!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.WebTorrent=e()}}(function(){var e;return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s0?t[Math.random()*t.length|0]:-1},r.prototype.destroy=function(){var e=this;e._torrent.removeListener("wire",e._onWire),e._torrent.wires.forEach(function(t){e._cleanupWireEvents(t)}),e._torrent=null,e._pieces=null,e._onWire=null,e._onWireHave=null,e._onWireBitfield=null},r.prototype._initWire=function(e){var t=this;e._onClose=function(){t._cleanupWireEvents(e);for(var n=0;n65536)return r._debug("ignoring invalid PORT from peer");r._debug("port: %s (from %s)",n,t),r.client.dht.addNode({host:e.remoteAddress,port:n})}}),e.on("timeout",function(){r._debug("wire timeout (%s)",t),e.destroy()}),e.setTimeout(z,!0),e.setKeepAlive(!0),e.use(M(r.metadata)),e.ut_metadata.on("warning",function(e){r._debug("ut_metadata warning: %s",e.message)}),r.metadata||(e.ut_metadata.on("metadata",function(e){r._debug("got metadata via ut_metadata"),r._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof j||r.private||(e.use(j()),e.ut_pex.on("peer",function(e){r.done||(r._debug("ut_pex: got peer: %s (from %s)",e,t),r.addPeer(e))}),e.ut_pex.on("dropped",function(e){var n=r._peers[e];n&&!n.connected&&(r._debug("ut_pex: dropped peer: %s (from %s)",e,t),r.removePeer(e))}),e.once("close",function(){e.ut_pex.reset()})),r.emit("wire",e,t),r.metadata&&n.nextTick(function(){r._onWireWithMetadata(e)})},o.prototype._onWireWithMetadata=function(e){function t(){r.destroyed||e.destroyed||(r._numQueued>2*(r._numConns-r.numPeers)&&e.amInterested?e.destroy():(o=setTimeout(t,F),o.unref&&o.unref()))}function n(){if(e.peerPieces.length===r.pieces.length){for(;iW?e.destroy():void(r.pieces[t]||r.store.get(t,{offset:n,length:o},i))}),e.bitfield(r.bitfield),e.interested(),e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening&&e.port(r.client.dht.address().port),"webSeed"!==e.type&&(o=setTimeout(t,F),o.unref&&o.unref()),e.isSeeder=!1,n()},o.prototype._updateSelections=function(){var e=this;e.ready&&!e.destroyed&&(n.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},o.prototype._gcSelections=function(){var e,t=this,n=[];for(e=0;e0){for(e=n.length-1;e>=0;--e)t._selections.splice(e,1);r.notify(),t._updateInterest()}t._selections.length||t.emit("idle")},o.prototype._updateInterest=function(){var e=this,t=e._amInterested;e._amInterested=!!e._selections.length,e.wires.forEach(function(t){e._amInterested?t.interested():t.uninterested()}),t!==e._amInterested&&(e._amInterested?e.emit("interested"):e.emit("uninterested"))},o.prototype._update=function(){var e=this;if(!e.destroyed)for(var t,n=U(e.wires);t=n();)e._updateWire(t)},o.prototype._updateWire=function(e){function t(t,n,r,o){return function(i){return i>=t&&i<=n&&!(i in r)&&e.peerPieces.get(i)&&(!o||o(i))}}function n(){if(!e.requests.length)for(var n=a._selections.length;n--;){var r,o=a._selections[n];if("rarest"===a.strategy)for(var i=o.from+o.offset,s=o.to,u=s-i+1,c={},f=0,d=t(i,s,c);f=o.from+o.offset;--r)if(e.peerPieces.get(r)&&a._request(e,r,!1))return}}function r(){var t=e.downloadSpeed()||1;if(t>V)return function(){return!0};var n=Math.max(1,e.requests.length)*L.BLOCK_LENGTH/t,r=10,o=0;return function(e){if(!r||a.bitfield.get(e))return!0;for(var i=a.pieces[e].missing;o0))return r--,!1}return!0}}function o(e){for(var t=e,n=e;n=c)return!0;for(var i=r(),s=0;s=u)){var c=i(e,$);s(!1)||s(!0)}}},o.prototype._rechoke=function(){function e(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt}var t=this;if(t.ready){t._rechokeOptimisticTime>0?t._rechokeOptimisticTime-=1:t._rechokeOptimisticWire=null;var n=[];t.wires.forEach(function(e){e.isSeeder||e===t._rechokeOptimisticWire||n.push({wire:e,downloadSpeed:e.downloadSpeed(),uploadSpeed:e.uploadSpeed(),salt:Math.random(),isChoked:!0})}),n.sort(e);for(var r=0,o=0;o=V||2*c>r||c>a||(i=u,a=c)}}if(!i)return!1;for(s=0;s=f)return!1;var d=a.pieces[t],h=c?d.reserveRemaining():d.reserve();if(h===-1&&r&&a._hotswap(e,t)&&(h=c?d.reserveRemaining():d.reserve()),h===-1)return!1;var l=a._reservations[t];l||(l=a._reservations[t]=[]);var p=l.indexOf(null);p===-1&&(p=l.length),l[p]=e;var m=d.chunkOffset(h),g=c?d.chunkLengthRemaining(h):d.chunkLength(h);return e.request(t,m,g,function n(r,i){if(!a.ready)return a.once("ready",function(){n(r,i)});if(l[p]===e&&(l[p]=null),d!==a.pieces[t])return o();if(r)return a._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,m,g,e.remoteAddress+":"+e.remotePort,r.message),c?d.cancelRemaining(h):d.cancel(h),void o();if(a._debug("got piece %s (offset: %s length: %s) from %s",t,m,g,e.remoteAddress+":"+e.remotePort),!d.set(h,i,e))return o();var s=d.flush();R(s,function(e){if(!a.destroyed){if(e===a._hashes[t]){if(!a.pieces[t])return;a._debug("piece verified %s",t),a.pieces[t]=null,a._reservations[t]=null,a.bitfield.set(t,!0),a.store.put(t,s),a.wires.forEach(function(e){e.have(t)}),a._checkDone()&&!a.destroyed&&a.discovery.complete()}else a.pieces[t]=new L(d.length),a.emit("warning",new Error("Piece "+t+" failed verification"));o()}})}),!0},o.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var n=t._startPiece;n<=t._endPiece;++n)if(!e.bitfield.get(n))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,n=0;n=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);var t=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);var n=f(t.addr),r={host:n[0],port:n[1]},o=t.conn=x.connect(r);o.once("connect",function(){t.onConnect()}),o.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),o.on("close",function(){if(!e.destroyed){if(t.retries>=Y.length)return void e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,Y.length);var n=Y[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var r=setTimeout(function(){var n=e._addPeer(t.addr);n&&(n.retries=t.retries+1)},n);r.unref&&r.unref()}})}}},o.prototype._validAddr=function(e){var t;try{t=f(e)}catch(e){return!1}var n=t[0],r=t[1];return r>0&&r<65535&&!("127.0.0.1"===n&&r===this.client.torrentPort)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../package.json":122,"./file":2,"./peer":3,"./rarity-map":4,"./server":21,_process:67,"addr-to-ip-port":7,bitfield:13,"chunk-store-stream/write":26,debug:30,events:35,fs:22,"fs-chunk-store":51,"immediate-chunk-store":41,inherits:42,multistream:59,net:21,os:21,"parse-torrent":63,path:64,pump:68,"random-iterate":73,"run-parallel":86,"run-parallel-limit":85,"simple-get":90,"simple-sha1":92,speedometer:94,"torrent-discovery":106,"torrent-piece":107,uniq:110,ut_metadata:114,ut_pex:21,xtend:119,"xtend/mutable":120}],6:[function(e,t,n){function r(e,t){f.call(this),this.url=e,this.webPeerId=c.sync(e),this._torrent=t,this._init()}t.exports=r;var o=e("bitfield"),i=e("safe-buffer").Buffer,s=e("debug")("webtorrent:webconn"),a=e("simple-get"),u=e("inherits"),c=e("simple-sha1"),f=e("bittorrent-protocol"),d=e("../package.json").version;u(r,f),r.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t,n){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var r=e._torrent.pieces.length,i=new o(r),s=0;s<=r;s++)i.set(s,!0);e.bitfield(i)}}),e.once("interested",function(){s("interested"),e.unchoke()}),e.on("uninterested",function(){s("uninterested")}),e.on("choke",function(){s("choke")}),e.on("unchoke",function(){s("unchoke")}),e.on("bitfield",function(){s("bitfield")}),e.on("request",function(t,n,r,o){s("request pieceIndex=%d offset=%d length=%d",t,n,r),e.httpRequest(t,n,r,o)})},r.prototype.httpRequest=function(e,t,n,r){var o,u=this,c=e*u._torrent.pieceLength,f=c+t,h=f+n-1,l=u._torrent.files;if(l.length<=1)o=[{url:u.url,start:f,end:h}];else{var p=l.filter(function(e){return e.offset<=h&&e.offset+e.length>f});if(p.length<1)return r(new Error("Could not find file corresponnding to web seed range request"));o=p.map(function(e){var t=e.offset+e.length-1,n=u.url+("/"===u.url[u.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:Math.max(e.offset-f,0),start:Math.max(f-e.offset,0),end:Math.min(t,h-e.offset)}})}var m,g=0,y=!1;o.length>1&&(m=i.alloc(n)),o.forEach(function(i){function u(e,t){return e.statusCode<200||e.statusCode>=300?(y=!0,r(new Error("Unexpected HTTP status code "+e.statusCode))):(s("Got data of length %d",t.length),void(1===o.length?r(null,t):(t.copy(m,i.fileOffsetInRange),++g===o.length&&r(null,m))))}var c=i.url,f=i.start,h=i.end;s("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",c,e,t,n,f,h);var l={url:c,method:"GET",headers:{"user-agent":"WebTorrent/"+d+" (https://webtorrent.io)",range:"bytes="+f+"-"+h}};a.concat(l,function(e,t,n){if(!y)return e?"undefined"==typeof window||c.startsWith(window.location.origin+"/")?(y=!0,r(e)):a.head(c,function(t,n){if(!y){if(t)return y=!0,r(t);if(n.statusCode<200||n.statusCode>=300)return y=!0,r(new Error("Unexpected HTTP status code "+n.statusCode));if(n.url===c)return y=!0,r(e);l.url=n.url,a.concat(l,function(e,t,n){if(!y)return e?(y=!0,r(e)):void u(t,n)})}}):void u(t,n)})})},r.prototype.destroy=function(){f.prototype.destroy.call(this),this._torrent=null}},{"../package.json":122,bitfield:13,"bittorrent-protocol":14,debug:30,inherits:42,"safe-buffer":88,"simple-get":90,"simple-sha1":92}],7:[function(e,t,n){var r=/^\[?([^\]]+)\]?:(\d+)$/,o={},i=0;t.exports=function(e){if(1e5===i&&t.exports.reset(),!o[e]){var n=r.exec(e);if(!n)throw new Error("invalid addr: "+e);o[e]=[n[1],Number(n[2])],i+=1}return o[e]},t.exports.reset=function(){o={},i=0}},{}],8:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function o(e){return 3*e.length/4-r(e)}function i(e){var t,n,o,i,s,a,u=e.length;s=r(e),a=new d(3*u/4-s),o=s>0?u-4:u;var c=0;for(t=0,n=0;t>16&255,a[c++]=i>>8&255,a[c++]=255&i;return 2===s?(i=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,a[c++]=255&i):1===s&&(i=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,a[c++]=i>>8&255,a[c++]=255&i),a}function s(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function a(e,t,n){for(var r,o=[],i=t;if?f:u+s));return 1===r?(t=e[n-1],o+=c[t>>2],o+=c[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=c[t>>10],o+=c[t>>4&63],o+=c[t<<2&63],o+="="),i.push(o),i.join("")}n.byteLength=o,n.toByteArray=i,n.fromByteArray=u;for(var c=[],f=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=h.length;l=48)r=10*r+(s-48);else if(i!==t||43!==s){if(i!==t||45!==s){if(46===s)break;throw new Error("not a number: buffer["+i+"] = "+s)}o=-1}}return r*o}function r(t,n,o,i){return null==t||0===t.length?null:("number"!=typeof n&&null==i&&(i=n,n=void 0),"number"!=typeof o&&null==i&&(i=o,o=void 0),r.position=0,r.encoding=i||null,r.data=e.isBuffer(t)?t.slice(n,o):new e(t),r.bytes=r.data.length,r.next())}r.bytes=0,r.position=0,r.data=null,r.encoding=null,r.next=function(){switch(r.data[r.position]){case 100:return r.dictionary();case 108:return r.list();case 105:return r.integer();default:return r.buffer()}},r.find=function(e){for(var t=r.position,n=r.data.length,o=r.data;t=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o|=0,o=e.length)throw new RangeError("invalid upper bound");for(;r<=o;)if(i=r+(o-r>>1),s=+n(e[i],t,i,e),s<0)r=i+1;else{if(!(s>0))return i;o=i-1}return~r}},{}],13:[function(e,t,n){(function(e){function n(e,t){return this instanceof n?(0===arguments.length&&(e=0),this.grow=t&&(isFinite(t.grow)&&r(t.grow)||t.grow)||0,"number"!=typeof e&&void 0!==e||(e=new o(r(e)),e.fill&&!e._isBuffer&&e.fill(0)),void(this.buffer=e)):new n(e,t)}function r(e){var t=e>>3;return e%8!==0&&t++,t}var o="undefined"!=typeof e?e:"undefined"!=typeof Int8Array?Int8Array:function(e){for(var t=new Array(e),n=0;n>3;return t>e%8)},n.prototype.set=function(e,t){var n=e>>3;t||1===arguments.length?(this.buffer.length>e%8):n>e%8))},n.prototype._grow=function(e){if(this.buffer.length=this._parserSize;){var r=1===this._buffer.length?this._buffer[0]:c.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[r.slice(this._parserSize)]:[],this._parser(r.slice(0,this._parserSize))}n(null)},o.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,n))},o.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},o.prototype._updateTimeout=function(){var e=this;e._timeoutMs&&e.requests.length&&!e._timeout&&(e._timeout=setTimeout(function(){e._onTimeout()},e._timeoutMs),e._timeoutUnref&&e._timeout.unref&&e._timeout.unref())},o.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},o.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))},o.prototype._onMessage=function(e){switch(this._parse(4,this._onMessageLength),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._debug("got unknown message"),this.emit("unknownmessage",e)}},o.prototype._parseHandshake=function(){var e=this;e._parse(1,function(t){var n=t.readUInt8(0);e._parse(n+48,function(t){var r=t.slice(0,n);return"BitTorrent protocol"!==r.toString()?(e._debug("Error: wire not speaking BitTorrent protocol (%s)",r.toString()),void e.end()):(t=t.slice(n),e._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),void e._parse(4,e._onMessageLength))})})},o.prototype._onFinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,function(){});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)},o.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],f.apply(null,e)}},{bencode:11,bitfield:13,debug:30,inherits:42,randombytes:74,"readable-stream":82,"safe-buffer":88,speedometer:94,"unordered-array-remove":111,xtend:119}],15:[function(e,t,n){(function(n){function r(e){function t(e){n.nextTick(function(){a.emit("warning",e)})}var a=this;if(!(a instanceof r))return new r(e);if(s.call(a),e||(e={}),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");a.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),a._peerIdBuffer=o.from(a.peerId,"hex"),a._peerIdBinary=a._peerIdBuffer.toString("binary"),a.infoHash="string"==typeof e.infoHash?e.infoHash:e.infoHash.toString("hex"),a._infoHashBuffer=o.from(a.infoHash,"hex"),a._infoHashBinary=a._infoHashBuffer.toString("binary"),i("new client %s",a.infoHash),a.destroyed=!1,a._port=e.port,a._getAnnounceOpts=e.getAnnounceOpts,a._rtcConfig=e.rtcConfig,a._userAgent=e.userAgent,a._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc,a._socketPool={};var u="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;u=u.map(function(e){return e=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}),u=h(u);var c=a._wrtc!==!1&&(!!a._wrtc||d.WEBRTC_SUPPORT);a._trackers=u.map(function(e){var n=l.parse(e).protocol;return"http:"!==n&&"https:"!==n||"function"!=typeof m?"udp:"===n&&"function"==typeof g?new g(a,e):"ws:"!==n&&"wss:"!==n||!c?(t(new Error("Unsupported tracker protocol: "+e)),null):"ws:"===n&&"undefined"!=typeof window&&"https:"===window.location.protocol?(t(new Error("Unsupported tracker protocol: "+e)),null):new y(a,e):new m(a,e)}).filter(Boolean)}t.exports=r;var o=e("safe-buffer").Buffer,i=e("debug")("bittorrent-tracker:client"),s=e("events").EventEmitter,a=e("xtend"),u=e("inherits"),c=e("once"),f=e("run-parallel"),d=e("simple-peer"),h=e("uniq"),l=e("url"),p=e("./lib/common"),m=e("./lib/client/http-tracker"),g=e("./lib/client/udp-tracker"),y=e("./lib/client/websocket-tracker");u(r,s),r.scrape=function(e,t){if(t=c(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");var n=a(e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:o.from("01234567890123456789"),port:6881}),i=new r(n);i.once("error",t),i.once("warning",t);var s=Array.isArray(e.infoHash)?e.infoHash.length:1,u={};return i.on("scrape",function(e){if(s-=1,u[e.infoHash]=e,0===s){i.destroy();var n=Object.keys(u);1===n.length?t(null,u[n[0]]):t(null,u)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(function(e){return o.from(e,"hex")}):o.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i},r.prototype.start=function(e){var t=this;i("send `start`"),e=t._defaultAnnounceOpts(e),e.event="started",t._announce(e),t._trackers.forEach(function(e){e.setInterval()})},r.prototype.stop=function(e){var t=this;i("send `stop`"),e=t._defaultAnnounceOpts(e),e.event="stopped",t._announce(e)},r.prototype.complete=function(e){var t=this;i("send `complete`"),e||(e={}),e=t._defaultAnnounceOpts(e),e.event="completed",t._announce(e)},r.prototype.update=function(e){var t=this;i("send `update`"),e=t._defaultAnnounceOpts(e),e.event&&delete e.event,t._announce(e)},r.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})},r.prototype.scrape=function(e){var t=this;i("send `scrape`"),e||(e={}),t._trackers.forEach(function(t){t.scrape(e)})},r.prototype.setInterval=function(e){var t=this;i("setInterval %d",e),t._trackers.forEach(function(t){t.setInterval(e)})},r.prototype.destroy=function(e){var t=this;if(!t.destroyed){t.destroyed=!0,i("destroy");var n=t._trackers.map(function(e){return function(t){e.destroy(t)}});f(n,e),t._trackers=[],t._getAnnounceOpts=null}},r.prototype._defaultAnnounceOpts=function(e){var t=this;return e||(e={}),null==e.numwant&&(e.numwant=p.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),t._getAnnounceOpts&&(e=a(e,t._getAnnounceOpts())),e}}).call(this,e("_process"))},{"./lib/client/http-tracker":21,"./lib/client/udp-tracker":21,"./lib/client/websocket-tracker":17,"./lib/common":18,_process:67,debug:30,events:35,inherits:42,once:61,"run-parallel":86,"safe-buffer":88,"simple-peer":91,uniq:110,url:112,xtend:119}],16:[function(e,t,n){function r(e,t){var n=this;o.call(n),n.client=e,n.announceUrl=t,n.interval=null,n.destroyed=!1}t.exports=r;var o=e("events").EventEmitter,i=e("inherits");i(r,o),r.prototype.setInterval=function(e){var t=this;null==e&&(e=t.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(t.interval),e&&(t.interval=setInterval(function(){t.announce(t.client._defaultAnnounceOpts())},e),t.interval.unref&&t.interval.unref())}},{events:35,inherits:42}],17:[function(e,t,n){function r(e,t,n){var r=this;h.call(r,e,t),i("new websocket tracker %s",t),r.peers={},r.socket=null,r.reconnecting=!1,r.retries=0,r.reconnectTimer=null,r.expectingResponse=!1,r._openSocket()}function o(){}t.exports=r;var i=e("debug")("bittorrent-tracker:websocket-tracker"),s=e("xtend"),a=e("inherits"),u=e("simple-peer"),c=e("randombytes"),f=e("simple-websocket"),d=e("../common"),h=e("./tracker"),l=15e3,p=18e5,m=3e4,g=5e4;a(r,h),r.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,r.prototype.announce=function(e){var t=this;if(!t.destroyed&&!t.reconnecting){if(!t.socket.connected)return void t.socket.once("connect",function(){t.announce(e)});var n=s(e,{action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary});if(t._trackerId&&(n.trackerid=t._trackerId),"stopped"===e.event||"completed"===e.event)t._send(n);else{var r=Math.min(e.numwant,10);t._generateOffers(r,function(e){n.numwant=r,n.offers=e,t._send(n)})}}},r.prototype.scrape=function(e){var t=this;if(!t.destroyed&&!t.reconnecting){if(!t.socket.connected)return void t.socket.once("connect",function(){t.scrape(e)});var n=Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(function(e){return e.toString("binary")}):e.infoHash&&e.infoHash.toString("binary")||t.client._infoHashBinary,r={action:"scrape",info_hash:n};t._send(r)}},r.prototype.destroy=function(e){function t(){a&&(clearTimeout(a),a=null),s.removeListener("data",t),s.destroy(),s=null}var n=this;if(e||(e=o),n.destroyed)return e(null);n.destroyed=!0,clearInterval(n.interval),clearTimeout(n.reconnectTimer);for(var r in n.peers){var i=n.peers[r];clearTimeout(i.trackerTimeout),i.destroy()}if(n.peers=null,n.socket&&(n.socket.removeListener("connect",n._onSocketConnectBound),n.socket.removeListener("data",n._onSocketDataBound),n.socket.removeListener("close",n._onSocketCloseBound),n.socket.removeListener("error",n._onSocketErrorBound),n.socket=null),n._onSocketConnectBound=null,n._onSocketErrorBound=null,n._onSocketDataBound=null,n._onSocketCloseBound=null,n.client._socketPool[n.announceUrl]&&(n.client._socketPool[n.announceUrl].consumers-=1),n.client._socketPool[n.announceUrl].consumers>0)return e();var s=n.client._socketPool[n.announceUrl];if(delete n.client._socketPool[n.announceUrl],s.on("error",o),s.once("close",e),!n.expectingResponse)return t();var a=setTimeout(t,d.DESTROY_TIMEOUT);s.once("data",t)},r.prototype._openSocket=function(){var e=this;e.destroyed=!1,e.peers||(e.peers={}),e._onSocketConnectBound=function(){e._onSocketConnect()},e._onSocketErrorBound=function(t){e._onSocketError(t)},e._onSocketDataBound=function(t){e._onSocketData(t)},e._onSocketCloseBound=function(){e._onSocketClose()},e.socket=e.client._socketPool[e.announceUrl],e.socket?e.client._socketPool[e.announceUrl].consumers+=1:(e.socket=e.client._socketPool[e.announceUrl]=new f(e.announceUrl),e.socket.consumers=1,e.socket.once("connect",e._onSocketConnectBound)),e.socket.on("data",e._onSocketDataBound),e.socket.once("close",e._onSocketCloseBound),e.socket.once("error",e._onSocketErrorBound)},r.prototype._onSocketConnect=function(){var e=this;e.destroyed||e.reconnecting&&(e.reconnecting=!1,e.retries=0,e.announce(e.client._defaultAnnounceOpts()))},r.prototype._onSocketData=function(e){var t=this;if(!t.destroyed){t.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void t.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?t._onAnnounceResponse(e):"scrape"===e.action?t._onScrapeResponse(e):t._onSocketError(new Error("invalid action in WS response: "+e.action))}},r.prototype._onAnnounceResponse=function(e){var t=this;if(e.info_hash!==t.client._infoHashBinary)return void i("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,d.binaryToHex(e.info_hash),t.client.infoHash);if(!e.peer_id||e.peer_id!==t.client._peerIdBinary){i("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client.infoHash);var n=e["failure reason"];if(n)return t.client.emit("warning",new Error(n));var r=e["warning message"];r&&t.client.emit("warning",new Error(r));var o=e.interval||e["min interval"];o&&t.setInterval(1e3*o);var s=e["tracker id"];s&&(t._trackerId=s),null!=e.complete&&t.client.emit("update",{announce:t.announceUrl,complete:e.complete,incomplete:e.incomplete});var a;if(e.offer&&e.peer_id&&(i("creating peer (from remote offer)"),a=new u({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc}),a.id=d.binaryToHex(e.peer_id),a.once("signal",function(n){var r={action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};t._trackerId&&(r.trackerid=t._trackerId),t._send(r)}),a.signal(e.offer),t.client.emit("peer",a)),e.answer&&e.peer_id){var c=d.binaryToHex(e.offer_id);a=t.peers[c],a?(a.id=d.binaryToHex(e.peer_id),a.signal(e.answer),t.client.emit("peer",a),clearTimeout(a.trackerTimeout),a.trackerTimeout=null,delete t.peers[c]):i("got unexpected answer: "+JSON.stringify(e.answer))}}},r.prototype._onScrapeResponse=function(e){var t=this;e=e.files||{};var n=Object.keys(e);return 0===n.length?void t.client.emit("warning",new Error("invalid scrape response")):void n.forEach(function(n){var r=e[n];t.client.emit("scrape",{announce:t.announceUrl,infoHash:d.binaryToHex(n),complete:r.complete,incomplete:r.incomplete,downloaded:r.downloaded})})},r.prototype._onSocketClose=function(){var e=this;e.destroyed||(e.destroy(),e._startReconnectTimer())},r.prototype._onSocketError=function(e){var t=this;t.destroyed||(t.destroy(), t.client.emit("warning",e),t._startReconnectTimer())},r.prototype._startReconnectTimer=function(){var e=this,t=Math.floor(Math.random()*m)+Math.min(Math.pow(2,e.retries)*l,p);e.reconnecting=!0,clearTimeout(e.reconnectTimer),e.reconnectTimer=setTimeout(function(){e.retries++,e._openSocket()},t),e.reconnectTimer.unref&&e.reconnectTimer.unref(),i("reconnecting socket in %s ms",t)},r.prototype._send=function(e){var t=this;if(!t.destroyed){t.expectingResponse=!0;var n=JSON.stringify(e);i("send %s",n),t.socket.send(n)}},r.prototype._generateOffers=function(e,t){function n(){var e=c(20).toString("hex");i("creating peer (from _generateOffers)");var t=o.peers[e]=new u({initiator:!0,trickle:!1,config:o.client._rtcConfig,wrtc:o.client._wrtc});t.once("signal",function(t){s.push({offer:t,offer_id:d.hexToBinary(e)}),r()}),t.trackerTimeout=setTimeout(function(){i("tracker timeout: destroying peer"),t.trackerTimeout=null,delete o.peers[e],t.destroy()},g),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function r(){s.length===e&&(i("generated %s offers",e),t(s))}var o=this,s=[];i("generating %s offers",e);for(var a=0;a=this.size;){var o=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(o.slice(0,this.size)),this._buffered=[o.slice(this.size,o.length)]}r()},r.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new n(this.size-this._bufferedBytes);e.fill(0),this._buffered.push(e),this.push(n.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(n.concat(this._buffered)),this._buffered=null);this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:24,defined:32,inherits:42,"readable-stream":82}],21:[function(e,t,n){},{}],22:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21}],23:[function(e,t,n){(function(t){"use strict";var r=e("buffer"),o=r.Buffer,i=r.SlowBuffer,s=r.kMaxLength||2147483647;n.alloc=function(e,t,n){if("function"==typeof o.alloc)return o.alloc(e,t,n);if("number"==typeof n)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>s)throw new RangeError("size is too large");var r=n,i=t;void 0===i&&(r=void 0,i=0);var a=new o(e);if("string"==typeof i)for(var u=new o(i,r),c=u.length,f=-1;++fs)throw new RangeError("size is too large");return new o(e)},n.from=function(e,n,r){if("function"==typeof o.from&&(!t.Uint8Array||Uint8Array.from!==o.from))return o.from(e,n,r);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new o(e,n);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var i=n;if(1===arguments.length)return new o(e);"undefined"==typeof i&&(i=0);var s=r;if("undefined"==typeof s&&(s=e.byteLength-i),i>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(s>e.byteLength-i)throw new RangeError("'length' is out of bounds");return new o(e.slice(i,i+s))}if(o.isBuffer(e)){var a=new o(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new o(e);if("Buffer"===e.type&&Array.isArray(e.data))return new o(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},n.allocUnsafeSlow=function(e){if("function"==typeof o.allocUnsafeSlow)return o.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=s)throw new RangeError("size is too large");return new i(e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:24}],24:[function(e,t,n){"use strict";function r(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function o(e){if(e>J)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=i.prototype,t}function i(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return c(e)}return s(e,t,n)}function s(e,t,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?h(e,t,n):"string"==typeof e?f(e,t):l(e)}function a(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function u(e,t,n){return a(e),e<=0?o(e):void 0!==t?"string"==typeof n?o(e).fill(t,n):o(e).fill(t):o(e)}function c(e){return a(e),o(e<0?0:0|p(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var n=0|g(e,t),r=o(n),s=r.write(e,t);return s!==n&&(r=r.slice(0,s)),r}function d(e){for(var t=e.length<0?0:0|p(e.length),n=o(t),r=0;r=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),i.alloc(+e)}function g(e,t){if(i.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(e).length;default:if(r)return W(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return L(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,o){function i(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,a=e.length,u=t.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}var c;if(o){var f=-1;for(c=n;ca&&(n=a-u),c=n;c>=0;c--){for(var d=!0,h=0;ho&&(r=o)):r=o;var i=t.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s239?4:i>223?3:i>191?2:1;if(o+a<=n){var u,c,f,d;switch(a){case 1:i<128&&(s=i);break;case 2:u=e[o+1],128===(192&u)&&(d=(31&i)<<6|63&u,d>127&&(s=d));break;case 3:u=e[o+1],c=e[o+2],128===(192&u)&&128===(192&c)&&(d=(15&i)<<12|(63&u)<<6|63&c,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:u=e[o+1],c=e[o+2],f=e[o+3],128===(192&u)&&128===(192&c)&&128===(192&f)&&(d=(15&i)<<18|(63&u)<<12|(63&c)<<6|63&f,d>65535&&d<1114112&&(s=d))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),o+=a}return C(r)}function C(e){var t=e.length;if(t<=Y)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,o,s){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function M(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(e,t,n,r,o){return t=+t,n>>>=0,o||M(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,n,r,23,4),n+4}function H(e,t,n,r,o){return t=+t,n>>>=0,o||M(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,n,r,52,8),n+8}function q(e){if(e=D(e).replace(Z,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function D(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function N(e){return e<16?"0"+e.toString(16):e.toString(16)}function W(e,t){t=t||1/0;for(var n,r=e.length,o=null,i=[],s=0;s55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(e){for(var t=[],n=0;n>8,o=n%256,i.push(o),i.push(r);return i}function V(e){return K.toByteArray(q(e))}function G(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function $(e){return e!==e}var K=e("base64-js"),X=e("ieee754");n.Buffer=i,n.SlowBuffer=m,n.INSPECT_MAX_BYTES=50;var J=2147483647;n.kMaxLength=J,i.TYPED_ARRAY_SUPPORT=r(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(e,t,n){return s(e,t,n)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(e,t,n){return u(e,t,n)},i.allocUnsafe=function(e){return c(e)},i.allocUnsafeSlow=function(e){return c(e)},i.isBuffer=function(e){return null!=e&&e._isBuffer===!0},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,s=Math.min(n,r);o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},i.prototype.compare=function(e,t,n,r,o){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,o>>>=0,this===e)return 0;for(var s=o-r,a=n-t,u=Math.min(s,a),c=this.slice(r,o),f=e.slice(t,n),d=0;d>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return E(this,e,t,n);case"ascii":return k(this,e,t,n);case"latin1":case"binary":return x(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Y=4096;i.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],o=1,i=0;++i>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},i.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],o=1,i=0;++i=o&&(r-=Math.pow(2,8*t)),r},i.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},i.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),X.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),X.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),X.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),X.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){var o=Math.pow(2,8*n)-1;P(this,e,t,n,o,0)}var i=1,s=0;for(this[t]=255&e;++s>>=0,n>>>=0,!r){var o=Math.pow(2,8*n)-1;P(this,e,t,n,o,0)}var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},i.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,1,255,0),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},i.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},i.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},i.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},i.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeFloatLE=function(e,t,n){return j(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){return j(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){return H(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){return H(this,e,t,!1,n)},i.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var s;if("number"==typeof e)for(s=t;s>1),s=t[r]-e,s<0?u=r+1:s>0?c=r-1:void 0,s=o(s),s1||c;return void u(e,r,t)}throw new Error("invalid input type")}n.getStream=w(e,n),n.length=0}n.path=e.path,t(null,n)}}),function(e,t){return e?r(e):(t=A(t),void r(null,t,c))})}if(Array.isArray(e)&&0===e.length)throw new Error("invalid input type");g(e)&&(e=Array.prototype.slice.call(e)),Array.isArray(e)||(e=[e]),e=e.map(function(e){return m(e)&&"string"==typeof e.path&&"function"==typeof C.stat?e.path:e}),1!==e.length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);var s=null;e.forEach(function(t,n){if("string"!=typeof t){var r=t.fullPath||t.name;r||(r="Unknown File "+(n+1),t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),t.path.length<2?s=null:0===n&&e.length>1?s=t.path[0]:t.path[0]!==s&&(s=null)}}),e=e.filter(function(e){if("string"==typeof e)return!0;var t=e.path[e.path.length-1];return d(t)&&T.not(t)}),s&&e.forEach(function(e){var t=(o.isBuffer(e)||y(e))&&!e.path;"string"==typeof e||t||e.path.shift()}),!t.name&&s&&(t.name=s),t.name||e.some(function(e){return"string"==typeof e?(t.name=S.basename(e),!0):e.unknownName?void 0:(t.name=e.path[e.path.length-1],!0)}),t.name||(t.name="Unnamed Torrent "+Date.now());var a=e.reduce(function(e,t){return e+Number("string"==typeof t)},0),c=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof C.stat)throw new Error("filesystem paths do not work in the browser");L(e[0],function(e,t){return e?r(e):(c=t,void i())})}else n.nextTick(function(){i()})}function u(e,t,n){f(e,c,function(r,o){return r?n(r):(o=Array.isArray(o)?A(o):[o],e=S.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(S.sep)+1)),e[e.length-1]!==S.sep&&(e+=S.sep),o.forEach(function(t){t.getStream=b(t.path),t.path=t.path.replace(e,"").split(S.sep)}),void n(null,o))})}function c(e,t){t=R(t),C.stat(e,function(n,r){if(n)return t(n);var o={length:r.size,path:e};t(null,o)})}function f(e,t,n){C.stat(e,function(r,o){return r?n(r):void(o.isDirectory()?C.readdir(e,function(r,o){return r?n(r):void O(o.filter(d).filter(T.not).map(function(n){return function(r){f(S.join(e,n),t,r)}}),n)}):o.isFile()&&t(e,n))})}function d(e){return"."!==e[0]}function h(e,t,n){function r(e){f+=e.length;var t=l;P(e,function(e){c[t]=e,h-=1,u()}),h+=1,l+=1}function i(){p=!0,u()}function s(e){a(),n(e)}function a(){m.removeListener("error",s),g.removeListener("data",r),g.removeListener("end",i),g.removeListener("error",s)}function u(){p&&0===h&&(a(),n(null,new o(c.join(""),"hex"),f))}n=R(n);var c=[],f=0,d=e.map(function(e){return e.getStream}),h=0,l=0,p=!1,m=new U(d),g=new k(t,{zeroPadding:!1});m.on("error",s),m.pipe(g).on("data",r).on("end",i).on("error",s)}function l(e,n,o){var i=n.announceList;i||("string"==typeof n.announce?i=[[n.announce]]:Array.isArray(n.announce)&&(i=n.announce.map(function(e){return[e]}))),i||(i=[]),r.WEBTORRENT_ANNOUNCE&&("string"==typeof r.WEBTORRENT_ANNOUNCE?i.push([[r.WEBTORRENT_ANNOUNCE]]):Array.isArray(r.WEBTORRENT_ANNOUNCE)&&(i=i.concat(r.WEBTORRENT_ANNOUNCE.map(function(e){return[e]})))),void 0===n.announce&&void 0===n.announceList&&(i=i.concat(t.exports.announceList)),"string"==typeof n.urlList&&(n.urlList=[n.urlList]);var s={info:{name:n.name},"creation date":Math.ceil((Number(n.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==i.length&&(s.announce=i[0][0],s["announce-list"]=i),void 0!==n.comment&&(s.comment=n.comment),void 0!==n.createdBy&&(s["created by"]=n.createdBy),void 0!==n.private&&(s.info.private=Number(n.private)),void 0!==n.sslCert&&(s.info["ssl-cert"]=n.sslCert),void 0!==n.urlList&&(s["url-list"]=n.urlList);var a=n.pieceLength||x(e.reduce(p,0));s.info["piece length"]=a,h(e,a,function(t,r,i){return t?o(t):(s.info.pieces=r, e.forEach(function(e){delete e.getStream}),n.singleFileTorrent?s.info.length=i:s.info.files=e,void o(null,E.encode(s)))})}function p(e,t){return e+t.length}function m(e){return"undefined"!=typeof Blob&&e instanceof Blob}function g(e){return"undefined"!=typeof FileList&&e instanceof FileList}function y(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function _(e){return function(){return new I(e)}}function v(e){return function(){var t=new M.PassThrough;return t.end(e),t}}function b(e){return function(){return C.createReadStream(e)}}function w(e,t){return function(){var n=new M.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}t.exports=i,t.exports.parseInput=s,t.exports.announceList=[["udp://tracker.openbittorrent.com:80"],["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://zer0day.ch:1337"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]];var E=e("bencode"),k=e("block-stream2"),x=e("piece-length"),S=e("path"),B=e("xtend"),I=e("filestream/read"),A=e("flatten"),C=e("fs"),L=e("is-file"),T=e("junk"),U=e("multistream"),R=e("once"),O=e("run-parallel"),P=e("simple-sha1"),M=e("readable-stream")}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{_process:67,bencode:11,"block-stream2":20,buffer:24,"filestream/read":36,flatten:37,fs:22,"is-file":45,junk:48,multistream:59,once:61,path:64,"piece-length":65,"readable-stream":82,"run-parallel":86,"simple-sha1":92,xtend:119}],30:[function(e,t,n){(function(r){function o(){return!("undefined"==typeof window||!window||"undefined"==typeof window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document&&"WebkitAppearance"in document.documentElement.style||"undefined"!=typeof window&&window&&window.console&&(console.firebug||console.exception&&console.table)||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),t){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}}function u(){try{return n.storage.debug}catch(e){}if("undefined"!=typeof r&&"env"in r)return r.env.DEBUG}function c(){try{return window.localStorage}catch(e){}}n=t.exports=e("./debug"),n.log=s,n.formatArgs=i,n.save=a,n.load=u,n.useColors=o,n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(u())}).call(this,e("_process"))},{"./debug":31,_process:67}],31:[function(e,t,n){function r(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return n.colors[Math.abs(r)%n.colors.length]}function o(e){function t(){if(t.enabled){var e=t,r=+new Date,o=r-(c||r);e.diff=o,e.prev=c,e.curr=r,c=r;for(var i=new Array(arguments.length),s=0;s0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,i,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=i;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],o(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],36:[function(e,t,n){function r(e,t){var n=this;return this instanceof r?(t=t||{},o.call(this,t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800),this.reader=new FileReader,void this._generateHeaderBlocks(e,t,function(e,t){return e?n.emit("error",e):(Array.isArray(t)&&t.forEach(function(e){n.push(e)}),n._ready=!0,void n.emit("_ready"))})):new r(e,t)}var o=e("readable-stream").Readable,i=e("inherits"),s=e("typedarray-to-buffer");i(r,o),t.exports=r,r.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])},r.prototype._read=function(){if(!this._ready)return void this.once("_ready",this._read.bind(this));var e=this,t=this.reader,n=this._offset,r=this._offset+this._chunkSize;return r>this._size&&(r=this._size),n===this._size?(this.destroy(),void this.push(null)):(t.onload=function(){e._offset=r,e.push(s(t.result))},t.onerror=function(){e.emit("error",t.error)},void t.readAsArrayBuffer(this._file.slice(n,r)))},r.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:42,"readable-stream":82,"typedarray-to-buffer":108}],37:[function(e,t,n){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,o){return Array.isArray(o)&&r>1,f=-7,d=n?o-1:0,h=n?-1:1,l=e[t+d];for(d+=h,i=l&(1<<-f)-1,l>>=-f,f+=a;f>0;i=256*i+e[t+d],d+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+e[t+d],d+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:(l?-1:1)*(1/0);s+=Math.pow(2,r),i-=c}return(l?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+d>=1?h/u:h*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*u-1)*Math.pow(2,o),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[n+l]=255&a,l+=p,a/=256,o-=8);for(s=s<0;e[n+l]=255&s,l+=p,s/=256,c-=8);e[n+l-p]|=128*m}},{}],41:[function(e,t,n){(function(e){function n(e){if(!(this instanceof n))return new n(e);if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}function r(t,n,r){e.nextTick(function(){t&&t(n,r)})}t.exports=n,n.prototype.put=function(e,t,n){var r=this;r.mem[e]=t,r.store.put(e,t,function(t){r.mem[e]=null,n&&n(t)})},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);var o=t&&t.offset||0,i=t&&t.length&&o+t.length,s=this.mem[e];return s?r(n,null,t?s.slice(o,i):s):void this.store.get(e,t,n)},n.prototype.close=function(e){this.store.close(e)},n.prototype.destroy=function(e){this.store.destroy(e)}}).call(this,e("_process"))},{_process:67}],42:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],43:[function(e,t,n){var r=127;t.exports=function(e){for(var t=0,n=e.length;tr)return!1;return!0}},{}],44:[function(e,t,n){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function o(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}t.exports=function(e){return null!=e&&(r(e)||o(e)||!!e._isBuffer)}},{}],45:[function(e,t,n){"use strict";function r(e){return o.existsSync(e)&&o.statSync(e).isFile()}var o=e("fs");t.exports=function(e,t){return t?void o.stat(e,function(e,n){return e?t(e):t(null,n.isFile())}):r(e)},t.exports.sync=r},{fs:22}],46:[function(e,t,n){function r(e){return o(e)||i(e)}function o(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function i(e){return a[s.call(e)]}t.exports=r,r.strict=o,r.loose=i;var s=Object.prototype.toString,a={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],47:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],48:[function(e,t,n){"use strict";n.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon\r$|^\._.*|^\.Spotlight-V100$|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$/,n.is=function(e){return n.re.test(e)},n.not=n.isnt=function(e){return!n.is(e)}},{}],49:[function(e,t,n){(function(n){function r(e){var t={},r=e.split("magnet:?")[1],o=r&&r.length>=0?r.split("&"):[];o.forEach(function(e){var n=e.split("=");if(2===n.length){var r=n[0],o=n[1];if("dn"===r&&(o=decodeURIComponent(o).replace(/\+/g," ")),"tr"!==r&&"xs"!==r&&"as"!==r&&"ws"!==r||(o=decodeURIComponent(o)),"kt"===r&&(o=decodeURIComponent(o).split("+")),"ix"===r&&(o=Number(o)),t[r])if(Array.isArray(t[r]))t[r].push(o);else{var i=t[r];t[r]=[i,o]}else t[r]=o}});var s;if(t.xt){var u=Array.isArray(t.xt)?t.xt:[t.xt];u.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/))t.infoHash=s[1].toLowerCase();else if(s=e.match(/^urn:btih:(.{32})/)){var r=i.decode(s[1]);t.infoHash=new n(r,"binary").toString("hex")}})}return t.infoHash&&(t.infoHashBuffer=new n(t.infoHash,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),"string"==typeof t.tr?t.announce=[t.tr]:Array.isArray(t.tr)?t.announce=t.tr:t.announce=[],t.urlList=[],("string"==typeof t.as||Array.isArray(t.as))&&(t.urlList=t.urlList.concat(t.as)),("string"==typeof t.ws||Array.isArray(t.ws))&&(t.urlList=t.urlList.concat(t.ws)),a(t.announce),a(t.urlList),t}function o(e){e=s(e),e.infoHashBuffer&&(e.xt="urn:btih:"+e.infoHashBuffer.toString("hex")),e.infoHash&&(e.xt="urn:btih:"+e.infoHash),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(n,r){var o=Array.isArray(e[n])?e[n]:[e[n]];o.forEach(function(e,o){!(r>0||o>0)||"kt"===n&&0!==o||(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&o>0?"+"+e:n+"="+e})}),t}t.exports=r,t.exports.decode=r,t.exports.encode=o;var i=e("thirty-two"),s=e("xtend"),a=e("uniq")}).call(this,e("buffer").Buffer)},{buffer:24,"thirty-two":103,uniq:110,xtend:119}],50:[function(e,t,n){function r(e,t){var n=this;if(!(n instanceof r))return new r(e,t);if(!u)throw new Error("web browser lacks MediaSource support");t||(t={}),n._bufferDuration=t.bufferDuration||c,n._elem=e,n._mediaSource=new u,n._streams=[],n.detailedError=null,n._errorHandler=function(){n._elem.removeEventListener("error",n._errorHandler);var e=n._streams.slice();e.forEach(function(e){e.destroy(n._elem.error)})},n._elem.addEventListener("error",n._errorHandler),n._elem.src=window.URL.createObjectURL(n._mediaSource)}function o(e,t){var n=this;if(s.Writable.call(n),n._wrapper=e,n._elem=e._elem,n._mediaSource=e._mediaSource,n._allStreams=e._streams,n._allStreams.push(n),n._bufferDuration=e._bufferDuration,n._sourceBuffer=null,n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},"string"==typeof t)n._type=t,"open"===n._mediaSource.readyState?n._createSourceBuffer():n._mediaSource.addEventListener("sourceopen",n._openHandler);else if(null===t._sourceBuffer)t.destroy(),n._type=t._type,n._mediaSource.addEventListener("sourceopen",n._openHandler);else{if(!t._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._sourceBuffer.addEventListener("updateend",n._flowHandler)}n._elem.addEventListener("timeupdate",n._flowHandler),n.on("error",function(e){n._wrapper.error(e)}),n.on("finish",function(){if(!n.destroyed&&(n._finished=!0,n._allStreams.every(function(e){return e._finished})))try{n._mediaSource.endOfStream()}catch(e){}})}t.exports=r;var i=e("inherits"),s=e("readable-stream"),a=e("to-arraybuffer"),u="undefined"!=typeof window&&window.MediaSource,c=60;r.prototype.createWriteStream=function(e){var t=this;return new o(t,e)},r.prototype.error=function(e){var t=this;t.detailedError||(t.detailedError=e);try{t._mediaSource.endOfStream("decode")}catch(e){}},i(o,s.Writable),o.prototype._onSourceOpen=function(){var e=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},o.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,t._allStreams.splice(t._allStreams.indexOf(t),1),t._mediaSource.removeEventListener("sourceopen",t._openHandler),t._elem.removeEventListener("timeupdate",t._flowHandler),t._sourceBuffer&&(t._sourceBuffer.removeEventListener("updateend",t._flowHandler),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},o.prototype._createSourceBuffer=function(){var e=this;if(!e.destroyed)if(u.isTypeSupported(e._type)){if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._cb){var t=e._cb;e._cb=null,t()}}else e.destroy(new Error("The provided type is not supported"))},o.prototype._write=function(e,t,n){var r=this;if(!r.destroyed){if(!r._sourceBuffer)return void(r._cb=function(o){return o?n(o):void r._write(e,t,n)});if(r._sourceBuffer.updating)return n(new Error("Cannot append buffer while source buffer updating"));try{r._sourceBuffer.appendBuffer(a(e))}catch(e){return void r.destroy(e)}r._cb=n}},o.prototype._flow=function(){var e=this;if(!e.destroyed&&e._sourceBuffer&&!e._sourceBuffer.updating&&!("open"===e._mediaSource.readyState&&e._getBufferDuration()>e._bufferDuration)&&e._cb){var t=e._cb;e._cb=null,t()}};var f=0;o.prototype._getBufferDuration=function(){for(var e=this,t=e._sourceBuffer.buffered,n=e._elem.currentTime,r=-1,o=0;on)break;(r>=0||n<=s)&&(r=s)}var a=r-n;return a<0&&(a=0),a}},{inherits:42,"readable-stream":82,"to-arraybuffer":105}],51:[function(e,t,n){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function r(t,n,r){e.nextTick(function(){t&&t(n,r)})}t.exports=n,n.prototype.put=function(e,t,n){if(this.closed)return r(n,new Error("Storage is closed"));var o=e===this.lastChunkIndex;return o&&t.length!==this.lastChunkLength?r(n,new Error("Last chunk length must be "+this.lastChunkLength)):o||t.length===this.chunkLength?(this.chunks[e]=t,void r(n,null)):r(n,new Error("Chunk length must be "+this.chunkLength))},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return r(n,new Error("Storage is closed"));var o=this.chunks[e];if(!o)return r(n,new Error("Chunk not found"));if(!t)return r(n,null,o);var i=t.offset||0,s=t.length||o.length-i;r(n,null,o.slice(i,s+i))},n.prototype.close=n.prototype.destroy=function(e){return this.closed?r(e,new Error("Storage is closed")):(this.closed=!0,this.chunks=null,void r(e,null))}}).call(this,e("_process"))},{_process:67}],52:[function(e,t,n){(function(t){function r(e,t,n){for(var r=t;r=8;){var a=p.decode(e,s,r);i.children.push(a),i[a.type]=a,s+=a.length}return i},n.VisualSampleEntry.encodingLength=function(e){var t=78,n=e.children||[];return n.forEach(function(e){t+=p.encodingLength(e)}),t},n.avcC={},n.avcC.encode=function(e,r,o){r=r?r.slice(o):t(e.buffer.length),e.buffer.copy(r),n.avcC.encode.bytes=e.buffer.length},n.avcC.decode=function(e,n,r){return e=e.slice(n,r),{mimeCodec:e.toString("hex",1,4),buffer:new t(e)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(e,o,i){o=o?o.slice(i):new t(n.AudioSampleEntry.encodingLength(e)),r(o,0,6),o.writeUInt16BE(e.dataReferenceIndex||0,6),r(o,8,16),o.writeUInt16BE(e.channelCount||2,16),o.writeUInt16BE(e.sampleSize||16,18),r(o,20,24),o.writeUInt32BE(e.sampleRate||0,24);var s=28,a=e.children||[];a.forEach(function(e){p.encode(e,o,s),s+=p.encode.bytes}),n.AudioSampleEntry.encode.bytes=s},n.AudioSampleEntry.decode=function(e,t,n){e=e.slice(t,n);for(var r=n-t,o={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},i=28;r-i>=8;){var s=p.decode(e,i,r);o.children.push(s),o[s.type]=s,i+=s.length}return o},n.AudioSampleEntry.encodingLength=function(e){var t=28,n=e.children||[];return n.forEach(function(e){t+=p.encodingLength(e)}),t},n.esds={},n.esds.encode=function(e,r,o){r=r?r.slice(o):t(e.buffer.length),e.buffer.copy(r,0),n.esds.encode.bytes=e.buffer.length},n.esds.decode=function(e,n,r){e=e.slice(n,r);var o=m.Descriptor.decode(e,0,e.length),i="ESDescriptor"===o.tagName?o:{},s=i.DecoderConfigDescriptor||{},a=s.oti||0,u=s.DecoderSpecificInfo,c=u?(248&u.buffer.readUInt8(0))>>3:0,f=null;return a&&(f=a.toString(16),c&&(f+="."+c)),{mimeCodec:f,buffer:new t(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,r,o){var i=e.entries||[];r=r?r.slice(o):t(n.stsz.encodingLength(e)),r.writeUInt32BE(0,0),r.writeUInt32BE(i.length,4);for(var s=0;si&&(c=1),t.writeUInt32BE(c,n),t.write(e.type,n+4,4,"ascii");var f=n+8;if(1===c&&(r.encode(e.length,t,f),f+=8),o.fullBoxes[u]&&(t.writeUInt32BE(e.flags||0,f),t.writeUInt8(e.version||0,f),f+=4),a[u]){var d=a[u];d.forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){s._encode(e,t,f),f+=s.encode.bytes})}else e[n]&&(s._encode(e[n],t,f),f+=s.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){s._encode(e,t,f),f+=s.encode.bytes})}else if(o[u]){var h=o[u].encode;h(e,t,f),f+=h.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+u+"') or `buffer` must be set");var l=e.buffer;l.copy(t,f),f+=e.buffer.length}return s.encode.bytes=f-n,t},s.readHeaders=function(e,t,n){if(t=t||0,n=n||e.length,n-t<8)return 8;var i=e.readUInt32BE(t),s=e.toString("ascii",t+4,t+8),a=t+8;if(1===i){if(n-t<16)return 16;i=r.decode(e,a),a+=8}var u,c;return o.fullBoxes[s]&&(u=e.readUInt8(a),c=16777215&e.readUInt32BE(a),a+=4),{length:i,headersLen:a-t,contentLen:i-(a-t),type:s,version:u,flags:c}},s.decode=function(e,t,n){t=t||0,n=n||e.length;var r=s.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return s.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},s.decodeWithoutHeaders=function(e,n,r,i){r=r||0,i=i||n.length;var u=e.type,c={};if(a[u]){c.otherBoxes=[];for(var f=a[u],d=r;i-d>=8;){var h=s.decode(n,d,i);if(d+=h.length,f.indexOf(h.type)>=0)c[h.type]=h;else if(f.indexOf(h.type+"s")>=0){var l=h.type+"s",p=c[l]=c[l]||[];p.push(h)}else c.otherBoxes.push(h)}}else if(o[u]){var m=o[u].decode;c=m(n,r,i)}else c.buffer=new t(n.slice(r,i));return c.length=e.length,c.contentLen=e.contentLen,c.type=e.type,c.version=e.version,c.flags=e.flags,c},s.encodingLength=function(e){var t=e.type,n=8;if(o.fullBoxes[t]&&(n+=4),a[t]){var r=a[t];r.forEach(function(t){if(5===t.length){var r=e[t]||[];t=t.substr(0,4),r.forEach(function(e){e.type=t,n+=s.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=s.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=s.encodingLength(e)})}else if(o[t])n+=o[t].encodingLength(e);else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");n+=e.buffer.length}return n>i&&(n+=8),e.length=n,n}}).call(this,e("buffer").Buffer)},{"./boxes":52,buffer:24,uint64be:109}],55:[function(e,t,n){(function(n){function r(){return this instanceof r?(i.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,void this._kick()):new r}function o(e){this._parent=e,this.destroyed=!1,i.PassThrough.call(this)}var i=e("readable-stream"),s=e("inherits"),a=e("next-event"),u=e("mp4-box-encoding"),c=new n(0);t.exports=r,s(r,i.Writable),r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},r.prototype._write=function(e,t,n){if(!this.destroyed){for(var r=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=n);var o=e.length1e4)){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){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*d;case"days":case"day":case"d":return n*f;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function o(e){return e>=f?Math.round(e/f)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,f,"day")||s(e,c,"hour")||s(e,u,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,n){if(!(e0)return r(e);if("number"===n&&isNaN(e)===!1)return t.long?i(e):o(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],59:[function(e,t,n){function r(e,t){var n=this;return n instanceof r?(s.Readable.call(n,t),n.destroyed=!1,n._drained=!1,n._forwarding=!1,n._current=null,"function"==typeof e?n._queue=e:(n._queue=e.map(o),n._queue.forEach(function(e){"function"!=typeof e&&n._attachErrorListener(e)})),void n._next()):new r(e,t)}function o(e){if(!e||"function"==typeof e||e._readableState)return e;var t=(new s.Readable).wrap(e);return e.destroy&&(t.destroy=e.destroy.bind(e)),t}t.exports=r;var i=e("inherits"),s=e("readable-stream");i(r,s.Readable),r.obj=function(e){return new r(e,{objectMode:!0,highWaterMark:16})},r.prototype._read=function(){this._drained=!0,this._forward()},r.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(var e;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},r.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,n){return t?e.destroy(t):(n=o(n),e._attachErrorListener(n),void e._gotNextStream(n))});else{var t=e._queue.shift();"function"==typeof t&&(t=o(t()),e._attachErrorListener(t)),e._gotNextStream(t)}},r.prototype._gotNextStream=function(e){function t(){o._forward()}function n(){e._readableState.ended||o.destroy()}function r(){o._current=null,e.removeListener("readable",t),e.removeListener("end",r),e.removeListener("close",n),o._next()}var o=this;return e?(o._current=e,o._forward(),e.on("readable",t),e.once("end",r),void e.once("close",n)):(o.push(null),void o.destroy())},r.prototype._attachErrorListener=function(e){function t(r){e.removeListener("error",t),n.destroy(r)}var n=this;e&&e.once("error",t)}},{inherits:42,"readable-stream":82}],60:[function(e,t,n){function r(e,t){var n=null;return e.on(t,function(e){if(n){var t=n;n=null,t(e)}}),function(e){n=e}}t.exports=r},{}],61:[function(e,t,n){function r(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}var i=e("wrappy");t.exports=i(r),t.exports.strict=i(o),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},{wrappy:118}],62:[function(e,t,n){(function(n){function r(e){n.isBuffer(e)&&(e=u.decode(e)),a(e.info,"info"),a(e.info["name.utf-8"]||e.info.name,"info.name"),a(e.info["piece length"],"info['piece length']"),a(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){a("number"==typeof e.length,"info.files[0].length"),a(e["path.utf-8"]||e.path,"info.files[0].path")}):a("number"==typeof e.info.length,"info.length");var t={};t.info=e.info,t.infoBuffer=u.encode(e.info),t.infoHash=f.sync(t.infoBuffer),t.infoHashBuffer=new n(t.infoHash,"hex"),t.name=(e.info["name.utf-8"]||e.info.name).toString(),void 0!==e.info.private&&(t.private=!!e.info.private),e["creation date"]&&(t.created=new Date(1e3*e["creation date"])),e["created by"]&&(t.createdBy=e["created by"].toString()),n.isBuffer(e.comment)&&(t.comment=e.comment.toString()),t.announce=[],e["announce-list"]&&e["announce-list"].length?e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})}):e.announce&&t.announce.push(e.announce.toString()),n.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()}),d(t.announce),d(t.urlList);var r=e.info.files||[e.info];t.files=r.map(function(e,n){var o=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:c.join.apply(null,[c.sep].concat(o)).slice(1),name:o[o.length-1],length:e.length,offset:r.slice(0,n).reduce(i,0)}}),t.length=r.reduce(i,0);var o=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(o.offset+o.length)%t.pieceLength||t.pieceLength,t.pieces=s(e.info.pieces),t}function o(e){var t={info:e.info};return t["announce-list"]=(e.announce||[]).map(function(e){return t.announce||(t.announce=e),e=new n(e,"utf8"),[e]}),t["url-list"]=e.urlList||[],e.created&&(t["creation date"]=e.created.getTime()/1e3|0),e.createdBy&&(t["created by"]=e.createdBy),e.comment&&(t.comment=e.comment),u.encode(t)}function i(e,t){return e+t.length}function s(e){for(var t=[],n=0;n=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r=-1&&!o;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,o="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!o).join("/"),(o?"/":"")+n||"."},n.normalize=function(e){var o=n.isAbsolute(e),i="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!o).join("/"),e||o||(e="."),e&&i&&(e+="/"),(o?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),s=Math.min(o.length,i.length),a=s,u=0;u1)for(var n=1;n0;return f(o,s,a,function(e){n||(n=e),e&&r.forEach(d),s||(r.forEach(d),t(n))})});return e.reduce(h)};t.exports=l},{"end-of-stream":33,fs:21,once:61}],69:[function(t,n,r){(function(t){!function(o){function i(e){throw new RangeError(O[e])}function s(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function a(e,t){var n=e.split("@"),r="";n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(R,".");var o=e.split("."),i=s(o,t).join(".");return r+i}function u(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(e-=65536,t+=j(e>>>10&1023|55296),e=56320|1023&e),t+=j(e)}).join("")}function f(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:k}function d(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?M(e/I):e>>1,e+=M(e/t);e>P*S>>1;r+=k)e=M(e/P);return M(r+(P+1)*e/(e+B))}function l(e){var t,n,r,o,s,a,u,d,l,p,m=[],g=e.length,y=0,_=C,v=A;for(n=e.lastIndexOf(L),n<0&&(n=0),r=0;r=128&&i("not-basic"),m.push(e.charCodeAt(r));for(o=n>0?n+1:0;o=g&&i("invalid-input"),d=f(e.charCodeAt(o++)),(d>=k||d>M((E-y)/a))&&i("overflow"),y+=d*a,l=u<=v?x:u>=v+S?S:u-v,!(dM(E/p)&&i("overflow"),a*=p;t=m.length+1,v=h(y-s,t,0==s),M(y/t)>E-_&&i("overflow"),_+=M(y/t),y%=t,m.splice(y++,0,_)}return c(m)}function p(e){var t,n,r,o,s,a,c,f,l,p,m,g,y,_,v,b=[];for(e=u(e),g=e.length,t=C,n=0,s=A,a=0;a=t&&mM((E-n)/y)&&i("overflow"),n+=(c-t)*y,t=c,a=0;aE&&i("overflow"),m==t){for(f=n,l=k;p=l<=s?x:l>=s+S?S:l-s,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},P=k-x,M=Math.floor,j=String.fromCharCode;if(b={version:"1.4.1",ucs2:{decode:u,encode:c},decode:l,encode:p,toASCII:g,toUnicode:m},"function"==typeof e&&"object"==typeof e.amd&&e.amd)e("punycode",function(){return b});else if(y&&_)if(n.exports==y)_.exports=b;else for(w in b)b.hasOwnProperty(w)&&(y[w]=b[w]);else o.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],70:[function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(d=m.substr(0,g),h=m.substr(g+1)):(d=m, h=""),l=decodeURIComponent(d),p=decodeURIComponent(h),r(s,l)?o(s[l])?s[l].push(p):s[l]=[s[l],p]:s[l]=p}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],71:[function(e,t,n){"use strict";function r(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r65536)throw new Error("requested too many random bytes");var i=new n.Uint8Array(t);t>0&&s.getRandomValues(i);var a=new r(i.buffer);return"function"==typeof o?e.nextTick(function(){o(null,a)}):a}var s=n.crypto||n.msCrypto;s&&s.getRandomValues?t.exports=i:t.exports=o}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{_process:67,buffer:24}],75:[function(e,t,n){function r(e,t){var n=this;return n instanceof r?(i.Writable.call(n,t),n.destroyed=!1,n._queue=[],n._position=e||0,n._cb=null,n._buffer=null,void(n._out=null)):new r(e)}var o=e("inherits"),i=e("readable-stream");t.exports=r,o(r,i.Writable),r.prototype._write=function(e,t,n){for(var r=this,o=!0;;){if(r.destroyed)return;if(0===r._queue.length)return r._buffer=e,void(r._cb=n);r._buffer=null;var i=r._queue[0],s=Math.max(i.start-r._position,0),a=i.end-r._position;if(s>=e.length)return r._position+=e.length,n(null);var u;if(a>e.length){r._position+=e.length,u=0===s?e:e.slice(s),o=i.stream.write(u)&&o;break}r._position+=a,u=0===s&&a===e.length?e:e.slice(s,a),o=i.stream.write(u)&&o,i.last&&i.stream.end(),e=e.slice(a),r._queue.shift()}o?n(null):i.stream.once("drain",n.bind(null,null))},r.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var n=new i.PassThrough;return e.forEach(function(r,o){t._queue.push({start:r.start,end:r.end,stream:n,last:o===e.length-1})}),t._buffer&&t._write(t._buffer,null,t._cb),n},r.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,e&&t.emit("error",e))}},{inherits:42,"readable-stream":82}],76:[function(e,t,n){"use strict";function r(e){return this instanceof r?(c.call(this,e),f.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",o)):new r(e)}function o(){this.allowHalfOpen||this._writableState.ended||a(i,this)}function i(e){e.end()}var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=r;var a=e("process-nextick-args"),u=e("core-util-is");u.inherits=e("inherits");var c=e("./_stream_readable"),f=e("./_stream_writable");u.inherits(r,c);for(var d=s(f.prototype),h=0;h0)if(t.ended&&!o){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&o){var u=new Error("stream.unshift() after end event");e.emit("error",u)}else{var c;!t.decoder||o||r||(n=t.decoder.write(n),c=!t.objectMode&&0===n.length),o||(t.reading=!1),c||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,o?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&h(e))),p(e,t)}else o||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function c(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=u(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function f(e,t){var n=null;return O.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function d(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,h(e)}}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(H("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?L(l,e):l(e))}function l(e){H("emit readable"),e.emit("readable"),b(e)}function p(e,t){t.readingMore||(t.readingMore=!0,L(m,e,t))}function m(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=E(e,t.buffer,t.decoder),n}function E(e,t,n){var r;return ei.length?i.length:e;if(o+=s===i.length?i:i.slice(0,e),e-=s,0===e){s===i.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(s));break}++r}return t.length-=r,o}function x(e,t){var n=P.allocUnsafe(e),r=t.head,o=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var i=r.data,s=e>i.length?i.length:e;if(i.copy(n,n.length-e,0,s),e-=s,0===e){s===i.length?(++o,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(s));break}++o}return t.length-=o,n}function S(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,L(B,t,e))}function B(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function I(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return H("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?S(this):h(this),null;if(e=c(e,t),0===e&&t.ended)return 0===t.length&&S(this),null;var r=t.needReadable;H("need readable",r),(0===t.length||t.length-e0?w(e,t):null,null===o?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&S(this)),null!==o&&this.emit("data",o),o},i.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},i.prototype.pipe=function(e,t){function o(e){H("onunpipe"),e===h&&s()}function i(){H("onend"),e.end()}function s(){H("cleanup"),e.removeListener("close",c),e.removeListener("finish",f),e.removeListener("drain",y),e.removeListener("error",u),e.removeListener("unpipe",o),h.removeListener("end",i),h.removeListener("end",s),h.removeListener("data",a),_=!0,!l.awaitDrain||e._writableState&&!e._writableState.needDrain||y()}function a(t){H("ondata"),v=!1;var n=e.write(t);!1!==n||v||((1===l.pipesCount&&l.pipes===e||l.pipesCount>1&&A(l.pipes,e)!==-1)&&!_&&(H("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,v=!0),h.pause())}function u(t){H("onerror",t),d(),e.removeListener("error",u),0===R(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",f),d()}function f(){H("onfinish"),e.removeListener("close",c),d()}function d(){H("unpipe"),h.unpipe(e)}var h=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1,H("pipe count=%d opts=%j",l.pipesCount,t);var p=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,m=p?i:s;l.endEmitted?L(m):h.once("end",m),e.on("unpipe",o);var y=g(h);e.on("drain",y);var _=!1,v=!1;return h.on("data",a),r(e,"error",u),e.once("close",c),e.once("finish",f),e.emit("pipe",h),l.flowing||(H("pipe resume"),h.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:x;s.WritableState=i;var B=e("core-util-is");B.inherits=e("inherits");var I,A={deprecate:e("util-deprecate")};!function(){try{I=e("stream")}catch(e){}finally{I||(I=e("events").EventEmitter)}}();var C=e("buffer").Buffer,L=e("buffer-shims");B.inherits(s,I),i.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(i.prototype,"buffer",{get:A.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var T;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(T=Function.prototype[Symbol.hasInstance],Object.defineProperty(s,Symbol.hasInstance,{value:function(e){return!!T.call(this,e)||e&&e._writableState instanceof i}})):T=function(e){return e instanceof this},s.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},s.prototype.write=function(e,t,n){var o=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),C.isBuffer(e)?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof n&&(n=r),o.ended?a(this,n):u(this,o,e,n)&&(o.pendingcb++,i=f(this,o,e,t,n)),i},s.prototype.cork=function(){var e=this._writableState;e.corked++},s.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||y(this,e))},s.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},s.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},s.prototype._writev=null,s.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||w(this,r,n)}}).call(this,e("_process"))},{"./_stream_duplex":76,_process:67,buffer:24,"buffer-shims":23,"core-util-is":28,events:35,inherits:42,"process-nextick-args":66,"util-deprecate":115}],81:[function(e,t,n){"use strict";function r(){this.head=null,this.tail=null,this.length=0}var o=(e("buffer").Buffer,e("buffer-shims"));t.exports=r,r.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},r.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},r.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},r.prototype.clear=function(){this.head=this.tail=null,this.length=0},r.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},r.prototype.concat=function(e){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var t=o.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t}},{buffer:24,"buffer-shims":23}],82:[function(e,t,n){(function(r){var o=function(){try{return e("stream")}catch(e){}}();n=t.exports=e("./lib/_stream_readable.js"),n.Stream=o||n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),!r.browser&&"disable"===r.env.READABLE_STREAM&&o&&(t.exports=o)}).call(this,e("_process"))},{"./lib/_stream_duplex.js":76,"./lib/_stream_passthrough.js":77,"./lib/_stream_readable.js":78,"./lib/_stream_transform.js":79,"./lib/_stream_writable.js":80,_process:67}],83:[function(e,t,n){function r(e,t,n,r){"function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),a(e),c(n),"string"==typeof t&&(t=document.querySelector(t)),i(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=l.extname(e.name).toLowerCase();throw new Error('Cannot render "'+r+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+n+'"')}return t},n,r)}function o(e,t,n,r){function o(e){return"video"===e||"audio"===e?s(e):u(e)}function s(e){var r=u(e);return n.controls&&(r.controls=!0),n.autoplay&&(r.autoplay=!0),t.appendChild(r),r}function u(e){var n=document.createElement(e);return t.appendChild(n),n}function f(e,t){e&&t&&t.remove(),r(e,t)}if("function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),a(e),c(n),"string"==typeof t&&(t=document.querySelector(t)),t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");i(e,o,n,f)}function i(e,t,n,r){function o(){function r(){f("Use `videostream` package for "+e.name),p(),B.addEventListener("error",d),B.addEventListener("loadstart",a),B.addEventListener("canplay",c),m(e,B)}function o(){f("Use MediaSource API for "+e.name),p(),B.addEventListener("error",l),B.addEventListener("loadstart",a),B.addEventListener("canplay",c);var t=new h(B),n=t.createWriteStream(u(e.name));e.createReadStream().pipe(n),A&&(B.currentTime=A)}function i(){f("Use Blob URL for "+e.name),p(),B.addEventListener("error",S),B.addEventListener("loadstart",a),B.addEventListener("canplay",c),s(e,function(e,t){return e?S(e):(B.src=t,void(A&&(B.currentTime=A)))})}function d(e){f("videostream error: fallback to MediaSource API: %o",e.message||e),B.removeEventListener("error",d),B.removeEventListener("canplay",c),o()}function l(t){return f("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength?(f("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),S(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"))):(B.removeEventListener("error",l),B.removeEventListener("canplay",c),void i())}function p(){B||(B=t(_),B.addEventListener("progress",function(){A=B.currentTime}))}var _=y.indexOf(I)>=0?"video":"audio";x?g.indexOf(I)>=0?r():o():i()}function i(){B=t("audio"),s(e,function(e,t){return e?S(e):(B.addEventListener("error",S),B.addEventListener("loadstart",a),B.addEventListener("canplay",c),void(B.src=t))})}function a(){B.removeEventListener("loadstart",a),n.autoplay&&B.play()}function c(){B.removeEventListener("canplay",c),r(null,B)}function p(){B=t("img"),s(e,function(t,n){return t?S(t):(B.src=n,B.alt=e.name,void r(null,B))})}function _(){B=t("iframe"),s(e,function(e,t){return e?S(e):(B.src=t,".pdf"!==I&&(B.sandbox="allow-forms allow-scripts"),void r(null,B))})}function k(){function t(){d(n)?(f('File extension "%s" appears ascii, so will render.',I),_()):(f('File extension "%s" appears non-ascii, will not render.',I),r(new Error('Unsupported file type "'+I+'": Cannot append to DOM')))}f('Unknown file extension "%s" - will attempt to render into iframe',I);var n="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){n+=e}).on("end",t).on("error",r)}function S(t){t.message='Error rendering file "'+e.name+'": '+t.message,f(t.message),r(t)}var B,I=l.extname(e.name).toLowerCase(),A=0;v.indexOf(I)>=0?o():b.indexOf(I)>=0?i():w.indexOf(I)>=0?p():E.indexOf(I)>=0?_():k()}function s(e,t){var r=l.extname(e.name).toLowerCase();p(e.createReadStream(),n.mime[r],t)}function a(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function u(e){var t=l.extname(e).toLowerCase();return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[t]}function c(e){null==e.autoplay&&(e.autoplay=!0),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=k)}n.render=r,n.append=o,n.mime=e("./lib/mime.json");var f=e("debug")("render-media"),d=e("is-ascii"),h=e("mediasource"),l=e("path"),p=e("stream-to-blob-url"),m=e("videostream"),g=[".m4a",".m4v",".mp4"],y=[".m4v",".mkv",".mp4",".webm"],_=[".m4a",".mp3"],v=[].concat(y,_),b=[".aac",".oga",".ogg",".wav"],w=[".bmp",".gif",".jpeg",".jpg",".png"],E=[".css",".html",".js",".md",".pdf",".txt"],k=2e8,x="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":84,debug:30,"is-ascii":43,mediasource:50,path:64,"stream-to-blob-url":99,videostream:117}],84:[function(e,t,n){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],85:[function(e,t,n){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,s),r=null}d?e.nextTick(n):n()}function i(e,n,r){if(s[e]=r,n&&(f=!0),0===--u||n)o(n);else if(!f&&h0;e+=1);return e},s=function(e,t){var n=new Uint8Array(e.buffer),r=t%4,o=t-r;switch(r){case 0:n[o+3]=0;case 1:n[o+2]=0;case 2:n[o+1]=0;case 3:n[o+0]=0}for(var i=(t>>2)+1;i>2]|=128<<24-(t%4<<3),e[((t>>2)+2&-16)+14]=n/(1<<29)|0,e[((t>>2)+2&-16)+15]=n<<3},u=function(e,t,n,r,o){var i,s=this,a=o%4,u=(r+a)%4,c=r-u;switch(a){case 0:e[o]=s.charCodeAt(n+3);case 1:e[o+1-(a<<1)|0]=s.charCodeAt(n+2);case 2:e[o+2-(a<<1)|0]=s.charCodeAt(n+1);case 3:e[o+3-(a<<1)|0]=s.charCodeAt(n)}if(!(r>2]=s.charCodeAt(n+i)<<24|s.charCodeAt(n+i+1)<<16|s.charCodeAt(n+i+2)<<8|s.charCodeAt(n+i+3);switch(u){case 3:e[o+c+1|0]=s.charCodeAt(n+c+2);case 2:e[o+c+2|0]=s.charCodeAt(n+c+1);case 1:e[o+c+3|0]=s.charCodeAt(n+c)}}},c=function(e,t,n,r,o){var i,s=this,a=o%4,u=(r+a)%4,c=r-u;switch(a){case 0:e[o]=s[n+3];case 1:e[o+1-(a<<1)|0]=s[n+2];case 2:e[o+2-(a<<1)|0]=s[n+1];case 3:e[o+3-(a<<1)|0]=s[n]}if(!(r>2|0]=s[n+i]<<24|s[n+i+1]<<16|s[n+i+2]<<8|s[n+i+3];switch(u){case 3:e[o+c+1|0]=s[n+c+2];case 2:e[o+c+2|0]=s[n+c+1];case 1:e[o+c+3|0]=s[n+c]}}},f=function(e,t,n,r,i){var s,a=this,u=i%4,c=(r+u)%4,f=r-c,d=new Uint8Array(o.readAsArrayBuffer(a.slice(n,n+r)));switch(u){case 0:e[i]=d[3];case 1:e[i+1-(u<<1)|0]=d[2];case 2:e[i+2-(u<<1)|0]=d[1];case 3:e[i+3-(u<<1)|0]=d[0]}if(!(r>2|0]=d[s]<<24|d[s+1]<<16|d[s+2]<<8|d[s+3];switch(c){case 3:e[i+f+1|0]=d[f+2];case 2:e[i+f+2|0]=d[f+1];case 1:e[i+f+3|0]=d[f]}}},d=function(e){switch(r.getDataType(e)){case"string":return u.bind(e);case"array":return c.bind(e);case"buffer":return c.bind(e);case"arraybuffer":return c.bind(new Uint8Array(e));case"view":return c.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},h=new Array(256),l=0;l<256;l++)h[l]=(l<16?"0":"")+l.toString(16);var p=function(e){for(var t=new Uint8Array(e),n=new Array(e.byteLength),r=0;r0)throw new Error("Chunk size must be a multiple of 128 bit");t.offset=0,t.maxChunkLen=e,t.padMaxChunkLen=i(e),t.heap=new ArrayBuffer(m(t.padMaxChunkLen+320+20)),t.h32=new Int32Array(t.heap),t.h8=new Int8Array(t.heap),t.core=new n._core({Int32Array:Int32Array,DataView:DataView},{},t.heap),t.buffer=null};g(e||65536);var y=function(e,n){t.offset=0;var r=new Int32Array(e,n+320,5);r[0]=1732584193,r[1]=-271733879,r[2]=-1732584194,r[3]=271733878,r[4]=-1009589776},_=function(e,n){var r=i(e),o=new Int32Array(t.heap,0,r>>2);return s(o,e),a(o,e,n),r},v=function(e,n,r,o){d(e)(t.h8,t.h32,n,r,o||0)},b=function(e,n,r,o,i){var s=r;v(e,n,r),i&&(s=_(r,o)),t.core.hash(s,t.padMaxChunkLen)},w=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),o=new DataView(r.buffer);return o.setInt32(0,n[0],!1),o.setInt32(4,n[1],!1),o.setInt32(8,n[2],!1),o.setInt32(12,n[3],!1),o.setInt32(16,n[4],!1),r},E=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;y(t.heap,t.padMaxChunkLen);var r=0,o=t.maxChunkLen;for(r=0;n>r+o;r+=o)b(e,r,o,n,!1);return b(e,r,n-r,n,!0),w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return p(E(e).buffer)},this.resetState=function(){return y(t.heap,t.padMaxChunkLen),this},this.append=function(e){var n,r=0,o=e.byteLength||e.length||e.size||0,i=t.offset%t.maxChunkLen;for(t.offset+=o;r>2]|0;a=o[t+324>>2]|0;c=o[t+328>>2]|0;d=o[t+332>>2]|0;l=o[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=i;u=a;f=c;h=d;p=l;for(r=0;(r|0)<64;r=r+4|0){g=o[n+r>>2]|0;m=((i<<5|i>>>27)+(a&c|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[e+r>>2]=g}for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a&c|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a^c^d)|0)+((g+l|0)+1859775393|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a&c|a&d|c&d)|0)+((g+l|0)-1894007588|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a^c^d)|0)+((g+l|0)-899497514|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}i=i+s|0;a=a+u|0;c=c+f|0;d=d+h|0;l=l+p|0}o[t+320>>2]=i;o[t+324>>2]=a;o[t+328>>2]=c;o[t+332>>2]=d;o[t+336>>2]=l}return{hash:i}},"undefined"!=typeof t?t.exports=n:"undefined"!=typeof window&&(window.Rusha=n),"undefined"!=typeof FileReaderSync){var o=new FileReaderSync,i=new n(4194304);self.onmessage=function(e){var t,n=e.data.data;try{t=i.digest(n),self.postMessage({id:e.data.id,hash:t})}catch(t){self.postMessage({id:e.data.id,error:t.name})}}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],88:[function(e,t,n){t.exports=e("buffer")},{buffer:24}],89:[function(e,t,n){(function(e){t.exports=function(t,n){var r=[];t.on("data",function(e){r.push(e)}),t.once("end",function(){n&&n(null,e.concat(r)),n=null}),t.once("error",function(e){n&&n(e),n=null})}}).call(this,e("buffer").Buffer)},{buffer:24}],90:[function(e,t,n){(function(n){function r(e,t){e="string"==typeof e?{url:e}:Object.assign({},e),t=u(t),e.url&&o(e),null==e.headers&&(e.headers={}),null==e.maxRedirects&&(e.maxRedirects=10);var i;e.form&&(i="string"==typeof e.form?e.form:c.stringify(e.form)),e.body&&(i=e.json?JSON.stringify(e.body):e.body),e.json&&(e.headers.accept="application/json"),e.json&&i&&(e.headers["content-type"]="application/json"),e.form&&(e.headers["content-type"]="application/x-www-form-urlencoded"),i&&(e.headers["content-length"]=n.byteLength(i)),delete e.body,delete e.form,i&&!e.method&&(e.method="POST"),e.method&&(e.method=e.method.toUpperCase());var d=Object.keys(e.headers).some(function(e){return"accept-encoding"===e.toLowerCase()});d||(e.headers["accept-encoding"]="gzip, deflate");var h="https:"===e.protocol?a:s,l=h.request(e,function(n){if(n.statusCode>=300&&n.statusCode<400&&"location"in n.headers)return e.url=n.headers.location,o(e),n.resume(),e.maxRedirects-=1,void(e.maxRedirects>0?r(e,t):t(new Error("too many redirects")));var i="function"==typeof f&&"HEAD"!==e.method;t(null,i?f(n):n)});return l.on("timeout",function(){l.abort(),t(new Error("Request timed out"))}),l.on("error",t),l.end(i),l}function o(e){var t=d.parse(e.url);t.hostname&&(e.hostname=t.hostname),t.port&&(e.port=t.port),t.protocol&&(e.protocol=t.protocol),t.auth&&(e.auth=t.auth),e.path=t.path,delete e.url}t.exports=r;var i=e("simple-concat"),s=e("http"),a=e("https"),u=e("once"),c=e("querystring"),f=e("unzip-response"),d=e("url");r.concat=function(e,t){return r(e,function(n,r){return n?t(n):void i(r,function(n,o){if(n)return t(n);if(e.json)try{o=JSON.parse(o.toString())}catch(e){return t(e,r,o)}t(null,r,o)})})},["get","post","put","patch","head","delete"].forEach(function(e){r[e]=function(t,n){return"string"==typeof t&&(t={url:t}),t.method=e.toUpperCase(),r(t,n)}})}).call(this,e("buffer").Buffer)},{buffer:24,http:95,https:39,once:61,querystring:72,"simple-concat":89,"unzip-response":21,url:112}],91:[function(e,t,n){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._id=u(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({},{allowHalfOpen:!1,highWaterMark:1048576},e),c.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||u(20).toString("hex"):null,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=e.config||r.config,t.constraints=e.constraints||r.constraints,t.offerConstraints=e.offerConstraints||{},t.answerConstraints=e.answerConstraints||{},t.reconnectTimer=e.reconnectTimer||!1,t.sdpTransform=e.sdpTransform||function(e){return e},t.stream=e.stream||!1,t.trickle=void 0===e.trickle||e.trickle,t.destroyed=!1,t.connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:s(),!t._wrtc)throw"undefined"==typeof window?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser");if(t._maxBufferedAmount=e.highWaterMark,t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._channel=null,t._pendingCandidates=[],t._chunk=null,t._cb=null,t._interval=null,t._reconnectTimeout=null,t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints),t._isWrtc=Array.isArray(t._pc.RTCIceConnectionStates),t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceConnectionStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.stream&&t._pc.addStream(t.stream),"ontrack"in t._pc?t._pc.ontrack=function(e){t._onTrack(e)}:t._pc.onaddstream=function(e){t._onAddStream(e)},t.initiator){var n=!1;t._pc.onnegotiationneeded=function(){n||t._createOffer(),n=!0},t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}),t._isWrtc&&t._pc.onnegotiationneeded()}else t._pc.ondatachannel=function(e){t._setupData(e)};t.on("finish",function(){t.connected?setTimeout(function(){t._destroy()},100):t.once("connect",function(){setTimeout(function(){t._destroy()},100)})})}function o(){}t.exports=r;var i=e("debug")("simple-peer"),s=e("get-browser-rtc"),a=e("inherits"),u=e("randombytes"),c=e("readable-stream");a(r,c.Duplex),r.WEBRTC_SUPPORT=!!s(),r.config={iceServers:[{urls:"stun:stun.l.google.com:19302"}]},r.constraints={},r.channelConfig={},Object.defineProperty(r.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}}),r.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}},r.prototype.signal=function(e){function t(e){try{n._pc.addIceCandidate(new n._wrtc.RTCIceCandidate(e),o,function(e){n._onError(e)})}catch(e){n._destroy(new Error("error adding candidate: "+e.message))}}var n=this;if(n.destroyed)throw new Error("cannot signal after peer is destroyed");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}n._debug("signal()"),e.sdp&&n._pc.setRemoteDescription(new n._wrtc.RTCSessionDescription(e),function(){n.destroyed||("offer"===n._pc.remoteDescription.type&&n._createAnswer(),n._pendingCandidates.forEach(t),n._pendingCandidates=[])},function(e){n._onError(e)}),e.candidate&&(n._pc.remoteDescription?t(e.candidate):n._pendingCandidates.push(e.candidate)),e.sdp||e.candidate||n._destroy(new Error("signal() called with invalid signal data"))},r.prototype.send=function(e){var t=this;t._isWrtc&&n.isBuffer(e)&&(e=new Uint8Array(e)),t._channel.send(e)},r.prototype.destroy=function(e){var t=this;t._destroy(null,e)},r.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(t&&n.once("close",t),n._debug("destroy (error: %s)",e&&e.message),n.readable=n.writable=!1,n._readableState.ended||n.push(null),n._writableState.finished||n.end(),n.destroyed=!0,n.connected=!1,n._pcReady=!1,n._channelReady=!1,n._chunk=null,n._cb=null,clearInterval(n._interval),clearTimeout(n._reconnectTimeout),n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null,"ontrack"in n._pc?n._pc.ontrack=null:n._pc.onaddstream=null,n._pc.onnegotiationneeded=null,n._pc.ondatachannel=null}if(n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null}n._pc=null,n._channel=null,e&&n.emit("error",e),n.emit("close")}},r.prototype._setupData=function(e){var t=this;t._channel=e.channel,t.channelName=t._channel.label,t._channel.binaryType="arraybuffer",t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()}},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(new Error("cannot write after peer is destroyed"));if(r.connected){try{r.send(e)}catch(e){return r._onError(e)}r._channel.bufferedAmount>r._maxBufferedAmount?(r._debug("start backpressure: bufferedAmount %d",r._channel.bufferedAmount),r._cb=n):n(null)}else r._debug("write before connect"),r._chunk=e,r._cb=n},r.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){if(!e.destroyed){t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,o,function(t){e._onError(t)});var n=function(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})};e.trickle||e._iceComplete?n():e.once("_iceComplete",n)}},function(t){e._onError(t)},e.offerConstraints)},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){if(!e.destroyed){t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,o,function(t){e._onError(t)});var n=function(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})};e.trickle||e._iceComplete?n():e.once("_iceComplete",n)}},function(t){e._onError(t)},e.answerConstraints)},r.prototype._onIceConnectionStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceGatheringState,n=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,n),e.emit("iceConnectionStateChange",t,n),"connected"!==n&&"completed"!==n||(clearTimeout(e._reconnectTimeout),e._pcReady=!0,e._maybeReady()),"disconnected"===n&&(e.reconnectTimer?(clearTimeout(e._reconnectTimeout),e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)):e._destroy()),"failed"===n&&e._destroy(new Error("Ice connection failed.")),"closed"===n&&e._destroy()}},r.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var n=[];t.forEach(function(e){n.push(e)}),e(n)},function(e){t._onError(e)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(n)},function(e){t._onError(e)}):t._pc.getStats.length>0?t._pc.getStats(function(t){var n=[];t.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e(n)},function(e){t._onError(e)}):e([])},r.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,e.getStats(function(t){function n(t){var n=o[t.localCandidateId];n&&n.ip?(e.localAddress=n.ip,e.localPort=Number(n.port)):n&&n.ipAddress?(e.localAddress=n.ipAddress,e.localPort=Number(n.portNumber)):"string"==typeof t.googLocalAddress&&(n=t.googLocalAddress.split(":"),e.localAddress=n[0],e.localPort=Number(n[1]));var i=r[t.remoteCandidateId];i&&i.ip?(e.remoteAddress=i.ip,e.remotePort=Number(i.port)):i&&i.ipAddress?(e.remoteAddress=i.ipAddress,e.remotePort=Number(i.portNumber)):"string"==typeof t.googRemoteAddress&&(i=t.googRemoteAddress.split(":"),e.remoteAddress=i[0],e.remotePort=Number(i[1])),e.remoteFamily="IPv4",e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}e._connecting=!1,e.connected=!0;var r={},o={},i={};if(t.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(r[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(o[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(i[e.id]=e)}),t.forEach(function(e){"transport"===e.type&&n(i[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&n(e)}),e._chunk){try{e.send(e._chunk)}catch(t){return e._onError(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var s=e._cb;e._cb=null,s(null)}e._interval=setInterval(function(){if(e._cb&&e._channel&&!(e._channel.bufferedAmount>e._maxBufferedAmount)){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},150),e._interval.unref&&e._interval.unref(),e._debug("connect"),e.emit("connect")}))},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||(e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},r.prototype._onIceCandidate=function(e){var t=this;t.destroyed||(e.candidate&&t.trickle?t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||(t._iceComplete=!0,t.emit("_iceComplete")))},r.prototype._onChannelMessage=function(e){var t=this;if(!t.destroyed){var r=e.data;t._debug("read: %d bytes",r.byteLength||r.length),r instanceof ArrayBuffer&&(r=new n(r)),t.push(r)}},r.prototype._onChannelOpen=function(){var e=this;e.connected||e.destroyed||(e._debug("on channel open"),e._channelReady=!0,e._maybeReady())},r.prototype._onChannelClose=function(){var e=this;e.destroyed||(e._debug("on channel close"),e._destroy())},r.prototype._onAddStream=function(e){var t=this;t.destroyed||(t._debug("on add stream"),t.emit("stream",e.stream))},r.prototype._onTrack=function(e){var t=this;t.destroyed||(t._debug("on track"),t.emit("stream",e.streams[0]))},r.prototype._onError=function(e){var t=this;t.destroyed||(t._debug("error %s",e.message||e),t._destroy(e))},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],i.apply(null,t)}}).call(this,e("buffer").Buffer)},{buffer:24,debug:30,"get-browser-rtc":38,inherits:42,randombytes:74,"readable-stream":82}],92:[function(e,t,n){function r(e){return u.digest(e)}function o(e,t){return d?("string"==typeof e&&(e=i(e)),void d.digest({name:"sha-1"},e).then(function(e){t(s(new Uint8Array(e)))},function(n){t(r(e))})):void setTimeout(t,0,r(e))}function i(e){for(var t=e.length,n=new Uint8Array(t),r=0;r>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")}var a=e("rusha"),u=new a,c="undefined"!=typeof window?window:self,f=c.crypto||c.msCrypto||{},d=f.subtle||f.webkitSubtle;try{d.digest({name:"sha-1"},new Uint8Array).catch(function(){d=!1})}catch(e){d=!1}t.exports=o,t.exports.sync=r},{rusha:87}],93:[function(e,t,n){(function(n,r){function o(e,t){var r=this;if(!(r instanceof o))return new o(e,t);t||(t={}),r._id=u(4).toString("hex").slice(0,7),r._debug("new websocket: %s %o",e,t),t=s({},{allowHalfOpen:!1,highWaterMark:1048576},t),c.Duplex.call(r,t),r.url=e,r.connected=!1,r.destroyed=!1,r._maxBufferedAmount=t.highWaterMark,r._chunk=null,r._cb=null,r._interval=null;try{"function"==typeof f?r._ws=new d(r.url,t):r._ws=new d(r.url)}catch(e){return void n.nextTick(function(){r._onError(e)})}r._ws.binaryType="arraybuffer",r._ws.onopen=function(){r._onOpen()},r._ws.onmessage=function(e){r._onMessage(e)},r._ws.onclose=function(){r._onClose()},r._ws.onerror=function(){r._onError(new Error("connection error to "+r.url))},r.on("finish",function(){r.connected?setTimeout(function(){r._destroy()},100):r.once("connect",function(){setTimeout(function(){r._destroy()},100)})})}t.exports=o;var i=e("debug")("simple-websocket"),s=e("xtend"),a=e("inherits"),u=e("randombytes"),c=e("readable-stream"),f=e("ws"),d="function"!=typeof f?WebSocket:f;a(o,c.Duplex),o.WEBSOCKET_SUPPORT=!!d,o.prototype.send=function(e){var t=this;t._ws.send(e)},o.prototype.destroy=function(e){var t=this;t._destroy(null,e)},o.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(t&&n.once("close",t),n._debug("destroy (error: %s)",e&&e.message),n.readable=n.writable=!1,n._readableState.ended||n.push(null),n._writableState.finished||n.end(),n.connected=!1,n.destroyed=!0,clearInterval(n._interval),n._interval=null,n._chunk=null,n._cb=null,n._ws){var r=n._ws,o=function(){r.onclose=null};if(r.readyState===d.CLOSED)o();else try{r.onclose=o,r.close()}catch(e){o()}r.onopen=null,r.onmessage=null,r.onerror=null}n._ws=null,e&&n.emit("error",e),n.emit("close")}},o.prototype._read=function(){},o.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(new Error("cannot write after socket is destroyed"));if(r.connected){try{r.send(e)}catch(e){return r._onError(e)}"function"!=typeof f&&r._ws.bufferedAmount>r._maxBufferedAmount?(r._debug("start backpressure: bufferedAmount %d",r._ws.bufferedAmount),r._cb=n):n(null)}else r._debug("write before connect"),r._chunk=e,r._cb=n},o.prototype._onMessage=function(e){var t=this;if(!t.destroyed){var n=e.data;n instanceof ArrayBuffer&&(n=new r(n)),t.push(n)}},o.prototype._onOpen=function(){var e=this;if(!e.connected&&!e.destroyed){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e._onError(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof f&&(e._interval=setInterval(function(){if(e._cb&&e._ws&&!(e._ws.bufferedAmount>e._maxBufferedAmount)){e._debug("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},o.prototype._onClose=function(){var e=this;e.destroyed||(e._debug("on close"),e._destroy())},o.prototype._onError=function(e){var t=this;t.destroyed||(t._debug("error: %s",e.message||e),t._destroy(e))},o.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],i.apply(null,t)}}).call(this,e("_process"),e("buffer").Buffer)},{_process:67,buffer:24,debug:30,inherits:42,randombytes:74,"readable-stream":82,ws:21,xtend:119}],94:[function(e,t,n){var r=1,o=65535,i=4,s=function(){r=r+1&o},a=setInterval(s,1e3/i|0);a.unref&&a.unref(),t.exports=function(e){var t=i*(e||5),n=[0],s=1,a=r-1&o;return function(e){var u=r-a&o;for(u>t&&(u=t),a=r;u--;)s===t&&(s=0),n[s]=n[0===s?t-1:s-1],s++;e&&(n[s-1]+=e);var c=n[s-1],f=n.lengthe._pos){var i=n.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new o(i.length),a=0;ae._pos&&(e.push(new o(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(n)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":96,_process:67,buffer:24,inherits:42,"readable-stream":82}],99:[function(e,t,n){var r=e("stream-to-blob");t.exports=function e(t,n,o){return"function"==typeof n?e(t,null,n):void r(t,n,function(e,t){if(e)return o(e);var n=URL.createObjectURL(t);o(null,n)})}},{"stream-to-blob":100}],100:[function(e,t,n){var r=e("once");t.exports=function e(t,n,o){if("function"==typeof n)return e(t,null,n);o=r(o);var i=[];t.on("data",function(e){i.push(e)}).on("end",function(){var e=n?new Blob(i,{type:n}):new Blob(i);o(null,e)}).on("error",o)}},{once:61}],101:[function(e,t,n){(function(n){var r=e("once");t.exports=function(e,t,o){o=r(o);var i=new n(t),s=0;e.on("data",function(e){e.copy(i,s),s+=e.length}).on("end",function(){o(null,i)}).on("error",o)}}).call(this,e("buffer").Buffer)},{buffer:24,once:61}],102:[function(e,t,n){function r(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function o(e){return e.toString(this.encoding)}function i(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.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!0;default:return!1}},c=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=i;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=o)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var o=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,o),o-=this.charReceived),t+=e.toString(this.encoding,0,o);var o=t.length-1,r=t.charCodeAt(o);if(r>=55296&&r<=56319){var i=this.surrogateSize;return this.charLength+=i,this.charReceived+=i,this.charBuffer.copy(this.charBuffer,i,0,i),e.copy(this.charBuffer,0,0,i),t.substring(0,o)}return t},c.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,o=this.encoding;t+=r.slice(0,n).toString(o)}return t}},{buffer:24}],103:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":104}],104:[function(e,t,n){(function(e){"use strict";function t(e){var t=Math.floor(e.length/5);return e.length%5===0?t:t+1}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",o=[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];n.encode=function(n){e.isBuffer(n)||(n=new e(n));for(var o=0,i=0,s=0,a=0,u=new e(8*t(n));o3?(a=c&255>>s,s=(s+5)%8,a=a<>8-s,o++):(a=c>>8-(s+5)&31,s=(s+5)%8,0===s&&o++),u[i]=r.charCodeAt(a),i++}for(o=i;o>>r,a[s]=n,s++,n=255&i<<8-r)}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:24}],105:[function(e,t,n){var r=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(r.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,o=0;o=e.length||t<0)){var n=e.pop();if(t",'"',"`"," ","\r","\n","\t"],p=["{","}","|","\\","^","`"].concat(l),m=["'"].concat(p),g=["%","/","?",";","#"].concat(m),y=["/","?","#"],_=255,v=/^[+a-z0-9A-Z_-]{0,63}$/,b=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},k={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},x=e("querystring");r.prototype.parse=function(e,t,n){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=r!==-1&&r127?"x":O[M];if(!P.match(v)){var H=U.slice(0,I),q=U.slice(I+1),D=O.match(b);D&&(H.push(D[1]),q.unshift(D[2])),q.length&&(a="/"+q.join(".")+a),this.hostname=H.join(".");break}}}this.hostname.length>_?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=u.toASCII(this.hostname));var N=this.port?":"+this.port:"",W=this.hostname||"";this.host=W+N,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[p])for(var I=0,R=m.length;I0)&&n.host.split("@");S&&(n.auth=S.shift(),n.host=n.hostname=S.shift())}return n.search=e.search,n.query=e.query,c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!w.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var B=w.slice(-1)[0],I=(n.host||e.host||w.length>1)&&("."===B||".."===B)||""===B,A=0,C=w.length;C>=0;C--)B=w[C],"."===B?w.splice(C,1):".."===B?(w.splice(C,1),A++):A&&(w.splice(C,1),A--);if(!v&&!b)for(;A--;A)w.unshift("..");!v||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),I&&"/"!==w.join("/").substr(-1)&&w.push("");var L=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(x){n.hostname=n.host=L?"":w.length?w.shift():"";var S=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");S&&(n.auth=S.shift(),n.host=n.hostname=S.shift())}return v=v||n.host&&w.length,v&&!L&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var e=this.host,t=d.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":113,punycode:69,querystring:72}],113:[function(e,t,n){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],114:[function(e,t,n){var r=e("bencode"),o=e("bitfield"),i=e("safe-buffer").Buffer,s=e("debug")("ut_metadata"),a=e("events").EventEmitter,u=e("inherits"),c=e("simple-sha1"),f=1e7,d=1e3,h=16384;t.exports=function(e){function t(t){a.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new o(0,{grow:d}),i.isBuffer(e)&&this.setMetadata(e)}return u(t,a),t.prototype.name="ut_metadata",t.prototype.onHandshake=function(e,t,n){this._infoHash=e},t.prototype.onExtendedHandshake=function(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||fthis._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t,n){t.length>h||(t.copy(this.metadata,e*h),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=i.alloc(this._metadataSize);for(var e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}},{bencode:11,bitfield:13,debug:30,events:35,inherits:42,"safe-buffer":88,"simple-sha1":92}],115:[function(e,t,n){(function(e){function n(e,t){function n(){if(!o){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),o=!0}return e.apply(this,arguments)}if(r("noDeprecation"))return e;var o=!1;return n}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],116:[function(e,t,n){(function(n){function r(e){var t=this;a.call(t),t._tracks=[],t._fragmentSequence=1,t._file=e,t._decoder=null,t._findMoov(0)}function o(e,t){var n=this;n._entries=e,n._countName=t||"count",n._index=0,n._offset=0,n.value=n._entries[0]}function i(){return{version:0,flags:0,entries:[]}}var s=e("binary-search"),a=e("events").EventEmitter,u=e("inherits"),c=e("mp4-stream"),f=e("mp4-box-encoding"),d=e("range-slice-stream");t.exports=r,u(r,a),r.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=c.decode();var n=t._file.createReadStream({start:e});n.pipe(t._decoder),t._decoder.once("box",function(r){"moov"===r.type?t._decoder.decode(function(e){n.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(n.destroy(),t._findMoov(e+r.length))})},o.prototype.inc=function(){var e=this;e._offset++,e._offset>=e._entries[e._index][e._countName]&&(e._index++,e._offset=0),e.value=e._entries[e._index]},r.prototype._processMoov=function(e){var t=this,r=e.traks;t._tracks=[],t._hasVideo=!1,t._hasAudio=!1;for(var s=0;s=d.stsz.entries.length)break;if(g++,_+=S,g>=x.samplesPerChunk){g=0,_=0,y++;var C=d.stsc.entries[v+1];C&&y+1>=C.firstChunk&&v++}b+=B,w.inc(),E&&E.inc(),A&&k++}c.mdia.mdhd.duration=0,c.tkhd.duration=0;var L=x.sampleDescriptionId,T={type:"moov",mvhd:e.mvhd,traks:[{tkhd:c.tkhd,mdia:{mdhd:c.mdia.mdhd,hdlr:c.mdia.hdlr,elng:c.mdia.elng,minf:{vmhd:c.mdia.minf.vmhd,smhd:c.mdia.minf.smhd,dinf:c.mdia.minf.dinf,stbl:{stsd:d.stsd,stts:i(),ctts:i(),stsc:i(),stsz:i(),stco:i(),stss:i()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:c.tkhd.trackId,defaultSampleDescriptionIndex:L,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:c.tkhd.trackId,timeScale:c.mdia.mdhd.timeScale,samples:p,currSample:null,currTime:null,moov:T,mime:u})}if(0===t._tracks.length)return void t.emit("error",new Error("no playable tracks"));e.mvhd.duration=0,t._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var U=f.encode(t._ftyp),R=t._tracks.map(function(e){var t=f.encode(e.moov);return{mime:e.mime,init:n.concat([U,t])}});t.emit("ready",R)},r.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var n=-1;if(t._tracks.map(function(r,o){function i(e){s.destroyed||s.box(e.moof,function(n){if(n)return t.emit("error",n);if(!s.destroyed){var a=r.inStream.slice(e.ranges);a.pipe(s.mediaData(e.length,function(e){if(e)return t.emit("error",e);if(!s.destroyed){var n=t._generateFragment(o);return n?void i(n):s.finalize()}}))}})}r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var s=r.outStream=c.encode(),a=t._generateFragment(o,e);return a?((n===-1||a.ranges[0].start=0){var r=t._fileStream=t._file.createReadStream({start:n});t._tracks.forEach(function(e){e.inStream=new d(n,{highWaterMark:1e7}),r.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},r.prototype._findSampleBefore=function(e,t){var n=this,r=n._tracks[e],o=Math.floor(r.timeScale*t),i=s(r.samples,o,function(e,t){var n=e.dts+e.presentationOffset;return n-t});for(i===-1?i=0:i<0&&(i=-i-2);!r.samples[i].sync;)i--;return i};var h=1;r.prototype._generateFragment=function(e,t){var n,r=this,o=r._tracks[e];if(n=void 0!==t?r._findSampleBefore(e,t):o.currSample,n>=o.samples.length)return null;for(var i=o.samples[n].dts,s=0,a=[],u=n;u=o.timeScale*h)break;s+=c.size;var f=a.length-1;f<0||a[f].end!==c.offset?a.push({start:c.offset,end:c.offset+c.size}):a[f].end+=c.size}return o.currSample=u,{moof:r._generateMoof(e,n,u),ranges:a,length:s}},r.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],i=[],s=t;s0?new Array(t+(/\./.test(n)?2:1)).join(r)+n:n+"")}},{}],122:[function(e,t,n){t.exports={version:"0.98.8"}},{}],123:[function(e,t,n){(function(n,r){function o(e){function t(){i.destroyed||(i.ready=!0,i.emit("ready"))}var i=this;return i instanceof o?(h.call(i),e||(e={}),"string"==typeof e.peerId?i.peerId=e.peerId:a.isBuffer(e.peerId)?i.peerId=e.peerId.toString("hex"):i.peerId=a.from(I+b(9).toString("base64")).toString("hex"),i.peerIdBuffer=a.from(i.peerId,"hex"),"string"==typeof e.nodeId?i.nodeId=e.nodeId:a.isBuffer(e.nodeId)?i.nodeId=e.nodeId.toString("hex"):i.nodeId=b(20).toString("hex"),i.nodeIdBuffer=a.from(i.nodeId,"hex"),i._debugId=i.peerId.toString("hex").substring(0,7),i.destroyed=!1,i.listening=!1,i.torrentPort=e.torrentPort||0,i.dhtPort=e.dhtPort||0,i.tracker=void 0!==e.tracker?e.tracker:{},i.torrents=[],i.maxConns=Number(e.maxConns)||55,i._debug("new webtorrent (peerId %s, nodeId %s, port %s)",i.peerId,i.nodeId,i.torrentPort),i.tracker&&("object"!=typeof i.tracker&&(i.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),i.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),i.tracker.wrtc=e.wrtc),r.WRTC&&!i.tracker.wrtc&&(i.tracker.wrtc=r.WRTC)),"function"==typeof k?i._tcpPool=new k(i):n.nextTick(function(){i._onListening()}),i._downloadSpeed=w(),i._uploadSpeed=w(),e.dht!==!1&&"function"==typeof d?(i.dht=new d(l({nodeId:i.nodeId},e.dht)),i.dht.once("error",function(e){i._destroy(e)}),i.dht.once("listening",function(){var e=i.dht.address();e&&(i.dhtPort=e.port)}),i.dht.setMaxListeners(0),i.dht.listen(i.dhtPort)):i.dht=!1,i.enableWebSeeds=e.webSeeds!==!1,void("function"==typeof m&&null!=e.blocklist?m(e.blocklist,{headers:{"user-agent":"WebTorrent/"+S+" (https://webtorrent.io)"}},function(e,n){return e?i.error("Failed to load blocklist: "+e.message):(i.blocked=n,void t())}):n.nextTick(t))):new o(e)}function i(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function s(e){return"undefined"!=typeof FileList&&e instanceof FileList}t.exports=o;var a=e("safe-buffer").Buffer,u=e("simple-concat"),c=e("create-torrent"),f=e("debug")("webtorrent"),d=e("bittorrent-dht/client"),h=e("events").EventEmitter,l=e("xtend"),p=e("inherits"),m=e("load-ip-set"),g=e("run-parallel"),y=e("parse-torrent"),_=e("path"),v=e("simple-peer"),b=e("randombytes"),w=e("speedometer"),E=e("zero-fill"),k=e("./lib/tcp-pool"),x=e("./lib/torrent"),S=e("./package.json").version,B=S.match(/([0-9]+)/g).slice(0,2).map(function(e){return E(2,e)}).join(""),I="-WW"+B+"-";p(o,h),o.WEBRTC_SUPPORT=v.WEBRTC_SUPPORT,Object.defineProperty(o.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(o.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(o.prototype,"progress",{get:function(){var e=this.torrents.filter(function(e){return 1!==e.progress}),t=e.reduce(function(e,t){return e+t.downloaded},0),n=e.reduce(function(e,t){return e+(t.length||0)},0)||1;return t/n}}),Object.defineProperty(o.prototype,"ratio",{get:function(){var e=this.torrents.reduce(function(e,t){return e+t.uploaded},0),t=this.torrents.reduce(function(e,t){return e+t.received},0)||1;return e/t}}),o.prototype.get=function(e){var t,n,r=this,o=r.torrents.length;if(e instanceof x){for(t=0;t