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-05-24 20:21:47 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-05-24 20:21:47 +0300
commit513e6fa11de121d083da60ed3cb959dad2257b23 (patch)
tree0adb837eaec43376c0bfa20527efa32aae08ecef /webtorrent.min.js
parentc1aadb2e4d2831b96fa931d6be87b16e8751a668 (diff)
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r--webtorrent.min.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 957ea79..ad69f37 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1,7 +1,7 @@
-(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.WebTorrent=e()}})(function(){var e,t,r;return function n(e,t,r){function i(a,s){if(!t[a]){if(!e[a]){var f=typeof require=="function"&&require;if(!s&&f)return f(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[a]={exports:{}};e[a][0].call(c.exports,function(t){var r=e[a][1][t];return i(r?r:t)},c,c.exports,n,e,t,r)}return t[a].exports}var o=typeof require=="function"&&require;for(var a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,r){(function(r,n,i){t.exports=b;var o=e("create-torrent");var a=e("debug")("webtorrent");var s=e("bittorrent-dht/client");var f=e("events").EventEmitter;var u=e("xtend");var c=e("hat");var l=e("inherits");var h=e("load-ip-set");var d=e("run-parallel");var p=e("parse-torrent");var g=e("speedometer");var m=e("zero-fill");var v=e("./lib/fs-storage");var y=e("./lib/storage");var _=e("./lib/torrent");l(b,f);var w=e("./package.json").version.match(/([0-9]+)/g).slice(0,2).map(m(2)).join("");function b(e){var t=this;if(!(t instanceof b))return new b(e);if(!e)e={};f.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||n.WRTC;t.torrents=[];t.downloadSpeed=g();t.uploadSpeed=g();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof v==="function"?v:y;t.peerId=e.peerId===undefined?new i("-WW"+w+"-"+c(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(c(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(u({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}a("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof h==="function"){h(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=r;o()})}else r.nextTick(o);function o(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(b.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});b.prototype.get=function(e){var t=this;var r=p(e);if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,i=t.torrents.length;n<i;n++){var o=t.torrents[n];if(o.infoHash===r.infoHash)return o}return null};b.prototype.add=b.prototype.download=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");a("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.client=n;t.storage=t.storage||n.storage;var i=new _(e,t);n.torrents.push(i);function o(e){if(i.infoHash===e.infoHash){r(i);n.removeListener("torrent",o)}}if(r)n.on("torrent",o);i.on("error",function(e){n.emit("error",e,i);n.remove(i)});i.on("listening",function(e){n.emit("listening",e,i)});i.on("ready",function(){a("torrent");n.emit("torrent",i)});return i};b.prototype.seed=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");a("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.noVerify=true;o.parseInput(e,t,function(i,a){if(i)return n.emit("error",i);var s=a.map(function(e){return e.getStream});o(e,t,function(e,i){if(e)return n.emit("error",e);if(n.destroyed)return;n.add(i,t,function(e){var t=[function(t){e.storage.load(s,t)}];if(n.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return n.emit("error",t);if(r)r(e);n.emit("seed",e)})})})})};b.prototype.remove=function(e,t){var r=this;var n=r.get(e);if(!n)throw new Error("No torrent with id "+e);a("remove");r.torrents.splice(r.torrents.indexOf(n),1);n.destroy(t)};b.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};b.prototype.destroy=function(e){var t=this;t.destroyed=true;a("destroy");var r=t.torrents.map(function(e){return function(r){t.remove(e.infoHash,r)}});if(t.dht){r.push(function(e){t.dht.destroy(e)})}d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":44,"./lib/storage":5,"./lib/torrent":6,"./package.json":192,_process:52,"bittorrent-dht/client":44,buffer:45,"create-torrent":71,debug:108,events:49,hat:115,inherits:116,"load-ip-set":44,"parse-torrent":121,"run-parallel":136,speedometer:142,xtend:190,"zero-fill":191}],2:[function(e,t,r){t.exports=f;var n=e("debug")("webtorrent:file-stream");var i=e("inherits");var o=e("path");var a=e("stream");var s=e("./media-stream");i(f,a.Readable);function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);a.Readable.call(r,t);n("new filestream %s",JSON.stringify(t));if(!t)t={};if(!t.start)t.start=0;if(!t.end)t.end=e.length-1;r.destroyed=false;r.length=t.end-t.start+1;var i=t.start+e.offset;var s=t.pieceLength;r.startPiece=i/s|0;r.endPiece=(t.end+e.offset)/s|0;r._extname=o.extname(e.name);r._storage=e.storage;r._piece=r.startPiece;r._missing=r.length;r._reading=false;r._notifying=false;r._criticalLength=Math.min(1024*1024/s|0,2);r._offset=i-r.startPiece*s}f.prototype._read=function(){var e=this;n("_read");if(e._reading)return;e._reading=true;e.notify()};f.prototype.notify=function(){var e=this;n("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;n("before read %s",t);e._storage.read(e._piece++,function(r,i){n("after read %s (length %s) (err %s)",t,i.length,r&&r.message);e._notifying=false;if(e.destroyed)return;if(r){e._storage.emit("error",r);return e.destroy(r)}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;n("pushing buffer of length %s",i.length);e._reading=false;e.push(i);if(e._missing===0)e.push(null)})};f.prototype.pipe=function(e){var t=this;var r=a.Readable.prototype.pipe;if(e&&(e.nodeName==="VIDEO"||e.nodeName==="AUDIO")){var n={".webm":'video/webm; codecs="vorbis,vp8"',".mp4":'video/mp4; codecs="avc1.42c01e,mp4a.40.2"',".mp3":"audio/mpeg"}[t._extname];return r.call(t,new s(e,{type:n}))}else{return r.call(t,e)}};f.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._storage.emit("deselect",e.startPiece,e.endPiece,true)}},{"./media-stream":3,debug:108,inherits:116,path:51,stream:68}],3:[function(e,t,r){t.exports=f;var n=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(f,a.Writable);function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);a.Writable.call(r,t);if(!s)throw new Error("web browser lacks MediaSource support");r.media=e;t=t||{};t.type=t.type||'video/webm; codecs="vorbis,vp8"';n("new mediastream %s %s",e,JSON.stringify(t));r._mediaSource=new s;r._sourceBuffer=null;r._cb=null;r.media.src=window.URL.createObjectURL(r._mediaSource);var i=o(function(){r._sourceBuffer=r._mediaSource.addSourceBuffer(t.type);r._sourceBuffer.addEventListener("updateend",r._flow.bind(r));r._flow()});r._mediaSource.addEventListener("webkitsourceopen",i,false);r._mediaSource.addEventListener("sourceopen",i,false);r.on("finish",function(){n("finish");r._mediaSource.endOfStream()});window.vs=r}f.prototype._write=function(e,t,r){var i=this;if(!i._sourceBuffer){i._cb=function(n){if(n)return r(n);i._write(e,t,r)};return}if(i._sourceBuffer.updating){return r(new Error("Cannot append buffer while source buffer updating"))}i._sourceBuffer.appendBuffer(e);n("appendBuffer %s",e.length);i._cb=r};f.prototype._flow=function(){var e=this;n("flow");if(e._cb){e._cb(null)}}},{debug:108,inherits:116,once:120,stream:68}],4:[function(e,t,r){t.exports=n;function n(e,t){var r=this;r.swarm=e;r.numPieces=t;function n(e){e.on("have",function(e){r.pieces[e]++});e.on("bitfield",r.recalculate.bind(r));e.on("close",function(){for(var t=0;t<r.numPieces;++t){r.pieces[t]-=e.peerPieces.get(t)}})}r.swarm.wires.forEach(n);r.swarm.on("wire",function(e){r.recalculate();n(e)});r.recalculate()}n.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 r=0;r<e.numPieces;++r){e.pieces[r]+=t.peerPieces.get(r)}})};n.prototype.getRarestPiece=function(e){var t=this;var r=[];var n=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===n){r.push(i)}else if(o<n){r=[i];n=o}}if(r.length>0){return r[Math.random()*r.length|0]}else{return-1}}},{}],5:[function(e,t,r){(function(r,n){t.exports=k;var i=e("bitfield");var o=e("block-stream2");var a=e("debug")("webtorrent:storage");var s=e("dezalgo");var f=e("end-of-stream");var u=e("events").EventEmitter;var c=e("./file-stream");var l=e("inherits");var h=e("multistream");var d=e("once");var p=e("simple-sha1");var g=16*1024;var m=0;var v=1;var y=2;function _(){}l(w,u);function w(e,t,r,n){var i=this;u.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!n;if(typeof r==="number"){i.buffer=null;i.length=r}else{i.buffer=r;i.length=r.length}i._reset()}w.prototype.readBlock=function(e,t,r){var n=this;r=s(r);if(!n.buffer||!n._verifyOffset(e)){return r(new Error("invalid block offset "+e))}r(null,n.buffer.slice(e,e+t))};w.prototype.writeBlock=function(e,t,r){var n=this;r=s(r);if(!n._verifyOffset(e)||!n._verifyBlock(e,t)){return r(new Error("invalid block "+e+":"+t.length))}n._lazyAllocBuffer();var i=e/g;if(n.blocks[i]===y){return r(null)}t.copy(n.buffer,e);n.blocks[i]=y;n.blocksWritten+=1;if(n.blocksWritten===n.blocks.length){n.verify()}r(null)};w.prototype.reserveBlock=function(e){var t=this;var r=t.blocks.length;for(var n=0;n<r;n++){if(t.blocks[n]&&!e||t.blocks[n]===y){continue}t.blocks[n]=v;return{offset:n*g,length:n===r-1?t.length-n*g:g}}return null};w.prototype.cancelBlock=function(e){var t=this;if(!t._verifyOffset(e)){return false}var r=e/g;if(t.blocks[r]===v){t.blocks[r]=m}return true};w.prototype._reset=function(){var e=this;e.verified=false;e.blocks=new n(Math.ceil(e.length/g));e.blocks.fill(0);e.blocksWritten=0};w.prototype.verify=function(e){var t=this;e=e||t.buffer;if(t.verified||!e){return}if(t.noVerify){t.verified=true;r();return}p(e,function(e){t.verified=e===t.hash;r()});function r(){if(t.verified){t.emit("done")}else{t.emit("warning",new Error("piece "+t.index+" failed verification"));t._reset()}}};w.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}};w.prototype._verifyBlock=function(e,t){var r=this;if(t.length===g){return true}else if(t.length===r.length-e&&r.length-e<g){return true}else{r.emit("warning",new Error("invalid block size "+t.length));return false}};w.prototype._lazyAllocBuffer=function(){var e=this;if(!e.buffer){e.buffer=new n(e.length)}};l(b,u);function b(e,t,r,n){var i=this;u.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=r;i.pieceLength=n;i.done=false;i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})});i._checkDone()}b.prototype.select=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,r,false)}};b.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,r,false)}};b.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var r=new c(t,e);t.storage.emit("select",r.startPiece,r.endPiece,true,r.notify.bind(r));f(r,function(){t.storage.emit("deselect",r.startPiece,r.endPiece,true)});return r};b.prototype.getBlobURL=function(e,t){var r=this;if(typeof window==="undefined")throw new Error("browser-only method");r.getBuffer(function(r,n){if(r)return e(r);var i=t?new window.Blob([n],{type:t}):new window.Blob([n]);var o=window.URL.createObjectURL(i);e(null,o)})};b.prototype.getBuffer=function(e){var t=this;e=s(d(e));var r;if(t.storage.buffer){var i=function(){r=t.storage.buffer.slice(t.offset,t.offset+t.length);e(null,r)};if(t.done)i();else t.once("done",i)}else{r=new n(t.length);var o=0;t.createReadStream().on("data",function(e){e.copy(r,o);o+=e.length}).on("end",function(){e(null,r)}).on("error",e)}};b.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){r.nextTick(function(){e.emit("done")})}};l(k,u);function k(e,t){var r=this;u.call(r);if(!a.enabled)r.setMaxListeners(0);if(!t)t={};r.bitfield=new i(e.pieces.length);r.done=false;r.closed=false;r.readonly=true;if(!t.nobuffer){r.buffer=new n(e.length)}var o=r.pieceLength=e.pieceLength;var s=e.lastPieceLength;var f=e.pieces.length;r.pieces=e.pieces.map(function(e,n){var i=n*o;var a=i+(n===f-1?s:o);var u=r.buffer?r.buffer.slice(i,a):a-i;var c=new w(n,e,u,!!t.noVerify);c.on("done",r._onPieceDone.bind(r,c));return c});r.files=e.files.map(function(e){var t=e.offset;var n=t+e.length-1;var i=t/o|0;var a=n/o|0;var s=r.pieces.slice(i,a+1);var f=new b(r,e,s,o);f.on("done",r._onFileDone.bind(r,f));return f})}k.BLOCK_LENGTH=g;k.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];t=d(t||function(){});var n=0;var i=new h(e);var a=new o(r.pieceLength,{zeroPadding:false});i.on("error",f);r.once("done",u);i.pipe(a).on("data",s).on("error",f);function s(e){var t=n;n+=1;var i=0;var a=new o(g,{zeroPadding:false});a.on("data",s);a.on("end",f);function s(e){var n=i*g;i+=1;r.writeBlock(t,n,e)}function f(){u()}function u(){a.removeListener("data",s);a.removeListener("end",f)}a.end(e)}function f(e){c();t(e)}function u(){c();t(null)}function c(){i.removeListener("error",f);a.removeListener("data",s);a.removeListener("error",f);r.removeListener("done",u)}};Object.defineProperty(k.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*g)},0)}});Object.defineProperty(k.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var r=0,n=e.pieces.length;r<n;r++){t-=e.bitfield.get(r)}return t}});k.prototype.readBlock=function(e,t,r,n){var i=this;n=s(n);var o=i.pieces[e];if(!o)return n(new Error("invalid piece index "+e));o.readBlock(t,r,n)};k.prototype.writeBlock=function(e,t,r,n){var i=this;if(!n)n=_;n=s(n);if(i.readonly)return n(new Error("cannot write to readonly storage"));var o=i.pieces[e];if(!o)return n(new Error("invalid piece index "+e));o.writeBlock(t,r,n)};k.prototype.read=function(e,t,r,i){var o=this;if(typeof t==="function"){i=r;r=t;t=null}r=s(r);var a=o.pieces[e];if(!a){return r(new Error("invalid piece index "+e))}if(!a.verified&&!i){return r(new Error("Storage.read called on incomplete piece "+e))}var f=0;var u=a.length;if(t){f=t.offset||0;u=t.length||u}if(a.buffer){return r(null,a.buffer.slice(f,f+u))}var c=[];function l(){if(u<=0)return r(null,n.concat(c));var t=f;var i=Math.min(g,u);f+=i;u-=i;o.readBlock(e,t,i,function(e,t){if(e)return r(e);c.push(t);l()})}l()};k.prototype.reserveBlock=function(e,t){var r=this;var n=r.pieces[e];if(!n)return null;return n.reserveBlock(t)};k.prototype.cancelBlock=function(e,t){var r=this;var n=r.pieces[e];if(!n)return false;return n.cancelBlock(t)};k.prototype.remove=function(e){if(e)s(e)(null)};k.prototype.close=function(e){var t=this;t.closed=true;if(e)s(e)(null)};k.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)};k.prototype._onFileDone=function(e){var t=this;a("file done "+e.name);t.emit("file",e);t._checkDone()};k.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":2,_process:52,bitfield:8,"block-stream2":32,buffer:45,debug:108,dezalgo:111,"end-of-stream":114,events:49,inherits:116,multistream:117,once:120,"simple-sha1":140}],6:[function(e,t,r){(function(r,n){t.exports=B;var i=e("addr-to-ip-port");var o=e("create-torrent");var a=e("debug")("webtorrent:torrent");var s=e("torrent-discovery");var f=e("events").EventEmitter;var u=e("fs");var c=e("simple-get");var l=e("inherits");var h=e("run-parallel");var d=e("parse-torrent");var p=e("re-emitter");var g=e("bittorrent-swarm");var m=e("uniq");var v=e("ut_metadata");var y=e("ut_pex");var _=e("./rarity-map");var w=e("./server");var b=e("./storage");var k=128*1024;var E=3e4;var x=5e3;var S=3*b.BLOCK_LENGTH;var A=.5;var I=1;var T=1e4;var C=2;function L(){}l(B,f);function B(e,t){var i=this;f.call(i);if(!a.enabled)i.setMaxListeners(0);a("new torrent");i.opts=t;i.client=t.client;i.hotswapEnabled="hotswap"in t?t.hotswap:true;i.verify=t.verify;i.chokeTimeout=t.chokeTimeout||x;i.pieceTimeout=t.pieceTimeout||E;i.strategy=t.strategy||"sequential";i._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;i._rechokeOptimisticWire=null;i._rechokeOptimisticTime=0;i._rechokeIntervalId=null;i.ready=false;i.destroyed=false;i.files=[];i.metadata=null;i.parsedTorrent=null;i.storage=null;i.numBlockedPeers=0;i._amInterested=false;i._selections=[];i._critical=[];i._storageImpl=t.storage||b;this._torrentFileURL=null;var s;try{s=e&&e.parsedTorrent||d(e)}catch(l){}if(s&&s.infoHash){h(s)}else if(typeof c==="function"&&/^https?:/.test(e)){c.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,t){if(e){e=new Error("Error downloading torrent: "+e.message);return i._onError(e)}h(t)})}else if(typeof u.readFile==="function"){u.readFile(e,function(e,t){if(e)return i._onError(new Error("Invalid torrent identifier"));h(t)})}else throw new Error("Invalid torrent identifier");function h(e){try{i.parsedTorrent=d(e)}catch(a){return i._onError(new Error("Malformed torrent data: "+a.message))}i.infoHash=i.parsedTorrent.infoHash;if(!i.infoHash){return i._onError(new Error("Malformed torrent data: Missing info hash."))}if(i.parsedTorrent.name)i.name=i.parsedTorrent.name;if(t.announce){i.parsedTorrent.announce.push.apply(i.parsedTorrent.announce,t.announce)}if(i.parsedTorrent.announce.length===0){i.parsedTorrent.announce=o.announceList.map(function(e){return e[0]})}if(n.WEBTORRENT_ANNOUNCE){n.WEBTORRENT_ANNOUNCE.forEach(function(e){i.parsedTorrent.announce.push(e)})}m(i.parsedTorrent.announce);i.swarm=new g(i.infoHash,i.client.peerId,{handshake:{dht:!!i.client.dht}});i.swarm.on("error",i._onError.bind(i));p(i.swarm,i,["warning"]);i.swarm.on("wire",i._onWire.bind(i));i.swarm.on("download",i.client.downloadSpeed.bind(i.client));i.swarm.on("upload",i.client.uploadSpeed.bind(i.client));i.swarm.listen(i.client.torrentPort,i._onSwarmListening.bind(i));r.nextTick(function(){i.emit("infoHash")})}}Object.defineProperty(B.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}});Object.defineProperty(B.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(B.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}});Object.defineProperty(B.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}});Object.defineProperty(B.prototype,"uploaded",{get:function(){return this.swarm.uploaded}});Object.defineProperty(B.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}});Object.defineProperty(B.prototype,"magnetURI",{get:function(){return d.toMagnetURI(this.parsedTorrent)}});Object.defineProperty(B.prototype,"torrentFile",{get:function(){return d.toTorrentFile(this.parsedTorrent)}});Object.defineProperty(B.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}});B.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)};B.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;a("got metadata");if(e&&e.infoHash){t.metadata=d.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;try{t.parsedTorrent=d(t.metadata)}catch(n){return t._onError(n)}}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new _(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){r.nextTick(function(){a("verifying existing torrent data");var e=0;var r=0;h(t.storage.pieces.map(function(n){return function(i){t.storage.read(n.index,function(o,s){e+=1;t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*r/t.storage.pieces.length});if(!o&&s){n.verify(s);r+=n.verified;a("piece "+(n.verified?"verified":"invalid")+" "+n.index)}i()},true)}}),t._onStorage.bind(t))})}else{r.nextTick(t._onStorage.bind(t))}r.nextTick(function(){t.emit("metadata")})};B.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 r=[];if(t.swarm)r.push(function(e){t.swarm.destroy(e)});if(t.discovery)r.push(function(e){t.discovery.stop(e)});if(t.storage)r.push(function(e){t.storage.close(e)});h(r,e)};B.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}};B.prototype.select=function(e,t,r,n){var i=this;if(e>t||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;a("select %s-%s (priority %s)",e,t,r);i._selections.push({from:e,to:t,offset:0,priority:r,notify:n||L});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};B.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;a("deselect %s-%s (priority %s)",e,t,r);for(var i=0;i<n._selections.length;++i){var o=n._selections[i];if(o.from===e&&o.to===t&&o.priority===r){n._selections.splice(i--,1);break}}n._updateSelections()};B.prototype.critical=function(e,t){var r=this;a("critical %s-%s",e,t);for(var n=e;n<=t;++n){r._critical[n]=true}r._updateSelections()};B.prototype._onWire=function(e,t){var r=this;a("got wire (%s)",t||"Unknown");if(t){var n=i(t);e.remoteAddress=n[0];e.remotePort=n[1]}e.use(v(r.metadata));if(!r.metadata){e.ut_metadata.on("metadata",function(e){a("got metadata via ut_metadata");r._onMetadata(e)});e.ut_metadata.fetch()}if(typeof y==="function"){e.use(y());e.ut_pex.on("peer",function(e){a("ut_pex: got peer: %s (from %s)",e,t);r.addPeer(e)});e.ut_pex.on("dropped",function(e){a("ut_pex: dropped peer: %s (from %s)",e,t);var n=r.swarm._peers[e];if(!n||!n.conn)r.swarm.removePeer(e)})}e.setKeepAlive(true);if(e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening){e.port(r.client.dht.address().port)}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);if(r.client.dht)r.client.dht.addNode(e.remoteAddress+":"+t)});e.on("timeout",function(){a("wire timeout (%s)",t);e.destroy()});e.setTimeout(r.pieceTimeout,true);if(r.metadata){r._onWireWithMetadata(e)}};B.prototype._onWireWithMetadata=function(e){var t=this;var r=null;var n=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{r=setTimeout(i,n);if(r.unref)r.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(r)});e.on("choke",function(){clearTimeout(r);r=setTimeout(i,n);if(r.unref)r.unref()});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,n,i,o){if(i>k){a("got invalid block size request %s (from %s)",i,e.remoteAddress+":"+e.remotePort);return e.destroy()}t.storage.readBlock(r,n,i,o)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(i,n);if(r.unref)r.unref();e.isSeeder=false;s()};B.prototype._onStorage=function(){var e=this;if(e.destroyed)return;a("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),T);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};B.prototype._onStoragePiece=function(e){var t=this;a("piece done %s",e.index);t._reservations[e.index]=null;t.swarm.wires.forEach(function(t){t.have(e.index)});t._gcSelections()};B.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));r.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};B.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var r=e._selections[t];var n=r.offset;while(e.storage.bitfield.get(r.from+r.offset)&&r.from+r.offset<r.to){r.offset++}if(n!==r.offset)r.notify();if(r.to!==r.from+r.offset)continue;if(!e.storage.bitfield.get(r.from+r.offset))continue;e._selections.splice(t--,1);r.notify();e._updateInterest()}if(!e._selections.length)e.emit("idle")};B.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")};B.prototype._update=function(){var e=this;if(e.destroyed)return;P(e.swarm.wires,e._updateWire.bind(e))};B.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return o();var r=R(e,A);if(e.requests.length>=r)return;var n=R(e,I);f(false)||f(true);function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var n=t._selections[r];var o;if(t.strategy==="rarest"){var a=n.from+n.offset;var s=n.to;var f=s-a+1;var u={};var c=0;var l=i(a,s,u);while(c<f){o=t.rarityMap.getRarestPiece(l);if(o<0)break;if(t._request(e,o,false))return;u[o]=true;c+=1}}else{for(o=n.to;o>=n.from+n.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function a(){var r=e.downloadSpeed()||1;if(r>S)return function(){return true};var n=Math.max(1,e.requests.length)*b.BLOCK_LENGTH/r;var i=10;var o=0;return function(e){if(!i||t.storage.bitfield.get(e))return true;var a=t.storage.pieces[e];var s=a.blocks.length-a.blocksWritten;for(;o<t.swarm.wires.length;o++){var f=t.swarm.wires[o];var u=f.downloadSpeed();if(u<S)continue;if(u<=r)continue;if(!f.peerPieces.get(e))continue;if((s-=u*n)>0)continue;i--;return false}return true}}function s(e){var r=e;for(var n=e;n<t._selections.length&&t._selections[n].priority;n++){r=n}var i=t._selections[e];t._selections[e]=t._selections[r];t._selections[r]=i}function f(r){if(e.requests.length>=n)return true;var o=a();for(var f=0;f<t._selections.length;f++){var u=t._selections[f];var c;if(t.strategy==="rarest"){var l=u.from+u.offset;var h=u.to;var d=h-l+1;var p={};var g=0;var m=i(l,h,p,o);while(g<d){c=t.rarityMap.getRarestPiece(m);if(c<0)break;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n){p[c]=true;g++;continue}if(u.priority)s(f);return true}}else{for(c=u.from+u.offset;c<=u.to;c++){if(!e.peerPieces.get(c)||!o(c))continue;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n)continue;if(u.priority)s(f);return true}}}return false}};B.prototype._rechoke=function(){var e=this;if(e._rechokeOptimisticTime>0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(r){if(!r.isSeeder&&r!==e._rechokeOptimisticWire){t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(a);var r=0;var n=0;for(;n<t.length&&r<e._rechokeNumSlots;++n){t[n].isChoked=false;if(t[n].wire.peerInterested)r+=1}if(!e._rechokeOptimisticWire&&n<t.length&&e._rechokeNumSlots){var i=t.slice(n).filter(function(e){return e.wire.peerInterested});var o=i[M(i.length)];if(o){o.isChoked=false;e._rechokeOptimisticWire=o.wire;e._rechokeOptimisticTime=C}}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}};B.prototype._hotswap=function(e,t){var r=this;if(!r.hotswapEnabled)return false;var n=e.downloadSpeed();if(n<b.BLOCK_LENGTH)return false;if(!r._reservations[t])return false;var i=r._reservations[t];if(!i){return false}var o=Infinity;var a;var s;for(s=0;s<i.length;s++){var f=i[s];if(!f||f===e)continue;var u=f.downloadSpeed();if(u>=S)continue;if(2*u>n||u>o)continue;a=f;o=u}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 c=a.requests[s];if(c.piece!==t)continue;r.storage.cancelBlock(t,c.offset)}r.emit("hotswap",a,e,t);return true};B.prototype._request=function(e,t,n){var i=this;var o=e.requests.length;if(i.storage.bitfield.get(t))return false;var s=R(e,I);if(o>=s)return false;var f=e.requests.length===0&&i.storage.numMissing<30;var u=i.storage.reserveBlock(t,f);if(!u&&!f&&n&&i._hotswap(e,t)){u=i.storage.reserveBlock(t,false)}if(!u)return false;var c=i._reservations[t];if(!c){c=i._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,o){if(!i.ready){i.once("ready",function(){h(n,o)});return}if(c[l]===e)c[l]=null;if(n){a("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort,n.message);
-i.storage.cancelBlock(t,u.offset);r.nextTick(i._update.bind(i));return false}else{a("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort);i.storage.writeBlock(t,u.offset,o,function(e){if(e){a("error writing block");i.storage.cancelBlock(t,u.offset)}r.nextTick(i._update.bind(i))})}}e.request(t,u.offset,u.length,h);return true};B.prototype.createServer=function(e){var t=this;if(typeof w==="function"){return new w(t,e)}};B.prototype._onError=function(e){var t=this;a("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function R(e,t){return Math.ceil(2+t*e.downloadSpeed()/b.BLOCK_LENGTH)}function M(e){return Math.random()*e|0}function P(e,t){var r=e.map(function(e,t){return t});for(var n=r.length-1;n>0;--n){var i=M(n+1);var o=r[n];r[n]=r[i];r[i]=o}r.forEach(function(r){t(e[r],r,e)})}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./rarity-map":4,"./server":44,"./storage":5,_process:52,"addr-to-ip-port":7,"bittorrent-swarm":9,"create-torrent":71,debug:108,events:49,fs:43,inherits:116,"parse-torrent":121,"re-emitter":135,"run-parallel":136,"simple-get":44,"torrent-discovery":143,uniq:180,ut_metadata:181,ut_pex:44}],7:[function(e,t,r){var n=/^\[?([^\]]+)\]?:(\d+)$/;var i={};var o=0;t.exports=function a(e){if(o===1e5)i={};if(!i[e]){var t=n.exec(e);if(!t)throw new Error("invalid addr: "+e);i[e]=[t[1],Number(t[2])];o+=1}return i[e]};t.exports.reset=function s(){i={}}},{}],8:[function(e,t,r){(function(e){var r=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var r=0;r<e;r++)t[r]=0};function n(e,t){if(!(this instanceof n)){return new n(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 r(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}n.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};n.prototype.set=function(e,t){var r=e>>3;if(t||arguments.length===1){if(this.buffer.length<r+1)this._grow(Math.max(r+1,Math.min(2*this.buffer.length,this.grow)));this.buffer[r]|=128>>e%8}else if(r<this.buffer.length){this.buffer[r]&=~(128>>e%8)}};n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new r(e);if(t.fill)t.fill(0);if(this.buffer.copy)this.buffer.copy(t,0);else{for(var n=0;n<this.buffer.length;n++){t[n]=this.buffer[n]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=n}).call(this,e("buffer").Buffer)},{buffer:45}],9:[function(e,t,r){(function(r,n){t.exports=g;var i=e("addr-to-ip-port");var o=e("debug")("bittorrent-swarm");var a=e("dezalgo");var s=e("events").EventEmitter;var f=e("inherits");var u=e("net");var c=e("./lib/peer");var l=e("speedometer");var h=e("./lib/tcp-pool");var d=55;var p=[1e3,5e3,15e3];f(g,s);function g(e,t,r){var i=this;if(!(i instanceof g))return new g(e,t,r);s.call(i);i.infoHash=typeof e==="string"?new n(e,"hex"):e;i.infoHashHex=i.infoHash.toString("hex");i.peerId=typeof t==="string"?new n(t,"hex"):t;i.peerIdHex=i.peerId.toString("hex");if(!r)r={};o("new swarm (i %s p %s)",i.infoHashHex,i.peerIdHex);i.handshakeOpts=r.handshake;i.maxConns=r.maxConns!==undefined?r.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=l();i.uploadSpeed=l()}Object.defineProperty(g.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(g.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(g.prototype,"numConns",{get:function(){var e=this;var t=0;for(var r in e._peers){var n=e._peers[r];if(n&&n.conn)t+=1}return t}});Object.defineProperty(g.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});g.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 r=e&&e.id||e;if(t._peers[r])return;o("addPeer %s",r);var n;if(typeof e==="string"){n=c.createOutgoingTCPPeer(e,t);t._queue.push(n);t._drain()}else{n=c.createWebRTCPeer(e,t)}t._peers[n.id]=n;t._peersLength+=1};g.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};g.prototype.removePeer=function(e){var t=this;var r=t._peers[e];if(!r)return;o("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;r.destroy()};g.prototype.pause=function(){var e=this;if(e.destroyed)return;o("pause");e.paused=true};g.prototype.resume=function(){var e=this;if(e.destroyed)return;o("resume");e.paused=false;e._drain()};g.prototype.listen=function(e,t,n){var i=this;if(typeof t==="function"){n=t;t=undefined}if(n)n=a(n);if(i.listening)throw new Error("swarm already listening");if(r.browser){n()}else{i._port=e||h.getDefaultListenPort(i.infoHashHex);i._hostname=t;if(n)i.once("listening",n);o("listen %s",e);var s=h.addSwarm(i);i.server=s.server}};g.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};g.prototype.address=function(){var e=this;return e.server.address()};g.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 r in t._peers){t.removePeer(r)}h.removeSwarm(t,function(){t.emit("close")})};g.prototype._drain=function(){var e=this;o("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof u.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 r=i(t.addr);var n=r[0];var a=r[1];var s=t.conn=u.connect({host:n,port:a,localAddress:e._hostname});s.once("connect",function(){t.onConnect()});s.once("error",function(e){t.destroy(e)});t.setConnectTimeout();s.on("close",function(){if(e.destroyed)return;if(t.retries>=p.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,p.length);return}function r(){var r=c.createOutgoingTCPPeer(t.addr,e);r.retries=t.retries+1;e._queue.push(r);e._drain()}var n=p[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var i=setTimeout(r,n);if(i.unref)i.unref()})};g.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};g.prototype._validAddr=function(e){var t=this;var r=i(e);var n=r[0];var o=r[1];return o>0&&o<65535&&!(n==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":10,"./lib/tcp-pool":11,_process:52,"addr-to-ip-port":44,buffer:45,debug:24,dezalgo:27,events:49,inherits:30,net:44,speedometer:31}],10:[function(e,t,r){var n=e("debug")("bittorrent-swarm:peer");var i=e("bittorrent-protocol");var o=25e3;var a=25e3;r.createWebRTCPeer=function(e,t){var r=new s(e.id);r.conn=e;r.swarm=t;if(r.conn.connected){r.onConnect()}else{r.conn.once("connect",function(){r.onConnect()});r.conn.once("error",function(e){r.destroy(e)});r.setConnectTimeout()}return r};r.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var r=new s(t);r.conn=e;r.addr=t;r.onConnect();return r};r.createOutgoingTCPPeer=function(e,t){var r=new s(e);r.swarm=t;r.addr=e;return r};function s(e){var t=this;t.id=e;n("new Peer %s",e);t.addr=null;t.conn=null;t.swarm=null;t.wire=null;t.destroyed=false;t.timeout=null;t.retries=0;t.sentHandshake=false}s.prototype.onConnect=function(){var e=this;n("Peer %s connected",e.id);clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()});t.once("close",function(){e.destroy()});t.once("finish",function(){e.destroy()});t.once("error",function(t){e.destroy(t)});var r=e.wire=new i;r.once("end",function(){e.destroy()});r.once("finish",function(){e.destroy()});r.once("error",function(t){e.destroy(t)});r.once("handshake",function(t,r){e.onHandshake(t,r)});e.setHandshakeTimeout();t.pipe(r).pipe(t);if(e.swarm)e.handshake()};s.prototype.onHandshake=function(e,t){var r=this;if(!r.swarm)return;var i=e.toString("hex");var o=t.toString("hex");if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(i!==r.swarm.infoHashHex){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(o===r.swarm.peerIdHex){return r.destroy(new Error("refusing to handshake with self"))}n("Peer %s got handshake %s",r.id,i);clearTimeout(r.handshakeTimeout);r.retries=0;r.wire.on("download",function(e){r.swarm.downloaded+=e;r.swarm.downloadSpeed(e);r.swarm.emit("download",e)});r.wire.on("upload",function(e){r.swarm.uploaded+=e;r.swarm.uploadSpeed(e);r.swarm.emit("upload",e)});if(!r.sentHandshake)r.handshake();r.swarm.wires.push(r.wire);var a=r.addr;if(!a&&r.conn.remoteAddress){a=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,a)};s.prototype.handshake=function(){var e=this;e.wire.handshake(e.swarm.infoHash,e.swarm.peerId,e.swarm.handshakeOpts);e.sentHandshake=true};s.prototype.setConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout);e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},o);if(e.connectTimeout.unref)e.connectTimeout.unref()};s.prototype.setHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout);e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},a);if(e.handshakeTimeout.unref)e.handshakeTimeout.unref()};s.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;n("destroy Peer %s (error: %s)",t.id,e&&(e.message||e));t.swarm.wires.splice(t.swarm.wires.indexOf(t.wire),1);if(t.conn)t.conn.destroy();if(t.wire)t.wire.destroy();if(t.swarm){t.swarm.removePeer(t.id);t.swarm._drain()}clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);t.conn=null;t.swarm=null;t.wire=null}},{"bittorrent-protocol":12,debug:24}],11:[function(e,t,r){(function(r){t.exports=f;var n=e("debug")("bittorrent-swarm:tcp-pool");var i=e("dezalgo");var o=e("net");var a=e("./peer");var s={};function f(e,t){var r=this;r.port=e;r.listening=false;r.swarms={};n("new TCPPool (port: %s, hostname: %s)",e,t);r.pendingConns=[];r.server=o.createServer();r.server.on("connection",function(e){r._onConnection(e)});r.server.on("error",function(e){r._onError(e)});r.server.on("listening",function(){r._onListening()});r.server.listen(r.port,t)}f.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new f(e._port,e._hostname);t.addSwarm(e);return t};f.removeSwarm=function(e,t){var n=s[e._port];if(!n)return t();n.removeSwarm(e);var i=0;for(var o in n.swarms){var a=n.swarms[o];if(a)i+=1}if(i===0)n.destroy(t);else r.nextTick(t)};f.getDefaultListenPort=function(e){for(var t in s){var r=s[t];if(r&&!r.swarms[e])return r.port}return 0};f.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}n("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};f.prototype.removeSwarm=function(e){var t=this;n("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};f.prototype.destroy=function(e){var t=this;if(e)e=i(e);n("destroy tcp pool %s",t.port);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});s[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};f.prototype._onListening=function(){var e=this;var t=e.server.address().port;n("tcp pool listening on %s",t);if(t!==e.port){s[e.port]=null;e.port=t;s[e.port]=e}e.listening=true;for(var r in e.swarms){var i=e.swarms[r];if(i)i._onListening(e.port)}};f.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var n=a.createIncomingTCPPeer(e);n.wire.once("handshake",function(i,o){var a=i.toString("hex");r();e.removeListener("close",r);var s=t.swarms[a];if(s){n.swarm=s;s._addIncomingPeer(n);n.onHandshake(i,o)}else{var f=new Error("Unexpected info hash "+a+" from incoming peer "+n.id+": destroying peer");n.destroy(f)}})};f.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var n=t.swarms[r];if(n){t.removeSwarm(n);n._onError(e)}}}}).call(this,e("_process"))},{"./peer":10,_process:52,debug:24,dezalgo:27,net:44}],12:[function(e,t,r){(function(r){t.exports=w;var n=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var a=e("xtend");var s=e("inherits");var f=e("speedometer");var u=e("stream");var c=4e5;var l=new r("BitTorrent protocol");var h=new r([0,0,0,0]);var d=new r([0,0,0,1,0]);var p=new r([0,0,0,1,1]);var g=new r([0,0,0,1,2]);var m=new r([0,0,0,1,3]);var v=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function _(e,t,r,n){this.piece=e;this.offset=t;this.length=r;this.callback=n}s(w,u.Duplex);function w(){if(!(this instanceof w))return new w;u.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=f();this.downloadSpeed=f();this._keepAlive=null;this._timeout=null;this._timeoutMs=0;this.destroyed=false;this._finished=false;this._buffer=[];this._bufferSize=0;this._parser=null;this._parserSize=0;this.on("finish",this._onfinish);this._parseHandshake()}w.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,h),6e4)};w.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};w.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;o("destroy");this.end()};w.prototype.end=function(){this._onUninterested();this._onChoke();u.Duplex.prototype.end.apply(this,arguments)};w.prototype.use=function(e){var t=e.prototype.name;if(!t){throw new Error("Extension API requires a named function, e.g. function name() {}")}var r=this._nextExt;var n=new e(this);function i(){}if(typeof n.onHandshake!=="function"){n.onHandshake=i}if(typeof n.onExtendedHandshake!=="function"){n.onExtendedHandshake=i}if(typeof n.onMessage!=="function"){n.onMessage=i}this.extendedMapping[r]=t;this._ext[t]=n;this[t]=n;this._nextExt+=1};w.prototype.handshake=function(e,t,n){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new r(v);i[5]|=16;if(n&&n.dht)i[7]|=1;this._push(r.concat([l,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=a(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};w.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(p)};w.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(g)};w.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(m)};w.prototype.have=function(e){this._message(4,[e],null)};w.prototype.bitfield=function(e){if(!r.isBuffer(e))e=e.buffer;this._message(5,[],e)};w.prototype.request=function(e,t,r,n){if(!n)n=function(){};if(this._finished)return n(new Error("wire is closed"));if(this.peerChoking)return n(new Error("peer is choking"));this.requests.push(new _(e,t,r,n));this._updateTimeout();this._message(6,[e,t,r],null)};w.prototype.piece=function(e,t,r){this.uploaded+=r.length;this.uploadSpeed(r.length);this.emit("upload",r.length);this._message(7,[e,t],r)};w.prototype.cancel=function(e,t,r){this._callback(b(this.requests,e,t,r),new Error("request was cancelled"),null);this._message(8,[e,t,r],null)};w.prototype.port=function(e){var t=new r(y);t.writeUInt16BE(e,5);this._push(t)};w.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var n=new r([e]);var o=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,o]))}else{throw new Error("Unrecognized extension: "+e)}};w.prototype._onKeepAlive=function(){this.emit("keep-alive")};w.prototype._onHandshake=function(e,t,r){this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var n;for(n in this._ext){this._ext[n].onHandshake(e,t,r)}if(r.extended&&this._handshakeSent){this._sendExtendedHandshake()}};w.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};w.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};w.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};w.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};w.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};w.prototype._onBitField=function(e){this.peerPieces=new n(e);this.emit("bitfield",this.peerPieces)};w.prototype._onRequest=function(e,t,r){if(this.amChoking)return;var n=function(n,o){if(i!==b(this.peerRequests,e,t,r))return;if(n)return;this.piece(e,t,o)}.bind(this);var i=new _(e,t,r,n);this.peerRequests.push(i);this.emit("request",e,t,r,n)};w.prototype._onPiece=function(e,t,r){this._callback(b(this.requests,e,t,r.length),null,r);this.downloaded+=r.length;this.downloadSpeed(r.length);this.emit("download",r.length);this.emit("piece",e,t,r)};w.prototype._onCancel=function(e,t,r){b(this.peerRequests,e,t,r);this.emit("cancel",e,t,r)};w.prototype._onPort=function(e){this.emit("port",e)};w.prototype._onExtended=function(e,t){var r,n;if(e===0&&(r=k(t))){this.peerExtendedHandshake=r;if(typeof r.m==="object"){for(n in r.m){this.peerExtendedMapping[n]=Number(r.m[n].toString())}}for(n in this._ext){if(this.peerExtendedMapping[n]){this._ext[n].onExtendedHandshake(this.peerExtendedHandshake)}}this.emit("extended","handshake",this.peerExtendedHandshake)}else{if(this.extendedMapping[e]){e=this.extendedMapping[e];if(this._ext[e]){this._ext[e].onMessage(t)}}this.emit("extended",e,t)}};w.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};w.prototype._push=function(e){if(this._finished)return;return this.push(e)};w.prototype._write=function(e,t,n){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}n(null)};w.prototype._read=function(){};w.prototype._callback=function(e,t,r){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,r)};w.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};w.prototype._updateTimeout=function(){if(!this._timeoutMs||!this.requests.length||this._timeout)return;this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs);if(this._timeoutUnref&&this._timeout.unref)this._timeout.unref()};w.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};w.prototype._message=function(e,t,n){var i=n?n.length:0;var o=new r(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var a=0;a<t.length;a++){o.writeUInt32BE(t[a],5+4*a)}this._push(o);if(n)this._push(n)};w.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)}};w.prototype._onmessage=function(e){this._parse(4,this._onmessagelength);switch(e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this.emit("unknownmessage",e)}};w.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var r=e.slice(0,t);if(r.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",r.toString());this.end();return}e=e.slice(t);this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(e[7]&1),extended:!!(e[5]&16)});this._parse(4,this._onmessagelength)}.bind(this))}.bind(this))};w.prototype._onfinish=function(){this._finished=true;this.push(null);while(this.read()){}clearInterval(this._keepAlive);this._parse(Number.MAX_VALUE,function(){});this.peerRequests=[];while(this.requests.length){this._callback(this.requests.shift(),new Error("wire was closed"),null)}};function b(e,t,r,n){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece!==t||o.offset!==r||o.length!==n)continue;if(i===0)e.shift();else e.splice(i,1);return o}return null}function k(e){try{return i.decode(e)}catch(t){console.warn(t)}}}).call(this,e("buffer").Buffer)},{bencode:13,bitfield:17,buffer:45,debug:18,inherits:21,speedometer:22,stream:68,xtend:23}],13:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":14,"./lib/encode":16}],14:[function(e,t,r){(function(r){var n=e("./dict");function i(e,t){i.position=0;i.encoding=t||null;i.data=!r.isBuffer(e)?new r(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 r=i.data.length;var n=i.data;while(t<r){if(n[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 n;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 r=++e+t;i.position=r;return i.encoding?i.data.toString(i.encoding,e,r):i.data.slice(e,r)};t.exports=i}).call(this,e("buffer").Buffer)},{"./dict":15,buffer:45}],15:[function(e,t,r){var n=t.exports=function i(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};n.prototype.binaryKeys=function o(){return this._keys.slice()};n.prototype.binarySet=function a(e,t){this._keys.push(e);this[e]=t}},{}],16:[function(e,t,r){(function(e){function r(t){var n=[];r._encode(n,t);return e.concat(n)}r._floatConversionDetected=false;r._encode=function(t,n){if(e.isBuffer(n)){t.push(new e(n.length+":"));t.push(n);return}switch(typeof n){case"string":r.bytes(t,n);break;case"number":r.number(t,n);break;case"object":n.constructor===Array?r.list(t,n):r.dict(t,n);break}};var n=new e("e"),i=new e("d"),o=new e("l");r.bytes=function(t,r){t.push(new e(e.byteLength(r)+":"+r))};r.number=function(t,n){var i=2147483648;var o=n/i<<0;var a=n%i<<0;var s=o*i+a;t.push(new e("i"+s+"e"));if(s!==n&&!r._floatConversionDetected){r._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+n+'":','Bencoding only defines support for integers, value was converted to "'+s+'"');console.trace()}};r.dict=function(e,t){e.push(i);var o=0;var a;var s=Object.keys(t).sort();var f=s.length;for(;o<f;o++){a=s[o];r.bytes(e,a);r._encode(e,t[a])}e.push(n)};r.list=function(e,t){var i=0,a=1;var s=t.length;e.push(o);for(;i<s;i++){r._encode(e,t[i])}e.push(n)};t.exports=r}).call(this,e("buffer").Buffer)},{buffer:45}],17:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{buffer:45,dup:8}],18:[function(e,t,r){r=t.exports=e("./debug");r.log=a;r.formatArgs=o;r.save=s;r.load=f;r.useColors=i;var n;if(typeof chrome!=="undefined"&&typeof chrome.storage!=="undefined")n=chrome.storage.local;else n=u();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function i(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function o(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function a(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{if(null==e){n.removeItem("debug")}else{n.debug=e}}catch(t){}}function f(){var e;try{e=n.debug}catch(t){}return e}r.enable(f());function u(){try{return window.localStorage}catch(e){}}},{"./debug":19}],19:[function(e,t,r){r=t.exports=a;r.coerce=c;r.disable=f;r.enable=s;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var n=0;var i;function o(){return r.colors[n++%r.colors.length]}function a(e){function t(){}t.enabled=false;function n(){var e=n;var t=+new Date;var a=t-(i||t);e.diff=a;e.prev=i;e.curr=t;i=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=o();var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]);if("string"!==typeof s[0]){s=["%o"].concat(s)}var f=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,n){if(t==="%%")return t;f++;var i=r.formatters[n];if("function"===typeof i){var o=s[f];t=i.call(e,o);s.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){s=r.formatArgs.apply(e,s)}var u=n.log||r.log||console.log.bind(console);u.apply(e,s)}n.enabled=true;var a=r.enabled(e)?n:t;a.namespace=e;return a}function s(e){r.save(e);var t=(e||"").split(/[\s,]+/);var n=t.length;for(var i=0;i<n;i++){if(!t[i])continue;e=t[i].replace(/\*/g,".*?");if(e[0]==="-"){r.skips.push(new RegExp("^"+e.substr(1)+"$"))}else{r.names.push(new RegExp("^"+e+"$"))}}}function f(){r.enable("")}function u(e){var t,n;for(t=0,n=r.skips.length;t<n;t++){if(r.skips[t].test(e)){return false}}for(t=0,n=r.names.length;t<n;t++){if(r.names[t].test(e)){return true}}return false}function c(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:20}],20:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var a=o*24;var s=a*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*s;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+r;return Math.ceil(e/t)+" "+r+"s"}},{}],21:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function n(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 r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],22:[function(e,t,r){var n=1;var i=65535;var o=4;var a=function(){n=n+1&i};var s=setInterval(a,1e3/o|0);if(s.unref)s.unref();t.exports=function(e){var t=o*(e||5);var r=[0];var a=1;var s=n-1&i;return function(e){var f=n-s&i;if(f>t)f=t;s=n;while(f--){if(a===t)a=0;r[a]=r[a===0?t-1:a-1];a++}if(e)r[a-1]+=e;var u=r[a-1];var c=r.length<t?0:r[a===t?0:a];return r.length<o?u:(u-c)*o/r.length}}},{}],23:[function(e,t,r){t.exports=n;function n(){var e={};for(var t=0;t<arguments.length;t++){var r=arguments[t];for(var n in r){if(r.hasOwnProperty(n)){e[n]=r[n]}}}return e}},{}],24:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{"./debug":25,dup:18}],25:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:26}],26:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],27:[function(e,t,r){var n=e("wrappy");t.exports=n(o);var i=e("asap");function o(e){var t=true;i(function(){t=false});return function r(){var r=arguments;var n=this;if(t)i(function(){e.apply(n,r)});else e.apply(n,r)}}},{asap:28,wrappy:29}],28:[function(e,t,r){(function(e){var r={task:void 0,next:null};var n=r;var i=false;var o=void 0;var a=false;function s(){while(r.next){r=r.next;var e=r.task;r.task=void 0;var t=r.domain;if(t){r.domain=void 0;t.enter()}try{e()}catch(n){if(a){if(t){t.exit()}setTimeout(s,0);if(t){t.enter()}throw n}else{setTimeout(function(){throw n},0)}}if(t){t.exit()}}i=false}if(typeof e!=="undefined"&&e.nextTick){a=true;o=function(){e.nextTick(s)}}else if(typeof setImmediate==="function"){if(typeof window!=="undefined"){o=setImmediate.bind(window,s)}else{o=function(){setImmediate(s)}}}else if(typeof MessageChannel!=="undefined"){var f=new MessageChannel;f.port1.onmessage=s;o=function(){f.port2.postMessage(0)}}else{o=function(){setTimeout(s,0)}}function u(t){n=n.next={task:t,domain:a&&e.domain,next:null};if(!i){i=true;o()}}t.exports=u}).call(this,e("_process"))},{_process:52}],29:[function(e,t,r){t.exports=n;function n(e,t){if(e&&t)return n(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){r[t]=e[t]});return r;function r(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var n=e.apply(this,t);var i=t[t.length-1];if(typeof n==="function"&&n!==i){Object.keys(i).forEach(function(e){n[e]=i[e]})}return n}}},{}],30:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],31:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],32:[function(e,t,r){(function(r){var n=e("inherits");var i=e("readable-stream").Transform;var o=e("defined");t.exports=a;n(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,n){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var i=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}n()};a.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new r(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(r.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(r.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:45,defined:33,inherits:116,"readable-stream":42}],33:[function(e,t,r){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],34:[function(e,t,r){(function(r){t.exports=s;var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);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);u(n(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",f)}function f(){if(this.allowHalfOpen||this._writableState.ended)return;r.nextTick(this.end.bind(this))}function u(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}}).call(this,e("_process"))},{"./_stream_readable":36,"./_stream_writable":38,_process:52,"core-util-is":39,inherits:116}],35:[function(e,t,r){t.exports=o;var n=e("./_stream_transform");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(o,n);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}o.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":37,"core-util-is":39,inherits:116}],36:[function(e,t,r){(function(r){t.exports=c;var n=e("isarray");var i=e("buffer").Buffer;c.ReadableState=u;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 f;s.inherits(c,a);function u(t,r){t=t||{};var n=t.highWaterMark;this.highWaterMark=n||n===0?n:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function c(e){if(!(this instanceof c))return new c(e);this._readableState=new u(e,this);this.readable=true;a.call(this)}c.prototype.push=function(e,t){var r=this._readableState;if(typeof e==="string"&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new i(e,t);t=""}}return l(this,r,e,t,false)};c.prototype.unshift=function(e){var t=this._readableState;return l(this,t,e,"",true)};function l(e,t,r,n,i){var o=m(t,r);if(o){e.emit("error",o)}else if(r===null||r===undefined){t.reading=false;if(!t.ended)v(e,t)}else if(t.objectMode||r&&r.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&&!n)r=t.decoder.write(r);t.length+=t.objectMode?1:r.length;if(i){t.buffer.unshift(r)}else{t.reading=false;t.buffer.push(r)}if(t.needReadable)y(e);w(e,t)}}else if(!i){t.reading=false}return h(t)}function h(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}c.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t};var d=8388608;function p(e){if(e>=d){e=d}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function g(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(e===null||isNaN(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=p(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}c.prototype.read=function(e){var t=this._readableState;t.calledRead=true;var r=e;var n;if(typeof e!=="number"||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){y(this);return null}e=g(e,t);if(e===0&&t.ended){n=null;if(t.length>0&&t.decoder){n=A(e,t);t.length-=n.length}if(t.length===0)I(this);return n}var i=t.needReadable;if(t.length-e<=t.highWaterMark)i=true;if(t.ended||t.reading)i=false;if(i){t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=g(r,t);if(e>0)n=A(e,t);else n=null;if(n===null){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(t.ended&&!t.endEmitted&&t.length===0)I(this);return n};function m(e,t){var r=null;if(!i.isBuffer(t)&&"string"!==typeof t&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function v(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;if(t.length>0)y(e);else I(e)}function y(e){var t=e._readableState;t.needReadable=false;if(t.emittedReadable)return;t.emittedReadable=true;if(t.sync)r.nextTick(function(){_(e)});else _(e)}function _(e){e.emit("readable")}function w(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){b(e,t)})}}function b(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}c.prototype._read=function(e){this.emit("error",new Error("not implemented"))};c.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;var s=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=s?c:h;if(a.endEmitted)r.nextTick(f);else i.once("end",f);e.on("unpipe",u);function u(e){if(e!==i)return;h()}function c(){e.end()}var l=k(i);e.on("drain",l);function h(){e.removeListener("close",p);e.removeListener("finish",g);e.removeListener("drain",l);e.removeListener("error",d);e.removeListener("unpipe",u);i.removeListener("end",c);i.removeListener("end",h);if(!e._writableState||e._writableState.needDrain)l()}function d(t){m();e.removeListener("error",d);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",d);else if(n(e._events.error))e._events.error.unshift(d);else e._events.error=[d,e._events.error];function p(){e.removeListener("finish",g);m()}e.once("close",p);function g(){e.removeListener("close",p);m()}e.once("finish",g);function m(){i.unpipe(e)}e.emit("pipe",i);if(!a.flowing){this.on("readable",x);a.flowing=true;r.nextTick(function(){E(i)})}return e};function k(e){return function(){var t=this;var r=e._readableState;r.awaitDrain--;if(r.awaitDrain===0)E(e)}}function E(e){var t=e._readableState;var r;t.awaitDrain=0;function n(e,n,i){var o=e.write(r);if(false===o){t.awaitDrain++}}while(t.pipesCount&&null!==(r=e.read())){if(t.pipesCount===1)n(t.pipes,0,null);else T(t.pipes,n);e.emit("data",r);if(t.awaitDrain>0)return}if(t.pipesCount===0){t.flowing=false;if(o.listenerCount(e,"data")>0)S(e);return}t.ranOut=true}function x(){if(this._readableState.ranOut){this._readableState.ranOut=false;E(this)}}c.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=C(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};c.prototype.on=function(e,t){var r=a.prototype.on.call(this,e,t);if(e==="data"&&!this._readableState.flowing)S(this);if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){this.read(0)}else if(n.length){y(this,n)}}}return r};c.prototype.addListener=c.prototype.on;c.prototype.resume=function(){S(this);this.read(0);this.emit("resume")};c.prototype.pause=function(){S(this,true);this.emit("pause")};function S(e,t){var n=e._readableState;if(n.flowing){throw new Error("Cannot switch to old mode now.")}var i=t||false;var o=false;e.readable=true;e.pipe=a.prototype.pipe;e.on=e.addListener=a.prototype.on;e.on("readable",function(){o=true;var t;while(!i&&null!==(t=e.read()))e.emit("data",t);if(t===null){o=false;e._readableState.needReadable=true}});e.pause=function(){i=true;this.emit("pause")};e.resume=function(){i=false;if(o)r.nextTick(function(){e.emit("readable")});else this.read(0);this.emit("resume")};e.emit("readable")}c.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){if(t.decoder)i=t.decoder.write(i);if(t.objectMode&&(i===null||i===undefined))return;else if(!t.objectMode&&(!i||!i.length))return;var o=n.push(i);if(!o){r=true;e.pause()}});for(var i in e){if(typeof e[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var o=["error","close","destroy","pause","resume"];T(o,function(t){e.on(t,n.emit.bind(n,t))});n._read=function(t){if(r){r=false;e.resume()}};return n};c._fromList=A;function A(e,t){var r=t.buffer;var n=t.length;var o=!!t.decoder;var a=!!t.objectMode;var s;if(r.length===0)return null;if(n===0)s=null;else if(a)s=r.shift();else if(!e||e>=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e<r[0].length){var f=r[0];s=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){s=r.shift()}else{if(o)s="";else s=new i(e);var u=0;for(var c=0,l=r.length;c<l&&u<e;c++){var f=r[0];var h=Math.min(e-u,f.length);if(o)s+=f.slice(0,h);else f.copy(s,u,0,h);if(h<f.length)r[0]=f.slice(h);else r.shift();u+=h}}}return s}function I(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted&&t.calledRead){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function T(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}function C(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{_process:52,buffer:45,"core-util-is":39,events:49,inherits:116,isarray:40,stream:68,"string_decoder/":41}],37:[function(e,t,r){t.exports=s;var n=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(s,n);function o(e,t){this.afterTransform=function(e,r){return a(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,r){var n=e._transformState;n.transforming=false;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(r!==null&&r!==undefined)e.push(r);if(i)i(t);var o=e._readableState;o.reading=false;if(o.needReadable||o.length<o.highWaterMark){e._read(o.highWaterMark)}}function s(e){if(!(this instanceof s))return new s(e);n.call(this,e);var t=this._transformState=new o(e,this);var r=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("finish",function(){if("function"===typeof this._flush)this._flush(function(e){f(r,e)});else f(r)})}s.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};s.prototype._transform=function(e,t,r){throw new Error("not implemented")};s.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};s.prototype._read=function(e){var t=this._transformState;if(t.writechunk!==null&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._readableState;var i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":34,"core-util-is":39,inherits:116}],38:[function(e,t,r){(function(r){t.exports=f;var n=e("buffer").Buffer;f.WritableState=s;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(f,o);function a(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function s(e,t){e=e||{};var r=e.highWaterMark;this.highWaterMark=r||r===0?r:16*1024;this.objectMode=!!e.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var n=e.decodeStrings===false;this.decodeStrings=!n;this.defaultEncoding=e.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){m(t,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new s(t,this);this.writable=true;o.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,n){var i=new Error("write after end");e.emit("error",i);r.nextTick(function(){n(i)})}function c(e,t,i,o){var a=true;if(!n.isBuffer(i)&&"string"!==typeof i&&i!==null&&i!==undefined&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);r.nextTick(function(){o(s)});a=false}return a}f.prototype.write=function(e,t,r){var i=this._writableState;var o=false;if(typeof t==="function"){r=t;t=null}if(n.isBuffer(e))t="buffer";else if(!t)t=i.defaultEncoding;if(typeof r!=="function")r=function(){};if(i.ended)u(this,i,r);else if(c(this,i,e,r))o=h(this,i,e,t,r);return o};function l(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=new n(t,r)}return t}function h(e,t,r,i,o){r=l(t,r,i);if(n.isBuffer(r))i="buffer";var s=t.objectMode?1:r.length;t.length+=s;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing)t.buffer.push(new a(r,i,o));else d(e,t,s,r,i,o);return f}function d(e,t,r,n,i,o){t.writelen=r;t.writecb=o;t.writing=true;t.sync=true;e._write(n,i,t.onwrite);t.sync=false}function p(e,t,n,i,o){if(n)r.nextTick(function(){o(i)});else o(i);e._writableState.errorEmitted=true;e.emit("error",i)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function m(e,t){var n=e._writableState;var i=n.sync;var o=n.writecb;g(n);if(t)p(e,n,i,t,o);else{var a=w(e,n);if(!a&&!n.bufferProcessing&&n.buffer.length)_(e,n);if(i){r.nextTick(function(){v(e,n,a,o)})}else{v(e,n,a,o)}}}function v(e,t,r,n){if(!r)y(e,t);n();if(r)b(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;for(var r=0;r<t.buffer.length;r++){var n=t.buffer[r];var i=n.chunk;var o=n.encoding;var a=n.callback;var s=t.objectMode?1:i.length;d(e,t,s,i,o,a);if(t.writing){r++;break}}t.bufferProcessing=false;if(r<t.buffer.length)t.buffer=t.buffer.slice(r);else t.buffer.length=0}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype.end=function(e,t,r){var n=this._writableState;if(typeof e==="function"){r=e;e=null;t=null}else if(typeof t==="function"){r=t;t=null}if(typeof e!=="undefined"&&e!==null)this.write(e,t);if(!n.ending&&!n.finished)k(this,n,r)};function w(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function b(e,t){var r=w(e,t);if(r){t.finished=true;e.emit("finish")}return r}function k(e,t,n){t.ending=true;b(e,t);if(n){if(t.finished)r.nextTick(n);else e.once("finish",n)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":34,_process:52,buffer:45,"core-util-is":39,inherits:116,stream:68}],39:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function a(e){return typeof e==="number"}r.isNumber=a;function s(e){return typeof e==="string"}r.isString=s;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return l(e)&&v(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function h(e){return l(e)&&v(e)==="[object Date]"}r.isDate=h;function d(e){return l(e)&&(v(e)==="[object Error]"||e instanceof Error)}r.isError=d;function p(e){return typeof e==="function"}r.isFunction=p;function g(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=g;function m(t){return e.isBuffer(t)}r.isBuffer=m;function v(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:45}],40:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],41:[function(e,t,r){var n=e("buffer").Buffer;var i=n.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=r.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=f;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=u;break;default:this.write=s;return}this.charBuffer=new n(6);this.charReceived=0;this.charLength=0};a.prototype.write=function(e){var t="";while(this.charLength){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,r);this.charReceived+=r;if(this.charReceived<this.charLength){return""}e=e.slice(r,e.length);t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(n>=55296&&n<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var i=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,i);i-=this.charReceived}t+=e.toString(this.encoding,0,i);var i=t.length-1;var n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);e.copy(this.charBuffer,0,0,o);return t.substring(0,i)}return t};a.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t};a.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function s(e){return e.toString(this.encoding)}function f(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:45}],42:[function(e,t,r){var n=e("stream");r=t.exports=e("./lib/_stream_readable.js");r.Stream=n;r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":34,"./lib/_stream_passthrough.js":35,"./lib/_stream_readable.js":36,"./lib/_stream_transform.js":37,"./lib/_stream_writable.js":38,stream:68}],43:[function(e,t,r){},{}],44:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{dup:43}],45:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=_;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var a=1073741823;var s={};f.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0);var t=new Uint8Array(e);t.foo=function(){return 42};return t.foo()===42&&typeof t.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(r){return false}}();function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return c(this,e,arguments.length>1?arguments[1]:"utf8")}return l(this,e)}function u(e,t){e=v(e,t<0?0:y(t)|0);if(!f.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;r++){e[r]=0}}return e}function c(e,t,r){if(typeof r!=="string"||r==="")r="utf8";var n=w(t,r)|0;e=v(e,n);e.write(t,r);return e}function l(e,t){if(f.isBuffer(t))return h(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 p(e,t)}if(t.length)return g(e,t);return m(e,t)}function h(e,t){var r=y(t.length)|0;e=v(e,r);t.copy(e,0,0,r);return e}function d(e,t){var r=y(t.length)|0;e=v(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function p(e,t){var r=y(t.length)|0;e=v(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function g(e,t){var r=y(t.length)|0;e=v(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function m(e,t){var r;var n=0;if(t.type==="Buffer"&&o(t.data)){r=t.data;n=y(r.length)|0}e=v(e,n);for(var i=0;i<n;i+=1){e[i]=r[i]&255}return e}function v(e,t){if(f.TYPED_ARRAY_SUPPORT){e=f._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var r=t!==0&&t<=f.poolSize>>>1;if(r)e.parent=s;return e}function y(e){if(e>=a){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+a.toString(16)+" bytes")}return e|0}function _(e,t){if(!(this instanceof _))return new _(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function X(e){return!!(e!=null&&e._isBuffer)};f.compare=function Q(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;var i=0;var o=Math.min(r,n);while(i<o){if(e[i]!==t[i])break;++i}if(i!==o){r=e[i];n=t[i]}if(r<n)return-1;if(n<r)return 1;return 0};f.isEncoding=function Z(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}};f.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 f(0)}else if(e.length===1){return e[0]}var r;if(t===undefined){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var n=new f(t);var i=0;for(r=0;r<e.length;r++){var a=e[r];a.copy(n,i);i+=a.length}return n};function w(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 $(e).length;default:return e.length}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function te(e,t,r){var n=false;t=t|0;r=r===undefined||r===Infinity?this.length:r|0;if(!e)e="utf8";if(t<0)t=0;if(r>this.length)r=this.length;if(r<=t)return"";while(true){switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return C(this,t,r);case"binary":return L(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function re(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function ne(){var e="";var t=r.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return"<Buffer "+e+">"};f.prototype.compare=function ie(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function oe(e,t){if(t>2147483647)t=2147483647;else if(t<-2147483648)t=-2147483648;t>>=0;if(this.length===0)return-1;if(t>=this.length)return-1;if(t<0)t=Math.max(this.length+t,0);if(typeof e==="string"){if(e.length===0)return-1;return String.prototype.indexOf.call(this,e,t)}if(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var n=-1;for(var i=0;r+i<e.length;i++){if(e[r+i]===t[n===-1?0:i-n]){if(n===-1)n=i;if(i-n+1===t.length)return r+n}else{n=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};f.prototype.get=function ae(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function se(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function b(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(n>o/2){n=o/2}for(var a=0;a<n;a++){var s=parseInt(t.substr(a*2,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[r+a]=s}return a}function k(e,t,r,n){return K(Y(t,e.length-r),e,r,n)}function E(e,t,r,n){return K(V(t),e,r,n)}function x(e,t,r,n){return E(e,t,r,n)}function S(e,t,r,n){return K($(t),e,r,n)}function A(e,t,r,n){return K(J(t,e.length-r),e,r,n)}f.prototype.write=function fe(e,t,r,n){if(t===undefined){n="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){n=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(n===undefined)n="utf8"}else{n=r;r=undefined}}else{var i=n;n=t;t=r|0;r=i}var o=this.length-t;if(r===undefined||r>o)r=o;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!n)n="utf8";var a=false;for(;;){switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return k(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return x(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();a=true}}};f.prototype.toJSON=function ue(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function T(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var o=t;o<r;o++){if(e[o]<=127){n+=G(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return n+G(i)}function C(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i]&127)}return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i])}return n}function B(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var o=t;o<r;o++){i+=F(e[o])}return i}function R(e,t,r){var n=e.slice(t,r);var i="";for(var o=0;o<n.length;o+=2){i+=String.fromCharCode(n[o]+n[o+1]*256)}return i}f.prototype.slice=function ce(e,t){var r=this.length;e=~~e;t=t===undefined?r:~~t;if(e<0){e+=r;if(e<0)e=0}else if(e>r){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(t<e)t=e;var n;if(f.TYPED_ARRAY_SUPPORT){n=f._augment(this.subarray(e,t))}else{var i=t-e;n=new f(i,undefined);for(var o=0;o<i;o++){n[o]=this[o+e]}}if(n.length)n.parent=this.parent||this;return n};function M(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function le(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}return n};f.prototype.readUIntBE=function he(e,t,r){e=e|0;t=t|0;if(!r){M(e,t,this.length)}var n=this[e+--t];var i=1;while(t>0&&(i*=256)){n+=this[e+--t]*i}return n};f.prototype.readUInt8=function de(e,t){if(!t)M(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function pe(e,t){if(!t)M(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ge(e,t){if(!t)M(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function me(e,t){if(!t)M(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function ve(e,t){if(!t)M(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ye(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}i*=128;if(n>=i)n-=Math.pow(2,8*t);return n};f.prototype.readIntBE=function _e(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=t;var i=1;var o=this[e+--n];while(n>0&&(i*=256)){o+=this[e+--n]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};f.prototype.readInt8=function we(e,t){if(!t)M(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function be(e,t){if(!t)M(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function ke(e,t){if(!t)M(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ee(e,t){if(!t)M(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function xe(e,t){if(!t)M(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Se(e,t){if(!t)M(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function Ae(e,t){if(!t)M(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Ie(e,t){if(!t)M(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Te(e,t){if(!t)M(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,r,n,i,o){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||t<o)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Ce(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=1;var o=0;this[t]=e&255;while(++o<r&&(i*=256)){this[t+o]=e/i&255}return t+r};f.prototype.writeUIntBE=function Le(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=r-1;var o=1;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=e/o&255;
-}return t+r};f.prototype.writeUInt8=function Be(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function j(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-r,2);i<o;i++){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}f.prototype.writeUInt16LE=function Re(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function Me(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};function U(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-r,4);i<o;i++){e[r+i]=t>>>(n?i:3-i)*8&255}}f.prototype.writeUInt32LE=function Pe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{U(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function je(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{U(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Ue(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0;var a=1;var s=e<0?1:0;this[t]=e&255;while(++o<r&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+r};f.prototype.writeIntBE=function Oe(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1;var a=1;var s=e<0?1:0;this[t+o]=e&255;while(--o>=0&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+r};f.prototype.writeInt8=function He(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function De(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Ne(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function qe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{U(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function ze(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{U(this,e,t,false)}return t+4};function O(e,t,r,n,i,o){if(t>i||t<o)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function H(e,t,r,n,o){if(!o){O(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function We(e,t,r){return H(this,e,t,true,r)};f.prototype.writeFloatBE=function Fe(e,t,r){return H(this,e,t,false,r)};function D(e,t,r,n,o){if(!o){O(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function Ye(e,t,r){return D(this,e,t,true,r)};f.prototype.writeDoubleBE=function Ve(e,t,r){return D(this,e,t,false,r)};f.prototype.copy=function Je(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n<r)n=r;if(n===r)return 0;if(e.length===0||this.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r){n=e.length-t+r}var i=n-r;if(i<1e3||!f.TYPED_ARRAY_SUPPORT){for(var o=0;o<i;o++){e[o+t]=this[o+r]}}else{e._set(this.subarray(r,r+i),t)}return i};f.prototype.fill=function $e(e,t,r){if(!e)e=0;if(!t)t=0;if(!r)r=this.length;if(r<t)throw new RangeError("end < start");if(r===t)return;if(this.length===0)return;if(t<0||t>=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if(typeof e==="number"){for(n=t;n<r;n++){this[n]=e}}else{var i=Y(e.toString());var o=i.length;for(n=t;n<r;n++){this[n]=i[n%o]}}return this};f.prototype.toArrayBuffer=function Ke(){if(typeof Uint8Array!=="undefined"){if(f.TYPED_ARRAY_SUPPORT){return new f(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,r=e.length;t<r;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var N=f.prototype;f._augment=function Ge(e){e.constructor=f;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 z(e){e=W(e).replace(q,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function W(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function F(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function Y(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var o=[];var a=0;for(;a<n;a++){r=e.charCodeAt(a);if(r>55295&&r<57344){if(i){if(r<56320){if((t-=3)>-1)o.push(239,191,189);i=r;continue}else{r=i-55296<<10|r-56320|65536;i=null}}else{if(r>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)o.push(239,191,189);continue}else{i=r;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<2097152){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function V(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function J(e,t){var r,n,i;var o=[];for(var a=0;a<e.length;a++){if((t-=2)<0)break;r=e.charCodeAt(a);n=r>>8;i=r%256;o.push(i);o.push(n)}return o}function $(e){return n.toByteArray(z(e))}function K(e,t,r,n){for(var i=0;i<n;i++){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function G(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":46,ieee754:47,"is-array":48}],46:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var a="a".charCodeAt(0);var s="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===i||t===u)return 63;if(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 l(e){var r,n,i,o,a,s;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var f=e.length;a="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0;s=new t(e.length*3/4-a);i=a>0?e.length-4:e.length;var u=0;function l(e){s[u++]=e}for(r=0,n=0;r<i;r+=4,n+=3){o=c(e.charAt(r))<<18|c(e.charAt(r+1))<<12|c(e.charAt(r+2))<<6|c(e.charAt(r+3));l((o&16711680)>>16);l((o&65280)>>8);l(o&255)}if(a===2){o=c(e.charAt(r))<<2|c(e.charAt(r+1))>>4;l(o&255)}else if(a===1){o=c(e.charAt(r))<<10|c(e.charAt(r+1))<<4|c(e.charAt(r+2))>>2;l(o>>8&255);l(o&255)}return s}function h(e){var t,r=e.length%3,i="",o,a;function s(e){return n.charAt(e)}function f(e){return s(e>>18&63)+s(e>>12&63)+s(e>>6&63)+s(e&63)}for(t=0,a=e.length-r;t<a;t+=3){o=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=f(o)}switch(r){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=l;e.fromByteArray=h})(typeof r==="undefined"?this.base64js={}:r)},{}],47:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=i*8-n-1,f=(1<<s)-1,u=f>>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];l+=h;o=d&(1<<-c)-1;d>>=-c;c+=s;for(;c>0;o=o*256+e[t+l],l+=h,c-=8){}a=o&(1<<-c)-1;o>>=-c;c+=n;for(;c>0;a=a*256+e[t+l],l+=h,c-=8){}if(o===0){o=1-u}else if(o===f){return a?NaN:(d?-1:1)*Infinity}else{a=a+Math.pow(2,n);o=o-u}return(d?-1:1)*a*Math.pow(2,o-n)};r.write=function(e,t,r,n,i,o){var a,s,f,u=o*8-i-1,c=(1<<u)-1,l=c>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){s=isNaN(t)?1:0;a=c}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-a))<1){a--;f*=2}if(a+l>=1){t+=h/f}else{t+=h*Math.pow(2,1-l)}if(t*f>=2){a++;f/=2}if(a+l>=c){s=0;a=c}else if(a+l>=1){s=(t*f-1)*Math.pow(2,i);a=a+l}else{s=t*Math.pow(2,l-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+d]=s&255,d+=p,s/=256,i-=8){}a=a<<i|s;u+=i;for(;u>0;e[r+d]=a&255,d+=p,a/=256,u-=8){}e[r+d-p]|=g*128}},{}],48:[function(e,t,r){var n=Array.isArray;var i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],49:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,f,u;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||a(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}r=this._events[e];if(s(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=arguments.length;o=new Array(n-1);for(f=1;f<n;f++)o[f-1]=arguments[f];r.apply(this,o)}}else if(a(r)){n=arguments.length;o=new Array(n-1);for(f=1;f<n;f++)o[f-1]=arguments[f];u=r.slice();n=u.length;for(f=0;f<n;f++)u[f].apply(this,o)}return true};n.prototype.addListener=function(e,t){var r;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 r;if(!s(this._maxListeners)){r=this._maxListeners}else{r=n.defaultMaxListeners}if(r&&r>0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(r)){for(s=o;s-->0;){if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(i(e._events[t]))r=1;else r=e._events[t].length;return r};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function a(e){return typeof e==="object"&&e!==null}function s(e){return e===void 0}},{}],50:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],51:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return n.exec(e).slice(1)};r.resolve=function(){var r="",n=false;for(var i=arguments.length-1;i>=-1&&!n;i--){var a=i>=0?arguments[i]:e.cwd();if(typeof a!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!a){continue}r=a+"/"+r;n=a.charAt(0)==="/"}r=t(o(r.split("/"),function(e){return!!e}),!n).join("/");return(n?"/":"")+r||"."};r.normalize=function(e){var n=r.isAbsolute(e),i=a(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!n).join("/");if(!e&&!n){e="."}if(e&&i){e+="/"}return(n?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};r.relative=function(e,t){e=r.resolve(e).substr(1);t=r.resolve(t).substr(1);function n(e){var t=0;for(;t<e.length;t++){if(e[t]!=="")break}var r=e.length-1;for(;r>=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var i=n(e.split("/"));var o=n(t.split("/"));var a=Math.min(i.length,o.length);var s=a;for(var f=0;f<a;f++){if(i[f]!==o[f]){s=f;break}}var u=[];for(var f=s;f<i.length;f++){u.push("..")}u=u.concat(o.slice(s));return u.join("/")};r.sep="/";r.delimiter=":";r.dirname=function(e){var t=i(e),r=t[0],n=t[1];if(!r&&!n){return"."}if(n){n=n.substr(0,n.length-1)}return r+n};r.basename=function(e,t){var r=i(e)[2];if(t&&r.substr(-1*t.length)===t){r=r.substr(0,r.length-t.length)}return r};r.extname=function(e){return i(e)[3]};function o(e,t){if(e.filter)return e.filter(t);var r=[];for(var n=0;n<e.length;n++){if(t(e[n],n,e))r.push(e[n])}return r}var a="ab".substr(-1)==="b"?function(e,t,r){return e.substr(t,r)}:function(e,t,r){if(t<0)t=e.length+t;return e.substr(t,r)}}).call(this,e("_process"))},{_process:52}],52:[function(e,t,r){var n=t.exports={};var i=[];var o=false;var a;var s=-1;function f(){o=false;if(a.length){i=a.concat(i)}else{s=-1}if(i.length){u()}}function u(){if(o){return}var e=setTimeout(f);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)}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}}i.push(new c(e,t));if(!o){setTimeout(u,0)}};function c(e,t){this.fun=e;this.array=t}c.prototype.run=function(){this.fun.apply(null,this.array)};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function l(){}n.on=l;n.addListener=l;n.once=l;n.off=l;n.removeListener=l;n.removeAllListeners=l;n.emit=l;n.binding=function(e){throw new Error("process.binding is not supported")};n.cwd=function(){return"/"};n.chdir=function(e){throw new Error("process.chdir is not supported")};n.umask=function(){return 0}},{}],53:[function(t,r,n){(function(t){(function(i){var o=typeof n=="object"&&n&&!n.nodeType&&n;var a=typeof r=="object"&&r&&!r.nodeType&&r;var s=typeof t=="object"&&t;if(s.global===s||s.window===s||s.self===s){i=s}var f,u=2147483647,c=36,l=1,h=26,d=38,p=700,g=72,m=128,v="-",y=/^xn--/,_=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=c-l,E=Math.floor,x=String.fromCharCode,S;function A(e){throw RangeError(b[e])}function I(e,t){var r=e.length;var n=[];while(r--){n[r]=t(e[r])}return n}function T(e,t){var r=e.split("@");var n="";if(r.length>1){n=r[0]+"@";e=r[1]}e=e.replace(w,".");var i=e.split(".");var o=I(i,t).join(".");return n+o}function C(e){var t=[],r=0,n=e.length,i,o;while(r<n){i=e.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){o=e.charCodeAt(r++);if((o&64512)==56320){t.push(((i&1023)<<10)+(o&1023)+65536)}else{t.push(i);r--}}else{t.push(i)}}return t}function L(e){return I(e,function(e){var t="";if(e>65535){e-=65536;t+=x(e>>>10&1023|55296);e=56320|e&1023}t+=x(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function M(e,t,r){var n=0;e=r?E(e/p):e>>1;e+=E(e/t);for(;e>k*h>>1;n+=c){e=E(e/k)}return E(n+(k+1)*e/(e+d))}function P(e){var t=[],r=e.length,n,i=0,o=m,a=g,s,f,d,p,y,_,w,b,k;s=e.lastIndexOf(v);if(s<0){s=0}for(f=0;f<s;++f){if(e.charCodeAt(f)>=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=s>0?s+1:0;d<r;){for(p=i,y=1,_=c;;_+=c){if(d>=r){A("invalid-input")}w=B(e.charCodeAt(d++));if(w>=c||w>E((u-i)/y)){A("overflow")}i+=w*y;b=_<=a?l:_>=a+h?h:_-a;if(w<b){break}k=c-b;if(y>E(u/k)){A("overflow")}y*=k}n=t.length+1;a=M(i-p,n,p==0);if(E(i/n)>u-o){A("overflow")}o+=E(i/n);i%=n;t.splice(i++,0,o)}return L(t)}function j(e){var t,r,n,i,o,a,s,f,d,p,y,_=[],w,b,k,S;e=C(e);w=e.length;t=m;r=0;o=g;for(a=0;a<w;++a){y=e[a];if(y<128){_.push(x(y))}}n=i=_.length;if(i){_.push(v)}while(n<w){for(s=u,a=0;a<w;++a){y=e[a];if(y>=t&&y<s){s=y}}b=n+1;if(s-t>E((u-r)/b)){A("overflow")}r+=(s-t)*b;t=s;for(a=0;a<w;++a){y=e[a];if(y<t&&++r>u){A("overflow")}if(y==t){for(f=r,d=c;;d+=c){p=d<=o?l:d>=o+h?h:d-o;if(f<p){break}S=f-p;k=c-p;_.push(x(R(p+S%k,0)));f=E(S/k)}_.push(x(R(f,0)));o=M(r,b,n==i);r=0;++n}}++r;++t}return _.join("")}function U(e){return T(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function O(e){return T(e,function(e){return _.test(e)?"xn--"+j(e):e})}f={version:"1.3.2",ucs2:{decode:C,encode:L},decode:P,encode:j,toASCII:O,toUnicode:U};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return f})}else if(o&&a){if(r.exports==o){a.exports=f}else{for(S in f){f.hasOwnProperty(S)&&(o[S]=f[S])}}}else{i.punycode=f}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],54:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&";r=r||"=";var a={};if(typeof e!=="string"||e.length===0){return a}var s=/\+/g;e=e.split(t);var f=1e3;if(o&&typeof o.maxKeys==="number"){f=o.maxKeys}var u=e.length;if(f>0&&u>f){u=f}for(var c=0;c<u;++c){var l=e[c].replace(s,"%20"),h=l.indexOf(r),d,p,g,m;if(h>=0){d=l.substr(0,h);p=l.substr(h+1)}else{d=l;p=""}g=decodeURIComponent(d);m=decodeURIComponent(p);if(!n(a,g)){a[g]=m}else if(i(a[g])){a[g].push(m)}else{a[g]=[a[g],m]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],55:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(a(e),function(a){var s=encodeURIComponent(n(a))+r;if(i(e[a])){return o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t)}else{return s+encodeURIComponent(n(e[a]))}}).join(t)}if(!s)return"";return encodeURIComponent(n(s))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function o(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n<e.length;n++){r.push(t(e[n],n))}return r}var a=Object.keys||function(e){var t=[];for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t.push(r)}return t}},{}],56:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":54,"./encode":55}],57:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":58}],58:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{"./_stream_readable":60,"./_stream_writable":62,_process:52,"core-util-is":63,dup:34,inherits:116}],59:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./_stream_transform":61,"core-util-is":63,dup:35,inherits:116}],60:[function(e,t,r){(function(r){t.exports=l;var n=e("isarray");var i=e("buffer").Buffer;l.ReadableState=c;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 f;var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}s.inherits(l,a);function c(t,r){var n=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(r instanceof n)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(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function l(t){var r=e("./_stream_duplex");if(!(this instanceof l))return new l(t);this._readableState=new c(t,this);this.readable=true;a.call(this)}l.prototype.push=function(e,t){var r=this._readableState;if(s.isString(e)&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new i(e,t);t=""}}return h(this,r,e,t,false)};l.prototype.unshift=function(e){var t=this._readableState;return h(this,t,e,"",true)};function h(e,t,r,n,i){var o=v(t,r);if(o){e.emit("error",o)}else if(s.isNullOrUndefined(r)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||r&&r.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&&!n)r=t.decoder.write(r);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}b(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}l.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t;return this};var p=8388608;function g(e){if(e>=p){e=p}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function m(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||s.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=g(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}l.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!s.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)T(this);else _(this);return null}e=m(e,t);if(e===0&&t.ended){if(t.length===0)T(this);return null}var n=t.needReadable;u("need readable",n);if(t.length===0||t.length-e<t.highWaterMark){n=true;u("length less than watermark",n)}if(t.ended||t.reading){n=false;u("reading or ended",n)}if(n){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(n&&!t.reading)e=m(r,t);var i;if(e>0)i=I(e,t);else i=null;if(s.isNull(i)){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(r!==e&&t.ended&&t.length===0)T(this);if(!s.isNull(i))this.emit("data",i);return i};function v(e,t){var r=null;if(!s.isBuffer(t)&&!s.isString(t)&&!s.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){w(e)});else w(e)}}function w(e){u("emit readable");e.emit("readable");A(e)}function b(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){k(e,t)})}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}l.prototype._read=function(e){this.emit("error",new Error("not implemented"))};l.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;u("pipe count=%d opts=%j",a.pipesCount,t);var s=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=s?l:d;if(a.endEmitted)r.nextTick(f);else i.once("end",f);e.on("unpipe",c);function c(e){u("onunpipe");if(e===i){d()}}function l(){u("onend");e.end()}var h=E(i);e.on("drain",h);function d(){u("cleanup");e.removeListener("close",m);e.removeListener("finish",v);e.removeListener("drain",h);e.removeListener("error",g);e.removeListener("unpipe",c);i.removeListener("end",l);i.removeListener("end",d);i.removeListener("data",p);if(a.awaitDrain&&(!e._writableState||e._writableState.needDrain))h()}i.on("data",p);function p(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",i._readableState.awaitDrain);i._readableState.awaitDrain++;i.pause()}}function g(t){u("onerror",t);y();e.removeListener("error",g);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",g);else if(n(e._events.error))e._events.error.unshift(g);else e._events.error=[g,e._events.error];function m(){e.removeListener("finish",v);y()}e.once("close",m);function v(){u("onfinish");e.removeListener("close",m);y()}e.once("finish",v);function y(){u("unpipe");i.unpipe(e)}e.emit("pipe",i);if(!a.flowing){u("pipe resume");i.resume()}return e};function E(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&o.listenerCount(e,"data")){t.flowing=true;A(e)}}}l.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 r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=L(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};l.prototype.on=function(e,t){var n=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;r.nextTick(function(){u("readable nexttick read 0");o.read(0)})}else if(i.length){_(this,i)}}}return n};l.prototype.addListener=l.prototype.on;l.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;if(!e.reading){u("resume read 0");this.read(0)}x(this,e)}return this};function x(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;r.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)}l.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}l.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){u("wrapped data");if(t.decoder)i=t.decoder.write(i);if(!i||!t.objectMode&&!i.length)return;var o=n.push(i);if(!o){r=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"];C(o,function(t){e.on(t,n.emit.bind(n,t))});n._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return n};l._fromList=I;function I(e,t){var r=t.buffer;var n=t.length;var o=!!t.decoder;var a=!!t.objectMode;var s;if(r.length===0)return null;if(n===0)s=null;else if(a)s=r.shift();else if(!e||e>=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e<r[0].length){var f=r[0];s=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){s=r.shift()}else{if(o)s="";else s=new i(e);var u=0;for(var c=0,l=r.length;c<l&&u<e;c++){var f=r[0];var h=Math.min(e-u,f.length);if(o)s+=f.slice(0,h);else f.copy(s,u,0,h);if(h<f.length)r[0]=f.slice(h);else r.shift();u+=h}}}return s}function T(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function C(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}function L(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":58,_process:52,buffer:45,"core-util-is":63,events:49,inherits:116,isarray:50,stream:68,"string_decoder/":69,util:44}],61:[function(e,t,r){t.exports=s;var n=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(s,n);function o(e,t){this.afterTransform=function(e,r){
-return a(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,r){var n=e._transformState;n.transforming=false;var o=n.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(!i.isNullOrUndefined(r))e.push(r);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);n.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){f(t,e)});else f(t)})}s.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};s.prototype._transform=function(e,t,r){throw new Error("not implemented")};s.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.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 f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":58,"core-util-is":63,inherits:116}],62:[function(e,t,r){(function(r){t.exports=f;var n=e("buffer").Buffer;f.WritableState=s;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(f,o);function a(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function s(t,r){var n=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(r instanceof n)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(r,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new s(t,this);this.writable=true;o.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,n){var i=new Error("write after end");e.emit("error",i);r.nextTick(function(){n(i)})}function c(e,t,n,o){var a=true;if(!i.isBuffer(n)&&!i.isString(n)&&!i.isNullOrUndefined(n)&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);r.nextTick(function(){o(s)});a=false}return a}f.prototype.write=function(e,t,r){var n=this._writableState;var o=false;if(i.isFunction(t)){r=t;t=null}if(i.isBuffer(e))t="buffer";else if(!t)t=n.defaultEncoding;if(!i.isFunction(r))r=function(){};if(n.ended)u(this,n,r);else if(c(this,n,e,r)){n.pendingcb++;o=h(this,n,e,t,r)}return o};f.prototype.cork=function(){var e=this._writableState;e.corked++};f.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)_(this,e)}};function l(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&i.isString(t)){t=new n(t,r)}return t}function h(e,t,r,n,o){r=l(t,r,n);if(i.isBuffer(r))n="buffer";var s=t.objectMode?1:r.length;t.length+=s;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new a(r,n,o));else d(e,t,false,s,r,n,o);return f}function d(e,t,r,n,i,o,a){t.writelen=n;t.writecb=a;t.writing=true;t.sync=true;if(r)e._writev(i,t.onwrite);else e._write(i,o,t.onwrite);t.sync=false}function p(e,t,n,i,o){if(n)r.nextTick(function(){t.pendingcb--;o(i)});else{t.pendingcb--;o(i)}e._writableState.errorEmitted=true;e.emit("error",i)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function m(e,t){var n=e._writableState;var i=n.sync;var o=n.writecb;g(n);if(t)p(e,n,i,t,o);else{var a=w(e,n);if(!a&&!n.corked&&!n.bufferProcessing&&n.buffer.length){_(e,n)}if(i){r.nextTick(function(){v(e,n,a,o)})}else{v(e,n,a,o)}}}function v(e,t,r,n){if(!r)y(e,t);t.pendingcb--;n();k(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var r=[];for(var n=0;n<t.buffer.length;n++)r.push(t.buffer[n].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var n=0;n<r.length;n++){t.pendingcb--;r[n](e)}});t.buffer=[]}else{for(var n=0;n<t.buffer.length;n++){var i=t.buffer[n];var o=i.chunk;var a=i.encoding;var s=i.callback;var f=t.objectMode?1:o.length;d(e,t,false,f,o,a,s);if(t.writing){n++;break}}if(n<t.buffer.length)t.buffer=t.buffer.slice(n);else t.buffer.length=0}t.bufferProcessing=false}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype._writev=null;f.prototype.end=function(e,t,r){var n=this._writableState;if(i.isFunction(e)){r=e;e=null;t=null}else if(i.isFunction(t)){r=t;t=null}if(!i.isNullOrUndefined(e))this.write(e,t);if(n.corked){n.corked=1;this.uncork()}if(!n.ending&&!n.finished)E(this,n,r)};function w(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function b(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function k(e,t){var r=w(e,t);if(r){if(t.pendingcb===0){b(e,t);t.finished=true;e.emit("finish")}else b(e,t)}return r}function E(e,t,n){t.ending=true;k(e,t);if(n){if(t.finished)r.nextTick(n);else e.once("finish",n)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":58,_process:52,buffer:45,"core-util-is":63,inherits:116,stream:68}],63:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{buffer:45,dup:39}],64:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":59}],65:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js");r.Stream=e("stream");r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":58,"./lib/_stream_passthrough.js":59,"./lib/_stream_readable.js":60,"./lib/_stream_transform.js":61,"./lib/_stream_writable.js":62,stream:68}],66:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":61}],67:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":62}],68:[function(e,t,r){t.exports=o;var n=e("events").EventEmitter;var i=e("inherits");i(o,n);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(){n.call(this)}o.prototype.pipe=function(e,t){var r=this;function i(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",i);function o(){if(r.readable&&r.resume){r.resume()}}e.on("drain",o);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",s);r.on("close",f)}var a=false;function s(){if(a)return;a=true;e.end()}function f(){if(a)return;a=true;if(typeof e.destroy==="function")e.destroy()}function u(e){c();if(n.listenerCount(this,"error")===0){throw e}}r.on("error",u);e.on("error",u);function c(){r.removeListener("data",i);e.removeListener("drain",o);r.removeListener("end",s);r.removeListener("close",f);r.removeListener("error",u);e.removeListener("error",u);r.removeListener("end",c);r.removeListener("close",c);e.removeListener("close",c)}r.on("end",c);r.on("close",c);e.on("close",c);e.emit("pipe",r);return e}},{events:49,inherits:116,"readable-stream/duplex.js":57,"readable-stream/passthrough.js":64,"readable-stream/readable.js":65,"readable-stream/transform.js":66,"readable-stream/writable.js":67}],69:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{buffer:45,dup:41}],70:[function(e,t,r){var n=e("punycode");r.parse=_;r.resolve=b;r.resolveObject=k;r.format=w;r.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"," "],f=["{","}","|","\\","^","`"].concat(s),u=["'"].concat(f),c=["%","/","?",";","#"].concat(u),l=["/","?","#"],h=255,d=/^[a-z0-9A-Z_-]{0,63}$/,p=/^([a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:true,"javascript:":true},m={javascript:true,"javascript:":true},v={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&x(e)&&e instanceof i)return e;var n=new i;n.parse(e,t,r);return n}i.prototype.parse=function(e,t,r){if(!E(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var i=e;i=i.trim();var a=o.exec(i);if(a){a=a[0];var s=a.toLowerCase();this.protocol=s;i=i.substr(a.length)}if(r||a||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=i.substr(0,2)==="//";if(f&&!(a&&m[a])){i=i.substr(2);this.slashes=true}}if(!m[a]&&(f||a&&!v[a])){var _=-1;for(var w=0;w<l.length;w++){var b=i.indexOf(l[w]);if(b!==-1&&(_===-1||b<_))_=b}var k,x;if(_===-1){x=i.lastIndexOf("@")}else{x=i.lastIndexOf("@",_)}if(x!==-1){k=i.slice(0,x);i=i.slice(x+1);this.auth=decodeURIComponent(k)}_=-1;for(var w=0;w<c.length;w++){var b=i.indexOf(c[w]);if(b!==-1&&(_===-1||b<_))_=b}if(_===-1)_=i.length;this.host=i.slice(0,_);i=i.slice(_);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 w=0,I=A.length;w<I;w++){var T=A[w];if(!T)continue;if(!T.match(d)){var C="";for(var L=0,B=T.length;L<B;L++){if(T.charCodeAt(L)>127){C+="x"}else{C+=T[L]}}if(!C.match(d)){var R=A.slice(0,w);var M=A.slice(w+1);var P=T.match(p);if(P){R.push(P[1]);M.unshift(P[2])}if(M.length){i="/"+M.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>h){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var j=this.hostname.split(".");var U=[];for(var w=0;w<j.length;++w){var O=j[w];U.push(O.match(/[^A-Za-z0-9_-]/)?"xn--"+n.encode(O):O)}this.hostname=U.join(".")}var H=this.port?":"+this.port:"";var D=this.hostname||"";this.host=D+H;this.href+=this.host;if(S){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(i[0]!=="/"){i="/"+i}}}if(!g[s]){for(var w=0,I=u.length;w<I;w++){var N=u[w];var q=encodeURIComponent(N);if(q===N){q=escape(N)}i=i.split(N).join(q)}}var z=i.indexOf("#");if(z!==-1){this.hash=i.substr(z);i=i.slice(0,z)}var W=i.indexOf("?");if(W!==-1){this.search=i.substr(W);this.query=i.substr(W+1);if(t){this.query=y.parse(this.query)}i=i.slice(0,W)}else if(t){this.search="";this.query={}}if(i)this.pathname=i;if(v[s]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var H=this.pathname||"";var O=this.search||"";this.path=H+O}this.href=this.format();return this};function w(e){if(E(e))e=_(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||"",r=this.pathname||"",n=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&&x(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||v[t])&&i!==false){i="//"+(i||"");if(r&&r.charAt(0)!=="/")r="/"+r}else if(!i){i=""}if(n&&n.charAt(0)!=="#")n="#"+n;if(a&&a.charAt(0)!=="?")a="?"+a;r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)});a=a.replace("#","%23");return t+i+r+a+n};function b(e,t){return _(e,false,true).resolve(t)}i.prototype.resolve=function(e){return this.resolveObject(_(e,false,true)).format()};function k(e,t){if(!e)return t;return _(e,false,true).resolveObject(t)}i.prototype.resolveObject=function(e){if(E(e)){var t=new i;t.parse(e,false,true);e=t}var r=new i;Object.keys(this).forEach(function(e){r[e]=this[e]},this);r.hash=e.hash;if(e.href===""){r.href=r.format();return r}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")r[t]=e[t]});if(v[r.protocol]&&r.hostname&&!r.pathname){r.path=r.pathname="/"}r.href=r.format();return r}if(e.protocol&&e.protocol!==r.protocol){if(!v[e.protocol]){Object.keys(e).forEach(function(t){r[t]=e[t]});r.href=r.format();return r}r.protocol=e.protocol;if(!e.host&&!m[e.protocol]){var n=(e.pathname||"").split("/");while(n.length&&!(e.host=n.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(n[0]!=="")n.unshift("");if(n.length<2)n.unshift("");r.pathname=n.join("/")}else{r.pathname=e.pathname}r.search=e.search;r.query=e.query;r.host=e.host||"";r.auth=e.auth;r.hostname=e.hostname||e.host;r.port=e.port;if(r.pathname||r.search){var o=r.pathname||"";var a=r.search||"";r.path=o+a}r.slashes=r.slashes||e.slashes;r.href=r.format();return r}var s=r.pathname&&r.pathname.charAt(0)==="/",f=e.host||e.pathname&&e.pathname.charAt(0)==="/",u=f||s||r.host&&e.pathname,c=u,l=r.pathname&&r.pathname.split("/")||[],n=e.pathname&&e.pathname.split("/")||[],h=r.protocol&&!v[r.protocol];if(h){r.hostname="";r.port=null;if(r.host){if(l[0]==="")l[0]=r.host;else l.unshift(r.host)}r.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(n[0]==="")n[0]=e.host;else n.unshift(e.host)}e.host=null}u=u&&(n[0]===""||l[0]==="")}if(f){r.host=e.host||e.host===""?e.host:r.host;r.hostname=e.hostname||e.hostname===""?e.hostname:r.hostname;r.search=e.search;r.query=e.query;l=n}else if(n.length){if(!l)l=[];l.pop();l=l.concat(n);r.search=e.search;r.query=e.query}else if(!A(e.search)){if(h){r.hostname=r.host=l.shift();var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!l.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var p=l.slice(-1)[0];var g=(r.host||e.host)&&(p==="."||p==="..")||p==="";var y=0;for(var _=l.length;_>=0;_--){p=l[_];if(p=="."){l.splice(_,1)}else if(p===".."){l.splice(_,1);y++}else if(y){l.splice(_,1);y--}}if(!u&&!c){for(;y--;y){l.unshift("..")}}if(u&&l[0]!==""&&(!l[0]||l[0].charAt(0)!=="/")){l.unshift("")}if(g&&l.join("/").substr(-1)!=="/"){l.push("")}var w=l[0]===""||l[0]&&l[0].charAt(0)==="/";if(h){r.hostname=r.host=w?"":l.length?l.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&l.length;if(u&&!w){l.unshift("")}if(!l.length){r.pathname=null;r.path=null}else{r.pathname=l.join("/")}if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.auth=e.auth||r.auth;r.slashes=r.slashes||e.slashes;r.href=r.format();return r};i.prototype.parseHost=function(){var e=this.host;var t=a.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function E(e){return typeof e==="string"}function x(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:53,querystring:56}],71:[function(e,t,r){(function(r){t.exports=m;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=v;var n=e("bencode");var i=e("block-stream2");var o=e("piece-length");var a=e("path");var s=e("dezalgo");var f=e("filestream/read");var u=e("flatten");var c=e("fs");var l=e("multistream");var h=e("once");var d=e("run-parallel");var p=e("simple-sha1");var g=e("stream");function m(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};v(e,t,function(e,n){if(e)return r(e);E(n,t,r)})}function v(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};n=s(n);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(A(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&a.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var i=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);d(e.map(function(e){return function(n){var o={};if(S(e)){o.getStream=T(e);o.length=e.size}else if(r.isBuffer(e)){o.getStream=C(e);o.length=e.length}else if(I(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}o.getStream=B(e,o);o.length=0}else if(typeof e==="string"){if(typeof c.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var s=i>1;y(e,s,n);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");o.path=e.name.split(a.sep);n(null,o)}}),function(e,t){if(e)return n(e);t=u(t);n(null,t)})}function y(e,t,r){w(_,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=u(i);else i=[i];var o=a.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(a.sep)+1)}else{if(o[o.length-1]!==a.sep)o+=a.sep}i.forEach(function(e){e.getStream=L(e.path);e.path=e.path.replace(o,"").split(a.sep)});r(null,i)})}function _(e,t){t=h(t);c.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function w(e,t,r){c.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{d(i.filter(b).map(function(r){return function(n){w(e,a.join(t,r),n)}}),r)}})}function b(e){return e[0]!=="."}function k(e,t,n){n=h(n);var o=[];var a=0;var s=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;var d=new l(s);var g=new i(t,{zeroPadding:false});d.on("error",y);d.pipe(g).on("data",m).on("end",v).on("error",y);function m(e){a+=e.length;var t=u;p(e,function(e){o[t]=e;f-=1;w()});f+=1;u+=1}function v(){c=true;w()}function y(e){_();n(e)}function _(){d.removeListener("error",y);g.removeListener("data",m);g.removeListener("end",v);g.removeListener("error",y)}function w(){if(c&&f===0){_();n(null,new r(o.join(""),"hex"),a)}}}function E(e,r,i){var a=r.announceList!==undefined?r.announceList:r.announce!==undefined?r.announce.map(function(e){return[e]}):t.exports.announceList;var s={info:{name:r.name},announce:a[0][0],"announce-list":a,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)s.info.comment=r.comment;if(r.createdBy!==undefined)s.info["created by"]=r.createdBy;if(r.private!==undefined)s.info.private=Number(r.private);if(r.sslCert!==undefined)s.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)s["url-list"]=r.urlList;var f=e.length===1;var u=r.pieceLength||o(e.reduce(x,0));s.info["piece length"]=u;k(e,u,function(t,r,o){if(t)return i(t);s.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){s.info.files=e}else{s.info.length=o}i(null,n.encode(s))})}function x(e,t){return e+t.length}function S(e){return typeof Blob!=="undefined"&&e instanceof Blob}function A(e){return typeof FileList==="function"&&e instanceof FileList}function I(e){return typeof e==="object"&&typeof e.pipe==="function"}function T(e){return function(){return new f(e)}}function C(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function L(e){return function(){return c.createReadStream(e)}}function B(e,t){return function(){var r=new g.Transform;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("buffer").Buffer)},{bencode:72,"block-stream2":76,buffer:45,dezalgo:88,"filestream/read":94,flatten:95,fs:43,multistream:96,once:99,path:51,"piece-length":100,"run-parallel":102,"simple-sha1":106,stream:68}],72:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":73,"./lib/encode":75,dup:13}],73:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":74,buffer:45,dup:14}],74:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],75:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],76:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{buffer:45,defined:77,dup:32,inherits:78,"readable-stream":87}],77:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{dup:33}],78:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],79:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{"./_stream_readable":81,"./_stream_writable":83,_process:52,"core-util-is":84,dup:34,inherits:78}],80:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./_stream_transform":82,"core-util-is":84,dup:35,inherits:78}],81:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{_process:52,buffer:45,"core-util-is":84,dup:36,events:49,inherits:78,isarray:85,stream:68,"string_decoder/":86}],82:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{"./_stream_duplex":79,"core-util-is":84,dup:37,inherits:78}],83:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{"./_stream_duplex":79,_process:52,buffer:45,"core-util-is":84,dup:38,inherits:78,stream:68}],84:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{buffer:45,dup:39}],85:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],86:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{buffer:45,dup:41}],87:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./lib/_stream_duplex.js":79,"./lib/_stream_passthrough.js":80,"./lib/_stream_readable.js":81,"./lib/_stream_transform.js":82,"./lib/_stream_writable.js":83,dup:42,stream:68}],88:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:89,dup:27,wrappy:90}],89:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],90:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],91:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],92:[function(e,t,r){(function(r){var n=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(n(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:45,"is-typedarray":93}],93:[function(e,t,r){t.exports=o;o.strict=a;o.loose=s;var n=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint16Array]":true,"[object Uint32Array]":true,"[object Float32Array]":true,"[object Float64Array]":true};function o(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return i[n.call(e)]}},{}],94:[function(e,t,r){var n=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var a=e("typedarray-to-buffer");function s(e,t){var r=this;if(!(this instanceof s)){return new s(e,t)}t=t||{};n.call(this,t);this._offset=0;this._ready=false;this._file=e;this._size=e.size;this._chunkSize=t.chunkSize||Math.max(this._size/1e3,200*1024);this.reader=new FileReader;this._generateHeaderBlocks(e,t,function(e,t){if(e){return r.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){r.push(e)})}r._ready=true;r.emit("_ready")})}i(s,n);t.exports=s;s.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};s.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var r=this._offset;var n=this._offset+this._chunkSize;if(n>this._size)n=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=n;e.push(a(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,n))};s.prototype.destroy=function(){this._file=null;if(this.reader){this.reader.onload=null;this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:91,stream:68,"typedarray-to-buffer":92}],95:[function(e,t,r){t.exports=function n(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,n){return e.reduce(function(e,i){if(Array.isArray(i)&&n<t){return e.concat(r(i,n+1))}else{return e.concat(i)}},[])}}},{}],96:[function(e,t,r){t.exports=o;var n=e("inherits");var i=e("stream");n(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",r);t.on("end",i);t.on("error",o);t.on("close",n);function r(){e._forward()}function n(){if(!t._readableState.ended){e.destroy()}}function i(){e._current=null;t.removeListener("readable",r);t.removeListener("end",i);t.removeListener("error",o);t.removeListener("close",n);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:97,stream:68}],97:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],98:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],99:[function(e,t,r){var n=e("wrappy");t.exports=n(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:98}],100:[function(e,t,r){var n=e("closest-to");var i=[];for(var o=14;o<=22;o++){i.push(Math.pow(2,o))}t.exports=function(e){return n(e/Math.pow(2,10),i)}},{"closest-to":101}],101:[function(e,t,r){t.exports=function(e,t){var r=Infinity;var n=0;var i=null;t.sort(function(e,t){return e-t});for(var o=0,a=t.length;o<a;o++){n=Math.abs(e-t[o]);if(n>=r){break}r=n;i=t[o]}return i}},{}],102:[function(e,t,r){var n=e("dezalgo");t.exports=function(e,t){if(t)t=n(t);var r,i,o;if(Array.isArray(e)){r=[];i=e.length}else{o=Object.keys(e);r={};i=o.length}function a(e,n,o){r[e]=o;if(--i===0||n){if(t)t(n,r);t=null}}if(!i){if(t)t(null,r);t=null}else if(o){o.forEach(function(t){e[t](a.bind(undefined,t))})}else{e.forEach(function(e,t){e(a.bind(undefined,t))})}}},{dezalgo:103}],103:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:104,dup:27,wrappy:105}],104:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],105:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],106:[function(e,t,r){var n=e("rusha");var i=new n;var o=window.crypto||window.msCrypto||{};var a=o.subtle||o.webkitSubtle;var s=i.digest.bind(i);try{a.digest({name:"sha-1"},new Uint8Array).catch(function(){a=false})}catch(f){a=false}function u(e,t){if(!a){setTimeout(t,0,s(e));return}if(typeof e==="string"){e=c(e)}a.digest({name:"sha-1"},e).then(function r(e){t(l(new Uint8Array(e)))},function n(r){t(s(e))})}function c(e){var t=e.length;var r=new Uint8Array(t);for(var n=0;n<t;n++){r[n]=e.charCodeAt(n)}return r}function l(e){var t=e.length;var r=[];for(var n=0;n<t;n++){var i=e[n];r.push((i>>>4).toString(16));r.push((i&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=s},{rusha:107}],107:[function(e,t,r){(function(e){(function(){if(typeof t!=="undefined"){t.exports=o}else if(typeof window!=="undefined"){window.Rusha=o}if(typeof FileReaderSync!=="undefined"){var r=new FileReaderSync,n=new o(4*1024*1024);self.onmessage=function s(e){var t,r=e.data.data;try{t=n.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}var i={getDataType:function(t){if(typeof t==="string"){return"string"}if(t instanceof Array){return"array"}if(typeof e!=="undefined"&&e.Buffer&&e.Buffer.isBuffer(t)){return"buffer"}if(t instanceof ArrayBuffer){return"arraybuffer"}if(t.buffer instanceof ArrayBuffer){return"view"}if(t instanceof Blob){return"blob"}throw new Error("Unsupported data type.")}};function o(e){"use strict";var t={fill:0};var n=function(e){for(e+=9;e%64>0;e+=1);return e};var o=function(e,t){for(var r=t>>2;r<e.length;r++)e[r]=0};var s=function(e,t,r){e[t>>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=r>>29;e[((t>>2)+2&~15)+15]=r<<3};var f=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o.charCodeAt(r);case 1:e[i+2|0]=o.charCodeAt(r+1);case 2:e[i+1|0]=o.charCodeAt(r+2);case 3:e[i|0]=o.charCodeAt(r+3)}}for(a=s;a<u;a=a+4|0){t[i+a>>2]=o.charCodeAt(r+a)<<24|o.charCodeAt(r+a+1)<<16|o.charCodeAt(r+a+2)<<8|o.charCodeAt(r+a+3)}switch(f){case 3:e[i+u+1|0]=o.charCodeAt(r+u+2);case 2:e[i+u+2|0]=o.charCodeAt(r+u+1);case 1:e[i+u+3|0]=o.charCodeAt(r+u)}};var u=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o[r];case 1:e[i+2|0]=o[r+1];case 2:e[i+1|0]=o[r+2];case 3:e[i|0]=o[r+3]}}for(a=4-s;a<u;a=a+=4|0){t[i+a>>2]=o[r+a]<<24|o[r+a+1]<<16|o[r+a+2]<<8|o[r+a+3]}switch(f){case 3:e[i+u+1|0]=o[r+u+2];case 2:e[i+u+2|0]=o[r+u+1];case 1:e[i+u+3|0]=o[r+u]}};var c=function(e,t,n,i,o){var a=this,s,f=o%4,u=i%4,c=i-u;var l=new Uint8Array(r.readAsArrayBuffer(a.slice(n,n+i)));if(c>0){switch(f){case 0:e[o+3|0]=l[0];case 1:e[o+2|0]=l[1];case 2:e[o+1|0]=l[2];case 3:e[o|0]=l[3]}}for(s=4-f;s<c;s=s+=4|0){t[o+s>>2]=l[s]<<24|l[s+1]<<16|l[s+2]<<8|l[s+3]}switch(u){case 3:e[o+c+1|0]=l[c+2];case 2:e[o+c+2|0]=l[c+1];case 1:e[o+c+3|0]=l[c]}};var l=function(e){switch(i.getDataType(e)){case"string":return f.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return c.bind(e)}};var h=function(e,t){switch(i.getDataType(e)){case"string":return e.slice(t);case"array":return e.slice(t);case"buffer":return e.slice(t);case"arraybuffer":return e.slice(t);case"view":return e.buffer.slice(t)}};var d=function(e){var t,r,n="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++){r=o[t];i[t]=n.charAt(r>>4&15)+n.charAt(r>>0&15)}return i.join("")};var p=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t<e;t=t<<1);}else{for(t=16777216;t<e;t+=16777216);}return t};var g=function(e){if(e%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=n(e);t.heap=new ArrayBuffer(p(t.padMaxChunkLen+320+20));
-t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=a({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};g(e||64*1024);var m=function(e,t){var r=new Int32Array(e,t+320,5);r[0]=1732584193;r[1]=-271733879;r[2]=-1732584194;r[3]=271733878;r[4]=-1009589776};var v=function(e,r){var i=n(e);var a=new Int32Array(t.heap,0,i>>2);o(a,e);s(a,e,r);return i};var y=function(e,r,n){l(e)(t.h8,t.h32,r,n,0)};var _=function(e,r,n,i,o){var a=n;if(o){a=v(n,i)}y(e,r,n);t.core.hash(a,t.padMaxChunkLen)};var w=function(e,t){var r=new Int32Array(e,t+320,5);var n=new Int32Array(5);var i=new DataView(n.buffer);i.setInt32(0,r[0],false);i.setInt32(4,r[1],false);i.setInt32(8,r[2],false);i.setInt32(12,r[3],false);i.setInt32(16,r[4],false);return n};var b=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var n=0,i=t.maxChunkLen,o;for(n=0;r>n+i;n+=i){_(e,n,i,r,false)}_(e,n,r-n,r,true);return w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(b(e).buffer)}}function a(e,t,r){"use asm";var n=new e.Int32Array(r);function i(e,t){e=e|0;t=t|0;var r=0,i=0,o=0,a=0,s=0,f=0,u=0,c=0,l=0,h=0,d=0,p=0,g=0,m=0;o=n[t+320>>2]|0;s=n[t+324>>2]|0;u=n[t+328>>2]|0;l=n[t+332>>2]|0;d=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){a=o;f=s;c=u;h=l;p=d;for(i=0;(i|0)<64;i=i+4|0){m=n[r+i>>2]|0;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)+1859775393|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|s&l|u&l)|0)+((m+d|0)-1894007588|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)-899497514|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}o=o+a|0;s=s+f|0;u=u+c|0;l=l+h|0;d=d+p|0}n[t+320>>2]=o;n[t+324>>2]=s;n[t+328>>2]=u;n[t+332>>2]=l;n[t+336>>2]=d}return{hash:i}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],108:[function(e,t,r){r=t.exports=e("./debug");r.log=o;r.formatArgs=i;r.save=a;r.load=s;r.useColors=n;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function i(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function o(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{if(null==e){r.storage.removeItem("debug")}else{r.storage.debug=e}}catch(t){}}function s(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(s());function f(){try{return window.localStorage}catch(e){}}},{"./debug":109}],109:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:110}],110:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var a=o*24;var s=a*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){e=""+e;if(e.length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*s;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+r;return Math.ceil(e/t)+" "+r+"s"}},{}],111:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:112,dup:27,wrappy:113}],112:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],113:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],114:[function(e,t,r){var n=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,r){if(typeof t==="function")return s(e,null,t);if(!t)t={};r=n(r||i);var f=e._writableState;var u=e._readableState;var c=t.readable||t.readable!==false&&e.readable;var l=t.writable||t.writable!==false&&e.writable;var h=function(){if(!e.writable)d()};var d=function(){l=false;if(!c)r()};var p=function(){c=false;if(!l)r()};var g=function(e){r(e?new Error("exited with error code: "+e):null)};var m=function(){if(c&&!(u&&u.ended))return r(new Error("premature close"));if(l&&!(f&&f.ended))return r(new Error("premature close"))};var v=function(){e.req.on("finish",d)};if(o(e)){e.on("complete",d);e.on("abort",m);if(e.req)v();else e.on("request",v)}else if(l&&!f){e.on("end",h);e.on("close",h)}if(a(e))e.on("exit",g);e.on("end",p);e.on("finish",d);if(t.error!==false)e.on("error",r);e.on("close",m);return function(){e.removeListener("complete",d);e.removeListener("abort",m);e.removeListener("request",v);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",h);e.removeListener("close",h);e.removeListener("finish",d);e.removeListener("exit",g);e.removeListener("end",p);e.removeListener("error",r);e.removeListener("close",m)}};t.exports=s},{once:120}],115:[function(e,t,r){var n=t.exports=function(e,t){if(!t)t=16;if(e===undefined)e=128;if(e<=0)return"0";var r=Math.log(Math.pow(2,e))/Math.log(t);for(var i=2;r===Infinity;i*=2){r=Math.log(Math.pow(2,e/i))/Math.log(t)*i}var o=r-Math.floor(r);var a="";for(var i=0;i<Math.floor(r);i++){var s=Math.floor(Math.random()*t).toString(t);a=s+a}if(o){var f=Math.pow(t,o);var s=Math.floor(Math.random()*f).toString(t);a=s+a}var u=parseInt(a,t);if(u!==Infinity&&u>=Math.pow(2,e)){return n(e,t)}else return a};n.rack=function(e,t,r){var i=function(i){var a=0;do{if(a++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var s=n(e,t)}while(Object.hasOwnProperty.call(o,s));o[s]=i;return s};var o=i.hats={};i.get=function(e){return i.hats[e]};i.set=function(e,t){i.hats[e]=t;return i};i.bits=e||128;i.base=t||16;return i}},{}],116:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],117:[function(e,t,r){arguments[4][96][0].apply(r,arguments)},{dup:96,inherits:118,stream:68}],118:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],119:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],120:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:119}],121:[function(e,t,r){(function(r){var n=e("magnet-uri");var i=e("parse-torrent-file");t.exports=function o(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return n(e)}else if(typeof e==="string"&&(t===40||t===32)){return n("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return n("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return i(e)}else if(e&&e.infoHash){return e}else{throw new Error("Invalid torrent identifier")}};t.exports.toMagnetURI=n.encode;t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:45,"magnet-uri":122,"parse-torrent-file":127}],122:[function(e,t,r){(function(r){t.exports=a;t.exports.decode=a;t.exports.encode=s;var n=e("thirty-two");var i=e("xtend");var o=e("uniq");function a(e){var t={};var i=e.split("magnet:?")[1];var a=i&&i.length>=0?i.split("&"):[];a.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var n=r[0];var i=r[1];if(n==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){i=decodeURIComponent(i)}if(n==="kt")i=decodeURIComponent(i).split("+");if(t[n]){if(Array.isArray(t[n])){t[n].push(i)}else{var o=t[n];t[n]=[o,i]}}else{t[n]=i}});var s;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=n.decode(s[1]);t.infoHash=new r(i,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];o(t.announce);t.urlList=[];if(typeof t.as==="string"||Array.isArray(t.as)){t.urlList=t.urlList.concat(t.as)}if(typeof t.ws==="string"||Array.isArray(t.ws)){t.urlList=t.urlList.concat(t.ws)}return t}function s(e){e=i(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,n){var i=Array.isArray(e[r])?e[r]:[e[r]];i.forEach(function(e,i){if((n>0||i>0)&&(r!=="kt"||i===0))t+="&";if(r==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){e=encodeURIComponent(e)}if(r==="kt")e=encodeURIComponent(e);if(r==="kt"&&i>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:45,"thirty-two":123,uniq:125,xtend:126}],123:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":124}],124:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var n=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var n=0;var o=0;var a=0;var s=0;var f=new e(i(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(n<r.length){var u=r[n];if(a>3){s=u&255>>a;a=(a+5)%8;s=s<<a|(n+1<r.length?r[n+1]:0)>>8-a;n++}else{s=u>>8-(a+5)&31;a=(a+5)%8;if(a==0)n++}f[o]=t.charCodeAt(s);o++}for(n=o;n<f.length;n++)f[n]=61;return f};r.decode=function(t){var r=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 f=0;f<t.length;f++){if(t[f]==61){break}var u=t[f]-48;if(u<n.length){i=n[u];if(r<=3){r=(r+5)%8;if(r==0){o|=i;s[a]=o;a++;o=0}else{o|=255&i<<8-r}}else{r=(r+5)%8;o|=255&i>>>r;s[a]=o;a++;o=255&i<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return s.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:45}],125:[function(e,t,r){"use strict";function n(e,t){var r=1,n=e.length,i=e[0],o=e[0];for(var a=1;a<n;++a){o=i;i=e[a];if(t(i,o)){if(a===r){r++;continue}e[r++]=i}}e.length=r;return e}function i(e){var t=1,r=e.length,n=e[0],i=e[0];for(var o=1;o<r;++o,i=n){i=n;n=e[o];if(n!==i){if(o===t){t++;continue}e[t++]=n}}e.length=t;return e}function o(e,t,r){if(e.length===0){return e}if(t){if(!r){e.sort(t)}return n(e,t)}if(!r){e.sort()}return i(e)}t.exports=o},{}],126:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],127:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=f;var n=e("bencode");var i=e("path");var o=e("simple-sha1");var a=e("uniq");function s(e){if(r.isBuffer(e)){e=n.decode(e)}l(e.info,"info");l(e.info.name,"info.name");l(e.info["piece length"],"info['piece length']");l(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){l(typeof e.length==="number","info.files[0].length");l(e.path,"info.files[0].path")})}else{l(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=n.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(r.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(r.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,r){var n=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(n)).slice(1),name:n[n.length-1],length:e.length,offset:s.slice(0,r).reduce(u,0)}});t.length=s.reduce(u,0);var f=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(f.offset+f.length)%t.pieceLength||t.pieceLength;t.pieces=c(e.info.pieces);return t}function f(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new r(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return n.encode(t)}function u(e,t){return e+t.length}function c(e){var t=[];for(var r=0;r<e.length;r+=20){t.push(e.slice(r,r+20).toString("hex"))}return t}function l(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:128,buffer:45,path:51,"simple-sha1":132,uniq:134}],128:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":129,"./lib/encode":131,dup:13}],129:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":130,buffer:45,dup:14}],130:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],131:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],132:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106,rusha:133}],133:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107}],134:[function(e,t,r){arguments[4][125][0].apply(r,arguments)},{dup:125}],135:[function(e,t,r){t.exports=i;t.exports.filter=o;var n=e("events").EventEmitter;function i(e,t,r){if(!Array.isArray(r))r=[r];var n=[];r.forEach(function(r){var i=function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)};n.push(i);e.on(r,i)});return function i(){r.forEach(function(t,r){e.removeListener(t,n[r])})}}function o(e,t){var r=new n;i(e,r,t);return r}},{events:49}],136:[function(e,t,r){arguments[4][102][0].apply(r,arguments)},{dezalgo:137,dup:102}],137:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:138,dup:27,wrappy:139}],138:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],139:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],140:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106,rusha:141}],141:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107}],142:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],143:[function(e,t,r){(function(r){t.exports=c;var n=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 f=e("re-emitter");var u=e("bittorrent-tracker/client");s(c,o);function c(e){var t=this;if(!(t instanceof c))return new c(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(!r.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}c.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}n("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))}};c.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 r.nextTick(function(){e(null)})};c.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new i;f(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,r){if(r===t.infoHash)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};c.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};var r={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new u(e.peerId,e.port,t,r);f(e.tracker,e,["peer","warning","error"]);e.tracker.start()};c.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;n("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;n("dht announce");e.dht.announce(e.infoHash,e.port,function(){n("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"))},{_process:52,"bittorrent-dht/client":44,"bittorrent-tracker/client":144,debug:174,events:49,inherits:177,"re-emitter":178,"xtend/mutable":179}],144:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("bittorrent-tracker");var i=e("events").EventEmitter;var o=e("inherits");var a=e("once");var s=e("url");var f=e("./lib/common");var u=e("./lib/http-tracker");var c=e("./lib/udp-tracker");var l=e("./lib/websocket-tracker");o(h,i);function h(e,t,o,a){var d=this;if(!(d instanceof h))return new h(e,t,o,a);i.call(d);if(!a)a={};d._peerId=r.isBuffer(e)?e:new r(e,"hex");d._peerIdHex=d._peerId.toString("hex");d._peerIdBinary=d._peerId.toString("binary");d._infoHash=r.isBuffer(o.infoHash)?o.infoHash:new r(o.infoHash,"hex");d._infoHashHex=d._infoHash.toString("hex");d._infoHashBinary=d._infoHash.toString("binary");d._port=t;d.torrentLength=o.length;d._rtcConfig=a.rtcConfig;d._wrtc=a.wrtc;d._numWant=a.numWant||f.DEFAULT_ANNOUNCE_PEERS;d._intervalMs=a.interval||f.DEFAULT_ANNOUNCE_INTERVAL;n("new client %s",d._infoHashHex);var p={interval:d._intervalMs};var g=!!d._wrtc||typeof window!=="undefined";var m=typeof o.announce==="string"?[o.announce]:o.announce==null?[]:o.announce;d._trackers=m.map(function(e){e=e.toString();var t=s.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof u==="function"){return new u(d,e,p)}else if(t==="udp:"&&typeof c==="function"){return new c(d,e,p)}else if((t==="ws:"||t==="wss:")&&g){return new l(d,e,p)}return null}).filter(Boolean)}h.scrape=function(e,t,n){n=a(n);var i=new r("01234567890123456789");var o=6881;var s={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var f=new h(i,o,s);f.once("error",n);var u=Array.isArray(t)?t.length:1;var c={};f.on("scrape",function(e){u-=1;c[e.infoHash]=e;if(u===0){f.destroy();var t=Object.keys(c);if(t.length===1){n(null,c[t[0]])}else{n(null,c)}}});t=Array.isArray(t)?t.map(function(e){return new r(e,"hex")}):new r(t,"hex");f.scrape({infoHash:t})};h.prototype.start=function(e){var t=this;n("send `start`");e=t._defaultAnnounceOpts(e);e.event="started";t._announce(e);t._trackers.forEach(function(e){e.setInterval(t._intervalMs)})};h.prototype.stop=function(e){var t=this;n("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};h.prototype.complete=function(e){var t=this;n("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)};h.prototype.update=function(e){var t=this;n("send `update`");e=t._defaultAnnounceOpts(e);if(e.event)delete e.event;t._announce(e)};h.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})};h.prototype.scrape=function(e){var t=this;n("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};h.prototype.setInterval=function(e){var t=this;n("setInterval");t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};h.prototype.destroy=function(){var e=this;n("destroy");e._trackers.forEach(function(e){e.destroy();e.setInterval(0)});e._trackers=[]};h.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("buffer").Buffer)},{"./lib/common":146,"./lib/http-tracker":44,"./lib/udp-tracker":44,"./lib/websocket-tracker":147,buffer:45,debug:148,events:49,inherits:152,once:154,url:70}],145:[function(e,t,r){(function(t){var n=e("querystring");r.IPV4_RE=/^[\d\.]+$/;r.IPV6_RE=/^[\da-fA-F:]+$/;r.CONNECTION_ID=t.concat([i(1047),i(655366528)]);r.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};r.EVENTS={update:0,completed:1,started:2,stopped:3};r.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};r.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function i(e){var r=new t(4);r.writeUInt32BE(e,0);return r}r.toUInt32=i;r.querystringParse=function(e){var t=n.unescape;n.unescape=unescape;var r=n.parse(e);n.unescape=t;return r};r.querystringStringify=function(e){var t=n.escape;n.escape=escape;var r=n.stringify(e);r=r.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});n.escape=t;return r}}).call(this,e("buffer").Buffer)},{buffer:45,querystring:56}],146:[function(e,t,r){(function(t){var n=e("xtend/mutable");r.DEFAULT_ANNOUNCE_INTERVAL=30*60*1e3;r.DEFAULT_ANNOUNCE_PEERS=50;r.MAX_ANNOUNCE_PEERS=82;r.binaryToHex=function(e){return new t(e,"binary").toString("hex")};r.hexToBinary=function(e){return new t(e,"hex").toString("binary")};var i=e("./common-node");n(r,i)}).call(this,e("buffer").Buffer)},{"./common-node":145,buffer:45,"xtend/mutable":173}],147:[function(e,t,r){t.exports=h;var n=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 f=e("simple-websocket");var u=e("./common");var c=30*1e3;var l=5*1e3;a(h,i);function h(e,t,r){var a=this;i.call(a);n("new websocket tracker %s",t);a.client=e;a.destroyed=false;a._opts=r;a._announceUrl=t;if(a._announceUrl[a._announceUrl.length-1]!=="/")a._announceUrl+="/";a._announceUrl+="?"+o(40);a._peers={};a._socket=null;a._intervalMs=a.client._intervalMs;a._interval=null;a._openSocket()}h.prototype.announce=function(e){var t=this;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(r){e.offers=r;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};h.prototype.scrape=function(e){var t=this;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};h.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var r=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(r,t._intervalMs)}};h.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._socket.removeListener("data",e._onSocketDataBound);e._socket.removeListener("close",e._onSocketCloseBound);e._socket.removeListener("error",e._onSocketErrorBound);e._onSocketErrorBound=null;e._onSocketDataBound=null;e._onSocketCloseBound=null;e._socket.on("error",d);try{e._socket.close()}catch(t){}e._socket=null};h.prototype._openSocket=function(){var e=this;e._onSocketErrorBound=e._onSocketError.bind(e);e._onSocketDataBound=e._onSocketData.bind(e);e._onSocketCloseBound=e._onSocketClose.bind(e);e._socket=new f(e._announceUrl);e._socket.on("data",e._onSocketDataBound);e._socket.on("close",e._onSocketCloseBound);e._socket.on("error",e._onSocketErrorBound)};h.prototype._onSocketData=function(e){var t=this;if(t.destroyed)return;if(!(typeof e==="object"&&e!==null)){return t.client.emit("warning",new Error("Invalid tracker response"))}if(e.info_hash!==t.client._infoHashBinary){return t.client.emit("warning",new Error("Invalid tracker response"))}n("received %s from %s",JSON.stringify(e),t._announceUrl);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];if(i)t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];if(o&&!t._opts.interval&&t._intervalMs!==0){t.setInterval(o*1e3)}var a=e["tracker id"];if(a){t._trackerId=a}if(e.complete){t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete})}if(t.client._peerIdHex===u.binaryToHex(e.peer_id)){return}var f;if(e.offer){f=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});f.id=u.binaryToHex(e.peer_id);f.once("signal",function(r){var n={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)});f.signal(e.offer);t.client.emit("peer",f)}if(e.answer){f=t._peers[u.binaryToHex(e.offer_id)];if(f){f.id=u.binaryToHex(e.peer_id);f.signal(e.answer);t.client.emit("peer",f)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};h.prototype._onSocketClose=function(){var e=this;e.destroy();var t=Math.floor(Math.random()*c)+l;setTimeout(function(){e._openSocket()},t);n("reconnecting socket in %s ms",t)};h.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.client.emit("error",e)};h.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);n("send %s",r);t._socket.send(r)};h.prototype._generateOffers=function(e,t){var r=this;var i=[];n("generating %s offers",e);for(var a=0;a<e;++a){f()}function f(){var e=o(160);var t=r._peers[e]=new s({initiator:true,trickle:false,config:r.client._rtcConfig,wrtc:r.client._wrtc});t.once("signal",function(t){i.push({offer:t,offer_id:u.hexToBinary(e)});c()})}function c(){if(i.length===e){n("generated %s offers",e);t(i)}}};function d(){}},{"./common":146,debug:148,events:49,hat:151,inherits:152,"simple-peer":155,"simple-websocket":165}],148:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{"./debug":149,dup:18}],149:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:150}],150:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],151:[function(e,t,r){arguments[4][115][0].apply(r,arguments)},{dup:115}],152:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],153:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],154:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:153}],155:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-peer");var i=e("hat");var o=e("inherits");var a=e("is-typedarray");var s=e("once");var f=e("stream");var u=e("typedarray-to-buffer");o(c,f.Duplex);function c(e){var t=this;if(!(t instanceof c))return new c(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||c.channelConfig;t.channelName=e.channelName||i(160);if(!e.initiator)t.channelName=null;t.config=e.config||c.config;t.constraints=e.constraints||c.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||l();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=s(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)})}})}c.WEBRTC_SUPPORT=!!l();c.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};c.constraints={};c.channelConfig={};Object.defineProperty(c.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}});c.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}};c.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(r){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),d,t._onError.bind(t))}catch(r){t._destroy(new Error("error adding candidate: "+r.message))}}if(!e.sdp&&!e.candidate){t._destroy(new Error("signal() called with invalid signal data"))}};c.prototype.send=function(e){var t=this;if(!a.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}if(r.isBuffer(e)&&!a.strict(e)){e=new Uint8Array(e)}var n=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",n)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);r._debug("destroy (error: %s)",e&&e.message);r.readable=r.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.destroyed=true;r.connected=false;r._pcReady=false;r._channelReady=false;r._chunk=null;r._cb=null;clearInterval(r._interval);clearTimeout(r._reconnectTimeout);if(r._pc){try{r._pc.close()}catch(e){}r._pc.oniceconnectionstatechange=null;r._pc.onsignalingstatechange=null;r._pc.onicecandidate=null}if(r._channel){try{r._channel.close()}catch(e){}r._channel.onmessage=null;r._channel.onopen=null;r._channel.onclose=null}r._pc=null;r._channel=null;if(e)r.emit("error",e);r.emit("close")};c.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)};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var n=this;if(n.destroyed)return r(new Error("cannot write after peer is destroyed"));if(n.connected){n.send(e);if(n._channel.bufferedAmount>n._maxBufferedAmount){n._debug("start backpressure: bufferedAmount %d",n._channel.bufferedAmount);n._cb=r}else{r(null)}}else{n._debug("write before connect");n._chunk=e;n._cb=r}};c.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.offerConstraints)};c.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.answerConstraints)};c.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,r);e.emit("iceConnectionStateChange",t,r);if(r==="connected"||r==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(r==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(r==="closed"){e._destroy()}};c.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(e.connected||e._connecting||!e._pcReady||!e._channelReady)return;e._connecting=true;if(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.remoteFamily="IPv4";e.remotePort=Number(t.portNumber);e._debug("connect remote: %s:%s (%s)",e.remoteAddress,e.remotePort,e.remoteFamily)}else if(t.type==="localcandidate"&&t.candidateType==="host"){e.localAddress=t.ipAddress;e.localPort=Number(t.portNumber);e._debug("connect local: %s:%s",e.localAddress,e.localPort)}});e._connecting=false;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;e._debug('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}e._interval=setInterval(function(){if(!e._cb||!e._channel||e._channel.bufferedAmount>e._maxBufferedAmount)return;e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref();e._debug("connect");e.emit("connect")}};c.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};c.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:e.candidate})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};c.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var r=e.data;t._debug("read: %d bytes",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=u(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};c.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};c.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};c.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};c.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};c.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var r=e.channelName&&e.channelName.substring(0,7);t[0]="["+r+"] "+t[0];n.apply(null,t)};function l(){if(typeof window==="undefined")return null;var e={RTCPeerConnection:window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate};if(!e.RTCPeerConnection)return null;return e}function h(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function d(){}}).call(this,e("buffer").Buffer)},{buffer:45,debug:156,hat:159,inherits:160,"is-typedarray":161,once:163,stream:68,"typedarray-to-buffer":164}],156:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{"./debug":157,dup:108}],157:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:158}],158:[function(e,t,r){arguments[4][110][0].apply(r,arguments)},{dup:110}],159:[function(e,t,r){arguments[4][115][0].apply(r,arguments)},{dup:115}],160:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],161:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],162:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],163:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:162}],164:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{buffer:45,dup:92,"is-typedarray":161}],165:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var a=e("stream");var s=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;i(c,a.Duplex);function c(e,t){var r=this;if(!(r instanceof c))return new c(e,t);if(!t)t={};n("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;a.Duplex.call(r,t);r.url=e;r.connected=false;r.destroyed=false;r._maxBufferedAmount=t.highWaterMark;r._chunk=null;r._cb=null;r._interval=null;r._ws=new u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=r._onError.bind(r);r.on("finish",function(){if(r.connected){setTimeout(function(){r._destroy()},100)}else{r.once("connect",function(){setTimeout(function(){r._destroy()},100)})}})}c.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}var i=e.length||e.byteLength||e.size;t._ws.send(e);n("write: %d bytes",i)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);n("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.connected=false;r.destroyed=true;clearInterval(r._interval);r._interval=null;r._chunk=null;r._cb=null;if(r._ws){try{r._ws.close()}catch(e){}r._ws.onopen=null;r._ws.onmessage=null;r._ws.onclose=null;r._ws.onerror=null}r._ws=null;if(e)r.emit("error",e);r.emit("close")};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var i=this;if(i.destroyed)return r(new Error("cannot write after socket is destroyed"));if(i.connected){i.send(e);if(typeof f!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){n("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=r}else{r(null)}}else{n("write before connect");i._chunk=e;i._cb=r}};c.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;n("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=s(new Uint8Array(i));t.push(i)}else if(r.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};c.prototype._onOpen=function(){var e=this;if(e.connected||e.destroyed)return;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;n('sent chunk from "write before connect"');var t=e._cb;e._cb=null;t(null)}if(typeof f!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}n("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}n("connect");e.emit("connect")};c.prototype._onClose=function(){var e=this;if(e.destroyed)return;n("on close");e._destroy()};c.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);n("error: %s",t.message||t);e._destroy(t)}}).call(this,e("buffer").Buffer)},{buffer:45,debug:166,inherits:169,"is-typedarray":170,stream:68,"typedarray-to-buffer":171,ws:44}],166:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{"./debug":167,dup:18}],167:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:168}],168:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],169:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],170:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],171:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{buffer:45,dup:92,"is-typedarray":172}],172:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],173:[function(e,t,r){t.exports=n;function n(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r){if(r.hasOwnProperty(n)){e[n]=r[n]}}}return e}},{}],174:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{"./debug":175,dup:18}],175:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:176}],176:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],177:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],178:[function(e,t,r){arguments[4][135][0].apply(r,arguments)},{dup:135,events:49}],179:[function(e,t,r){arguments[4][173][0].apply(r,arguments)},{dup:173}],180:[function(e,t,r){arguments[4][125][0].apply(r,arguments)},{dup:125}],181:[function(e,t,r){(function(r){var n=e("bencode");var i=e("bitfield");var o=e("events").EventEmitter;var a=e("inherits");var s=e("simple-sha1");var f=1e7;var u=1e3;var c=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:u});if(r.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,r){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>f){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/c);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var i=e.toString();var o=i.indexOf("ee")+2;t=n.decode(i.substring(0,o));r=e.slice(o)}catch(a){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);break}};t.prototype.fetch=function(){if(this._metadataComplete){return}this._fetching=true;if(this._metadataSize){this._requestPieces()}};t.prototype.cancel=function(){this._fetching=false};t.prototype.setMetadata=function(e){if(this._metadataComplete)return true;try{var t=n.decode(e).info;if(t){e=n.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==s.sync(e)){return false}this.cancel();this.metadata=e;this._metadataComplete=true;this._metadataSize=this.metadata.length;this._wire.extendedHandshake.metadata_size=this._metadataSize;this.emit("metadata",n.encode({info:n.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=n.encode(e);if(r.isBuffer(t)){i=r.concat([i,t])}this._wire.extended("ut_metadata",i)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var n={msg_type:1,piece:e};if(typeof r==="number"){n.total_size=r}this._send(n,t)};t.prototype._reject=function(e){this._send({msg_type:2,piece:e})};t.prototype._onRequest=function(e){if(!this._metadataComplete){this._reject(e);return}var t=e*c;var r=t+c;if(r>this._metadataSize){r=this._metadataSize}var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>c){return}t.copy(this.metadata,e*c);this._bitfield.set(e);this._checkDone()};t.prototype._onReject=function(e){if(this._remainingRejects>0&&this._fetching){this._request(e);this._remainingRejects-=1}else{this.emit("warning",new Error('Peer sent "reject" too much'))}};t.prototype._requestPieces=function(){this.metadata=new r(this._metadataSize);for(var e=0;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 r=this.setMetadata(this.metadata);if(!r){this._failedMetadata()}};t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:u});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:182,bitfield:186,buffer:45,events:49,inherits:187,"simple-sha1":188}],182:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":183,"./lib/encode":185,dup:13}],183:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":184,buffer:45,dup:14}],184:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],185:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],186:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{buffer:45,dup:8}],187:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],188:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106,rusha:189}],189:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107}],190:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],191:[function(e,t,r){t.exports=function n(e,t,r){if(t===undefined){return function(t,r){return n(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}],192:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.46.0",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./server":false,"bittorrent-dht/client":false,"load-ip-set":false,"simple-get":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","block-stream2":"^1.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^5.0.0","pretty-bytes":"^1.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-get":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^4.0.0",brfs:"^1.2.0",browserify:"^10.0.0","run-auto":"^1.0.0",standard:"^3.1.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}]},{},[1])(1)});
+(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.WebTorrent=e()}})(function(){var e,t,r;return function n(e,t,r){function i(a,s){if(!t[a]){if(!e[a]){var f=typeof require=="function"&&require;if(!s&&f)return f(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[a]={exports:{}};e[a][0].call(c.exports,function(t){var r=e[a][1][t];return i(r?r:t)},c,c.exports,n,e,t,r)}return t[a].exports}var o=typeof require=="function"&&require;for(var a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,r){(function(r,n,i){t.exports=b;var o=e("create-torrent");var a=e("debug")("webtorrent");var s=e("bittorrent-dht/client");var f=e("events").EventEmitter;var u=e("xtend");var c=e("hat");var l=e("inherits");var h=e("load-ip-set");var d=e("run-parallel");var p=e("parse-torrent");var g=e("speedometer");var m=e("zero-fill");var v=e("./lib/fs-storage");var y=e("./lib/storage");var _=e("./lib/torrent");l(b,f);var w=e("./package.json").version.match(/([0-9]+)/g).slice(0,2).map(m(2)).join("");function b(e){var t=this;if(!(t instanceof b))return new b(e);if(!e)e={};f.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||n.WRTC;t.torrents=[];t.downloadSpeed=g();t.uploadSpeed=g();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof v==="function"?v:y;t.peerId=e.peerId===undefined?new i("-WW"+w+"-"+c(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(c(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(u({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}a("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof h==="function"){h(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=r;o()})}else r.nextTick(o);function o(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(b.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});b.prototype.get=function(e){var t=this;var r=p(e);if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,i=t.torrents.length;n<i;n++){var o=t.torrents[n];if(o.infoHash===r.infoHash)return o}return null};b.prototype.add=b.prototype.download=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");a("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.client=n;t.storage=t.storage||n.storage;var i=new _(e,t);n.torrents.push(i);function o(e){if(i.infoHash===e.infoHash){r(i);n.removeListener("torrent",o)}}if(r)n.on("torrent",o);i.on("error",function(e){n.emit("error",e,i);n.remove(i)});i.on("listening",function(e){n.emit("listening",e,i)});i.on("ready",function(){a("torrent");n.emit("torrent",i)});return i};b.prototype.seed=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");a("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.noVerify=true;o.parseInput(e,t,function(i,a){if(i)return n.emit("error",i);var s=a.map(function(e){return e.getStream});o(e,t,function(e,i){if(e)return n.emit("error",e);if(n.destroyed)return;n.add(i,t,function(e){var t=[function(t){e.storage.load(s,t)}];if(n.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return n.emit("error",t);if(r)r(e);n.emit("seed",e)})})})})};b.prototype.remove=function(e,t){var r=this;var n=r.get(e);if(!n)throw new Error("No torrent with id "+e);a("remove");r.torrents.splice(r.torrents.indexOf(n),1);n.destroy(t)};b.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};b.prototype.destroy=function(e){var t=this;t.destroyed=true;a("destroy");var r=t.torrents.map(function(e){return function(r){t.remove(e.infoHash,r)}});if(t.dht){r.push(function(e){t.dht.destroy(e)})}d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":45,"./lib/storage":6,"./lib/torrent":7,"./package.json":193,_process:53,"bittorrent-dht/client":45,buffer:46,"create-torrent":72,debug:109,events:50,hat:116,inherits:117,"load-ip-set":45,"parse-torrent":122,"run-parallel":137,speedometer:143,xtend:191,"zero-fill":192}],2:[function(e,t,r){t.exports=f;var n=e("debug")("webtorrent:file-stream");var i=e("inherits");var o=e("path");var a=e("stream");var s=e("./media-stream");i(f,a.Readable);function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);a.Readable.call(r,t);n("new filestream %s",JSON.stringify(t));if(!t)t={};if(!t.start)t.start=0;if(!t.end)t.end=e.length-1;r.destroyed=false;r.length=t.end-t.start+1;var i=t.start+e.offset;var s=t.pieceLength;r.startPiece=i/s|0;r.endPiece=(t.end+e.offset)/s|0;r._extname=o.extname(e.name).toLowerCase();r._storage=e.storage;r._piece=r.startPiece;r._missing=r.length;r._reading=false;r._notifying=false;r._criticalLength=Math.min(1024*1024/s|0,2);r._offset=i-r.startPiece*s}f.prototype._read=function(){var e=this;n("_read");if(e._reading)return;e._reading=true;e.notify()};f.prototype.notify=function(){var e=this;n("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;n("before read %s",t);e._storage.read(e._piece++,function(r,i){n("after read %s (length %s) (err %s)",t,i.length,r&&r.message);e._notifying=false;if(e.destroyed)return;if(r){e._storage.emit("error",r);return e.destroy(r)}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;n("pushing buffer of length %s",i.length);e._reading=false;e.push(i);if(e._missing===0)e.push(null)})};f.prototype.pipe=function(e){var t=this;var r=a.Readable.prototype.pipe;if(e&&(e.nodeName==="VIDEO"||e.nodeName==="AUDIO")){var n={".webm":'video/webm; codecs="vorbis,vp8"',".mp4":'video/mp4; codecs="avc1.42c01e,mp4a.40.2"',".mp3":"audio/mpeg"}[t._extname];return r.call(t,new s(e,{type:n}))}else{return r.call(t,e)}};f.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._storage.emit("deselect",e.startPiece,e.endPiece,true)}},{"./media-stream":3,debug:109,inherits:117,path:52,stream:69}],3:[function(e,t,r){t.exports=f;var n=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(f,a.Writable);function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);a.Writable.call(r,t);if(!s)throw new Error("web browser lacks MediaSource support");r.media=e;t=t||{};t.type=t.type||'video/webm; codecs="vorbis,vp8"';n("new mediastream %s %s",e,JSON.stringify(t));r._mediaSource=new s;r._sourceBuffer=null;r._cb=null;r.media.src=window.URL.createObjectURL(r._mediaSource);var i=o(function(){r._sourceBuffer=r._mediaSource.addSourceBuffer(t.type);r._sourceBuffer.addEventListener("updateend",r._flow.bind(r));r._flow()});r._mediaSource.addEventListener("webkitsourceopen",i,false);r._mediaSource.addEventListener("sourceopen",i,false);r.on("finish",function(){n("finish");r._mediaSource.endOfStream()});window.vs=r}f.prototype._write=function(e,t,r){var i=this;if(!i._sourceBuffer){i._cb=function(n){if(n)return r(n);i._write(e,t,r)};return}if(i._sourceBuffer.updating){return r(new Error("Cannot append buffer while source buffer updating"))}i._sourceBuffer.appendBuffer(e);n("appendBuffer %s",e.length);i._cb=r};f.prototype._flow=function(){var e=this;n("flow");if(e._cb){e._cb(null)}}},{debug:109,inherits:117,once:121,stream:69}],4:[function(e,t,r){t.exports={".aac":"audio/aac",".m4a":"audio/mp4",".mp3":"audio/mpeg",".mp4":"video/mp4",".oga":"audio/ogg",".ogg":"audio/ogg",".pdf":"application/pdf",".wav":"audio/wav",".webm":"video/webm"}},{}],5:[function(e,t,r){t.exports=n;function n(e,t){var r=this;r.swarm=e;r.numPieces=t;function n(e){e.on("have",function(e){r.pieces[e]++});e.on("bitfield",r.recalculate.bind(r));e.on("close",function(){for(var t=0;t<r.numPieces;++t){r.pieces[t]-=e.peerPieces.get(t)}})}r.swarm.wires.forEach(n);r.swarm.on("wire",function(e){r.recalculate();n(e)});r.recalculate()}n.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 r=0;r<e.numPieces;++r){e.pieces[r]+=t.peerPieces.get(r)}})};n.prototype.getRarestPiece=function(e){var t=this;var r=[];var n=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===n){r.push(i)}else if(o<n){r=[i];n=o}}if(r.length>0){return r[Math.random()*r.length|0]}else{return-1}}},{}],6:[function(e,t,r){(function(r,n){t.exports=x;var i=e("bitfield");var o=e("block-stream2");var a=e("debug")("webtorrent:storage");var s=e("dezalgo");var f=e("end-of-stream");var u=e("events").EventEmitter;var c=e("./file-stream");var l=e("inherits");var h=e("./mime.json");var d=e("multistream");var p=e("once");var g=e("path");var m=e("simple-sha1");var v=16*1024;var y=0;var _=1;var w=2;function b(){}l(k,u);function k(e,t,r,n){var i=this;u.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!n;if(typeof r==="number"){i.buffer=null;i.length=r}else{i.buffer=r;i.length=r.length}i._reset()}k.prototype.readBlock=function(e,t,r){var n=this;r=s(r);if(!n.buffer||!n._verifyOffset(e)){return r(new Error("invalid block offset "+e))}r(null,n.buffer.slice(e,e+t))};k.prototype.writeBlock=function(e,t,r){var n=this;r=s(r);if(!n._verifyOffset(e)||!n._verifyBlock(e,t)){return r(new Error("invalid block "+e+":"+t.length))}n._lazyAllocBuffer();var i=e/v;if(n.blocks[i]===w){return r(null)}t.copy(n.buffer,e);n.blocks[i]=w;n.blocksWritten+=1;if(n.blocksWritten===n.blocks.length){n.verify()}r(null)};k.prototype.reserveBlock=function(e){var t=this;var r=t.blocks.length;for(var n=0;n<r;n++){if(t.blocks[n]&&!e||t.blocks[n]===w){continue}t.blocks[n]=_;return{offset:n*v,length:n===r-1?t.length-n*v:v}}return null};k.prototype.cancelBlock=function(e){var t=this;if(!t._verifyOffset(e)){return false}var r=e/v;if(t.blocks[r]===_){t.blocks[r]=y}return true};k.prototype._reset=function(){var e=this;e.verified=false;e.blocks=new n(Math.ceil(e.length/v));e.blocks.fill(0);e.blocksWritten=0};k.prototype.verify=function(e){var t=this;e=e||t.buffer;if(t.verified||!e){return}if(t.noVerify){t.verified=true;r();return}m(e,function(e){t.verified=e===t.hash;r()});function r(){if(t.verified){t.emit("done")}else{t.emit("warning",new Error("piece "+t.index+" failed verification"));t._reset()}}};k.prototype._verifyOffset=function(e){var t=this;if(e%v===0){return true}else{t.emit("warning",new Error("invalid block offset "+e+", not multiple of "+v));return false}};k.prototype._verifyBlock=function(e,t){var r=this;if(t.length===v){return true}else if(t.length===r.length-e&&r.length-e<v){return true}else{r.emit("warning",new Error("invalid block size "+t.length));return false}};k.prototype._lazyAllocBuffer=function(){var e=this;if(!e.buffer){e.buffer=new n(e.length)}};l(E,u);function E(e,t,r,n){var i=this;u.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=r;i.pieceLength=n;i.done=false;i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})});i._checkDone()}E.prototype.select=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,r,false)}};E.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,r,false)}};E.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var r=new c(t,e);t.storage.emit("select",r.startPiece,r.endPiece,true,r.notify.bind(r));f(r,function(){t.storage.emit("deselect",r.startPiece,r.endPiece,true)});return r};E.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(r,n){if(r)return e(r);var i=h[g.extname(t.name).toLowerCase()];var o=i?new window.Blob([n],{type:i}):new window.Blob([n]);var a=window.URL.createObjectURL(o);e(null,a)})};E.prototype.getBuffer=function(e){var t=this;e=s(p(e));var r;if(t.storage.buffer){var i=function(){r=t.storage.buffer.slice(t.offset,t.offset+t.length);e(null,r)};if(t.done)i();else t.once("done",i)}else{r=new n(t.length);var o=0;t.createReadStream().on("data",function(e){e.copy(r,o);o+=e.length}).on("end",function(){e(null,r)}).on("error",e)}};E.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){r.nextTick(function(){e.emit("done")})}};l(x,u);function x(e,t){var r=this;u.call(r);if(!a.enabled)r.setMaxListeners(0);if(!t)t={};r.bitfield=new i(e.pieces.length);r.done=false;r.closed=false;r.readonly=true;if(!t.nobuffer){r.buffer=new n(e.length)}var o=r.pieceLength=e.pieceLength;var s=e.lastPieceLength;var f=e.pieces.length;r.pieces=e.pieces.map(function(e,n){var i=n*o;var a=i+(n===f-1?s:o);var u=r.buffer?r.buffer.slice(i,a):a-i;var c=new k(n,e,u,!!t.noVerify);c.on("done",r._onPieceDone.bind(r,c));return c});r.files=e.files.map(function(e){var t=e.offset;var n=t+e.length-1;var i=t/o|0;var a=n/o|0;var s=r.pieces.slice(i,a+1);var f=new E(r,e,s,o);f.on("done",r._onFileDone.bind(r,f));return f})}x.BLOCK_LENGTH=v;x.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];t=p(t||function(){});var n=0;var i=new d(e);var a=new o(r.pieceLength,{zeroPadding:false});i.on("error",f);r.once("done",u);i.pipe(a).on("data",s).on("error",f);function s(e){var t=n;n+=1;var i=0;var a=new o(v,{zeroPadding:false});a.on("data",s);a.on("end",f);function s(e){var n=i*v;i+=1;r.writeBlock(t,n,e)}function f(){u()}function u(){a.removeListener("data",s);a.removeListener("end",f)}a.end(e)}function f(e){c();t(e)}function u(){c();t(null)}function c(){i.removeListener("error",f);a.removeListener("data",s);a.removeListener("error",f);r.removeListener("done",u)}};Object.defineProperty(x.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*v)},0)}});Object.defineProperty(x.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var r=0,n=e.pieces.length;r<n;r++){t-=e.bitfield.get(r)}return t}});x.prototype.readBlock=function(e,t,r,n){var i=this;n=s(n);var o=i.pieces[e];if(!o)return n(new Error("invalid piece index "+e));o.readBlock(t,r,n)};x.prototype.writeBlock=function(e,t,r,n){var i=this;if(!n)n=b;n=s(n);if(i.readonly)return n(new Error("cannot write to readonly storage"));var o=i.pieces[e];if(!o)return n(new Error("invalid piece index "+e));o.writeBlock(t,r,n)};x.prototype.read=function(e,t,r,i){var o=this;if(typeof t==="function"){i=r;r=t;t=null}r=s(r);var a=o.pieces[e];if(!a){return r(new Error("invalid piece index "+e))}if(!a.verified&&!i){return r(new Error("Storage.read called on incomplete piece "+e))}var f=0;var u=a.length;if(t){f=t.offset||0;u=t.length||u}if(a.buffer){return r(null,a.buffer.slice(f,f+u))}var c=[];function l(){if(u<=0)return r(null,n.concat(c));var t=f;var i=Math.min(v,u);f+=i;u-=i;o.readBlock(e,t,i,function(e,t){if(e)return r(e);c.push(t);l()})}l()};x.prototype.reserveBlock=function(e,t){var r=this;var n=r.pieces[e];if(!n)return null;return n.reserveBlock(t)};x.prototype.cancelBlock=function(e,t){var r=this;var n=r.pieces[e];if(!n)return false;return n.cancelBlock(t)};x.prototype.remove=function(e){if(e)s(e)(null)};x.prototype.close=function(e){var t=this;t.closed=true;if(e)s(e)(null)};x.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)};x.prototype._onFileDone=function(e){var t=this;a("file done "+e.name);t.emit("file",e);t._checkDone()};x.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":2,"./mime.json":4,_process:53,bitfield:9,"block-stream2":33,buffer:46,debug:109,dezalgo:112,"end-of-stream":115,events:50,inherits:117,multistream:118,once:121,path:52,"simple-sha1":141}],7:[function(e,t,r){(function(r,n){t.exports=B;var i=e("addr-to-ip-port");var o=e("create-torrent");var a=e("debug")("webtorrent:torrent");var s=e("torrent-discovery");var f=e("events").EventEmitter;var u=e("fs");var c=e("simple-get");var l=e("inherits");var h=e("run-parallel");var d=e("parse-torrent");var p=e("re-emitter");var g=e("bittorrent-swarm");var m=e("uniq");var v=e("ut_metadata");var y=e("ut_pex");var _=e("./rarity-map");var w=e("./server");var b=e("./storage");var k=128*1024;var E=3e4;var x=5e3;var S=3*b.BLOCK_LENGTH;var A=.5;var I=1;var T=1e4;var C=2;function L(){}l(B,f);function B(e,t){var i=this;f.call(i);if(!a.enabled)i.setMaxListeners(0);a("new torrent");i.opts=t;i.client=t.client;i.hotswapEnabled="hotswap"in t?t.hotswap:true;i.verify=t.verify;i.chokeTimeout=t.chokeTimeout||x;i.pieceTimeout=t.pieceTimeout||E;i.strategy=t.strategy||"sequential";i._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;i._rechokeOptimisticWire=null;i._rechokeOptimisticTime=0;i._rechokeIntervalId=null;i.ready=false;i.destroyed=false;i.files=[];i.metadata=null;i.parsedTorrent=null;i.storage=null;i.numBlockedPeers=0;i._amInterested=false;i._selections=[];i._critical=[];i._storageImpl=t.storage||b;this._torrentFileURL=null;var s;try{s=e&&e.parsedTorrent||d(e)}catch(l){}if(s&&s.infoHash){h(s)}else if(typeof c==="function"&&/^https?:/.test(e)){c.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,t){if(e){e=new Error("Error downloading torrent: "+e.message);return i._onError(e)}h(t)})}else if(typeof u.readFile==="function"){u.readFile(e,function(e,t){if(e)return i._onError(new Error("Invalid torrent identifier"));h(t)})}else throw new Error("Invalid torrent identifier");function h(e){try{i.parsedTorrent=d(e)}catch(a){return i._onError(new Error("Malformed torrent data: "+a.message))}i.infoHash=i.parsedTorrent.infoHash;if(!i.infoHash){return i._onError(new Error("Malformed torrent data: Missing info hash."))}if(i.parsedTorrent.name)i.name=i.parsedTorrent.name;if(t.announce){i.parsedTorrent.announce.push.apply(i.parsedTorrent.announce,t.announce)}if(i.parsedTorrent.announce.length===0){i.parsedTorrent.announce=o.announceList.map(function(e){return e[0]})}if(n.WEBTORRENT_ANNOUNCE){n.WEBTORRENT_ANNOUNCE.forEach(function(e){i.parsedTorrent.announce.push(e)})}m(i.parsedTorrent.announce);i.swarm=new g(i.infoHash,i.client.peerId,{handshake:{dht:!!i.client.dht}});i.swarm.on("error",i._onError.bind(i));p(i.swarm,i,["warning"]);i.swarm.on("wire",i._onWire.bind(i));i.swarm.on("download",i.client.downloadSpeed.bind(i.client));i.swarm.on("upload",i.client.uploadSpeed.bind(i.client));i.swarm.listen(i.client.torrentPort,i._onSwarmListening.bind(i));r.nextTick(function(){i.emit("infoHash")})}}Object.defineProperty(B.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}});Object.defineProperty(B.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(B.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}});Object.defineProperty(B.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}});Object.defineProperty(B.prototype,"uploaded",{get:function(){return this.swarm.uploaded}});Object.defineProperty(B.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}});Object.defineProperty(B.prototype,"magnetURI",{get:function(){return d.toMagnetURI(this.parsedTorrent)}});Object.defineProperty(B.prototype,"torrentFile",{get:function(){return d.toTorrentFile(this.parsedTorrent)}});Object.defineProperty(B.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}});B.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)};B.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;a("got metadata");if(e&&e.infoHash){t.metadata=d.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;try{t.parsedTorrent=d(t.metadata)}catch(n){return t._onError(n)}}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new _(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){r.nextTick(function(){a("verifying existing torrent data");var e=0;var r=0;h(t.storage.pieces.map(function(n){return function(i){t.storage.read(n.index,function(o,s){e+=1;t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*r/t.storage.pieces.length});if(!o&&s){n.verify(s);r+=n.verified;a("piece "+(n.verified?"verified":"invalid")+" "+n.index)}i()},true)}}),t._onStorage.bind(t))})}else{r.nextTick(t._onStorage.bind(t))}r.nextTick(function(){t.emit("metadata")})};B.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 r=[];if(t.swarm)r.push(function(e){t.swarm.destroy(e)});if(t.discovery)r.push(function(e){t.discovery.stop(e)});if(t.storage)r.push(function(e){t.storage.close(e)});h(r,e)};B.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}};B.prototype.select=function(e,t,r,n){var i=this;if(e>t||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;a("select %s-%s (priority %s)",e,t,r);i._selections.push({from:e,to:t,offset:0,priority:r,notify:n||L});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};B.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;a("deselect %s-%s (priority %s)",e,t,r);for(var i=0;i<n._selections.length;++i){var o=n._selections[i];if(o.from===e&&o.to===t&&o.priority===r){n._selections.splice(i--,1);break}}n._updateSelections()};B.prototype.critical=function(e,t){var r=this;a("critical %s-%s",e,t);for(var n=e;n<=t;++n){r._critical[n]=true}r._updateSelections()};B.prototype._onWire=function(e,t){var r=this;a("got wire (%s)",t||"Unknown");if(t){var n=i(t);e.remoteAddress=n[0];e.remotePort=n[1]}e.use(v(r.metadata));if(!r.metadata){e.ut_metadata.on("metadata",function(e){a("got metadata via ut_metadata");r._onMetadata(e)});e.ut_metadata.fetch()}if(typeof y==="function"){e.use(y());e.ut_pex.on("peer",function(e){a("ut_pex: got peer: %s (from %s)",e,t);r.addPeer(e)});e.ut_pex.on("dropped",function(e){a("ut_pex: dropped peer: %s (from %s)",e,t);var n=r.swarm._peers[e];if(!n||!n.conn)r.swarm.removePeer(e)})}e.setKeepAlive(true);if(e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening){e.port(r.client.dht.address().port)}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);if(r.client.dht)r.client.dht.addNode(e.remoteAddress+":"+t)});e.on("timeout",function(){a("wire timeout (%s)",t);e.destroy()});e.setTimeout(r.pieceTimeout,true);if(r.metadata){r._onWireWithMetadata(e)}};B.prototype._onWireWithMetadata=function(e){var t=this;var r=null;var n=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{r=setTimeout(i,n);if(r.unref)r.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(r)});e.on("choke",function(){clearTimeout(r);r=setTimeout(i,n);if(r.unref)r.unref()});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,n,i,o){if(i>k){a("got invalid block size request %s (from %s)",i,e.remoteAddress+":"+e.remotePort);return e.destroy()}t.storage.readBlock(r,n,i,o)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(i,n);if(r.unref)r.unref();e.isSeeder=false;s()};B.prototype._onStorage=function(){var e=this;if(e.destroyed)return;a("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),T);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};B.prototype._onStoragePiece=function(e){var t=this;a("piece done %s",e.index);t._reservations[e.index]=null;t.swarm.wires.forEach(function(t){t.have(e.index)});t._gcSelections()};B.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));r.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};B.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var r=e._selections[t];var n=r.offset;while(e.storage.bitfield.get(r.from+r.offset)&&r.from+r.offset<r.to){r.offset++}if(n!==r.offset)r.notify();if(r.to!==r.from+r.offset)continue;if(!e.storage.bitfield.get(r.from+r.offset))continue;e._selections.splice(t--,1);r.notify();e._updateInterest()}if(!e._selections.length)e.emit("idle")};B.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")};B.prototype._update=function(){var e=this;if(e.destroyed)return;P(e.swarm.wires,e._updateWire.bind(e))};B.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return o();var r=R(e,A);if(e.requests.length>=r)return;var n=R(e,I);f(false)||f(true);function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var n=t._selections[r];var o;if(t.strategy==="rarest"){var a=n.from+n.offset;var s=n.to;var f=s-a+1;var u={};var c=0;var l=i(a,s,u);while(c<f){o=t.rarityMap.getRarestPiece(l);if(o<0)break;if(t._request(e,o,false))return;u[o]=true;c+=1}}else{for(o=n.to;o>=n.from+n.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function a(){var r=e.downloadSpeed()||1;if(r>S)return function(){return true};var n=Math.max(1,e.requests.length)*b.BLOCK_LENGTH/r;var i=10;var o=0;return function(e){if(!i||t.storage.bitfield.get(e))return true;var a=t.storage.pieces[e];var s=a.blocks.length-a.blocksWritten;for(;o<t.swarm.wires.length;o++){var f=t.swarm.wires[o];var u=f.downloadSpeed();if(u<S)continue;if(u<=r)continue;if(!f.peerPieces.get(e))continue;if((s-=u*n)>0)continue;i--;return false}return true}}function s(e){var r=e;for(var n=e;n<t._selections.length&&t._selections[n].priority;n++){r=n}var i=t._selections[e];t._selections[e]=t._selections[r];t._selections[r]=i}function f(r){if(e.requests.length>=n)return true;var o=a();for(var f=0;f<t._selections.length;f++){var u=t._selections[f];var c;if(t.strategy==="rarest"){var l=u.from+u.offset;var h=u.to;var d=h-l+1;var p={};var g=0;var m=i(l,h,p,o);while(g<d){c=t.rarityMap.getRarestPiece(m);if(c<0)break;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n){p[c]=true;g++;continue}if(u.priority)s(f);return true}}else{for(c=u.from+u.offset;c<=u.to;c++){if(!e.peerPieces.get(c)||!o(c))continue;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n)continue;if(u.priority)s(f);return true}}}return false}};B.prototype._rechoke=function(){var e=this;if(e._rechokeOptimisticTime>0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(r){if(!r.isSeeder&&r!==e._rechokeOptimisticWire){t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(a);var r=0;var n=0;for(;n<t.length&&r<e._rechokeNumSlots;++n){t[n].isChoked=false;if(t[n].wire.peerInterested)r+=1}if(!e._rechokeOptimisticWire&&n<t.length&&e._rechokeNumSlots){var i=t.slice(n).filter(function(e){return e.wire.peerInterested});var o=i[M(i.length)];if(o){o.isChoked=false;e._rechokeOptimisticWire=o.wire;e._rechokeOptimisticTime=C}}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}};B.prototype._hotswap=function(e,t){var r=this;if(!r.hotswapEnabled)return false;var n=e.downloadSpeed();if(n<b.BLOCK_LENGTH)return false;if(!r._reservations[t])return false;var i=r._reservations[t];if(!i){return false}var o=Infinity;var a;var s;for(s=0;s<i.length;s++){var f=i[s];if(!f||f===e)continue;var u=f.downloadSpeed();if(u>=S)continue;if(2*u>n||u>o)continue;a=f;o=u}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 c=a.requests[s];if(c.piece!==t)continue;r.storage.cancelBlock(t,c.offset)}r.emit("hotswap",a,e,t);return true};B.prototype._request=function(e,t,n){var i=this;var o=e.requests.length;if(i.storage.bitfield.get(t))return false;var s=R(e,I);if(o>=s)return false;var f=e.requests.length===0&&i.storage.numMissing<30;var u=i.storage.reserveBlock(t,f);if(!u&&!f&&n&&i._hotswap(e,t)){
+u=i.storage.reserveBlock(t,false)}if(!u)return false;var c=i._reservations[t];if(!c){c=i._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,o){if(!i.ready){i.once("ready",function(){h(n,o)});return}if(c[l]===e)c[l]=null;if(n){a("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort,n.message);i.storage.cancelBlock(t,u.offset);r.nextTick(i._update.bind(i));return false}else{a("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort);i.storage.writeBlock(t,u.offset,o,function(e){if(e){a("error writing block");i.storage.cancelBlock(t,u.offset)}r.nextTick(i._update.bind(i))})}}e.request(t,u.offset,u.length,h);return true};B.prototype.createServer=function(e){var t=this;if(typeof w==="function"){return new w(t,e)}};B.prototype._onError=function(e){var t=this;a("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function R(e,t){return Math.ceil(2+t*e.downloadSpeed()/b.BLOCK_LENGTH)}function M(e){return Math.random()*e|0}function P(e,t){var r=e.map(function(e,t){return t});for(var n=r.length-1;n>0;--n){var i=M(n+1);var o=r[n];r[n]=r[i];r[i]=o}r.forEach(function(r){t(e[r],r,e)})}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./rarity-map":5,"./server":45,"./storage":6,_process:53,"addr-to-ip-port":8,"bittorrent-swarm":10,"create-torrent":72,debug:109,events:50,fs:44,inherits:117,"parse-torrent":122,"re-emitter":136,"run-parallel":137,"simple-get":45,"torrent-discovery":144,uniq:181,ut_metadata:182,ut_pex:45}],8:[function(e,t,r){var n=/^\[?([^\]]+)\]?:(\d+)$/;var i={};var o=0;t.exports=function a(e){if(o===1e5)i={};if(!i[e]){var t=n.exec(e);if(!t)throw new Error("invalid addr: "+e);i[e]=[t[1],Number(t[2])];o+=1}return i[e]};t.exports.reset=function s(){i={}}},{}],9:[function(e,t,r){(function(e){var r=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var r=0;r<e;r++)t[r]=0};function n(e,t){if(!(this instanceof n)){return new n(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 r(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}n.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};n.prototype.set=function(e,t){var r=e>>3;if(t||arguments.length===1){if(this.buffer.length<r+1)this._grow(Math.max(r+1,Math.min(2*this.buffer.length,this.grow)));this.buffer[r]|=128>>e%8}else if(r<this.buffer.length){this.buffer[r]&=~(128>>e%8)}};n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new r(e);if(t.fill)t.fill(0);if(this.buffer.copy)this.buffer.copy(t,0);else{for(var n=0;n<this.buffer.length;n++){t[n]=this.buffer[n]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=n}).call(this,e("buffer").Buffer)},{buffer:46}],10:[function(e,t,r){(function(r,n){t.exports=g;var i=e("addr-to-ip-port");var o=e("debug")("bittorrent-swarm");var a=e("dezalgo");var s=e("events").EventEmitter;var f=e("inherits");var u=e("net");var c=e("./lib/peer");var l=e("speedometer");var h=e("./lib/tcp-pool");var d=55;var p=[1e3,5e3,15e3];f(g,s);function g(e,t,r){var i=this;if(!(i instanceof g))return new g(e,t,r);s.call(i);i.infoHash=typeof e==="string"?new n(e,"hex"):e;i.infoHashHex=i.infoHash.toString("hex");i.peerId=typeof t==="string"?new n(t,"hex"):t;i.peerIdHex=i.peerId.toString("hex");if(!r)r={};o("new swarm (i %s p %s)",i.infoHashHex,i.peerIdHex);i.handshakeOpts=r.handshake;i.maxConns=r.maxConns!==undefined?r.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=l();i.uploadSpeed=l()}Object.defineProperty(g.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(g.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(g.prototype,"numConns",{get:function(){var e=this;var t=0;for(var r in e._peers){var n=e._peers[r];if(n&&n.conn)t+=1}return t}});Object.defineProperty(g.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});g.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 r=e&&e.id||e;if(t._peers[r])return;o("addPeer %s",r);var n;if(typeof e==="string"){n=c.createOutgoingTCPPeer(e,t);t._queue.push(n);t._drain()}else{n=c.createWebRTCPeer(e,t)}t._peers[n.id]=n;t._peersLength+=1};g.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};g.prototype.removePeer=function(e){var t=this;var r=t._peers[e];if(!r)return;o("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;r.destroy()};g.prototype.pause=function(){var e=this;if(e.destroyed)return;o("pause");e.paused=true};g.prototype.resume=function(){var e=this;if(e.destroyed)return;o("resume");e.paused=false;e._drain()};g.prototype.listen=function(e,t,n){var i=this;if(typeof t==="function"){n=t;t=undefined}if(n)n=a(n);if(i.listening)throw new Error("swarm already listening");if(r.browser){n()}else{i._port=e||h.getDefaultListenPort(i.infoHashHex);i._hostname=t;if(n)i.once("listening",n);o("listen %s",e);var s=h.addSwarm(i);i.server=s.server}};g.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};g.prototype.address=function(){var e=this;return e.server.address()};g.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 r in t._peers){t.removePeer(r)}h.removeSwarm(t,function(){t.emit("close")})};g.prototype._drain=function(){var e=this;o("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof u.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 r=i(t.addr);var n=r[0];var a=r[1];var s=t.conn=u.connect({host:n,port:a,localAddress:e._hostname});s.once("connect",function(){t.onConnect()});s.once("error",function(e){t.destroy(e)});t.setConnectTimeout();s.on("close",function(){if(e.destroyed)return;if(t.retries>=p.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,p.length);return}function r(){var r=c.createOutgoingTCPPeer(t.addr,e);r.retries=t.retries+1;e._queue.push(r);e._drain()}var n=p[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var i=setTimeout(r,n);if(i.unref)i.unref()})};g.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};g.prototype._validAddr=function(e){var t=this;var r=i(e);var n=r[0];var o=r[1];return o>0&&o<65535&&!(n==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":11,"./lib/tcp-pool":12,_process:53,"addr-to-ip-port":45,buffer:46,debug:25,dezalgo:28,events:50,inherits:31,net:45,speedometer:32}],11:[function(e,t,r){var n=e("debug")("bittorrent-swarm:peer");var i=e("bittorrent-protocol");var o=25e3;var a=25e3;r.createWebRTCPeer=function(e,t){var r=new s(e.id);r.conn=e;r.swarm=t;if(r.conn.connected){r.onConnect()}else{r.conn.once("connect",function(){r.onConnect()});r.conn.once("error",function(e){r.destroy(e)});r.setConnectTimeout()}return r};r.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var r=new s(t);r.conn=e;r.addr=t;r.onConnect();return r};r.createOutgoingTCPPeer=function(e,t){var r=new s(e);r.swarm=t;r.addr=e;return r};function s(e){var t=this;t.id=e;n("new Peer %s",e);t.addr=null;t.conn=null;t.swarm=null;t.wire=null;t.destroyed=false;t.timeout=null;t.retries=0;t.sentHandshake=false}s.prototype.onConnect=function(){var e=this;n("Peer %s connected",e.id);clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()});t.once("close",function(){e.destroy()});t.once("finish",function(){e.destroy()});t.once("error",function(t){e.destroy(t)});var r=e.wire=new i;r.once("end",function(){e.destroy()});r.once("finish",function(){e.destroy()});r.once("error",function(t){e.destroy(t)});r.once("handshake",function(t,r){e.onHandshake(t,r)});e.setHandshakeTimeout();t.pipe(r).pipe(t);if(e.swarm)e.handshake()};s.prototype.onHandshake=function(e,t){var r=this;if(!r.swarm)return;var i=e.toString("hex");var o=t.toString("hex");if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(i!==r.swarm.infoHashHex){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(o===r.swarm.peerIdHex){return r.destroy(new Error("refusing to handshake with self"))}n("Peer %s got handshake %s",r.id,i);clearTimeout(r.handshakeTimeout);r.retries=0;r.wire.on("download",function(e){r.swarm.downloaded+=e;r.swarm.downloadSpeed(e);r.swarm.emit("download",e)});r.wire.on("upload",function(e){r.swarm.uploaded+=e;r.swarm.uploadSpeed(e);r.swarm.emit("upload",e)});if(!r.sentHandshake)r.handshake();r.swarm.wires.push(r.wire);var a=r.addr;if(!a&&r.conn.remoteAddress){a=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,a)};s.prototype.handshake=function(){var e=this;e.wire.handshake(e.swarm.infoHash,e.swarm.peerId,e.swarm.handshakeOpts);e.sentHandshake=true};s.prototype.setConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout);e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},o);if(e.connectTimeout.unref)e.connectTimeout.unref()};s.prototype.setHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout);e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},a);if(e.handshakeTimeout.unref)e.handshakeTimeout.unref()};s.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;n("destroy Peer %s (error: %s)",t.id,e&&(e.message||e));t.swarm.wires.splice(t.swarm.wires.indexOf(t.wire),1);if(t.conn)t.conn.destroy();if(t.wire)t.wire.destroy();if(t.swarm){t.swarm.removePeer(t.id);t.swarm._drain()}clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);t.conn=null;t.swarm=null;t.wire=null}},{"bittorrent-protocol":13,debug:25}],12:[function(e,t,r){(function(r){t.exports=f;var n=e("debug")("bittorrent-swarm:tcp-pool");var i=e("dezalgo");var o=e("net");var a=e("./peer");var s={};function f(e,t){var r=this;r.port=e;r.listening=false;r.swarms={};n("new TCPPool (port: %s, hostname: %s)",e,t);r.pendingConns=[];r.server=o.createServer();r.server.on("connection",function(e){r._onConnection(e)});r.server.on("error",function(e){r._onError(e)});r.server.on("listening",function(){r._onListening()});r.server.listen(r.port,t)}f.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new f(e._port,e._hostname);t.addSwarm(e);return t};f.removeSwarm=function(e,t){var n=s[e._port];if(!n)return t();n.removeSwarm(e);var i=0;for(var o in n.swarms){var a=n.swarms[o];if(a)i+=1}if(i===0)n.destroy(t);else r.nextTick(t)};f.getDefaultListenPort=function(e){for(var t in s){var r=s[t];if(r&&!r.swarms[e])return r.port}return 0};f.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}n("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};f.prototype.removeSwarm=function(e){var t=this;n("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};f.prototype.destroy=function(e){var t=this;if(e)e=i(e);n("destroy tcp pool %s",t.port);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});s[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};f.prototype._onListening=function(){var e=this;var t=e.server.address().port;n("tcp pool listening on %s",t);if(t!==e.port){s[e.port]=null;e.port=t;s[e.port]=e}e.listening=true;for(var r in e.swarms){var i=e.swarms[r];if(i)i._onListening(e.port)}};f.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var n=a.createIncomingTCPPeer(e);n.wire.once("handshake",function(i,o){var a=i.toString("hex");r();e.removeListener("close",r);var s=t.swarms[a];if(s){n.swarm=s;s._addIncomingPeer(n);n.onHandshake(i,o)}else{var f=new Error("Unexpected info hash "+a+" from incoming peer "+n.id+": destroying peer");n.destroy(f)}})};f.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var n=t.swarms[r];if(n){t.removeSwarm(n);n._onError(e)}}}}).call(this,e("_process"))},{"./peer":11,_process:53,debug:25,dezalgo:28,net:45}],13:[function(e,t,r){(function(r){t.exports=w;var n=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var a=e("xtend");var s=e("inherits");var f=e("speedometer");var u=e("stream");var c=4e5;var l=new r("BitTorrent protocol");var h=new r([0,0,0,0]);var d=new r([0,0,0,1,0]);var p=new r([0,0,0,1,1]);var g=new r([0,0,0,1,2]);var m=new r([0,0,0,1,3]);var v=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function _(e,t,r,n){this.piece=e;this.offset=t;this.length=r;this.callback=n}s(w,u.Duplex);function w(){if(!(this instanceof w))return new w;u.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=f();this.downloadSpeed=f();this._keepAlive=null;this._timeout=null;this._timeoutMs=0;this.destroyed=false;this._finished=false;this._buffer=[];this._bufferSize=0;this._parser=null;this._parserSize=0;this.on("finish",this._onfinish);this._parseHandshake()}w.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,h),6e4)};w.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};w.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;o("destroy");this.end()};w.prototype.end=function(){this._onUninterested();this._onChoke();u.Duplex.prototype.end.apply(this,arguments)};w.prototype.use=function(e){var t=e.prototype.name;if(!t){throw new Error("Extension API requires a named function, e.g. function name() {}")}var r=this._nextExt;var n=new e(this);function i(){}if(typeof n.onHandshake!=="function"){n.onHandshake=i}if(typeof n.onExtendedHandshake!=="function"){n.onExtendedHandshake=i}if(typeof n.onMessage!=="function"){n.onMessage=i}this.extendedMapping[r]=t;this._ext[t]=n;this[t]=n;this._nextExt+=1};w.prototype.handshake=function(e,t,n){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new r(v);i[5]|=16;if(n&&n.dht)i[7]|=1;this._push(r.concat([l,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=a(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};w.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(p)};w.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(g)};w.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(m)};w.prototype.have=function(e){this._message(4,[e],null)};w.prototype.bitfield=function(e){if(!r.isBuffer(e))e=e.buffer;this._message(5,[],e)};w.prototype.request=function(e,t,r,n){if(!n)n=function(){};if(this._finished)return n(new Error("wire is closed"));if(this.peerChoking)return n(new Error("peer is choking"));this.requests.push(new _(e,t,r,n));this._updateTimeout();this._message(6,[e,t,r],null)};w.prototype.piece=function(e,t,r){this.uploaded+=r.length;this.uploadSpeed(r.length);this.emit("upload",r.length);this._message(7,[e,t],r)};w.prototype.cancel=function(e,t,r){this._callback(b(this.requests,e,t,r),new Error("request was cancelled"),null);this._message(8,[e,t,r],null)};w.prototype.port=function(e){var t=new r(y);t.writeUInt16BE(e,5);this._push(t)};w.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var n=new r([e]);var o=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,o]))}else{throw new Error("Unrecognized extension: "+e)}};w.prototype._onKeepAlive=function(){this.emit("keep-alive")};w.prototype._onHandshake=function(e,t,r){this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var n;for(n in this._ext){this._ext[n].onHandshake(e,t,r)}if(r.extended&&this._handshakeSent){this._sendExtendedHandshake()}};w.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};w.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};w.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};w.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};w.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};w.prototype._onBitField=function(e){this.peerPieces=new n(e);this.emit("bitfield",this.peerPieces)};w.prototype._onRequest=function(e,t,r){if(this.amChoking)return;var n=function(n,o){if(i!==b(this.peerRequests,e,t,r))return;if(n)return;this.piece(e,t,o)}.bind(this);var i=new _(e,t,r,n);this.peerRequests.push(i);this.emit("request",e,t,r,n)};w.prototype._onPiece=function(e,t,r){this._callback(b(this.requests,e,t,r.length),null,r);this.downloaded+=r.length;this.downloadSpeed(r.length);this.emit("download",r.length);this.emit("piece",e,t,r)};w.prototype._onCancel=function(e,t,r){b(this.peerRequests,e,t,r);this.emit("cancel",e,t,r)};w.prototype._onPort=function(e){this.emit("port",e)};w.prototype._onExtended=function(e,t){var r,n;if(e===0&&(r=k(t))){this.peerExtendedHandshake=r;if(typeof r.m==="object"){for(n in r.m){this.peerExtendedMapping[n]=Number(r.m[n].toString())}}for(n in this._ext){if(this.peerExtendedMapping[n]){this._ext[n].onExtendedHandshake(this.peerExtendedHandshake)}}this.emit("extended","handshake",this.peerExtendedHandshake)}else{if(this.extendedMapping[e]){e=this.extendedMapping[e];if(this._ext[e]){this._ext[e].onMessage(t)}}this.emit("extended",e,t)}};w.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};w.prototype._push=function(e){if(this._finished)return;return this.push(e)};w.prototype._write=function(e,t,n){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}n(null)};w.prototype._read=function(){};w.prototype._callback=function(e,t,r){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,r)};w.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};w.prototype._updateTimeout=function(){if(!this._timeoutMs||!this.requests.length||this._timeout)return;this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs);if(this._timeoutUnref&&this._timeout.unref)this._timeout.unref()};w.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};w.prototype._message=function(e,t,n){var i=n?n.length:0;var o=new r(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var a=0;a<t.length;a++){o.writeUInt32BE(t[a],5+4*a)}this._push(o);if(n)this._push(n)};w.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)}};w.prototype._onmessage=function(e){this._parse(4,this._onmessagelength);switch(e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this.emit("unknownmessage",e)}};w.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var r=e.slice(0,t);if(r.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",r.toString());this.end();return}e=e.slice(t);this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(e[7]&1),extended:!!(e[5]&16)});this._parse(4,this._onmessagelength)}.bind(this))}.bind(this))};w.prototype._onfinish=function(){this._finished=true;this.push(null);while(this.read()){}clearInterval(this._keepAlive);this._parse(Number.MAX_VALUE,function(){});this.peerRequests=[];while(this.requests.length){this._callback(this.requests.shift(),new Error("wire was closed"),null)}};function b(e,t,r,n){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece!==t||o.offset!==r||o.length!==n)continue;if(i===0)e.shift();else e.splice(i,1);return o}return null}function k(e){try{return i.decode(e)}catch(t){console.warn(t)}}}).call(this,e("buffer").Buffer)},{bencode:14,bitfield:18,buffer:46,debug:19,inherits:22,speedometer:23,stream:69,xtend:24}],14:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":15,"./lib/encode":17}],15:[function(e,t,r){(function(r){var n=e("./dict");function i(e,t){i.position=0;i.encoding=t||null;i.data=!r.isBuffer(e)?new r(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 r=i.data.length;var n=i.data;while(t<r){if(n[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 n;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 r=++e+t;i.position=r;return i.encoding?i.data.toString(i.encoding,e,r):i.data.slice(e,r)};t.exports=i}).call(this,e("buffer").Buffer)},{"./dict":16,buffer:46}],16:[function(e,t,r){var n=t.exports=function i(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};n.prototype.binaryKeys=function o(){return this._keys.slice()};n.prototype.binarySet=function a(e,t){this._keys.push(e);this[e]=t}},{}],17:[function(e,t,r){(function(e){function r(t){var n=[];r._encode(n,t);return e.concat(n)}r._floatConversionDetected=false;r._encode=function(t,n){if(e.isBuffer(n)){t.push(new e(n.length+":"));t.push(n);return}switch(typeof n){case"string":r.bytes(t,n);break;case"number":r.number(t,n);break;case"object":n.constructor===Array?r.list(t,n):r.dict(t,n);break}};var n=new e("e"),i=new e("d"),o=new e("l");r.bytes=function(t,r){t.push(new e(e.byteLength(r)+":"+r))};r.number=function(t,n){var i=2147483648;var o=n/i<<0;var a=n%i<<0;var s=o*i+a;t.push(new e("i"+s+"e"));if(s!==n&&!r._floatConversionDetected){r._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+n+'":','Bencoding only defines support for integers, value was converted to "'+s+'"');console.trace()}};r.dict=function(e,t){e.push(i);var o=0;var a;var s=Object.keys(t).sort();var f=s.length;for(;o<f;o++){a=s[o];r.bytes(e,a);r._encode(e,t[a])}e.push(n)};r.list=function(e,t){var i=0,a=1;var s=t.length;e.push(o);for(;i<s;i++){r._encode(e,t[i])}e.push(n)};t.exports=r}).call(this,e("buffer").Buffer)},{buffer:46}],18:[function(e,t,r){arguments[4][9][0].apply(r,arguments)},{buffer:46,dup:9}],19:[function(e,t,r){r=t.exports=e("./debug");r.log=a;r.formatArgs=o;r.save=s;r.load=f;r.useColors=i;var n;if(typeof chrome!=="undefined"&&typeof chrome.storage!=="undefined")n=chrome.storage.local;else n=u();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function i(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function o(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function a(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{if(null==e){n.removeItem("debug")}else{n.debug=e}}catch(t){}}function f(){var e;try{e=n.debug}catch(t){}return e}r.enable(f());function u(){try{return window.localStorage}catch(e){}}},{"./debug":20}],20:[function(e,t,r){r=t.exports=a;r.coerce=c;r.disable=f;r.enable=s;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var n=0;var i;function o(){return r.colors[n++%r.colors.length]}function a(e){function t(){}t.enabled=false;function n(){var e=n;var t=+new Date;var a=t-(i||t);e.diff=a;e.prev=i;e.curr=t;i=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=o();var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]);if("string"!==typeof s[0]){s=["%o"].concat(s)}var f=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,n){if(t==="%%")return t;f++;var i=r.formatters[n];if("function"===typeof i){var o=s[f];t=i.call(e,o);s.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){s=r.formatArgs.apply(e,s)}var u=n.log||r.log||console.log.bind(console);u.apply(e,s)}n.enabled=true;var a=r.enabled(e)?n:t;a.namespace=e;return a}function s(e){r.save(e);var t=(e||"").split(/[\s,]+/);var n=t.length;for(var i=0;i<n;i++){if(!t[i])continue;e=t[i].replace(/\*/g,".*?");if(e[0]==="-"){r.skips.push(new RegExp("^"+e.substr(1)+"$"))}else{r.names.push(new RegExp("^"+e+"$"))}}}function f(){r.enable("")}function u(e){var t,n;for(t=0,n=r.skips.length;t<n;t++){if(r.skips[t].test(e)){return false}}for(t=0,n=r.names.length;t<n;t++){if(r.names[t].test(e)){return true}}return false}function c(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:21}],21:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var a=o*24;var s=a*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*s;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+r;return Math.ceil(e/t)+" "+r+"s"}},{}],22:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function n(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 r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],23:[function(e,t,r){var n=1;var i=65535;var o=4;var a=function(){n=n+1&i};var s=setInterval(a,1e3/o|0);if(s.unref)s.unref();t.exports=function(e){var t=o*(e||5);var r=[0];var a=1;var s=n-1&i;return function(e){var f=n-s&i;if(f>t)f=t;s=n;while(f--){if(a===t)a=0;r[a]=r[a===0?t-1:a-1];a++}if(e)r[a-1]+=e;var u=r[a-1];var c=r.length<t?0:r[a===t?0:a];return r.length<o?u:(u-c)*o/r.length}}},{}],24:[function(e,t,r){t.exports=n;function n(){var e={};for(var t=0;t<arguments.length;t++){var r=arguments[t];for(var n in r){if(r.hasOwnProperty(n)){e[n]=r[n]}}}return e}},{}],25:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{"./debug":26,dup:19}],26:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,ms:27}],27:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],28:[function(e,t,r){var n=e("wrappy");t.exports=n(o);var i=e("asap");function o(e){var t=true;i(function(){t=false});return function r(){var r=arguments;var n=this;if(t)i(function(){e.apply(n,r)});else e.apply(n,r)}}},{asap:29,wrappy:30}],29:[function(e,t,r){(function(e){var r={task:void 0,next:null};var n=r;var i=false;var o=void 0;var a=false;function s(){while(r.next){r=r.next;var e=r.task;r.task=void 0;var t=r.domain;if(t){r.domain=void 0;t.enter()}try{e()}catch(n){if(a){if(t){t.exit()}setTimeout(s,0);if(t){t.enter()}throw n}else{setTimeout(function(){throw n},0)}}if(t){t.exit()}}i=false}if(typeof e!=="undefined"&&e.nextTick){a=true;o=function(){e.nextTick(s)}}else if(typeof setImmediate==="function"){if(typeof window!=="undefined"){o=setImmediate.bind(window,s)}else{o=function(){setImmediate(s)}}}else if(typeof MessageChannel!=="undefined"){var f=new MessageChannel;f.port1.onmessage=s;o=function(){f.port2.postMessage(0)}}else{o=function(){setTimeout(s,0)}}function u(t){n=n.next={task:t,domain:a&&e.domain,next:null};if(!i){i=true;o()}}t.exports=u}).call(this,e("_process"))},{_process:53}],30:[function(e,t,r){t.exports=n;function n(e,t){if(e&&t)return n(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){r[t]=e[t]});return r;function r(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var n=e.apply(this,t);var i=t[t.length-1];
+if(typeof n==="function"&&n!==i){Object.keys(i).forEach(function(e){n[e]=i[e]})}return n}}},{}],31:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],32:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],33:[function(e,t,r){(function(r){var n=e("inherits");var i=e("readable-stream").Transform;var o=e("defined");t.exports=a;n(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,n){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var i=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}n()};a.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new r(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(r.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(r.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:46,defined:34,inherits:117,"readable-stream":43}],34:[function(e,t,r){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],35:[function(e,t,r){(function(r){t.exports=s;var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);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);u(n(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",f)}function f(){if(this.allowHalfOpen||this._writableState.ended)return;r.nextTick(this.end.bind(this))}function u(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}}).call(this,e("_process"))},{"./_stream_readable":37,"./_stream_writable":39,_process:53,"core-util-is":40,inherits:117}],36:[function(e,t,r){t.exports=o;var n=e("./_stream_transform");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(o,n);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}o.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":38,"core-util-is":40,inherits:117}],37:[function(e,t,r){(function(r){t.exports=c;var n=e("isarray");var i=e("buffer").Buffer;c.ReadableState=u;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 f;s.inherits(c,a);function u(t,r){t=t||{};var n=t.highWaterMark;this.highWaterMark=n||n===0?n:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function c(e){if(!(this instanceof c))return new c(e);this._readableState=new u(e,this);this.readable=true;a.call(this)}c.prototype.push=function(e,t){var r=this._readableState;if(typeof e==="string"&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new i(e,t);t=""}}return l(this,r,e,t,false)};c.prototype.unshift=function(e){var t=this._readableState;return l(this,t,e,"",true)};function l(e,t,r,n,i){var o=m(t,r);if(o){e.emit("error",o)}else if(r===null||r===undefined){t.reading=false;if(!t.ended)v(e,t)}else if(t.objectMode||r&&r.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&&!n)r=t.decoder.write(r);t.length+=t.objectMode?1:r.length;if(i){t.buffer.unshift(r)}else{t.reading=false;t.buffer.push(r)}if(t.needReadable)y(e);w(e,t)}}else if(!i){t.reading=false}return h(t)}function h(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}c.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t};var d=8388608;function p(e){if(e>=d){e=d}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function g(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(e===null||isNaN(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=p(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}c.prototype.read=function(e){var t=this._readableState;t.calledRead=true;var r=e;var n;if(typeof e!=="number"||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){y(this);return null}e=g(e,t);if(e===0&&t.ended){n=null;if(t.length>0&&t.decoder){n=A(e,t);t.length-=n.length}if(t.length===0)I(this);return n}var i=t.needReadable;if(t.length-e<=t.highWaterMark)i=true;if(t.ended||t.reading)i=false;if(i){t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=g(r,t);if(e>0)n=A(e,t);else n=null;if(n===null){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(t.ended&&!t.endEmitted&&t.length===0)I(this);return n};function m(e,t){var r=null;if(!i.isBuffer(t)&&"string"!==typeof t&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function v(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;if(t.length>0)y(e);else I(e)}function y(e){var t=e._readableState;t.needReadable=false;if(t.emittedReadable)return;t.emittedReadable=true;if(t.sync)r.nextTick(function(){_(e)});else _(e)}function _(e){e.emit("readable")}function w(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){b(e,t)})}}function b(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}c.prototype._read=function(e){this.emit("error",new Error("not implemented"))};c.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;var s=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=s?c:h;if(a.endEmitted)r.nextTick(f);else i.once("end",f);e.on("unpipe",u);function u(e){if(e!==i)return;h()}function c(){e.end()}var l=k(i);e.on("drain",l);function h(){e.removeListener("close",p);e.removeListener("finish",g);e.removeListener("drain",l);e.removeListener("error",d);e.removeListener("unpipe",u);i.removeListener("end",c);i.removeListener("end",h);if(!e._writableState||e._writableState.needDrain)l()}function d(t){m();e.removeListener("error",d);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",d);else if(n(e._events.error))e._events.error.unshift(d);else e._events.error=[d,e._events.error];function p(){e.removeListener("finish",g);m()}e.once("close",p);function g(){e.removeListener("close",p);m()}e.once("finish",g);function m(){i.unpipe(e)}e.emit("pipe",i);if(!a.flowing){this.on("readable",x);a.flowing=true;r.nextTick(function(){E(i)})}return e};function k(e){return function(){var t=this;var r=e._readableState;r.awaitDrain--;if(r.awaitDrain===0)E(e)}}function E(e){var t=e._readableState;var r;t.awaitDrain=0;function n(e,n,i){var o=e.write(r);if(false===o){t.awaitDrain++}}while(t.pipesCount&&null!==(r=e.read())){if(t.pipesCount===1)n(t.pipes,0,null);else T(t.pipes,n);e.emit("data",r);if(t.awaitDrain>0)return}if(t.pipesCount===0){t.flowing=false;if(o.listenerCount(e,"data")>0)S(e);return}t.ranOut=true}function x(){if(this._readableState.ranOut){this._readableState.ranOut=false;E(this)}}c.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=C(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};c.prototype.on=function(e,t){var r=a.prototype.on.call(this,e,t);if(e==="data"&&!this._readableState.flowing)S(this);if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){this.read(0)}else if(n.length){y(this,n)}}}return r};c.prototype.addListener=c.prototype.on;c.prototype.resume=function(){S(this);this.read(0);this.emit("resume")};c.prototype.pause=function(){S(this,true);this.emit("pause")};function S(e,t){var n=e._readableState;if(n.flowing){throw new Error("Cannot switch to old mode now.")}var i=t||false;var o=false;e.readable=true;e.pipe=a.prototype.pipe;e.on=e.addListener=a.prototype.on;e.on("readable",function(){o=true;var t;while(!i&&null!==(t=e.read()))e.emit("data",t);if(t===null){o=false;e._readableState.needReadable=true}});e.pause=function(){i=true;this.emit("pause")};e.resume=function(){i=false;if(o)r.nextTick(function(){e.emit("readable")});else this.read(0);this.emit("resume")};e.emit("readable")}c.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){if(t.decoder)i=t.decoder.write(i);if(t.objectMode&&(i===null||i===undefined))return;else if(!t.objectMode&&(!i||!i.length))return;var o=n.push(i);if(!o){r=true;e.pause()}});for(var i in e){if(typeof e[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var o=["error","close","destroy","pause","resume"];T(o,function(t){e.on(t,n.emit.bind(n,t))});n._read=function(t){if(r){r=false;e.resume()}};return n};c._fromList=A;function A(e,t){var r=t.buffer;var n=t.length;var o=!!t.decoder;var a=!!t.objectMode;var s;if(r.length===0)return null;if(n===0)s=null;else if(a)s=r.shift();else if(!e||e>=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e<r[0].length){var f=r[0];s=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){s=r.shift()}else{if(o)s="";else s=new i(e);var u=0;for(var c=0,l=r.length;c<l&&u<e;c++){var f=r[0];var h=Math.min(e-u,f.length);if(o)s+=f.slice(0,h);else f.copy(s,u,0,h);if(h<f.length)r[0]=f.slice(h);else r.shift();u+=h}}}return s}function I(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted&&t.calledRead){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function T(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}function C(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{_process:53,buffer:46,"core-util-is":40,events:50,inherits:117,isarray:41,stream:69,"string_decoder/":42}],38:[function(e,t,r){t.exports=s;var n=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(s,n);function o(e,t){this.afterTransform=function(e,r){return a(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,r){var n=e._transformState;n.transforming=false;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(r!==null&&r!==undefined)e.push(r);if(i)i(t);var o=e._readableState;o.reading=false;if(o.needReadable||o.length<o.highWaterMark){e._read(o.highWaterMark)}}function s(e){if(!(this instanceof s))return new s(e);n.call(this,e);var t=this._transformState=new o(e,this);var r=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("finish",function(){if("function"===typeof this._flush)this._flush(function(e){f(r,e)});else f(r)})}s.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};s.prototype._transform=function(e,t,r){throw new Error("not implemented")};s.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};s.prototype._read=function(e){var t=this._transformState;if(t.writechunk!==null&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._readableState;var i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":35,"core-util-is":40,inherits:117}],39:[function(e,t,r){(function(r){t.exports=f;var n=e("buffer").Buffer;f.WritableState=s;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(f,o);function a(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function s(e,t){e=e||{};var r=e.highWaterMark;this.highWaterMark=r||r===0?r:16*1024;this.objectMode=!!e.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var n=e.decodeStrings===false;this.decodeStrings=!n;this.defaultEncoding=e.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){m(t,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new s(t,this);this.writable=true;o.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,n){var i=new Error("write after end");e.emit("error",i);r.nextTick(function(){n(i)})}function c(e,t,i,o){var a=true;if(!n.isBuffer(i)&&"string"!==typeof i&&i!==null&&i!==undefined&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);r.nextTick(function(){o(s)});a=false}return a}f.prototype.write=function(e,t,r){var i=this._writableState;var o=false;if(typeof t==="function"){r=t;t=null}if(n.isBuffer(e))t="buffer";else if(!t)t=i.defaultEncoding;if(typeof r!=="function")r=function(){};if(i.ended)u(this,i,r);else if(c(this,i,e,r))o=h(this,i,e,t,r);return o};function l(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=new n(t,r)}return t}function h(e,t,r,i,o){r=l(t,r,i);if(n.isBuffer(r))i="buffer";var s=t.objectMode?1:r.length;t.length+=s;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing)t.buffer.push(new a(r,i,o));else d(e,t,s,r,i,o);return f}function d(e,t,r,n,i,o){t.writelen=r;t.writecb=o;t.writing=true;t.sync=true;e._write(n,i,t.onwrite);t.sync=false}function p(e,t,n,i,o){if(n)r.nextTick(function(){o(i)});else o(i);e._writableState.errorEmitted=true;e.emit("error",i)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function m(e,t){var n=e._writableState;var i=n.sync;var o=n.writecb;g(n);if(t)p(e,n,i,t,o);else{var a=w(e,n);if(!a&&!n.bufferProcessing&&n.buffer.length)_(e,n);if(i){r.nextTick(function(){v(e,n,a,o)})}else{v(e,n,a,o)}}}function v(e,t,r,n){if(!r)y(e,t);n();if(r)b(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;for(var r=0;r<t.buffer.length;r++){var n=t.buffer[r];var i=n.chunk;var o=n.encoding;var a=n.callback;var s=t.objectMode?1:i.length;d(e,t,s,i,o,a);if(t.writing){r++;break}}t.bufferProcessing=false;if(r<t.buffer.length)t.buffer=t.buffer.slice(r);else t.buffer.length=0}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype.end=function(e,t,r){var n=this._writableState;if(typeof e==="function"){r=e;e=null;t=null}else if(typeof t==="function"){r=t;t=null}if(typeof e!=="undefined"&&e!==null)this.write(e,t);if(!n.ending&&!n.finished)k(this,n,r)};function w(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function b(e,t){var r=w(e,t);if(r){t.finished=true;e.emit("finish")}return r}function k(e,t,n){t.ending=true;b(e,t);if(n){if(t.finished)r.nextTick(n);else e.once("finish",n)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":35,_process:53,buffer:46,"core-util-is":40,inherits:117,stream:69}],40:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function a(e){return typeof e==="number"}r.isNumber=a;function s(e){return typeof e==="string"}r.isString=s;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return l(e)&&v(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function h(e){return l(e)&&v(e)==="[object Date]"}r.isDate=h;function d(e){return l(e)&&(v(e)==="[object Error]"||e instanceof Error)}r.isError=d;function p(e){return typeof e==="function"}r.isFunction=p;function g(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=g;function m(t){return e.isBuffer(t)}r.isBuffer=m;function v(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:46}],41:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],42:[function(e,t,r){var n=e("buffer").Buffer;var i=n.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=r.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=f;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=u;break;default:this.write=s;return}this.charBuffer=new n(6);this.charReceived=0;this.charLength=0};a.prototype.write=function(e){var t="";while(this.charLength){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,r);this.charReceived+=r;if(this.charReceived<this.charLength){return""}e=e.slice(r,e.length);t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(n>=55296&&n<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var i=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,i);i-=this.charReceived}t+=e.toString(this.encoding,0,i);var i=t.length-1;var n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);e.copy(this.charBuffer,0,0,o);return t.substring(0,i)}return t};a.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t};a.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function s(e){return e.toString(this.encoding)}function f(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:46}],43:[function(e,t,r){var n=e("stream");r=t.exports=e("./lib/_stream_readable.js");r.Stream=n;r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":35,"./lib/_stream_passthrough.js":36,"./lib/_stream_readable.js":37,"./lib/_stream_transform.js":38,"./lib/_stream_writable.js":39,stream:69}],44:[function(e,t,r){},{}],45:[function(e,t,r){arguments[4][44][0].apply(r,arguments)},{dup:44}],46:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=_;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var a=1073741823;var s={};f.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0);var t=new Uint8Array(e);t.foo=function(){return 42};return t.foo()===42&&typeof t.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(r){return false}}();function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return c(this,e,arguments.length>1?arguments[1]:"utf8")}return l(this,e)}function u(e,t){e=v(e,t<0?0:y(t)|0);if(!f.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;r++){e[r]=0}}return e}function c(e,t,r){if(typeof r!=="string"||r==="")r="utf8";var n=w(t,r)|0;e=v(e,n);e.write(t,r);return e}function l(e,t){if(f.isBuffer(t))return h(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 p(e,t)}if(t.length)return g(e,t);return m(e,t)}function h(e,t){var r=y(t.length)|0;e=v(e,r);t.copy(e,0,0,r);return e}function d(e,t){var r=y(t.length)|0;e=v(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function p(e,t){var r=y(t.length)|0;e=v(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function g(e,t){var r=y(t.length)|0;e=v(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function m(e,t){var r;var n=0;if(t.type==="Buffer"&&o(t.data)){r=t.data;n=y(r.length)|0}e=v(e,n);for(var i=0;i<n;i+=1){e[i]=r[i]&255}return e}function v(e,t){if(f.TYPED_ARRAY_SUPPORT){e=f._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var r=t!==0&&t<=f.poolSize>>>1;if(r)e.parent=s;return e}function y(e){if(e>=a){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+a.toString(16)+" bytes")}return e|0}function _(e,t){if(!(this instanceof _))return new _(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function X(e){return!!(e!=null&&e._isBuffer)};f.compare=function Q(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;var i=0;var o=Math.min(r,n);while(i<o){if(e[i]!==t[i])break;++i}if(i!==o){r=e[i];n=t[i]}if(r<n)return-1;if(n<r)return 1;return 0};f.isEncoding=function Z(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}};f.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 f(0)}else if(e.length===1){return e[0]}var r;if(t===undefined){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var n=new f(t);var i=0;for(r=0;r<e.length;r++){var a=e[r];a.copy(n,i);i+=a.length}return n};function w(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 $(e).length;default:return e.length}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function te(e,t,r){var n=false;t=t|0;r=r===undefined||r===Infinity?this.length:r|0;if(!e)e="utf8";if(t<0)t=0;if(r>this.length)r=this.length;if(r<=t)return"";while(true){switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return C(this,t,r);case"binary":return L(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function re(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function ne(){var e="";var t=r.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return"<Buffer "+e+">"};f.prototype.compare=function ie(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function oe(e,t){if(t>2147483647)t=2147483647;else if(t<-2147483648)t=-2147483648;t>>=0;if(this.length===0)return-1;if(t>=this.length)return-1;if(t<0)t=Math.max(this.length+t,0);if(typeof e==="string"){if(e.length===0)return-1;return String.prototype.indexOf.call(this,e,t)}if(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var n=-1;for(var i=0;r+i<e.length;i++){if(e[r+i]===t[n===-1?0:i-n]){if(n===-1)n=i;if(i-n+1===t.length)return r+n}else{n=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};f.prototype.get=function ae(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function se(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function b(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(n>o/2){n=o/2}for(var a=0;a<n;a++){var s=parseInt(t.substr(a*2,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[r+a]=s}return a}function k(e,t,r,n){return K(Y(t,e.length-r),e,r,n)}function E(e,t,r,n){return K(V(t),e,r,n)}function x(e,t,r,n){return E(e,t,r,n)}function S(e,t,r,n){return K($(t),e,r,n)}function A(e,t,r,n){return K(J(t,e.length-r),e,r,n)}f.prototype.write=function fe(e,t,r,n){if(t===undefined){n="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){n=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(n===undefined)n="utf8"}else{n=r;r=undefined}}else{var i=n;n=t;t=r|0;r=i}var o=this.length-t;if(r===undefined||r>o)r=o;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!n)n="utf8";var a=false;for(;;){switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return k(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return x(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();a=true}}};f.prototype.toJSON=function ue(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function T(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var o=t;o<r;o++){if(e[o]<=127){n+=G(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return n+G(i)}function C(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i]&127)}return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i])}return n}function B(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var o=t;o<r;o++){i+=F(e[o])}return i}function R(e,t,r){var n=e.slice(t,r);var i="";for(var o=0;o<n.length;o+=2){i+=String.fromCharCode(n[o]+n[o+1]*256)}return i}f.prototype.slice=function ce(e,t){var r=this.length;e=~~e;t=t===undefined?r:~~t;if(e<0){e+=r;if(e<0)e=0}else if(e>r){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(t<e)t=e;var n;if(f.TYPED_ARRAY_SUPPORT){n=f._augment(this.subarray(e,t))}else{var i=t-e;n=new f(i,undefined);for(var o=0;o<i;o++){n[o]=this[o+e]}}if(n.length)n.parent=this.parent||this;return n};function M(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function le(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}return n};f.prototype.readUIntBE=function he(e,t,r){e=e|0;t=t|0;if(!r){M(e,t,this.length)}var n=this[e+--t];var i=1;while(t>0&&(i*=256)){n+=this[e+--t]*i}return n};f.prototype.readUInt8=function de(e,t){if(!t)M(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function pe(e,t){if(!t)M(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ge(e,t){if(!t)M(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function me(e,t){if(!t)M(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function ve(e,t){if(!t)M(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ye(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}i*=128;if(n>=i)n-=Math.pow(2,8*t);return n};f.prototype.readIntBE=function _e(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=t;var i=1;var o=this[e+--n];while(n>0&&(i*=256)){o+=this[e+--n]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};f.prototype.readInt8=function we(e,t){if(!t)M(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function be(e,t){if(!t)M(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function ke(e,t){if(!t)M(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ee(e,t){if(!t)M(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function xe(e,t){if(!t)M(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Se(e,t){if(!t)M(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function Ae(e,t){if(!t)M(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Ie(e,t){if(!t)M(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Te(e,t){if(!t)M(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,r,n,i,o){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||t<o)throw new RangeError("value is out of bounds");
+if(r+n>e.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Ce(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=1;var o=0;this[t]=e&255;while(++o<r&&(i*=256)){this[t+o]=e/i&255}return t+r};f.prototype.writeUIntBE=function Le(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=r-1;var o=1;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=e/o&255}return t+r};f.prototype.writeUInt8=function Be(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function j(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-r,2);i<o;i++){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}f.prototype.writeUInt16LE=function Re(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function Me(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};function U(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-r,4);i<o;i++){e[r+i]=t>>>(n?i:3-i)*8&255}}f.prototype.writeUInt32LE=function Pe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{U(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function je(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{U(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Ue(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0;var a=1;var s=e<0?1:0;this[t]=e&255;while(++o<r&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+r};f.prototype.writeIntBE=function Oe(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1;var a=1;var s=e<0?1:0;this[t+o]=e&255;while(--o>=0&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+r};f.prototype.writeInt8=function He(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function De(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Ne(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function qe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{U(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function ze(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{U(this,e,t,false)}return t+4};function O(e,t,r,n,i,o){if(t>i||t<o)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function H(e,t,r,n,o){if(!o){O(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function We(e,t,r){return H(this,e,t,true,r)};f.prototype.writeFloatBE=function Fe(e,t,r){return H(this,e,t,false,r)};function D(e,t,r,n,o){if(!o){O(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function Ye(e,t,r){return D(this,e,t,true,r)};f.prototype.writeDoubleBE=function Ve(e,t,r){return D(this,e,t,false,r)};f.prototype.copy=function Je(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n<r)n=r;if(n===r)return 0;if(e.length===0||this.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r){n=e.length-t+r}var i=n-r;if(i<1e3||!f.TYPED_ARRAY_SUPPORT){for(var o=0;o<i;o++){e[o+t]=this[o+r]}}else{e._set(this.subarray(r,r+i),t)}return i};f.prototype.fill=function $e(e,t,r){if(!e)e=0;if(!t)t=0;if(!r)r=this.length;if(r<t)throw new RangeError("end < start");if(r===t)return;if(this.length===0)return;if(t<0||t>=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if(typeof e==="number"){for(n=t;n<r;n++){this[n]=e}}else{var i=Y(e.toString());var o=i.length;for(n=t;n<r;n++){this[n]=i[n%o]}}return this};f.prototype.toArrayBuffer=function Ke(){if(typeof Uint8Array!=="undefined"){if(f.TYPED_ARRAY_SUPPORT){return new f(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,r=e.length;t<r;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var N=f.prototype;f._augment=function Ge(e){e.constructor=f;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 z(e){e=W(e).replace(q,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function W(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function F(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function Y(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var o=[];var a=0;for(;a<n;a++){r=e.charCodeAt(a);if(r>55295&&r<57344){if(i){if(r<56320){if((t-=3)>-1)o.push(239,191,189);i=r;continue}else{r=i-55296<<10|r-56320|65536;i=null}}else{if(r>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)o.push(239,191,189);continue}else{i=r;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<2097152){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function V(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function J(e,t){var r,n,i;var o=[];for(var a=0;a<e.length;a++){if((t-=2)<0)break;r=e.charCodeAt(a);n=r>>8;i=r%256;o.push(i);o.push(n)}return o}function $(e){return n.toByteArray(z(e))}function K(e,t,r,n){for(var i=0;i<n;i++){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function G(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":47,ieee754:48,"is-array":49}],47:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var a="a".charCodeAt(0);var s="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===i||t===u)return 63;if(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 l(e){var r,n,i,o,a,s;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var f=e.length;a="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0;s=new t(e.length*3/4-a);i=a>0?e.length-4:e.length;var u=0;function l(e){s[u++]=e}for(r=0,n=0;r<i;r+=4,n+=3){o=c(e.charAt(r))<<18|c(e.charAt(r+1))<<12|c(e.charAt(r+2))<<6|c(e.charAt(r+3));l((o&16711680)>>16);l((o&65280)>>8);l(o&255)}if(a===2){o=c(e.charAt(r))<<2|c(e.charAt(r+1))>>4;l(o&255)}else if(a===1){o=c(e.charAt(r))<<10|c(e.charAt(r+1))<<4|c(e.charAt(r+2))>>2;l(o>>8&255);l(o&255)}return s}function h(e){var t,r=e.length%3,i="",o,a;function s(e){return n.charAt(e)}function f(e){return s(e>>18&63)+s(e>>12&63)+s(e>>6&63)+s(e&63)}for(t=0,a=e.length-r;t<a;t+=3){o=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=f(o)}switch(r){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=l;e.fromByteArray=h})(typeof r==="undefined"?this.base64js={}:r)},{}],48:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=i*8-n-1,f=(1<<s)-1,u=f>>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];l+=h;o=d&(1<<-c)-1;d>>=-c;c+=s;for(;c>0;o=o*256+e[t+l],l+=h,c-=8){}a=o&(1<<-c)-1;o>>=-c;c+=n;for(;c>0;a=a*256+e[t+l],l+=h,c-=8){}if(o===0){o=1-u}else if(o===f){return a?NaN:(d?-1:1)*Infinity}else{a=a+Math.pow(2,n);o=o-u}return(d?-1:1)*a*Math.pow(2,o-n)};r.write=function(e,t,r,n,i,o){var a,s,f,u=o*8-i-1,c=(1<<u)-1,l=c>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){s=isNaN(t)?1:0;a=c}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-a))<1){a--;f*=2}if(a+l>=1){t+=h/f}else{t+=h*Math.pow(2,1-l)}if(t*f>=2){a++;f/=2}if(a+l>=c){s=0;a=c}else if(a+l>=1){s=(t*f-1)*Math.pow(2,i);a=a+l}else{s=t*Math.pow(2,l-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+d]=s&255,d+=p,s/=256,i-=8){}a=a<<i|s;u+=i;for(;u>0;e[r+d]=a&255,d+=p,a/=256,u-=8){}e[r+d-p]|=g*128}},{}],49:[function(e,t,r){var n=Array.isArray;var i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],50:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,f,u;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||a(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}r=this._events[e];if(s(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=arguments.length;o=new Array(n-1);for(f=1;f<n;f++)o[f-1]=arguments[f];r.apply(this,o)}}else if(a(r)){n=arguments.length;o=new Array(n-1);for(f=1;f<n;f++)o[f-1]=arguments[f];u=r.slice();n=u.length;for(f=0;f<n;f++)u[f].apply(this,o)}return true};n.prototype.addListener=function(e,t){var r;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 r;if(!s(this._maxListeners)){r=this._maxListeners}else{r=n.defaultMaxListeners}if(r&&r>0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(r)){for(s=o;s-->0;){if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(i(e._events[t]))r=1;else r=e._events[t].length;return r};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function a(e){return typeof e==="object"&&e!==null}function s(e){return e===void 0}},{}],51:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{dup:41}],52:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return n.exec(e).slice(1)};r.resolve=function(){var r="",n=false;for(var i=arguments.length-1;i>=-1&&!n;i--){var a=i>=0?arguments[i]:e.cwd();if(typeof a!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!a){continue}r=a+"/"+r;n=a.charAt(0)==="/"}r=t(o(r.split("/"),function(e){return!!e}),!n).join("/");return(n?"/":"")+r||"."};r.normalize=function(e){var n=r.isAbsolute(e),i=a(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!n).join("/");if(!e&&!n){e="."}if(e&&i){e+="/"}return(n?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};r.relative=function(e,t){e=r.resolve(e).substr(1);t=r.resolve(t).substr(1);function n(e){var t=0;for(;t<e.length;t++){if(e[t]!=="")break}var r=e.length-1;for(;r>=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var i=n(e.split("/"));var o=n(t.split("/"));var a=Math.min(i.length,o.length);var s=a;for(var f=0;f<a;f++){if(i[f]!==o[f]){s=f;break}}var u=[];for(var f=s;f<i.length;f++){u.push("..")}u=u.concat(o.slice(s));return u.join("/")};r.sep="/";r.delimiter=":";r.dirname=function(e){var t=i(e),r=t[0],n=t[1];if(!r&&!n){return"."}if(n){n=n.substr(0,n.length-1)}return r+n};r.basename=function(e,t){var r=i(e)[2];if(t&&r.substr(-1*t.length)===t){r=r.substr(0,r.length-t.length)}return r};r.extname=function(e){return i(e)[3]};function o(e,t){if(e.filter)return e.filter(t);var r=[];for(var n=0;n<e.length;n++){if(t(e[n],n,e))r.push(e[n])}return r}var a="ab".substr(-1)==="b"?function(e,t,r){return e.substr(t,r)}:function(e,t,r){if(t<0)t=e.length+t;return e.substr(t,r)}}).call(this,e("_process"))},{_process:53}],53:[function(e,t,r){var n=t.exports={};var i=[];var o=false;var a;var s=-1;function f(){o=false;if(a.length){i=a.concat(i)}else{s=-1}if(i.length){u()}}function u(){if(o){return}var e=setTimeout(f);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)}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}}i.push(new c(e,t));if(!o){setTimeout(u,0)}};function c(e,t){this.fun=e;this.array=t}c.prototype.run=function(){this.fun.apply(null,this.array)};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function l(){}n.on=l;n.addListener=l;n.once=l;n.off=l;n.removeListener=l;n.removeAllListeners=l;n.emit=l;n.binding=function(e){throw new Error("process.binding is not supported")};n.cwd=function(){return"/"};n.chdir=function(e){throw new Error("process.chdir is not supported")};n.umask=function(){return 0}},{}],54:[function(t,r,n){(function(t){(function(i){var o=typeof n=="object"&&n&&!n.nodeType&&n;var a=typeof r=="object"&&r&&!r.nodeType&&r;var s=typeof t=="object"&&t;if(s.global===s||s.window===s||s.self===s){i=s}var f,u=2147483647,c=36,l=1,h=26,d=38,p=700,g=72,m=128,v="-",y=/^xn--/,_=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=c-l,E=Math.floor,x=String.fromCharCode,S;function A(e){throw RangeError(b[e])}function I(e,t){var r=e.length;var n=[];while(r--){n[r]=t(e[r])}return n}function T(e,t){var r=e.split("@");var n="";if(r.length>1){n=r[0]+"@";e=r[1]}e=e.replace(w,".");var i=e.split(".");var o=I(i,t).join(".");return n+o}function C(e){var t=[],r=0,n=e.length,i,o;while(r<n){i=e.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){o=e.charCodeAt(r++);if((o&64512)==56320){t.push(((i&1023)<<10)+(o&1023)+65536)}else{t.push(i);r--}}else{t.push(i)}}return t}function L(e){return I(e,function(e){var t="";if(e>65535){e-=65536;t+=x(e>>>10&1023|55296);e=56320|e&1023}t+=x(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function M(e,t,r){var n=0;e=r?E(e/p):e>>1;e+=E(e/t);for(;e>k*h>>1;n+=c){e=E(e/k)}return E(n+(k+1)*e/(e+d))}function P(e){var t=[],r=e.length,n,i=0,o=m,a=g,s,f,d,p,y,_,w,b,k;s=e.lastIndexOf(v);if(s<0){s=0}for(f=0;f<s;++f){if(e.charCodeAt(f)>=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=s>0?s+1:0;d<r;){for(p=i,y=1,_=c;;_+=c){if(d>=r){A("invalid-input")}w=B(e.charCodeAt(d++));if(w>=c||w>E((u-i)/y)){A("overflow")}i+=w*y;b=_<=a?l:_>=a+h?h:_-a;if(w<b){break}k=c-b;if(y>E(u/k)){A("overflow")}y*=k}n=t.length+1;a=M(i-p,n,p==0);if(E(i/n)>u-o){A("overflow")}o+=E(i/n);i%=n;t.splice(i++,0,o)}return L(t)}function j(e){var t,r,n,i,o,a,s,f,d,p,y,_=[],w,b,k,S;e=C(e);w=e.length;t=m;r=0;o=g;for(a=0;a<w;++a){y=e[a];if(y<128){_.push(x(y))}}n=i=_.length;if(i){_.push(v)}while(n<w){for(s=u,a=0;a<w;++a){y=e[a];if(y>=t&&y<s){s=y}}b=n+1;if(s-t>E((u-r)/b)){A("overflow")}r+=(s-t)*b;t=s;for(a=0;a<w;++a){y=e[a];if(y<t&&++r>u){A("overflow")}if(y==t){for(f=r,d=c;;d+=c){p=d<=o?l:d>=o+h?h:d-o;if(f<p){break}S=f-p;k=c-p;_.push(x(R(p+S%k,0)));f=E(S/k)}_.push(x(R(f,0)));o=M(r,b,n==i);r=0;++n}}++r;++t}return _.join("")}function U(e){return T(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function O(e){return T(e,function(e){return _.test(e)?"xn--"+j(e):e})}f={version:"1.3.2",ucs2:{decode:C,encode:L},decode:P,encode:j,toASCII:O,toUnicode:U};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return f})}else if(o&&a){if(r.exports==o){a.exports=f}else{for(S in f){f.hasOwnProperty(S)&&(o[S]=f[S])}}}else{i.punycode=f}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],55:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&";r=r||"=";var a={};if(typeof e!=="string"||e.length===0){return a}var s=/\+/g;e=e.split(t);var f=1e3;if(o&&typeof o.maxKeys==="number"){f=o.maxKeys}var u=e.length;if(f>0&&u>f){u=f}for(var c=0;c<u;++c){var l=e[c].replace(s,"%20"),h=l.indexOf(r),d,p,g,m;if(h>=0){d=l.substr(0,h);p=l.substr(h+1)}else{d=l;p=""}g=decodeURIComponent(d);m=decodeURIComponent(p);if(!n(a,g)){a[g]=m}else if(i(a[g])){a[g].push(m)}else{a[g]=[a[g],m]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],56:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(a(e),function(a){var s=encodeURIComponent(n(a))+r;if(i(e[a])){return o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t)}else{return s+encodeURIComponent(n(e[a]))}}).join(t)}if(!s)return"";return encodeURIComponent(n(s))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function o(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n<e.length;n++){r.push(t(e[n],n))}return r}var a=Object.keys||function(e){var t=[];for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t.push(r)}return t}},{}],57:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":55,"./encode":56}],58:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":59}],59:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./_stream_readable":61,"./_stream_writable":63,_process:53,"core-util-is":64,dup:35,inherits:117}],60:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./_stream_transform":62,"core-util-is":64,dup:36,inherits:117}],61:[function(e,t,r){(function(r){t.exports=l;var n=e("isarray");var i=e("buffer").Buffer;l.ReadableState=c;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 f;var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}s.inherits(l,a);function c(t,r){var n=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(r instanceof n)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(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function l(t){var r=e("./_stream_duplex");if(!(this instanceof l))return new l(t);this._readableState=new c(t,this);this.readable=true;a.call(this)}l.prototype.push=function(e,t){var r=this._readableState;if(s.isString(e)&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new i(e,t);t=""}}return h(this,r,e,t,false)};l.prototype.unshift=function(e){var t=this._readableState;return h(this,t,e,"",true)};function h(e,t,r,n,i){var o=v(t,r);if(o){e.emit("error",o)}else if(s.isNullOrUndefined(r)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||r&&r.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&&!n)r=t.decoder.write(r);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}b(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}l.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t;return this};var p=8388608;function g(e){if(e>=p){e=p}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function m(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||s.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=g(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}l.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!s.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)T(this);else _(this);return null}e=m(e,t);if(e===0&&t.ended){if(t.length===0)T(this);return null}var n=t.needReadable;u("need readable",n);if(t.length===0||t.length-e<t.highWaterMark){n=true;u("length less than watermark",n)}if(t.ended||t.reading){n=false;u("reading or ended",n)}if(n){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(n&&!t.reading)e=m(r,t);var i;if(e>0)i=I(e,t);else i=null;if(s.isNull(i)){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(r!==e&&t.ended&&t.length===0)T(this);if(!s.isNull(i))this.emit("data",i);return i};function v(e,t){var r=null;if(!s.isBuffer(t)&&!s.isString(t)&&!s.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){w(e)});else w(e)}}function w(e){u("emit readable");e.emit("readable");A(e)}function b(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){k(e,t)})}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}l.prototype._read=function(e){this.emit("error",new Error("not implemented"))};l.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;u("pipe count=%d opts=%j",a.pipesCount,t);var s=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=s?l:d;if(a.endEmitted)r.nextTick(f);else i.once("end",f);e.on("unpipe",c);function c(e){u("onunpipe");if(e===i){d()}}function l(){u("onend");e.end()}var h=E(i);e.on("drain",h);function d(){u("cleanup");e.removeListener("close",m);e.removeListener("finish",v);e.removeListener("drain",h);e.removeListener("error",g);e.removeListener("unpipe",c);i.removeListener("end",l);i.removeListener("end",d);i.removeListener("data",p);if(a.awaitDrain&&(!e._writableState||e._writableState.needDrain))h()}i.on("data",p);function p(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",i._readableState.awaitDrain);i._readableState.awaitDrain++;i.pause()}}function g(t){u("onerror",t);y();e.removeListener("error",g);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",g);else if(n(e._events.error))e._events.error.unshift(g);else e._events.error=[g,e._events.error];function m(){e.removeListener("finish",v);y()}e.once("close",m);function v(){u("onfinish");e.removeListener("close",m);y()}e.once("finish",v);function y(){u("unpipe");i.unpipe(e)}e.emit("pipe",i);if(!a.flowing){u("pipe resume");i.resume()}return e};function E(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&o.listenerCount(e,"data")){t.flowing=true;A(e)}}}l.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 r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=L(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};l.prototype.on=function(e,t){var n=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;r.nextTick(function(){u("readable nexttick read 0");o.read(0)})}else if(i.length){_(this,i)}}}return n};l.prototype.addListener=l.prototype.on;l.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;if(!e.reading){u("resume read 0");this.read(0)}x(this,e)}return this};function x(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;r.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)}l.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}l.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){u("wrapped data");if(t.decoder)i=t.decoder.write(i);if(!i||!t.objectMode&&!i.length)return;var o=n.push(i);if(!o){r=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"];C(o,function(t){e.on(t,n.emit.bind(n,t))});n._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return n};l._fromList=I;function I(e,t){var r=t.buffer;var n=t.length;var o=!!t.decoder;var a=!!t.objectMode;var s;if(r.length===0)return null;if(n===0)s=null;else if(a)s=r.shift();else if(!e||e>=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e<r[0].length){var f=r[0];s=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){s=r.shift()}else{if(o)s="";else s=new i(e);var u=0;for(var c=0,l=r.length;c<l&&u<e;c++){var f=r[0];var h=Math.min(e-u,f.length);if(o)s+=f.slice(0,h);else f.copy(s,u,0,h);if(h<f.length)r[0]=f.slice(h);else r.shift();u+=h}}}return s}function T(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function C(e,t){for(var r=0,n=e.length;r<n;r++){
+t(e[r],r)}}function L(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":59,_process:53,buffer:46,"core-util-is":64,events:50,inherits:117,isarray:51,stream:69,"string_decoder/":70,util:45}],62:[function(e,t,r){t.exports=s;var n=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(s,n);function o(e,t){this.afterTransform=function(e,r){return a(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,r){var n=e._transformState;n.transforming=false;var o=n.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(!i.isNullOrUndefined(r))e.push(r);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);n.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){f(t,e)});else f(t)})}s.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};s.prototype._transform=function(e,t,r){throw new Error("not implemented")};s.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.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 f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":59,"core-util-is":64,inherits:117}],63:[function(e,t,r){(function(r){t.exports=f;var n=e("buffer").Buffer;f.WritableState=s;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(f,o);function a(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function s(t,r){var n=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(r instanceof n)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(r,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new s(t,this);this.writable=true;o.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,n){var i=new Error("write after end");e.emit("error",i);r.nextTick(function(){n(i)})}function c(e,t,n,o){var a=true;if(!i.isBuffer(n)&&!i.isString(n)&&!i.isNullOrUndefined(n)&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);r.nextTick(function(){o(s)});a=false}return a}f.prototype.write=function(e,t,r){var n=this._writableState;var o=false;if(i.isFunction(t)){r=t;t=null}if(i.isBuffer(e))t="buffer";else if(!t)t=n.defaultEncoding;if(!i.isFunction(r))r=function(){};if(n.ended)u(this,n,r);else if(c(this,n,e,r)){n.pendingcb++;o=h(this,n,e,t,r)}return o};f.prototype.cork=function(){var e=this._writableState;e.corked++};f.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)_(this,e)}};function l(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&i.isString(t)){t=new n(t,r)}return t}function h(e,t,r,n,o){r=l(t,r,n);if(i.isBuffer(r))n="buffer";var s=t.objectMode?1:r.length;t.length+=s;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new a(r,n,o));else d(e,t,false,s,r,n,o);return f}function d(e,t,r,n,i,o,a){t.writelen=n;t.writecb=a;t.writing=true;t.sync=true;if(r)e._writev(i,t.onwrite);else e._write(i,o,t.onwrite);t.sync=false}function p(e,t,n,i,o){if(n)r.nextTick(function(){t.pendingcb--;o(i)});else{t.pendingcb--;o(i)}e._writableState.errorEmitted=true;e.emit("error",i)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function m(e,t){var n=e._writableState;var i=n.sync;var o=n.writecb;g(n);if(t)p(e,n,i,t,o);else{var a=w(e,n);if(!a&&!n.corked&&!n.bufferProcessing&&n.buffer.length){_(e,n)}if(i){r.nextTick(function(){v(e,n,a,o)})}else{v(e,n,a,o)}}}function v(e,t,r,n){if(!r)y(e,t);t.pendingcb--;n();k(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var r=[];for(var n=0;n<t.buffer.length;n++)r.push(t.buffer[n].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var n=0;n<r.length;n++){t.pendingcb--;r[n](e)}});t.buffer=[]}else{for(var n=0;n<t.buffer.length;n++){var i=t.buffer[n];var o=i.chunk;var a=i.encoding;var s=i.callback;var f=t.objectMode?1:o.length;d(e,t,false,f,o,a,s);if(t.writing){n++;break}}if(n<t.buffer.length)t.buffer=t.buffer.slice(n);else t.buffer.length=0}t.bufferProcessing=false}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype._writev=null;f.prototype.end=function(e,t,r){var n=this._writableState;if(i.isFunction(e)){r=e;e=null;t=null}else if(i.isFunction(t)){r=t;t=null}if(!i.isNullOrUndefined(e))this.write(e,t);if(n.corked){n.corked=1;this.uncork()}if(!n.ending&&!n.finished)E(this,n,r)};function w(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function b(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function k(e,t){var r=w(e,t);if(r){if(t.pendingcb===0){b(e,t);t.finished=true;e.emit("finish")}else b(e,t)}return r}function E(e,t,n){t.ending=true;k(e,t);if(n){if(t.finished)r.nextTick(n);else e.once("finish",n)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":59,_process:53,buffer:46,"core-util-is":64,inherits:117,stream:69}],64:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{buffer:46,dup:40}],65:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":60}],66:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js");r.Stream=e("stream");r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":59,"./lib/_stream_passthrough.js":60,"./lib/_stream_readable.js":61,"./lib/_stream_transform.js":62,"./lib/_stream_writable.js":63,stream:69}],67:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":62}],68:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":63}],69:[function(e,t,r){t.exports=o;var n=e("events").EventEmitter;var i=e("inherits");i(o,n);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(){n.call(this)}o.prototype.pipe=function(e,t){var r=this;function i(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",i);function o(){if(r.readable&&r.resume){r.resume()}}e.on("drain",o);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",s);r.on("close",f)}var a=false;function s(){if(a)return;a=true;e.end()}function f(){if(a)return;a=true;if(typeof e.destroy==="function")e.destroy()}function u(e){c();if(n.listenerCount(this,"error")===0){throw e}}r.on("error",u);e.on("error",u);function c(){r.removeListener("data",i);e.removeListener("drain",o);r.removeListener("end",s);r.removeListener("close",f);r.removeListener("error",u);e.removeListener("error",u);r.removeListener("end",c);r.removeListener("close",c);e.removeListener("close",c)}r.on("end",c);r.on("close",c);e.on("close",c);e.emit("pipe",r);return e}},{events:50,inherits:117,"readable-stream/duplex.js":58,"readable-stream/passthrough.js":65,"readable-stream/readable.js":66,"readable-stream/transform.js":67,"readable-stream/writable.js":68}],70:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{buffer:46,dup:42}],71:[function(e,t,r){var n=e("punycode");r.parse=_;r.resolve=b;r.resolveObject=k;r.format=w;r.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"," "],f=["{","}","|","\\","^","`"].concat(s),u=["'"].concat(f),c=["%","/","?",";","#"].concat(u),l=["/","?","#"],h=255,d=/^[a-z0-9A-Z_-]{0,63}$/,p=/^([a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:true,"javascript:":true},m={javascript:true,"javascript:":true},v={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&x(e)&&e instanceof i)return e;var n=new i;n.parse(e,t,r);return n}i.prototype.parse=function(e,t,r){if(!E(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var i=e;i=i.trim();var a=o.exec(i);if(a){a=a[0];var s=a.toLowerCase();this.protocol=s;i=i.substr(a.length)}if(r||a||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=i.substr(0,2)==="//";if(f&&!(a&&m[a])){i=i.substr(2);this.slashes=true}}if(!m[a]&&(f||a&&!v[a])){var _=-1;for(var w=0;w<l.length;w++){var b=i.indexOf(l[w]);if(b!==-1&&(_===-1||b<_))_=b}var k,x;if(_===-1){x=i.lastIndexOf("@")}else{x=i.lastIndexOf("@",_)}if(x!==-1){k=i.slice(0,x);i=i.slice(x+1);this.auth=decodeURIComponent(k)}_=-1;for(var w=0;w<c.length;w++){var b=i.indexOf(c[w]);if(b!==-1&&(_===-1||b<_))_=b}if(_===-1)_=i.length;this.host=i.slice(0,_);i=i.slice(_);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 w=0,I=A.length;w<I;w++){var T=A[w];if(!T)continue;if(!T.match(d)){var C="";for(var L=0,B=T.length;L<B;L++){if(T.charCodeAt(L)>127){C+="x"}else{C+=T[L]}}if(!C.match(d)){var R=A.slice(0,w);var M=A.slice(w+1);var P=T.match(p);if(P){R.push(P[1]);M.unshift(P[2])}if(M.length){i="/"+M.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>h){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var j=this.hostname.split(".");var U=[];for(var w=0;w<j.length;++w){var O=j[w];U.push(O.match(/[^A-Za-z0-9_-]/)?"xn--"+n.encode(O):O)}this.hostname=U.join(".")}var H=this.port?":"+this.port:"";var D=this.hostname||"";this.host=D+H;this.href+=this.host;if(S){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(i[0]!=="/"){i="/"+i}}}if(!g[s]){for(var w=0,I=u.length;w<I;w++){var N=u[w];var q=encodeURIComponent(N);if(q===N){q=escape(N)}i=i.split(N).join(q)}}var z=i.indexOf("#");if(z!==-1){this.hash=i.substr(z);i=i.slice(0,z)}var W=i.indexOf("?");if(W!==-1){this.search=i.substr(W);this.query=i.substr(W+1);if(t){this.query=y.parse(this.query)}i=i.slice(0,W)}else if(t){this.search="";this.query={}}if(i)this.pathname=i;if(v[s]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var H=this.pathname||"";var O=this.search||"";this.path=H+O}this.href=this.format();return this};function w(e){if(E(e))e=_(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||"",r=this.pathname||"",n=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&&x(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||v[t])&&i!==false){i="//"+(i||"");if(r&&r.charAt(0)!=="/")r="/"+r}else if(!i){i=""}if(n&&n.charAt(0)!=="#")n="#"+n;if(a&&a.charAt(0)!=="?")a="?"+a;r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)});a=a.replace("#","%23");return t+i+r+a+n};function b(e,t){return _(e,false,true).resolve(t)}i.prototype.resolve=function(e){return this.resolveObject(_(e,false,true)).format()};function k(e,t){if(!e)return t;return _(e,false,true).resolveObject(t)}i.prototype.resolveObject=function(e){if(E(e)){var t=new i;t.parse(e,false,true);e=t}var r=new i;Object.keys(this).forEach(function(e){r[e]=this[e]},this);r.hash=e.hash;if(e.href===""){r.href=r.format();return r}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")r[t]=e[t]});if(v[r.protocol]&&r.hostname&&!r.pathname){r.path=r.pathname="/"}r.href=r.format();return r}if(e.protocol&&e.protocol!==r.protocol){if(!v[e.protocol]){Object.keys(e).forEach(function(t){r[t]=e[t]});r.href=r.format();return r}r.protocol=e.protocol;if(!e.host&&!m[e.protocol]){var n=(e.pathname||"").split("/");while(n.length&&!(e.host=n.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(n[0]!=="")n.unshift("");if(n.length<2)n.unshift("");r.pathname=n.join("/")}else{r.pathname=e.pathname}r.search=e.search;r.query=e.query;r.host=e.host||"";r.auth=e.auth;r.hostname=e.hostname||e.host;r.port=e.port;if(r.pathname||r.search){var o=r.pathname||"";var a=r.search||"";r.path=o+a}r.slashes=r.slashes||e.slashes;r.href=r.format();return r}var s=r.pathname&&r.pathname.charAt(0)==="/",f=e.host||e.pathname&&e.pathname.charAt(0)==="/",u=f||s||r.host&&e.pathname,c=u,l=r.pathname&&r.pathname.split("/")||[],n=e.pathname&&e.pathname.split("/")||[],h=r.protocol&&!v[r.protocol];if(h){r.hostname="";r.port=null;if(r.host){if(l[0]==="")l[0]=r.host;else l.unshift(r.host)}r.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(n[0]==="")n[0]=e.host;else n.unshift(e.host)}e.host=null}u=u&&(n[0]===""||l[0]==="")}if(f){r.host=e.host||e.host===""?e.host:r.host;r.hostname=e.hostname||e.hostname===""?e.hostname:r.hostname;r.search=e.search;r.query=e.query;l=n}else if(n.length){if(!l)l=[];l.pop();l=l.concat(n);r.search=e.search;r.query=e.query}else if(!A(e.search)){if(h){r.hostname=r.host=l.shift();var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!l.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var p=l.slice(-1)[0];var g=(r.host||e.host)&&(p==="."||p==="..")||p==="";var y=0;for(var _=l.length;_>=0;_--){p=l[_];if(p=="."){l.splice(_,1)}else if(p===".."){l.splice(_,1);y++}else if(y){l.splice(_,1);y--}}if(!u&&!c){for(;y--;y){l.unshift("..")}}if(u&&l[0]!==""&&(!l[0]||l[0].charAt(0)!=="/")){l.unshift("")}if(g&&l.join("/").substr(-1)!=="/"){l.push("")}var w=l[0]===""||l[0]&&l[0].charAt(0)==="/";if(h){r.hostname=r.host=w?"":l.length?l.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&l.length;if(u&&!w){l.unshift("")}if(!l.length){r.pathname=null;r.path=null}else{r.pathname=l.join("/")}if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.auth=e.auth||r.auth;r.slashes=r.slashes||e.slashes;r.href=r.format();return r};i.prototype.parseHost=function(){var e=this.host;var t=a.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function E(e){return typeof e==="string"}function x(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:54,querystring:57}],72:[function(e,t,r){(function(r){t.exports=m;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=v;var n=e("bencode");var i=e("block-stream2");var o=e("piece-length");var a=e("path");var s=e("dezalgo");var f=e("filestream/read");var u=e("flatten");var c=e("fs");var l=e("multistream");var h=e("once");var d=e("run-parallel");var p=e("simple-sha1");var g=e("stream");function m(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};v(e,t,function(e,n){if(e)return r(e);E(n,t,r)})}function v(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};n=s(n);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(A(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&a.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var i=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);d(e.map(function(e){return function(n){var o={};if(S(e)){o.getStream=T(e);o.length=e.size}else if(r.isBuffer(e)){o.getStream=C(e);o.length=e.length}else if(I(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}o.getStream=B(e,o);o.length=0}else if(typeof e==="string"){if(typeof c.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var s=i>1;y(e,s,n);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");o.path=e.name.split(a.sep);n(null,o)}}),function(e,t){if(e)return n(e);t=u(t);n(null,t)})}function y(e,t,r){w(_,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=u(i);else i=[i];var o=a.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(a.sep)+1)}else{if(o[o.length-1]!==a.sep)o+=a.sep}i.forEach(function(e){e.getStream=L(e.path);e.path=e.path.replace(o,"").split(a.sep)});r(null,i)})}function _(e,t){t=h(t);c.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function w(e,t,r){c.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{d(i.filter(b).map(function(r){return function(n){w(e,a.join(t,r),n)}}),r)}})}function b(e){return e[0]!=="."}function k(e,t,n){n=h(n);var o=[];var a=0;var s=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;var d=new l(s);var g=new i(t,{zeroPadding:false});d.on("error",y);d.pipe(g).on("data",m).on("end",v).on("error",y);function m(e){a+=e.length;var t=u;p(e,function(e){o[t]=e;f-=1;w()});f+=1;u+=1}function v(){c=true;w()}function y(e){_();n(e)}function _(){d.removeListener("error",y);g.removeListener("data",m);g.removeListener("end",v);g.removeListener("error",y)}function w(){if(c&&f===0){_();n(null,new r(o.join(""),"hex"),a)}}}function E(e,r,i){var a=r.announceList!==undefined?r.announceList:r.announce!==undefined?r.announce.map(function(e){return[e]}):t.exports.announceList;var s={info:{name:r.name},announce:a[0][0],"announce-list":a,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)s.info.comment=r.comment;if(r.createdBy!==undefined)s.info["created by"]=r.createdBy;if(r.private!==undefined)s.info.private=Number(r.private);if(r.sslCert!==undefined)s.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)s["url-list"]=r.urlList;var f=e.length===1;var u=r.pieceLength||o(e.reduce(x,0));s.info["piece length"]=u;k(e,u,function(t,r,o){if(t)return i(t);s.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){s.info.files=e}else{s.info.length=o}i(null,n.encode(s))})}function x(e,t){return e+t.length}function S(e){return typeof Blob!=="undefined"&&e instanceof Blob}function A(e){return typeof FileList==="function"&&e instanceof FileList}function I(e){return typeof e==="object"&&typeof e.pipe==="function"}function T(e){return function(){return new f(e)}}function C(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function L(e){return function(){return c.createReadStream(e)}}function B(e,t){return function(){var r=new g.Transform;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("buffer").Buffer)},{bencode:73,"block-stream2":77,buffer:46,dezalgo:89,"filestream/read":95,flatten:96,fs:44,multistream:97,once:100,path:52,"piece-length":101,"run-parallel":103,"simple-sha1":107,stream:69}],73:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./lib/decode":74,"./lib/encode":76,dup:14}],74:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{"./dict":75,buffer:46,dup:15}],75:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{dup:16}],76:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{buffer:46,dup:17}],77:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{buffer:46,defined:78,dup:33,inherits:79,"readable-stream":88}],78:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{dup:34}],79:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],80:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./_stream_readable":82,"./_stream_writable":84,_process:53,"core-util-is":85,dup:35,inherits:79}],81:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./_stream_transform":83,"core-util-is":85,dup:36,inherits:79}],82:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{_process:53,buffer:46,"core-util-is":85,dup:37,events:50,inherits:79,isarray:86,stream:69,"string_decoder/":87}],83:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{"./_stream_duplex":80,"core-util-is":85,dup:38,inherits:79}],84:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{"./_stream_duplex":80,_process:53,buffer:46,"core-util-is":85,dup:39,inherits:79,stream:69}],85:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{buffer:46,dup:40}],86:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{dup:41}],87:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{buffer:46,dup:42}],88:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{"./lib/_stream_duplex.js":80,"./lib/_stream_passthrough.js":81,"./lib/_stream_readable.js":82,"./lib/_stream_transform.js":83,"./lib/_stream_writable.js":84,dup:43,stream:69}],89:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{asap:90,dup:28,wrappy:91}],90:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{_process:53,dup:29}],91:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],92:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],93:[function(e,t,r){(function(r){var n=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(n(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:46,"is-typedarray":94}],94:[function(e,t,r){t.exports=o;o.strict=a;o.loose=s;var n=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint16Array]":true,"[object Uint32Array]":true,"[object Float32Array]":true,"[object Float64Array]":true};function o(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return i[n.call(e)]}},{}],95:[function(e,t,r){var n=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var a=e("typedarray-to-buffer");function s(e,t){var r=this;if(!(this instanceof s)){return new s(e,t)}t=t||{};n.call(this,t);this._offset=0;this._ready=false;this._file=e;this._size=e.size;this._chunkSize=t.chunkSize||Math.max(this._size/1e3,200*1024);this.reader=new FileReader;this._generateHeaderBlocks(e,t,function(e,t){if(e){return r.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){r.push(e)})}r._ready=true;r.emit("_ready")})}i(s,n);t.exports=s;s.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};s.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var r=this._offset;var n=this._offset+this._chunkSize;if(n>this._size)n=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=n;e.push(a(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,n))};s.prototype.destroy=function(){this._file=null;if(this.reader){this.reader.onload=null;this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:92,stream:69,"typedarray-to-buffer":93}],96:[function(e,t,r){t.exports=function n(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,n){return e.reduce(function(e,i){if(Array.isArray(i)&&n<t){return e.concat(r(i,n+1))}else{return e.concat(i)}},[])}}},{}],97:[function(e,t,r){t.exports=o;var n=e("inherits");var i=e("stream");n(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",r);t.on("end",i);t.on("error",o);t.on("close",n);function r(){e._forward()}function n(){if(!t._readableState.ended){e.destroy()}}function i(){e._current=null;t.removeListener("readable",r);t.removeListener("end",i);t.removeListener("error",o);t.removeListener("close",n);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:98,stream:69}],98:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],99:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],100:[function(e,t,r){var n=e("wrappy");t.exports=n(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:99}],101:[function(e,t,r){var n=e("closest-to");var i=[];for(var o=14;o<=22;o++){i.push(Math.pow(2,o))}t.exports=function(e){return n(e/Math.pow(2,10),i)}},{"closest-to":102}],102:[function(e,t,r){t.exports=function(e,t){var r=Infinity;var n=0;var i=null;t.sort(function(e,t){return e-t});for(var o=0,a=t.length;o<a;o++){n=Math.abs(e-t[o]);if(n>=r){break}r=n;i=t[o]}return i}},{}],103:[function(e,t,r){var n=e("dezalgo");t.exports=function(e,t){if(t)t=n(t);var r,i,o;if(Array.isArray(e)){r=[];i=e.length}else{o=Object.keys(e);r={};i=o.length}function a(e,n,o){r[e]=o;if(--i===0||n){if(t)t(n,r);t=null}}if(!i){if(t)t(null,r);t=null}else if(o){o.forEach(function(t){e[t](a.bind(undefined,t))})}else{e.forEach(function(e,t){e(a.bind(undefined,t))})}}},{dezalgo:104}],104:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{asap:105,dup:28,wrappy:106}],105:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{_process:53,dup:29}],106:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],107:[function(e,t,r){var n=e("rusha");var i=new n;var o=window.crypto||window.msCrypto||{};var a=o.subtle||o.webkitSubtle;var s=i.digest.bind(i);try{a.digest({name:"sha-1"},new Uint8Array).catch(function(){a=false})}catch(f){a=false}function u(e,t){if(!a){setTimeout(t,0,s(e));return}if(typeof e==="string"){e=c(e)}a.digest({name:"sha-1"},e).then(function r(e){t(l(new Uint8Array(e)))},function n(r){t(s(e))})}function c(e){var t=e.length;var r=new Uint8Array(t);for(var n=0;n<t;n++){r[n]=e.charCodeAt(n)}return r}function l(e){var t=e.length;var r=[];for(var n=0;n<t;n++){var i=e[n];r.push((i>>>4).toString(16));r.push((i&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=s},{rusha:108}],108:[function(e,t,r){(function(e){(function(){if(typeof t!=="undefined"){t.exports=o}else if(typeof window!=="undefined"){window.Rusha=o}if(typeof FileReaderSync!=="undefined"){var r=new FileReaderSync,n=new o(4*1024*1024);self.onmessage=function s(e){var t,r=e.data.data;try{t=n.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}var i={getDataType:function(t){if(typeof t==="string"){return"string"}if(t instanceof Array){return"array"}if(typeof e!=="undefined"&&e.Buffer&&e.Buffer.isBuffer(t)){return"buffer"}if(t instanceof ArrayBuffer){return"arraybuffer"}if(t.buffer instanceof ArrayBuffer){return"view"}if(t instanceof Blob){return"blob"}throw new Error("Unsupported data type.")}};function o(e){"use strict";var t={fill:0};var n=function(e){for(e+=9;e%64>0;e+=1);return e};var o=function(e,t){for(var r=t>>2;r<e.length;r++)e[r]=0};var s=function(e,t,r){e[t>>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=r>>29;e[((t>>2)+2&~15)+15]=r<<3};var f=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o.charCodeAt(r);case 1:e[i+2|0]=o.charCodeAt(r+1);case 2:e[i+1|0]=o.charCodeAt(r+2);case 3:e[i|0]=o.charCodeAt(r+3)}}for(a=s;a<u;a=a+4|0){t[i+a>>2]=o.charCodeAt(r+a)<<24|o.charCodeAt(r+a+1)<<16|o.charCodeAt(r+a+2)<<8|o.charCodeAt(r+a+3)}switch(f){case 3:e[i+u+1|0]=o.charCodeAt(r+u+2);case 2:e[i+u+2|0]=o.charCodeAt(r+u+1);case 1:e[i+u+3|0]=o.charCodeAt(r+u)}};var u=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o[r];case 1:e[i+2|0]=o[r+1];case 2:e[i+1|0]=o[r+2];case 3:e[i|0]=o[r+3]}}for(a=4-s;a<u;a=a+=4|0){t[i+a>>2]=o[r+a]<<24|o[r+a+1]<<16|o[r+a+2]<<8|o[r+a+3]}switch(f){case 3:e[i+u+1|0]=o[r+u+2];case 2:e[i+u+2|0]=o[r+u+1];case 1:e[i+u+3|0]=o[r+u]}};var c=function(e,t,n,i,o){var a=this,s,f=o%4,u=i%4,c=i-u;var l=new Uint8Array(r.readAsArrayBuffer(a.slice(n,n+i)));if(c>0){switch(f){case 0:e[o+3|0]=l[0];case 1:e[o+2|0]=l[1];case 2:e[o+1|0]=l[2];case 3:e[o|0]=l[3]}}for(s=4-f;s<c;s=s+=4|0){t[o+s>>2]=l[s]<<24|l[s+1]<<16|l[s+2]<<8|l[s+3]}switch(u){case 3:e[o+c+1|0]=l[c+2];case 2:e[o+c+2|0]=l[c+1];case 1:e[o+c+3|0]=l[c]}};var l=function(e){switch(i.getDataType(e)){case"string":return f.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return c.bind(e)}};var h=function(e,t){switch(i.getDataType(e)){case"string":return e.slice(t);case"array":return e.slice(t);case"buffer":return e.slice(t);case"arraybuffer":return e.slice(t);case"view":return e.buffer.slice(t);
+}};var d=function(e){var t,r,n="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++){r=o[t];i[t]=n.charAt(r>>4&15)+n.charAt(r>>0&15)}return i.join("")};var p=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t<e;t=t<<1);}else{for(t=16777216;t<e;t+=16777216);}return t};var g=function(e){if(e%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=n(e);t.heap=new ArrayBuffer(p(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=a({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};g(e||64*1024);var m=function(e,t){var r=new Int32Array(e,t+320,5);r[0]=1732584193;r[1]=-271733879;r[2]=-1732584194;r[3]=271733878;r[4]=-1009589776};var v=function(e,r){var i=n(e);var a=new Int32Array(t.heap,0,i>>2);o(a,e);s(a,e,r);return i};var y=function(e,r,n){l(e)(t.h8,t.h32,r,n,0)};var _=function(e,r,n,i,o){var a=n;if(o){a=v(n,i)}y(e,r,n);t.core.hash(a,t.padMaxChunkLen)};var w=function(e,t){var r=new Int32Array(e,t+320,5);var n=new Int32Array(5);var i=new DataView(n.buffer);i.setInt32(0,r[0],false);i.setInt32(4,r[1],false);i.setInt32(8,r[2],false);i.setInt32(12,r[3],false);i.setInt32(16,r[4],false);return n};var b=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var n=0,i=t.maxChunkLen,o;for(n=0;r>n+i;n+=i){_(e,n,i,r,false)}_(e,n,r-n,r,true);return w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(b(e).buffer)}}function a(e,t,r){"use asm";var n=new e.Int32Array(r);function i(e,t){e=e|0;t=t|0;var r=0,i=0,o=0,a=0,s=0,f=0,u=0,c=0,l=0,h=0,d=0,p=0,g=0,m=0;o=n[t+320>>2]|0;s=n[t+324>>2]|0;u=n[t+328>>2]|0;l=n[t+332>>2]|0;d=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){a=o;f=s;c=u;h=l;p=d;for(i=0;(i|0)<64;i=i+4|0){m=n[r+i>>2]|0;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)+1859775393|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|s&l|u&l)|0)+((m+d|0)-1894007588|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)-899497514|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}o=o+a|0;s=s+f|0;u=u+c|0;l=l+h|0;d=d+p|0}n[t+320>>2]=o;n[t+324>>2]=s;n[t+328>>2]=u;n[t+332>>2]=l;n[t+336>>2]=d}return{hash:i}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],109:[function(e,t,r){r=t.exports=e("./debug");r.log=o;r.formatArgs=i;r.save=a;r.load=s;r.useColors=n;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function i(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function o(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{if(null==e){r.storage.removeItem("debug")}else{r.storage.debug=e}}catch(t){}}function s(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(s());function f(){try{return window.localStorage}catch(e){}}},{"./debug":110}],110:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,ms:111}],111:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var a=o*24;var s=a*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){e=""+e;if(e.length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*s;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+r;return Math.ceil(e/t)+" "+r+"s"}},{}],112:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{asap:113,dup:28,wrappy:114}],113:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{_process:53,dup:29}],114:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],115:[function(e,t,r){var n=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,r){if(typeof t==="function")return s(e,null,t);if(!t)t={};r=n(r||i);var f=e._writableState;var u=e._readableState;var c=t.readable||t.readable!==false&&e.readable;var l=t.writable||t.writable!==false&&e.writable;var h=function(){if(!e.writable)d()};var d=function(){l=false;if(!c)r()};var p=function(){c=false;if(!l)r()};var g=function(e){r(e?new Error("exited with error code: "+e):null)};var m=function(){if(c&&!(u&&u.ended))return r(new Error("premature close"));if(l&&!(f&&f.ended))return r(new Error("premature close"))};var v=function(){e.req.on("finish",d)};if(o(e)){e.on("complete",d);e.on("abort",m);if(e.req)v();else e.on("request",v)}else if(l&&!f){e.on("end",h);e.on("close",h)}if(a(e))e.on("exit",g);e.on("end",p);e.on("finish",d);if(t.error!==false)e.on("error",r);e.on("close",m);return function(){e.removeListener("complete",d);e.removeListener("abort",m);e.removeListener("request",v);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",h);e.removeListener("close",h);e.removeListener("finish",d);e.removeListener("exit",g);e.removeListener("end",p);e.removeListener("error",r);e.removeListener("close",m)}};t.exports=s},{once:121}],116:[function(e,t,r){var n=t.exports=function(e,t){if(!t)t=16;if(e===undefined)e=128;if(e<=0)return"0";var r=Math.log(Math.pow(2,e))/Math.log(t);for(var i=2;r===Infinity;i*=2){r=Math.log(Math.pow(2,e/i))/Math.log(t)*i}var o=r-Math.floor(r);var a="";for(var i=0;i<Math.floor(r);i++){var s=Math.floor(Math.random()*t).toString(t);a=s+a}if(o){var f=Math.pow(t,o);var s=Math.floor(Math.random()*f).toString(t);a=s+a}var u=parseInt(a,t);if(u!==Infinity&&u>=Math.pow(2,e)){return n(e,t)}else return a};n.rack=function(e,t,r){var i=function(i){var a=0;do{if(a++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var s=n(e,t)}while(Object.hasOwnProperty.call(o,s));o[s]=i;return s};var o=i.hats={};i.get=function(e){return i.hats[e]};i.set=function(e,t){i.hats[e]=t;return i};i.bits=e||128;i.base=t||16;return i}},{}],117:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],118:[function(e,t,r){arguments[4][97][0].apply(r,arguments)},{dup:97,inherits:119,stream:69}],119:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],120:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],121:[function(e,t,r){arguments[4][100][0].apply(r,arguments)},{dup:100,wrappy:120}],122:[function(e,t,r){(function(r){var n=e("magnet-uri");var i=e("parse-torrent-file");t.exports=function o(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return n(e)}else if(typeof e==="string"&&(t===40||t===32)){return n("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return n("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return i(e)}else if(e&&e.infoHash){return e}else{throw new Error("Invalid torrent identifier")}};t.exports.toMagnetURI=n.encode;t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:46,"magnet-uri":123,"parse-torrent-file":128}],123:[function(e,t,r){(function(r){t.exports=a;t.exports.decode=a;t.exports.encode=s;var n=e("thirty-two");var i=e("xtend");var o=e("uniq");function a(e){var t={};var i=e.split("magnet:?")[1];var a=i&&i.length>=0?i.split("&"):[];a.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var n=r[0];var i=r[1];if(n==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){i=decodeURIComponent(i)}if(n==="kt")i=decodeURIComponent(i).split("+");if(t[n]){if(Array.isArray(t[n])){t[n].push(i)}else{var o=t[n];t[n]=[o,i]}}else{t[n]=i}});var s;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=n.decode(s[1]);t.infoHash=new r(i,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];o(t.announce);t.urlList=[];if(typeof t.as==="string"||Array.isArray(t.as)){t.urlList=t.urlList.concat(t.as)}if(typeof t.ws==="string"||Array.isArray(t.ws)){t.urlList=t.urlList.concat(t.ws)}return t}function s(e){e=i(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,n){var i=Array.isArray(e[r])?e[r]:[e[r]];i.forEach(function(e,i){if((n>0||i>0)&&(r!=="kt"||i===0))t+="&";if(r==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){e=encodeURIComponent(e)}if(r==="kt")e=encodeURIComponent(e);if(r==="kt"&&i>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:46,"thirty-two":124,uniq:126,xtend:127}],124:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":125}],125:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var n=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var n=0;var o=0;var a=0;var s=0;var f=new e(i(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(n<r.length){var u=r[n];if(a>3){s=u&255>>a;a=(a+5)%8;s=s<<a|(n+1<r.length?r[n+1]:0)>>8-a;n++}else{s=u>>8-(a+5)&31;a=(a+5)%8;if(a==0)n++}f[o]=t.charCodeAt(s);o++}for(n=o;n<f.length;n++)f[n]=61;return f};r.decode=function(t){var r=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 f=0;f<t.length;f++){if(t[f]==61){break}var u=t[f]-48;if(u<n.length){i=n[u];if(r<=3){r=(r+5)%8;if(r==0){o|=i;s[a]=o;a++;o=0}else{o|=255&i<<8-r}}else{r=(r+5)%8;o|=255&i>>>r;s[a]=o;a++;o=255&i<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return s.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:46}],126:[function(e,t,r){"use strict";function n(e,t){var r=1,n=e.length,i=e[0],o=e[0];for(var a=1;a<n;++a){o=i;i=e[a];if(t(i,o)){if(a===r){r++;continue}e[r++]=i}}e.length=r;return e}function i(e){var t=1,r=e.length,n=e[0],i=e[0];for(var o=1;o<r;++o,i=n){i=n;n=e[o];if(n!==i){if(o===t){t++;continue}e[t++]=n}}e.length=t;return e}function o(e,t,r){if(e.length===0){return e}if(t){if(!r){e.sort(t)}return n(e,t)}if(!r){e.sort()}return i(e)}t.exports=o},{}],127:[function(e,t,r){arguments[4][24][0].apply(r,arguments)},{dup:24}],128:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=f;var n=e("bencode");var i=e("path");var o=e("simple-sha1");var a=e("uniq");function s(e){if(r.isBuffer(e)){e=n.decode(e)}l(e.info,"info");l(e.info.name,"info.name");l(e.info["piece length"],"info['piece length']");l(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){l(typeof e.length==="number","info.files[0].length");l(e.path,"info.files[0].path")})}else{l(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=n.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(r.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(r.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,r){var n=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(n)).slice(1),name:n[n.length-1],length:e.length,offset:s.slice(0,r).reduce(u,0)}});t.length=s.reduce(u,0);var f=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(f.offset+f.length)%t.pieceLength||t.pieceLength;t.pieces=c(e.info.pieces);return t}function f(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new r(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return n.encode(t)}function u(e,t){return e+t.length}function c(e){var t=[];for(var r=0;r<e.length;r+=20){t.push(e.slice(r,r+20).toString("hex"))}return t}function l(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:129,buffer:46,path:52,"simple-sha1":133,uniq:135}],129:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./lib/decode":130,"./lib/encode":132,dup:14}],130:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{"./dict":131,buffer:46,dup:15}],131:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{dup:16}],132:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{buffer:46,dup:17}],133:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107,rusha:134}],134:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{dup:108}],135:[function(e,t,r){arguments[4][126][0].apply(r,arguments)},{dup:126}],136:[function(e,t,r){t.exports=i;t.exports.filter=o;var n=e("events").EventEmitter;function i(e,t,r){if(!Array.isArray(r))r=[r];var n=[];r.forEach(function(r){var i=function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)};n.push(i);e.on(r,i)});return function i(){r.forEach(function(t,r){e.removeListener(t,n[r])})}}function o(e,t){var r=new n;i(e,r,t);return r}},{events:50}],137:[function(e,t,r){arguments[4][103][0].apply(r,arguments)},{dezalgo:138,dup:103}],138:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{asap:139,dup:28,wrappy:140}],139:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{_process:53,dup:29}],140:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],141:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107,rusha:142}],142:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{dup:108}],143:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],144:[function(e,t,r){(function(r){t.exports=c;var n=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 f=e("re-emitter");var u=e("bittorrent-tracker/client");s(c,o);function c(e){var t=this;if(!(t instanceof c))return new c(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(!r.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}c.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}n("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))}};c.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 r.nextTick(function(){e(null)})};c.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new i;f(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,r){if(r===t.infoHash)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};c.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};var r={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new u(e.peerId,e.port,t,r);f(e.tracker,e,["peer","warning","error"]);e.tracker.start()};c.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;n("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;n("dht announce");e.dht.announce(e.infoHash,e.port,function(){n("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"))},{_process:53,"bittorrent-dht/client":45,"bittorrent-tracker/client":145,debug:175,events:50,inherits:178,"re-emitter":179,"xtend/mutable":180}],145:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("bittorrent-tracker");var i=e("events").EventEmitter;var o=e("inherits");var a=e("once");var s=e("url");var f=e("./lib/common");var u=e("./lib/http-tracker");var c=e("./lib/udp-tracker");var l=e("./lib/websocket-tracker");o(h,i);function h(e,t,o,a){var d=this;if(!(d instanceof h))return new h(e,t,o,a);i.call(d);if(!a)a={};d._peerId=r.isBuffer(e)?e:new r(e,"hex");d._peerIdHex=d._peerId.toString("hex");d._peerIdBinary=d._peerId.toString("binary");d._infoHash=r.isBuffer(o.infoHash)?o.infoHash:new r(o.infoHash,"hex");d._infoHashHex=d._infoHash.toString("hex");d._infoHashBinary=d._infoHash.toString("binary");d._port=t;d.torrentLength=o.length;d._rtcConfig=a.rtcConfig;d._wrtc=a.wrtc;d._numWant=a.numWant||f.DEFAULT_ANNOUNCE_PEERS;d._intervalMs=a.interval||f.DEFAULT_ANNOUNCE_INTERVAL;n("new client %s",d._infoHashHex);var p={interval:d._intervalMs};var g=!!d._wrtc||typeof window!=="undefined";var m=typeof o.announce==="string"?[o.announce]:o.announce==null?[]:o.announce;d._trackers=m.map(function(e){e=e.toString();var t=s.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof u==="function"){return new u(d,e,p)}else if(t==="udp:"&&typeof c==="function"){return new c(d,e,p)}else if((t==="ws:"||t==="wss:")&&g){return new l(d,e,p)}return null}).filter(Boolean)}h.scrape=function(e,t,n){n=a(n);var i=new r("01234567890123456789");var o=6881;var s={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var f=new h(i,o,s);f.once("error",n);var u=Array.isArray(t)?t.length:1;var c={};f.on("scrape",function(e){u-=1;c[e.infoHash]=e;if(u===0){f.destroy();var t=Object.keys(c);if(t.length===1){n(null,c[t[0]])}else{n(null,c)}}});t=Array.isArray(t)?t.map(function(e){return new r(e,"hex")}):new r(t,"hex");f.scrape({infoHash:t})};h.prototype.start=function(e){var t=this;n("send `start`");e=t._defaultAnnounceOpts(e);e.event="started";t._announce(e);t._trackers.forEach(function(e){e.setInterval(t._intervalMs)})};h.prototype.stop=function(e){var t=this;n("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};h.prototype.complete=function(e){var t=this;n("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)};h.prototype.update=function(e){var t=this;n("send `update`");e=t._defaultAnnounceOpts(e);if(e.event)delete e.event;t._announce(e)};h.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})};h.prototype.scrape=function(e){var t=this;n("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};h.prototype.setInterval=function(e){var t=this;n("setInterval");t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};h.prototype.destroy=function(){var e=this;n("destroy");e._trackers.forEach(function(e){e.destroy();e.setInterval(0)});e._trackers=[]};h.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("buffer").Buffer)},{"./lib/common":147,"./lib/http-tracker":45,"./lib/udp-tracker":45,"./lib/websocket-tracker":148,buffer:46,debug:149,events:50,inherits:153,once:155,url:71}],146:[function(e,t,r){(function(t){var n=e("querystring");r.IPV4_RE=/^[\d\.]+$/;r.IPV6_RE=/^[\da-fA-F:]+$/;r.CONNECTION_ID=t.concat([i(1047),i(655366528)]);r.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};r.EVENTS={update:0,completed:1,started:2,stopped:3};r.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};r.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function i(e){var r=new t(4);r.writeUInt32BE(e,0);return r}r.toUInt32=i;r.querystringParse=function(e){var t=n.unescape;n.unescape=unescape;var r=n.parse(e);n.unescape=t;return r};r.querystringStringify=function(e){var t=n.escape;n.escape=escape;var r=n.stringify(e);r=r.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});n.escape=t;return r}}).call(this,e("buffer").Buffer)},{buffer:46,querystring:57}],147:[function(e,t,r){(function(t){var n=e("xtend/mutable");r.DEFAULT_ANNOUNCE_INTERVAL=30*60*1e3;r.DEFAULT_ANNOUNCE_PEERS=50;r.MAX_ANNOUNCE_PEERS=82;r.binaryToHex=function(e){return new t(e,"binary").toString("hex")};r.hexToBinary=function(e){return new t(e,"hex").toString("binary")};var i=e("./common-node");n(r,i)}).call(this,e("buffer").Buffer)},{"./common-node":146,buffer:46,"xtend/mutable":174}],148:[function(e,t,r){t.exports=h;var n=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 f=e("simple-websocket");var u=e("./common");var c=30*1e3;var l=5*1e3;a(h,i);function h(e,t,r){var a=this;i.call(a);n("new websocket tracker %s",t);a.client=e;a.destroyed=false;a._opts=r;a._announceUrl=t;if(a._announceUrl[a._announceUrl.length-1]!=="/")a._announceUrl+="/";a._announceUrl+="?"+o(40);a._peers={};a._socket=null;a._intervalMs=a.client._intervalMs;a._interval=null;a._openSocket()}h.prototype.announce=function(e){var t=this;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(r){e.offers=r;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};h.prototype.scrape=function(e){var t=this;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};h.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var r=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(r,t._intervalMs)}};h.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._socket.removeListener("data",e._onSocketDataBound);e._socket.removeListener("close",e._onSocketCloseBound);e._socket.removeListener("error",e._onSocketErrorBound);e._onSocketErrorBound=null;e._onSocketDataBound=null;e._onSocketCloseBound=null;e._socket.on("error",d);try{e._socket.close()}catch(t){}e._socket=null};h.prototype._openSocket=function(){var e=this;e._onSocketErrorBound=e._onSocketError.bind(e);e._onSocketDataBound=e._onSocketData.bind(e);e._onSocketCloseBound=e._onSocketClose.bind(e);e._socket=new f(e._announceUrl);e._socket.on("data",e._onSocketDataBound);e._socket.on("close",e._onSocketCloseBound);e._socket.on("error",e._onSocketErrorBound)};h.prototype._onSocketData=function(e){var t=this;if(t.destroyed)return;if(!(typeof e==="object"&&e!==null)){return t.client.emit("warning",new Error("Invalid tracker response"))}if(e.info_hash!==t.client._infoHashBinary){return t.client.emit("warning",new Error("Invalid tracker response"))}n("received %s from %s",JSON.stringify(e),t._announceUrl);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];if(i)t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];if(o&&!t._opts.interval&&t._intervalMs!==0){t.setInterval(o*1e3)}var a=e["tracker id"];if(a){t._trackerId=a}if(e.complete){t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete})}if(t.client._peerIdHex===u.binaryToHex(e.peer_id)){return}var f;if(e.offer){f=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});f.id=u.binaryToHex(e.peer_id);f.once("signal",function(r){var n={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)});f.signal(e.offer);t.client.emit("peer",f)}if(e.answer){f=t._peers[u.binaryToHex(e.offer_id)];if(f){f.id=u.binaryToHex(e.peer_id);f.signal(e.answer);t.client.emit("peer",f)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};h.prototype._onSocketClose=function(){var e=this;e.destroy();var t=Math.floor(Math.random()*c)+l;setTimeout(function(){e._openSocket()},t);n("reconnecting socket in %s ms",t)};h.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.client.emit("error",e)};h.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);n("send %s",r);t._socket.send(r)};h.prototype._generateOffers=function(e,t){var r=this;var i=[];n("generating %s offers",e);for(var a=0;a<e;++a){f()}function f(){var e=o(160);var t=r._peers[e]=new s({initiator:true,trickle:false,config:r.client._rtcConfig,wrtc:r.client._wrtc});t.once("signal",function(t){i.push({offer:t,offer_id:u.hexToBinary(e)});c()})}function c(){if(i.length===e){n("generated %s offers",e);t(i)}}};function d(){}},{"./common":147,debug:149,events:50,hat:152,inherits:153,"simple-peer":156,"simple-websocket":166}],149:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{"./debug":150,dup:19}],150:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,ms:151}],151:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],152:[function(e,t,r){arguments[4][116][0].apply(r,arguments)},{dup:116}],153:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],154:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],155:[function(e,t,r){arguments[4][100][0].apply(r,arguments)},{dup:100,wrappy:154}],156:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-peer");var i=e("hat");var o=e("inherits");var a=e("is-typedarray");var s=e("once");var f=e("stream");var u=e("typedarray-to-buffer");o(c,f.Duplex);function c(e){var t=this;if(!(t instanceof c))return new c(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||c.channelConfig;t.channelName=e.channelName||i(160);if(!e.initiator)t.channelName=null;t.config=e.config||c.config;t.constraints=e.constraints||c.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||l();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=s(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)})}})}c.WEBRTC_SUPPORT=!!l();c.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};c.constraints={};c.channelConfig={};Object.defineProperty(c.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}});c.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}};c.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(r){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),d,t._onError.bind(t))}catch(r){t._destroy(new Error("error adding candidate: "+r.message))}}if(!e.sdp&&!e.candidate){t._destroy(new Error("signal() called with invalid signal data"))}};c.prototype.send=function(e){var t=this;if(!a.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}if(r.isBuffer(e)&&!a.strict(e)){e=new Uint8Array(e)}var n=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",n)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);r._debug("destroy (error: %s)",e&&e.message);r.readable=r.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.destroyed=true;r.connected=false;r._pcReady=false;r._channelReady=false;r._chunk=null;r._cb=null;clearInterval(r._interval);clearTimeout(r._reconnectTimeout);
+if(r._pc){try{r._pc.close()}catch(e){}r._pc.oniceconnectionstatechange=null;r._pc.onsignalingstatechange=null;r._pc.onicecandidate=null}if(r._channel){try{r._channel.close()}catch(e){}r._channel.onmessage=null;r._channel.onopen=null;r._channel.onclose=null}r._pc=null;r._channel=null;if(e)r.emit("error",e);r.emit("close")};c.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)};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var n=this;if(n.destroyed)return r(new Error("cannot write after peer is destroyed"));if(n.connected){n.send(e);if(n._channel.bufferedAmount>n._maxBufferedAmount){n._debug("start backpressure: bufferedAmount %d",n._channel.bufferedAmount);n._cb=r}else{r(null)}}else{n._debug("write before connect");n._chunk=e;n._cb=r}};c.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.offerConstraints)};c.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.answerConstraints)};c.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,r);e.emit("iceConnectionStateChange",t,r);if(r==="connected"||r==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(r==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(r==="closed"){e._destroy()}};c.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(e.connected||e._connecting||!e._pcReady||!e._channelReady)return;e._connecting=true;if(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.remoteFamily="IPv4";e.remotePort=Number(t.portNumber);e._debug("connect remote: %s:%s (%s)",e.remoteAddress,e.remotePort,e.remoteFamily)}else if(t.type==="localcandidate"&&t.candidateType==="host"){e.localAddress=t.ipAddress;e.localPort=Number(t.portNumber);e._debug("connect local: %s:%s",e.localAddress,e.localPort)}});e._connecting=false;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;e._debug('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}e._interval=setInterval(function(){if(!e._cb||!e._channel||e._channel.bufferedAmount>e._maxBufferedAmount)return;e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref();e._debug("connect");e.emit("connect")}};c.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};c.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:e.candidate})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};c.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var r=e.data;t._debug("read: %d bytes",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=u(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};c.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};c.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};c.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};c.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};c.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var r=e.channelName&&e.channelName.substring(0,7);t[0]="["+r+"] "+t[0];n.apply(null,t)};function l(){if(typeof window==="undefined")return null;var e={RTCPeerConnection:window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate};if(!e.RTCPeerConnection)return null;return e}function h(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function d(){}}).call(this,e("buffer").Buffer)},{buffer:46,debug:157,hat:160,inherits:161,"is-typedarray":162,once:164,stream:69,"typedarray-to-buffer":165}],157:[function(e,t,r){arguments[4][109][0].apply(r,arguments)},{"./debug":158,dup:109}],158:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,ms:159}],159:[function(e,t,r){arguments[4][111][0].apply(r,arguments)},{dup:111}],160:[function(e,t,r){arguments[4][116][0].apply(r,arguments)},{dup:116}],161:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],162:[function(e,t,r){arguments[4][94][0].apply(r,arguments)},{dup:94}],163:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30}],164:[function(e,t,r){arguments[4][100][0].apply(r,arguments)},{dup:100,wrappy:163}],165:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{buffer:46,dup:93,"is-typedarray":162}],166:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var a=e("stream");var s=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;i(c,a.Duplex);function c(e,t){var r=this;if(!(r instanceof c))return new c(e,t);if(!t)t={};n("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;a.Duplex.call(r,t);r.url=e;r.connected=false;r.destroyed=false;r._maxBufferedAmount=t.highWaterMark;r._chunk=null;r._cb=null;r._interval=null;r._ws=new u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=r._onError.bind(r);r.on("finish",function(){if(r.connected){setTimeout(function(){r._destroy()},100)}else{r.once("connect",function(){setTimeout(function(){r._destroy()},100)})}})}c.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}var i=e.length||e.byteLength||e.size;t._ws.send(e);n("write: %d bytes",i)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);n("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.connected=false;r.destroyed=true;clearInterval(r._interval);r._interval=null;r._chunk=null;r._cb=null;if(r._ws){try{r._ws.close()}catch(e){}r._ws.onopen=null;r._ws.onmessage=null;r._ws.onclose=null;r._ws.onerror=null}r._ws=null;if(e)r.emit("error",e);r.emit("close")};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var i=this;if(i.destroyed)return r(new Error("cannot write after socket is destroyed"));if(i.connected){i.send(e);if(typeof f!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){n("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=r}else{r(null)}}else{n("write before connect");i._chunk=e;i._cb=r}};c.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;n("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=s(new Uint8Array(i));t.push(i)}else if(r.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};c.prototype._onOpen=function(){var e=this;if(e.connected||e.destroyed)return;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;n('sent chunk from "write before connect"');var t=e._cb;e._cb=null;t(null)}if(typeof f!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}n("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}n("connect");e.emit("connect")};c.prototype._onClose=function(){var e=this;if(e.destroyed)return;n("on close");e._destroy()};c.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);n("error: %s",t.message||t);e._destroy(t)}}).call(this,e("buffer").Buffer)},{buffer:46,debug:167,inherits:170,"is-typedarray":171,stream:69,"typedarray-to-buffer":172,ws:45}],167:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{"./debug":168,dup:19}],168:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,ms:169}],169:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],170:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],171:[function(e,t,r){arguments[4][94][0].apply(r,arguments)},{dup:94}],172:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{buffer:46,dup:93,"is-typedarray":173}],173:[function(e,t,r){arguments[4][94][0].apply(r,arguments)},{dup:94}],174:[function(e,t,r){t.exports=n;function n(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r){if(r.hasOwnProperty(n)){e[n]=r[n]}}}return e}},{}],175:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{"./debug":176,dup:19}],176:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,ms:177}],177:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],178:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],179:[function(e,t,r){arguments[4][136][0].apply(r,arguments)},{dup:136,events:50}],180:[function(e,t,r){arguments[4][174][0].apply(r,arguments)},{dup:174}],181:[function(e,t,r){arguments[4][126][0].apply(r,arguments)},{dup:126}],182:[function(e,t,r){(function(r){var n=e("bencode");var i=e("bitfield");var o=e("events").EventEmitter;var a=e("inherits");var s=e("simple-sha1");var f=1e7;var u=1e3;var c=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:u});if(r.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,r){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>f){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/c);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var i=e.toString();var o=i.indexOf("ee")+2;t=n.decode(i.substring(0,o));r=e.slice(o)}catch(a){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);break}};t.prototype.fetch=function(){if(this._metadataComplete){return}this._fetching=true;if(this._metadataSize){this._requestPieces()}};t.prototype.cancel=function(){this._fetching=false};t.prototype.setMetadata=function(e){if(this._metadataComplete)return true;try{var t=n.decode(e).info;if(t){e=n.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==s.sync(e)){return false}this.cancel();this.metadata=e;this._metadataComplete=true;this._metadataSize=this.metadata.length;this._wire.extendedHandshake.metadata_size=this._metadataSize;this.emit("metadata",n.encode({info:n.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=n.encode(e);if(r.isBuffer(t)){i=r.concat([i,t])}this._wire.extended("ut_metadata",i)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var n={msg_type:1,piece:e};if(typeof r==="number"){n.total_size=r}this._send(n,t)};t.prototype._reject=function(e){this._send({msg_type:2,piece:e})};t.prototype._onRequest=function(e){if(!this._metadataComplete){this._reject(e);return}var t=e*c;var r=t+c;if(r>this._metadataSize){r=this._metadataSize}var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>c){return}t.copy(this.metadata,e*c);this._bitfield.set(e);this._checkDone()};t.prototype._onReject=function(e){if(this._remainingRejects>0&&this._fetching){this._request(e);this._remainingRejects-=1}else{this.emit("warning",new Error('Peer sent "reject" too much'))}};t.prototype._requestPieces=function(){this.metadata=new r(this._metadataSize);for(var e=0;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 r=this.setMetadata(this.metadata);if(!r){this._failedMetadata()}};t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:u});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:183,bitfield:187,buffer:46,events:50,inherits:188,"simple-sha1":189}],183:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./lib/decode":184,"./lib/encode":186,dup:14}],184:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{"./dict":185,buffer:46,dup:15}],185:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{dup:16}],186:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{buffer:46,dup:17}],187:[function(e,t,r){arguments[4][9][0].apply(r,arguments)},{buffer:46,dup:9}],188:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],189:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107,rusha:190}],190:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{dup:108}],191:[function(e,t,r){arguments[4][24][0].apply(r,arguments)},{dup:24}],192:[function(e,t,r){t.exports=function n(e,t,r){if(t===undefined){return function(t,r){return n(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}],193:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.47.0",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./server":false,"bittorrent-dht/client":false,"load-ip-set":false,"simple-get":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","block-stream2":"^1.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^5.0.0","pretty-bytes":"^1.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-get":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^4.0.0",brfs:"^1.2.0",browserify:"^10.0.0","run-auto":"^1.0.0",standard:"^3.1.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}]},{},[1])(1)});