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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/config.yml4
-rw-r--r--.github/lock.yml2
-rw-r--r--.github/no-response.yml2
-rw-r--r--.github/stale.yml5
-rw-r--r--AUTHORS.md13
-rw-r--r--CONTRIBUTING.md75
-rw-r--r--README.md6
-rw-r--r--SECURITY.md42
-rw-r--r--docs/api.md74
-rw-r--r--docs/faq.md3
-rw-r--r--docs/get-started.md6
-rw-r--r--index.js4
-rw-r--r--lib/file-stream.js3
-rw-r--r--lib/file.js12
-rw-r--r--lib/rarity-map.js2
-rw-r--r--lib/server.js88
-rw-r--r--lib/torrent.js79
-rw-r--r--lib/webconn.js1
-rw-r--r--package.json56
-rw-r--r--test/browser/basic.js1
-rw-r--r--test/client-add-duplicate-trackers.js10
-rw-r--r--test/client-add.js7
-rw-r--r--test/client-destroy.js1
-rw-r--r--test/client-seed.js3
-rw-r--r--test/common.js13
-rw-r--r--test/node/blocklist-dht.js11
-rw-r--r--test/node/blocklist-tracker.js11
-rw-r--r--test/node/blocklist.js4
-rw-r--r--test/node/download-dht-magnet.js2
-rw-r--r--test/node/download-dht-torrent.js2
-rw-r--r--test/node/download-tracker-magnet.js2
-rw-r--r--test/node/download-tracker-torrent.js2
-rw-r--r--test/node/seed-stream.js2
-rw-r--r--test/node/swarm-basic.js1
-rw-r--r--test/node/swarm-reconnect.js1
-rw-r--r--test/node/swarm-timeout.js1
-rw-r--r--test/swarm.js1
-rw-r--r--webtorrent.min.js12
38 files changed, 314 insertions, 250 deletions
diff --git a/.github/config.yml b/.github/config.yml
index 3fcf78b..ea6bf58 100644
--- a/.github/config.yml
+++ b/.github/config.yml
@@ -13,7 +13,3 @@ newPRWelcomeComment: >
firstPRMergeComment: >
🎉 Congrats on getting your first pull request landed! <br><br>
![](https://feross.net/s/cats/29.gif)
-
-# ProBot WIP (https://probot.github.io/apps/wip/)
-
-# (Requires no configuration)
diff --git a/.github/lock.yml b/.github/lock.yml
index 0f82605..5df3141 100644
--- a/.github/lock.yml
+++ b/.github/lock.yml
@@ -1,4 +1,4 @@
# ProBot Lock (https://probot.github.io/apps/lock/)
-daysUntilLock: 90
+daysUntilLock: 365
lockComment: false
diff --git a/.github/no-response.yml b/.github/no-response.yml
index 714c1e1..7e320d2 100644
--- a/.github/no-response.yml
+++ b/.github/no-response.yml
@@ -1,6 +1,6 @@
# ProBot No Response (https://probot.github.io/apps/no-response/)
-daysUntilClose: 7
+daysUntilClose: 14
responseRequiredLabel: 'need more info'
closeComment: >
This issue has been automatically closed because there was no response to a
diff --git a/.github/stale.yml b/.github/stale.yml
index df9115c..4de49ea 100644
--- a/.github/stale.yml
+++ b/.github/stale.yml
@@ -1,11 +1,14 @@
# ProBot Stale (https://probot.github.io/apps/stale/)
daysUntilStale: 90
-daysUntilClose: 7
+daysUntilClose: 14
exemptLabels:
- accepted
+ - blocked
- bug
- enhancement
+ - greenkeeper
+ - 'help wanted'
- meta
staleLabel: stale
markComment: >
diff --git a/AUTHORS.md b/AUTHORS.md
index 513a900..69b5bb2 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -133,6 +133,7 @@
- Kaylee (34007889+KayleePop@users.noreply.github.com)
- Brad Marsden (silentbot1@gmail.com)
- lovefoodcode (38153617+lovefoodcode@users.noreply.github.com)
+- Gabriel Almeida (gabrieel@email.com)
- filesfm (41144556+filesfm@users.noreply.github.com)
- John Hiesey (john@hiesey.com)
- KayleePop (34007889+KayleePop@users.noreply.github.com)
@@ -140,5 +141,17 @@
- Chris McCormick (chris@mccormick.cx)
- Jimmy Wärting (jimmy@warting.se)
- Jorge Cuadra (jorgecuadrafueyo@gmail.com)
+- Chocobozzz (florian.chocobo@gmail.com)
+- Chocobozzz (me@florianbigard.com)
+- Gabriel (gabrieel@email.com)
+- Shachar Itzhaky (corwin.amber@gmail.com)
+- Arnaldas Augutis (info@untitled.lt)
+- Diego Rodriguez (diegorbaquero@gmail.com)
+- Francois Carpentier (Francewhoa@users.noreply.github.com)
+- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com)
+- Dan Dumont (ddumont@gmail.com)
+- Eric Guan (guanzo91@gmail.com)
+- Gabriel Juchault (gabriel.juchault@gmail.com)
+- Feross (feross@feross.org)
#### Generated by scripts/update-authors.sh.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 7957636..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,75 +0,0 @@
-# Contributing Guidelines
-
-Contributions welcome!
-
-**Before spending lots of time on something, ask for feedback on your idea first!**
-
-Please search issues and pull requests before adding something new to avoid duplicating
-efforts and conversations.
-
-This project welcomes non-code contributions, too! The following types of contributions
-are welcome:
-
-- **Ideas**: participate in an issue thread or start your own to have your voice heard.
-- **Writing**: contribute your expertise in an area by helping expand the included docs.
-- **Copy editing**: fix typos, clarify language, and improve the quality of the docs.
-- **Formatting**: help keep docs easy to read with consistent formatting.
-
-## Code Style
-
-[![standard][standard-image]][standard-url]
-
-This repository uses [`standard`][standard-url] to maintain code style and consistency,
-and to avoid style arguments. `npm test` runs `standard` automatically, so you don't have
-to!
-
-[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg
-[standard-url]: https://standardjs.com
-
-## Project Governance
-
-Individuals making significant and valuable contributions are given commit-access to the
-project to contribute as they see fit. This project is more like an open wiki than a
-standard guarded open source project.
-
-### Rules
-
-There are a few basic ground-rules for contributors:
-
-1. **No `--force` pushes** or modifying the Git history in any way.
-2. **Non-master branches** should be used for ongoing work.
-3. **Significant modifications** like API changes should be subject to a **pull request**
- to solicit feedback from other contributors.
-4. **Pull requests** are *encouraged* for all contributions to solicit feedback, but left to
- the discretion of the contributor.
-
-### Releases
-
-Declaring formal releases remains the prerogative of the project maintainer.
-
-### Changes to this arrangement
-
-This is an experiment and feedback is welcome! This document may also be subject to pull-
-requests or changes by contributors where you believe you have something valuable to add
-or change.
-
-## Developer's Certificate of Origin 1.1
-
-By making a contribution to this project, I certify that:
-
-- (a) The contribution was created in whole or in part by me and I have the right to
- submit it under the open source license indicated in the file; or
-
-- (b) The contribution is based upon previous work that, to the best of my knowledge, is
- covered under an appropriate open source license and I have the right under that license
- to submit that work with modifications, whether created in whole or in part by me, under
- the same open source license (unless I am permitted to submit under a different
- license), as indicated in the file; or
-
-- (c) The contribution was provided directly to me by some other person who certified
- (a), (b) or (c) and I have not modified it.
-
-- (d) I understand and agree that this project and the contribution are public and that a
- record of the contribution (including all personal information I submit with it,
- including my sign-off) is maintained indefinitely and may be redistributed consistent
- with this project or the open source license(s) involved.
diff --git a/README.md b/README.md
index c624edf..0bd85e3 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
<h4 align="center">The streaming torrent client. For node.js and the web.</h4>
<p align="center">
- <a href="https://gitter.im/webtorrent/webtorrent"><img src="https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg" alt="gitter"></a>
+ <a href="https://discord.gg/cnXkm4Z"><img src="https://img.shields.io/discord/612575111718895616" alt="discord"></a>
<a href="https://travis-ci.org/webtorrent/webtorrent"><img src="https://img.shields.io/travis/webtorrent/webtorrent/master.svg" alt="travis"></a>
<a href="https://ci.appveyor.com/project/webtorrent/webtorrent"><img src="https://ci.appveyor.com/api/projects/status/cgu85xlgl72uoswq/branch/master?svg=true" alt="appveyor"></a>
<a href="https://www.npmjs.com/package/webtorrent"><img src="https://img.shields.io/npm/v/webtorrent.svg" alt="npm version"></a>
@@ -54,8 +54,8 @@ they can connect to both normal *and* web peers. We hope other clients will foll
### Open Source Sponsors
-[<img src='https://webtorrent.io/img/supporters/popchest.png' width=300>](https://popchest.com) | [<img src='https://webtorrent.io/img/supporters/brave.png' width=300>](https://brave.com)
-|---|---|
+[<img src='https://webtorrent.io/img/supporters/brave.png' width=300>](https://brave.com)
+|---|
### Features
diff --git a/SECURITY.md b/SECURITY.md
deleted file mode 100644
index fd097c3..0000000
--- a/SECURITY.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Security Policies and Procedures
-
-This document outlines security procedures and general policies for the WebTorrent
-project.
-
- * [Reporting a Bug](#reporting-a-bug)
- * [Disclosure Policy](#disclosure-policy)
- * [Comments on this Policy](#comments-on-this-policy)
-
-## Reporting a Bug
-
-The WebTorrent team and community take all security bugs in WebTorrent seriously.
-Thank you for improving the security of WebTorrent. We appreciate your efforts and
-responsible disclosure and will make every effort to acknowledge your
-contributions.
-
-Report security bugs by emailing the lead maintainer at feross@feross.org.
-
-The lead maintainer will acknowledge your email within 48 hours, and will send a
-more detailed response within 48 hours indicating the next steps in handling
-your report. After the initial reply to your report, the security team will
-endeavor to keep you informed of the progress towards a fix and full
-announcement, and may ask for additional information or guidance.
-
-Report security bugs in third-party modules to the person or team maintaining
-the module.
-
-## Disclosure Policy
-
-When the security team receives a security bug report, they will assign it to a
-primary handler. This person will coordinate the fix and release process,
-involving the following steps:
-
- * Confirm the problem and determine the affected versions.
- * Audit code to find any potential similar problems.
- * Prepare fixes for all releases still under maintenance. These fixes will be
- released as fast as possible to npm.
-
-## Comments on this Policy
-
-If you have suggestions on how this process could be improved please submit a
-pull request.
diff --git a/docs/api.md b/docs/api.md
index 52d1125..843e5af 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -201,6 +201,10 @@ Aggregate "seed ratio" for all torrents (uploaded / downloaded).
# Torrent API
+## `torrent.name`
+
+Name of the torrent (string).
+
## `torrent.infoHash`
Info hash of the torrent (string).
@@ -217,11 +221,28 @@ Magnet URI of the torrent (string).
`.torrent` file of the torrent (Blob URL).
+## `torrent.announce[...]`
+
+Array of all tracker servers. Each announce is an URL (string).
+
## `torrent.files[...]`
Array of all files in the torrent. See documentation for `File` below to learn what
methods/properties files have.
+## `torrent.pieces[...]`
+
+Array of all pieces in the torrent. See documentation for `Piece` below to learn what
+properties pieces have. Some pieces can be null.
+
+## `torrent.pieceLength`
+
+Length in bytes of every piece but the last one.
+
+## `torrent.lastPieceLength`
+
+Length in bytes of the last piece (<= of `torrent.pieceLength`).
+
## `torrent.timeRemaining`
Time remaining for download to complete (in milliseconds).
@@ -258,10 +279,45 @@ Torrent "seed ratio" (uploaded / downloaded).
Number of peers in the torrent swarm.
+## `torrent.maxWebConns`
+
+Max number of simultaneous connections per web seed, as passed in the options.
+
## `torrent.path`
Torrent download location.
+## `torrent.ready`
+
+True when the torrent is ready to be used (i.e. metadata is available and store is
+ready).
+
+## `torrent.paused`
+
+True when the torrent has stopped connecting to new peers. Note that this does
+not pause new incoming connections, nor does it pause the streams of existing
+connections or their wires.
+
+## `torrent.done`
+
+True when all the torrent files have been downloaded.
+
+## `torrent.length`
+
+Sum of the files length (in bytes).
+
+## `torrent.created`
+
+Date of creation of the torrent (as a [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object).
+
+## `torrent.createdBy`
+
+Author of the torrent (string).
+
+## `torrent.comment`
+
+A comment optionnaly set by the author (string).
+
## `torrent.destroy([callback])`
Alias for `client.remove(torrent)`. If `callback` is provided, it will be called when
@@ -366,6 +422,14 @@ connections, nor does it pause the streams of existing connections or their wire
Resume connecting to new peers.
+## `torrent.rescanFiles([function callback (err) {}])`
+
+Verify the hashes of all pieces in the store and update the bitfield for any new valid
+pieces. Useful if data has been added to the store outside WebTorrent, e.g. if another
+process puts a valid file in the right place. Once the scan is complete,
+`callback(null)` will be called (if provided), unless the torrent was destroyed during
+the scan, in which case `callback` will be called with an error.
+
## `torrent.on('infoHash', function () {})`
Emitted when the info hash of the torrent has been determined.
@@ -625,3 +689,13 @@ file.getBlobURL(function (err, url) {
document.body.appendChild(a)
})
```
+
+# Piece API
+
+## `piece.length`
+
+Piece length (in bytes). *Example: 12345*
+
+## `piece.missing`
+
+Piece missing length (in bytes). *Example: 100*
diff --git a/docs/faq.md b/docs/faq.md
index 3d9be9a..e32c1a1 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -111,6 +111,7 @@ WebTorrent is still pretty new, but it's already being used in cool ways:
- **[Bugout][Bugout]** - build and run back-end web services in a browser tab.
- **[P2P Media Loader][p2p-media-loader]** - engine for Hls.js and Shaka Player that enables P2P sharing of live and VOD streams over HLS or DASH protocols.
- **[Cheff][Cheff]** - Share food recipes between your devices. [source code](https://github.com/vasco3/cheff)
+- **[Hubzilla](https://hubzilla.org)** - WebTorrent player integration into posts ([source code](https://github.com/demitas-ace/wtplayer/tree/master/wtplayer))
- ***Your app here – [Send a pull request][pr] with your URL!***
#### WebTorrent Product Alternatives
@@ -230,7 +231,7 @@ clients like Transmission, and uTorrent to add support for WebTorrent. **Vuze**
## How do I get started?
To start using WebTorrent, simply include the
-[`webtorrent.min.js`](https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js)
+[`webtorrent.min.js`](https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js)
script on your page. If you use [browserify](http://browserify.org/), you can
`npm install webtorrent` and `require('webtorrent')`.
diff --git a/docs/get-started.md b/docs/get-started.md
index 58529d6..362e8fe 100644
--- a/docs/get-started.md
+++ b/docs/get-started.md
@@ -6,7 +6,7 @@ to get started!
## Install
To start using WebTorrent, simply include the
-[`webtorrent.min.js`](https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js)
+[`webtorrent.min.js`](https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js)
script on your page.
```html
@@ -129,7 +129,7 @@ downloaded.
<div class="log"></div>
<!-- Include the latest version of WebTorrent -->
- <script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js"></script>
<script>
var client = new WebTorrent()
@@ -282,7 +282,7 @@ or [Instant.io](https://instant.io) to seed torrents to the WebTorrent network.
</div>
</div>
<!-- Include the latest version of WebTorrent -->
- <script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js"></script>
<!-- Moment is used to show a human-readable remaining time -->
<script src="http://momentjs.com/downloads/moment.min.js"></script>
diff --git a/index.js b/index.js
index 3b5e6f7..135fb93 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,5 @@
/* global FileList */
-const { Buffer } = require('safe-buffer')
const { EventEmitter } = require('events')
const concat = require('simple-concat')
const createTorrent = require('create-torrent')
@@ -153,6 +152,7 @@ class WebTorrent extends EventEmitter {
}
get downloadSpeed () { return this._downloadSpeed() }
+
get uploadSpeed () { return this._uploadSpeed() }
get progress () {
@@ -297,7 +297,7 @@ class WebTorrent extends EventEmitter {
let streams
if (isFileList(input)) input = Array.from(input)
- else if (!Array.isArray(input)) input = [ input ]
+ else if (!Array.isArray(input)) input = [input]
parallel(input.map(item => cb => {
if (isReadable(item)) concat(item, cb)
diff --git a/lib/file-stream.js b/lib/file-stream.js
index 72622b2..f6a8402 100644
--- a/lib/file-stream.js
+++ b/lib/file-stream.js
@@ -56,9 +56,10 @@ class FileStream extends stream.Readable {
this._torrent.store.get(p, (err, buffer) => {
this._notifying = false
if (this.destroyed) return
- if (err) return this._destroy(err)
debug('read %s (length %s) (err %s)', p, buffer.length, err && err.message)
+ if (err) return this._destroy(err)
+
if (this._offset) {
buffer = buffer.slice(this._offset)
this._offset = 0
diff --git a/lib/file.js b/lib/file.js
index 8bcfe22..381ae5c 100644
--- a/lib/file.js
+++ b/lib/file.js
@@ -104,12 +104,20 @@ class File extends EventEmitter {
getBlob (cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
- streamToBlob(this.createReadStream(), this._getMimeType(), cb)
+ streamToBlob(this.createReadStream(), this._getMimeType())
+ .then(
+ blob => cb(null, blob),
+ err => cb(err)
+ )
}
getBlobURL (cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
- streamToBlobURL(this.createReadStream(), this._getMimeType(), cb)
+ streamToBlobURL(this.createReadStream(), this._getMimeType())
+ .then(
+ blobUrl => cb(null, blobUrl),
+ err => cb(err)
+ )
}
appendTo (elem, opts, cb) {
diff --git a/lib/rarity-map.js b/lib/rarity-map.js
index 7630734..af712cc 100644
--- a/lib/rarity-map.js
+++ b/lib/rarity-map.js
@@ -45,7 +45,7 @@ class RarityMap {
if (availability === min) {
candidates.push(i)
} else if (availability < min) {
- candidates = [ i ]
+ candidates = [i]
min = availability
}
}
diff --git a/lib/server.js b/lib/server.js
index 60595a8..0bbdafb 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -1,9 +1,9 @@
const arrayRemove = require('unordered-array-remove')
+const escapeHtml = require('escape-html')
const http = require('http')
const mime = require('mime')
const pump = require('pump')
const rangeParser = require('range-parser')
-const url = require('url')
function Server (torrent, opts = {}) {
const server = http.createServer()
@@ -12,11 +12,17 @@ function Server (torrent, opts = {}) {
const sockets = []
const pendingReady = []
let closed = false
+ const _listen = server.listen
+ const _close = server.close
- server.on('connection', onConnection)
- server.on('request', onRequest)
+ server.listen = (...args) => {
+ closed = false
+ server.on('connection', onConnection)
+ server.on('request', onRequest)
+ _listen.apply(server, args)
+ return server
+ }
- const _close = server.close
server.close = cb => {
closed = true
server.removeListener('connection', onConnection)
@@ -25,7 +31,6 @@ function Server (torrent, opts = {}) {
const onReady = pendingReady.pop()
torrent.removeListener('ready', onReady)
}
- torrent = null
_close.call(server, cb)
}
@@ -38,6 +43,7 @@ function Server (torrent, opts = {}) {
if (!cb) cb = () => {}
if (closed) process.nextTick(cb)
else server.close(cb)
+ torrent = null
}
function isOriginAllowed (req) {
@@ -48,13 +54,6 @@ function Server (torrent, opts = {}) {
// deny them
if (req.headers.origin == null) return false
- // If a 'hostname' string is specified, deny requests with a 'Host'
- // header that does not match the origin of the torrent server to prevent
- // DNS rebinding attacks.
- if (opts.hostname && req.headers.host !== `${opts.hostname}:${server.address().port}`) {
- return false
- }
-
// The user allowed all origins
if (opts.origin === '*') return true
@@ -71,12 +70,15 @@ function Server (torrent, opts = {}) {
}
function onRequest (req, res) {
- const pathname = url.parse(req.url).pathname
-
- if (pathname === '/favicon.ico') {
- return serve404Page()
+ // If a 'hostname' string is specified, deny requests with a 'Host'
+ // header that does not match the origin of the torrent server to prevent
+ // DNS rebinding attacks.
+ if (opts.hostname && req.headers.host !== `${opts.hostname}:${server.address().port}`) {
+ return req.destroy()
}
+ const pathname = new URL(req.url, 'http://example.com').pathname
+
// Allow cross-origin requests (CORS)
if (isOriginAllowed(req)) {
res.setHeader('Access-Control-Allow-Origin', req.headers.origin)
@@ -85,6 +87,13 @@ function Server (torrent, opts = {}) {
// Prevent browser mime-type sniffing
res.setHeader('X-Content-Type-Options', 'nosniff')
+ // Defense-in-depth: Set a strict Content Security Policy to mitigate XSS
+ res.setHeader('Content-Security-Policy', "base-uri 'none'; default-src 'none'; frame-ancestors 'none'; form-action 'none';")
+
+ if (pathname === '/favicon.ico') {
+ return serve404Page()
+ }
+
// Allow CORS requests to specify arbitrary headers, e.g. 'Range',
// by responding to the OPTIONS preflight request with the specified
// origin and requested headers.
@@ -142,11 +151,26 @@ function Server (torrent, opts = {}) {
res.statusCode = 200
res.setHeader('Content-Type', 'text/html')
- const listHtml = torrent.files.map((file, i) => `<li><a download="${file.name}" href="/${i}/${file.name}">${file.path}</a> (${file.length} bytes)</li>`).join('<br>')
+ const listHtml = torrent.files
+ .map((file, i) => (
+ `<li>
+ <a
+ download="${escapeHtml(file.name)}"
+ href="${escapeHtml(i)}/${escapeHtml(file.name)}"
+ >
+ ${escapeHtml(file.path)}
+ </a>
+ (${escapeHtml(file.length)} bytes)
+ </li>`
+ ))
+ .join('<br>')
const html = getPageHTML(
- `${torrent.name} - WebTorrent`,
- `<h1>${torrent.name}</h1><ol>${listHtml}</ol>`
+ `${escapeHtml(torrent.name)} - WebTorrent`,
+ `
+ <h1>${escapeHtml(torrent.name)}</h1>
+ <ol>${listHtml}</ol>
+ `
)
res.end(html)
}
@@ -155,13 +179,16 @@ function Server (torrent, opts = {}) {
res.statusCode = 404
res.setHeader('Content-Type', 'text/html')
- const html = getPageHTML('404 - Not Found', '<h1>404 - Not Found</h1>')
+ const html = getPageHTML(
+ '404 - Not Found',
+ '<h1>404 - Not Found</h1>'
+ )
res.end(html)
}
function serveFile (file) {
res.statusCode = 200
- res.setHeader('Content-Type', mime.getType(file.name))
+ res.setHeader('Content-Type', mime.getType(file.name) || 'application/octet-stream')
// Support range-requests
res.setHeader('Accept-Ranges', 'bytes')
@@ -209,7 +236,10 @@ function Server (torrent, opts = {}) {
function serveMethodNotAllowed () {
res.statusCode = 405
res.setHeader('Content-Type', 'text/html')
- const html = getPageHTML('405 - Method Not Allowed', '<h1>405 - Method Not Allowed</h1>')
+ const html = getPageHTML(
+ '405 - Method Not Allowed',
+ '<h1>405 - Method Not Allowed</h1>'
+ )
res.end(html)
}
}
@@ -217,8 +247,20 @@ function Server (torrent, opts = {}) {
return server
}
+// NOTE: Arguments must already be HTML-escaped
function getPageHTML (title, pageHtml) {
- return `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>${title}</title></head><body>${pageHtml}</body></html>`
+ return `
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>${title}</title>
+ </head>
+ <body>
+ ${pageHtml}
+ </body>
+ </html>
+ `
}
// From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
diff --git a/lib/torrent.js b/lib/torrent.js
index f50c107..77cf898 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -1,4 +1,4 @@
-/* global URL, Blob */
+/* global Blob */
const addrToIPPort = require('addr-to-ip-port')
const BitField = require('bitfield')
@@ -46,7 +46,7 @@ const RECHOKE_OPTIMISTIC_DURATION = 2 // 30 seconds
// IndexedDB chunk stores used in the browser benefit from maximum concurrency
const FILESYSTEM_CONCURRENCY = process.browser ? Infinity : 2
-const RECONNECT_WAIT = [ 1000, 5000, 15000 ]
+const RECONNECT_WAIT = [1000, 5000, 15000]
const VERSION = require('../package.json').version
const USER_AGENT = `WebTorrent/${VERSION} (https://webtorrent.io)`
@@ -169,7 +169,7 @@ class Torrent extends EventEmitter {
if (typeof window === 'undefined') throw new Error('browser-only property')
if (!this.torrentFile) return null
return URL.createObjectURL(
- new Blob([ this.torrentFile ], { type: 'application/x-bittorrent' })
+ new Blob([this.torrentFile], { type: 'application/x-bittorrent' })
)
}
@@ -277,6 +277,19 @@ class Torrent extends EventEmitter {
}
_onListening () {
+ if (this.destroyed) return
+
+ if (this.info) {
+ // if full metadata was included in initial torrent id, use it immediately. Otherwise,
+ // wait for torrent-discovery to find peers and ut_metadata to get the metadata.
+ this._onMetadata(this)
+ } else {
+ if (this.xs) this._getMetadataFromServer()
+ this._startDiscovery()
+ }
+ }
+
+ _startDiscovery () {
if (this.discovery || this.destroyed) return
let trackerOpts = this.client.tracker
@@ -334,21 +347,13 @@ class Torrent extends EventEmitter {
this.discovery.on('warning', (err) => {
this.emit('warning', err)
})
-
- if (this.info) {
- // if full metadata was included in initial torrent id, use it immediately. Otherwise,
- // wait for torrent-discovery to find peers and ut_metadata to get the metadata.
- this._onMetadata(this)
- } else if (this.xs) {
- this._getMetadataFromServer()
- }
}
_getMetadataFromServer () {
// to allow function hoisting
const self = this
- const urls = Array.isArray(this.xs) ? this.xs : [ this.xs ]
+ const urls = Array.isArray(this.xs) ? this.xs : [this.xs]
const tasks = urls.map(url => cb => {
getMetadataFromURL(url, cb)
@@ -500,11 +505,23 @@ class Torrent extends EventEmitter {
this._onWireWithMetadata(wire)
})
+ // Emit 'metadata' before 'ready' and 'done'
+ this.emit('metadata')
+
+ // User might destroy torrent in response to 'metadata' event
+ if (this.destroyed) return
+
if (this.skipVerify) {
// Skip verifying exisitng data and just assume it's correct
this._markAllVerified()
this._onStore()
} else {
+ const onPiecesVerified = (err) => {
+ if (err) return this._destroy(err)
+ this._debug('done verifying')
+ this._onStore()
+ }
+
this._debug('verifying existing torrent data')
if (this._fileModtimes && this._store === FSChunkStore) {
// don't verify if the files haven't been modified since we last checked
@@ -517,15 +534,13 @@ class Torrent extends EventEmitter {
this._markAllVerified()
this._onStore()
} else {
- this._verifyPieces()
+ this._verifyPieces(onPiecesVerified)
}
})
} else {
- this._verifyPieces()
+ this._verifyPieces(onPiecesVerified)
}
}
-
- this.emit('metadata')
}
/*
@@ -547,8 +562,8 @@ class Torrent extends EventEmitter {
})
}
- _verifyPieces () {
- parallelLimit(this.pieces.map((_, index) => cb => {
+ _verifyPieces (cb) {
+ parallelLimit(this.pieces.map((piece, index) => cb => {
if (this.destroyed) return cb(new Error('torrent is destroyed'))
this.store.get(index, (err, buf) => {
@@ -559,7 +574,7 @@ class Torrent extends EventEmitter {
if (this.destroyed) return cb(new Error('torrent is destroyed'))
if (hash === this._hashes[index]) {
- if (!this.pieces[index]) return
+ if (!this.pieces[index]) return cb(null)
this._debug('piece verified %s', index)
this._markVerified(index)
} else {
@@ -568,10 +583,21 @@ class Torrent extends EventEmitter {
cb(null)
})
})
- }), FILESYSTEM_CONCURRENCY, err => {
- if (err) return this._destroy(err)
- this._debug('done verifying')
- this._onStore()
+ }), FILESYSTEM_CONCURRENCY, cb)
+ }
+
+ rescanFiles (cb) {
+ if (this.destroyed) throw new Error('torrent is destroyed')
+ if (!cb) cb = noop
+
+ this._verifyPieces((err) => {
+ if (err) {
+ this._destroy(err)
+ return cb(err)
+ }
+
+ this._checkDone()
+ cb(null)
})
}
@@ -594,6 +620,9 @@ class Torrent extends EventEmitter {
if (this.destroyed) return
this._debug('on store')
+ // Start discovery before emitting 'ready'
+ this._startDiscovery()
+
this.ready = true
this.emit('ready')
@@ -820,7 +849,7 @@ class Torrent extends EventEmitter {
if (this.destroyed) throw new Error('torrent is destroyed')
if (start < 0 || end < start || this.pieces.length <= end) {
- throw new Error('invalid selection ', start, ':', end)
+ throw new Error(`invalid selection ${start} : ${end}`)
}
priority = Number(priority) || 0
@@ -1564,7 +1593,7 @@ class Torrent extends EventEmitter {
if (this.destroyed) throw new Error('torrent is destroyed')
if (!this.ready) return this.once('ready', () => { this.load(streams, cb) })
- if (!Array.isArray(streams)) streams = [ streams ]
+ if (!Array.isArray(streams)) streams = [streams]
if (!cb) cb = noop
const readable = new MultiStream(streams)
diff --git a/lib/webconn.js b/lib/webconn.js
index 9c2b461..e99c04c 100644
--- a/lib/webconn.js
+++ b/lib/webconn.js
@@ -1,5 +1,4 @@
const BitField = require('bitfield')
-const Buffer = require('safe-buffer').Buffer
const debug = require('debug')('webtorrent:webconn')
const get = require('simple-get')
const sha1 = require('simple-sha1')
diff --git a/package.json b/package.json
index 1f452ed..eaea8b0 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "webtorrent",
"description": "Streaming torrent client",
- "version": "0.103.1",
+ "version": "0.107.10",
"author": {
"name": "WebTorrent, LLC",
"email": "feross@webtorrent.io",
@@ -25,24 +25,34 @@
"bugs": {
"url": "https://github.com/webtorrent/webtorrent/issues"
},
+ "chromeapp": {
+ "fs-chunk-store": "memory-chunk-store",
+ "http": "http-node",
+ "load-ip-set": false,
+ "net": "chrome-net",
+ "os": false
+ },
"dependencies": {
"addr-to-ip-port": "^1.4.2",
- "bitfield": "^2.0.0",
+ "bitfield": "^3.0.0",
"bittorrent-dht": "^9.0.0",
"bittorrent-protocol": "^3.0.0",
- "chunk-store-stream": "^3.0.1",
- "create-torrent": "^3.33.0",
+ "chrome-net": "^3.3.2",
+ "chunk-store-stream": "^4.0.0",
+ "create-torrent": "^4.0.0",
"debug": "^4.1.0",
"end-of-stream": "^1.1.0",
- "fs-chunk-store": "^1.6.2",
+ "escape-html": "^1.0.3",
+ "fs-chunk-store": "^2.0.0",
+ "http-node": "github:feross/http-node#cddd2872f0020ecf5016f326cf5e58c965eef52a",
"immediate-chunk-store": "^2.0.0",
"load-ip-set": "^2.1.0",
"memory-chunk-store": "^1.2.0",
"mime": "^2.4.0",
- "multistream": "^2.0.5",
+ "multistream": "^4.0.0",
"package-json-versionify": "^1.0.2",
"parse-numeric-range": "^0.0.2",
- "parse-torrent": "^6.1.2",
+ "parse-torrent": "^7.0.0",
"pump": "^3.0.0",
"random-iterate": "^1.0.1",
"randombytes": "^2.0.3",
@@ -51,40 +61,38 @@
"render-media": "^3.0.0",
"run-parallel": "^1.1.6",
"run-parallel-limit": "^1.0.3",
- "safe-buffer": "^5.0.1",
"simple-concat": "^1.0.0",
"simple-get": "^3.0.1",
"simple-peer": "^9.0.0",
- "simple-sha1": "^2.0.8",
+ "simple-sha1": "^3.0.0",
"speedometer": "^1.0.0",
- "stream-to-blob": "^1.0.0",
- "stream-to-blob-url": "^2.1.0",
+ "stream-to-blob": "^2.0.0",
+ "stream-to-blob-url": "^3.0.0",
"stream-with-known-length-to-buffer": "^1.0.0",
"torrent-discovery": "^9.1.1",
"torrent-piece": "^2.0.0",
"uniq": "^1.0.1",
"unordered-array-remove": "^1.0.2",
"ut_metadata": "^3.3.0",
- "ut_pex": "^1.1.1"
+ "ut_pex": "^2.0.0"
},
"devDependencies": {
- "airtap": "2.0.2",
- "babel-minify": "^0.5.0",
- "bittorrent-tracker": "^9.4.0",
- "brfs": "^2.0.0",
- "browserify": "^16.2.3",
- "cross-spawn": "^6.0.3",
- "electron": "^4.0.0",
+ "airtap": "^2.0.3",
+ "bittorrent-tracker": "^9.14.0",
+ "browserify": "^16.4.0",
+ "disc": "^1.3.3",
+ "electron": "^6.0.1",
"finalhandler": "^1.0.0",
"network-address": "^1.1.0",
"run-series": "^1.1.4",
"serve-static": "^1.11.1",
"standard": "*",
"tape": "^4.6.0",
+ "tinyify": "^2.5.1",
"webtorrent-fixtures": "^1.5.0"
},
"engines": {
- "node": ">=4"
+ "node": ">=10"
},
"homepage": "https://webtorrent.io",
"keywords": [
@@ -110,9 +118,11 @@
"url": "git://github.com/webtorrent/webtorrent.git"
},
"scripts": {
- "build": "browserify -s WebTorrent -e ./ | minify > webtorrent.min.js",
- "build-debug": "browserify -s WebTorrent -e ./ > webtorrent.debug.js",
- "size": "npm run build && cat webtorrent.min.js | gzip | wc -c",
+ "build": "browserify --standalone WebTorrent --plugin tinyify . > webtorrent.min.js",
+ "build-debug": "browserify --standalone WebTorrent . > webtorrent.debug.js",
+ "size": "npm run size-js && npm run size-disc",
+ "size-disc": "browserify --plugin tinyify --full-paths . | discify --open",
+ "size-js": "npm run build && cat webtorrent.min.js | gzip | wc -c",
"test": "standard && npm run test-node && npm run test-browser",
"test-browser": "airtap -- test/*.js test/browser/*.js",
"test-browser-local": "airtap --local -- test/*.js test/browser/*.js",
diff --git a/test/browser/basic.js b/test/browser/basic.js
index 7bc488e..a70f530 100644
--- a/test/browser/basic.js
+++ b/test/browser/basic.js
@@ -1,4 +1,3 @@
-var Buffer = require('safe-buffer').Buffer
var test = require('tape')
var WebTorrent = require('../../')
diff --git a/test/client-add-duplicate-trackers.js b/test/client-add-duplicate-trackers.js
index 161e920..3c9c366 100644
--- a/test/client-add-duplicate-trackers.js
+++ b/test/client-add-duplicate-trackers.js
@@ -11,7 +11,7 @@ test('client.add: duplicate trackers', function (t) {
client.on('warning', function (err) { t.fail(err) })
var torrent = client.add(fixtures.leaves.torrent, {
- announce: [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ announce: ['wss://example.com', 'wss://example.com', 'wss://example.com']
})
torrent.on('ready', function () {
@@ -26,7 +26,7 @@ test('client.add: duplicate trackers, with multiple torrents', function (t) {
// Re-use this object, in case webtorrent is changing it
var opts = {
- announce: [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ announce: ['wss://example.com', 'wss://example.com', 'wss://example.com']
}
var client = new WebTorrent({ dht: false, tracker: false })
@@ -56,15 +56,15 @@ test('client.add: duplicate trackers (including in .torrent file), multiple torr
// Re-use this object, in case webtorrent is changing it
var opts = {
- announce: [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ announce: ['wss://example.com', 'wss://example.com', 'wss://example.com']
}
// Include the duplicate trackers in the .torrent files
var parsedTorrentLeaves = Object.assign({}, fixtures.leaves.parsedTorrent)
- parsedTorrentLeaves.announce = [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ parsedTorrentLeaves.announce = ['wss://example.com', 'wss://example.com', 'wss://example.com']
var parsedTorrentAlice = Object.assign({}, fixtures.alice.parsedTorrent)
- parsedTorrentAlice.announce = [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ parsedTorrentAlice.announce = ['wss://example.com', 'wss://example.com', 'wss://example.com']
var client = new WebTorrent({ dht: false, tracker: false })
diff --git a/test/client-add.js b/test/client-add.js
index 009cdc6..07de490 100644
--- a/test/client-add.js
+++ b/test/client-add.js
@@ -1,4 +1,3 @@
-var Buffer = require('safe-buffer').Buffer
var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../')
@@ -135,7 +134,7 @@ test('client.add: parsed torrent, with string type announce property', function
t.equal(torrent.magnetURI, expectedMagnetURI)
// `torrent.announce` must always be an array
- t.deepEqual(torrent.announce, [ 'http://tracker.local:80' ])
+ t.deepEqual(torrent.announce, ['http://tracker.local:80'])
client.remove(fixtures.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -153,7 +152,7 @@ test('client.add: parsed torrent, with array type announce property', function (
client.on('warning', function (err) { t.fail(err) })
var parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)
- parsedTorrent.announce = [ 'http://tracker.local:80', 'http://tracker.local:81' ]
+ parsedTorrent.announce = ['http://tracker.local:80', 'http://tracker.local:81']
var torrent = client.add(parsedTorrent)
t.equal(client.torrents.length, 1)
@@ -166,7 +165,7 @@ test('client.add: parsed torrent, with array type announce property', function (
'&tr=' + encodeURIComponent('http://tracker.local:81')
t.equal(torrent.magnetURI, expectedMagnetURI)
- t.deepEqual(torrent.announce, [ 'http://tracker.local:80', 'http://tracker.local:81' ])
+ t.deepEqual(torrent.announce, ['http://tracker.local:80', 'http://tracker.local:81'])
client.remove(fixtures.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
diff --git a/test/client-destroy.js b/test/client-destroy.js
index 956c966..43992a1 100644
--- a/test/client-destroy.js
+++ b/test/client-destroy.js
@@ -1,4 +1,3 @@
-var Buffer = require('safe-buffer').Buffer
var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../')
diff --git a/test/client-seed.js b/test/client-seed.js
index 48d958d..a50d3cf 100644
--- a/test/client-seed.js
+++ b/test/client-seed.js
@@ -1,6 +1,5 @@
/* global Blob */
-var Buffer = require('safe-buffer').Buffer
var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../')
@@ -61,7 +60,7 @@ test('client.seed: torrent file (Blob)', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(new Blob([ fixtures.leaves.content ]), {
+ client.seed(new Blob([fixtures.leaves.content]), {
name: 'Leaves of Grass by Walt Whitman.epub',
announce: []
}, function (torrent) {
diff --git a/test/common.js b/test/common.js
new file mode 100644
index 0000000..6f2ce1e
--- /dev/null
+++ b/test/common.js
@@ -0,0 +1,13 @@
+const os = require('os')
+const fs = require('fs')
+const path = require('path')
+
+exports.getDownloadPath = function (infix, infoHash) {
+ let tmpPath
+ try {
+ tmpPath = path.join(fs.statSync('/tmp') && '/tmp')
+ } catch (err) {
+ tmpPath = path.join(typeof os.tmpdir === 'function' ? os.tmpdir() : '/')
+ }
+ return path.join(tmpPath, 'webtorrent', 'test', infix, infoHash)
+}
diff --git a/test/node/blocklist-dht.js b/test/node/blocklist-dht.js
index 3e23424..fa3915a 100644
--- a/test/node/blocklist-dht.js
+++ b/test/node/blocklist-dht.js
@@ -3,6 +3,7 @@ var fixtures = require('webtorrent-fixtures')
var series = require('run-series')
var test = require('tape')
var WebTorrent = require('../../')
+var common = require('../common')
test('blocklist blocks peers discovered via DHT', function (t) {
t.plan(8)
@@ -25,7 +26,9 @@ test('blocklist blocks peers discovered via DHT', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })
- var torrent1 = client1.add(fixtures.leaves.parsedTorrent)
+ var torrent1 = client1.add(fixtures.leaves.parsedTorrent, {
+ path: common.getDownloadPath('client_1', fixtures.leaves.parsedTorrent.infoHash)
+ })
torrent1.on('peer', function () {
t.fail('client1 should not find any peers')
@@ -58,12 +61,14 @@ test('blocklist blocks peers discovered via DHT', function (t) {
client2 = new WebTorrent({
tracker: false,
dht: { bootstrap: '127.0.0.1:' + dhtServer.address().port },
- blocklist: [ '127.0.0.1' ]
+ blocklist: ['127.0.0.1']
})
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })
- var torrent2 = client2.add(fixtures.leaves.parsedTorrent)
+ var torrent2 = client2.add(fixtures.leaves.parsedTorrent, {
+ path: common.getDownloadPath('client_2', fixtures.leaves.parsedTorrent.infoHash)
+ })
torrent2.on('blockedPeer', function (addr) {
t.pass('client2 blocked connection to client1: ' + addr)
diff --git a/test/node/blocklist-tracker.js b/test/node/blocklist-tracker.js
index 7c92e9a..e877d24 100644
--- a/test/node/blocklist-tracker.js
+++ b/test/node/blocklist-tracker.js
@@ -3,6 +3,7 @@ var series = require('run-series')
var test = require('tape')
var TrackerServer = require('bittorrent-tracker/server')
var WebTorrent = require('../../')
+var common = require('../common')
test('blocklist blocks peers discovered via tracker', function (t) {
t.plan(9)
@@ -38,7 +39,9 @@ test('blocklist blocks peers discovered via tracker', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })
- var torrent1 = client1.add(parsedTorrent)
+ var torrent1 = client1.add(parsedTorrent, {
+ path: common.getDownloadPath('client_1', parsedTorrent.infoHash)
+ })
torrent1.on('invalidPeer', function () {
t.pass('client1 found itself')
@@ -53,12 +56,14 @@ test('blocklist blocks peers discovered via tracker', function (t) {
function (cb) {
client2 = new WebTorrent({
dht: false,
- blocklist: [ '127.0.0.1' ]
+ blocklist: ['127.0.0.1']
})
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })
- var torrent2 = client2.add(parsedTorrent)
+ var torrent2 = client2.add(parsedTorrent, {
+ path: common.getDownloadPath('client_2', parsedTorrent.infoHash)
+ })
torrent2.once('blockedPeer', function () {
t.pass('client2 blocked first peer')
diff --git a/test/node/blocklist.js b/test/node/blocklist.js
index f39b232..87c131f 100644
--- a/test/node/blocklist.js
+++ b/test/node/blocklist.js
@@ -25,7 +25,7 @@ test('blocklist (single IP)', function (t) {
var client = new WebTorrent({
dht: false,
tracker: false,
- blocklist: [ '1.2.3.4' ]
+ blocklist: ['1.2.3.4']
})
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
@@ -51,7 +51,7 @@ test('blocklist (array of IPs)', function (t) {
var client = new WebTorrent({
dht: false,
tracker: false,
- blocklist: [ '1.2.3.4', '5.6.7.8' ]
+ blocklist: ['1.2.3.4', '5.6.7.8']
})
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
diff --git a/test/node/download-dht-magnet.js b/test/node/download-dht-magnet.js
index aeb580a..3372317 100644
--- a/test/node/download-dht-magnet.js
+++ b/test/node/download-dht-magnet.js
@@ -47,7 +47,7 @@ test('Download using DHT (via magnet uri)', function (t) {
// torrent metadata has been fetched -- sanity check it
t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')
- var names = [ 'Leaves of Grass by Walt Whitman.epub' ]
+ var names = ['Leaves of Grass by Walt Whitman.epub']
t.deepEqual(torrent.files.map(function (file) { return file.name }), names)
})
diff --git a/test/node/download-dht-torrent.js b/test/node/download-dht-torrent.js
index b9fc932..9d5a93b 100644
--- a/test/node/download-dht-torrent.js
+++ b/test/node/download-dht-torrent.js
@@ -40,7 +40,7 @@ test('Download using DHT (via .torrent file)', function (t) {
// torrent metadata has been fetched -- sanity check it
t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')
- var names = [ 'Leaves of Grass by Walt Whitman.epub' ]
+ var names = ['Leaves of Grass by Walt Whitman.epub']
t.deepEqual(torrent.files.map(function (file) { return file.name }), names)
})
diff --git a/test/node/download-tracker-magnet.js b/test/node/download-tracker-magnet.js
index de56007..e597191 100644
--- a/test/node/download-tracker-magnet.js
+++ b/test/node/download-tracker-magnet.js
@@ -43,7 +43,7 @@ function magnetDownloadTest (t, serverType) {
? 'http://127.0.0.1:' + port + '/announce'
: 'udp://127.0.0.1:' + port
- parsedTorrent.announce = [ announceUrl ]
+ parsedTorrent.announce = [announceUrl]
magnetURI = 'magnet:?xt=urn:btih:' + parsedTorrent.infoHash + '&tr=' + encodeURIComponent(announceUrl)
client1 = new WebTorrent({ dht: false })
diff --git a/test/node/download-tracker-torrent.js b/test/node/download-tracker-torrent.js
index f1a04a9..17f9a0b 100644
--- a/test/node/download-tracker-torrent.js
+++ b/test/node/download-tracker-torrent.js
@@ -50,7 +50,7 @@ function torrentDownloadTest (t, serverType) {
: 'udp://127.0.0.1:' + port
// Overwrite announce with our local tracker
- parsedTorrent.announce = [ announceUrl ]
+ parsedTorrent.announce = [announceUrl]
client1.on('torrent', function (torrent) {
// torrent metadata has been fetched -- sanity check it
diff --git a/test/node/seed-stream.js b/test/node/seed-stream.js
index eafc9e7..e56964e 100644
--- a/test/node/seed-stream.js
+++ b/test/node/seed-stream.js
@@ -36,7 +36,7 @@ test('client.seed: stream', function (t) {
var seederOpts = {
name: 'hello.txt',
pieceLength: 5,
- announce: [ announceUrl ]
+ announce: [announceUrl]
}
seeder.seed([stream], seederOpts, function (torrent) {
magnetURI = torrent.magnetURI
diff --git a/test/node/swarm-basic.js b/test/node/swarm-basic.js
index 3061f8d..d7d4f18 100644
--- a/test/node/swarm-basic.js
+++ b/test/node/swarm-basic.js
@@ -1,4 +1,3 @@
-// var Buffer = require('safe-buffer').Buffer
// var randombytes = require('randombytes')
// var Swarm = require('../../lib/swarm')
// var test = require('tape')
diff --git a/test/node/swarm-reconnect.js b/test/node/swarm-reconnect.js
index cd18d1d..591798f 100644
--- a/test/node/swarm-reconnect.js
+++ b/test/node/swarm-reconnect.js
@@ -1,4 +1,3 @@
-// var Buffer = require('safe-buffer').Buffer
// var randombytes = require('randombytes')
// var Swarm = require('../../lib/swarm')
// var test = require('tape')
diff --git a/test/node/swarm-timeout.js b/test/node/swarm-timeout.js
index ceac357..61eeeb0 100644
--- a/test/node/swarm-timeout.js
+++ b/test/node/swarm-timeout.js
@@ -1,4 +1,3 @@
-// var Buffer = require('safe-buffer').Buffer
// var randombytes = require('randombytes')
// var Swarm = require('../../lib/swarm')
// var test = require('tape')
diff --git a/test/swarm.js b/test/swarm.js
index 1869b87..05b89a1 100644
--- a/test/swarm.js
+++ b/test/swarm.js
@@ -1,4 +1,3 @@
-// var Buffer = require('safe-buffer').Buffer
// var randombytes = require('randombytes')
// var Swarm = require('../lib/swarm')
// var test = require('tape')
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 6cf30dd..bc72c45 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1,11 +1 @@
-(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?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.WebTorrent=e()}})(function(){var t=Math.pow,n=Math.floor,r=Math.abs,o=String.fromCharCode,a=Math.ceil,s=Math.max,d=Math.min,l;return function(){function s(d,e,n){function t(o,i){if(!e[o]){if(!d[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var a=e[o]={exports:{}};d[o][0].call(a.exports,function(e){var r=d[o][1][e];return t(r||e)},a,a.exports,s,d,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o<n.length;o++)t(n[o]);return t}return s}()({1:[function(e,t){const n=e("debug")("webtorrent:file-stream"),r=e("readable-stream");class o extends r.Readable{constructor(e,t){super(t),this.destroyed=!1,this._torrent=e._torrent;const n=t&&t.start||0,r=t&&t.end&&t.end<e.length?t.end:e.length-1,o=e._torrent.pieceLength;this._startPiece=0|(n+e.offset)/o,this._endPiece=0|(r+e.offset)/o,this._piece=this._startPiece,this._offset=n+e.offset-this._startPiece*o,this._missing=r-n+1,this._reading=!1,this._notifying=!1,this._criticalLength=d(0|1048576/o,2)}_read(){this._reading||(this._reading=!0,this._notify())}_notify(){if(!this._reading||0===this._missing)return;if(!this._torrent.bitfield.get(this._piece))return this._torrent.critical(this._piece,this._piece+this._criticalLength);if(this._notifying)return;if(this._notifying=!0,this._torrent.destroyed)return this._destroy(new Error("Torrent removed"));const e=this._piece;this._torrent.store.get(e,(t,r)=>(this._notifying=!1,this.destroyed?void 0:t?this._destroy(t):void(n("read %s (length %s) (err %s)",e,r.length,t&&t.message),this._offset&&(r=r.slice(this._offset),this._offset=0),this._missing<r.length&&(r=r.slice(0,this._missing)),this._missing-=r.length,n("pushing buffer of length %s",r.length),this._reading=!1,this.push(r),0===this._missing&&this.push(null)))),this._piece+=1}destroy(e){this._destroy(null,e)}_destroy(e,t){this.destroyed||(this.destroyed=!0,!this._torrent.destroyed&&this._torrent.deselect(this._startPiece,this._endPiece,!0),e&&this.emit("error",e),this.emit("close"),t&&t())}}t.exports=o},{debug:69,"readable-stream":168}],2:[function(e,t){(function(n){const{EventEmitter:r}=e("events"),{PassThrough:o}=e("readable-stream"),i=e("end-of-stream"),a=e("path"),l=e("render-media"),c=e("stream-to-blob"),u=e("stream-to-blob-url"),p=e("stream-with-known-length-to-buffer"),f=e("./file-stream");class h extends r{constructor(e,t){super(),this._torrent=e,this._destroyed=!1,this.name=t.name,this.path=t.path,this.length=t.length,this.offset=t.offset,this.done=!1;const n=t.offset,r=n+t.length-1;this._startPiece=0|n/this._torrent.pieceLength,this._endPiece=0|r/this._torrent.pieceLength,0===this.length&&(this.done=!0,this.emit("done"))}get downloaded(){if(!this._torrent.bitfield)return 0;const{pieces:e,bitfield:t,pieceLength:n}=this._torrent,{_startPiece:r,_endPiece:o}=this,i=e[r];let a=t.get(r)?n-this.offset%n:s(i.length-i.missing-this.offset,0);for(let i=r+1;i<=o;++i)if(t.get(i))a+=n;else{const t=e[i];a+=t.length-t.missing}return d(a,this.length)}get progress(){return this.length?this.downloaded/this.length:0}select(e){0===this.length||this._torrent.select(this._startPiece,this._endPiece,e)}deselect(){0===this.length||this._torrent.deselect(this._startPiece,this._endPiece,!1)}createReadStream(e){if(0===this.length){const e=new o;return n.nextTick(()=>{e.end()}),e}const t=new f(this,e);return this._torrent.select(t._startPiece,t._endPiece,!0,()=>{t._notify()}),i(t,()=>{this._destroyed||!this._torrent.destroyed&&this._torrent.deselect(t._startPiece,t._endPiece,!0)}),t}getBuffer(e){p(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");c(this.createReadStream(),this._getMimeType(),e)}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");u(this.createReadStream(),this._getMimeType(),e)}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");l.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");l.render(this,e,t,n)}_getMimeType(){return l.mime[a.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}t.exports=h}).call(this,e("_process"))},{"./file-stream":1,_process:138,"end-of-stream":72,events:48,path:135,"readable-stream":168,"render-media":169,"stream-to-blob":222,"stream-to-blob-url":221,"stream-with-known-length-to-buffer":223}],3:[function(e,t,n){const r=e("unordered-array-remove"),o=e("debug")("webtorrent:peer"),i=e("bittorrent-protocol"),a=e("./webconn");n.createWebRTCPeer=(e,t)=>{const n=new s(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",()=>{n.onConnect()}),n.conn.once("error",e=>{n.destroy(e)}),n.startConnectTimeout()),n},n.createTCPIncomingPeer=e=>{const t=`${e.remoteAddress}:${e.remotePort}`,n=new s(t,"tcpIncoming");return n.conn=e,n.addr=t,n.onConnect(),n},n.createTCPOutgoingPeer=(e,t)=>{const n=new s(e,"tcpOutgoing");return n.addr=e,n.swarm=t,n},n.createWebSeedPeer=(e,t)=>{const n=new s(e,"webSeed");return n.swarm=t,n.conn=new a(e,t),n.onConnect(),n};class s{constructor(e,t){this.id=e,this.type=t,o("new %s Peer %s",t,e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}onConnect(){if(!this.destroyed){this.connected=!0,o("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",()=>{this.destroy()}),e.once("close",()=>{this.destroy()}),e.once("finish",()=>{this.destroy()}),e.once("error",e=>{this.destroy(e)});const t=this.wire=new i;t.type=this.type,t.once("end",()=>{this.destroy()}),t.once("close",()=>{this.destroy()}),t.once("finish",()=>{this.destroy()}),t.once("error",e=>{this.destroy(e)}),t.once("handshake",(e,t)=>{this.onHandshake(e,t)}),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));o("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n);this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout),this.connectTimeout=setTimeout(()=>{this.destroy(new Error("connect timeout"))},"webrtc"===this.type?25e3:5e3),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout(()=>{this.destroy(new Error("handshake timeout"))},25e3),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,o("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,i=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&i&&r(t.wires,t.wires.indexOf(i)),n&&(n.on("error",()=>{}),n.destroy()),i&&i.destroy(),t&&t.removePeer(this.id)}}},{"./webconn":6,"bittorrent-protocol":14,debug:69,"unordered-array-remove":237}],4:[function(e,t){t.exports=class{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=Array(this._numPieces),this._onWire=e=>{this.recalculate(),this._initWire(e)},this._onWireHave=e=>{this._pieces[e]+=1},this._onWireBitfield=()=>{this.recalculate()},this._torrent.wires.forEach(e=>{this._initWire(e)}),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let r=0;r<this._numPieces;++r){if(e&&!e(r))continue;const o=this._pieces[r];o===n?t.push(r):o<n&&(t=[r],n=o)}return t.length?t[0|Math.random()*t.length]:-1}destroy(){this._torrent.removeListener("wire",this._onWire),this._torrent.wires.forEach(e=>{this._cleanupWireEvents(e)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=()=>{this._cleanupWireEvents(e);for(let t=0;t<this._numPieces;++t)this._pieces[t]-=e.peerPieces.get(t)},e.on("have",this._onWireHave),e.on("bitfield",this._onWireBitfield),e.once("close",e._onClose)}recalculate(){this._pieces.fill(0);for(const e of this._torrent.wires)for(let t=0;t<this._numPieces;++t)this._pieces[t]+=e.peerPieces.get(t)}_cleanupWireEvents(e){e.removeListener("have",this._onWireHave),e.removeListener("bitfield",this._onWireBitfield),e._onClose&&e.removeListener("close",e._onClose),e._onClose=null}}},{}],5:[function(e,t){(function(n,r){function o(e,t){return 2+a(t*e.downloadSpeed()/I.BLOCK_LENGTH)}function l(e,t,n){return 1+a(t*e.downloadSpeed()/n)}function c(e){return 0|Math.random()*e}function u(){}const p=e("addr-to-ip-port"),f=e("bitfield"),h=e("chunk-store-stream/write"),m=e("debug")("webtorrent:torrent"),g=e("torrent-discovery"),_=e("events").EventEmitter,b=e("fs"),i=e("fs-chunk-store"),y=e("simple-get"),w=e("immediate-chunk-store"),k=e("multistream"),x=e("net"),C=e("os"),S=e("run-parallel"),v=e("run-parallel-limit"),E=e("parse-torrent"),L=e("path"),I=e("torrent-piece"),B=e("pump"),T=e("random-iterate"),R=e("simple-sha1"),A=e("speedometer"),U=e("uniq"),P=e("ut_metadata"),M=e("ut_pex"),O=e("parse-numeric-range"),j=e("./file"),N=e("./peer"),F=e("./rarity-map"),H=e("./server"),q=5e3,D=3*I.BLOCK_LENGTH,W=1,z=n.browser?1/0:2,V=[1e3,5e3,15e3],G=e("../package.json").version,K=`WebTorrent/${G} (https://webtorrent.io)`;let Y;try{Y=L.join(b.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){Y=L.join("function"==typeof C.tmpdir?C.tmpdir():"/","webtorrent")}class X extends _{constructor(e,t,n){super(),this._debugId="unknown infohash",this.client=t,this.announce=n.announce,this.urlList=n.urlList,this.path=n.path,this.skipVerify=!!n.skipVerify,this._store=n.store||i,this._getAnnounceOpts=n.getAnnounceOpts,this.strategy=n.strategy||"sequential",this.maxWebConns=n.maxWebConns||4,this._rechokeNumSlots=!1===n.uploads||0===n.uploads?0:+n.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=A(),this._uploadSpeed=A(),this._servers=[],this._xsRequests=[],this._fileModtimes=n.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}get timeRemaining(){return this.done?0:0===this.downloadSpeed?1/0:1e3*((this.length-this.downloaded)/this.downloadSpeed)}get downloaded(){if(!this.bitfield)return 0;let e=0;for(let t=0,n=this.pieces.length;t<n;++t)if(this.bitfield.get(t))e+=t==n-1?this.lastPieceLength:this.pieceLength;else{const n=this.pieces[t];e+=n.length-n.missing}return e}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){return this.length?this.downloaded/this.length:0}get ratio(){return this.uploaded/(this.received||1)}get numPeers(){return this.wires.length}get torrentFileBlobURL(){if("undefined"==typeof window)throw new Error("browser-only property");return this.torrentFile?URL.createObjectURL(new Blob([this.torrentFile],{type:"application/x-bittorrent"})):null}get _numQueued(){return this._queue.length+(this._peersLength-this._numConns)}get _numConns(){let e=0;for(const t in this._peers)this._peers[t].connected&&(e+=1);return e}get swarm(){return console.warn("WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead."),this}_onTorrentId(e){if(this.destroyed)return;let t;try{t=E(e)}catch(e){}t?(this.infoHash=t.infoHash,this._debugId=t.infoHash.toString("hex").substring(0,7),n.nextTick(()=>{this.destroyed||this._onParsedTorrent(t)})):E.remote(e,(e,t)=>this.destroyed?void 0:e?this._destroy(e):void this._onParsedTorrent(t))}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));(this.path||(this.path=L.join(Y,this.infoHash)),this._rechokeIntervalId=setInterval(()=>{this._rechoke()},1e4),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),!this.destroyed)&&(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",()=>{this._onListening()})))}}_processParsedTorrent(e){this._debugId=e.infoHash.toString("hex").substring(0,7),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&r.WEBTORRENT_ANNOUNCE&&!this.private&&(e.announce=e.announce.concat(r.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),U(e.announce),U(e.urlList),Object.assign(this,e),this.magnetURI=E.toMagnetURI(e),this.torrentFile=E.toTorrentFile(e)}_onListening(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{const e={uploaded:this.uploaded,downloaded:this.downloaded,left:s(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.discovery=new g({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:K}),this.discovery.on("error",e=>{this._destroy(e)}),this.discovery.on("peer",e=>{"string"==typeof e&&this.done||this.addPeer(e)}),this.discovery.on("trackerAnnounce",()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")}),this.discovery.on("dhtAnnounce",()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")}),this.discovery.on("warning",e=>{this.emit("warning",e)}),this.info?this._onMetadata(this):this.xs&&this._getMetadataFromServer()}_getMetadataFromServer(){function e(e,n){function r(r,o,i){if(t.destroyed)return n(null);if(t.metadata)return n(null);if(r)return t.emit("warning",new Error(`http error from xs param: ${e}`)),n(null);if(200!==o.statusCode)return t.emit("warning",new Error(`non-200 status code ${o.statusCode} from xs param: ${e}`)),n(null);let a;try{a=E(i)}catch(e){}return a?a.infoHash===t.infoHash?void(t._onMetadata(a),n(null)):(t.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${e}`)),n(null)):(t.emit("warning",new Error(`got invalid torrent file from xs param: ${e}`)),n(null))}if(0!==e.indexOf("http://")&&0!==e.indexOf("https://"))return t.emit("warning",new Error(`skipping non-http xs param: ${e}`)),n(null);let o;try{o=y.concat({url:e,method:"GET",headers:{"user-agent":K}},r)}catch(r){return t.emit("warning",new Error(`skipping invalid url xs param: ${e}`)),n(null)}t._xsRequests.push(o)}const t=this,n=Array.isArray(this.xs)?this.xs:[this.xs],r=n.map(t=>n=>{e(t,n)});S(r)}_onMetadata(e){if(this.metadata||this.destroyed)return;this._debug("got metadata"),this._xsRequests.forEach(e=>{e.abort()}),this._xsRequests=[];let t;if(e&&e.infoHash)t=e;else try{t=E(e)}catch(e){return this._destroy(e)}if(this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(e=>{this.addWebSeed(e)}),this._rarityMap=new F(this),this.store=new w(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map(e=>({path:L.join(this.path,e.path),length:e.length,offset:e.offset})),length:this.length,name:this.infoHash})),this.files=this.files.map(e=>new j(this,e)),this.so){const e=O.parse(this.so);this.files.forEach((t,n)=>{e.includes(n)&&this.files[n].select(!0)})}else 0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1);this._hashes=this.pieces,this.pieces=this.pieces.map((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new I(n)}),this._reservations=this.pieces.map(()=>[]),this.bitfield=new f(this.pieces.length),this.wires.forEach(e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)}),this.skipVerify?(this._markAllVerified(),this._onStore()):(this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===i?this.getFileModtimes((e,t)=>{if(e)return this._destroy(e);const n=this.files.map((e,n)=>t[n]===this._fileModtimes[n]).every(e=>e);n?(this._markAllVerified(),this._onStore()):this._verifyPieces()}):this._verifyPieces()),this.emit("metadata")}getFileModtimes(e){const t=[];v(this.files.map((e,n)=>r=>{b.stat(L.join(this.path,e.path),(e,o)=>e&&"ENOENT"!==e.code?r(e):void(t[n]=o&&o.mtime.getTime(),r(null)))}),z,n=>{this._debug("done getting file modtimes"),e(n,t)})}_verifyPieces(){v(this.pieces.map((e,t)=>e=>this.destroyed?e(new Error("torrent is destroyed")):void this.store.get(t,(r,o)=>this.destroyed?e(new Error("torrent is destroyed")):r?n.nextTick(e,null):void R(o,n=>{if(this.destroyed)return e(new Error("torrent is destroyed"));if(n===this._hashes[t]){if(!this.pieces[t])return;this._debug("piece verified %s",t),this._markVerified(t)}else this._debug("piece invalid %s",t);e(null)}))),z,e=>e?this._destroy(e):void(this._debug("done verifying"),this._onStore()))}_markAllVerified(){for(let e=0;e<this.pieces.length;e++)this._markVerified(e)}_markVerified(e){this.pieces[e]=null,this._reservations[e]=null,this.bitfield.set(e,!0)}_onStore(){this.destroyed||(this._debug("on store"),this.ready=!0,this.emit("ready"),this._checkDone(),this._updateSelections())}destroy(e){this._destroy(null,e)}_destroy(e,t){if(!this.destroyed){for(const e in this.destroyed=!0,this._debug("destroy"),this.client._remove(this),clearInterval(this._rechokeIntervalId),this._xsRequests.forEach(e=>{e.abort()}),this._rarityMap&&this._rarityMap.destroy(),this._peers)this.removePeer(e);this.files.forEach(e=>{e instanceof j&&e._destroy()});const n=this._servers.map(e=>t=>{e.destroy(t)});this.discovery&&n.push(e=>{this.discovery.destroy(e)}),this.store&&n.push(e=>{this.store.close(e)}),S(n,t),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}}addPeer(t){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let e;if("string"==typeof t){let n;try{n=p(t)}catch(n){return this._debug("ignoring peer: invalid %s",t),this.emit("invalidPeer",t),!1}e=n[0]}else"string"==typeof t.remoteAddress&&(e=t.remoteAddress);if(e&&this.client.blocked.contains(e))return this._debug("ignoring peer: blocked %s",t),"string"!=typeof t&&t.destroy(),this.emit("blockedPeer",t),!1}const n=!!this._addPeer(t);return n?this.emit("peer",t):this.emit("invalidPeer",t),n}_addPeer(e){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;const t=e&&e.id||e;if(this._peers[t])return this._debug("ignoring peer: duplicate (%s)",t),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;this._debug("add peer %s",t);let n;return n="string"==typeof e?N.createTCPOutgoingPeer(e,this):N.createWebRTCPeer(e,this),this._peers[n.id]=n,this._peersLength+=1,"string"==typeof e&&(this._queue.push(n),this._drain()),n}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=N.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):void(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,this._peersLength+=1)}removePeer(e){const t=e&&e.id||e;e=this._peers[t];e&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,r){if(this.destroyed)throw new Error("torrent is destroyed");if(0>e||t<e||this.pieces.length<=t)throw new Error("invalid selection ",e,":",t);n=+n||0,this._debug("select %s-%s (priority %s)",e,t,n),this._selections.push({from:e,to:t,offset:0,priority:n,notify:r||u}),this._selections.sort((e,t)=>t.priority-e.priority),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=+n||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let r=0;r<this._selections.length;++r){const o=this._selections[r];if(o.from===e&&o.to===t&&o.priority===n){this._selections.splice(r,1);break}}this._updateSelections()}critical(e,t){if(this.destroyed)throw new Error("torrent is destroyed");this._debug("critical %s-%s",e,t);for(let n=e;n<=t;++n)this._critical[n]=!0;this._updateSelections()}_onWire(e,t){if(this._debug("got wire %s (%s)",e._debugId,t||"Unknown"),e.on("download",e=>{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.client.emit("download",e))}),e.on("upload",e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.client.emit("upload",e))}),this.wires.push(e),t){const n=p(t);e.remoteAddress=n[0],e.remotePort=n[1]}this.client.dht&&this.client.dht.listening&&e.on("port",n=>this.destroyed||this.client.dht.destroyed?void 0:e.remoteAddress?0===n||65536<n?this._debug("ignoring invalid PORT from peer"):void(this._debug("port: %s (from %s)",n,t),this.client.dht.addNode({host:e.remoteAddress,port:n})):this._debug("ignoring PORT from peer with no address")),e.on("timeout",()=>{this._debug("wire timeout (%s)",t),e.destroy()}),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(P(this.metadata)),e.ut_metadata.on("warning",e=>{this._debug("ut_metadata warning: %s",e.message)}),this.metadata||(e.ut_metadata.on("metadata",e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof M||this.private||(e.use(M()),e.ut_pex.on("peer",e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,t),this.addPeer(e))}),e.ut_pex.on("dropped",e=>{const n=this._peers[e];n&&!n.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,t),this.removePeer(e))}),e.once("close",()=>{e.ut_pex.reset()})),this.emit("wire",e,t),this.metadata&&n.nextTick(()=>{this._onWireWithMetadata(e)})}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,q),t.unref&&t.unref()))};let r;const o=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(r=0;r<this.pieces.length;++r)if(!e.peerPieces.get(r))return;e.isSeeder=!0,e.choke()}};e.on("bitfield",()=>{o(),this._update()}),e.on("have",()=>{o(),this._update()}),e.once("interested",()=>{e.unchoke()}),e.once("close",()=>{clearTimeout(t)}),e.on("choke",()=>{clearTimeout(t),t=setTimeout(n,q),t.unref&&t.unref()}),e.on("unchoke",()=>{clearTimeout(t),this._update()}),e.on("request",(t,n,r,o)=>r>131072?e.destroy():void(this.pieces[t]||this.store.get(t,{offset:n,length:r},o))),e.bitfield(this.bitfield),e.uninterested(),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,q),t.unref&&t.unref()),e.isSeeder=!1,o()}_updateSelections(){!this.ready||this.destroyed||(n.nextTick(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;e<this._selections.length;++e){const t=this._selections[e],n=t.offset;for(;this.bitfield.get(t.from+t.offset)&&t.from+t.offset<t.to;)t.offset+=1;n!==t.offset&&t.notify(),t.to===t.from+t.offset&&this.bitfield.get(t.from+t.offset)&&(this._selections.splice(e,1),e-=1,t.notify(),this._updateInterest())}this._selections.length||this.emit("idle")}_updateInterest(){const e=this._amInterested;this._amInterested=!!this._selections.length,this.wires.forEach(e=>{let t=!1;for(let n=0;n<this.pieces.length;++n)if(this.pieces[n]&&e.peerPieces.get(n)){t=!0;break}t?e.interested():e.uninterested()});e===this._amInterested||(this._amInterested?this.emit("interested"):this.emit("uninterested"))}_update(){if(!this.destroyed){const e=T(this.wires);for(let t;t=e();)this._updateWireWrapper(t)}}_updateWireWrapper(e){const t=this;"undefined"!=typeof window&&"function"==typeof window.requestIdleCallback?window.requestIdleCallback(function(){t._updateWire(e)}):t._updateWire(e)}_updateWire(e){function t(t,n,r,o){return a=>a>=t&&a<=n&&!(a in r)&&e.peerPieces.get(a)&&(!o||o(a))}function n(){const t=e.downloadSpeed()||1;if(t>D)return()=>!0;const n=s(1,e.requests.length)*I.BLOCK_LENGTH/t;let r=10,o=0;return e=>{if(!r||a.bitfield.get(e))return!0;for(let i=a.pieces[e].missing;o<a.wires.length;o++){const s=a.wires[o],d=s.downloadSpeed();if(!(d<D)&&!(d<=t)&&s.peerPieces.get(e)&&!(0<(i-=d*n)))return r--,!1}return!0}}function r(e){let t=e;for(let n=e;n<a._selections.length&&a._selections[n].priority;n++)t=n;const n=a._selections[e];a._selections[e]=a._selections[t],a._selections[t]=n}function i(o){if(e.requests.length>=l)return!0;const s=n();for(let n=0;n<a._selections.length;n++){const i=a._selections[n];let d;if("rarest"===a.strategy){const c=i.from+i.offset,u=i.to,p={};let f=0;for(const h=t(c,u,p,s);f<u-c+1&&(d=a._rarityMap.getRarestPiece(h),!(0>d));){for(;a._request(e,d,a._critical[d]||o););if(e.requests.length<l){p[d]=!0,f++;continue}return i.priority&&r(n),!0}}else for(d=i.from+i.offset;d<=i.to;d++)if(e.peerPieces.get(d)&&s(d)){for(;a._request(e,d,a._critical[d]||o););if(!(e.requests.length<l))return i.priority&&r(n),!0}}return!1}const a=this;if(e.peerChoking)return;if(!e.downloaded)return function(){if(!e.requests.length)for(let n=a._selections.length;n--;){const r=a._selections[n];let o;if("rarest"===a.strategy){const n=r.from+r.offset,i=r.to,s={};let d=0;for(const r=t(n,i,s);d<i-n+1&&(o=a._rarityMap.getRarestPiece(r),!(0>o));){if(a._request(e,o,!1))return;s[o]=!0,d+=1}}else for(o=r.to;o>=r.from+r.offset;--o)if(e.peerPieces.get(o)&&a._request(e,o,!1))return}}();const d=o(e,.5);if(e.requests.length>=d)return;const l=o(e,W);i(!1)||i(!0)}_rechoke(){if(!this.ready)return;0<this._rechokeOptimisticTime?this._rechokeOptimisticTime-=1:this._rechokeOptimisticWire=null;const e=[];this.wires.forEach(t=>{t.isSeeder||t===this._rechokeOptimisticWire||e.push({wire:t,downloadSpeed:t.downloadSpeed(),uploadSpeed:t.uploadSpeed(),salt:Math.random(),isChoked:!0})}),e.sort(function(e,t){return e.downloadSpeed===t.downloadSpeed?e.uploadSpeed===t.uploadSpeed?e.wire.amChoking===t.wire.amChoking?e.salt-t.salt:e.wire.amChoking?1:-1:t.uploadSpeed-e.uploadSpeed:t.downloadSpeed-e.downloadSpeed});let t=0,n=0;for(;n<e.length&&t<this._rechokeNumSlots;++n)e[n].isChoked=!1,e[n].wire.peerInterested&&(t+=1);if(!this._rechokeOptimisticWire&&n<e.length&&this._rechokeNumSlots){const t=e.slice(n).filter(e=>e.wire.peerInterested),r=t[c(t.length)];r&&(r.isChoked=!1,this._rechokeOptimisticWire=r.wire,this._rechokeOptimisticTime=2)}e.forEach(e=>{e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})}_hotswap(e,t){const n=e.downloadSpeed();if(n<I.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const o=this._reservations[t];if(!o)return!1;let r=1/0,a,s;for(s=0;s<o.length;s++){const t=o[s];if(!t||t===e)continue;const i=t.downloadSpeed();i>=D||2*i>n||i>r||(a=t,r=i)}if(!a)return!1;for(s=0;s<o.length;s++)o[s]===a&&(o[s]=null);for(s=0;s<a.requests.length;s++){const e=a.requests[s];e.piece===t&&this.pieces[t].cancel(0|e.offset/I.BLOCK_LENGTH)}return this.emit("hotswap",a,e,t),!0}_request(e,t,a){function s(){n.nextTick(()=>{c._update()})}const c=this,u=e.requests.length,p="webSeed"===e.type;if(c.bitfield.get(t))return!1;const f=p?d(l(e,W,c.pieceLength),c.maxWebConns):o(e,W);if(u>=f)return!1;const h=c.pieces[t];let m=p?h.reserveRemaining():h.reserve();if(-1===m&&a&&c._hotswap(e,t)&&(m=p?h.reserveRemaining():h.reserve()),-1===m)return!1;let g=c._reservations[t];g||(g=c._reservations[t]=[]);let _=g.indexOf(null);-1===_&&(_=g.length),g[_]=e;const b=h.chunkOffset(m),y=p?h.chunkLengthRemaining(m):h.chunkLength(m);return e.request(t,b,y,function n(r,o){if(c.destroyed)return;if(!c.ready)return c.once("ready",()=>{n(r,o)});if(g[_]===e&&(g[_]=null),h!==c.pieces[t])return s();if(r)return c._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,b,y,`${e.remoteAddress}:${e.remotePort}`,r.message),p?h.cancelRemaining(m):h.cancel(m),void s();if(c._debug("got piece %s (offset: %s length: %s) from %s",t,b,y,`${e.remoteAddress}:${e.remotePort}`),!h.set(m,o,e))return s();const i=h.flush();R(i,e=>{if(!c.destroyed){if(e===c._hashes[t]){if(!c.pieces[t])return;c._debug("piece verified %s",t),c.pieces[t]=null,c._reservations[t]=null,c.bitfield.set(t,!0),c.store.put(t,i),c.wires.forEach(e=>{e.have(t)}),c._checkDone()&&!c.destroyed&&c.discovery.complete()}else c.pieces[t]=new I(h.length),c.emit("warning",new Error(`Piece ${t} failed verification`));s()}})}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}});let e=!0;for(let t=0;t<this._selections.length;t++){const n=this._selections[t];for(let t=n.from;t<=n.to;t++)if(!this.bitfield.get(t)){e=!1;break}if(!e)break}return!this.done&&e&&(this.done=!0,this._debug(`torrent done: ${this.infoHash}`),this.emit("done")),this._gcSelections(),e}load(e,t){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.ready)return this.once("ready",()=>{this.load(e,t)});Array.isArray(e)||(e=[e]),t||(t=u);const n=new k(e),r=new h(this.store,this.pieceLength);B(n,r,e=>e?t(e):void(this._markAllVerified(),this._checkDone(),t(null)))}createServer(e){if("function"!=typeof H)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new H(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client._debugId}] [${this._debugId}] ${e[0]}`,m(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof x.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("tcp connect attempt to %s",e.addr);const t=p(e.addr),n={host:t[0],port:t[1]},r=e.conn=x.connect(n);r.once("connect",()=>{e.onConnect()}),r.once("error",t=>{e.destroy(t)}),e.startConnectTimeout(),r.on("close",()=>{if(!this.destroyed){if(e.retries>=V.length)return void this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,V.length);const t=V[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout(()=>{const t=this._addPeer(e.addr);t&&(t.retries=e.retries+1)},t);n.unref&&n.unref()}})}_validAddr(e){let t;try{t=p(e)}catch(t){return!1}const n=t[0],r=t[1];return 0<r&&65535>r&&("127.0.0.1"!==n||r!==this.client.torrentPort)}}t.exports=X}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../package.json":250,"./file":2,"./peer":3,"./rarity-map":4,"./server":45,_process:138,"addr-to-ip-port":7,bitfield:13,"chunk-store-stream/write":64,debug:69,events:48,fs:46,"fs-chunk-store":105,"immediate-chunk-store":86,multistream:121,net:45,os:45,"parse-numeric-range":133,"parse-torrent":134,path:135,pump:139,"random-iterate":144,"run-parallel":175,"run-parallel-limit":174,"simple-get":179,"simple-sha1":193,speedometer:207,"torrent-discovery":229,"torrent-piece":233,uniq:236,ut_metadata:240,ut_pex:45}],6:[function(e,t){const n=e("bitfield"),r=e("safe-buffer").Buffer,o=e("debug")("webtorrent:webconn"),i=e("simple-get"),a=e("simple-sha1"),l=e("bittorrent-protocol"),c=e("../package.json").version;t.exports=class extends l{constructor(e,t){super(),this.url=e,this.webPeerId=a.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.once("handshake",e=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const t=this._torrent.pieces.length,r=new n(t);for(let n=0;n<=t;n++)r.set(n,!0);this.bitfield(r)}),this.once("interested",()=>{o("interested"),this.unchoke()}),this.on("uninterested",()=>{o("uninterested")}),this.on("choke",()=>{o("choke")}),this.on("unchoke",()=>{o("unchoke")}),this.on("bitfield",()=>{o("bitfield")}),this.on("request",(e,t,n,r)=>{o("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,r)})}httpRequest(e,t,n,a){const l=e*this._torrent.pieceLength,u=l+t,p=u+n-1,f=this._torrent.files;let h;if(1>=f.length)h=[{url:this.url,start:u,end:p}];else{const e=f.filter(e=>e.offset<=p&&e.offset+e.length>u);if(1>e.length)return a(new Error("Could not find file corresponnding to web seed range request"));h=e.map(e=>{const t=e.offset+e.length-1,n=this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:s(e.offset-u,0),start:s(u-e.offset,0),end:d(t,p-e.offset)}})}let m=0,g=!1,_;1<h.length&&(_=r.alloc(n)),h.forEach(r=>{function s(e,t){return 200>e.statusCode||300<=e.statusCode?(g=!0,a(new Error(`Unexpected HTTP status code ${e.statusCode}`))):void(o("Got data of length %d",t.length),1===h.length?a(null,t):(t.copy(_,r.fileOffsetInRange),++m===h.length&&a(null,_)))}const d=r.url,l=r.start,u=r.end;o("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",d,e,t,n,l,u);const p={url:d,method:"GET",headers:{"user-agent":`WebTorrent/${c} (https://webtorrent.io)`,range:`bytes=${l}-${u}`}};i.concat(p,(e,t,n)=>g?void 0:e?"undefined"==typeof window||d.startsWith(`${window.location.origin}/`)?(g=!0,a(e)):i.head(d,(t,n)=>g?void 0:t?(g=!0,a(t)):200>n.statusCode||300<=n.statusCode?(g=!0,a(new Error(`Unexpected HTTP status code ${n.statusCode}`))):n.url===d?(g=!0,a(e)):void(p.url=n.url,i.concat(p,(e,t,n)=>g?void 0:e?(g=!0,a(e)):void s(t,n)))):void s(t,n))})}destroy(){super.destroy(),this._torrent=null}}},{"../package.json":250,bitfield:13,"bittorrent-protocol":14,debug:69,"safe-buffer":177,"simple-get":179,"simple-sha1":193}],7:[function(e,t){const n=/^\[?([^\]]+)\]?:(\d+)$/;let r={},o=0;t.exports=function(e){if(1e5===o&&t.exports.reset(),!r[e]){const t=n.exec(e);if(!t)throw new Error(`invalid addr: ${e}`);r[e]=[t[1],+t[2]],o+=1}return r[e]},t.exports.reset=function(){r={},o=0}},{}],8:[function(e,t,n){"use strict";function r(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");-1===n&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function o(e,t,n){return 3*(t+n)/4-n}function a(e){for(var t=r(e),n=t[0],a=t[1],s=new p(o(e,n,a)),d=0,l=0<a?n-4:n,c=0,f;c<l;c+=4)f=u[e.charCodeAt(c)]<<18|u[e.charCodeAt(c+1)]<<12|u[e.charCodeAt(c+2)]<<6|u[e.charCodeAt(c+3)],s[d++]=255&f>>16,s[d++]=255&f>>8,s[d++]=255&f;return 2===a&&(f=u[e.charCodeAt(c)]<<2|u[e.charCodeAt(c+1)]>>4,s[d++]=255&f),1===a&&(f=u[e.charCodeAt(c)]<<10|u[e.charCodeAt(c+1)]<<4|u[e.charCodeAt(c+2)]>>2,s[d++]=255&f>>8,s[d++]=255&f),s}function s(e){return c[63&e>>18]+c[63&e>>12]+c[63&e>>6]+c[63&e]}function d(e,t,n){for(var r=[],o=t,a;o<n;o+=3)a=(16711680&e[o]<<16)+(65280&e[o+1]<<8)+(255&e[o+2]),r.push(s(a));return r.join("")}function l(e){for(var t=e.length,n=t%3,r=[],o=16383,a=0,s=t-n,l;a<s;a+=o)r.push(d(e,a,a+o>s?s:a+o));return 1===n?(l=e[t-1],r.push(c[l>>2]+c[63&l<<4]+"==")):2===n&&(l=(e[t-2]<<8)+e[t-1],r.push(c[l>>10]+c[63&l>>4]+c[63&l<<2]+"=")),r.join("")}n.byteLength=function(e){var t=r(e),n=t[0],o=t[1];return 3*(n+o)/4-o},n.toByteArray=a,n.fromByteArray=l;for(var c=[],u=[],p="undefined"==typeof Uint8Array?Array:Uint8Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,m=f.length;h<m;++h)c[h]=f[h],u[f.charCodeAt(h)]=h;u[45]=62,u[95]=63},{}],9:[function(e,t){(function(e){function n(e,t,n){for(var r=0,o=1,a=t,s;a<n;a++){if(s=e[a],58>s&&48<=s){r=10*r+(s-48);continue}if(a!==t||43!==s){if(a===t&&45===s){o=-1;continue}if(46===s)break;throw new Error("not a number: buffer["+a+"] = "+s)}}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())}const i=101;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,a=r.data;t<n;){if(a[t]===e)return t;t++}throw new Error("Invalid data: Missing delimiter \""+o(e)+"\" [0x"+e.toString(16)+"]")},r.dictionary=function(){r.position++;for(var e={};r.data[r.position]!==i;)e[r.buffer()]=r.next();return r.position++,e},r.list=function(){r.position++;for(var e=[];r.data[r.position]!==i;)e.push(r.next());return r.position++,e},r.integer=function(){var e=r.find(i),t=n(r.data,r.position+1,e);return r.position+=e+1-r.position,t},r.buffer=function(){var e=r.find(58),t=n(r.data,r.position,e),o=++e+t;return r.position=o,r.encoding?r.data.toString(r.encoding,e,o):r.data.slice(e,o)},t.exports=r}).call(this,e("buffer").Buffer)},{buffer:47}],10:[function(e,t){function n(e,t,o){var i=[],a=null;return n._encode(i,e),a=r.concat(i),n.bytes=a.length,r.isBuffer(t)?(a.copy(t,o),t):a}var r=e("safe-buffer").Buffer;n.bytes=-1,n._floatConversionDetected=!1,n.getType=function(e){return r.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},n._encode=function(e,t){if(null!=t)switch(n.getType(t)){case"buffer":n.buffer(e,t);break;case"object":n.dict(e,t);break;case"array":n.list(e,t);break;case"string":n.string(e,t);break;case"number":n.number(e,t);break;case"boolean":n.number(e,t);break;case"arraybufferview":n.buffer(e,r.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":n.buffer(e,r.from(t));}};var o=r.from("e"),i=r.from("d"),a=r.from("l");n.buffer=function(e,t){e.push(new r(t.length+":"),t)},n.string=function(e,t){e.push(r.from(r.byteLength(t)+":"+t))},n.number=function(e,t){var o=(t/2147483648<<0)*2147483648+(t%2147483648<<0);e.push(r.from("i"+o+"e")),o===t||n._floatConversionDetected||(n._floatConversionDetected=!0,console.warn("WARNING: Possible data corruption detected with value \""+t+"\":","Bencoding only defines support for integers, value was converted to \""+o+"\""),console.trace())},n.dict=function(e,t){e.push(i);for(var r=0,a=Object.keys(t).sort(),s=a.length,d;r<s;r++)d=a[r],null==t[d]||(n.string(e,d),n._encode(e,t[d]));e.push(o)},n.list=function(e,t){var r=0,s=t.length;for(e.push(a);r<s;r++)null!=t[r]&&n._encode(e,t[r]);e.push(o)},t.exports=n},{"safe-buffer":177}],11:[function(e,t){var n=t.exports;n.encode=e("./encode"),n.decode=e("./decode"),n.byteLength=n.encodingLength=function(e){return n.encode(e).length}},{"./decode":9,"./encode":10}],12:[function(e,t){t.exports=function(e,t,n,r,o){var i,a;if(void 0===r)r=0;else if(r|=0,0>r||r>=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o|=0,o<r||o>=e.length)throw new RangeError("invalid upper bound");for(;r<=o;)if(i=r+(o-r>>1),a=+n(e[i],t,i,e),0>a)r=i+1;else if(0<a)o=i-1;else return i;return~r}},{}],13:[function(e,t){(function(e){function n(e,t){return this instanceof n?void(0===arguments.length&&(e=0),this.grow=t&&(isFinite(t.grow)&&r(t.grow)||t.grow)||0,("number"==typeof e||e===void 0)&&(e=new o(r(e)),e.fill&&!e._isBuffer&&e.fill(0)),this.buffer=e):new n(e,t)}function r(e){var t=e>>3;return 0!=e%8&&t++,t}var o="undefined"==typeof e?Uint8Array:e;n.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)},n.prototype.set=function(e,t){var n=e>>3;t||1===arguments.length?(this.buffer.length<n+1&&this._grow(s(n+1,d(2*this.buffer.length,this.grow))),this.buffer[n]|=128>>e%8):n<this.buffer.length&&(this.buffer[n]&=~(128>>e%8))},n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new o(e);if(t.fill&&t.fill(0),this.buffer.copy)this.buffer.copy(t,0);else for(var n=0;n<this.buffer.length;n++)t[n]=this.buffer[n];this.buffer=t}},"undefined"!=typeof t&&(t.exports=n)}).call(this,e("buffer").Buffer)},{buffer:47}],14:[function(e,t){(function(n){const r=e("unordered-array-remove"),o=e("bencode"),i=e("bitfield"),a=e("debug")("bittorrent-protocol"),s=e("xtend"),d=e("randombytes"),l=e("speedometer"),c=e("readable-stream"),u=n.from("\x13BitTorrent protocol"),p=n.from([0,0,0,0]),f=n.from([0,0,0,1,0]),h=n.from([0,0,0,1,1]),m=n.from([0,0,0,1,2]),g=n.from([0,0,0,1,3]),_=[0,0,0,0,0,0,0,0],b=[0,0,0,3,9,0,0];class y{constructor(e,t,n,r){this.piece=e,this.offset=t,this.length=n,this.callback=r}}class w extends c.Duplex{constructor(){super(),this._debugId=d(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=null,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new i(0,{grow:4e5}),this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=l(),this.downloadSpeed=l(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this.on("finish",this._onFinish),this._parseHandshake()}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval);!1===e||(this._keepAliveInterval=setInterval(()=>{this.keepAlive()},55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._clearTimeout(),this._timeoutMs=e,this._timeoutUnref=!!t,this._updateTimeout()}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){function t(){}const n=e.prototype.name;if(!n)throw new Error("Extension class requires a \"name\" property on the prototype");this._debug("use extension.name=%s",n);const r=this._nextExt,o=new e(this);"function"!=typeof o.onHandshake&&(o.onHandshake=t),"function"!=typeof o.onExtendedHandshake&&(o.onExtendedHandshake=t),"function"!=typeof o.onMessage&&(o.onMessage=t),this.extendedMapping[r]=n,this._ext[n]=o,this[n]=o,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(p)}handshake(e,t,r){let o,i;if("string"==typeof e?(e=e.toLowerCase(),o=n.from(e,"hex")):(o=e,e=o.toString("hex")),"string"==typeof t?i=n.from(t,"hex"):(i=t,t=i.toString("hex")),20!==o.length||20!==i.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,r);const a=n.from(_);a[5]|=16,r&&r.dht&&(a[7]|=1),this._push(n.concat([u,a,o,i])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=s(this.extendedHandshake);for(const t in e.m={},this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=+t}this.extended(0,o.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(f)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(h))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(m))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(g))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(e){this._debug("bitfield"),n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(e,t,n,r){return r||(r=()=>{}),this._finished?r(new Error("wire is closed")):this.peerChoking?r(new Error("peer is choking")):void(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new y(e,t,n,r)),this._updateTimeout(),this._message(6,[e,t,n],null))}piece(e,t,n){this._debug("piece index=%d offset=%d",e,t),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(e){this._debug("port %d",e);const t=n.from(b);t.writeUInt16BE(e,5),this._push(t)}extended(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"==typeof e){const r=n.from([e]),i=n.isBuffer(t)?t:o.encode(t);this._message(20,[],n.concat([r,i]))}else throw new Error(`Unrecognized extension: ${e}`)}_read(){}_message(e,t,r){const o=r?r.length:0,a=n.allocUnsafe(5+4*t.length);a.writeUInt32BE(a.length+o-4,0),a[4]=e;for(let n=0;n<t.length;n++)a.writeUInt32BE(t[n],5+4*n);this._push(a),r&&this._push(r)}_push(e){return this._finished?void 0:this.push(e)}_onKeepAlive(){this._debug("got keep-alive"),this.emit("keep-alive")}_onHandshake(e,t,n){const r=e.toString("hex"),o=t.toString("hex");this._debug("got handshake i=%s p=%s exts=%o",r,o,n),this.peerId=o,this.peerIdBuffer=t,this.peerExtensions=n,this.emit("handshake",r,o,n);for(var i in this._ext)this._ext[i].onHandshake(r,o,n);n.extended&&this._handshakeSent&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_onChoke(){for(this.peerChoking=!0,this._debug("got choke"),this.emit("choke");this.requests.length;)this._callback(this.requests.pop(),new Error("peer is choking"),null)}_onUnchoke(){this.peerChoking=!1,this._debug("got unchoke"),this.emit("unchoke")}_onInterested(){this.peerInterested=!0,this._debug("got interested"),this.emit("interested")}_onUninterested(){this.peerInterested=!1,this._debug("got uninterested"),this.emit("uninterested")}_onHave(e){this.peerPieces.get(e)||(this._debug("got have %d",e),this.peerPieces.set(e,!0),this.emit("have",e))}_onBitField(e){this.peerPieces=new i(e),this._debug("got bitfield"),this.emit("bitfield",this.peerPieces)}_onRequest(e,t,n){if(!this.amChoking){this._debug("got request index=%d offset=%d length=%d",e,t,n);const o=(o,i)=>r===this._pull(this.peerRequests,e,t,n)?o?this._debug("error satisfying request index=%d offset=%d length=%d (%s)",e,t,n,o.message):void this.piece(e,t,i):void 0;var r=new y(e,t,n,o);this.peerRequests.push(r),this.emit("request",e,t,n,o)}}_onPiece(e,t,n){this._debug("got piece index=%d offset=%d",e,t),this._callback(this._pull(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)}_onCancel(e,t,n){this._debug("got cancel index=%d offset=%d length=%d",e,t,n),this._pull(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)}_onPort(e){this._debug("got port %d",e),this.emit("port",e)}_onExtended(e,t){if(0===e){let e;try{e=o.decode(t)}catch(e){this._debug("ignoring invalid extended handshake: %s",e.message||e)}if(!e)return;this.peerExtendedHandshake=e;if("object"==typeof e.m)for(var n in e.m)this.peerExtendedMapping[n]=+e.m[n].toString();for(n in this._ext)this.peerExtendedMapping[n]&&this._ext[n].onExtendedHandshake(this.peerExtendedHandshake);this._debug("got extended handshake"),this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this._debug("got extended message ext=%s",e),this.emit("extended",e,t)}_onTimeout(){this._debug("request timed out"),this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")}_write(e,t,r){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){const e=1===this._buffer.length?this._buffer[0]:n.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[e.slice(this._parserSize)]:[],this._parser(e.slice(0,this._parserSize))}r(null)}_callback(e,t,n){e&&(this._clearTimeout(),!this.peerChoking&&!this._finished&&this._updateTimeout(),e.callback(t,n))}_clearTimeout(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)}_updateTimeout(){this._timeoutMs&&this.requests.length&&!this._timeout&&(this._timeout=setTimeout(()=>this._onTimeout(),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref())}_parse(e,t){this._parserSize=e,this._parser=t}_onMessageLength(e){const t=e.readUInt32BE(0);0<t?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(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);}}_parseHandshake(){this._parse(1,e=>{const t=e.readUInt8(0);this._parse(t+48,e=>{const n=e.slice(0,t);return"BitTorrent protocol"===n.toString()?void(e=e.slice(t),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),this._parse(4,this._onMessageLength)):(this._debug("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void this.end())})})}_onFinish(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,()=>{});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)}_debug(...e){e[0]=`[${this._debugId}] ${e[0]}`,a(...e)}_pull(e,t,n,o){for(let a=0;a<e.length;a++){const i=e[a];if(i.piece===t&&i.offset===n&&i.length===o)return r(e,a),i}return null}}t.exports=w}).call(this,e("buffer").Buffer)},{bencode:11,bitfield:13,buffer:47,debug:15,randombytes:145,"readable-stream":26,speedometer:207,"unordered-array-remove":237,xtend:248}],15:[function(e,t,n){(function(o){"use strict";function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(){var e;return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&(e=console).log.apply(e,arguments)}function s(){var e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}n.log=a,n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!!this.useColors){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"===e||(r++,"%c"===e&&(o=r))}),e.splice(o,0,n)}},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=s,n.useColors=function(){return!!("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(n);var d=t.exports.formatters;d.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":16,_process:138}],16:[function(e,t){"use strict";t.exports=function(t){function n(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return o.colors[r(t)%o.colors.length]}function o(e){function t(){if(t.enabled){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];var a=t,s=+new Date,d=s-(r||s);a.diff=d,a.prev=r,a.curr=s,r=s,n[0]=o.coerce(n[0]),"string"!=typeof n[0]&&n.unshift("%O");var l=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,function(e,t){if("%%"===e)return e;l++;var r=o.formatters[t];if("function"==typeof r){var i=n[l];e=r.call(a,i),n.splice(l,1),l--}return e}),o.formatArgs.call(a,n);var c=a.log||o.log;c.apply(a,n)}}var r;return t.namespace=e,t.enabled=o.enabled(e),t.useColors=o.useColors(),t.color=n(e),t.destroy=i,t.extend=a,"function"==typeof o.init&&o.init(t),o.instances.push(t),t}function i(){var e=o.instances.indexOf(this);return-1!==e&&(o.instances.splice(e,1),!0)}function a(e,t){return o(this.namespace+("undefined"==typeof t?":":t)+e)}return o.debug=o,o.default=o,o.coerce=function(e){return e instanceof Error?e.stack||e.message:e},o.disable=function(){o.enable("")},o.enable=function(e){o.save(e),o.names=[],o.skips=[];var t=("string"==typeof e?e:"").split(/[\s,]+/),n=t.length,r;for(r=0;r<n;r++)t[r]&&(e=t[r].replace(/\*/g,".*?"),"-"===e[0]?o.skips.push(new RegExp("^"+e.substr(1)+"$")):o.names.push(new RegExp("^"+e+"$")));for(r=0;r<o.instances.length;r++){var a=o.instances[r];a.enabled=o.enabled(a.namespace)}},o.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=o.skips.length;t<n;t++)if(o.skips[t].test(e))return!1;for(t=0,n=o.names.length;t<n;t++)if(o.names[t].test(e))return!0;return!1},o.humanize=e("ms"),Object.keys(t).forEach(function(e){o[e]=t[e]}),o.instances=[],o.names=[],o.skips=[],o.formatters={},o.selectColor=n,o.enable(o.load()),o}},{ms:17}],17:[function(e,t){var s=Math.round;function n(e){if(e+="",!(100<e.length)){var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();return"years"===n||"year"===n||"yrs"===n||"yr"===n||"y"===n?31557600000*r:"weeks"===n||"week"===n||"w"===n?604800000*r:"days"===n||"day"===n||"d"===n?86400000*r:"hours"===n||"hour"===n||"hrs"===n||"hr"===n||"h"===n?3600000*r:"minutes"===n||"minute"===n||"mins"===n||"min"===n||"m"===n?60000*r:"seconds"===n||"second"===n||"secs"===n||"sec"===n||"s"===n?1000*r:"milliseconds"===n||"millisecond"===n||"msecs"===n||"msec"===n||"ms"===n?r:void 0}}}function o(e){var t=r(e);return 86400000<=t?s(e/86400000)+"d":3600000<=t?s(e/3600000)+"h":60000<=t?s(e/60000)+"m":1000<=t?s(e/1000)+"s":e+"ms"}function i(e){var t=r(e);return 86400000<=t?a(e,t,86400000,"day"):3600000<=t?a(e,t,3600000,"hour"):60000<=t?a(e,t,60000,"minute"):1000<=t?a(e,t,1000,"second"):e+" ms"}function a(e,t,r,n){return s(e/r)+" "+n+(t>=1.5*r?"s":"")}var l=24*(60*60000);t.exports=function(e,t){t=t||{};var r=typeof e;if("string"==r&&0<e.length)return n(e);if("number"==r&&!1===isNaN(e))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))}},{}],18:[function(e,t){"use strict";function n(e){return this instanceof n?void(d.call(this,e),l.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",r)):new n(e)}function r(){this.allowHalfOpen||this._writableState.ended||i.nextTick(o,this)}function o(e){e.end()}var i=e("process-nextick-args"),a=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=n;var s=e("core-util-is");s.inherits=e("inherits");var d=e("./_stream_readable"),l=e("./_stream_writable");s.inherits(n,d);for(var c=a(l.prototype),u=0,p;u<c.length;u++)p=c[u],n.prototype[p]||(n.prototype[p]=l.prototype[p]);Object.defineProperty(n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(n.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0===this._readableState||void 0===this._writableState||(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),n.prototype._destroy=function(e,t){this.push(null),this.end(),i.nextTick(t,e)}},{"./_stream_readable":20,"./_stream_writable":22,"core-util-is":66,inherits:87,"process-nextick-args":137}],19:[function(e,t){"use strict";function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./_stream_transform"),o=e("core-util-is");o.inherits=e("inherits"),o.inherits(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":21,"core-util-is":66,inherits:87}],20:[function(e,t){(function(r,o){"use strict";function i(e){return F.from(e)}function a(e){return F.isBuffer(e)||e instanceof H}function s(e,t,n){return"function"==typeof e.prependListener?e.prependListener(t,n):void(e._events&&e._events[t]?P(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n))}function d(t,r){M=M||e("./_stream_duplex"),t=t||{};var o=r instanceof M;this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,a=t.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o&&(a||0===a)?a:s,this.highWaterMark=n(this.highWaterMark),this.buffer=new z,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(!G&&(G=e("string_decoder/").StringDecoder),this.decoder=new G(t.encoding),this.encoding=t.encoding)}function l(t){return M=M||e("./_stream_duplex"),this instanceof l?void(this._readableState=new d(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),N.call(this)):new l(t)}function c(e,t,n,r,o){var a=e._readableState;if(null===t)a.reading=!1,g(e,a);else{var s;o||(s=p(a,t)),s?e.emit("error",s):a.objectMode||t&&0<t.length?("string"!=typeof t&&!a.objectMode&&Object.getPrototypeOf(t)!==F.prototype&&(t=i(t)),r?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):u(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?u(e,a,t,!1):y(e,a)):u(e,a,t,!1))):!r&&(a.reading=!1)}return f(a)}function u(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&_(e)),y(e,t)}function p(e,t){var n;return a(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function f(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function h(e){return 8388608<=e?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function m(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=h(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function g(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,_(e)}}function _(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(W("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U.nextTick(b,e):b(e))}function b(e){W("emit readable"),e.emit("readable"),v(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U.nextTick(w,e,t))}function w(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(W("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function k(e){return function(){var t=e._readableState;W("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&j(e,"data")&&(t.flowing=!0,v(e))}}function x(e){W("readable nexttick read 0"),e.read(0)}function C(e,t){t.resumeScheduled||(t.resumeScheduled=!0,U.nextTick(S,e,t))}function S(e,t){t.reading||(W("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),v(e),t.flowing&&!t.reading&&e.read(0)}function v(e){var t=e._readableState;for(W("flow",t.flowing);t.flowing&&null!==e.read(););}function E(e,t){if(0===t.length)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=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=L(e,t.buffer,t.decoder),n}function L(e,t,n){var r;return e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?r=t.shift():r=n?I(e,t):B(e,t),r}function I(e,t){var r=t.head,o=1,i=r.data;for(e-=i.length;r=r.next;){var a=r.data,s=e>a.length?a.length:e;if(i+=s===a.length?a:a.slice(0,e),e-=s,0===e){s===a.length?(++o,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=a.slice(s));break}++o}return t.length-=o,i}function B(e,t){var r=F.allocUnsafe(e),o=t.head,i=1;for(o.data.copy(r),e-=o.data.length;o=o.next;){var a=o.data,s=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,s),e-=s,0===e){s===a.length?(++i,t.head=o.next?o.next:t.tail=null):(t.head=o,o.data=a.slice(s));break}++i}return t.length-=i,r}function T(e){var t=e._readableState;if(0<t.length)throw new Error("\"endReadable()\" called on non-empty stream");t.endEmitted||(t.ended=!0,U.nextTick(R,t,e))}function R(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function A(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}var U=e("process-nextick-args");t.exports=l;var P=e("isarray"),M;l.ReadableState=d;var O=e("events").EventEmitter,j=function(e,t){return e.listeners(t).length},N=e("./internal/streams/stream"),F=e("safe-buffer").Buffer,H=o.Uint8Array||function(){},q=e("core-util-is");q.inherits=e("inherits");var D=e("util"),W=void 0;W=D&&D.debuglog?D.debuglog("stream"):function(){};var z=e("./internal/streams/BufferList"),V=e("./internal/streams/destroy"),G;q.inherits(l,N);var K=["error","close","destroy","pause","resume"];Object.defineProperty(l.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),l.prototype.destroy=V.destroy,l.prototype._undestroy=V.undestroy,l.prototype._destroy=function(e,t){this.push(null),t(e)},l.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:"string"==typeof e&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=F.from(e,t),t=""),r=!0),c(this,e,t,!1,r)},l.prototype.unshift=function(e){return c(this,e,null,!0,!1)},l.prototype.isPaused=function(){return!1===this._readableState.flowing},l.prototype.setEncoding=function(t){return G||(G=e("string_decoder/").StringDecoder),this._readableState.decoder=new G(t),this._readableState.encoding=t,this};l.prototype.read=function(e){W("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return W("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):_(this),null;if(e=m(e,t),0===e&&t.ended)return 0===t.length&&T(this),null;var o=t.needReadable;W("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&(o=!0,W("length less than watermark",o)),t.ended||t.reading?(o=!1,W("reading or ended",o)):o&&(W("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,!t.reading&&(e=m(r,t)));var i;return i=0<e?E(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(!t.ended&&(t.needReadable=!0),r!==e&&t.ended&&T(this)),null!==i&&this.emit("data",i),i},l.prototype._read=function(){this.emit("error",new Error("_read() is not implemented"))},l.prototype.pipe=function(e,t){function n(e,t){W("onunpipe"),e===p&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,i())}function o(){W("onend"),e.end()}function i(){W("cleanup"),e.removeListener("close",l),e.removeListener("finish",c),e.removeListener("drain",g),e.removeListener("error",d),e.removeListener("unpipe",n),p.removeListener("end",o),p.removeListener("end",u),p.removeListener("data",a),_=!0,f.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&g()}function a(t){W("ondata"),b=!1;var n=e.write(t);!1!==n||b||((1===f.pipesCount&&f.pipes===e||1<f.pipesCount&&-1!==A(f.pipes,e))&&!_&&(W("false write response, pause",p._readableState.awaitDrain),p._readableState.awaitDrain++,b=!0),p.pause())}function d(t){W("onerror",t),u(),e.removeListener("error",d),0===j(e,"error")&&e.emit("error",t)}function l(){e.removeListener("finish",c),u()}function c(){W("onfinish"),e.removeListener("close",l),u()}function u(){W("unpipe"),p.unpipe(e)}var p=this,f=this._readableState;switch(f.pipesCount){case 0:f.pipes=e;break;case 1:f.pipes=[f.pipes,e];break;default:f.pipes.push(e);}f.pipesCount+=1,W("pipe count=%d opts=%j",f.pipesCount,t);var h=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr,m=h?o:u;f.endEmitted?U.nextTick(m):p.once("end",m),e.on("unpipe",n);var g=k(p);e.on("drain",g);var _=!1,b=!1;return p.on("data",a),s(e,"error",d),e.once("close",l),e.once("finish",c),e.emit("pipe",p),f.flowing||(W("pipe resume"),p.resume()),e},l.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};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,n),this);if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<o;a++)r[a].emit("unpipe",this,n);return this}var s=A(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},l.prototype.on=function(e,t){var n=N.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&_(this):U.nextTick(x,this))}return n},l.prototype.addListener=l.prototype.on,l.prototype.resume=function(){var e=this._readableState;return e.flowing||(W("resume"),e.flowing=!0,C(this,e)),this},l.prototype.pause=function(){return W("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(W("pause"),this._readableState.flowing=!1,this.emit("pause")),this},l.prototype.wrap=function(e){var t=this,r=this._readableState,o=!1;for(var a in e.on("end",function(){if(W("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){if((W("wrapped data"),r.decoder&&(n=r.decoder.write(n)),!(r.objectMode&&(null===n||void 0===n)))&&(r.objectMode||n&&n.length)){var i=t.push(n);i||(o=!0,e.pause())}}),e)void 0===this[a]&&"function"==typeof e[a]&&(this[a]=function(t){return function(){return e[t].apply(e,arguments)}}(a));for(var i=0;i<K.length;i++)e.on(K[i],this.emit.bind(this,K[i]));return this._read=function(t){W("wrapped _read",t),o&&(o=!1,e.resume())},this},Object.defineProperty(l.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),l._fromList=E}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./_stream_duplex":18,"./internal/streams/BufferList":23,"./internal/streams/destroy":24,"./internal/streams/stream":25,_process:138,"core-util-is":66,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],21:[function(e,t){"use strict";function n(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function r(e){return this instanceof r?void(a.call(this,e),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",o)):new r(e)}function o(){var e=this;"function"==typeof this._flush?this._flush(function(t,n){i(e,t,n)}):i(this,null,null)}function i(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}t.exports=r;var a=e("./_stream_duplex"),s=e("core-util-is");s.inherits=e("inherits"),s.inherits(r,a),r.prototype.push=function(e,t){return this._transformState.needTransform=!1,a.prototype.push.call(this,e,t)},r.prototype._transform=function(){throw new Error("_transform() is not implemented")},r.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},r.prototype._read=function(){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},r.prototype._destroy=function(e,t){var n=this;a.prototype._destroy.call(this,e,function(e){t(e),n.emit("close")})}},{"./_stream_duplex":18,"core-util-is":66,inherits:87}],22:[function(e,t){(function(r,o,i){"use strict";function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){I(t,e)}}function s(e){return M.from(e)}function d(e){return M.isBuffer(e)||e instanceof O}function l(){}function c(t,r){R=R||e("./_stream_duplex"),t=t||{};var o=r instanceof R;this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,s=t.writableHighWaterMark,d=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o&&(s||0===s)?s:d,this.highWaterMark=n(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function u(t){return R=R||e("./_stream_duplex"),N.call(u,this)||this instanceof R?void(this._writableState=new c(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),P.call(this)):new u(t)}function p(e,t){var n=new Error("write after end");e.emit("error",n),B.nextTick(t,n)}function f(e,t,n,r){var o=!0,i=!1;return null===n?i=new TypeError("May not write null values to stream"):"string"!=typeof n&&void 0!==n&&!t.objectMode&&(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),B.nextTick(r,i),o=!1),o}function h(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=M.from(t,n)),t}function m(e,t,n,r,o,i){if(!n){var a=h(t,r,o);r!==a&&(n=!0,o="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var d=t.length<t.highWaterMark;if(d||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else g(e,t,!1,s,r,o,i);return d}function g(e,t,n,r,o,i,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function _(e,t,n,r,o){--t.pendingcb,n?(B.nextTick(o,r),B.nextTick(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(o(r),e._writableState.errorEmitted=!0,e.emit("error",r),E(e,t))}function b(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function y(e,t){var n=e._writableState,r=n.sync,o=n.writecb;if(b(n),t)_(e,n,r,t,o);else{var i=C(n);i||n.corked||n.bufferProcessing||!n.bufferedRequest||x(e,n),r?T(w,e,n,i,o):w(e,n,i,o)}}function w(e,t,n,r){n||k(e,t),t.pendingcb--,r(),E(e,t)}function k(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function x(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,o=Array(r),i=t.corkedRequestsFree;i.entry=n;for(var s=0,d=!0;n;)o[s]=n,n.isBuf||(d=!1),n=n.next,s+=1;o.allBuffers=d,g(e,t,!0,t.length,o,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,c=n.encoding,u=n.callback,p=t.objectMode?1:l.length;if(g(e,t,!1,p,l,c,u),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function S(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function v(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,B.nextTick(S,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function E(e,t){var n=C(t);return n&&(v(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}function L(e,t,n){t.ending=!0,E(e,t),n&&(t.finished?B.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function I(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}var B=e("process-nextick-args");t.exports=u;var T=!r.browser&&-1<["v0.10","v0.9."].indexOf(r.version.slice(0,5))?i:B.nextTick,R;u.WritableState=c;var A=e("core-util-is");A.inherits=e("inherits");var U={deprecate:e("util-deprecate")},P=e("./internal/streams/stream"),M=e("safe-buffer").Buffer,O=o.Uint8Array||function(){},j=e("./internal/streams/destroy");A.inherits(u,P),c.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(c.prototype,"buffer",{get:U.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var N;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(N=Function.prototype[Symbol.hasInstance],Object.defineProperty(u,Symbol.hasInstance,{value:function(e){return!!N.call(this,e)||!(this!==u)&&e&&e._writableState instanceof c}})):N=function(e){return e instanceof this},u.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},u.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&d(e);return i&&!M.isBuffer(e)&&(e=s(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":!t&&(t=r.defaultEncoding),"function"!=typeof n&&(n=l),r.ended?p(this,n):(i||f(this,r,e,n))&&(r.pendingcb++,o=m(this,r,i,e,t,n)),o},u.prototype.cork=function(){var e=this._writableState;e.corked++},u.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&x(this,e))},u.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),u.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},u.prototype._writev=null,u.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&&e!==void 0&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||L(this,r,n)},Object.defineProperty(u.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),u.prototype.destroy=j.destroy,u.prototype._undestroy=j.undestroy,u.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("timers").setImmediate)},{"./_stream_duplex":18,"./internal/streams/destroy":24,"./internal/streams/stream":25,_process:138,"core-util-is":66,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],23:[function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,n){e.copy(t,n)}var o=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){n(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};0<this.length?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.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},e.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,a=0;n;)r(n.data,t,a),a+=n.data.length,n=n.next;return t},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":177,util:45}],24:[function(e,t){"use strict";function n(e,t){e.emit("error",t)}var r=e("process-nextick-args");t.exports={destroy:function(e,t){var o=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(t?t(e):e&&(!this._writableState||!this._writableState.errorEmitted)&&r.nextTick(n,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(r.nextTick(n,o,e),o._writableState&&(o._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":137}],25:[function(e,t){t.exports=e("events").EventEmitter},{events:48}],26:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js"),n.Stream=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")},{"./lib/_stream_duplex.js":18,"./lib/_stream_passthrough.js":19,"./lib/_stream_readable.js":20,"./lib/_stream_transform.js":21,"./lib/_stream_writable.js":22}],27:[function(e,t){(function(n){function r(e){function t(e){n.nextTick(function(){s.emit("warning",e)})}var s=this;if(!(s instanceof r))return new r(e);if(a.call(s),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");s.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),s._peerIdBuffer=o.from(s.peerId,"hex"),s._peerIdBinary=s._peerIdBuffer.toString("binary"),s.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),s._infoHashBuffer=o.from(s.infoHash,"hex"),s._infoHashBinary=s._infoHashBuffer.toString("binary"),i("new client %s",s.infoHash),s.destroyed=!1,s._port=e.port,s._getAnnounceOpts=e.getAnnounceOpts,s._rtcConfig=e.rtcConfig,s._userAgent=e.userAgent,s._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;var d="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;d=d.map(function(e){return e=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}),d=p(d);var l=!1!==s._wrtc&&(!!s._wrtc||u.WEBRTC_SUPPORT);s._trackers=d.map(function(e){var n=f.parse(e).protocol;return("http:"===n||"https:"===n)&&"function"==typeof m?new m(s,e):"udp:"===n&&"function"==typeof g?new g(s,e):("ws:"===n||"wss:"===n)&&l?"ws:"===n&&"undefined"!=typeof window&&"https:"===window.location.protocol?(t(new Error("Unsupported tracker protocol: "+e)),null):new _(s,e):(t(new Error("Unsupported tracker protocol: "+e)),null)}).filter(Boolean)}t.exports=r;var o=e("safe-buffer").Buffer,i=e("debug")("bittorrent-tracker:client"),a=e("events").EventEmitter,s=e("xtend"),d=e("inherits"),l=e("once"),c=e("run-parallel"),u=e("simple-peer"),p=e("uniq"),f=e("url"),h=e("./lib/common"),m=e("./lib/client/http-tracker"),g=e("./lib/client/udp-tracker"),_=e("./lib/client/websocket-tracker");d(r,a),r.scrape=function(e,t){if(t=l(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");var n=s(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 a=Array.isArray(e.infoHash)?e.infoHash.length:1,d={};return i.on("scrape",function(e){if(a-=1,d[e.infoHash]=e,0===a){i.destroy();var n=Object.keys(d);1===n.length?t(null,d[n[0]]):t(null,d)}}),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)}});c(n,e),t._trackers=[],t._getAnnounceOpts=null}},r.prototype._defaultAnnounceOpts=function(e){var t=this;return e||(e={}),null==e.numwant&&(e.numwant=h.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),t._getAnnounceOpts&&(e=s(e,t._getAnnounceOpts())),e}}).call(this,e("_process"))},{"./lib/client/http-tracker":45,"./lib/client/udp-tracker":45,"./lib/client/websocket-tracker":29,"./lib/common":30,_process:138,debug:31,events:48,inherits:87,once:132,"run-parallel":175,"safe-buffer":177,"simple-peer":180,uniq:236,url:238,xtend:248}],28:[function(e,t){function n(e,t){var n=this;r.call(n),n.client=e,n.announceUrl=t,n.interval=null,n.destroyed=!1}t.exports=n;var r=e("events").EventEmitter,o=e("inherits");o(n,r),n.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:48,inherits:87}],29:[function(e,r){function o(e,t){var n=this;h.call(n,e,t),a("new websocket tracker %s",t),n.peers={},n.socket=null,n.reconnecting=!1,n.retries=0,n.reconnectTimer=null,n.expectingResponse=!1,n._openSocket()}function i(){}r.exports=o;var a=e("debug")("bittorrent-tracker:websocket-tracker"),s=e("xtend"),l=e("inherits"),c=e("simple-peer"),u=e("randombytes"),p=e("simple-websocket"),f=e("../common"),h=e("./tracker"),m={};o._socketPool=m;l(o,h),o.prototype.DEFAULT_ANNOUNCE_INTERVAL=30000,o.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=d(e.numwant,10);t._generateOffers(r,function(e){n.numwant=r,n.offers=e,t._send(n)})}}},o.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)&&0<e.infoHash.length?e.infoHash.map(function(e){return e.toString("binary")}):e.infoHash&&e.infoHash.toString("binary")||t.client._infoHashBinary;t._send({action:"scrape",info_hash:n})}},o.prototype.destroy=function(e){function t(){s&&(clearTimeout(s),s=null),a.removeListener("data",t),a.destroy(),a=null}var n=this;if(e||(e=i),n.destroyed)return e(null);for(var r in n.destroyed=!0,clearInterval(n.interval),clearTimeout(n.reconnectTimer),n.peers){var o=n.peers[r];clearTimeout(o.trackerTimeout),o.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,m[n.announceUrl]&&(m[n.announceUrl].consumers-=1),0<m[n.announceUrl].consumers)return e();var a=m[n.announceUrl];if(delete m[n.announceUrl],a.on("error",i),a.once("close",e),!n.expectingResponse)return t();var s=setTimeout(t,f.DESTROY_TIMEOUT);a.once("data",t)},o.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=m[e.announceUrl],e.socket?m[e.announceUrl].consumers+=1:(e.socket=m[e.announceUrl]=new p(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)},o.prototype._onSocketConnect=function(){var e=this;e.destroyed||e.reconnecting&&(e.reconnecting=!1,e.retries=0,e.announce(e.client._defaultAnnounceOpts()))},o.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))}},o.prototype._onAnnounceResponse=function(e){var t=this;if(e.info_hash!==t.client._infoHashBinary)return void a("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,f.binaryToHex(e.info_hash),t.client.infoHash);if(!(e.peer_id&&e.peer_id===t.client._peerIdBinary)){a("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 i=e["tracker id"];if(i&&(t._trackerId=i),null!=e.complete){var s=Object.assign({},e,{announce:t.announceUrl,infoHash:f.binaryToHex(e.info_hash)});t.client.emit("update",s)}var d;if(e.offer&&e.peer_id&&(a("creating peer (from remote offer)"),d=t._createPeer(),d.id=f.binaryToHex(e.peer_id),d.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)}),d.signal(e.offer),t.client.emit("peer",d)),e.answer&&e.peer_id){var l=f.binaryToHex(e.offer_id);d=t.peers[l],d?(d.id=f.binaryToHex(e.peer_id),d.signal(e.answer),t.client.emit("peer",d),clearTimeout(d.trackerTimeout),d.trackerTimeout=null,delete t.peers[l]):a("got unexpected answer: "+JSON.stringify(e.answer))}}},o.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=Object.assign(e[n],{announce:t.announceUrl,infoHash:f.binaryToHex(n)});t.client.emit("scrape",r)})},o.prototype._onSocketClose=function(){var e=this;e.destroyed||(e.destroy(),e._startReconnectTimer())},o.prototype._onSocketError=function(e){var t=this;t.destroyed||(t.destroy(),t.client.emit("warning",e),t._startReconnectTimer())},o.prototype._startReconnectTimer=function(){var e=this,r=n(Math.random()*30000)+d(t(2,e.retries)*15000,1800000);e.reconnecting=!0,clearTimeout(e.reconnectTimer),e.reconnectTimer=setTimeout(function(){e.retries++,e._openSocket()},r),e.reconnectTimer.unref&&e.reconnectTimer.unref(),a("reconnecting socket in %s ms",r)},o.prototype._send=function(e){var t=this;if(!t.destroyed){t.expectingResponse=!0;var n=JSON.stringify(e);a("send %s",n),t.socket.send(n)}},o.prototype._generateOffers=function(e,t){function n(){var e=u(20).toString("hex");a("creating peer (from _generateOffers)");var t=o.peers[e]=o._createPeer({initiator:!0});t.once("signal",function(t){s.push({offer:t,offer_id:f.hexToBinary(e)}),r()}),t.trackerTimeout=setTimeout(function(){a("tracker timeout: destroying peer"),t.trackerTimeout=null,delete o.peers[e],t.destroy()},50000),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function r(){s.length===e&&(a("generated %s offers",e),t(s))}var o=this,s=[];a("generating %s offers",e);for(var d=0;d<e;++d)n();r()},o.prototype._createPeer=function(e){function t(e){r.client.emit("warning",new Error("Connection error: "+e.message)),o.destroy()}function n(){o.removeListener("error",t),o.removeListener("connect",n)}var r=this;e=Object.assign({trickle:!1,config:r.client._rtcConfig,wrtc:r.client._wrtc},e);var o=new c(e);return o.once("error",t),o.once("connect",n),o}},{"../common":30,"./tracker":28,debug:31,inherits:87,randombytes:145,"simple-peer":180,"simple-websocket":194,xtend:248}],30:[function(e,t,n){var r=e("safe-buffer").Buffer,o=e("xtend/mutable");n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=function(e){return"string"!=typeof e&&(e+=""),r.from(e,"binary").toString("hex")},n.hexToBinary=function(e){return"string"!=typeof e&&(e+=""),r.from(e,"hex").toString("binary")};var i=e("./common-node");o(n,i)},{"./common-node":45,"safe-buffer":177,"xtend/mutable":249}],31:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./common":32,_process:138,dup:15}],32:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:33}],33:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],34:[function(e,t){(function(n){t.exports=function(e,t){function r(i){o.removeEventListener("loadend",r,!1),i.error?t(i.error):t(null,n.from(o.result))}if("undefined"==typeof Blob||!(e instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof t)throw new Error("second argument must be a function");var o=new FileReader;o.addEventListener("loadend",r,!1),o.readAsArrayBuffer(e)}}).call(this,e("buffer").Buffer)},{buffer:47}],35:[function(e,t){(function(n){function r(e,t){return this instanceof r?void(i.call(this),!t&&(t={}),"object"==typeof e&&(t=e,e=t.size),this.size=e||512,this._zeroPadding=!t.nopad&&a(t.zeroPadding,!0),this._buffered=[],this._bufferedBytes=0):new r(e,t)}var o=e("inherits"),i=e("readable-stream").Transform,a=e("defined");t.exports=r,o(r,i),r.prototype._transform=function(e,t,r){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=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:47,defined:71,inherits:87,"readable-stream":44}],36:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":38,"./_stream_writable":40,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],37:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":39,"core-util-is":66,dup:19,inherits:87}],38:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":36,"./internal/streams/BufferList":41,"./internal/streams/destroy":42,"./internal/streams/stream":43,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],39:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":36,"core-util-is":66,dup:21,inherits:87}],40:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":36,"./internal/streams/destroy":42,"./internal/streams/stream":43,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],41:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],42:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],43:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],44:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":36,"./lib/_stream_passthrough.js":37,"./lib/_stream_readable.js":38,"./lib/_stream_transform.js":39,"./lib/_stream_writable.js":40,dup:26}],45:[function(){},{}],46:[function(e,t,n){arguments[4][45][0].apply(n,arguments)},{dup:45}],47:[function(e,n,r){/*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */"use strict";function a(e){if(2147483647<e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"");var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError("The \"string\" argument must be of type string. Received type number");return p(e)}return l(e,t,n)}function l(e,t,n){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return h(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return m(e,t,n);if("number"==typeof e)throw new TypeError("The \"value\" argument must not be of type number. Received type number");var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return s.from(r,t,n);var o=g(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be of type number");else if(0>e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"")}function u(e,t,n){return c(e),0>=e?a(e):void 0===t?a(e):"string"==typeof n?a(e).fill(t,n):a(e).fill(t)}function p(e){return c(e),a(0>e?0:0|_(e))}function f(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|b(e,t),r=a(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function h(e){for(var t=0>e.length?0:0|_(e.length),n=a(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function m(e,t,n){if(0>t||e.byteLength<t)throw new RangeError("\"offset\" is outside of buffer bounds");if(e.byteLength<t+(n||0))throw new RangeError("\"length\" is outside of buffer bounds");var r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),r.__proto__=s.prototype,r}function g(e){if(s.isBuffer(e)){var t=0|_(e.length),n=a(t);return 0===n.length?n:(e.copy(n,0,0,t),n)}return void 0===e.length?"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0:"number"!=typeof e.length||X(e.length)?a(0):h(e)}function _(e){if(e>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647 .toString(16)+" bytes");return 0|e}function b(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type "+typeof e);var n=e.length,r=2<arguments.length&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":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 G(e).length;default:if(o)return r?-1:W(e).length;t=(""+t).toLowerCase(),o=!0;}}function y(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return A(this,t,n);case"latin1":case"binary":return U(this,t,n);case"base64":return B(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0;}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647<n?n=2147483647:-2147483648>n&&(n=-2147483648),n=+n,X(n)&&(n=o?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(0>n)if(o)n=0;else return-1;if("string"==typeof t&&(t=s.from(t,r)),s.isBuffer(t))return 0===t.length?-1:x(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):x(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function x(e,t,n,r,o){function a(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,d=e.length,l=t.length;if(void 0!==r&&(r=(r+"").toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>e.length||2>t.length)return-1;s=2,d/=2,l/=2,n/=2}var c;if(o){var u=-1;for(c=n;c<d;c++)if(a(e,c)!==a(t,-1===u?0:c-u))-1!==u&&(c-=c-u),u=-1;else if(-1===u&&(u=c),c-u+1===l)return u*s}else for(n+l>d&&(n=d-l),c=n;0<=c;c--){for(var p=!0,f=0;f<l;f++)if(a(e,c+f)!==a(t,f)){p=!1;break}if(p)return c}return-1}function C(e,t,n,r){n=+n||0;var o=e.length-n;r?(r=+r,r>o&&(r=o)):r=o;var a=t.length;r>a/2&&(r=a/2);for(var s=0,d;s<r;++s){if(d=parseInt(t.substr(2*s,2),16),X(d))return s;e[n+s]=d}return s}function S(e,t,n,r){return K(W(t,e.length-n),e,n,r)}function v(e,t,n,r){return K(z(t),e,n,r)}function E(e,t,n,r){return v(e,t,n,r)}function L(e,t,n,r){return K(G(t),e,n,r)}function I(e,t,n,r){return K(V(t,e.length-n),e,n,r)}function B(e,t,n){return 0===t&&n===e.length?$.fromByteArray(e):$.fromByteArray(e.slice(t,n))}function T(e,t,n){n=d(e.length,n);for(var r=[],o=t;o<n;){var a=e[o],s=null,l=239<a?4:223<a?3:191<a?2:1;if(o+l<=n){var c,u,p,f;1===l?128>a&&(s=a):2===l?(c=e[o+1],128==(192&c)&&(f=(31&a)<<6|63&c,127<f&&(s=f))):3===l?(c=e[o+1],u=e[o+2],128==(192&c)&&128==(192&u)&&(f=(15&a)<<12|(63&c)<<6|63&u,2047<f&&(55296>f||57343<f)&&(s=f))):4===l?(c=e[o+1],u=e[o+2],p=e[o+3],128==(192&c)&&128==(192&u)&&128==(192&p)&&(f=(15&a)<<18|(63&c)<<12|(63&u)<<6|63&p,65535<f&&1114112>f&&(s=f))):void 0}null===s?(s=65533,l=1):65535<s&&(s-=65536,r.push(55296|1023&s>>>10),s=56320|1023&s),r.push(s),o+=l}return R(r)}function R(e){var t=e.length;if(t<=4096)return o.apply(String,e);for(var n="",r=0;r<t;)n+=o.apply(String,e.slice(r,r+=4096));return n}function A(e,t,n){var r="";n=d(e.length,n);for(var a=t;a<n;++a)r+=o(127&e[a]);return r}function U(e,t,n){var r="";n=d(e.length,n);for(var a=t;a<n;++a)r+=o(e[a]);return r}function P(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",a=t;a<n;++a)o+=D(e[a]);return o}function M(e,t,n){for(var r=e.slice(t,n),a="",s=0;s<r.length;s+=2)a+=o(r[s]+256*r[s+1]);return a}function O(e,t,n){if(0!=e%1||0>e)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,n,r,o,i){if(!s.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>o||t<i)throw new RangeError("\"value\" argument is out of bounds");if(n+r>e.length)throw new RangeError("Index out of range")}function N(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function F(e,t,n,r,o){return t=+t,n>>>=0,o||N(e,t,n,4,34028234663852886e22,-34028234663852886e22),J.write(e,t,n,r,23,4),n+4}function H(e,t,n,r,o){return t=+t,n>>>=0,o||N(e,t,n,8,17976931348623157e292,-17976931348623157e292),J.write(e,t,n,r,52,8),n+8}function q(e){if(e=e.split("=")[0],e=e.trim().replace(Q,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function D(e){return 16>e?"0"+e.toString(16):e.toString(16)}function W(e,t){t=t||1/0;for(var n=e.length,r=null,o=[],a=0,s;a<n;++a){if(s=e.charCodeAt(a),55295<s&&57344>s){if(!r){if(56319<s){-1<(t-=3)&&o.push(239,191,189);continue}else if(a+1===n){-1<(t-=3)&&o.push(239,191,189);continue}r=s;continue}if(56320>s){-1<(t-=3)&&o.push(239,191,189),r=s;continue}s=(r-55296<<10|s-56320)+65536}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,128>s){if(0>(t-=1))break;o.push(s)}else if(2048>s){if(0>(t-=2))break;o.push(192|s>>6,128|63&s)}else if(65536>s){if(0>(t-=3))break;o.push(224|s>>12,128|63&s>>6,128|63&s)}else if(1114112>s){if(0>(t-=4))break;o.push(240|s>>18,128|63&s>>12,128|63&s>>6,128|63&s)}else throw new Error("Invalid code point")}return o}function z(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function V(e,t){for(var n=[],r=0,o,a,s;r<e.length&&!(0>(t-=2));++r)o=e.charCodeAt(r),a=o>>8,s=o%256,n.push(s),n.push(a);return n}function G(e){return $.toByteArray(q(e))}function K(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!==e}var $=e("base64-js"),J=e("ieee754");r.Buffer=s,r.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},r.INSPECT_MAX_BYTES=50;r.kMaxLength=2147483647,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(t){return!1}}(),s.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."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){return s.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){return s.isBuffer(this)?this.byteOffset:void 0}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,n){return l(e,t,n)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,n){return u(e,t,n)},s.allocUnsafe=function(e){return p(e)},s.allocUnsafeSlow=function(e){return p(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,l=d(n,r);o<l;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},s.isEncoding=function(e){switch((e+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1;}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError("\"list\" argument must be an Array of Buffers");if(0===e.length)return s.alloc(0);var n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=s.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var a=e[n];if(Y(a,Uint8Array)&&(a=s.from(a)),!s.isBuffer(a))throw new TypeError("\"list\" argument must be an Array of Buffers");a.copy(r,o),o+=a.length}return r},s.byteLength=b,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(0!=e%2)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(0!=e%4)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(0!=e%8)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):y.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s.prototype.compare=function(e,t,n,r,o){if(Y(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type "+typeof e);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),0>t||n>e.length||0>r||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 a=o-r,l=n-t,c=d(a,l),u=this.slice(r,o),p=e.slice(t,n),f=0;f<c;++f)if(u[f]!==p[f]){a=u[f],l=p[f];break}return a<l?-1:l<a?1:0},s.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},s.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},s.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-t;if((void 0===n||n>o)&&(n=o),0<e.length&&(0>n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return C(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return v(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return L(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0;}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};s.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return r.__proto__=s.prototype,r},s.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],o=1,a=0;++a<t&&(o*=256);)r+=this[e+a]*o;return r},s.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e+--t],o=1;0<t&&(o*=256);)r+=this[e+--t]*o;return r},s.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},s.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]},s.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])},s.prototype.readIntLE=function(e,n,r){e>>>=0,n>>>=0,r||O(e,n,this.length);for(var o=this[e],a=1,s=0;++s<n&&(a*=256);)o+=this[e+s]*a;return a*=128,o>=a&&(o-=t(2,8*n)),o},s.prototype.readIntBE=function(e,n,r){e>>>=0,n>>>=0,r||O(e,n,this.length);for(var o=n,a=1,s=this[e+--o];0<o&&(a*=256);)s+=this[e+--o]*a;return a*=128,s>=a&&(s-=t(2,8*n)),s},s.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.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},s.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},s.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},s.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]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),J.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),J.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),J.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),J.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,n,r,o){if(e=+e,n>>>=0,r>>>=0,!o){var a=t(2,8*r)-1;j(this,e,n,r,a,0)}var s=1,d=0;for(this[n]=255&e;++d<r&&(s*=256);)this[n+d]=255&e/s;return n+r},s.prototype.writeUIntBE=function(e,n,r,o){if(e=+e,n>>>=0,r>>>=0,!o){var a=t(2,8*r)-1;j(this,e,n,r,a,0)}var s=r-1,d=1;for(this[n+s]=255&e;0<=--s&&(d*=256);)this[n+s]=255&e/d;return n+r},s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||j(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},s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||j(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},s.prototype.writeIntLE=function(e,n,r,o){if(e=+e,n>>>=0,!o){var a=t(2,8*r-1);j(this,e,n,r,a-1,-a)}var s=0,d=1,l=0;for(this[n]=255&e;++s<r&&(d*=256);)0>e&&0===l&&0!==this[n+s-1]&&(l=1),this[n+s]=255&(e/d>>0)-l;return n+r},s.prototype.writeIntBE=function(e,n,r,o){if(e=+e,n>>>=0,!o){var a=t(2,8*r-1);j(this,e,n,r,a-1,-a)}var s=r-1,d=1,l=0;for(this[n+s]=255&e;0<=--s&&(d*=256);)0>e&&0===l&&0!==this[n+s+1]&&(l=1),this[n+s]=255&(e/d>>0)-l;return n+r},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||j(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},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||j(this,e,t,4,2147483647,-2147483648),0>e&&(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},s.prototype.writeFloatLE=function(e,t,n){return F(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return F(this,e,t,!1,n)},s.prototype.writeDoubleLE=function(e,t,n){return H(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return H(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),0<r&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var a=o-1;0<=a;--a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return o},s.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&128>o||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(0>t||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a<n;++a)this[a]=e;else{var d=s.isBuffer(e)?e:s.from(e,r),l=d.length;if(0===l)throw new TypeError("The value \""+e+"\" is invalid for argument \"value\"");for(a=0;a<n-t;++a)this[a+t]=d[a%l]}return this};var Q=/[^+/0-9A-Za-z-_]/g},{"base64-js":8,ieee754:85}],48:[function(e,t){function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=y(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function r(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function a(e,t,n){if(t)e.call(n);else for(var r=e.length,o=_(e,r),a=0;a<r;++a)o[a].call(n)}function s(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,a=_(e,o),s=0;s<o;++s)a[s].call(n,r)}function d(e,t,n,r,o){if(t)e.call(n,r,o);else for(var a=e.length,s=_(e,a),d=0;d<a;++d)s[d].call(n,r,o)}function l(e,t,n,r,o,a){if(t)e.call(n,r,o,a);else for(var s=e.length,d=_(e,s),l=0;l<s;++l)d[l].call(n,r,o,a)}function c(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,a=_(e,o),s=0;s<o;++s)a[s].apply(n,r)}function u(e,t,n,o){var i,a,s;if("function"!=typeof n)throw new TypeError("\"listener\" argument must be a function");if(a=e._events,a?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),s=a[t]):(a=e._events=y(null),e._eventsCount=0),!s)s=a[t]=n,++e._eventsCount;else if("function"==typeof s?s=a[t]=o?[n,s]:[s,n]:o?s.unshift(n):s.push(n),!s.warned&&(i=r(e),i&&0<i&&s.length>i)){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" \""+(t+"\" listeners added. Use emitter.setMaxListeners() to increase limit."));d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",d.name,d.message)}return e}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e);}}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=k.call(p,r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?b(o):_(o,o.length):[]}function m(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(e,t){for(var r=t,o=r+1,a=e.length;o<a;r+=1,o+=1)e[r]=e[o];e.pop()}function _(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function b(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}var y=Object.create||function(e){var t=function(){};return t.prototype=e,new t},w=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},k=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0;var x=10,C;try{var S={};Object.defineProperty&&Object.defineProperty(S,"x",{value:0}),C=0===S.x}catch(e){C=!1}C?Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return x},set:function(e){if("number"!=typeof e||0>e||e!==e)throw new TypeError("\"defaultMaxListeners\" must be a positive number");x=e}}):n.defaultMaxListeners=x,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||0>e||isNaN(e))throw new TypeError("\"n\" argument must be a positive number");return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return r(this)},n.prototype.emit=function(e){var t="error"===e,n,r,o,u,p,f;if(f=this._events,f)t=t&&null==f.error;else if(!t)return!1;if(t){if(1<arguments.length&&(n=arguments[1]),n instanceof Error)throw n;else{var h=new Error("Unhandled \"error\" event. ("+n+")");throw h.context=n,h}return!1}if(r=f[e],!r)return!1;var m="function"==typeof r;switch(o=arguments.length,o){case 1:a(r,m,this);break;case 2:s(r,m,this,arguments[1]);break;case 3:d(r,m,this,arguments[1],arguments[2]);break;case 4:l(r,m,this,arguments[1],arguments[2],arguments[3]);break;default:for(u=Array(o-1),p=1;p<o;p++)u[p-1]=arguments[p];c(r,m,this,u);}return!0},n.prototype.addListener=function(e,t){return u(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return u(this,e,t,!0)},n.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");return this.on(e,f(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");return this.prependListener(e,f(this,e,t)),this},n.prototype.removeListener=function(e,t){var n,r,o,a,s;if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");if(r=this._events,!r)return this;if(n=r[e],!n)return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=y(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,a=n.length-1;0<=a;a--)if(n[a]===t||n[a].listener===t){s=n[a].listener,o=a;break}if(0>o)return this;0===o?n.shift():g(n,o),1===n.length&&(r[e]=n[0]),r.removeListener&&this.emit("removeListener",e,s||t)}return this},n.prototype.removeAllListeners=function(e){var t,n,r;if(n=this._events,!n)return this;if(!n.removeListener)return 0===arguments.length?(this._events=y(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=y(null):delete n[e]),this;if(0===arguments.length){var o=w(n),a;for(r=0;r<o.length;++r)a=o[r],"removeListener"===a||this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=y(null),this._eventsCount=0,this}if(t=n[e],"function"==typeof t)this.removeListener(e,t);else if(t)for(r=t.length-1;0<=r;r--)this.removeListener(e,t[r]);return this},n.prototype.listeners=function(e){return h(this,e,!0)},n.prototype.rawListeners=function(e){return h(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},n.prototype.listenerCount=m,n.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],49:[function(e,t){function n(e){if("string"==typeof e&&(e=o.parse(e)),e.protocol||(e.protocol="https:"),"https:"!==e.protocol)throw new Error("Protocol \""+e.protocol+"\" not supported. Expected \"https:\"");return e}var r=e("http"),o=e("url"),i=t.exports;for(var a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);i.request=function(e,t){return e=n(e),r.request.call(this,e,t)},i.get=function(e,t){return e=n(e),r.get.call(this,e,t)}},{http:208,url:238}],50:[function(e,t){(function(e){t.exports=function(t){if("number"!=typeof t)throw new TypeError("\"size\" argument must be a number");if(0>t)throw new RangeError("\"size\" argument must not be negative");return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this,e("buffer").Buffer)},{buffer:47}],51:[function(e,t){(function(n){var r=e("buffer-fill"),o=e("buffer-alloc-unsafe");t.exports=function(e,t,i){if("number"!=typeof e)throw new TypeError("\"size\" argument must be a number");if(0>e)throw new RangeError("\"size\" argument must not be negative");if(n.alloc)return n.alloc(e,t,i);var a=o(e);return 0===e?a:void 0===t?r(a,0):("string"!=typeof i&&(i=void 0),r(a,t,i))}}).call(this,e("buffer").Buffer)},{buffer:47,"buffer-alloc-unsafe":50,"buffer-fill":52}],52:[function(e,t){(function(e){function n(e){return 1===e.length&&256>e.charCodeAt(0)}function r(e,t,n,r){if(0>n||r>e.length)throw new RangeError("Out of range index");return n>>>=0,r=void 0===r?e.length:r>>>0,r>n&&e.fill(t,n,r),e}function o(e,t,n,r){if(0>n||r>e.length)throw new RangeError("Out of range index");if(r<=n)return e;n>>>=0,r=void 0===r?e.length:r>>>0;for(var o=n,i=t.length;o<=r-i;)t.copy(e,o),o+=i;return o!==r&&t.copy(e,o,0,r-o),e}var i=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(e){return!1}}();t.exports=function(t,a,s,d,l){if(i)return t.fill(a,s,d,l);if("number"==typeof a)return r(t,a,s,d);if("string"==typeof a){if("string"==typeof s?(l=s,s=0,d=t.length):"string"==typeof d&&(l=d,d=t.length),void 0!==l&&"string"!=typeof l)throw new TypeError("encoding must be a string");if("latin1"===l&&(l="binary"),"string"==typeof l&&!e.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(""===a)return r(t,0,s,d);if(n(a))return r(t,a.charCodeAt(0),s,d);a=new e(a,l)}return e.isBuffer(a)?o(t,a,s,d):r(t,0,s,d)}}).call(this,e("buffer").Buffer)},{buffer:47}],53:[function(e,t){(function(e){function n(e){return"ArrayBuffer"===i.call(e).slice(8,-1)}function r(t,n,r){n>>>=0;var o=t.byteLength-n;if(0>o)throw new RangeError("'offset' is out of bounds");if(void 0===r)r=o;else if(r>>>=0,r>o)throw new RangeError("'length' is out of bounds");return a?e.from(t.slice(n,n+r)):new e(new Uint8Array(t.slice(n,n+r)))}function o(t,n){if(("string"!=typeof n||""===n)&&(n="utf8"),!e.isEncoding(n))throw new TypeError("\"encoding\" must be a valid string encoding");return a?e.from(t,n):new e(t,n)}var i=Object.prototype.toString,a="function"==typeof e.alloc&&"function"==typeof e.allocUnsafe&&"function"==typeof e.from;t.exports=function(t,i,s){if("number"==typeof t)throw new TypeError("\"value\" argument must not be a number");return n(t)?r(t,i,s):"string"==typeof t?o(t,i):a?e.from(t):new e(t)}}).call(this,e("buffer").Buffer)},{buffer:47}],54:[function(e,t){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],55:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":57,"./_stream_writable":59,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],56:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":58,"core-util-is":66,dup:19,inherits:87}],57:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":55,"./internal/streams/BufferList":60,"./internal/streams/destroy":61,"./internal/streams/stream":62,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],58:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":55,"core-util-is":66,dup:21,inherits:87}],59:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":55,"./internal/streams/destroy":61,"./internal/streams/stream":62,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],60:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],61:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],62:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],63:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":55,"./lib/_stream_passthrough.js":56,"./lib/_stream_readable.js":57,"./lib/_stream_transform.js":58,"./lib/_stream_writable.js":59,dup:26}],64:[function(e,t){const n=e("block-stream2"),r=e("readable-stream");class o extends r.Writable{constructor(e,t,r={}){if(super(r),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(t=+t,!t)throw new Error("Second argument must be a chunk length");this._blockstream=new n(t,{zeroPadding:!1});let o=0;const i=t=>{this.destroyed||(e.put(o,t),o+=1)};this._blockstream.on("data",i).on("error",e=>{this.destroy(e)}),this.on("finish",()=>this._blockstream.end())}_write(e,t,n){this._blockstream.write(e,t,n)}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}}t.exports=o},{"block-stream2":35,"readable-stream":63}],65:[function(e,t){t.exports=function(e,t,n){for(var o=1/0,a=0,s=t.length-1,d,l,c;a<=s&&(d=a+(s-a>>1),c=t[d]-e,0>c?a=d+1:0<c?s=d-1:void 0,c=r(c),c<o&&(o=c,l=d),t[d]!==e););return n?l:t[l]}},{}],66:[function(e,t,n){(function(e){function t(e){return Object.prototype.toString.call(e)}n.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},n.isBoolean=function(e){return"boolean"==typeof e},n.isNull=function(e){return null===e},n.isNullOrUndefined=function(e){return null==e},n.isNumber=function(e){return"number"==typeof e},n.isString=function(e){return"string"==typeof e},n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=function(e){return void 0===e},n.isRegExp=function(e){return"[object RegExp]"===t(e)},n.isObject=function(e){return"object"==typeof e&&null!==e},n.isDate=function(e){return"[object Date]"===t(e)},n.isError=function(n){return"[object Error]"===t(n)||n instanceof Error},n.isFunction=function(e){return"function"==typeof e},n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e},n.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":89}],67:[function(e,t){(function(n,r,o){function i(e,t,r){function i(){A(e.map(e=>t=>{const n={};if(h(e))n.getStream=_(e),n.length=e.size;else if(o.isBuffer(e))n.getStream=b(e),n.length=e.length;else if(g(e))n.getStream=w(e,n),n.length=0;else{if("string"==typeof e){if("function"!=typeof L.stat)throw new Error("filesystem paths do not work in the browser");const n=1<d||l;return void s(e,n,t)}throw new Error("invalid input type")}n.path=e.path,t(null,n)}),(e,t)=>e?r(e):void(t=E(t),r(null,t,l)))}if(m(e)&&(e=Array.from(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");e.forEach(e=>{if(null==e)throw new Error(`invalid input type: ${e}`)}),e=e.map(e=>h(e)&&"string"==typeof e.path&&"function"==typeof L.stat?e.path:e),1!==e.length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);let a=null;e.forEach((t,n)=>{if("string"==typeof t)return;let r=t.fullPath||t.name;r||(r=`Unknown File ${n+1}`,t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),2>t.path.length?a=null:0===n&&1<e.length?a=t.path[0]:t.path[0]!==a&&(a=null)}),e=e.filter(e=>{if("string"==typeof e)return!0;const t=e.path[e.path.length-1];return c(t)&&B.not(t)}),a&&e.forEach(e=>{const t=(o.isBuffer(e)||g(e))&&!e.path;"string"==typeof e||t||e.path.shift()}),!t.name&&a&&(t.name=a),t.name||e.some(e=>"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()}`);const d=e.reduce((e,t)=>e+ +("string"==typeof t),0);let l=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof L.stat)throw new Error("filesystem paths do not work in the browser");I(e[0],(e,t)=>e?r(e):void(l=t,i()))}else n.nextTick(()=>{i()})}function s(e,t,n){l(e,d,(r,o)=>r?n(r):void(o=Array.isArray(o)?E(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(t=>{t.getStream=y(t.path),t.path=t.path.replace(e,"").split(S.sep)}),n(null,o)))}function d(e,t){t=R(t),L.stat(e,(n,r)=>{if(n)return t(n);const o={length:r.size,path:e};t(null,o)})}function l(e,t,n){L.stat(e,(r,o)=>r?n(r):void(o.isDirectory()?L.readdir(e,(r,o)=>r?n(r):void A(o.filter(c).filter(B.not).map(n=>r=>{l(S.join(e,n),t,r)}),n)):o.isFile()&&t(e,n)))}function c(e){return"."!==e[0]}function u(e,t,n){function r(e){c+=e.length;const t=f;U(e,e=>{l[t]=e,p-=1,d()}),p+=1,f+=1}function i(){h=!0,d()}function a(e){s(),n(e)}function s(){m.removeListener("error",a),g.removeListener("data",r),g.removeListener("end",i),g.removeListener("error",a)}function d(){h&&0==p&&(s(),n(null,o.from(l.join(""),"hex"),c))}n=R(n);const l=[];let c=0;const u=e.map(e=>e.getStream);let p=0,f=0,h=!1;const m=new T(u),g=new x(t,{zeroPadding:!1});m.on("error",a),m.pipe(g).on("data",r).on("end",i).on("error",a)}function p(e,n,o){let i=n.announceList;i||("string"==typeof n.announce?i=[[n.announce]]:Array.isArray(n.announce)&&(i=n.announce.map(e=>[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(e=>[e])))),n.announce===void 0&&n.announceList===void 0&&(i=i.concat(t.exports.announceList)),"string"==typeof n.urlList&&(n.urlList=[n.urlList]);const s={info:{name:n.name},"creation date":a((+n.creationDate||Date.now())/1e3),encoding:"UTF-8"};0!==i.length&&(s.announce=i[0][0],s["announce-list"]=i),n.comment!==void 0&&(s.comment=n.comment),n.createdBy!==void 0&&(s["created by"]=n.createdBy),n.private!==void 0&&(s.info.private=+n.private),n.sslCert!==void 0&&(s.info["ssl-cert"]=n.sslCert),n.urlList!==void 0&&(s["url-list"]=n.urlList);const d=n.pieceLength||C(e.reduce(f,0));s.info["piece length"]=d,u(e,d,(t,r,i)=>t?o(t):void(s.info.pieces=r,e.forEach(e=>{delete e.getStream}),n.singleFileTorrent?s.info.length=i:s.info.files=e,o(null,k.encode(s))))}function f(e,t){return e+t.length}function h(e){return"undefined"!=typeof Blob&&e instanceof Blob}function m(e){return"undefined"!=typeof FileList&&e instanceof FileList}function g(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function _(e){return()=>new v(e)}function b(e){return()=>{const t=new P.PassThrough;return t.end(e),t}}function y(e){return()=>L.createReadStream(e)}function w(e,t){return()=>{const n=new P.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}const k=e("bencode"),x=e("block-stream2"),C=e("piece-length"),S=e("path"),v=e("filestream/read"),E=e("flatten"),L=e("fs"),I=e("is-file"),B=e("junk"),T=e("multistream"),R=e("once"),A=e("run-parallel"),U=e("simple-sha1"),P=e("readable-stream");t.exports=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},i(e,t,(e,r,o)=>e?n(e):void(t.singleFileTorrent=o,p(r,t,n)))},t.exports.parseInput=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},i(e,t,n)},t.exports.announceList=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]]}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{_process:138,bencode:11,"block-stream2":35,buffer:47,"filestream/read":82,flatten:83,fs:46,"is-file":90,junk:93,multistream:121,once:132,path:135,"piece-length":136,"readable-stream":168,"run-parallel":175,"simple-sha1":193}],68:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],69:[function(e,t,n){(function(o){function i(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}n.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"===e||(r++,"%c"===e&&(o=r))}),e.splice(o,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=i,n.useColors=function(){return!!("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(n);const{formatters:a}=t.exports;a.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":70,_process:138}],70:[function(e,t){t.exports=function(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return o.colors[r(t)%o.colors.length]}function o(e){function t(...e){if(!t.enabled)return;const n=t,i=+new Date,a=i-(r||i);n.diff=a,n.prev=r,n.curr=i,r=i,e[0]=o.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if("%%"===t)return t;s++;const i=o.formatters[r];if("function"==typeof i){const r=e[s];t=i.call(n,r),e.splice(s,1),s--}return t}),o.formatArgs.call(n,e);const d=n.log||o.log;d.apply(n,e)}let r;return t.namespace=e,t.enabled=o.enabled(e),t.useColors=o.useColors(),t.color=n(e),t.destroy=i,t.extend=a,"function"==typeof o.init&&o.init(t),o.instances.push(t),t}function i(){const e=o.instances.indexOf(this);return-1!==e&&(o.instances.splice(e,1),!0)}function a(e,t){return o(this.namespace+("undefined"==typeof t?":":t)+e)}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return o.debug=o,o.default=o,o.coerce=function(e){return e instanceof Error?e.stack||e.message:e},o.disable=function(){const e=[...o.names.map(s),...o.skips.map(s).map(e=>"-"+e)].join(",");return o.enable(""),e},o.enable=function(e){o.save(e),o.names=[],o.skips=[];let t;const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(t=0;t<r;t++)n[t]&&(e=n[t].replace(/\*/g,".*?"),"-"===e[0]?o.skips.push(new RegExp("^"+e.substr(1)+"$")):o.names.push(new RegExp("^"+e+"$")));for(t=0;t<o.instances.length;t++){const e=o.instances[t];e.enabled=o.enabled(e.namespace)}},o.enabled=function(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=o.skips.length;t<n;t++)if(o.skips[t].test(e))return!1;for(t=0,n=o.names.length;t<n;t++)if(o.names[t].test(e))return!0;return!1},o.humanize=e("ms"),Object.keys(t).forEach(e=>{o[e]=t[e]}),o.instances=[],o.names=[],o.skips=[],o.formatters={},o.selectColor=n,o.enable(o.load()),o}},{ms:68}],71:[function(e,t){t.exports=function(){for(var e=0;e<arguments.length;e++)if(arguments[e]!==void 0)return arguments[e]}},{}],72:[function(e,t){var n=e("once"),r=function(){},o=function(e){return e.setHeader&&"function"==typeof e.abort},i=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,s){if("function"==typeof t)return a(e,null,t);t||(t={}),s=n(s||r);var d=e._writableState,l=e._readableState,c=t.readable||!1!==t.readable&&e.readable,u=t.writable||!1!==t.writable&&e.writable,p=function(){e.writable||f()},f=function(){u=!1,c||s.call(e)},h=function(){c=!1,u||s.call(e)},m=function(t){s.call(e,t?new Error("exited with error code: "+t):null)},g=function(t){s.call(e,t)},_=function(){return c&&!(l&&l.ended)?s.call(e,new Error("premature close")):u&&!(d&&d.ended)?s.call(e,new Error("premature close")):void 0},b=function(){e.req.on("finish",f)};return o(e)?(e.on("complete",f),e.on("abort",_),e.req?b():e.on("request",b)):u&&!d&&(e.on("end",p),e.on("close",p)),i(e)&&e.on("exit",m),e.on("end",h),e.on("finish",f),!1!==t.error&&e.on("error",g),e.on("close",_),function(){e.removeListener("complete",f),e.removeListener("abort",_),e.removeListener("request",b),e.req&&e.req.removeListener("finish",f),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",f),e.removeListener("exit",m),e.removeListener("end",h),e.removeListener("error",g),e.removeListener("close",_)}};t.exports=a},{once:132}],73:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":75,"./_stream_writable":77,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],74:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":76,"core-util-is":66,dup:19,inherits:87}],75:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":73,"./internal/streams/BufferList":78,"./internal/streams/destroy":79,"./internal/streams/stream":80,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],76:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":73,"core-util-is":66,dup:21,inherits:87}],77:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":73,"./internal/streams/destroy":79,"./internal/streams/stream":80,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],78:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],79:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],80:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],81:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":73,"./lib/_stream_passthrough.js":74,"./lib/_stream_readable.js":75,"./lib/_stream_transform.js":76,"./lib/_stream_writable.js":77,dup:26}],82:[function(e,t){function n(e,t){var o=this;return this instanceof n?void(t=t||{},r.call(this,t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||s(this._size/1e3,204800),this.reader=new FileReader,this._generateHeaderBlocks(e,t,function(e,t){return e?o.emit("error",e):void(Array.isArray(t)&&t.forEach(function(e){o.push(e)}),o._ready=!0,o.emit("_ready"))})):new n(e,t)}var r=e("readable-stream").Readable,o=e("inherits"),i=/^.*\.(\w+)$/,a=e("typedarray-to-buffer");o(n,r),t.exports=n,n.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])},n.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)):void(t.onload=function(){e._offset=r,e.push(a(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(n,r)))},n.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(t){}}this.reader=null}},{inherits:87,"readable-stream":81,"typedarray-to-buffer":234}],83:[function(e,t){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,o){return Array.isArray(o)&&r<t?e.concat(n(o,r+1)):e.concat(o)},[])}return t="number"==typeof t?t:1/0,t?n(e,1):Array.isArray(e)?e.map(function(e){return e}):e}},{}],84:[function(e,t){t.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],85:[function(e,o,i){i.read=function(n,r,o,a,l){var c=8*l-a-1,u=(1<<c)-1,p=u>>1,f=-7,h=o?l-1:0,g=o?-1:1,d=n[r+h],_,b;for(h+=g,_=d&(1<<-f)-1,d>>=-f,f+=c;0<f;_=256*_+n[r+h],h+=g,f-=8);for(b=_&(1<<-f)-1,_>>=-f,f+=a;0<f;b=256*b+n[r+h],h+=g,f-=8);if(0===_)_=1-p;else{if(_===u)return b?NaN:(d?-1:1)*(1/0);b+=t(2,a),_-=p}return(d?-1:1)*b*t(2,_-a)},i.write=function(o,a,l,u,p,f){var h=Math.LN2,g=Math.log,_=8*f-p-1,b=(1<<_)-1,y=b>>1,w=23===p?t(2,-24)-t(2,-77):0,k=u?0:f-1,x=u?1:-1,d=0>a||0===a&&0>1/a?1:0,s,C,S;for(a=r(a),isNaN(a)||a===1/0?(C=isNaN(a)?1:0,s=b):(s=n(g(a)/h),1>a*(S=t(2,-s))&&(s--,S*=2),a+=1<=s+y?w/S:w*t(2,1-y),2<=a*S&&(s++,S/=2),s+y>=b?(C=0,s=b):1<=s+y?(C=(a*S-1)*t(2,p),s+=y):(C=a*t(2,y-1)*t(2,p),s=0));8<=p;o[l+k]=255&C,k+=x,C/=256,p-=8);for(s=s<<p|C,_+=p;0<_;o[l+k]=255&s,k+=x,s/=256,_-=8);o[l+k-x]|=128*d}},{}],86:[function(e,t){(function(e){function n(t,n,r){e.nextTick(()=>{t&&t(n,r)})}t.exports=class{constructor(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=[]}put(e,t,n){this.mem[e]=t,this.store.put(e,t,t=>{this.mem[e]=null,n&&n(t)})}get(e,t,r){if("function"==typeof t)return this.get(e,null,t);const o=t&&t.offset||0,i=t&&t.length&&o+t.length,a=this.mem[e];return a?n(r,null,t?a.slice(o,i):a):void this.store.get(e,t,r)}close(e){this.store.close(e)}destroy(e){this.store.destroy(e)}}}).call(this,e("_process"))},{_process:138}],87:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],88:[function(e,t){t.exports=function(e){for(var t=0,n=e.length;t<n;++t)if(e.charCodeAt(t)>127)return!1;return!0}},{}],89:[function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}/*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */t.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},{}],90:[function(e,t){"use strict";function n(e){return r.existsSync(e)&&r.statSync(e).isFile()}var r=e("fs");t.exports=function(e,t){return t?void r.stat(e,function(e,n){return e?t(e):t(null,n.isFile())}):n(e)},t.exports.sync=n},{fs:46}],91:[function(e,t){function n(e){return r(e)||o(e)}function r(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 o(e){return a[i.call(e)]}t.exports=n,n.strict=r,n.loose=o;var i=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}},{}],92:[function(e,t){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],93:[function(e,t,n){"use strict";n.regex=n.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon\r$|^\._.*|^\.Spotlight-V100(?:$|\/)|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$|^@eaDir$/,n.is=e=>n.re.test(e),n.not=e=>!n.is(e)},{}],94:[function(e,t){(function(n){function r(e){const t={},r=e.split("magnet:?")[1],i=r&&0<=r.length?r.split("&"):[];i.forEach(e=>{const n=e.split("=");if(2!==n.length)return;const r=n[0];let 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=+o),!t[r])t[r]=o;else if(Array.isArray(t[r]))t[r].push(o);else{const e=t[r];t[r]=[e,o]}});let s;if(t.xt){const e=Array.isArray(t.xt)?t.xt:[t.xt];e.forEach(e=>{if(s=e.match(/^urn:btih:(.{40})/))t.infoHash=s[1].toLowerCase();else if(s=e.match(/^urn:btih:(.{32})/)){const e=o.decode(s[1]);t.infoHash=n.from(e,"binary").toString("hex")}})}return t.infoHash&&(t.infoHashBuffer=n.from(t.infoHash,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),t.announce="string"==typeof t.tr?[t.tr]:Array.isArray(t.tr)?t.tr:[],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}t.exports=r,t.exports.decode=r,t.exports.encode=function(e){e=i(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);let t="magnet:?";return Object.keys(e).filter(e=>2===e.length).forEach((n,r)=>{const o=Array.isArray(e[n])?e[n]:[e[n]];o.forEach((e,o)=>{(0<r||0<o)&&("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&&0<o?`+${e}`:`${n}=${e}`})}),t};const o=e("thirty-two"),i=e("xtend"),a=e("uniq")}).call(this,e("buffer").Buffer)},{buffer:47,"thirty-two":225,uniq:236,xtend:248}],95:[function(e,t){function n(e,t){var r=this;if(!(r instanceof n))return new n(e,t);if(!d)throw new Error("web browser lacks MediaSource support");t||(t={}),r._debug=t.debug,r._bufferDuration=t.bufferDuration||60,r._elem=e,r._mediaSource=new d,r._streams=[],r.detailedError=null,r._errorHandler=function(){r._elem.removeEventListener("error",r._errorHandler);var e=r._streams.slice();e.forEach(function(e){e.destroy(r._elem.error)})},r._elem.addEventListener("error",r._errorHandler),r._elem.src=window.URL.createObjectURL(r._mediaSource)}function r(e,t){var n=this;if(a.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._debugBuffers=[],n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},n._errorHandler=function(e){n.destroyed||n.emit("error",e)},"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)t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._debugBuffers=t._debugBuffers,n._sourceBuffer.addEventListener("updateend",n._flowHandler),n._sourceBuffer.addEventListener("error",n._errorHandler);else throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");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}))){n._wrapper._dumpDebugData();try{n._mediaSource.endOfStream()}catch(e){}}})}function o(e,t){var n=document.createElement("a");n.href=window.URL.createObjectURL(new window.Blob(e)),n.download=t,n.click()}t.exports=n;var i=e("inherits"),a=e("readable-stream"),s=e("to-arraybuffer"),d="undefined"!=typeof window&&window.MediaSource;n.prototype.createWriteStream=function(e){var t=this;return new r(t,e)},n.prototype.error=function(e){var t=this;t.detailedError||(t.detailedError=e),t._dumpDebugData();try{t._mediaSource.endOfStream("decode")}catch(e){}},n.prototype._dumpDebugData=function(){var e=this;e._debug&&(e._debug=!1,e._streams.forEach(function(e,t){o(e._debugBuffers,"mediasource-stream-"+t)}))},i(r,a.Writable),r.prototype._onSourceOpen=function(){var e=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},r.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),t._sourceBuffer.removeEventListener("error",t._errorHandler),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},r.prototype._createSourceBuffer=function(){var e=this;if(!e.destroyed)if(!d.isTypeSupported(e._type))e.destroy(new Error("The provided type is not supported"));else if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._sourceBuffer.addEventListener("error",e._errorHandler),e._cb){var t=e._cb;e._cb=null,t()}},r.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"));var o=s(e);r._wrapper._debug&&r._debugBuffers.push(o);try{r._sourceBuffer.appendBuffer(o)}catch(e){return void r.destroy(e)}r._cb=n}},r.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()}};r.prototype._getBufferDuration=function(){for(var e=this,t=e._sourceBuffer.buffered,n=e._elem.currentTime,r=-1,o=0;o<t.length;o++){var a=t.start(o),s=t.end(o)+0;if(a>n)break;else(0<=r||n<=s)&&(r=s)}var d=r-n;return 0>d&&(d=0),d}},{inherits:87,"readable-stream":104,"to-arraybuffer":228}],96:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":98,"./_stream_writable":100,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],97:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":99,"core-util-is":66,dup:19,inherits:87}],98:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":96,"./internal/streams/BufferList":101,"./internal/streams/destroy":102,"./internal/streams/stream":103,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],99:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":96,"core-util-is":66,dup:21,inherits:87}],100:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":96,"./internal/streams/destroy":102,"./internal/streams/stream":103,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],101:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],102:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],103:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],104:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":96,"./lib/_stream_passthrough.js":97,"./lib/_stream_readable.js":98,"./lib/_stream_transform.js":99,"./lib/_stream_writable.js":100,dup:26}],105:[function(e,t){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=+e,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+t.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=a(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?void(this.chunks[e]=t,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){var i=new Error("Chunk not found");return i.notFound=!0,r(n,i)}if(!t)return r(n,null,o);var a=t.offset||0,s=t.length||o.length-a;r(n,null,o.slice(a,s+a))},n.prototype.close=n.prototype.destroy=function(e){return this.closed?r(e,new Error("Storage is closed")):void(this.closed=!0,this.chunks=null,r(e,null))}}).call(this,e("_process"))},{_process:138}],106:[function(e,t,r){function o(e,t,n){for(var r=t;r<n;r++)e[r]=0}function i(e,t,r){t.writeUInt32BE(n((e.getTime()+2082844800000)/1e3),r)}function a(e,t,r){t.writeUIntBE(n((e.getTime()+2082844800000)/1e3),r,6)}function s(e,t,r){t.writeUInt16BE(n(e)%65536,r),t.writeUInt16BE(n(256*(256*e))%65536,r+2)}function l(e,t,r){t[r]=n(e)%256,t[r+1]=n(256*e)%256}function c(e,t,n){e||(e=[0,0,0,0,0,0,0,0,0]);for(var r=0;r<e.length;r++)s(e[r],t,n+4*r)}function u(e,t,n){var r=k(e,"utf8");r.copy(t,n),t[n+r.length]=0}function p(e){for(var t=Array(e.length/4),n=0;n<t.length;n++)t[n]=m(e,4*n);return t}function f(e,t){return new Date(1e3*e.readUIntBE(t,6)-2082844800000)}function h(e,t){return new Date(1e3*e.readUInt32BE(t)-2082844800000)}function m(e,t){return e.readUInt16BE(t)+e.readUInt16BE(t+2)/65536}function g(e,t){return e[t]+e[t+1]/256}function _(e,t,n){var r;for(r=0;r<n&&!(0===e[t+r]);r++);return e.toString("utf8",t,t+r)}var b=e("./index"),y=e("./descriptor"),w=e("buffer-alloc"),k=e("buffer-from"),x=e("uint64be");r.fullBoxes={};["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(e){r.fullBoxes[e]=!0}),r.ftyp={},r.ftyp.encode=function(e,t,n){t=t?t.slice(n):w(r.ftyp.encodingLength(e));var o=e.compatibleBrands||[];t.write(e.brand,0,4,"ascii"),t.writeUInt32BE(e.brandVersion,4);for(var a=0;a<o.length;a++)t.write(o[a],8+4*a,4,"ascii");return r.ftyp.encode.bytes=8+4*o.length,t},r.ftyp.decode=function(e,t){e=e.slice(t);for(var n=e.toString("ascii",0,4),r=e.readUInt32BE(4),o=[],a=8;a<e.length;a+=4)o.push(e.toString("ascii",a,a+4));return{brand:n,brandVersion:r,compatibleBrands:o}},r.ftyp.encodingLength=function(e){return 8+4*(e.compatibleBrands||[]).length},r.mvhd={},r.mvhd.encode=function(e,t,n){return t=t?t.slice(n):w(96),i(e.ctime||new Date,t,0),i(e.mtime||new Date,t,4),t.writeUInt32BE(e.timeScale||0,8),t.writeUInt32BE(e.duration||0,12),s(e.preferredRate||0,t,16),l(e.preferredVolume||0,t,20),o(t,22,32),c(e.matrix,t,32),t.writeUInt32BE(e.previewTime||0,68),t.writeUInt32BE(e.previewDuration||0,72),t.writeUInt32BE(e.posterTime||0,76),t.writeUInt32BE(e.selectionTime||0,80),t.writeUInt32BE(e.selectionDuration||0,84),t.writeUInt32BE(e.currentTime||0,88),t.writeUInt32BE(e.nextTrackId||0,92),r.mvhd.encode.bytes=96,t},r.mvhd.decode=function(e,t){return e=e.slice(t),{ctime:h(e,0),mtime:h(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),preferredRate:m(e,16),preferredVolume:g(e,20),matrix:p(e.slice(32,68)),previewTime:e.readUInt32BE(68),previewDuration:e.readUInt32BE(72),posterTime:e.readUInt32BE(76),selectionTime:e.readUInt32BE(80),selectionDuration:e.readUInt32BE(84),currentTime:e.readUInt32BE(88),nextTrackId:e.readUInt32BE(92)}},r.mvhd.encodingLength=function(){return 96},r.tkhd={},r.tkhd.encode=function(e,t,n){return t=t?t.slice(n):w(80),i(e.ctime||new Date,t,0),i(e.mtime||new Date,t,4),t.writeUInt32BE(e.trackId||0,8),o(t,12,16),t.writeUInt32BE(e.duration||0,16),o(t,20,28),t.writeUInt16BE(e.layer||0,28),t.writeUInt16BE(e.alternateGroup||0,30),t.writeUInt16BE(e.volume||0,32),c(e.matrix,t,36),t.writeUInt32BE(e.trackWidth||0,72),t.writeUInt32BE(e.trackHeight||0,76),r.tkhd.encode.bytes=80,t},r.tkhd.decode=function(e,t){return e=e.slice(t),{ctime:h(e,0),mtime:h(e,4),trackId:e.readUInt32BE(8),duration:e.readUInt32BE(16),layer:e.readUInt16BE(28),alternateGroup:e.readUInt16BE(30),volume:e.readUInt16BE(32),matrix:p(e.slice(36,72)),trackWidth:e.readUInt32BE(72),trackHeight:e.readUInt32BE(76)}},r.tkhd.encodingLength=function(){return 80},r.mdhd={},r.mdhd.encode=function(e,t,n){return 1===e.version?(t=t?t.slice(n):w(32),a(e.ctime||new Date,t,0),a(e.mtime||new Date,t,8),t.writeUInt32BE(e.timeScale||0,16),t.writeUIntBE(e.duration||0,20,6),t.writeUInt16BE(e.language||0,28),t.writeUInt16BE(e.quality||0,30),r.mdhd.encode.bytes=32,t):(t=t?t.slice(n):w(20),i(e.ctime||new Date,t,0),i(e.mtime||new Date,t,4),t.writeUInt32BE(e.timeScale||0,8),t.writeUInt32BE(e.duration||0,12),t.writeUInt16BE(e.language||0,16),t.writeUInt16BE(e.quality||0,18),r.mdhd.encode.bytes=20,t)},r.mdhd.decode=function(e,t,n){e=e.slice(t);return 20!=n-t?{ctime:f(e,0),mtime:f(e,8),timeScale:e.readUInt32BE(16),duration:e.readUIntBE(20,6),language:e.readUInt16BE(28),quality:e.readUInt16BE(30)}:{ctime:h(e,0),mtime:h(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),language:e.readUInt16BE(16),quality:e.readUInt16BE(18)}},r.mdhd.encodingLength=function(e){return 1===e.version?32:20},r.vmhd={},r.vmhd.encode=function(e,t,n){t=t?t.slice(n):w(8),t.writeUInt16BE(e.graphicsMode||0,0);var o=e.opcolor||[0,0,0];return t.writeUInt16BE(o[0],2),t.writeUInt16BE(o[1],4),t.writeUInt16BE(o[2],6),r.vmhd.encode.bytes=8,t},r.vmhd.decode=function(e,t){return e=e.slice(t),{graphicsMode:e.readUInt16BE(0),opcolor:[e.readUInt16BE(2),e.readUInt16BE(4),e.readUInt16BE(6)]}},r.vmhd.encodingLength=function(){return 8},r.smhd={},r.smhd.encode=function(e,t,n){return t=t?t.slice(n):w(4),t.writeUInt16BE(e.balance||0,0),o(t,2,4),r.smhd.encode.bytes=4,t},r.smhd.decode=function(e,t){return e=e.slice(t),{balance:e.readUInt16BE(0)}},r.smhd.encodingLength=function(){return 4},r.stsd={},r.stsd.encode=function(e,t,n){t=t?t.slice(n):w(r.stsd.encodingLength(e));var o=e.entries||[];t.writeUInt32BE(o.length,0);for(var a=4,s=0,d;s<o.length;s++)d=o[s],b.encode(d,t,a),a+=b.encode.bytes;return r.stsd.encode.bytes=a,t},r.stsd.decode=function(e,t,n){e=e.slice(t);for(var r=e.readUInt32BE(0),o=Array(r),a=4,s=0,d;s<r;s++)d=b.decode(e,a,n),o[s]=d,a+=d.length;return{entries:o}},r.stsd.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++)t+=b.encodingLength(e.entries[n]);return t},r.avc1=r.VisualSampleEntry={},r.VisualSampleEntry.encode=function(e,t,n){t=t?t.slice(n):w(r.VisualSampleEntry.encodingLength(e)),o(t,0,6),t.writeUInt16BE(e.dataReferenceIndex||0,6),o(t,8,24),t.writeUInt16BE(e.width||0,24),t.writeUInt16BE(e.height||0,26),t.writeUInt32BE(e.hResolution||4718592,28),t.writeUInt32BE(e.vResolution||4718592,32),o(t,36,40),t.writeUInt16BE(e.frameCount||1,40);var i=e.compressorName||"",a=d(i.length,31);t.writeUInt8(a,42),t.write(i,43,a,"utf8"),t.writeUInt16BE(e.depth||24,74),t.writeInt16BE(-1,76);var s=78,l=e.children||[];l.forEach(function(e){b.encode(e,t,s),s+=b.encode.bytes}),r.VisualSampleEntry.encode.bytes=s},r.VisualSampleEntry.decode=function(e,t,n){e=e.slice(t);for(var r=n-t,o=d(e.readUInt8(42),31),i={dataReferenceIndex:e.readUInt16BE(6),width:e.readUInt16BE(24),height:e.readUInt16BE(26),hResolution:e.readUInt32BE(28),vResolution:e.readUInt32BE(32),frameCount:e.readUInt16BE(40),compressorName:e.toString("utf8",43,43+o),depth:e.readUInt16BE(74),children:[]},a=78;8<=r-a;){var s=b.decode(e,a,r);i.children.push(s),i[s.type]=s,a+=s.length}return i},r.VisualSampleEntry.encodingLength=function(e){var t=78,n=e.children||[];return n.forEach(function(e){t+=b.encodingLength(e)}),t},r.avcC={},r.avcC.encode=function(e,t,n){t=t?t.slice(n):w(e.buffer.length),e.buffer.copy(t),r.avcC.encode.bytes=e.buffer.length},r.avcC.decode=function(e,t,n){return e=e.slice(t,n),{mimeCodec:e.toString("hex",1,4),buffer:k(e)}},r.avcC.encodingLength=function(e){return e.buffer.length},r.mp4a=r.AudioSampleEntry={},r.AudioSampleEntry.encode=function(e,t,n){t=t?t.slice(n):w(r.AudioSampleEntry.encodingLength(e)),o(t,0,6),t.writeUInt16BE(e.dataReferenceIndex||0,6),o(t,8,16),t.writeUInt16BE(e.channelCount||2,16),t.writeUInt16BE(e.sampleSize||16,18),o(t,20,24),t.writeUInt32BE(e.sampleRate||0,24);var i=28,a=e.children||[];a.forEach(function(e){b.encode(e,t,i),i+=b.encode.bytes}),r.AudioSampleEntry.encode.bytes=i},r.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;8<=r-i;){var a=b.decode(e,i,r);o.children.push(a),o[a.type]=a,i+=a.length}return o},r.AudioSampleEntry.encodingLength=function(e){var t=28,n=e.children||[];return n.forEach(function(e){t+=b.encodingLength(e)}),t},r.esds={},r.esds.encode=function(e,t,n){t=t?t.slice(n):w(e.buffer.length),e.buffer.copy(t,0),r.esds.encode.bytes=e.buffer.length},r.esds.decode=function(e,t,n){e=e.slice(t,n);var r=y.Descriptor.decode(e,0,e.length),o="ESDescriptor"===r.tagName?r:{},i=o.DecoderConfigDescriptor||{},a=i.oti||0,s=i.DecoderSpecificInfo,d=s?(248&s.buffer.readUInt8(0))>>3:0,l=null;return a&&(l=a.toString(16),d&&(l+="."+d)),{mimeCodec:l,buffer:k(e.slice(0))}},r.esds.encodingLength=function(e){return e.buffer.length},r.stsz={},r.stsz.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.stsz.encodingLength(e)),t.writeUInt32BE(0,0),t.writeUInt32BE(o.length,4);for(var a=0;a<o.length;a++)t.writeUInt32BE(o[a],4*a+8);return r.stsz.encode.bytes=8+4*o.length,t},r.stsz.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=e.readUInt32BE(4),o=Array(r),a=0;a<r;a++)o[a]=0===n?e.readUInt32BE(4*a+8):n;return{entries:o}},r.stsz.encodingLength=function(e){return 8+4*e.entries.length},r.stss=r.stco={},r.stco.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.stco.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0;a<o.length;a++)t.writeUInt32BE(o[a],4*a+4);return r.stco.encode.bytes=4+4*o.length,t},r.stco.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0;o<n;o++)r[o]=e.readUInt32BE(4*o+4);return{entries:r}},r.stco.encodingLength=function(e){return 4+4*e.entries.length},r.co64={},r.co64.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.co64.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0;a<o.length;a++)x.encode(o[a],t,8*a+4);return r.co64.encode.bytes=4+8*o.length,t},r.co64.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0;o<n;o++)r[o]=x.decode(e,8*o+4);return{entries:r}},r.co64.encodingLength=function(e){return 4+8*e.entries.length},r.stts={},r.stts.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.stts.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,s;a<o.length;a++)s=8*a+4,t.writeUInt32BE(o[a].count||0,s),t.writeUInt32BE(o[a].duration||0,s+4);return r.stts.encode.bytes=4+8*e.entries.length,t},r.stts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=8*o+4,r[o]={count:e.readUInt32BE(a),duration:e.readUInt32BE(a+4)};return{entries:r}},r.stts.encodingLength=function(e){return 4+8*e.entries.length},r.ctts={},r.ctts.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.ctts.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,s;a<o.length;a++)s=8*a+4,t.writeUInt32BE(o[a].count||0,s),t.writeUInt32BE(o[a].compositionOffset||0,s+4);return r.ctts.encode.bytes=4+8*o.length,t},r.ctts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=8*o+4,r[o]={count:e.readUInt32BE(a),compositionOffset:e.readInt32BE(a+4)};return{entries:r}},r.ctts.encodingLength=function(e){return 4+8*e.entries.length},r.stsc={},r.stsc.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.stsc.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,s;a<o.length;a++)s=12*a+4,t.writeUInt32BE(o[a].firstChunk||0,s),t.writeUInt32BE(o[a].samplesPerChunk||0,s+4),t.writeUInt32BE(o[a].sampleDescriptionId||0,s+8);return r.stsc.encode.bytes=4+12*o.length,t},r.stsc.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=12*o+4,r[o]={firstChunk:e.readUInt32BE(a),samplesPerChunk:e.readUInt32BE(a+4),sampleDescriptionId:e.readUInt32BE(a+8)};return{entries:r}},r.stsc.encodingLength=function(e){return 4+12*e.entries.length},r.dref={},r.dref.encode=function(e,t,n){t=t?t.slice(n):w(r.dref.encodingLength(e));var o=e.entries||[];t.writeUInt32BE(o.length,0);for(var a=4,s=0;s<o.length;s++){var d=o[s],l=(d.buf?d.buf.length:0)+4+4;t.writeUInt32BE(l,a),a+=4,t.write(d.type,a,4,"ascii"),a+=4,d.buf&&(d.buf.copy(t,a),a+=d.buf.length)}return r.dref.encode.bytes=a,t},r.dref.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=4,a=0;a<n;a++){var s=e.readUInt32BE(o),d=e.toString("ascii",o+4,o+8),l=e.slice(o+8,o+s);o+=s,r[a]={type:d,buf:l}}return{entries:r}},r.dref.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0,r;n<e.entries.length;n++)r=e.entries[n].buf,t+=(r?r.length:0)+4+4;return t},r.elst={},r.elst.encode=function(e,t,n){var o=e.entries||[];t=t?t.slice(n):w(r.elst.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,d;a<o.length;a++)d=12*a+4,t.writeUInt32BE(o[a].trackDuration||0,d),t.writeUInt32BE(o[a].mediaTime||0,d+4),s(o[a].mediaRate||0,t,d+8);return r.elst.encode.bytes=4+12*o.length,t},r.elst.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=12*o+4,r[o]={trackDuration:e.readUInt32BE(a),mediaTime:e.readInt32BE(a+4),mediaRate:m(e,a+8)};return{entries:r}},r.elst.encodingLength=function(e){return 4+12*e.entries.length},r.hdlr={},r.hdlr.encode=function(e,t,n){t=t?t.slice(n):w(r.hdlr.encodingLength(e));var o=21+(e.name||"").length;return t.fill(0,0,o),t.write(e.handlerType||"",4,4,"ascii"),u(e.name||"",t,20),r.hdlr.encode.bytes=o,t},r.hdlr.decode=function(e,t,n){return e=e.slice(t),{handlerType:e.toString("ascii",4,8),name:_(e,20,n)}},r.hdlr.encodingLength=function(e){return 21+(e.name||"").length},r.mehd={},r.mehd.encode=function(e,t,n){return t=t?t.slice(n):w(4),t.writeUInt32BE(e.fragmentDuration||0,0),r.mehd.encode.bytes=4,t},r.mehd.decode=function(e,t){return e=e.slice(t),{fragmentDuration:e.readUInt32BE(0)}},r.mehd.encodingLength=function(){return 4},r.trex={},r.trex.encode=function(e,t,n){return t=t?t.slice(n):w(20),t.writeUInt32BE(e.trackId||0,0),t.writeUInt32BE(e.defaultSampleDescriptionIndex||0,4),t.writeUInt32BE(e.defaultSampleDuration||0,8),t.writeUInt32BE(e.defaultSampleSize||0,12),t.writeUInt32BE(e.defaultSampleFlags||0,16),r.trex.encode.bytes=20,t},r.trex.decode=function(e,t){return e=e.slice(t),{trackId:e.readUInt32BE(0),defaultSampleDescriptionIndex:e.readUInt32BE(4),defaultSampleDuration:e.readUInt32BE(8),defaultSampleSize:e.readUInt32BE(12),defaultSampleFlags:e.readUInt32BE(16)}},r.trex.encodingLength=function(){return 20},r.mfhd={},r.mfhd.encode=function(e,t,n){return t=t?t.slice(n):w(4),t.writeUInt32BE(e.sequenceNumber||0,0),r.mfhd.encode.bytes=4,t},r.mfhd.decode=function(e){return{sequenceNumber:e.readUInt32BE(0)}},r.mfhd.encodingLength=function(){return 4},r.tfhd={},r.tfhd.encode=function(e,t,n){return t=t?t.slice(n):w(4),t.writeUInt32BE(e.trackId,0),r.tfhd.encode.bytes=4,t},r.tfhd.decode=function(){},r.tfhd.encodingLength=function(){return 4},r.tfdt={},r.tfdt.encode=function(e,t,n){return t=t?t.slice(n):w(4),t.writeUInt32BE(e.baseMediaDecodeTime||0,0),r.tfdt.encode.bytes=4,t},r.tfdt.decode=function(){},r.tfdt.encodingLength=function(){return 4},r.trun={},r.trun.encode=function(e,t,n){t=t?t.slice(n):w(8+16*e.entries.length),t.writeUInt32BE(e.entries.length,0),t.writeInt32BE(e.dataOffset,4);for(var o=8,a=0,s;a<e.entries.length;a++)s=e.entries[a],t.writeUInt32BE(s.sampleDuration,o),o+=4,t.writeUInt32BE(s.sampleSize,o),o+=4,t.writeUInt32BE(s.sampleFlags,o),o+=4,0===(e.version||0)?t.writeUInt32BE(s.sampleCompositionTimeOffset,o):t.writeInt32BE(s.sampleCompositionTimeOffset,o),o+=4;r.trun.encode.bytes=o},r.trun.decode=function(){},r.trun.encodingLength=function(e){return 8+16*e.entries.length},r.mdat={},r.mdat.encode=function(e,t,n){e.buffer?(e.buffer.copy(t,n),r.mdat.encode.bytes=e.buffer.length):r.mdat.encode.bytes=r.mdat.encodingLength(e)},r.mdat.decode=function(e,t,n){return{buffer:k(e.slice(t,n))}},r.mdat.encodingLength=function(e){return e.buffer?e.buffer.length:e.contentLength}},{"./descriptor":107,"./index":108,"buffer-alloc":51,"buffer-from":53,uint64be:235}],107:[function(e,t,n){var r=e("buffer-from"),o={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};n.Descriptor={},n.Descriptor.decode=function(e,t,i){var a=e.readUInt8(t),s=t+1,d=0,l;do l=e.readUInt8(s++),d=d<<7|127&l;while(128&l);var c=o[a],u;return u=n[c]?n[c].decode(e,s,i):{buffer:r(e.slice(s,s+d))},u.tag=a,u.tagName=c,u.length=s-t+d,u.contentsLen=d,u},n.DescriptorArray={},n.DescriptorArray.decode=function(e,t,r){for(var i=t,a={};i+2<=r;){var s=n.Descriptor.decode(e,i,r);i+=s.length;var d=o[s.tag]||"Descriptor"+s.tag;a[d]=s}return a},n.ESDescriptor={},n.ESDescriptor.decode=function(e,t,r){var o=e.readUInt8(t+2),i=t+3;if(128&o&&(i+=2),64&o){var a=e.readUInt8(i);i+=a+1}return 32&o&&(i+=2),n.DescriptorArray.decode(e,i,r)},n.DecoderConfigDescriptor={},n.DecoderConfigDescriptor.decode=function(e,t,r){var o=e.readUInt8(t),i=n.DescriptorArray.decode(e,t+13,r);return i.oti=o,i}},{"buffer-from":53}],108:[function(e,t,n){var r=e("uint64be"),o=e("buffer-alloc"),i=e("buffer-from"),a=e("./boxes"),s=4294967295,d=n,l=n.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};d.encode=function(e,t,n){return d.encodingLength(e),n=n||0,t=t||o(e.length),d._encode(e,t,n)},d._encode=function(e,t,n){var o=e.type,i=e.length;i>s&&(i=1),t.writeUInt32BE(i,n),t.write(e.type,n+4,4,"ascii");var c=n+8;if(1===i&&(r.encode(e.length,t,c),c+=8),a.fullBoxes[o]&&(t.writeUInt32BE(e.flags||0,c),t.writeUInt8(e.version||0,c),c+=4),l[o]){var u=l[o];u.forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){d._encode(e,t,c),c+=d.encode.bytes})}else e[n]&&(d._encode(e[n],t,c),c+=d.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){d._encode(e,t,c),c+=d.encode.bytes})}else if(a[o]){var p=a[o].encode;p(e,t,c),c+=p.bytes}else if(e.buffer){var f=e.buffer;f.copy(t,c),c+=e.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+o+"') or `buffer` must be set");return d.encode.bytes=c-n,t},d.readHeaders=function(e,t,n){if(t=t||0,n=n||e.length,8>n-t)return 8;var o=e.readUInt32BE(t),i=e.toString("ascii",t+4,t+8),s=t+8;if(1===o){if(16>n-t)return 16;o=r.decode(e,s),s+=8}var d,l;return a.fullBoxes[i]&&(d=e.readUInt8(s),l=16777215&e.readUInt32BE(s),s+=4),{length:o,headersLen:s-t,contentLen:o-(s-t),type:i,version:d,flags:l}},d.decode=function(e,t,n){t=t||0,n=n||e.length;var r=d.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return d.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},d.decodeWithoutHeaders=function(e,t,n,r){n=n||0,r=r||t.length;var o=e.type,s={};if(l[o]){s.otherBoxes=[];for(var c=l[o],u=n,p;8<=r-u;)if(p=d.decode(t,u,r),u+=p.length,0<=c.indexOf(p.type))s[p.type]=p;else if(0<=c.indexOf(p.type+"s")){var f=p.type+"s",h=s[f]=s[f]||[];h.push(p)}else s.otherBoxes.push(p)}else if(a[o]){var m=a[o].decode;s=m(t,n,r)}else s.buffer=i(t.slice(n,r));return s.length=e.length,s.contentLen=e.contentLen,s.type=e.type,s.version=e.version,s.flags=e.flags,s},d.encodingLength=function(e){var t=e.type,n=8;if(a.fullBoxes[t]&&(n+=4),l[t]){var r=l[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+=d.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=d.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=d.encodingLength(e)})}else if(a[t])n+=a[t].encodingLength(e);else if(e.buffer)n+=e.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");return n>s&&(n+=8),e.length=n,n}},{"./boxes":106,"buffer-alloc":51,"buffer-from":53,uint64be:235}],109:[function(e,t){(function(n){function r(){return this instanceof r?void(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,this._kick()):new r}function o(e){this._parent=e,this.destroyed=!1,i.PassThrough.call(this)}var i=e("readable-stream"),a=e("inherits"),s=e("next-event"),d=e("mp4-box-encoding"),l=e("buffer-alloc"),c=l(0);t.exports=r,a(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.length<this._missing?e.length:this._missing;if(this._buf?e.copy(this._buf,this._buf.length-this._missing):this._str&&(r=this._str.write(o===e.length?e:e.slice(0,o))),this._missing-=o,!this._missing){var i=this._buf,a=this._cb,s=this._str;this._buf=this._cb=this._str=this._ondrain=null,r=!0,s&&s.end(),a&&a(i)}e=o===e.length?c:e.slice(o)}return this._pending&&!this._missing?(this._writeBuffer=e,void(this._writeCb=n)):void(r?n():this._ondrain(n))}},r.prototype._buffer=function(e,t){this._missing=e,this._buf=l(e),this._cb=t},r.prototype._stream=function(e,t){var n=this;return this._missing=e,this._str=new o(this),this._ondrain=s(this._str,"drain"),this._pending++,this._str.on("end",function(){n._pending--,n._kick()}),this._cb=t,this._str},r.prototype._readBox=function(){function e(r,o){t._buffer(r,function(r){o=o?n.concat([o,r]):r;var i=d.readHeaders(o);"number"==typeof i?e(i-o.length,o):(t._pending++,t._headers=i,t.emit("box",i))})}var t=this;e(8)},r.prototype.stream=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;return e._headers=null,e._stream(t.contentLen,null)},r.prototype.decode=function(e){var t=this;if(!t._headers)throw new Error("this function can only be called once after 'box' is emitted");var n=t._headers;t._headers=null,t._buffer(n.contentLen,function(r){var o=d.decodeWithoutHeaders(n,r);e(o),t._pending--,t._kick()})},r.prototype.ignore=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;e._headers=null,this._missing=t.contentLen,this._cb=function(){e._pending--,e._kick()}},r.prototype._kick=function(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var e=this._writeCb,t=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(t,null,e)}},a(o,i.PassThrough),o.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}).call(this,e("buffer").Buffer)},{buffer:47,"buffer-alloc":51,inherits:87,"mp4-box-encoding":108,"next-event":131,"readable-stream":120}],110:[function(e,t){(function(n){function r(){}function o(){if(!(this instanceof o))return new o;a.Readable.call(this),this.destroyed=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=function(){e._want&&(e._want=!1,e._read())},this._onend=function(){e._stream=null};var e=this}function i(e){this._parent=e,this.destroyed=!1,a.PassThrough.call(this)}var a=e("readable-stream"),s=e("inherits"),d=e("mp4-box-encoding"),l=e("buffer-alloc");t.exports=o,s(o,a.Readable),o.prototype.mediaData=o.prototype.mdat=function(e,t){var n=new i(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n},o.prototype.box=function(e,t){if(t||(t=r),this.destroyed)return t(new Error("Encoder is destroyed"));var o;if(e.encodeBufferLen&&(o=l(e.encodeBufferLen)),e.stream)e.buffer=null,o=d.encode(e,o),this.push(o),this._stream=e.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",t),this._forward();else{o=d.encode(e,o);var i=this.push(o);if(i)return n.nextTick(t);this._drain=t}},o.prototype.destroy=function(e){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var t=this._drain;this._drain=null,t(e)}e&&this.emit("error",e),this.emit("close")}},o.prototype.finalize=function(){this.push(null)},o.prototype._forward=function(){if(this._stream)for(;!this.destroyed;){var e=this._stream.read();if(!e)return void(this._want=!!this._stream);if(!this.push(e))return}},o.prototype._read=function(){if(!(this._reading||this.destroyed)){if(this._reading=!0,this._stream&&this._forward(),this._drain){var e=this._drain;this._drain=null,e()}this._reading=!1}},s(i,a.PassThrough),i.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}).call(this,e("_process"))},{_process:138,"buffer-alloc":51,inherits:87,"mp4-box-encoding":108,"readable-stream":120}],111:[function(e,t,n){n.decode=e("./decode"),n.encode=e("./encode")},{"./decode":109,"./encode":110}],112:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":114,"./_stream_writable":116,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],113:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":115,"core-util-is":66,dup:19,inherits:87}],114:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":112,"./internal/streams/BufferList":117,"./internal/streams/destroy":118,"./internal/streams/stream":119,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],115:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":112,"core-util-is":66,dup:21,inherits:87}],116:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":112,"./internal/streams/destroy":118,"./internal/streams/stream":119,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],117:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],118:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],119:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],120:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":112,"./lib/_stream_passthrough.js":113,"./lib/_stream_readable.js":114,"./lib/_stream_transform.js":115,"./lib/_stream_writable.js":116,dup:26}],121:[function(e,t){function n(e,t){var i=this;return i instanceof n?void(d.Readable.call(i,t),i.destroyed=!1,i._drained=!1,i._forwarding=!1,i._current=null,i._toStreams2=t&&t.objectMode?r:o,"function"==typeof e?i._queue=e:(i._queue=e.map(i._toStreams2),i._queue.forEach(function(e){"function"!=typeof e&&i._attachErrorListener(e)})),i._next()):new n(e,t)}function r(e){return i(e,{objectMode:!0,highWaterMark:16})}function o(e){return i(e)}function i(e,t){if(!e||"function"==typeof e||e._readableState)return e;var n=new d.Readable(t).wrap(e);return e.destroy&&(n.destroy=e.destroy.bind(e)),n}t.exports=n;var a=e("inherits"),d=e("readable-stream");a(n,d.Readable),n.obj=function(e){return new n(e,{objectMode:!0,highWaterMark:16})},n.prototype._read=function(){this._drained=!0,this._forward()},n.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}},n.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"))},n.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,n){return t?e.destroy(t):void(n=e._toStreams2(n),e._attachErrorListener(n),e._gotNextStream(n))});else{var t=e._queue.shift();"function"==typeof t&&(t=e._toStreams2(t()),e._attachErrorListener(t)),e._gotNextStream(t)}},n.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?void(o._current=e,o._forward(),e.on("readable",t),e.once("end",r),e.once("close",n)):(o.push(null),void o.destroy())},n.prototype._attachErrorListener=function(e){function t(r){e.removeListener("error",t),n.destroy(r)}var n=this;e&&e.once("error",t)}},{inherits:87,"readable-stream":130}],122:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":124,"./_stream_writable":126,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],123:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":125,"core-util-is":66,dup:19,inherits:87}],124:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":122,"./internal/streams/BufferList":127,"./internal/streams/destroy":128,"./internal/streams/stream":129,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],125:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":122,"core-util-is":66,dup:21,inherits:87}],126:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":122,"./internal/streams/destroy":128,"./internal/streams/stream":129,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],127:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],128:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],129:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],130:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":122,"./lib/_stream_passthrough.js":123,"./lib/_stream_readable.js":124,"./lib/_stream_transform.js":125,"./lib/_stream_writable.js":126,dup:26}],131:[function(e,t){t.exports=function(e,t){var n=null;return e.on(t,function(e){if(n){var t=n;n=null,t(e)}}),function(e){n=e}}},{}],132:[function(e,t){function n(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function r(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 o=e("wrappy");t.exports=o(n),t.exports.strict=o(r),n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return r(this)},configurable:!0})})},{wrappy:247}],133:[function(e,t){function n(e){if(/^-?\d+$/.test(e))return parseInt(e,10);var t;if(t=e.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){var n=t[1],r=t[2],o=t[3];if(n&&o){n=parseInt(n),o=parseInt(o);var a=[],s=n<o?1:-1;("-"==r||".."==r||"\u2025"==r)&&(o+=s);for(var d=n;d!=o;d+=s)a.push(d);return a}}return[]}t.exports.parse=function(e){var t=e.split(","),r=t.map(function(e){return n(e)});return 0===r.length?[]:1===r.length?Array.isArray(r[0])?r[0]:r:r.reduce(function(e,t){return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.concat(t)})}},{}],134:[function(e,t){(function(n,r){function o(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e))return h(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return h(`magnet:?xt=urn:btih:${e}`);if(r.isBuffer(e)&&20===e.length)return h(`magnet:?xt=urn:btih:${e.toString("hex")}`);if(r.isBuffer(e))return i(e);if(e&&e.infoHash)return e.infoHash=e.infoHash.toLowerCase(),e.announce||(e.announce=[]),"string"==typeof e.announce&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;throw new Error("Invalid torrent identifier")}function i(e){r.isBuffer(e)&&(e=c.decode(e)),l(e.info,"info"),l(e.info["name.utf-8"]||e.info.name,"info.name"),l(e.info["piece length"],"info['piece length']"),l(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(e=>{l("number"==typeof e.length,"info.files[0].length"),l(e["path.utf-8"]||e.path,"info.files[0].path")}):l("number"==typeof e.info.length,"info.length");const t={info:e.info,infoBuffer:c.encode(e.info),name:(e.info["name.utf-8"]||e.info.name).toString(),announce:[]};t.infoHash=g.sync(t.infoBuffer),t.infoHashBuffer=r.from(t.infoHash,"hex"),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()),r.isBuffer(e.comment)&&(t.comment=e.comment.toString()),Array.isArray(e["announce-list"])&&0<e["announce-list"].length?e["announce-list"].forEach(e=>{e.forEach(e=>{t.announce.push(e.toString())})}):e.announce&&t.announce.push(e.announce.toString()),r.isBuffer(e["url-list"])&&(e["url-list"]=0<e["url-list"].length?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(e=>e.toString()),_(t.announce),_(t.urlList);const n=e.info.files||[e.info];t.files=n.map((e,r)=>{const o=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(e=>e.toString());return{path:m.join.apply(null,[m.sep].concat(o)).slice(1),name:o[o.length-1],length:e.length,offset:n.slice(0,r).reduce(s,0)}}),t.length=n.reduce(s,0);const 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=d(e.info.pieces),t}function a(e){return"undefined"!=typeof Blob&&e instanceof Blob}function s(e,t){return e+t.length}function d(e){const t=[];for(let n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}function l(e,t){if(!e)throw new Error(`Torrent is missing required field: ${t}`)}const c=e("bencode"),u=e("blob-to-buffer"),p=e("fs"),f=e("simple-get"),h=e("magnet-uri"),m=e("path"),g=e("simple-sha1"),_=e("uniq");t.exports=o,t.exports.remote=function(e,t){function r(e){try{i=o(e)}catch(e){return t(e)}i&&i.infoHash?t(null,i):t(new Error("Invalid torrent identifier"))}let i;if("function"!=typeof t)throw new Error("second argument must be a Function");try{i=o(e)}catch(e){}i&&i.infoHash?n.nextTick(()=>{t(null,i)}):a(e)?u(e,(e,n)=>e?t(new Error(`Error converting Blob: ${e.message}`)):void r(n)):"function"==typeof f&&/^https?:/.test(e)?f.concat({url:e,timeout:30000,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},(e,n,o)=>e?t(new Error(`Error downloading torrent: ${e.message}`)):void r(o)):"function"==typeof p.readFile&&"string"==typeof e?p.readFile(e,(e,n)=>e?t(new Error("Invalid torrent identifier")):void r(n)):n.nextTick(()=>{t(new Error("Invalid torrent identifier"))})},t.exports.toMagnetURI=h.encode,t.exports.toTorrentFile=function(e){const t={info:e.info};return t["announce-list"]=(e.announce||[]).map(e=>(t.announce||(t.announce=e),e=r.from(e,"utf8"),[e])),t["url-list"]=e.urlList||[],void 0!==e.private&&(t["private"]=+e.private),e.created&&(t["creation date"]=0|e.created.getTime()/1e3),e.createdBy&&(t["created by"]=e.createdBy),e.comment&&(t.comment=e.comment),c.encode(t)};(()=>{r.alloc(0)})()}).call(this,e("_process"),e("buffer").Buffer)},{_process:138,bencode:11,"blob-to-buffer":34,buffer:47,fs:46,"magnet-uri":94,path:135,"simple-get":179,"simple-sha1":193,uniq:236}],135:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1,o;0<=r;r--)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){"string"!=typeof e&&(e+="");var t=0,n=-1,r=!0,o;for(o=e.length-1;0<=o;--o)if(!(47===e.charCodeAt(o)))-1===n&&(r=!1,n=o+1);else if(!r){t=o+1;break}return-1===n?"":e.slice(t,n)}function o(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}n.resolve=function(){for(var n="",r=!1,a=arguments.length-1,s;-1<=a&&!r;a--){if(s=0<=a?arguments[a]:e.cwd(),"string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");else if(!s)continue;n=s+"/"+n,r="/"===s.charAt(0)}return n=t(o(n.split("/"),function(e){return!!e}),!r).join("/"),(r?"/":"")+n||"."},n.normalize=function(e){var r=n.isAbsolute(e),a="/"===i(e,-1);return e=t(o(e.split("/"),function(e){return!!e}),!r).join("/"),e||r||(e="."),e&&a&&(e+="/"),(r?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(o(e,function(e){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<e.length&&""===e[t];t++);for(var n=e.length-1;0<=n&&""===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("/")),a=r(t.split("/")),s=d(o.length,a.length),l=s,c=0;c<s;c++)if(o[c]!==a[c]){l=c;break}for(var u=[],c=l;c<o.length;c++)u.push("..");return u=u.concat(a.slice(l)),u.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,a=e.length-1;1<=a;--a)if(t=e.charCodeAt(a),47!==t)o=!1;else if(!o){r=a;break}return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=r(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,a=0,s=e.length-1,d;0<=s;--s){if(d=e.charCodeAt(s),47===d){if(!o){n=s+1;break}continue}-1===r&&(o=!1,r=s+1),46===d?-1===t?t=s:1!==a&&(a=1):-1!==t&&(a=-1)}return-1===t||-1===r||0===a||1===a&&t===r-1&&t===n+1?"":e.slice(t,r)};var i=function(e,t,n){return e.substr(t,n)}}).call(this,e("_process"))},{_process:138}],136:[function(e,n){for(var r=e("closest-to"),o=t(2,10),i=13,a=[];22>i++;)a.push(t(2,i));n.exports=function(e){return r(e/o,a)}},{"closest-to":65}],137:[function(e,t){(function(e){"use strict";t.exports=e.version&&0!==e.version.indexOf("v0.")&&(0!==e.version.indexOf("v1.")||0===e.version.indexOf("v1.8."))?e:{nextTick:function(t,n,r,o){if("function"!=typeof t)throw new TypeError("\"callback\" argument must be a function");var a=arguments.length,s,d;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,o)});default:for(s=Array(a-1),d=0;d<s.length;)s[d++]=arguments[d];return e.nextTick(function(){t.apply(null,s)});}}}}).call(this,e("_process"))},{_process:138}],138:[function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(t){if(u===setTimeout)return setTimeout(t,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(n){try{return u.call(null,t,0)}catch(n){return u.call(this,t,0)}}}function i(t){if(p===clearTimeout)return clearTimeout(t);if((p===r||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(t);try{return p(t)}catch(n){try{return p.call(null,t)}catch(n){return p.call(this,t)}}}function a(){h&&g&&(h=!1,g.length?f=g.concat(f):m=-1,f.length&&s())}function s(){if(!h){var e=o(a);h=!0;for(var t=f.length;t;){for(g=f,f=[];++m<t;)g&&g[m].run();m=-1,t=f.length}g=null,h=!1,i(e)}}function d(e,t){this.fun=e,this.array=t}function l(){}var c=t.exports={},u,p;(function(){try{u="function"==typeof setTimeout?setTimeout:n}catch(t){u=n}try{p="function"==typeof clearTimeout?clearTimeout:r}catch(t){p=r}})();var f=[],h=!1,m=-1,g;c.nextTick=function(e){var t=Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new d(e,t)),1!==f.length||h||o(s)},d.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=l,c.addListener=l,c.once=l,c.off=l,c.removeListener=l,c.removeAllListeners=l,c.emit=l,c.prependListener=l,c.prependOnceListener=l,c.listeners=function(){return[]},c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},{}],139:[function(e,t){(function(n){var r=e("once"),o=e("end-of-stream"),i=e("fs"),a=function(){},s=/^v?\.0/.test(n.version),d=function(e){return"function"==typeof e},l=function(e){return!!s&&!!i&&(e instanceof(i.ReadStream||a)||e instanceof(i.WriteStream||a))&&d(e.close)},c=function(e){return e.setHeader&&d(e.abort)},u=function(e,t,n,i){i=r(i);var s=!1;e.on("close",function(){s=!0}),o(e,{readable:t,writable:n},function(e){return e?i(e):void(s=!0,i())});var u=!1;return function(t){if(!s)return u?void 0:(u=!0,l(e)?e.close(a):c(e)?e.abort():d(e.destroy)?e.destroy():void i(t||new Error("stream was destroyed")))}},p=function(e){e()},f=function(e,t){return e.pipe(t)};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=d(e[e.length-1]||a)&&e.pop()||a;if(Array.isArray(e[0])&&(e=e[0]),2>e.length)throw new Error("pump requires two streams per minimum");var n=e.map(function(o,a){var i=a<e.length-1;return u(o,i,0<a,function(e){r||(r=e),e&&n.forEach(p),i||(n.forEach(p),t(r))})}),r;return e.reduce(f)}}).call(this,e("_process"))},{_process:138,"end-of-stream":72,fs:45,once:132}],140:[function(e,t,r){(function(e){/*! https://mths.be/punycode v1.4.1 by @mathias */(function(i){function a(e){throw new RangeError(C[e])}function s(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function d(e,t){var n=e.split("@"),r="";1<n.length&&(r=n[0]+"@",e=n[1]),e=e.replace(x,".");var o=e.split("."),i=s(o,t).join(".");return r+i}function c(e){for(var t=[],n=0,r=e.length,o,i;n<r;)o=e.charCodeAt(n++),55296<=o&&56319>=o&&n<r?(i=e.charCodeAt(n++),56320==(64512&i)?t.push(((1023&o)<<10)+(1023&i)+65536):(t.push(o),n--)):t.push(o);return t}function u(e){return s(e,function(e){var t="";return 65535<e&&(e-=65536,t+=v(55296|1023&e>>>10),e=56320|1023&e),t+=v(e),t}).join("")}function p(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:36}function f(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?S(e/700):e>>1,e+=S(e/t);455<e;r+=36)e=S(e/35);return S(r+36*e/(e+38))}function m(e){var r=[],o=e.length,s=0,d=128,l=72,c,f,m,g,_,b,y,x,C,v;for(f=e.lastIndexOf("-"),0>f&&(f=0),m=0;m<f;++m)128<=e.charCodeAt(m)&&a("not-basic"),r.push(e.charCodeAt(m));for(g=0<f?f+1:0;g<o;){for(_=s,b=1,y=36;;y+=36){if(g>=o&&a("invalid-input"),x=p(e.charCodeAt(g++)),(36<=x||x>S((2147483647-s)/b))&&a("overflow"),s+=x*b,C=y<=l?1:y>=l+26?26:y-l,x<C)break;v=36-C,b>S(2147483647/v)&&a("overflow"),b*=v}c=r.length+1,l=h(s-_,c,0==_),S(s/c)>2147483647-d&&a("overflow"),d+=S(s/c),s%=c,r.splice(s++,0,d)}return u(r)}function g(e){var r=[],o,i,s,d,l,u,p,g,_,b,y,w,x,C,E;for(e=c(e),w=e.length,o=128,i=0,l=72,u=0;u<w;++u)y=e[u],128>y&&r.push(v(y));for(s=d=r.length,d&&r.push("-");s<w;){for(p=2147483647,u=0;u<w;++u)y=e[u],y>=o&&y<p&&(p=y);for(x=s+1,p-o>S((2147483647-i)/x)&&a("overflow"),i+=(p-o)*x,o=p,u=0;u<w;++u)if(y=e[u],y<o&&2147483647<++i&&a("overflow"),y==o){for(g=i,_=36;;_+=36){if(b=_<=l?1:_>=l+26?26:_-l,g<b)break;E=g-b,C=36-b,r.push(v(f(b+E%C,0))),g=S(E/C)}r.push(v(f(g,0))),l=h(i,x,s==d),i=0,++s}++i,++o}return r.join("")}var _="object"==typeof r&&r&&!r.nodeType&&r,b="object"==typeof t&&t&&!t.nodeType&&t,y="object"==typeof e&&e;(y.global===y||y.window===y||y.self===y)&&(i=y);var w=/^xn--/,k=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=n,v=o,E,L;if(E={version:"1.4.1",ucs2:{decode:c,encode:u},decode:m,encode:g,toASCII:function(e){return d(e,function(e){return k.test(e)?"xn--"+g(e):e})},toUnicode:function(e){return d(e,function(e){return w.test(e)?m(e.slice(4).toLowerCase()):e})}},"function"==typeof l&&"object"==typeof l.amd&&l.amd)l("punycode",function(){return E});else if(!(_&&b))i.punycode=E;else if(t.exports==_)b.exports=E;else for(L in E)E.hasOwnProperty(L)&&(_[L]=E[L])})(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],141:[function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,o,a){t=t||"&",o=o||"=";var s={};if("string"!=typeof e||0===e.length)return s;var d=/\+/g;e=e.split(t);var l=1e3;a&&"number"==typeof a.maxKeys&&(l=a.maxKeys);var c=e.length;0<l&&c>l&&(c=l);for(var u=0;u<c;++u){var p=e[u].replace(d,"%20"),f=p.indexOf(o),h,m,g,_;0<=f?(h=p.substr(0,f),m=p.substr(f+1)):(h=p,m=""),g=decodeURIComponent(h),_=decodeURIComponent(m),n(s,g)?r(s[g])?s[g].push(_):s[g]=[s[g],_]:s[g]=_}return s};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],142:[function(e,t){"use strict";function n(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return"";}};t.exports=function(e,t,a,s){return t=t||"&",a=a||"=",null===e&&(e=void 0),"object"==typeof e?n(i(e),function(i){var s=encodeURIComponent(r(i))+a;return o(e[i])?n(e[i],function(e){return s+encodeURIComponent(r(e))}).join(t):s+encodeURIComponent(r(e[i]))}).join(t):s?encodeURIComponent(r(s))+a+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},i=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],143:[function(e,t,n){"use strict";n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":141,"./encode":142}],144:[function(e,t){t.exports=function(e){var t=0;return function(){if(t===e.length)return null;var n=e.length-t,r=0|Math.random()*n,o=e[t+r],i=e[t];return e[t]=o,e[t+r]=i,t++,o}}},{}],145:[function(e,t){(function(n,r){"use strict";var o=e("safe-buffer").Buffer,i=r.crypto||r.msCrypto;t.exports=i&&i.getRandomValues?function(e,t){if(65536<e)throw new Error("requested too many random bytes");var a=new r.Uint8Array(e);0<e&&i.getRandomValues(a);var s=o.from(a.buffer);return"function"==typeof t?n.nextTick(function(){t(null,s)}):s}:function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:138,"safe-buffer":177}],146:[function(e,t){function n(e,t){var r=this;return r instanceof n?void(o.Writable.call(r,t),r.destroyed=!1,r._queue=[],r._position=e||0,r._cb=null,r._buffer=null,r._out=null):new n(e)}var r=e("inherits"),o=e("readable-stream");t.exports=n,r(n,o.Writable),n.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],a=s(i.start-r._position,0),d=i.end-r._position;if(a>=e.length)return r._position+=e.length,n(null);var l;if(d>e.length){r._position+=e.length,l=0===a?e:e.slice(a),o=i.stream.write(l)&&o;break}r._position+=d,l=0===a&&d===e.length?e:e.slice(a,d),o=i.stream.write(l)&&o,i.last&&i.stream.end(),e=e.slice(d),r._queue.shift()}o?n(null):i.stream.once("drain",n.bind(null,null))},n.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var n=new o.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},n.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,e&&t.emit("error",e))}},{inherits:87,"readable-stream":155}],147:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":149,"./_stream_writable":151,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],148:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":150,"core-util-is":66,dup:19,inherits:87}],149:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":147,"./internal/streams/BufferList":152,"./internal/streams/destroy":153,"./internal/streams/stream":154,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],150:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":147,"core-util-is":66,dup:21,inherits:87}],151:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":147,"./internal/streams/destroy":153,"./internal/streams/stream":154,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],152:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],153:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],154:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],155:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":147,"./lib/_stream_passthrough.js":148,"./lib/_stream_readable.js":149,"./lib/_stream_transform.js":150,"./lib/_stream_writable.js":151,dup:26}],156:[function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&("object"==typeof t||"function"==typeof t)?t:e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t,i){function a(e,n,r){return"string"==typeof t?t:t(e,n,r)}i||(i=Error);var s=function(e){function t(e,o,i){return n(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,a(e,o,i)))}return o(t,e),t}(i);s.prototype.name=i.name,s.prototype.code=e,u[e]=s}function a(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return e+""}),2<n?"one of "+t+" "+e.slice(0,n-1).join(", ")+", or "+e[n-1]:2===n?"one of "+t+" "+e[0]+" or "+e[1]:"of "+t+" "+e[0]}return"of "+t+" "+(e+"")}function s(e,t,n){return e.substr(!n||0>n?0:+n,t.length)===t}function d(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function l(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u={};i("ERR_INVALID_OPT_VALUE",function(e,t){return"The value \""+t+"\" is invalid for option \""+e+"\""},TypeError),i("ERR_INVALID_ARG_TYPE",function(e,t,n){var r;"string"==typeof t&&s(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be";var o;if(d(e," argument"))o="The "+e+" "+r+" "+a(t,"type");else{var i=l(e,".")?"property":"argument";o="The \""+e+"\" "+i+" "+r+" "+a(t,"type")}return o+=". Received type "+("undefined"==typeof n?"undefined":c(n)),o},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=u},{}],157:[function(e,t){(function(e){"use strict";var n=new Set;t.exports.emitExperimentalWarning=e.emitWarning?function(t){if(!n.has(t)){n.add(t),e.emitWarning(t+" is an experimental feature. This feature could change at any time","ExperimentalWarning")}}:function(){}}).call(this,e("_process"))},{_process:138}],158:[function(e,t){(function(n){"use strict";function r(e){return this instanceof r?void(s.call(this,e),d.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",o)))):new r(e)}function o(){this._writableState.ended||n.nextTick(i,this)}function i(e){e.end()}var a=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=r;var s=e("./_stream_readable"),d=e("./_stream_writable");e("inherits")(r,s);for(var l=a(d.prototype),c=0,u;c<l.length;c++)u=l[c],r.prototype[u]||(r.prototype[u]=d.prototype[u]);Object.defineProperty(r.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(r.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(r.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(r.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0===this._readableState||void 0===this._writableState||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this,e("_process"))},{"./_stream_readable":160,"./_stream_writable":162,_process:138,inherits:87}],159:[function(e,t){"use strict";function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./_stream_transform");e("inherits")(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":161,inherits:87}],160:[function(e,t){(function(n,r){"use strict";function o(e){return U.from(e)}function i(e){return U.isBuffer(e)||e instanceof P}function a(e,t,n){return"function"==typeof e.prependListener?e.prependListener(t,n):void(e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n))}function s(t,n,r){B=B||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof B),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=H(this,t,"readableHighWaterMark",r),this.buffer=new j,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.emitClose=!1!==t.emitClose,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(!Y&&(Y=e("string_decoder/").StringDecoder),this.decoder=new Y(t.encoding),this.encoding=t.encoding)}function d(t){if(B=B||e("./_stream_duplex"),!(this instanceof d))return new d(t);var n=this instanceof B;this._readableState=new s(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),A.call(this)}function l(e,t,n,r,i){O("readableAddChunk",t);var a=e._readableState;if(null===t)a.reading=!1,h(e,a);else{var s;if(i||(s=u(a,t)),s)e.emit("error",s);else if(!(a.objectMode||t&&0<t.length))r||(a.reading=!1,_(e,a));else if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===U.prototype||(t=o(t)),r)a.endEmitted?e.emit("error",new V):c(e,a,t,!0);else if(a.ended)e.emit("error",new W);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?c(e,a,t,!1):_(e,a)):c(e,a,t,!1)}}return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function c(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&m(e)),_(e,t)}function u(e,t){var n;return i(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new D("chunk",["string","Buffer","Uint8Array"],t)),n}function p(e){return 8388608<=e?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function f(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=p(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function h(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,t.sync?m(e):(t.needReadable=!1,!t.emittedReadable&&(t.emittedReadable=!0,g(e)))}}function m(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(O("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(g,e))}function g(e){var t=e._readableState;O("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&e.emit("readable"),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,S(e)}function _(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(b,e,t))}function b(e,t){for(var n=t.length;!t.reading&&!t.ended&&t.length<t.highWaterMark&&(O("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function y(e){return function(){var t=e._readableState;O("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&R(e,"data")&&(t.flowing=!0,S(e))}}function w(e){e._readableState.readableListening=0<e.listenerCount("readable"),0<e.listenerCount("data")&&e.resume()}function k(e){O("readable nexttick read 0"),e.read(0)}function x(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(C,e,t))}function C(e,t){O("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),S(e),t.flowing&&!t.reading&&e.read(0)}function S(e){var t=e._readableState;for(O("flow",t.flowing);t.flowing&&null!==e.read(););}function v(e,t){if(0===t.length)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function E(e){var t=e._readableState;O("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(L,t,e))}function L(e,t){O("endReadableNT",e.endEmitted,e.length),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<r;n++)if(e[n]===t)return n;return-1}t.exports=d;var B;d.ReadableState=s;var T=e("events").EventEmitter,R=function(e,t){return e.listeners(t).length},A=e("./internal/streams/stream"),U=e("buffer").Buffer,P=r.Uint8Array||function(){},M=e("util"),O=void 0;O=M&&M.debuglog?M.debuglog("stream"):function(){};var j=e("./internal/streams/buffer_list"),N=e("./internal/streams/destroy"),F=e("./internal/streams/state"),H=F.getHighWaterMark,q=e("../errors").codes,D=q.ERR_INVALID_ARG_TYPE,W=q.ERR_STREAM_PUSH_AFTER_EOF,z=q.ERR_METHOD_NOT_IMPLEMENTED,V=q.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,G=e("../experimentalWarning"),K=G.emitExperimentalWarning,Y=void 0,X=void 0;e("inherits")(d,A);var $=["error","close","destroy","pause","resume"];Object.defineProperty(d.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),d.prototype.destroy=N.destroy,d.prototype._undestroy=N.undestroy,d.prototype._destroy=function(e,t){t(e)},d.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:"string"==typeof e&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=U.from(e,t),t=""),r=!0),l(this,e,t,!1,r)},d.prototype.unshift=function(e){return l(this,e,null,!0,!1)},d.prototype.isPaused=function(){return!1===this._readableState.flowing},d.prototype.setEncoding=function(t){return Y||(Y=e("string_decoder/").StringDecoder),this._readableState.decoder=new Y(t),this._readableState.encoding=this._readableState.decoder.encoding,this};d.prototype.read=function(e){O("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0===t.highWaterMark?0<t.length:t.length>=t.highWaterMark)||t.ended))return O("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?E(this):m(this),null;if(e=f(e,t),0===e&&t.ended)return 0===t.length&&E(this),null;var o=t.needReadable;O("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&(o=!0,O("length less than watermark",o)),t.ended||t.reading?(o=!1,O("reading or ended",o)):o&&(O("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,!t.reading&&(e=f(r,t)));var i;return i=0<e?v(e,t):null,null===i?(t.needReadable=!0,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(!t.ended&&(t.needReadable=!0),r!==e&&t.ended&&E(this)),null!==i&&this.emit("data",i),i},d.prototype._read=function(){this.emit("error",new z("_read()"))},d.prototype.pipe=function(e,t){function r(e,t){O("onunpipe"),e===p&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,i())}function o(){O("onend"),e.end()}function i(){O("cleanup"),e.removeListener("close",l),e.removeListener("finish",c),e.removeListener("drain",g),e.removeListener("error",d),e.removeListener("unpipe",r),p.removeListener("end",o),p.removeListener("end",u),p.removeListener("data",s),_=!0,f.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&g()}function s(t){O("ondata");var n=e.write(t);O("dest.write",n),!1===n&&((1===f.pipesCount&&f.pipes===e||1<f.pipesCount&&-1!==I(f.pipes,e))&&!_&&(O("false write response, pause",f.awaitDrain),f.awaitDrain++),p.pause())}function d(t){O("onerror",t),u(),e.removeListener("error",d),0===R(e,"error")&&e.emit("error",t)}function l(){e.removeListener("finish",c),u()}function c(){O("onfinish"),e.removeListener("close",l),u()}function u(){O("unpipe"),p.unpipe(e)}var p=this,f=this._readableState;switch(f.pipesCount){case 0:f.pipes=e;break;case 1:f.pipes=[f.pipes,e];break;default:f.pipes.push(e);}f.pipesCount+=1,O("pipe count=%d opts=%j",f.pipesCount,t);var h=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr,m=h?o:u;f.endEmitted?n.nextTick(m):p.once("end",m),e.on("unpipe",r);var g=y(p);e.on("drain",g);var _=!1;return p.on("data",s),a(e,"error",d),e.once("close",l),e.once("finish",c),e.emit("pipe",p),f.flowing||(O("pipe resume"),p.resume()),e},d.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};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,n),this);if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<o;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var s=I(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},d.prototype.on=function(e,t){var r=A.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=0<this.listenerCount("readable"),!1!==o.flowing&&this.resume()):"readable"==e&&!o.endEmitted&&!o.readableListening&&(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,O("on readable",o.length,o.reading),o.length?m(this):!o.reading&&n.nextTick(k,this)),r},d.prototype.addListener=d.prototype.on,d.prototype.removeListener=function(e,t){var r=A.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(w,this),r},d.prototype.removeAllListeners=function(e){var t=A.prototype.removeAllListeners.apply(this,arguments);return("readable"===e||void 0===e)&&n.nextTick(w,this),t},d.prototype.resume=function(){var e=this._readableState;return e.flowing||(O("resume"),e.flowing=!e.readableListening,x(this,e)),this},d.prototype.pause=function(){return O("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(O("pause"),this._readableState.flowing=!1,this.emit("pause")),this},d.prototype.wrap=function(e){var t=this,r=this._readableState,o=!1;for(var a in e.on("end",function(){if(O("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){if((O("wrapped data"),r.decoder&&(n=r.decoder.write(n)),!(r.objectMode&&(null===n||void 0===n)))&&(r.objectMode||n&&n.length)){var i=t.push(n);i||(o=!0,e.pause())}}),e)void 0===this[a]&&"function"==typeof e[a]&&(this[a]=function(t){return function(){return e[t].apply(e,arguments)}}(a));for(var i=0;i<$.length;i++)e.on($[i],this.emit.bind(this,$[i]));return this._read=function(t){O("wrapped _read",t),o&&(o=!1,e.resume())},this},"function"==typeof Symbol&&(d.prototype[Symbol.asyncIterator]=function(){return K("Readable[Symbol.asyncIterator]"),void 0===X&&(X=e("./internal/streams/async_iterator")),new X(this)}),Object.defineProperty(d.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(d.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(d.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),d._fromList=v,Object.defineProperty(d.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}})}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../errors":156,"../experimentalWarning":157,"./_stream_duplex":158,"./internal/streams/async_iterator":163,"./internal/streams/buffer_list":164,"./internal/streams/destroy":165,"./internal/streams/state":166,"./internal/streams/stream":167,_process:138,buffer:47,events:48,inherits:87,"string_decoder/":224,util:45}],161:[function(e,t){"use strict";function n(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new d);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function r(e){return this instanceof r?void(u.call(this,e),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",o)):new r(e)}function o(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?i(this,null,null):this._flush(function(t,n){i(e,t,n)})}function i(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new c;if(e._transformState.transforming)throw new l;return e.push(null)}t.exports=r;var a=e("../errors").codes,s=a.ERR_METHOD_NOT_IMPLEMENTED,d=a.ERR_MULTIPLE_CALLBACK,l=a.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=a.ERR_TRANSFORM_WITH_LENGTH_0,u=e("./_stream_duplex");e("inherits")(r,u),r.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},r.prototype._transform=function(e,t,n){n(new s("_transform()"))},r.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},r.prototype._read=function(){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},r.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,function(e){t(e)})}},{"../errors":156,"./_stream_duplex":158,inherits:87}],162:[function(e,t){(function(n,r){"use strict";function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){E(t,e)}}function i(e){return T.from(e)}function a(e){return T.isBuffer(e)||e instanceof R}function s(){}function d(t,n,r){L=L||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof L),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=P(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=!1===t.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){_(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function l(t){L=L||e("./_stream_duplex");var n=this instanceof L;return n||z.call(l,this)?void(this._writableState=new d(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),B.call(this)):new l(t)}function c(e,t){var r=new D;e.emit("error",r),n.nextTick(t,r)}function u(e,t,r,o){var i;return null===r?i=new q:"string"!=typeof r&&!t.objectMode&&(i=new O("chunk",["string","Buffer"],r)),!i||(e.emit("error",i),n.nextTick(o,i),!1)}function p(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=T.from(t,n)),t}function f(e,t,n,r,o,i){if(!n){var a=p(t,r,o);r!==a&&(n=!0,o="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var d=t.length<t.highWaterMark;if(d||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else h(e,t,!1,s,r,o,i);return d}function h(e,t,n,r,o,i,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new H("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function m(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",o)):(i(o),e._writableState.errorEmitted=!0,e.emit("error",o),S(e,t))}function g(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function _(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new N;if(g(r),t)m(e,r,o,t,i);else{var a=k(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),o?n.nextTick(b,e,r,a,i):b(e,r,a,i)}}function b(e,t,n,r){n||y(e,t),t.pendingcb--,r(),S(e,t)}function y(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function w(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=Array(r),a=t.corkedRequestsFree;a.entry=n;for(var s=0,d=!0;n;)i[s]=n,n.isBuf||(d=!1),n=n.next,s+=1;i.allBuffers=d,h(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,c=n.encoding,u=n.callback,p=t.objectMode?1:l.length;if(h(e,t,!1,p,l,c,u),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function C(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(x,e,t)))}function S(e,t){var n=k(t);return n&&(C(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}function v(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function E(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}t.exports=l;var L;l.WritableState=d;var I={deprecate:e("util-deprecate")},B=e("./internal/streams/stream"),T=e("buffer").Buffer,R=r.Uint8Array||function(){},A=e("./internal/streams/destroy"),U=e("./internal/streams/state"),P=U.getHighWaterMark,M=e("../errors").codes,O=M.ERR_INVALID_ARG_TYPE,j=M.ERR_METHOD_NOT_IMPLEMENTED,N=M.ERR_MULTIPLE_CALLBACK,F=M.ERR_STREAM_CANNOT_PIPE,H=M.ERR_STREAM_DESTROYED,q=M.ERR_STREAM_NULL_VALUES,D=M.ERR_STREAM_WRITE_AFTER_END,W=M.ERR_UNKNOWN_ENCODING;e("inherits")(l,B),d.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(d.prototype,"buffer",{get:I.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var z;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(z=Function.prototype[Symbol.hasInstance],Object.defineProperty(l,Symbol.hasInstance,{value:function(e){return!!z.call(this,e)||!(this!==l)&&e&&e._writableState instanceof d}})):z=function(e){return e instanceof this},l.prototype.pipe=function(){this.emit("error",new F)},l.prototype.write=function(e,t,n){var r=this._writableState,o=!1,d=!r.objectMode&&a(e);return d&&!T.isBuffer(e)&&(e=i(e)),"function"==typeof t&&(n=t,t=null),d?t="buffer":!t&&(t=r.defaultEncoding),"function"!=typeof n&&(n=s),r.ending?c(this,n):(d||u(this,r,e,n))&&(r.pendingcb++,o=f(this,r,d,e,t,n)),o},l.prototype.cork=function(){this._writableState.corked++},l.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&w(this,e))},l.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())))throw new W(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),l.prototype._write=function(e,t,n){n(new j("_write()"))},l.prototype._writev=null,l.prototype.end=function(e,t,n){var r=this._writableState;return"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||v(this,r,n),this},Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),l.prototype.destroy=A.destroy,l.prototype._undestroy=A.undestroy,l.prototype._destroy=function(e,t){t(e)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../errors":156,"./_stream_duplex":158,"./internal/streams/destroy":165,"./internal/streams/state":166,"./internal/streams/stream":167,_process:138,buffer:47,inherits:87,"util-deprecate":244}],163:[function(e,t){(function(e){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){var t=e[l];if(null!==t){var n=e[m].read();null!==n&&(e[f]=null,e[l]=null,e[c]=null,t(new g(n,!1)))}}function o(t){e.nextTick(r,t)}function i(e){var t=e[l];null!==t&&(e[f]=null,e[l]=null,e[c]=null,t(new g(null,!0))),e[p]=!0}function a(e,t){var n=e[c];null!==n&&(e[f]=null,e[l]=null,e[c]=null,n(t)),e[u]=t}function s(e,t){return function(n,r){e.then(function(){t[h](n,r)},r)}}var d=function(){function e(e,t){for(var n=0,r;n<t.length;n++)r=t[n],r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),p=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),m=Symbol("stream"),g=function e(t,r){n(this,e),this.done=r,this.value=t},_=function(){function e(t){var r=this;n(this,e),this[m]=t,this[l]=null,this[c]=null,this[u]=null,this[p]=!1,this[f]=null,t.on("readable",o.bind(null,this)),t.on("end",i.bind(null,this)),t.on("error",a.bind(null,this)),this[h]=function(e,t){var n=r[m].read();n?(r[f]=null,r[l]=null,r[c]=null,e(new g(n,!1))):(r[l]=e,r[c]=t)}}return e.prototype.next=function(){var e=this[u];if(null!==e)return Promise.reject(e);if(this[p])return Promise.resolve(new g(null,!0));var t=this[f],n=void 0;if(t)n=new Promise(s(t,this));else{var r=this[m].read();if(null!==r)return Promise.resolve(new g(r,!1));n=new Promise(this[h])}return this[f]=n,n},e.prototype.return=function(){var e=this;return new Promise(function(t,n){e[m].destroy(null,function(e){return e?void n(e):void t(new g(null,!0))})})},d(e,[{key:"stream",get:function(){return this[m]}}]),e}();t.exports=_}).call(this,e("_process"))},{_process:138}],164:[function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,n){a.prototype.copy.call(e,t,n)}var o=e("buffer"),a=o.Buffer,s=e("util"),d=s.inspect,l=d&&l||"inspect";t.exports=function(){function e(){n(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};0<this.length?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.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},e.prototype.concat=function(e){if(0===this.length)return a.alloc(0);for(var t=a.allocUnsafe(e>>>0),n=this.head,o=0;n;)r(n.data,t,o),o+=n.data.length,n=n.next;return t},e.prototype.consume=function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):e===this.head.data.length?n=this.shift():n=t?this._getString(e):this._getBuffer(e),n},e.prototype.first=function(){return this.head.data},e.prototype._getString=function(e){var t=this.head,r=1,o=t.data;for(e-=o.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(o+=a===i.length?i:i.slice(0,e),e-=a,0===e){a===i.length?(++r,this.head=t.next?t.next:this.tail=null):(this.head=t,t.data=i.slice(a));break}++r}return this.length-=r,o},e.prototype._getBuffer=function(e){var t=a.allocUnsafe(e),r=this.head,o=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,s=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,s),e-=s,0===e){s===i.length?(++o,this.head=r.next?r.next:this.tail=null):(this.head=r,r.data=i.slice(s));break}++o}return this.length-=o,t},e.prototype[l]=function(){var e=d({length:this.length});return this.constructor.name+" "+e},e}()},{buffer:47,util:45}],165:[function(e,t){(function(e){"use strict";function n(e,t){o(e,t),r(e)}function r(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function o(e,t){e.emit("error",t)}t.exports={destroy:function(t,i){var a=this,s=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return s||d?(i?i(t):t&&(!this._writableState||!this._writableState.errorEmitted)&&e.nextTick(o,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!i&&t?(e.nextTick(n,a,t),a._writableState&&(a._writableState.errorEmitted=!0)):i?(e.nextTick(r,a),i(t)):e.nextTick(r,a)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}}).call(this,e("_process"))},{_process:138}],166:[function(e,t){"use strict";function r(e,t,n){return null==e.highWaterMark?t?e[n]:null:e.highWaterMark}var o=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,i,a){var s=r(t,a,i);if(null!=s){if(!Number.isInteger(s)||0>s){var d=a?i:"highWaterMark";throw new o(d,s)}return n(s)}return e.objectMode?16:16384}}},{"../../../errors":156}],167:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],168:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":158,"./lib/_stream_passthrough.js":159,"./lib/_stream_readable.js":160,"./lib/_stream_transform.js":161,"./lib/_stream_writable.js":162,dup:26}],169:[function(e,t,n){function r(e,t,n,r){function i(){S.removeEventListener("loadstart",i),n.autoplay&&S.play()}function s(){S.removeEventListener("canplay",s),r(null,S)}function p(){o(e,function(e,n){return e?k(e):void(".pdf"===x?(S=t("object"),S.setAttribute("typemustmatch",!0),S.setAttribute("type","application/pdf"),S.setAttribute("data",n)):(S=t("iframe"),S.sandbox="allow-forms allow-scripts",S.src=n),r(null,S))})}function k(t){t.message="Error rendering file \""+e.name+"\": "+t.message,d(t.message),r(t)}var x=u.extname(e.name).toLowerCase(),C=0,S;0<=g.indexOf(x)?function(){function r(){d("Use `videostream` package for "+e.name),_(),S.addEventListener("error",p),S.addEventListener("loadstart",i),S.addEventListener("canplay",s),f(e,S)}function l(){d("Use MediaSource API for "+e.name),_(),S.addEventListener("error",g),S.addEventListener("loadstart",i),S.addEventListener("canplay",s);var t=new c(S),n=t.createWriteStream(a(e.name));e.createReadStream().pipe(n),C&&(S.currentTime=C)}function u(){d("Use Blob URL for "+e.name),_(),S.addEventListener("error",k),S.addEventListener("loadstart",i),S.addEventListener("canplay",s),o(e,function(e,t){return e?k(e):void(S.src=t,C&&(S.currentTime=C))})}function p(e){d("videostream error: fallback to MediaSource API: %o",e.message||e),S.removeEventListener("error",p),S.removeEventListener("canplay",s),l()}function g(t){return d("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength?(d("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),k(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"))):void(S.removeEventListener("error",g),S.removeEventListener("canplay",s),u())}function _(){S||(S=t(b),S.addEventListener("progress",function(){C=S.currentTime}))}var b=0<=m.indexOf(x)?"video":"audio";w?0<=h.indexOf(x)?r():l():u()}():0<=_.indexOf(x)?function(){S=t("audio"),o(e,function(e,t){return e?k(e):void(S.addEventListener("error",k),S.addEventListener("loadstart",i),S.addEventListener("canplay",s),S.src=t)})}():0<=b.indexOf(x)?function(){S=t("img"),o(e,function(t,n){return t?k(t):void(S.src=n,S.alt=e.name,r(null,S))})}():0<=y.indexOf(x)?p():function(){function t(){l(n)?(d("File extension \"%s\" appears ascii, so will render.",x),p()):(d("File extension \"%s\" appears non-ascii, will not render.",x),r(new Error("Unsupported file type \""+x+"\": Cannot append to DOM")))}d("Unknown file extension \"%s\" - will attempt to render into iframe",x);var n="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){n+=e}).on("end",t).on("error",r)}()}function o(e,t){var r=u.extname(e.name).toLowerCase();p(e.createReadStream(),n.mime[r],t)}function i(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 a(e){var t=u.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 s(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=200000000)}n.render=function(e,t,n,o){"function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),i(e),s(n),"string"==typeof t&&(t=document.querySelector(t)),r(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=u.extname(e.name).toLowerCase();throw new Error("Cannot render \""+r+"\" inside a \""+t.nodeName.toLowerCase()+"\" element, expected \""+n+"\"")}return t},n,o)},n.append=function(e,t,n,o){function a(e){var r=d(e);return n.autoplay&&(r.autoplay=!0),n.muted&&(r.muted=!0),n.controls&&(r.controls=!0),t.appendChild(r),r}function d(e){var n=document.createElement(e);return t.appendChild(n),n}function l(e,t){e&&t&&t.remove(),o(e,t)}if("function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),i(e),s(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.");r(e,function(e){return"video"===e||"audio"===e?a(e):d(e)},n,l)},n.mime=e("./lib/mime.json");var d=e("debug")("render-media"),l=e("is-ascii"),c=e("mediasource"),u=e("path"),p=e("stream-to-blob-url"),f=e("videostream"),h=[".m4a",".m4v",".mp4"],m=[".m4v",".mkv",".mp4",".webm"],g=[].concat(m,[".m4a",".mp3"]),_=[".aac",".oga",".ogg",".wav",".flac"],b=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],y=[".css",".html",".js",".md",".pdf",".txt"],w="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":170,debug:171,"is-ascii":88,mediasource:95,path:135,"stream-to-blob-url":221,videostream:246}],170:[function(e,t){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"}},{}],171:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./common":172,_process:138,dup:15}],172:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:173}],173:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],174:[function(e,t){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,d),r=null}s?e.nextTick(n):n()}function a(e,n,r){if(d[e]=r,n&&(p=!0),0==--c||n)o(n);else if(!p&&f<l){var i;u?(i=u[f],f+=1,t[i](function(e,t){a(i,e,t)})):(i=f,f+=1,t[i](function(e,t){a(i,e,t)}))}}if("number"!=typeof n)throw new Error("second argument must be a Number");var s=!0,d,l,c,u,p;Array.isArray(t)?(d=[],c=l=t.length):(u=Object.keys(t),d={},c=l=u.length);var f=n;c?u?u.some(function(e,r){if(t[e](function(t,n){a(e,t,n)}),r===n-1)return!0}):t.some(function(e,t){if(e(function(e,n){a(t,e,n)}),t===n-1)return!0}):o(null),s=!1}}).call(this,e("_process"))},{_process:138}],175:[function(e,t){(function(e){t.exports=function(t,n){function r(t){function r(){n&&n(t,a),n=null}i?e.nextTick(r):r()}function o(e,t,n){a[e]=n,(0==--s||t)&&r(t)}var i=!0,a,s,d;Array.isArray(t)?(a=[],s=t.length):(d=Object.keys(t),a={},s=d.length),s?d?d.forEach(function(e){t[e](function(t,n){o(e,t,n)})}):t.forEach(function(e,t){e(function(e,n){o(t,e,n)})}):r(null),i=!1}}).call(this,e("_process"))},{_process:138}],176:[function(e,t,n){(function(e,r){"object"==typeof n&&"object"==typeof t?t.exports=r():"function"==typeof l&&l.amd?l([],r):"object"==typeof n?n.Rusha=r():e.Rusha=r()})("undefined"==typeof self?this:self,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=n(5),i=n(1),a=i.toHex,s=i.ceilHeapSize,l=n(6),c=function(e){for(e+=9;0<e%64;e+=1);return e},u=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 a=(t>>2)+1;a<e.length;a++)e[a]=0},p=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[(-16&(t>>2)+2)+14]=0|n/536870912,e[(-16&(t>>2)+2)+15]=n<<3},f=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},h=function(){function e(t){if(r(this,e),t=t||65536,0<t%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=c(t),this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new o({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},e.prototype._padChunk=function(e,t){var n=c(e),r=new Int32Array(this._heap,0,n>>2);return u(r,e),p(r,e,t),n},e.prototype._write=function(e,t,n,r){l(e,this._h8,this._h32,t,n,r||0)},e.prototype._coreCall=function(e,t,n,r,o){var i=n;this._write(e,t,n),o&&(i=this._padChunk(n,r)),this._core.hash(i,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,r=this._maxChunkLen;for(n=0;t>n+r;n+=r)this._coreCall(e,n,r,t,!1);return this._coreCall(e,n,t-n,t,!0),f(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return a(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,n=e.byteLength||e.length||e.size||0,r=this._offset%this._maxChunkLen,o=void 0;for(this._offset+=n;t<n;)o=d(n-t,this._maxChunkLen-r),this._write(e,t,o,r),r+=o,t+=o,r===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),r=0);return this},e.prototype.getState=function(){var e=this._offset%this._maxChunkLen,t=void 0;if(!e){var n=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=this._heap.slice(0);return{offset:this._offset,heap:t}},e.prototype.setState=function(e){if(this._offset=e.offset,20===e.heap.byteLength){var t=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t.set(new Int32Array(e.heap))}else this._h32.set(new Int32Array(e.heap));return this},e.prototype.rawEnd=function(){var e=this._offset,t=e%this._maxChunkLen,n=this._padChunk(t,e);this._core.hash(n,this._padMaxChunkLen);var r=f(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),r},e.prototype.end=function(){return a(this.rawEnd().buffer)},e}();e.exports=h,e.exports._core=o},function(e){for(var t=Array(256),n=0;256>n;n++)t[n]=(16>n?"0":"")+n.toString(16);e.exports.toHex=function(e){for(var n=new Uint8Array(e),r=Array(e.byteLength),o=0;o<r.length;o++)r[o]=t[n[o]];return r.join("")},e.exports.ceilHeapSize=function(e){var t=0;if(65536>=e)return 65536;if(16777216>e)for(t=1;t<e;t<<=1);else for(t=16777216;t<e;t+=16777216);return t},e.exports.isDedicatedWorkerScope=function(e){var t="WorkerGlobalScope"in e&&e instanceof e.WorkerGlobalScope,n="SharedWorkerGlobalScope"in e&&e instanceof e.SharedWorkerGlobalScope,r="ServiceWorkerGlobalScope"in e&&e instanceof e.ServiceWorkerGlobalScope;return t&&!n&&!r}},function(e,t,n){e.exports=function(){var e=n(0),t=function(e,t,n){try{return n(null,e.digest(t))}catch(t){return n(t)}},r=function(e,t,n,o,i){var a=new self.FileReader;a.onloadend=function(){if(a.error)return i(a.error);var s=a.result;t+=a.result.byteLength;try{e.append(s)}catch(t){return void i(t)}t<o.size?r(e,t,n,o,i):i(null,e.end())},a.readAsArrayBuffer(o.slice(t,t+n))},o=!0;return self.onmessage=function(n){if(o){var i=n.data.data,a=n.data.file,s=n.data.id;if("undefined"!=typeof s&&(a||i)){var d=n.data.blockSize||4194304,l=new e(d);l.resetState();var c=function(e,t){e?self.postMessage({id:s,error:e.name}):self.postMessage({id:s,hash:t})};i&&t(l,i,c),a&&r(l,0,d,a,c)}}},function(){o=!1}}},function(e,t,n){var r=n(4),o=n(0),i=n(7),a=n(2),s=n(1),d=s.isDedicatedWorkerScope,l="undefined"!=typeof self&&d(self);o.disableWorkerBehaviour=l?a():function(){},o.createWorker=function(){var e=r(2),t=e.terminate;return e.terminate=function(){URL.revokeObjectURL(e.objectURL),t.call(e)},e},o.createHash=i,e.exports=o},function(e,t,n){function r(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t.oe=function(e){throw console.error(e),e};var r=t(t.s=ENTRY_MODULE);return r.default||r}function o(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function i(e,t,r){var i={};i[r]=[];var a=t.toString(),s=a.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return i;for(var d=s[1],l=new RegExp("(\\\\n|\\W)"+o(d)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g"),c;c=l.exec(a);)"dll-reference"!==c[3]&&i[r].push(c[3]);for(l=new RegExp("\\("+o(d)+"\\(\"(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))\"\\)\\)\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");c=l.exec(a);)e[c[2]]||(i[r].push(c[1]),e[c[2]]=n(c[1]).m),i[c[2]]=i[c[2]]||[],i[c[2]].push(c[4]);return i}function a(e){var t=Object.keys(e);return t.reduce(function(t,n){return t||0<e[n].length},!1)}function s(e,t){for(var n={main:[t]},r={main:[]},o={main:{}};a(n);)for(var s=Object.keys(n),d=0;d<s.length;d++){var l=s[d],c=n[l],u=c.pop();if(o[l]=o[l]||{},!o[l][u]&&e[l][u]){o[l][u]=!0,r[l]=r[l]||[],r[l].push(u);for(var p=i(e,e[l][u],l),f=Object.keys(p),h=0;h<f.length;h++)n[f[h]]=n[f[h]]||[],n[f[h]]=n[f[h]].concat(p[f[h]])}}return r}e.exports=function(e,t){t=t||{};var o={main:n.m},i=t.all?{main:Object.keys(o)}:s(o,e),a="";Object.keys(i).filter(function(e){return"main"!==e}).forEach(function(e){for(var t=0;i[e][t];)t++;i[e].push(t),o[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+r.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+i[e].map(function(t){return""+JSON.stringify(t)+": "+o[e][t].toString()}).join(",")+"});\n"}),a=a+"("+r.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i.main.map(function(e){return""+JSON.stringify(e)+": "+o.main[e].toString()}).join(",")+"})(self);";var d=new window.Blob([a],{type:"text/javascript"});if(t.bare)return d;var l=window.URL||window.webkitURL||window.mozURL||window.msURL,c=l.createObjectURL(d),u=new window.Worker(c);return u.objectURL=c,u}},function(e){e.exports=function(e,t,n){"use asm";var r=new e.Int32Array(n);return{hash:function(e,t){e|=0,t|=0;var n=0,o=0,i=0,a=0,s=0,d=0,l=0,c=0,u=0,p=0,f=0,h=0,m=0,g=0;for(i=0|r[t+320>>2],s=0|r[t+324>>2],l=0|r[t+328>>2],u=0|r[t+332>>2],f=0|r[t+336>>2],n=0;(0|n)<(0|e);n=0|n+64){for(a=i,d=s,c=l,p=u,h=f,o=0;64>(0|o);o=0|o+4)g=0|r[n+o>>2],m=0|(0|(i<<5|i>>>27)+(s&l|~s&u))+(0|(0|g+f)+1518500249),f=u,u=l,l=s<<30|s>>>2,s=i,i=m,r[e+o>>2]=g;for(o=0|e+64;(0|o)<(0|e+80);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(s&l|~s&u))+(0|(0|g+f)+1518500249),f=u,u=l,l=s<<30|s>>>2,s=i,i=m,r[o>>2]=g;for(o=0|e+80;(0|o)<(0|e+160);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(s^l^u))+(0|(0|g+f)+1859775393),f=u,u=l,l=s<<30|s>>>2,s=i,i=m,r[o>>2]=g;for(o=0|e+160;(0|o)<(0|e+240);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(s&l|s&u|l&u))+(0|(0|g+f)-1894007588),f=u,u=l,l=s<<30|s>>>2,s=i,i=m,r[o>>2]=g;for(o=0|e+240;(0|o)<(0|e+320);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(s^l^u))+(0|(0|g+f)-899497514),f=u,u=l,l=s<<30|s>>>2,s=i,i=m,r[o>>2]=g;i=0|i+a,s=0|s+d,l=0|l+c,u=0|u+p,f=0|f+h}r[t+320>>2]=i,r[t+324>>2]=s,r[t+328>>2]=l,r[t+332>>2]=u,r[t+336>>2]=f}}}},function(e){var t=this,n=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(n=new self.FileReaderSync);var r=function(e,t,n,r,o,a){var s=a%4,d=(o+s)%4,l=o-d,c;switch(s){case 0:t[a]=e.charCodeAt(r+3);case 1:t[0|a+1-(s<<1)]=e.charCodeAt(r+2);case 2:t[0|a+2-(s<<1)]=e.charCodeAt(r+1);case 3:t[0|a+3-(s<<1)]=e.charCodeAt(r);}if(!(o<d+(4-s))){for(c=4-s;c<l;c=0|c+4)n[a+c>>2]=e.charCodeAt(r+c)<<24|e.charCodeAt(r+c+1)<<16|e.charCodeAt(r+c+2)<<8|e.charCodeAt(r+c+3);switch(d){case 3:t[0|a+l+1]=e.charCodeAt(r+l+2);case 2:t[0|a+l+2]=e.charCodeAt(r+l+1);case 1:t[0|a+l+3]=e.charCodeAt(r+l);}}},o=function(e,t,n,r,o,a){var s=a%4,d=(o+s)%4,l=o-d,c;switch(s){case 0:t[a]=e[r+3];case 1:t[0|a+1-(s<<1)]=e[r+2];case 2:t[0|a+2-(s<<1)]=e[r+1];case 3:t[0|a+3-(s<<1)]=e[r];}if(!(o<d+(4-s))){for(c=4-s;c<l;c=0|c+4)n[0|a+c>>2]=e[r+c]<<24|e[r+c+1]<<16|e[r+c+2]<<8|e[r+c+3];switch(d){case 3:t[0|a+l+1]=e[r+l+2];case 2:t[0|a+l+2]=e[r+l+1];case 1:t[0|a+l+3]=e[r+l];}}},i=function(e,t,r,o,a,s){var d=void 0,l=s%4,c=(a+l)%4,u=a-c,p=new Uint8Array(n.readAsArrayBuffer(e.slice(o,o+a)));switch(l){case 0:t[s]=p[3];case 1:t[0|s+1-(l<<1)]=p[2];case 2:t[0|s+2-(l<<1)]=p[1];case 3:t[0|s+3-(l<<1)]=p[0];}if(!(a<c+(4-l))){for(d=4-l;d<u;d=0|d+4)r[0|s+d>>2]=p[d]<<24|p[d+1]<<16|p[d+2]<<8|p[d+3];switch(c){case 3:t[0|s+u+1]=p[u+2];case 2:t[0|s+u+2]=p[u+1];case 1:t[0|s+u+3]=p[u];}}};e.exports=function(e,n,a,s,d,l){if("string"==typeof e)return r(e,n,a,s,d,l);if(e instanceof Array)return o(e,n,a,s,d,l);if(t&&t.Buffer&&t.Buffer.isBuffer(e))return o(e,n,a,s,d,l);if(e instanceof ArrayBuffer)return o(new Uint8Array(e),n,a,s,d,l);if(e.buffer instanceof ArrayBuffer)return o(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n,a,s,d,l);if(e instanceof Blob)return i(e,n,a,s,d,l);throw new Error("Unsupported data type.")}},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=n(0),i=n(1),a=i.toHex,s=function(){function e(){r(this,e),this._rusha=new o,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function e(t){var e=this._rusha.rawEnd().buffer;if(!t)return e;if("hex"===t)return a(e);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new s}}])})},{}],177:[function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return a(e,t,n)}var i=e("buffer"),a=i.Buffer;a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=i:(r(i,n),n.Buffer=o),r(a,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return a(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=a(e);return void 0===t?r.fill(0):"string"==typeof n?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return a(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:47}],178:[function(e,t){(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:47}],179:[function(e,t){(function(n){function r(e,t){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),t=d(t),e.url){const{hostname:t,port:n,protocol:r,auth:o,path:i}=c.parse(e.url);delete e.url,t||n||r||o?Object.assign(e,{hostname:t,port:n,protocol:r,auth:o,path:i}):e.path=i}const o={"accept-encoding":"gzip, deflate"};e.headers&&Object.keys(e.headers).forEach(t=>o[t.toLowerCase()]=e.headers[t]),e.headers=o;let p;e.body?p=e.json&&!u(e.body)?JSON.stringify(e.body):e.body:e.form&&(p="string"==typeof e.form?e.form:l.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),p&&(!e.method&&(e.method="POST"),!u(p)&&(e.headers["content-length"]=n.byteLength(p)),e.json&&!e.form&&(e.headers["content-type"]="application/json")),delete e.body,delete e.form,e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const f="https:"===e.protocol?s:a,h=f.request(e,n=>{if(300<=n.statusCode&&400>n.statusCode&&n.headers.location)return e.url=n.headers.location,delete e.headers.host,n.resume(),"POST"===e.method&&[301,302].includes(n.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?t(new Error("too many redirects")):r(e,t);const o="function"==typeof i&&"HEAD"!==e.method;t(null,o?i(n):n)});return h.on("timeout",()=>{h.abort(),t(new Error("Request timed out"))}),h.on("error",t),u(p)?p.on("error",t).pipe(h):h.end(p),h}t.exports=r;const o=e("simple-concat"),i=e("decompress-response"),a=e("http"),s=e("https"),d=e("once"),l=e("querystring"),c=e("url"),u=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;r.concat=(e,t)=>r(e,(n,r)=>n?t(n):void o(r,(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(e=>{r[e]=(t,n)=>("string"==typeof t&&(t={url:t}),r(Object.assign({method:e.toUpperCase()},t),n))})}).call(this,e("buffer").Buffer)},{buffer:47,"decompress-response":45,http:208,https:49,once:132,querystring:143,"simple-concat":178,url:238}],180:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._id=l(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),c.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||l(20).toString("hex"):null,t._isChromium="undefined"!=typeof window&&!!window.webkitRTCPeerConnection,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=e.config||r.config,t.constraints=t._transformConstraints(e.constraints||r.constraints),t.offerConstraints=t._transformConstraints(e.offerConstraints||{}),t.answerConstraints=t._transformConstraints(e.answerConstraints||{}),t.sdpTransform=e.sdpTransform||function(e){return e},t.streams=e.streams||(e.stream?[e.stream]:[]),t.trickle=void 0===e.trickle||e.trickle,t.destroyed=!1,t.connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:s(),!t._wrtc)if("undefined"==typeof window)throw o("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT");else throw o("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._channel=null,t._pendingCandidates=[],t._isNegotiating=!1,t._batchedNegotiation=!1,t._queuedNegotiation=!1,t._sendersAwaitingStable=[],t._senderMap=new WeakMap,t._remoteTracks=[],t._remoteStreams=[],t._chunk=null,t._cb=null,t._interval=null,t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints),t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceStateChange()},t._pc.onicegatheringstatechange=function(){t._onIceStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.initiator?t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}):t._pc.ondatachannel=function(e){t._setupData(e)},"addTrack"in t._pc&&(t.streams&&t.streams.forEach(function(e){t.addStream(e)}),t._pc.ontrack=function(e){t._onTrack(e)}),t.initiator&&t._needsNegotiation(),t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}function o(e,t){var n=new Error(e);return n.code=t,n}function i(){}t.exports=r;var a=e("debug")("simple-peer"),s=e("get-browser-rtc"),d=e("inherits"),l=e("randombytes"),c=e("readable-stream"),u=65536;d(r,c.Duplex),r.WEBRTC_SUPPORT=!!s(),r.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}]},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){var t=this;if(t.destroyed)throw o("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}t._debug("signal()"),e.renegotiate&&(t._debug("got request to renegotiate"),t._needsNegotiation()),e.candidate&&(t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())},function(e){t.destroy(o(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||t.destroy(o("signal() called with invalid signal data","ERR_SIGNALING"))},r.prototype._addIceCandidate=function(e){var t=this;try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),i,function(e){t.destroy(o(e,"ERR_ADD_ICE_CANDIDATE"))})}catch(e){t.destroy(o("error adding candidate: "+e.message,"ERR_ADD_ICE_CANDIDATE"))}},r.prototype.send=function(e){var t=this;t._channel.send(e)},r.prototype.addStream=function(e){var t=this;t._debug("addStream()"),e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype.addTrack=function(e,t){var n=this;n._debug("addTrack()");var r=n._pc.addTrack(e,t),o=n._senderMap.get(e)||new WeakMap;o.set(t,r),n._senderMap.set(e,o),n._needsNegotiation()},r.prototype.removeTrack=function(e,t){var n=this;n._debug("removeSender()");var r=n._senderMap.get(e),o=r?r.get(t):null;o||n.destroy(new Error("Cannot remove track that was never added."));try{n._pc.removeTrack(o)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?n._sendersAwaitingStable.push(o):n.destroy(e)}},r.prototype.removeStream=function(e){var t=this;t._debug("removeSenders()"),e.getTracks().forEach(function(n){t.removeTrack(n,e)})},r.prototype._needsNegotiation=function(){var e=this;e._debug("_needsNegotiation");e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e._debug("starting batched negotiation"),e.negotiate()},0))},r.prototype.negotiate=function(){var e=this;e.initiator?e._isNegotiating?(e._queuedNegotiation=!0,e._debug("already negotiating, queueing")):(e._debug("start negotiation"),e._createOffer()):(e._debug("requesting negotiation from initiator"),e.emit("signal",{renegotiate:!0})),e._isNegotiating=!0},r.prototype.destroy=function(e){var t=this;t._destroy(e,function(){})},r.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(n._debug("destroy (error: %s)",e&&(e.message||e)),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._remoteTracks=null,n._remoteStreams=null,n._senderMap=null,clearInterval(n._interval),n._interval=null,n._chunk=null,n._cb=null,n._onFinishBound&&n.removeListener("finish",n._onFinishBound),n._onFinishBound=null,n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null,n._channel.onerror=null}if(n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onicegatheringstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null,"addTrack"in n._pc&&(n._pc.ontrack=null),n._pc.ondatachannel=null}n._pc=null,n._channel=null,e&&n.emit("error",e),n.emit("close"),t()}},r.prototype._setupData=function(e){var t=this;return e.channel?void(t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=u),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t.destroy(o(e,"ERR_DATA_CHANNEL"))}):t.destroy(o("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"))},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(o("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(r.connected){try{r.send(e)}catch(e){return r.destroy(o(e,"ERR_DATA_CHANNEL"))}r._channel.bufferedAmount>u?(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._onFinish=function(){function e(){setTimeout(function(){t.destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},r.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e._debug("createOffer success");e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e.destroy(o(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(o(t,"ERR_CREATE_OFFER"))},e.offerConstraints)},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e.destroy(o(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(o(t,"ERR_CREATE_ANSWER"))},e.answerConstraints)},r.prototype._onIceStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceConnectionState,n=e._pc.iceGatheringState;e._debug("iceStateChange (connection: %s) (gathering: %s)",t,n),e.emit("iceStateChange",t,n),("connected"===t||"completed"===t)&&(e._pcReady=!0,e._maybeReady()),"failed"===t&&e.destroy(o("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===t&&e.destroy(new Error("Ice connection closed."))}},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(null,n)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):0<t._pc.getStats.length?t._pc.getStats(function(n){if(!t.destroyed){var r=[];n.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,r.push(t)}),e(null,r)}},function(t){e(t)}):e(null,[])},r.prototype._maybeReady=function(){function e(){t.destroyed||t.getStats(function(n,r){function i(e){l=!0;var n=s[e.localCandidateId];n&&n.ip?(t.localAddress=n.ip,t.localPort=+n.port):n&&n.ipAddress?(t.localAddress=n.ipAddress,t.localPort=+n.portNumber):"string"==typeof e.googLocalAddress&&(n=e.googLocalAddress.split(":"),t.localAddress=n[0],t.localPort=+n[1]);var r=a[e.remoteCandidateId];r&&r.ip?(t.remoteAddress=r.ip,t.remotePort=+r.port):r&&r.ipAddress?(t.remoteAddress=r.ipAddress,t.remotePort=+r.portNumber):"string"==typeof e.googRemoteAddress&&(r=e.googRemoteAddress.split(":"),t.remoteAddress=r[0],t.remotePort=+r[1]),t.remoteFamily="IPv4",t._debug("connect local: %s:%s remote: %s:%s",t.localAddress,t.localPort,t.remoteAddress,t.remotePort)}if(!t.destroyed){n&&(r=[]);var a={},s={},d={},l=!1;if(r.forEach(function(e){("remotecandidate"===e.type||"remote-candidate"===e.type)&&(a[e.id]=e),("localcandidate"===e.type||"local-candidate"===e.type)&&(s[e.id]=e),("candidatepair"===e.type||"candidate-pair"===e.type)&&(d[e.id]=e)}),r.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&i(d[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&i(e)}),!l&&(!Object.keys(d).length||Object.keys(s).length))return void setTimeout(e,100);if(t._connecting=!1,t.connected=!0,t._chunk){try{t.send(t._chunk)}catch(e){return t.destroy(o(e,"ERR_DATA_CHANNEL"))}t._chunk=null,t._debug("sent chunk from \"write before connect\"");var c=t._cb;t._cb=null,c(null)}"number"!=typeof t._channel.bufferedAmountLowThreshold&&(t._interval=setInterval(function(){t._onInterval()},150),t._interval.unref&&t._interval.unref()),t._debug("connect"),t.emit("connect")}})}var t=this;t._debug("maybeReady pc %s channel %s",t._pcReady,t._channelReady);t.connected||t._connecting||!t._pcReady||!t._channelReady||(t._connecting=!0,e())},r.prototype._onInterval=function(){var e=this;e._cb&&e._channel&&!(e._channel.bufferedAmount>u)&&e._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"===e._pc.signalingState&&(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),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;r instanceof ArrayBuffer&&(r=n.from(r)),t.push(r)}},r.prototype._onChannelBufferedAmountLow=function(){var e=this;if(!e.destroyed&&e._cb){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},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._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(n){t._debug("on track"),t.emit("track",e.track,n),t._remoteTracks.push({track:e.track,stream:n});t._remoteStreams.some(function(e){return e.id===n.id})||(t._remoteStreams.push(n),setTimeout(function(){t.emit("stream",n)},0))})},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],a.apply(null,t)},r.prototype._transformConstraints=function(e){var t=this;if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!t._isChromium){var n=Object.assign({},e.optional,e.mandatory);return void 0!==n.OfferToReceiveVideo&&(n.offerToReceiveVideo=n.OfferToReceiveVideo,delete n.OfferToReceiveVideo),void 0!==n.OfferToReceiveAudio&&(n.offerToReceiveAudio=n.OfferToReceiveAudio,delete n.OfferToReceiveAudio),n}return e.mandatory||e.optional||!t._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,e("buffer").Buffer)},{buffer:47,debug:181,"get-browser-rtc":84,inherits:87,randombytes:145,"readable-stream":192}],181:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./common":182,_process:138,dup:15}],182:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:183}],183:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],184:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":186,"./_stream_writable":188,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],185:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":187,"core-util-is":66,dup:19,inherits:87}],186:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":184,"./internal/streams/BufferList":189,"./internal/streams/destroy":190,"./internal/streams/stream":191,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],187:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":184,"core-util-is":66,dup:21,inherits:87}],188:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":184,"./internal/streams/destroy":190,"./internal/streams/stream":191,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],189:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],190:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],191:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],192:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":184,"./lib/_stream_passthrough.js":185,"./lib/_stream_readable.js":186,"./lib/_stream_transform.js":187,"./lib/_stream_writable.js":188,dup:26}],193:[function(e,t){function n(e){return s.digest(e)}function r(e,t){return c?void("string"==typeof e&&(e=o(e)),c.digest({name:"sha-1"},e).then(function(e){t(i(new Uint8Array(e)))},function(){t(n(e))})):void setTimeout(t,0,n(e))}function o(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n}function i(e){for(var t=e.length,n=[],r=0,o;r<t;r++)o=e[r],n.push((o>>>4).toString(16)),n.push((15&o).toString(16));return n.join("")}var a=e("rusha"),s=new a,d="undefined"==typeof window?self:window,l=d.crypto||d.msCrypto||{},c=l.subtle||l.webkitSubtle;try{c.digest({name:"sha-1"},new Uint8Array).catch(function(){c=!1})}catch(e){c=!1}t.exports=r,t.exports.sync=n},{rusha:176}],194:[function(e,t){(function(n,r){function o(e){var t=this;if(!(t instanceof o))return new o(e);if(e||(e={}),"string"==typeof e&&(e={url:e}),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(t._id=s(4).toString("hex").slice(0,7),t._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),d.Duplex.call(t,e),t.connected=!1,t.destroyed=!1,t._chunk=null,t._cb=null,t._interval=null,e.socket)t.url=e.socket.url,t._ws=e.socket;else{t.url=e.url;try{t._ws="function"==typeof l?new c(e.url,e):new c(e.url)}catch(e){return void n.nextTick(function(){t.destroy(e)})}}t._ws.binaryType="arraybuffer",t._ws.onopen=function(){t._onOpen()},t._ws.onmessage=function(e){t._onMessage(e)},t._ws.onclose=function(){t._onClose()},t._ws.onerror=function(){t.destroy(new Error("connection error to "+t.url))},t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}t.exports=o;var i=e("debug")("simple-websocket"),a=e("inherits"),s=e("randombytes"),d=e("readable-stream"),l=e("ws"),c="function"==typeof l?l:WebSocket,u=65536;a(o,d.Duplex),o.WEBSOCKET_SUPPORT=!!c,o.prototype.send=function(e){this._ws.send(e)},o.prototype.destroy=function(e){this._destroy(e,function(){})},o.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(n._debug("destroy (error: %s)",e&&(e.message||e)),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._onFinishBound&&n.removeListener("finish",n._onFinishBound),n._onFinishBound=null,n._ws){var r=n._ws,o=function(){r.onclose=null};if(r.readyState===c.CLOSED)o();else try{r.onclose=o,r.close()}catch(e){o()}r.onopen=null,r.onmessage=null,r.onerror=function(){}}if(n._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){var i=e.code;e=new Error(e.message),e.code=i}n.emit("error",e)}n.emit("close"),t()}},o.prototype._read=function(){},o.prototype._write=function(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof l&&this._ws.bufferedAmount>u?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},o.prototype._onFinish=function(){function e(){setTimeout(function(){t.destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},o.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=r.from(t)),this.push(t)}},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.destroy(t)}e._chunk=null,e._debug("sent chunk from \"write before connect\"");var t=e._cb;e._cb=null,t(null)}"function"!=typeof l&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},o.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>u)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},o.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this.destroy())},o.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}).call(this,e("_process"),e("buffer").Buffer)},{_process:138,buffer:47,debug:195,inherits:87,randombytes:145,"readable-stream":206,ws:45}],195:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./common":196,_process:138,dup:15}],196:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:197}],197:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],198:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":200,"./_stream_writable":202,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],199:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":201,"core-util-is":66,dup:19,inherits:87}],200:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":198,"./internal/streams/BufferList":203,"./internal/streams/destroy":204,"./internal/streams/stream":205,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],201:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":198,"core-util-is":66,dup:21,inherits:87}],202:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":198,"./internal/streams/destroy":204,"./internal/streams/stream":205,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],203:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],204:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],205:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],206:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":198,"./lib/_stream_passthrough.js":199,"./lib/_stream_readable.js":200,"./lib/_stream_transform.js":201,"./lib/_stream_writable.js":202,dup:26}],207:[function(e,t){var n=1,r=65535,o=4,i=function(){n=n+1&r},a;t.exports=function(e){a||(a=setInterval(i,0|1e3/o),a.unref&&a.unref());var t=o*(e||5),s=[0],d=1,l=n-1&r;return function(e){var i=n-l&r;for(i>t&&(i=t),l=n;i--;)d===t&&(d=0),s[d]=s[0===d?t-1:d-1],d++;e&&(s[d-1]+=e);var a=s[d-1],c=s.length<t?0:s[d===t?0:d];return s.length<o?a:(a-c)*o/s.length}}},{}],208:[function(e,t,n){(function(t){var r=e("./lib/request"),o=e("./lib/response"),i=e("xtend"),a=e("builtin-status-codes"),s=e("url"),d=n;d.request=function(e,n){e="string"==typeof e?s.parse(e):i(e);var o=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||o,d=e.hostname||e.host,l=e.port,c=e.path||"/";d&&-1!==d.indexOf(":")&&(d="["+d+"]"),e.url=(d?a+"//"+d:"")+(l?":"+l:"")+c,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var u=new r(e);return n&&u.on("response",n),u},d.get=function(e,t){var n=d.request(e,t);return n.end(),n},d.ClientRequest=r,d.IncomingMessage=o.IncomingMessage,d.Agent=function(){},d.Agent.defaultMaxSockets=4,d.globalAgent=new d.Agent,d.STATUS_CODES=a,d.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/request":210,"./lib/response":211,"builtin-status-codes":54,url:238,xtend:248}],209:[function(e,t,n){(function(e){function t(){if(s!==void 0)return s;if(e.XMLHttpRequest){s=new e.XMLHttpRequest;try{s.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(t){s=null}}else s=null;return s}function r(e){var n=t();if(!n)return!1;try{return n.responseType=e,n.responseType===e}catch(t){}return!1}function o(e){return"function"==typeof e}n.fetch=o(e.fetch)&&o(e.ReadableStream),n.writableStream=o(e.WritableStream),n.abortController=o(e.AbortController),n.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),n.blobConstructor=!0}catch(t){}var i="undefined"!=typeof e.ArrayBuffer,a=i&&o(e.ArrayBuffer.prototype.slice),s;n.arraybuffer=n.fetch||i&&r("arraybuffer"),n.msstream=!n.fetch&&a&&r("ms-stream"),n.mozchunkedarraybuffer=!n.fetch&&i&&r("moz-chunked-arraybuffer"),n.overrideMimeType=n.fetch||!!t()&&o(t().overrideMimeType),n.vbArray=o(e.VBArray),s=null}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],210:[function(e,t){(function(n,r,o){function i(e,t){return s.fetch&&t?"fetch":s.mozchunkedarraybuffer?"moz-chunked-arraybuffer":s.msstream?"ms-stream":s.arraybuffer&&e?"arraybuffer":s.vbArray&&e?"text:vbarray":"text"}function a(e){try{var t=e.status;return null!==t&&0!==t}catch(t){return!1}}var s=e("./capability"),d=e("inherits"),l=e("./response"),c=e("readable-stream"),u=e("to-arraybuffer"),p=l.IncomingMessage,f=l.readyStates,h=t.exports=function(e){var t=this;c.Writable.call(t),t._opts=e,t._body=[],t._headers={},e.auth&&t.setHeader("Authorization","Basic "+new o(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(n){t.setHeader(n,e.headers[n])});var n=!0,r;if("disable-fetch"===e.mode||"requestTimeout"in e&&!s.abortController)n=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!s.overrideMimeType;else if(!e.mode||"default"===e.mode||"prefer-fast"===e.mode)r=!0;else throw new Error("Invalid value for opts.mode");t._mode=i(r,n),t._fetchTimer=null,t.on("finish",function(){t._onFinish()})};d(h,c.Writable),h.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1!==m.indexOf(r)||(n._headers[r]={name:e,value:t})},h.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},h.prototype.removeHeader=function(e){var t=this;delete t._headers[e.toLowerCase()]},h.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,i=e._headers,a=null;"GET"!==t.method&&"HEAD"!==t.method&&(s.arraybuffer?a=u(o.concat(e._body)):s.blobConstructor?a=new r.Blob(e._body.map(function(e){return u(e)}),{type:(i["content-type"]||{}).value||""}):a=o.concat(e._body).toString());var d=[];if(Object.keys(i).forEach(function(e){var t=i[e].name,n=i[e].value;Array.isArray(n)?n.forEach(function(e){d.push([t,e])}):d.push([t,n])}),"fetch"===e._mode){var l=null;if(s.abortController){var c=new AbortController;l=c.signal,e._fetchAbortController=c,"requestTimeout"in t&&0!==t.requestTimeout&&(e._fetchTimer=r.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout))}r.fetch(e._opts.url,{method:e._opts.method,headers:d,body:a||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:l}).then(function(t){e._fetchResponse=t,e._connect()},function(t){r.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var p=e._xhr=new r.XMLHttpRequest;try{p.open(e._opts.method,e._opts.url,!0)}catch(t){return void n.nextTick(function(){e.emit("error",t)})}"responseType"in p&&(p.responseType=e._mode.split(":")[0]),"withCredentials"in p&&(p.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in p&&p.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in t&&(p.timeout=t.requestTimeout,p.ontimeout=function(){e.emit("requestTimeout")}),d.forEach(function(e){p.setRequestHeader(e[0],e[1])}),e._response=null,p.onreadystatechange=function(){switch(p.readyState){case f.LOADING:case f.DONE:e._onXHRProgress();}},"moz-chunked-arraybuffer"===e._mode&&(p.onprogress=function(){e._onXHRProgress()}),p.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{p.send(a)}catch(t){return void n.nextTick(function(){e.emit("error",t)})}}}},h.prototype._onXHRProgress=function(){var e=this;!a(e._xhr)||e._destroyed||(!e._response&&e._connect(),e._response._onXHRProgress())},h.prototype._connect=function(){var e=this;e._destroyed||(e._response=new p(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},h.prototype._write=function(e,t,n){var r=this;r._body.push(e),n()},h.prototype.abort=h.prototype.destroy=function(){var e=this;e._destroyed=!0,r.clearTimeout(e._fetchTimer),e._response&&(e._response._destroyed=!0),e._xhr?e._xhr.abort():e._fetchAbortController&&e._fetchAbortController.abort()},h.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),c.Writable.prototype.end.call(r,e,t,n)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":209,"./response":211,_process:138,buffer:47,inherits:87,"readable-stream":220,"to-arraybuffer":228}],211:[function(e,t,n){(function(t,r,o){var i=e("./capability"),a=e("inherits"),s=e("readable-stream"),d=n.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},l=n.IncomingMessage=function(e,n,a,d){var l=this;if(s.Readable.call(l),l._mode=a,l.headers={},l.rawHeaders=[],l.trailers={},l.rawTrailers=[],l.on("end",function(){t.nextTick(function(){l.emit("close")})}),"fetch"===a){function e(){u.read().then(function(t){return l._destroyed?void 0:t.done?(r.clearTimeout(d),void l.push(null)):void(l.push(new o(t.value)),e())}).catch(function(e){r.clearTimeout(d),l._destroyed||l.emit("error",e)})}if(l._fetchResponse=n,l.url=n.url,l.statusCode=n.status,l.statusMessage=n.statusText,n.headers.forEach(function(e,t){l.headers[t.toLowerCase()]=e,l.rawHeaders.push(t,e)}),i.writableStream){var c=new WritableStream({write:function(e){return new Promise(function(t,n){l._destroyed?n():l.push(new o(e))?t():l._resumeFetch=t})},close:function(){r.clearTimeout(d),l._destroyed||l.push(null)},abort:function(e){l._destroyed||l.emit("error",e)}});try{return void n.body.pipeTo(c).catch(function(e){r.clearTimeout(d),l._destroyed||l.emit("error",e)})}catch(t){}}var u=n.body.getReader();e()}else{l._xhr=e,l._pos=0,l.url=e.responseURL,l.statusCode=e.status,l.statusMessage=e.statusText;var p=e.getAllResponseHeaders().split(/\r?\n/);if(p.forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===l.headers[n]&&(l.headers[n]=[]),l.headers[n].push(t[2])):void 0===l.headers[n]?l.headers[n]=t[2]:l.headers[n]+=", "+t[2],l.rawHeaders.push(t[1],t[2])}}),l._charset="x-user-defined",!i.overrideMimeType){var f=l.rawHeaders["mime-type"];if(f){var h=f.match(/;\s*charset=([^;])(;|$)/);h&&(l._charset=h[1].toLowerCase())}l._charset||(l._charset="utf-8")}}};a(l,s.Readable),l.prototype._read=function(){var e=this,t=e._resumeFetch;t&&(e._resumeFetch=null,t())},l.prototype._onXHRProgress=function(){var t=this,n=t._xhr,a=null;switch(t._mode){case"text:vbarray":if(n.readyState!==d.DONE)break;try{a=new r.VBArray(n.responseBody).toArray()}catch(t){}if(null!==a){t.push(new o(a));break}case"text":try{a=n.responseText}catch(n){t._mode="text:vbarray";break}if(a.length>t._pos){var s=a.substr(t._pos);if("x-user-defined"===t._charset){for(var l=new o(s.length),c=0;c<s.length;c++)l[c]=255&s.charCodeAt(c);t.push(l)}else t.push(s,t._charset);t._pos=a.length}break;case"arraybuffer":if(n.readyState!==d.DONE||!n.response)break;a=n.response,t.push(new o(new Uint8Array(a)));break;case"moz-chunked-arraybuffer":if(a=n.response,n.readyState!==d.LOADING||!a)break;t.push(new o(new Uint8Array(a)));break;case"ms-stream":if(a=n.response,n.readyState!==d.LOADING)break;var e=new r.MSStreamReader;e.onprogress=function(){e.result.byteLength>t._pos&&(t.push(new o(new Uint8Array(e.result.slice(t._pos)))),t._pos=e.result.byteLength)},e.onload=function(){t.push(null)},e.readAsArrayBuffer(a);}t._xhr.readyState===d.DONE&&"ms-stream"!==t._mode&&t.push(null)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":209,_process:138,buffer:47,inherits:87,"readable-stream":220}],212:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"./_stream_readable":214,"./_stream_writable":216,"core-util-is":66,dup:18,inherits:87,"process-nextick-args":137}],213:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"./_stream_transform":215,"core-util-is":66,dup:19,inherits:87}],214:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"./_stream_duplex":212,"./internal/streams/BufferList":217,"./internal/streams/destroy":218,"./internal/streams/stream":219,_process:138,"core-util-is":66,dup:20,events:48,inherits:87,isarray:92,"process-nextick-args":137,"safe-buffer":177,"string_decoder/":224,util:45}],215:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./_stream_duplex":212,"core-util-is":66,dup:21,inherits:87}],216:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{"./_stream_duplex":212,"./internal/streams/destroy":218,"./internal/streams/stream":219,_process:138,"core-util-is":66,dup:22,inherits:87,"process-nextick-args":137,"safe-buffer":177,timers:227,"util-deprecate":244}],217:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{dup:23,"safe-buffer":177,util:45}],218:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{dup:24,"process-nextick-args":137}],219:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25,events:48}],220:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"./lib/_stream_duplex.js":212,"./lib/_stream_passthrough.js":213,"./lib/_stream_readable.js":214,"./lib/_stream_transform.js":215,"./lib/_stream_writable.js":216,dup:26}],221:[function(e,t){var n=e("stream-to-blob");t.exports=function e(t,r,o){return"function"==typeof r?e(t,null,r):void n(t,r,function(e,t){if(e)return o(e);var n=URL.createObjectURL(t);o(null,n)})}},{"stream-to-blob":222}],222:[function(e,t){var n=e("once");t.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);o=n(o);var i=[];t.on("data",function(e){i.push(e)}).on("end",function(){var e=r?new Blob(i,{type:r}):new Blob(i);o(null,e)}).on("error",o)}},{once:132}],223:[function(e,t){(function(n){var r=e("once");t.exports=function(e,t,o){o=r(o);var i=n.alloc(t),a=0;e.on("data",function(e){e.copy(i,a),a+=e.length}).on("end",function(){o(null,i)}).on("error",o)}}).call(this,e("buffer").Buffer)},{buffer:47,once:132}],224:[function(e,t,n){"use strict";function r(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0;}}function o(e){var t=r(e);if("string"!=typeof t&&(g.isEncoding===_||!_(e)))throw new Error("Unknown encoding: "+e);return t||e}function i(e){this.encoding=o(e);var t;switch(this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=l,t=4;break;case"base64":this.text=p,this.end=f,t=3;break;default:return this.write=h,void(this.end=m);}this.lastNeed=0,this.lastTotal=0,this.lastChar=g.allocUnsafe(t)}function a(e){if(127>=e)return 0;return 6==e>>5?2:14==e>>4?3:30==e>>3?4:2==e>>6?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var o=a(t[r]);return 0<=o?(0<o&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=a(t[r]),0<=o)?(0<o&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=a(t[r]),0<=o?(0<o&&(2===o?o=0:e.lastNeed=o-3),o):0)}function d(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"\uFFFD";if(1<e.lastNeed&&1<t.length){if(128!=(192&t[1]))return e.lastNeed=1,"\uFFFD";if(2<e.lastNeed&&2<t.length&&128!=(192&t[2]))return e.lastNeed=2,"\uFFFD"}}function l(e){var t=this.lastTotal-this.lastNeed,n=d(this,e,t);return void 0===n?this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length):n}function c(e,t){if(0==(e.length-t)%2){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(55296<=r&&56319>=r)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function p(e,t){var r=(e.length-t)%3;return 0==r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1==r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}var g=e("safe-buffer").Buffer,_=g.isEncoding||function(e){switch(e=""+e,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;}};n.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},i.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t},i.prototype.text=function(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},i.prototype.fillLast=function(e){return this.lastNeed<=e.length?(e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length)}},{"safe-buffer":177}],225:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":226}],226:[function(e,t,r){(function(e){"use strict";function t(e){var t=n(e.length/5);return 0==e.length%5?t:t+1}var 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];r.encode=function(n){e.isBuffer(n)||(n=new e(n));for(var r=0,o=0,a=0,s=0,d=new e(8*t(n));r<n.length;){var l=n[r];3<a?(s=l&255>>a,a=(a+5)%8,s=s<<a|(r+1<n.length?n[r+1]:0)>>8-a,r++):(s=31&l>>8-(a+5),a=(a+5)%8,0===a&&r++),d[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(s),o++}for(r=o;r<d.length;r++)d[r]=61;return d},r.decode=function(t){var n=0,r=0,s=0,d;e.isBuffer(t)||(t=new e(t));for(var l=new e(a(5*t.length/8)),c=0;c<t.length&&!(61===t[c]);c++){var u=t[c]-48;if(u<o.length)r=o[u],3>=n?(n=(n+5)%8,0==n?(d|=r,l[s]=d,s++,d=0):d|=255&r<<8-n):(n=(n+5)%8,d|=255&r>>>n,l[s]=d,s++,d=255&r<<8-n);else throw new Error("Invalid input - it is not base32 encoded string")}return l.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:47}],227:[function(e,t,n){(function(t,r){function o(e,t){this._id=e,this._clearFn=t}var i=e("process/browser.js").nextTick,a=Function.prototype.apply,s=Array.prototype.slice,d={},l=0;n.setTimeout=function(){return new o(a.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new o(a.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=l++,r=!(2>arguments.length)&&s.call(arguments,1);return d[t]=!0,i(function(){d[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof r?r:function(e){delete d[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":138,timers:227}],228:[function(e,t){var n=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(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,o=0;o<r;o++)t[o]=e[o];return t.buffer}throw new Error("Argument must be a Buffer")}},{buffer:47}],229:[function(e,t){(function(r){const o=e("debug")("torrent-discovery"),i=e("bittorrent-dht/client"),a=e("events").EventEmitter,s=e("run-parallel"),d=e("bittorrent-tracker/client");t.exports=class extends a{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!r.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||900000,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=e=>{this.emit("warning",e)},this._onError=e=>{this.emit("error",e)},this._onDHTPeer=(e,t)=>{t.toString("hex")!==this.infoHash||this.emit("peer",`${e.host}:${e.port}`,"dht")},this._onTrackerPeer=e=>{this.emit("peer",e,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")};const t=(e,t)=>{const n=new i(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1===e.dht||"function"!=typeof i?null:e.dht&&"function"==typeof e.dht.addNode?e.dht:e.dht&&"object"==typeof e.dht?t(e.dhtPort,e.dht):t(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce())}updatePort(e){e===this._port||(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push(e=>{this.tracker.destroy(e)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push(e=>{this.dht.destroy(e)})),s(t,e),this.dht=null,this.tracker=null,this._announce=null}}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new d(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(o("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,e=>{this._dhtAnnouncing=!1,o("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+n(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}}}).call(this,e("_process"))},{_process:138,"bittorrent-dht/client":45,"bittorrent-tracker/client":27,debug:230,events:48,"run-parallel":175}],230:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./common":231,_process:138,dup:15}],231:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:232}],232:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],233:[function(e,t){(function(e){const n=16384;class r{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=a(e/n),this._remainder=e%n||n,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:n}chunkLengthRemaining(e){return this.length-e*n}chunkOffset(e){return e*n}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._reservations<this._chunks){const e=this._reservations;return this._reservations=this._chunks,e}return-1}cancel(e){this.init()&&this._cancellations.push(e)}cancelRemaining(e){this.init()&&(this._reservations=e)}get(e){return this.init()?this._buffer[e]:null}set(e,t,r){if(!this.init())return!1;const o=t.length,i=a(o/n);for(let o=0;o<i;o++)if(!this._buffer[e+o]){const i=o*n,a=t.slice(i,i+n);this._buffered++,this._buffer[e+o]=a,this.missing-=a.length,this.sources.includes(r)||this.sources.push(r)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const t=e.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,t}init(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}Object.defineProperty(r,"BLOCK_LENGTH",{value:16384}),t.exports=r}).call(this,e("buffer").Buffer)},{buffer:47}],234:[function(e,t){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){if(r(e)){var t=n.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(t=t.slice(e.byteOffset,e.byteOffset+e.byteLength)),t}return n.from(e)}}).call(this,e("buffer").Buffer)},{buffer:47,"is-typedarray":91}],235:[function(e,r,o){var i=e("buffer-alloc"),a=t(2,32);o.encodingLength=function(){return 8},o.encode=function(e,t,r){t||(t=i(8)),r||(r=0);var o=n(e/a);return t.writeUInt32BE(o,r),t.writeUInt32BE(e-o*a,r+4),t},o.decode=function(e,t){t||(t=0);var n=e.readUInt32BE(t),r=e.readUInt32BE(t+4);return n*a+r},o.encode.bytes=8,o.decode.bytes=8},{"buffer-alloc":51}],236:[function(e,t){"use strict";function n(e,t){for(var n=1,r=e.length,o=e[0],s=e[0],d=1;d<r;++d)if(s=o,o=e[d],t(o,s)){if(d===n){n++;continue}e[n++]=o}return e.length=n,e}function r(e){for(var t=1,n=e.length,r=e[0],o=e[0],s=1;s<n;++s,o=r)if(o=r,r=e[s],r!==o){if(s===t){t++;continue}e[t++]=r}return e.length=t,e}t.exports=function(e,t,o){return 0===e.length?e:t?(o||e.sort(t),n(e,t)):(o||e.sort(),r(e))}},{}],237:[function(e,t){t.exports=function(e,t){if(!(t>=e.length||0>t)){var n=e.pop();if(t<e.length){var r=e[t];return e[t]=n,r}return n}}},{}],238:[function(e,t,n){"use strict";function r(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function o(e,t,n){if(e&&d.isObject(e)&&e instanceof r)return e;var o=new r;return o.parse(e,t,n),o}var a=e("punycode"),d=e("./util");n.parse=o,n.resolve=function(e,t){return o(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?o(e,!1,!0).resolveObject(t):t},n.format=function(e){return d.isString(e)&&(e=o(e)),e instanceof r?e.format():r.prototype.format.call(e)},n.Url=r;var c=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,p=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),h=["'"].concat(f),m=["%","/","?",";","#"].concat(h),g=["/","?","#"],_=/^[+a-z0-9A-Z_-]{0,63}$/,b=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},C=e("querystring");r.prototype.parse=function(e,t,n){if(!d.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=-1!==r&&r<e.indexOf("#")?"?":"#",u=e.split(o),f=/\\/g;u[0]=u[0].replace(f,"/"),e=u.join(o);var S=e;if(S=S.trim(),!n&&1===e.split("#").length){var v=p.exec(S);if(v)return this.path=S,this.href=S,this.pathname=v[1],v[2]?(this.search=v[2],this.query=t?C.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var E=c.exec(S);if(E){E=E[0];var L=E.toLowerCase();this.protocol=L,S=S.substr(E.length)}if(n||E||S.match(/^\/\/[^@\/]+@[^@\/]+/)){var I="//"===S.substr(0,2);I&&!(E&&w[E])&&(S=S.substr(2),this.slashes=!0)}if(!w[E]&&(I||E&&!x[E])){for(var B=-1,T=0,R;T<g.length;T++)R=S.indexOf(g[T]),-1!==R&&(-1===B||R<B)&&(B=R);var A,U;U=-1===B?S.lastIndexOf("@"):S.lastIndexOf("@",B),-1!==U&&(A=S.slice(0,U),S=S.slice(U+1),this.auth=decodeURIComponent(A)),B=-1;for(var T=0,R;T<m.length;T++)R=S.indexOf(m[T]),-1!==R&&(-1===B||R<B)&&(B=R);-1===B&&(B=S.length),this.host=S.slice(0,B),S=S.slice(B),this.parseHost(),this.hostname=this.hostname||"";var P="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!P)for(var M=this.hostname.split(/\./),T=0,O=M.length,N;T<O;T++)if(N=M[T],N&&!N.match(_)){for(var F="",H=0,q=N.length;H<q;H++)F+=127<N.charCodeAt(H)?"x":N[H];if(!F.match(_)){var k=M.slice(0,T),D=M.slice(T+1),W=N.match(b);W&&(k.push(W[1]),D.unshift(W[2])),D.length&&(S="/"+D.join(".")+S),this.hostname=k.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),P||(this.hostname=a.toASCII(this.hostname));var z=this.port?":"+this.port:"",V=this.hostname||"";this.host=V+z,this.href+=this.host,P&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==S[0]&&(S="/"+S))}if(!y[L])for(var T=0,O=h.length,G;T<O;T++)if(G=h[T],-1!==S.indexOf(G)){var K=encodeURIComponent(G);K===G&&(K=escape(G)),S=S.split(G).join(K)}var Y=S.indexOf("#");-1!==Y&&(this.hash=S.substr(Y),S=S.slice(0,Y));var X=S.indexOf("?");if(-1===X?t&&(this.search="",this.query={}):(this.search=S.substr(X),this.query=S.substr(X+1),t&&(this.query=C.parse(this.query)),S=S.slice(0,X)),S&&(this.pathname=S),x[L]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var z=this.pathname||"",$=this.search||"";this.path=z+$}return this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,i="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&d.isObject(this.query)&&Object.keys(this.query).length&&(i=C.stringify(this.query));var a=this.search||i&&"?"+i||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||x[t])&&!1!=o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):!o&&(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),a=a.replace("#","%23"),t+o+n+a+r},r.prototype.resolve=function(e){return this.resolveObject(o(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(d.isString(e)){var t=new r;t.parse(e,!1,!0),e=t}for(var n=new r,o=Object.keys(this),a=0,l;a<o.length;a++)l=o[a],n[l]=this[l];if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0,f;u<c.length;u++)f=c[u],"protocol"!==f&&(n[f]=e[f]);return x[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!x[e.protocol]){for(var h=Object.keys(e),m=0,g;m<h.length;m++)g=h[m],n[g]=e[g];return n.href=n.format(),n}if(n.protocol=e.protocol,!e.host&&!w[e.protocol]){for(var _=(e.pathname||"").split("/");_.length&&!(e.host=_.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==_[0]&&_.unshift(""),2>_.length&&_.unshift(""),n.pathname=_.join("/")}else n.pathname=e.pathname;if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var b=n.pathname||"",p=n.search||"";n.path=b+p}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var s=n.pathname&&"/"===n.pathname.charAt(0),y=e.host||e.pathname&&"/"===e.pathname.charAt(0),C=y||s||n.host&&e.pathname,S=C,E=n.pathname&&n.pathname.split("/")||[],_=e.pathname&&e.pathname.split("/")||[],L=n.protocol&&!x[n.protocol];if(L&&(n.hostname="",n.port=null,n.host&&(""===E[0]?E[0]=n.host:E.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===_[0]?_[0]=e.host:_.unshift(e.host)),e.host=null),C=C&&(""===_[0]||""===E[0])),y)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,E=_;else if(_.length)E||(E=[]),E.pop(),E=E.concat(_),n.search=e.search,n.query=e.query;else if(!d.isNullOrUndefined(e.search)){if(L){n.hostname=n.host=E.shift();var I=!!(n.host&&0<n.host.indexOf("@"))&&n.host.split("@");I&&(n.auth=I.shift(),n.host=n.hostname=I.shift())}return n.search=e.search,n.query=e.query,d.isNull(n.pathname)&&d.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!E.length)return n.pathname=null,n.path=n.search?"/"+n.search:null,n.href=n.format(),n;for(var B=E.slice(-1)[0],T=(n.host||e.host||1<E.length)&&("."===B||".."===B)||""===B,R=0,A=E.length;0<=A;A--)B=E[A],"."===B?E.splice(A,1):".."===B?(E.splice(A,1),R++):R&&(E.splice(A,1),R--);if(!C&&!S)for(;R--;R)E.unshift("..");C&&""!==E[0]&&(!E[0]||"/"!==E[0].charAt(0))&&E.unshift(""),T&&"/"!==E.join("/").substr(-1)&&E.push("");var U=""===E[0]||E[0]&&"/"===E[0].charAt(0);if(L){n.hostname=n.host=U?"":E.length?E.shift():"";var I=!!(n.host&&0<n.host.indexOf("@"))&&n.host.split("@");I&&(n.auth=I.shift(),n.host=n.hostname=I.shift())}return C=C||n.host&&E.length,C&&!U&&E.unshift(""),E.length?n.pathname=E.join("/"):(n.pathname=null,n.path=null),d.isNull(n.pathname)&&d.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=u.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":239,punycode:140,querystring:143}],239:[function(e,t){"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}}},{}],240:[function(e,t){(function(n){const{EventEmitter:r}=e("events"),o=e("bencode"),i=e("bitfield"),s=e("debug")("ut_metadata"),d=e("simple-sha1"),l=1E3,c=16384;t.exports=e=>{class t extends r{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new i(0,{grow:l}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1E7<e.metadata_size||0>=e.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=e.metadata_size,this._numPieces=a(this._metadataSize/c),this._remainingRejects=2*this._numPieces,this._fetching&&this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const r=e.toString(),i=r.indexOf("ee")+2;t=o.decode(r.substring(0,i)),n=e.slice(i)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;s("set metadata");try{const t=o.decode(e).info;t&&(e=o.encode(t))}catch(e){}return!(this._infoHash&&this._infoHash!==d.sync(e))&&(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",o.encode({info:o.decode(this.metadata)})),!0)}_send(e,t){let r=o.encode(e);n.isBuffer(t)&&(r=n.concat([r,t])),this._wire.extended("ut_metadata",r)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*c;let n=t+c;n>this._metadataSize&&(n=this._metadataSize);const r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)}_onData(e,t){t.length>c||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){0<this._remainingRejects&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){this.metadata=n.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(e){const e=this.setMetadata(this.metadata);e||this._failedMetadata()}}_failedMetadata(){this._bitfield=new i(0,{grow:l}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this,e("buffer").Buffer)},{bencode:11,bitfield:13,buffer:47,debug:241,events:48,"simple-sha1":193}],241:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./common":242,_process:138,dup:15}],242:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{dup:16,ms:243}],243:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{dup:17}],244:[function(e,t){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===(n+"").toLowerCase()}t.exports=function(e,t){function r(){if(!o){if(n("throwDeprecation"))throw new Error(t);else n("traceDeprecation")?console.trace(t):console.warn(t);o=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var o=!1;return r}}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],245:[function(e,t){(function(r){function o(e){var t=this;i.call(t),t._tracks=[],t._fragmentSequence=1,t._file=e,t._decoder=null,t._findMoov(0)}function a(e,t){var n=this;n._entries=e,n._countName=t||"count",n._index=0,n._offset=0,n.value=n._entries[0]}function s(){return{version:0,flags:0,entries:[]}}var d=e("binary-search"),i=e("events").EventEmitter,l=e("inherits"),c=e("mp4-stream"),u=e("mp4-box-encoding"),p=e("range-slice-stream");t.exports=o,l(o,i),o.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))})},a.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]},o.prototype._processMoov=function(e){var t=this,n=e.traks;t._tracks=[],t._hasVideo=!1,t._hasAudio=!1;for(var o=0;o<n.length;o++){var d=n[o],l=d.mdia.minf.stbl,c=l.stsd.entries[0],p=d.mdia.hdlr.handlerType,f,h;if("vide"===p&&"avc1"===c.type){if(t._hasVideo)continue;t._hasVideo=!0,f="avc1",c.avcC&&(f+="."+c.avcC.mimeCodec),h="video/mp4; codecs=\""+f+"\""}else if("soun"===p&&"mp4a"===c.type){if(t._hasAudio)continue;t._hasAudio=!0,f="mp4a",c.esds&&c.esds.mimeCodec&&(f+="."+c.esds.mimeCodec),h="audio/mp4; codecs=\""+f+"\""}else continue;var m=[],g=0,_=0,b=0,y=0,w=0,k=0,x=new a(l.stts.entries),C=null;l.ctts&&(C=new a(l.ctts.entries));for(var S=0;;){var v=l.stsc.entries[w],E=l.stsz.entries[g],L=x.value.duration,I=C?C.value.compositionOffset:0,B=!0;l.stss&&(B=l.stss.entries[S]===g+1);var T=l.stco||l.co64;if(m.push({size:E,duration:L,dts:k,presentationOffset:I,sync:B,offset:y+T.entries[b]}),g++,g>=l.stsz.entries.length)break;if(_++,y+=E,_>=v.samplesPerChunk){_=0,y=0,b++;var R=l.stsc.entries[w+1];R&&b+1>=R.firstChunk&&w++}k+=L,x.inc(),C&&C.inc(),B&&S++}d.mdia.mdhd.duration=0,d.tkhd.duration=0;var A=v.sampleDescriptionId,U={type:"moov",mvhd:e.mvhd,traks:[{tkhd:d.tkhd,mdia:{mdhd:d.mdia.mdhd,hdlr:d.mdia.hdlr,elng:d.mdia.elng,minf:{vmhd:d.mdia.minf.vmhd,smhd:d.mdia.minf.smhd,dinf:d.mdia.minf.dinf,stbl:{stsd:l.stsd,stts:s(),ctts:s(),stsc:s(),stsz:s(),stco:s(),stss:s()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:d.tkhd.trackId,defaultSampleDescriptionIndex:A,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:d.tkhd.trackId,timeScale:d.mdia.mdhd.timeScale,samples:m,currSample:null,currTime:null,moov:U,mime:h})}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 P=u.encode(t._ftyp),M=t._tracks.map(function(e){var t=u.encode(e.moov);return{mime:e.mime,init:r.concat([P,t])}});t.emit("ready",M)},o.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){a.destroyed||a.box(e.moof,function(n){if(n)return t.emit("error",n);if(!a.destroyed){var s=r.inStream.slice(e.ranges);s.pipe(a.mediaData(e.length,function(e){if(e)return t.emit("error",e);if(!a.destroyed){var n=t._generateFragment(o);return n?void i(n):a.finalize()}}))}})}r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var a=r.outStream=c.encode(),s=t._generateFragment(o,e);return s?void((-1===n||s.ranges[0].start<n)&&(n=s.ranges[0].start),i(s)):a.finalize()}),0<=n){var r=t._fileStream=t._file.createReadStream({start:n});t._tracks.forEach(function(e){e.inStream=new p(n,{highWaterMark:1e7}),r.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},o.prototype._findSampleBefore=function(e,t){var r=this,o=r._tracks[e],i=n(o.timeScale*t),a=d(o.samples,i,function(e,n){var t=e.dts+e.presentationOffset;return t-n});for(-1===a?a=0:0>a&&(a=-a-2);!o.samples[a].sync;)a--;return a};o.prototype._generateFragment=function(e,t){var n=this,r=n._tracks[e],o;if(o=void 0===t?r.currSample:n._findSampleBefore(e,t),o>=r.samples.length)return null;for(var i=r.samples[o].dts,a=0,s=[],d=o,l;d<r.samples.length&&(l=r.samples[d],!(l.sync&&l.dts-i>=1*r.timeScale));d++){a+=l.size;var c=s.length-1;0>c||s[c].end!==l.offset?s.push({start:l.offset,end:l.offset+l.size}):s[c].end+=l.size}return r.currSample=d,{moof:n._generateMoof(e,o,d),ranges:s,length:a}},o.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],i=[],a=0,s=t,d;s<n;s++)d=o.samples[s],0>d.presentationOffset&&(a=1),i.push({sampleDuration:d.duration,sampleSize:d.size,sampleFlags:d.sync?33554432:16842752,sampleCompositionTimeOffset:d.presentationOffset});var l={type:"moof",mfhd:{sequenceNumber:r._fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:o.trackId},tfdt:{baseMediaDecodeTime:o.samples[t].dts},trun:{flags:3841,dataOffset:8,entries:i,version:a}}]};return l.trafs[0].trun.dataOffset+=u.encodingLength(l),l}}).call(this,e("buffer").Buffer)},{"binary-search":12,buffer:47,events:48,inherits:87,"mp4-box-encoding":108,"mp4-stream":111,"range-slice-stream":146}],246:[function(e,t){function n(e,t,o){var i=this;return this instanceof n?void(o=o||{},i.detailedError=null,i._elem=t,i._elemWrapper=new r(t),i._waitingFired=!1,i._trackMeta=null,i._file=e,i._tracks=null,"none"!==i._elem.preload&&i._createMuxer(),i._onError=function(){i.detailedError=i._elemWrapper.detailedError,i.destroy()},i._onWaiting=function(){i._waitingFired=!0,i._muxer?i._tracks&&i._pump():i._createMuxer()},i._elem.addEventListener("waiting",i._onWaiting),i._elem.addEventListener("error",i._onError)):new n(e,t,o)}var r=e("mediasource"),o=e("pump"),i=e("./mp4-remuxer");t.exports=n,n.prototype._createMuxer=function(){var e=this;e._muxer=new i(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var n=e._elemWrapper.createWriteStream(t.mime);n.on("error",function(t){e._elemWrapper.error(t)});var r={muxed:null,mediaSource:n,initFlushed:!1,onInitFlushed:null};return n.write(t.init,function(e){r.initFlushed=!0,r.onInitFlushed&&r.onInitFlushed(e)}),r}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},n.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(n,r){var i=function(){n.muxed&&(n.muxed.destroy(),n.mediaSource=e._elemWrapper.createWriteStream(n.mediaSource),n.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),n.muxed=t[r],o(n.muxed,n.mediaSource)};n.initFlushed?i():n.onInitFlushed=function(t){return t?void e._elemWrapper.error(t):void i()}})},n.prototype.destroy=function(){var e=this;e.destroyed||(e.destroyed=!0,e._elem.removeEventListener("waiting",e._onWaiting),e._elem.removeEventListener("error",e._onError),e._tracks&&e._tracks.forEach(function(e){e.muxed&&e.muxed.destroy()}),e._elem.src="")}},{"./mp4-remuxer":245,mediasource:95,pump:139}],247:[function(e,t){function n(e,t){function r(){for(var t=Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach(function(e){r[e]=o[e]}),r}if(e&&t)return n(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(t){r[t]=e[t]}),r}t.exports=n},{}],248:[function(e,t){t.exports=function(){for(var e={},t=0,r;t<arguments.length;t++)for(var o in r=arguments[t],r)n.call(r,o)&&(e[o]=r[o]);return e};var n=Object.prototype.hasOwnProperty},{}],249:[function(e,t){t.exports=function(e){for(var t=1,r;t<arguments.length;t++)for(var o in r=arguments[t],r)n.call(r,o)&&(e[o]=r[o]);return e};var n=Object.prototype.hasOwnProperty},{}],250:[function(e,t){t.exports={version:"0.103.1"}},{}],251:[function(e,t){(function(n,r){function o(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function i(e){return"undefined"!=typeof FileList&&e instanceof FileList}const{Buffer:a}=e("safe-buffer"),{EventEmitter:s}=e("events"),d=e("simple-concat"),l=e("create-torrent"),c=e("debug")("webtorrent"),u=e("bittorrent-dht/client"),p=e("load-ip-set"),f=e("run-parallel"),h=e("parse-torrent"),m=e("path"),g=e("simple-peer"),_=e("randombytes"),b=e("speedometer"),y=e("./lib/tcp-pool"),w=e("./lib/torrent"),k=e("./package.json").version,x=k.replace(/\d*./g,e=>`0${e%100}`.slice(-2)).slice(0,4);class C extends s{constructor(e={}){super(),this.peerId="string"==typeof e.peerId?e.peerId:a.isBuffer(e.peerId)?e.peerId.toString("hex"):a.from(`-WW${x}-`+_(9).toString("base64")).toString("hex"),this.peerIdBuffer=a.from(this.peerId,"hex"),this.nodeId="string"==typeof e.nodeId?e.nodeId:a.isBuffer(e.nodeId)?e.nodeId.toString("hex"):_(20).toString("hex"),this.nodeIdBuffer=a.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=e.tracker===void 0?{}:e.tracker,this.torrents=[],this.maxConns=+e.maxConns||55,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),r.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=r.WRTC)),"function"==typeof y?this._tcpPool=new y(this):n.nextTick(()=>{this._onListening()}),this._downloadSpeed=b(),this._uploadSpeed=b(),!1!==e.dht&&"function"==typeof u?(this.dht=new u(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",e=>{this._destroy(e)}),this.dht.once("listening",()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof p&&null!=e.blocklist?p(e.blocklist,{headers:{"user-agent":`WebTorrent/${k} (https://webtorrent.io)`}},(e,n)=>e?this.error(`Failed to load blocklist: ${e.message}`):void(this.blocked=n,t())):n.nextTick(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter(e=>1!==e.progress),t=e.reduce((e,t)=>e+t.downloaded,0),n=e.reduce((e,t)=>e+(t.length||0),0)||1;return t/n}get ratio(){const e=this.torrents.reduce((e,t)=>e+t.uploaded,0),t=this.torrents.reduce((e,t)=>e+t.received,0)||1;return e/t}get(e){if(!(e instanceof w)){let t;try{t=h(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}else if(this.torrents.includes(e))return e;return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n){function r(){a.removeListener("_infoHash",o),a.removeListener("ready",i),a.removeListener("close",r)}if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const o=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===a.infoHash&&e!==a)return void a._destroy(new Error(`Cannot add duplicate torrent ${a.infoHash}`))},i=()=>{this.destroyed||("function"==typeof n&&n(a),this.emit("torrent",a))};this._debug("add"),t=t?Object.assign({},t):{};const a=new w(e,this,t);return this.torrents.push(a),a.once("_infoHash",o),a.once("ready",i),a.once("close",r),a}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),t=t?Object.assign({},t):{},t.skipVerify=!0;const r="string"==typeof e;r&&(t.path=m.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${x}`);const a=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},s=this.add(null,t,e=>{const t=[t=>r?t():void e.load(c,t)];this.dht&&t.push(t=>{e.once("dhtAnnounce",t)}),f(t,t=>this.destroyed?void 0:t?e._destroy(t):void a(e))});let c;return i(e)?e=Array.from(e):!Array.isArray(e)&&(e=[e]),f(e.map(e=>t=>{o(e)?d(e,t):t(null,e)}),(e,n)=>this.destroyed?void 0:e?s._destroy(e):void l.parseInput(n,t,(e,r)=>this.destroyed?void 0:e?s._destroy(e):void(c=r.map(e=>e.getStream),l(n,t,(e,t)=>{if(!this.destroyed){if(e)return s._destroy(e);const n=this.get(t);n?s._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):s._onTorrentId(t)}})))),s}remove(e,t){this._debug("remove");const n=this.get(e);if(!n)throw new Error(`No torrent with id ${e}`);this._remove(e,t)}_remove(e,t){const n=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))}address(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map(e=>t=>{e.destroy(t)});this._tcpPool&&n.push(e=>{this._tcpPool.destroy(e)}),this.dht&&n.push(e=>{this.dht.destroy(e)}),f(n,t),e&&this.emit("error",e),this.torrents=[],this._tcpPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._tcpPool){const e=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,c(...e)}}C.WEBRTC_SUPPORT=g.WEBRTC_SUPPORT,C.VERSION=k,t.exports=C}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/tcp-pool":45,"./lib/torrent":5,"./package.json":250,_process:138,"bittorrent-dht/client":45,"create-torrent":67,debug:69,events:48,"load-ip-set":45,"parse-torrent":134,path:135,randombytes:145,"run-parallel":175,"safe-buffer":177,"simple-concat":178,"simple-peer":180,speedometer:207}]},{},[251])(251)}); \ No newline at end of file
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WebTorrent=e()}}(function(){var e=function(e){var t;return function(n){return t||e(t={exports:{},parent:n},t.exports),t.exports}},t=e(function(e,t){(function(e){var r=n({}),i=t,s={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};i.encode=function(t,n,r){return i.encodingLength(t),r=r||0,n=n||e.alloc(t.length),i._encode(t,n,r)},i._encode=function(e,t,n){var o=e.type,a=e.length;a>4294967295&&(a=1),t.writeUInt32BE(a,n),t.write(e.type,n+4,4,"ascii");var h=n+8;if(1===a&&(kr.encode(e.length,t,h),h+=8),r.fullBoxes[o]&&(t.writeUInt32BE(e.flags||0,h),t.writeUInt8(e.version||0,h),h+=4),s[o])s[o].forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){i._encode(e,t,h),h+=i.encode.bytes})}else e[n]&&(i._encode(e[n],t,h),h+=i.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){i._encode(e,t,h),h+=i.encode.bytes});else if(r[o]){var c=r[o].encode;c(e,t,h),h+=c.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+o+"') or `buffer` must be set");e.buffer.copy(t,h),h+=e.buffer.length}return i.encode.bytes=h-n,t},i.readHeaders=function(e,t,n){if(t=t||0,(n=n||e.length)-t<8)return 8;var i,s,o=e.readUInt32BE(t),a=e.toString("ascii",t+4,t+8),h=t+8;if(1===o){if(n-t<16)return 16;o=kr.decode(e,h),h+=8}return r.fullBoxes[a]&&(i=e.readUInt8(h),s=16777215&e.readUInt32BE(h),h+=4),{length:o,headersLen:h-t,contentLen:o-(h-t),type:a,version:i,flags:s}},i.decode=function(e,t,n){t=t||0,n=n||e.length;var r=i.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return i.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},i.decodeWithoutHeaders=function(t,n,o,a){o=o||0,a=a||n.length;var h=t.type,c={};if(s[h]){c.otherBoxes=[];for(var u=s[h],d=o;a-d>=8;){var l=i.decode(n,d,a);if(d+=l.length,u.indexOf(l.type)>=0)c[l.type]=l;else if(u.indexOf(l.type+"s")>=0){var f=l.type+"s";(c[f]=c[f]||[]).push(l)}else c.otherBoxes.push(l)}}else r[h]?c=(0,r[h].decode)(n,o,a):c.buffer=e.from(n.slice(o,a));return c.length=t.length,c.contentLen=t.contentLen,c.type=t.type,c.version=t.version,c.flags=t.flags,c},i.encodingLength=function(e){var t=e.type,n=8;if(r.fullBoxes[t]&&(n+=4),s[t])s[t].forEach(function(t){if(5===t.length){var r=e[t]||[];t=t.substr(0,4),r.forEach(function(e){e.type=t,n+=i.encodingLength(e)})}else if(e[t]){var s=e[t];s.type=t,n+=i.encodingLength(s)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=i.encodingLength(e)});else if(r[t])n+=r[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>4294967295&&(n+=8),e.length=n,n}}).call(this,u({}).Buffer)}),n=e(function(e,n){(function(e){var r=t({}),i=20828448e5;function s(e,t,n){for(var r=t;r<n;r++)e[r]=0}function o(e,t,n){t.writeUInt32BE(Math.floor((e.getTime()+i)/1e3),n)}function a(e,t,n){t.writeUIntBE(Math.floor((e.getTime()+i)/1e3),n,6)}function h(e,t,n){t.writeUInt16BE(Math.floor(e)%65536,n),t.writeUInt16BE(Math.floor(256*e*256)%65536,n+2)}function c(e,t,n){e||(e=[0,0,0,0,0,0,0,0,0]);for(var r=0;r<e.length;r++)h(e[r],t,n+4*r)}function u(e){for(var t=new Array(e.length/4),n=0;n<t.length;n++)t[n]=f(e,4*n);return t}function d(e,t){return new Date(1e3*e.readUIntBE(t,6)-i)}function l(e,t){return new Date(1e3*e.readUInt32BE(t)-i)}function f(e,t){return e.readUInt16BE(t)+e.readUInt16BE(t+2)/65536}function p(e,t){return e[t]+e[t+1]/256}function g(e,t,n){var r;for(r=0;r<n&&0!==e[t+r];r++);return e.toString("utf8",t,t+r)}n.fullBoxes={},["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(e){n.fullBoxes[e]=!0}),n.ftyp={},n.ftyp.encode=function(t,r,i){r=r?r.slice(i):e.alloc(n.ftyp.encodingLength(t));var s=t.compatibleBrands||[];r.write(t.brand,0,4,"ascii"),r.writeUInt32BE(t.brandVersion,4);for(var o=0;o<s.length;o++)r.write(s[o],8+4*o,4,"ascii");return n.ftyp.encode.bytes=8+4*s.length,r},n.ftyp.decode=function(e,t){for(var n=(e=e.slice(t)).toString("ascii",0,4),r=e.readUInt32BE(4),i=[],s=8;s<e.length;s+=4)i.push(e.toString("ascii",s,s+4));return{brand:n,brandVersion:r,compatibleBrands:i}},n.ftyp.encodingLength=function(e){return 8+4*(e.compatibleBrands||[]).length},n.mvhd={},n.mvhd.encode=function(t,r,i){return r=r?r.slice(i):e.alloc(96),o(t.ctime||new Date,r,0),o(t.mtime||new Date,r,4),r.writeUInt32BE(t.timeScale||0,8),r.writeUInt32BE(t.duration||0,12),h(t.preferredRate||0,r,16),function(e,t,n){t[20]=Math.floor(e)%256,t[21]=Math.floor(256*e)%256}(t.preferredVolume||0,r),s(r,22,32),c(t.matrix,r,32),r.writeUInt32BE(t.previewTime||0,68),r.writeUInt32BE(t.previewDuration||0,72),r.writeUInt32BE(t.posterTime||0,76),r.writeUInt32BE(t.selectionTime||0,80),r.writeUInt32BE(t.selectionDuration||0,84),r.writeUInt32BE(t.currentTime||0,88),r.writeUInt32BE(t.nextTrackId||0,92),n.mvhd.encode.bytes=96,r},n.mvhd.decode=function(e,t){return{ctime:l(e=e.slice(t),0),mtime:l(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),preferredRate:f(e,16),preferredVolume:p(e,20),matrix:u(e.slice(32,68)),previewTime:e.readUInt32BE(68),previewDuration:e.readUInt32BE(72),posterTime:e.readUInt32BE(76),selectionTime:e.readUInt32BE(80),selectionDuration:e.readUInt32BE(84),currentTime:e.readUInt32BE(88),nextTrackId:e.readUInt32BE(92)}},n.mvhd.encodingLength=function(e){return 96},n.tkhd={},n.tkhd.encode=function(t,r,i){return r=r?r.slice(i):e.alloc(80),o(t.ctime||new Date,r,0),o(t.mtime||new Date,r,4),r.writeUInt32BE(t.trackId||0,8),s(r,12,16),r.writeUInt32BE(t.duration||0,16),s(r,20,28),r.writeUInt16BE(t.layer||0,28),r.writeUInt16BE(t.alternateGroup||0,30),r.writeUInt16BE(t.volume||0,32),c(t.matrix,r,36),r.writeUInt32BE(t.trackWidth||0,72),r.writeUInt32BE(t.trackHeight||0,76),n.tkhd.encode.bytes=80,r},n.tkhd.decode=function(e,t){return{ctime:l(e=e.slice(t),0),mtime:l(e,4),trackId:e.readUInt32BE(8),duration:e.readUInt32BE(16),layer:e.readUInt16BE(28),alternateGroup:e.readUInt16BE(30),volume:e.readUInt16BE(32),matrix:u(e.slice(36,72)),trackWidth:e.readUInt32BE(72),trackHeight:e.readUInt32BE(76)}},n.tkhd.encodingLength=function(e){return 80},n.mdhd={},n.mdhd.encode=function(t,r,i){return 1===t.version?(r=r?r.slice(i):e.alloc(32),a(t.ctime||new Date,r,0),a(t.mtime||new Date,r,8),r.writeUInt32BE(t.timeScale||0,16),r.writeUIntBE(t.duration||0,20,6),r.writeUInt16BE(t.language||0,28),r.writeUInt16BE(t.quality||0,30),n.mdhd.encode.bytes=32,r):(r=r?r.slice(i):e.alloc(20),o(t.ctime||new Date,r,0),o(t.mtime||new Date,r,4),r.writeUInt32BE(t.timeScale||0,8),r.writeUInt32BE(t.duration||0,12),r.writeUInt16BE(t.language||0,16),r.writeUInt16BE(t.quality||0,18),n.mdhd.encode.bytes=20,r)},n.mdhd.decode=function(e,t,n){return e=e.slice(t),n-t!=20?{ctime:d(e,0),mtime:d(e,8),timeScale:e.readUInt32BE(16),duration:e.readUIntBE(20,6),language:e.readUInt16BE(28),quality:e.readUInt16BE(30)}:{ctime:l(e,0),mtime:l(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),language:e.readUInt16BE(16),quality:e.readUInt16BE(18)}},n.mdhd.encodingLength=function(e){return 1===e.version?32:20},n.vmhd={},n.vmhd.encode=function(t,r,i){(r=r?r.slice(i):e.alloc(8)).writeUInt16BE(t.graphicsMode||0,0);var s=t.opcolor||[0,0,0];return r.writeUInt16BE(s[0],2),r.writeUInt16BE(s[1],4),r.writeUInt16BE(s[2],6),n.vmhd.encode.bytes=8,r},n.vmhd.decode=function(e,t){return{graphicsMode:(e=e.slice(t)).readUInt16BE(0),opcolor:[e.readUInt16BE(2),e.readUInt16BE(4),e.readUInt16BE(6)]}},n.vmhd.encodingLength=function(e){return 8},n.smhd={},n.smhd.encode=function(t,r,i){return(r=r?r.slice(i):e.alloc(4)).writeUInt16BE(t.balance||0,0),s(r,2,4),n.smhd.encode.bytes=4,r},n.smhd.decode=function(e,t){return{balance:(e=e.slice(t)).readUInt16BE(0)}},n.smhd.encodingLength=function(e){return 4},n.stsd={},n.stsd.encode=function(t,i,s){i=i?i.slice(s):e.alloc(n.stsd.encodingLength(t));var o=t.entries||[];i.writeUInt32BE(o.length,0);for(var a=4,h=0;h<o.length;h++){var c=o[h];r.encode(c,i,a),a+=r.encode.bytes}return n.stsd.encode.bytes=a,i},n.stsd.decode=function(e,t,n){for(var i=(e=e.slice(t)).readUInt32BE(0),s=new Array(i),o=4,a=0;a<i;a++){var h=r.decode(e,o,n);s[a]=h,o+=h.length}return{entries:s}},n.stsd.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++)t+=r.encodingLength(e.entries[n]);return t},n.avc1=n.VisualSampleEntry={},n.VisualSampleEntry.encode=function(t,i,o){s(i=i?i.slice(o):e.alloc(n.VisualSampleEntry.encodingLength(t)),0,6),i.writeUInt16BE(t.dataReferenceIndex||0,6),s(i,8,24),i.writeUInt16BE(t.width||0,24),i.writeUInt16BE(t.height||0,26),i.writeUInt32BE(t.hResolution||4718592,28),i.writeUInt32BE(t.vResolution||4718592,32),s(i,36,40),i.writeUInt16BE(t.frameCount||1,40);var a=t.compressorName||"",h=Math.min(a.length,31);i.writeUInt8(h,42),i.write(a,43,h,"utf8"),i.writeUInt16BE(t.depth||24,74),i.writeInt16BE(-1,76);var c=78;(t.children||[]).forEach(function(e){r.encode(e,i,c),c+=r.encode.bytes}),n.VisualSampleEntry.encode.bytes=c},n.VisualSampleEntry.decode=function(e,t,n){e=e.slice(t);for(var i=n-t,s=Math.min(e.readUInt8(42),31),o={dataReferenceIndex:e.readUInt16BE(6),width:e.readUInt16BE(24),height:e.readUInt16BE(26),hResolution:e.readUInt32BE(28),vResolution:e.readUInt32BE(32),frameCount:e.readUInt16BE(40),compressorName:e.toString("utf8",43,43+s),depth:e.readUInt16BE(74),children:[]},a=78;i-a>=8;){var h=r.decode(e,a,i);o.children.push(h),o[h.type]=h,a+=h.length}return o},n.VisualSampleEntry.encodingLength=function(e){var t=78;return(e.children||[]).forEach(function(e){t+=r.encodingLength(e)}),t},n.avcC={},n.avcC.encode=function(t,r,i){r=r?r.slice(i):e.alloc(t.buffer.length),t.buffer.copy(r),n.avcC.encode.bytes=t.buffer.length},n.avcC.decode=function(t,n,r){return{mimeCodec:(t=t.slice(n,r)).toString("hex",1,4),buffer:e.from(t)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(t,i,o){s(i=i?i.slice(o):e.alloc(n.AudioSampleEntry.encodingLength(t)),0,6),i.writeUInt16BE(t.dataReferenceIndex||0,6),s(i,8,16),i.writeUInt16BE(t.channelCount||2,16),i.writeUInt16BE(t.sampleSize||16,18),s(i,20,24),i.writeUInt32BE(t.sampleRate||0,24);var a=28;(t.children||[]).forEach(function(e){r.encode(e,i,a),a+=r.encode.bytes}),n.AudioSampleEntry.encode.bytes=a},n.AudioSampleEntry.decode=function(e,t,n){for(var i=n-t,s={dataReferenceIndex:(e=e.slice(t,n)).readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},o=28;i-o>=8;){var a=r.decode(e,o,i);s.children.push(a),s[a.type]=a,o+=a.length}return s},n.AudioSampleEntry.encodingLength=function(e){var t=28;return(e.children||[]).forEach(function(e){t+=r.encodingLength(e)}),t},n.esds={},n.esds.encode=function(t,r,i){r=r?r.slice(i):e.alloc(t.buffer.length),t.buffer.copy(r,0),n.esds.encode.bytes=t.buffer.length},n.esds.decode=function(t,n,r){t=t.slice(n,r);var i=Cr.Descriptor.decode(t,0,t.length),s=("ESDescriptor"===i.tagName?i:{}).DecoderConfigDescriptor||{},o=s.oti||0,a=s.DecoderSpecificInfo,h=a?(248&a.buffer.readUInt8(0))>>3:0,c=null;return o&&(c=o.toString(16),h&&(c+="."+h)),{mimeCodec:c,buffer:e.from(t.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.stsz.encodingLength(t))).writeUInt32BE(0,0),r.writeUInt32BE(s.length,4);for(var o=0;o<s.length;o++)r.writeUInt32BE(s[o],4*o+8);return n.stsz.encode.bytes=8+4*s.length,r},n.stsz.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=e.readUInt32BE(4),i=new Array(r),s=0;s<r;s++)i[s]=0===n?e.readUInt32BE(4*s+8):n;return{entries:i}},n.stsz.encodingLength=function(e){return 8+4*e.entries.length},n.stss=n.stco={},n.stco.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.stco.encodingLength(t))).writeUInt32BE(s.length,0);for(var o=0;o<s.length;o++)r.writeUInt32BE(s[o],4*o+4);return n.stco.encode.bytes=4+4*s.length,r},n.stco.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=0;i<n;i++)r[i]=e.readUInt32BE(4*i+4);return{entries:r}},n.stco.encodingLength=function(e){return 4+4*e.entries.length},n.co64={},n.co64.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.co64.encodingLength(t))).writeUInt32BE(s.length,0);for(var o=0;o<s.length;o++)kr.encode(s[o],r,8*o+4);return n.co64.encode.bytes=4+8*s.length,r},n.co64.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=0;i<n;i++)r[i]=kr.decode(e,8*i+4);return{entries:r}},n.co64.encodingLength=function(e){return 4+8*e.entries.length},n.stts={},n.stts.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.stts.encodingLength(t))).writeUInt32BE(s.length,0);for(var o=0;o<s.length;o++){var a=8*o+4;r.writeUInt32BE(s[o].count||0,a),r.writeUInt32BE(s[o].duration||0,a+4)}return n.stts.encode.bytes=4+8*t.entries.length,r},n.stts.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=0;i<n;i++){var s=8*i+4;r[i]={count:e.readUInt32BE(s),duration:e.readUInt32BE(s+4)}}return{entries:r}},n.stts.encodingLength=function(e){return 4+8*e.entries.length},n.ctts={},n.ctts.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.ctts.encodingLength(t))).writeUInt32BE(s.length,0);for(var o=0;o<s.length;o++){var a=8*o+4;r.writeUInt32BE(s[o].count||0,a),r.writeUInt32BE(s[o].compositionOffset||0,a+4)}return n.ctts.encode.bytes=4+8*s.length,r},n.ctts.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=0;i<n;i++){var s=8*i+4;r[i]={count:e.readUInt32BE(s),compositionOffset:e.readInt32BE(s+4)}}return{entries:r}},n.ctts.encodingLength=function(e){return 4+8*e.entries.length},n.stsc={},n.stsc.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.stsc.encodingLength(t))).writeUInt32BE(s.length,0);for(var o=0;o<s.length;o++){var a=12*o+4;r.writeUInt32BE(s[o].firstChunk||0,a),r.writeUInt32BE(s[o].samplesPerChunk||0,a+4),r.writeUInt32BE(s[o].sampleDescriptionId||0,a+8)}return n.stsc.encode.bytes=4+12*s.length,r},n.stsc.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=0;i<n;i++){var s=12*i+4;r[i]={firstChunk:e.readUInt32BE(s),samplesPerChunk:e.readUInt32BE(s+4),sampleDescriptionId:e.readUInt32BE(s+8)}}return{entries:r}},n.stsc.encodingLength=function(e){return 4+12*e.entries.length},n.dref={},n.dref.encode=function(t,r,i){r=r?r.slice(i):e.alloc(n.dref.encodingLength(t));var s=t.entries||[];r.writeUInt32BE(s.length,0);for(var o=4,a=0;a<s.length;a++){var h=s[a],c=(h.buf?h.buf.length:0)+4+4;r.writeUInt32BE(c,o),o+=4,r.write(h.type,o,4,"ascii"),o+=4,h.buf&&(h.buf.copy(r,o),o+=h.buf.length)}return n.dref.encode.bytes=o,r},n.dref.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=4,s=0;s<n;s++){var o=e.readUInt32BE(i),a=e.toString("ascii",i+4,i+8),h=e.slice(i+8,i+o);i+=o,r[s]={type:a,buf:h}}return{entries:r}},n.dref.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++){var r=e.entries[n].buf;t+=(r?r.length:0)+4+4}return t},n.elst={},n.elst.encode=function(t,r,i){var s=t.entries||[];(r=r?r.slice(i):e.alloc(n.elst.encodingLength(t))).writeUInt32BE(s.length,0);for(var o=0;o<s.length;o++){var a=12*o+4;r.writeUInt32BE(s[o].trackDuration||0,a),r.writeUInt32BE(s[o].mediaTime||0,a+4),h(s[o].mediaRate||0,r,a+8)}return n.elst.encode.bytes=4+12*s.length,r},n.elst.decode=function(e,t){for(var n=(e=e.slice(t)).readUInt32BE(0),r=new Array(n),i=0;i<n;i++){var s=12*i+4;r[i]={trackDuration:e.readUInt32BE(s),mediaTime:e.readInt32BE(s+4),mediaRate:f(e,s+8)}}return{entries:r}},n.elst.encodingLength=function(e){return 4+12*e.entries.length},n.hdlr={},n.hdlr.encode=function(t,r,i){r=r?r.slice(i):e.alloc(n.hdlr.encodingLength(t));var s=21+(t.name||"").length;return r.fill(0,0,s),r.write(t.handlerType||"",4,4,"ascii"),function(t,n,r){var i=e.from(t,"utf8");i.copy(n,20),n[20+i.length]=0}(t.name||"",r),n.hdlr.encode.bytes=s,r},n.hdlr.decode=function(e,t,n){return{handlerType:(e=e.slice(t)).toString("ascii",4,8),name:g(e,20,n)}},n.hdlr.encodingLength=function(e){return 21+(e.name||"").length},n.mehd={},n.mehd.encode=function(t,r,i){return(r=r?r.slice(i):e.alloc(4)).writeUInt32BE(t.fragmentDuration||0,0),n.mehd.encode.bytes=4,r},n.mehd.decode=function(e,t){return{fragmentDuration:(e=e.slice(t)).readUInt32BE(0)}},n.mehd.encodingLength=function(e){return 4},n.trex={},n.trex.encode=function(t,r,i){return(r=r?r.slice(i):e.alloc(20)).writeUInt32BE(t.trackId||0,0),r.writeUInt32BE(t.defaultSampleDescriptionIndex||0,4),r.writeUInt32BE(t.defaultSampleDuration||0,8),r.writeUInt32BE(t.defaultSampleSize||0,12),r.writeUInt32BE(t.defaultSampleFlags||0,16),n.trex.encode.bytes=20,r},n.trex.decode=function(e,t){return{trackId:(e=e.slice(t)).readUInt32BE(0),defaultSampleDescriptionIndex:e.readUInt32BE(4),defaultSampleDuration:e.readUInt32BE(8),defaultSampleSize:e.readUInt32BE(12),defaultSampleFlags:e.readUInt32BE(16)}},n.trex.encodingLength=function(e){return 20},n.mfhd={},n.mfhd.encode=function(t,r,i){return(r=r?r.slice(i):e.alloc(4)).writeUInt32BE(t.sequenceNumber||0,0),n.mfhd.encode.bytes=4,r},n.mfhd.decode=function(e,t){return{sequenceNumber:e.readUInt32BE(0)}},n.mfhd.encodingLength=function(e){return 4},n.tfhd={},n.tfhd.encode=function(t,r,i){return(r=r?r.slice(i):e.alloc(4)).writeUInt32BE(t.trackId,0),n.tfhd.encode.bytes=4,r},n.tfhd.decode=function(e,t){},n.tfhd.encodingLength=function(e){return 4},n.tfdt={},n.tfdt.encode=function(t,r,i){return(r=r?r.slice(i):e.alloc(4)).writeUInt32BE(t.baseMediaDecodeTime||0,0),n.tfdt.encode.bytes=4,r},n.tfdt.decode=function(e,t){},n.tfdt.encodingLength=function(e){return 4},n.trun={},n.trun.encode=function(t,r,i){(r=r?r.slice(i):e.alloc(8+16*t.entries.length)).writeUInt32BE(t.entries.length,0),r.writeInt32BE(t.dataOffset,4);for(var s=8,o=0;o<t.entries.length;o++){var a=t.entries[o];r.writeUInt32BE(a.sampleDuration,s),s+=4,r.writeUInt32BE(a.sampleSize,s),s+=4,r.writeUInt32BE(a.sampleFlags,s),s+=4,0===(t.version||0)?r.writeUInt32BE(a.sampleCompositionTimeOffset,s):r.writeInt32BE(a.sampleCompositionTimeOffset,s),s+=4}n.trun.encode.bytes=s},n.trun.decode=function(e,t){},n.trun.encodingLength=function(e){return 8+16*e.entries.length},n.mdat={},n.mdat.encode=function(e,t,r){e.buffer?(e.buffer.copy(t,r),n.mdat.encode.bytes=e.buffer.length):n.mdat.encode.bytes=n.mdat.encodingLength(e)},n.mdat.decode=function(t,n,r){return{buffer:e.from(t.slice(n,r))}},n.mdat.encodingLength=function(e){return e.buffer?e.buffer.length:e.contentLength}}).call(this,u({}).Buffer)}),r=e(function(e,t){var n=1e3,r=6e4,i=36e5,s=24*i;function o(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,t){t=t||{};var a,h,c=typeof e;if("string"===c&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var o=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*o;case"weeks":case"week":case"w":return 6048e5*o;case"days":case"day":case"d":return o*s;case"hours":case"hour":case"hrs":case"hr":case"h":return o*i;case"minutes":case"minute":case"mins":case"min":case"m":return o*r;case"seconds":case"second":case"secs":case"sec":case"s":return o*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}}}(e);if("number"===c&&isFinite(e))return t.long?(a=e,(h=Math.abs(a))>=s?o(a,h,s,"day"):h>=i?o(a,h,i,"hour"):h>=r?o(a,h,r,"minute"):h>=n?o(a,h,n,"second"):a+" ms"):function(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=r?Math.round(e/r)+"m":t>=n?Math.round(e/n)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}}),i=e(function(e,t){(function(t,n){"use strict";var r;e.exports=S,S.ReadableState=k,d.EventEmitter;var i,o=function(e,t){return e.listeners(t).length},c=u({}).Buffer,l=n.Uint8Array||function(){};i=te&&te.debuglog?te.debuglog("stream"):function(){};var f,p,g=Ie.getHighWaterMark,m=ke.codes,_=m.ERR_INVALID_ARG_TYPE,y=m.ERR_STREAM_PUSH_AFTER_EOF,b=m.ERR_METHOD_NOT_IMPLEMENTED,w=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,v=Ae.emitExperimentalWarning;Re(S,ee);var E=["error","close","destroy","pause","resume"];function k(e,t,n){r=r||h({}),e=e||{},"boolean"!=typeof n&&(n=t instanceof r),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=g(this,e,"readableHighWaterMark",n),this.buffer=new he,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=a({}).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function S(e){if(r=r||h({}),!(this instanceof S))return new S(e);var t=this instanceof r;this._readableState=new k(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),ee.call(this)}function C(e,t,n,r,s){i("readableAddChunk",t);var o,a=e._readableState;if(null===t)a.reading=!1,function(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,t.sync?A(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,R(e)))}}(e,a);else if(s||(o=function(e,t){var n,r;return r=t,c.isBuffer(r)||r instanceof l||"string"==typeof t||void 0===t||e.objectMode||(n=new _("chunk",["string","Buffer","Uint8Array"],t)),n}(a,t)),o)e.emit("error",o);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),r)a.endEmitted?e.emit("error",new w):x(e,a,t,!0);else if(a.ended)e.emit("error",new y);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?x(e,a,t,!1):L(e,a)):x(e,a,t,!1)}else r||(a.reading=!1,L(e,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function x(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&A(e)),L(e,t)}Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),S.prototype.destroy=Ee.destroy,S.prototype._undestroy=Ee.undestroy,S.prototype._destroy=function(e,t){t(e)},S.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=c.from(e,t),t=""),n=!0),C(this,e,t,!1,n)},S.prototype.unshift=function(e){return C(this,e,null,!0,!1)},S.prototype.isPaused=function(){return!1===this._readableState.flowing},S.prototype.setEncoding=function(e){return f||(f=a({}).StringDecoder),this._readableState.decoder=new f(e),this._readableState.encoding=this._readableState.decoder.encoding,this};var T=8388608;function I(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=function(e){return e>=T?e=T:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function A(e){var n=e._readableState;n.needReadable=!1,n.emittedReadable||(i("emitReadable",n.flowing),n.emittedReadable=!0,t.nextTick(R,e))}function R(e){var t=e._readableState;i("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||e.emit("readable"),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,P(e)}function L(e,n){n.readingMore||(n.readingMore=!0,t.nextTick(B,e,n))}function B(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(i("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function U(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){i("readable nexttick read 0"),e.read(0)}function M(e,t){i("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),P(e),t.flowing&&!t.reading&&e.read(0)}function P(e){var t=e._readableState;for(i("flow",t.flowing);t.flowing&&null!==e.read(););}function N(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function j(e){var n=e._readableState;i("endReadable",n.endEmitted),n.endEmitted||(n.ended=!0,t.nextTick(H,n,e))}function H(e,t){i("endReadableNT",e.endEmitted,e.length),e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function D(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}S.prototype.read=function(e){i("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return i("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?j(this):A(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&j(this),null;var r,s=t.needReadable;return i("need readable",s),(0===t.length||t.length-e<t.highWaterMark)&&i("length less than watermark",s=!0),t.ended||t.reading?i("reading or ended",s=!1):s&&(i("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(n,t))),null===(r=e>0?N(e,t):null)?(t.needReadable=!0,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&j(this)),null!==r&&this.emit("data",r),r},S.prototype._read=function(e){this.emit("error",new b("_read()"))},S.prototype.pipe=function(e,n){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,i("pipe count=%d opts=%j",s.pipesCount,n);var a=n&&!1===n.end||e===t.stdout||e===t.stderr?g:h;function h(){i("onend"),e.end()}s.endEmitted?t.nextTick(a):r.once("end",a),e.on("unpipe",function t(n,o){i("onunpipe"),n===r&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,i("cleanup"),e.removeListener("close",f),e.removeListener("finish",p),e.removeListener("drain",c),e.removeListener("error",l),e.removeListener("unpipe",t),r.removeListener("end",h),r.removeListener("end",g),r.removeListener("data",d),u=!0,!s.awaitDrain||e._writableState&&!e._writableState.needDrain||c())});var c=function(e){return function(){var t=e._readableState;i("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,P(e))}}(r);e.on("drain",c);var u=!1;function d(t){i("ondata");var n=e.write(t);i("dest.write",n),!1===n&&((1===s.pipesCount&&s.pipes===e||s.pipesCount>1&&-1!==D(s.pipes,e))&&!u&&(i("false write response, pause",s.awaitDrain),s.awaitDrain++),r.pause())}function l(t){i("onerror",t),g(),e.removeListener("error",l),0===o(e,"error")&&e.emit("error",t)}function f(){e.removeListener("finish",p),g()}function p(){i("onfinish"),e.removeListener("close",f),g()}function g(){i("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener("error",n);e._events&&e._events.error?Array.isArray(e._events.error)?e._events.error.unshift(n):e._events.error=[n,e._events.error]:e.on("error",n)}(e,0,l),e.once("close",f),e.once("finish",p),e.emit("pipe",r),s.flowing||(i("pipe resume"),r.resume()),e},S.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};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,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<i;s++)r[s].emit("unpipe",this,{hasUnpiped:!1});return this}var o=D(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},S.prototype.on=function(e,n){var r=ee.prototype.on.call(this,e,n),s=this._readableState;return"data"===e?(s.readableListening=this.listenerCount("readable")>0,!1!==s.flowing&&this.resume()):"readable"===e&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,i("on readable",s.length,s.reading),s.length?A(this):s.reading||t.nextTick(O,this))),r},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(e,n){var r=ee.prototype.removeListener.call(this,e,n);return"readable"===e&&t.nextTick(U,this),r},S.prototype.removeAllListeners=function(e){var n=ee.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||t.nextTick(U,this),n},S.prototype.resume=function(){var e=this._readableState;return e.flowing||(i("resume"),e.flowing=!e.readableListening,function(e,n){n.resumeScheduled||(n.resumeScheduled=!0,t.nextTick(M,e,n))}(this,e)),e.paused=!1,this},S.prototype.pause=function(){return i("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(i("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},S.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var s in e.on("end",function(){if(i("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(s){i("wrapped data"),n.decoder&&(s=n.decoder.write(s)),n.objectMode&&null==s||(n.objectMode||s&&s.length)&&(t.push(s)||(r=!0,e.pause()))}),e)void 0===this[s]&&"function"==typeof e[s]&&(this[s]=function(t){return function(){return e[t].apply(e,arguments)}}(s));for(var o=0;o<E.length;o++)e.on(E[o],this.emit.bind(this,E[o]));return this._read=function(t){i("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(S.prototype[Symbol.asyncIterator]=function(){return v("Readable[Symbol.asyncIterator]"),void 0===p&&(p=s({})),p(this)}),Object.defineProperty(S.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(S.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(S.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),S._fromList=N,Object.defineProperty(S.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}})}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}),s=e(function(e,t){(function(t){"use strict";var n;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=o({}),s=Symbol("lastResolve"),a=Symbol("lastReject"),h=Symbol("error"),c=Symbol("ended"),u=Symbol("lastPromise"),d=Symbol("handlePromise"),l=Symbol("stream");function f(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var n=e[l].read();null!==n&&(e[u]=null,e[s]=null,e[a]=null,t(f(n,!1)))}}var g=Object.getPrototypeOf(function(){}),m=Object.setPrototypeOf((r(n={get stream(){return this[l]},next:function(){var e=this,n=this[h];if(null!==n)return Promise.reject(n);if(this[c])return Promise.resolve(f(void 0,!0));if(this[l].destroyed)return new Promise(function(n,r){t.nextTick(function(){e[h]?r(e[h]):n(f(void 0,!0))})});var r,i=this[u];if(i)r=new Promise(function(e,t){return function(n,r){e.then(function(){t[c]?n(f(void 0,!0)):t[d](n,r)},r)}}(i,this));else{var s=this[l].read();if(null!==s)return Promise.resolve(f(s,!1));r=new Promise(this[d])}return this[u]=r,r}},Symbol.asyncIterator,function(){return this}),r(n,"return",function(){var e=this;return new Promise(function(t,n){e[l].destroy(null,function(e){e?n(e):t(f(void 0,!0))})})}),n),g);e.exports=function(e){var n,o=Object.create(m,(r(n={},l,{value:e,writable:!0}),r(n,s,{value:null,writable:!0}),r(n,a,{value:null,writable:!0}),r(n,h,{value:null,writable:!0}),r(n,c,{value:e._readableState.endEmitted,writable:!0}),r(n,d,{value:function(e,t){var n=o[l].read();n?(o[u]=null,o[s]=null,o[a]=null,e(f(n,!1))):(o[s]=e,o[a]=t)},writable:!0}),n));return o[u]=null,i(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=o[a];return null!==t&&(o[u]=null,o[s]=null,o[a]=null,t(e)),void(o[h]=e)}var n=o[s];null!==n&&(o[u]=null,o[s]=null,o[a]=null,n(f(void 0,!0))),o[c]=!0}),e.on("readable",function(e){t.nextTick(p,e)}.bind(null,o)),o}}).call(this,ce)}),o=e(function(e,t){"use strict";var n=ke.codes.ERR_STREAM_PREMATURE_CLOSE;function r(){}e.exports=function e(t,i,s){if("function"==typeof i)return e(t,null,i);i||(i={}),s=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(s||r);var o=i.readable||!1!==i.readable&&t.readable,a=i.writable||!1!==i.writable&&t.writable,h=function(){t.writable||u()},c=t._writableState&&t._writableState.finished,u=function(){a=!1,c=!0,o||s.call(t)},d=t._readableState&&t._readableState.endEmitted,l=function(){o=!1,d=!0,a||s.call(t)},f=function(e){s.call(t,e)},p=function(){var e;return o&&!d?(t._readableState&&t._readableState.ended||(e=new n),s.call(t,e)):a&&!c?(t._writableState&&t._writableState.ended||(e=new n),s.call(t,e)):void 0},g=function(){t.req.on("finish",u)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",u),t.on("abort",p),t.req?g():t.on("request",g)):a&&!t._writableState&&(t.on("end",h),t.on("close",h)),t.on("end",l),t.on("finish",u),!1!==i.error&&t.on("error",f),t.on("close",p),function(){t.removeListener("complete",u),t.removeListener("abort",p),t.removeListener("request",g),t.req&&t.req.removeListener("finish",u),t.removeListener("end",h),t.removeListener("close",h),t.removeListener("finish",u),t.removeListener("end",l),t.removeListener("error",f),t.removeListener("close",p)}}}),a=e(function(e,t){"use strict";var n=N.Buffer,r=n.isEncoding||function(e){switch((e=""+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}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===r||!r(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=a,this.end=h,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=c,this.end=u,t=3;break;default:return this.write=d,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"\ufffd";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"\ufffd";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"\ufffd"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function h(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function c(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},i.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\ufffd":t},i.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=s(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||-2===i?0:(i=s(t[r]))>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||-2===i?0:(i=s(t[r]))>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}}),h=e(function(e,t){(function(t){"use strict";var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=u;var r=i({}),s=c({});Re(u,r);for(var o=n(s.prototype),a=0;a<o.length;a++){var h=o[a];u.prototype[h]||(u.prototype[h]=s.prototype[h])}function u(e){if(!(this instanceof u))return new u(e);r.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",d)))}function d(){this._writableState.ended||t.nextTick(l,this)}function l(e){e.end()}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this,ce)}),c=e(function(e,t){(function(t,n){"use strict";function r(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(void 0),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var i;e.exports=k,k.WritableState=E;var s,o={deprecate:Le},a=u({}).Buffer,c=n.Uint8Array||function(){},d=Ie.getHighWaterMark,l=ke.codes,f=l.ERR_INVALID_ARG_TYPE,p=l.ERR_METHOD_NOT_IMPLEMENTED,g=l.ERR_MULTIPLE_CALLBACK,m=l.ERR_STREAM_CANNOT_PIPE,_=l.ERR_STREAM_DESTROYED,y=l.ERR_STREAM_NULL_VALUES,b=l.ERR_STREAM_WRITE_AFTER_END,w=l.ERR_UNKNOWN_ENCODING;function v(){}function E(e,n,s){i=i||h({}),e=e||{},"boolean"!=typeof s&&(s=n instanceof i),this.objectMode=!!e.objectMode,s&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=d(this,e,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===e.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,n){var r=e._writableState,i=r.sync,s=r.writecb;if("function"!=typeof s)throw new g;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),n)!function(e,n,r,i,s){--n.pendingcb,r?(t.nextTick(s,i),t.nextTick(A,e,n),e._writableState.errorEmitted=!0,e.emit("error",i)):(s(i),e._writableState.errorEmitted=!0,e.emit("error",i),A(e,n))}(e,r,i,n,s);else{var o=T(r)||e.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||x(e,r),i?t.nextTick(C,e,r,o,s):C(e,r,o,s)}}(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function k(e){var t=this instanceof(i=i||h({}));if(!t&&!s.call(k,this))return new k(e);this._writableState=new E(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),ee.call(this)}function S(e,t,n,r,i,s,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new _("write")):n?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function C(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),A(e,t)}function x(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,s=new Array(i),o=t.corkedRequestsFree;o.entry=n;for(var a=0,h=!0;n;)s[a]=n,n.isBuf||(h=!1),n=n.next,a+=1;s.allBuffers=h,S(e,t,!0,t.length,s,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new r(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,u=n.encoding,d=n.callback;if(S(e,t,!1,t.objectMode?1:c.length,c,u,d),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function T(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function I(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),A(e,t)})}function A(e,n){var r=T(n);return r&&(function(e,n){n.prefinished||n.finalCalled||("function"!=typeof e._final||n.destroyed?(n.prefinished=!0,e.emit("prefinish")):(n.pendingcb++,n.finalCalled=!0,t.nextTick(I,e,n)))}(e,n),0===n.pendingcb&&(n.finished=!0,e.emit("finish"))),r}Re(k,ee),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(e){return!!s.call(this,e)||this===k&&e&&e._writableState instanceof E}})):s=function(e){return e instanceof this},k.prototype.pipe=function(){this.emit("error",new m)},k.prototype.write=function(e,n,r){var i,s=this._writableState,o=!1,h=!s.objectMode&&(i=e,a.isBuffer(i)||i instanceof c);return h&&!a.isBuffer(e)&&(e=function(e){return a.from(e)}(e)),"function"==typeof n&&(r=n,n=null),h?n="buffer":n||(n=s.defaultEncoding),"function"!=typeof r&&(r=v),s.ending?function(e,n){var r=new b;e.emit("error",r),t.nextTick(n,r)}(this,r):(h||function(e,n,r,i){var s;return null===r?s=new y:"string"==typeof r||n.objectMode||(s=new f("chunk",["string","Buffer"],r)),!s||(e.emit("error",s),t.nextTick(i,s),!1)}(this,s,e,r))&&(s.pendingcb++,o=function(e,t,n,r,i,s){if(!n){var o=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=a.from(t,n)),t}(t,r,i);r!==o&&(n=!0,i="buffer",r=o)}var h=t.objectMode?1:r.length;t.length+=h;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:s,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else S(e,t,!1,h,r,i,s);return c}(this,s,h,e,n,r)),o},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||x(this,e))},k.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 w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(e,t,n){n(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(e,n,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,n=null):"function"==typeof n&&(r=n,n=null),null!=e&&this.write(e,n),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,n,r){n.ending=!0,A(e,n),r&&(n.finished?t.nextTick(r):e.once("finish",r)),n.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),k.prototype.destroy=Ee.destroy,k.prototype._undestroy=Ee.undestroy,k.prototype._destroy=function(e,t){t(e)}}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}),u=e(function(e,t){(function(e){"use strict";var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=e,t.SlowBuffer=function(t){return+t!=t&&(t=0),e.alloc(+t)},t.INSPECT_MAX_BYTES=50;var r=2147483647;function i(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=new Uint8Array(t);return Object.setPrototypeOf(n,e.prototype),n}function e(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return a(e)}return s(e,t,n)}function s(t,n,r){if("string"==typeof t)return function(t,n){if("string"==typeof n&&""!==n||(n="utf8"),!e.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var r=0|u(t,n),s=i(r),o=s.write(t,n);return o!==r&&(s=s.slice(0,o)),s}(t,n);if(ArrayBuffer.isView(t))return h(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(j(t,ArrayBuffer)||t&&j(t.buffer,ArrayBuffer))return function(t,n,r){if(n<0||t.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;return i=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),Object.setPrototypeOf(i,e.prototype),i}(t,n,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var s=t.valueOf&&t.valueOf();if(null!=s&&s!==t)return e.from(s,n,r);var o=function(t){if(e.isBuffer(t)){var n=0|c(t.length),r=i(n);return 0===r.length?r:(t.copy(r,0,0,n),r)}return void 0!==t.length?"number"!=typeof t.length||H(t.length)?i(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return e.from(t[Symbol.toPrimitive]("string"),n,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function o(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function a(e){return o(e),i(e<0?0:0|c(e))}function h(e){for(var t=e.length<0?0:0|c(e.length),n=i(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function c(e){if(e>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|e}function u(t,n){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var s=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return O(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return P(t).length;default:if(s)return i?-1:O(t).length;n=(""+n).toLowerCase(),s=!0}}function d(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function l(t,n,r,i,s){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof n&&(n=e.from(n,i)),e.isBuffer(n))return 0===n.length?-1:f(t,n,r,i,s);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,n,r):Uint8Array.prototype.lastIndexOf.call(t,n,r):f(t,[n],r,i,s);throw new TypeError("val must be string, number or Buffer")}function f(e,t,n,r,i){var s,o=1,a=e.length,h=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,h/=2,n/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var u=-1;for(s=n;s<a;s++)if(c(e,s)===c(t,-1===u?0:s-u)){if(-1===u&&(u=s),s-u+1===h)return u*o}else-1!==u&&(s-=s-u),u=-1}else for(n+h>a&&(n=a-h),s=n;s>=0;s--){for(var d=!0,l=0;l<h;l++)if(c(e,s+l)!==c(t,l)){d=!1;break}if(d)return s}return-1}function p(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(H(a))return o;e[n+o]=a}return o}function g(e,t,n,r){return N(O(t,e.length-n),e,n,r)}function m(e,t,n,r){return N(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function _(e,t,n,r){return m(e,t,n,r)}function y(e,t,n,r){return N(P(t),e,n,r)}function b(e,t,n,r){return N(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function w(e,t,n){return 0===t&&n===e.length?x.fromByteArray(e):x.fromByteArray(e.slice(t,n))}function v(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,h,c=e[i],u=null,d=c>239?4:c>223?3:c>191?2:1;if(i+d<=n)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(s=e[i+1]))&&(h=(31&c)<<6|63&s)>127&&(u=h);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(h=(15&c)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(u=h);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(u=h)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=E));return n}(r)}t.kMaxLength=r,e.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(n){return!1}}(),e.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."),Object.defineProperty(e.prototype,"parent",{enumerable:!0,get:function(){if(e.isBuffer(this))return this.buffer}}),Object.defineProperty(e.prototype,"offset",{enumerable:!0,get:function(){if(e.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&e[Symbol.species]===e&&Object.defineProperty(e,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),e.poolSize=8192,e.from=function(e,t,n){return s(e,t,n)},Object.setPrototypeOf(e.prototype,Uint8Array.prototype),Object.setPrototypeOf(e,Uint8Array),e.alloc=function(e,t,n){return function(e,t,n){return o(e),e<=0?i(e):void 0!==t?"string"==typeof n?i(e).fill(t,n):i(e).fill(t):i(e)}(e,t,n)},e.allocUnsafe=function(e){return a(e)},e.allocUnsafeSlow=function(e){return a(e)},e.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==e.prototype},e.compare=function(t,n){if(j(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),j(n,Uint8Array)&&(n=e.from(n,n.offset,n.byteLength)),!e.isBuffer(t)||!e.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;for(var r=t.length,i=n.length,s=0,o=Math.min(r,i);s<o;++s)if(t[s]!==n[s]){r=t[s],i=n[s];break}return r<i?-1:i<r?1:0},e.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},e.concat=function(t,n){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return e.alloc(0);var r;if(void 0===n)for(n=0,r=0;r<t.length;++r)n+=t[r].length;var i=e.allocUnsafe(n),s=0;for(r=0;r<t.length;++r){var o=t[r];if(j(o,Uint8Array)&&(o=e.from(o)),!e.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i},e.byteLength=u,e.prototype._isBuffer=!0,e.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)d(this,t,t+1);return this},e.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)d(this,t,t+3),d(this,t+1,t+2);return this},e.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)d(this,t,t+7),d(this,t+1,t+6),d(this,t+2,t+5),d(this,t+3,t+4);return this},e.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?v(this,0,e):function(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))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return v(this,t,n);case"ascii":return k(this,t,n);case"latin1":case"binary":return S(this,t,n);case"base64":return w(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},n&&(e.prototype[n]=e.prototype.inspect),e.prototype.compare=function(t,n,r,i,s){if(j(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===n&&(n=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),n<0||r>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&n>=r)return 0;if(i>=s)return-1;if(n>=r)return 1;if(this===t)return 0;for(var o=(s>>>=0)-(i>>>=0),a=(r>>>=0)-(n>>>=0),h=Math.min(o,a),c=this.slice(i,s),u=t.slice(n,r),d=0;d<h;++d)if(c[d]!==u[d]){o=c[d],a=u[d];break}return o<a?-1:a<o?1:0},e.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},e.prototype.indexOf=function(e,t,n){return l(this,e,t,n,!0)},e.prototype.lastIndexOf=function(e,t,n){return l(this,e,t,n,!1)},e.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return p(this,e,t,n);case"utf8":case"utf-8":return g(this,e,t,n);case"ascii":return m(this,e,t,n);case"latin1":case"binary":return _(this,e,t,n);case"base64":return y(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function k(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function S(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var s="",o=t;o<n;++o)s+=(r=e[o])<16?"0"+r.toString(16):r.toString(16);return s}function T(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function I(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(t,n,r,i,s,o){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>s||n<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function R(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,i){return t=+t,n>>>=0,i||R(e,0,n,4),M.write(e,t,n,r,23,4),n+4}function B(e,t,n,r,i){return t=+t,n>>>=0,i||R(e,0,n,8),M.write(e,t,n,r,52,8),n+8}e.prototype.slice=function(t,n){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(n=void 0===n?r:~~n)<0?(n+=r)<0&&(n=0):n>r&&(n=r),n<t&&(n=t);var i=this.subarray(t,n);return Object.setPrototypeOf(i,e.prototype),i},e.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},e.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},e.prototype.readUInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]},e.prototype.readUInt16LE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]|this[e+1]<<8},e.prototype.readUInt16BE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]<<8|this[e+1]},e.prototype.readUInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},e.prototype.readUInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},e.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},e.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},e.prototype.readInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},e.prototype.readInt16LE=function(e,t){e>>>=0,t||I(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},e.prototype.readInt16BE=function(e,t){e>>>=0,t||I(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},e.prototype.readInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},e.prototype.readInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},e.prototype.readFloatLE=function(e,t){return e>>>=0,t||I(e,4,this.length),M.read(this,e,!0,23,4)},e.prototype.readFloatBE=function(e,t){return e>>>=0,t||I(e,4,this.length),M.read(this,e,!1,23,4)},e.prototype.readDoubleLE=function(e,t){return e>>>=0,t||I(e,8,this.length),M.read(this,e,!0,52,8)},e.prototype.readDoubleBE=function(e,t){return e>>>=0,t||I(e,8,this.length),M.read(this,e,!1,52,8)},e.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},e.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||A(this,e,t,n,Math.pow(2,8*n)-1,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},e.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,1,255,0),this[t]=255&e,t+1},e.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},e.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},e.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||A(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},e.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||A(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},e.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},e.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},e.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},e.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},e.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},e.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||A(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},e.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||A(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},e.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},e.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},e.prototype.writeDoubleLE=function(e,t,n){return B(this,e,t,!0,n)},e.prototype.writeDoubleBE=function(e,t,n){return B(this,e,t,!1,n)},e.prototype.copy=function(t,n,r,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-n<i-r&&(i=t.length-n+r);var s=i-r;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(n,r,i);else if(this===t&&r<n&&n<i)for(var o=s-1;o>=0;--o)t[o+n]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,i),n);return s},e.prototype.fill=function(t,n,r,i){if("string"==typeof t){if("string"==typeof n?(i=n,n=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var s=t.charCodeAt(0);("utf8"===i&&s<128||"latin1"===i)&&(t=s)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;var o;if(n>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=n;o<r;++o)this[o]=t;else{var a=e.isBuffer(t)?t:e.from(t,i),h=a.length;if(0===h)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-n;++o)this[o+n]=a[o%h]}return this};var U=/[^+\/0-9A-Za-z-_]/g;function O(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.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;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function P(e){return x.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function N(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function j(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}}).call(this,u({}).Buffer)}),d={},l=Object.create||function(e){var t=function(){};return t.prototype=e,new t},f=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},p=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function g(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=l(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}d=g,g.EventEmitter=g,g.prototype._events=void 0,g.prototype._maxListeners=void 0;var m,_=10;try{var y={};Object.defineProperty&&Object.defineProperty(y,"x",{value:0}),m=0===y.x}catch(fi){m=!1}function b(e){return void 0===e._maxListeners?g.defaultMaxListeners:e._maxListeners}function w(e,t,n,r){var i,s,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]):(s=e._events=l(null),e._eventsCount=0),o){if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=b(e))&&i>0&&o.length>i){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",a.name,a.message)}}else o=s[t]=n,++e._eventsCount;return e}function v(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function E(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=p.call(v,r);return i.listener=n,r.wrapFn=i,i}function k(e,t,n){var r=e._events;if(!r)return[];var i=r[t];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):C(i,i.length):[]}function S(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function C(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}m?Object.defineProperty(g,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');_=e}}):g.defaultMaxListeners=_,g.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},g.prototype.getMaxListeners=function(){return b(this)},g.prototype.emit=function(e){var t,n,r,i,s,o,a="error"===e;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var h=new Error('Unhandled "error" event. ('+t+")");throw h.context=t,h}if(!(n=o[e]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=C(e,r),s=0;s<r;++s)i[s].call(n)}(n,c,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=C(e,i),o=0;o<i;++o)s[o].call(n,r)}(n,c,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,o=C(e,s),a=0;a<s;++a)o[a].call(n,r,i)}(n,c,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var o=e.length,a=C(e,o),h=0;h<o;++h)a[h].call(n,r,i,s)}(n,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=C(e,i),o=0;o<i;++o)s[o].apply(n,r)}(n,c,this,i)}return!0},g.prototype.addListener=function(e,t){return w(this,e,t,!1)},g.prototype.on=g.prototype.addListener,g.prototype.prependListener=function(e,t){return w(this,e,t,!0)},g.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,E(this,e,t)),this},g.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,E(this,e,t)),this},g.prototype.removeListener=function(e,t){var n,r,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=l(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(var n=i,r=n+1,s=e.length;r<s;n+=1,r+=1)e[n]=e[r];e.pop()}(n),1===n.length&&(r[e]=n[0]),r.removeListener&&this.emit("removeListener",e,o||t)}return this},g.prototype.removeAllListeners=function(e){var t,n,r;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=l(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=l(null):delete n[e]),this;if(0===arguments.length){var i,s=f(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=l(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},g.prototype.listeners=function(e){return k(this,e,!0)},g.prototype.rawListeners=function(e){return k(this,e,!1)},g.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):S.call(e,t)},g.prototype.listenerCount=S,g.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};for(var x={toByteArray:function(e){var t,n,r=U(e),i=r[0],s=r[1],o=new A(function(e,t,n){return 3*(t+n)/4-n}(0,i,s)),a=0,h=s>0?i-4:i;for(n=0;n<h;n+=4)t=I[e.charCodeAt(n)]<<18|I[e.charCodeAt(n+1)]<<12|I[e.charCodeAt(n+2)]<<6|I[e.charCodeAt(n+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===s&&(t=I[e.charCodeAt(n)]<<2|I[e.charCodeAt(n+1)]>>4,o[a++]=255&t),1===s&&(t=I[e.charCodeAt(n)]<<10|I[e.charCodeAt(n+1)]<<4|I[e.charCodeAt(n+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o},fromByteArray:function(e){for(var t,n=e.length,r=n%3,i=[],s=0,o=n-r;s<o;s+=16383)i.push(O(e,s,s+16383>o?o:s+16383));return 1===r?(t=e[n-1],i.push(T[t>>2]+T[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],i.push(T[t>>10]+T[t>>4&63]+T[t<<2&63]+"=")),i.join("")}},T=[],I=[],A="undefined"!=typeof Uint8Array?Uint8Array:Array,R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,B=R.length;L<B;++L)T[L]=R[L],I[R.charCodeAt(L)]=L;function U(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function O(e,t,n){for(var r,i,s=[],o=t;o<n;o+=3)r=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(T[(i=r)>>18&63]+T[i>>12&63]+T[i>>6&63]+T[63&i]);return s.join("")}I["-".charCodeAt(0)]=62,I["_".charCodeAt(0)]=63;var M={read:function(e,t,n,r,i){var s,o,a=8*i-r-1,h=(1<<a)-1,c=h>>1,u=-7,d=n?i-1:0,l=n?-1:1,f=e[t+d];for(d+=l,s=f&(1<<-u)-1,f>>=-u,u+=a;u>0;s=256*s+e[t+d],d+=l,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=256*o+e[t+d],d+=l,u-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=c}return(f?-1:1)*o*Math.pow(2,s-r)},write:function(e,t,n,r,i,s){var o,a,h,c=8*s-i-1,u=(1<<c)-1,d=u>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+d>=1?l/h:l*Math.pow(2,1-d))*h>=2&&(o++,h/=2),o+d>=u?(a=0,o=u):o+d>=1?(a=(t*h-1)*Math.pow(2,i),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[n+f]=255&o,f+=p,o/=256,c-=8);e[n+f-p]|=128*g}},P={};(function(e){P=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,u({}).Buffer);var N={},j=u({}),H=j.Buffer;function D(e,t){for(var n in e)t[n]=e[n]}function q(e,t,n){return H(e,t,n)}H.from&&H.alloc&&H.allocUnsafe&&H.allocUnsafeSlow?N=j:(D(j,N),N.Buffer=q),q.prototype=Object.create(H.prototype),D(H,q),q.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return H(e,t,n)},q.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=H(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},q.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return H(e)},q.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return j.SlowBuffer(e)};var F,W=N.Buffer;function z(e,t,n){var r=[],i=null;return z._encode(r,e),i=W.concat(r),z.bytes=i.length,W.isBuffer(t)?(i.copy(t,n),t):i}z.bytes=-1,z._floatConversionDetected=!1,z.getType=function(e){return W.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},z._encode=function(e,t){if(null!=t)switch(z.getType(t)){case"buffer":z.buffer(e,t);break;case"object":z.dict(e,t);break;case"array":z.list(e,t);break;case"string":z.string(e,t);break;case"number":case"boolean":z.number(e,t);break;case"arraybufferview":z.buffer(e,W.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":z.buffer(e,W.from(t))}};var $=W.from("e"),V=W.from("d"),G=W.from("l");z.buffer=function(e,t){e.push(W.from(t.length+":"),t)},z.string=function(e,t){e.push(W.from(W.byteLength(t)+":"+t))},z.number=function(e,t){var n=2147483648*(t/2147483648<<0)+(t%2147483648<<0);e.push(W.from("i"+n+"e")),n===t||z._floatConversionDetected||(z._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+n+'"'),console.trace())},z.dict=function(e,t){e.push(V);for(var n,r=0,i=Object.keys(t).sort(),s=i.length;r<s;r++)null!=t[n=i[r]]&&(z.string(e,n),z._encode(e,t[n]));e.push($)},z.list=function(e,t){var n=0,r=t.length;for(e.push(G);n<r;n++)null!=t[n]&&z._encode(e,t[n]);e.push($)},F=z;var K,Y=N.Buffer;function J(e,t,n){for(var r=0,i=1,s=t;s<n;s++){var o=e[s];if(o<58&&o>=48)r=10*r+(o-48);else if(s!==t||43!==o){if(s!==t||45!==o){if(46===o)break;throw new Error("not a number: buffer["+s+"] = "+o)}i=-1}}return r*i}function X(e,t,n,r){return null==e||0===e.length?null:("number"!=typeof t&&null==r&&(r=t,t=void 0),"number"!=typeof n&&null==r&&(r=n,n=void 0),X.position=0,X.encoding=r||null,X.data=Y.isBuffer(e)?e.slice(t,n):Y.from(e),X.bytes=X.data.length,X.next())}X.bytes=0,X.position=0,X.data=null,X.encoding=null,X.next=function(){switch(X.data[X.position]){case 100:return X.dictionary();case 108:return X.list();case 105:return X.integer();default:return X.buffer()}},X.find=function(e){for(var t=X.position,n=X.data.length,r=X.data;t<n;){if(r[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")},X.dictionary=function(){X.position++;for(var e={};101!==X.data[X.position];)e[X.buffer()]=X.next();return X.position++,e},X.list=function(){X.position++;for(var e=[];101!==X.data[X.position];)e.push(X.next());return X.position++,e},X.integer=function(){var e=X.find(101),t=J(X.data,X.position+1,e);return X.position+=e+1-X.position,t},X.buffer=function(){var e=X.find(58),t=J(X.data,X.position,e),n=++e+t;return X.position=n,X.encoding?X.data.toString(X.encoding,e,n):X.data.slice(e,n)},K=X;var Z={},Q=Z;Q.encode=F,Q.decode=K,Q.byteLength=Q.encodingLength=function(e){return Q.encode(e).length};var ee=d.EventEmitter,te={};function ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var re,ie,se=u({}).Buffer,oe=te.inspect,ae=oe&&oe.custom||"inspect",he=function(){function e(){this.head=null,this.tail=null,this.length=0}var t=e.prototype;return t.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},t.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},t.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}},t.clear=function(){this.head=this.tail=null,this.length=0},t.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},t.concat=function(e){if(0===this.length)return se.alloc(0);for(var t,n,r,i=se.allocUnsafe(e>>>0),s=this.head,o=0;s;)t=s.data,n=i,r=o,se.prototype.copy.call(t,n,r),o+=s.data.length,s=s.next;return i},t.consume=function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n},t.first=function(){return this.head.data},t._getString=function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,s=e>i.length?i.length:e;if(s===i.length?r+=i:r+=i.slice(0,e),0==(e-=s)){s===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(s));break}++n}return this.length-=n,r},t._getBuffer=function(e){var t=se.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,s=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,s),0==(e-=s)){s===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(s));break}++r}return this.length-=r,t},t[ae]=function(e,t){return oe(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ne(e,t,n[t])})}return e}({},t,{depth:0,customInspect:!1}))},e}(),ce={},ue=ce={};function de(){throw new Error("setTimeout has not been defined")}function le(){throw new Error("clearTimeout has not been defined")}function fe(e){if(re===setTimeout)return setTimeout(e,0);if((re===de||!re)&&setTimeout)return re=setTimeout,setTimeout(e,0);try{return re(e,0)}catch(t){try{return re.call(null,e,0)}catch(t){return re.call(this,e,0)}}}!function(){try{re="function"==typeof setTimeout?setTimeout:de}catch(e){re=de}try{ie="function"==typeof clearTimeout?clearTimeout:le}catch(e){ie=le}}();var pe,ge=[],me=!1,_e=-1;function ye(){me&&pe&&(me=!1,pe.length?ge=pe.concat(ge):_e=-1,ge.length&&be())}function be(){if(!me){var e=fe(ye);me=!0;for(var t=ge.length;t;){for(pe=ge,ge=[];++_e<t;)pe&&pe[_e].run();_e=-1,t=ge.length}pe=null,me=!1,function(e){if(ie===clearTimeout)return clearTimeout(e);if((ie===le||!ie)&&clearTimeout)return ie=clearTimeout,clearTimeout(e);try{ie(e)}catch(t){try{return ie.call(null,e)}catch(t){return ie.call(this,e)}}}(e)}}function we(e,t){this.fun=e,this.array=t}function ve(){}ue.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];ge.push(new we(e,t)),1!==ge.length||me||fe(be)},we.prototype.run=function(){this.fun.apply(null,this.array)},ue.title="browser",ue.browser=!0,ue.env={},ue.argv=[],ue.version="",ue.versions={},ue.on=ve,ue.addListener=ve,ue.once=ve,ue.off=ve,ue.removeListener=ve,ue.removeAllListeners=ve,ue.emit=ve,ue.prependListener=ve,ue.prependOnceListener=ve,ue.listeners=function(e){return[]},ue.binding=function(e){throw new Error("process.binding is not supported")},ue.cwd=function(){return"/"},ue.chdir=function(e){throw new Error("process.chdir is not supported")},ue.umask=function(){return 0};var Ee={};(function(e){"use strict";function t(e,t){r(e,t),n(e)}function n(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function r(e,t){e.emit("error",t)}Ee={destroy:function(i,s){var o=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(s?s(i):!i||this._writableState&&this._writableState.errorEmitted||e.nextTick(r,this,i),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(i||null,function(r){!s&&r?(e.nextTick(t,o,r),o._writableState&&(o._writableState.errorEmitted=!0)):s?(e.nextTick(n,o),s(r)):e.nextTick(n,o)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}}).call(this,ce);var ke={},Se={};function Ce(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,Se[e]=r}function xe(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}Ce("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),Ce("ERR_INVALID_ARG_TYPE",function(e,t,n){var r,i,s,o;if("string"==typeof t&&("not ","not "===t.substr(0,"not ".length))?(r="must not be",t=t.replace(/^not /,"")):r="must be",s=e,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))i="The ".concat(e," ").concat(r," ").concat(xe(t,"type"));else{var a=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+".".length>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";i='The "'.concat(e,'" ').concat(a," ").concat(r," ").concat(xe(t,"type"))}return i+". Received type ".concat(typeof n)},TypeError),Ce("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Ce("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),Ce("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Ce("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),Ce("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Ce("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Ce("ERR_STREAM_WRITE_AFTER_END","write after end"),Ce("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Ce("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),Ce("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),ke.codes=Se;var Te=ke.codes.ERR_INVALID_OPT_VALUE,Ie={getHighWaterMark:function(e,t,n,r){var i=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new Te(r?n:"highWaterMark",i);return Math.floor(i)}return e.objectMode?16:16384}},Ae={};(function(e){"use strict";var t=new Set;Ae.emitExperimentalWarning=e.emitWarning?function(n){if(!t.has(n)){var r=n+" is an experimental feature. This feature could change at any time";t.add(n),e.emitWarning(r,"ExperimentalWarning")}}:function(){}}).call(this,ce);var Re={};Re="function"==typeof Object.create?function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}};var Le={};(function(e){function t(t){try{if(!e.localStorage)return!1}catch(r){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}Le=function(e,n){if(t("noDeprecation"))return e;var r=!1;return function(){if(!r){if(t("throwDeprecation"))throw new Error(n);t("traceDeprecation")?console.trace(n):console.warn(n),r=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Be=De,Ue=ke.codes,Oe=Ue.ERR_METHOD_NOT_IMPLEMENTED,Me=Ue.ERR_MULTIPLE_CALLBACK,Pe=Ue.ERR_TRANSFORM_ALREADY_TRANSFORMING,Ne=Ue.ERR_TRANSFORM_WITH_LENGTH_0,je=h({});function He(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new Me);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function De(e){if(!(this instanceof De))return new De(e);je.call(this,e),this._transformState={afterTransform:He.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",qe)}function qe(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?Fe(this,null,null):this._flush(function(t,n){Fe(e,t,n)})}function Fe(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Ne;if(e._transformState.transforming)throw new Pe;return e.push(null)}Re(De,je),De.prototype.push=function(e,t){return this._transformState.needTransform=!1,je.prototype.push.call(this,e,t)},De.prototype._transform=function(e,t,n){n(new Oe("_transform()"))},De.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},De.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},De.prototype._destroy=function(e,t){je.prototype._destroy.call(this,e,function(e){t(e)})};var We,ze=$e;function $e(e){if(!(this instanceof $e))return new $e(e);Be.call(this,e)}Re($e,Be),$e.prototype._transform=function(e,t,n){n(null,e)};var Ve=ke.codes,Ge=Ve.ERR_MISSING_ARGS,Ke=Ve.ERR_STREAM_DESTROYED;function Ye(e){if(e)throw e}function Je(e){e()}function Xe(e,t){return e.pipe(t)}var Ze={};(Ze=Ze=i({})).Stream=Ze,Ze.Readable=Ze,Ze.Writable=c({}),Ze.Duplex=h({}),Ze.Transform=Be,Ze.PassThrough=ze,Ze.finished=o({}),Ze.pipeline=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=function(e){return e.length?"function"!=typeof e[e.length-1]?Ye:e.pop():Ye}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Ge("streams");var s=t.map(function(e,n){var a=n<t.length-1;return function(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",function(){i=!0}),void 0===We&&(We=o({})),We(e,{readable:t,writable:n},function(e){if(e)return r(e);i=!0,r()});var s=!1;return function(t){if(!i&&!s)return s=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new Ke("pipe"))}}(e,a,n>0,function(e){r||(r=e),e&&s.forEach(Je),a||(s.forEach(Je),i(r))})});return t.reduce(Xe)};var Qe={};(function(e){const{Transform:t}=Ze;Qe=class extends t{constructor(e,t={}){super(t),"object"==typeof e&&(e=(t=e).size),this.size=e||512;const{nopad:n,zeroPadding:r=!0}=t;this._zeroPadding=!n&&!!r,this._buffered=[],this._bufferedBytes=0}_transform(t,n,r){for(this._bufferedBytes+=t.length,this._buffered.push(t);this._bufferedBytes>=this.size;){const t=e.concat(this._buffered);this._bufferedBytes-=this.size,this.push(t.slice(0,this.size)),this._buffered=[t.slice(this.size,t.length)]}r()}_flush(){if(this._bufferedBytes&&this._zeroPadding){const t=e.alloc(this.size-this._bufferedBytes);this._buffered.push(t),this.push(e.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(e.concat(this._buffered)),this._buffered=null);this.push(null)}}}).call(this,u({}).Buffer);var et={};(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}et.normalize=function(e){var i=et.isAbsolute(e),s="/"===r(e,-1);return(e=t(n(e.split("/"),function(e){return!!e}),!i).join("/"))||i||(e="."),e&&s&&(e+="/"),(i?"/":"")+e},et.isAbsolute=function(e){return"/"===e.charAt(0)},et.join=function(){var e=Array.prototype.slice.call(arguments,0);return et.normalize(n(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},et.sep="/",et.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,i=!0,s=e.length-1;s>=1;--s)if(47===(t=e.charCodeAt(s))){if(!i){r=s;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},et.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,i=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!i){n=t+1;break}}else-1===r&&(i=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},et.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,i=!0,s=0,o=e.length-1;o>=0;--o){var a=e.charCodeAt(o);if(47!==a)-1===r&&(i=!1,r=o+1),46===a?-1===t?t=o:1!==s&&(s=1):-1!==t&&(s=-1);else if(!i){n=o+1;break}}return-1===t||-1===r||0===s||1===s&&t===r-1&&t===n+1?"":e.slice(t,r)};var r="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,ce);var tt;tt=it,it.strict=st,it.loose=ot;var nt=Object.prototype.toString,rt={"[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};function it(e){return st(e)||ot(e)}function st(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 ot(e){return rt[nt.call(e)]}var at={};(function(e){var t=tt.strict;at=function(n){if(t(n)){var r=e.from(n.buffer);return n.byteLength!==n.buffer.byteLength&&(r=r.slice(n.byteOffset,n.byteOffset+n.byteLength)),r}return e.from(n)}}).call(this,u({}).Buffer);const{Readable:ht}=Ze;var ct=class extends ht{constructor(e,t={}){super(t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800);const n=new FileReader;n.onload=(()=>{this.push(at(n.result))}),n.onerror=(()=>{this.emit("error",n.error)}),this.reader=n,this._generateHeaderBlocks(e,t,(e,t)=>{if(e)return this.emit("error",e);Array.isArray(t)&&t.forEach(e=>this.push(e)),this._ready=!0,this.emit("_ready")})}_generateHeaderBlocks(e,t,n){n(null,[])}_read(){if(!this._ready)return void this.once("_ready",this._read.bind(this));const e=this._offset;let t=this._offset+this._chunkSize;if(t>this._size&&(t=this._size),e===this._size)return this.destroy(),void this.push(null);this.reader.readAsArrayBuffer(this._file.slice(e,t)),this._offset=t}destroy(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},ut={},dt={};function lt(e){return ut.existsSync(e)&&ut.statSync(e).isFile()}(dt=function(e,t){if(!t)return lt(e);ut.stat(e,function(e,n){return e?t(e):t(null,n.isFile())})}).sync=lt;var ft={};ft.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),ft.is=(e=>ft.regex.test(e)),ft.not=(e=>!ft.is(e));var pt={};function gt(e){return _t(e,{objectMode:!0,highWaterMark:16})}function mt(e){return _t(e)}function _t(e,t){if(!e||"function"==typeof e||e._readableState)return e;var n=new Ze.Readable(t).wrap(e);return e.destroy&&(n.destroy=e.destroy.bind(e)),n}class yt extends Ze.Readable{constructor(e,t){super(t),this.destroyed=!1,this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=t&&t.objectMode?gt:mt,"function"==typeof e?this._queue=e:(this._queue=e.map(this._toStreams2),this._queue.forEach(e=>{"function"!=typeof e&&this._attachErrorListener(e)})),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(!this._forwarding&&this._drained&&this._current){var e;for(this._forwarding=!0;null!==(e=this._current.read())&&this._drained;)this._drained=this.push(e);this._forwarding=!1}}destroy(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(e=>{e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))}_next(){if(this._current=null,"function"==typeof this._queue)this._queue((e,t)=>{if(e)return this.destroy(e);t=this._toStreams2(t),this._attachErrorListener(t),this._gotNextStream(t)});else{var e=this._queue.shift();"function"==typeof e&&(e=this._toStreams2(e()),this._attachErrorListener(e)),this._gotNextStream(e)}}_gotNextStream(e){if(!e)return this.push(null),void this.destroy();this._current=e,this._forward();const t=()=>{this._forward()},n=()=>{e._readableState.ended||this.destroy()},r=()=>{this._current=null,e.removeListener("readable",t),e.removeListener("end",r),e.removeListener("close",n),this._next()};e.on("readable",t),e.once("end",r),e.once("close",n)}_attachErrorListener(e){if(!e)return;const t=n=>{e.removeListener("error",t),this.destroy(n)};e.once("error",t)}}yt.obj=(e=>new yt(e,{objectMode:!0,highWaterMark:16})),pt=yt;var bt=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(e){r[e]=t[e]}),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}},wt={};function vt(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Et(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}(wt=bt(vt)).strict=bt(Et),vt.proto=vt(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return vt(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Et(this)},configurable:!0})});var kt={};(function(e){kt=function(t,n){var r,i,s,o=!0;function a(t){function i(){n&&n(t,r),n=null}o?e.nextTick(i):i()}function h(e,t,n){r[e]=n,(0==--i||t)&&a(t)}Array.isArray(t)?(r=[],i=t.length):(s=Object.keys(t),r={},i=s.length),i?s?s.forEach(function(e){t[e](function(t,n){h(e,t,n)})}):t.forEach(function(e,t){e(function(e,n){h(t,e,n)})}):a(null),o=!1}}).call(this,ce);var St,Ct,xt={exports:{}};St="undefined"!=typeof self?self:this,Ct=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){var r=n(5),i=n(1),s=i.toHex,o=i.ceilHeapSize,a=n(6),h=function(e){for(e+=9;e%64>0;e+=1);return e},c=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),i=new DataView(r.buffer);return i.setInt32(0,n[0],!1),i.setInt32(4,n[1],!1),i.setInt32(8,n[2],!1),i.setInt32(12,n[3],!1),i.setInt32(16,n[4],!1),r},u=function(){function e(t){if(function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),(t=t||65536)%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=h(t),this._heap=new ArrayBuffer(o(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new r({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},e.prototype._padChunk=function(e,t){var n=h(e),r=new Int32Array(this._heap,0,n>>2);return function(e,t){var n=new Uint8Array(e.buffer),r=t%4,i=t-r;switch(r){case 0:n[i+3]=0;case 1:n[i+2]=0;case 2:n[i+1]=0;case 3:n[i+0]=0}for(var s=1+(t>>2);s<e.length;s++)e[s]=0}(r,e),function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=n/(1<<29)|0,e[15+(2+(t>>2)&-16)]=n<<3}(r,e,t),n},e.prototype._write=function(e,t,n,r){a(e,this._h8,this._h32,t,n,r||0)},e.prototype._coreCall=function(e,t,n,r,i){var s=n;this._write(e,t,n),i&&(s=this._padChunk(n,r)),this._core.hash(s,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,r=this._maxChunkLen;for(n=0;t>n+r;n+=r)this._coreCall(e,n,r,t,!1);return this._coreCall(e,n,t-n,t,!0),c(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return s(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,n=e.byteLength||e.length||e.size||0,r=this._offset%this._maxChunkLen,i=void 0;for(this._offset+=n;t<n;)i=Math.min(n-t,this._maxChunkLen-r),this._write(e,t,i,r),t+=i,(r+=i)===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),r=0);return this},e.prototype.getState=function(){var e=void 0;if(this._offset%this._maxChunkLen)e=this._heap.slice(0);else{var t=new Int32Array(this._heap,this._padMaxChunkLen+320,5);e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}return{offset:this._offset,heap:e}},e.prototype.setState=function(e){return this._offset=e.offset,20===e.heap.byteLength?new Int32Array(this._heap,this._padMaxChunkLen+320,5).set(new Int32Array(e.heap)):this._h32.set(new Int32Array(e.heap)),this},e.prototype.rawEnd=function(){var e=this._offset,t=e%this._maxChunkLen,n=this._padChunk(t,e);this._core.hash(n,this._padMaxChunkLen);var r=c(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),r},e.prototype.end=function(){return s(this.rawEnd().buffer)},e}();e.exports=u,e.exports._core=r},function(e,t){for(var n=new Array(256),r=0;r<256;r++)n[r]=(r<16?"0":"")+r.toString(16);e.exports.toHex=function(e){for(var t=new Uint8Array(e),r=new Array(e.byteLength),i=0;i<r.length;i++)r[i]=n[t[i]];return r.join("")},e.exports.ceilHeapSize=function(e){var t=0;if(e<=65536)return 65536;if(e<16777216)for(t=1;t<e;t<<=1);else for(t=16777216;t<e;t+=16777216);return t},e.exports.isDedicatedWorkerScope=function(e){var t="WorkerGlobalScope"in e&&e instanceof e.WorkerGlobalScope,n="SharedWorkerGlobalScope"in e&&e instanceof e.SharedWorkerGlobalScope,r="ServiceWorkerGlobalScope"in e&&e instanceof e.ServiceWorkerGlobalScope;return t&&!n&&!r}},function(e,t,n){e.exports=function(){var e=n(0),t=function(e,n,r,i,s){var o=new self.FileReader;o.onloadend=function(){if(o.error)return s(o.error);var a=o.result;n+=o.result.byteLength;try{e.append(a)}catch(h){return void s(h)}n<i.size?t(e,n,r,i,s):s(null,e.end())},o.readAsArrayBuffer(i.slice(n,n+r))},r=!0;return self.onmessage=function(n){if(r){var i=n.data.data,s=n.data.file,o=n.data.id;if(void 0!==o&&(s||i)){var a=n.data.blockSize||4194304,h=new e(a);h.resetState();var c=function(e,t){e?self.postMessage({id:o,error:e.name}):self.postMessage({id:o,hash:t})};i&&function(e,t,n){try{n(null,e.digest(t))}catch(r){return n(r)}}(h,i,c),s&&t(h,0,a,s,c)}}},function(){r=!1}}},function(e,t,n){var r=n(4),i=n(0),s=n(7),o=n(2),a=n(1).isDedicatedWorkerScope,h="undefined"!=typeof self&&a(self);i.disableWorkerBehaviour=h?o():function(){},i.createWorker=function(){var e=r(2),t=e.terminate;return e.terminate=function(){URL.revokeObjectURL(e.objectURL),t.call(e)},e},i.createHash=s,e.exports=i},function(e,t,n){function r(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n.oe=function(e){throw console.error(e),e};var r=n(n.s=ENTRY_MODULE);return r.default||r}var i="[\\.|\\-|\\+|\\w|/|@]+",s="\\((/\\*.*?\\*/)?s?.*?("+i+").*?\\)";function o(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(e,t,r){var a={};a[r]=[];var h=t.toString(),c=h.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!c)return a;for(var u,d=c[1],l=new RegExp("(\\\\n|\\W)"+o(d)+s,"g");u=l.exec(h);)"dll-reference"!==u[3]&&a[r].push(u[3]);for(l=new RegExp("\\("+o(d)+'\\("(dll-reference\\s('+i+'))"\\)\\)'+s,"g");u=l.exec(h);)e[u[2]]||(a[r].push(u[1]),e[u[2]]=n(u[1]).m),a[u[2]]=a[u[2]]||[],a[u[2]].push(u[4]);return a}function h(e){return Object.keys(e).reduce(function(t,n){return t||e[n].length>0},!1)}e.exports=function(e,t){t=t||{};var i={main:n.m},s=t.all?{main:Object.keys(i)}:function(e,t){for(var n={main:[t]},r={main:[]},i={main:{}};h(n);)for(var s=Object.keys(n),o=0;o<s.length;o++){var c=s[o],u=n[c].pop();if(i[c]=i[c]||{},!i[c][u]&&e[c][u]){i[c][u]=!0,r[c]=r[c]||[],r[c].push(u);for(var d=a(e,e[c][u],c),l=Object.keys(d),f=0;f<l.length;f++)n[l[f]]=n[l[f]]||[],n[l[f]]=n[l[f]].concat(d[l[f]])}}return r}(i,e),o="";Object.keys(s).filter(function(e){return"main"!==e}).forEach(function(e){for(var t=0;s[e][t];)t++;s[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",o=o+"var "+e+" = ("+r.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s[e].map(function(t){return JSON.stringify(t)+": "+i[e][t].toString()}).join(",")+"});\n"}),o=o+"("+r.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+s.main.map(function(e){return JSON.stringify(e)+": "+i.main[e].toString()}).join(",")+"})(self);";var c=new window.Blob([o],{type:"text/javascript"});if(t.bare)return c;var u=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(c),d=new window.Worker(u);return d.objectURL=u,d}},function(e,t){e.exports=function(e,t,n){"use asm";var r=new e.Int32Array(n);function i(e,t){e=e|0;t=t|0;var n=0,i=0,s=0,o=0,a=0,h=0,c=0,u=0,d=0,l=0,f=0,p=0,g=0,m=0;s=r[t+320>>2]|0;a=r[t+324>>2]|0;c=r[t+328>>2]|0;d=r[t+332>>2]|0;f=r[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){o=s;h=a;u=c;l=d;p=f;for(i=0;(i|0)<64;i=i+4|0){m=r[n+i>>2]|0;g=((s<<5|s>>>27)+(a&c|~a&d)|0)+((m+f|0)+1518500249|0)|0;f=d;d=c;c=a<<30|a>>>2;a=s;s=g;r[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;g=((s<<5|s>>>27)+(a&c|~a&d)|0)+((m+f|0)+1518500249|0)|0;f=d;d=c;c=a<<30|a>>>2;a=s;s=g;r[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;g=((s<<5|s>>>27)+(a^c^d)|0)+((m+f|0)+1859775393|0)|0;f=d;d=c;c=a<<30|a>>>2;a=s;s=g;r[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;g=((s<<5|s>>>27)+(a&c|a&d|c&d)|0)+((m+f|0)-1894007588|0)|0;f=d;d=c;c=a<<30|a>>>2;a=s;s=g;r[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;g=((s<<5|s>>>27)+(a^c^d)|0)+((m+f|0)-899497514|0)|0;f=d;d=c;c=a<<30|a>>>2;a=s;s=g;r[i>>2]=m}s=s+o|0;a=a+h|0;c=c+u|0;d=d+l|0;f=f+p|0}r[t+320>>2]=s;r[t+324>>2]=a;r[t+328>>2]=c;r[t+332>>2]=d;r[t+336>>2]=f}return{hash:i}}},function(e,t){var n=this,r=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(r=new self.FileReaderSync);var i=function(e,t,n,r,i,s){var o=void 0,a=s%4,h=(i+a)%4,c=i-h;switch(a){case 0:t[s]=e[r+3];case 1:t[s+1-(a<<1)|0]=e[r+2];case 2:t[s+2-(a<<1)|0]=e[r+1];case 3:t[s+3-(a<<1)|0]=e[r]}if(!(i<h+(4-a))){for(o=4-a;o<c;o=o+4|0)n[s+o>>2|0]=e[r+o]<<24|e[r+o+1]<<16|e[r+o+2]<<8|e[r+o+3];switch(h){case 3:t[s+c+1|0]=e[r+c+2];case 2:t[s+c+2|0]=e[r+c+1];case 1:t[s+c+3|0]=e[r+c]}}};e.exports=function(e,t,s,o,a,h){if("string"==typeof e)return function(e,t,n,r,i,s){var o=void 0,a=s%4,h=(i+a)%4,c=i-h;switch(a){case 0:t[s]=e.charCodeAt(r+3);case 1:t[s+1-(a<<1)|0]=e.charCodeAt(r+2);case 2:t[s+2-(a<<1)|0]=e.charCodeAt(r+1);case 3:t[s+3-(a<<1)|0]=e.charCodeAt(r)}if(!(i<h+(4-a))){for(o=4-a;o<c;o=o+4|0)n[s+o>>2]=e.charCodeAt(r+o)<<24|e.charCodeAt(r+o+1)<<16|e.charCodeAt(r+o+2)<<8|e.charCodeAt(r+o+3);switch(h){case 3:t[s+c+1|0]=e.charCodeAt(r+c+2);case 2:t[s+c+2|0]=e.charCodeAt(r+c+1);case 1:t[s+c+3|0]=e.charCodeAt(r+c)}}}(e,t,s,o,a,h);if(e instanceof Array)return i(e,t,s,o,a,h);if(n&&n.Buffer&&n.Buffer.isBuffer(e))return i(e,t,s,o,a,h);if(e instanceof ArrayBuffer)return i(new Uint8Array(e),t,s,o,a,h);if(e.buffer instanceof ArrayBuffer)return i(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,s,o,a,h);if(e instanceof Blob)return function(e,t,n,i,s,o){var a=void 0,h=o%4,c=(s+h)%4,u=s-c,d=new Uint8Array(r.readAsArrayBuffer(e.slice(i,i+s)));switch(h){case 0:t[o]=d[3];case 1:t[o+1-(h<<1)|0]=d[2];case 2:t[o+2-(h<<1)|0]=d[1];case 3:t[o+3-(h<<1)|0]=d[0]}if(!(s<c+(4-h))){for(a=4-h;a<u;a=a+4|0)n[o+a>>2|0]=d[a]<<24|d[a+1]<<16|d[a+2]<<8|d[a+3];switch(c){case 3:t[o+u+1|0]=d[u+2];case 2:t[o+u+2|0]=d[u+1];case 1:t[o+u+3|0]=d[u]}}}(e,t,s,o,a,h);throw new Error("Unsupported data type.")}},function(e,t,n){var r=n(0),i=n(1).toHex,s=function(){function e(){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this._rusha=new r,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function(e){var t=this._rusha.rawEnd().buffer;if(!e)return t;if("hex"===e)return i(t);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new s}}])},"object"==typeof xt.exports?xt.exports=Ct():"object"==typeof xt.exports?xt.exports.Rusha=Ct():St.Rusha=Ct(),xt=xt.exports;var Tt,It=xt.createWorker(),At=1,Rt={};It.onmessage=function(e){var t=e.data.id,n=Rt[t];delete Rt[t],null!=e.data.error?n(new Error("Rusha worker error: "+e.data.error)):n(null,e.data.hash)},Tt=function(e,t){Rt[At]=t,It.postMessage({id:At,data:e}),At+=1};var Lt={},Bt=new xt,Ut="undefined"!=typeof window?window:self,Ot=Ut.crypto||Ut.msCrypto||{},Mt=Ot.subtle||Ot.webkitSubtle;function Pt(e){return Bt.digest(e)}try{Mt.digest({name:"sha-1"},new Uint8Array).catch(function(){Mt=!1})}catch(fi){Mt=!1}(Lt=function(e,t){Mt?("string"==typeof e&&(e=function(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n}(e)),Mt.digest({name:"sha-1"},e).then(function(e){t(function(e){for(var t=e.length,n=[],r=0;r<t;r++){var i=e[r];n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")}(new Uint8Array(e)))},function(){t(Pt(e))})):Tt(e,function(n,r){t(n?Pt(e):r)})}).sync=Pt;var Nt={};(function(e,t,n){function r(e){return e.reduce((e,t)=>Array.isArray(t)?e.concat(r(t)):e.concat(t),[])}function i(t,i,a){if("undefined"!=typeof FileList&&t instanceof FileList&&(t=Array.from(t)),Array.isArray(t)||(t=[t]),0===t.length)throw new Error("invalid input type");t.forEach(e=>{if(null==e)throw new Error(`invalid input type: ${e}`)}),1!==(t=t.map(e=>h(e)&&"string"==typeof e.path&&"function"==typeof ut.stat?e.path:e)).length||"string"==typeof t[0]||t[0].name||(t[0].name=i.name);let u=null;t.forEach((e,n)=>{if("string"==typeof e)return;let r=e.fullPath||e.name;r||(r=`Unknown File ${n+1}`,e.unknownName=!0),e.path=r.split("/"),e.path[0]||e.path.shift(),e.path.length<2?u=null:0===n&&t.length>1?u=e.path[0]:e.path[0]!==u&&(u=null)}),t=t.filter(e=>{if("string"==typeof e)return!0;const t=e.path[e.path.length-1];return o(t)&&ft.not(t)}),u&&t.forEach(e=>{const t=(n.isBuffer(e)||c(e))&&!e.path;"string"==typeof e||t||e.path.shift()}),!i.name&&u&&(i.name=u),i.name||t.some(e=>"string"==typeof e?(i.name=et.basename(e),!0):e.unknownName?void 0:(i.name=e.path[e.path.length-1],!0)),i.name||(i.name=`Unnamed Torrent ${Date.now()}`);const d=t.reduce((e,t)=>e+Number("string"==typeof t),0);let l=1===t.length;if(1===t.length&&"string"==typeof t[0]){if("function"!=typeof ut.stat)throw new Error("filesystem paths do not work in the browser");dt(t[0],(e,t)=>{if(e)return a(e);l=t,f()})}else e.nextTick(()=>{f()});function f(){kt(t.map(e=>t=>{const i={};if(h(e))i.getStream=function(e){return()=>new ct(e)}(e),i.length=e.size;else if(n.isBuffer(e))i.getStream=function(e){return()=>{const t=new Ze.PassThrough;return t.end(e),t}}(e),i.length=e.length;else{if(!c(e)){if("string"==typeof e){if("function"!=typeof ut.stat)throw new Error("filesystem paths do not work in the browser");return void function(e,t,n){!function e(t,n,r){ut.stat(t,(i,s)=>{if(i)return r(i);s.isDirectory()?ut.readdir(t,(i,s)=>{if(i)return r(i);kt(s.filter(o).filter(ft.not).map(r=>i=>{e(et.join(t,r),n,i)}),r)}):s.isFile()&&n(t,r)})}(e,s,(i,s)=>{if(i)return n(i);s=Array.isArray(s)?r(s):[s],e=et.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(et.sep)+1)),e[e.length-1]!==et.sep&&(e+=et.sep),s.forEach(t=>{t.getStream=function(e){return()=>ut.createReadStream(e)}(t.path),t.path=t.path.replace(e,"").split(et.sep)}),n(null,s)})}(e,d>1||l,t)}throw new Error("invalid input type")}i.getStream=function(e,t){return()=>{const n=new Ze.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}(e,i),i.length=0}i.path=e.path,t(null,i)}),(e,t)=>{if(e)return a(e);t=r(t),a(null,t,l)})}}function s(e,t){t=wt(t),ut.stat(e,(n,r)=>{if(n)return t(n);const i={length:r.size,path:e};t(null,i)})}function o(e){return"."!==e[0]}function a(e,t){return e+t.length}function h(e){return"undefined"!=typeof Blob&&e instanceof Blob}function c(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(Nt=function(e,r,s){"function"==typeof r&&([r,s]=[s,r]),i(e,r=r?Object.assign({},r):{},(e,i,o)=>{if(e)return s(e);r.singleFileTorrent=o,function(e,r,i){let s=r.announceList;s||("string"==typeof r.announce?s=[[r.announce]]:Array.isArray(r.announce)&&(s=r.announce.map(e=>[e]))),s||(s=[]),t.WEBTORRENT_ANNOUNCE&&("string"==typeof t.WEBTORRENT_ANNOUNCE?s.push([[t.WEBTORRENT_ANNOUNCE]]):Array.isArray(t.WEBTORRENT_ANNOUNCE)&&(s=s.concat(t.WEBTORRENT_ANNOUNCE.map(e=>[e])))),void 0===r.announce&&void 0===r.announceList&&(s=s.concat(Nt.announceList)),"string"==typeof r.urlList&&(r.urlList=[r.urlList]);const o={info:{name:r.name},"creation date":Math.ceil((Number(r.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==s.length&&(o.announce=s[0][0],o["announce-list"]=s),void 0!==r.comment&&(o.comment=r.comment),void 0!==r.createdBy&&(o["created by"]=r.createdBy),void 0!==r.private&&(o.info.private=Number(r.private)),void 0!==r.info&&Object.assign(o.info,r.info),void 0!==r.sslCert&&(o.info["ssl-cert"]=r.sslCert),void 0!==r.urlList&&(o["url-list"]=r.urlList);const h=r.pieceLength||(c=e.reduce(a,0),Math.max(16384,1<<Math.log2(c<1024?1:c/1024)+.5|0));var c;o.info["piece length"]=h,function(e,t,r){r=wt(r);const i=[];let s=0;const o=e.map(e=>e.getStream);let a=0,h=0,c=!1;const u=new pt(o),d=new Qe(t,{zeroPadding:!1});function l(e){s+=e.length;const t=h;Lt(e,e=>{i[t]=e,a-=1,m()}),a+=1,h+=1}function f(){c=!0,m()}function p(e){g(),r(e)}function g(){u.removeListener("error",p),d.removeListener("data",l),d.removeListener("end",f),d.removeListener("error",p)}function m(){c&&0===a&&(g(),r(null,n.from(i.join(""),"hex"),s))}u.on("error",p),u.pipe(d).on("data",l).on("end",f).on("error",p)}(e,h,(t,n,s)=>{if(t)return i(t);o.info.pieces=n,e.forEach(e=>{delete e.getStream}),r.singleFileTorrent?o.info.length=s:o.info.files=e,i(null,Z.encode(o))})}(i,r,s)})}).parseInput=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),i(e,t=t?Object.assign({},t):{},n)},Nt.announceList=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]]}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u({}).Buffer);var jt={};(function(e){jt.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},jt.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+jt.humanize(this.diff),!this.useColors)return;const t="color: "+this.color;e.splice(1,0,t,"color: inherit");let n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(r=n))}),e.splice(r,0,t)},jt.save=function(e){try{e?jt.storage.setItem("debug",e):jt.storage.removeItem("debug")}catch(t){}},jt.load=function(){let t;try{t=jt.storage.getItem("debug")}catch(n){}return!t&&void 0!==e&&"env"in e&&(t=e.env.DEBUG),t},jt.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},jt.storage=function(){try{return localStorage}catch(e){}}(),jt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],jt=function(e){function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){let r;function o(...e){if(!o.enabled)return;const t=o,i=Number(new Date),s=i-(r||i);t.diff=s,t.prev=r,t.curr=i,r=i,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return r;a++;const s=n.formatters[i];if("function"==typeof s){const n=e[a];r=s.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return o.namespace=e,o.enabled=n.enabled(e),o.useColors=n.useColors(),o.color=t(e),o.destroy=i,o.extend=s,"function"==typeof n.init&&n.init(o),n.instances.push(o),o}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function s(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(o),...n.skips.map(o).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t<i;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){const e=n.instances[t];e.enabled=n.enabled(e.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=r({}),Object.keys(e).forEach(t=>{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}(jt);const{formatters:t}=jt;t.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this,ce);var Ht={};(function(e){Ht=function(t,n){if("undefined"==typeof Blob||!(t instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof n)throw new Error("second argument must be a function");var r=new FileReader;r.addEventListener("loadend",function t(i){r.removeEventListener("loadend",t,!1),i.error?n(i.error):n(null,e.from(r.result))},!1),r.readAsArrayBuffer(t)}}).call(this,u({}).Buffer);var Dt={};(function(e){var t;function n(){if(void 0!==t)return t;if(e.XMLHttpRequest){t=new e.XMLHttpRequest;try{t.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(n){t=null}}else t=null;return t}function r(e){var t=n();if(!t)return!1;try{return t.responseType=e,t.responseType===e}catch(r){}return!1}function i(e){return"function"==typeof e}Dt.fetch=i(e.fetch)&&i(e.ReadableStream),Dt.writableStream=i(e.WritableStream),Dt.abortController=i(e.AbortController),Dt.arraybuffer=Dt.fetch||r("arraybuffer"),Dt.msstream=!Dt.fetch&&r("ms-stream"),Dt.mozchunkedarraybuffer=!Dt.fetch&&r("moz-chunked-arraybuffer"),Dt.overrideMimeType=Dt.fetch||!!n()&&i(n().overrideMimeType),t=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var qt={};(function(e,t,n){var r=qt.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},i=qt.IncomingMessage=function(r,i,s,o){var a=this;if(Ze.Readable.call(a),a._mode=s,a.headers={},a.rawHeaders=[],a.trailers={},a.rawTrailers=[],a.on("end",function(){e.nextTick(function(){a.emit("close")})}),"fetch"===s){if(a._fetchResponse=i,a.url=i.url,a.statusCode=i.status,a.statusMessage=i.statusText,i.headers.forEach(function(e,t){a.headers[t.toLowerCase()]=e,a.rawHeaders.push(t,e)}),Dt.writableStream){var h=new WritableStream({write:function(e){return new Promise(function(t,r){a._destroyed?r():a.push(n.from(e))?t():a._resumeFetch=t})},close:function(){t.clearTimeout(o),a._destroyed||a.push(null)},abort:function(e){a._destroyed||a.emit("error",e)}});try{return void i.body.pipeTo(h).catch(function(e){t.clearTimeout(o),a._destroyed||a.emit("error",e)})}catch(l){}}var c=i.body.getReader();!function e(){c.read().then(function(r){if(!a._destroyed){if(r.done)return t.clearTimeout(o),void a.push(null);a.push(n.from(r.value)),e()}}).catch(function(e){t.clearTimeout(o),a._destroyed||a.emit("error",e)})}()}else if(a._xhr=r,a._pos=0,a.url=r.responseURL,a.statusCode=r.status,a.statusMessage=r.statusText,r.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===a.headers[n]&&(a.headers[n]=[]),a.headers[n].push(t[2])):void 0!==a.headers[n]?a.headers[n]+=", "+t[2]:a.headers[n]=t[2],a.rawHeaders.push(t[1],t[2])}}),a._charset="x-user-defined",!Dt.overrideMimeType){var u=a.rawHeaders["mime-type"];if(u){var d=u.match(/;\s*charset=([^;])(;|$)/);d&&(a._charset=d[1].toLowerCase())}a._charset||(a._charset="utf-8")}};Re(i,Ze.Readable),i.prototype._read=function(){var e=this._resumeFetch;e&&(this._resumeFetch=null,e())},i.prototype._onXHRProgress=function(){var e=this,i=e._xhr,s=null;switch(e._mode){case"text":if((s=i.responseText).length>e._pos){var o=s.substr(e._pos);if("x-user-defined"===e._charset){for(var a=n.alloc(o.length),h=0;h<o.length;h++)a[h]=255&o.charCodeAt(h);e.push(a)}else e.push(o,e._charset);e._pos=s.length}break;case"arraybuffer":if(i.readyState!==r.DONE||!i.response)break;s=i.response,e.push(n.from(new Uint8Array(s)));break;case"moz-chunked-arraybuffer":if(s=i.response,i.readyState!==r.LOADING||!s)break;e.push(n.from(new Uint8Array(s)));break;case"ms-stream":if(s=i.response,i.readyState!==r.LOADING)break;var c=new t.MSStreamReader;c.onprogress=function(){c.result.byteLength>e._pos&&(e.push(n.from(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(s)}e._xhr.readyState===r.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u({}).Buffer);var Ft={};(function(e,t,n){var r=qt.IncomingMessage,i=qt.readyStates,s=Ft=function(e){var t,r=this;Ze.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+n.from(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){r.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!Dt.abortController)i=!1,t=!0;else if("prefer-streaming"===e.mode)t=!1;else if("allow-wrong-content-type"===e.mode)t=!Dt.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");t=!0}r._mode=function(e,t){return Dt.fetch&&t?"fetch":Dt.mozchunkedarraybuffer?"moz-chunked-arraybuffer":Dt.msstream?"ms-stream":Dt.arraybuffer&&e?"arraybuffer":"text"}(t,i),r._fetchTimer=null,r.on("finish",function(){r._onFinish()})};Re(s,Ze.Writable),s.prototype.setHeader=function(e,t){var n=e.toLowerCase();-1===o.indexOf(n)&&(this._headers[n]={name:e,value:t})},s.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},s.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},s.prototype._onFinish=function(){var n=this;if(!n._destroyed){var r=n._opts,s=n._headers,o=null;"GET"!==r.method&&"HEAD"!==r.method&&(o=new Blob(n._body,{type:(s["content-type"]||{}).value||""}));var a=[];if(Object.keys(s).forEach(function(e){var t=s[e].name,n=s[e].value;Array.isArray(n)?n.forEach(function(e){a.push([t,e])}):a.push([t,n])}),"fetch"===n._mode){var h=null;if(Dt.abortController){var c=new AbortController;h=c.signal,n._fetchAbortController=c,"requestTimeout"in r&&0!==r.requestTimeout&&(n._fetchTimer=t.setTimeout(function(){n.emit("requestTimeout"),n._fetchAbortController&&n._fetchAbortController.abort()},r.requestTimeout))}t.fetch(n._opts.url,{method:n._opts.method,headers:a,body:o||void 0,mode:"cors",credentials:r.withCredentials?"include":"same-origin",signal:h}).then(function(e){n._fetchResponse=e,n._connect()},function(e){t.clearTimeout(n._fetchTimer),n._destroyed||n.emit("error",e)})}else{var u=n._xhr=new t.XMLHttpRequest;try{u.open(n._opts.method,n._opts.url,!0)}catch(fi){return void e.nextTick(function(){n.emit("error",fi)})}"responseType"in u&&(u.responseType=n._mode),"withCredentials"in u&&(u.withCredentials=!!r.withCredentials),"text"===n._mode&&"overrideMimeType"in u&&u.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in r&&(u.timeout=r.requestTimeout,u.ontimeout=function(){n.emit("requestTimeout")}),a.forEach(function(e){u.setRequestHeader(e[0],e[1])}),n._response=null,u.onreadystatechange=function(){switch(u.readyState){case i.LOADING:case i.DONE:n._onXHRProgress()}},"moz-chunked-arraybuffer"===n._mode&&(u.onprogress=function(){n._onXHRProgress()}),u.onerror=function(){n._destroyed||n.emit("error",new Error("XHR error"))};try{u.send(o)}catch(fi){return void e.nextTick(function(){n.emit("error",fi)})}}}},s.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(n){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},s.prototype._connect=function(){var e=this;e._destroyed||(e._response=new r(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},s.prototype._write=function(e,t,n){this._body.push(e),n()},s.prototype.abort=s.prototype.destroy=function(){this._destroyed=!0,t.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},s.prototype.end=function(e,t,n){"function"==typeof e&&(n=e,e=void 0),Ze.Writable.prototype.end.call(this,e,t,n)},s.prototype.flushHeaders=function(){},s.prototype.setTimeout=function(){},s.prototype.setNoDelay=function(){},s.prototype.setSocketKeepAlive=function(){};var o=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u({}).Buffer);var Wt=Object.prototype.hasOwnProperty,zt={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},$t={exports:{}};(function(e){!function(t){var n="object"==typeof $t.exports&&$t.exports&&!$t.exports.nodeType&&$t.exports,r=$t&&!$t.nodeType&&$t,i="object"==typeof e&&e;i.global!==i&&i.window!==i&&i.self!==i||(t=i);var s,o,a=2147483647,h=36,c=1,u=26,d=38,l=700,f=72,p=128,g="-",m=/^xn--/,_=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=h-c,v=Math.floor,E=String.fromCharCode;function k(e){throw new RangeError(b[e])}function S(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function C(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+S((e=e.replace(y,".")).split("."),t).join(".")}function x(e){for(var t,n,r=[],i=0,s=e.length;i<s;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<s?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function T(e){return S(e,function(e){var t="";return e>65535&&(t+=E((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+E(e)}).join("")}function I(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function A(e,t,n){var r=0;for(e=n?v(e/l):e>>1,e+=v(e/t);e>w*u>>1;r+=h)e=v(e/w);return v(r+(w+1)*e/(e+d))}function R(e){var t,n,r,i,s,o,d,l,m,_,y,b=[],w=e.length,E=0,S=p,C=f;for((n=e.lastIndexOf(g))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&k("not-basic"),b.push(e.charCodeAt(r));for(i=n>0?n+1:0;i<w;){for(s=E,o=1,d=h;i>=w&&k("invalid-input"),((l=(y=e.charCodeAt(i++))-48<10?y-22:y-65<26?y-65:y-97<26?y-97:h)>=h||l>v((a-E)/o))&&k("overflow"),E+=l*o,!(l<(m=d<=C?c:d>=C+u?u:d-C));d+=h)o>v(a/(_=h-m))&&k("overflow"),o*=_;C=A(E-s,t=b.length+1,0==s),v(E/t)>a-S&&k("overflow"),S+=v(E/t),E%=t,b.splice(E++,0,S)}return T(b)}function L(e){var t,n,r,i,s,o,d,l,m,_,y,b,w,S,C,T=[];for(b=(e=x(e)).length,t=p,n=0,s=f,o=0;o<b;++o)(y=e[o])<128&&T.push(E(y));for(r=i=T.length,i&&T.push(g);r<b;){for(d=a,o=0;o<b;++o)(y=e[o])>=t&&y<d&&(d=y);for(d-t>v((a-n)/(w=r+1))&&k("overflow"),n+=(d-t)*w,t=d,o=0;o<b;++o)if((y=e[o])<t&&++n>a&&k("overflow"),y==t){for(l=n,m=h;!(l<(_=m<=s?c:m>=s+u?u:m-s));m+=h)C=l-_,S=h-_,T.push(E(I(_+C%S,0))),l=v(C/S);T.push(E(I(l,0))),s=A(n,w,r==i),n=0,++r}++n,++t}return T.join("")}if(s={version:"1.4.1",ucs2:{decode:x,encode:T},decode:R,encode:L,toASCII:function(e){return C(e,function(e){return _.test(e)?"xn--"+L(e):e})},toUnicode:function(e){return C(e,function(e){return m.test(e)?R(e.slice(4).toLowerCase()):e})}},n&&r)if($t.exports==n)r.exports=s;else for(o in s)s.hasOwnProperty(o)&&(n[o]=s[o]);else t.punycode=s}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),$t=$t.exports;var Vt={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}};function Gt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Kt=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Yt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Jt=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function Xt(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var Zt=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},Qt={parse:function(e,t,n,r){t=t||"&",n=n||"=";var i={};if("string"!=typeof e||0===e.length)return i;var s=/\+/g;e=e.split(t);var o=1e3;r&&"number"==typeof r.maxKeys&&(o=r.maxKeys);var a=e.length;o>0&&a>o&&(a=o);for(var h=0;h<a;++h){var c,u,d,l,f=e[h].replace(s,"%20"),p=f.indexOf(n);p>=0?(c=f.substr(0,p),u=f.substr(p+1)):(c=f,u=""),d=decodeURIComponent(c),l=decodeURIComponent(u),Gt(i,d)?Kt(i[d])?i[d].push(l):i[d]=[i[d],l]:i[d]=l}return i},stringify:function(e,t,n,r){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Xt(Zt(e),function(r){var i=encodeURIComponent(Yt(r))+n;return Jt(e[r])?Xt(e[r],function(e){return i+encodeURIComponent(Yt(e))}).join(t):i+encodeURIComponent(Yt(e[r]))}).join(t):r?encodeURIComponent(Yt(r))+n+encodeURIComponent(Yt(e)):""}},en={};function tn(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}en.parse=gn;var nn=/^([a-z0-9.+-]+:)/i,rn=/:[0-9]*$/,sn=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,on=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),an=["'"].concat(on),hn=["%","/","?",";","#"].concat(an),cn=["/","?","#"],un=/^[+a-z0-9A-Z_-]{0,63}$/,dn=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,ln={javascript:!0,"javascript:":!0},fn={javascript:!0,"javascript:":!0},pn={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function gn(e,t,n){if(e&&Vt.isObject(e)&&e instanceof tn)return e;var r=new tn;return r.parse(e,t,n),r}tn.prototype.parse=function(e,t,n){if(!Vt.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),i=-1!==r&&r<e.indexOf("#")?"?":"#",s=e.split(i);s[0]=s[0].replace(/\\/g,"/");var o=e=s.join(i);if(o=o.trim(),!n&&1===e.split("#").length){var a=sn.exec(o);if(a)return this.path=o,this.href=o,this.pathname=a[1],a[2]?(this.search=a[2],this.query=t?Qt.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=nn.exec(o);if(h){var c=(h=h[0]).toLowerCase();this.protocol=c,o=o.substr(h.length)}if(n||h||o.match(/^\/\/[^@\/]+@[^@\/]+/)){var u="//"===o.substr(0,2);!u||h&&fn[h]||(o=o.substr(2),this.slashes=!0)}if(!fn[h]&&(u||h&&!pn[h])){for(var d,l,f=-1,p=0;p<cn.length;p++)-1!==(g=o.indexOf(cn[p]))&&(-1===f||g<f)&&(f=g);for(-1!==(l=-1===f?o.lastIndexOf("@"):o.lastIndexOf("@",f))&&(d=o.slice(0,l),o=o.slice(l+1),this.auth=decodeURIComponent(d)),f=-1,p=0;p<hn.length;p++){var g;-1!==(g=o.indexOf(hn[p]))&&(-1===f||g<f)&&(f=g)}-1===f&&(f=o.length),this.host=o.slice(0,f),o=o.slice(f),this.parseHost(),this.hostname=this.hostname||"";var m="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!m)for(var _=this.hostname.split(/\./),y=(p=0,_.length);p<y;p++){var b=_[p];if(b&&!b.match(un)){for(var w="",v=0,E=b.length;v<E;v++)b.charCodeAt(v)>127?w+="x":w+=b[v];if(!w.match(un)){var k=_.slice(0,p),S=_.slice(p+1),C=b.match(dn);C&&(k.push(C[1]),S.unshift(C[2])),S.length&&(o="/"+S.join(".")+o),this.hostname=k.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),m||(this.hostname=$t.toASCII(this.hostname));var x=this.port?":"+this.port:"",T=this.hostname||"";this.host=T+x,this.href+=this.host,m&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!ln[c])for(p=0,y=an.length;p<y;p++){var I=an[p];if(-1!==o.indexOf(I)){var A=encodeURIComponent(I);A===I&&(A=escape(I)),o=o.split(I).join(A)}}var R=o.indexOf("#");-1!==R&&(this.hash=o.substr(R),o=o.slice(0,R));var L=o.indexOf("?");if(-1!==L?(this.search=o.substr(L),this.query=o.substr(L+1),t&&(this.query=Qt.parse(this.query)),o=o.slice(0,L)):t&&(this.search="",this.query={}),o&&(this.pathname=o),pn[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){x=this.pathname||"";var B=this.search||"";this.path=x+B}return this.href=this.format(),this},tn.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&Vt.isObject(this.query)&&Object.keys(this.query).length&&(s=Qt.stringify(this.query));var o=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||pn[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),o&&"?"!==o.charAt(0)&&(o="?"+o),t+i+(n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}))+(o=o.replace("#","%23"))+r},tn.prototype.resolve=function(e){return this.resolveObject(gn(e,!1,!0)).format()},tn.prototype.resolveObject=function(e){if(Vt.isString(e)){var t=new tn;t.parse(e,!1,!0),e=t}for(var n=new tn,r=Object.keys(this),i=0;i<r.length;i++){var s=r[i];n[s]=this[s]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var o=Object.keys(e),a=0;a<o.length;a++){var h=o[a];"protocol"!==h&&(n[h]=e[h])}return pn[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!pn[e.protocol]){for(var c=Object.keys(e),u=0;u<c.length;u++){var d=c[u];n[d]=e[d]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||fn[e.protocol])n.pathname=e.pathname;else{for(var l=(e.pathname||"").split("/");l.length&&!(e.host=l.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==l[0]&&l.unshift(""),l.length<2&&l.unshift(""),n.pathname=l.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var f=n.pathname||"",p=n.search||"";n.path=f+p}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var g=n.pathname&&"/"===n.pathname.charAt(0),m=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=m||g||n.host&&e.pathname,y=_,b=n.pathname&&n.pathname.split("/")||[],w=(l=e.pathname&&e.pathname.split("/")||[],n.protocol&&!pn[n.protocol]);if(w&&(n.hostname="",n.port=null,n.host&&(""===b[0]?b[0]=n.host:b.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===l[0]?l[0]=e.host:l.unshift(e.host)),e.host=null),_=_&&(""===l[0]||""===b[0])),m)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,b=l;else if(l.length)b||(b=[]),b.pop(),b=b.concat(l),n.search=e.search,n.query=e.query;else if(!Vt.isNullOrUndefined(e.search))return w&&(n.hostname=n.host=b.shift(),(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift())),n.search=e.search,n.query=e.query,Vt.isNull(n.pathname)&&Vt.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!b.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var v=b.slice(-1)[0],E=(n.host||e.host||b.length>1)&&("."===v||".."===v)||""===v,k=0,S=b.length;S>=0;S--)"."===(v=b[S])?b.splice(S,1):".."===v?(b.splice(S,1),k++):k&&(b.splice(S,1),k--);if(!_&&!y)for(;k--;k)b.unshift("..");!_||""===b[0]||b[0]&&"/"===b[0].charAt(0)||b.unshift(""),E&&"/"!==b.join("/").substr(-1)&&b.push("");var C,x=""===b[0]||b[0]&&"/"===b[0].charAt(0);return w&&(n.hostname=n.host=x?"":b.length?b.shift():"",(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift())),(_=_||n.host&&b.length)&&!x&&b.unshift(""),b.length?n.pathname=b.join("/"):(n.pathname=null,n.path=null),Vt.isNull(n.pathname)&&Vt.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},tn.prototype.parseHost=function(){var e=this.host,t=rn.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var mn={};(function(e){var t=mn;t.request=function(t,n){t="string"==typeof t?en.parse(t):function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)Wt.call(n,r)&&(e[r]=n[r])}return e}(t);var r=-1===e.location.protocol.search(/^https?:$/)?"http:":"",i=t.protocol||r,s=t.hostname||t.host,o=t.port,a=t.path||"/";s&&-1!==s.indexOf(":")&&(s="["+s+"]"),t.url=(s?i+"//"+s:"")+(o?":"+o:"")+a,t.method=(t.method||"GET").toUpperCase(),t.headers=t.headers||{};var h=new Ft(t);return n&&h.on("response",n),h},t.get=function(e,n){var r=t.request(e,n);return r.end(),r},t.ClientRequest=Ft,t.IncomingMessage=qt.IncomingMessage,t.Agent=function(){},t.Agent.defaultMaxSockets=4,t.globalAgent=new t.Agent,t.STATUS_CODES=zt,t.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var _n={},yn=_n;for(var bn in mn)mn.hasOwnProperty(bn)&&(yn[bn]=mn[bn]);function wn(e){if("string"==typeof e&&(e=en.parse(e)),e.protocol||(e.protocol="https:"),"https:"!==e.protocol)throw new Error('Protocol "'+e.protocol+'" not supported. Expected "https:"');return e}yn.request=function(e,t){return e=wn(e),mn.request.call(this,e,t)},yn.get=function(e,t){return e=wn(e),mn.get.call(this,e,t)};var vn={};(function(e){vn=n;const t=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;function n(r,i){if(r=Object.assign({maxRedirects:10},"string"==typeof r?{url:r}:r),i=wt(i),r.url){const{hostname:e,port:t,protocol:n,auth:i,path:s}=en.parse(r.url);delete r.url,e||t||n||i?Object.assign(r,{hostname:e,port:t,protocol:n,auth:i,path:s}):r.path=s}const s={"accept-encoding":"gzip, deflate"};let o;r.headers&&Object.keys(r.headers).forEach(e=>s[e.toLowerCase()]=r.headers[e]),r.headers=s,r.body?o=r.json&&!t(r.body)?JSON.stringify(r.body):r.body:r.form&&(o="string"==typeof r.form?r.form:Qt.stringify(r.form),r.headers["content-type"]="application/x-www-form-urlencoded"),o&&(r.method||(r.method="POST"),t(o)||(r.headers["content-length"]=e.byteLength(o)),r.json&&!r.form&&(r.headers["content-type"]="application/json")),delete r.body,delete r.form,r.json&&(r.headers.accept="application/json"),r.method&&(r.method=r.method.toUpperCase());const a=("https:"===r.protocol?_n:mn).request(r,e=>{if(e.statusCode>=300&&e.statusCode<400&&e.headers.location)return r.url=e.headers.location,delete r.headers.host,e.resume(),"POST"===r.method&&[301,302].includes(e.statusCode)&&(r.method="GET",delete r.headers["content-length"],delete r.headers["content-type"]),0==r.maxRedirects--?i(new Error("too many redirects")):n(r,i);const t="function"==typeof te&&"HEAD"!==r.method;i(null,t?te(e):e)});return a.on("timeout",()=>{a.abort(),i(new Error("Request timed out"))}),a.on("error",i),t(o)?o.on("error",i).pipe(a):a.end(o),a}n.concat=((e,t)=>n(e,(n,r)=>{if(n)return t(n);P(r,(n,i)=>{if(n)return t(n);if(e.json)try{i=JSON.parse(i.toString())}catch(n){return t(n,r,i)}t(null,r,i)})})),["get","post","put","patch","head","delete"].forEach(e=>{n[e]=((t,r)=>("string"==typeof t&&(t={url:t}),n(Object.assign({method:e.toUpperCase()},t),r)))})}).call(this,u({}).Buffer);var En={};(function(e){"use strict";var t=[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];En.decode=function(n){var r,i=0,s=0,o=0;e.isBuffer(n)||(n=new e(n));for(var a=new e(Math.ceil(5*n.length/8)),h=0;h<n.length&&61!==n[h];h++){var c=n[h]-48;if(!(c<t.length))throw new Error("Invalid input - it is not base32 encoded string");s=t[c],i<=3?0==(i=(i+5)%8)?(r|=s,a[o]=r,o++,r=0):r|=255&s<<8-i:(r|=255&s>>>(i=(i+5)%8),a[o]=r,o++,r=255&s<<8-i)}return a.slice(0,o)}}).call(this,u({}).Buffer);var kn={};En.encode,kn.decode=En.decode;var Sn=function(e,t,n){return 0===e.length?e:t?(n||e.sort(t),function(e,t){for(var n=1,r=e.length,i=e[0],s=e[0],o=1;o<r;++o)if(s=i,t(i=e[o],s)){if(o===n){n++;continue}e[n++]=i}return e.length=n,e}(e,t)):(n||e.sort(),function(e){for(var t=1,n=e.length,r=e[0],i=e[0],s=1;s<n;++s,i=r)if(i=r,(r=e[s])!==i){if(s===t){t++;continue}e[t++]=r}return e.length=t,e}(e))},Cn={};(function(e){function t(t){const n={},r=t.split("magnet:?")[1];let i;return(r&&r.length>=0?r.split("&"):[]).forEach(e=>{const t=e.split("=");if(2!==t.length)return;const r=t[0];let i=t[1];if("dn"===r&&(i=decodeURIComponent(i).replace(/\+/g," ")),"tr"!==r&&"xs"!==r&&"as"!==r&&"ws"!==r||(i=decodeURIComponent(i)),"kt"===r&&(i=decodeURIComponent(i).split("+")),"ix"===r&&(i=Number(i)),n[r])if(Array.isArray(n[r]))n[r].push(i);else{const e=n[r];n[r]=[e,i]}else n[r]=i}),n.xt&&(Array.isArray(n.xt)?n.xt:[n.xt]).forEach(t=>{if(i=t.match(/^urn:btih:(.{40})/))n.infoHash=i[1].toLowerCase();else if(i=t.match(/^urn:btih:(.{32})/)){const t=kn.decode(i[1]);n.infoHash=e.from(t,"binary").toString("hex")}}),n.infoHash&&(n.infoHashBuffer=e.from(n.infoHash,"hex")),n.dn&&(n.name=n.dn),n.kt&&(n.keywords=n.kt),"string"==typeof n.tr?n.announce=[n.tr]:Array.isArray(n.tr)?n.announce=n.tr:n.announce=[],n.urlList=[],("string"==typeof n.as||Array.isArray(n.as))&&(n.urlList=n.urlList.concat(n.as)),("string"==typeof n.ws||Array.isArray(n.ws))&&(n.urlList=n.urlList.concat(n.ws)),Sn(n.announce),Sn(n.urlList),n}(Cn=t).decode=t,Cn.encode=function(e){(e=Object.assign({},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);let t="magnet:?";return Object.keys(e).filter(e=>2===e.length).forEach((n,r)=>{(Array.isArray(e[n])?e[n]:[e[n]]).forEach((e,i)=>{!(r>0||i>0)||"kt"===n&&0!==i||(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&&i>0?`+${e}`:`${n}=${e}`})}),t}}).call(this,u({}).Buffer);var xn={};(function(e,t){function n(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e))return Cn(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return Cn(`magnet:?xt=urn:btih:${e}`);if(t.isBuffer(e)&&20===e.length)return Cn(`magnet:?xt=urn:btih:${e.toString("hex")}`);if(t.isBuffer(e))return function(e){t.isBuffer(e)&&(e=Z.decode(e)),i(e.info,"info"),i(e.info["name.utf-8"]||e.info.name,"info.name"),i(e.info["piece length"],"info['piece length']"),i(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(e=>{i("number"==typeof e.length,"info.files[0].length"),i(e["path.utf-8"]||e.path,"info.files[0].path")}):i("number"==typeof e.info.length,"info.length");const n={info:e.info,infoBuffer:Z.encode(e.info),name:(e.info["name.utf-8"]||e.info.name).toString(),announce:[]};n.infoHash=Lt.sync(n.infoBuffer),n.infoHashBuffer=t.from(n.infoHash,"hex"),void 0!==e.info.private&&(n.private=!!e.info.private),e["creation date"]&&(n.created=new Date(1e3*e["creation date"])),e["created by"]&&(n.createdBy=e["created by"].toString()),t.isBuffer(e.comment)&&(n.comment=e.comment.toString()),Array.isArray(e["announce-list"])&&e["announce-list"].length>0?e["announce-list"].forEach(e=>{e.forEach(e=>{n.announce.push(e.toString())})}):e.announce&&n.announce.push(e.announce.toString()),t.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),n.urlList=(e["url-list"]||[]).map(e=>e.toString()),Sn(n.announce),Sn(n.urlList);const s=e.info.files||[e.info];n.files=s.map((e,t)=>{const i=[].concat(n.name,e["path.utf-8"]||e.path||[]).map(e=>e.toString());return{path:et.join.apply(null,[et.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:s.slice(0,t).reduce(r,0)}}),n.length=s.reduce(r,0);const o=n.files[n.files.length-1];return n.pieceLength=e.info["piece length"],n.lastPieceLength=(o.offset+o.length)%n.pieceLength||n.pieceLength,n.pieces=function(e){const t=[];for(let n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}(e.info.pieces),n}(e);if(e&&e.infoHash)return e.infoHash=e.infoHash.toLowerCase(),e.announce||(e.announce=[]),"string"==typeof e.announce&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;throw new Error("Invalid torrent identifier")}function r(e,t){return e+t.length}function i(e,t){if(!e)throw new Error(`Torrent is missing required field: ${t}`)}(xn=n).remote=function(t,r){let i;if("function"!=typeof r)throw new Error("second argument must be a Function");try{i=n(t)}catch(fi){}function s(e){try{i=n(e)}catch(fi){return r(fi)}i&&i.infoHash?r(null,i):r(new Error("Invalid torrent identifier"))}i&&i.infoHash?e.nextTick(()=>{r(null,i)}):"undefined"!=typeof Blob&&t instanceof Blob?Ht(t,(e,t)=>{if(e)return r(new Error(`Error converting Blob: ${e.message}`));s(t)}):"function"==typeof vn&&/^https?:/.test(t)?vn.concat({url:t,timeout:3e4,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},(e,t,n)=>{if(e)return r(new Error(`Error downloading torrent: ${e.message}`));s(n)}):"function"==typeof ut.readFile&&"string"==typeof t?ut.readFile(t,(e,t)=>{if(e)return r(new Error("Invalid torrent identifier"));s(t)}):e.nextTick(()=>{r(new Error("Invalid torrent identifier"))})},xn.toMagnetURI=Cn.encode,xn.toTorrentFile=function(e){const n={info:e.info};return n["announce-list"]=(e.announce||[]).map(e=>(n.announce||(n.announce=e),[e=t.from(e,"utf8")])),n["url-list"]=e.urlList||[],void 0!==e.private&&(n.private=Number(e.private)),e.created&&(n["creation date"]=e.created.getTime()/1e3|0),e.createdBy&&(n["created by"]=e.createdBy),e.comment&&(n.comment=e.comment),Z.encode(n)},t.alloc(0)}).call(this,ce,u({}).Buffer);var Tn=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null},In={};(function(e,t){"use strict";var n=N.Buffer,r=t.crypto||t.msCrypto;In=r&&r.getRandomValues?function(t,i){if(t>4294967295)throw new RangeError("requested too many random bytes");var s=n.allocUnsafe(t);if(t>0)if(t>65536)for(var o=0;o<t;o+=65536)r.getRandomValues(s.slice(o,o+65536));else r.getRandomValues(s);return"function"==typeof i?e.nextTick(function(){i(null,s)}):s}:function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var An={};(function(e){An=r;var t=jt("simple-peer"),n=5e3;function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._id=In(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),Ze.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||In(20).toString("hex"):null,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=Object.assign({},r.config,e.config),t.offerOptions=e.offerOptions||{},t.answerOptions=e.answerOptions||{},t.sdpTransform=e.sdpTransform||function(e){return e},t.streams=e.streams||(e.stream?[e.stream]:[]),t.trickle=void 0===e.trickle||e.trickle,t.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,t.iceCompleteTimeout=e.iceCompleteTimeout||n,t.destroyed=!1,t._connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localFamily=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:Tn(),!t._wrtc)throw"undefined"==typeof window?s("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT"):s("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._iceCompleteTimer=null,t._channel=null,t._pendingCandidates=[],t._isNegotiating=!t.initiator,t._batchedNegotiation=!1,t._queuedNegotiation=!1,t._sendersAwaitingStable=[],t._senderMap=new Map,t._firstStable=!0,t._closingInterval=null,t._remoteTracks=[],t._remoteStreams=[],t._chunk=null,t._cb=null,t._interval=null;try{t._pc=new t._wrtc.RTCPeerConnection(t.config)}catch(fi){return void setTimeout(()=>t.destroy(fi),0)}t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceStateChange()},t._pc.onicegatheringstatechange=function(){t._onIceStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.initiator?t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}):t._pc.ondatachannel=function(e){t._setupData(e)},t.streams&&t.streams.forEach(function(e){t.addStream(e)}),t._pc.ontrack=function(e){t._onTrack(e)},t.initiator&&t._needsNegotiation(),t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}function i(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}function s(e,t){var n=new Error(e);return n.code=t,n}Re(r,Ze.Duplex),r.WEBRTC_SUPPORT=!!Tn(),r.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}],sdpSemantics:"unified-plan"},r.channelConfig={},Object.defineProperty(r.prototype,"bufferSize",{get:function(){return this._channel&&this._channel.bufferedAmount||0}}),Object.defineProperty(r.prototype,"connected",{get:function(){return this._connected&&"open"===this._channel.readyState}}),r.prototype.address=function(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}},r.prototype.signal=function(e){var t=this;if(t.destroyed)throw s("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(fi){e={}}t._debug("signal()"),e.renegotiate&&t.initiator&&(t._debug("got request to renegotiate"),t._needsNegotiation()),e.transceiverRequest&&t.initiator&&(t._debug("got request for transceiver"),t.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(t._pc.localDescription&&t._pc.localDescription.type&&t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e)).then(function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())}).catch(function(e){t.destroy(s(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||t.destroy(s("signal() called with invalid signal data","ERR_SIGNALING"))},r.prototype._addIceCandidate=function(e){var t=this,n=new t._wrtc.RTCIceCandidate(e);t._pc.addIceCandidate(n).catch(function(e){!n.address||n.address.endsWith(".local")?("Ignoring unsupported ICE candidate.",console.warn("Ignoring unsupported ICE candidate.")):t.destroy(s(e,"ERR_ADD_ICE_CANDIDATE"))})},r.prototype.send=function(e){this._channel.send(e)},r.prototype.addTransceiver=function(e,t){if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(fi){this.destroy(fi)}else this.emit("signal",{transceiverRequest:{kind:e,init:t}})},r.prototype.addStream=function(e){var t=this;t._debug("addStream()"),e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype.addTrack=function(e,t){this._debug("addTrack()");var n=this._senderMap.get(e)||new Map,r=n.get(t);r?r.removed?this.destroy(s("Track has been removed. You should enable/disable tracks that you want to re-add.","ERR_SENDER_REMOVED")):this.destroy(s("Track has already been added to that stream.","ERR_SENDER_ALREADY_ADDED")):(r=this._pc.addTrack(e,t),n.set(t,r),this._senderMap.set(e,n),this._needsNegotiation())},r.prototype.replaceTrack=function(e,t,n){this._debug("replaceTrack()");var r=this._senderMap.get(e),i=r?r.get(n):null;i||this.destroy(s("Cannot replace track that was never added.","ERR_TRACK_NOT_ADDED")),t&&this._senderMap.set(t,r),null!=i.replaceTrack?i.replaceTrack(t):this.destroy(s("replaceTrack is not supported in this browser","ERR_UNSUPPORTED_REPLACETRACK"))},r.prototype.removeTrack=function(e,t){this._debug("removeSender()");var n=this._senderMap.get(e),r=n?n.get(t):null;r||this.destroy(s("Cannot remove track that was never added.","ERR_TRACK_NOT_ADDED"));try{r.removed=!0,this._pc.removeTrack(r)}catch(fi){"NS_ERROR_UNEXPECTED"===fi.name?this._sendersAwaitingStable.push(r):this.destroy(fi)}this._needsNegotiation()},r.prototype.removeStream=function(e){var t=this;t._debug("removeSenders()"),e.getTracks().forEach(function(n){t.removeTrack(n,e)})},r.prototype._needsNegotiation=function(){var e=this;e._debug("_needsNegotiation"),e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e._debug("starting batched negotiation"),e.negotiate()},0))},r.prototype.negotiate=function(){var e=this;e.initiator?e._isNegotiating?(e._queuedNegotiation=!0,e._debug("already negotiating, queueing")):(e._debug("start negotiation"),setTimeout(()=>{e._createOffer()},0)):e._isNegotiating||(e._debug("requesting negotiation from initiator"),e.emit("signal",{renegotiate:!0})),e._isNegotiating=!0},r.prototype.destroy=function(e){this._destroy(e,function(){})},r.prototype._destroy=function(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.destroyed=!0,this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close"),t()}},r.prototype._setupData=function(e){var t=this;if(!e.channel)return t.destroy(s("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"));t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=65536),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t.destroy(s(e,"ERR_DATA_CHANNEL"))};var n=!1;t._closingInterval=setInterval(function(){t._channel&&"closing"===t._channel.readyState?(n&&t._onChannelClose(),n=!0):n=!1},5e3)},r.prototype._read=function(){},r.prototype._write=function(e,t,n){if(this.destroyed)return n(s("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(this._connected){try{this.send(e)}catch(fi){return this.destroy(s(fi,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},r.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e._connected?t():e.once("connect",t))},r.prototype._startIceCompleteTimeout=function(){var e=this;e.destroyed||e._iceCompleteTimer||(e._debug("started iceComplete timeout"),e._iceCompleteTimer=setTimeout(function(){e._iceComplete||(e._iceComplete=!0,e._debug("iceComplete timeout completed"),e.emit("iceTimeout"),e.emit("_iceComplete"))},e.iceCompleteTimeout))},r.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(e.offerOptions).then(function(t){function n(){if(!e.destroyed){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}}e.destroyed||(e.trickle||e.allowHalfTrickle||(t.sdp=i(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){e._debug("createOffer success"),e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))}).catch(function(t){e.destroy(s(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(s(t,"ERR_CREATE_OFFER"))})},r.prototype._requestMissingTransceivers=function(){var e=this;e._pc.getTransceivers&&e._pc.getTransceivers().forEach(t=>{t.mid||!t.sender.track||t.requested||(t.requested=!0,e.addTransceiver(t.sender.track.kind))})},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(e.answerOptions).then(function(t){function n(){if(!e.destroyed){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp}),e.initiator||e._requestMissingTransceivers()}}e.destroyed||(e.trickle||e.allowHalfTrickle||(t.sdp=i(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))}).catch(function(t){e.destroy(s(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(s(t,"ERR_CREATE_ANSWER"))})},r.prototype._onIceStateChange=function(){if(!this.destroyed){var e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(s("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(s("Ice connection closed.","ERR_ICE_CONNECTION_CLOSED"))}},r.prototype.getStats=function(e){var t=this;function n(e){return"[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach(function(t){Object.assign(e,t)}),e}0===t._pc.getStats.length?t._pc.getStats().then(function(t){var r=[];t.forEach(function(e){r.push(n(e))}),e(null,r)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var r=[];t.forEach(function(e){r.push(n(e))}),e(null,r)},function(t){e(t)}):t._pc.getStats.length>0?t._pc.getStats(function(r){if(!t.destroyed){var i=[];r.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,i.push(n(t))}),e(null,i)}},function(t){e(t)}):e(null,[])},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,function t(){e.destroyed||e.getStats(function(n,r){if(!e.destroyed){n&&(r=[]);var i={},o={},a={},h=!1;if(r.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(o[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(a[e.id]=e)}),r.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&u(a[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&u(e)}),h||Object.keys(a).length&&!Object.keys(o).length){if(e._connecting=!1,e._connected=!0,e._chunk){try{e.send(e._chunk)}catch(n){return e.destroy(s(n,"ERR_DATA_CHANNEL"))}e._chunk=null,e._debug('sent chunk from "write before connect"');var c=e._cb;e._cb=null,c(null)}"number"!=typeof e._channel.bufferedAmountLowThreshold&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}else setTimeout(t,100)}function u(t){h=!0;var n=o[t.localCandidateId];n&&(n.ip||n.address)?(e.localAddress=n.ip||n.address,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])),e.localAddress&&(e.localFamily=e.localAddress.includes(":")?"IPv6":"IPv4");var r=i[t.remoteCandidateId];r&&(r.ip||r.address)?(e.remoteAddress=r.ip||r.address,e.remotePort=Number(r.port)):r&&r.ipAddress?(e.remoteAddress=r.ipAddress,e.remotePort=Number(r.portNumber)):"string"==typeof t.googRemoteAddress&&(r=t.googRemoteAddress.split(":"),e.remoteAddress=r[0],e.remotePort=Number(r[1])),e.remoteAddress&&(e.remoteFamily=e.remoteAddress.includes(":")?"IPv6":"IPv4"),e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}})}())},r.prototype._onInterval=function(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"!==e._pc.signalingState||e._firstStable||(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e._pc.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._firstStable=!1,e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},r.prototype._onIceCandidate=function(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())},r.prototype._onChannelMessage=function(t){if(!this.destroyed){var n=t.data;n instanceof ArrayBuffer&&(n=e.from(n)),this.push(n)}},r.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},r.prototype._onChannelOpen=function(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},r.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this.destroy())},r.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(n){t._debug("on track"),t.emit("track",e.track,n),t._remoteTracks.push({track:e.track,stream:n}),t._remoteStreams.some(function(e){return e.id===n.id})||(t._remoteStreams.push(n),setTimeout(function(){t.emit("stream",n)},0))})},r.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],t.apply(null,e)}}).call(this,u({}).Buffer);var Rn,Ln=1,Bn=function(){Ln=Ln+1&65535},Un=function(e){Rn||(Rn=setInterval(Bn,250)).unref&&Rn.unref();var t=4*(e||5),n=[0],r=1,i=Ln-1&65535;return function(e){var s=Ln-i&65535;for(s>t&&(s=t),i=Ln;s--;)r===t&&(r=0),n[r]=n[0===r?t-1:r-1],r++;e&&(n[r-1]+=e);var o=n[r-1],a=n.length<t?0:n[r===t?0:r];return n.length<4?o:4*(o-a)/n.length}},On={};const Mn=/^\[?([^\]]+)\]?:(\d+)$/;let Pn={},Nn=0;(On=function(e){if(1e5===Nn&&On.reset(),!Pn[e]){const t=Mn.exec(e);if(!t)throw new Error(`invalid addr: ${e}`);Pn[e]=[t[1],Number(t[2])],Nn+=1}return Pn[e]}).reset=function(){Pn={},Nn=0};var jn={exports:{}};function Hn(e){let t=e>>3;return e%8!=0&&t++,t}jn.exports=class{constructor(e=0,t){const n=null!=t&&t.grow;this.grow=n&&isFinite(n)&&Hn(n)||n||0,this.buffer="number"==typeof e?new Uint8Array(Hn(e)):e}get(e){const t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)}set(e,t=!0){const n=e>>3;if(t){if(this.buffer.length<n+1){const e=Math.max(n+1,Math.min(2*this.buffer.length,this.grow));if(e<=this.grow){const t=new Uint8Array(e);t.set(this.buffer),this.buffer=t}}this.buffer[n]|=128>>e%8}else n<this.buffer.length&&(this.buffer[n]&=~(128>>e%8))}},jn=jn.exports;var Dn=class extends Ze.Writable{constructor(e,t,n={}){if(super(n),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(!(t=Number(t)))throw new Error("Second argument must be a chunk length");this._blockstream=new Qe(t,{zeroPadding:!1}),this._outstandingPuts=0;let r=0;this._blockstream.on("data",t=>{this.destroyed||(this._outstandingPuts+=1,e.put(r,t,()=>{this._outstandingPuts-=1,0===this._outstandingPuts&&"function"==typeof this._finalCb&&(this._finalCb(null),this._finalCb=null)}),r+=1)}).on("error",e=>{this.destroy(e)})}_write(e,t,n){this._blockstream.write(e,t,n)}_final(e){this._blockstream.end(),this._blockstream.once("end",()=>{0===this._outstandingPuts?e(null):this._finalCb=e})}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}},qn={};(function(e){qn.DEFAULT_ANNOUNCE_PEERS=50,qn.binaryToHex=function(t){return"string"!=typeof t&&(t=String(t)),e.from(t,"binary").toString("hex")},qn.hexToBinary=function(t){return"string"!=typeof t&&(t=String(t)),e.from(t,"hex").toString("binary")},Object.assign(qn,te)}).call(this,u({}).Buffer);var Fn={};(function(e,t){const n=jt("simple-websocket"),r="function"!=typeof te?WebSocket:te,i=65536;class s extends Ze.Duplex{constructor(t={}){if("string"==typeof t&&(t={url:t}),super(t=Object.assign({allowHalfOpen:!1},t)),null==t.url&&null==t.socket)throw new Error("Missing required `url` or `socket` option");if(null!=t.url&&null!=t.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=In(4).toString("hex").slice(0,7),this._debug("new websocket: %o",t),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,t.socket)this.url=t.socket.url,this._ws=t.socket,this.connected=t.socket.readyState===r.OPEN;else{this.url=t.url;try{this._ws="function"==typeof te?new r(t.url,t):new r(t.url)}catch(fi){return void e.nextTick(()=>this.destroy(fi))}}this._ws.binaryType="arraybuffer",this._ws.onopen=(()=>{this._onOpen()}),this._ws.onmessage=(e=>{this._onMessage(e)}),this._ws.onclose=(()=>{this._onClose()}),this._ws.onerror=(()=>{this.destroy(new Error("connection error to "+this.url))}),this._onFinishBound=(()=>{this._onFinish()}),this.once("finish",this._onFinishBound)}send(e){this._ws.send(e)}destroy(e){this._destroy(e,()=>{})}_destroy(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._ws){const t=this._ws,n=()=>{t.onclose=null};if(t.readyState===r.CLOSED)n();else try{t.onclose=n,t.close()}catch(e){n()}t.onopen=null,t.onmessage=null,t.onerror=(()=>{})}if(this._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){const t=e.code;(e=new Error(e.message)).code=t}this.emit("error",e)}this.emit("close"),t()}}_read(){}_write(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(fi){return this.destroy(fi)}"function"!=typeof te&&this._ws.bufferedAmount>i?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_onFinish(){if(this.destroyed)return;const e=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?e():this.once("connect",e)}_onMessage(e){if(this.destroyed)return;let n=e.data;n instanceof ArrayBuffer&&(n=t.from(n)),this.push(n)}_onOpen(){if(!this.connected&&!this.destroyed){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(fi){return this.destroy(fi)}this._chunk=null,this._debug('sent chunk from "write before connect"');const e=this._cb;this._cb=null,e(null)}"function"!=typeof te&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_onInterval(){if(!this._cb||!this._ws||this._ws.bufferedAmount>i)return;this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onClose(){this.destroyed||(this._debug("on close"),this.destroy())}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],n.apply(null,e)}}s.WEBSOCKET_SUPPORT=!!r,Fn=s}).call(this,ce,u({}).Buffer);var Wn=class extends d{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},e),this.interval.unref&&this.interval.unref())}},zn={};const $n=jt("bittorrent-tracker:websocket-tracker"),Vn={},Gn=1e4,Kn=18e5,Yn=12e4,Jn=5e4;class Xn extends Wn{constructor(e,t,n){super(e,t),$n("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(e)});const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,10);this._generateOffers(n,e=>{t.numwant=n,t.offers=e,this._send(t)})}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(e)});const t={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(e=>e.toString("binary")):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary};this._send(t)}destroy(e=Zn){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const i in this.peers){const e=this.peers[i];clearTimeout(e.trackerTimeout),e.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,Vn[this.announceUrl]&&(Vn[this.announceUrl].consumers-=1),Vn[this.announceUrl].consumers>0)return e();let t=Vn[this.announceUrl];if(delete Vn[this.announceUrl],t.on("error",Zn),t.once("close",e),!this.expectingResponse)return r();var n=setTimeout(r,qn.DESTROY_TIMEOUT);function r(){n&&(clearTimeout(n),n=null),t.removeListener("data",r),t.destroy(),t=null}t.once("data",r)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=(()=>{this._onSocketConnect()}),this._onSocketErrorBound=(e=>{this._onSocketError(e)}),this._onSocketDataBound=(e=>{this._onSocketData(e)}),this._onSocketCloseBound=(()=>{this._onSocketClose()}),this.socket=Vn[this.announceUrl],this.socket?(Vn[this.announceUrl].consumers+=1,this.socket.connected&&this._onSocketConnectBound()):(this.socket=Vn[this.announceUrl]=new Fn(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(fi){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void $n("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,qn.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;$n("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const r=e.interval||e["min interval"];r&&this.setInterval(1e3*r);const i=e["tracker id"];if(i&&(this._trackerId=i),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:qn.binaryToHex(e.info_hash)});this.client.emit("update",t)}let s;if(e.offer&&e.peer_id&&($n("creating peer (from remote offer)"),(s=this._createPeer()).id=qn.binaryToHex(e.peer_id),s.once("signal",t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)}),s.signal(e.offer),this.client.emit("peer",s)),e.answer&&e.peer_id){const t=qn.binaryToHex(e.offer_id);(s=this.peers[t])?(s.id=qn.binaryToHex(e.peer_id),s.signal(e.answer),this.client.emit("peer",s),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete this.peers[t]):$n(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach(t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:qn.binaryToHex(t)});this.client.emit("scrape",n)}):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(Math.random()*Yn)+Math.min(Math.pow(2,this.retries)*Gn,Kn);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),$n("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);$n("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,r=[];$n("generating %s offers",e);for(let o=0;o<e;++o)i();function i(){const e=In(20).toString("hex");$n("creating peer (from _generateOffers)");const t=n.peers[e]=n._createPeer({initiator:!0});t.once("signal",t=>{r.push({offer:t,offer_id:qn.hexToBinary(e)}),s()}),t.trackerTimeout=setTimeout(()=>{$n("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()},Jn),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function s(){r.length===e&&($n("generated %s offers",e),t(r))}s()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new An(e);return n.once("error",r),n.once("connect",function e(){n.removeListener("error",r),n.removeListener("connect",e)}),n;function r(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}}}function Zn(){}Xn.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,Xn._socketPool=Vn,zn=Xn;var Qn={};(function(e,t){const n=jt("bittorrent-tracker:client");class r extends d{constructor(r={}){if(super(),!r.peerId)throw new Error("Option `peerId` is required");if(!r.infoHash)throw new Error("Option `infoHash` is required");if(!r.announce)throw new Error("Option `announce` is required");if(!e.browser&&!r.port)throw new Error("Option `port` is required");this.peerId="string"==typeof r.peerId?r.peerId:r.peerId.toString("hex"),this._peerIdBuffer=t.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof r.infoHash?r.infoHash.toLowerCase():r.infoHash.toString("hex"),this._infoHashBuffer=t.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),n("new client %s",this.infoHash),this.destroyed=!1,this._port=r.port,this._getAnnounceOpts=r.getAnnounceOpts,this._rtcConfig=r.rtcConfig,this._userAgent=r.userAgent,this._wrtc="function"==typeof r.wrtc?r.wrtc():r.wrtc;let i="string"==typeof r.announce?[r.announce]:null==r.announce?[]:r.announce;i=i.map(e=>("/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e)),i=Sn(i);const s=!1!==this._wrtc&&(!!this._wrtc||An.WEBRTC_SUPPORT),o=t=>{e.nextTick(()=>{this.emit("warning",t)})};this._trackers=i.map(e=>{let t;try{t=new URL(e)}catch(fi){return o(new Error(`Invalid tracker URL: ${e}`)),null}const n=t.port;if(n<0||n>65535)return o(new Error(`Invalid tracker port: ${e}`)),null;const r=t.protocol;return"http:"!==r&&"https:"!==r||"function"!=typeof te?"udp:"===r&&"function"==typeof te?new te(this,e):"ws:"!==r&&"wss:"!==r||!s?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):"ws:"===r&&"undefined"!=typeof window&&"https:"===window.location.protocol?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):new zn(this,e):new te(this,e)}).filter(Boolean)}start(e){(e=this._defaultAnnounceOpts(e)).event="started",n("send `start` %o",e),this._announce(e),this._trackers.forEach(e=>{e.setInterval()})}stop(e){(e=this._defaultAnnounceOpts(e)).event="stopped",n("send `stop` %o",e),this._announce(e)}complete(e){e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",n("send `complete` %o",e),this._announce(e)}update(e){(e=this._defaultAnnounceOpts(e)).event&&delete e.event,n("send `update` %o",e),this._announce(e)}_announce(e){this._trackers.forEach(t=>{t.announce(e)})}scrape(e){n("send `scrape`"),e||(e={}),this._trackers.forEach(t=>{t.scrape(e)})}setInterval(e){n("setInterval %d",e),this._trackers.forEach(t=>{t.setInterval(e)})}destroy(e){if(this.destroyed)return;this.destroyed=!0,n("destroy");const t=this._trackers.map(e=>t=>{e.destroy(t)});kt(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=qn.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}r.scrape=((e,n)=>{if(n=wt(n),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const i=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:t.from("01234567890123456789"),port:6881}),s=new r(i);s.once("error",n),s.once("warning",n);let o=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return s.on("scrape",e=>{if(o-=1,a[e.infoHash]=e,0===o){s.destroy();const e=Object.keys(a);1===e.length?n(null,a[e[0]]):n(null,a)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(e=>t.from(e,"hex")):t.from(e.infoHash,"hex"),s.scrape({infoHash:e.infoHash}),s}),Qn=r}).call(this,ce,u({}).Buffer);var er={};(function(e){const t=jt("torrent-discovery"),n=d.EventEmitter;er=class extends n{constructor(t){if(super(),!t.peerId)throw new Error("Option `peerId` is required");if(!t.infoHash)throw new Error("Option `infoHash` is required");if(!e.browser&&!t.port)throw new Error("Option `port` is required");this.peerId="string"==typeof t.peerId?t.peerId:t.peerId.toString("hex"),this.infoHash="string"==typeof t.infoHash?t.infoHash.toLowerCase():t.infoHash.toString("hex"),this._port=t.port,this._userAgent=t.userAgent,this.destroyed=!1,this._announce=t.announce||[],this._intervalMs=t.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=(e=>{this.emit("warning",e)}),this._onError=(e=>{this.emit("error",e)}),this._onDHTPeer=((e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")}),this._onTrackerPeer=(e=>{this.emit("peer",e,"tracker")}),this._onTrackerAnnounce=(()=>{this.emit("trackerAnnounce")});const n=(e,t)=>{const n=new te(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===t.tracker?this.tracker=null:t.tracker&&"object"==typeof t.tracker?(this._trackerOpts=Object.assign({},t.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===t.dht||"function"!=typeof te?this.dht=null:t.dht&&"function"==typeof t.dht.addNode?this.dht=t.dht:t.dht&&"object"==typeof t.dht?this.dht=n(t.dhtPort,t.dht):this.dht=n(t.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce())}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push(e=>{this.tracker.destroy(e)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push(e=>{this.dht.destroy(e)})),kt(t,e),this.dht=null,this.tracker=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new Qn(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(t("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,e=>{this._dhtAnnouncing=!1,t("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}}}).call(this,ce);var tr={};(function(e){function t(e,n){if(!(this instanceof t))return new t(e,n);if(n||(n={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(n.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 n(t,n,r){e.nextTick(function(){t&&t(n,r)})}tr=t,t.prototype.put=function(e,t,r){if(this.closed)return n(r,new Error("Storage is closed"));var i=e===this.lastChunkIndex;return i&&t.length!==this.lastChunkLength?n(r,new Error("Last chunk length must be "+this.lastChunkLength)):i||t.length===this.chunkLength?(this.chunks[e]=t,void n(r,null)):n(r,new Error("Chunk length must be "+this.chunkLength))},t.prototype.get=function(e,t,r){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return n(r,new Error("Storage is closed"));var i=this.chunks[e];if(!i){var s=new Error("Chunk not found");return s.notFound=!0,n(r,s)}if(!t)return n(r,null,i);var o=t.offset||0,a=t.length||i.length-o;n(r,null,i.slice(o,a+o))},t.prototype.close=t.prototype.destroy=function(e){if(this.closed)return n(e,new Error("Storage is closed"));this.closed=!0,this.chunks=null,n(e,null)}}).call(this,ce);var nr={};(function(e){nr=class{constructor(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=[]}put(e,t,n){this.mem[e]=t,this.store.put(e,t,t=>{this.mem[e]=null,n&&n(t)})}get(t,n,r){if("function"==typeof n)return this.get(t,null,n);const i=n&&n.offset||0,s=n&&n.length&&i+n.length,o=this.mem[t];if(o)return function(t,n,r){e.nextTick(()=>{t&&t(null,r)})}(r,0,n?o.slice(i,s):o);this.store.get(t,n,r)}close(e){this.store.close(e)}destroy(e){this.store.destroy(e)}}}).call(this,ce);var rr={};(function(e){rr=function(t,n,r){if("number"!=typeof n)throw new Error("second argument must be a Number");var i,s,o,a,h,c=!0;function u(t){function n(){r&&r(t,i),r=null}c?e.nextTick(n):n()}function d(e,n,r){if(i[e]=r,n&&(h=!0),0==--o||n)u(n);else if(!h&&l<s){var c;a?(c=a[l],l+=1,t[c](function(e,t){d(c,e,t)})):(c=l,l+=1,t[c](function(e,t){d(c,e,t)}))}}Array.isArray(t)?(i=[],o=s=t.length):(a=Object.keys(t),i={},o=s=a.length);var l=n;o?a?a.some(function(e,r){if(t[e](function(t,n){d(e,t,n)}),r===n-1)return!0}):t.some(function(e,t){if(e(function(e,n){d(t,e,n)}),t===n-1)return!0}):u(null),c=!1}}).call(this,ce);var ir={};(function(e){const t=16384;class n{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/t),this._remainder=e%t||t,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:t}chunkLengthRemaining(e){return this.length-e*t}chunkOffset(e){return e*t}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._reservations<this._chunks){const e=this._reservations;return this._reservations=this._chunks,e}return-1}cancel(e){this.init()&&this._cancellations.push(e)}cancelRemaining(e){this.init()&&(this._reservations=e)}get(e){return this.init()?this._buffer[e]:null}set(e,n,r){if(!this.init())return!1;const i=n.length,s=Math.ceil(i/t);for(let o=0;o<s;o++)if(!this._buffer[e+o]){const i=o*t,s=n.slice(i,i+t);this._buffered++,this._buffer[e+o]=s,this.missing-=s.length,this.sources.includes(r)||this.sources.push(r)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const t=e.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,t}init(){return!(this._flushed||!this._buffer&&(this._buffer=new Array(this._chunks),this._cancellations=[],this.sources=[],0))}}Object.defineProperty(n,"BLOCK_LENGTH",{value:t}),ir=n}).call(this,u({}).Buffer);var sr=function(){},or=function(e,t,n){if("function"==typeof t)return or(e,null,t);t||(t={}),n=wt(n||sr);var r=e._writableState,i=e._readableState,s=t.readable||!1!==t.readable&&e.readable,o=t.writable||!1!==t.writable&&e.writable,a=function(){e.writable||h()},h=function(){o=!1,s||n.call(e)},c=function(){s=!1,o||n.call(e)},u=function(t){n.call(e,t?new Error("exited with error code: "+t):null)},d=function(t){n.call(e,t)},l=function(){return(!s||i&&i.ended)&&(!o||r&&r.ended)?void 0:n.call(e,new Error("premature close"))},f=function(){e.req.on("finish",h)};return function(e){return e.setHeader&&"function"==typeof e.abort}(e)?(e.on("complete",h),e.on("abort",l),e.req?f():e.on("request",f)):o&&!r&&(e.on("end",a),e.on("close",a)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",u),e.on("end",c),e.on("finish",h),!1!==t.error&&e.on("error",d),e.on("close",l),function(){e.removeListener("complete",h),e.removeListener("abort",l),e.removeListener("request",f),e.req&&e.req.removeListener("finish",h),e.removeListener("end",a),e.removeListener("close",a),e.removeListener("finish",h),e.removeListener("exit",u),e.removeListener("end",c),e.removeListener("error",d),e.removeListener("close",l)}},ar=or,hr={};(function(e){var t=function(){},n=/^v?\.0/.test(e.version),r=function(e){return"function"==typeof e},i=function(e){e()},s=function(e,t){return e.pipe(t)};hr=function(){var e,o=Array.prototype.slice.call(arguments),a=r(o[o.length-1]||t)&&o.pop()||t;if(Array.isArray(o[0])&&(o=o[0]),o.length<2)throw new Error("pump requires two streams per minimum");var h=o.map(function(s,c){var u=c<o.length-1;return function(e,i,s,o){o=wt(o);var a=!1;e.on("close",function(){a=!0}),ar(e,{readable:i,writable:s},function(e){if(e)return o(e);a=!0,o()});var h=!1;return function(i){if(!a&&!h)return h=!0,function(e){return!!n&&!!te&&(e instanceof(te.ReadStream||t)||e instanceof(te.WriteStream||t))&&r(e.close)}(e)?e.close(t):function(e){return e.setHeader&&r(e.abort)}(e)?e.abort():r(e.destroy)?e.destroy():void o(i||new Error("stream was destroyed"))}}(s,u,c>0,function(t){e||(e=t),t&&h.forEach(i),u||(h.forEach(i),a(e))})});return o.reduce(s)}}).call(this,ce);var cr={};(function(e){const{EventEmitter:t}=d,n=jt("ut_metadata"),r=1e7,i=1e3,s=16384;cr=(o=>{class a extends t{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new jn(0,{grow:i}),e.isBuffer(o)&&this.setMetadata(o)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||r<e.metadata_size||e.metadata_size<=0?this.emit("warning",new Error("Peer gave invalid metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/s),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const r=e.toString(),i=r.indexOf("ee")+2;t=Z.decode(r.substring(0,i)),n=e.slice(i)}catch(fi){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;n("set metadata");try{const t=Z.decode(e).info;t&&(e=Z.encode(t))}catch(fi){}return!(this._infoHash&&this._infoHash!==Lt.sync(e)||(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",Z.encode({info:Z.decode(this.metadata)})),0))}_send(t,n){let r=Z.encode(t);e.isBuffer(n)&&(r=e.concat([r,n])),this._wire.extended("ut_metadata",r)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*s;let n=t+s;n>this._metadataSize&&(n=this._metadataSize);const r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)}_onData(e,t,n){t.length>s||(t.copy(this.metadata,e*s),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){this.metadata=e.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}e&&(this.setMetadata(this.metadata)||this._failedMetadata())}_failedMetadata(){this._bitfield=new jn(0,{grow:i}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return a.prototype.name="ut_metadata",a})}).call(this,u({}).Buffer);var ur={parse:function(e){var t=e.split(",").map(function(e){return function(e){if(/^-?\d+$/.test(e))return parseInt(e,10);var t;if(t=e.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){var n=t[1],r=t[2],i=t[3];if(n&&i){var s=[],o=(n=parseInt(n))<(i=parseInt(i))?1:-1;"-"!=r&&".."!=r&&"\u2025"!=r||(i+=o);for(var a=n;a!=i;a+=o)s.push(a);return s}}return[]}(e)});return 0===t.length?[]:1===t.length?Array.isArray(t[0])?t[0]:t:t.reduce(function(e,t){return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.concat(t)})}},dr=function(e){for(var t=0,n=e.length;t<n;++t)if(e.charCodeAt(t)>127)return!1;return!0},lr=u({}).Buffer,fr=mr,pr="undefined"!=typeof window&&window.MediaSource,gr=60;function mr(e,t){var n=this;if(!(n instanceof mr))return new mr(e,t);if(!pr)throw new Error("web browser lacks MediaSource support");t||(t={}),n._debug=t.debug,n._bufferDuration=t.bufferDuration||gr,n._elem=e,n._mediaSource=new pr,n._streams=[],n.detailedError=null,n._errorHandler=function(){n._elem.removeEventListener("error",n._errorHandler),n._streams.slice().forEach(function(e){e.destroy(n._elem.error)})},n._elem.addEventListener("error",n._errorHandler),n._elem.src=window.URL.createObjectURL(n._mediaSource)}function _r(e,t){var n=this;if(Ze.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._debugBuffers=[],n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},n._errorHandler=function(e){n.destroyed||n.emit("error",e)},"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._debugBuffers=t._debugBuffers,n._sourceBuffer.addEventListener("updateend",n._flowHandler),n._sourceBuffer.addEventListener("error",n._errorHandler)}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}))){n._wrapper._dumpDebugData();try{n._mediaSource.endOfStream()}catch(fi){}}})}mr.prototype.createWriteStream=function(e){return new _r(this,e)},mr.prototype.error=function(e){this.detailedError||(this.detailedError=e),this._dumpDebugData();try{this._mediaSource.endOfStream("decode")}catch(e){}try{window.URL.revokeObjectURL(this._elem.src)}catch(e){}},mr.prototype._dumpDebugData=function(){this._debug&&(this._debug=!1,this._streams.forEach(function(e,t){var n,r,i;n=e._debugBuffers,r="mediasource-stream-"+t,(i=document.createElement("a")).href=window.URL.createObjectURL(new window.Blob(n)),i.download=r,i.click()}))},Re(_r,Ze.Writable),_r.prototype._onSourceOpen=function(){this.destroyed||(this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._createSourceBuffer())},_r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._allStreams.splice(this._allStreams.indexOf(this),1),this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._elem.removeEventListener("timeupdate",this._flowHandler),this._sourceBuffer&&(this._sourceBuffer.removeEventListener("updateend",this._flowHandler),this._sourceBuffer.removeEventListener("error",this._errorHandler),"open"===this._mediaSource.readyState&&this._sourceBuffer.abort()),e&&this.emit("error",e),this.emit("close"))},_r.prototype._createSourceBuffer=function(){if(!this.destroyed)if(pr.isTypeSupported(this._type)){if(this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.addEventListener("updateend",this._flowHandler),this._sourceBuffer.addEventListener("error",this._errorHandler),this._cb){var e=this._cb;this._cb=null,e()}}else this.destroy(new Error("The provided type is not supported"))},_r.prototype._write=function(e,t,n){var r=this;if(!r.destroyed)if(r._sourceBuffer){if(r._sourceBuffer.updating)return n(new Error("Cannot append buffer while source buffer updating"));var i=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(lr.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,r=0;r<n;r++)t[r]=e[r];return t.buffer}throw new Error("Argument must be a Buffer")}(e);r._wrapper._debug&&r._debugBuffers.push(i);try{r._sourceBuffer.appendBuffer(i)}catch(fi){return void r.destroy(fi)}r._cb=n}else r._cb=function(i){if(i)return n(i);r._write(e,t,n)}},_r.prototype._flow=function(){if(!this.destroyed&&this._sourceBuffer&&!this._sourceBuffer.updating&&!("open"===this._mediaSource.readyState&&this._getBufferDuration()>this._bufferDuration)&&this._cb){var e=this._cb;this._cb=null,e()}},_r.prototype._getBufferDuration=function(){for(var e=this._sourceBuffer.buffered,t=this._elem.currentTime,n=-1,r=0;r<e.length;r++){var i=e.start(r),s=e.end(r)+0;if(i>t)break;(n>=0||t<=s)&&(n=s)}var o=n-t;return o<0&&(o=0),o};var yr=function(e,t){if(null!=t&&"string"!=typeof t)throw new Error("Invalid mimetype, expected string.");return new Promise((n,r)=>{const i=[];e.on("data",e=>i.push(e)).once("end",()=>{const e=null!=t?new Blob(i,{type:t}):new Blob(i);n(e)}).once("error",r)})},br=async function(e,t){const n=await yr(e,t);return URL.createObjectURL(n)},wr={};(function(e){var t=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(n){return!1}}();function n(e,t,n,r){if(n<0||r>e.length)throw new RangeError("Out of range index");return n>>>=0,(r=void 0===r?e.length:r>>>0)>n&&e.fill(t,n,r),e}wr=function(r,i,s,o,a){if(t)return r.fill(i,s,o,a);if("number"==typeof i)return n(r,i,s,o);if("string"==typeof i){if("string"==typeof s?(a=s,s=0,o=r.length):"string"==typeof o&&(a=o,o=r.length),void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("latin1"===a&&(a="binary"),"string"==typeof a&&!e.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(""===i)return n(r,0,s,o);if(function(e){return 1===e.length&&e.charCodeAt(0)<256}(i))return n(r,i.charCodeAt(0),s,o);i=new e(i,a)}return e.isBuffer(i)?function(e,t,n,r){if(n<0||r>e.length)throw new RangeError("Out of range index");if(r<=n)return e;n>>>=0,r=void 0===r?e.length:r>>>0;for(var i=n,s=t.length;i<=r-s;)t.copy(e,i),i+=s;return i!==r&&t.copy(e,i,0,r-i),e}(r,i,s,o):n(r,0,s,o)}}).call(this,u({}).Buffer);var vr={};(function(e){vr=function(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this,u({}).Buffer);var Er={};(function(e){Er=function(t,n,r){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');if(e.alloc)return e.alloc(t,n,r);var i=vr(t);return 0===t?i:void 0===n?wr(i,0):("string"!=typeof r&&(r=void 0),wr(i,n,r))}}).call(this,u({}).Buffer);var kr={},Sr=Math.pow(2,32);kr.encode=function(e,t,n){t||(t=Er(8)),n||(n=0);var r=Math.floor(e/Sr),i=e-r*Sr;return t.writeUInt32BE(r,n),t.writeUInt32BE(i,n+4),t},kr.decode=function(e,t){t||(t=0);var n=e.readUInt32BE(t),r=e.readUInt32BE(t+4);return n*Sr+r},kr.encode.bytes=8,kr.decode.bytes=8;var Cr={};(function(e){var t={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};Cr.Descriptor={},Cr.Descriptor.decode=function(n,r,i){var s,o,a=n.readUInt8(r),h=r+1,c=0;do{c=c<<7|127&(s=n.readUInt8(h++))}while(128&s);var u=t[a];return(o=Cr[u]?Cr[u].decode(n,h,i):{buffer:e.from(n.slice(h,h+c))}).tag=a,o.tagName=u,o.length=h-r+c,o.contentsLen=c,o},Cr.DescriptorArray={},Cr.DescriptorArray.decode=function(e,n,r){for(var i=n,s={};i+2<=r;){var o=Cr.Descriptor.decode(e,i,r);i+=o.length,s[t[o.tag]||"Descriptor"+o.tag]=o}return s},Cr.ESDescriptor={},Cr.ESDescriptor.decode=function(e,t,n){var r=e.readUInt8(t+2),i=t+3;return 128&r&&(i+=2),64&r&&(i+=e.readUInt8(i)+1),32&r&&(i+=2),Cr.DescriptorArray.decode(e,i,n)},Cr.DecoderConfigDescriptor={},Cr.DecoderConfigDescriptor.decode=function(e,t,n){var r=e.readUInt8(t),i=Cr.DescriptorArray.decode(e,t+13,n);return i.oti=r,i}}).call(this,u({}).Buffer);var xr={};(function(e){var n=t({}),r=e.alloc(0);class i extends Ze.PassThrough{constructor(e){super(),this._parent=e,this.destroyed=!1}destroy(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}xr=class extends Ze.Writable{constructor(e){super(e),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}_write(e,t,n){if(!this.destroyed){for(var i=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=e,void(this._writeCb=n);var s=e.length<this._missing?e.length:this._missing;if(this._buf?e.copy(this._buf,this._buf.length-this._missing):this._str&&(i=this._str.write(s===e.length?e:e.slice(0,s))),this._missing-=s,!this._missing){var o=this._buf,a=this._cb,h=this._str;this._buf=this._cb=this._str=this._ondrain=null,i=!0,this._ignoreEmpty=!1,h&&h.end(),a&&a(o)}e=s===e.length?r:e.slice(s)}if(this._pending&&!this._missing)return this._writeBuffer=e,void(this._writeCb=n);i?n():this._ondrain(n)}}_buffer(t,n){this._missing=t,this._buf=e.alloc(t),this._cb=n}_stream(e,t){return this._missing=e,this._str=new i(this),this._ondrain=(n=this._str,r="drain",s=null,n.on(r,function(e){if(s){var t=s;s=null,t(e)}}),function(e){s=e}),this._pending++,this._str.on("end",()=>{this._pending--,this._kick()}),this._cb=t,this._str;var n,r,s}_readBox(){const t=(r,i)=>{this._buffer(r,r=>{i=i?e.concat([i,r]):r;var s=n.readHeaders(i);"number"==typeof s?t(s-i.length,i):(this._pending++,this._headers=s,this.emit("box",s))})};t(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;return this._headers=null,this._stream(e.contentLen,null)}decode(e){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=this._headers;this._headers=null,this._buffer(t.contentLen,r=>{var i=n.decodeWithoutHeaders(t,r);e(i),this._pending--,this._kick()})}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;this._headers=null,this._missing=e.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=(()=>{this._pending--,this._kick()})}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var e=this._writeCb,t=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(t,null,e)}}}}).call(this,u({}).Buffer);var Tr={};(function(e,n){var r=t({});function i(){}class s extends Ze.PassThrough{constructor(e){super(),this._parent=e,this.destroyed=!1}destroy(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}Tr=class extends Ze.Readable{constructor(e){super(e),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=(()=>{this._want&&(this._want=!1,this._read())}),this._onend=(()=>{this._stream=null})}mdat(e,t){this.mediaData(e,t)}mediaData(e,t){var n=new s(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n}box(t,s){if(s||(s=i),this.destroyed)return s(new Error("Encoder is destroyed"));var o;if(t.encodeBufferLen&&(o=n.alloc(t.encodeBufferLen)),t.stream)t.buffer=null,o=r.encode(t,o),this.push(o),this._stream=t.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",s),this._forward();else{if(o=r.encode(t,o),this.push(o))return e.nextTick(s);this._drain=s}}destroy(e){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var t=this._drain;this._drain=null,t(e)}e&&this.emit("error",e),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var e=this._stream.read();if(!e)return void(this._want=!!this._stream);if(!this.push(e))return}}_read(){if(!this._reading&&!this.destroyed){if(this._reading=!0,this._stream&&this._forward(),this._drain){var e=this._drain;this._drain=null,e()}this._reading=!1,this._finalized&&this.push(null)}}}}).call(this,ce,u({}).Buffer);var Ir={decode:e=>new xr(e),encode:e=>new Tr(e)};const{Writable:Ar,PassThrough:Rr}=Ze;var Lr=class extends Ar{constructor(e,t={}){super(t),this.destroyed=!1,this._queue=[],this._position=e||0,this._cb=null,this._buffer=null,this._out=null}_write(e,t,n){let r=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=e,void(this._cb=n);this._buffer=null;var i=this._queue[0];const t=Math.max(i.start-this._position,0),s=i.end-this._position;if(t>=e.length)return this._position+=e.length,n(null);let o;if(s>e.length){this._position+=e.length,o=0===t?e:e.slice(t),r=i.stream.write(o)&&r;break}this._position+=s,o=0===t&&s===e.length?e:e.slice(t,s),r=i.stream.write(o)&&r,i.last&&i.stream.end(),e=e.slice(s),this._queue.shift()}r?n(null):i.stream.once("drain",n.bind(null,null))}slice(e){if(this.destroyed)return null;Array.isArray(e)||(e=[e]);const t=new Rr;return e.forEach((n,r)=>{this._queue.push({start:n.start,end:n.end,stream:t,last:r===e.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),t}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}},Br={};(function(e){const n=t({});class r{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}Br=class extends d{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=Ir.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const r=i=>{"moov"===i.type?(this._decoder.removeListener("box",r),this._decoder.decode(e=>{n.destroy();try{this._processMoov(e)}catch(fi){fi.message=`Cannot parse mp4 file: ${fi.message}`,this.emit("error",fi)}})):i.length<4096?(t+=i.length,this._decoder.ignore()):(this._decoder.removeListener("box",r),t+=i.length,n.destroy(),this._decoder.destroy(),this._findMoov(e+t))};this._decoder.on("box",r)}_processMoov(t){const i=t.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let e=0;e<i.length;e++){const n=i[e],o=n.mdia.minf.stbl,a=o.stsd.entries[0],h=n.mdia.hdlr.handlerType;let c,u;if("vide"===h&&"avc1"===a.type){if(this._hasVideo)continue;this._hasVideo=!0,c="avc1",a.avcC&&(c+=`.${a.avcC.mimeCodec}`),u=`video/mp4; codecs="${c}"`}else{if("soun"!==h||"mp4a"!==a.type)continue;if(this._hasAudio)continue;this._hasAudio=!0,c="mp4a",a.esds&&a.esds.mimeCodec&&(c+=`.${a.esds.mimeCodec}`),u=`audio/mp4; codecs="${c}"`}const d=[];let l=0,f=0,p=0,g=0,m=0,_=0;const y=new r(o.stts.entries);let b=null;o.ctts&&(b=new r(o.ctts.entries));let w=0;for(;;){var s=o.stsc.entries[m];const e=o.stsz.entries[l],t=y.value.duration,n=b?b.value.compositionOffset:0;let r=!0;o.stss&&(r=o.stss.entries[w]===l+1);const i=o.stco||o.co64;if(d.push({size:e,duration:t,dts:_,presentationOffset:n,sync:r,offset:g+i.entries[p]}),++l>=o.stsz.entries.length)break;if(g+=e,++f>=s.samplesPerChunk){f=0,g=0,p++;const e=o.stsc.entries[m+1];e&&p+1>=e.firstChunk&&m++}_+=t,y.inc(),b&&b.inc(),r&&w++}n.mdia.mdhd.duration=0,n.tkhd.duration=0;const v=s.sampleDescriptionId,E={type:"moov",mvhd:t.mvhd,traks:[{tkhd:n.tkhd,mdia:{mdhd:n.mdia.mdhd,hdlr:n.mdia.hdlr,elng:n.mdia.elng,minf:{vmhd:n.mdia.minf.vmhd,smhd:n.mdia.minf.smhd,dinf:n.mdia.minf.dinf,stbl:{stsd:o.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:t.mvhd.duration},trexs:[{trackId:n.tkhd.trackId,defaultSampleDescriptionIndex:v,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:n.tkhd.trackId,timeScale:n.mdia.mdhd.timeScale,samples:d,currSample:null,currTime:null,moov:E,mime:u})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));t.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const o=n.encode(this._ftyp),a=this._tracks.map(t=>{const r=n.encode(t.moov);return{mime:t.mime,init:e.concat([o,r])}});this.emit("ready",a)}seek(e){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let t=-1;if(this._tracks.map((n,r)=>{n.outStream&&n.outStream.destroy(),n.inStream&&(n.inStream.destroy(),n.inStream=null);const i=n.outStream=Ir.encode(),s=this._generateFragment(r,e);if(!s)return i.finalize();(-1===t||s.ranges[0].start<t)&&(t=s.ranges[0].start);const o=e=>{i.destroyed||i.box(e.moof,t=>{if(t)return this.emit("error",t);i.destroyed||n.inStream.slice(e.ranges).pipe(i.mediaData(e.length,e=>{if(e)return this.emit("error",e);if(i.destroyed)return;const t=this._generateFragment(r);if(!t)return i.finalize();o(t)}))})};o(s)}),t>=0){const e=this._fileStream=this._file.createReadStream({start:t});this._tracks.forEach(n=>{n.inStream=new Lr(t,{highWaterMark:1e7}),e.pipe(n.inStream)})}return this._tracks.map(e=>e.outStream)}_findSampleBefore(e,t){const n=this._tracks[e],r=Math.floor(n.timeScale*t);let i=function(e,t,n,r,i){var s,o;if(void 0===r)r=0;else if((r|=0)<0||r>=e.length)throw new RangeError("invalid lower bound");if(void 0===i)i=e.length-1;else if((i|=0)<r||i>=e.length)throw new RangeError("invalid upper bound");for(;r<=i;)if((o=+n(e[s=r+(i-r>>>1)],t,s,e))<0)r=s+1;else{if(!(o>0))return s;i=s-1}return~r}(n.samples,r,(e,t)=>e.dts+e.presentationOffset-t);for(-1===i?i=0:i<0&&(i=-i-2);!n.samples[i].sync;)i--;return i}_generateFragment(e,t){const n=this._tracks[e];let r;if((r=void 0!==t?this._findSampleBefore(e,t):n.currSample)>=n.samples.length)return null;const i=n.samples[r].dts;let s=0;const o=[];for(var a=r;a<n.samples.length;a++){const e=n.samples[a];if(e.sync&&e.dts-i>=1*n.timeScale)break;s+=e.size;const t=o.length-1;t<0||o[t].end!==e.offset?o.push({start:e.offset,end:e.offset+e.size}):o[t].end+=e.size}return n.currSample=a,{moof:this._generateMoof(e,r,a),ranges:o,length:s}}_generateMoof(e,t,r){const i=this._tracks[e],s=[];let o=0;for(let n=t;n<r;n++){const e=i.samples[n];e.presentationOffset<0&&(o=1),s.push({sampleDuration:e.duration,sampleSize:e.size,sampleFlags:e.sync?33554432:16842752,sampleCompositionTimeOffset:e.presentationOffset})}const a={type:"moof",mfhd:{sequenceNumber:i.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:i.trackId},tfdt:{baseMediaDecodeTime:i.samples[t].dts},trun:{flags:3841,dataOffset:8,entries:s,version:o}}]};return a.trafs[0].trun.dataOffset+=n.encodingLength(a),a}}}).call(this,u({}).Buffer);var Ur={};function Or(e,t,n={}){if(!(this instanceof Or))return console.warn("don't invoked VideoStream without 'new'"),new Or(e,t,n);this.detailedError=null,this._elem=t,this._elemWrapper=new fr(t),this._waitingFired=!1,this._trackMeta=null,this._file=e,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=(()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()}),this._onWaiting=(()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()}),t.autoplay&&(t.preload="auto"),t.addEventListener("waiting",this._onWaiting),t.addEventListener("error",this._onError)}Or.prototype={_createMuxer(){this._muxer=new Br(this._file),this._muxer.on("ready",e=>{this._tracks=e.map(e=>{const t=this._elemWrapper.createWriteStream(e.mime);t.on("error",e=>{this._elemWrapper.error(e)});const n={muxed:null,mediaSource:t,initFlushed:!1,onInitFlushed:null};return t.write(e.init,e=>{n.initFlushed=!0,n.onInitFlushed&&n.onInitFlushed(e)}),n}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",e=>{this._elemWrapper.error(e)})},_pump(){const e=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((t,n)=>{const r=()=>{t.muxed&&(t.muxed.destroy(),t.mediaSource=this._elemWrapper.createWriteStream(t.mediaSource),t.mediaSource.on("error",e=>{this._elemWrapper.error(e)})),t.muxed=e[n],hr(t.muxed,t.mediaSource)};t.initFlushed?r():t.onInitFlushed=(e=>{e?this._elemWrapper.error(e):r()})})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(e=>{e.muxed&&e.muxed.destroy()}),this._elem.src="")}},Ur=Or;var Mr={render:function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),Kr(e),Yr(n),"string"==typeof t&&(t=document.querySelector(t)),Vr(e,function(r){if(t.nodeName!==r.toUpperCase()){var i=et.extname(e.name).toLowerCase();throw new Error('Cannot render "'+i+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+r+'"')}return"video"!==r&&"audio"!==r||Jr(t,n),t},n,r)},append:function(e,t,n,r){if("function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),Kr(e),Yr(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.");function i(e){var n=document.createElement(e);return t.appendChild(n),n}Vr(e,function(e){return"video"===e||"audio"===e?function(e){var r=i(e);return Jr(r,n),t.appendChild(r),r}(e):i(e)},n,function(e,t){e&&t&&t.remove(),r(e,t)})},mime:{".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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},Pr=jt("render-media"),Nr=[".m4a",".m4b",".m4p",".m4v",".mp4"],jr=[".m4v",".mkv",".mp4",".webm"],Hr=[].concat(jr,[".m4a",".m4b",".m4p",".mp3"]),Dr=[".mov",".ogv"],qr=[".aac",".oga",".ogg",".wav",".flac"],Fr=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],Wr=[".css",".html",".js",".md",".pdf",".txt"],zr=2e8,$r="undefined"!=typeof window&&window.MediaSource;function Vr(e,t,n,r){var i,s=et.extname(e.name).toLowerCase(),o=0;function a(){return!("number"==typeof e.length&&e.length>n.maxBlobLength&&(Pr("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),l(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")")),1))}function h(n){a()&&(i=t(n),Gr(e,function(e,t){if(e)return l(e);i.addEventListener("error",l),i.addEventListener("loadstart",c),i.addEventListener("canplay",u),i.src=t}))}function c(){i.removeEventListener("loadstart",c),n.autoplay&&i.play()}function u(){i.removeEventListener("canplay",u),r(null,i)}function d(){Gr(e,function(e,n){if(e)return l(e);".pdf"!==s?((i=t("iframe")).sandbox="allow-forms allow-scripts",i.src=n):((i=t("object")).setAttribute("typemustmatch",!0),i.setAttribute("type","application/pdf"),i.setAttribute("data",n)),r(null,i)})}function l(t){t.message='Error rendering file "'+e.name+'": '+t.message,Pr(t.message),r(t)}Hr.indexOf(s)>=0?function(){var n=jr.indexOf(s)>=0?"video":"audio";function r(){Pr("Use MediaSource API for "+e.name),f(),i.addEventListener("error",d),i.addEventListener("loadstart",c),i.addEventListener("canplay",u);var t,n=new fr(i).createWriteStream((t=e.name,{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4b":'audio/mp4; codecs="mp4a.40.5"',".m4p":'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"'}[et.extname(t).toLowerCase()]));e.createReadStream().pipe(n),o&&(i.currentTime=o)}function h(){Pr("Use Blob URL for "+e.name),f(),i.addEventListener("error",l),i.addEventListener("loadstart",c),i.addEventListener("canplay",u),Gr(e,function(e,t){if(e)return l(e);i.src=t,o&&(i.currentTime=o)})}function d(e){Pr("MediaSource API error: fallback to Blob URL: %o",e.message||e),a()&&(i.removeEventListener("error",d),i.removeEventListener("canplay",u),h())}function f(){i||(i=t(n)).addEventListener("progress",function(){o=i.currentTime})}$r?Nr.indexOf(s)>=0?(Pr("Use `videostream` package for "+e.name),f(),i.addEventListener("error",function e(t){Pr("videostream error: fallback to MediaSource API: %o",t.message||t),i.removeEventListener("error",e),i.removeEventListener("canplay",u),r()}),i.addEventListener("loadstart",c),i.addEventListener("canplay",u),Ur(e,i)):r():h()}():Dr.indexOf(s)>=0?h("video"):qr.indexOf(s)>=0?h("audio"):Fr.indexOf(s)>=0?(i=t("img"),Gr(e,function(t,n){if(t)return l(t);i.src=n,i.alt=e.name,r(null,i)})):Wr.indexOf(s)>=0?d():function(){Pr('Unknown file extension "%s" - will attempt to render into iframe',s);var t="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",function(){dr(t)?(Pr('File extension "%s" appears ascii, so will render.',s),d()):(Pr('File extension "%s" appears non-ascii, will not render.',s),r(new Error('Unsupported file type "'+s+'": Cannot append to DOM')))}).on("error",r)}()}function Gr(e,t){var n=et.extname(e.name).toLowerCase();br(e.createReadStream(),Mr.mime[n]).then(e=>t(null,e),e=>t(e))}function Kr(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 Yr(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=zr)}function Jr(e,t){e.autoplay=!!t.autoplay,e.muted=!!t.muted,e.controls=!!t.controls}var Xr={};(function(e){Xr=function(t,n,r){r=wt(r);var i=e.alloc(n),s=0;t.on("data",function(e){e.copy(i,s),s+=e.length}).on("end",function(){r(null,i)}).on("error",r)}}).call(this,u({}).Buffer);const Zr=jt("webtorrent:file-stream");var Qr=class extends Ze.Readable{constructor(e,t){super(t),this.destroyed=!1,this._torrent=e._torrent;const n=t&&t.start||0,r=t&&t.end&&t.end<e.length?t.end:e.length-1,i=e._torrent.pieceLength;this._startPiece=(n+e.offset)/i|0,this._endPiece=(r+e.offset)/i|0,this._piece=this._startPiece,this._offset=n+e.offset-this._startPiece*i,this._missing=r-n+1,this._reading=!1,this._notifying=!1,this._criticalLength=Math.min(1048576/i|0,2)}_read(){this._reading||(this._reading=!0,this._notify())}_notify(){if(!this._reading||0===this._missing)return;if(!this._torrent.bitfield.get(this._piece))return this._torrent.critical(this._piece,this._piece+this._criticalLength);if(this._notifying)return;if(this._notifying=!0,this._torrent.destroyed)return this._destroy(new Error("Torrent removed"));const e=this._piece;this._torrent.store.get(e,(t,n)=>{if(this._notifying=!1,!this.destroyed){if(Zr("read %s (length %s) (err %s)",e,n.length,t&&t.message),t)return this._destroy(t);this._offset&&(n=n.slice(this._offset),this._offset=0),this._missing<n.length&&(n=n.slice(0,this._missing)),this._missing-=n.length,Zr("pushing buffer of length %s",n.length),this._reading=!1,this.push(n),0===this._missing&&this.push(null)}}),this._piece+=1}destroy(e){this._destroy(null,e)}_destroy(e,t){this.destroyed||(this.destroyed=!0,this._torrent.destroyed||this._torrent.deselect(this._startPiece,this._endPiece,!0),e&&this.emit("error",e),this.emit("close"),t&&t())}},ei={};(function(e){const{EventEmitter:t}=d,{PassThrough:n}=Ze;ei=class extends t{constructor(e,t){super(),this._torrent=e,this._destroyed=!1,this.name=t.name,this.path=t.path,this.length=t.length,this.offset=t.offset,this.done=!1;const n=t.offset,r=n+t.length-1;this._startPiece=n/this._torrent.pieceLength|0,this._endPiece=r/this._torrent.pieceLength|0,0===this.length&&(this.done=!0,this.emit("done"))}get downloaded(){if(!this._torrent.bitfield)return 0;const{pieces:e,bitfield:t,pieceLength:n}=this._torrent,{_startPiece:r,_endPiece:i}=this,s=e[r];let o=t.get(r)?n-this.offset%n:Math.max(s.length-s.missing-this.offset,0);for(let a=r+1;a<=i;++a)if(t.get(a))o+=n;else{const t=e[a];o+=t.length-t.missing}return Math.min(o,this.length)}get progress(){return this.length?this.downloaded/this.length:0}select(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)}deselect(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)}createReadStream(t){if(0===this.length){const t=new n;return e.nextTick(()=>{t.end()}),t}const r=new Qr(this,t);return this._torrent.select(r._startPiece,r._endPiece,!0,()=>{r._notify()}),ar(r,()=>{this._destroyed||this._torrent.destroyed||this._torrent.deselect(r._startPiece,r._endPiece,!0)}),r}getBuffer(e){Xr(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");yr(this.createReadStream(),this._getMimeType()).then(t=>e(null,t),t=>e(t))}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");br(this.createReadStream(),this._getMimeType()).then(t=>e(null,t),t=>e(t))}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");Mr.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");Mr.render(this,e,t,n)}_getMimeType(){return Mr.mime[et.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}}).call(this,ce);var ti=function(e,t){if(!(t>=e.length||t<0)){var n=e.pop();if(t<e.length){var r=e[t];return e[t]=n,r}return n}},ni={};(function(e){const t=jt("bittorrent-protocol"),n=e.from("\x13BitTorrent protocol"),r=e.from([0,0,0,0]),i=e.from([0,0,0,1,0]),s=e.from([0,0,0,1,1]),o=e.from([0,0,0,1,2]),a=e.from([0,0,0,1,3]),h=[0,0,0,0,0,0,0,0],c=[0,0,0,3,9,0,0];class u{constructor(e,t,n,r){this.piece=e,this.offset=t,this.length=n,this.callback=r}}ni=class extends Ze.Duplex{constructor(){super(),this._debugId=In(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=null,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new jn(0,{grow:4e5}),this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=Un(),this.downloadSpeed=Un(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this.on("finish",this._onFinish),this._parseHandshake()}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval),!1!==e&&(this._keepAliveInterval=setInterval(()=>{this.keepAlive()},55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._clearTimeout(),this._timeoutMs=e,this._timeoutUnref=!!t,this._updateTimeout()}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){const t=e.prototype.name;if(!t)throw new Error('Extension class requires a "name" property on the prototype');this._debug("use extension.name=%s",t);const n=this._nextExt,r=new e(this);function i(){}"function"!=typeof r.onHandshake&&(r.onHandshake=i),"function"!=typeof r.onExtendedHandshake&&(r.onExtendedHandshake=i),"function"!=typeof r.onMessage&&(r.onMessage=i),this.extendedMapping[n]=t,this._ext[t]=r,this[t]=r,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(r)}handshake(t,r,i){let s,o;if("string"==typeof t?(t=t.toLowerCase(),s=e.from(t,"hex")):t=(s=t).toString("hex"),"string"==typeof r?o=e.from(r,"hex"):r=(o=r).toString("hex"),20!==s.length||20!==o.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",t,r,i);const a=e.from(h);a[5]|=16,i&&i.dht&&(a[7]|=1),this._push(e.concat([n,a,s,o])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=Object.assign({},this.extendedHandshake);e.m={};for(const t in this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,Z.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(i)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(s))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(o))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(a))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(t){this._debug("bitfield"),e.isBuffer(t)||(t=t.buffer),this._message(5,[],t)}request(e,t,n,r){return r||(r=(()=>{})),this._finished?r(new Error("wire is closed")):this.peerChoking?r(new Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new u(e,t,n,r)),this._updateTimeout(),void this._message(6,[e,t,n],null))}piece(e,t,n){this._debug("piece index=%d offset=%d",e,t),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(t){this._debug("port %d",t);const n=e.from(c);n.writeUInt16BE(t,5),this._push(n)}extended(t,n){if(this._debug("extended ext=%s",t),"string"==typeof t&&this.peerExtendedMapping[t]&&(t=this.peerExtendedMapping[t]),"number"!=typeof t)throw new Error(`Unrecognized extension: ${t}`);{const r=e.from([t]),i=e.isBuffer(n)?n:Z.encode(n);this._message(20,[],e.concat([r,i]))}}_read(){}_message(t,n,r){const i=r?r.length:0,s=e.allocUnsafe(5+4*n.length);s.writeUInt32BE(s.length+i-4,0),s[4]=t;for(let e=0;e<n.length;e++)s.writeUInt32BE(n[e],5+4*e);this._push(s),r&&this._push(r)}_push(e){if(!this._finished)return this.push(e)}_onKeepAlive(){this._debug("got keep-alive"),this.emit("keep-alive")}_onHandshake(e,t,n){const r=e.toString("hex"),i=t.toString("hex");let s;for(s in this._debug("got handshake i=%s p=%s exts=%o",r,i,n),this.peerId=i,this.peerIdBuffer=t,this.peerExtensions=n,this.emit("handshake",r,i,n),this._ext)this._ext[s].onHandshake(r,i,n);n.extended&&this._handshakeSent&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_onChoke(){for(this.peerChoking=!0,this._debug("got choke"),this.emit("choke");this.requests.length;)this._callback(this.requests.pop(),new Error("peer is choking"),null)}_onUnchoke(){this.peerChoking=!1,this._debug("got unchoke"),this.emit("unchoke")}_onInterested(){this.peerInterested=!0,this._debug("got interested"),this.emit("interested")}_onUninterested(){this.peerInterested=!1,this._debug("got uninterested"),this.emit("uninterested")}_onHave(e){this.peerPieces.get(e)||(this._debug("got have %d",e),this.peerPieces.set(e,!0),this.emit("have",e))}_onBitField(e){this.peerPieces=new jn(e),this._debug("got bitfield"),this.emit("bitfield",this.peerPieces)}_onRequest(e,t,n){if(this.amChoking)return;this._debug("got request index=%d offset=%d length=%d",e,t,n);const r=(r,s)=>{if(i===this._pull(this.peerRequests,e,t,n))return r?this._debug("error satisfying request index=%d offset=%d length=%d (%s)",e,t,n,r.message):void this.piece(e,t,s)};var i=new u(e,t,n,r);this.peerRequests.push(i),this.emit("request",e,t,n,r)}_onPiece(e,t,n){this._debug("got piece index=%d offset=%d",e,t),this._callback(this._pull(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)}_onCancel(e,t,n){this._debug("got cancel index=%d offset=%d length=%d",e,t,n),this._pull(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)}_onPort(e){this._debug("got port %d",e),this.emit("port",e)}_onExtended(e,t){if(0===e){let e,n;try{e=Z.decode(t)}catch(fi){this._debug("ignoring invalid extended handshake: %s",fi.message||fi)}if(!e)return;if(this.peerExtendedHandshake=e,"object"==typeof e.m)for(n in e.m)this.peerExtendedMapping[n]=Number(e.m[n].toString());for(n in this._ext)this.peerExtendedMapping[n]&&this._ext[n].onExtendedHandshake(this.peerExtendedHandshake);this._debug("got extended handshake"),this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this._debug("got extended message ext=%s",e),this.emit("extended",e,t)}_onTimeout(){this._debug("request timed out"),this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")}_write(t,n,r){for(this._bufferSize+=t.length,this._buffer.push(t);this._bufferSize>=this._parserSize;){const t=1===this._buffer.length?this._buffer[0]:e.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[t.slice(this._parserSize)]:[],this._parser(t.slice(0,this._parserSize))}r(null)}_callback(e,t,n){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,n))}_clearTimeout(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)}_updateTimeout(){this._timeoutMs&&this.requests.length&&!this._timeout&&(this._timeout=setTimeout(()=>this._onTimeout(),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref())}_parse(e,t){this._parserSize=e,this._parser=t}_onMessageLength(e){const t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(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)}}_parseHandshake(){this._parse(1,e=>{const t=e.readUInt8(0);this._parse(t+48,e=>{const n=e.slice(0,t);if("BitTorrent protocol"!==n.toString())return this._debug("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void this.end();e=e.slice(t),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),this._parse(4,this._onMessageLength)})})}_onFinish(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,()=>{});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)}_debug(...e){e[0]=`[${this._debugId}] ${e[0]}`,t(...e)}_pull(e,t,n,r){for(let i=0;i<e.length;i++){const s=e[i];if(s.piece===t&&s.offset===n&&s.length===r)return ti(e,i),s}return null}}}).call(this,u({}).Buffer);var ri="0.107.10",ii={};(function(e){const t=jt("webtorrent:webconn"),n=ri;ii=class extends ni{constructor(e,t){super(),this.url=e,this.webPeerId=Lt.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.once("handshake",(e,t)=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const n=this._torrent.pieces.length,r=new jn(n);for(let i=0;i<=n;i++)r.set(i,!0);this.bitfield(r)}),this.once("interested",()=>{t("interested"),this.unchoke()}),this.on("uninterested",()=>{t("uninterested")}),this.on("choke",()=>{t("choke")}),this.on("unchoke",()=>{t("unchoke")}),this.on("bitfield",()=>{t("bitfield")}),this.on("request",(e,n,r,i)=>{t("request pieceIndex=%d offset=%d length=%d",e,n,r),this.httpRequest(e,n,r,i)})}httpRequest(r,i,s,o){const a=r*this._torrent.pieceLength+i,h=a+s-1,c=this._torrent.files;let u;if(c.length<=1)u=[{url:this.url,start:a,end:h}];else{const e=c.filter(e=>e.offset<=h&&e.offset+e.length>a);if(e.length<1)return o(new Error("Could not find file corresponnding to web seed range request"));u=e.map(e=>{const t=e.offset+e.length-1;return{url:this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path,fileOffsetInRange:Math.max(e.offset-a,0),start:Math.max(a-e.offset,0),end:Math.min(t,h-e.offset)}})}let d,l=0,f=!1;u.length>1&&(d=e.alloc(s)),u.forEach(e=>{const a=e.url,h=e.start,c=e.end;t("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",a,r,i,s,h,c);const p={url:a,method:"GET",headers:{"user-agent":`WebTorrent/${n} (https://webtorrent.io)`,range:`bytes=${h}-${c}`}};function g(n,r){if(n.statusCode<200||n.statusCode>=300)return f=!0,o(new Error(`Unexpected HTTP status code ${n.statusCode}`));t("Got data of length %d",r.length),1===u.length?o(null,r):(r.copy(d,e.fileOffsetInRange),++l===u.length&&o(null,d))}vn.concat(p,(e,t,n)=>{if(!f)return e?"undefined"==typeof window||a.startsWith(`${window.location.origin}/`)?(f=!0,o(e)):vn.head(a,(t,n)=>{if(!f){if(t)return f=!0,o(t);if(n.statusCode<200||n.statusCode>=300)return f=!0,o(new Error(`Unexpected HTTP status code ${n.statusCode}`));if(n.url===a)return f=!0,o(e);p.url=n.url,vn.concat(p,(e,t,n)=>{if(!f)return e?(f=!0,o(e)):void g(t,n)})}}):void g(t,n)})})}destroy(){super.destroy(),this._torrent=null}}}).call(this,u({}).Buffer);var si={};const oi=jt("webtorrent:peer"),ai=5e3,hi=25e3,ci=25e3;si.createWebRTCPeer=((e,t)=>{const n=new ui(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",()=>{n.onConnect()}),n.conn.once("error",e=>{n.destroy(e)}),n.startConnectTimeout()),n}),si.createTCPOutgoingPeer=((e,t)=>{const n=new ui(e,"tcpOutgoing");return n.addr=e,n.swarm=t,n}),si.createWebSeedPeer=((e,t)=>{const n=new ui(e,"webSeed");return n.swarm=t,n.conn=new ii(e,t),n.onConnect(),n});class ui{constructor(e,t){this.id=e,this.type=t,oi("new %s Peer %s",t,e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}onConnect(){if(this.destroyed)return;this.connected=!0,oi("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",()=>{this.destroy()}),e.once("close",()=>{this.destroy()}),e.once("finish",()=>{this.destroy()}),e.once("error",e=>{this.destroy(e)});const t=this.wire=new ni;t.type=this.type,t.once("end",()=>{this.destroy()}),t.once("close",()=>{this.destroy()}),t.once("finish",()=>{this.destroy()}),t.once("error",e=>{this.destroy(e)}),t.once("handshake",(e,t)=>{this.onHandshake(e,t)}),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));oi("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout),this.connectTimeout=setTimeout(()=>{this.destroy(new Error("connect timeout"))},"webrtc"===this.type?hi:ai),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout(()=>{this.destroy(new Error("handshake timeout"))},ci),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,oi("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,r=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&r&&ti(t.wires,t.wires.indexOf(r)),n&&(n.on("error",()=>{}),n.destroy()),r&&r.destroy(),t&&t.removePeer(this.id)}}var di={};(function(e,t){const n=jt("webtorrent:torrent"),r=d.EventEmitter,i=3*ir.BLOCK_LENGTH,s=e.browser?1/0:2,o=[1e3,5e3,15e3],a=`WebTorrent/${ri} (https://webtorrent.io)`;let h;try{h=et.join(ut.statSync("/tmp")&&"/tmp","webtorrent")}catch(fi){h=et.join("function"==typeof te.tmpdir?te.tmpdir():"/","webtorrent")}function c(e,t){return 2+Math.ceil(t*e.downloadSpeed()/ir.BLOCK_LENGTH)}function u(){}di=class extends r{constructor(e,t,n){super(),this._debugId="unknown infohash",this.client=t,this.announce=n.announce,this.urlList=n.urlList,this.path=n.path,this.skipVerify=!!n.skipVerify,this._store=n.store||tr,this._getAnnounceOpts=n.getAnnounceOpts,this.strategy=n.strategy||"sequential",this.maxWebConns=n.maxWebConns||4,this._rechokeNumSlots=!1===n.uploads||0===n.uploads?0:+n.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=Un(),this._uploadSpeed=Un(),this._servers=[],this._xsRequests=[],this._fileModtimes=n.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}get timeRemaining(){return this.done?0:0===this.downloadSpeed?1/0:(this.length-this.downloaded)/this.downloadSpeed*1e3}get downloaded(){if(!this.bitfield)return 0;let e=0;for(let t=0,n=this.pieces.length;t<n;++t)if(this.bitfield.get(t))e+=t===n-1?this.lastPieceLength:this.pieceLength;else{const n=this.pieces[t];e+=n.length-n.missing}return e}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){return this.length?this.downloaded/this.length:0}get ratio(){return this.uploaded/(this.received||1)}get numPeers(){return this.wires.length}get torrentFileBlobURL(){if("undefined"==typeof window)throw new Error("browser-only property");return this.torrentFile?URL.createObjectURL(new Blob([this.torrentFile],{type:"application/x-bittorrent"})):null}get _numQueued(){return this._queue.length+(this._peersLength-this._numConns)}get _numConns(){let e=0;for(const t in this._peers)this._peers[t].connected&&(e+=1);return e}get swarm(){return console.warn("WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead."),this}_onTorrentId(t){if(this.destroyed)return;let n;try{n=xn(t)}catch(fi){}n?(this.infoHash=n.infoHash,this._debugId=n.infoHash.toString("hex").substring(0,7),e.nextTick(()=>{this.destroyed||this._onParsedTorrent(n)})):xn.remote(t,(e,t)=>{if(!this.destroyed)return e?this._destroy(e):void this._onParsedTorrent(t)})}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));this.path||(this.path=et.join(h,this.infoHash)),this._rechokeIntervalId=setInterval(()=>{this._rechoke()},1e4),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),this.destroyed||(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",()=>{this._onListening()})))}}_processParsedTorrent(e){this._debugId=e.infoHash.toString("hex").substring(0,7),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&t.WEBTORRENT_ANNOUNCE&&!this.private&&(e.announce=e.announce.concat(t.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),Sn(e.announce),Sn(e.urlList),Object.assign(this,e),this.magnetURI=xn.toMagnetURI(e),this.torrentFile=xn.toTorrentFile(e)}_onListening(){this.destroyed||(this.info?this._onMetadata(this):(this.xs&&this._getMetadataFromServer(),this._startDiscovery()))}_startDiscovery(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{const e={uploaded:this.uploaded,downloaded:this.downloaded,left:Math.max(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.discovery=new er({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:a}),this.discovery.on("error",e=>{this._destroy(e)}),this.discovery.on("peer",e=>{"string"==typeof e&&this.done||this.addPeer(e)}),this.discovery.on("trackerAnnounce",()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")}),this.discovery.on("dhtAnnounce",()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")}),this.discovery.on("warning",e=>{this.emit("warning",e)})}_getMetadataFromServer(){const e=this,t=(Array.isArray(this.xs)?this.xs:[this.xs]).map(t=>n=>{!function(t,n){if(0!==t.indexOf("http://")&&0!==t.indexOf("https://"))return e.emit("warning",new Error(`skipping non-http xs param: ${t}`)),n(null);const r={url:t,method:"GET",headers:{"user-agent":a}};let i;try{i=vn.concat(r,function(r,i,s){if(e.destroyed)return n(null);if(e.metadata)return n(null);if(r)return e.emit("warning",new Error(`http error from xs param: ${t}`)),n(null);if(200!==i.statusCode)return e.emit("warning",new Error(`non-200 status code ${i.statusCode} from xs param: ${t}`)),n(null);let o;try{o=xn(s)}catch(r){}return o?o.infoHash!==e.infoHash?(e.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${t}`)),n(null)):(e._onMetadata(o),void n(null)):(e.emit("warning",new Error(`got invalid torrent file from xs param: ${t}`)),n(null))})}catch(fi){return e.emit("warning",new Error(`skipping invalid url xs param: ${t}`)),n(null)}e._xsRequests.push(i)}(t,n)});kt(t)}_onMetadata(e){if(this.metadata||this.destroyed)return;let t;if(this._debug("got metadata"),this._xsRequests.forEach(e=>{e.abort()}),this._xsRequests=[],e&&e.infoHash)t=e;else try{t=xn(e)}catch(fi){return this._destroy(fi)}if(this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(e=>{this.addWebSeed(e)}),this._rarityMap=new class{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=new Array(this._numPieces),this._onWire=(e=>{this.recalculate(),this._initWire(e)}),this._onWireHave=(e=>{this._pieces[e]+=1}),this._onWireBitfield=(()=>{this.recalculate()}),this._torrent.wires.forEach(e=>{this._initWire(e)}),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let r=0;r<this._numPieces;++r){if(e&&!e(r))continue;const i=this._pieces[r];i===n?t.push(r):i<n&&(t=[r],n=i)}return t.length?t[Math.random()*t.length|0]:-1}destroy(){this._torrent.removeListener("wire",this._onWire),this._torrent.wires.forEach(e=>{this._cleanupWireEvents(e)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=(()=>{this._cleanupWireEvents(e);for(let t=0;t<this._numPieces;++t)this._pieces[t]-=e.peerPieces.get(t)}),e.on("have",this._onWireHave),e.on("bitfield",this._onWireBitfield),e.once("close",e._onClose)}recalculate(){this._pieces.fill(0);for(const e of this._torrent.wires)for(let t=0;t<this._numPieces;++t)this._pieces[t]+=e.peerPieces.get(t)}_cleanupWireEvents(e){e.removeListener("have",this._onWireHave),e.removeListener("bitfield",this._onWireBitfield),e._onClose&&e.removeListener("close",e._onClose),e._onClose=null}}(this),this.store=new nr(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map(e=>({path:et.join(this.path,e.path),length:e.length,offset:e.offset})),length:this.length,name:this.infoHash})),this.files=this.files.map(e=>new ei(this,e)),this.so){const e=ur.parse(this.so);this.files.forEach((t,n)=>{e.includes(n)&&this.files[n].select(!0)})}else 0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1);if(this._hashes=this.pieces,this.pieces=this.pieces.map((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new ir(n)}),this._reservations=this.pieces.map(()=>[]),this.bitfield=new jn(this.pieces.length),this.wires.forEach(e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)}),this.emit("metadata"),!this.destroyed)if(this.skipVerify)this._markAllVerified(),this._onStore();else{const e=e=>{if(e)return this._destroy(e);this._debug("done verifying"),this._onStore()};this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===tr?this.getFileModtimes((t,n)=>{if(t)return this._destroy(t);this.files.map((e,t)=>n[t]===this._fileModtimes[t]).every(e=>e)?(this._markAllVerified(),this._onStore()):this._verifyPieces(e)}):this._verifyPieces(e)}}getFileModtimes(e){const t=[];rr(this.files.map((e,n)=>r=>{ut.stat(et.join(this.path,e.path),(e,i)=>{if(e&&"ENOENT"!==e.code)return r(e);t[n]=i&&i.mtime.getTime(),r(null)})}),s,n=>{this._debug("done getting file modtimes"),e(n,t)})}_verifyPieces(t){rr(this.pieces.map((t,n)=>t=>{if(this.destroyed)return t(new Error("torrent is destroyed"));this.store.get(n,(r,i)=>this.destroyed?t(new Error("torrent is destroyed")):r?e.nextTick(t,null):void Lt(i,e=>{if(this.destroyed)return t(new Error("torrent is destroyed"));if(e===this._hashes[n]){if(!this.pieces[n])return t(null);this._debug("piece verified %s",n),this._markVerified(n)}else this._debug("piece invalid %s",n);t(null)}))}),s,t)}rescanFiles(e){if(this.destroyed)throw new Error("torrent is destroyed");e||(e=u),this._verifyPieces(t=>{if(t)return this._destroy(t),e(t);this._checkDone(),e(null)})}_markAllVerified(){for(let e=0;e<this.pieces.length;e++)this._markVerified(e)}_markVerified(e){this.pieces[e]=null,this._reservations[e]=null,this.bitfield.set(e,!0)}_onStore(){this.destroyed||(this._debug("on store"),this._startDiscovery(),this.ready=!0,this.emit("ready"),this._checkDone(),this._updateSelections())}destroy(e){this._destroy(null,e)}_destroy(e,t){if(this.destroyed)return;this.destroyed=!0,this._debug("destroy"),this.client._remove(this),clearInterval(this._rechokeIntervalId),this._xsRequests.forEach(e=>{e.abort()}),this._rarityMap&&this._rarityMap.destroy();for(const r in this._peers)this.removePeer(r);this.files.forEach(e=>{e instanceof ei&&e._destroy()});const n=this._servers.map(e=>t=>{e.destroy(t)});this.discovery&&n.push(e=>{this.discovery.destroy(e)}),this.store&&n.push(e=>{this.store.close(e)}),kt(n,t),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}addPeer(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let t;if("string"==typeof e){let r;try{r=On(e)}catch(n){return this._debug("ignoring peer: invalid %s",e),this.emit("invalidPeer",e),!1}t=r[0]}else"string"==typeof e.remoteAddress&&(t=e.remoteAddress);if(t&&this.client.blocked.contains(t))return this._debug("ignoring peer: blocked %s",e),"string"!=typeof e&&e.destroy(),this.emit("blockedPeer",e),!1}const t=!!this._addPeer(e);return t?this.emit("peer",e):this.emit("invalidPeer",e),t}_addPeer(e){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;const t=e&&e.id||e;if(this._peers[t])return this._debug("ignoring peer: duplicate (%s)",t),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;let n;return this._debug("add peer %s",t),n="string"==typeof e?si.createTCPOutgoingPeer(e,this):si.createWebRTCPeer(e,this),this._peers[n.id]=n,this._peersLength+=1,"string"==typeof e&&(this._queue.push(n),this._drain()),n}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=si.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,void(this._peersLength+=1))}removePeer(e){const t=e&&e.id||e;(e=this._peers[t])&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,r){if(this.destroyed)throw new Error("torrent is destroyed");if(e<0||t<e||this.pieces.length<=t)throw new Error(`invalid selection ${e} : ${t}`);n=Number(n)||0,this._debug("select %s-%s (priority %s)",e,t,n),this._selections.push({from:e,to:t,offset:0,priority:n,notify:r||u}),this._selections.sort((e,t)=>t.priority-e.priority),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=Number(n)||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let r=0;r<this._selections.length;++r){const i=this._selections[r];if(i.from===e&&i.to===t&&i.priority===n){this._selections.splice(r,1);break}}this._updateSelections()}critical(e,t){if(this.destroyed)throw new Error("torrent is destroyed");this._debug("critical %s-%s",e,t);for(let n=e;n<=t;++n)this._critical[n]=!0;this._updateSelections()}_onWire(t,n){if(this._debug("got wire %s (%s)",t._debugId,n||"Unknown"),t.on("download",e=>{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.client.emit("download",e))}),t.on("upload",e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.client.emit("upload",e))}),this.wires.push(t),n){const e=On(n);t.remoteAddress=e[0],t.remotePort=e[1]}this.client.dht&&this.client.dht.listening&&t.on("port",e=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!t.remoteAddress)return this._debug("ignoring PORT from peer with no address");if(0===e||e>65536)return this._debug("ignoring invalid PORT from peer");this._debug("port: %s (from %s)",e,n),this.client.dht.addNode({host:t.remoteAddress,port:e})}}),t.on("timeout",()=>{this._debug("wire timeout (%s)",n),t.destroy()}),t.setTimeout(3e4,!0),t.setKeepAlive(!0),t.use(cr(this.metadata)),t.ut_metadata.on("warning",e=>{this._debug("ut_metadata warning: %s",e.message)}),this.metadata||(t.ut_metadata.on("metadata",e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)}),t.ut_metadata.fetch()),"function"!=typeof te||this.private||(t.use(te()),t.ut_pex.on("peer",e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,n),this.addPeer(e))}),t.ut_pex.on("dropped",e=>{const t=this._peers[e];t&&!t.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,n),this.removePeer(e))}),t.once("close",()=>{t.ut_pex.reset()})),this.emit("wire",t,n),this.metadata&&e.nextTick(()=>{this._onWireWithMetadata(t)})}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,5e3)).unref&&t.unref())};let r;const i=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(r=0;r<this.pieces.length;++r)if(!e.peerPieces.get(r))return;e.isSeeder=!0,e.choke()}};e.on("bitfield",()=>{i(),this._update()}),e.on("have",()=>{i(),this._update()}),e.once("interested",()=>{e.unchoke()}),e.once("close",()=>{clearTimeout(t)}),e.on("choke",()=>{clearTimeout(t),(t=setTimeout(n,5e3)).unref&&t.unref()}),e.on("unchoke",()=>{clearTimeout(t),this._update()}),e.on("request",(t,n,r,i)=>{if(r>131072)return e.destroy();this.pieces[t]||this.store.get(t,{offset:n,length:r},i)}),e.bitfield(this.bitfield),e.uninterested(),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,5e3)).unref&&t.unref(),e.isSeeder=!1,i()}_updateSelections(){this.ready&&!this.destroyed&&(e.nextTick(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;e<this._selections.length;++e){const t=this._selections[e],n=t.offset;for(;this.bitfield.get(t.from+t.offset)&&t.from+t.offset<t.to;)t.offset+=1;n!==t.offset&&t.notify(),t.to===t.from+t.offset&&this.bitfield.get(t.from+t.offset)&&(this._selections.splice(e,1),e-=1,t.notify(),this._updateInterest())}this._selections.length||this.emit("idle")}_updateInterest(){const e=this._amInterested;this._amInterested=!!this._selections.length,this.wires.forEach(e=>{let t=!1;for(let n=0;n<this.pieces.length;++n)if(this.pieces[n]&&e.peerPieces.get(n)){t=!0;break}t?e.interested():e.uninterested()}),e!==this._amInterested&&(this._amInterested?this.emit("interested"):this.emit("uninterested"))}_update(){if(this.destroyed)return;const e=(t=this.wires,n=0,function(){if(n===t.length)return null;var e=t.length-n,r=Math.random()*e|0,i=t[n+r],s=t[n];return t[n]=i,t[n+r]=s,n++,i});var t,n;let r;for(;r=e();)this._updateWireWrapper(r)}_updateWireWrapper(e){const t=this;"undefined"!=typeof window&&"function"==typeof window.requestIdleCallback?window.requestIdleCallback(function(){t._updateWire(e)}):t._updateWire(e)}_updateWire(e){const t=this;if(e.peerChoking)return;if(!e.downloaded)return function(){if(e.requests.length)return;let n=t._selections.length;for(;n--;){const r=t._selections[n];let i;if("rarest"===t.strategy){const n=r.from+r.offset,o=r.to,a=o-n+1,h={};let c=0;const u=s(n,o,h);for(;c<a&&!((i=t._rarityMap.getRarestPiece(u))<0);){if(t._request(e,i,!1))return;h[i]=!0,c+=1}}else for(i=r.to;i>=r.from+r.offset;--i)if(e.peerPieces.get(i)&&t._request(e,i,!1))return}}();const n=c(e,.5);if(e.requests.length>=n)return;const r=c(e,1);function s(t,n,r,i){return s=>s>=t&&s<=n&&!(s in r)&&e.peerPieces.get(s)&&(!i||i(s))}function o(e){let n=e;for(let i=e;i<t._selections.length&&t._selections[i].priority;i++)n=i;const r=t._selections[e];t._selections[e]=t._selections[n],t._selections[n]=r}function a(n){if(e.requests.length>=r)return!0;const a=function(){const n=e.downloadSpeed()||1;if(n>i)return()=>!0;const r=Math.max(1,e.requests.length)*ir.BLOCK_LENGTH/n;let s=10,o=0;return e=>{if(!s||t.bitfield.get(e))return!0;let a=t.pieces[e].missing;for(;o<t.wires.length;o++){const h=t.wires[o],c=h.downloadSpeed();if(!(c<i)&&!(c<=n)&&h.peerPieces.get(e)&&!((a-=c*r)>0))return s--,!1}return!0}}();for(let i=0;i<t._selections.length;i++){const h=t._selections[i];let c;if("rarest"===t.strategy){const u=h.from+h.offset,d=h.to,l=d-u+1,f={};let p=0;const g=s(u,d,f,a);for(;p<l&&!((c=t._rarityMap.getRarestPiece(g))<0);){for(;t._request(e,c,t._critical[c]||n););if(!(e.requests.length<r))return h.priority&&o(i),!0;f[c]=!0,p++}}else for(c=h.from+h.offset;c<=h.to;c++)if(e.peerPieces.get(c)&&a(c)){for(;t._request(e,c,t._critical[c]||n););if(!(e.requests.length<r))return h.priority&&o(i),!0}}return!1}a(!1)||a(!0)}_rechoke(){if(!this.ready)return;this._rechokeOptimisticTime>0?this._rechokeOptimisticTime-=1:this._rechokeOptimisticWire=null;const e=[];this.wires.forEach(t=>{t.isSeeder||t===this._rechokeOptimisticWire||e.push({wire:t,downloadSpeed:t.downloadSpeed(),uploadSpeed:t.uploadSpeed(),salt:Math.random(),isChoked:!0})}),e.sort(function(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});let t=0,n=0;for(;n<e.length&&t<this._rechokeNumSlots;++n)e[n].isChoked=!1,e[n].wire.peerInterested&&(t+=1);if(!this._rechokeOptimisticWire&&n<e.length&&this._rechokeNumSlots){const t=e.slice(n).filter(e=>e.wire.peerInterested),i=t[(r=t.length,Math.random()*r|0)];i&&(i.isChoked=!1,this._rechokeOptimisticWire=i.wire,this._rechokeOptimisticTime=2)}var r;e.forEach(e=>{e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})}_hotswap(e,t){const n=e.downloadSpeed();if(n<ir.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const r=this._reservations[t];if(!r)return!1;let s,o,a=1/0;for(o=0;o<r.length;o++){const t=r[o];if(!t||t===e)continue;const h=t.downloadSpeed();h>=i||2*h>n||h>a||(s=t,a=h)}if(!s)return!1;for(o=0;o<r.length;o++)r[o]===s&&(r[o]=null);for(o=0;o<s.requests.length;o++){const e=s.requests[o];e.piece===t&&this.pieces[t].cancel(e.offset/ir.BLOCK_LENGTH|0)}return this.emit("hotswap",s,e,t),!0}_request(t,n,r){const i=this,s=t.requests.length,o="webSeed"===t.type;if(i.bitfield.get(n))return!1;if(s>=(o?Math.min(function(e,t,n){return 1+Math.ceil(1*e.downloadSpeed()/n)}(t,0,i.pieceLength),i.maxWebConns):c(t,1)))return!1;const a=i.pieces[n];let h=o?a.reserveRemaining():a.reserve();if(-1===h&&r&&i._hotswap(t,n)&&(h=o?a.reserveRemaining():a.reserve()),-1===h)return!1;let u=i._reservations[n];u||(u=i._reservations[n]=[]);let d=u.indexOf(null);-1===d&&(d=u.length),u[d]=t;const l=a.chunkOffset(h),f=o?a.chunkLengthRemaining(h):a.chunkLength(h);function p(){e.nextTick(()=>{i._update()})}return t.request(n,l,f,function e(r,s){if(i.destroyed)return;if(!i.ready)return i.once("ready",()=>{e(r,s)});if(u[d]===t&&(u[d]=null),a!==i.pieces[n])return p();if(r)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",n,l,f,`${t.remoteAddress}:${t.remotePort}`,r.message),o?a.cancelRemaining(h):a.cancel(h),void p();if(i._debug("got piece %s (offset: %s length: %s) from %s",n,l,f,`${t.remoteAddress}:${t.remotePort}`),!a.set(h,s,t))return p();const c=a.flush();Lt(c,e=>{if(!i.destroyed){if(e===i._hashes[n]){if(!i.pieces[n])return;i._debug("piece verified %s",n),i.pieces[n]=null,i._reservations[n]=null,i.bitfield.set(n,!0),i.store.put(n,c),i.wires.forEach(e=>{e.have(n)}),i._checkDone()&&!i.destroyed&&i.discovery.complete()}else i.pieces[n]=new ir(a.length),i.emit("warning",new Error(`Piece ${n} failed verification`));p()}})}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}});let e=!0;for(let t=0;t<this._selections.length;t++){const n=this._selections[t];for(let t=n.from;t<=n.to;t++)if(!this.bitfield.get(t)){e=!1;break}if(!e)break}return!this.done&&e&&(this.done=!0,this._debug(`torrent done: ${this.infoHash}`),this.emit("done")),this._gcSelections(),e}load(e,t){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.ready)return this.once("ready",()=>{this.load(e,t)});Array.isArray(e)||(e=[e]),t||(t=u);const n=new pt(e),r=new Dn(this.store,this.pieceLength);hr(n,r,e=>{if(e)return t(e);this._markAllVerified(),this._checkDone(),t(null)})}createServer(e){if("function"!=typeof te)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new te(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client._debugId}] [${this._debugId}] ${e[0]}`,n(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof te.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("tcp connect attempt to %s",e.addr);const t=On(e.addr),n={host:t[0],port:t[1]},r=e.conn=te.connect(n);r.once("connect",()=>{e.onConnect()}),r.once("error",t=>{e.destroy(t)}),e.startConnectTimeout(),r.on("close",()=>{if(this.destroyed)return;if(e.retries>=o.length)return void this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,o.length);const t=o[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout(()=>{const t=this._addPeer(e.addr);t&&(t.retries=e.retries+1)},t);n.unref&&n.unref()})}_validAddr(e){let t;try{t=On(e)}catch(i){return!1}const n=t[0],r=t[1];return r>0&&r<65535&&!("127.0.0.1"===n&&r===this.client.torrentPort)}}}).call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var li={};return function(e,t,n){const{EventEmitter:r}=d,i=jt("webtorrent"),s=ri,o=s.replace(/\d*./g,e=>`0${e%100}`.slice(-2)).slice(0,4),a=`-WW${o}-`;class h extends r{constructor(r={}){super(),"string"==typeof r.peerId?this.peerId=r.peerId:n.isBuffer(r.peerId)?this.peerId=r.peerId.toString("hex"):this.peerId=n.from(a+In(9).toString("base64")).toString("hex"),this.peerIdBuffer=n.from(this.peerId,"hex"),"string"==typeof r.nodeId?this.nodeId=r.nodeId:n.isBuffer(r.nodeId)?this.nodeId=r.nodeId.toString("hex"):this.nodeId=In(20).toString("hex"),this.nodeIdBuffer=n.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=r.torrentPort||0,this.dhtPort=r.dhtPort||0,this.tracker=void 0!==r.tracker?r.tracker:{},this.torrents=[],this.maxConns=Number(r.maxConns)||55,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),r.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=r.rtcConfig),r.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=r.wrtc),t.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=t.WRTC)),"function"==typeof te?this._tcpPool=new te(this):e.nextTick(()=>{this._onListening()}),this._downloadSpeed=Un(),this._uploadSpeed=Un(),!1!==r.dht&&"function"==typeof te?(this.dht=new te(Object.assign({},{nodeId:this.nodeId},r.dht)),this.dht.once("error",e=>{this._destroy(e)}),this.dht.once("listening",()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==r.webSeeds;const i=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof te&&null!=r.blocklist?te(r.blocklist,{headers:{"user-agent":`WebTorrent/${s} (https://webtorrent.io)`}},(e,t)=>{if(e)return this.error(`Failed to load blocklist: ${e.message}`);this.blocked=t,i()}):e.nextTick(i)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter(e=>1!==e.progress);return e.reduce((e,t)=>e+t.downloaded,0)/(e.reduce((e,t)=>e+(t.length||0),0)||1)}get ratio(){return this.torrents.reduce((e,t)=>e+t.uploaded,0)/(this.torrents.reduce((e,t)=>e+t.received,0)||1)}get(e){if(e instanceof di){if(this.torrents.includes(e))return e}else{let t;try{t=xn(e)}catch(fi){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const r=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===s.infoHash&&e!==s)return void s._destroy(new Error(`Cannot add duplicate torrent ${s.infoHash}`))},i=()=>{this.destroyed||("function"==typeof n&&n(s),this.emit("torrent",s))};this._debug("add"),t=t?Object.assign({},t):{};const s=new di(e,this,t);return this.torrents.push(s),s.once("_infoHash",r),s.once("ready",i),s.once("close",function e(){s.removeListener("_infoHash",r),s.removeListener("ready",i),s.removeListener("close",e)}),s}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const r="string"==typeof e;r&&(t.path=et.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${o}`);const i=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},s=this.add(null,t,e=>{const t=[t=>{if(r)return t();e.load(a,t)}];this.dht&&t.push(t=>{e.once("dhtAnnounce",t)}),kt(t,t=>{if(!this.destroyed)return t?e._destroy(t):void i(e)})});let a;return"undefined"!=typeof FileList&&e instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),kt(e.map(e=>t=>{!function(t){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}()?t(null,e):P(e,t)}),(e,n)=>{if(!this.destroyed)return e?s._destroy(e):void Nt.parseInput(n,t,(e,r)=>{if(!this.destroyed){if(e)return s._destroy(e);a=r.map(e=>e.getStream),Nt(n,t,(e,t)=>{if(this.destroyed)return;if(e)return s._destroy(e);const n=this.get(t);n?s._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):s._onTorrentId(t)})}})}),s}remove(e,t){if(this._debug("remove"),!this.get(e))throw new Error(`No torrent with id ${e}`);this._remove(e,t)}_remove(e,t){const n=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))}address(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map(e=>t=>{e.destroy(t)});this._tcpPool&&n.push(e=>{this._tcpPool.destroy(e)}),this.dht&&n.push(e=>{this.dht.destroy(e)}),kt(n,t),e&&this.emit("error",e),this.torrents=[],this._tcpPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._tcpPool){const e=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,i(...e)}}h.WEBRTC_SUPPORT=An.WEBRTC_SUPPORT,h.VERSION=s,li=h}.call(this,ce,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u({}).Buffer),li}); \ No newline at end of file