[
  {
    "path": ".airtap.yml",
    "content": "browsers:\n  - name: chrome\n    version: latest\n  - name: firefox\n    version: latest\n  # https://github.com/airtap/sauce/issues/11\n  # - name: safari\n  #   version: latest\n  - name: edge\n    version: latest\n  - name: and_chr\n    version: latest\n  - name: ios_saf\n    version: latest\nproviders:\n  - airtap-system\npresets:\n  local:\n    providers: airtap-manual\n    browsers:\n      - name: manual\n  sauce:\n  # Not used yet pending https://github.com/SocketDev/wormhole-crypto/issues/5\n  # and https://github.com/airtap/airtap/issues/311\n    providers: airtap-sauce\nbrowserify:\n  - transform: babelify\n    global: true\n    presets: ['@babel/preset-env']\n    plugins: ['@babel/plugin-syntax-import-assertions']\nserver: './scripts/browser-serve.js'\n"
  },
  {
    "path": ".eslintrc.cjs",
    "content": "module.exports = {\n  env: {\n    es2022: true,\n    browser: true,\n    node: true,\n    serviceworker: true\n  },\n  extends: ['standard'],\n  parser: '@babel/eslint-parser',\n  parserOptions: {\n    sourceType: 'module',\n    ecmaVersion: 'latest',\n    requireConfigFile: false,\n    babelOptions: {\n      parserOpts: {\n        plugins: ['importAssertions']\n      }\n    }\n  },\n  ignorePatterns: ['node_modules', 'dist']\n}\n"
  },
  {
    "path": ".github/config.yml",
    "content": "\n# ProBot Request Info (https://probot.github.io/apps/request-info/)\n\nrequestInfoReplyComment: >\n  👋 We would appreciate it if you could provide us with more information about this\n  issue or PR.\nrequestInfoLabelToAdd: 'need more info'\n\n# ProBot Welcome (https://probot.github.io/apps/welcome/)\n\nnewPRWelcomeComment: >\n  🙌 Thanks for opening this pull request! You're awesome.\n  <br><br> ![](https://feross.net/x/cats/6.gif)\nfirstPRMergeComment: >\n  🎉 Congrats on getting your first pull request landed! <br><br>\n  ![](https://feross.net/x/cats/29.gif)\n"
  },
  {
    "path": ".github/no-response.yml",
    "content": "# ProBot No Response (https://probot.github.io/apps/no-response/)\n\n# Number of days of inactivity before an Issue is closed for lack of response\ndaysUntilClose: 14\n\n# Label requiring a response\nresponseRequiredLabel: 'need more info'\n\n# Comment to post when closing an Issue for lack of response. Set to `false` to disable\ncloseComment: >\n  This issue has been automatically closed because there was no response to a\n  request for more information from the issue opener. Please leave a comment or\n  open a new issue if you have additional information related to this issue.\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: ci\non:\n  push:\n    branches:\n      - master\n    tags-ignore:\n      - '*'\n  pull_request:\n    branches:\n      - master\nconcurrency: \n  group: ${{ github.ref }}\n  cancel-in-progress: true\njobs:\n  test:\n    name: Node ${{ matrix.node }} / ${{ matrix.os }}\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        os:\n          - ubuntu-latest\n        node:\n          - '18'\n          - '16'\n    steps:\n      - uses: actions/checkout@v3\n      - uses: actions/setup-node@v3\n        with:\n          node-version: ${{ matrix.node }}\n      - run: npm install\n      - run: npm run build --if-present\n      - run: echo \"127.0.0.1 airtap.local\" | sudo tee -a /etc/hosts\n      - run: npm test\n        env:\n          SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}\n          SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}\n"
  },
  {
    "path": ".github/workflows/codeql-analysis.yml",
    "content": "name: \"CodeQL\"\n\non:\n  push:\n    branches: [ master ]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [ master ]\n  schedule:\n    - cron: '41 6 * * 2'\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n    permissions:\n      actions: read\n      contents: read\n      security-events: write\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [ 'javascript' ]\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v3\n\n    - name: Initialize CodeQL\n      uses: github/codeql-action/init@v3\n      with:\n        languages: ${{ matrix.language }}\n        # If you wish to specify custom queries, you can do so here or in a config file.\n        # By default, queries listed here will override any specified in a config file.\n        # Prefix the list here with \"+\" to use these queries and those in the config file.\n        # queries: ./path/to/local/query, your-org/your-repo/queries@main\n\n    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n    # If this step fails, then you should remove it and run the build manually (see below)\n    # - name: Autobuild\n    #  uses: github/codeql-action/autobuild@v1\n\n    # ℹ️ Command-line programs to run using the OS shell.\n    # 📚 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun\n\n    # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines\n    #    and modify them (or add more) to build your code if your project\n    #    uses a compiled language\n\n    #- run: |\n    #   make bootstrap\n    #   make release\n\n    - name: Perform CodeQL Analysis\n      uses: github/codeql-action/analyze@v3\n"
  },
  {
    "path": ".github/workflows/lock.yml",
    "content": "name: 'Lock Threads'\n\non:\n  schedule:\n    - cron: '0 13 * * *'\n  workflow_dispatch:\n\npermissions:\n  issues: write\n  pull-requests: write\n\nconcurrency:\n  group: lock\n\njobs:\n  action:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: dessant/lock-threads@v4\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Release\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  release:\n    name: Release\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n        with:\n          persist-credentials: false\n      - name: Setup Node.js\n        uses: actions/setup-node@v3\n        with:\n          node-version: 18\n      - name: Cache\n        uses: actions/cache@v3\n        with:\n          path: ~/.npm\n          key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}\n          restore-keys: |\n            ${{ runner.os }}-npm-\n      - name: Install dependencies\n        run: npm i\n        env:\n          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}\n      - name: Release\n        env:\n          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}\n          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}\n        run: npx semantic-release\n"
  },
  {
    "path": ".github/workflows/stale.yml",
    "content": "name: Mark stale issues and pull requests\n\non:\n  schedule:\n  - cron: '0 12 * * *'\n\njobs:\n  stale:\n    runs-on: ubuntu-latest\n    permissions:\n      issues: write\n      pull-requests: write\n\n    steps:\n    - uses: actions/stale@v8\n      with:\n        repo-token: ${{ secrets.GITHUB_TOKEN }}\n        stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'\n        stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'\n        exempt-issue-labels: accepted,blocked,bug,security,meta\n        exempt-pr-labels: accepted,blocked,bug,'help wanted',security,meta\n        stale-issue-label: 'stale'\n        stale-pr-label: 'stale'\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules/\npackage-lock.json\nwebtorrent.debug.js\nsw.debug.js\npnpm-lock.yaml\n"
  },
  {
    "path": ".npmignore",
    "content": ".github/\ndocs/\nscripts/\ntest/\n\n.airtap.yml\nCONTRIBUTING.md\n"
  },
  {
    "path": "AUTHORS.md",
    "content": "# Authors\n\n#### Ordered by first contribution.\n\n- Feross Aboukhadijeh (feross@feross.org)\n- John Hiesey (jhiesey@cs.stanford.edu)\n- Brad Berger (brad@bradb.net)\n- Matt Buresh (mattburesh@gmail.com)\n- cagedwisdom (cagedwisdom@tricorder.org)\n- Charles Julian Knight (charles@rabidaudio.com)\n- Maurits van Mastrigt (maurits@nerdieworks.nl)\n- Shyam S Kumar (shyam.salim.kumar@outlook.com)\n- fisch0920 (fisch0920@gmail.com)\n- iShift (shift.rus@gmail.com)\n- Bob Ren (bob@codecademy.com)\n- gtuk (gtuk@hush.ai)\n- thammin (thammin@live.co.uk)\n- Valérian Galliat (val@codejam.info)\n- charlescharles (charlescharles@users.noreply.github.com)\n- opfl (openthefrog@gmail.com)\n- Chris (abody.97@gmail.com)\n- Astro (astro@spaceboyz.net)\n- Sindre Sorhus (sindresorhus@gmail.com)\n- Josh Duff (me@JoshDuff.com)\n- Anthony MOI (anthony@totems.co)\n- Joseph Dykstra (josephdykstra@gmail.com)\n- mathiasvr (mathiasvr@gmail.com)\n- grunjol (grunjol@argenteam.net)\n- Liam Curry (liam@curry.name)\n- Francisco Pinzon (hello@pacho.me)\n- Jake Fulton Buckle (jacobafb@gmail.com)\n- alexeisavca (savca.alexei@gmail.com)\n- Olivier Lalonde (olalonde@gmail.com)\n- Johnny Tong (mailbox@johnnytong.com)\n- Mark Vayngrib (mark.vayngrib@lablz.com)\n- Tristan Davies (github@tristan.io)\n- Eric Wooley (ericwooley@gmail.com)\n- Afshin Mehrabani (afshin.meh@gmail.com)\n- Josip Janžić (josip.janzic@gmail.com)\n- Bigard Florian (florian.bigard@gmail.com)\n- OlaviSau (olavisau@gmail.com)\n- Simba Zhang (solderzzc@gmail.com)\n- Gilles De Mey (gilles.de.mey@gmail.com)\n- Linus Unnebäck (linus@folkdatorn.se)\n- André Stein (stivekx@gmail.com)\n- Joseph Frazier (joseph@onsip.com)\n- Yousef Amar (yousefamar@gmail.com)\n- Lucas Pelegrino (lucas.wxp@gmail.com)\n- Yoann Ciabaud (yoann@atacma.agency)\n- Joseph Frazier (1212jtraceur@gmail.com)\n- Ivan Vučica (ivan@vucica.net)\n- ReadmeCritic (frankensteinbot@gmail.com)\n- Anders D. Johnson (adjohnson916@users.noreply.github.com)\n- vinz243 (vinz243@gmail.com)\n- Diego Rodríguez (diegorbaquero@gmail.com)\n- Aram Drevekenin (grimsniffer@gmail.com)\n- andreapaiola (andrea.paiola@gmail.com)\n- Hrvoje Šimić (me@shime.io)\n- Romain Beaumont (romain.rom1@gmail.com)\n- Zander Mackie (zander@skilledup.com)\n- Wim (wim@sitebase.be)\n- William Blankenship (william.jblankenship@gmail.com)\n- James Halliday (mail@substack.net)\n- Bazyli Brzóska (bazyli.brzoska@gmail.com)\n- Liam Gray (liam.r.gray@gmail.com)\n- Mike (kenr.mk@gmail.com)\n- Autarc (autarc@gmail.com)\n- DC (dcposch@dcpos.ch)\n- Manuel Simoni (msimoni@gmail.com)\n- Diego Rodríguez Baquero (diegorbaquero@gmail.com)\n- Tercus (Terces86@gmail.com)\n- Lunik (guillaume.lunik@gmail.com)\n- Ajain Vivek (ajainvivek07@gmail.com)\n- Jonathan Harper (jharper@eecs.berkeley.edu)\n- Miguel Freitas (miguelfreitas@users.noreply.github.com)\n- Sebastian Mayr (github@smayr.name)\n- v0dy (k4r70ng@gmail.com)\n- Colin Steele (cvillecsteele@gmail.com)\n- Mathias Rasmussen (mathiasvr@gmail.com)\n- darkenvy (darkenvy6@gmail.com)\n- Amila Welihinda (amilajack@gmail.com)\n- Yoann Ciabaud (yoann@sonora.io)\n- michal (mich.spicka@gmail.com)\n- ferrolho (henriqueferrolho@gmail.com)\n- Henrique Ferrolho (ferrolho@users.noreply.github.com)\n- Facundo Zaldo (FaCuZ@users.noreply.github.com)\n- Alberto Miranda (codealchemist@gmail.com)\n- Jack Bates (jack@nottheoilrig.com)\n- Giovanni T. Parra (fiatjaf@gmail.com)\n- Mikeal Rogers (mikeal.rogers@gmail.com)\n- Jerod Santo (jerod.santo@gmail.com)\n- George Petrov (george@dmxzone.com)\n- Alexey Rodionov (fluorescent.hallucinogen@gmail.com)\n- Sidd Sridharan (sidd@sidd.com)\n- Hongbo Miao (Hongbo.Miao@outlook.com)\n- ronsoros (ronsor@mailnesia.com)\n- Ray Vahey (rnvahey@gmail.com)\n- Chuong (kocoten1992@users.noreply.github.com)\n- William (willyb321@users.noreply.github.com)\n- bradleyjkemp (scytheon3@gmail.com)\n- bradleyjkemp (bradleyjkemp@users.noreply.github.com)\n- Anthony Ettinger (anthony@chovy.com)\n- malone (toby.walsh@fxhome.com)\n- pahwaranger (amit@amitpahwa.com)\n- Benjamin Tan (demoneaux@gmail.com)\n- Diego R. B (diegorbaquero@gmail.com)\n- Andrea Paiola (andrea.paiola@gmail.com)\n- David (thegr8dave@gmail.com)\n- andreapaiola (andrea.paiola@digintel.it)\n- Ash (ashlesscinder@gmail.com)\n- Hrvoje Šimić (hrvoje@twobucks.co)\n- Alex Lu (alxlu@users.noreply.github.com)\n- David Chevers Williams (wdc@student.unimelb.edu.au)\n- snowinszu (86755838@qq.com)\n- XiaoJun (magic.xiao@admaster.com.cn)\n- Pierre Brocart (pierbrocar@gmail.com)\n- saramkn1 (31823057+saramkn1@users.noreply.github.com)\n- Alex (alxmorais8@msn.com)\n- Brian Clifton (brian@clifton.me)\n- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)\n- LukaKerr (lukakerr1@gmail.com)\n- Pierre-Louis Dubouilh (pldubouilh@gmail.com)\n- MiKatre (0mica4420@gmail.com)\n- Matthew Peveler (matt.peveler@gmail.com)\n- yan (yan@mit.edu)\n- Thijs Triemstra (info@collab.nl)\n- DEADBLACKCLOVER (asocio@protonmail.com)\n- Pierre Dubouilh (pldubouilh@gmail.com)\n- Konstantin Veretennicov (kveretennicov+github@gmail.com)\n- Gustavo Rodrigues (qgustavor@users.noreply.github.com)\n- faza (fazamhd@gmail.com)\n- Raymond Tan (now-raymond@users.noreply.github.com)\n- Kaylee (34007889+KayleePop@users.noreply.github.com)\n- Brad Marsden (silentbot1@gmail.com)\n- lovefoodcode (38153617+lovefoodcode@users.noreply.github.com)\n- Gabriel Almeida (gabrieel@email.com)\n- filesfm (41144556+filesfm@users.noreply.github.com)\n- John Hiesey (john@hiesey.com)\n- KayleePop (34007889+KayleePop@users.noreply.github.com)\n- Andriy Lysnevych (andriy.lysnevych@gmail.com)\n- Chris McCormick (chris@mccormick.cx)\n- Jimmy Wärting (jimmy@warting.se)\n- Jorge Cuadra (jorgecuadrafueyo@gmail.com)\n- Chocobozzz (florian.chocobo@gmail.com)\n- Chocobozzz (me@florianbigard.com)\n- Gabriel (gabrieel@email.com)\n- Shachar Itzhaky (corwin.amber@gmail.com)\n- Eric Guan (guanzo91@gmail.com)\n- Arnaldas Augutis (info@untitled.lt)\n- Diego Rodriguez (diegorbaquero@gmail.com)\n- Francois Carpentier (Francewhoa@users.noreply.github.com)\n- Anton Harniakou (anton.harniakou@gmail.com)\n- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com)\n- Dan Dumont (ddumont@gmail.com)\n- Gabriel Juchault (gabriel.juchault@gmail.com)\n- Feross (feross@feross.org)\n- Chandan Chowdary Bhagam (chandandharana@gmail.com)\n- Jiayin Pei (pjymymartin@gmail.com)\n- Eric Berry (coderberry@gmail.com)\n- DeltaF1 (DeltaF1@users.noreply.github.com)\n- jsdt (jeffreydallatezza@gmail.com)\n- Luc (luc.cadoret@gmail.com)\n- Diego Rodriguez Baquero (diego.baquero@pager.com)\n- Silvan Strübi (silvan.struebi@gmail.com)\n- Aditya Shankar (me@adityashankar.xyz)\n- x1alien (63802698+x1alien@users.noreply.github.com)\n- DEADBLACKCLOVER (deadblackclover@protonmail.com)\n- H3RSKO (34112131+H3RSKO@users.noreply.github.com)\n- Julen Garcia Leunda (hicom150@gmail.com)\n- Jean-Philippe ALLEGRO (jipai13@gmail.com)\n- Rhys Williams (me@rhyswilliams.co.za)\n- Leo (5376265+leoherzog@users.noreply.github.com)\n- ftreesmilo (58193105+ftreesmilo@users.noreply.github.com)\n- valverde82 (valverde.marcelo@gmail.com)\n- Jimmy Wärting (jimmy@warting.se)\n- Vintic (vlad.f.s.95@gmail.com)\n- dependabot[bot] (49699333+dependabot[bot]@users.noreply.github.com)\n- ThaUnknown (kapi.skowronek@gmail.com)\n- Renovate Bot (bot@renovateapp.com)\n- Diego Rodríguez Baquero (github@diegorbaquero.com)\n- Diego Rodríguez Baquero (diego@mothership.com)\n- semantic-release-bot (semantic-release-bot@martynus.net)\n- renovate[bot] (29139614+renovate[bot]@users.noreply.github.com)\n- Cas (6506529+ThaUnknown@users.noreply.github.com)\n- Diego Rodriguez Baquero (diego@arc.io)\n- nkavian (nas@sixclovers.com)\n- ftrees (58193105+ftreesmilo@users.noreply.github.com)\n- Matías (mati280341@gmail.com)\n- Serge Thompson (serge.thompson@gmail.com)\n- il3ven (vaibhavchanana@yahoo.co.in)\n- Martti Malmi (sirius@iki.fi)\n- Ivan Borzenkov (ivan.borzenkov@gmail.com)\n- Daniel Delgado Perera (33069494+audepe@users.noreply.github.com)\n- Lakshya Singh (lakshay.singh1108@gmail.com)\n- developomp (developomp@gmail.com)\n- Bruce Hopkins (behopkinsjr@gmail.com)\n- Paul-Louis Ageneau (paul-louis@ageneau.org)\n- Artak Safaryan (32634773+holoyan@users.noreply.github.com)\n- Drakonkat (adamo.mazzocchetti@gmail.com)\n- CommanderRoot (CommanderRoot@users.noreply.github.com)\n- Justin Lewis Salmon (jlsalmon@users.noreply.github.com)\n- Diego Rodriguez Baquero (diego@protocol.ai)\n- Sukka (isukkaw@gmail.com)\n- Nipuna Weerasekara (w.nipuna@gmail.com)\n- ThaUnknown (6506529+ThaUnknown@users.noreply.github.com)\n- tedd pasta (37799569+resession@users.noreply.github.com)\n- Ilaygoldman (29836366+Ilaygoldman@users.noreply.github.com)\n- Jeremy Kahn (jeremyckahn@gmail.com)\n- Bread Genie (63963181+BreadGenie@users.noreply.github.com)\n- Tom Moor (tom.moor@gmail.com)\n- funniray (funniray10@gmail.com)\n- Carl Gorringe (git@gorringe.org)\n- Banou (me@banou.dev)\n- Cas_ (6506529+ThaUnknown@users.noreply.github.com)\n- Andréas Livet (andreas.livet@gmail.com)\n- Evan Hahn (me@evanhahn.com)\n- Kende Détár (64217783+detarkende@users.noreply.github.com)\n- Parsa Yazdani (parsa@yazdani.au)\n- Todd Tanner (lostit1278@gmail.com)\n- ya1Ry (86045923+ya1Ry@users.noreply.github.com)\n- Paweł Zmarzły (pawo2500@gmail.com)\n- Maurizio Carboni (maury91@gmail.com)\n- hclarke (0@hclarke.ca)\n\n#### Generated by scripts/update-authors.sh.\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## [2.8.5](https://github.com/webtorrent/webtorrent/compare/v2.8.4...v2.8.5) (2025-11-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @silentbot1/nat-api to ^0.4.9 ([#2992](https://github.com/webtorrent/webtorrent/issues/2992)) ([15923e5](https://github.com/webtorrent/webtorrent/commit/15923e5238e068721da3399611e3eb6e3a27035b))\n\n## [2.8.4](https://github.com/webtorrent/webtorrent/compare/v2.8.3...v2.8.4) (2025-08-14)\n\n\n### Bug Fixes\n\n* connect count ([#2979](https://github.com/webtorrent/webtorrent/issues/2979)) ([ec009c8](https://github.com/webtorrent/webtorrent/commit/ec009c8476badbb7fac7b035f9a2c18a1019f81f))\n\n## [2.8.3](https://github.com/webtorrent/webtorrent/compare/v2.8.2...v2.8.3) (2025-08-09)\n\n\n### Bug Fixes\n\n* connect event name typo ([#2975](https://github.com/webtorrent/webtorrent/issues/2975)) ([30b535a](https://github.com/webtorrent/webtorrent/commit/30b535aca2d1e44231d6c6714134254b4c38c47d))\n\n## [2.8.2](https://github.com/webtorrent/webtorrent/compare/v2.8.1...v2.8.2) (2025-08-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^4.1.20 ([#2974](https://github.com/webtorrent/webtorrent/issues/2974)) ([6618b21](https://github.com/webtorrent/webtorrent/commit/6618b21fd975213898a9e6b475f7c258b7d37aa1))\n\n## [2.8.1](https://github.com/webtorrent/webtorrent/compare/v2.8.0...v2.8.1) (2025-08-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency throughput to ^1.0.2 ([#2973](https://github.com/webtorrent/webtorrent/issues/2973)) ([55ae332](https://github.com/webtorrent/webtorrent/commit/55ae3329935b1a933e6a02a47536b8b4b94bed3e))\n\n# [2.8.0](https://github.com/webtorrent/webtorrent/compare/v2.7.1...v2.8.0) (2025-08-03)\n\n\n### Features\n\n* **deps:** update dependency fs-chunk-store to v5 ([#2972](https://github.com/webtorrent/webtorrent/issues/2972)) ([2a1571d](https://github.com/webtorrent/webtorrent/commit/2a1571da7de9846cb58c27aabf9e233353e8d469))\n\n## [2.7.1](https://github.com/webtorrent/webtorrent/compare/v2.7.0...v2.7.1) (2025-08-03)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2971](https://github.com/webtorrent/webtorrent/issues/2971)) ([b23cf4f](https://github.com/webtorrent/webtorrent/commit/b23cf4fa90c6ca9f260a9b6dd32b1d435e97c519))\n\n# [2.7.0](https://github.com/webtorrent/webtorrent/compare/v2.6.10...v2.7.0) (2025-08-03)\n\n\n### Features\n\n* peers as map for performance ([#2970](https://github.com/webtorrent/webtorrent/issues/2970)) ([92db29f](https://github.com/webtorrent/webtorrent/commit/92db29f8172c27d8bdb33600e151576699d28b0c))\n\n## [2.6.10](https://github.com/webtorrent/webtorrent/compare/v2.6.9...v2.6.10) (2025-06-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^4.1.18 ([#2965](https://github.com/webtorrent/webtorrent/issues/2965)) ([0122af4](https://github.com/webtorrent/webtorrent/commit/0122af4c0e53fc70a7b9c8a5a712590f835a7e80))\n\n## [2.6.9](https://github.com/webtorrent/webtorrent/compare/v2.6.8...v2.6.9) (2025-06-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to v2.22.1 ([#2960](https://github.com/webtorrent/webtorrent/issues/2960)) ([a0dc518](https://github.com/webtorrent/webtorrent/commit/a0dc5188a9426e287af5b12aa037e7b7e248cbb9))\n\n## [2.6.8](https://github.com/webtorrent/webtorrent/compare/v2.6.7...v2.6.8) (2025-05-23)\n\n\n### Bug Fixes\n\n* bad file iterator code ([#2953](https://github.com/webtorrent/webtorrent/issues/2953)) ([b119706](https://github.com/webtorrent/webtorrent/commit/b119706f2a521b728e4e1ddea13c2802507968d9))\n\n## [2.6.7](https://github.com/webtorrent/webtorrent/compare/v2.6.6...v2.6.7) (2025-05-16)\n\n\n### Bug Fixes\n\n* removing stream selections ([#2952](https://github.com/webtorrent/webtorrent/issues/2952)) ([a5cbad0](https://github.com/webtorrent/webtorrent/commit/a5cbad0bfdf1bf8ebdc3c4f4e1500e183a8cd51a))\n\n## [2.6.6](https://github.com/webtorrent/webtorrent/compare/v2.6.5...v2.6.6) (2025-05-15)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2951](https://github.com/webtorrent/webtorrent/issues/2951)) ([e9eb53c](https://github.com/webtorrent/webtorrent/commit/e9eb53ce5db33f212bc44702d0e157b665040eb4))\n\n## [2.6.5](https://github.com/webtorrent/webtorrent/compare/v2.6.4...v2.6.5) (2025-05-14)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-dht to ^11.0.10 ([#2950](https://github.com/webtorrent/webtorrent/issues/2950)) ([effaf4e](https://github.com/webtorrent/webtorrent/commit/effaf4e55e30d91362b924a774ba243bea86d09c))\n\n## [2.6.4](https://github.com/webtorrent/webtorrent/compare/v2.6.3...v2.6.4) (2025-05-14)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.4.1 ([#2949](https://github.com/webtorrent/webtorrent/issues/2949)) ([2954871](https://github.com/webtorrent/webtorrent/commit/2954871756160e6071d873f489703c1c245dc202))\n\n## [2.6.3](https://github.com/webtorrent/webtorrent/compare/v2.6.2...v2.6.3) (2025-04-18)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^11.0.16 ([#2943](https://github.com/webtorrent/webtorrent/issues/2943)) ([6c0154e](https://github.com/webtorrent/webtorrent/commit/6c0154e5255f9c6590dcb62c466ed22c043d5ee0))\n\n## [2.6.2](https://github.com/webtorrent/webtorrent/compare/v2.6.1...v2.6.2) (2025-04-18)\n\n\n### Bug Fixes\n\n* null body on OPTIONS ([#2942](https://github.com/webtorrent/webtorrent/issues/2942)) ([76b508a](https://github.com/webtorrent/webtorrent/commit/76b508aa3482697dfad11d42d7d34de52484e65b))\n\n## [2.6.1](https://github.com/webtorrent/webtorrent/compare/v2.6.0...v2.6.1) (2025-04-18)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @silentbot1/nat-api to ^0.4.8 ([#2941](https://github.com/webtorrent/webtorrent/issues/2941)) ([134362e](https://github.com/webtorrent/webtorrent/commit/134362e51fa4c5f1996f3aaf38dcf1ca21e42580))\n\n# [2.6.0](https://github.com/webtorrent/webtorrent/compare/v2.5.19...v2.6.0) (2025-04-04)\n\n\n### Features\n\n* add an option to store the bitfield in the file system ([#2878](https://github.com/webtorrent/webtorrent/issues/2878)) ([e29a474](https://github.com/webtorrent/webtorrent/commit/e29a4740b45995719652a1886a42f816e38fa456))\n\n## [2.5.19](https://github.com/webtorrent/webtorrent/compare/v2.5.18...v2.5.19) (2025-02-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to v2.22.0 ([#2921](https://github.com/webtorrent/webtorrent/issues/2921)) ([f06ac81](https://github.com/webtorrent/webtorrent/commit/f06ac81887c4738067f92246949c1e5fcdf60d09))\n\n## [2.5.18](https://github.com/webtorrent/webtorrent/compare/v2.5.17...v2.5.18) (2025-02-02)\n\n## [2.5.17](https://github.com/webtorrent/webtorrent/compare/v2.5.16...v2.5.17) (2025-01-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-piece to ^3.0.1 ([#2920](https://github.com/webtorrent/webtorrent/issues/2920)) ([86d7980](https://github.com/webtorrent/webtorrent/commit/86d7980ff64161449ace94dba9f66520d038fad9))\n\n## [2.5.16](https://github.com/webtorrent/webtorrent/compare/v2.5.15...v2.5.16) (2025-01-29)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to v2.21.1 ([#2898](https://github.com/webtorrent/webtorrent/issues/2898)) ([7727845](https://github.com/webtorrent/webtorrent/commit/772784501d7e2aaa170344c79eb3c490634c64cd))\n\n## [2.5.15](https://github.com/webtorrent/webtorrent/compare/v2.5.14...v2.5.15) (2025-01-29)\n\n\n### Bug Fixes\n\n* bad done and select behavior and documentation ([#2916](https://github.com/webtorrent/webtorrent/issues/2916)) ([8237d5f](https://github.com/webtorrent/webtorrent/commit/8237d5fa23c9f8f46a0d1ad7bc820ff661ee5ba6))\n\n## [2.5.14](https://github.com/webtorrent/webtorrent/compare/v2.5.13...v2.5.14) (2025-01-21)\n\n\n### Bug Fixes\n\n* noPeers not working correctly ([#2915](https://github.com/webtorrent/webtorrent/issues/2915)) ([62b4118](https://github.com/webtorrent/webtorrent/commit/62b41182ac71acee82cb53ed490f35ad1710ca1f))\n\n## [2.5.13](https://github.com/webtorrent/webtorrent/compare/v2.5.12...v2.5.13) (2025-01-20)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2914](https://github.com/webtorrent/webtorrent/issues/2914)) ([e4f237d](https://github.com/webtorrent/webtorrent/commit/e4f237d9b0118146e7dced65fd5a8690b5771682))\n\n## [2.5.12](https://github.com/webtorrent/webtorrent/compare/v2.5.11...v2.5.12) (2025-01-04)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2910](https://github.com/webtorrent/webtorrent/issues/2910)) ([53049b6](https://github.com/webtorrent/webtorrent/commit/53049b6121d1ea4116d41ebec79b49cd8146ac3d))\n\n## [2.5.11](https://github.com/webtorrent/webtorrent/compare/v2.5.10...v2.5.11) (2024-12-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^11.0.14 ([#2908](https://github.com/webtorrent/webtorrent/issues/2908)) ([85e1d8a](https://github.com/webtorrent/webtorrent/commit/85e1d8add7bc0e2c426f1ec1bba54f77275dbfde))\n\n## [2.5.10](https://github.com/webtorrent/webtorrent/compare/v2.5.9...v2.5.10) (2024-12-07)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^11.0.13 ([#2901](https://github.com/webtorrent/webtorrent/issues/2901)) ([03f7021](https://github.com/webtorrent/webtorrent/commit/03f7021b89cc18be9becd1284b21b27b09790153))\n\n## [2.5.9](https://github.com/webtorrent/webtorrent/compare/v2.5.8...v2.5.9) (2024-12-07)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2900](https://github.com/webtorrent/webtorrent/issues/2900)) ([2b45a14](https://github.com/webtorrent/webtorrent/commit/2b45a142382fdcf2b48a6618b71930e119e55d70))\n\n## [2.5.8](https://github.com/webtorrent/webtorrent/compare/v2.5.7...v2.5.8) (2024-12-07)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.4.0 ([#2899](https://github.com/webtorrent/webtorrent/issues/2899)) ([1dd3c1a](https://github.com/webtorrent/webtorrent/commit/1dd3c1a45bca399d9800932318525881224527a4))\n\n## [2.5.7](https://github.com/webtorrent/webtorrent/compare/v2.5.6...v2.5.7) (2024-11-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to v2.20.2 ([#2888](https://github.com/webtorrent/webtorrent/issues/2888)) ([4b00a0e](https://github.com/webtorrent/webtorrent/commit/4b00a0e1e70b8f71f264e254f70f2bfe80b16992))\n\n## [2.5.6](https://github.com/webtorrent/webtorrent/compare/v2.5.5...v2.5.6) (2024-11-17)\n\n\n### Bug Fixes\n\n* uTP error on setup ([#2892](https://github.com/webtorrent/webtorrent/issues/2892)) ([283fd76](https://github.com/webtorrent/webtorrent/commit/283fd76b8ed0589c397711510d1efddf18297967))\n\n## [2.5.5](https://github.com/webtorrent/webtorrent/compare/v2.5.4...v2.5.5) (2024-11-06)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to v2.20.1 ([#2855](https://github.com/webtorrent/webtorrent/issues/2855)) ([6618cee](https://github.com/webtorrent/webtorrent/commit/6618cee538264639f92d436ee253e321a284777e))\n\n## [2.5.4](https://github.com/webtorrent/webtorrent/compare/v2.5.3...v2.5.4) (2024-11-06)\n\n\n### Bug Fixes\n\n* **deps:** update dependency pump to ^3.0.2 ([#2864](https://github.com/webtorrent/webtorrent/issues/2864)) ([019f115](https://github.com/webtorrent/webtorrent/commit/019f115031003a6cb119d13527bd6faaf5bfad8c))\n\n## [2.5.3](https://github.com/webtorrent/webtorrent/compare/v2.5.2...v2.5.3) (2024-11-05)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([c5eed32](https://github.com/webtorrent/webtorrent/commit/c5eed329cf06dc2638ddae4193f6c1af83d557d0))\n\n## [2.5.2](https://github.com/webtorrent/webtorrent/compare/v2.5.1...v2.5.2) (2024-11-05)\n\n\n### Bug Fixes\n\n* parse host even if this.client.blocked is false, to allow line 868 to pass correctly and default to utp. ([#2805](https://github.com/webtorrent/webtorrent/issues/2805)) ([beef270](https://github.com/webtorrent/webtorrent/commit/beef270d62e749c406637da8d82e2e5f85a03020))\n\n## [2.5.1](https://github.com/webtorrent/webtorrent/compare/v2.5.0...v2.5.1) (2024-09-07)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.3.7 ([69c1441](https://github.com/webtorrent/webtorrent/commit/69c14418af5fe724dc294ca5469d7c3188542b88))\n\n# [2.5.0](https://github.com/webtorrent/webtorrent/compare/v2.4.15...v2.5.0) (2024-08-04)\n\n\n### Features\n\n* drop IDB ([#2851](https://github.com/webtorrent/webtorrent/issues/2851)) ([dc26aa6](https://github.com/webtorrent/webtorrent/commit/dc26aa6363d6004518de4f7ffc1d6a3968543a26))\n\n## [2.4.15](https://github.com/webtorrent/webtorrent/compare/v2.4.14...v2.4.15) (2024-08-03)\n\n\n### Bug Fixes\n\n* custom length file buffer ([#2843](https://github.com/webtorrent/webtorrent/issues/2843)) ([5d40ad1](https://github.com/webtorrent/webtorrent/commit/5d40ad166ea531e1be9d07511c6245135ea9d87e))\n\n## [2.4.14](https://github.com/webtorrent/webtorrent/compare/v2.4.13...v2.4.14) (2024-07-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.3.6 ([c6dde2c](https://github.com/webtorrent/webtorrent/commit/c6dde2c95fb06cf6b5668225d3a1bdfa3a59c053))\n\n## [2.4.13](https://github.com/webtorrent/webtorrent/compare/v2.4.12...v2.4.13) (2024-07-28)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([9eb656f](https://github.com/webtorrent/webtorrent/commit/9eb656f81016dffcc178ece9f15402ef63bc6a99))\n\n## [2.4.12](https://github.com/webtorrent/webtorrent/compare/v2.4.11...v2.4.12) (2024-07-17)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @thaunknown/simple-peer to ^10.0.10 ([09d7ea0](https://github.com/webtorrent/webtorrent/commit/09d7ea08cc461902aab6c9fc699f7962b1d977bd))\n\n## [2.4.11](https://github.com/webtorrent/webtorrent/compare/v2.4.10...v2.4.11) (2024-06-29)\n\n\n### Bug Fixes\n\n* revert \"fix: drop IDB chunk store ([#2553](https://github.com/webtorrent/webtorrent/issues/2553))\" ([#2828](https://github.com/webtorrent/webtorrent/issues/2828)) ([348fba5](https://github.com/webtorrent/webtorrent/commit/348fba52e02670b506461f401cd067a759963b58))\n\n## [2.4.10](https://github.com/webtorrent/webtorrent/compare/v2.4.9...v2.4.10) (2024-06-29)\n\n\n### Bug Fixes\n\n* force streamx version ([#2826](https://github.com/webtorrent/webtorrent/issues/2826)) ([1f96952](https://github.com/webtorrent/webtorrent/commit/1f96952dbac120a52c27d5a65cb4384d28f748ab))\n\n## [2.4.9](https://github.com/webtorrent/webtorrent/compare/v2.4.8...v2.4.9) (2024-06-29)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @thaunknown/simple-peer to ^10.0.9 ([fc54e8e](https://github.com/webtorrent/webtorrent/commit/fc54e8e3c1fba34ca87b2312a91f72ecdfc26907))\n\n## [2.4.8](https://github.com/webtorrent/webtorrent/compare/v2.4.7...v2.4.8) (2024-06-29)\n\n\n### Bug Fixes\n\n* drop IDB chunk store ([#2553](https://github.com/webtorrent/webtorrent/issues/2553)) ([18a4683](https://github.com/webtorrent/webtorrent/commit/18a468304c3826da42d6e4a4bc7e074ea9297187))\n\n## [2.4.7](https://github.com/webtorrent/webtorrent/compare/v2.4.6...v2.4.7) (2024-06-29)\n\n\n### Bug Fixes\n\n* **deps:** update dependency parse-torrent to ^11.0.17 ([72f4abc](https://github.com/webtorrent/webtorrent/commit/72f4abc2963b985faa905cbea2da77f84600c706))\n\n## [2.4.6](https://github.com/webtorrent/webtorrent/compare/v2.4.5...v2.4.6) (2024-06-29)\n\n\n### Bug Fixes\n\n* revert streamx to 2.17 ([#2819](https://github.com/webtorrent/webtorrent/issues/2819)) ([f4465d0](https://github.com/webtorrent/webtorrent/commit/f4465d043f301452682a8db562d90123b94cd58e))\n\n## [2.4.5](https://github.com/webtorrent/webtorrent/compare/v2.4.4...v2.4.5) (2024-06-29)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^4.1.13 ([d596da6](https://github.com/webtorrent/webtorrent/commit/d596da6da8ea3f6f2f65947ab9e15fcebbb2ba9c))\n\n## [2.4.4](https://github.com/webtorrent/webtorrent/compare/v2.4.3...v2.4.4) (2024-06-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.18.0 ([#2798](https://github.com/webtorrent/webtorrent/issues/2798)) ([20e18b3](https://github.com/webtorrent/webtorrent/commit/20e18b3dbc9be6c2e9abfadaf041e986b99fa690))\n\n## [2.4.3](https://github.com/webtorrent/webtorrent/compare/v2.4.2...v2.4.3) (2024-06-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @thaunknown/simple-peer to ^10.0.8 ([27e34e5](https://github.com/webtorrent/webtorrent/commit/27e34e5059281af5a9d0de4231d3304fd71c5bda))\n* **deps:** update dependency hybrid-chunk-store to ^1.2.6 ([#2818](https://github.com/webtorrent/webtorrent/issues/2818)) ([478c691](https://github.com/webtorrent/webtorrent/commit/478c691bd89ab54f9e76dcddce7eb0f56d8bca68))\n\n## [2.4.2](https://github.com/webtorrent/webtorrent/compare/v2.4.1...v2.4.2) (2024-06-22)\n\n\n### Bug Fixes\n\n* allow client level default trackers to be set ([#2815](https://github.com/webtorrent/webtorrent/issues/2815)) ([a0e056d](https://github.com/webtorrent/webtorrent/commit/a0e056dc01c08c78e8b5ab33b3f50b7e96b37825))\n\n## [2.4.1](https://github.com/webtorrent/webtorrent/compare/v2.4.0...v2.4.1) (2024-06-13)\n\n# [2.4.0](https://github.com/webtorrent/webtorrent/compare/v2.3.6...v2.4.0) (2024-06-06)\n\n\n### Features\n\n* add `opts.seedOutgoingConnections` to allow controlling outbound connections for seeding. ([#2803](https://github.com/webtorrent/webtorrent/issues/2803)) ([d40616f](https://github.com/webtorrent/webtorrent/commit/d40616f27d1b584b1a8db66e75638298388505c9))\n\n## [2.3.6](https://github.com/webtorrent/webtorrent/compare/v2.3.5...v2.3.6) (2024-06-02)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent to ^11.0.6 ([63061c6](https://github.com/webtorrent/webtorrent/commit/63061c68dcd070db982e824eaccee755429f3549))\n\n## [2.3.5](https://github.com/webtorrent/webtorrent/compare/v2.3.4...v2.3.5) (2024-06-01)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^11.0.5 ([4742c01](https://github.com/webtorrent/webtorrent/commit/4742c01560e9f28d2d5bd194f6b84f3b5889ecd1))\n\n## [2.3.4](https://github.com/webtorrent/webtorrent/compare/v2.3.3...v2.3.4) (2024-06-01)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([6ff995f](https://github.com/webtorrent/webtorrent/commit/6ff995fafffb59138f31705fdca5944b0eafbb0c))\n\n## [2.3.3](https://github.com/webtorrent/webtorrent/compare/v2.3.2...v2.3.3) (2024-06-01)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.3.5 ([4a47201](https://github.com/webtorrent/webtorrent/commit/4a472018dfc5c6ca218d5a1b7ba4683aa8e312a7))\n\n## [2.3.2](https://github.com/webtorrent/webtorrent/compare/v2.3.1...v2.3.2) (2024-05-25)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bitfield to ^4.2.0 ([#2730](https://github.com/webtorrent/webtorrent/issues/2730)) ([867e4f2](https://github.com/webtorrent/webtorrent/commit/867e4f2cabcc4087fc55ef3cc0bc1e5f2d75fb21))\n\n## [2.3.1](https://github.com/webtorrent/webtorrent/compare/v2.3.0...v2.3.1) (2024-05-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency uint8-util to ^2.2.5 ([#2784](https://github.com/webtorrent/webtorrent/issues/2784)) ([3c3993f](https://github.com/webtorrent/webtorrent/commit/3c3993fb8c49c99214f7dce514b8751f37f4a277))\n\n# [2.3.0](https://github.com/webtorrent/webtorrent/compare/v2.2.2...v2.3.0) (2024-05-23)\n\n\n### Features\n\n* Built-in-webrtc ([#2786](https://github.com/webtorrent/webtorrent/issues/2786)) ([c693f9e](https://github.com/webtorrent/webtorrent/commit/c693f9ea91c32b0f8e81d2d57476405fda86c7a7))\n\n## [2.2.2](https://github.com/webtorrent/webtorrent/compare/v2.2.1...v2.2.2) (2024-05-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^11.0.4 ([9841d3d](https://github.com/webtorrent/webtorrent/commit/9841d3d99e7329a57abb40f9ef80dc914db6699e))\n\n## [2.2.1](https://github.com/webtorrent/webtorrent/compare/v2.2.0...v2.2.1) (2024-03-26)\n\n\n### Bug Fixes\n\n* **deps:** update dependency hybrid-chunk-store to ^1.2.4 ([#2764](https://github.com/webtorrent/webtorrent/issues/2764)) ([9ce6188](https://github.com/webtorrent/webtorrent/commit/9ce61882717a197aa9a05defe011c2135b44d235))\n\n# [2.2.0](https://github.com/webtorrent/webtorrent/compare/v2.1.37...v2.2.0) (2024-03-26)\n\n\n### Features\n\n* Refactor selections with non-overlapping data structure ([#2757](https://github.com/webtorrent/webtorrent/issues/2757)) ([467f30c](https://github.com/webtorrent/webtorrent/commit/467f30ccb48d318e7cf9e801d40ec3158fa220f6))\n\n## [2.1.37](https://github.com/webtorrent/webtorrent/compare/v2.1.36...v2.1.37) (2024-03-04)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.16.1 ([#2752](https://github.com/webtorrent/webtorrent/issues/2752)) ([33e87e2](https://github.com/webtorrent/webtorrent/commit/33e87e281c02d9cb9f3be7468271722d7d0c3a76))\n\n## [2.1.36](https://github.com/webtorrent/webtorrent/compare/v2.1.35...v2.1.36) (2024-02-09)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^6.0.17 ([54f6add](https://github.com/webtorrent/webtorrent/commit/54f6addef3f4e275b51f8c17f7bbd6e99beaf3f3))\n\n## [2.1.35](https://github.com/webtorrent/webtorrent/compare/v2.1.34...v2.1.35) (2024-02-04)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.15.7 ([#2748](https://github.com/webtorrent/webtorrent/issues/2748)) ([13b135f](https://github.com/webtorrent/webtorrent/commit/13b135f42e985b6af8b676dda24bca1aa75a7a5a))\n\n## [2.1.34](https://github.com/webtorrent/webtorrent/compare/v2.1.33...v2.1.34) (2024-01-16)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([0585322](https://github.com/webtorrent/webtorrent/commit/058532277f6e3a80cf9a772e3d8ca45ec7a41762))\n\n## [2.1.33](https://github.com/webtorrent/webtorrent/compare/v2.1.32...v2.1.33) (2024-01-12)\n\n\n### Bug Fixes\n\n* malformed debug ID ([#2733](https://github.com/webtorrent/webtorrent/issues/2733)) ([2453316](https://github.com/webtorrent/webtorrent/commit/24533162fada3d93404bfe104f5a0b9861350d0d))\n\n## [2.1.32](https://github.com/webtorrent/webtorrent/compare/v2.1.31...v2.1.32) (2023-12-12)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^6.0.16 ([97c0af1](https://github.com/webtorrent/webtorrent/commit/97c0af1e165f77f912e133fdf896d8cea3a5476a))\n\n## [2.1.31](https://github.com/webtorrent/webtorrent/compare/v2.1.30...v2.1.31) (2023-12-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.15.6 ([#2715](https://github.com/webtorrent/webtorrent/issues/2715)) ([3f4a80f](https://github.com/webtorrent/webtorrent/commit/3f4a80f8cea979d1d18329aec097bcdb22a9f2bc))\n\n## [2.1.30](https://github.com/webtorrent/webtorrent/compare/v2.1.29...v2.1.30) (2023-11-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.15.5 ([#2695](https://github.com/webtorrent/webtorrent/issues/2695)) ([262e1e5](https://github.com/webtorrent/webtorrent/commit/262e1e5c66815a3a3f5ebd1d408c1dd5e7cd60da))\n\n## [2.1.29](https://github.com/webtorrent/webtorrent/compare/v2.1.28...v2.1.29) (2023-11-12)\n\n\n### Bug Fixes\n\n* chromeapp build ([#2704](https://github.com/webtorrent/webtorrent/issues/2704)) ([ed9f368](https://github.com/webtorrent/webtorrent/commit/ed9f368fbbcb076f963e26a627ef6bc36b91a4b2))\n\n## [2.1.28](https://github.com/webtorrent/webtorrent/compare/v2.1.27...v2.1.28) (2023-11-09)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to v11 ([#2702](https://github.com/webtorrent/webtorrent/issues/2702)) ([62ff1bf](https://github.com/webtorrent/webtorrent/commit/62ff1bf6559474eb114f131c30eed18ff485afc0))\n\n## [2.1.27](https://github.com/webtorrent/webtorrent/compare/v2.1.26...v2.1.27) (2023-10-03)\n\n\n### Bug Fixes\n\n* **deps:** update dependency uint8-util to ^2.2.4 ([#2653](https://github.com/webtorrent/webtorrent/issues/2653)) ([26ab5d3](https://github.com/webtorrent/webtorrent/commit/26ab5d3e2196cc92edde3d89c1b8877a1385700a))\n\n## [2.1.26](https://github.com/webtorrent/webtorrent/compare/v2.1.25...v2.1.26) (2023-10-02)\n\n\n### Bug Fixes\n\n* incorrect File.stream() object this reference ([#2672](https://github.com/webtorrent/webtorrent/issues/2672)) ([8577a47](https://github.com/webtorrent/webtorrent/commit/8577a4719e32ece57f8e9d30df4c7e819e1b0f70))\n\n## [2.1.25](https://github.com/webtorrent/webtorrent/compare/v2.1.24...v2.1.25) (2023-08-11)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([1639c0e](https://github.com/webtorrent/webtorrent/commit/1639c0ea095942fdddaaee63b05e30498c2984d2))\n\n## [2.1.24](https://github.com/webtorrent/webtorrent/compare/v2.1.23...v2.1.24) (2023-08-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^4.1.11 ([701280f](https://github.com/webtorrent/webtorrent/commit/701280f635e375b0166c902925dadb6fa31c424c))\n\n## [2.1.23](https://github.com/webtorrent/webtorrent/compare/v2.1.22...v2.1.23) (2023-08-10)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^6.0.14 ([d7e81ea](https://github.com/webtorrent/webtorrent/commit/d7e81ea886c272efc0cad5944082aeab9fd66cf8))\n\n## [2.1.22](https://github.com/webtorrent/webtorrent/compare/v2.1.21...v2.1.22) (2023-08-10)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([d447f8c](https://github.com/webtorrent/webtorrent/commit/d447f8c1718c22df4c81844197119d17b5200e00))\n\n## [2.1.21](https://github.com/webtorrent/webtorrent/compare/v2.1.20...v2.1.21) (2023-08-10)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^4.1.10 ([0c60f65](https://github.com/webtorrent/webtorrent/commit/0c60f651ec5c4ab562d5cd155e887971fa78e5bf))\n\n## [2.1.20](https://github.com/webtorrent/webtorrent/compare/v2.1.19...v2.1.20) (2023-08-10)\n\n\n### Bug Fixes\n\n* **deps:** update dependency ut_metadata to ^4.0.3 ([c62044a](https://github.com/webtorrent/webtorrent/commit/c62044ae9fe5399526a896cb1bce1f16ff79b87f))\n\n## [2.1.19](https://github.com/webtorrent/webtorrent/compare/v2.1.18...v2.1.19) (2023-08-10)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([4a60108](https://github.com/webtorrent/webtorrent/commit/4a601081b74876cd0368155becffacee944c32b0))\n\n## [2.1.18](https://github.com/webtorrent/webtorrent/compare/v2.1.17...v2.1.18) (2023-08-09)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.15.1 ([#2593](https://github.com/webtorrent/webtorrent/issues/2593)) ([260fca8](https://github.com/webtorrent/webtorrent/commit/260fca8bac9efa2d102f70010815d3e6d91f7bbd))\n\n## [2.1.17](https://github.com/webtorrent/webtorrent/compare/v2.1.16...v2.1.17) (2023-08-06)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([9ad7e9b](https://github.com/webtorrent/webtorrent/commit/9ad7e9bf51fc88944a6d06888a2cbeccccb09612))\n\n## [2.1.16](https://github.com/webtorrent/webtorrent/compare/v2.1.15...v2.1.16) (2023-07-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency uint8-util to ^2.2.2 ([#2633](https://github.com/webtorrent/webtorrent/issues/2633)) ([8478be4](https://github.com/webtorrent/webtorrent/commit/8478be42b694eaaf7370ca5f8370973683bca0f8))\n\n## [2.1.15](https://github.com/webtorrent/webtorrent/compare/v2.1.14...v2.1.15) (2023-07-24)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([f9b34d6](https://github.com/webtorrent/webtorrent/commit/f9b34d615baec11a597e22894bf5384671af24c1))\n\n## [2.1.14](https://github.com/webtorrent/webtorrent/compare/v2.1.13...v2.1.14) (2023-07-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-piece to v3 ([#2623](https://github.com/webtorrent/webtorrent/issues/2623)) ([7fb7afa](https://github.com/webtorrent/webtorrent/commit/7fb7afab083551c9d6e60998eeb1837f80b45b6c))\n\n## [2.1.13](https://github.com/webtorrent/webtorrent/compare/v2.1.12...v2.1.13) (2023-07-19)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @silentbot1/nat-api to ^0.4.7 ([#2619](https://github.com/webtorrent/webtorrent/issues/2619)) ([a44286c](https://github.com/webtorrent/webtorrent/commit/a44286c4f7ea69c79a238651c95ef42d93e70581))\n\n## [2.1.12](https://github.com/webtorrent/webtorrent/compare/v2.1.11...v2.1.12) (2023-07-05)\n\n\n### Bug Fixes\n\n* perf: faster stream resolution ([#2607](https://github.com/webtorrent/webtorrent/issues/2607)) ([e692270](https://github.com/webtorrent/webtorrent/commit/e692270cf9ba7d793b4b35b509ac0572f07477ce))\n\n## [2.1.11](https://github.com/webtorrent/webtorrent/compare/v2.1.10...v2.1.11) (2023-06-17)\n\n\n### Performance Improvements\n\n* drop buffer ([#2596](https://github.com/webtorrent/webtorrent/issues/2596)) ([7679994](https://github.com/webtorrent/webtorrent/commit/76799949239b784f98ccfc45210f68c7233e74ac))\n\n## [2.1.10](https://github.com/webtorrent/webtorrent/compare/v2.1.9...v2.1.10) (2023-06-17)\n\n\n### Bug Fixes\n\n* **deps:** update dependency hybrid-chunk-store to ^1.2.2 ([#2595](https://github.com/webtorrent/webtorrent/issues/2595)) ([b04cc7a](https://github.com/webtorrent/webtorrent/commit/b04cc7a8ca3d555ebaecff0c3b90f91bc31d1508))\n\n## [2.1.9](https://github.com/webtorrent/webtorrent/compare/v2.1.8...v2.1.9) (2023-06-17)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2592](https://github.com/webtorrent/webtorrent/issues/2592)) ([0c62c36](https://github.com/webtorrent/webtorrent/commit/0c62c366b0310161c2d98a658515dac3f0d16502))\n\n## [2.1.8](https://github.com/webtorrent/webtorrent/compare/v2.1.7...v2.1.8) (2023-06-16)\n\n\n### Performance Improvements\n\n* use peer/lite ([#2591](https://github.com/webtorrent/webtorrent/issues/2591)) ([4e853f0](https://github.com/webtorrent/webtorrent/commit/4e853f0e965bbca21033c3912f8cc990b35ac2bf))\n\n## [2.1.7](https://github.com/webtorrent/webtorrent/compare/v2.1.6...v2.1.7) (2023-06-16)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2590](https://github.com/webtorrent/webtorrent/issues/2590)) ([01865c0](https://github.com/webtorrent/webtorrent/commit/01865c09dd84527dcf0d3caf3cbcb408bf009e2f))\n\n## [2.1.6](https://github.com/webtorrent/webtorrent/compare/v2.1.5...v2.1.6) (2023-06-16)\n\n\n### Performance Improvements\n\n* use path-esm as polyfill for path ([#2587](https://github.com/webtorrent/webtorrent/issues/2587)) ([6e08b00](https://github.com/webtorrent/webtorrent/commit/6e08b0069f1c7d7357ac56fcff9a81e0e07ff452))\n\n## [2.1.5](https://github.com/webtorrent/webtorrent/compare/v2.1.4...v2.1.5) (2023-06-16)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @thaunknown/simple-peer to ^9.12.1 ([#2588](https://github.com/webtorrent/webtorrent/issues/2588)) ([9ea487b](https://github.com/webtorrent/webtorrent/commit/9ea487b4f2470ba6d3afb4bcdbc4a19504a31a25))\n\n## [2.1.4](https://github.com/webtorrent/webtorrent/compare/v2.1.3...v2.1.4) (2023-06-16)\n\n\n### Bug Fixes\n\n* **deps:** update dependency hybrid-chunk-store to ^1.2.1 ([#2589](https://github.com/webtorrent/webtorrent/issues/2589)) ([f482419](https://github.com/webtorrent/webtorrent/commit/f482419d5ad94e205f33c2aa4d67e8ba4ad9ddfb))\n\n## [2.1.3](https://github.com/webtorrent/webtorrent/compare/v2.1.2...v2.1.3) (2023-06-16)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.14.3 ([#2583](https://github.com/webtorrent/webtorrent/issues/2583)) ([d68ea94](https://github.com/webtorrent/webtorrent/commit/d68ea941d53d6dfdf39046796c215c332fd338ab))\n\n## [2.1.2](https://github.com/webtorrent/webtorrent/compare/v2.1.1...v2.1.2) (2023-06-16)\n\n\n### Bug Fixes\n\n* **deps:** update dependency fs-chunk-store to ^4.1.0 ([c9103bf](https://github.com/webtorrent/webtorrent/commit/c9103bf410ad81d9afd3683a9c856bcbe3bf5079))\n\n## [2.1.1](https://github.com/webtorrent/webtorrent/compare/v2.1.0...v2.1.1) (2023-06-15)\n\n\n### Bug Fixes\n\n* Revert \"fix: correctly destroy piped streams in server\" ([#2585](https://github.com/webtorrent/webtorrent/issues/2585)) ([e3c9269](https://github.com/webtorrent/webtorrent/commit/e3c9269b9f9deba824559054ea6ba2e369357b60)), closes [#2565](https://github.com/webtorrent/webtorrent/issues/2565)\n\n# [2.1.0](https://github.com/webtorrent/webtorrent/compare/v2.0.37...v2.1.0) (2023-06-13)\n\n\n### Features\n\n* update dependency streamx to ^2.14.1 ([#2580](https://github.com/webtorrent/webtorrent/issues/2580)) ([92df3a9](https://github.com/webtorrent/webtorrent/commit/92df3a963293d5bee4b22a01421f794907966e19))\n\n## [2.0.37](https://github.com/webtorrent/webtorrent/compare/v2.0.36...v2.0.37) (2023-06-08)\n\n\n### Bug Fixes\n\n* dont encode url path ([#2573](https://github.com/webtorrent/webtorrent/issues/2573)) ([13ad0fb](https://github.com/webtorrent/webtorrent/commit/13ad0fb4f20d6035889569a55c89d4ef813a246d))\n\n## [2.0.36](https://github.com/webtorrent/webtorrent/compare/v2.0.35...v2.0.36) (2023-06-08)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^10.0.11 ([9415322](https://github.com/webtorrent/webtorrent/commit/94153227df2e0371af11dedf24cb1bd429dc2760))\n\n## [2.0.35](https://github.com/webtorrent/webtorrent/compare/v2.0.34...v2.0.35) (2023-06-07)\n\n\n### Bug Fixes\n\n* **deps:** update dependency semantic-release to v21 ([#2510](https://github.com/webtorrent/webtorrent/issues/2510)) ([e74b843](https://github.com/webtorrent/webtorrent/commit/e74b843f2f102d590d68db1db15ea7ac840fc485))\n\n## [2.0.34](https://github.com/webtorrent/webtorrent/compare/v2.0.33...v2.0.34) (2023-06-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^10.0.10 ([#2569](https://github.com/webtorrent/webtorrent/issues/2569)) ([31796f8](https://github.com/webtorrent/webtorrent/commit/31796f82f24ed4da2f634eec84203b49688b589c))\n\n## [2.0.33](https://github.com/webtorrent/webtorrent/compare/v2.0.32...v2.0.33) (2023-06-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.14.0 ([#2568](https://github.com/webtorrent/webtorrent/issues/2568)) ([29f412a](https://github.com/webtorrent/webtorrent/commit/29f412a665b95bdb35d10c5129271705edc1e184))\n\n## [2.0.32](https://github.com/webtorrent/webtorrent/compare/v2.0.31...v2.0.32) (2023-06-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.13.3 ([#2562](https://github.com/webtorrent/webtorrent/issues/2562)) ([11f86db](https://github.com/webtorrent/webtorrent/commit/11f86dbf495f2e16952054f3f0cea76d6a812fce))\n\n## [2.0.31](https://github.com/webtorrent/webtorrent/compare/v2.0.30...v2.0.31) (2023-06-05)\n\n\n### Bug Fixes\n\n* correctly destroy piped streams in server ([#2565](https://github.com/webtorrent/webtorrent/issues/2565)) ([86eda0a](https://github.com/webtorrent/webtorrent/commit/86eda0a470c4a5418a15ad55c31648ee043270c3))\n\n## [2.0.30](https://github.com/webtorrent/webtorrent/compare/v2.0.29...v2.0.30) (2023-06-05)\n\n\n### Bug Fixes\n\n* utp support bundlers and preprocessors ([#2564](https://github.com/webtorrent/webtorrent/issues/2564)) ([8b13937](https://github.com/webtorrent/webtorrent/commit/8b13937289629eeceb59a8dc8a9d4336d8f91ae7))\n\n## [2.0.29](https://github.com/webtorrent/webtorrent/compare/v2.0.28...v2.0.29) (2023-06-04)\n\n\n### Bug Fixes\n\n* utp ([#2561](https://github.com/webtorrent/webtorrent/issues/2561)) ([e4b2e34](https://github.com/webtorrent/webtorrent/commit/e4b2e34a69b6a09197b1cd8406f19fe2099c76a5))\n\n## [2.0.28](https://github.com/webtorrent/webtorrent/compare/v2.0.27...v2.0.28) (2023-06-03)\n\n\n### Bug Fixes\n\n* attempt to fix saucelabs CI ([#2557](https://github.com/webtorrent/webtorrent/issues/2557)) ([c89c27d](https://github.com/webtorrent/webtorrent/commit/c89c27d546bb89cfbe897f144afe48559452816f))\n\n## [2.0.27](https://github.com/webtorrent/webtorrent/compare/v2.0.26...v2.0.27) (2023-05-31)\n\n\n### Bug Fixes\n\n* **deps:** update dependency lt_donthave to v2 ([#2555](https://github.com/webtorrent/webtorrent/issues/2555)) ([21e5007](https://github.com/webtorrent/webtorrent/commit/21e5007e111de492ce46c6d858c7b4a6b05523af))\n\n## [2.0.26](https://github.com/webtorrent/webtorrent/compare/v2.0.25...v2.0.26) (2023-05-31)\n\n\n### Bug Fixes\n\n* **deps:** update dependency parse-torrent to ^11.0.12 ([2766f6f](https://github.com/webtorrent/webtorrent/commit/2766f6fa396bc2f82595a83d7ede3effd0d53a42))\n\n## [2.0.25](https://github.com/webtorrent/webtorrent/compare/v2.0.24...v2.0.25) (2023-05-30)\n\n\n### Bug Fixes\n\n* drop simple-concat ([#2552](https://github.com/webtorrent/webtorrent/issues/2552)) ([1243a76](https://github.com/webtorrent/webtorrent/commit/1243a76e51228e469568a52c94dc9bf666ee93be))\n\n## [2.0.24](https://github.com/webtorrent/webtorrent/compare/v2.0.23...v2.0.24) (2023-05-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^4.1.7 ([#2551](https://github.com/webtorrent/webtorrent/issues/2551)) ([da87d38](https://github.com/webtorrent/webtorrent/commit/da87d3827fef1e16405328c16c4f21d4e943c4e2))\n\n## [2.0.23](https://github.com/webtorrent/webtorrent/compare/v2.0.22...v2.0.23) (2023-05-28)\n\n\n### Bug Fixes\n\n* drop randombytes ([#2546](https://github.com/webtorrent/webtorrent/issues/2546)) ([06b6548](https://github.com/webtorrent/webtorrent/commit/06b6548fab240f425704abe044dea1be5c5662fe))\n\n## [2.0.22](https://github.com/webtorrent/webtorrent/compare/v2.0.21...v2.0.22) (2023-05-27)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^10.0.9 ([#2545](https://github.com/webtorrent/webtorrent/issues/2545)) ([e28a7ba](https://github.com/webtorrent/webtorrent/commit/e28a7ba784c970bb33a7218a21c7d0b497be23a2))\n\n## [2.0.21](https://github.com/webtorrent/webtorrent/compare/v2.0.20...v2.0.21) (2023-05-27)\n\n\n### Performance Improvements\n\n* reduce the impact of request idle callback ([#2542](https://github.com/webtorrent/webtorrent/issues/2542)) ([36a3e36](https://github.com/webtorrent/webtorrent/commit/36a3e3617a03a39b1fbceadf265ab297ae647500))\n\n## [2.0.20](https://github.com/webtorrent/webtorrent/compare/v2.0.19...v2.0.20) (2023-05-27)\n\n\n### Bug Fixes\n\n* replace simple-peer with maintained one ([#2540](https://github.com/webtorrent/webtorrent/issues/2540)) ([2994641](https://github.com/webtorrent/webtorrent/commit/29946414dbc53a23adf61e91d302fa1ea82f543f))\n\n## [2.0.19](https://github.com/webtorrent/webtorrent/compare/v2.0.18...v2.0.19) (2023-05-27)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^10.0.8 ([714535b](https://github.com/webtorrent/webtorrent/commit/714535bc30466c5bf84a9c544747b9a16b57a21d))\n\n## [2.0.18](https://github.com/webtorrent/webtorrent/compare/v2.0.17...v2.0.18) (2023-05-07)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @webtorrent/semantic-release-config to v1.0.9 ([#2528](https://github.com/webtorrent/webtorrent/issues/2528)) ([19d26f0](https://github.com/webtorrent/webtorrent/commit/19d26f00b7a0a0617ca4c0d6d94806a5256353ed))\n\n## [2.0.17](https://github.com/webtorrent/webtorrent/compare/v2.0.16...v2.0.17) (2023-05-04)\n\n\n### Bug Fixes\n\n* http rejections handling ([#2525](https://github.com/webtorrent/webtorrent/issues/2525)) ([6232ea0](https://github.com/webtorrent/webtorrent/commit/6232ea0ab10b29a7c92697d9376c8065eaf29e6e))\n\n## [2.0.16](https://github.com/webtorrent/webtorrent/compare/v2.0.15...v2.0.16) (2023-04-03)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([7a7838c](https://github.com/webtorrent/webtorrent/commit/7a7838c158ca35ad9587e5316521a776b4a3a8f5))\n\n## [2.0.15](https://github.com/webtorrent/webtorrent/compare/v2.0.14...v2.0.15) (2023-03-20)\n\n\n### Bug Fixes\n\n* Replace setting blob 'mimeType' property with 'type' ([#2502](https://github.com/webtorrent/webtorrent/issues/2502)) ([869bdcd](https://github.com/webtorrent/webtorrent/commit/869bdcd438052ac6a23dd3ac73c77146cd853c83))\n\n## [2.0.14](https://github.com/webtorrent/webtorrent/compare/v2.0.13...v2.0.14) (2023-02-22)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^6.0.10 ([d9e6784](https://github.com/webtorrent/webtorrent/commit/d9e678471124638c1ffa4b305d4fa6bc1165aa4f))\n\n## [2.0.13](https://github.com/webtorrent/webtorrent/compare/v2.0.12...v2.0.13) (2023-02-13)\n\n\n### Bug Fixes\n\n* **deps:** update dependency hybrid-chunk-store to ^1.2.0 ([#2482](https://github.com/webtorrent/webtorrent/issues/2482)) ([792876b](https://github.com/webtorrent/webtorrent/commit/792876b10bcd5d6a16f98bb93f95ab691447df79))\n\n## [2.0.12](https://github.com/webtorrent/webtorrent/compare/v2.0.11...v2.0.12) (2023-02-06)\n\n\n### Bug Fixes\n\n* **deps:** update dependency uint8-util to ^2.1.9 ([#2480](https://github.com/webtorrent/webtorrent/issues/2480)) ([d9efb5d](https://github.com/webtorrent/webtorrent/commit/d9efb5d329a0404bda21430994c112e0534339ff))\n\n## [2.0.11](https://github.com/webtorrent/webtorrent/compare/v2.0.10...v2.0.11) (2023-02-01)\n\n\n### Bug Fixes\n\n* **deps:** update dependency cross-fetch-ponyfill to ^1.0.3 ([#2477](https://github.com/webtorrent/webtorrent/issues/2477)) ([970d937](https://github.com/webtorrent/webtorrent/commit/970d937b9086d5a72f0ec4608e232deb951236a8))\n\n## [2.0.10](https://github.com/webtorrent/webtorrent/compare/v2.0.9...v2.0.10) (2023-02-01)\n\n\n### Bug Fixes\n\n* **deps:** update dependency cross-fetch-ponyfill to ^1.0.3 ([#2475](https://github.com/webtorrent/webtorrent/issues/2475)) ([63eeed1](https://github.com/webtorrent/webtorrent/commit/63eeed1090202d47c6dab9a3743cb0e5be1a64c0))\n\n## [2.0.9](https://github.com/webtorrent/webtorrent/compare/v2.0.8...v2.0.9) (2023-02-01)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2474](https://github.com/webtorrent/webtorrent/issues/2474)) ([bfbf36b](https://github.com/webtorrent/webtorrent/commit/bfbf36be6fe3ddda7112333a13c256a4bf2d190b)), closes [#2476](https://github.com/webtorrent/webtorrent/issues/2476)\n\n## [2.0.8](https://github.com/webtorrent/webtorrent/compare/v2.0.7...v2.0.8) (2023-01-31)\n\n\n### Bug Fixes\n\n* **deps:** update dependency uint8-util to ^2.1.7 ([#2473](https://github.com/webtorrent/webtorrent/issues/2473)) ([9a6edff](https://github.com/webtorrent/webtorrent/commit/9a6edff4ae25dfcef1dd168b1ef5066855eccbb0))\n\n## [2.0.7](https://github.com/webtorrent/webtorrent/compare/v2.0.6...v2.0.7) (2023-01-31)\n\n\n### Bug Fixes\n\n* **deps:** update dependency parse-torrent to ^11.0.5 ([#2470](https://github.com/webtorrent/webtorrent/issues/2470)) ([9447cd6](https://github.com/webtorrent/webtorrent/commit/9447cd65d522cd84d2abbe36bf9bc950631e6b7c))\n\n## [2.0.6](https://github.com/webtorrent/webtorrent/compare/v2.0.5...v2.0.6) (2023-01-30)\n\n\n### Performance Improvements\n\n* drop simple-get ([#2448](https://github.com/webtorrent/webtorrent/issues/2448)) ([b3c8376](https://github.com/webtorrent/webtorrent/commit/b3c83763abc964b705d66272ec7d76300ca0e4d2))\n\n## [2.0.5](https://github.com/webtorrent/webtorrent/compare/v2.0.4...v2.0.5) (2023-01-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency parse-torrent to v11 ([#2459](https://github.com/webtorrent/webtorrent/issues/2459)) ([4cb909d](https://github.com/webtorrent/webtorrent/commit/4cb909df7f368d4aeec1345f10c90ab4c44d8308)), closes [#2461](https://github.com/webtorrent/webtorrent/issues/2461)\n\n## [2.0.4](https://github.com/webtorrent/webtorrent/compare/v2.0.3...v2.0.4) (2023-01-28)\n\n\n### Bug Fixes\n\n* make server index pages return links with absolute urls ([#2455](https://github.com/webtorrent/webtorrent/issues/2455)) ([f2687e2](https://github.com/webtorrent/webtorrent/commit/f2687e28ea370c8e9e2ec4a8ed15c398c01f645a)), closes [#2454](https://github.com/webtorrent/webtorrent/issues/2454)\n\n## [2.0.3](https://github.com/webtorrent/webtorrent/compare/v2.0.2...v2.0.3) (2023-01-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency fs-chunk-store to ^4.0.1 ([#2463](https://github.com/webtorrent/webtorrent/issues/2463)) ([bb7c640](https://github.com/webtorrent/webtorrent/commit/bb7c6405b264223d7af13e21c654e575c2499b79))\n\n## [2.0.2](https://github.com/webtorrent/webtorrent/compare/v2.0.1...v2.0.2) (2023-01-28)\n\n\n### Performance Improvements\n\n* drop streamx ([#2462](https://github.com/webtorrent/webtorrent/issues/2462)) ([cde79ed](https://github.com/webtorrent/webtorrent/commit/cde79edf540932f10c9af26ccc5c56489e362a9f))\n\n## [2.0.1](https://github.com/webtorrent/webtorrent/compare/v2.0.0...v2.0.1) (2023-01-25)\n\n\n### Bug Fixes\n\n* **deps:** update dependency hybrid-chunk-store to ^1.1.3 ([2b7c435](https://github.com/webtorrent/webtorrent/commit/2b7c43576645baf1208c4352ce1e4dcc96554b3c))\n\n# [2.0.0](https://github.com/webtorrent/webtorrent/compare/v1.9.7...v2.0.0) (2023-01-23)\n\n\n### Bug Fixes\n\n* dependencies ([9bd7933](https://github.com/webtorrent/webtorrent/commit/9bd7933e4a1858dac20a668d1a12c26903cf77e5))\n* deprecate render-media ([#2180](https://github.com/webtorrent/webtorrent/issues/2180)) ([8b5ecea](https://github.com/webtorrent/webtorrent/commit/8b5ecea9a12be44fb258b2da31c3e1e35e9b725e))\n* **deps:** update dependency streamx to ^2.13.1 ([#2430](https://github.com/webtorrent/webtorrent/issues/2430)) ([fb5f5a6](https://github.com/webtorrent/webtorrent/commit/fb5f5a65f373a61b41d83b7ec5a5c0ca85eb7343))\n* **deps:** update dependency streamx to ^2.13.2 ([#2438](https://github.com/webtorrent/webtorrent/issues/2438)) ([4a177d7](https://github.com/webtorrent/webtorrent/commit/4a177d737a123aec2362b8be6c75a6dbabb991ec))\n* documentation, unity ([9ae5f17](https://github.com/webtorrent/webtorrent/commit/9ae5f177de6b7ba40440740b885098c58229e445))\n* ESM browser tests ([975c463](https://github.com/webtorrent/webtorrent/commit/975c46399fbda71a0baac1c81798156789fd83ca))\n* remove dead code ([2839c7a](https://github.com/webtorrent/webtorrent/commit/2839c7a55222d5b74feb2ce423b3cc2be61ee4e8))\n* remove tap-spec where it's not necessary ([5188eca](https://github.com/webtorrent/webtorrent/commit/5188ecac01b30115b20e87bfc4fec46348ea7f8d))\n* revert bittorent-protocol ver ([28df830](https://github.com/webtorrent/webtorrent/commit/28df830b2273200cf499fb3327259cd4c9c49eb9))\n* standard [whitespace] ([a4bc0c3](https://github.com/webtorrent/webtorrent/commit/a4bc0c3c5167405d0b93f8f061d9bad3229414fd))\n* standard linting ([a64a719](https://github.com/webtorrent/webtorrent/commit/a64a719e6a854f8d22d5b37781ee268441ca967d))\n\n\n### Continuous Integration\n\n* fix release node 18 ([25eb995](https://github.com/webtorrent/webtorrent/commit/25eb995c9804a0a4e6022e0be3b0b7e46ce60656))\n\n\n* Merge pull request #2260 from webtorrent/v2 ([f8c545a](https://github.com/webtorrent/webtorrent/commit/f8c545a7da0f0fb9a35c4377d249ee1e946540c4)), closes [#2260](https://github.com/webtorrent/webtorrent/issues/2260)\n* feat, perf: w3c-like File, file-iterator (#2414) ([69d85a8](https://github.com/webtorrent/webtorrent/commit/69d85a8b2d05f09702df5df40894c4e56c22d52d)), closes [#2414](https://github.com/webtorrent/webtorrent/issues/2414)\n\n\n### Features\n\n* esm ([98353d9](https://github.com/webtorrent/webtorrent/commit/98353d910a11e5cc90b4ed86bca558586cb787d5))\n* rescan of torrent should get all (in)valid events ([#1903](https://github.com/webtorrent/webtorrent/issues/1903)) ([4745739](https://github.com/webtorrent/webtorrent/commit/474573930a0f3c1cac242fb3b9616db881462d00))\n* sw-renderer tests ([73aff7f](https://github.com/webtorrent/webtorrent/commit/73aff7f1c22d340470777e462f9465736d0ed46d))\n* unify HTTP server and SW renderer ([7aeea17](https://github.com/webtorrent/webtorrent/commit/7aeea1757000741a04409dadeaf9fab3966b399d))\n* use storage (FSA+IDB) instead of memory in browser ([00e1c9f](https://github.com/webtorrent/webtorrent/commit/00e1c9f16d5d82bf1bfe3f889d29d8ce450fc787))\n\n\n### Performance Improvements\n\n* drop browserify ([c73d28e](https://github.com/webtorrent/webtorrent/commit/c73d28e7c17ebeb1921871275adb7a7899dada91))\n* drop chunk store stream ([cf4d593](https://github.com/webtorrent/webtorrent/commit/cf4d5938084f01f3004884f26abaea65fc3cb365))\n* drop rusha, drop Buffer ([#2390](https://github.com/webtorrent/webtorrent/issues/2390)) ([9ac1dfa](https://github.com/webtorrent/webtorrent/commit/9ac1dfacb25af85bfe2360fdc1872e41034e9efb))\n* use mime-lite ([c83734c](https://github.com/webtorrent/webtorrent/commit/c83734c5a2e0ba0fe789dda81f5f610581b4c973))\n\n\n### BREAKING CHANGES\n\n* v2\n* ESM only, drop node 12 and ndoe 14\n* deprecate getBuffer\n\n* fix: reading when destroyed\n\n## [1.9.7](https://github.com/webtorrent/webtorrent/compare/v1.9.6...v1.9.7) (2023-01-12)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2424](https://github.com/webtorrent/webtorrent/issues/2424)) ([1b002db](https://github.com/webtorrent/webtorrent/commit/1b002db3ec5395c3bccec3619480e3ad9af30e25))\n\n## [1.9.6](https://github.com/webtorrent/webtorrent/compare/v1.9.5...v1.9.6) (2022-12-03)\n\n\n### Bug Fixes\n\n* fix: fix: error loop ([14fe83f](https://github.com/webtorrent/webtorrent/commit/14fe83fe0088123b7caab4372217bc151094f9a3))\n\n## [1.9.5](https://github.com/webtorrent/webtorrent/compare/v1.9.4...v1.9.5) (2022-12-03)\n\n\n### Bug Fixes\n\n* infinite error loop, connecting after destroy ([79dbf69](https://github.com/webtorrent/webtorrent/commit/79dbf697cb50dc64e42139581603ac228003e1f4))\n\n## [1.9.4](https://github.com/webtorrent/webtorrent/compare/v1.9.3...v1.9.4) (2022-11-21)\n\n\n### Bug Fixes\n\n* typo in `removePeer` ([#2408](https://github.com/webtorrent/webtorrent/issues/2408)) ([83d5f72](https://github.com/webtorrent/webtorrent/commit/83d5f728b261bae5ff05160898738434f7512abb))\n\n## [1.9.3](https://github.com/webtorrent/webtorrent/compare/v1.9.2...v1.9.3) (2022-11-18)\n\n\n### Bug Fixes\n\n* removePeer error after destroy ([36a64a1](https://github.com/webtorrent/webtorrent/commit/36a64a1b5680929841e91cee5aef07b8b1359b7c))\n\n## [1.9.2](https://github.com/webtorrent/webtorrent/compare/v1.9.1...v1.9.2) (2022-11-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^5.0.9 ([#2392](https://github.com/webtorrent/webtorrent/issues/2392)) ([d5139ed](https://github.com/webtorrent/webtorrent/commit/d5139edf6dc91b04dd729b5d6aa08c111502b25a))\n\n## [1.9.1](https://github.com/webtorrent/webtorrent/compare/v1.9.0...v1.9.1) (2022-10-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency streamx to ^2.12.5 ([#2366](https://github.com/webtorrent/webtorrent/issues/2366)) ([457a2d3](https://github.com/webtorrent/webtorrent/commit/457a2d3d5def6bb75d2551f34ab9fa350ec4a4e5))\n\n# [1.9.0](https://github.com/webtorrent/webtorrent/compare/v1.8.32...v1.9.0) (2022-10-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency fs-chunk-store to v3 ([#2380](https://github.com/webtorrent/webtorrent/issues/2380)) ([9abd966](https://github.com/webtorrent/webtorrent/commit/9abd96691ab73ebc8fb10aa79a67b5db0c92ec72))\n\n\n### Features\n\n* add chitchatter link ([#2388](https://github.com/webtorrent/webtorrent/issues/2388)) ([7ef22f7](https://github.com/webtorrent/webtorrent/commit/7ef22f726bed2dfaa6f29ad633955f59db6a9022))\n\n## [1.8.32](https://github.com/webtorrent/webtorrent/compare/v1.8.31...v1.8.32) (2022-10-09)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^9.4.14 ([8fadd4f](https://github.com/webtorrent/webtorrent/commit/8fadd4f437a9e60da4cbc49b3b6d6e65db38373f))\n\n## [1.8.31](https://github.com/webtorrent/webtorrent/compare/v1.8.30...v1.8.31) (2022-10-08)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-dht to ^10.0.6 ([#2384](https://github.com/webtorrent/webtorrent/issues/2384)) ([34089f8](https://github.com/webtorrent/webtorrent/commit/34089f836bcb24df275f83b3026af548e32d02e9))\n\n## [1.8.30](https://github.com/webtorrent/webtorrent/compare/v1.8.29...v1.8.30) (2022-09-12)\n\n\n### Bug Fixes\n\n* return duplicate torrent on Webtorrent.add() ([#2372](https://github.com/webtorrent/webtorrent/issues/2372)) ([05d27bf](https://github.com/webtorrent/webtorrent/commit/05d27bfd449aa705cefefe74d4a9eef327f63b4a))\n\n## [1.8.29](https://github.com/webtorrent/webtorrent/compare/v1.8.28...v1.8.29) (2022-09-03)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^5.0.6 ([03a0f50](https://github.com/webtorrent/webtorrent/commit/03a0f500013172a5070dd5e8e67063bea6eaf190))\n\n## [1.8.28](https://github.com/webtorrent/webtorrent/compare/v1.8.27...v1.8.28) (2022-09-02)\n\n\n### Bug Fixes\n\n* **deps:** update dependency fast-blob-stream to ^1.1.1 ([a441dea](https://github.com/webtorrent/webtorrent/commit/a441dea5d1a20982e9ad3fbe5237bbb02fb55898))\n* **deps:** update dependency join-async-iterator to ^1.1.1 ([09b9958](https://github.com/webtorrent/webtorrent/commit/09b995814a2b5192cd9d9dd9a620d2b3dbdb5ab7))\n\n## [1.8.27](https://github.com/webtorrent/webtorrent/compare/v1.8.26...v1.8.27) (2022-09-02)\n\n\n### Bug Fixes\n\n* dedupe packages ([9ea33c2](https://github.com/webtorrent/webtorrent/commit/9ea33c2c1cd3ea9fcfa66569a3fb94148afd9869))\n* drop multi-stream ([5d87d1b](https://github.com/webtorrent/webtorrent/commit/5d87d1b32356f6b75ed4f9aefe91f3ddf1ecebdb))\n* null opts causing error ([3a8f901](https://github.com/webtorrent/webtorrent/commit/3a8f901a48503a5c767b6174904e2c062d403a6a))\n* use streamx instead of stream ([8b97ee8](https://github.com/webtorrent/webtorrent/commit/8b97ee8cc18b05e0d20135ea8f1651e97bb65c6f))\n\n## [1.8.26](https://github.com/webtorrent/webtorrent/compare/v1.8.25...v1.8.26) (2022-07-04)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^5.0.4 ([3728336](https://github.com/webtorrent/webtorrent/commit/37283369f3476d32ac9ca85c2c2da4bd4fee273c))\n\n## [1.8.25](https://github.com/webtorrent/webtorrent/compare/v1.8.24...v1.8.25) (2022-07-03)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^5.0.3 ([5009d10](https://github.com/webtorrent/webtorrent/commit/5009d1018bdec96afd4bf15e5f7143951623fd48))\n\n## [1.8.24](https://github.com/webtorrent/webtorrent/compare/v1.8.23...v1.8.24) (2022-06-23)\n\n\n### Bug Fixes\n\n* support stream cancelling ([#2335](https://github.com/webtorrent/webtorrent/issues/2335)) ([2e4f91f](https://github.com/webtorrent/webtorrent/commit/2e4f91f668ea867d768291e9efd3e1c1eb825b97))\n\n## [1.8.23](https://github.com/webtorrent/webtorrent/compare/v1.8.22...v1.8.23) (2022-06-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^9.4.13 ([1e3373a](https://github.com/webtorrent/webtorrent/commit/1e3373ab9e6dd16e5b10a2e32988386615f6cf28))\n\n## [1.8.22](https://github.com/webtorrent/webtorrent/compare/v1.8.21...v1.8.22) (2022-05-24)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-dht to ^10.0.4 ([327d723](https://github.com/webtorrent/webtorrent/commit/327d7234a85f38bf8d397e41875a5603a8d175d1))\n\n## [1.8.21](https://github.com/webtorrent/webtorrent/compare/v1.8.20...v1.8.21) (2022-05-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency throughput to ^1.0.1 ([#2321](https://github.com/webtorrent/webtorrent/issues/2321)) ([d53d95e](https://github.com/webtorrent/webtorrent/commit/d53d95e1ed75a288cea706d65fb660f2be3a02a0))\n\n## [1.8.20](https://github.com/webtorrent/webtorrent/compare/v1.8.19...v1.8.20) (2022-05-14)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-dht to ^10.0.3 ([#2320](https://github.com/webtorrent/webtorrent/issues/2320)) ([2ebbd8e](https://github.com/webtorrent/webtorrent/commit/2ebbd8eacfd0d7778357ca0f44ead331ba439a26))\n\n## [1.8.19](https://github.com/webtorrent/webtorrent/compare/v1.8.18...v1.8.19) (2022-05-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^9.4.12 ([36e931a](https://github.com/webtorrent/webtorrent/commit/36e931aff5e44fc5aa298a6166bfe7b4e1560499))\n\n## [1.8.18](https://github.com/webtorrent/webtorrent/compare/v1.8.17...v1.8.18) (2022-05-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-tracker to v9.18.6 ([#2315](https://github.com/webtorrent/webtorrent/issues/2315)) ([b63d652](https://github.com/webtorrent/webtorrent/commit/b63d652229c4cf55a4eebbe95c98a62716bcc377))\n\n## [1.8.17](https://github.com/webtorrent/webtorrent/compare/v1.8.16...v1.8.17) (2022-05-11)\n\n\n### Bug Fixes\n\n* measure transfer rates without using timeouts ([#2314](https://github.com/webtorrent/webtorrent/issues/2314)) ([522ee4c](https://github.com/webtorrent/webtorrent/commit/522ee4cd14d3b41e92c3978e9816cb66e00233f0))\n\n## [1.8.16](https://github.com/webtorrent/webtorrent/compare/v1.8.15...v1.8.16) (2022-04-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^3.5.5 ([3522080](https://github.com/webtorrent/webtorrent/commit/35220804054c5369b5e88a39411125f0273b2adc))\n\n## [1.8.15](https://github.com/webtorrent/webtorrent/compare/v1.8.14...v1.8.15) (2022-04-26)\n\n## [1.8.14](https://github.com/webtorrent/webtorrent/compare/v1.8.13...v1.8.14) (2022-04-22)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bitfield to ^4.1.0 ([#2303](https://github.com/webtorrent/webtorrent/issues/2303)) ([a778522](https://github.com/webtorrent/webtorrent/commit/a7785227d88fbac22a1b627460694b3523833fde))\n* **deps:** update dependency bittorrent-protocol to ^3.5.3 ([#2302](https://github.com/webtorrent/webtorrent/issues/2302)) ([11f9426](https://github.com/webtorrent/webtorrent/commit/11f9426ee9ef3b800ac978afa5082809eb87c545))\n\n## [1.8.13](https://github.com/webtorrent/webtorrent/compare/v1.8.12...v1.8.13) (2022-03-30)\n\n\n### Bug Fixes\n\n* **deps:** update dependency fs-chunk-store to ^2.0.5 ([2eef418](https://github.com/webtorrent/webtorrent/commit/2eef41884ffbee8f723ea2846e58756066983a0b))\n\n## [1.8.12](https://github.com/webtorrent/webtorrent/compare/v1.8.11...v1.8.12) (2022-03-28)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^3.5.2 ([13fb0d6](https://github.com/webtorrent/webtorrent/commit/13fb0d60df963edb83945c8b040159c560e67368))\n\n## [1.8.11](https://github.com/webtorrent/webtorrent/compare/v1.8.10...v1.8.11) (2022-03-27)\n\n## [1.8.10](https://github.com/webtorrent/webtorrent/compare/v1.8.9...v1.8.10) (2022-03-27)\n\n\n### Bug Fixes\n\n* web seed request URLs ([#2267](https://github.com/webtorrent/webtorrent/issues/2267)) ([5b4880a](https://github.com/webtorrent/webtorrent/commit/5b4880aee559b4b8d294503039d07af98b09418c))\n\n## [1.8.9](https://github.com/webtorrent/webtorrent/compare/v1.8.8...v1.8.9) (2022-03-26)\n\n\n### Bug Fixes\n\n* **deps:** update dependency parse-torrent to ^9.1.5 ([650a8c9](https://github.com/webtorrent/webtorrent/commit/650a8c93a68852da8beefd12c28a23ec4e1dc2a4))\n\n## [1.8.8](https://github.com/webtorrent/webtorrent/compare/v1.8.7...v1.8.8) (2022-03-25)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.3.4 ([017c488](https://github.com/webtorrent/webtorrent/commit/017c4889ff62d9b74a457fe8cf5d1699686a4754))\n\n## [1.8.7](https://github.com/webtorrent/webtorrent/compare/v1.8.6...v1.8.7) (2022-03-24)\n\n## [1.8.6](https://github.com/webtorrent/webtorrent/compare/v1.8.5...v1.8.6) (2022-03-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^5.0.2 ([#2276](https://github.com/webtorrent/webtorrent/issues/2276)) ([f389f87](https://github.com/webtorrent/webtorrent/commit/f389f8755de9ef8725adba8163347f7fd65fb069))\n\n## [1.8.5](https://github.com/webtorrent/webtorrent/compare/v1.8.4...v1.8.5) (2022-03-06)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^9.4.9 ([5a08647](https://github.com/webtorrent/webtorrent/commit/5a086471a8499ee41e16b4db20200baa0458d849))\n\n## [1.8.4](https://github.com/webtorrent/webtorrent/compare/v1.8.3...v1.8.4) (2022-03-03)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^9.4.8 ([#2272](https://github.com/webtorrent/webtorrent/issues/2272)) ([aa2fa59](https://github.com/webtorrent/webtorrent/commit/aa2fa59a4c7c166a52ecd9060191b6e695d3c85f))\n\n## [1.8.3](https://github.com/webtorrent/webtorrent/compare/v1.8.2...v1.8.3) (2022-02-21)\n\n## [1.8.2](https://github.com/webtorrent/webtorrent/compare/v1.8.1...v1.8.2) (2022-02-17)\n\n\n### Bug Fixes\n\n* **deps:** update dependency simple-peer to ^9.11.1 ([34df41a](https://github.com/webtorrent/webtorrent/commit/34df41a05438bcb765077187e04ac2d95d74ea74))\n\n## [1.8.1](https://github.com/webtorrent/webtorrent/compare/v1.8.0...v1.8.1) (2022-02-03)\n\n\n### Bug Fixes\n\n* going for 1.8.1 ([e39057f](https://github.com/webtorrent/webtorrent/commit/e39057f634a66ce813482f87d2bfa862ebce5737))\n\n# [1.8.0](https://github.com/webtorrent/webtorrent/compare/v1.7.4...v1.8.0) (2022-02-03)\n\n\n### Features\n\n* 1.8.0 fixing ([cac563b](https://github.com/webtorrent/webtorrent/commit/cac563b37d754fc4fa6993717bb6d1077b2bfd62))\n\n## [1.7.4](https://github.com/webtorrent/webtorrent/compare/v1.7.3...v1.7.4) (2022-02-03)\n\n\n### Bug Fixes\n\n* getStreamURL docs ([#2257](https://github.com/webtorrent/webtorrent/issues/2257)) ([69bdd93](https://github.com/webtorrent/webtorrent/commit/69bdd93bdbe64ab9cc2c22e700560ecea02645e2))\n\n## [1.7.3](https://github.com/webtorrent/webtorrent/compare/v1.7.2...v1.7.3) (2022-02-03)\n\n## [1.7.2](https://github.com/webtorrent/webtorrent/compare/v1.7.1...v1.7.2) (2022-01-27)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2247](https://github.com/webtorrent/webtorrent/issues/2247)) ([6345ebe](https://github.com/webtorrent/webtorrent/commit/6345ebe4bae018a01bab3a25202a1864fb2230d5))\n\n## [1.7.1](https://github.com/webtorrent/webtorrent/compare/v1.7.0...v1.7.1) (2022-01-20)\n\n# [1.7.0](https://github.com/webtorrent/webtorrent/compare/v1.6.0...v1.7.0) (2022-01-20)\n\n\n### Features\n\n* add reqq field support ([#2246](https://github.com/webtorrent/webtorrent/issues/2246)) ([8de2a13](https://github.com/webtorrent/webtorrent/commit/8de2a136d68366d298e3ec01b5e4b17a4c4e074c))\n\n# [1.6.0](https://github.com/webtorrent/webtorrent/compare/v1.5.11...v1.6.0) (2022-01-17)\n\n\n### Features\n\n* add BEP6 Fast Extension support ([#2243](https://github.com/webtorrent/webtorrent/issues/2243)) ([4f02de3](https://github.com/webtorrent/webtorrent/commit/4f02de3a445f3a9eb46c49a8964c9660bdf6e5d7))\n\n## [1.5.11](https://github.com/webtorrent/webtorrent/compare/v1.5.10...v1.5.11) (2022-01-14)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.3.3 ([#2228](https://github.com/webtorrent/webtorrent/issues/2228)) ([e268096](https://github.com/webtorrent/webtorrent/commit/e268096c201bc0b9e28d9c94cd7b9287c9f0f2e8))\n* **deps:** update dependency mime to v3 ([#2216](https://github.com/webtorrent/webtorrent/issues/2216)) ([77da8cb](https://github.com/webtorrent/webtorrent/commit/77da8cb629078d55870684e56e0e0b2091c7e723))\n\n## [1.5.10](https://github.com/webtorrent/webtorrent/compare/v1.5.9...v1.5.10) (2022-01-14)\n\n\n### Bug Fixes\n\n* use @webtorrent/http-node ([699d747](https://github.com/webtorrent/webtorrent/commit/699d747c477a26a5c8d4e6f1537e3e67b6c6ad94))\n\n## [1.5.9](https://github.com/webtorrent/webtorrent/compare/v1.5.8...v1.5.9) (2022-01-12)\n\n## [1.5.8](https://github.com/webtorrent/webtorrent/compare/v1.5.7...v1.5.8) (2021-10-26)\n\n\n### Bug Fixes\n\n* Prep for esm ([#2205](https://github.com/webtorrent/webtorrent/issues/2205)) ([ba6b799](https://github.com/webtorrent/webtorrent/commit/ba6b799ff614fedf26a29448620604aae3d2afec))\n\n## [1.5.7](https://github.com/webtorrent/webtorrent/compare/v1.5.6...v1.5.7) (2021-10-25)\n\n\n### Bug Fixes\n\n* add storeOpts, specify store path, align with docs ([#2121](https://github.com/webtorrent/webtorrent/issues/2121)) ([6cd9b5f](https://github.com/webtorrent/webtorrent/commit/6cd9b5f74d7cd676259cd11daa2a568a3c5666d9))\n\n## [1.5.6](https://github.com/webtorrent/webtorrent/compare/v1.5.5...v1.5.6) (2021-10-05)\n\n\n### Bug Fixes\n\n* http-node git location ([67ddac0](https://github.com/webtorrent/webtorrent/commit/67ddac03bc02e2923ec30af7054745a395d0280c))\n\n## [1.5.5](https://github.com/webtorrent/webtorrent/compare/v1.5.4...v1.5.5) (2021-09-02)\n\n\n### Bug Fixes\n\n* DHT cleanup after torrent removal ([#2185](https://github.com/webtorrent/webtorrent/issues/2185)) ([320541f](https://github.com/webtorrent/webtorrent/commit/320541f271fdbd7303f544b6e99ab6b0a450fd8c)), closes [#1289](https://github.com/webtorrent/webtorrent/issues/1289)\n\n## [1.5.4](https://github.com/webtorrent/webtorrent/compare/v1.5.3...v1.5.4) (2021-08-25)\n\n\n### Bug Fixes\n\n* handle done event when new files selected ([#2183](https://github.com/webtorrent/webtorrent/issues/2183)) ([c543788](https://github.com/webtorrent/webtorrent/commit/c5437886086f455c61f0ff71bbfecd3f9e6b2609))\n\n## [1.5.3](https://github.com/webtorrent/webtorrent/compare/v1.5.2...v1.5.3) (2021-08-20)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @webtorrent/semantic-release-config to v1.0.7 ([#2175](https://github.com/webtorrent/webtorrent/issues/2175)) ([404de99](https://github.com/webtorrent/webtorrent/commit/404de999f7dd83e7884c23511e92a3f5b28d784d))\n\n## [1.5.2](https://github.com/webtorrent/webtorrent/compare/v1.5.1...v1.5.2) (2021-08-20)\n\n## [1.5.1](https://github.com/webtorrent/webtorrent/compare/v1.5.0...v1.5.1) (2021-08-20)\n\n\n### Bug Fixes\n\n* **deps:** update dependency @webtorrent/semantic-release-config to v1.0.6 ([#2173](https://github.com/webtorrent/webtorrent/issues/2173)) ([210bda9](https://github.com/webtorrent/webtorrent/commit/210bda96533239c5a85eff4020c4684c29a3b758))\n\n# [1.5.0](https://github.com/webtorrent/webtorrent/compare/v1.4.0...v1.5.0) (2021-08-19)\n\n\n### Features\n\n* add service worker server as an alternative to renderMedia ([#2098](https://github.com/webtorrent/webtorrent/issues/2098)) ([604943e](https://github.com/webtorrent/webtorrent/commit/604943e325c68721251a71c29d94e6a07ce0b31c))\n\n# [1.4.0](https://github.com/webtorrent/webtorrent/compare/v1.3.10...v1.4.0) (2021-08-17)\n\n\n### Features\n\n* Add PE/MSE support ([#1820](https://github.com/webtorrent/webtorrent/issues/1820)) ([9938c94](https://github.com/webtorrent/webtorrent/commit/9938c949eee9c69c6774767e885e40f0a73898d9)), closes [#1384](https://github.com/webtorrent/webtorrent/issues/1384)\n\n## [1.3.10](https://github.com/webtorrent/webtorrent/compare/v1.3.9...v1.3.10) (2021-08-16)\n\n## [1.3.9](https://github.com/webtorrent/webtorrent/compare/v1.3.8...v1.3.9) (2021-08-06)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^5.0.1 ([#2167](https://github.com/webtorrent/webtorrent/issues/2167)) ([283cbf8](https://github.com/webtorrent/webtorrent/commit/283cbf84bffd4fbd0b267796dc45f00491bcdc92))\n\n## [1.3.8](https://github.com/webtorrent/webtorrent/compare/v1.3.7...v1.3.8) (2021-08-06)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to v5 ([#2165](https://github.com/webtorrent/webtorrent/issues/2165)) ([501fd9e](https://github.com/webtorrent/webtorrent/commit/501fd9ed79d1127d74a29c47e230697ed372ba5e))\n\n## [1.3.7](https://github.com/webtorrent/webtorrent/compare/v1.3.6...v1.3.7) (2021-08-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency torrent-discovery to ^9.4.4 ([#2164](https://github.com/webtorrent/webtorrent/issues/2164)) ([fb59617](https://github.com/webtorrent/webtorrent/commit/fb59617c016d5e64a86b3d20032664ba751019a9))\n\n## [1.3.6](https://github.com/webtorrent/webtorrent/compare/v1.3.5...v1.3.6) (2021-08-05)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-dht to ^10.0.2 ([#2163](https://github.com/webtorrent/webtorrent/issues/2163)) ([fc89c78](https://github.com/webtorrent/webtorrent/commit/fc89c7822eecdece2b80bb2841e5131722f8bac3))\n\n## [1.3.5](https://github.com/webtorrent/webtorrent/compare/v1.3.4...v1.3.5) (2021-08-04)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2162](https://github.com/webtorrent/webtorrent/issues/2162)) ([a00688b](https://github.com/webtorrent/webtorrent/commit/a00688b881bdec5109eeb45b6c7186d771ce5788))\n\n## [1.3.4](https://github.com/webtorrent/webtorrent/compare/v1.3.3...v1.3.4) (2021-07-30)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2149](https://github.com/webtorrent/webtorrent/issues/2149)) ([d03203d](https://github.com/webtorrent/webtorrent/commit/d03203d01fe7a98b6d8631ebd0ceba2ea4b5ab22))\n\n## [1.3.3](https://github.com/webtorrent/webtorrent/compare/v1.3.2...v1.3.3) (2021-07-25)\n\n\n### Bug Fixes\n\n* log error when failing to load blocklist ip set ([c0a07fb](https://github.com/webtorrent/webtorrent/commit/c0a07fbbbc3fb39dfeddf76383f22710b8ee1d54))\n\n## [1.3.2](https://github.com/webtorrent/webtorrent/compare/v1.3.1...v1.3.2) (2021-07-24)\n\n\n### Bug Fixes\n\n* **deps:** update dependency speed-limiter to ^1.0.2 ([#2153](https://github.com/webtorrent/webtorrent/issues/2153)) ([17fb0e2](https://github.com/webtorrent/webtorrent/commit/17fb0e240fafc396bfd124ae667238c5c21d02e3))\n\n## [1.3.1](https://github.com/webtorrent/webtorrent/compare/v1.3.0...v1.3.1) (2021-07-24)\n\n\n### Bug Fixes\n\n* speed limit for zero ([#2155](https://github.com/webtorrent/webtorrent/issues/2155)) ([88cca71](https://github.com/webtorrent/webtorrent/commit/88cca71fb46c1b9a65085ea674f5af5be4407a17))\n\n# [1.3.0](https://github.com/webtorrent/webtorrent/compare/v1.2.6...v1.3.0) (2021-07-23)\n\n\n### Features\n\n* add speed limit to client ([#2062](https://github.com/webtorrent/webtorrent/issues/2062)) ([39bb33c](https://github.com/webtorrent/webtorrent/commit/39bb33c3cf694cdee45378ea4b30c66c93576d2a))\n\n## [1.2.6](https://github.com/webtorrent/webtorrent/compare/v1.2.5...v1.2.6) (2021-07-23)\n\n\n### Bug Fixes\n\n* **deps:** update dependency create-torrent to ^4.7.1 ([#2145](https://github.com/webtorrent/webtorrent/issues/2145)) ([a75f1aa](https://github.com/webtorrent/webtorrent/commit/a75f1aa4b6173a0958d3c367070e27f0ef4e5e54))\n\n## [1.2.5](https://github.com/webtorrent/webtorrent/compare/v1.2.4...v1.2.5) (2021-07-19)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-dht to ^10.0.1 ([#2139](https://github.com/webtorrent/webtorrent/issues/2139)) ([8476d9c](https://github.com/webtorrent/webtorrent/commit/8476d9cd8b218b74bc3544de007680bcc1db9d31))\n\n## [1.2.4](https://github.com/webtorrent/webtorrent/compare/v1.2.3...v1.2.4) (2021-07-13)\n\n\n### Bug Fixes\n\n* call public FileStream.destroy method so cb is defined ([#2135](https://github.com/webtorrent/webtorrent/issues/2135)) ([b035cbe](https://github.com/webtorrent/webtorrent/commit/b035cbe9ea59d3fcfc6467dcf4f2f49da2f7c3d8))\n\n## [1.2.3](https://github.com/webtorrent/webtorrent/compare/v1.2.2...v1.2.3) (2021-07-13)\n\n\n### Bug Fixes\n\n* store.put is async and might fail ([#2006](https://github.com/webtorrent/webtorrent/issues/2006)) ([3b3f65a](https://github.com/webtorrent/webtorrent/commit/3b3f65afaecb88dcdbb1f342a3643343eaf22c80))\n\n## [1.2.2](https://github.com/webtorrent/webtorrent/compare/v1.2.1...v1.2.2) (2021-07-11)\n\n\n### Bug Fixes\n\n* **deps:** update dependency debug to ^4.3.2 ([#2127](https://github.com/webtorrent/webtorrent/issues/2127)) ([33f813d](https://github.com/webtorrent/webtorrent/commit/33f813d0a882d9d8727f5875a48ae40aab780656))\n\n## [1.2.1](https://github.com/webtorrent/webtorrent/compare/v1.2.0...v1.2.1) (2021-07-11)\n\n\n### Bug Fixes\n\n* modernize code ([#2134](https://github.com/webtorrent/webtorrent/issues/2134)) ([46033ae](https://github.com/webtorrent/webtorrent/commit/46033ae52eca6e22301bb8ed9566c498d3494711))\n\n# [1.2.0](https://github.com/webtorrent/webtorrent/compare/v1.1.6...v1.2.0) (2021-07-09)\n\n\n### Features\n\n* support adding paused torrents. ([#2004](https://github.com/webtorrent/webtorrent/issues/2004)) ([5c79c0a](https://github.com/webtorrent/webtorrent/commit/5c79c0a01424087e4c37776d86ef745191504df4))\n\n## [1.1.6](https://github.com/webtorrent/webtorrent/compare/v1.1.5...v1.1.6) (2021-07-08)\n\n\n### Bug Fixes\n\n* **deps:** update dependency bittorrent-protocol to ^3.4.2 ([#2132](https://github.com/webtorrent/webtorrent/issues/2132)) ([7223cbf](https://github.com/webtorrent/webtorrent/commit/7223cbf7918e543542acf9d53da4bec0753a5e00))\n\n## [1.1.5](https://github.com/webtorrent/webtorrent/compare/v1.1.4...v1.1.5) (2021-07-06)\n\n\n### Bug Fixes\n\n* ensure uTP peer address is IPv4 ([#2125](https://github.com/webtorrent/webtorrent/issues/2125)) ([100a2ae](https://github.com/webtorrent/webtorrent/commit/100a2aebe23420dd70842b3948896f8fecfee235))\n\n## [1.1.4](https://github.com/webtorrent/webtorrent/compare/v1.1.3...v1.1.4) (2021-07-03)\n\n\n### Bug Fixes\n\n* **deps:** update webtorrent ([#2126](https://github.com/webtorrent/webtorrent/issues/2126)) ([87c69be](https://github.com/webtorrent/webtorrent/commit/87c69bea112b6a33175962fefac14c825a690312))\n\n## [1.1.3](https://github.com/webtorrent/webtorrent/compare/v1.1.2...v1.1.3) (2021-07-02)\n\n\n### Bug Fixes\n\n* add preversion ([55fe206](https://github.com/webtorrent/webtorrent/commit/55fe206e3bd6b48e29018fb7f7bdf6e8055248a2))\n\n## [1.1.2](https://github.com/webtorrent/webtorrent/compare/v1.1.1...v1.1.2) (2021-07-02)\n\n## [1.1.1](https://github.com/webtorrent/webtorrent/compare/v1.1.0...v1.1.1) (2021-07-02)\n\n\n### Bug Fixes\n\n* Cleanup duplicated deselect() code ([#2113](https://github.com/webtorrent/webtorrent/issues/2113)) ([b94d713](https://github.com/webtorrent/webtorrent/commit/b94d71314bd7ae122c6150b6e92b3f2bd5da504a))\n\n# [1.1.0](https://github.com/webtorrent/webtorrent/compare/v1.0.4...v1.1.0) (2021-06-30)\n\n\n### Features\n\n* Use a cache on the chunk store ([#2095](https://github.com/webtorrent/webtorrent/issues/2095)) ([d540058](https://github.com/webtorrent/webtorrent/commit/d540058ebd7f32e613d26c33e8a99b16d39a13d8))\n\n## [1.0.4](https://github.com/webtorrent/webtorrent/compare/v1.0.3...v1.0.4) (2021-06-30)\n\n## [1.0.3](https://github.com/webtorrent/webtorrent/compare/v1.0.2...v1.0.3) (2021-06-30)\n\n\n### Bug Fixes\n\n* remove deprecated functionality ([#2118](https://github.com/webtorrent/webtorrent/issues/2118)) ([2bf6cf4](https://github.com/webtorrent/webtorrent/commit/2bf6cf42e09c448cab0dddcd74ea9a49dc3f18a0))\n\n## [1.0.2](https://github.com/webtorrent/webtorrent/compare/v1.0.1...v1.0.2) (2021-06-23)\n\n\n### Bug Fixes\n\n* enable UTP by default if there's support ([0df9eb6](https://github.com/webtorrent/webtorrent/commit/0df9eb60171ff18cec052e8f31a515b341bdd03a))\n\n## [1.0.1](https://github.com/webtorrent/webtorrent/compare/v1.0.0...v1.0.1) (2021-06-17)\n\n\n### Bug Fixes\n\n* make utp-native optional ([#1966](https://github.com/webtorrent/webtorrent/issues/1966)) ([73c941c](https://github.com/webtorrent/webtorrent/commit/73c941c6eb3b539efbbbb499ab3d033531347b19))\n\n# [1.0.0](https://github.com/webtorrent/webtorrent/compare/v0.118.0...v1.0.0) (2021-05-21)\n\n\n### Bug Fixes\n\n* bring back release config ([d78055b](https://github.com/webtorrent/webtorrent/commit/d78055b2fd6275f9ba18474f601c0a4d3284231c))\n* getAnnounceOpts ([#2075](https://github.com/webtorrent/webtorrent/issues/2075)) ([633b922](https://github.com/webtorrent/webtorrent/commit/633b9224b7c7176599a5e53775de1a48d8e864b5))\n* install config ([6ba44c4](https://github.com/webtorrent/webtorrent/commit/6ba44c444f6af6f070c3059ad00ca2d10868058d))\n* **deps:** update webtorrent ([18a8962](https://github.com/webtorrent/webtorrent/commit/18a8962328fb42e1ebc56ed5dbe73b97f096fbd1))\n* ci ([134721c](https://github.com/webtorrent/webtorrent/commit/134721c16d3338270cdcef300bb164720b1d3ae7))\n* github ci secrets ([fc7ec9f](https://github.com/webtorrent/webtorrent/commit/fc7ec9f223079a3c1a2a8b54a4cca022aef4c440))\n\n\n### chore\n\n* add release ([#2077](https://github.com/webtorrent/webtorrent/issues/2077)) ([db9de2d](https://github.com/webtorrent/webtorrent/commit/db9de2d99a260d68f2719396835a09b2d0742e9f))\n\n\n### Reverts\n\n* version strategy gh actions ([1cba675](https://github.com/webtorrent/webtorrent/commit/1cba6753d449ae46f287e9104ed1f0330d640911))\n\n\n### BREAKING CHANGES\n\n* chore: add release\n* add semantic release config\n* Update release.yml\n\n# WebTorrent Version History\n\n## v0.112.0 - 2020-11-05\n\n- Ensure that `appendTo` callback is called once video tag is added to DOM, not after play (#1967)\n\n## v0.111.0 - 2020-11-05\n\n- Add Local Service Discovery (BEP14)\n- bitfield@4\n\n## v0.110.1 - 2020-11-03\n\n- Fix BEP53 implementation\n\n## v0.110.0 - 2020-11-03\n\n- Support Implement the peer address property (x.pe) from BEP09\n\n## v0.109.2 - 2020-10-27\n\n- Fix \"Cannot read property 'utp' of null\"\n\n## v0.109.1 - 2020-10-23\n\n- Peer reconnect timeout throwing error after torrent is destroyed\n\n## v0.109.0 - 2020-10-22\n\n- refactor torrent._rechoke()\n- simple-get@4\n- electron@9\n- deps\n- Add stale bot config\n- Create no-response.yml\n- Create config.yml\n- Update no-response.yml\n- Add uTP support (BEP29)\n- check if torrent is destroyed before emitting download/upload event\n- ut_pex 2.0.1\n- browserify@17\n- electron@10\n\n## v0.108.6 - 2020-05-29\n\n- update deps\n\n## v0.108.5 - 2020-05-29\n\n- bump deps\n\n## v0.108.4 - 2020-05-28\n\n- add test for downloading from a manually added peer\n- fix: not setting initial wire interest\n- update interest when a peer's bitfield changes\n\n## v0.108.3 - 2020-05-15\n\n- Create `webtorrent.chromeapp.js`\n- update bittorrent-dht to version 10.0.0\n- Change parseRange.parse to parseRange\n\n## v0.108.2 - 2020-05-10\n\n- implement store destruction option\n- Fix drag-drop.min.js link\n- update parse-numeric-range to version 1.2.0\n- browsers: add tests for safari, edge, android, iphone\n\n## v0.108.1 - 2020-04-01\n\n- fix ratio calculation\n\n## v0.108.0 - 2020-04-01\n\n- Check if client is set when debug logging\n- downgrade end-of-stream to v1.4.1\n- `private` option overrides default, only if it's defined\n- use native Set instead of uniq library\n- Improve code readability\n\n## v0.107.17 - 2019-11-12\n\n- Unbreak built file\n\n## v0.107.16 - 2019-09-10\n\n- fix git commit reference to `http-node` package\n\n## v0.107.15 - 2019-09-10\n\n- Return server from server.listen for method chaining to work\n\n## v0.107.14 - 2019-09-10\n\n- Update .gitignore\n\n## v0.107.13 - 2019-09-10\n\n- Added tests to check the order of torrent events\n\n## v0.107.12 - 2019-09-08\n\n- Fixed how first piece's irrelevant bytes are calculated\n\n## v0.107.11 - 2019-09-07\n\n- Added timeout option for `requestIdlecallback` to prevent longer delays in download\n\n## v0.107.10 - 2019-09-07\n\n- Server now uses relative urls\n\n## v0.107.9 - 2019-09-07\n\n- Added a check in case user destroys torrent in response to `metadata` event\n\n## v0.107.8 - 2019-09-07\n\n- Fixed the torrent event emission order; now `metadata` is emitted before `ready` and `done`\n\n## v0.107.7 - 2019-09-06\n\n- Updated to simple-sha1@3\n- Updated jsdelivr urls to use latest Webtorrent\n\n## v0.107.6 - 2019-08-28\n\n- Fixed XSS vulnerability in the http Server ([issue](https://github.com/brave/brave-browser/issues/5821))\n\n## v0.107.5 - 2019-08-22\n\n- No meaningful changes\n\n## v0.107.4 - 2019-08-19\n\n- Added api documentation for some torrent properties\n- Bug fix: trackers now recieve 0 while seeding file instead of the file size\n- Updated org-wide security policies and contributing guidelines\n\n## v0.107.3 - 2019-08-10\n\n- No meaningful changes\n\n## v0.107.2 - 2019-08-09\n\n- Scripts are now more verbose\n\n## v0.107.1 - 2019-08-09\n\n- Updated to stream-to-bolob-url@3\n- Added `chromeapp` field to package.json for specifying Chrome App dependency substitutions\n\n## v0.107.0 - 2019-08-07\n\n- Smaller build with tinify\n- Added size-disc script to visualize bundle\n\n## v0.106.0 - 2019-08-05\n\n- Updated to electron@6\n- Dropped support for node versions < 10\n\n## v0.105.3 - 2019-08-02\n\n- Now uses 'application/octet-stream' mimetype as fallback instead of null\n\n## v0.105.2 - 2019-07-31\n\n- Fixed server `hostname` option to mitigate DNS rebinding attack ([issue](https://github.com/webtorrent/webtorrent/pull/1678))\n\n## v0.105.1 - 2019-07-24\n\n- Bug fixed: Video streaming is now fixed in Brave nightly and chromium nightly ([issue](https://github.com/brave/brave-browser/issues/5358))\n\n## v0.105.0 - 2019-07-06\n\n- Updated to parse-torrent@7\n- Added manual verification for torrent files\n\n## v0.104.0 - 2019-06-29\n\n- Updated to chunk-store-stream@4\n- Updated to multistream@3\n- Updated to create-torrent@4\n- Dropped support for node versions < 8\n\n## v0.103.4 - 2019-06-19\n\n- No meaningful changes\n\n## v0.103.3 - 2019-06-19\n\n- Updated to electron@5\n\n## v0.103.2 - 2019-06-12\n\n- Added the ability to close and restore streaming server\n\n## v0.103.1 - 2019-03-11\n\n- Updated to electron@4\n- Bug fixed: File progress is no longer shown in negative\n\n## v0.103.0 - 2018-12-11\n\n- No longer verifies file hashes passed to seed\n- No longer calls torrent.load() when seeding FS filepath\n- Reduced download impact on slower computers: now download chunks at a lower priority ([rationale](https://github.com/webtorrent/webtorrent/pull/1513))\n\n## v0.102.4 - 2018-08-31\n\n- No meaningful changes\n\n## v0.102.3 - 2018-08-31\n\n- Removed xtend\n- Removed the concurrency limit in browser\n- Reduced installtion size by removing zero-fill\n- Updated to bittorrent-dht@9\n\n## v0.102.2 - 2018-08-28\n\n- Update some webtorrent packages to ES6 ([webtorrent/#1443](https://github.com/webtorrent/webtorrent/issues/1443))\n\n## v0.102.1 - 2018-08-10\n\n- No meaningful changes\n\n## v0.102.0 - 2018-08-04\n\n- Updated to chunk-store-stream@3\n- Updated to immediate-chunk-store@2\n\n## v0.101.2 - 2018-07-27\n\n- Updated to torrent-discovery@9.0.2\n\n## v0.101.1 - 2018-07-27\n\n- Updated to bittorrent-protocol@3\n- Optimized peers:  peers now start as uninterested and only move to interested if/once they have a piece that we need  ([webtorrent/#1059](https://github.com/webtorrent/webtorrent/issues/1059))\n\n## v0.101.0 - 2018-07-19\n\n- No meaningful changes\n\n## v0.100.0 - 2018-05-23\n\n- Implemented BEP53 to alow file selection using `select only` parameter in MagnetURIs ([webtorrent/#1395](https://github.com/webtorrent/webtorrent-hybrid/issues/1395))\n\n## v0.99.4 - 2018-05-03\n\n- Use updated `babel-minify` minifier instead of deprecated `babili`\n\n## v0.99.3 - 2018-04-26\n\n- Add extra check to prevent invalid `peer.conn.remotePort` from being used ([webtorrent-hybrid/#76](https://github.com/webtorrent/webtorrent-hybrid/issues/76))\n\n## v0.99.2 - 2018-04-24\n\n- Use `.npmignore` to prevent unneeded files from being included in the published package\n\n## v0.99.1 - 2018-04-24\n\n- Expose `WebTorrent.VERSION` (#1358)\n- Update to simple-get@3\n- Update to parse-torrent@6\n\n## v0.99.0 - 2018-04-19\n\n- `renderTo()`/`appendTo()` does not autoplay by default anymore ([rationale](https://github.com/webtorrent/webtorrent/commit/fbbffbbb445096a909c851cdc4ca15204b9952b9))\n  - Pass `{autoplay: true}` to `renderTo()`/`appendTo()` to get the old behavior.\n- `renderTo()`/`appendTo()` has a new `muted` option to mute the video by default.\n\n## v0.98.24 - 2018-03-02\n\n- Add hostname option to mitigate DNS rebinding (#1260)\n- Update to simple-peer@9\n- Browser testing: switch from `zuul` to `airtap`\n\n## v0.98.23 - 2018-02-20\n\n- Update to bitfield@2\n\n## v0.98.22 - 2018-02-17\n\n- Update to browserify@16\n- Update to bittorrent-dht@8\n- Update to pump@3\n\n## v0.98.21 - 2018-01-26\n\n- Update to pump@2\n- Update to mime@2\n- Update to cross-spawn@6\n- Update to browserify@15\n\n## v0.98.20 - 2017-10-17\n\n- Fix `file.downloaded` for last piece\n- Fix destroyed torrent debug\n- Update to mime@2\n- Update to debug@3\n- Update to electron@1\n\n## v0.98.19 - 2017-06-25\n\n- Add `origin` option for torrent.createServer() (#1096)\n- Add `file.progress` property (#1140)\n- Switch to ES6-compatible minifier\n\n## v0.98.18 - 2017-04-14\n\n- Transfer webtorrent from @feross to @webtorrent organization.\n\n## v0.98.17 - 2017-04-13\n\n- Fix uncaught exception (#1103)\n\n## v0.98.16 - 2017-04-07\n\n- Update to simple-peer@8\n\n## v0.98.15 - 2017-03-30\n\n- No meaningful changes\n\n## v0.98.14 - 2017-03-17\n\n- Add filename to URLs on server index page (#1078)\n\n## v0.98.13 - 2017-03-16\n\n- No meaningful changes\n\n## v0.98.12 - 2017-03-13\n\n- Fix files under 16Kb are not downloaded correctly (#1077)\n\n## v0.98.11 - 2017-03-13\n\n- Fix detection of seeding peers (#1076)\n\n## v0.98.10 - 2017-03-06\n\n- Update to bittorrent-tracker@9\n\n## v0.98.9 - 2017-03-01\n\n- Update to finalhandler@1\n- Update to simple-peer@7\n\n## v0.98.8 - 2017-02-13\n\n- wait to notify() or updateInterest() at end of GC (#1044)\n- Update to cross-spawn@5\n\n## v0.98.7 - 2017-02-11\n\n- Change os.tmpDir() to os.tmpdir() (#1043)\n\n## v0.98.6 - 2017-02-09\n\n- Refactor http server; support content-disposition (#1039)\n\n## v0.98.5 - 2017-02-02\n\n- Don't print debug log after torrent is destroyed\n\n## v0.98.4 - 2017-02-02\n\n- Be more defensive: prevent code from running after destroy\n- Fix \"Cannot read property 'complete' of null\" (#1022)\n- Include infoHash in torrent.js debug logs\n- Update to browserify@14\n\n## v0.98.3 - 2017-01-19\n\n- Emit more warnings (#1021)\n- Set user-agent header for http tracker requests (#1019)\n\n## v0.98.2 - 2017-01-18\n\n- Don't send 'completed' event to tracker on client.seed (#991)\n- Set user-agent header for http tracker requests (#962)\n\n## v0.98.1 - 2017-01-13\n\n- Don't emit 'completed' on client.seed\n- Do not choke on web seeds (#972)\n\n## v0.98.0 - 2016-11-23\n\n- Add property for downloaded bytes per file (`file.downloaded`) (#974)\n- Cross-origin HTTP redirect workaround for web seeds (#909)\n\n## v0.97.2 - 2016-09-26\n\n- Creating a WebTorrent client with the `{tracker: false}` to disable communication with trackers should not affect creating a torrent with `.seed()`. The resulting torrent file should still contain the normal `announce` field. (#928)\n- Add more peer ID entropy\n\n## v0.97.1 - 2016-09-17\n\n- Handle invalid range handers instead of throwing (#921)\n\n## v0.97.0 - 2016-09-17\n\n- Add option to disable BEP19 web seeds (`webSeeds` option to the `WebTorrent` constructor)\n\n## v0.96.5 - 2016-09-13\n\n- Fix exceptions in `server.close()` and `server.destroy()`\n\n## v0.96.4 - 2016-08-23\n\n- Warn when WebTorrent is installed on Node.js older than v4.0.0.\n\n## v0.96.3 - 2016-08-22\n\n- Better docs for .renderTo()\n\n## v0.96.2 - 2016-08-20\n\n- Replace 'hat' with 'randombytes'\n- Better debug logs\n\n## v0.96.1 - 2016-08-18\n\n- Prevent possible stack overflow\n\n## v0.96.0 - 2016-08-03\n\n- Add options to disable autoplay/hide controls with `appendTo()` and `renderTo()`\n\n## v0.95.6 - 2016-07-28\n\n- Allow deselecting the entire torrent with `deselect()` to happen earlier\n\n## v0.95.5 - 2016-07-26\n\n- Fix support for FileList input to client.seed()\n\n## v0.95.4 - 2016-07-26\n\n- Skip blocklist logic when opts.blocklist is not set\n\n## v0.95.3 - 2016-07-26\n\n- Fix WebTorrent version string\n\n## v0.95.2 - 2016-06-22\n\n- HEAD requests to HTTP server should not send entire body\n- WebTorrent, LLC is now the steward of the project\n\n## v0.95.1 - 2016-06-15\n\n- Emit 'seed' event on the torrent object\n\n## v0.95.0 - 2016-06-15\n\n- API: Add `file.getBlob()` method\n- Fix rare exception in `lib/tcp-pool.js`\n\n## v0.94.4 - 2016-06-10\n\n- Support torrent with a single 0 byte file\n- Use `<` since it handles `NaN` in a predictable way, i.e. `false`\n\n## v0.94.3 - 2016-05-30\n\n- Use `safe-buffer` for improved buffer safety\n\n## v0.94.2 - 2016-05-28\n\n- Fix rare exception in `lib/file.js`\n\n## v0.94.1 - 2016-05-26\n\n- Make WebTorrent user agent string consistent across whole codebase\n\n## v0.94.0 - 2016-05-19\n\n- Support exact source (xs) paramter of magnet URIs, for retreiving metadata\n\n## v0.93.4 - 2016-05-17\n\n- Fix rare exception caused by race condition in `lib/peer.js`\n\n## v0.93.3 - 2016-05-13\n\n- Don't unset `{tracker: {wrtc: false}}` option to `WebTorrent` constructor.\n\n## v0.93.2 - 2016-05-12\n\n- When a duplicate torrent is added, don't emit the 'infoHash' event after 'error'. The 'error' event should be the last event.\n\n## v0.93.1 - 2016-05-08\n\n- Remove `path-exists` dependency.\n\n## v0.93.0 - 2016-05-08\n\n- Move tracker options (`rtcConfig` and `wrtc`) into `opts.tracker`.\n\n  Before:\n\n  ```js\n  var client = new WebTorrent({ rtcConfig: {}, wrtc: {} })\n  ```\n\n  After:\n\n  ```js\n  var client = new WebTorrent({ tracker: { rtcConfig: {}, wrtc: {} } })\n  ```\n\n## v0.92.0 - 2016-05-05\n\n- Add new event: `torrent.on('noPeers', function (announceType) {})`\n\n  Emitted whenever a DHT or tracker announce occurs, but no peers have been found.  `announceType` is either `'tracker'` or `'dht'` depending on which announce occurred to trigger this event.  Note that if you're attempting to discover peers from both a tracker and a DHT, you'll see this event separately for each.\n\n## v0.91.4 - 2016-05-05\n\n- Fix exception: \"peer.\\_destroy is not a function\" when calling `torrent.pause()`\n\n## v0.91.3 - 2016-05-04\n\n- Fix `torrent.swarm` from causing an infinite recursion.\n\n## v0.91.2 - 2016-04-28\n\n- Test node v6\n\n## v0.91.1 - 2016-04-24\n\n- Emit 'done' event *after* sending the `'complete'` message to the tracker.\n\n## v0.91.0 - 2016-04-21\n\n### Added\n\n- `client.listening` property to signal whether TCP server is listening for incoming\n  connections.\n\n- `client.dhtPort` property reflects the actual DHT port when user doesn't specify one\n  (this is parallel to `client.torrentPort` for the TCP torrent listening server)\n\n### Changed\n\n- Merged `Swarm` class into `Torrent` object. Properties on `torrent.swarm` (like\n  `torrent.swarm.wires`) now exist on `torrent` (e.g. `torrent.wires`).\n\n- Deprecate: Do not use `torrent.swarm` anymore. Use `torrent` instead.\n\n- `torrent.addPeer` can no longer be called before the `infoHash` event has been\n  emitted.\n\n- Remove `torrent.on('listening')` event. Use `client.on('listening')` instead.\n\n- Remove support from `TCPPool` for listening on multiple ports. This was not used by\n  WebTorrent and just added complexity. There is now a single `TCPPool` instance for the\n  whole WebTorrent client.\n\n- Deprecate: Do not use `client.download()` anymore. Use `client.add()` instead.\n\n- Only pass `torrent.infoHash` to the Chunk Store constructor, instead of the `Torrent`\n  instance itself, to prevent accidental memory leaks of the `Torrent` object by the\n  store. (Open an issue if you were using other properties. They can be re-added.)\n\n- Non-fatal errors with a single torrent will be emitted at `torrent.on('error')`. You\n  should listen to this event. Previously, all torrent errors were also emitted on\n  `client.on('error')` and handling `torrent.on('error')` was optional. This design is\n  better since now it is possible to distinguish between fatal client errors\n  (`client.on('error')`) when the whole client becomes unusable versus recoverable errors\n  where only a single torrent fails (`torrent.on('error')`) but the client can continue to\n  be used. However, if there is no `torrent.on('error')` event, then the error will be\n  forwarded to `client.on('error')`. This prevents crashing the client when the user\n  only has a listener on the client, but it makes it impossible for them to determine\n  a client error versus a torrent error.\n\n- Removed `torrent.numBlockedPeers` property. Use the `blockedPeer` event to track this\n  yourself.\n\n### Fixed\n\n- If `client.get` is passed a `Torrent` instance, it now only returns it if it is present\n  in the client.\n\n- Errors creating a torrent with `client.seed` are now emitted on the returned `torrent`\n  object instead of the client (unless there is no event listeners on\n  `torrent.on('error')` as previously discussed). The torrent object is now also destroyed\n  automatically for the user, as was probably expected.\n\n- Do not return existing torrent object when duplicate torrent is added. Fire an\n  `'error'` event instead.\n\n- Memory leaks of `Torrent` object caused by many internal subclasses of WebTorrent,\n  including `RarityMap`, `TCPPool`, `WebConn`, `Server`, `File`.\n\n- `client.ratio` and `torrent.ratio` are now calculated as `uploaded / received` instead\n  of `uploaded / downloaded`.\n\n## Previous versions\n\nWe did not maintain a changelog for versions prior to v0.91.0. The initial release of WebTorrent was on Dec 4, 2013.\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) Feross Aboukhadijeh and WebTorrent, LLC\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<h1 align=\"center\">\n  <br>\n  <a href=\"https://webtorrent.io\"><img src=\"https://webtorrent.io/img/WebTorrent.png\" alt=\"WebTorrent\" width=\"200\"></a>\n  <br>\n  WebTorrent\n  <br>\n  <br>\n</h1>\n\n<h4 align=\"center\">The streaming torrent client. For node.js and the web.</h4>\n\n<p align=\"center\">\n  <a href=\"https://discord.gg/cnXkm4Z\"><img src=\"https://img.shields.io/discord/612575111718895616\" alt=\"discord\"></a>\n  <a href=\"https://github.com/webtorrent/webtorrent/actions\"><img src=\"https://img.shields.io/github/actions/workflow/status/webtorrent/webtorrent/ci.yml?branch=master\" alt=\"ci\"></a>\n  <a href=\"https://www.npmjs.com/package/webtorrent\"><img src=\"https://img.shields.io/npm/v/webtorrent.svg\" alt=\"npm version\"></a>\n  <a href=\"https://www.npmjs.com/package/webtorrent\"><img src=\"https://img.shields.io/npm/dm/webtorrent.svg\" alt=\"npm downloads\"></a>\n  <a href=\"https://standardjs.com\"><img src=\"https://img.shields.io/badge/code_style-standard-brightgreen.svg\" alt=\"Standard - JavaScript Style Guide\"></a>\n</p>\n\n<h5 align=\"center\">\n  Sponsored by&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"https://socket.dev\"><img src=\"https://webtorrent.io/img/supporters/socket.png\" alt=\"Socket - JavaScript open source supply chain security\" height=35 valign=\"middle\"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"https://www.wormhole.app/?utm_medium=sponsorship&utm_source=webtorrent&utm_campaign=feross\"><img src=\"https://webtorrent.io/img/supporters/wormhole.png\" alt=\"Wormhole\" height=30 valign=\"middle\"></a>\n</h5>\n<br>\n\n**WebTorrent** is a streaming torrent client for **node.js** and the **browser**. YEP,\nTHAT'S RIGHT. THE BROWSER. It's written completely in JavaScript – the language of the web\n– so the same code works in both runtimes.\n\nIn node.js, this module is a simple torrent client, using TCP and UDP to talk to\nother torrent clients.\n\nIn the browser, WebTorrent uses **WebRTC** (data channels) for peer-to-peer transport.\nIt can be used **without** browser plugins, extensions, or installations. It's Just\nJavaScript™. Note: WebTorrent does **not** support UDP/TCP peers in browser.\n\nSimply include the\n[`webtorrent.min.js`](https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js) script\non your page to start fetching files over WebRTC using the BitTorrent protocol, or\n`import WebTorrent from 'webtorrent'` with [browserify](http://browserify.org/) or [webpack](https://webpack.js.org/). See [demo apps\n](#who-is-using-webtorrent-today) and [code examples](#usage) below.\n\n[![jsdelivr download count](https://data.jsdelivr.com/v1/package/npm/webtorrent/badge)](https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js)\n\nTo make BitTorrent work over WebRTC (which is the only P2P transport that works on the\nweb) we made some protocol changes. Therefore, a browser-based WebTorrent client or **\"web\npeer\"** can only connect to other clients that support WebTorrent/WebRTC.\n\nTo seed files to web peers, use a client that supports WebTorrent, e.g.\n[WebTorrent Desktop][webtorrent-desktop], a desktop client with a\nfamiliar UI that can connect to web peers,\n[webtorrent-hybrid](https://github.com/webtorrent/webtorrent-hybrid), a command line program,\nor [Instant.io](https://instant.io/), a website. Established torrent clients like\n**Vuze** have [already added WebTorrent support](https://wiki.vuze.com/w/WebTorrent) so\nthey can connect to both normal *and* web peers. We hope other clients will follow.\n\n![Network](https://webtorrent.io/img/network.png)\n\n### Features\n\n- **Torrent client for node.js & the browser** (same npm package!)\n- **Insanely fast**\n- Download **multiple torrents** simultaneously, efficiently\n- **Pure Javascript** (no native dependencies)\n- Exposes files as **streams**\n  - Fetches pieces from the network on-demand so seeking is supported (even before torrent is finished)\n  - Seamlessly switches between sequential and rarest-first piece selection strategy\n- Supports advanced torrent client features\n  - **magnet uri** support via **[ut_metadata](https://github.com/webtorrent/ut_metadata)**\n  - **peer discovery** via **[dht](https://github.com/webtorrent/bittorrent-dht)**,\n    **[tracker](https://github.com/webtorrent/bittorrent-tracker)**,\n    **[lsd](https://github.com/webtorrent/bittorrent-lsd)**, and\n    **[ut_pex](https://github.com/webtorrent/ut_pex)**\n  - **[protocol extension api](https://github.com/webtorrent/bittorrent-protocol#extension-api)**\n    for adding new extensions\n- **Comprehensive test suite** (runs completely offline, so it's reliable and fast)\n- Check all the **[supported BEPs here](docs/bep_support.md)**\n\n#### Browser/WebRTC environment features\n\n- **WebRTC data channels** for lightweight peer-to-peer communication with **no plugins**\n- **No silos.** WebTorrent is a P2P network for the **entire web.** WebTorrent clients\n  running on one domain can connect to clients on any other domain.\n- Stream video torrents into a `<video>` tag (`webm, mkv, mp4, ogv, mov, etc (AV1, H264, HEVC*, VP8, VP9, AAC, FLAC, MP3, OPUS, Vorbis, etc)`)\n- Supports Chrome, Firefox, Opera and Safari.\n\n<!-- <p align=\"center\">\n  <a href=\"https://saucelabs.com/u/webtorrent\">\n    <img src=\"https://saucelabs.com/browser-matrix/webtorrent.svg\" alt=\"Sauce Labs\">\n  </a>\n</p> -->\n\n### Install\n\nTo install WebTorrent for use in node or the browser with `import WebTorrent from 'webtorrent'`, run:\n\n```bash\nnpm install webtorrent\n```\n\nTo install a `webtorrent`\n[command line program](https://github.com/webtorrent/webtorrent-cli), run:\n\n```bash\nnpm install webtorrent-cli -g\n```\n\nTo install a WebTorrent desktop application for Mac, Windows, or Linux, see\n[WebTorrent Desktop][webtorrent-desktop].\n\n### Ways to help\n\n- **Join us in [Gitter][webtorrent-gitter-url]** or on freenode at `#webtorrent` to help\n  with development or to hang out with some mad science hackers :)\n- **[Create a new issue](https://github.com/webtorrent/webtorrent/issues/new)** to report bugs\n- **[Fix an issue](https://github.com/webtorrent/webtorrent/issues?state=open)**. WebTorrent\n  is an [OPEN Open Source Project](https://github.com/webtorrent/.github/blob/master/CONTRIBUTING.md)!\n\n### Who is using WebTorrent today?\n\n**[Lots of folks!](docs/faq.md#who-is-using-webtorrent-today)**\n\n### WebTorrent API Documentation\n\n**[Read the full API Documentation](docs/api.md).**\n\n### Usage\n\nWebTorrent is the first BitTorrent client that works in the browser, using open web\nstandards (no plugins, just HTML5 and WebRTC)! It's easy to get started!\n\n#### In the browser\n\n##### Downloading a file is simple:\n\n```js\nimport WebTorrent from 'webtorrent'\n\nconst client = new WebTorrent()\nconst magnetURI = '...'\n\nclient.add(magnetURI, torrent => {\n  // Got torrent metadata!\n  console.log('Client is downloading:', torrent.infoHash)\n\n  for (const file of torrent.files) {\n    document.body.append(file.name)\n  }\n})\n```\n\n##### Seeding a file is simple, too:\n\n```js\nimport dragDrop from 'drag-drop'\nimport WebTorrent from 'webtorrent'\n\nconst client = new WebTorrent()\n\n// When user drops files on the browser, create a new torrent and start seeding it!\ndragDrop('body', files => {\n  client.seed(files, torrent => {\n    console.log('Client is seeding:', torrent.infoHash)\n  })\n})\n```\n\nThere are more examples in [docs/get-started.md](docs/get-started.md).\n\n##### Browserify\n\nWebTorrent works great with [browserify](http://browserify.org/), an npm package that lets\nyou use [node](http://nodejs.org/)-style require() to organize your browser code and load modules installed by [npm](https://www.npmjs.com/) (as seen in the previous examples).\n\n##### Webpack\n\nWebTorrent also works with [webpack](https://webpack.js.org/), another module\nbundler. However, webpack requires extra configuration which you can find in [the webpack bundle config used by webtorrent](/scripts/browser.webpack.js).\n\n\nOr, you can just use the pre-built version via\n`import WebTorrent from 'webtorrent/dist/webtorrent.min.js'` and skip the webpack configuration.\n\n##### Script tag\n\nWebTorrent is also available as a standalone script\n([`webtorrent.min.js`](webtorrent.min.js)) which exposes `WebTorrent` on the `window`\nobject, so it can be used with just a script tag:\n\n```html\n<script type='module'>\n  import WebTorrent from 'webtorrent.min.js'\n</script>\n```\n\nThe WebTorrent script is also hosted on fast, reliable CDN infrastructure for easy inclusion on your site:\n\n```html\n<script type='module'>\n  import WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'\n</script>\n```\n\n##### Chrome App\n\nIf you want to use WebTorrent in a\n[Chrome App](https://developer.chrome.com/apps/about_apps), you can include the\nfollowing script:\n\n```html\n<script type='module'>\n  import WebTorrent from 'webtorrent.chromeapp.js'\n</script>\n```\n\nBe sure to enable the `chrome.sockets.udp` and `chrome.sockets.tcp` permissions!\n\n#### In Node.js\n\nWebTorrent also works in node.js, using the *same npm package!* It's mad science!\n\n**NOTE**: To connect to \"web peers\" (browsers) in addition to normal BitTorrent peers, use\n[webtorrent-hybrid](https://github.com/webtorrent/webtorrent-hybrid) which includes WebRTC\nsupport for node.\n\n#### As a command line app\n\nWebTorrent is also available as a\n[command line app](https://github.com/webtorrent/webtorrent-cli). Here's how to use it:\n\n```bash\n$ npm install webtorrent-cli -g\n$ webtorrent --help\n```\n\nTo download a torrent:\n\n```bash\n$ webtorrent magnet_uri\n```\n\nTo stream a torrent to a device like **AirPlay** or **Chromecast**, just pass a flag:\n\n```bash\n$ webtorrent magnet_uri --airplay\n```\n\nThere are many supported streaming options:\n\n```bash\n--airplay               Apple TV\n--chromecast            Chromecast\n--mplayer               MPlayer\n--mpv                   MPV\n--omx [jack]            omx [default: hdmi]\n--vlc                   VLC\n--xbmc                  XBMC\n--stdout                standard out [implies --quiet]\n```\n\nIn addition to magnet uris, WebTorrent supports [many ways](docs/api.md#clientaddtorrentid-opts-function-ontorrent-torrent-) to specify a torrent.\n\n### Talks about WebTorrent\n\n- Sep 2017 - Nordic JS - [Get Rich Quick With P2P Crypto Currency](https://www.youtube.com/watch?v=8N_4Furztjo)\n- May 2017 - Char.la - [WebTorrent and Peerify](https://youtu.be/D-04vg5hvEQ?t=54m20s) (Spanish)\n- Nov 2016 - NodeConf Argentina - [Real world Electron: Building Cross-platform desktop apps with JavaScript](https://www.youtube.com/watch?v=YLExGgEnbFY)\n- May 2016 - SIGNAL Conference - [BitTorrent in the Browser](https://www.youtube.com/watch?v=2qrUx-C5Np4)\n- May 2015 - Data Terra Nemo - [WebTorrent: Mother of all demos](https://www.youtube.com/watch?v=RRtNEcAaUO8)\n- May 2015 - Data Terra Nemo - [WebRTC Everywhere](https://www.youtube.com/watch?v=RRtNEcAaUO8)\n- Nov 2014 - JSConf Asia - [How WebTorrent Works](https://www.youtube.com/watch?v=kxHRATfvnlw)\n- Sep 2014 - NodeConf EU - [WebRTC Mad Science](https://www.youtube.com/watch?v=BVBXkzVjvPc) (first working WebTorrent demo)\n- Apr 2014 - CraftConf - [Bringing BitTorrent to the Web](https://www.youtube.com/watch?v=PT8s_IVWDgw)\n- May 2014 - JS.LA - [How I Built a BitTorrent Client in the Browser](https://vimeo.com/97324247) (progress update; node client working)\n- Oct 2013 - RealtimeConf - [WebRTC Black Magic](https://vimeo.com/77265280) (first mention of idea for WebTorrent)\n\n### Modules\n\nMost of the active development is happening inside of small npm packages which are used by WebTorrent.\n\n#### The Node Way™\n\n> \"When applications are done well, they are just the really application-specific, brackish residue that can't be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons.\" — substack from [\"how I write modules\"](https://gist.github.com/substack/5075355)\n\n![node.js is shiny](https://feross.net/x/node2.gif)\n\n#### Modules\n\nThese are the main modules that make up WebTorrent:\n\n| module | tests | version | description |\n|---|---|---|---|\n| **[webtorrent][webtorrent]** | [![][webtorrent-ti]][webtorrent-tu] | [![][webtorrent-ni]][webtorrent-nu] | **torrent client (this module)**\n| [bittorrent-dht][bittorrent-dht] | [![][bittorrent-dht-ti]][bittorrent-dht-tu] | [![][bittorrent-dht-ni]][bittorrent-dht-nu] | distributed hash table client\n| [bittorrent-peerid][bittorrent-peerid] | [![][bittorrent-peerid-ti]][bittorrent-peerid-tu] | [![][bittorrent-peerid-ni]][bittorrent-peerid-nu] | identify client name/version\n| [bittorrent-protocol][bittorrent-protocol] | [![][bittorrent-protocol-ti]][bittorrent-protocol-tu] | [![][bittorrent-protocol-ni]][bittorrent-protocol-nu] | bittorrent protocol stream\n| [bittorrent-tracker][bittorrent-tracker] | [![][bittorrent-tracker-ti]][bittorrent-tracker-tu] | [![][bittorrent-tracker-ni]][bittorrent-tracker-nu] | bittorrent tracker server/client\n| [bittorrent-lsd][bittorrent-lsd] | [![][bittorrent-lsd-ti]][bittorrent-lsd-tu] | [![][bittorrent-lsd-ni]][bittorrent-lsd-nu] | bittorrent local service discovery\n| [create-torrent][create-torrent] | [![][create-torrent-ti]][create-torrent-tu] | [![][create-torrent-ni]][create-torrent-nu] | create .torrent files\n| [magnet-uri][magnet-uri] | [![][magnet-uri-ti]][magnet-uri-tu] | [![][magnet-uri-ni]][magnet-uri-nu] | parse magnet uris\n| [parse-torrent][parse-torrent] | [![][parse-torrent-ti]][parse-torrent-tu] | [![][parse-torrent-ni]][parse-torrent-nu] | parse torrent identifiers\n| [torrent-discovery][torrent-discovery] | [![][torrent-discovery-ti]][torrent-discovery-tu] | [![][torrent-discovery-ni]][torrent-discovery-nu] | find peers via dht, tracker, and lsd\n| [ut_metadata][ut_metadata] | [![][ut_metadata-ti]][ut_metadata-tu] | [![][ut_metadata-ni]][ut_metadata-nu] | metadata for magnet uris (protocol extension)\n| [ut_pex][ut_pex] | [![][ut_pex-ti]][ut_pex-tu] | [![][ut_pex-ni]][ut_pex-nu] | peer discovery (protocol extension)\n\n[webtorrent]: https://github.com/webtorrent/webtorrent\n[webtorrent-gitter-url]: https://gitter.im/webtorrent/webtorrent\n\n[webtorrent-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/webtorrent/ci.yml\n[webtorrent-tu]: https://github.com/webtorrent/webtorrent/actions\n[webtorrent-ni]: https://img.shields.io/npm/v/webtorrent.svg\n[webtorrent-nu]: https://www.npmjs.com/package/webtorrent\n[webtorrent-desktop]: https://webtorrent.io/desktop\n\n[bittorrent-dht]: https://github.com/webtorrent/bittorrent-dht\n[bittorrent-dht-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-dht/ci.yml?branch=master\n[bittorrent-dht-tu]: https://github.com/webtorrent/bittorrent-dht/actions\n[bittorrent-dht-ni]: https://img.shields.io/npm/v/bittorrent-dht.svg\n[bittorrent-dht-nu]: https://www.npmjs.com/package/bittorrent-dht\n\n[bittorrent-peerid]: https://github.com/webtorrent/bittorrent-peerid\n[bittorrent-peerid-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-peerid/ci.yml?branch=master\n[bittorrent-peerid-tu]: https://github.com/webtorrent/bittorrent-peerid/actions\n[bittorrent-peerid-ni]: https://img.shields.io/npm/v/bittorrent-peerid.svg\n[bittorrent-peerid-nu]: https://www.npmjs.com/package/bittorrent-peerid\n\n[bittorrent-protocol]: https://github.com/webtorrent/bittorrent-protocol\n[bittorrent-protocol-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-protocol/ci.yml?branch=master\n[bittorrent-protocol-tu]: https://github.com/webtorrent/bittorrent-protocol/actions\n[bittorrent-protocol-ni]: https://img.shields.io/npm/v/bittorrent-protocol.svg\n[bittorrent-protocol-nu]: https://www.npmjs.com/package/bittorrent-protocol\n\n[bittorrent-tracker]: https://github.com/webtorrent/bittorrent-tracker\n[bittorrent-tracker-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-tracker/ci.yml?branch=master\n[bittorrent-tracker-tu]: https://github.com/webtorrent/bittorrent-tracker/actions\n[bittorrent-tracker-ni]: https://img.shields.io/npm/v/bittorrent-tracker.svg\n[bittorrent-tracker-nu]: https://www.npmjs.com/package/bittorrent-tracker\n\n[bittorrent-lsd]: https://github.com/webtorrent/bittorrent-lsd\n[bittorrent-lsd-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-lsd/ci.yml?branch=master\n[bittorrent-lsd-tu]: https://github.com/webtorrent/bittorrent-lsd/actions\n[bittorrent-lsd-ni]: https://img.shields.io/npm/v/bittorrent-lsd.svg\n[bittorrent-lsd-nu]: https://www.npmjs.com/package/bittorrent-lsd\n\n[create-torrent]: https://github.com/webtorrent/create-torrent\n[create-torrent-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/create-torrent/ci.yml?branch=master\n[create-torrent-tu]: https://github.com/webtorrent/create-torrent/actions\n[create-torrent-ni]: https://img.shields.io/npm/v/create-torrent.svg\n[create-torrent-nu]: https://www.npmjs.com/package/create-torrent\n\n[magnet-uri]: https://github.com/webtorrent/magnet-uri\n[magnet-uri-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/magnet-uri/ci.yml?branch=master\n[magnet-uri-tu]: https://github.com/webtorrent/magnet-uri/actions\n[magnet-uri-ni]: https://img.shields.io/npm/v/magnet-uri.svg\n[magnet-uri-nu]: https://www.npmjs.com/package/magnet-uri\n\n[parse-torrent]: https://github.com/webtorrent/parse-torrent\n[parse-torrent-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/parse-torrent/ci.yml?branch=master\n[parse-torrent-tu]: https://github.com/webtorrent/parse-torrent/actions\n[parse-torrent-ni]: https://img.shields.io/npm/v/parse-torrent.svg\n[parse-torrent-nu]: https://www.npmjs.com/package/parse-torrent\n\n[torrent-discovery]: https://github.com/webtorrent/torrent-discovery\n[torrent-discovery-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/torrent-discovery/ci.yml?branch=master\n[torrent-discovery-tu]: https://github.com/webtorrent/torrent-discovery/actions\n[torrent-discovery-ni]: https://img.shields.io/npm/v/torrent-discovery.svg\n[torrent-discovery-nu]: https://www.npmjs.com/package/torrent-discovery\n\n[ut_metadata]: https://github.com/webtorrent/ut_metadata\n[ut_metadata-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/ut_metadata/ci.yml?branch=master\n[ut_metadata-tu]: https://github.com/webtorrent/ut_metadata/actions\n[ut_metadata-ni]: https://img.shields.io/npm/v/ut_metadata.svg\n[ut_metadata-nu]: https://www.npmjs.com/package/ut_metadata\n\n[ut_pex]: https://github.com/webtorrent/ut_pex\n[ut_pex-ti]: https://img.shields.io/github/actions/workflow/status/webtorrent/ut_pex/ci.yml?branch=master\n[ut_pex-tu]: https://github.com/webtorrent/ut_pex/actions\n[ut_pex-ni]: https://img.shields.io/npm/v/ut_pex.svg\n[ut_pex-nu]: https://www.npmjs.com/package/ut_pex\n\n#### Enable debug logs\n\nIn **node**, enable debug logs by setting the `DEBUG` environment variable to the name of the\nmodule you want to debug (e.g. `bittorrent-protocol`, or `*` to print **all logs**).\n\n```bash\nDEBUG=* webtorrent\n```\n\nIn the **browser**, enable debug logs by running this in the developer console:\n\n```js\nlocalStorage.setItem('debug', '*')\n```\n\nDisable by running this:\n\n```js\nlocalStorage.removeItem('debug')\n```\n\n### License\n\nMIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org) and [WebTorrent, LLC](https://webtorrent.io).\n"
  },
  {
    "path": "dist/webtorrent.chromeapp.js",
    "content": "var t={20:(t,e,r)=>{var i=r(2861).Buffer,n=r(7108),s=r(96),o=r(6698),a=r(5359),h=r(4847),u=r(2951);function f(t){s.Writable.call(this);var e=u[t];if(!e)throw new Error(\"Unknown message digest\");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function l(t){s.Writable.call(this);var e=u[t];if(!e)throw new Error(\"Unknown message digest\");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function c(t){return new f(t)}function d(t){return new l(t)}Object.keys(u).forEach(function(t){u[t].id=i.from(u[t].id,\"hex\"),u[t.toLowerCase()]=u[t]}),o(f,s.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return this._hash.update(\"string\"==typeof t?i.from(t,e):t),this},f.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),i=a(r,t,this._hashType,this._signType,this._tag);return e?i.toString(e):i},o(l,s.Writable),l.prototype._write=function(t,e,r){this._hash.update(t),r()},l.prototype.update=function(t,e){return this._hash.update(\"string\"==typeof t?i.from(t,e):t),this},l.prototype.verify=function(t,e,r){var n=\"string\"==typeof e?i.from(e,r):e;this.end();var s=this._hash.digest();return h(n,s,t,this._signType,this._tag)},t.exports={Sign:c,Verify:d,createSign:c,createVerify:d}},41:(t,e,r)=>{var i=r(655),n=r(8068),s=r(9675),o=r(5795);t.exports=function(t,e,r){if(!t||\"object\"!=typeof t&&\"function\"!=typeof t)throw new s(\"`obj` must be an object or a function`\");if(\"string\"!=typeof e&&\"symbol\"!=typeof e)throw new s(\"`property` must be a string or a symbol`\");if(arguments.length>3&&\"boolean\"!=typeof arguments[3]&&null!==arguments[3])throw new s(\"`nonEnumerable`, if provided, must be a boolean or null\");if(arguments.length>4&&\"boolean\"!=typeof arguments[4]&&null!==arguments[4])throw new s(\"`nonWritable`, if provided, must be a boolean or null\");if(arguments.length>5&&\"boolean\"!=typeof arguments[5]&&null!==arguments[5])throw new s(\"`nonConfigurable`, if provided, must be a boolean or null\");if(arguments.length>6&&\"boolean\"!=typeof arguments[6])throw new s(\"`loose`, if provided, must be a boolean\");var a=arguments.length>3?arguments[3]:null,h=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],l=!!o&&o(t,e);if(i)i(t,e,{configurable:null===u&&l?l.configurable:!u,enumerable:null===a&&l?l.enumerable:!a,value:r,writable:null===h&&l?l.writable:!h});else{if(!f&&(a||h||u))throw new n(\"This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.\");t[e]=r}}},76:t=>{t.exports=Function.prototype.call},82:(t,e,r)=>{var i=r(6698),n=r(8287).Buffer,s=r(7568),o=s.base,a=s.constants.der;function h(t){this.enc=\"der\",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){o.Node.call(this,\"der\",t)}function f(t){return t<10?\"0\"+t:t}t.exports=h,h.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},i(u,o.Node),u.prototype._encodeComposite=function(t,e,r,i){var s,o=function(t,e,r,i){var n;\"seqof\"===t?t=\"seq\":\"setof\"===t&&(t=\"set\");if(a.tagByName.hasOwnProperty(t))n=a.tagByName[t];else{if(\"number\"!=typeof t||(0|t)!==t)return i.error(\"Unknown tag: \"+t);n=t}if(n>=31)return i.error(\"Multi-octet tag encoding unsupported\");e||(n|=32);return n|=a.tagClassByName[r||\"universal\"]<<6,n}(t,e,r,this.reporter);if(i.length<128)return(s=new n(2))[0]=o,s[1]=i.length,this._createEncoderBuffer([s,i]);for(var h=1,u=i.length;u>=256;u>>=8)h++;(s=new n(2+h))[0]=o,s[1]=128|h;u=1+h;for(var f=i.length;f>0;u--,f>>=8)s[u]=255&f;return this._createEncoderBuffer([s,i])},u.prototype._encodeStr=function(t,e){if(\"bitstr\"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if(\"bmpstr\"===e){for(var r=new n(2*t.length),i=0;i<t.length;i++)r.writeUInt16BE(t.charCodeAt(i),2*i);return this._createEncoderBuffer(r)}return\"numstr\"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error(\"Encoding of string type: numstr supports only digits and space\"):\"printstr\"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):this.reporter.error(\"Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark\"):/str$/.test(e)||\"objDesc\"===e?this._createEncoderBuffer(t):this.reporter.error(\"Encoding of string type: \"+e+\" unsupported\")},u.prototype._encodeObjid=function(t,e,r){if(\"string\"==typeof t){if(!e)return this.reporter.error(\"string objid given, but no values map found\");if(!e.hasOwnProperty(t))return this.reporter.error(\"objid not found in values map\");t=e[t].split(/[\\s\\.]+/g);for(var i=0;i<t.length;i++)t[i]|=0}else if(Array.isArray(t)){t=t.slice();for(i=0;i<t.length;i++)t[i]|=0}if(!Array.isArray(t))return this.reporter.error(\"objid() should be either array or string, got: \"+JSON.stringify(t));if(!r){if(t[1]>=40)return this.reporter.error(\"Second objid identifier OOB\");t.splice(0,2,40*t[0]+t[1])}var s=0;for(i=0;i<t.length;i++){var o=t[i];for(s++;o>=128;o>>=7)s++}var a=new n(s),h=a.length-1;for(i=t.length-1;i>=0;i--){o=t[i];for(a[h--]=127&o;(o>>=7)>0;)a[h--]=128|127&o}return this._createEncoderBuffer(a)},u.prototype._encodeTime=function(t,e){var r,i=new Date(t);return\"gentime\"===e?r=[f(i.getFullYear()),f(i.getUTCMonth()+1),f(i.getUTCDate()),f(i.getUTCHours()),f(i.getUTCMinutes()),f(i.getUTCSeconds()),\"Z\"].join(\"\"):\"utctime\"===e?r=[f(i.getFullYear()%100),f(i.getUTCMonth()+1),f(i.getUTCDate()),f(i.getUTCHours()),f(i.getUTCMinutes()),f(i.getUTCSeconds()),\"Z\"].join(\"\"):this.reporter.error(\"Encoding \"+e+\" time is not supported yet\"),this._encodeStr(r,\"octstr\")},u.prototype._encodeNull=function(){return this._createEncoderBuffer(\"\")},u.prototype._encodeInt=function(t,e){if(\"string\"==typeof t){if(!e)return this.reporter.error(\"String int or enum given, but no values map\");if(!e.hasOwnProperty(t))return this.reporter.error(\"Values map doesn't contain: \"+JSON.stringify(t));t=e[t]}if(\"number\"!=typeof t&&!n.isBuffer(t)){var r=t.toArray();!t.sign&&128&r[0]&&r.unshift(0),t=new n(r)}if(n.isBuffer(t)){var i=t.length;0===t.length&&i++;var s=new n(i);return t.copy(s),0===t.length&&(s[0]=0),this._createEncoderBuffer(s)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);i=1;for(var o=t;o>=256;o>>=8)i++;for(o=(s=new Array(i)).length-1;o>=0;o--)s[o]=255&t,t>>=8;return 128&s[0]&&s.unshift(0),this._createEncoderBuffer(new n(s))},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},u.prototype._use=function(t,e){return\"function\"==typeof t&&(t=t(e)),t._getEncoder(\"der\").tree},u.prototype._skipDefault=function(t,e,r){var i,n=this._baseState;if(null===n.default)return!1;var s=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),s.length!==n.defaultBuffer.length)return!1;for(i=0;i<s.length;i++)if(s[i]!==n.defaultBuffer[i])return!1;return!0}},96:(t,e,r)=>{var i=r(717),n=r(8310);\"disable\"===i.env.READABLE_STREAM&&n?(t.exports=n,(e=t.exports=n.Readable).Readable=n.Readable,e.Writable=n.Writable,e.Duplex=n.Duplex,e.Transform=n.Transform,e.PassThrough=n.PassThrough,e.Stream=n):((e=t.exports=r(206)).Stream=n||e,e.Readable=e,e.Writable=r(7314),e.Duplex=r(6248),e.Transform=r(1816),e.PassThrough=r(5242))},113:t=>{const e={};function r(t,r,i){i||(i=Error);class n extends i{constructor(t,e,i){super(function(t,e,i){return\"string\"==typeof r?r:r(t,e,i)}(t,e,i))}}n.prototype.name=i.name,n.prototype.code=t,e[t]=n}function i(t,e){if(Array.isArray(t)){const r=t.length;return t=t.map(t=>String(t)),r>2?`one of ${e} ${t.slice(0,r-1).join(\", \")}, or `+t[r-1]:2===r?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}return`of ${e} ${String(t)}`}r(\"ERR_INVALID_OPT_VALUE\",function(t,e){return'The value \"'+e+'\" is invalid for option \"'+t+'\"'},TypeError),r(\"ERR_INVALID_ARG_TYPE\",function(t,e,r){let n;var s,o;let a;if(\"string\"==typeof e&&(s=\"not \",e.substr(!o||o<0?0:+o,s.length)===s)?(n=\"must not be\",e=e.replace(/^not /,\"\")):n=\"must be\",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,\" argument\"))a=`The ${t} ${n} ${i(e,\"type\")}`;else{const r=function(t,e,r){return\"number\"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,\".\")?\"property\":\"argument\";a=`The \"${t}\" ${r} ${n} ${i(e,\"type\")}`}return a+=\". Received type \"+typeof r,a},TypeError),r(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\"),r(\"ERR_METHOD_NOT_IMPLEMENTED\",function(t){return\"The \"+t+\" method is not implemented\"}),r(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\"),r(\"ERR_STREAM_DESTROYED\",function(t){return\"Cannot call \"+t+\" after a stream was destroyed\"}),r(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\"),r(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\"),r(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\"),r(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),r(\"ERR_UNKNOWN_ENCODING\",function(t){return\"Unknown encoding: \"+t},TypeError),r(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\"),t.exports.F=e},125:(t,e,r)=>{var i=r(4050),n=r(1241),s=r(530),o=r(2438),a=r(8078);function h(t,e,r){if(t=t.toLowerCase(),s[t])return n.createCipheriv(t,e,r);if(o[t])return new i({key:e,iv:r,mode:t});throw new TypeError(\"invalid suite type\")}function u(t,e,r){if(t=t.toLowerCase(),s[t])return n.createDecipheriv(t,e,r);if(o[t])return new i({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError(\"invalid suite type\")}e.createCipher=e.Cipher=function(t,e){var r,i;if(t=t.toLowerCase(),s[t])r=s[t].key,i=s[t].iv;else{if(!o[t])throw new TypeError(\"invalid suite type\");r=8*o[t].key,i=o[t].iv}var n=a(e,!1,r,i);return h(t,n.key,n.iv)},e.createCipheriv=e.Cipheriv=h,e.createDecipher=e.Decipher=function(t,e){var r,i;if(t=t.toLowerCase(),s[t])r=s[t].key,i=s[t].iv;else{if(!o[t])throw new TypeError(\"invalid suite type\");r=8*o[t].key,i=o[t].iv}var n=a(e,!1,r,i);return u(t,n.key,n.iv)},e.createDecipheriv=e.Decipheriv=u,e.listCiphers=e.getCiphers=function(){return Object.keys(o).concat(n.getCiphers())}},206:(t,e,r)=>{var i=r(717),n=r(3225);t.exports=v;var s,o=r(2240);v.ReadableState=b;r(7007).EventEmitter;var a=function(t,e){return t.listeners(e).length},h=r(1862),u=r(4116).Buffer,f=(\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var l=Object.create(r(5622));l.inherits=r(6698);var c=r(537),d=void 0;d=c&&c.debuglog?c.debuglog(\"stream\"):function(){};var p,m=r(672),g=r(6278);l.inherits(v,h);var y=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function b(t,e){t=t||{};var i=e instanceof(s=s||r(6248));this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,o=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,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&&(p||(p=r(6427).I),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function v(t){if(s=s||r(6248),!(this instanceof v))return new v(t);this._readableState=new b(t,this),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),h.call(this)}function w(t,e,r,i,n){var s,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,k(t)}(t,o)):(n||(s=function(t,e){var r;i=e,u.isBuffer(i)||i instanceof f||\"string\"==typeof e||void 0===e||t.objectMode||(r=new TypeError(\"Invalid non-string/buffer chunk\"));var i;return r}(o,e)),s?t.emit(\"error\",s):o.objectMode||e&&e.length>0?(\"string\"==typeof e||o.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),i?o.endEmitted?t.emit(\"error\",new Error(\"stream.unshift() after end event\")):_(t,o,e,!0):o.ended?t.emit(\"error\",new Error(\"stream.push() after EOF\")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?_(t,o,e,!1):x(t,o)):_(t,o,e,!1))):i||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(o)}function _(t,e,r,i){e.flowing&&0===e.length&&!e.sync?(t.emit(\"data\",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&k(t)),x(t,e)}Object.defineProperty(v.prototype,\"destroyed\",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),v.prototype.destroy=g.destroy,v.prototype._undestroy=g.undestroy,v.prototype._destroy=function(t,e){this.push(null),e(t)},v.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:\"string\"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=u.from(t,e),e=\"\"),r=!0),w(this,t,e,!1,r)},v.prototype.unshift=function(t){return w(this,t,null,!0,!1)},v.prototype.isPaused=function(){return!1===this._readableState.flowing},v.prototype.setEncoding=function(t){return p||(p=r(6427).I),this._readableState.decoder=new p(t),this._readableState.encoding=t,this};var M=8388608;function S(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(d(\"emitReadable\",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(E,t):E(t))}function E(t){d(\"emit readable\"),t.emit(\"readable\"),C(t)}function x(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(A,t,e))}function A(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(d(\"maybeReadMore read 0\"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function I(t){d(\"readable nexttick read 0\"),t.read(0)}function T(t,e){e.reading||(d(\"resume read 0\"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit(\"resume\"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(d(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function P(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var i;t<e.head.data.length?(i=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):i=t===e.head.data.length?e.shift():r?function(t,e){var r=e.head,i=1,n=r.data;t-=n.length;for(;r=r.next;){var s=r.data,o=t>s.length?s.length:t;if(o===s.length?n+=s:n+=s.slice(0,t),0===(t-=o)){o===s.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++i}return e.length-=i,n}(t,e):function(t,e){var r=u.allocUnsafe(t),i=e.head,n=1;i.data.copy(r),t-=i.data.length;for(;i=i.next;){var s=i.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=s.slice(o));break}++n}return e.length-=n,r}(t,e);return i}(t,e.buffer,e.decoder),r);var r}function R(t){var e=t._readableState;if(e.length>0)throw new Error('\"endReadable()\" called on non-empty stream');e.endEmitted||(e.ended=!0,n.nextTick(O,e,t))}function O(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"))}function B(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}v.prototype.read=function(t){d(\"read\",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return d(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?R(this):k(this),null;if(0===(t=S(t,e))&&e.ended)return 0===e.length&&R(this),null;var i,n=e.needReadable;return d(\"need readable\",n),(0===e.length||e.length-t<e.highWaterMark)&&d(\"length less than watermark\",n=!0),e.ended||e.reading?d(\"reading or ended\",n=!1):n&&(d(\"do read\"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=S(r,e))),null===(i=t>0?P(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&R(this)),null!==i&&this.emit(\"data\",i),i},v.prototype._read=function(t){this.emit(\"error\",new Error(\"_read() is not implemented\"))},v.prototype.pipe=function(t,e){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,d(\"pipe count=%d opts=%j\",s.pipesCount,e);var h=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?f:v;function u(e,i){d(\"onunpipe\"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,d(\"cleanup\"),t.removeListener(\"close\",y),t.removeListener(\"finish\",b),t.removeListener(\"drain\",l),t.removeListener(\"error\",g),t.removeListener(\"unpipe\",u),r.removeListener(\"end\",f),r.removeListener(\"end\",v),r.removeListener(\"data\",m),c=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){d(\"onend\"),t.end()}s.endEmitted?n.nextTick(h):r.once(\"end\",h),t.on(\"unpipe\",u);var l=function(t){return function(){var e=t._readableState;d(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,\"data\")&&(e.flowing=!0,C(t))}}(r);t.on(\"drain\",l);var c=!1;var p=!1;function m(e){d(\"ondata\"),p=!1,!1!==t.write(e)||p||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==B(s.pipes,t))&&!c&&(d(\"false write response, pause\",s.awaitDrain),s.awaitDrain++,p=!0),r.pause())}function g(e){d(\"onerror\",e),v(),t.removeListener(\"error\",g),0===a(t,\"error\")&&t.emit(\"error\",e)}function y(){t.removeListener(\"finish\",b),v()}function b(){d(\"onfinish\"),t.removeListener(\"close\",y),v()}function v(){d(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",m),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",g),t.once(\"close\",y),t.once(\"finish\",b),t.emit(\"pipe\",r),s.flowing||(d(\"pipe resume\"),r.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s<n;s++)i[s].emit(\"unpipe\",this,{hasUnpiped:!1});return this}var o=B(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit(\"unpipe\",this,r)),this},v.prototype.on=function(t,e){var r=h.prototype.on.call(this,t,e);if(\"data\"===t)!1!==this._readableState.flowing&&this.resume();else if(\"readable\"===t){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&k(this):n.nextTick(I,this))}return r},v.prototype.addListener=v.prototype.on,v.prototype.resume=function(){var t=this._readableState;return t.flowing||(d(\"resume\"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(T,t,e))}(this,t)),this},v.prototype.pause=function(){return d(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(d(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this},v.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on(\"end\",function(){if(d(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on(\"data\",function(n){(d(\"wrapped data\"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(e.push(n)||(i=!0,t.pause()))}),t)void 0===this[n]&&\"function\"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s<y.length;s++)t.on(y[s],this.emit.bind(this,y[s]));return this._read=function(e){d(\"wrapped _read\",e),i&&(i=!1,t.resume())},this},Object.defineProperty(v.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),v._fromList=P},220:(t,e,r)=>{var i=r(8490),n=r(7011),s=n.assert,o=n.cachedProperty,a=n.parseBytes;function h(t,e){this.eddsa=t,\"object\"!=typeof e&&(e=a(e)),Array.isArray(e)&&(s(e.length===2*t.encodingLength,\"Signature has invalid size\"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),s(e.R&&e.S,\"Signature without R or S\"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof i&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}o(h,\"S\",function(){return this.eddsa.decodeInt(this.Sencoded())}),o(h,\"R\",function(){return this.eddsa.decodePoint(this.Rencoded())}),o(h,\"Rencoded\",function(){return this.eddsa.encodePoint(this.R())}),o(h,\"Sencoded\",function(){return this.eddsa.encodeInt(this.S())}),h.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},h.prototype.toHex=function(){return n.encode(this.toBytes(),\"hex\").toUpperCase()},t.exports=h},251:(t,e)=>{e.read=function(t,e,r,i,n){var s,o,a=8*n-i-1,h=(1<<a)-1,u=h>>1,f=-7,l=r?n-1:0,c=r?-1:1,d=t[e+l];for(l+=c,s=d&(1<<-f)-1,d>>=-f,f+=a;f>0;s=256*s+t[e+l],l+=c,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=i;f>0;o=256*o+t[e+l],l+=c,f-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),s-=u}return(d?-1:1)*o*Math.pow(2,s-i)},e.write=function(t,e,r,i,n,s){var o,a,h,u=8*s-n-1,f=(1<<u)-1,l=f>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?c/h:c*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=f?(a=0,o=f):o+l>=1?(a=(e*h-1)*Math.pow(2,n),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,n),o=0));n>=8;t[r+d]=255&a,d+=p,a/=256,n-=8);for(o=o<<n|a,u+=n;u>0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*m}},295:(t,e,r)=>{var i=r(8287).Buffer;t.exports=function(t,e){for(var r=Math.min(t.length,e.length),n=new i(r),s=0;s<r;++s)n[s]=t[s]^e[s];return n}},308:(t,e,r)=>{var i=r(3225),n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=l;var s=Object.create(r(5622));s.inherits=r(6698);var o=r(1706),a=r(2398);s.inherits(l,o);for(var h=n(a.prototype),u=0;u<h.length;u++){var f=h[u];l.prototype[f]||(l.prototype[f]=a.prototype[f])}function l(t){if(!(this instanceof l))return new l(t);o.call(this,t),a.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once(\"end\",c)}function c(){this.allowHalfOpen||this._writableState.ended||i.nextTick(d,this)}function d(t){t.end()}Object.defineProperty(l.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,\"destroyed\",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),l.prototype._destroy=function(t,e){this.push(null),this.end(),i.nextTick(e,t)}},320:(t,e,r)=>{var i=r(8276);t.exports=function(t){return(new i).update(t).digest()}},330:(t,e,r)=>{var i=r(3225);function n(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(n,this,t)):i.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,i.nextTick(n,r,t)):i.nextTick(n,r,t):e&&e(t)}),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)}}},345:(t,e,r)=>{function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function n(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach(function(e){s(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function s(t,e,r){return(e=a(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,\"value\"in i&&(i.writable=!0),Object.defineProperty(t,a(i.key),i)}}function a(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||\"default\");if(\"object\"!=typeof i)return i;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}var h=r(8287).Buffer,u=r(537).inspect,f=u&&u.custom||\"inspect\";function l(t,e,r){h.prototype.copy.call(t,e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError(\"Cannot call a class as a function\")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r,i;return e=t,(r=[{key:\"push\",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:\"unshift\",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:\"shift\",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:\"clear\",value:function(){this.head=this.tail=null,this.length=0}},{key:\"join\",value:function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r}},{key:\"concat\",value:function(t){if(0===this.length)return h.alloc(0);for(var e=h.allocUnsafe(t>>>0),r=this.head,i=0;r;)l(r.data,e,i),i+=r.data.length,r=r.next;return e}},{key:\"consume\",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:\"first\",value:function(){return this.head.data}},{key:\"_getString\",value:function(t){var e=this.head,r=1,i=e.data;for(t-=i.length;e=e.next;){var n=e.data,s=t>n.length?n.length:t;if(s===n.length?i+=n:i+=n.slice(0,t),0===(t-=s)){s===n.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++r}return this.length-=r,i}},{key:\"_getBuffer\",value:function(t){var e=h.allocUnsafe(t),r=this.head,i=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var n=r.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0===(t-=s)){s===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(s));break}++i}return this.length-=i,e}},{key:f,value:function(t,e){return u(this,n(n({},e),{},{depth:0,customInspect:!1}))}}])&&o(e.prototype,r),i&&o(e,i),Object.defineProperty(e,\"prototype\",{writable:!1}),t}()},370:(t,e,r)=>{var i=r(8490),n=r(6698),s=r(6677),o=r(7011);function a(t){s.call(this,\"mont\",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function h(t,e,r){s.BasePoint.call(this,t,\"projective\"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(e,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(a,s),t.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),i=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===i.redSqrt().redSqr().cmp(i)},n(h,s.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(o.toArray(t,e),1)},a.prototype.point=function(t,e){return new h(this,t,e)},a.prototype.pointFromJSON=function(t){return h.fromJSON(this,t)},h.prototype.precompute=function(){},h.prototype._encode=function(){return this.getX().toArray(\"be\",this.curve.p.byteLength())},h.fromJSON=function(t,e){return new h(t,e[0],e[1]||t.one)},h.prototype.inspect=function(){return this.isInfinity()?\"<EC Point Infinity>\":\"<EC Point x: \"+this.x.fromRed().toString(16,2)+\" z: \"+this.z.fromRed().toString(16,2)+\">\"},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},h.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),i=t.redMul(e),n=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},h.prototype.add=function(){throw new Error(\"Not supported on Montgomery curve\")},h.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(r),o=n.redMul(i),a=e.z.redMul(s.redAdd(o).redSqr()),h=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,h)},h.prototype.mul=function(t){for(var e=t.clone(),r=this,i=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},h.prototype.mulAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},h.prototype.jumlAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},h.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},h.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},392:(t,e,r)=>{var i=r(2861).Buffer,n=r(5377);function s(t,e){this._block=i.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}s.prototype.update=function(t,e){t=n(t,e||\"utf8\");for(var r=this._block,i=this._blockSize,s=t.length,o=this._len,a=0;a<s;){for(var h=o%i,u=Math.min(s-a,i-h),f=0;f<u;f++)r[h+f]=t[a+f];a+=u,(o+=u)%i===0&&this._update(r)}return this._len+=s,this},s.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s},s.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},t.exports=s},405:t=>{t.exports=async function*(t){for(let e of t)\"function\"==typeof e&&(e=e()),yield*e}},414:t=>{t.exports=Math.round},453:(t,e,r)=>{var i,n=r(9612),s=r(9383),o=r(1237),a=r(9290),h=r(9538),u=r(8068),f=r(9675),l=r(5345),c=r(1514),d=r(8968),p=r(6188),m=r(8002),g=r(5880),y=r(414),b=r(3093),v=Function,w=function(t){try{return v('\"use strict\"; return ('+t+\").constructor;\")()}catch(t){}},_=r(5795),M=r(655),S=function(){throw new f},k=_?function(){try{return S}catch(t){try{return _(arguments,\"callee\").get}catch(t){return S}}}():S,E=r(4039)(),x=r(3628),A=r(1064),I=r(8648),T=r(1002),C=r(76),P={},R=\"undefined\"!=typeof Uint8Array&&x?x(Uint8Array):i,O={__proto__:null,\"%AggregateError%\":\"undefined\"==typeof AggregateError?i:AggregateError,\"%Array%\":Array,\"%ArrayBuffer%\":\"undefined\"==typeof ArrayBuffer?i:ArrayBuffer,\"%ArrayIteratorPrototype%\":E&&x?x([][Symbol.iterator]()):i,\"%AsyncFromSyncIteratorPrototype%\":i,\"%AsyncFunction%\":P,\"%AsyncGenerator%\":P,\"%AsyncGeneratorFunction%\":P,\"%AsyncIteratorPrototype%\":P,\"%Atomics%\":\"undefined\"==typeof Atomics?i:Atomics,\"%BigInt%\":\"undefined\"==typeof BigInt?i:BigInt,\"%BigInt64Array%\":\"undefined\"==typeof BigInt64Array?i:BigInt64Array,\"%BigUint64Array%\":\"undefined\"==typeof BigUint64Array?i:BigUint64Array,\"%Boolean%\":Boolean,\"%DataView%\":\"undefined\"==typeof DataView?i:DataView,\"%Date%\":Date,\"%decodeURI%\":decodeURI,\"%decodeURIComponent%\":decodeURIComponent,\"%encodeURI%\":encodeURI,\"%encodeURIComponent%\":encodeURIComponent,\"%Error%\":s,\"%eval%\":eval,\"%EvalError%\":o,\"%Float16Array%\":\"undefined\"==typeof Float16Array?i:Float16Array,\"%Float32Array%\":\"undefined\"==typeof Float32Array?i:Float32Array,\"%Float64Array%\":\"undefined\"==typeof Float64Array?i:Float64Array,\"%FinalizationRegistry%\":\"undefined\"==typeof FinalizationRegistry?i:FinalizationRegistry,\"%Function%\":v,\"%GeneratorFunction%\":P,\"%Int8Array%\":\"undefined\"==typeof Int8Array?i:Int8Array,\"%Int16Array%\":\"undefined\"==typeof Int16Array?i:Int16Array,\"%Int32Array%\":\"undefined\"==typeof Int32Array?i:Int32Array,\"%isFinite%\":isFinite,\"%isNaN%\":isNaN,\"%IteratorPrototype%\":E&&x?x(x([][Symbol.iterator]())):i,\"%JSON%\":\"object\"==typeof JSON?JSON:i,\"%Map%\":\"undefined\"==typeof Map?i:Map,\"%MapIteratorPrototype%\":\"undefined\"!=typeof Map&&E&&x?x((new Map)[Symbol.iterator]()):i,\"%Math%\":Math,\"%Number%\":Number,\"%Object%\":n,\"%Object.getOwnPropertyDescriptor%\":_,\"%parseFloat%\":parseFloat,\"%parseInt%\":parseInt,\"%Promise%\":\"undefined\"==typeof Promise?i:Promise,\"%Proxy%\":\"undefined\"==typeof Proxy?i:Proxy,\"%RangeError%\":a,\"%ReferenceError%\":h,\"%Reflect%\":\"undefined\"==typeof Reflect?i:Reflect,\"%RegExp%\":RegExp,\"%Set%\":\"undefined\"==typeof Set?i:Set,\"%SetIteratorPrototype%\":\"undefined\"!=typeof Set&&E&&x?x((new Set)[Symbol.iterator]()):i,\"%SharedArrayBuffer%\":\"undefined\"==typeof SharedArrayBuffer?i:SharedArrayBuffer,\"%String%\":String,\"%StringIteratorPrototype%\":E&&x?x(\"\"[Symbol.iterator]()):i,\"%Symbol%\":E?Symbol:i,\"%SyntaxError%\":u,\"%ThrowTypeError%\":k,\"%TypedArray%\":R,\"%TypeError%\":f,\"%Uint8Array%\":\"undefined\"==typeof Uint8Array?i:Uint8Array,\"%Uint8ClampedArray%\":\"undefined\"==typeof Uint8ClampedArray?i:Uint8ClampedArray,\"%Uint16Array%\":\"undefined\"==typeof Uint16Array?i:Uint16Array,\"%Uint32Array%\":\"undefined\"==typeof Uint32Array?i:Uint32Array,\"%URIError%\":l,\"%WeakMap%\":\"undefined\"==typeof WeakMap?i:WeakMap,\"%WeakRef%\":\"undefined\"==typeof WeakRef?i:WeakRef,\"%WeakSet%\":\"undefined\"==typeof WeakSet?i:WeakSet,\"%Function.prototype.call%\":C,\"%Function.prototype.apply%\":T,\"%Object.defineProperty%\":M,\"%Object.getPrototypeOf%\":A,\"%Math.abs%\":c,\"%Math.floor%\":d,\"%Math.max%\":p,\"%Math.min%\":m,\"%Math.pow%\":g,\"%Math.round%\":y,\"%Math.sign%\":b,\"%Reflect.getPrototypeOf%\":I};if(x)try{null.error}catch(t){var B=x(x(t));O[\"%Error.prototype%\"]=B}var L=function t(e){var r;if(\"%AsyncFunction%\"===e)r=w(\"async function () {}\");else if(\"%GeneratorFunction%\"===e)r=w(\"function* () {}\");else if(\"%AsyncGeneratorFunction%\"===e)r=w(\"async function* () {}\");else if(\"%AsyncGenerator%\"===e){var i=t(\"%AsyncGeneratorFunction%\");i&&(r=i.prototype)}else if(\"%AsyncIteratorPrototype%\"===e){var n=t(\"%AsyncGenerator%\");n&&x&&(r=x(n.prototype))}return O[e]=r,r},N={__proto__:null,\"%ArrayBufferPrototype%\":[\"ArrayBuffer\",\"prototype\"],\"%ArrayPrototype%\":[\"Array\",\"prototype\"],\"%ArrayProto_entries%\":[\"Array\",\"prototype\",\"entries\"],\"%ArrayProto_forEach%\":[\"Array\",\"prototype\",\"forEach\"],\"%ArrayProto_keys%\":[\"Array\",\"prototype\",\"keys\"],\"%ArrayProto_values%\":[\"Array\",\"prototype\",\"values\"],\"%AsyncFunctionPrototype%\":[\"AsyncFunction\",\"prototype\"],\"%AsyncGenerator%\":[\"AsyncGeneratorFunction\",\"prototype\"],\"%AsyncGeneratorPrototype%\":[\"AsyncGeneratorFunction\",\"prototype\",\"prototype\"],\"%BooleanPrototype%\":[\"Boolean\",\"prototype\"],\"%DataViewPrototype%\":[\"DataView\",\"prototype\"],\"%DatePrototype%\":[\"Date\",\"prototype\"],\"%ErrorPrototype%\":[\"Error\",\"prototype\"],\"%EvalErrorPrototype%\":[\"EvalError\",\"prototype\"],\"%Float32ArrayPrototype%\":[\"Float32Array\",\"prototype\"],\"%Float64ArrayPrototype%\":[\"Float64Array\",\"prototype\"],\"%FunctionPrototype%\":[\"Function\",\"prototype\"],\"%Generator%\":[\"GeneratorFunction\",\"prototype\"],\"%GeneratorPrototype%\":[\"GeneratorFunction\",\"prototype\",\"prototype\"],\"%Int8ArrayPrototype%\":[\"Int8Array\",\"prototype\"],\"%Int16ArrayPrototype%\":[\"Int16Array\",\"prototype\"],\"%Int32ArrayPrototype%\":[\"Int32Array\",\"prototype\"],\"%JSONParse%\":[\"JSON\",\"parse\"],\"%JSONStringify%\":[\"JSON\",\"stringify\"],\"%MapPrototype%\":[\"Map\",\"prototype\"],\"%NumberPrototype%\":[\"Number\",\"prototype\"],\"%ObjectPrototype%\":[\"Object\",\"prototype\"],\"%ObjProto_toString%\":[\"Object\",\"prototype\",\"toString\"],\"%ObjProto_valueOf%\":[\"Object\",\"prototype\",\"valueOf\"],\"%PromisePrototype%\":[\"Promise\",\"prototype\"],\"%PromiseProto_then%\":[\"Promise\",\"prototype\",\"then\"],\"%Promise_all%\":[\"Promise\",\"all\"],\"%Promise_reject%\":[\"Promise\",\"reject\"],\"%Promise_resolve%\":[\"Promise\",\"resolve\"],\"%RangeErrorPrototype%\":[\"RangeError\",\"prototype\"],\"%ReferenceErrorPrototype%\":[\"ReferenceError\",\"prototype\"],\"%RegExpPrototype%\":[\"RegExp\",\"prototype\"],\"%SetPrototype%\":[\"Set\",\"prototype\"],\"%SharedArrayBufferPrototype%\":[\"SharedArrayBuffer\",\"prototype\"],\"%StringPrototype%\":[\"String\",\"prototype\"],\"%SymbolPrototype%\":[\"Symbol\",\"prototype\"],\"%SyntaxErrorPrototype%\":[\"SyntaxError\",\"prototype\"],\"%TypedArrayPrototype%\":[\"TypedArray\",\"prototype\"],\"%TypeErrorPrototype%\":[\"TypeError\",\"prototype\"],\"%Uint8ArrayPrototype%\":[\"Uint8Array\",\"prototype\"],\"%Uint8ClampedArrayPrototype%\":[\"Uint8ClampedArray\",\"prototype\"],\"%Uint16ArrayPrototype%\":[\"Uint16Array\",\"prototype\"],\"%Uint32ArrayPrototype%\":[\"Uint32Array\",\"prototype\"],\"%URIErrorPrototype%\":[\"URIError\",\"prototype\"],\"%WeakMapPrototype%\":[\"WeakMap\",\"prototype\"],\"%WeakSetPrototype%\":[\"WeakSet\",\"prototype\"]},j=r(6743),U=r(9957),q=j.call(C,Array.prototype.concat),D=j.call(T,Array.prototype.splice),H=j.call(C,String.prototype.replace),F=j.call(C,String.prototype.slice),z=j.call(C,RegExp.prototype.exec),W=/[^%.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|%$))/g,$=/\\\\(\\\\)?/g,V=function(t,e){var r,i=t;if(U(N,i)&&(i=\"%\"+(r=N[i])[0]+\"%\"),U(O,i)){var n=O[i];if(n===P&&(n=L(i)),void 0===n&&!e)throw new f(\"intrinsic \"+t+\" exists, but is not available. Please file an issue!\");return{alias:r,name:i,value:n}}throw new u(\"intrinsic \"+t+\" does not exist!\")};t.exports=function(t,e){if(\"string\"!=typeof t||0===t.length)throw new f(\"intrinsic name must be a non-empty string\");if(arguments.length>1&&\"boolean\"!=typeof e)throw new f('\"allowMissing\" argument must be a boolean');if(null===z(/^%?[^%]*%?$/,t))throw new u(\"`%` may not be present anywhere but at the beginning and end of the intrinsic name\");var r=function(t){var e=F(t,0,1),r=F(t,-1);if(\"%\"===e&&\"%\"!==r)throw new u(\"invalid intrinsic syntax, expected closing `%`\");if(\"%\"===r&&\"%\"!==e)throw new u(\"invalid intrinsic syntax, expected opening `%`\");var i=[];return H(t,W,function(t,e,r,n){i[i.length]=r?H(n,$,\"$1\"):e||t}),i}(t),i=r.length>0?r[0]:\"\",n=V(\"%\"+i+\"%\",e),s=n.name,o=n.value,a=!1,h=n.alias;h&&(i=h[0],D(r,q([0,1],h)));for(var l=1,c=!0;l<r.length;l+=1){var d=r[l],p=F(d,0,1),m=F(d,-1);if(('\"'===p||\"'\"===p||\"`\"===p||'\"'===m||\"'\"===m||\"`\"===m)&&p!==m)throw new u(\"property names with quotes must have matching quotes\");if(\"constructor\"!==d&&c||(a=!0),U(O,s=\"%\"+(i+=\".\"+d)+\"%\"))o=O[s];else if(null!=o){if(!(d in o)){if(!e)throw new f(\"base intrinsic for \"+t+\" exists, but the property is not available.\");return}if(_&&l+1>=r.length){var g=_(o,d);o=(c=!!g)&&\"get\"in g&&!(\"originalValue\"in g.get)?g.get:o[d]}else c=U(o,d),o=o[d];c&&!a&&(O[s]=o)}}return o}},462:(t,e,r)=>{var i=r(2861).Buffer;function n(t){i.isBuffer(t)||(t=i.from(t));for(var e=t.length/4|0,r=new Array(e),n=0;n<e;n++)r[n]=t.readUInt32BE(4*n);return r}function s(t){for(;0<t.length;t++)t[0]=0}function o(t,e,r,i,n){for(var s,o,a,h,u=r[0],f=r[1],l=r[2],c=r[3],d=t[0]^e[0],p=t[1]^e[1],m=t[2]^e[2],g=t[3]^e[3],y=4,b=1;b<n;b++)s=u[d>>>24]^f[p>>>16&255]^l[m>>>8&255]^c[255&g]^e[y++],o=u[p>>>24]^f[m>>>16&255]^l[g>>>8&255]^c[255&d]^e[y++],a=u[m>>>24]^f[g>>>16&255]^l[d>>>8&255]^c[255&p]^e[y++],h=u[g>>>24]^f[d>>>16&255]^l[p>>>8&255]^c[255&m]^e[y++],d=s,p=o,m=a,g=h;return s=(i[d>>>24]<<24|i[p>>>16&255]<<16|i[m>>>8&255]<<8|i[255&g])^e[y++],o=(i[p>>>24]<<24|i[m>>>16&255]<<16|i[g>>>8&255]<<8|i[255&d])^e[y++],a=(i[m>>>24]<<24|i[g>>>16&255]<<16|i[d>>>8&255]<<8|i[255&p])^e[y++],h=(i[g>>>24]<<24|i[d>>>16&255]<<16|i[p>>>8&255]<<8|i[255&m])^e[y++],[s>>>=0,o>>>=0,a>>>=0,h>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],h=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],i=[],n=[[],[],[],[]],s=[[],[],[],[]],o=0,a=0,h=0;h<256;++h){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,r[o]=u,i[u]=o;var f=t[o],l=t[f],c=t[l],d=257*t[u]^16843008*u;n[0][o]=d<<24|d>>>8,n[1][o]=d<<16|d>>>16,n[2][o]=d<<8|d>>>24,n[3][o]=d,d=16843009*c^65537*l^257*f^16843008*o,s[0][u]=d<<24|d>>>8,s[1][u]=d<<16|d>>>16,s[2][u]=d<<8|d>>>24,s[3][u]=d,0===o?o=a=1:(o=f^t[t[t[c^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:s}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,i=4*(r+1),n=[],s=0;s<e;s++)n[s]=t[s];for(s=e;s<i;s++){var o=n[s-1];s%e===0?(o=o<<8|o>>>24,o=h.SBOX[o>>>24]<<24|h.SBOX[o>>>16&255]<<16|h.SBOX[o>>>8&255]<<8|h.SBOX[255&o],o^=a[s/e|0]<<24):e>6&&s%e===4&&(o=h.SBOX[o>>>24]<<24|h.SBOX[o>>>16&255]<<16|h.SBOX[o>>>8&255]<<8|h.SBOX[255&o]),n[s]=n[s-e]^o}for(var u=[],f=0;f<i;f++){var l=i-f,c=n[l-(f%4?0:4)];u[f]=f<4||l<=4?c:h.INV_SUB_MIX[0][h.SBOX[c>>>24]]^h.INV_SUB_MIX[1][h.SBOX[c>>>16&255]]^h.INV_SUB_MIX[2][h.SBOX[c>>>8&255]]^h.INV_SUB_MIX[3][h.SBOX[255&c]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=u},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,h.SUB_MIX,h.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=i.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,h.INV_SUB_MIX,h.INV_SBOX,this._nRounds),s=i.allocUnsafe(16);return s.writeUInt32BE(r[0],0),s.writeUInt32BE(r[3],4),s.writeUInt32BE(r[2],8),s.writeUInt32BE(r[1],12),s},u.prototype.scrub=function(){s(this._keySchedule),s(this._invKeySchedule),s(this._key)},t.exports.AES=u},480:(t,e,r)=>{var i,n=e,s=r(7952),o=r(894),a=r(7011).assert;function h(t){\"short\"===t.type?this.curve=new o.short(t):\"edwards\"===t.type?this.curve=new o.edwards(t):this.curve=new o.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),\"Invalid curve\"),a(this.g.mul(this.n).isInfinity(),\"Invalid curve, G*N != O\")}function u(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new h(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=h,u(\"p192\",{type:\"short\",prime:\"p192\",p:\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\",a:\"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc\",b:\"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1\",n:\"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831\",hash:s.sha256,gRed:!1,g:[\"188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012\",\"07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811\"]}),u(\"p224\",{type:\"short\",prime:\"p224\",p:\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\",a:\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe\",b:\"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4\",n:\"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d\",hash:s.sha256,gRed:!1,g:[\"b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21\",\"bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34\"]}),u(\"p256\",{type:\"short\",prime:null,p:\"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff\",a:\"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc\",b:\"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b\",n:\"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551\",hash:s.sha256,gRed:!1,g:[\"6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296\",\"4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5\"]}),u(\"p384\",{type:\"short\",prime:null,p:\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff\",a:\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc\",b:\"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef\",n:\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973\",hash:s.sha384,gRed:!1,g:[\"aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7\",\"3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f\"]}),u(\"p521\",{type:\"short\",prime:null,p:\"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff\",a:\"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc\",b:\"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00\",n:\"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409\",hash:s.sha512,gRed:!1,g:[\"000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66\",\"00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650\"]}),u(\"curve25519\",{type:\"mont\",prime:\"p25519\",p:\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\",a:\"76d06\",b:\"1\",n:\"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed\",hash:s.sha256,gRed:!1,g:[\"9\"]}),u(\"ed25519\",{type:\"edwards\",prime:\"p25519\",p:\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\",a:\"-1\",c:\"1\",d:\"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3\",n:\"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed\",hash:s.sha256,gRed:!1,g:[\"216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a\",\"6666666666666666666666666666666666666666666666666666666666666658\"]});try{i=r(4011)}catch(t){i=void 0}u(\"secp256k1\",{type:\"short\",prime:\"k256\",p:\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\",a:\"0\",b:\"7\",n:\"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141\",h:\"1\",hash:s.sha256,beta:\"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\",lambda:\"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72\",basis:[{a:\"3086d221a7d46bcde86c90e49284eb15\",b:\"-e4437ed6010e88286f547fa90abfe4c3\"},{a:\"114ca50f7a8e2f3f657c1108d9d44cfd8\",b:\"3086d221a7d46bcde86c90e49284eb15\"}],gRed:!1,g:[\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\",\"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\",i]})},487:(t,e,r)=>{var i=r(6897),n=r(655),s=r(3126),o=r(2205);t.exports=function(t){var e=s(arguments),r=t.length-(arguments.length-1);return i(e,1+(r>0?r:0),!0)},n?n(t.exports,\"apply\",{value:o}):t.exports.apply=o},507:(t,e,r)=>{var i=r(453),n=r(6556),s=r(8859),o=r(9675),a=i(\"%Map%\",!0),h=n(\"Map.prototype.get\",!0),u=n(\"Map.prototype.set\",!0),f=n(\"Map.prototype.has\",!0),l=n(\"Map.prototype.delete\",!0),c=n(\"Map.prototype.size\",!0);t.exports=!!a&&function(){var t,e={assert:function(t){if(!e.has(t))throw new o(\"Side channel does not contain \"+s(t))},delete:function(e){if(t){var r=l(t,e);return 0===c(t)&&(t=void 0),r}return!1},get:function(e){if(t)return h(t,e)},has:function(e){return!!t&&f(t,e)},set:function(e,r){t||(t=new a),u(t,e,r)}};return e}},530:(t,e,r)=>{var i={ECB:r(2632),CBC:r(2884),CFB:r(6383),CFB8:r(6975),CFB1:r(5264),OFB:r(6843),CTR:r(3053),GCM:r(3053)},n=r(3219);for(var s in n)n[s].module=i[n[s].mode];t.exports=n},537:(t,e,r)=>{var i=r(717),n=/%[sdj%]/g;e.format=function(t){if(!y(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(\" \")}r=1;for(var i=arguments,s=i.length,o=String(t).replace(n,function(t){if(\"%%\"===t)return\"%\";if(r>=s)return t;switch(t){case\"%s\":return String(i[r++]);case\"%d\":return Number(i[r++]);case\"%j\":try{return JSON.stringify(i[r++])}catch(t){return\"[Circular]\"}default:return t}}),h=i[r];r<s;h=i[++r])m(h)||!w(h)?o+=\" \"+h:o+=\" \"+a(h);return o},e.deprecate=function(t,r){if(b(globalThis.process))return function(){return e.deprecate(t,r).apply(this,arguments)};if(!0===i.noDeprecation)return t;var n=!1;return function(){if(!n){if(i.throwDeprecation)throw new Error(r);i.traceDeprecation?console.trace(r):console.error(r),n=!0}return t.apply(this,arguments)}};var s,o={};function a(t,r){var i={seen:[],stylize:u};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(r)?i.showHidden=r:r&&e._extend(i,r),b(i.showHidden)&&(i.showHidden=!1),b(i.depth)&&(i.depth=2),b(i.colors)&&(i.colors=!1),b(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=h),f(i,t,i.depth)}function h(t,e){var r=a.styles[e];return r?\"\u001b[\"+a.colors[r][0]+\"m\"+t+\"\u001b[\"+a.colors[r][1]+\"m\":t}function u(t,e){return t}function f(t,r,i){if(t.customInspect&&r&&S(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(i,t);return y(n)||(n=f(t,n,i)),n}var s=function(t,e){if(b(e))return t.stylize(\"undefined\",\"undefined\");if(y(e)){var r=\"'\"+JSON.stringify(e).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return t.stylize(r,\"string\")}if(g(e))return t.stylize(\"\"+e,\"number\");if(p(e))return t.stylize(\"\"+e,\"boolean\");if(m(e))return t.stylize(\"null\",\"null\")}(t,r);if(s)return s;var o=Object.keys(r),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),M(r)&&(o.indexOf(\"message\")>=0||o.indexOf(\"description\")>=0))return l(r);if(0===o.length){if(S(r)){var h=r.name?\": \"+r.name:\"\";return t.stylize(\"[Function\"+h+\"]\",\"special\")}if(v(r))return t.stylize(RegExp.prototype.toString.call(r),\"regexp\");if(_(r))return t.stylize(Date.prototype.toString.call(r),\"date\");if(M(r))return l(r)}var u,w=\"\",k=!1,E=[\"{\",\"}\"];(d(r)&&(k=!0,E=[\"[\",\"]\"]),S(r))&&(w=\" [Function\"+(r.name?\": \"+r.name:\"\")+\"]\");return v(r)&&(w=\" \"+RegExp.prototype.toString.call(r)),_(r)&&(w=\" \"+Date.prototype.toUTCString.call(r)),M(r)&&(w=\" \"+l(r)),0!==o.length||k&&0!=r.length?i<0?v(r)?t.stylize(RegExp.prototype.toString.call(r),\"regexp\"):t.stylize(\"[Object]\",\"special\"):(t.seen.push(r),u=k?function(t,e,r,i,n){for(var s=[],o=0,a=e.length;o<a;++o)A(e,String(o))?s.push(c(t,e,r,i,String(o),!0)):s.push(\"\");return n.forEach(function(n){n.match(/^\\d+$/)||s.push(c(t,e,r,i,n,!0))}),s}(t,r,i,a,o):o.map(function(e){return c(t,r,i,a,e,k)}),t.seen.pop(),function(t,e,r){var i=t.reduce(function(t,e){return e.indexOf(\"\\n\")>=0&&0,t+e.replace(/\\u001b\\[\\d\\d?m/g,\"\").length+1},0);if(i>60)return r[0]+(\"\"===e?\"\":e+\"\\n \")+\" \"+t.join(\",\\n  \")+\" \"+r[1];return r[0]+e+\" \"+t.join(\", \")+\" \"+r[1]}(u,w,E)):E[0]+w+E[1]}function l(t){return\"[\"+Error.prototype.toString.call(t)+\"]\"}function c(t,e,r,i,n,s){var o,a,h;if((h=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]}).get?a=h.set?t.stylize(\"[Getter/Setter]\",\"special\"):t.stylize(\"[Getter]\",\"special\"):h.set&&(a=t.stylize(\"[Setter]\",\"special\")),A(i,n)||(o=\"[\"+n+\"]\"),a||(t.seen.indexOf(h.value)<0?(a=m(r)?f(t,h.value,null):f(t,h.value,r-1)).indexOf(\"\\n\")>-1&&(a=s?a.split(\"\\n\").map(function(t){return\"  \"+t}).join(\"\\n\").substr(2):\"\\n\"+a.split(\"\\n\").map(function(t){return\"   \"+t}).join(\"\\n\")):a=t.stylize(\"[Circular]\",\"special\")),b(o)){if(s&&n.match(/^\\d+$/))return a;(o=JSON.stringify(\"\"+n)).match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,\"name\")):(o=o.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),o=t.stylize(o,\"string\"))}return o+\": \"+a}function d(t){return Array.isArray(t)}function p(t){return\"boolean\"==typeof t}function m(t){return null===t}function g(t){return\"number\"==typeof t}function y(t){return\"string\"==typeof t}function b(t){return void 0===t}function v(t){return w(t)&&\"[object RegExp]\"===k(t)}function w(t){return\"object\"==typeof t&&null!==t}function _(t){return w(t)&&\"[object Date]\"===k(t)}function M(t){return w(t)&&(\"[object Error]\"===k(t)||t instanceof Error)}function S(t){return\"function\"==typeof t}function k(t){return Object.prototype.toString.call(t)}function E(t){return t<10?\"0\"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(b(s)&&(s=i.env.NODE_DEBUG||\"\"),t=t.toUpperCase(),!o[t])if(new RegExp(\"\\\\b\"+t+\"\\\\b\",\"i\").test(s)){var r=i.pid;o[t]=function(){var i=e.format.apply(e,arguments);console.error(\"%s %d: %s\",t,r,i)}}else o[t]=function(){};return o[t]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"},e.isArray=d,e.isBoolean=p,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=y,e.isSymbol=function(t){return\"symbol\"==typeof t},e.isUndefined=b,e.isRegExp=v,e.isObject=w,e.isDate=_,e.isError=M,e.isFunction=S,e.isPrimitive=function(t){return null===t||\"boolean\"==typeof t||\"number\"==typeof t||\"string\"==typeof t||\"symbol\"==typeof t||void 0===t},e.isBuffer=r(2503);var x=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];function A(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){var t,r;console.log(\"%s - %s\",(t=new Date,r=[E(t.getHours()),E(t.getMinutes()),E(t.getSeconds())].join(\":\"),[t.getDate(),x[t.getMonth()],r].join(\" \")),e.format.apply(e,arguments))},e.inherits=r(6622),e._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),i=r.length;i--;)t[r[i]]=e[r[i]];return t}},580:t=>{var e=/[\"'&<>]/;t.exports=function(t){var r,i=\"\"+t,n=e.exec(i);if(!n)return i;var s=\"\",o=0,a=0;for(o=n.index;o<i.length;o++){switch(i.charCodeAt(o)){case 34:r=\"&quot;\";break;case 38:r=\"&amp;\";break;case 39:r=\"&#39;\";break;case 60:r=\"&lt;\";break;case 62:r=\"&gt;\";break;default:continue}a!==o&&(s+=i.substring(a,o)),a=o+1,s+=r}return a!==o?s+i.substring(a,o):s}},592:(t,e,r)=>{var i=r(655),n=function(){return!!i};n.hasArrayLengthDefineBug=function(){if(!i)return null;try{return 1!==i([],\"length\",{value:1}).length}catch(t){return!0}},t.exports=n},640:function(t){!function(e){const r=\"(0?\\\\d+|0x[a-f0-9]+)\",i={fourOctet:new RegExp(`^${r}\\\\.${r}\\\\.${r}\\\\.${r}$`,\"i\"),threeOctet:new RegExp(`^${r}\\\\.${r}\\\\.${r}$`,\"i\"),twoOctet:new RegExp(`^${r}\\\\.${r}$`,\"i\"),longValue:new RegExp(`^${r}$`,\"i\")},n=new RegExp(\"^0[0-7]+$\",\"i\"),s=new RegExp(\"^0x[a-f0-9]+$\",\"i\"),o=\"%[0-9a-z]{1,}\",a=\"(?:[0-9a-f]+::?)+\",h={zoneIndex:new RegExp(o,\"i\"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${o})?$`,\"i\"),deprecatedTransitional:new RegExp(`^(?:::)(${r}\\\\.${r}\\\\.${r}\\\\.${r}(${o})?)$`,\"i\"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${r}\\\\.${r}\\\\.${r}\\\\.${r}(${o})?$`,\"i\")};function u(t,e){if(t.indexOf(\"::\")!==t.lastIndexOf(\"::\"))return null;let r,i,n=0,s=-1,o=(t.match(h.zoneIndex)||[])[0];for(o&&(o=o.substring(1),t=t.replace(/%.+$/,\"\"));(s=t.indexOf(\":\",s+1))>=0;)n++;if(\"::\"===t.substr(0,2)&&n--,\"::\"===t.substr(-2,2)&&n--,n>e)return null;for(i=e-n,r=\":\";i--;)r+=\"0:\";return\":\"===(t=t.replace(\"::\",r))[0]&&(t=t.slice(1)),\":\"===t[t.length-1]&&(t=t.slice(0,-1)),{parts:e=function(){const e=t.split(\":\"),r=[];for(let t=0;t<e.length;t++)r.push(parseInt(e[t],16));return r}(),zoneId:o}}function f(t,e,r,i){if(t.length!==e.length)throw new Error(\"ipaddr: cannot match CIDR for objects with different lengths\");let n,s=0;for(;i>0;){if(n=r-i,n<0&&(n=0),t[s]>>n!==e[s]>>n)return!1;i-=r,s+=1}return!0}function l(t){if(s.test(t))return parseInt(t,16);if(\"0\"===t[0]&&!isNaN(parseInt(t[1],10))){if(n.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function c(t,e){for(;t.length<e;)t=`0${t}`;return t}const d={};d.IPv4=function(){function t(t){if(4!==t.length)throw new Error(\"ipaddr: ipv4 octet count should be 4\");let e,r;for(e=0;e<t.length;e++)if(r=t[e],!(0<=r&&r<=255))throw new Error(\"ipaddr: ipv4 octet should fit in 8 bits\");this.octets=t}return t.prototype.SpecialRanges={unspecified:[[new t([0,0,0,0]),8]],broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],carrierGradeNat:[[new t([100,64,0,0]),10]],private:[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,18,0,0]),15],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]],as112:[[new t([192,175,48,0]),24],[new t([192,31,196,0]),24]],amt:[[new t([192,52,193,0]),24]]},t.prototype.kind=function(){return\"ipv4\"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),\"ipv4\"!==t.kind())throw new Error(\"ipaddr: cannot match ipv4 address with non-ipv4 one\");return f(this.octets,t.octets,8,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let i,n,s;for(i=3;i>=0;i-=1){if(n=this.octets[i],!(n in r))return null;if(s=r[n],e&&0!==s)return null;8!==s&&(e=!0),t+=s}return 32-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return d.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(\".\")},t}(),d.IPv4.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),i=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),n=[];let s=0;for(;s<4;)n.push(parseInt(r[s],10)|255^parseInt(i[s],10)),s++;return new this(n)}catch(t){throw new Error(\"ipaddr: the address does not have IPv4 CIDR format\")}},d.IPv4.isIPv4=function(t){return null!==this.parser(t)},d.IPv4.isValid=function(t){try{return new this(this.parser(t)),!0}catch(t){return!1}},d.IPv4.isValidCIDR=function(t){try{return this.parseCIDR(t),!0}catch(t){return!1}},d.IPv4.isValidFourPartDecimal=function(t){return!(!d.IPv4.isValid(t)||!t.match(/^(0|[1-9]\\d*)(\\.(0|[1-9]\\d*)){3}$/))},d.IPv4.isValidCIDRFourPartDecimal=function(t){const e=t.match(/^(.+)\\/(\\d+)$/);return!(!d.IPv4.isValidCIDR(t)||!e)&&d.IPv4.isValidFourPartDecimal(e[1])},d.IPv4.networkAddressFromCIDR=function(t){let e,r,i,n,s;try{for(e=this.parseCIDR(t),i=e[0].toByteArray(),s=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),n=[],r=0;r<4;)n.push(parseInt(i[r],10)&parseInt(s[r],10)),r++;return new this(n)}catch(t){throw new Error(\"ipaddr: the address does not have IPv4 CIDR format\")}},d.IPv4.parse=function(t){const e=this.parser(t);if(null===e)throw new Error(\"ipaddr: string is not formatted like an IPv4 Address\");return new this(e)},d.IPv4.parseCIDR=function(t){let e;if(e=t.match(/^(.+)\\/(\\d+)$/)){const t=parseInt(e[2]);if(t>=0&&t<=32){const r=[this.parse(e[1]),t];return Object.defineProperty(r,\"toString\",{value:function(){return this.join(\"/\")}}),r}}throw new Error(\"ipaddr: string is not formatted like an IPv4 CIDR range\")},d.IPv4.parser=function(t){let e,r,n;if(e=t.match(i.fourOctet))return function(){const t=e.slice(1,6),i=[];for(let e=0;e<t.length;e++)r=t[e],i.push(l(r));return i}();if(e=t.match(i.longValue)){if(n=l(e[1]),n>4294967295||n<0)throw new Error(\"ipaddr: address outside defined range\");return function(){const t=[];let e;for(e=0;e<=24;e+=8)t.push(n>>e&255);return t}().reverse()}return(e=t.match(i.twoOctet))?function(){const t=e.slice(1,4),r=[];if(n=l(t[1]),n>16777215||n<0)throw new Error(\"ipaddr: address outside defined range\");return r.push(l(t[0])),r.push(n>>16&255),r.push(n>>8&255),r.push(255&n),r}():(e=t.match(i.threeOctet))?function(){const t=e.slice(1,5),r=[];if(n=l(t[2]),n>65535||n<0)throw new Error(\"ipaddr: address outside defined range\");return r.push(l(t[0])),r.push(l(t[1])),r.push(n>>8&255),r.push(255&n),r}():null},d.IPv4.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>32)throw new Error(\"ipaddr: invalid IPv4 prefix length\");const e=[0,0,0,0];let r=0;const i=Math.floor(t/8);for(;r<i;)e[r]=255,r++;return i<4&&(e[i]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.IPv6=function(){function t(t,e){let r,i;if(16===t.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(t[r]<<8|t[r+1]);else{if(8!==t.length)throw new Error(\"ipaddr: ipv6 part count should be 8 or 16\");this.parts=t}for(r=0;r<this.parts.length;r++)if(i=this.parts[r],!(0<=i&&i<=65535))throw new Error(\"ipaddr: ipv6 part should fit in 16 bits\");e&&(this.zoneId=e)}return t.prototype.SpecialRanges={unspecified:[new t([0,0,0,0,0,0,0,0]),128],linkLocal:[new t([65152,0,0,0,0,0,0,0]),10],multicast:[new t([65280,0,0,0,0,0,0,0]),8],loopback:[new t([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new t([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new t([0,0,0,0,0,65535,0,0]),96],discard:[new t([256,0,0,0,0,0,0,0]),64],rfc6145:[new t([0,0,0,0,65535,0,0,0]),96],rfc6052:[new t([100,65435,0,0,0,0,0,0]),96],\"6to4\":[new t([8194,0,0,0,0,0,0,0]),16],teredo:[new t([8193,0,0,0,0,0,0,0]),32],benchmarking:[new t([8193,2,0,0,0,0,0,0]),48],amt:[new t([8193,3,0,0,0,0,0,0]),32],as112v6:[[new t([8193,4,274,0,0,0,0,0]),48],[new t([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new t([8193,16,0,0,0,0,0,0]),28],orchid2:[new t([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new t([8193,48,0,0,0,0,0,0]),28],reserved:[[new t([8193,0,0,0,0,0,0,0]),23],[new t([8193,3512,0,0,0,0,0,0]),32]]},t.prototype.isIPv4MappedAddress=function(){return\"ipv4Mapped\"===this.range()},t.prototype.kind=function(){return\"ipv6\"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),\"ipv6\"!==t.kind())throw new Error(\"ipaddr: cannot match ipv6 address with non-ipv6 one\");return f(this.parts,t.parts,16,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let i,n;for(let s=7;s>=0;s-=1){if(i=this.parts[s],!(i in r))return null;if(n=r[i],e&&0!==n)return null;16!==n&&(e=!0),t+=n}return 128-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){let t;const e=[],r=this.parts;for(let i=0;i<r.length;i++)t=r[i],e.push(t>>8),e.push(255&t);return e},t.prototype.toFixedLengthString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(c(this.parts[e].toString(16),4));return t}.call(this).join(\":\");let e=\"\";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error(\"ipaddr: trying to convert a generic ipv6 address to ipv4\");const t=this.parts.slice(-2),e=t[0],r=t[1];return new d.IPv4([e>>8,255&e,r>>8,255&r])},t.prototype.toNormalizedString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(this.parts[e].toString(16));return t}.call(this).join(\":\");let e=\"\";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toRFC5952String=function(){const t=/((^|:)(0(:|$)){2,})/g,e=this.toNormalizedString();let r,i=0,n=-1;for(;r=t.exec(e);)r[0].length>n&&(i=r.index,n=r[0].length);return n<0?e:`${e.substring(0,i)}::${e.substring(i+n)}`},t.prototype.toString=function(){return this.toRFC5952String()},t}(),d.IPv6.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),i=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),n=[];let s=0;for(;s<16;)n.push(parseInt(r[s],10)|255^parseInt(i[s],10)),s++;return new this(n)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.isIPv6=function(t){return null!==this.parser(t)},d.IPv6.isValid=function(t){if(\"string\"==typeof t&&-1===t.indexOf(\":\"))return!1;try{const e=this.parser(t);return new this(e.parts,e.zoneId),!0}catch(t){return!1}},d.IPv6.isValidCIDR=function(t){if(\"string\"==typeof t&&-1===t.indexOf(\":\"))return!1;try{return this.parseCIDR(t),!0}catch(t){return!1}},d.IPv6.networkAddressFromCIDR=function(t){let e,r,i,n,s;try{for(e=this.parseCIDR(t),i=e[0].toByteArray(),s=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),n=[],r=0;r<16;)n.push(parseInt(i[r],10)&parseInt(s[r],10)),r++;return new this(n)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.parse=function(t){const e=this.parser(t);if(null===e.parts)throw new Error(\"ipaddr: string is not formatted like an IPv6 Address\");return new this(e.parts,e.zoneId)},d.IPv6.parseCIDR=function(t){let e,r,i;if((r=t.match(/^(.+)\\/(\\d+)$/))&&(e=parseInt(r[2]),e>=0&&e<=128))return i=[this.parse(r[1]),e],Object.defineProperty(i,\"toString\",{value:function(){return this.join(\"/\")}}),i;throw new Error(\"ipaddr: string is not formatted like an IPv6 CIDR range\")},d.IPv6.parser=function(t){let e,r,i,n,s,o;if(i=t.match(h.deprecatedTransitional))return this.parser(`::ffff:${i[1]}`);if(h.native.test(t))return u(t,8);if((i=t.match(h.transitional))&&(o=i[6]||\"\",e=i[1],i[1].endsWith(\"::\")||(e=e.slice(0,-1)),e=u(e+o,6),e.parts)){for(s=[parseInt(i[2]),parseInt(i[3]),parseInt(i[4]),parseInt(i[5])],r=0;r<s.length;r++)if(n=s[r],!(0<=n&&n<=255))return null;return e.parts.push(s[0]<<8|s[1]),e.parts.push(s[2]<<8|s[3]),{parts:e.parts,zoneId:e.zoneId}}return null},d.IPv6.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>128)throw new Error(\"ipaddr: invalid IPv6 prefix length\");const e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const i=Math.floor(t/8);for(;r<i;)e[r]=255,r++;return i<16&&(e[i]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.fromByteArray=function(t){const e=t.length;if(4===e)return new d.IPv4(t);if(16===e)return new d.IPv6(t);throw new Error(\"ipaddr: the binary input is neither an IPv6 nor IPv4 address\")},d.isValid=function(t){return d.IPv6.isValid(t)||d.IPv4.isValid(t)},d.isValidCIDR=function(t){return d.IPv6.isValidCIDR(t)||d.IPv4.isValidCIDR(t)},d.parse=function(t){if(d.IPv6.isValid(t))return d.IPv6.parse(t);if(d.IPv4.isValid(t))return d.IPv4.parse(t);throw new Error(\"ipaddr: the address has neither IPv6 nor IPv4 format\")},d.parseCIDR=function(t){try{return d.IPv6.parseCIDR(t)}catch(e){try{return d.IPv4.parseCIDR(t)}catch(t){throw new Error(\"ipaddr: the address has neither IPv6 nor IPv4 CIDR format\")}}},d.process=function(t){const e=this.parse(t);return\"ipv6\"===e.kind()&&e.isIPv4MappedAddress()?e.toIPv4Address():e},d.subnetMatch=function(t,e,r){let i,n,s,o;for(n in null==r&&(r=\"unicast\"),e)if(Object.prototype.hasOwnProperty.call(e,n))for(s=e[n],!s[0]||s[0]instanceof Array||(s=[s]),i=0;i<s.length;i++)if(o=s[i],t.kind()===o[0].kind()&&t.match.apply(t,o))return n;return r},t.exports?t.exports=d:e.ipaddr=d}(this)},650:(t,e,r)=>{var i=r(462),n=r(2861).Buffer,s=r(6168);function o(t,e,r,o){s.call(this),this._cipher=new i.AES(e),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=o,this._mode=t}r(6698)(o,s),o.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},o.prototype._final=function(){this._cipher.scrub()},t.exports=o},655:t=>{var e=Object.defineProperty||!1;if(e)try{e({},\"a\",{value:1})}catch(t){e=!1}t.exports=e},672:(t,e,r)=>{var i=r(4116).Buffer,n=r(537);function s(t,e,r){t.copy(e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError(\"Cannot call a class as a function\")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return i.alloc(0);for(var e=i.allocUnsafe(t>>>0),r=this.head,n=0;r;)s(r.data,e,n),n+=r.data.length,r=r.next;return e},t}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+\" \"+t})},681:(t,e,r)=>{var i={__proto__:null,md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,\"sha512-256\":32,rmd160:20,ripemd160:20},n={__proto__:null,\"sha-1\":\"sha1\",\"sha-224\":\"sha224\",\"sha-256\":\"sha256\",\"sha-384\":\"sha384\",\"sha-512\":\"sha512\",\"ripemd-160\":\"ripemd160\"},s=r(3507),o=r(2861).Buffer,a=r(4196),h=r(2455),u=r(3382);t.exports=function(t,e,r,f,l){a(r,f),t=u(t,h,\"Password\"),e=u(e,h,\"Salt\");var c=(l||\"sha1\").toLowerCase(),d=n[c]||c,p=i[d];if(\"number\"!=typeof p||!p)throw new TypeError(\"Digest algorithm not supported: \"+l);var m=o.allocUnsafe(f),g=o.allocUnsafe(e.length+4);e.copy(g,0,0,e.length);for(var y=0,b=p,v=Math.ceil(f/b),w=1;w<=v;w++){g.writeUInt32BE(w,e.length);for(var _=s(d,t).update(g).digest(),M=_,S=1;S<r;S++){M=s(d,t).update(M).digest();for(var k=0;k<b;k++)_[k]^=M[k]}_.copy(m,y),y+=b}return m}},717:(t,e,r)=>{r.r(e),r.d(e,{addListener:()=>c,argv:()=>a,binding:()=>k,browser:()=>s,chdir:()=>E,cwd:()=>M,emit:()=>y,env:()=>o,listeners:()=>_,nextTick:()=>w,off:()=>p,on:()=>l,once:()=>d,prependListener:()=>b,prependOnceListener:()=>v,removeAllListeners:()=>g,removeListener:()=>m,title:()=>n,umask:()=>S,version:()=>h,versions:()=>u});var i=r(9596);const n=\"browser\",s=!0,o={},a=[],h=\"\",u={};function f(){}const l=f,c=f,d=f,p=f,m=f,g=f,y=f,b=f,v=f,w=(t,...e)=>i(()=>t(...e)),_=t=>[],M=()=>\"/\",S=()=>0,k=t=>{throw new Error(\"process.binding is not supported\")},E=t=>{throw new Error(\"process.chdir is not supported\")}},735:(t,e,r)=>{var i=r(6698),n=r(82);function s(t){n.call(this,t),this.enc=\"pem\"}i(s,n),t.exports=s,s.prototype.encode=function(t,e){for(var r=n.prototype.encode.call(this,t).toString(\"base64\"),i=[\"-----BEGIN \"+e.label+\"-----\"],s=0;s<r.length;s+=64)i.push(r.slice(s,s+64));return i.push(\"-----END \"+e.label+\"-----\"),i.join(\"\\n\")}},736:(t,e,r)=>{t.exports=function(t){function e(t){let r,n,s,o=null;function a(...t){if(!a.enabled)return;const i=a,n=Number(new Date),s=n-(r||n);i.diff=s,i.prev=r,i.curr=n,r=n,t[0]=e.coerce(t[0]),\"string\"!=typeof t[0]&&t.unshift(\"%O\");let o=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(r,n)=>{if(\"%%\"===r)return\"%\";o++;const s=e.formatters[n];if(\"function\"==typeof s){const e=t[o];r=s.call(i,e),t.splice(o,1),o--}return r}),e.formatArgs.call(i,t);(i.log||e.log).apply(i,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=i,a.destroy=e.destroy,Object.defineProperty(a,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==e.namespaces&&(n=e.namespaces,s=e.enabled(t)),s),set:t=>{o=t}}),\"function\"==typeof e.init&&e.init(a),a}function i(t,r){const i=e(this.namespace+(void 0===r?\":\":r)+t);return i.log=this.log,i}function n(t,e){let r=0,i=0,n=-1,s=0;for(;r<t.length;)if(i<e.length&&(e[i]===t[r]||\"*\"===e[i]))\"*\"===e[i]?(n=i,s=r,i++):(r++,i++);else{if(-1===n)return!1;i=n+1,s++,r=s}for(;i<e.length&&\"*\"===e[i];)i++;return i===e.length}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names,...e.skips.map(t=>\"-\"+t)].join(\",\");return e.enable(\"\"),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];const r=(\"string\"==typeof t?t:\"\").trim().replace(/\\s+/g,\",\").split(\",\").filter(Boolean);for(const t of r)\"-\"===t[0]?e.skips.push(t.slice(1)):e.names.push(t)},e.enabled=function(t){for(const r of e.skips)if(n(t,r))return!1;for(const r of e.names)if(n(t,r))return!0;return!1},e.humanize=r(6585),e.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(t).forEach(r=>{e[r]=t[r]}),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return e.colors[Math.abs(r)%e.colors.length]},e.enable(e.load()),e}},815:(t,e,r)=>{var i,n=r(717),s=r(3519),o=r(6611);try{i=r(2376)}catch(t){}var a=function(){},h=void 0!==n&&/^v?\\.0/.test(n.version),u=function(t){return\"function\"==typeof t},f=function(t,e,r,n){n=s(n);var f=!1;t.on(\"close\",function(){f=!0}),o(t,{readable:e,writable:r},function(t){if(t)return n(t);f=!0,n()});var l=!1;return function(e){if(!f&&!l)return l=!0,function(t){return!!h&&!!i&&(t instanceof(i.ReadStream||a)||t instanceof(i.WriteStream||a))&&u(t.close)}(t)?t.close(a):function(t){return t.setHeader&&u(t.abort)}(t)?t.abort():u(t.destroy)?t.destroy():void n(e||new Error(\"stream was destroyed\"))}},l=function(t){t()},c=function(t,e){return t.pipe(e)};t.exports=function(){var t,e=Array.prototype.slice.call(arguments),r=u(e[e.length-1]||a)&&e.pop()||a;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error(\"pump requires two streams per minimum\");var i=e.map(function(n,s){var o=s<e.length-1;return f(n,o,s>0,function(e){t||(t=e),e&&i.forEach(l),o||(i.forEach(l),r(t))})});return e.reduce(c)}},894:(t,e,r)=>{var i=e;i.base=r(6677),i.short=r(9188),i.mont=r(370),i.edwards=r(1298)},920:(t,e,r)=>{var i=r(9675),n=r(8859),s=r(4803),o=r(507),a=r(2271)||o||s;t.exports=function(){var t,e={assert:function(t){if(!e.has(t))throw new i(\"Side channel does not contain \"+n(t))},delete:function(e){return!!t&&t.delete(e)},get:function(e){return t&&t.get(e)},has:function(e){return!!t&&t.has(e)},set:function(e,r){t||(t=a()),t.set(e,r)}};return e}},943:t=>{const e=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",r=new Uint8Array(256);for(let t=0;t<64;t++)r[e.charCodeAt(t)]=t;r[45]=62,r[95]=63,t.exports={byteLength:function(t){let e=t.length;return 61===t.charCodeAt(e-1)&&e--,e>1&&61===t.charCodeAt(e-1)&&e--,3*e>>>2},toString:function(t){const r=t.byteLength;let i=\"\";for(let n=0;n<r;n+=3)i+=e[t[n]>>2]+e[(3&t[n])<<4|t[n+1]>>4]+e[(15&t[n+1])<<2|t[n+2]>>6]+e[63&t[n+2]];return r%3==2?i=i.substring(0,i.length-1)+\"=\":r%3==1&&(i=i.substring(0,i.length-2)+\"==\"),i},write:function(t,e){const i=t.byteLength;for(let n=0,s=0;s<i;n+=4){const i=r[e.charCodeAt(n)],o=r[e.charCodeAt(n+1)],a=r[e.charCodeAt(n+2)],h=r[e.charCodeAt(n+3)];t[s++]=i<<2|o>>4,t[s++]=(15&o)<<4|a>>2,t[s++]=(3&a)<<6|63&h}return i}}},975:t=>{var e=function(){function t(t,e,r){this.name=t,this.max=e,this.constructor=null!=r?r:function(){},this.list=[]}return t.prototype.alloc=function(){return this.list.length?this.list.shift():this.constructor.apply(this,arguments)},t.prototype.free=function(t){return this.list.length<this.max&&(this.list.push(t),!0)},t}();e.FreeList=e,t.exports=e},988:(t,e,r)=>{r.d(e,{A:()=>p});var i=r(9639);function n(t){const e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function s(t){return ArrayBuffer.isView(t)?\"arraybufferview\":Array.isArray(t)?\"array\":t instanceof Number?\"number\":t instanceof Boolean?\"boolean\":t instanceof Set?\"set\":t instanceof Map?\"map\":t instanceof String?\"string\":t instanceof ArrayBuffer?\"arraybuffer\":typeof t}function o(t,e,r){const n=[];let s=null;return o._encode(n,t),s=(0,i.xW)(n),o.bytes=s.length,ArrayBuffer.isView(e)?(e.set(s,r),e):s}o.bytes=-1,o._floatConversionDetected=!1,o._encode=function(t,e){if(null!=e)switch(s(e)){case\"object\":o.dict(t,e);break;case\"map\":o.dictMap(t,e);break;case\"array\":o.list(t,e);break;case\"set\":o.listSet(t,e);break;case\"string\":o.string(t,e);break;case\"number\":case\"boolean\":o.number(t,e);break;case\"arraybufferview\":o.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case\"arraybuffer\":o.buffer(t,new Uint8Array(e))}};const a=new Uint8Array([101]),h=new Uint8Array([100]),u=new Uint8Array([108]);o.buffer=function(t,e){t.push((0,i.L0)(e.length+\":\"),e)},o.string=function(t,e){t.push((0,i.L0)((0,i.L0)(e).byteLength+\":\"+e))},o.number=function(t,e){if(Number.isInteger(e))return t.push((0,i.L0)(\"i\"+BigInt(e)+\"e\"));const r=2147483648,n=(e/r|0)*r+(e%r|0);t.push((0,i.L0)(\"i\"+n+\"e\")),n===e||o._floatConversionDetected||(o._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value \"'+e+'\":','Bencoding only defines support for integers, value was converted to \"'+n+'\"'),console.trace())},o.dict=function(t,e){t.push(h);let r,i=0;const n=Object.keys(e).sort(),s=n.length;for(;i<s;i++)r=n[i],null!=e[r]&&(o.string(t,r),o._encode(t,e[r]));t.push(a)},o.dictMap=function(t,e){t.push(h);const r=Array.from(e.keys()).sort();for(const i of r)null!=e.get(i)&&(ArrayBuffer.isView(i)?o._encode(t,i):o.string(t,String(i)),o._encode(t,e.get(i)));t.push(a)},o.list=function(t,e){let r=0;const i=e.length;for(t.push(u);r<i;r++)null!=e[r]&&o._encode(t,e[r]);t.push(a)},o.listSet=function(t,e){t.push(u);for(const r of e)null!=r&&o._encode(t,r);t.push(a)};const f=o;function l(t,e,r){let i=0,n=1;for(let s=e;s<r;s++){const r=t[s];if(r<58&&r>=48)i=10*i+(r-48);else if(s!==e||43!==r){if(s!==e||45!==r){if(46===r)break;throw new Error(\"not a number: buffer[\"+s+\"] = \"+r)}n=-1}}return i*n}function c(t,e,r,n){return null==t||0===t.length?null:(\"number\"!=typeof e&&null==n&&(n=e,e=void 0),\"number\"!=typeof r&&null==n&&(n=r,r=void 0),c.position=0,c.encoding=n||null,c.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):(0,i.L0)(t),c.bytes=c.data.length,c.next())}c.bytes=0,c.position=0,c.data=null,c.encoding=null,c.next=function(){switch(c.data[c.position]){case 100:return c.dictionary();case 108:return c.list();case 105:return c.integer();default:return c.buffer()}},c.find=function(t){let e=c.position;const r=c.data.length,i=c.data;for(;e<r;){if(i[e]===t)return e;e++}throw new Error('Invalid data: Missing delimiter \"'+String.fromCharCode(t)+'\" [0x'+t.toString(16)+\"]\")},c.dictionary=function(){c.position++;const t={};for(;101!==c.data[c.position];){const e=c.buffer();let r=(0,i.dU)(e);r.includes(\"�\")&&(r=(0,i.V5)(e)),t[r]=c.next()}return c.position++,t},c.list=function(){c.position++;const t=[];for(;101!==c.data[c.position];)t.push(c.next());return c.position++,t},c.integer=function(){const t=c.find(101),e=l(c.data,c.position+1,t);return c.position+=t+1-c.position,e},c.buffer=function(){let t=c.find(58);const e=l(c.data,c.position,t),r=++t+e;return c.position=r,c.encoding?(0,i.dU)(c.data.slice(t,r)):c.data.slice(t,r)};function d(t){if(null==t)return 0;const e=s(t);switch(e){case\"arraybufferview\":return function(t){const e=t.byteLength-t.byteOffset;return n(e)+1+e}(t);case\"string\":return function(t){const e=(0,i.L0)(t).byteLength;return n(e)+1+e}(t);case\"array\":case\"set\":return function(t){let e=2;for(const r of t)e+=d(r);return e}(t);case\"number\":return 1+n(Math.floor(t))+1;case\"bigint\":return 1+t.toString().length+1;case\"object\":return function(t){let e=2;const r=Object.keys(t);for(let s=0;s<r.length;s++){const o=(0,i.L0)(r[s]).byteLength;e+=n(o)+1+o,e+=d(t[r[s]])}return e}(t);case\"map\":return function(t){let e=2;for(const[r,s]of t){const t=(0,i.L0)(r).byteLength;e+=n(t)+1+t,e+=d(s)}return e}(t);default:throw new TypeError(`Unsupported value of type \"${e}\"`)}}const p={encode:f,decode:c,byteLength:d,encodingLength:d}},993:(t,e,r)=>{var i=r(9673).Reporter,n=r(9673).EncoderBuffer,s=r(9673).DecoderBuffer,o=r(3349),a=[\"seq\",\"seqof\",\"set\",\"setof\",\"objid\",\"bool\",\"gentime\",\"utctime\",\"null_\",\"enum\",\"int\",\"objDesc\",\"bitstr\",\"bmpstr\",\"charstr\",\"genstr\",\"graphstr\",\"ia5str\",\"iso646str\",\"numstr\",\"octstr\",\"printstr\",\"t61str\",\"unistr\",\"utf8str\",\"videostr\"],h=[\"key\",\"obj\",\"use\",\"optional\",\"explicit\",\"implicit\",\"def\",\"choice\",\"any\",\"contains\"].concat(a);function u(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=u;var f=[\"enc\",\"parent\",\"children\",\"tag\",\"args\",\"reverseArgs\",\"choice\",\"optional\",\"any\",\"obj\",\"use\",\"alteredUse\",\"key\",\"default\",\"explicit\",\"implicit\",\"contains\"];u.prototype.clone=function(){var t=this._baseState,e={};f.forEach(function(r){e[r]=t[r]});var r=new this.constructor(e.parent);return r._baseState=e,r},u.prototype._wrap=function(){var t=this._baseState;h.forEach(function(e){this[e]=function(){var r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments)}},this)},u.prototype._init=function(t){var e=this._baseState;o(null===e.parent),t.call(this),e.children=e.children.filter(function(t){return t._baseState.parent===this},this),o.equal(e.children.length,1,\"Root node can have only one child\")},u.prototype._useArgs=function(t){var e=this._baseState,r=t.filter(function(t){return t instanceof this.constructor},this);t=t.filter(function(t){return!(t instanceof this.constructor)},this),0!==r.length&&(o(null===e.children),e.children=r,r.forEach(function(t){t._baseState.parent=this},this)),0!==t.length&&(o(null===e.args),e.args=t,e.reverseArgs=t.map(function(t){if(\"object\"!=typeof t||t.constructor!==Object)return t;var e={};return Object.keys(t).forEach(function(r){r==(0|r)&&(r|=0);var i=t[r];e[i]=r}),e}))},[\"_peekTag\",\"_decodeTag\",\"_use\",\"_decodeStr\",\"_decodeObjid\",\"_decodeTime\",\"_decodeNull\",\"_decodeInt\",\"_decodeBool\",\"_decodeList\",\"_encodeComposite\",\"_encodeStr\",\"_encodeObjid\",\"_encodeTime\",\"_encodeNull\",\"_encodeInt\",\"_encodeBool\"].forEach(function(t){u.prototype[t]=function(){var e=this._baseState;throw new Error(t+\" not implemented for encoding: \"+e.enc)}}),a.forEach(function(t){u.prototype[t]=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return o(null===e.tag),e.tag=t,this._useArgs(r),this}}),u.prototype.use=function(t){o(t);var e=this._baseState;return o(null===e.use),e.use=t,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(t){var e=this._baseState;return o(null===e.default),e.default=t,e.optional=!0,this},u.prototype.explicit=function(t){var e=this._baseState;return o(null===e.explicit&&null===e.implicit),e.explicit=t,this},u.prototype.implicit=function(t){var e=this._baseState;return o(null===e.explicit&&null===e.implicit),e.implicit=t,this},u.prototype.obj=function(){var t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},u.prototype.key=function(t){var e=this._baseState;return o(null===e.key),e.key=t,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(t){var e=this._baseState;return o(null===e.choice),e.choice=t,this._useArgs(Object.keys(t).map(function(e){return t[e]})),this},u.prototype.contains=function(t){var e=this._baseState;return o(null===e.use),e.contains=t,this},u.prototype._decode=function(t,e){var r=this._baseState;if(null===r.parent)return t.wrapResult(r.children[0]._decode(t,e));var i,n=r.default,o=!0,a=null;if(null!==r.key&&(a=t.enterKey(r.key)),r.optional){var h=null;if(null!==r.explicit?h=r.explicit:null!==r.implicit?h=r.implicit:null!==r.tag&&(h=r.tag),null!==h||r.any){if(o=this._peekTag(t,h,r.any),t.isError(o))return o}else{var u=t.save();try{null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),o=!0}catch(t){o=!1}t.restore(u)}}if(r.obj&&o&&(i=t.enterObject()),o){if(null!==r.explicit){var f=this._decodeTag(t,r.explicit);if(t.isError(f))return f;t=f}var l=t.offset;if(null===r.use&&null===r.choice){if(r.any)u=t.save();var c=this._decodeTag(t,null!==r.implicit?r.implicit:r.tag,r.any);if(t.isError(c))return c;r.any?n=t.raw(u):t=c}if(e&&e.track&&null!==r.tag&&e.track(t.path(),l,t.length,\"tagged\"),e&&e.track&&null!==r.tag&&e.track(t.path(),t.offset,t.length,\"content\"),r.any||(n=null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e)),t.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(t,e)}),r.contains&&(\"octstr\"===r.tag||\"bitstr\"===r.tag)){var d=new s(n);n=this._getUse(r.contains,t._reporterState.obj)._decode(d,e)}}return r.obj&&o&&(n=t.leaveObject(i)),null===r.key||null===n&&!0!==o?null!==a&&t.exitKey(a):t.leaveKey(a,r.key,n),n},u.prototype._decodeGeneric=function(t,e,r){var i=this._baseState;return\"seq\"===t||\"set\"===t?null:\"seqof\"===t||\"setof\"===t?this._decodeList(e,t,i.args[0],r):/str$/.test(t)?this._decodeStr(e,t,r):\"objid\"===t&&i.args?this._decodeObjid(e,i.args[0],i.args[1],r):\"objid\"===t?this._decodeObjid(e,null,null,r):\"gentime\"===t||\"utctime\"===t?this._decodeTime(e,t,r):\"null_\"===t?this._decodeNull(e,r):\"bool\"===t?this._decodeBool(e,r):\"objDesc\"===t?this._decodeStr(e,t,r):\"int\"===t||\"enum\"===t?this._decodeInt(e,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,e._reporterState.obj)._decode(e,r):e.error(\"unknown tag: \"+t)},u.prototype._getUse=function(t,e){var r=this._baseState;return r.useDecoder=this._use(t,e),o(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},u.prototype._decodeChoice=function(t,e){var r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some(function(s){var o=t.save(),a=r.choice[s];try{var h=a._decode(t,e);if(t.isError(h))return!1;i={type:s,value:h},n=!0}catch(e){return t.restore(o),!1}return!0},this),n?i:t.error(\"Choice not matched\")},u.prototype._createEncoderBuffer=function(t){return new n(t,this.reporter)},u.prototype._encode=function(t,e,r){var i=this._baseState;if(null===i.default||i.default!==t){var n=this._encodeValue(t,e,r);if(void 0!==n&&!this._skipDefault(n,e,r))return n}},u.prototype._encodeValue=function(t,e,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(t,e||new i);var s=null;if(this.reporter=e,n.optional&&void 0===t){if(null===n.default)return;t=n.default}var o=null,a=!1;if(n.any)s=this._createEncoderBuffer(t);else if(n.choice)s=this._encodeChoice(t,e);else if(n.contains)o=this._getUse(n.contains,r)._encode(t,e),a=!0;else if(n.children)o=n.children.map(function(r){if(\"null_\"===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error(\"Child should have a key\");var i=e.enterKey(r._baseState.key);if(\"object\"!=typeof t)return e.error(\"Child expected, but input is not object\");var n=r._encode(t[r._baseState.key],e,t);return e.leaveKey(i),n},this).filter(function(t){return t}),o=this._createEncoderBuffer(o);else if(\"seqof\"===n.tag||\"setof\"===n.tag){if(!n.args||1!==n.args.length)return e.error(\"Too many args for : \"+n.tag);if(!Array.isArray(t))return e.error(\"seqof/setof, but data is not Array\");var h=this.clone();h._baseState.implicit=null,o=this._createEncoderBuffer(t.map(function(r){var i=this._baseState;return this._getUse(i.args[0],t)._encode(r,e)},h))}else null!==n.use?s=this._getUse(n.use,r)._encode(t,e):(o=this._encodePrimitive(n.tag,t),a=!0);if(!n.any&&null===n.choice){var u=null!==n.implicit?n.implicit:n.tag,f=null===n.implicit?\"universal\":\"context\";null===u?null===n.use&&e.error(\"Tag could be omitted only for .use()\"):null===n.use&&(s=this._encodeComposite(u,a,f,o))}return null!==n.explicit&&(s=this._encodeComposite(n.explicit,!1,\"context\",s)),s},u.prototype._encodeChoice=function(t,e){var r=this._baseState,i=r.choice[t.type];return i||o(!1,t.type+\" not found in \"+JSON.stringify(Object.keys(r.choice))),i._encode(t.value,e)},u.prototype._encodePrimitive=function(t,e){var r=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if(\"objid\"===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if(\"objid\"===t)return this._encodeObjid(e,null,null);if(\"gentime\"===t||\"utctime\"===t)return this._encodeTime(e,t);if(\"null_\"===t)return this._encodeNull();if(\"int\"===t||\"enum\"===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if(\"bool\"===t)return this._encodeBool(e);if(\"objDesc\"===t)return this._encodeStr(e,t);throw new Error(\"Unsupported tag: \"+t)},u.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},u.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '\\(\\)\\+,\\-\\.\\/:=\\?]*$/.test(t)}},1002:t=>{t.exports=Function.prototype.apply},1035:(t,e,r)=>{var i=r(717);const n=void 0!==i&&!!i.hrtime,s=65535,o=n?1e8:100,a=n?()=>{const[t,e]=i.hrtime();return 1e9*t+e}:()=>performance.now();function h(t){return(a()-t)/o&s}t.exports=function(t){const e=a(),r=10*(t||5),i=[0];let n=1,o=h(e)-1&s;return function(t){const a=h(e);let u=a-o&s;for(u>r&&(u=r),o=a;u--;)n===r&&(n=0),i[n]=i[0===n?r-1:n-1],n++;t&&(i[n-1]+=t);const f=i[n-1],l=i.length<r?0:i[n===r?0:n];return i.length<10?f:10*(f-l)/i.length}}},1064:(t,e,r)=>{var i=r(9612);t.exports=i.getPrototypeOf||null},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),i=\"[object Arguments]\"===r;return i||(i=\"[object Array]\"!==r&&null!==t&&\"object\"==typeof t&&\"number\"==typeof t.length&&t.length>=0&&\"[object Function]\"===e.call(t.callee)),i}},1133:(t,e,r)=>{let i=r(8673);t.exports=new i(r(8446))},1137:(t,e,r)=>{var i=r(7568);e.certificate=r(6413);var n=i.define(\"RSAPrivateKey\",function(){this.seq().obj(this.key(\"version\").int(),this.key(\"modulus\").int(),this.key(\"publicExponent\").int(),this.key(\"privateExponent\").int(),this.key(\"prime1\").int(),this.key(\"prime2\").int(),this.key(\"exponent1\").int(),this.key(\"exponent2\").int(),this.key(\"coefficient\").int())});e.RSAPrivateKey=n;var s=i.define(\"RSAPublicKey\",function(){this.seq().obj(this.key(\"modulus\").int(),this.key(\"publicExponent\").int())});e.RSAPublicKey=s;var o=i.define(\"AlgorithmIdentifier\",function(){this.seq().obj(this.key(\"algorithm\").objid(),this.key(\"none\").null_().optional(),this.key(\"curve\").objid().optional(),this.key(\"params\").seq().obj(this.key(\"p\").int(),this.key(\"q\").int(),this.key(\"g\").int()).optional())}),a=i.define(\"SubjectPublicKeyInfo\",function(){this.seq().obj(this.key(\"algorithm\").use(o),this.key(\"subjectPublicKey\").bitstr())});e.PublicKey=a;var h=i.define(\"PrivateKeyInfo\",function(){this.seq().obj(this.key(\"version\").int(),this.key(\"algorithm\").use(o),this.key(\"subjectPrivateKey\").octstr())});e.PrivateKey=h;var u=i.define(\"EncryptedPrivateKeyInfo\",function(){this.seq().obj(this.key(\"algorithm\").seq().obj(this.key(\"id\").objid(),this.key(\"decrypt\").seq().obj(this.key(\"kde\").seq().obj(this.key(\"id\").objid(),this.key(\"kdeparams\").seq().obj(this.key(\"salt\").octstr(),this.key(\"iters\").int())),this.key(\"cipher\").seq().obj(this.key(\"algo\").objid(),this.key(\"iv\").octstr()))),this.key(\"subjectPrivateKey\").octstr())});e.EncryptedPrivateKey=u;var f=i.define(\"DSAPrivateKey\",function(){this.seq().obj(this.key(\"version\").int(),this.key(\"p\").int(),this.key(\"q\").int(),this.key(\"g\").int(),this.key(\"pub_key\").int(),this.key(\"priv_key\").int())});e.DSAPrivateKey=f,e.DSAparam=i.define(\"DSAparam\",function(){this.int()});var l=i.define(\"ECParameters\",function(){this.choice({namedCurve:this.objid()})}),c=i.define(\"ECPrivateKey\",function(){this.seq().obj(this.key(\"version\").int(),this.key(\"privateKey\").octstr(),this.key(\"parameters\").optional().explicit(0).use(l),this.key(\"publicKey\").optional().explicit(1).bitstr())});e.ECPrivateKey=c,e.signature=i.define(\"signature\",function(){this.seq().obj(this.key(\"r\").int(),this.key(\"s\").int())})},1147:(t,e,r)=>{var i=r(2861).Buffer,n=r(8537),s=r(3828).Transform;function o(t){s.call(this),this._block=i.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,s),o.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(t){i=t}r(i)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(this._finalized)throw new Error(\"Digest already called\");for(var r=n(t,e),i=this._block,s=0;this._blockOffset+r.length-s>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)i[o]=r[s],o+=1,s+=1;this._update(),this._blockOffset=0}for(;s<r.length;)i[this._blockOffset]=r[s],this._blockOffset+=1,s+=1;for(var a=0,h=8*r.length;h>0;++a)this._length[a]+=h,(h=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*h);return this},o.prototype._update=function(){throw new Error(\"_update is not implemented\")},o.prototype.digest=function(t){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},t.exports=o},1158:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"};var f=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],d=c[t];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:f[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\"),this.strip();var o,a,h=\"le\"===e,u=new t(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a<s;a++)u[a]=0}else{for(a=0;a<s-n;a++)u[a]=0;for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[s-a-1]=o}return u},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},g.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),m(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i(\"number\"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a.strip(),i.strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new S(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function w(){b.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function _(){b.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function M(){b.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function k(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,b),n(_,b),n(M,b),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if(\"k256\"===t)e=new v;else if(\"p224\"===t)e=new w;else if(\"p192\"===t)e=new _;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new M}return y[t]=e,e},S.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},S.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new k(t)},n(k,S),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},1189:(t,e,r)=>{var i=Array.prototype.slice,n=r(1093),s=Object.keys,o=s?function(t){return s(t)}:r(8875),a=Object.keys;o.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return n(t)?a(i.call(t)):a(t)})}else Object.keys=o;return Object.keys||o},t.exports=o},1200:(t,e,r)=>{var i=r(8490),n=r(7011).assert;function s(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}t.exports=s,s.fromPublic=function(t,e,r){return e instanceof s?e:new s(t,{pub:e,pubEnc:r})},s.fromPrivate=function(t,e,r){return e instanceof s?e:new s(t,{priv:e,privEnc:r})},s.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:\"Invalid public key\"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:\"Public key * N != O\"}:{result:!1,reason:\"Public key is not a point\"}},s.prototype.getPublic=function(t,e){return\"string\"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},s.prototype.getPrivate=function(t){return\"hex\"===t?this.priv.toString(16,2):this.priv},s.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},s.prototype._importPublic=function(t,e){if(t.x||t.y)return\"mont\"===this.ec.curve.type?n(t.x,\"Need x coordinate\"):\"short\"!==this.ec.curve.type&&\"edwards\"!==this.ec.curve.type||n(t.x&&t.y,\"Need both x and y coordinate\"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},s.prototype.derive=function(t){return t.validate()||n(t.validate(),\"public point not validated\"),t.mul(this.priv).getX()},s.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},s.prototype.verify=function(t,e,r){return this.ec.verify(t,e,this,void 0,r)},s.prototype.inspect=function(){return\"<Key priv: \"+(this.priv&&this.priv.toString(16,2))+\" pub: \"+(this.pub&&this.pub.inspect())+\" >\"}},1237:t=>{t.exports=EvalError},1241:(t,e,r)=>{var i=r(5799),n=r(6171),s=r(3219);e.createCipher=e.Cipher=i.createCipher,e.createCipheriv=e.Cipheriv=i.createCipheriv,e.createDecipher=e.Decipher=n.createDecipher,e.createDecipheriv=e.Decipheriv=n.createDecipheriv,e.listCiphers=e.getCiphers=function(){return Object.keys(s)}},1298:(t,e,r)=>{var i=r(7011),n=r(8490),s=r(6698),o=r(6677),a=i.assert;function h(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,o.call(this,\"edwards\",t),this.a=new n(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new n(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new n(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function u(t,e,r,i,s){o.BasePoint.call(this,t,\"projective\"),null===e&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new n(e,16),this.y=new n(r,16),this.z=i?new n(i,16):this.curve.one,this.t=s&&new n(s,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(h,o),t.exports=h,h.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},h.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},h.prototype.jpoint=function(t,e,r,i){return this.point(t,e,r,i)},h.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=i.redMul(s.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error(\"invalid point\");var h=a.fromRed().isOdd();return(e&&!h||!e&&h)&&(a=a.redNeg()),this.point(t,a)},h.prototype.pointFromY=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=i.redMul(s.redInvm());if(0===o.cmp(this.zero)){if(e)throw new Error(\"invalid point\");return this.point(this.zero,t)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error(\"invalid point\");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},h.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),i=e.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===i.cmp(n)},s(u,o.BasePoint),h.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},h.prototype.point=function(t,e,r,i){return new u(this,t,e,r,i)},u.fromJSON=function(t,e){return new u(t,e[0],e[1],e[2])},u.prototype.inspect=function(){return this.isInfinity()?\"<EC Point Infinity>\":\"<EC Point x: \"+this.x.fromRed().toString(16,2)+\" y: \"+this.y.fromRed().toString(16,2)+\" z: \"+this.z.fromRed().toString(16,2)+\">\"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=i.redAdd(e),o=s.redSub(r),a=i.redSub(e),h=n.redMul(o),u=s.redMul(a),f=n.redMul(a),l=o.redMul(s);return this.curve.point(h,u,l,f)},u.prototype._projDbl=function(){var t,e,r,i,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var u=(i=this.curve._mulA(a)).redAdd(h);this.zOne?(t=o.redSub(a).redSub(h).redMul(u.redSub(this.curve.two)),e=u.redMul(i.redSub(h)),r=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),s=u.redSub(n).redISub(n),t=o.redSub(a).redISub(h).redMul(s),e=u.redMul(i.redSub(h)),r=u.redMul(s))}else i=a.redAdd(h),n=this.curve._mulC(this.z).redSqr(),s=i.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(i)).redMul(s),e=this.curve._mulC(i).redMul(a.redISub(h)),r=i.redMul(s);return this.curve.point(t,e,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),o=n.redSub(i),a=n.redAdd(i),h=r.redAdd(e),u=s.redMul(o),f=a.redMul(h),l=s.redMul(h),c=o.redMul(a);return this.curve.point(u,f,c,l)},u.prototype._projAdd=function(t){var e,r,i=this.z.redMul(t.z),n=i.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),h=n.redSub(a),u=n.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),l=i.redMul(h).redMul(f);return this.curve.twisted?(e=i.redMul(u).redMul(o.redSub(this.curve._mulA(s))),r=h.redMul(u)):(e=i.redMul(u).redMul(o.redSub(s)),r=this.curve._mulC(h).redMul(u)),this.curve.point(l,e,r)},u.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},u.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},u.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},u.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(i),0===this.x.cmp(e))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},1314:t=>{t.exports=function(t,e){if(e>=t.length||e<0)return;var r=t.pop();if(e<t.length){var i=t[e];return t[e]=r,i}return r}},1324:(t,e,r)=>{var i=r(8287).Buffer,n=r(6729),s=r(2801);t.exports=function(t){return new a(t)};var o={secp256k1:{name:\"secp256k1\",byteLength:32},secp224r1:{name:\"p224\",byteLength:28},prime256v1:{name:\"p256\",byteLength:32},prime192v1:{name:\"p192\",byteLength:24},ed25519:{name:\"ed25519\",byteLength:32},secp384r1:{name:\"p384\",byteLength:48},secp521r1:{name:\"p521\",byteLength:66}};function a(t){this.curveType=o[t],this.curveType||(this.curveType={name:t}),this.curve=new n.ec(this.curveType.name),this.keys=void 0}function h(t,e,r){Array.isArray(t)||(t=t.toArray());var n=new i(t);if(r&&n.length<r){var s=new i(r-n.length);s.fill(0),n=i.concat([s,n])}return e?n.toString(e):n}o.p224=o.secp224r1,o.p256=o.secp256r1=o.prime256v1,o.p192=o.secp192r1=o.prime192v1,o.p384=o.secp384r1,o.p521=o.secp521r1,a.prototype.generateKeys=function(t,e){return this.keys=this.curve.genKeyPair(),this.getPublicKey(t,e)},a.prototype.computeSecret=function(t,e,r){return e=e||\"utf8\",i.isBuffer(t)||(t=new i(t,e)),h(this.curve.keyFromPublic(t).getPublic().mul(this.keys.getPrivate()).getX(),r,this.curveType.byteLength)},a.prototype.getPublicKey=function(t,e){var r=this.keys.getPublic(\"compressed\"===e,!0);return\"hybrid\"===e&&(r[r.length-1]%2?r[0]=7:r[0]=6),h(r,t)},a.prototype.getPrivateKey=function(t){return h(this.keys.getPrivate(),t)},a.prototype.setPublicKey=function(t,e){return e=e||\"utf8\",i.isBuffer(t)||(t=new i(t,e)),this.keys._importPublic(t),this},a.prototype.setPrivateKey=function(t,e){e=e||\"utf8\",i.isBuffer(t)||(t=new i(t,e));var r=new s(t);return r=r.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(r),this}},1333:t=>{t.exports=function(){if(\"function\"!=typeof Symbol||\"function\"!=typeof Object.getOwnPropertySymbols)return!1;if(\"symbol\"==typeof Symbol.iterator)return!0;var t={},e=Symbol(\"test\"),r=Object(e);if(\"string\"==typeof e)return!1;if(\"[object Symbol]\"!==Object.prototype.toString.call(e))return!1;if(\"[object Symbol]\"!==Object.prototype.toString.call(r))return!1;for(var i in t[e]=42,t)return!1;if(\"function\"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if(\"function\"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(\"function\"==typeof Object.getOwnPropertyDescriptor){var s=Object.getOwnPropertyDescriptor(t,e);if(42!==s.value||!0!==s.enumerable)return!1}return!0}},1416:(t,e,r)=>{t.exports=r(8310)},1467:t=>{function e(t,e){if(\"string\"==typeof t[0])return t.join(\"\");if(\"number\"==typeof t[0])return new Uint8Array(t);const r=new Uint8Array(e);let i=0;for(let e=0,n=t.length;e<n;e++){const n=t[e];r.set(n,i),i+=n.byteLength||n.length}return r}t.exports=async function*(t,r=512,i={}){\"object\"==typeof r&&(r=(i=r).size);let{nopad:n,zeroPadding:s=!0}=i;n&&(s=!1);let o=[],a=0;for await(const i of t)if(a+=i.byteLength||i.length||1,o.push(i),a>=r){const t=e(o,a);let i=0;for(;a>=r;)yield t.slice(i,i+r),a-=r,i+=r;o=[t.slice(i,t.length)]}a&&(yield e(o,s?r:a))}},1514:t=>{t.exports=Math.abs},1565:(t,e,r)=>{e.randomBytes=e.rng=e.pseudoRandomBytes=e.prng=r(3209),e.createHash=e.Hash=r(7108),e.createHmac=e.Hmac=r(3507);var i=r(5715),n=Object.keys(i),s=[\"sha1\",\"sha224\",\"sha256\",\"sha384\",\"sha512\",\"md5\",\"rmd160\"].concat(n);e.getHashes=function(){return s};var o=r(5488);e.pbkdf2=o.pbkdf2,e.pbkdf2Sync=o.pbkdf2Sync;var a=r(125);e.Cipher=a.Cipher,e.createCipher=a.createCipher,e.Cipheriv=a.Cipheriv,e.createCipheriv=a.createCipheriv,e.Decipher=a.Decipher,e.createDecipher=a.createDecipher,e.Decipheriv=a.Decipheriv,e.createDecipheriv=a.createDecipheriv,e.getCiphers=a.getCiphers,e.listCiphers=a.listCiphers;var h=r(5380);e.DiffieHellmanGroup=h.DiffieHellmanGroup,e.createDiffieHellmanGroup=h.createDiffieHellmanGroup,e.getDiffieHellman=h.getDiffieHellman,e.createDiffieHellman=h.createDiffieHellman,e.DiffieHellman=h.DiffieHellman;var u=r(20);e.createSign=u.createSign,e.Sign=u.Sign,e.createVerify=u.createVerify,e.Verify=u.Verify,e.createECDH=r(1324);var f=r(7168);e.publicEncrypt=f.publicEncrypt,e.privateEncrypt=f.privateEncrypt,e.publicDecrypt=f.publicDecrypt,e.privateDecrypt=f.privateDecrypt;var l=r(6983);e.randomFill=l.randomFill,e.randomFillSync=l.randomFillSync,e.createCredentials=function(){throw new Error(\"sorry, createCredentials is not implemented yet\\nwe accept pull requests\\nhttps://github.com/browserify/crypto-browserify\")},e.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},1591:t=>{t.exports=function(){throw new Error(\"ws does not work in the browser. Browser clients must use the native WebSocket object\")}},1630:t=>{function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,r,i,n){r=r||\"&\",i=i||\"=\";var s={};if(\"string\"!=typeof t||0===t.length)return s;var o=/\\+/g;t=t.split(r);var a=1e3;n&&\"number\"==typeof n.maxKeys&&(a=n.maxKeys);var h=t.length;a>0&&h>a&&(h=a);for(var u=0;u<h;++u){var f,l,c,d,p=t[u].replace(o,\"%20\"),m=p.indexOf(i);m>=0?(f=p.substr(0,m),l=p.substr(m+1)):(f=p,l=\"\"),c=decodeURIComponent(f),d=decodeURIComponent(l),e(s,c)?Array.isArray(s[c])?s[c].push(d):s[c]=[s[c],d]:s[c]=d}return s}},1636:t=>{t.exports={rE:\"6.6.1\"}},1672:(t,e,r)=>{var i=r(717);t.exports=function(t,e){var r=0,n=[],s=!0;function o(t){function r(){e&&e(t,n)}s?i.nextTick(r):r()}t.length>0?t[0](function e(i,s){n.push(s),++r>=t.length||i?o(i):t[r](e)}):o(null);s=!1}},1678:(t,e,r)=>{const i=r(537),n=r(8957),s=r(5905).HTTPParser,o=r(4529).ok,a=r(2728),h=a.parsers,u=a.freeParser,f=a.debug,l=a.CRLF,c=a.continueExpression,d=a.chunkExpression,p=a.httpSocketSetup,m=r(8419).OutgoingMessage,g=e.STATUS_CODES={100:\"Continue\",101:\"Switching Protocols\",102:\"Processing\",200:\"OK\",201:\"Created\",202:\"Accepted\",203:\"Non-Authoritative Information\",204:\"No Content\",205:\"Reset Content\",206:\"Partial Content\",207:\"Multi-Status\",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\"},y=0|s.kOnExecute;function b(t){m.call(this),\"HEAD\"===t.method&&(this._hasBody=!1),this.sendDate=!0,(t.httpVersionMajor<1||t.httpVersionMinor<1)&&(this.useChunkedEncodingByDefault=d.test(t.headers.te),this.shouldKeepAlive=!1)}function v(){this._httpMessage&&this._httpMessage.emit(\"close\")}function w(t){if(!(this instanceof w))return new w(t);n.Server.call(this,{allowHalfOpen:!0}),t&&this.addListener(\"request\",t),this.httpAllowHalfOpen=!1,this.addListener(\"connection\",_),this.timeout=12e4,this._pendingResponseData=0}function _(t){var e=this,r=[],i=[],n=0;function a(e){if(n+=e,t._paused&&n<t._writableState.highWaterMark)return A()}function l(){for(;i.length;){var t=i.shift();t.emit(\"aborted\"),t.emit(\"close\")}}function d(){f(\"server socket close\"),this.parser&&u(this.parser,null,this),l()}f(\"SERVER new http connection\"),p(t),e.timeout&&t.setTimeout(e.timeout),t.on(\"timeout\",function(){var r=t.parser&&t.parser.incoming,i=r&&!r.complete&&r.emit(\"timeout\",t),n=t._httpMessage,s=n&&n.emit(\"timeout\",t),o=e.emit(\"timeout\",t);i||s||o||t.destroy()});var m=h.alloc();m.reinitialize(s.REQUEST),m.socket=t,t.parser=m,m.incoming=null,\"number\"==typeof this.maxHeadersCount?m.maxHeaderPairs=this.maxHeadersCount<<1:m.maxHeaderPairs=2e3,t.addListener(\"error\",v),t.addListener(\"close\",d),m.onIncoming=function(s,h){if(i.push(s),!t._paused){(t._writableState.needDrain||n>=t._writableState.highWaterMark)&&(t._paused=!0,t.pause())}var u=new b(s);u._onPendingData=a,u.shouldKeepAlive=h,t._httpMessage?r.push(u):u.assignSocket(t);u.on(\"finish\",function(){o(0===i.length||i[0]===s),i.shift(),s._consuming||s._readableState.resumeScheduled||s._dump();if(u.detachSocket(t),u._last)t.destroySoon();else{var e=r.shift();e&&e.assignSocket(t)}}),void 0!==s.headers.expect&&1==s.httpVersionMajor&&1==s.httpVersionMinor?c.test(s.headers.expect)?(u._expect_continue=!0,e.listenerCount(\"checkContinue\")>0?e.emit(\"checkContinue\",s,u):(u.writeContinue(),e.emit(\"request\",s,u))):e.listenerCount(\"checkExpectation\")>0?e.emit(\"checkExpectation\",s,u):(u.writeHead(417),u.end()):e.emit(\"request\",s,u);return!1},t.on(\"end\",x),t.on(\"data\",w),t.on(\"resume\",M),t.on(\"pause\",S),t.on(\"drain\",A),t.on=E;var g=t._handle&&t._handle._externalStream;function v(t){this.removeListener(\"error\",v),this.on(\"error\",()=>{}),e.emit(\"clientError\",t,this)||this.destroy(t)}function w(e){o(!t._paused),f(\"SERVER socketOnData %d\",e.length),_(m.execute(e),e)}function _(r,i){if(r instanceof Error)f(\"parse error\"),v.call(t,r);else if(m.incoming&&m.incoming.upgrade){var n=r,s=m.incoming;f(\"SERVER upgrade or connect\",s.method),i||(i=m.getCurrentBuffer()),t.removeListener(\"data\",w),t.removeListener(\"end\",x),t.removeListener(\"close\",d),k(m,t),m.finish(),u(m,s,null),m=null;var o=\"CONNECT\"===s.method?\"connect\":\"upgrade\";if(e.listenerCount(o)>0){f(\"SERVER have listener for %s\",o);var a=i.slice(n,i.length);t._readableState.flowing=null,e.emit(o,s,t,a)}else t.destroy()}t._paused&&t.parser&&(f(\"pause parser\"),t.parser.pause())}function x(){var t=this,i=m.finish();if(i instanceof Error)return f(\"parse error\"),void v.call(t,i);e.httpAllowHalfOpen?r.length?r[r.length-1]._last=!0:t._httpMessage?t._httpMessage._last=!0:t.writable&&t.end():(l(),t.writable&&t.end())}function A(){var e=n>t._writableState.highWaterMark;t._paused&&!e&&(t._paused=!1,t.parser&&t.parser.resume(),t.resume())}g&&(m._consumed=!0,m.consume(g)),g=null,m[y]=function(e,r){t._unrefTimer(),f(\"SERVER socketOnParserExecute %d\",e),_(e,void 0)},t._paused=!1}function M(){this._paused?this.pause():this._handle&&!this._handle.reading&&(this._handle.reading=!0,this._handle.readStart())}function S(){this._handle&&this._handle.reading&&(this._handle.reading=!1,this._handle.readStop())}function k(t,e){e._handle&&(t._consumed&&t.unconsume(e._handle._externalStream),t._consumed=!1,e.removeListener(\"pause\",S),e.removeListener(\"resume\",M))}function E(t,e){var r=n.Socket.prototype.on.call(this,t,e);return this.parser?(\"data\"!==t&&\"readable\"!==t||k(this.parser,this),r):(this.on=n.Socket.prototype.on,r)}i.inherits(b,m),b.prototype._finish=function(){m.prototype._finish.call(this)},e.ServerResponse=b,b.prototype.statusCode=200,b.prototype.statusMessage=void 0,b.prototype.assignSocket=function(t){o(!t._httpMessage),t._httpMessage=this,t.on(\"close\",v),this.socket=t,this.connection=t,this.emit(\"socket\",t),this._flush()},b.prototype.detachSocket=function(t){o(t._httpMessage===this),t.removeListener(\"close\",v),t._httpMessage=null,this.socket=this.connection=null},b.prototype.writeContinue=function(t){this._writeRaw(\"HTTP/1.1 100 Continue\"+l+l,\"ascii\",t),this._sent100=!0},b.prototype._implicitHeader=function(){this.writeHead(this.statusCode)},b.prototype.writeHead=function(t,e,r){var i;if(\"string\"==typeof e?this.statusMessage=e:(this.statusMessage=this.statusMessage||g[t]||\"unknown\",r=e),this.statusCode=t,this._headers){if(r)for(var n=Object.keys(r),s=0;s<n.length;s++){var o=n[s];o&&this.setHeader(o,r[o])}i=this._renderHeaders()}else i=r;if((t|=0)<100||t>999)throw new RangeError(`Invalid status code: ${t}`);var a=\"HTTP/1.1 \"+t.toString()+\" \"+this.statusMessage+l;(204===t||304===t||100<=t&&t<=199)&&(this._hasBody=!1),this._expect_continue&&!this._sent100&&(this.shouldKeepAlive=!1),this._storeHeader(a,i)},b.prototype.writeHeader=function(){this.writeHead.apply(this,arguments)},i.inherits(w,n.Server),w.prototype.setTimeout=function(t,e){return this.timeout=t,e&&this.on(\"timeout\",e),this},e.Server=w,e._connectionListener=_},1706:(t,e,r)=>{var i=r(717),n=r(3225);t.exports=v;var s,o=r(9860);v.ReadableState=b;r(7007).EventEmitter;var a=function(t,e){return t.listeners(e).length},h=r(9530),u=r(3392).Buffer,f=(\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var l=Object.create(r(5622));l.inherits=r(6698);var c=r(537),d=void 0;d=c&&c.debuglog?c.debuglog(\"stream\"):function(){};var p,m=r(6972),g=r(330);l.inherits(v,h);var y=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function b(t,e){t=t||{};var i=e instanceof(s=s||r(308));this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,o=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,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&&(p||(p=r(7479).I),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function v(t){if(s=s||r(308),!(this instanceof v))return new v(t);this._readableState=new b(t,this),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),h.call(this)}function w(t,e,r,i,n){var s,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,k(t)}(t,o)):(n||(s=function(t,e){var r;i=e,u.isBuffer(i)||i instanceof f||\"string\"==typeof e||void 0===e||t.objectMode||(r=new TypeError(\"Invalid non-string/buffer chunk\"));var i;return r}(o,e)),s?t.emit(\"error\",s):o.objectMode||e&&e.length>0?(\"string\"==typeof e||o.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),i?o.endEmitted?t.emit(\"error\",new Error(\"stream.unshift() after end event\")):_(t,o,e,!0):o.ended?t.emit(\"error\",new Error(\"stream.push() after EOF\")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?_(t,o,e,!1):x(t,o)):_(t,o,e,!1))):i||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(o)}function _(t,e,r,i){e.flowing&&0===e.length&&!e.sync?(t.emit(\"data\",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&k(t)),x(t,e)}Object.defineProperty(v.prototype,\"destroyed\",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),v.prototype.destroy=g.destroy,v.prototype._undestroy=g.undestroy,v.prototype._destroy=function(t,e){this.push(null),e(t)},v.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:\"string\"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=u.from(t,e),e=\"\"),r=!0),w(this,t,e,!1,r)},v.prototype.unshift=function(t){return w(this,t,null,!0,!1)},v.prototype.isPaused=function(){return!1===this._readableState.flowing},v.prototype.setEncoding=function(t){return p||(p=r(7479).I),this._readableState.decoder=new p(t),this._readableState.encoding=t,this};var M=8388608;function S(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(d(\"emitReadable\",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(E,t):E(t))}function E(t){d(\"emit readable\"),t.emit(\"readable\"),C(t)}function x(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(A,t,e))}function A(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(d(\"maybeReadMore read 0\"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function I(t){d(\"readable nexttick read 0\"),t.read(0)}function T(t,e){e.reading||(d(\"resume read 0\"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit(\"resume\"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(d(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function P(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var i;t<e.head.data.length?(i=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):i=t===e.head.data.length?e.shift():r?function(t,e){var r=e.head,i=1,n=r.data;t-=n.length;for(;r=r.next;){var s=r.data,o=t>s.length?s.length:t;if(o===s.length?n+=s:n+=s.slice(0,t),0===(t-=o)){o===s.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++i}return e.length-=i,n}(t,e):function(t,e){var r=u.allocUnsafe(t),i=e.head,n=1;i.data.copy(r),t-=i.data.length;for(;i=i.next;){var s=i.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=s.slice(o));break}++n}return e.length-=n,r}(t,e);return i}(t,e.buffer,e.decoder),r);var r}function R(t){var e=t._readableState;if(e.length>0)throw new Error('\"endReadable()\" called on non-empty stream');e.endEmitted||(e.ended=!0,n.nextTick(O,e,t))}function O(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"))}function B(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}v.prototype.read=function(t){d(\"read\",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return d(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?R(this):k(this),null;if(0===(t=S(t,e))&&e.ended)return 0===e.length&&R(this),null;var i,n=e.needReadable;return d(\"need readable\",n),(0===e.length||e.length-t<e.highWaterMark)&&d(\"length less than watermark\",n=!0),e.ended||e.reading?d(\"reading or ended\",n=!1):n&&(d(\"do read\"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=S(r,e))),null===(i=t>0?P(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&R(this)),null!==i&&this.emit(\"data\",i),i},v.prototype._read=function(t){this.emit(\"error\",new Error(\"_read() is not implemented\"))},v.prototype.pipe=function(t,e){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,d(\"pipe count=%d opts=%j\",s.pipesCount,e);var h=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?f:v;function u(e,i){d(\"onunpipe\"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,d(\"cleanup\"),t.removeListener(\"close\",y),t.removeListener(\"finish\",b),t.removeListener(\"drain\",l),t.removeListener(\"error\",g),t.removeListener(\"unpipe\",u),r.removeListener(\"end\",f),r.removeListener(\"end\",v),r.removeListener(\"data\",m),c=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){d(\"onend\"),t.end()}s.endEmitted?n.nextTick(h):r.once(\"end\",h),t.on(\"unpipe\",u);var l=function(t){return function(){var e=t._readableState;d(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,\"data\")&&(e.flowing=!0,C(t))}}(r);t.on(\"drain\",l);var c=!1;var p=!1;function m(e){d(\"ondata\"),p=!1,!1!==t.write(e)||p||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==B(s.pipes,t))&&!c&&(d(\"false write response, pause\",s.awaitDrain),s.awaitDrain++,p=!0),r.pause())}function g(e){d(\"onerror\",e),v(),t.removeListener(\"error\",g),0===a(t,\"error\")&&t.emit(\"error\",e)}function y(){t.removeListener(\"finish\",b),v()}function b(){d(\"onfinish\"),t.removeListener(\"close\",y),v()}function v(){d(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",m),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",g),t.once(\"close\",y),t.once(\"finish\",b),t.emit(\"pipe\",r),s.flowing||(d(\"pipe resume\"),r.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s<n;s++)i[s].emit(\"unpipe\",this,{hasUnpiped:!1});return this}var o=B(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit(\"unpipe\",this,r)),this},v.prototype.on=function(t,e){var r=h.prototype.on.call(this,t,e);if(\"data\"===t)!1!==this._readableState.flowing&&this.resume();else if(\"readable\"===t){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&k(this):n.nextTick(I,this))}return r},v.prototype.addListener=v.prototype.on,v.prototype.resume=function(){var t=this._readableState;return t.flowing||(d(\"resume\"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(T,t,e))}(this,t)),this},v.prototype.pause=function(){return d(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(d(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this},v.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on(\"end\",function(){if(d(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on(\"data\",function(n){(d(\"wrapped data\"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(e.push(n)||(i=!0,t.pause()))}),t)void 0===this[n]&&\"function\"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s<y.length;s++)t.on(y[s],this.emit.bind(this,y[s]));return this._read=function(e){d(\"wrapped _read\",e),i&&(i=!1,t.resume())},this},Object.defineProperty(v.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),v._fromList=P},1800:(t,e,r)=>{var i=r(6698),n=r(2861).Buffer,s=r(6168),o=n.alloc(128),a=64;function h(t,e){s.call(this,\"digest\"),\"string\"==typeof e&&(e=n.from(e)),this._alg=t,this._key=e,e.length>a?e=t(e):e.length<a&&(e=n.concat([e,o],a));for(var r=this._ipad=n.allocUnsafe(a),i=this._opad=n.allocUnsafe(a),h=0;h<a;h++)r[h]=54^e[h],i[h]=92^e[h];this._hash=[r]}i(h,s),h.prototype._update=function(t){this._hash.push(t)},h.prototype._final=function(){var t=this._alg(n.concat(this._hash));return this._alg(n.concat([this._opad,t]))},t.exports=h},1816:(t,e,r)=>{t.exports=o;var i=r(6248),n=Object.create(r(5622));function s(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit(\"error\",new Error(\"write callback called multiple times\"));r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);i.call(this,t),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(\"function\"==typeof t.transform&&(this._transform=t.transform),\"function\"==typeof t.flush&&(this._flush=t.flush)),this.on(\"prefinish\",a)}function a(){var t=this;\"function\"==typeof this._flush?this._flush(function(e,r){h(t,e,r)}):h(this,null,null)}function h(t,e,r){if(e)return t.emit(\"error\",e);if(null!=r&&t.push(r),t._writableState.length)throw new Error(\"Calling transform done when ws.length != 0\");if(t._transformState.transforming)throw new Error(\"Calling transform done when still transforming\");return t.push(null)}n.inherits=r(6698),n.inherits(o,i),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,i.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,r){throw new Error(\"_transform() is not implemented\")},o.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},o.prototype._read=function(t){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},o.prototype._destroy=function(t,e){var r=this;i.prototype._destroy.call(this,t,function(t){e(t),r.emit(\"close\")})}},1827:()=>{},1847:t=>{function e(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:void 0}t.exports={byteLength:function(t){return t.length>>>1},toString:function(t){const e=t.byteLength;t=new DataView(t.buffer,t.byteOffset,e);let r=\"\",i=0;for(let n=e-e%4;i<n;i+=4)r+=t.getUint32(i).toString(16).padStart(8,\"0\");for(;i<e;i++)r+=t.getUint8(i).toString(16).padStart(2,\"0\");return r},write:function(t,r){const i=t.byteLength;for(let n=0;n<i;n++){const i=e(r.charCodeAt(2*n)),s=e(r.charCodeAt(2*n+1));if(void 0===i||void 0===s)return t.subarray(0,n);t[n]=i<<4|s}return i}}},1862:(t,e,r)=>{t.exports=r(8310)},1911:(t,e,r)=>{var i=r(7426),n=r(7766);function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(s,n),t.exports=s,s.blockSize=1024,s.outSize=384,s.hmacStrength=192,s.padLength=128,s.prototype._digest=function(t){return\"hex\"===t?i.toHex32(this.h.slice(0,12),\"big\"):i.split32(this.h.slice(0,12),\"big\")}},2010:(t,e,r)=>{var i=r(6698),n=r(7568),s=n.base,o=n.bignum,a=n.constants.der;function h(t){this.enc=\"der\",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){s.Node.call(this,\"der\",t)}function f(t,e){var r=t.readUInt8(e);if(t.isError(r))return r;var i=a.tagClass[r>>6],n=!(32&r);if(31&~r)r&=31;else{var s=r;for(r=0;!(128&~s);){if(s=t.readUInt8(e),t.isError(s))return s;r<<=7,r|=127&s}}return{cls:i,primitive:n,tag:r,tagStr:a.tag[r]}}function l(t,e,r){var i=t.readUInt8(r);if(t.isError(i))return i;if(!e&&128===i)return null;if(!(128&i))return i;var n=127&i;if(n>4)return t.error(\"length octect is too long\");i=0;for(var s=0;s<n;s++){i<<=8;var o=t.readUInt8(r);if(t.isError(o))return o;i|=o}return i}t.exports=h,h.prototype.decode=function(t,e){return t instanceof s.DecoderBuffer||(t=new s.DecoderBuffer(t,e)),this.tree._decode(t,e)},i(u,s.Node),u.prototype._peekTag=function(t,e,r){if(t.isEmpty())return!1;var i=t.save(),n=f(t,'Failed to peek tag: \"'+e+'\"');return t.isError(n)?n:(t.restore(i),n.tag===e||n.tagStr===e||n.tagStr+\"of\"===e||r)},u.prototype._decodeTag=function(t,e,r){var i=f(t,'Failed to decode tag of \"'+e+'\"');if(t.isError(i))return i;var n=l(t,i.primitive,'Failed to get length of \"'+e+'\"');if(t.isError(n))return n;if(!r&&i.tag!==e&&i.tagStr!==e&&i.tagStr+\"of\"!==e)return t.error('Failed to match tag: \"'+e+'\"');if(i.primitive||null!==n)return t.skip(n,'Failed to match body of: \"'+e+'\"');var s=t.save(),o=this._skipUntilEnd(t,'Failed to skip indefinite length body: \"'+this.tag+'\"');return t.isError(o)?o:(n=t.offset-s.offset,t.restore(s),t.skip(n,'Failed to match body of: \"'+e+'\"'))},u.prototype._skipUntilEnd=function(t,e){for(;;){var r=f(t,e);if(t.isError(r))return r;var i,n=l(t,r.primitive,e);if(t.isError(n))return n;if(i=r.primitive||null!==n?t.skip(n):this._skipUntilEnd(t,e),t.isError(i))return i;if(\"end\"===r.tagStr)break}},u.prototype._decodeList=function(t,e,r,i){for(var n=[];!t.isEmpty();){var s=this._peekTag(t,\"end\");if(t.isError(s))return s;var o=r.decode(t,\"der\",i);if(t.isError(o)&&s)break;n.push(o)}return n},u.prototype._decodeStr=function(t,e){if(\"bitstr\"===e){var r=t.readUInt8();return t.isError(r)?r:{unused:r,data:t.raw()}}if(\"bmpstr\"===e){var i=t.raw();if(i.length%2==1)return t.error(\"Decoding of string type: bmpstr length mismatch\");for(var n=\"\",s=0;s<i.length/2;s++)n+=String.fromCharCode(i.readUInt16BE(2*s));return n}if(\"numstr\"===e){var o=t.raw().toString(\"ascii\");return this._isNumstr(o)?o:t.error(\"Decoding of string type: numstr unsupported characters\")}if(\"octstr\"===e)return t.raw();if(\"objDesc\"===e)return t.raw();if(\"printstr\"===e){var a=t.raw().toString(\"ascii\");return this._isPrintstr(a)?a:t.error(\"Decoding of string type: printstr unsupported characters\")}return/str$/.test(e)?t.raw().toString():t.error(\"Decoding of string type: \"+e+\" unsupported\")},u.prototype._decodeObjid=function(t,e,r){for(var i,n=[],s=0;!t.isEmpty();){var o=t.readUInt8();s<<=7,s|=127&o,128&o||(n.push(s),s=0)}128&o&&n.push(s);var a=n[0]/40|0,h=n[0]%40;if(i=r?n:[a,h].concat(n.slice(1)),e){var u=e[i.join(\" \")];void 0===u&&(u=e[i.join(\".\")]),void 0!==u&&(i=u)}return i},u.prototype._decodeTime=function(t,e){var r=t.raw().toString();if(\"gentime\"===e)var i=0|r.slice(0,4),n=0|r.slice(4,6),s=0|r.slice(6,8),o=0|r.slice(8,10),a=0|r.slice(10,12),h=0|r.slice(12,14);else{if(\"utctime\"!==e)return t.error(\"Decoding \"+e+\" time is not supported yet\");i=0|r.slice(0,2),n=0|r.slice(2,4),s=0|r.slice(4,6),o=0|r.slice(6,8),a=0|r.slice(8,10),h=0|r.slice(10,12);i=i<70?2e3+i:1900+i}return Date.UTC(i,n-1,s,o,a,h,0)},u.prototype._decodeNull=function(t){return null},u.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},u.prototype._decodeInt=function(t,e){var r=t.raw(),i=new o(r);return e&&(i=e[i.toString(10)]||i),i},u.prototype._use=function(t,e){return\"function\"==typeof t&&(t=t(e)),t._getDecoder(\"der\").tree}},2061:t=>{t.exports=function(t,e){for(var r=t.length,i=-1;++i<r;)t[i]^=e[i];return t}},2072:t=>{t.exports={wait:function(t){return new Promise(e=>setTimeout(e,t))}}},2085:(t,e,r)=>{var i=r(640),n=function(t){switch(t.length){case 6:return t[0]+\".\"+t[1]+\".\"+t[2]+\".\"+t[3]+\":\"+t.readUInt16BE(4);case 18:for(var e=[],r=0;r<8;r++)e.push(t.readUInt16BE(2*r).toString(16));return\"[\"+i.parse(e.join(\":\")).toString()+\"]:\"+t.readUInt16BE(16);default:throw new Error(\"Invalid Compact IP/PORT, It should contain 6 or 18 bytes\")}};n.multi=function(t){if(t.length%6!=0)throw new Error(\"buf length isn't multiple of compact IP/PORTs (6 bytes)\");for(var e=[],r=0;r<=t.length-1;r+=6)e.push(n(t.slice(r,r+6)));return e},n.multi6=function(t){if(t.length%18!=0)throw new Error(\"buf length isn't multiple of compact IP6/PORTs (18 bytes)\");for(var e=[],r=0;r<=t.length-1;r+=18)e.push(n(t.slice(r,r+18)));return e},t.exports=n},2153:(t,e,r)=>{var i=e;i._reverse=function(t){var e={};return Object.keys(t).forEach(function(r){(0|r)==r&&(r|=0);var i=t[r];e[i]=r}),e},i.der=r(4598)},2195:(t,e,r)=>{const i=r(537),n=i,s=r(7007);e.IncomingMessage=r(3989).IncomingMessage;const o=r(2728);e.METHODS=o.methods.slice().sort(),e.OutgoingMessage=r(8419).OutgoingMessage;const a=r(1678);e.ServerResponse=a.ServerResponse,e.STATUS_CODES=a.STATUS_CODES;const h=r(8748),u=e.Agent=h.Agent;e.globalAgent=h.globalAgent;const f=r(5930),l=e.ClientRequest=f.ClientRequest;e.request=function(t,e){return new l(t,e)},e.get=function(t,r){var i=e.request(t,r);return i.end(),i},e._connectionListener=a._connectionListener;const c=e.Server=a.Server;function d(t,e){if(!(this instanceof d))return new d(t,e);s.call(this),e=e||\"localhost\",t=t||80,this.host=e,this.port=t,this.agent=new u({host:e,port:t,maxSockets:1})}e.createServer=function(t){return new c(t)},i.inherits(d,s),d.prototype.request=function(t,e,r){var i=this,n={};n.host=i.host,n.port=i.port,\"/\"===t[0]&&(r=e,e=t,t=\"GET\"),n.method=t,n.path=e,n.headers=r,n.agent=i.agent;var s=new l(n);return s.on(\"error\",function(t){i.emit(\"error\",t)}),s.on(\"socket\",function(t){t.on(\"end\",function(){if(i._decoder){var t=i._decoder.end();t&&i.emit(\"data\",t)}i.emit(\"end\")})}),s},e.Client=n.deprecate(d,\"http.Client is deprecated.\"),e.createClient=n.deprecate(function(t,e){return new d(t,e)},\"http.createClient is deprecated. Use http.request instead.\")},2205:(t,e,r)=>{var i=r(6743),n=r(1002),s=r(3144);t.exports=function(){return s(i,n,arguments)}},2211:(t,e,r)=>{var i=r(3349),n=r(6698),s=r(7626),o=r(2808);function a(){this.tmp=new Array(2),this.keys=null}function h(t){o.call(this,t);var e=new a;this._desState=e,this.deriveKeys(e,t.key)}n(h,o),t.exports=h,h.create=function(t){return new h(t)};var u=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];h.prototype.deriveKeys=function(t,e){t.keys=new Array(32),i.equal(e.length,this.blockSize,\"Invalid key length\");var r=s.readUInt32BE(e,0),n=s.readUInt32BE(e,4);s.pc1(r,n,t.tmp,0),r=t.tmp[0],n=t.tmp[1];for(var o=0;o<t.keys.length;o+=2){var a=u[o>>>1];r=s.r28shl(r,a),n=s.r28shl(n,a),s.pc2(r,n,t.keys,o)}},h.prototype._update=function(t,e,r,i){var n=this._desState,o=s.readUInt32BE(t,e),a=s.readUInt32BE(t,e+4);s.ip(o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],\"encrypt\"===this.type?this._encrypt(n,o,a,n.tmp,0):this._decrypt(n,o,a,n.tmp,0),o=n.tmp[0],a=n.tmp[1],s.writeUInt32BE(r,o,i),s.writeUInt32BE(r,a,i+4)},h.prototype._pad=function(t,e){if(!1===this.padding)return!1;for(var r=t.length-e,i=e;i<t.length;i++)t[i]=r;return!0},h.prototype._unpad=function(t){if(!1===this.padding)return t;for(var e=t[t.length-1],r=t.length-e;r<t.length;r++)i.equal(t[r],e);return t.slice(0,t.length-e)},h.prototype._encrypt=function(t,e,r,i,n){for(var o=e,a=r,h=0;h<t.keys.length;h+=2){var u=t.keys[h],f=t.keys[h+1];s.expand(a,t.tmp,0),u^=t.tmp[0],f^=t.tmp[1];var l=s.substitute(u,f),c=a;a=(o^s.permute(l))>>>0,o=c}s.rip(a,o,i,n)},h.prototype._decrypt=function(t,e,r,i,n){for(var o=r,a=e,h=t.keys.length-2;h>=0;h-=2){var u=t.keys[h],f=t.keys[h+1];s.expand(o,t.tmp,0),u^=t.tmp[0],f^=t.tmp[1];var l=s.substitute(u,f),c=o;o=(a^s.permute(l))>>>0,a=c}s.rip(o,a,i,n)}},2240:t=>{var e={}.toString;t.exports=Array.isArray||function(t){return\"[object Array]\"==e.call(t)}},2244:(t,e,r)=>{var i=r(1158),n=r(5037);function s(t){this.rand=t||new n.Rand}t.exports=s,s.create=function(t){return new s(t)},s.prototype._randbelow=function(t){var e=t.bitLength(),r=Math.ceil(e/8);do{var n=new i(this.rand.generate(r))}while(n.cmp(t)>=0);return n},s.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},s.prototype.test=function(t,e,r){var n=t.bitLength(),s=i.mont(t),o=new i(1).toRed(s);e||(e=Math.max(1,n/48|0));for(var a=t.subn(1),h=0;!a.testn(h);h++);for(var u=t.shrn(h),f=a.toRed(s);e>0;e--){var l=this._randrange(new i(2),a);r&&r(l);var c=l.toRed(s).redPow(u);if(0!==c.cmp(o)&&0!==c.cmp(f)){for(var d=1;d<h;d++){if(0===(c=c.redSqr()).cmp(o))return!1;if(0===c.cmp(f))break}if(d===h)return!1}}return!0},s.prototype.getDivisor=function(t,e){var r=t.bitLength(),n=i.mont(t),s=new i(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var o=t.subn(1),a=0;!o.testn(a);a++);for(var h=t.shrn(a),u=o.toRed(n);e>0;e--){var f=this._randrange(new i(2),o),l=t.gcd(f);if(0!==l.cmpn(1))return l;var c=f.toRed(n).redPow(h);if(0!==c.cmp(s)&&0!==c.cmp(u)){for(var d=1;d<a;d++){if(0===(c=c.redSqr()).cmp(s))return c.fromRed().subn(1).gcd(t);if(0===c.cmp(u))break}if(d===a)return(c=c.redSqr()).fromRed().subn(1).gcd(t)}}return!1}},2271:(t,e,r)=>{var i=r(453),n=r(6556),s=r(8859),o=r(507),a=r(9675),h=i(\"%WeakMap%\",!0),u=n(\"WeakMap.prototype.get\",!0),f=n(\"WeakMap.prototype.set\",!0),l=n(\"WeakMap.prototype.has\",!0),c=n(\"WeakMap.prototype.delete\",!0);t.exports=h?function(){var t,e,r={assert:function(t){if(!r.has(t))throw new a(\"Side channel does not contain \"+s(t))},delete:function(r){if(h&&r&&(\"object\"==typeof r||\"function\"==typeof r)){if(t)return c(t,r)}else if(o&&e)return e.delete(r);return!1},get:function(r){return h&&r&&(\"object\"==typeof r||\"function\"==typeof r)&&t?u(t,r):e&&e.get(r)},has:function(r){return h&&r&&(\"object\"==typeof r||\"function\"==typeof r)&&t?l(t,r):!!e&&e.has(r)},set:function(r,i){h&&r&&(\"object\"==typeof r||\"function\"==typeof r)?(t||(t=new h),f(t,r,i)):o&&(e||(e=o()),e.set(r,i))}};return r}:o},2287:(t,e,r)=>{var i=r(7426),n=r(6166),s=r(6225),o=r(3349),a=i.sum32,h=i.sum32_4,u=i.sum32_5,f=s.ch32,l=s.maj32,c=s.s0_256,d=s.s1_256,p=s.g0_256,m=s.g1_256,g=n.BlockHash,y=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}i.inherits(b,g),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=h(m(r[i-2]),r[i-7],p(r[i-15]),r[i-16]);var n=this.h[0],s=this.h[1],g=this.h[2],y=this.h[3],b=this.h[4],v=this.h[5],w=this.h[6],_=this.h[7];for(o(this.k.length===r.length),i=0;i<r.length;i++){var M=u(_,d(b),f(b,v,w),this.k[i],r[i]),S=a(c(n),l(n,s,g));_=w,w=v,v=b,b=a(y,M),y=g,g=s,s=n,n=a(M,S)}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],s),this.h[2]=a(this.h[2],g),this.h[3]=a(this.h[3],y),this.h[4]=a(this.h[4],b),this.h[5]=a(this.h[5],v),this.h[6]=a(this.h[6],w),this.h[7]=a(this.h[7],_)},b.prototype._digest=function(t){return\"hex\"===t?i.toHex32(this.h,\"big\"):i.split32(this.h,\"big\")}},2344:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"};var f=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],d=c[t];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:f[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\"),this.strip();var o,a,h=\"le\"===e,u=new t(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a<s;a++)u[a]=0}else{for(a=0;a<s-n;a++)u[a]=0;for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[s-a-1]=o}return u},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},g.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),m(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i(\"number\"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a.strip(),i.strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new S(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function w(){b.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function _(){b.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function M(){b.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function k(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,b),n(_,b),n(M,b),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if(\"k256\"===t)e=new v;else if(\"p224\"===t)e=new w;else if(\"p192\"===t)e=new _;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new M}return y[t]=e,e},S.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},S.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new k(t)},n(k,S),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},2356:(t,e,r)=>{var i=r(462),n=r(2861).Buffer,s=r(6168),o=r(6698),a=r(5892),h=r(295),u=r(5122);function f(t,e,r,o){s.call(this);var h=n.alloc(4,0);this._cipher=new i.AES(e);var f=this._cipher.encryptBlock(h);this._ghash=new a(f),r=function(t,e,r){if(12===e.length)return t._finID=n.concat([e,n.from([0,0,0,1])]),n.concat([e,n.from([0,0,0,2])]);var i=new a(r),s=e.length,o=s%16;i.update(e),o&&(o=16-o,i.update(n.alloc(o,0))),i.update(n.alloc(8,0));var h=8*s,f=n.alloc(8);f.writeUIntBE(h,0,8),i.update(f),t._finID=i.state;var l=n.from(t._finID);return u(l),l}(this,r,f),this._prev=n.from(r),this._cache=n.allocUnsafe(0),this._secCache=n.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(f,s),f.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=n.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error(\"Unsupported state or unable to authenticate data\");var t=h(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var i=Math.min(t.length,e.length),n=0;n<i;++n)r+=t[n]^e[n];return r}(t,this._authTag))throw new Error(\"Unsupported state or unable to authenticate data\");this._authTag=t,this._cipher.scrub()},f.prototype.getAuthTag=function(){if(this._decrypt||!n.isBuffer(this._authTag))throw new Error(\"Attempting to get auth tag in unsupported state\");return this._authTag},f.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error(\"Attempting to set auth tag in unsupported state\");this._authTag=t},f.prototype.setAAD=function(t){if(this._called)throw new Error(\"Attempting to set AAD in unsupported state\");this._ghash.update(t),this._alen+=t.length},t.exports=f},2376:()=>{},2398:(t,e,r)=>{var i=r(717),n=r(3225);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;t.entry=null;for(;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=y;var o,a=!i.browser&&[\"v0.10\",\"v0.9.\"].indexOf(i.version.slice(0,5))>-1?setImmediate:n.nextTick;y.WritableState=g;var h=Object.create(r(5622));h.inherits=r(6698);var u={deprecate:r(4643)},f=r(9530),l=r(3392).Buffer,c=(\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var d,p=r(330);function m(){}function g(t,e){o=o||r(308),t=t||{};var i=e instanceof o;this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var h=t.highWaterMark,u=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=h||0===h?h:i&&(u||0===u)?u:f,this.highWaterMark=Math.floor(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(t){!function(t,e){var r=t._writableState,i=r.sync,s=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,s){--e.pendingcb,r?(n.nextTick(s,i),n.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit(\"error\",i)):(s(i),t._writableState.errorEmitted=!0,t.emit(\"error\",i),S(t,e))}(t,r,i,e,s);else{var o=_(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),i?a(v,t,r,o,s):v(t,r,o,s)}}(e,t)},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 s(this)}function y(t){if(o=o||r(308),!(d.call(y,this)||this instanceof o))return new y(t);this._writableState=new g(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)),f.call(this)}function b(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function v(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,i(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),o=e.corkedRequestsFree;o.entry=r;for(var a=0,h=!0;r;)n[a]=r,r.isBuf||(h=!1),r=r.next,a+=1;n.allBuffers=h,b(t,e,!0,e.length,n,\"\",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,l=r.callback;if(b(t,e,!1,e.objectMode?1:u.length,u,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function M(t,e){t._final(function(r){e.pendingcb--,r&&t.emit(\"error\",r),e.prefinished=!0,t.emit(\"prefinish\"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||(\"function\"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,n.nextTick(M,t,e)):(e.prefinished=!0,t.emit(\"prefinish\")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"))),r}h.inherits(y,f),g.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(g.prototype,\"buffer\",{get:u.deprecate(function(){return this.getBuffer()},\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===y&&(t&&t._writableState instanceof g)}})):d=function(t){return t instanceof this},y.prototype.pipe=function(){this.emit(\"error\",new Error(\"Cannot pipe, not readable\"))},y.prototype.write=function(t,e,r){var i,s=this._writableState,o=!1,a=!s.objectMode&&(i=t,l.isBuffer(i)||i instanceof c);return a&&!l.isBuffer(t)&&(t=function(t){return l.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),a?e=\"buffer\":e||(e=s.defaultEncoding),\"function\"!=typeof r&&(r=m),s.ended?function(t,e){var r=new Error(\"write after end\");t.emit(\"error\",r),n.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var s=!0,o=!1;return null===r?o=new TypeError(\"May not write null values to stream\"):\"string\"==typeof r||void 0===r||e.objectMode||(o=new TypeError(\"Invalid non-string/buffer chunk\")),o&&(t.emit(\"error\",o),n.nextTick(i,o),s=!1),s}(this,s,t,r))&&(s.pendingcb++,o=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=l.from(e,r));return e}(e,i,n);i!==o&&(r=!0,n=\"buffer\",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var h=e.length<e.highWaterMark;h||(e.needDrain=!0);if(e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:s,next:null},u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else b(t,e,!1,a,i,n,s);return h}(this,s,a,t,e,r)),o},y.prototype.cork=function(){this._writableState.corked++},y.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||w(this,t))},y.prototype.setDefaultEncoding=function(t){if(\"string\"==typeof t&&(t=t.toLowerCase()),!([\"hex\",\"utf8\",\"utf-8\",\"ascii\",\"binary\",\"base64\",\"ucs2\",\"ucs-2\",\"utf16le\",\"utf-16le\",\"raw\"].indexOf((t+\"\").toLowerCase())>-1))throw new TypeError(\"Unknown encoding: \"+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(y.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(t,e,r){r(new Error(\"_write() is not implemented\"))},y.prototype._writev=null,y.prototype.end=function(t,e,r){var i=this._writableState;\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?n.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,i,r)},Object.defineProperty(y.prototype,\"destroyed\",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),y.prototype.destroy=p.destroy,y.prototype._undestroy=p.undestroy,y.prototype._destroy=function(t,e){this.end(),e(t)}},2438:(t,e)=>{e[\"des-ecb\"]={key:8,iv:0},e[\"des-cbc\"]=e.des={key:8,iv:8},e[\"des-ede3-cbc\"]=e.des3={key:24,iv:8},e[\"des-ede3\"]={key:24,iv:0},e[\"des-ede-cbc\"]={key:16,iv:8},e[\"des-ede\"]={key:16,iv:0}},2455:(t,e,r)=>{var i,n=r(717);if(globalThis.process&&globalThis.process.browser)i=\"utf-8\";else if(globalThis.process&&globalThis.process.version){i=parseInt(n.version.split(\".\")[0].slice(1),10)>=6?\"utf-8\":\"binary\"}else i=\"utf-8\";t.exports=i},2503:(t,e,r)=>{var i=r(8287).Buffer;t.exports=function(t){return t instanceof i}},2509:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"};var f=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],d=c[t];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:f[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\"),this.strip();var o,a,h=\"le\"===e,u=new t(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a<s;a++)u[a]=0}else{for(a=0;a<s-n;a++)u[a]=0;for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[s-a-1]=o}return u},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},g.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),m(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i(\"number\"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a.strip(),i.strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new S(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function w(){b.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function _(){b.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function M(){b.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function k(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,b),n(_,b),n(M,b),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if(\"k256\"===t)e=new v;else if(\"p224\"===t)e=new w;else if(\"p192\"===t)e=new _;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new M}return y[t]=e,e},S.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},S.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new k(t)},n(k,S),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},2632:(t,e)=>{e.encrypt=function(t,e){return t._cipher.encryptBlock(e)},e.decrypt=function(t,e){return t._cipher.decryptBlock(e)}},2642:(t,e,r)=>{var i=r(7720),n=Object.prototype.hasOwnProperty,s=Array.isArray,o={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:\"utf-8\",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:i.decode,delimiter:\"&\",depth:5,duplicates:\"combine\",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},a=function(t){return t.replace(/&#(\\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},h=function(t,e){return t&&\"string\"==typeof t&&e.comma&&t.indexOf(\",\")>-1?t.split(\",\"):t},u=function(t,e,r,i){if(t){var s=r.allowDots?t.replace(/\\.([^.[]+)/g,\"[$1]\"):t,o=/(\\[[^[\\]]*])/g,a=r.depth>0&&/(\\[[^[\\]]*])/.exec(s),u=a?s.slice(0,a.index):s,f=[];if(u){if(!r.plainObjects&&n.call(Object.prototype,u)&&!r.allowPrototypes)return;f.push(u)}for(var l=0;r.depth>0&&null!==(a=o.exec(s))&&l<r.depth;){if(l+=1,!r.plainObjects&&n.call(Object.prototype,a[1].slice(1,-1))&&!r.allowPrototypes)return;f.push(a[1])}if(a){if(!0===r.strictDepth)throw new RangeError(\"Input depth exceeded depth option of \"+r.depth+\" and strictDepth is true\");f.push(\"[\"+s.slice(a.index)+\"]\")}return function(t,e,r,i){for(var n=i?e:h(e,r),s=t.length-1;s>=0;--s){var o,a=t[s];if(\"[]\"===a&&r.parseArrays)o=r.allowEmptyArrays&&(\"\"===n||r.strictNullHandling&&null===n)?[]:[].concat(n);else{o=r.plainObjects?Object.create(null):{};var u=\"[\"===a.charAt(0)&&\"]\"===a.charAt(a.length-1)?a.slice(1,-1):a,f=r.decodeDotInKeys?u.replace(/%2E/g,\".\"):u,l=parseInt(f,10);r.parseArrays||\"\"!==f?!isNaN(l)&&a!==f&&String(l)===f&&l>=0&&r.parseArrays&&l<=r.arrayLimit?(o=[])[l]=n:\"__proto__\"!==f&&(o[f]=n):o={0:n}}n=o}return n}(f,e,r,i)}};t.exports=function(t,e){var r=function(t){if(!t)return o;if(void 0!==t.allowEmptyArrays&&\"boolean\"!=typeof t.allowEmptyArrays)throw new TypeError(\"`allowEmptyArrays` option can only be `true` or `false`, when provided\");if(void 0!==t.decodeDotInKeys&&\"boolean\"!=typeof t.decodeDotInKeys)throw new TypeError(\"`decodeDotInKeys` option can only be `true` or `false`, when provided\");if(null!==t.decoder&&void 0!==t.decoder&&\"function\"!=typeof t.decoder)throw new TypeError(\"Decoder has to be a function.\");if(void 0!==t.charset&&\"utf-8\"!==t.charset&&\"iso-8859-1\"!==t.charset)throw new TypeError(\"The charset option must be either utf-8, iso-8859-1, or undefined\");var e=void 0===t.charset?o.charset:t.charset,r=void 0===t.duplicates?o.duplicates:t.duplicates;if(\"combine\"!==r&&\"first\"!==r&&\"last\"!==r)throw new TypeError(\"The duplicates option must be either combine, first, or last\");return{allowDots:void 0===t.allowDots?!0===t.decodeDotInKeys||o.allowDots:!!t.allowDots,allowEmptyArrays:\"boolean\"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:o.allowEmptyArrays,allowPrototypes:\"boolean\"==typeof t.allowPrototypes?t.allowPrototypes:o.allowPrototypes,allowSparse:\"boolean\"==typeof t.allowSparse?t.allowSparse:o.allowSparse,arrayLimit:\"number\"==typeof t.arrayLimit?t.arrayLimit:o.arrayLimit,charset:e,charsetSentinel:\"boolean\"==typeof t.charsetSentinel?t.charsetSentinel:o.charsetSentinel,comma:\"boolean\"==typeof t.comma?t.comma:o.comma,decodeDotInKeys:\"boolean\"==typeof t.decodeDotInKeys?t.decodeDotInKeys:o.decodeDotInKeys,decoder:\"function\"==typeof t.decoder?t.decoder:o.decoder,delimiter:\"string\"==typeof t.delimiter||i.isRegExp(t.delimiter)?t.delimiter:o.delimiter,depth:\"number\"==typeof t.depth||!1===t.depth?+t.depth:o.depth,duplicates:r,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:\"boolean\"==typeof t.interpretNumericEntities?t.interpretNumericEntities:o.interpretNumericEntities,parameterLimit:\"number\"==typeof t.parameterLimit?t.parameterLimit:o.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:\"boolean\"==typeof t.plainObjects?t.plainObjects:o.plainObjects,strictDepth:\"boolean\"==typeof t.strictDepth?!!t.strictDepth:o.strictDepth,strictNullHandling:\"boolean\"==typeof t.strictNullHandling?t.strictNullHandling:o.strictNullHandling}}(e);if(\"\"===t||null==t)return r.plainObjects?Object.create(null):{};for(var f=\"string\"==typeof t?function(t,e){var r={__proto__:null},u=e.ignoreQueryPrefix?t.replace(/^\\?/,\"\"):t;u=u.replace(/%5B/gi,\"[\").replace(/%5D/gi,\"]\");var f,l=e.parameterLimit===1/0?void 0:e.parameterLimit,c=u.split(e.delimiter,l),d=-1,p=e.charset;if(e.charsetSentinel)for(f=0;f<c.length;++f)0===c[f].indexOf(\"utf8=\")&&(\"utf8=%E2%9C%93\"===c[f]?p=\"utf-8\":\"utf8=%26%2310003%3B\"===c[f]&&(p=\"iso-8859-1\"),d=f,f=c.length);for(f=0;f<c.length;++f)if(f!==d){var m,g,y=c[f],b=y.indexOf(\"]=\"),v=-1===b?y.indexOf(\"=\"):b+1;-1===v?(m=e.decoder(y,o.decoder,p,\"key\"),g=e.strictNullHandling?null:\"\"):(m=e.decoder(y.slice(0,v),o.decoder,p,\"key\"),g=i.maybeMap(h(y.slice(v+1),e),function(t){return e.decoder(t,o.decoder,p,\"value\")})),g&&e.interpretNumericEntities&&\"iso-8859-1\"===p&&(g=a(g)),y.indexOf(\"[]=\")>-1&&(g=s(g)?[g]:g);var w=n.call(r,m);w&&\"combine\"===e.duplicates?r[m]=i.combine(r[m],g):w&&\"last\"!==e.duplicates||(r[m]=g)}return r}(t,r):t,l=r.plainObjects?Object.create(null):{},c=Object.keys(f),d=0;d<c.length;++d){var p=c[d],m=u(p,f[p],r,\"string\"==typeof t);l=i.merge(l,m,r)}return!0===r.allowSparse?l:i.compact(l)}},2682:(t,e,r)=>{var i=r(9600),n=Object.prototype.toString,s=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!i(e))throw new TypeError(\"iterator must be a function\");var o,a;arguments.length>=3&&(o=r),a=t,\"[object Array]\"===n.call(a)?function(t,e,r){for(var i=0,n=t.length;i<n;i++)s.call(t,i)&&(null==r?e(t[i],i,t):e.call(r,t[i],i,t))}(t,e,o):\"string\"==typeof t?function(t,e,r){for(var i=0,n=t.length;i<n;i++)null==r?e(t.charAt(i),i,t):e.call(r,t.charAt(i),i,t)}(t,e,o):function(t,e,r){for(var i in t)s.call(t,i)&&(null==r?e(t[i],i,t):e.call(r,t[i],i,t))}(t,e,o)}},2723:(t,e,r)=>{var i=r(7952),n=r(4367),s=r(3349);function o(t){if(!(this instanceof o))return new o(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=n.toArray(t.entropy,t.entropyEnc||\"hex\"),r=n.toArray(t.nonce,t.nonceEnc||\"hex\"),i=n.toArray(t.pers,t.persEnc||\"hex\");s(e.length>=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._init(e,r,i)}t.exports=o,o.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},o.prototype._hmac=function(){return new i.hmac(this.hash,this.K)},o.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},o.prototype.reseed=function(t,e,r,i){\"string\"!=typeof e&&(i=r,r=e,e=null),t=n.toArray(t,e),r=n.toArray(r,i),s(t.length>=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._update(t.concat(r||[])),this._reseed=1},o.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error(\"Reseed is required\");\"string\"!=typeof e&&(i=r,r=e,e=null),r&&(r=n.toArray(r,i||\"hex\"),this._update(r));for(var s=[];s.length<t;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,t);return this._update(r),this._reseed++,n.encode(o,e)}},2728:(t,e,r)=>{const i=r(5905),n=i.methods,s=i.HTTPParser,o=r(975).FreeList,a=r(3989),h=a.IncomingMessage,u=a.readStart,f=a.readStop,l=r(537).debuglog(\"http\");e.debug=l,e.CRLF=\"\\r\\n\",e.chunkExpression=/chunk/i,e.continueExpression=/100-continue/i,e.methods=n;const c=0|s.kOnHeaders,d=0|s.kOnHeadersComplete,p=0|s.kOnBody,m=0|s.kOnMessageComplete,g=0|s.kOnExecute;function y(t,e){(this.maxHeaderPairs<=0||this._headers.length<this.maxHeaderPairs)&&(this._headers=this._headers.concat(t)),this._url+=e}function b(t,e,r,i,s,o,a,u,f){var l=this;r||(r=l._headers,l._headers=[]),s||(s=l._url,l._url=\"\"),l.incoming=new h(l.socket),l.incoming.httpVersionMajor=t,l.incoming.httpVersionMinor=e,l.incoming.httpVersion=t+\".\"+e,l.incoming.url=s;var c=r.length;l.maxHeaderPairs>0&&(c=Math.min(c,l.maxHeaderPairs)),l.incoming._addHeaderLines(r,c),\"number\"==typeof i?l.incoming.method=n[i]:(l.incoming.statusCode=o,l.incoming.statusMessage=a),!u||null===l.outgoing||void 0!==l.outgoing._headers.upgrade&&/(^|\\W)upgrade(\\W|$)/i.test(l.outgoing._headers.connection)||(u=!1),l.incoming.upgrade=u;var d=0;return u||(d=l.onIncoming(l.incoming,f)),\"number\"!=typeof d?d?1:0:d}function v(t,e,r){var i=this.incoming;if(i){var n=i.socket;if(r>0&&!i._dumped){var s=t.slice(e,e+r);i.push(s)||f(n)}}}function w(){var t=this,e=t.incoming;if(e){e.complete=!0;var r=t._headers;r&&(t.incoming._addHeaderLines(r,r.length),t._headers=[],t._url=\"\"),e.push(null)}u(t.socket)}var _=new o(\"parsers\",1e3,function(){var t=new s(s.REQUEST);return t._headers=[],t._url=\"\",t._consumed=!1,t.socket=null,t.incoming=null,t.outgoing=null,t[c]=y,t[d]=b,t[p]=v,t[m]=w,t[g]=null,t});function M(){this._httpMessage&&this._httpMessage.emit(\"drain\")}function S(t){return t>=94&&t<=122||(t>=65&&t<=90||(45===t||(t>=48&&t<=57||34!==t&&40!==t&&41!==t&&44!==t&&(t>=33&&t<=46||(124===t||126===t)))))}e.parsers=_,e.freeParser=function(t,e,r){t&&(t._headers=[],t.onIncoming=null,t._consumed&&t.unconsume(),t._consumed=!1,t.socket&&(t.socket.parser=null),t.socket=null,t.incoming=null,t.outgoing=null,t[g]=null,!1===_.free(t)&&t.close(),t=null),e&&(e.parser=null),r&&(r.parser=null)},e.httpSocketSetup=function(t){t.removeListener(\"drain\",M),t.on(\"drain\",M)},e._checkIsHttpToken=function(t){if(\"string\"!=typeof t||0===t.length)return!1;if(!S(t.charCodeAt(0)))return!1;const e=t.length;if(e>1){if(!S(t.charCodeAt(1)))return!1;if(e>2){if(!S(t.charCodeAt(2)))return!1;if(e>3){if(!S(t.charCodeAt(3)))return!1;for(var r=4;r<e;r++)if(!S(t.charCodeAt(r)))return!1}}}return!0},e._checkInvalidHeaderChar=function(t){if((t+=\"\").length<1)return!1;var e=t.charCodeAt(0);if(e<=31&&9!==e||e>255||127===e)return!0;if(t.length<2)return!1;if((e=t.charCodeAt(1))<=31&&9!==e||e>255||127===e)return!0;if(t.length<3)return!1;if((e=t.charCodeAt(2))<=31&&9!==e||e>255||127===e)return!0;for(var r=3;r<t.length;++r)if((e=t.charCodeAt(r))<=31&&9!==e||e>255||127===e)return!0;return!1}},2791:function(t,e,r){var i=r(717);!function(t){if(!t.setImmediate){var e,r,n,s,o,a=1,h={},u=!1,f=t.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(t);l=l&&l.setTimeout?l:t,\"[object process]\"==={}.toString.call(t.process)?e=function(t){i.nextTick(function(){d(t)})}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,r=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage(\"\",\"*\"),t.onmessage=r,e}}()?t.MessageChannel?((n=new MessageChannel).port1.onmessage=function(t){d(t.data)},e=function(t){n.port2.postMessage(t)}):f&&\"onreadystatechange\"in f.createElement(\"script\")?(r=f.documentElement,e=function(t){var e=f.createElement(\"script\");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,r.removeChild(e),e=null},r.appendChild(e)}):e=function(t){setTimeout(d,0,t)}:(s=\"setImmediate$\"+Math.random()+\"$\",o=function(e){e.source===t&&\"string\"==typeof e.data&&0===e.data.indexOf(s)&&d(+e.data.slice(s.length))},t.addEventListener?t.addEventListener(\"message\",o,!1):t.attachEvent(\"onmessage\",o),e=function(e){t.postMessage(s+e,\"*\")}),l.setImmediate=function(t){\"function\"!=typeof t&&(t=new Function(\"\"+t));for(var r=new Array(arguments.length-1),i=0;i<r.length;i++)r[i]=arguments[i+1];var n={callback:t,args:r};return h[a]=n,e(a),a++},l.clearImmediate=c}function c(t){delete h[t]}function d(t){if(u)setTimeout(d,0,t);else{var e=h[t];if(e){u=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(void 0,r)}}(e)}finally{c(t),u=!1}}}}}(\"undefined\"==typeof self?\"undefined\"==typeof globalThis?this:globalThis:self)},2801:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"};var f=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],d=c[t];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:f[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\"),this.strip();var o,a,h=\"le\"===e,u=new t(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a<s;a++)u[a]=0}else{for(a=0;a<s-n;a++)u[a]=0;for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[s-a-1]=o}return u},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},g.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),m(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i(\"number\"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a.strip(),i.strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new S(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function w(){b.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function _(){b.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function M(){b.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function k(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,b),n(_,b),n(M,b),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if(\"k256\"===t)e=new v;else if(\"p224\"===t)e=new w;else if(\"p192\"===t)e=new _;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new M}return y[t]=e,e},S.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},S.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new k(t)},n(k,S),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},2802:(t,e,r)=>{t.exports=function(e){var r=e.toLowerCase(),i=t.exports[r];if(!i)throw new Error(r+\" is not supported (we accept pull requests)\");return new i},t.exports.sha=r(7816),t.exports.sha1=r(3737),t.exports.sha224=r(6710),t.exports.sha256=r(4107),t.exports.sha384=r(2827),t.exports.sha512=r(2890)},2808:(t,e,r)=>{var i=r(3349);function n(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=!1!==t.padding}t.exports=n,n.prototype._init=function(){},n.prototype.update=function(t){return 0===t.length?[]:\"decrypt\"===this.type?this._updateDecrypt(t):this._updateEncrypt(t)},n.prototype._buffer=function(t,e){for(var r=Math.min(this.buffer.length-this.bufferOff,t.length-e),i=0;i<r;i++)this.buffer[this.bufferOff+i]=t[e+i];return this.bufferOff+=r,r},n.prototype._flushBuffer=function(t,e){return this._update(this.buffer,0,t,e),this.bufferOff=0,this.blockSize},n.prototype._updateEncrypt=function(t){var e=0,r=0,i=(this.bufferOff+t.length)/this.blockSize|0,n=new Array(i*this.blockSize);0!==this.bufferOff&&(e+=this._buffer(t,e),this.bufferOff===this.buffer.length&&(r+=this._flushBuffer(n,r)));for(var s=t.length-(t.length-e)%this.blockSize;e<s;e+=this.blockSize)this._update(t,e,n,r),r+=this.blockSize;for(;e<t.length;e++,this.bufferOff++)this.buffer[this.bufferOff]=t[e];return n},n.prototype._updateDecrypt=function(t){for(var e=0,r=0,i=Math.ceil((this.bufferOff+t.length)/this.blockSize)-1,n=new Array(i*this.blockSize);i>0;i--)e+=this._buffer(t,e),r+=this._flushBuffer(n,r);return e+=this._buffer(t,e),n},n.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r=\"encrypt\"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},n.prototype._pad=function(t,e){if(0===e)return!1;for(;e<t.length;)t[e++]=0;return!0},n.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var t=new Array(this.blockSize);return this._update(this.buffer,0,t,0),t},n.prototype._unpad=function(t){return t},n.prototype._finalDecrypt=function(){i.equal(this.bufferOff,this.blockSize,\"Not enough data to decrypt\");var t=new Array(this.blockSize);return this._flushBuffer(t,0),this._unpad(t)}},2827:(t,e,r)=>{var i=r(6698),n=r(2890),s=r(392),o=r(2861).Buffer,a=new Array(160);function h(){this.init(),this._w=a,s.call(this,128,112)}i(h,n),h.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},h.prototype._hash=function(){var t=o.allocUnsafe(48);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=h},2853:(t,e,r)=>{var i=e;i.der=r(2010),i.pem=r(8903)},2861:(t,e,r)=>{var i=r(8287),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),o.prototype=Object.create(n.prototype),s(n,o),o.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return n(t,e,r)},o.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var i=n(t);return void 0!==e?\"string\"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n(t)},o.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i.SlowBuffer(t)}},2878:t=>{function e(t,e){return{start:t.start,end:t.end,index:e}}function r(t){return{start:t.start,end:t.end}}function i(t,e){return t.index-e.index}function n(t,e){return t.start-e.start}t.exports=function(t,s,o){if(\"string\"!=typeof s)throw new TypeError(\"argument str must be a string\");var a=s.indexOf(\"=\");if(-1===a)return-2;var h=s.slice(a+1).split(\",\"),u=[];u.type=s.slice(0,a);for(var f=0;f<h.length;f++){var l=h[f].split(\"-\"),c=parseInt(l[0],10),d=parseInt(l[1],10);isNaN(c)?(c=t-d,d=t-1):isNaN(d)&&(d=t-1),d>t-1&&(d=t-1),isNaN(c)||isNaN(d)||c>d||c<0||u.push({start:c,end:d})}if(u.length<1)return-1;return o&&o.combine?function(t){for(var s=t.map(e).sort(n),o=0,a=1;a<s.length;a++){var h=s[a],u=s[o];h.start>u.end+1?s[++o]=h:h.end>u.end&&(u.end=h.end,u.index=Math.min(u.index,h.index))}s.length=o+1;var f=s.sort(i).map(r);return f.type=t.type,f}(u):u}},2884:(t,e,r)=>{var i=r(295);e.encrypt=function(t,e){var r=i(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},e.decrypt=function(t,e){var r=t._prev;t._prev=e;var n=t._cipher.decryptBlock(e);return i(n,r)}},2890:(t,e,r)=>{var i=r(6698),n=r(392),s=r(2861).Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function h(){this.init(),this._w=a,n.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function c(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function m(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0<e>>>0?1:0}i(h,n),h.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},h.prototype._update=function(t){for(var e=this._w,r=0|this._ah,i=0|this._bh,n=0|this._ch,s=0|this._dh,a=0|this._eh,h=0|this._fh,b=0|this._gh,v=0|this._hh,w=0|this._al,_=0|this._bl,M=0|this._cl,S=0|this._dl,k=0|this._el,E=0|this._fl,x=0|this._gl,A=0|this._hl,I=0;I<32;I+=2)e[I]=t.readInt32BE(4*I),e[I+1]=t.readInt32BE(4*I+4);for(;I<160;I+=2){var T=e[I-30],C=e[I-30+1],P=d(T,C),R=p(C,T),O=m(T=e[I-4],C=e[I-4+1]),B=g(C,T),L=e[I-14],N=e[I-14+1],j=e[I-32],U=e[I-32+1],q=R+N|0,D=P+L+y(q,R)|0;D=(D=D+O+y(q=q+B|0,B)|0)+j+y(q=q+U|0,U)|0,e[I]=D,e[I+1]=q}for(var H=0;H<160;H+=2){D=e[H],q=e[H+1];var F=f(r,i,n),z=f(w,_,M),W=l(r,w),$=l(w,r),V=c(a,k),K=c(k,a),Z=o[H],G=o[H+1],Y=u(a,h,b),J=u(k,E,x),X=A+K|0,Q=v+V+y(X,A)|0;Q=(Q=(Q=Q+Y+y(X=X+J|0,J)|0)+Z+y(X=X+G|0,G)|0)+D+y(X=X+q|0,q)|0;var tt=$+z|0,et=W+F+y(tt,$)|0;v=b,A=x,b=h,x=E,h=a,E=k,a=s+Q+y(k=S+X|0,S)|0,s=n,S=M,n=i,M=_,i=r,_=w,r=Q+et+y(w=X+tt|0,X)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+M|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+E|0,this._gl=this._gl+x|0,this._hl=this._hl+A|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+i+y(this._bl,_)|0,this._ch=this._ch+n+y(this._cl,M)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+h+y(this._fl,E)|0,this._gh=this._gh+b+y(this._gl,x)|0,this._hh=this._hh+v+y(this._hl,A)|0},h.prototype._hash=function(){var t=s.allocUnsafe(64);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=h},2951:t=>{t.exports=JSON.parse('{\"sha224WithRSAEncryption\":{\"sign\":\"rsa\",\"hash\":\"sha224\",\"id\":\"302d300d06096086480165030402040500041c\"},\"RSA-SHA224\":{\"sign\":\"ecdsa/rsa\",\"hash\":\"sha224\",\"id\":\"302d300d06096086480165030402040500041c\"},\"sha256WithRSAEncryption\":{\"sign\":\"rsa\",\"hash\":\"sha256\",\"id\":\"3031300d060960864801650304020105000420\"},\"RSA-SHA256\":{\"sign\":\"ecdsa/rsa\",\"hash\":\"sha256\",\"id\":\"3031300d060960864801650304020105000420\"},\"sha384WithRSAEncryption\":{\"sign\":\"rsa\",\"hash\":\"sha384\",\"id\":\"3041300d060960864801650304020205000430\"},\"RSA-SHA384\":{\"sign\":\"ecdsa/rsa\",\"hash\":\"sha384\",\"id\":\"3041300d060960864801650304020205000430\"},\"sha512WithRSAEncryption\":{\"sign\":\"rsa\",\"hash\":\"sha512\",\"id\":\"3051300d060960864801650304020305000440\"},\"RSA-SHA512\":{\"sign\":\"ecdsa/rsa\",\"hash\":\"sha512\",\"id\":\"3051300d060960864801650304020305000440\"},\"RSA-SHA1\":{\"sign\":\"rsa\",\"hash\":\"sha1\",\"id\":\"3021300906052b0e03021a05000414\"},\"ecdsa-with-SHA1\":{\"sign\":\"ecdsa\",\"hash\":\"sha1\",\"id\":\"\"},\"sha256\":{\"sign\":\"ecdsa\",\"hash\":\"sha256\",\"id\":\"\"},\"sha224\":{\"sign\":\"ecdsa\",\"hash\":\"sha224\",\"id\":\"\"},\"sha384\":{\"sign\":\"ecdsa\",\"hash\":\"sha384\",\"id\":\"\"},\"sha512\":{\"sign\":\"ecdsa\",\"hash\":\"sha512\",\"id\":\"\"},\"DSA-SHA\":{\"sign\":\"dsa\",\"hash\":\"sha1\",\"id\":\"\"},\"DSA-SHA1\":{\"sign\":\"dsa\",\"hash\":\"sha1\",\"id\":\"\"},\"DSA\":{\"sign\":\"dsa\",\"hash\":\"sha1\",\"id\":\"\"},\"DSA-WITH-SHA224\":{\"sign\":\"dsa\",\"hash\":\"sha224\",\"id\":\"\"},\"DSA-SHA224\":{\"sign\":\"dsa\",\"hash\":\"sha224\",\"id\":\"\"},\"DSA-WITH-SHA256\":{\"sign\":\"dsa\",\"hash\":\"sha256\",\"id\":\"\"},\"DSA-SHA256\":{\"sign\":\"dsa\",\"hash\":\"sha256\",\"id\":\"\"},\"DSA-WITH-SHA384\":{\"sign\":\"dsa\",\"hash\":\"sha384\",\"id\":\"\"},\"DSA-SHA384\":{\"sign\":\"dsa\",\"hash\":\"sha384\",\"id\":\"\"},\"DSA-WITH-SHA512\":{\"sign\":\"dsa\",\"hash\":\"sha512\",\"id\":\"\"},\"DSA-SHA512\":{\"sign\":\"dsa\",\"hash\":\"sha512\",\"id\":\"\"},\"DSA-RIPEMD160\":{\"sign\":\"dsa\",\"hash\":\"rmd160\",\"id\":\"\"},\"ripemd160WithRSA\":{\"sign\":\"rsa\",\"hash\":\"rmd160\",\"id\":\"3021300906052b2403020105000414\"},\"RSA-RIPEMD160\":{\"sign\":\"rsa\",\"hash\":\"rmd160\",\"id\":\"3021300906052b2403020105000414\"},\"md5WithRSAEncryption\":{\"sign\":\"rsa\",\"hash\":\"md5\",\"id\":\"3020300c06082a864886f70d020505000410\"},\"RSA-MD5\":{\"sign\":\"rsa\",\"hash\":\"md5\",\"id\":\"3020300c06082a864886f70d020505000410\"}}')},2955:(t,e,r)=>{var i,n=r(717);function s(t,e,r){return(e=function(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||\"default\");if(\"object\"!=typeof i)return i;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(6238),a=Symbol(\"lastResolve\"),h=Symbol(\"lastReject\"),u=Symbol(\"error\"),f=Symbol(\"ended\"),l=Symbol(\"lastPromise\"),c=Symbol(\"handlePromise\"),d=Symbol(\"stream\");function p(t,e){return{value:t,done:e}}function m(t){var e=t[a];if(null!==e){var r=t[d].read();null!==r&&(t[l]=null,t[a]=null,t[h]=null,e(p(r,!1)))}}function g(t){n.nextTick(m,t)}var y=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((i={get stream(){return this[d]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise(function(e,r){n.nextTick(function(){t[u]?r(t[u]):e(p(void 0,!0))})});var r,i=this[l];if(i)r=new Promise(function(t,e){return function(r,i){t.then(function(){e[f]?r(p(void 0,!0)):e[c](r,i)},i)}}(i,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(p(s,!1));r=new Promise(this[c])}return this[l]=r,r}},s(i,Symbol.asyncIterator,function(){return this}),s(i,\"return\",function(){var t=this;return new Promise(function(e,r){t[d].destroy(null,function(t){t?r(t):e(p(void 0,!0))})})}),i),y);t.exports=function(t){var e,r=Object.create(b,(s(e={},d,{value:t,writable:!0}),s(e,a,{value:null,writable:!0}),s(e,h,{value:null,writable:!0}),s(e,u,{value:null,writable:!0}),s(e,f,{value:t._readableState.endEmitted,writable:!0}),s(e,c,{value:function(t,e){var i=r[d].read();i?(r[l]=null,r[a]=null,r[h]=null,t(p(i,!1))):(r[a]=t,r[h]=e)},writable:!0}),e));return r[l]=null,o(t,function(t){if(t&&\"ERR_STREAM_PREMATURE_CLOSE\"!==t.code){var e=r[h];return null!==e&&(r[l]=null,r[a]=null,r[h]=null,e(t)),void(r[u]=t)}var i=r[a];null!==i&&(r[l]=null,r[a]=null,r[h]=null,i(p(void 0,!0))),r[f]=!0}),t.on(\"readable\",g.bind(null,r)),r}},3033:(t,e,r)=>{function i(t){return(t>>3)+Number(t%8!=0)}r.d(e,{A:()=>n});class n{get length(){return this.buffer.length<<3}constructor(t=0,e){const r=null==e?void 0:e.grow;this.grow=r?Number.isFinite(r)?i(r):r:0,this.buffer=\"number\"==typeof t?new Uint8Array(i(t)):t}get(t){const e=t>>3;return e<this.buffer.length&&!!(this.buffer[e]&128>>t%8)}set(t,e=!0){const r=t>>3;if(e){if(r>=this.buffer.length){const t=Math.max(r+1,Math.min(2*this.buffer.length,this.grow));if(t<=this.grow){const e=new Uint8Array(t);e.set(this.buffer),this.buffer=e}}this.buffer[r]|=128>>t%8}else r<this.buffer.length&&(this.buffer[r]&=~(128>>t%8))}setAll(t,e=0){const r=Math.min(i(e+t.length),this.grow);if(this.buffer.length<r){const t=new Uint8Array(r);t.set(this.buffer),this.buffer=t}let n=e>>3,s=128>>e%8;for(let e=0;e<t.length;e++)if(t[e]?this.buffer[n]|=s:this.buffer[n]&=~s,1===s){if(n+=1,n>=this.buffer.length)break;s=128}else s>>=1}forEach(t,e=0,r=8*this.buffer.length){let i=e>>3,n=128>>e%8;for(let s=e;s<r;s++)t(!!(this.buffer[i]&n),s),1===n?(i+=1,n=128):n>>=1}isEmpty(){for(let t=0;t<this.buffer.length;t++)if(0!==this.buffer[t])return!1;return!0}}},3053:(t,e,r)=>{var i=r(295),n=r(2861).Buffer,s=r(5122);function o(t){var e=t._cipher.encryptBlockRaw(t._prev);return s(t._prev),e}e.encrypt=function(t,e){var r=Math.ceil(e.length/16),s=t._cache.length;t._cache=n.concat([t._cache,n.allocUnsafe(16*r)]);for(var a=0;a<r;a++){var h=o(t),u=s+16*a;t._cache.writeUInt32BE(h[0],u+0),t._cache.writeUInt32BE(h[1],u+4),t._cache.writeUInt32BE(h[2],u+8),t._cache.writeUInt32BE(h[3],u+12)}var f=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),i(e,f)}},3065:(t,e,r)=>{var i=r(717),n=r(5472),s=r(3085),o=function(t,e,r){this.tokenBucket=new n(t,t,e,null),this.tokenBucket.content=t,this.curIntervalStart=s(),this.tokensThisInterval=0,this.fireImmediately=r};o.prototype={tokenBucket:null,curIntervalStart:0,tokensThisInterval:0,fireImmediately:!1,removeTokens:function(t,e){if(t>this.tokenBucket.bucketSize)return i.nextTick(e.bind(null,\"Requested tokens \"+t+\" exceeds maximum tokens per interval \"+this.tokenBucket.bucketSize,null)),!1;var r=this,n=s();if((n<this.curIntervalStart||n-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=n,this.tokensThisInterval=0),t>this.tokenBucket.tokensPerInterval-this.tokensThisInterval){if(this.fireImmediately)i.nextTick(e.bind(null,null,-1));else{var o=Math.ceil(this.curIntervalStart+this.tokenBucket.interval-n);setTimeout(function(){r.tokenBucket.removeTokens(t,a)},o)}return!1}return this.tokenBucket.removeTokens(t,a);function a(i,n){if(i)return e(i,null);r.tokensThisInterval+=t,e(null,n)}},tryRemoveTokens:function(t){if(t>this.tokenBucket.bucketSize)return!1;var e=s();if((e<this.curIntervalStart||e-this.curIntervalStart>=this.tokenBucket.interval)&&(this.curIntervalStart=e,this.tokensThisInterval=0),t>this.tokenBucket.tokensPerInterval-this.tokensThisInterval)return!1;var r=this.tokenBucket.tryRemoveTokens(t);return r&&(this.tokensThisInterval+=t),r},getTokensRemaining:function(){return this.tokenBucket.drip(),this.tokenBucket.content}},t.exports=o},3085:(t,e,r)=>{var i=r(717);t.exports=function(){if(void 0!==i&&i.hrtime){var t=i.hrtime(),e=t[0],r=t[1];return 1e3*e+Math.floor(r/1e6)}return(new Date).getTime()}},3093:(t,e,r)=>{var i=r(4459);t.exports=function(t){return i(t)||0===t?t:t<0?-1:1}},3126:(t,e,r)=>{var i=r(6743),n=r(9675),s=r(76),o=r(3144);t.exports=function(t){if(t.length<1||\"function\"!=typeof t[0])throw new n(\"a function is required\");return o(i,s,t)}},3141:(t,e,r)=>{var i=r(2861).Buffer,n=i.isEncoding||function(t){switch((t=\"\"+t)&&t.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 s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){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 t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=h,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=l,e=3;break;default:return this.write=c,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):\"\"}e.I=s,s.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||\"\"},s.prototype.end=function(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+\"�\":e},s.prototype.text=function(t,e){var r=function(t,e,r){var i=e.length-1;if(i<r)return 0;var n=o(e[i]);if(n>=0)return n>0&&(t.lastNeed=n-1),n;if(--i<r||-2===n)return 0;if(n=o(e[i]),n>=0)return n>0&&(t.lastNeed=n-2),n;if(--i<r||-2===n)return 0;if(n=o(e[i]),n>=0)return n>0&&(2===n?n=0:t.lastNeed=n-3),n;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString(\"utf8\",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},3144:(t,e,r)=>{var i=r(6743),n=r(1002),s=r(76),o=r(7119);t.exports=o||i.call(s,n)},3208:()=>{},3209:(t,e,r)=>{var i=r(717),n=65536,s=4294967295;var o=r(2861).Buffer,a=globalThis.crypto||globalThis.msCrypto;a&&a.getRandomValues?t.exports=function(t,e){if(t>s)throw new RangeError(\"requested too many random bytes\");var r=o.allocUnsafe(t);if(t>0)if(t>n)for(var h=0;h<t;h+=n)a.getRandomValues(r.slice(h,h+n));else a.getRandomValues(r);if(\"function\"==typeof e)return i.nextTick(function(){e(null,r)});return r}:t.exports=function(){throw new Error(\"Secure random number generation is not supported by this browser.\\nUse Chrome, Firefox or Internet Explorer 11\")}},3219:t=>{t.exports=JSON.parse('{\"aes-128-ecb\":{\"cipher\":\"AES\",\"key\":128,\"iv\":0,\"mode\":\"ECB\",\"type\":\"block\"},\"aes-192-ecb\":{\"cipher\":\"AES\",\"key\":192,\"iv\":0,\"mode\":\"ECB\",\"type\":\"block\"},\"aes-256-ecb\":{\"cipher\":\"AES\",\"key\":256,\"iv\":0,\"mode\":\"ECB\",\"type\":\"block\"},\"aes-128-cbc\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"CBC\",\"type\":\"block\"},\"aes-192-cbc\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"CBC\",\"type\":\"block\"},\"aes-256-cbc\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"CBC\",\"type\":\"block\"},\"aes128\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"CBC\",\"type\":\"block\"},\"aes192\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"CBC\",\"type\":\"block\"},\"aes256\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"CBC\",\"type\":\"block\"},\"aes-128-cfb\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"CFB\",\"type\":\"stream\"},\"aes-192-cfb\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"CFB\",\"type\":\"stream\"},\"aes-256-cfb\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"CFB\",\"type\":\"stream\"},\"aes-128-cfb8\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"CFB8\",\"type\":\"stream\"},\"aes-192-cfb8\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"CFB8\",\"type\":\"stream\"},\"aes-256-cfb8\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"CFB8\",\"type\":\"stream\"},\"aes-128-cfb1\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"CFB1\",\"type\":\"stream\"},\"aes-192-cfb1\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"CFB1\",\"type\":\"stream\"},\"aes-256-cfb1\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"CFB1\",\"type\":\"stream\"},\"aes-128-ofb\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"OFB\",\"type\":\"stream\"},\"aes-192-ofb\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"OFB\",\"type\":\"stream\"},\"aes-256-ofb\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"OFB\",\"type\":\"stream\"},\"aes-128-ctr\":{\"cipher\":\"AES\",\"key\":128,\"iv\":16,\"mode\":\"CTR\",\"type\":\"stream\"},\"aes-192-ctr\":{\"cipher\":\"AES\",\"key\":192,\"iv\":16,\"mode\":\"CTR\",\"type\":\"stream\"},\"aes-256-ctr\":{\"cipher\":\"AES\",\"key\":256,\"iv\":16,\"mode\":\"CTR\",\"type\":\"stream\"},\"aes-128-gcm\":{\"cipher\":\"AES\",\"key\":128,\"iv\":12,\"mode\":\"GCM\",\"type\":\"auth\"},\"aes-192-gcm\":{\"cipher\":\"AES\",\"key\":192,\"iv\":12,\"mode\":\"GCM\",\"type\":\"auth\"},\"aes-256-gcm\":{\"cipher\":\"AES\",\"key\":256,\"iv\":12,\"mode\":\"GCM\",\"type\":\"auth\"}}')},3225:(t,e,r)=>{var i=r(717);void 0===i||!i.version||0===i.version.indexOf(\"v0.\")||0===i.version.indexOf(\"v1.\")&&0!==i.version.indexOf(\"v1.8.\")?t.exports={nextTick:function(t,e,r,n){if(\"function\"!=typeof t)throw new TypeError('\"callback\" argument must be a function');var s,o,a=arguments.length;switch(a){case 0:case 1:return i.nextTick(t);case 2:return i.nextTick(function(){t.call(null,e)});case 3:return i.nextTick(function(){t.call(null,e,r)});case 4:return i.nextTick(function(){t.call(null,e,r,n)});default:for(s=new Array(a-1),o=0;o<s.length;)s[o++]=arguments[o];return i.nextTick(function(){t.apply(null,s)})}}}:t.exports=i},3241:t=>{t.exports=JSON.parse('{\"modp1\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff\"},\"modp2\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff\"},\"modp5\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff\"},\"modp14\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff\"},\"modp15\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff\"},\"modp16\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff\"},\"modp17\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff\"},\"modp18\":{\"gen\":\"02\",\"prime\":\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff\"}}')},3278:()=>{},3349:t=>{function e(t,e){if(!t)throw new Error(e||\"Assertion failed\")}t.exports=e,e.equal=function(t,e,r){if(t!=e)throw new Error(r||\"Assertion failed: \"+t+\" != \"+e)}},3382:(t,e,r)=>{var i=r(2861).Buffer,n=r(5377),s=\"undefined\"!=typeof Uint8Array,o=s&&\"undefined\"!=typeof ArrayBuffer&&ArrayBuffer.isView;t.exports=function(t,e,r){if(\"string\"==typeof t||i.isBuffer(t)||s&&t instanceof Uint8Array||o&&o(t))return n(t,e);throw new TypeError(r+\" must be a string, a Buffer, a Uint8Array, or a DataView\")}},3389:(t,e,r)=>{var i=r(3349),n=r(6698),s={};function o(t){i.equal(t.length,8,\"Invalid IV length\"),this.iv=new Array(8);for(var e=0;e<this.iv.length;e++)this.iv[e]=t[e]}e.instantiate=function(t){function e(e){t.call(this,e),this._cbcInit()}n(e,t);for(var r=Object.keys(s),i=0;i<r.length;i++){var o=r[i];e.prototype[o]=s[o]}return e.create=function(t){return new e(t)},e},s._cbcInit=function(){var t=new o(this.options.iv);this._cbcState=t},s._update=function(t,e,r,i){var n=this._cbcState,s=this.constructor.super_.prototype,o=n.iv;if(\"encrypt\"===this.type){for(var a=0;a<this.blockSize;a++)o[a]^=t[e+a];s._update.call(this,o,0,r,i);for(a=0;a<this.blockSize;a++)o[a]=r[i+a]}else{s._update.call(this,t,e,r,i);for(a=0;a<this.blockSize;a++)r[i+a]^=o[a];for(a=0;a<this.blockSize;a++)o[a]=t[e+a]}}},3392:(t,e,r)=>{var i=r(8287),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),s(n,o),o.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return n(t,e,r)},o.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var i=n(t);return void 0!==e?\"string\"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n(t)},o.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i.SlowBuffer(t)}},3468:()=>{\"undefined\"!=typeof ReadableStream&&(ReadableStream.prototype[Symbol.asyncIterator]||(ReadableStream.prototype[Symbol.asyncIterator]=function({preventCancel:t}={}){const e=this.getReader(),r=this;let i=e.read();return{next(){const t=i;return i=e.read(),t},return:async n=>(await i,e.releaseLock(),t||r.cancel(),{done:!0,value:n}),async throw(t){throw await this.return(),t},[Symbol.asyncIterator](){return this}}}),ReadableStream.prototype.getIterator||(ReadableStream.prototype.getIterator=function({preventCancel:t}={}){return this[Symbol.asyncIterator]({preventCancel:t})}))},3507:(t,e,r)=>{var i=r(6698),n=r(1800),s=r(6168),o=r(2861).Buffer,a=r(320),h=r(6011),u=r(2802),f=o.alloc(128);function l(t,e){s.call(this,\"digest\"),\"string\"==typeof e&&(e=o.from(e));var r=\"sha512\"===t||\"sha384\"===t?128:64;(this._alg=t,this._key=e,e.length>r)?e=(\"rmd160\"===t?new h:u(t)).update(e).digest():e.length<r&&(e=o.concat([e,f],r));for(var i=this._ipad=o.allocUnsafe(r),n=this._opad=o.allocUnsafe(r),a=0;a<r;a++)i[a]=54^e[a],n[a]=92^e[a];this._hash=\"rmd160\"===t?new h:u(t),this._hash.update(i)}i(l,s),l.prototype._update=function(t){this._hash.update(t)},l.prototype._final=function(){var t=this._hash.digest();return(\"rmd160\"===this._alg?new h:u(this._alg)).update(this._opad).update(t).digest()},t.exports=function(t,e){return\"rmd160\"===(t=t.toLowerCase())||\"ripemd160\"===t?new l(\"rmd160\",e):\"md5\"===t?new n(a,e):new l(t,e)}},3519:(t,e,r)=>{var i=r(6587);function n(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function s(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||\"Function wrapped with `once`\";return e.onceError=r+\" shouldn't be called more than once\",e.called=!1,e}t.exports=i(n),t.exports.strict=i(s),n.proto=n(function(){Object.defineProperty(Function.prototype,\"once\",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,\"onceStrict\",{value:function(){return s(this)},configurable:!0})})},3549:()=>{},3600:(t,e,r)=>{t.exports=n;var i=r(4610);function n(t){if(!(this instanceof n))return new n(t);i.call(this,t)}r(6698)(n,i),n.prototype._transform=function(t,e,r){r(null,t)}},3628:(t,e,r)=>{var i=r(8648),n=r(1064),s=r(7176);t.exports=i?function(t){return i(t)}:n?function(t){if(!t||\"object\"!=typeof t&&\"function\"!=typeof t)throw new TypeError(\"getProto: not an object\");return n(t)}:s?function(t){return s(t)}:null},3714:(t,e,r)=>{const i=r(9596);t.exports=class{constructor(t){if(this.store=t,this.chunkLength=t.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error(\"First argument must be abstract-chunk-store compliant\");this.mem=[]}put(t,e,r=()=>{}){this.mem[t]=e,this.store.put(t,e,e=>{this.mem[t]=null,r(e)})}get(t,e,r=()=>{}){if(\"function\"==typeof e)return this.get(t,null,e);let n=this.mem[t];if(!n)return this.store.get(t,e,r);e||(e={});const s=e.offset||0,o=e.length||n.length-s;0===s&&o===n.length||(n=n.slice(s,o+s)),i(()=>r(null,n))}close(t=()=>{}){this.store.close(t)}destroy(t=()=>{}){this.store.destroy(t)}}},3737:(t,e,r)=>{var i=r(6698),n=r(392),s=r(2861).Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function h(){this.init(),this._w=a,n.call(this,64,56)}function u(t){return t<<1|t>>>31}function f(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function c(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}i(h,n),h.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},h.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,s=0|this._d,a=0|this._e,h=0;h<16;++h)e[h]=t.readInt32BE(4*h);for(;h<80;++h)e[h]=u(e[h-3]^e[h-8]^e[h-14]^e[h-16]);for(var d=0;d<80;++d){var p=~~(d/20),m=f(r)+c(p,i,n,s)+a+e[d]+o[p]|0;a=s,s=n,n=l(i),i=r,r=m}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0},h.prototype._hash=function(){var t=s.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=h},3828:(t,e,r)=>{var i=r(717),n=r(8310);\"disable\"===i.env.READABLE_STREAM&&n?(t.exports=n,(e=t.exports=n.Readable).Readable=n.Readable,e.Writable=n.Writable,e.Duplex=n.Duplex,e.Transform=n.Transform,e.PassThrough=n.PassThrough,e.Stream=n):((e=t.exports=r(1706)).Stream=n||e,e.Readable=e,e.Writable=r(2398),e.Duplex=r(308),e.Transform=r(5972),e.PassThrough=r(8158))},3832:(t,e,r)=>{var i,n,s=r(2861).Buffer,o=r(4196),a=r(2455),h=r(681),u=r(3382),f=globalThis.crypto&&globalThis.crypto.subtle,l={sha:\"SHA-1\",\"sha-1\":\"SHA-1\",sha1:\"SHA-1\",sha256:\"SHA-256\",\"sha-256\":\"SHA-256\",sha384:\"SHA-384\",\"sha-384\":\"SHA-384\",\"sha-512\":\"SHA-512\",sha512:\"SHA-512\"},c=[];function d(){return n||(n=globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.queueMicrotask?globalThis.queueMicrotask:globalThis.setImmediate?globalThis.setImmediate:globalThis.setTimeout)}function p(t,e,r,i,n){return f.importKey(\"raw\",t,{name:\"PBKDF2\"},!1,[\"deriveBits\"]).then(function(t){return f.deriveBits({name:\"PBKDF2\",salt:e,iterations:r,hash:{name:n}},t,i<<3)}).then(function(t){return s.from(t)})}t.exports=function(t,e,r,n,m,g){if(\"function\"==typeof m&&(g=m,m=void 0),o(r,n),t=u(t,a,\"Password\"),e=u(e,a,\"Salt\"),\"function\"!=typeof g)throw new Error(\"No callback provided to pbkdf2\");var y=l[(m=m||\"sha1\").toLowerCase()];y&&\"function\"==typeof globalThis.Promise?function(t,e){t.then(function(t){d()(function(){e(null,t)})},function(t){d()(function(){e(t)})})}(function(t){if(globalThis.process&&!globalThis.process.browser)return Promise.resolve(!1);if(!f||!f.importKey||!f.deriveBits)return Promise.resolve(!1);if(void 0!==c[t])return c[t];var e=p(i=i||s.alloc(8),i,10,128,t).then(function(){return!0},function(){return!1});return c[t]=e,e}(y).then(function(i){return i?p(t,e,r,n,y):h(t,e,r,n,m)}),g):d()(function(){var i;try{i=h(t,e,r,n,m)}catch(t){return void g(t)}g(null,i)})}},3917:(t,e,r)=>{var i=r(7426),n=r(6166),s=r(6225),o=i.rotl32,a=i.sum32,h=i.sum32_5,u=s.ft_1,f=n.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function c(){if(!(this instanceof c))return new c;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(c,f),t.exports=c,c.blockSize=512,c.outSize=160,c.hmacStrength=80,c.padLength=64,c.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=o(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],s=this.h[1],f=this.h[2],c=this.h[3],d=this.h[4];for(i=0;i<r.length;i++){var p=~~(i/20),m=h(o(n,5),u(p,s,f,c),d,r[i],l[p]);d=c,c=f,f=o(s,30),s=n,n=m}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],s),this.h[2]=a(this.h[2],f),this.h[3]=a(this.h[3],c),this.h[4]=a(this.h[4],d)},c.prototype._digest=function(t){return\"hex\"===t?i.toHex32(this.h,\"big\"):i.split32(this.h,\"big\")}},3989:(t,e,r)=>{const i=r(537),n=r(8310);function s(t){t&&!t._paused&&t.readable&&t.resume()}function o(t){n.Readable.call(this),this._readableState.readingMore=!0,this.socket=t,this.connection=t,this.httpVersionMajor=null,this.httpVersionMinor=null,this.httpVersion=null,this.complete=!1,this.headers={},this.rawHeaders=[],this.trailers={},this.rawTrailers=[],this.readable=!0,this.upgrade=null,this.url=\"\",this.method=null,this.statusCode=null,this.statusMessage=null,this.client=t,this._consuming=!1,this._dumped=!1}e.readStart=s,e.readStop=function(t){t&&t.pause()},i.inherits(o,n.Readable),e.IncomingMessage=o,o.prototype.setTimeout=function(t,e){return e&&this.on(\"timeout\",e),this.socket.setTimeout(t),this},o.prototype.read=function(t){return this._consuming||(this._readableState.readingMore=!1),this._consuming=!0,this.read=n.Readable.prototype.read,this.read(t)},o.prototype._read=function(t){this.socket.readable&&s(this.socket)},o.prototype.destroy=function(t){this.socket&&this.socket.destroy(t)},o.prototype._addHeaderLines=function(t,e){if(t&&t.length){var r,i;this.complete?(r=this.rawTrailers,i=this.trailers):(r=this.rawHeaders,i=this.headers);for(var n=0;n<e;n+=2){var s=t[n],o=t[n+1];r.push(s),r.push(o),this._addHeaderLine(s,o,i)}}},o.prototype._addHeaderLine=function(t,e,r){switch(t=t.toLowerCase()){case\"set-cookie\":void 0!==r[t]?r[t].push(e):r[t]=[e];break;case\"content-type\":case\"content-length\":case\"user-agent\":case\"referer\":case\"host\":case\"authorization\":case\"proxy-authorization\":case\"if-modified-since\":case\"if-unmodified-since\":case\"from\":case\"location\":case\"max-forwards\":case\"retry-after\":case\"etag\":case\"last-modified\":case\"server\":case\"age\":case\"expires\":void 0===r[t]&&(r[t]=e);break;default:\"string\"==typeof r[t]?r[t]+=\", \"+e:r[t]=e}},o.prototype._dump=function(){this._dumped||(this._dumped=!0,this.resume())}},4011:t=>{t.exports={doubles:{step:4,points:[[\"e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a\",\"f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821\"],[\"8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508\",\"11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf\"],[\"175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739\",\"d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695\"],[\"363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640\",\"4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9\"],[\"8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c\",\"4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36\"],[\"723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda\",\"96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f\"],[\"eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa\",\"5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999\"],[\"100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0\",\"cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09\"],[\"e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d\",\"9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d\"],[\"feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d\",\"e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088\"],[\"da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1\",\"9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d\"],[\"53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0\",\"5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8\"],[\"8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047\",\"10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a\"],[\"385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862\",\"283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453\"],[\"6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7\",\"7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160\"],[\"3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd\",\"56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0\"],[\"85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83\",\"7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6\"],[\"948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a\",\"53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589\"],[\"6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8\",\"bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17\"],[\"e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d\",\"4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda\"],[\"e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725\",\"7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd\"],[\"213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754\",\"4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2\"],[\"4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c\",\"17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6\"],[\"fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6\",\"6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f\"],[\"76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39\",\"c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01\"],[\"c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891\",\"893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3\"],[\"d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b\",\"febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f\"],[\"b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03\",\"2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7\"],[\"e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d\",\"eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78\"],[\"a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070\",\"7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1\"],[\"90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4\",\"e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150\"],[\"8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da\",\"662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82\"],[\"e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11\",\"1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc\"],[\"8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e\",\"efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b\"],[\"e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41\",\"2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51\"],[\"b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef\",\"67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45\"],[\"d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8\",\"db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120\"],[\"324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d\",\"648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84\"],[\"4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96\",\"35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d\"],[\"9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd\",\"ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d\"],[\"6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5\",\"9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8\"],[\"a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266\",\"40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8\"],[\"7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71\",\"34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac\"],[\"928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac\",\"c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f\"],[\"85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751\",\"1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962\"],[\"ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e\",\"493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907\"],[\"827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241\",\"c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec\"],[\"eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3\",\"be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d\"],[\"e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f\",\"4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414\"],[\"1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19\",\"aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd\"],[\"146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be\",\"b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0\"],[\"fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9\",\"6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811\"],[\"da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2\",\"8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1\"],[\"a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13\",\"7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c\"],[\"174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c\",\"ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73\"],[\"959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba\",\"2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd\"],[\"d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151\",\"e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405\"],[\"64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073\",\"d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589\"],[\"8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458\",\"38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e\"],[\"13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b\",\"69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27\"],[\"bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366\",\"d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1\"],[\"8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa\",\"40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482\"],[\"8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0\",\"620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945\"],[\"dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787\",\"7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573\"],[\"f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e\",\"ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82\"]]},naf:{wnd:7,points:[[\"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9\",\"388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672\"],[\"2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4\",\"d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6\"],[\"5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc\",\"6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da\"],[\"acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe\",\"cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37\"],[\"774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb\",\"d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b\"],[\"f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8\",\"ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81\"],[\"d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e\",\"581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58\"],[\"defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34\",\"4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77\"],[\"2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c\",\"85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a\"],[\"352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5\",\"321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c\"],[\"2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f\",\"2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67\"],[\"9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714\",\"73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402\"],[\"daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729\",\"a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55\"],[\"c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db\",\"2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482\"],[\"6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4\",\"e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82\"],[\"1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5\",\"b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396\"],[\"605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479\",\"2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49\"],[\"62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d\",\"80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf\"],[\"80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f\",\"1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a\"],[\"7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb\",\"d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7\"],[\"d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9\",\"eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933\"],[\"49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963\",\"758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a\"],[\"77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74\",\"958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6\"],[\"f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530\",\"e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37\"],[\"463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b\",\"5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e\"],[\"f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247\",\"cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6\"],[\"caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1\",\"cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476\"],[\"2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120\",\"4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40\"],[\"7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435\",\"91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61\"],[\"754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18\",\"673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683\"],[\"e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8\",\"59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5\"],[\"186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb\",\"3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b\"],[\"df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f\",\"55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417\"],[\"5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143\",\"efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868\"],[\"290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba\",\"e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a\"],[\"af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45\",\"f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6\"],[\"766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a\",\"744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996\"],[\"59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e\",\"c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e\"],[\"f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8\",\"e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d\"],[\"7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c\",\"30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2\"],[\"948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519\",\"e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e\"],[\"7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab\",\"100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437\"],[\"3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca\",\"ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311\"],[\"d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf\",\"8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4\"],[\"1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610\",\"68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575\"],[\"733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4\",\"f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d\"],[\"15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c\",\"d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d\"],[\"a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940\",\"edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629\"],[\"e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980\",\"a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06\"],[\"311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3\",\"66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374\"],[\"34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf\",\"9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee\"],[\"f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63\",\"4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1\"],[\"d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448\",\"fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b\"],[\"32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf\",\"5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661\"],[\"7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5\",\"8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6\"],[\"ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6\",\"8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e\"],[\"16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5\",\"5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d\"],[\"eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99\",\"f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc\"],[\"78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51\",\"f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4\"],[\"494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5\",\"42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c\"],[\"a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5\",\"204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b\"],[\"c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997\",\"4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913\"],[\"841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881\",\"73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154\"],[\"5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5\",\"39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865\"],[\"36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66\",\"d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc\"],[\"336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726\",\"ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224\"],[\"8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede\",\"6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e\"],[\"1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94\",\"60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6\"],[\"85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31\",\"3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511\"],[\"29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51\",\"b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b\"],[\"a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252\",\"ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2\"],[\"4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5\",\"cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c\"],[\"d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b\",\"6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3\"],[\"ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4\",\"322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d\"],[\"af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f\",\"6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700\"],[\"e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889\",\"2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4\"],[\"591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246\",\"b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196\"],[\"11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984\",\"998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4\"],[\"3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a\",\"b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257\"],[\"cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030\",\"bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13\"],[\"c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197\",\"6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096\"],[\"c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593\",\"c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38\"],[\"a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef\",\"21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f\"],[\"347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38\",\"60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448\"],[\"da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a\",\"49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a\"],[\"c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111\",\"5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4\"],[\"4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502\",\"7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437\"],[\"3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea\",\"be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7\"],[\"cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26\",\"8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d\"],[\"b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986\",\"39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a\"],[\"d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e\",\"62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54\"],[\"48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4\",\"25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77\"],[\"dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda\",\"ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517\"],[\"6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859\",\"cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10\"],[\"e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f\",\"f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125\"],[\"eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c\",\"6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e\"],[\"13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942\",\"fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1\"],[\"ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a\",\"1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2\"],[\"b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80\",\"5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423\"],[\"ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d\",\"438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8\"],[\"8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1\",\"cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758\"],[\"52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63\",\"c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375\"],[\"e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352\",\"6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d\"],[\"7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193\",\"ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec\"],[\"5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00\",\"9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0\"],[\"32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58\",\"ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c\"],[\"e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7\",\"d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4\"],[\"8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8\",\"c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f\"],[\"4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e\",\"67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649\"],[\"3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d\",\"cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826\"],[\"674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b\",\"299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5\"],[\"d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f\",\"f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87\"],[\"30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6\",\"462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b\"],[\"be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297\",\"62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc\"],[\"93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a\",\"7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c\"],[\"b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c\",\"ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f\"],[\"d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52\",\"4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a\"],[\"d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb\",\"bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46\"],[\"463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065\",\"bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f\"],[\"7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917\",\"603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03\"],[\"74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9\",\"cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08\"],[\"30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3\",\"553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8\"],[\"9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57\",\"712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373\"],[\"176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66\",\"ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3\"],[\"75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8\",\"9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8\"],[\"809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721\",\"9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1\"],[\"1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180\",\"4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9\"]]}}},4018:t=>{t.exports=function(){for(var t=navigator.hardwareConcurrency||1,e=[],r=0;r<t;r++)e.push({model:\"\",speed:0,times:{user:0,nice:0,sys:0,idle:0,irq:0}});return e}},4039:(t,e,r)=>{var i=\"undefined\"!=typeof Symbol&&Symbol,n=r(1333);t.exports=function(){return\"function\"==typeof i&&(\"function\"==typeof Symbol&&(\"symbol\"==typeof i(\"foo\")&&(\"symbol\"==typeof Symbol(\"bar\")&&n())))}},4050:(t,e,r)=>{var i=r(6168),n=r(9560),s=r(6698),o=r(2861).Buffer,a={\"des-ede3-cbc\":n.CBC.instantiate(n.EDE),\"des-ede3\":n.EDE,\"des-ede-cbc\":n.CBC.instantiate(n.EDE),\"des-ede\":n.EDE,\"des-cbc\":n.CBC.instantiate(n.DES),\"des-ecb\":n.DES};function h(t){i.call(this);var e,r=t.mode.toLowerCase(),n=a[r];e=t.decrypt?\"decrypt\":\"encrypt\";var s=t.key;o.isBuffer(s)||(s=o.from(s)),\"des-ede\"!==r&&\"des-ede-cbc\"!==r||(s=o.concat([s,s.slice(0,8)]));var h=t.iv;o.isBuffer(h)||(h=o.from(h)),this._des=n.create({key:s,iv:h,type:e})}a.des=a[\"des-cbc\"],a.des3=a[\"des-ede3-cbc\"],t.exports=h,s(h,i),h.prototype._update=function(t){return o.from(this._des.update(t))},h.prototype._final=function(){return o.from(this._des.final())}},4101:(t,e,r)=>{var i=/Proc-Type: 4,ENCRYPTED[\\n\\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\\n\\r]+([0-9A-z\\n\\r+/=]+)[\\n\\r]+/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,s=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\\n\\r+/=]+)-----END \\1-----$/m,o=r(8078),a=r(1241),h=r(2861).Buffer;t.exports=function(t,e){var r,u=t.toString(),f=u.match(i);if(f){var l=\"aes\"+f[1],c=h.from(f[2],\"hex\"),d=h.from(f[3].replace(/[\\r\\n]/g,\"\"),\"base64\"),p=o(e,c.slice(0,8),parseInt(f[1],10)).key,m=[],g=a.createDecipheriv(l,p,c);m.push(g.update(d)),m.push(g.final()),r=h.concat(m)}else{var y=u.match(s);r=h.from(y[2].replace(/[\\r\\n]/g,\"\"),\"base64\")}return{tag:u.match(n)[1],data:r}}},4107:(t,e,r)=>{var i=r(6698),n=r(392),s=r(2861).Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function h(){this.init(),this._w=a,n.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function c(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function d(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function p(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}i(h,n),h.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},h.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,s=0|this._d,a=0|this._e,h=0|this._f,m=0|this._g,g=0|this._h,y=0;y<16;++y)e[y]=t.readInt32BE(4*y);for(;y<64;++y)e[y]=p(e[y-2])+e[y-7]+d(e[y-15])+e[y-16]|0;for(var b=0;b<64;++b){var v=g+c(a)+u(a,h,m)+o[b]+e[b]|0,w=l(r)+f(r,i,n)|0;g=m,m=h,h=a,a=s+v|0,s=n,n=i,i=r,r=v+w|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0,this._f=h+this._f|0,this._g=m+this._g|0,this._h=g+this._h|0},h.prototype._hash=function(){var t=s.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=h},4116:(t,e,r)=>{var i=r(8287),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),s(n,o),o.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return n(t,e,r)},o.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var i=n(t);return void 0!==e?\"string\"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n(t)},o.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i.SlowBuffer(t)}},4196:t=>{var e=isFinite,r=Math.pow(2,30)-1;t.exports=function(t,i){if(\"number\"!=typeof t)throw new TypeError(\"Iterations not a number\");if(t<0||!e(t))throw new TypeError(\"Bad iterations\");if(\"number\"!=typeof i)throw new TypeError(\"Key length not a number\");if(i<0||i>r||i!=i)throw new TypeError(\"Bad key length\")}},4343:()=>{},4367:(t,e)=>{var r=e;function i(t){return 1===t.length?\"0\"+t:t}function n(t){for(var e=\"\",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(\"string\"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if(\"hex\"===e){(t=t.replace(/[^a-z0-9]+/gi,\"\")).length%2!=0&&(t=\"0\"+t);for(i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(i=0;i<t.length;i++){var n=t.charCodeAt(i),s=n>>8,o=255&n;s?r.push(s,o):r.push(o)}return r},r.zero2=i,r.toHex=n,r.encode=function(t,e){return\"hex\"===e?n(t):t}},4372:(t,e,r)=>{var i=r(9675),n=r(6556)(\"TypedArray.prototype.buffer\",!0),s=r(5680);t.exports=n||function(t){if(!s(t))throw new i(\"Not a Typed Array\");return t.buffer}},4459:t=>{t.exports=Number.isNaN||function(t){return t!=t}},4497:(t,e,r)=>{const i=r(8454),n=r(9596);t.exports=class{constructor(t,e){if(this.store=t,this.chunkLength=t.chunkLength,this.inProgressGets=new Map,!this.store||!this.store.get||!this.store.put)throw new Error(\"First argument must be abstract-chunk-store compliant\");this.cache=new i(e)}put(t,e,r=()=>{}){if(!this.cache)return n(()=>r(new Error(\"CacheStore closed\")));this.cache.remove(t),this.store.put(t,e,r)}get(t,e,r=()=>{}){if(\"function\"==typeof e)return this.get(t,null,e);if(!this.cache)return n(()=>r(new Error(\"CacheStore closed\")));e||(e={});let i=this.cache.get(t);if(i){const t=e.offset||0,s=e.length||i.length-t;return 0===t&&s===i.length||(i=i.slice(t,s+t)),n(()=>r(null,i))}let s=this.inProgressGets.get(t);const o=!!s;s||(s=[],this.inProgressGets.set(t,s)),s.push({opts:e,cb:r}),o||this.store.get(t,(e,r)=>{e||null==this.cache||this.cache.set(t,r);const i=this.inProgressGets.get(t);this.inProgressGets.delete(t);for(const{opts:t,cb:n}of i)if(e)n(e);else{const e=t.offset||0,i=t.length||r.length-e;let s=r;0===e&&i===r.length||(s=r.slice(e,i+e)),n(null,s)}})}close(t=()=>{}){if(!this.cache)return n(()=>t(new Error(\"CacheStore closed\")));this.cache=null,this.store.close(t)}destroy(t=()=>{}){if(!this.cache)return n(()=>t(new Error(\"CacheStore closed\")));this.cache=null,this.store.destroy(t)}}},4529:(t,e,r)=>{var i=r(9133)();function n(t,e){if(t===e)return 0;for(var r=t.length,i=e.length,n=0,s=Math.min(r,i);n<s;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0}function s(t){return globalThis.Buffer&&\"function\"==typeof globalThis.Buffer.isBuffer?globalThis.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var o=r(537),a=Object.prototype.hasOwnProperty,h=Array.prototype.slice,u=\"foo\"===function(){}.name;function f(t){return Object.prototype.toString.call(t)}function l(t){return!s(t)&&(\"function\"==typeof globalThis.ArrayBuffer&&(\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer))))}var c=t.exports=b,d=/\\s*function\\s+([^\\(\\s]*)\\s*/;function p(t){if(o.isFunction(t)){if(u)return t.name;var e=t.toString().match(d);return e&&e[1]}}function m(t,e){return\"string\"==typeof t?t.length<e?t:t.slice(0,e):t}function g(t){if(u||!o.isFunction(t))return o.inspect(t);var e=p(t);return\"[Function\"+(e?\": \"+e:\"\")+\"]\"}function y(t,e,r,i,n){throw new c.AssertionError({message:r,actual:t,expected:e,operator:i,stackStartFunction:n})}function b(t,e){t||y(t,!0,e,\"==\",c.ok)}function v(t,e,r,i){if(t===e)return!0;if(s(t)&&s(e))return 0===n(t,e);if(o.isDate(t)&&o.isDate(e))return t.getTime()===e.getTime();if(o.isRegExp(t)&&o.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&\"object\"==typeof t||null!==e&&\"object\"==typeof e){if(l(t)&&l(e)&&f(t)===f(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===n(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(s(t)!==s(e))return!1;var a=(i=i||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===i.expected.indexOf(e)||(i.actual.push(t),i.expected.push(e),function(t,e,r,i){if(null==t||null==e)return!1;if(o.isPrimitive(t)||o.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var n=w(t),s=w(e);if(n&&!s||!n&&s)return!1;if(n)return v(t=h.call(t),e=h.call(e),r);var a,u,f=S(t),l=S(e);if(f.length!==l.length)return!1;for(f.sort(),l.sort(),u=f.length-1;u>=0;u--)if(f[u]!==l[u])return!1;for(u=f.length-1;u>=0;u--)if(!v(t[a=f[u]],e[a],r,i))return!1;return!0}(t,e,r,i))}return r?t===e:t==e}function w(t){return\"[object Arguments]\"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if(\"[object RegExp]\"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function M(t,e,r,i){var n;if(\"function\"!=typeof e)throw new TypeError('\"block\" argument must be a function');\"string\"==typeof r&&(i=r,r=null),n=function(t){var e;try{t()}catch(t){e=t}return e}(e),i=(r&&r.name?\" (\"+r.name+\").\":\".\")+(i?\" \"+i:\".\"),t&&!n&&y(n,r,\"Missing expected exception\"+i);var s=\"string\"==typeof i,a=!t&&n&&!r;if((!t&&o.isError(n)&&s&&_(n,r)||a)&&y(n,r,\"Got unwanted exception\"+i),t&&n&&r&&!_(n,r)||!t&&n)throw n}c.AssertionError=function(t){this.name=\"AssertionError\",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return m(g(t.actual),128)+\" \"+t.operator+\" \"+m(g(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var i=r.stack,n=p(e),s=i.indexOf(\"\\n\"+n);if(s>=0){var o=i.indexOf(\"\\n\",s+1);i=i.substring(o+1)}this.stack=i}}},o.inherits(c.AssertionError,Error),c.fail=y,c.ok=b,c.equal=function(t,e,r){t!=e&&y(t,e,r,\"==\",c.equal)},c.notEqual=function(t,e,r){t==e&&y(t,e,r,\"!=\",c.notEqual)},c.deepEqual=function(t,e,r){v(t,e,!1)||y(t,e,r,\"deepEqual\",c.deepEqual)},c.deepStrictEqual=function(t,e,r){v(t,e,!0)||y(t,e,r,\"deepStrictEqual\",c.deepStrictEqual)},c.notDeepEqual=function(t,e,r){v(t,e,!1)&&y(t,e,r,\"notDeepEqual\",c.notDeepEqual)},c.notDeepStrictEqual=function t(e,r,i){v(e,r,!0)&&y(e,r,i,\"notDeepStrictEqual\",t)},c.strictEqual=function(t,e,r){t!==e&&y(t,e,r,\"===\",c.strictEqual)},c.notStrictEqual=function(t,e,r){t===e&&y(t,e,r,\"!==\",c.notStrictEqual)},c.throws=function(t,e,r){M(!0,t,e,r)},c.doesNotThrow=function(t,e,r){M(!1,t,e,r)},c.ifError=function(t){if(t)throw t},c.strict=i(function t(e,r){e||y(e,!0,r,\"==\",t)},c,{equal:c.strictEqual,deepEqual:c.deepStrictEqual,notEqual:c.notStrictEqual,notDeepEqual:c.notDeepStrictEqual}),c.strict.strict=c.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}},4589:t=>{t.exports=JSON.parse('{\"1.3.132.0.10\":\"secp256k1\",\"1.3.132.0.33\":\"p224\",\"1.2.840.10045.3.1.1\":\"p192\",\"1.2.840.10045.3.1.7\":\"p256\",\"1.3.132.0.34\":\"p384\",\"1.3.132.0.35\":\"p521\"}')},4598:(t,e,r)=>{var i=r(2153);e.tagClass={0:\"universal\",1:\"application\",2:\"context\",3:\"private\"},e.tagClassByName=i._reverse(e.tagClass),e.tag={0:\"end\",1:\"bool\",2:\"int\",3:\"bitstr\",4:\"octstr\",5:\"null_\",6:\"objid\",7:\"objDesc\",8:\"external\",9:\"real\",10:\"enum\",11:\"embed\",12:\"utf8str\",13:\"relativeOid\",16:\"seq\",17:\"set\",18:\"numstr\",19:\"printstr\",20:\"t61str\",21:\"videostr\",22:\"ia5str\",23:\"utctime\",24:\"gentime\",25:\"graphstr\",26:\"iso646str\",27:\"genstr\",28:\"unistr\",29:\"charstr\",30:\"bmpstr\"},e.tagByName=i._reverse(e.tag)},4610:(t,e,r)=>{t.exports=f;var i=r(113).F,n=i.ERR_METHOD_NOT_IMPLEMENTED,s=i.ERR_MULTIPLE_CALLBACK,o=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,h=r(5382);function u(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit(\"error\",new s);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);h.call(this,t),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(\"function\"==typeof t.transform&&(this._transform=t.transform),\"function\"==typeof t.flush&&(this._flush=t.flush)),this.on(\"prefinish\",l)}function l(){var t=this;\"function\"!=typeof this._flush||this._readableState.destroyed?c(this,null,null):this._flush(function(e,r){c(t,e,r)})}function c(t,e,r){if(e)return t.emit(\"error\",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new o;return t.push(null)}r(6698)(f,h),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,h.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new n(\"_transform()\"))},f.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){h.prototype._destroy.call(this,t,function(t){e(t)})}},4611:(t,e,r)=>{const i=r(5682);t.exports=class{constructor(t){this.encoding=t}get remaining(){return 0}decode(t){return i.toString(t,this.encoding)}flush(){return\"\"}}},4634:t=>{var e={}.toString;t.exports=Array.isArray||function(t){return\"[object Array]\"==e.call(t)}},4643:t=>{function e(t){try{if(!globalThis.localStorage)return!1}catch(t){return!1}var e=globalThis.localStorage[t];return null!=e&&\"true\"===String(e).toLowerCase()}t.exports=function(t,r){if(e(\"noDeprecation\"))return t;var i=!1;return function(){if(!i){if(e(\"throwDeprecation\"))throw new Error(r);e(\"traceDeprecation\")?console.trace(r):console.warn(r),i=!0}return t.apply(this,arguments)}}},4662:(t,e,r)=>{var i=r(8287).Buffer;function n(t,e,r){let i=0,n=1;for(let s=e;s<r;s++){const r=t[s];if(r<58&&r>=48)i=10*i+(r-48);else if(s!==e||43!==r){if(s!==e||45!==r){if(46===r)break;throw new Error(\"not a number: buffer[\"+s+\"] = \"+r)}n=-1}}return i*n}function s(t,e,r,n){return null==t||0===t.length?null:(\"number\"!=typeof e&&null==n&&(n=e,e=void 0),\"number\"!=typeof r&&null==n&&(n=r,r=void 0),s.position=0,s.encoding=n||null,s.data=i.isBuffer(t)?t.slice(e,r):i.from(t),s.bytes=s.data.length,s.next())}s.bytes=0,s.position=0,s.data=null,s.encoding=null,s.next=function(){switch(s.data[s.position]){case 100:return s.dictionary();case 108:return s.list();case 105:return s.integer();default:return s.buffer()}},s.find=function(t){let e=s.position;const r=s.data.length,i=s.data;for(;e<r;){if(i[e]===t)return e;e++}throw new Error('Invalid data: Missing delimiter \"'+String.fromCharCode(t)+'\" [0x'+t.toString(16)+\"]\")},s.dictionary=function(){s.position++;const t={};for(;101!==s.data[s.position];)t[s.buffer()]=s.next();return s.position++,t},s.list=function(){s.position++;const t=[];for(;101!==s.data[s.position];)t.push(s.next());return s.position++,t},s.integer=function(){const t=s.find(101),e=n(s.data,s.position+1,t);return s.position+=t+1-s.position,e},s.buffer=function(){let t=s.find(58);const e=n(s.data,s.position,t),r=++t+e;return s.position=r,s.encoding?s.data.toString(s.encoding,t,r):s.data.slice(t,r)},t.exports=s},4669:(t,e,r)=>{var i=e;i.der=r(82),i.pem=r(735)},4729:(t,e,r)=>{var i=r(2861).Buffer,n=r(8310).Transform;function s(t){n.call(this),this._block=i.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(s,n),s.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(t){i=t}r(i)},s.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)};var o=\"undefined\"!=typeof Uint8Array,a=\"undefined\"!=typeof ArrayBuffer&&\"undefined\"!=typeof Uint8Array&&ArrayBuffer.isView&&(i.prototype instanceof Uint8Array||i.TYPED_ARRAY_SUPPORT);s.prototype.update=function(t,e){if(this._finalized)throw new Error(\"Digest already called\");t=function(t,e){if(t instanceof i)return t;if(\"string\"==typeof t)return i.from(t,e);if(a&&ArrayBuffer.isView(t)){if(0===t.byteLength)return i.alloc(0);var r=i.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}if(o&&t instanceof Uint8Array)return i.from(t);if(i.isBuffer(t)&&t.constructor&&\"function\"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return i.from(t);throw new TypeError('The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(t,e);for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var s=this._blockOffset;s<this._blockSize;)r[s++]=t[n++];this._update(),this._blockOffset=0}for(;n<t.length;)r[this._blockOffset++]=t[n++];for(var h=0,u=8*t.length;u>0;++h)this._length[h]+=u,(u=this._length[h]/4294967296|0)>0&&(this._length[h]-=4294967296*u);return this},s.prototype._update=function(){throw new Error(\"_update is not implemented\")},s.prototype.digest=function(t){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},s.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},t.exports=s},4765:t=>{var e=String.prototype.replace,r=/%20/g,i=\"RFC1738\",n=\"RFC3986\";t.exports={default:n,formatters:{RFC1738:function(t){return e.call(t,r,\"+\")},RFC3986:function(t){return String(t)}},RFC1738:i,RFC3986:n}},4803:(t,e,r)=>{var i=r(8859),n=r(9675),s=function(t,e,r){for(var i,n=t;null!=(i=n.next);n=i)if(i.key===e)return n.next=i.next,r||(i.next=t.next,t.next=i),i};t.exports=function(){var t,e={assert:function(t){if(!e.has(t))throw new n(\"Side channel does not contain \"+i(t))},delete:function(e){var r=t&&t.next,i=function(t,e){if(t)return s(t,e,!0)}(t,e);return i&&r&&r===i&&(t=void 0),!!i},get:function(e){return function(t,e){if(t){var r=s(t,e);return r&&r.value}}(t,e)},has:function(e){return function(t,e){return!!t&&!!s(t,e)}(t,e)},set:function(e,r){t||(t={next:void 0}),function(t,e,r){var i=s(t,e);i?i.value=r:t.next={key:e,next:t.next,value:r}}(t,e,r)}};return e}},4835:()=>{},4847:(t,e,r)=>{var i=r(2861).Buffer,n=r(9404),s=r(6729).ec,o=r(8170),a=r(4589);function h(t,e){if(t.cmpn(0)<=0)throw new Error(\"invalid sig\");if(t.cmp(e)>=0)throw new Error(\"invalid sig\")}t.exports=function(t,e,r,u,f){var l=o(r);if(\"ec\"===l.type){if(\"ecdsa\"!==u&&\"ecdsa/rsa\"!==u)throw new Error(\"wrong public key type\");return function(t,e,r){var i=a[r.data.algorithm.curve.join(\".\")];if(!i)throw new Error(\"unknown curve \"+r.data.algorithm.curve.join(\".\"));var n=new s(i),o=r.data.subjectPrivateKey.data;return n.verify(e,t,o)}(t,e,l)}if(\"dsa\"===l.type){if(\"dsa\"!==u)throw new Error(\"wrong public key type\");return function(t,e,r){var i=r.data.p,s=r.data.q,a=r.data.g,u=r.data.pub_key,f=o.signature.decode(t,\"der\"),l=f.s,c=f.r;h(l,s),h(c,s);var d=n.mont(i),p=l.invm(s),m=a.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(u.toRed(d).redPow(c.mul(p).mod(s)).fromRed()).mod(i).mod(s);return 0===m.cmp(c)}(t,e,l)}if(\"rsa\"!==u&&\"ecdsa/rsa\"!==u)throw new Error(\"wrong public key type\");e=i.concat([f,e]);for(var c=l.modulus.byteLength(),d=[1],p=0;e.length+d.length+2<c;)d.push(255),p+=1;d.push(0);for(var m=-1;++m<e.length;)d.push(e[m]);d=i.from(d);var g=n.mont(l.modulus);t=(t=new n(t).toRed(g)).redPow(new n(l.publicExponent)),t=i.from(t.fromRed().toArray());var y=p<8?1:0;for(c=Math.min(t.length,d.length),t.length!==d.length&&(y=1),m=-1;++m<c;)y|=t[m]^d[m];return 0===y}},4862:(t,e,r)=>{t.exports=n;const i=r(9596);function n(t,e){if(!(this instanceof n))return new n(t,e);if(e||(e={}),this.chunkLength=Number(t),!this.chunkLength)throw new Error(\"First argument must be a chunk length\");this.chunks=[],this.closed=!1,this.length=Number(e.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}n.prototype.put=function(t,e,r=()=>{}){if(this.closed)return i(()=>r(new Error(\"Storage is closed\")));const n=t===this.lastChunkIndex;return n&&e.length!==this.lastChunkLength?i(()=>r(new Error(\"Last chunk length must be \"+this.lastChunkLength))):n||e.length===this.chunkLength?(this.chunks[t]=e,void i(()=>r(null))):i(()=>r(new Error(\"Chunk length must be \"+this.chunkLength)))},n.prototype.get=function(t,e,r=()=>{}){if(\"function\"==typeof e)return this.get(t,null,e);if(this.closed)return i(()=>r(new Error(\"Storage is closed\")));let n=this.chunks[t];if(!n){const t=new Error(\"Chunk not found\");return t.notFound=!0,i(()=>r(t))}e||(e={});const s=e.offset||0,o=e.length||n.length-s;0===s&&o===n.length||(n=n.slice(s,o+s)),i(()=>r(null,n))},n.prototype.close=n.prototype.destroy=function(t=()=>{}){if(this.closed)return i(()=>t(new Error(\"Storage is closed\")));this.closed=!0,this.chunks=null,i(()=>t(null))}},4910:(t,e,r)=>{var i=r(8287).Buffer,n=r(6473),s=new(r(2244)),o=new n(24),a=new n(11),h=new n(10),u=new n(3),f=new n(7),l=r(4934),c=r(3209);function d(t,e){return e=e||\"utf8\",i.isBuffer(t)||(t=new i(t,e)),this._pub=new n(t),this}function p(t,e){return e=e||\"utf8\",i.isBuffer(t)||(t=new i(t,e)),this._priv=new n(t),this}t.exports=g;var m={};function g(t,e,r){this.setGenerator(e),this.__prime=new n(t),this._prime=n.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,r?(this.setPublicKey=d,this.setPrivateKey=p):this._primeCode=8}function y(t,e){var r=new i(t.toArray());return e?r.toString(e):r}Object.defineProperty(g.prototype,\"verifyError\",{enumerable:!0,get:function(){return\"number\"!=typeof this._primeCode&&(this._primeCode=function(t,e){var r=e.toString(\"hex\"),i=[r,t.toString(16)].join(\"_\");if(i in m)return m[i];var n,c=0;if(t.isEven()||!l.simpleSieve||!l.fermatTest(t)||!s.test(t))return c+=1,c+=\"02\"===r||\"05\"===r?8:4,m[i]=c,c;switch(s.test(t.shrn(1))||(c+=2),r){case\"02\":t.mod(o).cmp(a)&&(c+=8);break;case\"05\":(n=t.mod(h)).cmp(u)&&n.cmp(f)&&(c+=8);break;default:c+=4}return m[i]=c,c}(this.__prime,this.__gen)),this._primeCode}}),g.prototype.generateKeys=function(){return this._priv||(this._priv=new n(c(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},g.prototype.computeSecret=function(t){var e=(t=(t=new n(t)).toRed(this._prime)).redPow(this._priv).fromRed(),r=new i(e.toArray()),s=this.getPrime();if(r.length<s.length){var o=new i(s.length-r.length);o.fill(0),r=i.concat([o,r])}return r},g.prototype.getPublicKey=function(t){return y(this._pub,t)},g.prototype.getPrivateKey=function(t){return y(this._priv,t)},g.prototype.getPrime=function(t){return y(this.__prime,t)},g.prototype.getGenerator=function(t){return y(this._gen,t)},g.prototype.setGenerator=function(t,e){return e=e||\"utf8\",i.isBuffer(t)||(t=new i(t,e)),this.__gen=t,this._gen=new n(t),this}},4934:(t,e,r)=>{var i=r(3209);t.exports=b,b.simpleSieve=g,b.fermatTest=y;var n=r(6473),s=new n(24),o=new(r(2244)),a=new n(1),h=new n(2),u=new n(5),f=(new n(16),new n(8),new n(10)),l=new n(3),c=(new n(7),new n(11)),d=new n(4),p=(new n(12),null);function m(){if(null!==p)return p;var t=[];t[0]=2;for(var e=1,r=3;r<1048576;r+=2){for(var i=Math.ceil(Math.sqrt(r)),n=0;n<e&&t[n]<=i&&r%t[n]!==0;n++);e!==n&&t[n]<=i||(t[e++]=r)}return p=t,t}function g(t){for(var e=m(),r=0;r<e.length;r++)if(0===t.modn(e[r]))return 0===t.cmpn(e[r]);return!0}function y(t){var e=n.mont(t);return 0===h.toRed(e).redPow(t.subn(1)).fromRed().cmpn(1)}function b(t,e){if(t<16)return new n(2===e||5===e?[140,123]:[140,39]);var r,p;for(e=new n(e);;){for(r=new n(i(Math.ceil(t/8)));r.bitLength()>t;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(h),e.cmp(h)){if(!e.cmp(u))for(;r.mod(f).cmp(l);)r.iadd(d)}else for(;r.mod(s).cmp(c);)r.iadd(d);if(g(p=r.shrn(1))&&g(r)&&y(p)&&y(r)&&o.test(p)&&o.test(r))return r}}},4988:(t,e,r)=>{var i=r(717),n=r(8287).Buffer,s=r(7558),o=r(9971),a=r(7007),h=r(3209),u=r(537),f=[{host:\"router.bittorrent.com\",port:6881},{host:\"router.utorrent.com\",port:6881},{host:\"dht.transmissionbt.com\",port:6881}];function l(t){if(!(this instanceof l))return new l(t);t||(t={});var e,r=this;function i(t,e){if(t&&c(t.id,r._idLength)&&!t.id.equals(r.id)){var i=r.nodes.get(t.id);if(i)return void(i.seen=Date.now());r._addNode({id:t.id,host:e.address||e.host,port:e.port,distance:0,seen:Date.now()})}}this._idLength=t.idLength||20,this.id=function(t){if(n.isBuffer(t))return t;if(ArrayBuffer.isView(t))return n.from(t.buffer,t.byteOffset,t.byteLength);if(\"string\"==typeof t)return n.from(t,\"hex\");throw new Error(\"Pass a buffer or a string\")}(t.id||t.nodeId||h(this._idLength)),this.socket=t.krpcSocket||s(t),this.bootstrap=!1===(e=t.nodes||t.bootstrap)?[]:!0===e?f:[].concat(e||f).map(p),this.concurrency=t.concurrency||16,this.backgroundConcurrency=t.backgroundConcurrency||this.concurrency/4|0,this.k=t.k||20,this.destroyed=!1,this.pending=[],this.nodes=null,this.socket.setMaxListeners(0),this.socket.on(\"query\",function(t,e){i(t.a,e),r.emit(\"query\",t,e)}),this.socket.on(\"response\",function(t,e){i(t.r,e)}),this.socket.on(\"warning\",function(t){r.emit(\"warning\",t)}),this.socket.on(\"error\",function(t){r.emit(\"error\",t)}),this.socket.on(\"update\",function(){for(;r.pending.length&&r.socket.inflight<r.concurrency;){var t=r.pending.shift();r.query(t[0],t[1],t[2])}}),this.socket.on(\"listening\",function(){r.emit(\"listening\")}),a.EventEmitter.call(this),this.clear()}function c(t,e){return t&&n.isBuffer(t)&&t.length===e}function d(t,e){return t[e++]+\".\"+t[e++]+\".\"+t[e++]+\".\"+t[e++]}function p(t){return\"string\"==typeof t?{host:t.split(\":\")[0],port:Number(t.split(\":\")[1])}:t}function m(){}t.exports=l,u.inherits(l,a.EventEmitter),l.prototype.response=function(t,e,r,i,s){\"function\"==typeof i&&(s=i,i=null),r.id||(r.id=this.id),i&&(r.nodes=function(t,e){for(var r=n.allocUnsafe(t.length*(e+6)),i=0,s=0;s<t.length;s++){var o=t[s];if(c(o.id,e)){o.id.copy(r,i),i+=e;for(var a=(o.host||o.address).split(\".\"),h=0;h<4;h++)r[i++]=parseInt(a[h]||0,10);r.writeUInt16BE(o.port,i),i+=2}}return i===r.length?r:r.slice(0,i)}(i,this._idLength)),this.socket.response(t,e,r,s)},l.prototype.error=function(t,e,r,i){this.socket.error(t,e,r,i)},l.prototype.bind=function(){this.socket.bind.apply(this.socket,arguments)},l.prototype.address=function(){return this.socket.address()},l.prototype.queryAll=function(t,e,r,i){e.a||(e.a={}),e.a.id||(e.a.id=this.id);var n=!1,s=t.length,o=0,a=null;if(!s)return i(new Error(\"No nodes to query\"),0);for(var h=0;h<t.length;h++)this.query(t[h],e,u);function u(t,e,h){t?t.code>=300&&t.code<400&&(a=t):o++,t||n||r&&!1===r(e,h)&&(n=!0),--s||i(o?null:a||new Error(\"All queries failed\"),o)}},l.prototype.query=function(t,e,r){this.socket.inflight>=this.concurrency?this.pending.push([t,e,r]):(e.a||(e.a={}),e.a.id||(e.a.id=this.id),t.token&&(e.a.token=t.token),this.socket.query(t,e,r))},l.prototype.destroy=function(t){this.destroyed=!0,this.socket.destroy(t)},l.prototype.clear=function(){var t=this;this.nodes=new o({localNodeId:this.id,numberOfNodesPerKBucket:this.k,numberOfNodesToPing:this.concurrency}),this.nodes.on(\"ping\",function(e,r){t.emit(\"ping\",e,function(e){e&&(e.id&&t.nodes.remove(e.id),t._addNode(r))})})},l.prototype.populate=function(t,e,r){this._closest(t,e,!0,null,r)},l.prototype.closest=function(t,e,r,i){this._closest(t,e,!1,r,i)},l.prototype._addNode=function(t){var e=this.nodes.get(t.id);this.nodes.add(t),e||this.emit(\"node\",t)},l.prototype._closest=function(t,e,r,n,s){s||(s=m);var a=this,h=0,u={},f=0,l=!0,p=!1;e.a||(e.a={}),e.a.id||(e.a.id=this.id);var g=new o({localNodeId:t,numberOfNodesPerKBucket:this.k,numberOfNodesToPing:this.concurrency}),y=r?\"postupdate\":\"update\";function b(){if(!(a.destroyed||a.socket.inflight>=a.concurrency)){var n=a.pending.length+a.socket.inflight-f;if(!(r&&a.socket.inflight>=a.backgroundConcurrency&&n)){var s=g.closest(t,a.k);(!s.length||s.length<a.bootstrap.length)&&(!(s=a.nodes.closest(t,a.k)).length||s.length<a.bootstrap.length)&&function(){if(!l)return;l=!1,a.bootstrap.forEach(function(t){f++,a.socket.query(t,e,w)})}();for(var o=0;o<s.length&&!p;o++){if(a.socket.inflight>=a.concurrency)return;var h=s[o],c=h.host+\":\"+h.port;u[c]||(u[c]=!0,f++,a.socket.query(h,e,w))}f||(a.socket.removeListener(y,b),i.nextTick(v))}}}function v(){s(null,h)}function w(t,e,r){f--,r&&(u[(r.address||r.host)+\":\"+r.port]=!0),r&&r.id&&a.nodes.get(r.id)&&(!t||\"EUNEXPECTEDNODE\"!==t.code&&\"ETIMEDOUT\"!==t.code||a.nodes.remove(r.id));var i=e&&e.r;if(!i)return b();!t&&c(i.id,a._idLength)&&(h++,_({id:i.id,port:r.port,host:r.host||r.address,distance:0}));for(var s=i.nodes?function(t,e){var r=[];try{for(var i=0;i<t.length;i+=e+6){var n=t.readUInt16BE(i+(e+4));n&&r.push({id:t.slice(i,i+e),host:d(t,i+e),port:n,distance:0,token:null})}}catch(t){}return r}(i.nodes,a._idLength):[],o=0;o<s.length;o++)_(s[o]);n&&!1===n(e,r)&&(p=!0),b()}function _(t){t.id.equals(a.id)||g.add(t)}this.socket.on(y,b),b()}},5037:(t,e,r)=>{var i;function n(t){this.rand=t}if(t.exports=function(t){return i||(i=new n(null)),i.generate(t)},t.exports.Rand=n,n.prototype.generate=function(t){return this._rand(t)},n.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e},\"object\"==typeof self)self.crypto&&self.crypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e}:self.msCrypto&&self.msCrypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e}:\"object\"==typeof window&&(n.prototype._rand=function(){throw new Error(\"Not implemented yet\")});else try{var s=r(1565);if(\"function\"!=typeof s.randomBytes)throw new Error(\"Not supported\");n.prototype._rand=function(t){return s.randomBytes(t)}}catch(t){}},5122:t=>{t.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},5185:()=>{},5221:(t,e,r)=>{const{isIPv4:i,isIPv6:n}=r(8957);e.lookup=function t(e,r,s){if(\"function\"==typeof r)return t(e,null,r);chrome.dns.resolve(e,t=>{if(0!==t.resultCode)return s(new Error(\"DNS lookup error: \"+chrome.runtime.lastError.message));const e=t.address,r=i(e)?4:n(e)?6:0;s(null,e,r)})}},5242:(t,e,r)=>{t.exports=s;var i=r(1816),n=Object.create(r(5622));function s(t){if(!(this instanceof s))return new s(t);i.call(this,t)}n.inherits=r(6698),n.inherits(s,i),s.prototype._transform=function(t,e,r){r(null,t)}},5264:(t,e,r)=>{var i=r(2861).Buffer;function n(t,e,r){for(var i,n,o=-1,a=0;++o<8;)i=e&1<<7-o?128:0,a+=(128&(n=t._cipher.encryptBlock(t._prev)[0]^i))>>o%8,t._prev=s(t._prev,r?i:n);return a}function s(t,e){var r=t.length,n=-1,s=i.allocUnsafe(t.length);for(t=i.concat([t,i.from([e])]);++n<r;)s[n]=t[n]<<1|t[n+1]>>7;return s}e.encrypt=function(t,e,r){for(var s=e.length,o=i.allocUnsafe(s),a=-1;++a<s;)o[a]=n(t,e[a],r);return o}},5279:(t,e,r)=>{var i=r(3349),n=r(6698),s=r(2808),o=r(2211);function a(t,e){i.equal(e.length,24,\"Invalid key length\");var r=e.slice(0,8),n=e.slice(8,16),s=e.slice(16,24);this.ciphers=\"encrypt\"===t?[o.create({type:\"encrypt\",key:r}),o.create({type:\"decrypt\",key:n}),o.create({type:\"encrypt\",key:s})]:[o.create({type:\"decrypt\",key:s}),o.create({type:\"encrypt\",key:n}),o.create({type:\"decrypt\",key:r})]}function h(t){s.call(this,t);var e=new a(this.type,this.options.key);this._edeState=e}n(h,s),t.exports=h,h.create=function(t){return new h(t)},h.prototype._update=function(t,e,r,i){var n=this._edeState;n.ciphers[0]._update(t,e,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},h.prototype._pad=o.prototype._pad,h.prototype._unpad=o.prototype._unpad},5291:(t,e,r)=>{var i=r(113).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,n){var s=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,n,r);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new i(n?r:\"highWaterMark\",s);return Math.floor(s)}return t.objectMode?16:16384}}},5307:(t,e,r)=>{const i=r(5682);var n=[];function s(){this.list=[],this.map=new Map}function o(){this.records=new Map,this.size=0}function a(t){if(!(this instanceof a))return new a(t);if(t||(t={}),this.maxSize=t.maxSize||1/0,this.maxAge=t.maxAge||0,this._onstale=t.onStale||t.onstale||null,this._fresh=new o,this._stale=new o,this._interval=null,this._gced=!1,this.maxAge&&this.maxAge<1/0){var e=Math.ceil(2/3*this.maxAge);this._interval=setInterval(this._gcAuto.bind(this),e),this._interval.unref&&this._interval.unref()}}function h(t){return i.isBuffer(t)?i.toString(t,\"hex\"):t}function u(t,e,r){var i=t[e];i.index=r,t[r].index=e,t[e]=t[r],t[r]=i}t.exports=a,s.prototype.add=function(t,e){var r=h(t),i=this.map.get(r);return!i&&(i={index:this.list.length,record:e||t},this.list.push(i),this.map.set(r,i),!0)},s.prototype.remove=function(t){var e=h(t),r=this.map.get(e);return!!r&&(u(this.list,r.index,this.list.length-1),this.list.pop(),this.map.delete(e),!0)},o.prototype.add=function(t,e,r){var i=this.records.get(t);return i||(i=new s,this.records.set(t,i)),!!i.add(e,r)&&(this.size++,!0)},o.prototype.remove=function(t,e,r){var i=this.records.get(t);return!!i&&(!!i.remove(e,r)&&(this.size--,i.map.size||this.records.delete(t),!0))},o.prototype.get=function(t){var e=this.records.get(t);return e?e.list:n},Object.defineProperty(a.prototype,\"size\",{get:function(){return this._fresh.size+this._stale.size}}),a.prototype.add=function(t,e,r){this._stale.remove(t,e,r),this._fresh.add(t,e,r)&&this._fresh.size>this.maxSize&&this._gc()},a.prototype.remove=function(t,e,r){this._fresh.remove(t,e,r),this._stale.remove(t,e,r)},a.prototype.get=function(t,e){var r=this._fresh.get(t),i=this._stale.get(t),n=r.length,s=i.length,o=n+s;(e>o||!e)&&(e=o);for(var a=new Array(e),h=0;h<e;h++){var f=Math.floor(Math.random()*(n+s));f<n?(a[h]=r[f].record,u(r,f,--n)):(f-=n,a[h]=i[f].record,u(i,f,--s))}return a},a.prototype._gcAuto=function(){this._gced||this._gc(),this._gced=!1},a.prototype._gc=function(){this._onstale&&this._stale.size>0&&this._onstale(this._stale),this._stale=this._fresh,this._fresh=new o,this._gced=!0},a.prototype.clear=function(){this._gc(),this._gc()},a.prototype.destroy=function(){this.clear(),clearInterval(this._interval),this._interval=null}},5335:(t,e,r)=>{const i=r(4611),n=r(6045);t.exports=class{constructor(t=\"utf8\"){switch(this.encoding=function(t){switch(t=t.toLowerCase()){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 t;default:throw new Error(\"Unknown encoding: \"+t)}}(t),this.encoding){case\"utf8\":this.decoder=new n;break;case\"utf16le\":case\"base64\":throw new Error(\"Unsupported encoding: \"+this.encoding);default:this.decoder=new i(this.encoding)}}get remaining(){return this.decoder.remaining}push(t){return\"string\"==typeof t?t:this.decoder.decode(t)}write(t){return this.push(t)}end(t){let e=\"\";return t&&(e=this.push(t)),e+=this.decoder.flush(),e}}},5345:t=>{t.exports=URIError},5359:(t,e,r)=>{var i=r(2861).Buffer,n=r(3507),s=r(7332),o=r(6729).ec,a=r(9404),h=r(8170),u=r(4589);function f(t,e,r,s){if((t=i.from(t.toArray())).length<e.byteLength()){var o=i.alloc(e.byteLength()-t.length);t=i.concat([o,t])}var a=r.length,h=function(t,e){t=l(t,e),t=t.mod(e);var r=i.from(t.toArray());if(r.length<e.byteLength()){var n=i.alloc(e.byteLength()-r.length);r=i.concat([n,r])}return r}(r,e),u=i.alloc(a);u.fill(1);var f=i.alloc(a);return f=n(s,f).update(u).update(i.from([0])).update(t).update(h).digest(),u=n(s,f).update(u).digest(),{k:f=n(s,f).update(u).update(i.from([1])).update(t).update(h).digest(),v:u=n(s,f).update(u).digest()}}function l(t,e){var r=new a(t),i=(t.length<<3)-e.bitLength();return i>0&&r.ishrn(i),r}function c(t,e,r){var s,o;do{for(s=i.alloc(0);8*s.length<t.bitLength();)e.v=n(r,e.k).update(e.v).digest(),s=i.concat([s,e.v]);o=l(s,t),e.k=n(r,e.k).update(e.v).update(i.from([0])).digest(),e.v=n(r,e.k).update(e.v).digest()}while(-1!==o.cmp(t));return o}function d(t,e,r,i){return t.toRed(a.mont(r)).redPow(e).fromRed().mod(i)}t.exports=function(t,e,r,n,p){var m=h(e);if(m.curve){if(\"ecdsa\"!==n&&\"ecdsa/rsa\"!==n)throw new Error(\"wrong private key type\");return function(t,e){var r=u[e.curve.join(\".\")];if(!r)throw new Error(\"unknown curve \"+e.curve.join(\".\"));var n=new o(r).keyFromPrivate(e.privateKey),s=n.sign(t);return i.from(s.toDER())}(t,m)}if(\"dsa\"===m.type){if(\"dsa\"!==n)throw new Error(\"wrong private key type\");return function(t,e,r){var n,s=e.params.priv_key,o=e.params.p,h=e.params.q,u=e.params.g,p=new a(0),m=l(t,h).mod(h),g=!1,y=f(s,h,t,r);for(;!1===g;)p=d(u,n=c(h,y,r),o,h),0===(g=n.invm(h).imul(m.add(s.mul(p))).mod(h)).cmpn(0)&&(g=!1,p=new a(0));return function(t,e){t=t.toArray(),e=e.toArray(),128&t[0]&&(t=[0].concat(t));128&e[0]&&(e=[0].concat(e));var r=t.length+e.length+4,n=[48,r,2,t.length];return n=n.concat(t,[2,e.length],e),i.from(n)}(p,g)}(t,m,r)}if(\"rsa\"!==n&&\"ecdsa/rsa\"!==n)throw new Error(\"wrong private key type\");if(void 0!==e.padding&&1!==e.padding)throw new Error(\"illegal or unsupported padding mode\");t=i.concat([p,t]);for(var g=m.modulus.byteLength(),y=[0,1];t.length+y.length+1<g;)y.push(255);y.push(0);for(var b=-1;++b<t.length;)y.push(t[b]);return s(y,m)},t.exports.getKey=f,t.exports.makeKey=c},5372:(t,e,r)=>{t.exports=function(t,e,r){if(\"number\"!=typeof e)throw new Error(\"second argument must be a Number\");let n,s,o,a,h,u,f=!0;Array.isArray(t)?(n=[],o=s=t.length):(a=Object.keys(t),n={},o=s=a.length);function l(t){function e(){r&&r(t,n),r=null}f?i(e):e()}function c(e,r,i){if(n[e]=i,r&&(h=!0),0===--o||r)l(r);else if(!h&&u<s){let e;a?(e=a[u],u+=1,t[e](function(t,r){c(e,t,r)})):(e=u,u+=1,t[e](function(t,r){c(e,t,r)}))}}u=e,o?a?a.some(function(r,i){return t[r](function(t,e){c(r,t,e)}),i===e-1}):t.some(function(t,r){return t(function(t,e){c(r,t,e)}),r===e-1}):l(null);f=!1};const i=r(9596)},5373:(t,e,r)=>{var i=r(8636),n=r(2642),s=r(4765);t.exports={formats:s,parse:n,stringify:i}},5377:(t,e,r)=>{var i=r(2861).Buffer,n=r(4634),s=r(4372),o=ArrayBuffer.isView||function(t){try{return s(t),!0}catch(t){return!1}},a=\"undefined\"!=typeof Uint8Array,h=\"undefined\"!=typeof ArrayBuffer&&\"undefined\"!=typeof Uint8Array,u=h&&(i.prototype instanceof Uint8Array||i.TYPED_ARRAY_SUPPORT);t.exports=function(t,e){if(i.isBuffer(t))return t.constructor&&!(\"isBuffer\"in t)?i.from(t):t;if(\"string\"==typeof t)return i.from(t,e);if(h&&o(t)){if(0===t.byteLength)return i.alloc(0);if(u){var r=i.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}var s=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),f=i.from(s);if(f.length===t.byteLength)return f}if(a&&t instanceof Uint8Array)return i.from(t);var l=n(t);if(l)for(var c=0;c<t.length;c+=1){var d=t[c];if(\"number\"!=typeof d||d<0||d>255||~~d!==d)throw new RangeError(\"Array items must be numbers in the range 0-255.\")}if(l||i.isBuffer(t)&&t.constructor&&\"function\"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))return i.from(t);throw new TypeError('The \"data\" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}},5380:(t,e,r)=>{var i=r(8287).Buffer,n=r(4934),s=r(3241),o=r(4910);var a={binary:!0,hex:!0,base64:!0};e.DiffieHellmanGroup=e.createDiffieHellmanGroup=e.getDiffieHellman=function(t){var e=new i(s[t].prime,\"hex\"),r=new i(s[t].gen,\"hex\");return new o(e,r)},e.createDiffieHellman=e.DiffieHellman=function t(e,r,s,h){return i.isBuffer(r)||void 0===a[r]?t(e,\"binary\",r,s):(r=r||\"binary\",h=h||\"binary\",s=s||new i([2]),i.isBuffer(s)||(s=new i(s,h)),\"number\"==typeof e?new o(n(e,s),s,!0):(i.isBuffer(e)||(e=new i(e,r)),new o(e,s,!0)))}},5382:(t,e,r)=>{var i=r(717),n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var s=r(5412),o=r(6708);r(6698)(f,s);for(var a=n(o.prototype),h=0;h<a.length;h++){var u=a[h];f.prototype[u]||(f.prototype[u]=o.prototype[u])}function f(t){if(!(this instanceof f))return new f(t);s.call(this,t),o.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once(\"end\",l)))}function l(){this._writableState.ended||i.nextTick(c,this)}function c(t){t.end()}Object.defineProperty(f.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,\"writableLength\",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},5412:(t,e,r)=>{var i,n=r(717);t.exports=E,E.ReadableState=k;r(7007).EventEmitter;var s=function(t,e){return t.listeners(e).length},o=r(1416),a=r(8287).Buffer,h=(\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var u,f=r(537);u=f&&f.debuglog?f.debuglog(\"stream\"):function(){};var l,c,d,p=r(345),m=r(5896),g=r(5291).getHighWaterMark,y=r(113).F,b=y.ERR_INVALID_ARG_TYPE,v=y.ERR_STREAM_PUSH_AFTER_EOF,w=y.ERR_METHOD_NOT_IMPLEMENTED,_=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(E,o);var M=m.errorOrDestroy,S=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function k(t,e,n){i=i||r(5382),t=t||{},\"boolean\"!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,\"readableHighWaterMark\",n),this.buffer=new p,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!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(3141).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function E(t){if(i=i||r(5382),!(this instanceof E))return new E(t);var e=this instanceof i;this._readableState=new k(t,this,e),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function x(t,e,r,i,n){u(\"readableAddChunk\",e);var s,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(u(\"onEofChunk\"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?C(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,P(t)))}(t,o);else if(n||(s=function(t,e){var r;i=e,a.isBuffer(i)||i instanceof h||\"string\"==typeof e||void 0===e||t.objectMode||(r=new b(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],e));var i;return r}(o,e)),s)M(t,s);else if(o.objectMode||e&&e.length>0)if(\"string\"==typeof e||o.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=function(t){return a.from(t)}(e)),i)o.endEmitted?M(t,new _):A(t,o,e,!0);else if(o.ended)M(t,new v);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?A(t,o,e,!1):R(t,o)):A(t,o,e,!1)}else i||(o.reading=!1,R(t,o));return!o.ended&&(o.length<o.highWaterMark||0===o.length)}function A(t,e,r,i){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit(\"data\",r)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&C(t)),R(t,e)}Object.defineProperty(E.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),E.prototype.destroy=m.destroy,E.prototype._undestroy=m.undestroy,E.prototype._destroy=function(t,e){e(t)},E.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:\"string\"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=a.from(t,e),e=\"\"),r=!0),x(this,t,e,!1,r)},E.prototype.unshift=function(t){return x(this,t,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(t){l||(l=r(3141).I);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,n=\"\";null!==i;)n+=e.write(i.data),i=i.next;return this._readableState.buffer.clear(),\"\"!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var I=1073741824;function T(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;u(\"emitReadable\",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u(\"emitReadable\",e.flowing),e.emittedReadable=!0,n.nextTick(P,t))}function P(t){var e=t._readableState;u(\"emitReadable_\",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit(\"readable\"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function R(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(O,t,e))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(u(\"maybeReadMore read 0\"),t.read(0),r===e.length)break}e.readingMore=!1}function B(t){var e=t._readableState;e.readableListening=t.listenerCount(\"readable\")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount(\"data\")>0&&t.resume()}function L(t){u(\"readable nexttick read 0\"),t.read(0)}function N(t,e){u(\"resume\",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit(\"resume\"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function U(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function q(t){var e=t._readableState;u(\"endReadable\",e.endEmitted),e.endEmitted||(e.ended=!0,n.nextTick(D,e,t))}function D(t,e){if(u(\"endReadableNT\",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}E.prototype.read=function(t){u(\"read\",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return u(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?q(this):C(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&q(this),null;var i,n=e.needReadable;return u(\"need readable\",n),(0===e.length||e.length-t<e.highWaterMark)&&u(\"length less than watermark\",n=!0),e.ended||e.reading?u(\"reading or ended\",n=!1):n&&(u(\"do read\"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=T(r,e))),null===(i=t>0?U(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&q(this)),null!==i&&this.emit(\"data\",i),i},E.prototype._read=function(t){M(this,new w(\"_read()\"))},E.prototype.pipe=function(t,e){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u(\"pipe count=%d opts=%j\",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?h:g;function a(e,n){u(\"onunpipe\"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u(\"cleanup\"),t.removeListener(\"close\",p),t.removeListener(\"finish\",m),t.removeListener(\"drain\",f),t.removeListener(\"error\",d),t.removeListener(\"unpipe\",a),r.removeListener(\"end\",h),r.removeListener(\"end\",g),r.removeListener(\"data\",c),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function h(){u(\"onend\"),t.end()}i.endEmitted?n.nextTick(o):r.once(\"end\",o),t.on(\"unpipe\",a);var f=function(t){return function(){var e=t._readableState;u(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,\"data\")&&(e.flowing=!0,j(t))}}(r);t.on(\"drain\",f);var l=!1;function c(e){u(\"ondata\");var n=t.write(e);u(\"dest.write\",n),!1===n&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!l&&(u(\"false write response, pause\",i.awaitDrain),i.awaitDrain++),r.pause())}function d(e){u(\"onerror\",e),g(),t.removeListener(\"error\",d),0===s(t,\"error\")&&M(t,e)}function p(){t.removeListener(\"finish\",m),g()}function m(){u(\"onfinish\"),t.removeListener(\"close\",p),g()}function g(){u(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",c),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",d),t.once(\"close\",p),t.once(\"finish\",m),t.emit(\"pipe\",r),i.flowing||(u(\"pipe resume\"),r.resume()),t},E.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s<n;s++)i[s].emit(\"unpipe\",this,{hasUnpiped:!1});return this}var o=H(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit(\"unpipe\",this,r)),this},E.prototype.on=function(t,e){var r=o.prototype.on.call(this,t,e),i=this._readableState;return\"data\"===t?(i.readableListening=this.listenerCount(\"readable\")>0,!1!==i.flowing&&this.resume()):\"readable\"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u(\"on readable\",i.length,i.reading),i.length?C(this):i.reading||n.nextTick(L,this))),r},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return\"readable\"===t&&n.nextTick(B,this),r},E.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return\"readable\"!==t&&void 0!==t||n.nextTick(B,this),e},E.prototype.resume=function(){var t=this._readableState;return t.flowing||(u(\"resume\"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(N,t,e))}(this,t)),t.paused=!1,this},E.prototype.pause=function(){return u(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(u(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this._readableState.paused=!0,this},E.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on(\"end\",function(){if(u(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on(\"data\",function(n){(u(\"wrapped data\"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(e.push(n)||(i=!0,t.pause()))}),t)void 0===this[n]&&\"function\"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s<S.length;s++)t.on(S[s],this.emit.bind(this,S[s]));return this._read=function(e){u(\"wrapped _read\",e),i&&(i=!1,t.resume())},this},\"function\"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===c&&(c=r(2955)),c(this)}),Object.defineProperty(E.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,\"readableBuffer\",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,\"readableFlowing\",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),E._fromList=U,Object.defineProperty(E.prototype,\"readableLength\",{enumerable:!1,get:function(){return this._readableState.length}}),\"function\"==typeof Symbol&&(E.from=function(t,e){return void 0===d&&(d=r(6532)),d(E,t,e)})},5435:t=>{t.exports={byteLength:function(t){return 2*t.length},toString:function(t){const e=t.byteLength;let r=\"\";for(let i=0;i<e-1;i+=2)r+=String.fromCharCode(t[i]+256*t[i+1]);return r},write:function(t,e){const r=t.byteLength;let i=r;for(let r=0;r<e.length&&!((i-=2)<0);++r){const i=e.charCodeAt(r),n=i>>8,s=i%256;t[2*r]=s,t[2*r+1]=n}return r}}},5472:(t,e,r)=>{var i=r(717),n=function(t,e,r,i){if(this.bucketSize=t,this.tokensPerInterval=e,\"string\"==typeof r)switch(r){case\"sec\":case\"second\":this.interval=1e3;break;case\"min\":case\"minute\":this.interval=6e4;break;case\"hr\":case\"hour\":this.interval=36e5;break;case\"day\":this.interval=864e5;break;default:throw new Error(\"Invaid interval \"+r)}else this.interval=r;this.parentBucket=i,this.content=0,this.lastDrip=+new Date};n.prototype={bucketSize:1,tokensPerInterval:1,interval:1e3,parentBucket:null,content:0,lastDrip:0,removeTokens:function(t,e){var r=this;return this.bucketSize?t>this.bucketSize?(i.nextTick(e.bind(null,\"Requested tokens \"+t+\" exceeds bucket size \"+this.bucketSize,null)),!1):(this.drip(),t>this.content?n():this.parentBucket?this.parentBucket.removeTokens(t,function(i,s){return i?e(i,null):t>r.content?n():(r.content-=t,void e(null,Math.min(s,r.content)))}):(this.content-=t,i.nextTick(e.bind(null,null,this.content)),!0)):(i.nextTick(e.bind(null,null,t,Number.POSITIVE_INFINITY)),!0);function n(){var i=Math.ceil((t-r.content)*(r.interval/r.tokensPerInterval));return setTimeout(function(){r.removeTokens(t,e)},i),!1}},tryRemoveTokens:function(t){return!this.bucketSize||!(t>this.bucketSize)&&(this.drip(),!(t>this.content)&&(!(this.parentBucket&&!this.parentBucket.tryRemoveTokens(t))&&(this.content-=t,!0)))},drip:function(){if(this.tokensPerInterval){var t=+new Date,e=Math.max(t-this.lastDrip,0);this.lastDrip=t;var r=e*(this.tokensPerInterval/this.interval);this.content=Math.min(this.content+r,this.bucketSize)}else this.content=this.bucketSize}},t.exports=n},5488:(t,e,r)=>{var i=r(1565),n=r(4196),s=r(2455),o=r(3382);i.pbkdf2Sync&&-1!==i.pbkdf2Sync.toString().indexOf(\"keylen, digest\")?(e.pbkdf2Sync=function(t,e,r,a,h){return n(r,a),t=o(t,s,\"Password\"),e=o(e,s,\"Salt\"),h=h||\"sha1\",i.pbkdf2Sync(t,e,r,a,h)},e.pbkdf2=function(t,e,r,a,h,u){if(n(r,a),t=o(t,s,\"Password\"),e=o(e,s,\"Salt\"),\"function\"==typeof h&&(u=h,h=\"sha1\"),\"function\"!=typeof u)throw new Error(\"No callback provided to pbkdf2\");return i.pbkdf2(t,e,r,a,h,u)}):(e.pbkdf2Sync=r(681),e.pbkdf2=r(3832))},5579:t=>{t.exports=JSON.parse('{\"2.16.840.1.101.3.4.1.1\":\"aes-128-ecb\",\"2.16.840.1.101.3.4.1.2\":\"aes-128-cbc\",\"2.16.840.1.101.3.4.1.3\":\"aes-128-ofb\",\"2.16.840.1.101.3.4.1.4\":\"aes-128-cfb\",\"2.16.840.1.101.3.4.1.21\":\"aes-192-ecb\",\"2.16.840.1.101.3.4.1.22\":\"aes-192-cbc\",\"2.16.840.1.101.3.4.1.23\":\"aes-192-ofb\",\"2.16.840.1.101.3.4.1.24\":\"aes-192-cfb\",\"2.16.840.1.101.3.4.1.41\":\"aes-256-ecb\",\"2.16.840.1.101.3.4.1.42\":\"aes-256-cbc\",\"2.16.840.1.101.3.4.1.43\":\"aes-256-ofb\",\"2.16.840.1.101.3.4.1.44\":\"aes-256-cfb\"}')},5622:(t,e,r)=>{var i=r(8287).Buffer;function n(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):\"[object Array]\"===n(t)},e.isBoolean=function(t){return\"boolean\"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return\"number\"==typeof t},e.isString=function(t){return\"string\"==typeof t},e.isSymbol=function(t){return\"symbol\"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return\"[object RegExp]\"===n(t)},e.isObject=function(t){return\"object\"==typeof t&&null!==t},e.isDate=function(t){return\"[object Date]\"===n(t)},e.isError=function(t){return\"[object Error]\"===n(t)||t instanceof Error},e.isFunction=function(t){return\"function\"==typeof t},e.isPrimitive=function(t){return null===t||\"boolean\"==typeof t||\"number\"==typeof t||\"string\"==typeof t||\"symbol\"==typeof t||void 0===t},e.isBuffer=i.isBuffer},5658:(t,e,r)=>{r.d(e,{A:()=>g,enableSecure:()=>m});var i=r(7007),n=r(8179),s=r(1314),o=r(7833),a=r(6458);const h=\"tcpIncoming\",u=\"tcpOutgoing\",f=\"utpIncoming\",l=\"utpOutgoing\",c=\"webSeed\",d=o(\"webtorrent:peer\");let p=!1;const m=()=>{p=!0};class g extends i{constructor(t,e){super(),this.id=t,this.type=e,d(\"new %s Peer %s\",e,t),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.source=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentPe1=!1,this.sentPe2=!1,this.sentPe3=!1,this.sentPe4=!1,this.sentHandshake=!1}onConnect(){if(this.destroyed)return;this.connected=!0,this.emit(\"connect\"),d(\"Peer %s connected\",this.id),clearTimeout(this.connectTimeout);const t=this.conn;t.once(\"end\",()=>{this.destroy()}),t.once(\"close\",()=>{this.destroy()}),t.once(\"finish\",()=>{this.destroy()}),t.once(\"error\",t=>{this.destroy(t)});const e=this.wire=new a.A(this.type,this.retries,p);e.once(\"end\",()=>{this.destroy()}),e.once(\"close\",()=>{this.destroy()}),e.once(\"finish\",()=>{this.destroy()}),e.once(\"error\",t=>{this.destroy(t)}),e.once(\"pe1\",()=>{this.onPe1()}),e.once(\"pe2\",()=>{this.onPe2()}),e.once(\"pe3\",()=>{this.onPe3()}),e.once(\"pe4\",()=>{this.onPe4()}),e.once(\"handshake\",(t,e)=>{this.onHandshake(t,e)}),this.startHandshakeTimeout(),this.setThrottlePipes(),this.swarm&&(\"tcpOutgoing\"===this.type?p&&0===this.retries&&!this.sentPe1?this.sendPe1():this.sentHandshake||this.handshake():\"tcpIncoming\"===this.type||this.sentHandshake||this.handshake())}sendPe1(){this.wire.sendPe1(),this.sentPe1=!0}onPe1(){this.sendPe2()}sendPe2(){this.wire.sendPe2(),this.sentPe2=!0}onPe2(){this.sendPe3()}sendPe3(){this.wire.sendPe3(this.swarm.infoHash),this.sentPe3=!0}onPe3(t){this.swarm&&(this.swarm.infoHashHash!==t&&this.destroy(new Error(\"unexpected crypto handshake info hash for this swarm\")),this.sendPe4())}sendPe4(){this.wire.sendPe4(this.swarm.infoHash),this.sentPe4=!0}onPe4(){this.sentHandshake||this.handshake()}clearPipes(){this.conn.unpipe(),this.wire.unpipe()}setThrottlePipes(){const t=this;(0,n.pipeline)(this.conn,this.throttleGroups.down.throttle(),new n.Transform({transform(e,r){t.emit(\"download\",e.length),t.destroyed||r(null,e)}}),this.wire,this.throttleGroups.up.throttle(),new n.Transform({transform(e,r){t.emit(\"upload\",e.length),t.destroyed||r(null,e)}}),this.conn)}onHandshake(t,e){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error(\"swarm already destroyed\"));if(t!==this.swarm.infoHash)return this.destroy(new Error(\"unexpected handshake info hash for this swarm\"));if(e===this.swarm.peerId)return this.destroy(new Error(\"refusing to connect to ourselves\"));d(\"Peer %s got handshake %s\",this.id,t),clearTimeout(this.handshakeTimeout),this.retries=0;let r=this.addr;!r&&this.conn.remoteAddress&&this.conn.remotePort&&(r=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,r),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const t={dht:!this.swarm.private&&!!this.swarm.client.dht,fast:!0};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,t),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout);const t={webrtc:25e3,tcpOutgoing:5e3,utpOutgoing:5e3};this.connectTimeout=setTimeout(()=>{this.destroy(new Error(\"connect timeout\"))},t[this.type]),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(t){if(this.destroyed)return;this.destroyed=!0,this.connected&&this.emit(\"disconnect\",t),this.connected=!1,d(\"destroy %s %s (error: %s)\",this.type,this.id,t&&(t.message||t)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const e=this.swarm,r=this.conn,i=this.wire;this.swarm=null,this.conn=null,this.wire=null,e&&i&&s(e.wires,e.wires.indexOf(i)),r&&(r.on(\"error\",()=>{}),r.destroy()),i&&i.destroy(),e&&e.removePeer(this.id)}}g.TYPE_TCP_INCOMING=h,g.TYPE_TCP_OUTGOING=u,g.TYPE_UTP_INCOMING=f,g.TYPE_UTP_OUTGOING=l,g.TYPE_WEBRTC=\"webrtc\",g.TYPE_WEBSEED=c,g.SOURCE_MANUAL=\"manual\",g.SOURCE_TRACKER=\"tracker\",g.SOURCE_DHT=\"dht\",g.SOURCE_LSD=\"lsd\",g.SOURCE_UT_PEX=\"ut_pex\",g.createWebRTCPeer=(t,e,r,i=null)=>{const n=new g(t.id,\"webrtc\");if(n.conn=t,n.swarm=e,n.throttleGroups=r,n.source=i,n.conn.connected)n.onConnect();else{const t=()=>{n.conn.removeListener(\"connect\",e),n.conn.removeListener(\"error\",r)},e=()=>{t(),n.onConnect()},r=e=>{t(),n.destroy(e)};n.conn.once(\"connect\",e),n.conn.once(\"error\",r),n.startConnectTimeout()}return n},g.createTCPIncomingPeer=(t,e)=>g._createIncomingPeer(t,h,e),g.createUTPIncomingPeer=(t,e)=>g._createIncomingPeer(t,f,e),g.createTCPOutgoingPeer=(t,e,r,i)=>g._createOutgoingPeer(t,e,u,r,i),g.createUTPOutgoingPeer=(t,e,r,i)=>g._createOutgoingPeer(t,e,l,r,i),g._createIncomingPeer=(t,e,r)=>{const i=`${t.remoteAddress}:${t.remotePort}`,n=new g(i,e);return n.conn=t,n.addr=i,n.throttleGroups=r,n.onConnect(),n},g._createOutgoingPeer=(t,e,r,i,n=null)=>{const s=new g(t,r);return s.addr=t,s.swarm=e,s.throttleGroups=i,s.source=n,s},g.createWebSeedPeer=(t,e,r,i)=>{const n=new g(e,c);return n.swarm=r,n.conn=t,n.throttleGroups=i,n.onConnect(),n}},5680:(t,e,r)=>{var i=r(5767);t.exports=function(t){return!!i(t)}},5682:(t,e,r)=>{const i=r(6209),n=r(943),s=r(1847),o=r(6679),a=r(5435),h=255===new Uint8Array(Uint16Array.of(255).buffer)[0];function u(t){switch(t){case\"ascii\":return i;case\"base64\":return n;case\"hex\":return s;case\"utf8\":case\"utf-8\":case void 0:case null:return o;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return a;default:throw new Error(`Unknown encoding '${t}'`)}}function f(t,e){if(t===e)return 0;const r=Math.min(t.byteLength,e.byteLength);t=new DataView(t.buffer,t.byteOffset,t.byteLength),e=new DataView(e.buffer,e.byteOffset,e.byteLength);let i=0;for(let n=r-r%4;i<n;i+=4){if(t.getUint32(i,h)!==e.getUint32(i,h))break}for(;i<r;i++){const r=t.getUint8(i),n=e.getUint8(i);if(r<n)return-1;if(r>n)return 1}return t.byteLength>e.byteLength?1:t.byteLength<e.byteLength?-1:0}function l(t,e,r){return\"string\"==typeof t?function(t,e){const r=u(e),i=new Uint8Array(r.byteLength(t));return r.write(i,t),i}(t,e):Array.isArray(t)?function(t){const e=new Uint8Array(t.length);return e.set(t),e}(t):ArrayBuffer.isView(t)?function(t){const e=new Uint8Array(t.byteLength);return e.set(t),e}(t):function(t,e,r){return new Uint8Array(t,e,r)}(t,e,r)}function c(t,e,r,i){return d(t,e,r,i,!0)}function d(t,e,r,i,n){if(0===t.byteLength)return-1;if(\"string\"==typeof r?(i=r,r=0):void 0===r?r=n?0:t.length-1:r<0&&(r+=t.byteLength),r>=t.byteLength){if(n)return-1;r=t.byteLength-1}else if(r<0){if(!n)return-1;r=0}if(\"string\"==typeof e)e=l(e,i);else if(\"number\"==typeof e)return e&=255,n?t.indexOf(e,r):t.lastIndexOf(e,r);if(0===e.byteLength)return-1;if(n){let i=-1;for(let n=r;n<t.byteLength;n++)if(t[n]===e[-1===i?0:n-i]){if(-1===i&&(i=n),n-i+1===e.byteLength)return i}else-1!==i&&(n-=n-i),i=-1}else{r+e.byteLength>t.byteLength&&(r=t.byteLength-e.byteLength);for(let i=r;i>=0;i--){let r=!0;for(let n=0;n<e.byteLength;n++)if(t[i+n]!==e[n]){r=!1;break}if(r)return i}}return-1}function p(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}t.exports=e={isBuffer:function(t){return t instanceof Uint8Array},isEncoding:function(t){try{return u(t),!0}catch{return!1}},alloc:function(t,r,i){const n=new Uint8Array(t);return void 0!==r&&e.fill(n,r,0,n.byteLength,i),n},allocUnsafe:function(t){return new Uint8Array(t)},allocUnsafeSlow:function(t){return new Uint8Array(t)},byteLength:function(t,e){return u(e).byteLength(t)},compare:f,concat:function(t,e){void 0===e&&(e=t.reduce((t,e)=>t+e.byteLength,0));const r=new Uint8Array(e);let i=0;for(const e of t){if(i+e.byteLength>r.byteLength)return r.set(e.subarray(0,r.byteLength-i),i),r;r.set(e,i),i+=e.byteLength}return r},copy:function(t,e,r=0,i=0,n=t.byteLength){if(r<0&&(r=0),r>=e.byteLength)return 0;const s=e.byteLength-r;if(i<0&&(i=0),i>=t.byteLength)return 0;if(n<=i)return 0;n>t.byteLength&&(n=t.byteLength),n-i>s&&(n=i+s);const o=n-i;return t===e?e.copyWithin(r,i,n):(0===i&&n===t.byteLength||(t=t.subarray(i,n)),e.set(t,r)),o},equals:function(t,e){return t===e||t.byteLength===e.byteLength&&0===f(t,e)},fill:function(t,r,i=0,n=t.byteLength,s=\"utf8\"){if(\"string\"==typeof r?\"string\"==typeof i?(s=i,i=0,n=t.byteLength):\"string\"==typeof n&&(s=n,n=t.byteLength):\"number\"==typeof r?r&=255:\"boolean\"==typeof r&&(r=+r),i<0&&(i=0),i>=t.byteLength)return t;if(n<=i)return t;if(n>t.byteLength&&(n=t.byteLength),\"number\"==typeof r)return t.fill(r,i,n);\"string\"==typeof r&&(r=e.from(r,s));const o=r.byteLength;for(let e=0,s=n-i;e<s;++e)t[e+i]=r[e%o];return t},from:l,includes:function(t,e,r,i){return-1!==c(t,e,r,i)},indexOf:c,lastIndexOf:function(t,e,r,i){return d(t,e,r,i,!1)},swap16:function(t){const e=t.byteLength;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let r=0;r<e;r+=2)p(t,r,r+1);return t},swap32:function(t){const e=t.byteLength;if(e%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(let r=0;r<e;r+=4)p(t,r,r+3),p(t,r+1,r+2);return t},swap64:function(t){const e=t.byteLength;if(e%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(let r=0;r<e;r+=8)p(t,r,r+7),p(t,r+1,r+6),p(t,r+2,r+5),p(t,r+3,r+4);return t},toBuffer:function(t){return t},toString:function(t,e=\"utf8\",r=0,i=t.byteLength){return 1===arguments.length?o.toString(t):2===arguments.length?u(e).toString(t):(r<0&&(r=0),r>=t.byteLength||i<=r?\"\":(i>t.byteLength&&(i=t.byteLength),0===r&&i===t.byteLength||(t=t.subarray(r,i)),u(e).toString(t)))},write:function(t,r,i,n,s){if(2===arguments.length)return o.write(t,r);\"string\"==typeof i?(s=i,i=0,n=t.byteLength):\"string\"==typeof n&&(s=n,n=t.byteLength-i),n=Math.min(n,e.byteLength(r,s));let a=i;if(a<0&&(a=0),a>=t.byteLength)return 0;let h=i+n;return h<=a?0:(h>t.byteLength&&(h=t.byteLength),0===a&&h===t.byteLength||(t=t.subarray(a,h)),u(s).write(t,r))},readDoubleBE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e,!1)},readDoubleLE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e,!0)},readFloatBE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e,!1)},readFloatLE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e,!0)},readInt32BE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt32(e,!1)},readInt32LE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt32(e,!0)},readUInt32BE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(e,!1)},readUInt32LE:function(t,e=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(e,!0)},writeDoubleBE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e,!1),r+8},writeDoubleLE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e,!0),r+8},writeFloatBE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e,!1),r+4},writeFloatLE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e,!0),r+4},writeInt32BE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setInt32(r,e,!1),r+4},writeInt32LE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setInt32(r,e,!0),r+4},writeUInt32BE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint32(r,e,!1),r+4},writeUInt32LE:function(t,e,r=0){return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint32(r,e,!0),r+4}}},5715:(t,e,r)=>{t.exports=r(2951)},5767:(t,e,r)=>{var i=r(2682),n=r(9209),s=r(487),o=r(6556),a=r(5795),h=r(3628),u=o(\"Object.prototype.toString\"),f=r(9092)(),l=globalThis,c=n(),d=o(\"String.prototype.slice\"),p=o(\"Array.prototype.indexOf\",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},m={__proto__:null};i(c,f&&a&&h?function(t){var e=new l[t];if(Symbol.toStringTag in e&&h){var r=h(e),i=a(r,Symbol.toStringTag);if(!i&&r){var n=h(r);i=a(n,Symbol.toStringTag)}m[\"$\"+t]=s(i.get)}}:function(t){var e=new l[t],r=e.slice||e.set;r&&(m[\"$\"+t]=s(r))});t.exports=function(t){if(!t||\"object\"!=typeof t)return!1;if(!f){var e=d(u(t),8,-1);return p(c,e)>-1?e:\"Object\"===e&&function(t){var e=!1;return i(m,function(r,i){if(!e)try{r(t),e=d(i,1)}catch(t){}}),e}(t)}return a?function(t){var e=!1;return i(m,function(r,i){if(!e)try{\"$\"+r(t)===i&&(e=d(i,1))}catch(t){}}),e}(t):null}},5795:(t,e,r)=>{var i=r(6549);if(i)try{i([],\"length\")}catch(t){i=null}t.exports=i},5799:(t,e,r)=>{var i=r(530),n=r(2356),s=r(2861).Buffer,o=r(650),a=r(6168),h=r(462),u=r(8078);function f(t,e,r){a.call(this),this._cache=new c,this._cipher=new h.AES(e),this._prev=s.from(r),this._mode=t,this._autopadding=!0}r(6698)(f,a),f.prototype._update=function(t){var e,r;this._cache.add(t);for(var i=[];e=this._cache.get();)r=this._mode.encrypt(this,e),i.push(r);return s.concat(i)};var l=s.alloc(16,16);function c(){this.cache=s.allocUnsafe(0)}function d(t,e,r){var a=i[t.toLowerCase()];if(!a)throw new TypeError(\"invalid suite type\");if(\"string\"==typeof e&&(e=s.from(e)),e.length!==a.key/8)throw new TypeError(\"invalid key length \"+e.length);if(\"string\"==typeof r&&(r=s.from(r)),\"GCM\"!==a.mode&&r.length!==a.iv)throw new TypeError(\"invalid iv length \"+r.length);return\"stream\"===a.type?new o(a.module,e,r):\"auth\"===a.type?new n(a.module,e,r):new f(a.module,e,r)}f.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(l))throw this._cipher.scrub(),new Error(\"data not multiple of block length\")},f.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},c.prototype.add=function(t){this.cache=s.concat([this.cache,t])},c.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},c.prototype.flush=function(){for(var t=16-this.cache.length,e=s.allocUnsafe(t),r=-1;++r<t;)e.writeUInt8(t,r);return s.concat([this.cache,e])},e.createCipheriv=d,e.createCipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError(\"invalid suite type\");var n=u(e,!1,r.key,r.iv);return d(t,n.key,n.iv)}},5809:t=>{t.exports=class{constructor(t){if(!(t>0)||t-1&t)throw new Error(\"Max size for a FixedFIFO should be a power of two\");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}clear(){this.top=this.btm=0,this.next=null,this.buffer.fill(void 0)}push(t){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){const t=this.buffer[this.btm];if(void 0!==t)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},5880:t=>{t.exports=Math.pow},5892:(t,e,r)=>{var i=r(2861).Buffer,n=i.alloc(16,0);function s(t){var e=i.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=i.alloc(16,0),this.cache=i.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e<t.length;)this.state[e]^=t[e];this._multiply()},o.prototype._multiply=function(){for(var t,e,r,i=[(t=this.h).readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)],n=[0,0,0,0],o=-1;++o<128;){for(!!(this.state[~~(o/8)]&1<<7-o%8)&&(n[0]^=i[0],n[1]^=i[1],n[2]^=i[2],n[3]^=i[3]),r=!!(1&i[3]),e=3;e>0;e--)i[e]=i[e]>>>1|(1&i[e-1])<<31;i[0]=i[0]>>>1,r&&(i[0]=i[0]^225<<24)}this.state=s(n)},o.prototype.update=function(t){var e;for(this.cache=i.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(i.concat([this.cache,n],16)),this.ghash(s([0,t,0,e])),this.state},t.exports=o},5896:(t,e,r)=>{var i=r(717);function n(t,e){o(t,e),s(t)}function s(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit(\"close\")}function o(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,e){var r=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(o,this,t)):i.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted?i.nextTick(s,r):(r._writableState.errorEmitted=!0,i.nextTick(n,r,t)):i.nextTick(n,r,t):e?(i.nextTick(s,r),e(t)):i.nextTick(s,r)}),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)},errorOrDestroy:function(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit(\"error\",e)}}},5905:(t,e,r)=>{var i=r(4529);function n(t){i.ok(t===n.REQUEST||t===n.RESPONSE),this.type=t,this.state=t+\"_LINE\",this.info={headers:[],upgrade:!1},this.trailers=[],this.line=\"\",this.isChunked=!1,this.connection=\"\",this.headerSize=0,this.body_bytes=null,this.isUserCall=!1,this.hadError=!1}e.HTTPParser=n,n.encoding=\"ascii\",n.maxHeaderSize=81920,n.REQUEST=\"REQUEST\",n.RESPONSE=\"RESPONSE\";var s=n.kOnHeaders=0,o=n.kOnHeadersComplete=1,a=n.kOnBody=2,h=n.kOnMessageComplete=3;n.prototype[s]=n.prototype[o]=n.prototype[a]=n.prototype[h]=function(){};var u=!0;Object.defineProperty(n,\"kOnExecute\",{get:function(){return u=!1,4}});var f=e.methods=n.methods=[\"DELETE\",\"GET\",\"HEAD\",\"POST\",\"PUT\",\"CONNECT\",\"OPTIONS\",\"TRACE\",\"COPY\",\"LOCK\",\"MKCOL\",\"MOVE\",\"PROPFIND\",\"PROPPATCH\",\"SEARCH\",\"UNLOCK\",\"BIND\",\"REBIND\",\"UNBIND\",\"ACL\",\"REPORT\",\"MKACTIVITY\",\"CHECKOUT\",\"MERGE\",\"M-SEARCH\",\"NOTIFY\",\"SUBSCRIBE\",\"UNSUBSCRIBE\",\"PATCH\",\"PURGE\",\"MKCALENDAR\",\"LINK\",\"UNLINK\"],l=f.indexOf(\"CONNECT\");n.prototype.reinitialize=n,n.prototype.close=n.prototype.pause=n.prototype.resume=n.prototype.free=function(){},n.prototype._compatMode0_11=!1,n.prototype.getAsyncId=function(){return 0};var c={REQUEST_LINE:!0,RESPONSE_LINE:!0,HEADER:!0};n.prototype.execute=function(t,e,r){if(!(this instanceof n))throw new TypeError(\"not a HTTPParser\");e=e||0,r=\"number\"==typeof r?r:t.length,this.chunk=t,this.offset=e;var i=this.end=e+r;try{for(;this.offset<i&&!this[this.state](););}catch(t){if(this.isUserCall)throw t;return this.hadError=!0,t}return this.chunk=null,r=this.offset-e,c[this.state]&&(this.headerSize+=r,this.headerSize>n.maxHeaderSize)?new Error(\"max header size exceeded\"):r};var d={REQUEST_LINE:!0,RESPONSE_LINE:!0,BODY_RAW:!0};n.prototype.finish=function(){if(!this.hadError)return d[this.state]?void(\"BODY_RAW\"===this.state&&this.userCall()(this[h]())):new Error(\"invalid state for EOF\")},n.prototype.consume=n.prototype.unconsume=n.prototype.getCurrentBuffer=function(){},n.prototype.userCall=function(){this.isUserCall=!0;var t=this;return function(e){return t.isUserCall=!1,e}},n.prototype.nextRequest=function(){this.userCall()(this[h]()),this.reinitialize(this.type)},n.prototype.consumeLine=function(){for(var t=this.end,e=this.chunk,r=this.offset;r<t;r++)if(10===e[r]){var i=this.line+e.toString(n.encoding,this.offset,r);return\"\\r\"===i.charAt(i.length-1)&&(i=i.substr(0,i.length-1)),this.line=\"\",this.offset=r+1,i}this.line+=e.toString(n.encoding,this.offset,this.end),this.offset=this.end};var p=/^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/,m=/^[ \\t]+(.*[^ \\t])/;n.prototype.parseHeader=function(t,e){if(-1!==t.indexOf(\"\\r\"))throw b(\"HPE_LF_EXPECTED\");var r=p.exec(t),i=r&&r[1];if(i)e.push(i),e.push(r[2]);else{var n=m.exec(t);n&&e.length&&(e[e.length-1]&&(e[e.length-1]+=\" \"),e[e.length-1]+=n[1])}};var g=/^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;n.prototype.REQUEST_LINE=function(){var t=this.consumeLine();if(t){var e=g.exec(t);if(null===e)throw b(\"HPE_INVALID_CONSTANT\");if(this.info.method=this._compatMode0_11?e[1]:f.indexOf(e[1]),-1===this.info.method)throw new Error(\"invalid request method\");this.info.url=e[2],this.info.versionMajor=+e[3],this.info.versionMinor=+e[4],this.body_bytes=0,this.state=\"HEADER\"}};var y=/^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;function b(t){var e=new Error(\"Parse Error\");return e.code=t,e}n.prototype.RESPONSE_LINE=function(){var t=this.consumeLine();if(t){var e=y.exec(t);if(null===e)throw b(\"HPE_INVALID_CONSTANT\");this.info.versionMajor=+e[1],this.info.versionMinor=+e[2];var r=this.info.statusCode=+e[3];this.info.statusMessage=e[4],1!=(r/100|0)&&204!==r&&304!==r||(this.body_bytes=0),this.state=\"HEADER\"}},n.prototype.shouldKeepAlive=function(){if(this.info.versionMajor>0&&this.info.versionMinor>0){if(-1!==this.connection.indexOf(\"close\"))return!1}else if(-1===this.connection.indexOf(\"keep-alive\"))return!1;return!(null===this.body_bytes&&!this.isChunked)},n.prototype.HEADER=function(){var t=this.consumeLine();if(void 0!==t){var e=this.info;if(t)this.parseHeader(t,e.headers);else{for(var r,i,s=e.headers,a=!1,h=!1,f=0;f<s.length;f+=2)switch(s[f].toLowerCase()){case\"transfer-encoding\":this.isChunked=\"chunked\"===s[f+1].toLowerCase();break;case\"content-length\":if(r=+s[f+1],a){if(r!==this.body_bytes)throw b(\"HPE_UNEXPECTED_CONTENT_LENGTH\")}else a=!0,this.body_bytes=r;break;case\"connection\":this.connection+=s[f+1].toLowerCase();break;case\"upgrade\":h=!0}if(this.isChunked&&a&&(this.isChunked=!1),h&&-1!=this.connection.indexOf(\"upgrade\")?e.upgrade=this.type===n.REQUEST||101===e.statusCode:e.upgrade=e.method===l,e.shouldKeepAlive=this.shouldKeepAlive(),2===(i=u?this.userCall()(this[o](e)):this.userCall()(this[o](e.versionMajor,e.versionMinor,e.headers,e.method,e.url,e.statusCode,e.statusMessage,e.upgrade,e.shouldKeepAlive))))return this.nextRequest(),!0;if(this.isChunked&&!i)this.state=\"BODY_CHUNKHEAD\";else{if(i||0===this.body_bytes)return this.nextRequest(),e.upgrade;null===this.body_bytes?this.state=\"BODY_RAW\":this.state=\"BODY_SIZED\"}}}},n.prototype.BODY_CHUNKHEAD=function(){var t=this.consumeLine();void 0!==t&&(this.body_bytes=parseInt(t,16),this.body_bytes?this.state=\"BODY_CHUNK\":this.state=\"BODY_CHUNKTRAILERS\")},n.prototype.BODY_CHUNK=function(){var t=Math.min(this.end-this.offset,this.body_bytes);this.userCall()(this[a](this.chunk,this.offset,t)),this.offset+=t,this.body_bytes-=t,this.body_bytes||(this.state=\"BODY_CHUNKEMPTYLINE\")},n.prototype.BODY_CHUNKEMPTYLINE=function(){var t=this.consumeLine();void 0!==t&&(i.equal(t,\"\"),this.state=\"BODY_CHUNKHEAD\")},n.prototype.BODY_CHUNKTRAILERS=function(){var t=this.consumeLine();void 0!==t&&(t?this.parseHeader(t,this.trailers):(this.trailers.length&&this.userCall()(this[s](this.trailers,\"\")),this.nextRequest()))},n.prototype.BODY_RAW=function(){var t=this.end-this.offset;this.userCall()(this[a](this.chunk,this.offset,t)),this.offset=this.end},n.prototype.BODY_SIZED=function(){var t=Math.min(this.end-this.offset,this.body_bytes);this.userCall()(this[a](this.chunk,this.offset,t)),this.offset+=t,this.body_bytes-=t,this.body_bytes||this.nextRequest()},[\"Headers\",\"HeadersComplete\",\"Body\",\"MessageComplete\"].forEach(function(t){var e=n[\"kOn\"+t];Object.defineProperty(n.prototype,\"on\"+t,{get:function(){return this[e]},set:function(t){return this._compatMode0_11=!0,l=\"CONNECT\",this[e]=t}})})},5930:(t,e,r)=>{var i=r(717);const n=r(537),s=r(8957),o=r(8835),a=r(5905).HTTPParser,h=r(4529).ok,u=r(2728),f=u.httpSocketSetup,l=u.parsers,c=u.freeParser,d=u.debug,p=r(8419).OutgoingMessage,m=r(8748),g=r(8287).Buffer;function y(t,e){var r=this;if(p.call(r),\"string\"==typeof t){if(!(t=o.parse(t)).hostname)throw new Error(\"Unable to determine the domain name\")}else t=n._extend({},t);var a=t.agent,h=t._defaultAgent||m.globalAgent;!1===a?a=new h.constructor:null==a&&\"function\"!=typeof t.createConnection&&(a=h),r.agent=a;var f=t.protocol||h.protocol,l=h.protocol;if(r.agent&&r.agent.protocol&&(l=r.agent.protocol),t.path&&/ /.test(t.path))throw new TypeError(\"Request path contains unescaped characters\");if(f!==l)throw new Error('Protocol \"'+f+'\" not supported. Expected \"'+l+'\"');const c=t.defaultPort||r.agent&&r.agent.defaultPort;var y=t.port=t.port||c||80,b=t.host=t.hostname||t.host||\"localhost\";if(void 0===t.setHost)var v=!0;r.socketPath=t.socketPath;var w=r.method=(t.method||\"GET\").toUpperCase();if(!u._checkIsHttpToken(w))throw new TypeError(\"Method must be a valid HTTP token\");if(r.path=t.path||\"/\",e&&r.once(\"response\",e),!Array.isArray(t.headers)){if(t.headers)for(var _=Object.keys(t.headers),M=0,S=_.length;M<S;M++){var k=_[M];r.setHeader(k,t.headers[k])}if(b&&!this.getHeader(\"host\")&&v){var E=b,x=-1;-1!==(x=E.indexOf(\":\"))&&-1!==(x=E.indexOf(\":\",x))&&\"[\"!==E[0]&&(E=`[${E}]`),y&&+y!==c&&(E+=\":\"+y),this.setHeader(\"Host\",E)}}t.auth&&!this.getHeader(\"Authorization\")&&this.setHeader(\"Authorization\",\"Basic \"+g.from(t.auth).toString(\"base64\")),r.useChunkedEncodingByDefault=\"GET\"!==w&&\"HEAD\"!==w&&\"DELETE\"!==w&&\"OPTIONS\"!==w&&\"CONNECT\"!==w,Array.isArray(t.headers)?r._storeHeader(r.method+\" \"+r.path+\" HTTP/1.1\\r\\n\",t.headers):r.getHeader(\"expect\")&&r._storeHeader(r.method+\" \"+r.path+\" HTTP/1.1\\r\\n\",r._renderHeaders());var A=!1;if(r.socketPath){r._last=!0,r.shouldKeepAlive=!1;const t={path:r.socketPath},e=r.agent.createConnection(t,I);if(!e||A)return;A=!0,r.onSocket(e)}else if(r.agent)r.agent.keepAlive||Number.isFinite(r.agent.maxSockets)?(r._last=!1,r.shouldKeepAlive=!0):(r._last=!0,r.shouldKeepAlive=!1),r.agent.addRequest(r,t);else if(r._last=!0,r.shouldKeepAlive=!1,\"function\"==typeof t.createConnection){const e=t.createConnection(t,I);if(!e||A)return;A=!0,r.onSocket(e)}else d(\"CLIENT use net.createConnection\",t),r.onSocket(s.createConnection(t));function I(t,e){A||(A=!0,t?i.nextTick(function(){r.emit(\"error\",t)}):(r.onSocket(e),r._deferToConnect(null,null,function(){r._flush(),r=null})))}r._deferToConnect(null,null,function(){r._flush(),r=null}),this._ended=!1}function b(t){t.emit(\"abort\")}function v(){var t=new Error(\"socket hang up\");return t.code=\"ECONNRESET\",t}function w(){var t=this,e=t._httpMessage;d(\"HTTP socket close\"),t.read();var r=t.parser;if(e.emit(\"close\"),e.res&&e.res.readable){e.res.emit(\"aborted\");var i=e.res;i.on(\"end\",function(){i.emit(\"close\")}),i.push(null)}else e.res||e.socket._hadError||(e.emit(\"error\",v()),e.socket._hadError=!0);e.output&&(e.output.length=0),e.outputEncodings&&(e.outputEncodings.length=0),r&&(r.finish(),c(r,e,t))}function _(t){var e=this,r=e._httpMessage;d(\"SOCKET ERROR:\",t.message,t.stack),r&&(r.emit(\"error\",t),r.socket._hadError=!0),e.read();var i=e.parser;i&&(i.finish(),c(i,r,e)),e.removeListener(\"data\",k),e.removeListener(\"end\",S),e.destroy()}function M(t){d(\"SOCKET ERROR on FREE socket:\",t.message,t.stack),this.destroy(),this.emit(\"agentRemove\")}function S(){var t=this._httpMessage,e=this.parser;t.res||t.socket._hadError||(t.emit(\"error\",v()),t.socket._hadError=!0),e&&(e.finish(),c(e,t,this)),this.destroy()}function k(t){var e=this,r=this._httpMessage,i=this.parser;h(i&&i.socket===e);var n=i.execute(t);if(n instanceof Error)d(\"parse error\"),c(i,r,e),e.destroy(),r.emit(\"error\",n),r.socket._hadError=!0;else if(i.incoming&&i.incoming.upgrade){var s=n,o=i.incoming;r.res=o,e.removeListener(\"data\",k),e.removeListener(\"end\",S),i.finish();var a=t.slice(s,t.length),u=\"CONNECT\"===r.method?\"connect\":\"upgrade\";r.listenerCount(u)>0?(r.upgradeOrConnect=!0,e.emit(\"agentRemove\"),e.removeListener(\"close\",w),e.removeListener(\"error\",_),e._readableState.flowing=null,r.emit(u,o,e,a),r.emit(\"close\")):e.destroy(),c(i,r,e)}else i.incoming&&i.incoming.complete&&100!==i.incoming.statusCode&&(e.removeListener(\"data\",k),e.removeListener(\"end\",S),c(i,r,e))}function E(t,e){var r=this.socket,i=r._httpMessage;if(i.domain&&!t.domain&&(d('setting \"res.domain\"'),t.domain=i.domain),d(\"AGENT incoming response!\"),!i.res){if(i.res=t,\"CONNECT\"===i.method)return t.upgrade=!0,2;var n=\"HEAD\"===i.method;return d(\"AGENT isHeadResponse\",n),100===t.statusCode?(delete i.res,i.emit(\"continue\"),!0):(!i.shouldKeepAlive||e||i.upgradeOrConnect||(i.shouldKeepAlive=!1),i.res=t,t.req=i,t.on(\"end\",A),i.on(\"prefinish\",I),i.emit(\"response\",t)||t._dump(),n)}r.destroy()}function x(t,e){var r=e.socket;e.shouldKeepAlive?(d(\"AGENT socket keep-alive\"),e.timeoutCb&&(r.setTimeout(0,e.timeoutCb),e.timeoutCb=null),r.removeListener(\"close\",w),r.removeListener(\"error\",_),r.once(\"error\",M),i.nextTick(T,r)):(r.writable&&(d(\"AGENT socket.destroySoon()\"),r.destroySoon()),h(!r.writable))}function A(){const t=this.req;t._ended=!0,t.shouldKeepAlive&&!t.finished||x(0,t)}function I(){const t=this;this.res;t.shouldKeepAlive&&t._ended&&x(0,t)}function T(t){t.emit(\"free\")}function C(t,e){t.aborted?e.emit(\"free\"):function(t,e){var r=l.alloc();t.socket=e,t.connection=e,r.reinitialize(a.RESPONSE),r.socket=e,r.incoming=null,r.outgoing=t,t.parser=r,e.parser=r,e._httpMessage=t,f(e),\"number\"==typeof t.maxHeadersCount?r.maxHeaderPairs=t.maxHeadersCount<<1:r.maxHeaderPairs=2e3,r.onIncoming=E,e.removeListener(\"error\",M),e.on(\"error\",_),e.on(\"data\",k),e.on(\"end\",S),e.on(\"close\",w),t.emit(\"socket\",e)}(t,e)}n.inherits(y,p),e.ClientRequest=y,y.prototype.aborted=void 0,y.prototype._finish=function(){p.prototype._finish.call(this)},y.prototype._implicitHeader=function(){this._storeHeader(this.method+\" \"+this.path+\" HTTP/1.1\\r\\n\",this._renderHeaders())},y.prototype.abort=function(){void 0===this.aborted&&i.nextTick(b,this),this.aborted=Date.now(),this.res?this.res._dump():this.once(\"response\",function(t){t._dump()}),this.socket&&this.socket.destroy()},y.prototype.onSocket=function(t){i.nextTick(C,this,t)},y.prototype._deferToConnect=function(t,e,r){var i=this;function n(){t&&i.socket[t].apply(i.socket,e),\"function\"==typeof r&&r()}var s=function(){i.socket.writable?n():i.socket.once(\"connect\",n)};i.socket?s():i.once(\"socket\",s)},y.prototype.setTimeout=function(t,e){e&&this.once(\"timeout\",e);var r=this;function i(){r.emit(\"timeout\")}if(this.socket&&this.socket.writable)return this.timeoutCb&&this.socket.setTimeout(0,this.timeoutCb),this.timeoutCb=i,this.socket.setTimeout(t,i),this;if(this.timeoutCb=i,this.socket){var n=this.socket;return this.socket.once(\"connect\",function(){n.setTimeout(t,i)}),this}return this.once(\"socket\",function(e){e.setTimeout(t,i)}),this},y.prototype.setNoDelay=function(){const t=arguments.length,e=new Array(t);for(var r=0;r<t;r++)e[r]=arguments[r];this._deferToConnect(\"setNoDelay\",e)},y.prototype.setSocketKeepAlive=function(){const t=arguments.length,e=new Array(t);for(var r=0;r<t;r++)e[r]=arguments[r];this._deferToConnect(\"setKeepAlive\",e)},y.prototype.clearTimeout=function(t){this.setTimeout(0,t)}},5972:(t,e,r)=>{t.exports=o;var i=r(308),n=Object.create(r(5622));function s(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit(\"error\",new Error(\"write callback called multiple times\"));r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function o(t){if(!(this instanceof o))return new o(t);i.call(this,t),this._transformState={afterTransform:s.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(\"function\"==typeof t.transform&&(this._transform=t.transform),\"function\"==typeof t.flush&&(this._flush=t.flush)),this.on(\"prefinish\",a)}function a(){var t=this;\"function\"==typeof this._flush?this._flush(function(e,r){h(t,e,r)}):h(this,null,null)}function h(t,e,r){if(e)return t.emit(\"error\",e);if(null!=r&&t.push(r),t._writableState.length)throw new Error(\"Calling transform done when ws.length != 0\");if(t._transformState.transforming)throw new Error(\"Calling transform done when still transforming\");return t.push(null)}n.inherits=r(6698),n.inherits(o,i),o.prototype.push=function(t,e){return this._transformState.needTransform=!1,i.prototype.push.call(this,t,e)},o.prototype._transform=function(t,e,r){throw new Error(\"_transform() is not implemented\")},o.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},o.prototype._read=function(t){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},o.prototype._destroy=function(t,e){var r=this;i.prototype._destroy.call(this,t,function(t){e(t),r.emit(\"close\")})}},6011:(t,e,r)=>{var i=r(8287).Buffer,n=r(6698),s=r(1147),o=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],h=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],c=[1352829926,1548603684,1836072691,2053994217,0];function d(t,e){return t<<e|t>>>32-e}function p(t,e,r,i,n,s,o,a){return d(t+(e^r^i)+s+o|0,a)+n|0}function m(t,e,r,i,n,s,o,a){return d(t+(e&r|~e&i)+s+o|0,a)+n|0}function g(t,e,r,i,n,s,o,a){return d(t+((e|~r)^i)+s+o|0,a)+n|0}function y(t,e,r,i,n,s,o,a){return d(t+(e&i|r&~i)+s+o|0,a)+n|0}function b(t,e,r,i,n,s,o,a){return d(t+(e^(r|~i))+s+o|0,a)+n|0}function v(){s.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}n(v,s),v.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,i=0|this._b,n=0|this._c,s=0|this._d,v=0|this._e,w=0|this._a,_=0|this._b,M=0|this._c,S=0|this._d,k=0|this._e,E=0;E<80;E+=1){var x,A;E<16?(x=p(r,i,n,s,v,t[a[E]],l[0],u[E]),A=b(w,_,M,S,k,t[h[E]],c[0],f[E])):E<32?(x=m(r,i,n,s,v,t[a[E]],l[1],u[E]),A=y(w,_,M,S,k,t[h[E]],c[1],f[E])):E<48?(x=g(r,i,n,s,v,t[a[E]],l[2],u[E]),A=g(w,_,M,S,k,t[h[E]],c[2],f[E])):E<64?(x=y(r,i,n,s,v,t[a[E]],l[3],u[E]),A=m(w,_,M,S,k,t[h[E]],c[3],f[E])):(x=b(r,i,n,s,v,t[a[E]],l[4],u[E]),A=p(w,_,M,S,k,t[h[E]],c[4],f[E])),r=v,v=s,s=d(n,10),n=i,i=x,w=k,k=S,S=d(M,10),M=_,_=A}var I=this._b+n+S|0;this._b=this._c+s+k|0,this._c=this._d+v+w|0,this._d=this._e+r+_|0,this._e=this._a+i+M|0,this._a=I},v.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=i.alloc?i.alloc(20):new i(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=v},6045:(t,e,r)=>{const i=r(5682);t.exports=class{constructor(){this.codePoint=0,this.bytesSeen=0,this.bytesNeeded=0,this.lowerBoundary=128,this.upperBoundary=191}get remaining(){return this.bytesSeen}decode(t){if(0===this.bytesNeeded){let e=!0;for(let r=Math.max(0,t.byteLength-4),i=t.byteLength;r<i&&e;r++)e=t[r]<=127;if(e)return i.toString(t,\"utf8\")}let e=\"\";for(let r=0,i=t.byteLength;r<i;r++){const i=t[r];0!==this.bytesNeeded?i<this.lowerBoundary||i>this.upperBoundary?(this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191,e+=\"�\"):(this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|63&i,this.bytesSeen++,this.bytesSeen===this.bytesNeeded&&(e+=String.fromCodePoint(this.codePoint),this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0)):i<=127?e+=String.fromCharCode(i):(this.bytesSeen=1,i>=194&&i<=223?(this.bytesNeeded=2,this.codePoint=31&i):i>=224&&i<=239?(224===i?this.lowerBoundary=160:237===i&&(this.upperBoundary=159),this.bytesNeeded=3,this.codePoint=15&i):i>=240&&i<=244?(240===i&&(this.lowerBoundary=144),244===i&&(this.upperBoundary=143),this.bytesNeeded=4,this.codePoint=7&i):e+=\"�\")}return e}flush(){const t=this.bytesNeeded>0?\"�\":\"\";return this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191,t}}},6080:(t,e,r)=>{const i=r(5809);t.exports=class{constructor(t){this.hwm=t||16,this.head=new i(this.hwm),this.tail=this.head,this.length=0}clear(){this.head=this.tail,this.head.clear(),this.length=0}push(t){if(this.length++,!this.head.push(t)){const e=this.head;this.head=e.next=new i(2*this.head.buffer.length),this.head.push(t)}}shift(){0!==this.length&&this.length--;const t=this.tail.shift();if(void 0===t&&this.tail.next){const t=this.tail.next;return this.tail.next=null,this.tail=t,this.tail.shift()}return t}peek(){const t=this.tail.peek();return void 0===t&&this.tail.next?this.tail.next.peek():t}isEmpty(){return 0===this.length}}},6166:(t,e,r)=>{var i=r(7426),n=r(3349);function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian=\"big\",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=s,s.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},s.prototype.digest=function(t){return this.update(this._pad()),n(null===this.pending),this._digest(t)},s.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,\"big\"===this.endian){for(var s=8;s<this.padLength;s++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s<this.padLength;s++)i[n++]=0;return i}},6168:(t,e,r)=>{var i=r(2861).Buffer,n=r(8310).Transform,s=r(3141).I,o=r(6698),a=r(5377);function h(t){n.call(this),this.hashMode=\"string\"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}o(h,n),h.prototype.update=function(t,e,r){var i=a(t,e),n=this._update(i);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},h.prototype.setAutoPadding=function(){},h.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},h.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},h.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},h.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){i=t}finally{r(i)}},h.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},h.prototype._finalOrDigest=function(t){var e=this.__final()||i.alloc(0);return t&&(e=this._toString(e,t,!0)),e},h.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new s(e),this._encoding=e),this._encoding!==e)throw new Error(\"can’t switch encodings\");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i},t.exports=h},6171:(t,e,r)=>{var i=r(2356),n=r(2861).Buffer,s=r(530),o=r(650),a=r(6168),h=r(462),u=r(8078);function f(t,e,r){a.call(this),this._cache=new l,this._last=void 0,this._cipher=new h.AES(e),this._prev=n.from(r),this._mode=t,this._autopadding=!0}function l(){this.cache=n.allocUnsafe(0)}function c(t,e,r){var a=s[t.toLowerCase()];if(!a)throw new TypeError(\"invalid suite type\");if(\"string\"==typeof r&&(r=n.from(r)),\"GCM\"!==a.mode&&r.length!==a.iv)throw new TypeError(\"invalid iv length \"+r.length);if(\"string\"==typeof e&&(e=n.from(e)),e.length!==a.key/8)throw new TypeError(\"invalid key length \"+e.length);return\"stream\"===a.type?new o(a.module,e,r,!0):\"auth\"===a.type?new i(a.module,e,r,!0):new f(a.module,e,r)}r(6698)(f,a),f.prototype._update=function(t){var e,r;this._cache.add(t);for(var i=[];e=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,e),i.push(r);return n.concat(i)},f.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return function(t){var e=t[15];if(e<1||e>16)throw new Error(\"unable to decrypt data\");var r=-1;for(;++r<e;)if(t[r+(16-e)]!==e)throw new Error(\"unable to decrypt data\");if(16===e)return;return t.slice(0,16-e)}(this._mode.decrypt(this,t));if(t)throw new Error(\"data not multiple of block length\")},f.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},l.prototype.add=function(t){this.cache=n.concat([this.cache,t])},l.prototype.get=function(t){var e;if(t){if(this.cache.length>16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},l.prototype.flush=function(){if(this.cache.length)return this.cache},e.createDecipher=function(t,e){var r=s[t.toLowerCase()];if(!r)throw new TypeError(\"invalid suite type\");var i=u(e,!1,r.key,r.iv);return c(t,i.key,i.iv)},e.createDecipheriv=c},6188:t=>{t.exports=Math.max},6209:t=>{t.exports={byteLength:function(t){return t.length},toString:function(t){const e=t.byteLength;let r=\"\";for(let i=0;i<e;i++)r+=String.fromCharCode(t[i]);return r},write:function(t,e){const r=t.byteLength;for(let i=0;i<r;i++)t[i]=e.charCodeAt(i);return r}}},6225:(t,e,r)=>{var i=r(7426).rotr32;function n(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}function o(t,e,r){return t^e^r}e.ft_1=function(t,e,r,i){return 0===t?n(e,r,i):1===t||3===t?o(e,r,i):2===t?s(e,r,i):void 0},e.ch32=n,e.maj32=s,e.p32=o,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},6229:(t,e,r)=>{var i=r(8287),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),s(n,o),o.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return n(t,e,r)},o.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var i=n(t);return void 0!==e?\"string\"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n(t)},o.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i.SlowBuffer(t)}},6238:(t,e,r)=>{var i=r(113).F.ERR_STREAM_PREMATURE_CLOSE;function n(){}t.exports=function t(e,r,s){if(\"function\"==typeof r)return t(e,null,r);r||(r={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];t.apply(this,i)}}}(s||n);var o=r.readable||!1!==r.readable&&e.readable,a=r.writable||!1!==r.writable&&e.writable,h=function(){e.writable||f()},u=e._writableState&&e._writableState.finished,f=function(){a=!1,u=!0,o||s.call(e)},l=e._readableState&&e._readableState.endEmitted,c=function(){o=!1,l=!0,a||s.call(e)},d=function(t){s.call(e,t)},p=function(){var t;return o&&!l?(e._readableState&&e._readableState.ended||(t=new i),s.call(e,t)):a&&!u?(e._writableState&&e._writableState.ended||(t=new i),s.call(e,t)):void 0},m=function(){e.req.on(\"finish\",f)};return!function(t){return t.setHeader&&\"function\"==typeof t.abort}(e)?a&&!e._writableState&&(e.on(\"end\",h),e.on(\"close\",h)):(e.on(\"complete\",f),e.on(\"abort\",p),e.req?m():e.on(\"request\",m)),e.on(\"end\",c),e.on(\"finish\",f),!1!==r.error&&e.on(\"error\",d),e.on(\"close\",p),function(){e.removeListener(\"complete\",f),e.removeListener(\"abort\",p),e.removeListener(\"request\",m),e.req&&e.req.removeListener(\"finish\",f),e.removeListener(\"end\",h),e.removeListener(\"close\",h),e.removeListener(\"finish\",f),e.removeListener(\"end\",c),e.removeListener(\"error\",d),e.removeListener(\"close\",p)}}},6248:(t,e,r)=>{var i=r(3225),n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=l;var s=Object.create(r(5622));s.inherits=r(6698);var o=r(206),a=r(7314);s.inherits(l,o);for(var h=n(a.prototype),u=0;u<h.length;u++){var f=h[u];l.prototype[f]||(l.prototype[f]=a.prototype[f])}function l(t){if(!(this instanceof l))return new l(t);o.call(this,t),a.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once(\"end\",c)}function c(){this.allowHalfOpen||this._writableState.ended||i.nextTick(d,this)}function d(t){t.end()}Object.defineProperty(l.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,\"destroyed\",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),l.prototype._destroy=function(t,e){this.push(null),this.end(),i.nextTick(e,t)}},6278:(t,e,r)=>{var i=r(3225);function n(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(n,this,t)):i.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,i.nextTick(n,r,t)):i.nextTick(n,r,t):e&&e(t)}),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)}}},6310:t=>{function e(t,e){for(const r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}t.exports=function(t,r,i){if(!t||\"string\"==typeof t)throw new TypeError(\"Please pass an Error to err-code\");i||(i={}),\"object\"==typeof r&&(i=r,r=\"\"),r&&(i.code=r);try{return e(t,i)}catch(r){i.message=t.message,i.stack=t.stack;const n=function(){};n.prototype=Object.create(Object.getPrototypeOf(t));return e(new n,i)}}},6383:(t,e,r)=>{var i=r(2861).Buffer,n=r(295);function s(t,e,r){var s=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(s),t._prev=i.concat([t._prev,r?e:o]),o}e.encrypt=function(t,e,r){for(var n,o=i.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=i.allocUnsafe(0)),!(t._cache.length<=e.length)){o=i.concat([o,s(t,e,r)]);break}n=t._cache.length,o=i.concat([o,s(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},6413:(t,e,r)=>{var i=r(7568),n=i.define(\"Time\",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),s=i.define(\"AttributeTypeValue\",function(){this.seq().obj(this.key(\"type\").objid(),this.key(\"value\").any())}),o=i.define(\"AlgorithmIdentifier\",function(){this.seq().obj(this.key(\"algorithm\").objid(),this.key(\"parameters\").optional(),this.key(\"curve\").objid().optional())}),a=i.define(\"SubjectPublicKeyInfo\",function(){this.seq().obj(this.key(\"algorithm\").use(o),this.key(\"subjectPublicKey\").bitstr())}),h=i.define(\"RelativeDistinguishedName\",function(){this.setof(s)}),u=i.define(\"RDNSequence\",function(){this.seqof(h)}),f=i.define(\"Name\",function(){this.choice({rdnSequence:this.use(u)})}),l=i.define(\"Validity\",function(){this.seq().obj(this.key(\"notBefore\").use(n),this.key(\"notAfter\").use(n))}),c=i.define(\"Extension\",function(){this.seq().obj(this.key(\"extnID\").objid(),this.key(\"critical\").bool().def(!1),this.key(\"extnValue\").octstr())}),d=i.define(\"TBSCertificate\",function(){this.seq().obj(this.key(\"version\").explicit(0).int().optional(),this.key(\"serialNumber\").int(),this.key(\"signature\").use(o),this.key(\"issuer\").use(f),this.key(\"validity\").use(l),this.key(\"subject\").use(f),this.key(\"subjectPublicKeyInfo\").use(a),this.key(\"issuerUniqueID\").implicit(1).bitstr().optional(),this.key(\"subjectUniqueID\").implicit(2).bitstr().optional(),this.key(\"extensions\").explicit(3).seqof(c).optional())}),p=i.define(\"X509Certificate\",function(){this.seq().obj(this.key(\"tbsCertificate\").use(d),this.key(\"signatureAlgorithm\").use(o),this.key(\"signatureValue\").bitstr())});t.exports=p},6427:(t,e,r)=>{var i=r(8393).Buffer,n=i.isEncoding||function(t){switch((t=\"\"+t)&&t.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 s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){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 t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=h,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=l,e=3;break;default:return this.write=c,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):\"\"}e.I=s,s.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||\"\"},s.prototype.end=function(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+\"�\":e},s.prototype.text=function(t,e){var r=function(t,e,r){var i=e.length-1;if(i<r)return 0;var n=o(e[i]);if(n>=0)return n>0&&(t.lastNeed=n-1),n;if(--i<r||-2===n)return 0;if(n=o(e[i]),n>=0)return n>0&&(t.lastNeed=n-2),n;if(--i<r||-2===n)return 0;if(n=o(e[i]),n>=0)return n>0&&(2===n?n=0:t.lastNeed=n-3),n;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString(\"utf8\",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},6458:(t,e,r)=>{r.d(e,{A:()=>R});var i=r(988),n=r(3033),s=r(1565),o=r(7833),a=r(8727),h=r(8179),u=r(9639),f=r(1035),l=r(1314);const c=o(\"bittorrent-protocol\"),d=(0,u.L0)(\"\u0013BitTorrent protocol\"),p=new Uint8Array([0,0,0,0]),m=new Uint8Array([0,0,0,1,0]),g=new Uint8Array([0,0,0,1,1]),y=new Uint8Array([0,0,0,1,2]),b=new Uint8Array([0,0,0,1,3]),v=[0,0,0,0,0,0,0,0],w=[0,0,0,3,9,0,0],_=new Uint8Array([0,0,0,1,14]),M=new Uint8Array([0,0,0,1,15]),S=new Uint8Array([0,0,0,0,0,0,0,0]),k=new Uint8Array([0,0,1,2]),E=new Uint8Array([0,0,0,2]);function x(t,e){for(let r=t.length;r--;)t[r]^=e[r];return t}function A(t,e=0){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function I(t,e,r){t[e]=r>>>24&255,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=255&r}class T{constructor(t,e,r,i){this.piece=t,this.offset=e,this.length=r,this.callback=i}}class C{constructor(){this.buffer=new Uint8Array}get(t){return!0}set(t){}}class P extends h.Duplex{constructor(t=null,e=0,r=!1){super(),this._debugId=(0,u.V5)((0,u.po)(4)),this._debug(\"new wire\"),this.peerId=null,this.peerIdBuffer=null,this.type=t,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new n.A(0,{grow:4e5}),this.extensions={},this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this.hasFast=!1,this.allowedFastSet=[],this.peerAllowedFastSet=[],this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=f(),this.downloadSpeed=f(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this._timeoutExpiresAt=null,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this._peEnabled=r,r?(this._dh=s.createDiffieHellman(\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a36210000000000090563\",\"hex\",2),this._myPubKey=this._dh.generateKeys(\"hex\")):this._myPubKey=null,this._peerPubKey=null,this._sharedSecret=null,this._peerCryptoProvide=[],this._cryptoHandshakeDone=!1,this._cryptoSyncPattern=null,this._waitMaxBytes=null,this._encryptionMethod=null,this._encryptGenerator=null,this._decryptGenerator=null,this._setGenerators=!1,this.once(\"finish\",()=>this._onFinish()),this.on(\"finish\",this._onFinish),this._debug(\"type:\",this.type),\"tcpIncoming\"===this.type&&this._peEnabled?this._determineHandshakeType():\"tcpOutgoing\"===this.type&&this._peEnabled&&0===e?this._parsePe2():this._parseHandshake(null)}setKeepAlive(t){this._debug(\"setKeepAlive %s\",t),clearInterval(this._keepAliveInterval),!1!==t&&(this._keepAliveInterval=setInterval(()=>{this.keepAlive()},55e3))}setTimeout(t,e){this._debug(\"setTimeout ms=%d unref=%s\",t,e),this._timeoutMs=t,this._timeoutUnref=!!e,this._resetTimeout(!0)}destroy(){if(!this.destroyed)return this._debug(\"destroy\"),this.end(),this}end(t){if(!this.destroyed&&!this.destroying)return this._debug(\"end\"),this._onUninterested(),this._onChoke(),super.end(t)}use(t){const e=t.prototype.name;if(!e)throw new Error('Extension class requires a \"name\" property on the prototype');this._debug(\"use extension.name=%s\",e);const r=this._nextExt,i=new t(this);function n(){}\"function\"!=typeof i.onHandshake&&(i.onHandshake=n),\"function\"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=n),\"function\"!=typeof i.onMessage&&(i.onMessage=n),this.extendedMapping[r]=e,this._ext[e]=i,this[e]=i,this._nextExt+=1}keepAlive(){this._debug(\"keep-alive\"),this._push(p)}sendPe1(){if(this._peEnabled){const t=Math.floor(513*Math.random()),e=(0,u.po)(t);this._push((0,u.xW)([(0,u.fk)(this._myPubKey),e]))}}sendPe2(){const t=Math.floor(513*Math.random()),e=(0,u.po)(t);this._push((0,u.xW)([(0,u.fk)(this._myPubKey),e]))}async sendPe3(t){await this.setEncrypt(this._sharedSecret,t);const e=await(0,u.tW)((0,u.fk)(this._utfToHex(\"req1\")+this._sharedSecret)),r=x(await(0,u.tW)((0,u.fk)(this._utfToHex(\"req2\")+t)),await(0,u.tW)((0,u.fk)(this._utfToHex(\"req3\")+this._sharedSecret))),i=new DataView((0,u.po)(2).buffer).getUint16(0)%512,n=(0,u.po)(i);let s=new Uint8Array(14+i+2);s.set(S),s.set(k,8);const o=new DataView(s.buffer);o.setInt16(12,i),n.copy(s,14),o.setInt16(14+i,0),s=this._encryptHandshake(s),this._push((0,u.xW)([e,r,s]))}async sendPe4(t){await this.setEncrypt(this._sharedSecret,t);const e=new DataView((0,u.po)(2).buffer).getUint16(0)%512,r=(0,u.po)(e);let i=new Uint8Array(14+e);const n=new DataView(i.buffer);i.set(S),i.set(E,8),n.setInt16(12,e),i.set(r,14),i=this._encryptHandshake(i),this._push(i),this._cryptoHandshakeDone=!0,this._debug(\"completed crypto handshake\")}handshake(t,e,r){let i,n;if(\"string\"==typeof t?(t=t.toLowerCase(),i=(0,u.fk)(t)):(i=t,t=(0,u.V5)(i)),\"string\"==typeof e?n=(0,u.fk)(e):(n=e,e=(0,u.V5)(n)),this._infoHash=i,20!==i.length||20!==n.length)throw new Error(\"infoHash and peerId MUST have length 20\");this._debug(\"handshake i=%s p=%s exts=%o\",t,e,r);const s=new Uint8Array(v);this.extensions={extended:!0,dht:!(!r||!r.dht),fast:!(!r||!r.fast)},s[5]|=16,this.extensions.dht&&(s[7]|=1),this.extensions.fast&&(s[7]|=4),this.extensions.fast&&this.peerExtensions.fast&&(this._debug(\"fast extension is enabled\"),this.hasFast=!0),this._push((0,u.xW)([d,s,i,n])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const t=Object.assign({},this.extendedHandshake);t.m={};for(const e in this.extendedMapping){const r=this.extendedMapping[e];t.m[r]=Number(e)}this.extended(0,i.A.encode(t)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking)if(this.amChoking=!0,this._debug(\"choke\"),this._push(m),this.hasFast){let t=0;for(;this.peerRequests.length>t;){const e=this.peerRequests[t];this.allowedFastSet.includes(e.piece)?++t:this.reject(e.piece,e.offset,e.length)}}else for(;this.peerRequests.length;)this.peerRequests.pop()}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug(\"unchoke\"),this._push(g))}interested(){this.amInterested||(this.amInterested=!0,this._debug(\"interested\"),this._push(y))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug(\"uninterested\"),this._push(b))}have(t){this._debug(\"have %d\",t),this._message(4,[t],null)}bitfield(t){this._debug(\"bitfield\"),ArrayBuffer.isView(t)||(t=t.buffer),this._message(5,[],t)}request(t,e,r,i){return i||(i=()=>{}),this._finished?i(new Error(\"wire is closed\")):!this.peerChoking||this.hasFast&&this.peerAllowedFastSet.includes(t)?(this._debug(\"request index=%d offset=%d length=%d\",t,e,r),this.requests.push(new T(t,e,r,i)),this._timeout||this._resetTimeout(!0),void this._message(6,[t,e,r],null)):i(new Error(\"peer is choking\"))}piece(t,e,r){this._debug(\"piece index=%d offset=%d\",t,e),this._message(7,[t,e],r),this.uploaded+=r.length,this.uploadSpeed(r.length),this.emit(\"upload\",r.length)}cancel(t,e,r){this._debug(\"cancel index=%d offset=%d length=%d\",t,e,r),this._callback(this._pull(this.requests,t,e,r),new Error(\"request was cancelled\"),null),this._message(8,[t,e,r],null)}port(t){this._debug(\"port %d\",t);const e=new Uint8Array(w);new DataView(e.buffer).setUint16(5,t),this._push(e)}suggest(t){if(!this.hasFast)throw Error(\"fast extension is disabled\");this._debug(\"suggest %d\",t),this._message(13,[t],null)}haveAll(){if(!this.hasFast)throw Error(\"fast extension is disabled\");this._debug(\"have-all\"),this._push(_)}haveNone(){if(!this.hasFast)throw Error(\"fast extension is disabled\");this._debug(\"have-none\"),this._push(M)}reject(t,e,r){if(!this.hasFast)throw Error(\"fast extension is disabled\");this._debug(\"reject index=%d offset=%d length=%d\",t,e,r),this._pull(this.peerRequests,t,e,r),this._message(16,[t,e,r],null)}allowedFast(t){if(!this.hasFast)throw Error(\"fast extension is disabled\");this._debug(\"allowed-fast %d\",t),this.allowedFastSet.includes(t)||this.allowedFastSet.push(t),this._message(17,[t],null)}extended(t,e){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=new Uint8Array([t]),n=ArrayBuffer.isView(e)?e:i.A.encode(e);this._message(20,[],(0,u.xW)([r,n]))}}async setEncrypt(t,e){if(!this.type.startsWith(\"tcp\"))return!1;const r=\"tcpOutgoing\"===this.type,i=new a([...await(0,u.tW)((0,u.fk)(this._utfToHex(\"keyA\")+t+e))]),n=new a([...await(0,u.tW)((0,u.fk)(this._utfToHex(\"keyB\")+t+e))]);this._encryptGenerator=r?i:n,this._decryptGenerator=r?n:i;for(let t=0;t<1024;t++)this._encryptGenerator.randomByte(),this._decryptGenerator.randomByte();return this._setGenerators=!0,this.emit(\"_generators\"),!0}_message(t,e,r){const i=r?r.length:0,n=new Uint8Array(5+4*e.length);I(n,0,n.length+i-4),n[4]=t;for(let t=0;t<e.length;t++)I(n,5+4*t,e[t]);this._push(n),r&&this._push(r)}_push(t){if(!this._finished)return 2===this._encryptionMethod&&this._cryptoHandshakeDone&&(t=this._encrypt(t)),this.push(t)}_onKeepAlive(){this._debug(\"got keep-alive\"),this.emit(\"keep-alive\")}_onPe1(t){this._peerPubKey=(0,u.V5)(t),this._sharedSecret=this._dh.computeSecret(this._peerPubKey,\"hex\",\"hex\"),this.emit(\"pe1\")}_onPe2(t){this._peerPubKey=(0,u.V5)(t),this._sharedSecret=this._dh.computeSecret(this._peerPubKey,\"hex\",\"hex\"),this.emit(\"pe2\")}async _onPe3(t){const e=await(0,u.tW)((0,u.fk)(this._utfToHex(\"req3\")+this._sharedSecret)),r=(0,u.V5)(x(e,t));this.emit(\"pe3\",r)}_onPe3Encrypted(t,e){if(!(0,u.LC)(t,S))return this._debug(\"Error: verification constant did not match\"),void this.destroy();for(const t of e.values())0!==t&&this._peerCryptoProvide.push(t);this._peerCryptoProvide.includes(2)?this._encryptionMethod=2:(this._debug(\"Error: RC4 encryption method not provided by peer\"),this.destroy())}_onPe4(t){this._encryptionMethod=t[3],k.includes(this._encryptionMethod)||(this._debug(\"Error: peer selected invalid crypto method\"),this.destroy()),this._cryptoHandshakeDone=!0,this._debug(\"crypto handshake done\"),this.emit(\"pe4\")}_onHandshake(t,e,r){const i=(0,u.V5)(t),n=(0,u.V5)(e);this._debug(\"got handshake i=%s p=%s exts=%o\",i,n,r),this.peerId=n,this.peerIdBuffer=e,this.peerExtensions=r,this.extensions.fast&&this.peerExtensions.fast&&(this._debug(\"fast extension is enabled\"),this.hasFast=!0),this.emit(\"handshake\",i,n,r);for(const t in this._ext)this._ext[t].onHandshake(i,n,r);r.extended&&this._handshakeSent&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_onChoke(){if(this.peerChoking=!0,this._debug(\"got choke\"),this.emit(\"choke\"),!this.hasFast)for(;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(t){this.peerPieces.get(t)||(this._debug(\"got have %d\",t),this.peerPieces.set(t,!0),this.emit(\"have\",t))}_onBitField(t){this.peerPieces=new n.A(t),this._debug(\"got bitfield\"),this.emit(\"bitfield\",this.peerPieces)}_onRequest(t,e,r){if(this.amChoking&&(!this.hasFast||!this.allowedFastSet.includes(t)))return void(this.hasFast&&this.reject(t,e,r));this._debug(\"got request index=%d offset=%d length=%d\",t,e,r);const i=(i,s)=>{if(n===this._pull(this.peerRequests,t,e,r))return i?(this._debug(\"error satisfying request index=%d offset=%d length=%d (%s)\",t,e,r,i.message),void(this.hasFast&&this.reject(t,e,r))):void this.piece(t,e,s)},n=new T(t,e,r,i);this.peerRequests.push(n),this.emit(\"request\",t,e,r,i)}_onPiece(t,e,r){this._debug(\"got piece index=%d offset=%d\",t,e),this._callback(this._pull(this.requests,t,e,r.length),null,r),this.downloaded+=r.length,this.downloadSpeed(r.length),this.emit(\"download\",r.length),this.emit(\"piece\",t,e,r)}_onCancel(t,e,r){this._debug(\"got cancel index=%d offset=%d length=%d\",t,e,r),this._pull(this.peerRequests,t,e,r),this.emit(\"cancel\",t,e,r)}_onPort(t){this._debug(\"got port %d\",t),this.emit(\"port\",t)}_onSuggest(t){if(!this.hasFast)return this._debug(\"Error: got suggest whereas fast extension is disabled\"),void this.destroy();this._debug(\"got suggest %d\",t),this.emit(\"suggest\",t)}_onHaveAll(){if(!this.hasFast)return this._debug(\"Error: got have-all whereas fast extension is disabled\"),void this.destroy();this._debug(\"got have-all\"),this.peerPieces=new C,this.emit(\"have-all\")}_onHaveNone(){if(!this.hasFast)return this._debug(\"Error: got have-none whereas fast extension is disabled\"),void this.destroy();this._debug(\"got have-none\"),this.emit(\"have-none\")}_onReject(t,e,r){if(!this.hasFast)return this._debug(\"Error: got reject whereas fast extension is disabled\"),void this.destroy();this._debug(\"got reject index=%d offset=%d length=%d\",t,e,r),this._callback(this._pull(this.requests,t,e,r),new Error(\"request was rejected\"),null),this.emit(\"reject\",t,e,r)}_onAllowedFast(t){if(!this.hasFast)return this._debug(\"Error: got allowed-fast whereas fast extension is disabled\"),void this.destroy();this._debug(\"got allowed-fast %d\",t),this.peerAllowedFastSet.includes(t)||this.peerAllowedFastSet.push(t),this.peerAllowedFastSet.length>100&&this.peerAllowedFastSet.shift(),this.emit(\"allowed-fast\",t)}_onExtended(t,e){if(0===t){let t;try{t=i.A.decode(e)}catch(t){this._debug(\"ignoring invalid extended handshake: %s\",t.message||t)}if(!t)return;if(this.peerExtendedHandshake=t,\"object\"==typeof t.m)for(const e in t.m)this.peerExtendedMapping[e]=Number(t.m[e].toString());for(const t in this._ext)this.peerExtendedMapping[t]&&this._ext[t].onExtendedHandshake(this.peerExtendedHandshake);this._debug(\"got extended handshake\"),this.emit(\"extended\",\"handshake\",this.peerExtendedHandshake)}else this.extendedMapping[t]&&(t=this.extendedMapping[t],this._ext[t]&&this._ext[t].onMessage(e)),this._debug(\"got extended message ext=%s\",t),this.emit(\"extended\",t,e)}_onTimeout(){this._debug(\"request timed out\"),this._callback(this.requests.shift(),new Error(\"request has timed out\"),null),this.emit(\"timeout\")}_write(t,e){if(2===this._encryptionMethod&&this._cryptoHandshakeDone&&(t=this._decrypt(t)),this._bufferSize+=t.length,this._buffer.push(t),this._buffer.length>1&&(this._buffer=[(0,u.xW)(this._buffer,this._bufferSize)]),this._cryptoSyncPattern){const e=this._buffer[0].indexOf(this._cryptoSyncPattern);if(-1!==e)this._buffer[0]=this._buffer[0].slice(e+this._cryptoSyncPattern.length),this._bufferSize-=e+this._cryptoSyncPattern.length,this._cryptoSyncPattern=null;else if(this._bufferSize+t.length>this._waitMaxBytes+this._cryptoSyncPattern.length)return this._debug(\"Error: could not resynchronize\"),void this.destroy()}for(;this._bufferSize>=this._parserSize&&!this._cryptoSyncPattern;)if(0===this._parserSize)this._parser(new Uint8Array);else{const t=this._buffer[0];this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[t.subarray(this._parserSize)]:[],this._parser(t.subarray(0,this._parserSize))}e(null)}_callback(t,e,r){t&&(this._resetTimeout(!this.peerChoking&&!this._finished),t.callback(e,r))}_resetTimeout(t){if(!t||!this._timeoutMs||!this.requests.length)return clearTimeout(this._timeout),this._timeout=null,void(this._timeoutExpiresAt=null);const e=Date.now()+this._timeoutMs;if(this._timeout){if(e-this._timeoutExpiresAt<.05*this._timeoutMs)return;clearTimeout(this._timeout)}this._timeoutExpiresAt=e,this._timeout=setTimeout(()=>this._onTimeout(),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref()}_parse(t,e){this._parserSize=t,this._parser=e}_parseUntil(t,e){this._cryptoSyncPattern=t,this._waitMaxBytes=e}_onMessageLength(t){const e=A(t);e>0?this._parse(e,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(t){switch(this._parse(4,this._onMessageLength),t[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(A(t,1));case 5:return this._onBitField(t.subarray(1));case 6:return this._onRequest(A(t,1),A(t,5),A(t,9));case 7:return this._onPiece(A(t,1),A(t,5),t.subarray(9));case 8:return this._onCancel(A(t,1),A(t,5),A(t,9));case 9:return this._onPort(t[1]<<8|t[2]);case 13:return this._onSuggest(A(t,1));case 14:return this._onHaveAll();case 15:return this._onHaveNone();case 16:return this._onReject(A(t,1),A(t,5),A(t,9));case 17:return this._onAllowedFast(A(t,1));case 20:return this._onExtended(t[1],t.subarray(2));default:return this._debug(\"got unknown message\"),this.emit(\"unknownmessage\",t)}}_determineHandshakeType(){this._parse(1,t=>{const e=t[0];19===e?this._parse(e+48,this._onHandshakeBuffer):this._parsePe1(t)})}_parsePe1(t){this._parse(95,e=>{this._onPe1((0,u.xW)([t,e])),this._parsePe3()})}_parsePe2(){this._parse(96,async t=>{this._onPe2(t),this._setGenerators||await new Promise(t=>this.once(\"_generators\",t)),this._parsePe4()})}async _parsePe3(){const t=await(0,u.tW)((0,u.fk)(this._utfToHex(\"req1\")+this._sharedSecret));this._parseUntil(t,512),this._parse(20,async t=>{this._onPe3(t),this._setGenerators||await new Promise(t=>this.once(\"_generators\",t)),this._parsePe3Encrypted()})}_parsePe3Encrypted(){this._parse(14,t=>{const e=this._decryptHandshake(t.slice(0,8)),r=this._decryptHandshake(t.slice(8,12)),i=new DataView(this._decryptHandshake(t.slice(12,14)).buffer).getUint16(0);this._parse(i,t=>{t=this._decryptHandshake(t),this._parse(2,i=>{const n=new DataView(this._decryptHandshake(i).buffer).getUint16(0);this._parse(n,i=>{i=this._decryptHandshake(i),this._onPe3Encrypted(e,r,t,i);const s=n?i[0]:null,o=n?i.slice(1,20):null;19===s&&\"BitTorrent protocol\"===(0,u.dU)(o)?this._onHandshakeBuffer(i.slice(1)):this._parseHandshake()})})})})}_parsePe4(){const t=this._decryptHandshake(S);this._parseUntil(t,512),this._parse(6,t=>{const e=this._decryptHandshake(t.slice(0,4)),r=new DataView(this._decryptHandshake(t.slice(4,6)).buffer).getUint16(0);this._parse(r,t=>{this._decryptHandshake(t),this._onPe4(e),this._parseHandshake(null)})})}_parseHandshake(){this._parse(1,t=>{const e=t[0];if(19!==e)return this._debug(\"Error: wire not speaking BitTorrent protocol (%s)\",e.toString()),void this.end();this._parse(e+48,this._onHandshakeBuffer)})}_onHandshakeBuffer(t){const e=t.slice(0,19);if(\"BitTorrent protocol\"!==(0,u.dU)(e))return this._debug(\"Error: wire not speaking BitTorrent protocol (%s)\",(0,u.dU)(e)),void this.end();t=t.slice(19),this._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),fast:!!(4&t[7]),extended:!!(16&t[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(...t){t[0]=`[${this._debugId}] ${t[0]}`,c(...t)}_pull(t,e,r,i){for(let n=0;n<t.length;n++){const s=t[n];if(s.piece===e&&s.offset===r&&s.length===i)return l(t,n),s}return null}_encryptHandshake(t){const e=new Uint8Array(t);if(!this._encryptGenerator)return this._debug(\"Warning: Encrypting without any generator\"),e;for(let r=0;r<t.length;r++){const t=this._encryptGenerator.randomByte();e[r]=e[r]^t}return e}_encrypt(t){const e=new Uint8Array(t);if(!this._encryptGenerator||2!==this._encryptionMethod)return e;for(let r=0;r<t.length;r++){const t=this._encryptGenerator.randomByte();e[r]=e[r]^t}return e}_decryptHandshake(t){const e=new Uint8Array(t);if(!this._decryptGenerator)return this._debug(\"Warning: Decrypting without any generator\"),e;for(let r=0;r<t.length;r++){const t=this._decryptGenerator.randomByte();e[r]=e[r]^t}return e}_decrypt(t){const e=new Uint8Array(t);if(!this._decryptGenerator||2!==this._encryptionMethod)return e;for(let r=0;r<t.length;r++){const t=this._decryptGenerator.randomByte();e[r]=e[r]^t}return e}_utfToHex(t){return(0,u.V5)((0,u.L0)(t))}}const R=P},6473:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"};var f=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],d=c[t];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:f[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\"),this.strip();var o,a,h=\"le\"===e,u=new t(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a<s;a++)u[a]=0}else{for(a=0;a<s-n;a++)u[a]=0;for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[s-a-1]=o}return u},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},g.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),m(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i(\"number\"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a.strip(),i.strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new S(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function w(){b.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function _(){b.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function M(){b.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function k(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,b),n(_,b),n(M,b),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if(\"k256\"===t)e=new v;else if(\"p224\"===t)e=new w;else if(\"p192\"===t)e=new _;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new M}return y[t]=e,e},S.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},S.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new k(t)},n(k,S),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},6532:(t,e,r)=>{function i(t,e,r,i,n,s,o){try{var a=t[s](o),h=a.value}catch(t){return void r(t)}a.done?e(h):Promise.resolve(h).then(i,n)}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function s(t,e,r){return(e=function(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||\"default\");if(\"object\"!=typeof i)return i;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(113).F.ERR_INVALID_ARG_TYPE;t.exports=function(t,e,r){var a;if(e&&\"function\"==typeof e.next)a=e;else if(e&&e[Symbol.asyncIterator])a=e[Symbol.asyncIterator]();else{if(!e||!e[Symbol.iterator])throw new o(\"iterable\",[\"Iterable\"],e);a=e[Symbol.iterator]()}var h=new t(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach(function(e){s(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({objectMode:!0},r)),u=!1;function f(){return l.apply(this,arguments)}function l(){var t;return t=function*(){try{var t=yield a.next(),e=t.value;t.done?h.push(null):h.push(yield e)?f():u=!1}catch(t){h.destroy(t)}},l=function(){var e=this,r=arguments;return new Promise(function(n,s){var o=t.apply(e,r);function a(t){i(o,n,s,a,h,\"next\",t)}function h(t){i(o,n,s,a,h,\"throw\",t)}a(void 0)})},l.apply(this,arguments)}return h._read=function(){u||(u=!0,f())},h}},6549:t=>{t.exports=Object.getOwnPropertyDescriptor},6556:(t,e,r)=>{var i=r(453),n=r(3126),s=n([i(\"%String.prototype.indexOf%\")]);t.exports=function(t,e){var r=i(t,!!e);return\"function\"==typeof r&&s(t,\".prototype.\")>-1?n([r]):r}},6578:t=>{t.exports=[\"Float16Array\",\"Float32Array\",\"Float64Array\",\"Int8Array\",\"Int16Array\",\"Int32Array\",\"Uint8Array\",\"Uint8ClampedArray\",\"Uint16Array\",\"Uint32Array\",\"BigInt64Array\",\"BigUint64Array\"]},6585:t=>{var e=1e3,r=60*e,i=60*r,n=24*i,s=7*n,o=365.25*n;function a(t,e,r,i){var n=e>=1.5*r;return Math.round(t/r)+\" \"+i+(n?\"s\":\"\")}t.exports=function(t,h){h=h||{};var u=typeof t;if(\"string\"===u&&t.length>0)return function(t){if((t=String(t)).length>100)return;var a=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!a)return;var h=parseFloat(a[1]);switch((a[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return h*o;case\"weeks\":case\"week\":case\"w\":return h*s;case\"days\":case\"day\":case\"d\":return h*n;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return h*i;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return h*r;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return h*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return h;default:return}}(t);if(\"number\"===u&&isFinite(t))return h.long?function(t){var s=Math.abs(t);if(s>=n)return a(t,s,n,\"day\");if(s>=i)return a(t,s,i,\"hour\");if(s>=r)return a(t,s,r,\"minute\");if(s>=e)return a(t,s,e,\"second\");return t+\" ms\"}(t):function(t){var s=Math.abs(t);if(s>=n)return Math.round(t/n)+\"d\";if(s>=i)return Math.round(t/i)+\"h\";if(s>=r)return Math.round(t/r)+\"m\";if(s>=e)return Math.round(t/e)+\"s\";return t+\"ms\"}(t);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(t))}},6587:t=>{t.exports=function t(e,r){if(e&&r)return t(e)(r);if(\"function\"!=typeof e)throw new TypeError(\"need wrapper function\");return Object.keys(e).forEach(function(t){i[t]=e[t]}),i;function i(){for(var t=new Array(arguments.length),r=0;r<t.length;r++)t[r]=arguments[r];var i=e.apply(this,t),n=t[t.length-1];return\"function\"==typeof i&&i!==n&&Object.keys(n).forEach(function(t){i[t]=n[t]}),i}}},6611:(t,e,r)=>{var i=r(717),n=r(3519),s=function(){},o=globalThis.Bare?queueMicrotask:i.nextTick.bind(i),a=function(t,e,r){if(\"function\"==typeof e)return a(t,null,e);e||(e={}),r=n(r||s);var i=t._writableState,h=t._readableState,u=e.readable||!1!==e.readable&&t.readable,f=e.writable||!1!==e.writable&&t.writable,l=!1,c=function(){t.writable||d()},d=function(){f=!1,u||r.call(t)},p=function(){u=!1,f||r.call(t)},m=function(e){r.call(t,e?new Error(\"exited with error code: \"+e):null)},g=function(e){r.call(t,e)},y=function(){o(b)},b=function(){if(!l)return(!u||h&&h.ended&&!h.destroyed)&&(!f||i&&i.ended&&!i.destroyed)?void 0:r.call(t,new Error(\"premature close\"))},v=function(){t.req.on(\"finish\",d)};return!function(t){return t.setHeader&&\"function\"==typeof t.abort}(t)?f&&!i&&(t.on(\"end\",c),t.on(\"close\",c)):(t.on(\"complete\",d),t.on(\"abort\",y),t.req?v():t.on(\"request\",v)),function(t){return t.stdio&&Array.isArray(t.stdio)&&3===t.stdio.length}(t)&&t.on(\"exit\",m),t.on(\"end\",p),t.on(\"finish\",d),!1!==e.error&&t.on(\"error\",g),t.on(\"close\",y),function(){l=!0,t.removeListener(\"complete\",d),t.removeListener(\"abort\",y),t.removeListener(\"request\",v),t.req&&t.req.removeListener(\"finish\",d),t.removeListener(\"end\",c),t.removeListener(\"close\",c),t.removeListener(\"finish\",d),t.removeListener(\"exit\",m),t.removeListener(\"end\",p),t.removeListener(\"error\",g),t.removeListener(\"close\",y)}};t.exports=a},6622:t=>{\"function\"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},6661:(t,e,r)=>{var i=r(7011),n=i.assert,s=i.parseBytes,o=i.cachedProperty;function a(t,e){this.eddsa=t,this._secret=s(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=s(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},o(a,\"pubBytes\",function(){return this.eddsa.encodePoint(this.pub())}),o(a,\"pub\",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),o(a,\"privBytes\",function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,i=e.slice(0,t.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i}),o(a,\"priv\",function(){return this.eddsa.decodeInt(this.privBytes())}),o(a,\"hash\",function(){return this.eddsa.hash().update(this.secret()).digest()}),o(a,\"messagePrefix\",function(){return this.hash().slice(this.eddsa.encodingLength)}),a.prototype.sign=function(t){return n(this._secret,\"KeyPair can only verify\"),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return n(this._secret,\"KeyPair is public only\"),i.encode(this.secret(),t)},a.prototype.getPublic=function(t){return i.encode(this.pubBytes(),t)},t.exports=a},6677:(t,e,r)=>{var i=r(8490),n=r(7011),s=n.getNAF,o=n.getJSF,a=n.assert;function h(t,e){this.type=t,this.p=new i(e.p,16),this.red=e.prime?i.red(e.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=e.n&&new i(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=h,h.prototype.point=function(){throw new Error(\"Not implemented\")},h.prototype.validate=function(){throw new Error(\"Not implemented\")},h.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),i=s(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var o,h,u=[];for(o=0;o<i.length;o+=r.step){h=0;for(var f=o+r.step-1;f>=o;f--)h=(h<<1)+i[f];u.push(h)}for(var l=this.jpoint(null,null,null),c=this.jpoint(null,null,null),d=n;d>0;d--){for(o=0;o<u.length;o++)(h=u[o])===d?c=c.mixedAdd(r.points[o]):h===-d&&(c=c.mixedAdd(r.points[o].neg()));l=l.add(c)}return l.toP()},h.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,o=s(e,r,this._bitLength),h=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var f=0;u>=0&&0===o[u];u--)f++;if(u>=0&&f++,h=h.dblp(f),u<0)break;var l=o[u];a(0!==l),h=\"affine\"===t.type?l>0?h.mixedAdd(n[l-1>>1]):h.mixedAdd(n[-l-1>>1].neg()):l>0?h.add(n[l-1>>1]):h.add(n[-l-1>>1].neg())}return\"affine\"===t.type?h.toP():h},h.prototype._wnafMulAdd=function(t,e,r,i,n){var a,h,u,f=this._wnafT1,l=this._wnafT2,c=this._wnafT3,d=0;for(a=0;a<i;a++){var p=(u=e[a])._getNAFPoints(t);f[a]=p.wnd,l[a]=p.points}for(a=i-1;a>=1;a-=2){var m=a-1,g=a;if(1===f[m]&&1===f[g]){var y=[e[m],null,null,e[g]];0===e[m].y.cmp(e[g].y)?(y[1]=e[m].add(e[g]),y[2]=e[m].toJ().mixedAdd(e[g].neg())):0===e[m].y.cmp(e[g].y.redNeg())?(y[1]=e[m].toJ().mixedAdd(e[g]),y[2]=e[m].add(e[g].neg())):(y[1]=e[m].toJ().mixedAdd(e[g]),y[2]=e[m].toJ().mixedAdd(e[g].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],v=o(r[m],r[g]);for(d=Math.max(v[0].length,d),c[m]=new Array(d),c[g]=new Array(d),h=0;h<d;h++){var w=0|v[0][h],_=0|v[1][h];c[m][h]=b[3*(w+1)+(_+1)],c[g][h]=0,l[m]=y}}else c[m]=s(r[m],f[m],this._bitLength),c[g]=s(r[g],f[g],this._bitLength),d=Math.max(c[m].length,d),d=Math.max(c[g].length,d)}var M=this.jpoint(null,null,null),S=this._wnafT4;for(a=d;a>=0;a--){for(var k=0;a>=0;){var E=!0;for(h=0;h<i;h++)S[h]=0|c[h][a],0!==S[h]&&(E=!1);if(!E)break;k++,a--}if(a>=0&&k++,M=M.dblp(k),a<0)break;for(h=0;h<i;h++){var x=S[h];0!==x&&(x>0?u=l[h][x-1>>1]:x<0&&(u=l[h][-x-1>>1].neg()),M=\"affine\"===u.type?M.mixedAdd(u):M.add(u))}}for(a=0;a<i;a++)l[a]=null;return n?M:M.toP()},h.BasePoint=u,u.prototype.eq=function(){throw new Error(\"Not implemented\")},u.prototype.validate=function(){return this.curve.validate(this)},h.prototype.decodePoint=function(t,e){t=n.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?a(t[t.length-1]%2==0):7===t[0]&&a(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error(\"Unknown point format\")},u.prototype.encodeCompressed=function(t){return this.encode(t,!0)},u.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray(\"be\",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray(\"be\",e))},u.prototype.encode=function(t,e){return n.encode(this._encode(e),t)},u.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},u.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var s=0;s<t;s++)i=i.dbl();r.push(i)}return{step:t,points:r}},u.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},6679:t=>{let e,r;if(\"undefined\"!=typeof TextDecoder){const t=new TextDecoder;e=function(e){return t.decode(e)}}else e=function(t){const e=t.byteLength;let r=\"\",i=0;for(;i<e;){let n=t[i];if(n<=127){r+=String.fromCharCode(n),i++;continue}let s=0,o=0;if(n<=223?(s=1,o=31&n):n<=239?(s=2,o=15&n):n<=244&&(s=3,o=7&n),e-i-s>0){let e=0;for(;e<s;)n=t[i+e+1],o=o<<6|63&n,e+=1}else o=65533,s=e-i;r+=String.fromCodePoint(o),i+=s+1}return r};if(\"undefined\"!=typeof TextEncoder){const t=new TextEncoder;r=function(e,r){return t.encodeInto(r,e).written}}else r=function(t,e){const r=t.byteLength;let i=0,n=0;for(;i<e.length;){const r=e.codePointAt(i);if(r<=127){t[n++]=r,i++;continue}let s=0,o=0;for(r<=2047?(s=6,o=192):r<=65535?(s=12,o=224):r<=2097151&&(s=18,o=240),t[n++]=o|r>>s,s-=6;s>=0;)t[n++]=128|r>>s&63,s-=6;i+=r>=65536?2:1}return r};t.exports={byteLength:function(t){let e=0;for(let r=0,i=t.length;r<i;r++){const n=t.charCodeAt(r);if(n>=55296&&n<=56319&&r+1<i){const i=t.charCodeAt(r+1);if(i>=56320&&i<=57343){e+=4,r++;continue}}e+=n<=127?1:n<=2047?2:3}return e},toString:e,write:r}},6686:()=>{},6698:t=>{\"function\"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},6708:(t,e,r)=>{var i,n=r(717);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;t.entry=null;for(;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=E,E.WritableState=k;var o={deprecate:r(4643)},a=r(1416),h=r(8287).Buffer,u=(\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var f,l=r(5896),c=r(5291).getHighWaterMark,d=r(113).F,p=d.ERR_INVALID_ARG_TYPE,m=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,y=d.ERR_STREAM_CANNOT_PIPE,b=d.ERR_STREAM_DESTROYED,v=d.ERR_STREAM_NULL_VALUES,w=d.ERR_STREAM_WRITE_AFTER_END,_=d.ERR_UNKNOWN_ENCODING,M=l.errorOrDestroy;function S(){}function k(t,e,o){i=i||r(5382),t=t||{},\"boolean\"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=c(this,t,\"writableHighWaterMark\",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,s=r.writecb;if(\"function\"!=typeof s)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,s){--e.pendingcb,r?(n.nextTick(s,i),n.nextTick(P,t,e),t._writableState.errorEmitted=!0,M(t,i)):(s(i),t._writableState.errorEmitted=!0,M(t,i),P(t,e))}(t,r,i,e,s);else{var o=T(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),i?n.nextTick(A,t,r,o,s):A(t,r,o,s)}}(e,t)},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.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function E(t){var e=this instanceof(i=i||r(5382));if(!e&&!f.call(E,this))return new E(t);this._writableState=new k(t,this,e),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)),a.call(this)}function x(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b(\"write\")):r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function A(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,i(),P(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),o=e.corkedRequestsFree;o.entry=r;for(var a=0,h=!0;r;)n[a]=r,r.isBuf||(h=!1),r=r.next,a+=1;n.allBuffers=h,x(t,e,!0,e.length,n,\"\",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,l=r.callback;if(x(t,e,!1,e.objectMode?1:u.length,u,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function T(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function C(t,e){t._final(function(r){e.pendingcb--,r&&M(t,r),e.prefinished=!0,t.emit(\"prefinish\"),P(t,e)})}function P(t,e){var r=T(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||(\"function\"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit(\"prefinish\")):(e.pendingcb++,e.finalCalled=!0,n.nextTick(C,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}r(6698)(E,a),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,\"buffer\",{get:o.deprecate(function(){return this.getBuffer()},\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===E&&(t&&t._writableState instanceof k)}})):f=function(t){return t instanceof this},E.prototype.pipe=function(){M(this,new y)},E.prototype.write=function(t,e,r){var i,s=this._writableState,o=!1,a=!s.objectMode&&(i=t,h.isBuffer(i)||i instanceof u);return a&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),a?e=\"buffer\":e||(e=s.defaultEncoding),\"function\"!=typeof r&&(r=S),s.ending?function(t,e){var r=new w;M(t,r),n.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var s;return null===r?s=new v:\"string\"==typeof r||e.objectMode||(s=new p(\"chunk\",[\"string\",\"Buffer\"],r)),!s||(M(t,s),n.nextTick(i,s),!1)}(this,s,t,r))&&(s.pendingcb++,o=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=h.from(e,r));return e}(e,i,n);i!==o&&(r=!0,n=\"buffer\",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var u=e.length<e.highWaterMark;u||(e.needDrain=!0);if(e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:s,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else x(t,e,!1,a,i,n,s);return u}(this,s,a,t,e,r)),o},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},E.prototype.setDefaultEncoding=function(t){if(\"string\"==typeof t&&(t=t.toLowerCase()),!([\"hex\",\"utf8\",\"utf-8\",\"ascii\",\"binary\",\"base64\",\"ucs2\",\"ucs-2\",\"utf16le\",\"utf-16le\",\"raw\"].indexOf((t+\"\").toLowerCase())>-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,r){r(new m(\"_write()\"))},E.prototype._writev=null,E.prototype.end=function(t,e,r){var i=this._writableState;return\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,P(t,e),r&&(e.finished?n.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(E.prototype,\"writableLength\",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=l.destroy,E.prototype._undestroy=l.undestroy,E.prototype._destroy=function(t,e){e(t)}},6710:(t,e,r)=>{var i=r(6698),n=r(4107),s=r(392),o=r(2861).Buffer,a=new Array(64);function h(){this.init(),this._w=a,s.call(this,64,56)}i(h,n),h.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},h.prototype._hash=function(){var t=o.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=h},6729:(t,e,r)=>{var i=e;i.version=r(1636).rE,i.utils=r(7011),i.rand=r(5037),i.curve=r(894),i.curves=r(480),i.ec=r(7447),i.eddsa=r(8650)},6743:(t,e,r)=>{var i=r(9353);t.exports=Function.prototype.bind||i},6784:(t,e,r)=>{var i=r(7426),n=r(6166),s=i.rotl32,o=i.sum32,a=i.sum32_3,h=i.sum32_4,u=n.BlockHash;function f(){if(!(this instanceof f))return new f;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian=\"little\"}function l(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function c(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function d(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(f,u),e.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],u=this.h[3],f=this.h[4],b=r,v=i,w=n,_=u,M=f,S=0;S<80;S++){var k=o(s(h(r,l(S,i,n,u),t[p[S]+e],c(S)),g[S]),f);r=f,f=u,u=s(n,10),n=i,i=k,k=o(s(h(b,l(79-S,v,w,_),t[m[S]+e],d(S)),y[S]),M),b=M,M=_,_=s(w,10),w=v,v=k}k=a(this.h[1],n,_),this.h[1]=a(this.h[2],u,M),this.h[2]=a(this.h[3],f,b),this.h[3]=a(this.h[4],r,v),this.h[4]=a(this.h[0],i,w),this.h[0]=k},f.prototype._digest=function(t){return\"hex\"===t?i.toHex32(this.h,\"little\"):i.split32(this.h,\"little\")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],m=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],g=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],y=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},6814:(t,e,r)=>{var i=r(8287).Buffer;const{digitCount:n,getType:s}=r(7972);function o(t){if(null==t)return 0;const e=s(t);switch(e){case\"buffer\":return n(t.length)+1+t.length;case\"arraybufferview\":return function(t){const e=t.byteLength-t.byteOffset;return n(e)+1+e}(t);case\"string\":return function(t){const e=i.byteLength(t);return n(e)+1+e}(t);case\"array\":case\"set\":return function(t){let e=2;for(const r of t)e+=o(r);return e}(t);case\"number\":return 1+n(Math.floor(t))+1;case\"bigint\":return 1+t.toString().length+1;case\"object\":return function(t){let e=2;const r=Object.keys(t);for(let s=0;s<r.length;s++){const a=i.byteLength(r[s]);e+=n(a)+1+a,e+=o(t[r[s]])}return e}(t);case\"map\":return function(t){let e=2;for(const[r,s]of t){const t=i.byteLength(r);e+=n(t)+1+t,e+=o(s)}return e}(t);default:throw new TypeError(`Unsupported value of type \"${e}\"`)}}t.exports=o},6819:(t,e,r)=>{t.exports=r(8330).version},6843:(t,e,r)=>{var i=r(8287).Buffer,n=r(295);function s(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}e.encrypt=function(t,e){for(;t._cache.length<e.length;)t._cache=i.concat([t._cache,s(t)]);var r=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),n(e,r)}},6889:()=>{},6897:(t,e,r)=>{var i=r(453),n=r(41),s=r(592)(),o=r(5795),a=r(9675),h=i(\"%Math.floor%\");t.exports=function(t,e){if(\"function\"!=typeof t)throw new a(\"`fn` is not a function\");if(\"number\"!=typeof e||e<0||e>4294967295||h(e)!==e)throw new a(\"`length` must be a positive 32-bit integer\");var r=arguments.length>2&&!!arguments[2],i=!0,u=!0;if(\"length\"in t&&o){var f=o(t,\"length\");f&&!f.configurable&&(i=!1),f&&!f.writable&&(u=!1)}return(i||u||!r)&&(s?n(t,\"length\",e,!0,!0):n(t,\"length\",e)),t}},6972:(t,e,r)=>{var i=r(3392).Buffer,n=r(537);function s(t,e,r){t.copy(e,r)}t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError(\"Cannot call a class as a function\")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return i.alloc(0);for(var e=i.allocUnsafe(t>>>0),r=this.head,n=0;r;)s(r.data,e,n),n+=r.data.length,r=r.next;return e},t}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+\" \"+t})},6975:(t,e,r)=>{var i=r(2861).Buffer;function n(t,e,r){var n=t._cipher.encryptBlock(t._prev)[0]^e;return t._prev=i.concat([t._prev.slice(1),i.from([r?e:n])]),n}e.encrypt=function(t,e,r){for(var s=e.length,o=i.allocUnsafe(s),a=-1;++a<s;)o[a]=n(t,e[a],r);return o}},6983:(t,e,r)=>{var i=r(717);function n(){throw new Error(\"secure random number generation not supported by this browser\\nuse chrome, FireFox or Internet Explorer 11\")}var s=r(2861),o=r(3209),a=s.Buffer,h=s.kMaxLength,u=globalThis.crypto||globalThis.msCrypto,f=Math.pow(2,32)-1;function l(t,e){if(\"number\"!=typeof t||t!=t)throw new TypeError(\"offset must be a number\");if(t>f||t<0)throw new TypeError(\"offset must be a uint32\");if(t>h||t>e)throw new RangeError(\"offset out of range\")}function c(t,e,r){if(\"number\"!=typeof t||t!=t)throw new TypeError(\"size must be a number\");if(t>f||t<0)throw new TypeError(\"size must be a uint32\");if(t+e>r||t>h)throw new RangeError(\"buffer too small\")}function d(t,e,r,n){if(i.browser){var s=t.buffer,a=new Uint8Array(s,e,r);return u.getRandomValues(a),n?void i.nextTick(function(){n(null,t)}):t}if(!n)return o(r).copy(t,e),t;o(r,function(r,i){if(r)return n(r);i.copy(t,e),n(null,t)})}u&&u.getRandomValues||!i.browser?(e.randomFill=function(t,e,r,i){if(!(a.isBuffer(t)||t instanceof globalThis.Uint8Array))throw new TypeError('\"buf\" argument must be a Buffer or Uint8Array');if(\"function\"==typeof e)i=e,e=0,r=t.length;else if(\"function\"==typeof r)i=r,r=t.length-e;else if(\"function\"!=typeof i)throw new TypeError('\"cb\" argument must be a function');return l(e,t.length),c(r,e,t.length),d(t,e,r,i)},e.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(a.isBuffer(t)||t instanceof globalThis.Uint8Array))throw new TypeError('\"buf\" argument must be a Buffer or Uint8Array');l(e,t.length),void 0===r&&(r=t.length-e);return c(r,e,t.length),d(t,e,r)}):(e.randomFill=n,e.randomFillSync=n)},7007:t=>{var e=Object.create||function(t){var e=function(){};return e.prototype=t,new e},r=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},i=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function n(){this._events&&Object.prototype.hasOwnProperty.call(this,\"_events\")||(this._events=e(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0;var s,o=10;try{var a={};Object.defineProperty&&Object.defineProperty(a,\"x\",{value:0}),s=0===a.x}catch(t){s=!1}function h(t){return void 0===t._maxListeners?n.defaultMaxListeners:t._maxListeners}function u(t,r,i,n){var s,o,a;if(\"function\"!=typeof i)throw new TypeError('\"listener\" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit(\"newListener\",r,i.listener?i.listener:i),o=t._events),a=o[r]):(o=t._events=e(null),t._eventsCount=0),a){if(\"function\"==typeof a?a=o[r]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),!a.warned&&(s=h(t))&&s>0&&a.length>s){a.warned=!0;var u=new Error(\"Possible EventEmitter memory leak detected. \"+a.length+' \"'+String(r)+'\" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name=\"MaxListenersExceededWarning\",u.emitter=t,u.type=r,u.count=a.length,\"object\"==typeof console&&console.warn&&console.warn(\"%s: %s\",u.name,u.message)}}else a=o[r]=i,++t._eventsCount;return t}function f(){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 t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=i.call(f,n);return s.listener=r,n.wrapFn=s,s}function c(t,e,r){var i=t._events;if(!i)return[];var n=i[e];return n?\"function\"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(n):p(n,n.length):[]}function d(t){var e=this._events;if(e){var r=e[t];if(\"function\"==typeof r)return 1;if(r)return r.length}return 0}function p(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}s?Object.defineProperty(n,\"defaultMaxListeners\",{enumerable:!0,get:function(){return o},set:function(t){if(\"number\"!=typeof t||t<0||t!=t)throw new TypeError('\"defaultMaxListeners\" must be a positive number');o=t}}):n.defaultMaxListeners=o,n.prototype.setMaxListeners=function(t){if(\"number\"!=typeof t||t<0||isNaN(t))throw new TypeError('\"n\" argument must be a positive number');return this._maxListeners=t,this},n.prototype.getMaxListeners=function(){return h(this)},n.prototype.emit=function(t){var e,r,i,n,s,o,a=\"error\"===t;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(arguments.length>1&&(e=arguments[1]),e instanceof Error)throw e;var h=new Error('Unhandled \"error\" event. ('+e+\")\");throw h.context=e,h}if(!(r=o[t]))return!1;var u=\"function\"==typeof r;switch(i=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var i=t.length,n=p(t,i),s=0;s<i;++s)n[s].call(r)}(r,u,this);break;case 2:!function(t,e,r,i){if(e)t.call(r,i);else for(var n=t.length,s=p(t,n),o=0;o<n;++o)s[o].call(r,i)}(r,u,this,arguments[1]);break;case 3:!function(t,e,r,i,n){if(e)t.call(r,i,n);else for(var s=t.length,o=p(t,s),a=0;a<s;++a)o[a].call(r,i,n)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(t,e,r,i,n,s){if(e)t.call(r,i,n,s);else for(var o=t.length,a=p(t,o),h=0;h<o;++h)a[h].call(r,i,n,s)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(i-1),s=1;s<i;s++)n[s-1]=arguments[s];!function(t,e,r,i){if(e)t.apply(r,i);else for(var n=t.length,s=p(t,n),o=0;o<n;++o)s[o].apply(r,i)}(r,u,this,n)}return!0},n.prototype.addListener=function(t,e){return u(this,t,e,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(t,e){return u(this,t,e,!0)},n.prototype.once=function(t,e){if(\"function\"!=typeof e)throw new TypeError('\"listener\" argument must be a function');return this.on(t,l(this,t,e)),this},n.prototype.prependOnceListener=function(t,e){if(\"function\"!=typeof e)throw new TypeError('\"listener\" argument must be a function');return this.prependListener(t,l(this,t,e)),this},n.prototype.removeListener=function(t,r){var i,n,s,o,a;if(\"function\"!=typeof r)throw new TypeError('\"listener\" argument must be a function');if(!(n=this._events))return this;if(!(i=n[t]))return this;if(i===r||i.listener===r)0===--this._eventsCount?this._events=e(null):(delete n[t],n.removeListener&&this.emit(\"removeListener\",t,i.listener||r));else if(\"function\"!=typeof i){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;0===s?i.shift():function(t,e){for(var r=e,i=r+1,n=t.length;i<n;r+=1,i+=1)t[r]=t[i];t.pop()}(i,s),1===i.length&&(n[t]=i[0]),n.removeListener&&this.emit(\"removeListener\",t,a||r)}return this},n.prototype.removeAllListeners=function(t){var i,n,s;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=e(null),this._eventsCount=0):n[t]&&(0===--this._eventsCount?this._events=e(null):delete n[t]),this;if(0===arguments.length){var o,a=r(n);for(s=0;s<a.length;++s)\"removeListener\"!==(o=a[s])&&this.removeAllListeners(o);return this.removeAllListeners(\"removeListener\"),this._events=e(null),this._eventsCount=0,this}if(\"function\"==typeof(i=n[t]))this.removeListener(t,i);else if(i)for(s=i.length-1;s>=0;s--)this.removeListener(t,i[s]);return this},n.prototype.listeners=function(t){return c(this,t,!0)},n.prototype.rawListeners=function(t){return c(this,t,!1)},n.listenerCount=function(t,e){return\"function\"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},n.prototype.listenerCount=d,n.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},7011:(t,e,r)=>{var i=e,n=r(8490),s=r(3349),o=r(4367);i.assert=s,i.toArray=o.toArray,i.zero2=o.zero2,i.toHex=o.toHex,i.encode=o.encode,i.getNAF=function(t,e,r){var i,n=new Array(Math.max(t.bitLength(),r)+1);for(i=0;i<n.length;i+=1)n[i]=0;var s=1<<e+1,o=t.clone();for(i=0;i<n.length;i++){var a,h=o.andln(s-1);o.isOdd()?(a=h>(s>>1)-1?(s>>1)-h:h,o.isubn(a)):a=0,n[i]=a,o.iushrn(1)}return n},i.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,h=t.andln(3)+n&3,u=e.andln(3)+s&3;3===h&&(h=-1),3===u&&(u=-1),o=1&h?3!==(i=t.andln(7)+n&7)&&5!==i||2!==u?h:-h:0,r[0].push(o),a=1&u?3!==(i=e.andln(7)+s&7)&&5!==i||2!==h?u:-u:0,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},i.cachedProperty=function(t,e,r){var i=\"_\"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(t){return\"string\"==typeof t?i.toArray(t,\"hex\"):t},i.intFromLE=function(t){return new n(t,\"hex\",\"le\")}},7103:function(t,e,r){var i=\"undefined\"!=typeof globalThis&&globalThis||\"undefined\"!=typeof self&&self||window,n=Function.prototype.apply;function s(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new s(n.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new s(n.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r(2791),e.setImmediate=\"undefined\"!=typeof self&&self.setImmediate||\"undefined\"!=typeof globalThis&&globalThis.setImmediate||this&&this.setImmediate,e.clearImmediate=\"undefined\"!=typeof self&&self.clearImmediate||\"undefined\"!=typeof globalThis&&globalThis.clearImmediate||this&&this.clearImmediate},7108:(t,e,r)=>{var i=r(6698),n=r(8276),s=r(6011),o=r(2802),a=r(6168);function h(t){a.call(this,\"digest\"),this._hash=t}i(h,a),h.prototype._update=function(t){this._hash.update(t)},h.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return\"md5\"===(t=t.toLowerCase())?new n:\"rmd160\"===t||\"ripemd160\"===t?new s:new h(o(t))}},7119:t=>{t.exports=\"undefined\"!=typeof Reflect&&Reflect&&Reflect.apply},7168:(t,e,r)=>{e.publicEncrypt=r(8902),e.privateDecrypt=r(7362),e.privateEncrypt=function(t,r){return e.publicEncrypt(t,r,!0)},e.publicDecrypt=function(t,r){return e.privateDecrypt(t,r,!0)}},7176:(t,e,r)=>{var i,n=r(3126),s=r(5795);try{i=[].__proto__===Array.prototype}catch(t){if(!t||\"object\"!=typeof t||!(\"code\"in t)||\"ERR_PROTO_ACCESS\"!==t.code)throw t}var o=!!i&&s&&s(Object.prototype,\"__proto__\"),a=Object,h=a.getPrototypeOf;t.exports=o&&\"function\"==typeof o.get?n([o.get]):\"function\"==typeof h&&function(t){return h(null==t?t:a(t))}},7180:t=>{function e(t){}t.exports=function(t){var r=null,i=null,n=null,s=null;return function(t,r){s=t,o(r||e)};function o(e){if(i)return r||(r=[]),void r.push(e);var n=s;s=null,i=e,t(n,a)}function a(t){var s=i,a=n;if(n=null,i=null,r&&(n=r,r=null,o(e)),a)for(var h=0;h<a.length;h++)a[h](t);s(t)}}},7186:(t,e,r)=>{e.decode=e.parse=r(1630),e.encode=e.stringify=r(9106)},7227:(t,e,r)=>{var i=r(6698),n=r(9673).Reporter,s=r(8287).Buffer;function o(t,e){n.call(this,e),s.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error(\"Input not Buffer\")}function a(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(t){return t instanceof a||(t=new a(t,e)),this.length+=t.length,t},this);else if(\"number\"==typeof t){if(!(0<=t&&t<=255))return e.error(\"non-byte EncoderBuffer value\");this.value=t,this.length=1}else if(\"string\"==typeof t)this.value=t,this.length=s.byteLength(t);else{if(!s.isBuffer(t))return e.error(\"Unsupported type: \"+typeof t);this.value=t,this.length=t.length}}i(o,n),e.t=o,o.prototype.save=function(){return{offset:this.offset,reporter:n.prototype.save.call(this)}},o.prototype.restore=function(t){var e=new o(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,n.prototype.restore.call(this,t.reporter),e},o.prototype.isEmpty=function(){return this.offset===this.length},o.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||\"DecoderBuffer overrun\")},o.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||\"DecoderBuffer overrun\");var r=new o(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r},o.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},e.d=a,a.prototype.join=function(t,e){return t||(t=new s(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach(function(r){r.join(t,e),e+=r.length}):(\"number\"==typeof this.value?t[e]=this.value:\"string\"==typeof this.value?t.write(this.value,e):s.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t}},7266:(t,e,r)=>{var i=r(3549);function n(t){return i.existsSync(t)&&i.statSync(t).isFile()}t.exports=function(t,e){if(!e)return n(t);i.stat(t,function(t,r){return t?e(t):e(null,r.isFile())})},t.exports.sync=n},7314:(t,e,r)=>{var i=r(717),n=r(3225);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;t.entry=null;for(;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=y;var o,a=!i.browser&&[\"v0.10\",\"v0.9.\"].indexOf(i.version.slice(0,5))>-1?setImmediate:n.nextTick;y.WritableState=g;var h=Object.create(r(5622));h.inherits=r(6698);var u={deprecate:r(4643)},f=r(1862),l=r(4116).Buffer,c=(\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var d,p=r(6278);function m(){}function g(t,e){o=o||r(6248),t=t||{};var i=e instanceof o;this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var h=t.highWaterMark,u=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=h||0===h?h:i&&(u||0===u)?u:f,this.highWaterMark=Math.floor(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(t){!function(t,e){var r=t._writableState,i=r.sync,s=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,s){--e.pendingcb,r?(n.nextTick(s,i),n.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit(\"error\",i)):(s(i),t._writableState.errorEmitted=!0,t.emit(\"error\",i),S(t,e))}(t,r,i,e,s);else{var o=_(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),i?a(v,t,r,o,s):v(t,r,o,s)}}(e,t)},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 s(this)}function y(t){if(o=o||r(6248),!(d.call(y,this)||this instanceof o))return new y(t);this._writableState=new g(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)),f.call(this)}function b(t,e,r,i,n,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function v(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,i(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,n=new Array(i),o=e.corkedRequestsFree;o.entry=r;for(var a=0,h=!0;r;)n[a]=r,r.isBuf||(h=!1),r=r.next,a+=1;n.allBuffers=h,b(t,e,!0,e.length,n,\"\",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,l=r.callback;if(b(t,e,!1,e.objectMode?1:u.length,u,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function M(t,e){t._final(function(r){e.pendingcb--,r&&t.emit(\"error\",r),e.prefinished=!0,t.emit(\"prefinish\"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||(\"function\"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,n.nextTick(M,t,e)):(e.prefinished=!0,t.emit(\"prefinish\")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"))),r}h.inherits(y,f),g.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(g.prototype,\"buffer\",{get:u.deprecate(function(){return this.getBuffer()},\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===y&&(t&&t._writableState instanceof g)}})):d=function(t){return t instanceof this},y.prototype.pipe=function(){this.emit(\"error\",new Error(\"Cannot pipe, not readable\"))},y.prototype.write=function(t,e,r){var i,s=this._writableState,o=!1,a=!s.objectMode&&(i=t,l.isBuffer(i)||i instanceof c);return a&&!l.isBuffer(t)&&(t=function(t){return l.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),a?e=\"buffer\":e||(e=s.defaultEncoding),\"function\"!=typeof r&&(r=m),s.ended?function(t,e){var r=new Error(\"write after end\");t.emit(\"error\",r),n.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var s=!0,o=!1;return null===r?o=new TypeError(\"May not write null values to stream\"):\"string\"==typeof r||void 0===r||e.objectMode||(o=new TypeError(\"Invalid non-string/buffer chunk\")),o&&(t.emit(\"error\",o),n.nextTick(i,o),s=!1),s}(this,s,t,r))&&(s.pendingcb++,o=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=l.from(e,r));return e}(e,i,n);i!==o&&(r=!0,n=\"buffer\",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var h=e.length<e.highWaterMark;h||(e.needDrain=!0);if(e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:s,next:null},u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else b(t,e,!1,a,i,n,s);return h}(this,s,a,t,e,r)),o},y.prototype.cork=function(){this._writableState.corked++},y.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||w(this,t))},y.prototype.setDefaultEncoding=function(t){if(\"string\"==typeof t&&(t=t.toLowerCase()),!([\"hex\",\"utf8\",\"utf-8\",\"ascii\",\"binary\",\"base64\",\"ucs2\",\"ucs-2\",\"utf16le\",\"utf-16le\",\"raw\"].indexOf((t+\"\").toLowerCase())>-1))throw new TypeError(\"Unknown encoding: \"+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(y.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(t,e,r){r(new Error(\"_write() is not implemented\"))},y.prototype._writev=null,y.prototype.end=function(t,e,r){var i=this._writableState;\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?n.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,i,r)},Object.defineProperty(y.prototype,\"destroyed\",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),y.prototype.destroy=p.destroy,y.prototype._undestroy=p.undestroy,y.prototype._destroy=function(t,e){this.end(),e(t)}},7332:(t,e,r)=>{var i=r(9404),n=r(3209),s=r(2861).Buffer;function o(t){var e,r=t.modulus.byteLength();do{e=new i(n(r))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function a(t,e){var r=function(t){var e=o(t);return{blinder:e.toRed(i.mont(t.modulus)).redPow(new i(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),n=e.modulus.byteLength(),a=new i(t).mul(r.blinder).umod(e.modulus),h=a.toRed(i.mont(e.prime1)),u=a.toRed(i.mont(e.prime2)),f=e.coefficient,l=e.prime1,c=e.prime2,d=h.redPow(e.exponent1).fromRed(),p=u.redPow(e.exponent2).fromRed(),m=d.isub(p).imul(f).umod(l).imul(c);return p.iadd(m).imul(r.unblinder).umod(e.modulus).toArrayLike(s,\"be\",n)}a.getr=o,t.exports=a},7362:(t,e,r)=>{var i=r(8170),n=r(8206),s=r(2061),o=r(2509),a=r(7332),h=r(7108),u=r(9247),f=r(2861).Buffer;t.exports=function(t,e,r){var l;l=t.padding?t.padding:r?1:4;var c,d=i(t),p=d.modulus.byteLength();if(e.length>p||new o(e).cmp(d.modulus)>=0)throw new Error(\"decryption error\");c=r?u(new o(e),d):a(e,d);var m=f.alloc(p-c.length);if(c=f.concat([m,c],p),4===l)return function(t,e){var r=t.modulus.byteLength(),i=h(\"sha1\").update(f.alloc(0)).digest(),o=i.length;if(0!==e[0])throw new Error(\"decryption error\");var a=e.slice(1,o+1),u=e.slice(o+1),l=s(a,n(u,o)),c=s(u,n(l,r-o-1));if(function(t,e){t=f.from(t),e=f.from(e);var r=0,i=t.length;t.length!==e.length&&(r++,i=Math.min(t.length,e.length));var n=-1;for(;++n<i;)r+=t[n]^e[n];return r}(i,c.slice(0,o)))throw new Error(\"decryption error\");var d=o;for(;0===c[d];)d++;if(1!==c[d++])throw new Error(\"decryption error\");return c.slice(d)}(d,c);if(1===l)return function(t,e,r){var i=e.slice(0,2),n=2,s=0;for(;0!==e[n++];)if(n>=e.length){s++;break}var o=e.slice(2,n-1);(\"0002\"!==i.toString(\"hex\")&&!r||\"0001\"!==i.toString(\"hex\")&&r)&&s++;o.length<8&&s++;if(s)throw new Error(\"decryption error\");return e.slice(n)}(0,c,r);if(3===l)return c;throw new Error(\"unknown padding\")}},7363:(t,e,r)=>{var i=r(7568),n=r(6698);function s(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}e.define=function(t,e){return new s(t,e)},s.prototype._createNamed=function(t){var e;try{e=Object(function(){var t=new Error(\"Cannot find module 'vm'\");throw t.code=\"MODULE_NOT_FOUND\",t}())(\"(function \"+this.name+\"(entity) {\\n  this._initNamed(entity);\\n})\")}catch(t){e=function(t){this._initNamed(t)}}return n(e,t),e.prototype._initNamed=function(e){t.call(this,e)},new e(this)},s.prototype._getDecoder=function(t){return t=t||\"der\",this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(i.decoders[t])),this.decoders[t]},s.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r)},s.prototype._getEncoder=function(t){return t=t||\"der\",this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(i.encoders[t])),this.encoders[t]},s.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r)}},7373:t=>{t.exports=function(t){var e=0;return function(){if(e===t.length)return null;var r=t.length-e,i=Math.random()*r|0,n=t[e+i],s=t[e];return t[e]=n,t[e+i]=s,e++,n}}},7426:(t,e,r)=>{var i=r(3349),n=r(6698);function s(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function o(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?\"0\"+t:t}function h(t){return 7===t.length?\"0\"+t:6===t.length?\"00\"+t:5===t.length?\"000\"+t:4===t.length?\"0000\"+t:3===t.length?\"00000\"+t:2===t.length?\"000000\"+t:1===t.length?\"0000000\"+t:t}e.inherits=n,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(\"string\"==typeof t)if(e){if(\"hex\"===e)for((t=t.replace(/[^a-z0-9]+/gi,\"\")).length%2!=0&&(t=\"0\"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var o=t.charCodeAt(n);o<128?r[i++]=o:o<2048?(r[i++]=o>>6|192,r[i++]=63&o|128):s(t,n)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n<t.length;n++)r[n]=0|t[n];return r},e.toHex=function(t){for(var e=\"\",r=0;r<t.length;r++)e+=a(t[r].toString(16));return e},e.htonl=o,e.toHex32=function(t,e){for(var r=\"\",i=0;i<t.length;i++){var n=t[i];\"little\"===e&&(n=o(n)),r+=h(n.toString(16))}return r},e.zero2=a,e.zero8=h,e.join32=function(t,e,r,n){var s=r-e;i(s%4==0);for(var o=new Array(s/4),a=0,h=e;a<o.length;a++,h+=4){var u;u=\"big\"===n?t[h]<<24|t[h+1]<<16|t[h+2]<<8|t[h+3]:t[h+3]<<24|t[h+2]<<16|t[h+1]<<8|t[h],o[a]=u>>>0}return o},e.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];\"big\"===e?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},e.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},e.sum64=function(t,e,r,i){var n=t[e],s=i+t[e+1]>>>0,o=(s<i?1:0)+r+n;t[e]=o>>>0,t[e+1]=s},e.sum64_hi=function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,i){return e+i>>>0},e.sum64_4_hi=function(t,e,r,i,n,s,o,a){var h=0,u=e;return h+=(u=u+i>>>0)<e?1:0,h+=(u=u+s>>>0)<s?1:0,t+r+n+o+(h+=(u=u+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,r,i,n,s,o,a){return e+i+s+a>>>0},e.sum64_5_hi=function(t,e,r,i,n,s,o,a,h,u){var f=0,l=e;return f+=(l=l+i>>>0)<e?1:0,f+=(l=l+s>>>0)<s?1:0,f+=(l=l+a>>>0)<a?1:0,t+r+n+o+h+(f+=(l=l+u>>>0)<u?1:0)>>>0},e.sum64_5_lo=function(t,e,r,i,n,s,o,a,h,u){return e+i+s+a+u>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},7447:(t,e,r)=>{var i=r(8490),n=r(2723),s=r(7011),o=r(480),a=r(5037),h=s.assert,u=r(1200),f=r(8545);function l(t){if(!(this instanceof l))return new l(t);\"string\"==typeof t&&(h(Object.prototype.hasOwnProperty.call(o,t),\"Unknown curve \"+t),t=o[t]),t instanceof o.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}t.exports=l,l.prototype.keyPair=function(t){return new u(this,t)},l.prototype.keyFromPrivate=function(t,e){return u.fromPrivate(this,t,e)},l.prototype.keyFromPublic=function(t,e){return u.fromPublic(this,t,e)},l.prototype.genKeyPair=function(t){t||(t={});for(var e=new n({hash:this.hash,pers:t.pers,persEnc:t.persEnc||\"utf8\",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||\"utf8\",nonce:this.n.toArray()}),r=this.n.byteLength(),s=this.n.sub(new i(2));;){var o=new i(e.generate(r));if(!(o.cmp(s)>0))return o.iaddn(1),this.keyFromPrivate(o)}},l.prototype._truncateToN=function(t,e,r){var n;if(i.isBN(t)||\"number\"==typeof t)n=(t=new i(t,16)).byteLength();else if(\"object\"==typeof t)n=t.length,t=new i(t,16);else{var s=t.toString();n=s.length+1>>>1,t=new i(s,16)}\"number\"!=typeof r&&(r=8*n);var o=r-this.n.bitLength();return o>0&&(t=t.ushrn(o)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},l.prototype.sign=function(t,e,r,s){if(\"object\"==typeof r&&(s=r,r=null),s||(s={}),\"string\"!=typeof t&&\"number\"!=typeof t&&!i.isBN(t)){h(\"object\"==typeof t&&t&&\"number\"==typeof t.length,\"Expected message to be an array-like, a hex string, or a BN instance\"),h(t.length>>>0===t.length);for(var o=0;o<t.length;o++)h((255&t[o])===t[o])}e=this.keyFromPrivate(e,r),t=this._truncateToN(t,!1,s.msgBitLength),h(!t.isNeg(),\"Can not sign a negative message\");var a=this.n.byteLength(),u=e.getPrivate().toArray(\"be\",a),l=t.toArray(\"be\",a);h(new i(l).eq(t),\"Can not sign message\");for(var c=new n({hash:this.hash,entropy:u,nonce:l,pers:s.pers,persEnc:s.persEnc||\"utf8\"}),d=this.n.sub(new i(1)),p=0;;p++){var m=s.k?s.k(p):new i(c.generate(this.n.byteLength()));if(!((m=this._truncateToN(m,!0)).cmpn(1)<=0||m.cmp(d)>=0)){var g=this.g.mul(m);if(!g.isInfinity()){var y=g.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var v=m.invm(this.n).mul(b.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var w=(g.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return s.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),w^=1),new f({r:b,s:v,recoveryParam:w})}}}}}},l.prototype.verify=function(t,e,r,i,n){n||(n={}),t=this._truncateToN(t,!1,n.msgBitLength),r=this.keyFromPublic(r,i);var s=(e=new f(e,\"hex\")).r,o=e.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,h=o.invm(this.n),u=h.mul(t).umod(this.n),l=h.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),l)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(u,r.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},l.prototype.recoverPubKey=function(t,e,r,n){h((3&r)===r,\"The recovery param is more than two bits\"),e=new f(e,n);var s=this.n,o=new i(t),a=e.r,u=e.s,l=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error(\"Unable to find sencond key candinate\");a=c?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var d=e.r.invm(s),p=s.sub(o).mul(d).umod(s),m=u.mul(d).umod(s);return this.g.mulAdd(p,a,m)},l.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new f(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(r))return n}throw new Error(\"Unable to find valid recovery factor\")}},7479:(t,e,r)=>{var i=r(6229).Buffer,n=i.isEncoding||function(t){switch((t=\"\"+t)&&t.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 s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){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 t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=h,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=l,e=3;break;default:return this.write=c,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):\"\"}e.I=s,s.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||\"\"},s.prototype.end=function(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+\"�\":e},s.prototype.text=function(t,e){var r=function(t,e,r){var i=e.length-1;if(i<r)return 0;var n=o(e[i]);if(n>=0)return n>0&&(t.lastNeed=n-1),n;if(--i<r||-2===n)return 0;if(n=o(e[i]),n>=0)return n>0&&(t.lastNeed=n-2),n;if(--i<r||-2===n)return 0;if(n=o(e[i]),n>=0)return n>0&&(2===n?n=0:t.lastNeed=n-3),n;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString(\"utf8\",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},7526:(t,e)=>{e.byteLength=function(t){var e=a(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,s=a(t),o=s[0],h=s[1],u=new n(function(t,e,r){return 3*(e+r)/4-r}(0,o,h)),f=0,l=h>0?o-4:o;for(r=0;r<l;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],u[f++]=e>>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===h&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===h&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,s=[],o=16383,a=0,h=i-n;a<h;a+=o)s.push(u(t,a,a+o>h?h:a+o));1===n?(e=t[i-1],s.push(r[e>>2]+r[e<<4&63]+\"==\")):2===n&&(e=(t[i-2]<<8)+t[i-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\"));return s.join(\"\")};for(var r=[],i=[],n=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,s=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0;o<64;++o)r[o]=s[o],i[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var r=t.indexOf(\"=\");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function u(t,e,r){for(var i,n=[],s=e;s<r;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),n.push(h(i));return n.join(\"\")}i[\"-\".charCodeAt(0)]=62,i[\"_\".charCodeAt(0)]=63},7541:(t,e,r)=>{const i=r(8765),n=r(8499);t.exports={Throttle:i,ThrottleGroup:n}},7558:(t,e,r)=>{var i=r(8287).Buffer,n=r(7861),s=r(8394),o=r(8957).isIP,a=r(5221),h=r(537),u=r(7007),f=new Error(\"Query timed out\");f.code=\"ETIMEDOUT\";var l=new Error(\"Unexpected node id\");function c(t){if(!(this instanceof c))return new c(t);t||(t={});var e=this;this.timeout=t.timeout||2e3,this.inflight=0,this.destroyed=!1,this.isIP=t.isIP||o,this.socket=t.socket||n.createSocket(\"udp4\"),this.socket.on(\"message\",function(t,r){if(e.destroyed)return;if(!r.port)return;try{var n=s.decode(t)}catch(t){return e.emit(\"warning\",t)}var o=n&&n.y&&n.y.toString();if(\"r\"===o||\"e\"===o){if(!i.isBuffer(n.t))return;try{var a=n.t.readUInt16BE(0)}catch(c){return e.emit(\"warning\",c)}var h=e._ids.indexOf(a);if(-1===h||0===a)return e.emit(\"response\",n,r),void e.emit(\"warning\",new Error(\"Unexpected transaction id: \"+a));var u=e._reqs[h];if(u.peer.host!==r.address)return e.emit(\"response\",n,r),void e.emit(\"warning\",new Error(\"Out of order response\"));if(e._ids[h]=0,e._reqs[h]=null,e.inflight--,\"e\"===o){var f=Array.isArray(n.e),c=new Error(f?n.e.join(\" \"):\"Unknown error\");return c.code=f&&n.e.length&&\"number\"==typeof n.e[0]?n.e[0]:0,u.callback(c,n,r,u.message),e.emit(\"update\"),void e.emit(\"postupdate\")}var d=n.r&&n.r.id;if(u.peer&&u.peer.id&&d&&!u.peer.id.equals(d))return u.callback(l,null,r),e.emit(\"update\"),void e.emit(\"postupdate\");u.callback(null,n,r,u.message),e.emit(\"update\"),e.emit(\"postupdate\"),e.emit(\"response\",n,r)}else\"q\"===o?e.emit(\"query\",n,r):e.emit(\"warning\",new Error(\"Unknown type: \"+o))}),this.socket.on(\"error\",function(t){\"EACCES\"===t.code||\"EADDRINUSE\"===t.code?e.emit(\"error\",t):e.emit(\"warning\",t)}),this.socket.on(\"listening\",function(){e.emit(\"listening\")}),this._tick=0,this._ids=[],this._reqs=[],this._timer=setInterval(function(){var t=e.inflight;if(!t)return;for(var r=0;r<e._reqs.length;r++){var i=e._reqs[r];if(i&&(i.ttl?i.ttl--:e._cancel(r,f),! --t))return}},Math.floor(this.timeout/4)),u.EventEmitter.call(this)}function d(){}l.code=\"EUNEXPECTEDNODE\",t.exports=c,h.inherits(c,u.EventEmitter),c.prototype.address=function(){return this.socket.address()},c.prototype.response=function(t,e,r,i){this.send(t,{t:e.t,y:\"r\",r},i)},c.prototype.error=function(t,e,r,i){this.send(t,{t:e.t,y:\"e\",e:[].concat(r.message||r)},i)},c.prototype.send=function(t,e,r){var i=s.encode(e);this.socket.send(i,0,i.length,t.port,t.address||t.host,r||d)},c.prototype.bind=function(){this.socket.bind.apply(this.socket,arguments)},c.prototype.destroy=function(t){this.destroyed=!0,clearInterval(this._timer),t&&this.socket.on(\"close\",t);for(var e=0;e<this._ids.length;e++)this._cancel(e);this.socket.close()},c.prototype.query=function(t,e,r){if(r||(r=d),!this.isIP(t.host))return this._resolveAndQuery(t,e,r);var n={t:i.allocUnsafe(2),y:\"q\",q:e.q,a:e.a},s={ttl:4,peer:t,message:n,callback:r};65535===this._tick&&(this._tick=0);var o=++this._tick,a=this._ids.indexOf(0);for(-1===a&&(a=this._ids.push(0)-1),this._ids[a]=o;this._reqs.length<a;)this._reqs.push(null);return this._reqs[a]=s,this.inflight++,n.t.writeUInt16BE(o,0),this.send(t,n),o},c.prototype.cancel=function(t,e){var r=this._ids.indexOf(t);r>-1&&this._cancel(r,e)},c.prototype._cancel=function(t,e){var r=this._reqs[t];this._ids[t]=0,this._reqs[t]=null,r&&(this.inflight--,r.callback(e||new Error(\"Query was cancelled\"),null,r.peer),this.emit(\"update\"),this.emit(\"postupdate\"))},c.prototype._resolveAndQuery=function(t,e,r){var i=this;a.lookup(t.host,function(n,s){return n?r(n):i.destroyed?r(new Error(\"k-rpc-socket is destroyed\")):void i.query({host:s,port:t.port},e,r)})}},7568:(t,e,r)=>{var i=e;i.bignum=r(2344),i.define=r(7363).define,i.base=r(9673),i.constants=r(2153),i.decoders=r(2853),i.encoders=r(4669)},7626:(t,e)=>{e.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},e.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},e.ip=function(t,e,r,i){for(var n=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>>a+o&1}for(o=6;o>=0;o-=2){for(a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1;for(a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1}r[i+0]=n>>>0,r[i+1]=s>>>0},e.rip=function(t,e,r,i){for(var n=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)n<<=1,n|=e>>>a+o&1,n<<=1,n|=t>>>a+o&1;for(o=4;o<8;o++)for(a=24;a>=0;a-=8)s<<=1,s|=e>>>a+o&1,s<<=1,s|=t>>>a+o&1;r[i+0]=n>>>0,r[i+1]=s>>>0},e.pc1=function(t,e,r,i){for(var n=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>a+o&1}for(a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(o=1;o<=3;o++){for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1}for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;r[i+0]=n>>>0,r[i+1]=s>>>0},e.r28shl=function(t,e){return t<<e&268435455|t>>>28-e};var r=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];e.pc2=function(t,e,i,n){for(var s=0,o=0,a=r.length>>>1,h=0;h<a;h++)s<<=1,s|=t>>>r[h]&1;for(h=a;h<r.length;h++)o<<=1,o|=e>>>r[h]&1;i[n+0]=s>>>0,i[n+1]=o>>>0},e.expand=function(t,e,r){var i=0,n=0;i=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=t>>>s&63;for(s=11;s>=3;s-=4)n|=t>>>s&63,n<<=6;n|=(31&t)<<1|t>>>31,e[r+0]=i>>>0,e[r+1]=n>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];e.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var n=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];e.permute=function(t){for(var e=0,r=0;r<n.length;r++)e<<=1,e|=t>>>n[r]&1;return e>>>0},e.padSplit=function(t,e,r){for(var i=t.toString(2);i.length<e;)i=\"0\"+i;for(var n=[],s=0;s<e;s+=r)n.push(i.slice(s,s+r));return n.join(\" \")}},7714:(t,e,r)=>{var i=r(7426),n=r(2287);function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(s,n),t.exports=s,s.blockSize=512,s.outSize=224,s.hmacStrength=192,s.padLength=64,s.prototype._digest=function(t){return\"hex\"===t?i.toHex32(this.h.slice(0,7),\"big\"):i.split32(this.h.slice(0,7),\"big\")}},7720:(t,e,r)=>{var i=r(4765),n=Object.prototype.hasOwnProperty,s=Array.isArray,o=function(){for(var t=[],e=0;e<256;++e)t.push(\"%\"+((e<16?\"0\":\"\")+e.toString(16)).toUpperCase());return t}(),a=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},i=0;i<t.length;++i)void 0!==t[i]&&(r[i]=t[i]);return r},h=1024;t.exports={arrayToObject:a,assign:function(t,e){return Object.keys(e).reduce(function(t,r){return t[r]=e[r],t},t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:\"o\"}],r=[],i=0;i<e.length;++i)for(var n=e[i],o=n.obj[n.prop],a=Object.keys(o),h=0;h<a.length;++h){var u=a[h],f=o[u];\"object\"==typeof f&&null!==f&&-1===r.indexOf(f)&&(e.push({obj:o,prop:u}),r.push(f))}return function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(s(r)){for(var i=[],n=0;n<r.length;++n)void 0!==r[n]&&i.push(r[n]);e.obj[e.prop]=i}}}(e),t},decode:function(t,e,r){var i=t.replace(/\\+/g,\" \");if(\"iso-8859-1\"===r)return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch(t){return i}},encode:function(t,e,r,n,s){if(0===t.length)return t;var a=t;if(\"symbol\"==typeof t?a=Symbol.prototype.toString.call(t):\"string\"!=typeof t&&(a=String(t)),\"iso-8859-1\"===r)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(t){return\"%26%23\"+parseInt(t.slice(2),16)+\"%3B\"});for(var u=\"\",f=0;f<a.length;f+=h){for(var l=a.length>=h?a.slice(f,f+h):a,c=[],d=0;d<l.length;++d){var p=l.charCodeAt(d);45===p||46===p||95===p||126===p||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||s===i.RFC1738&&(40===p||41===p)?c[c.length]=l.charAt(d):p<128?c[c.length]=o[p]:p<2048?c[c.length]=o[192|p>>6]+o[128|63&p]:p<55296||p>=57344?c[c.length]=o[224|p>>12]+o[128|p>>6&63]+o[128|63&p]:(d+=1,p=65536+((1023&p)<<10|1023&l.charCodeAt(d)),c[c.length]=o[240|p>>18]+o[128|p>>12&63]+o[128|p>>6&63]+o[128|63&p])}u+=c.join(\"\")}return u},isBuffer:function(t){return!(!t||\"object\"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return\"[object RegExp]\"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(s(t)){for(var r=[],i=0;i<t.length;i+=1)r.push(e(t[i]));return r}return e(t)},merge:function t(e,r,i){if(!r)return e;if(\"object\"!=typeof r){if(s(e))e.push(r);else{if(!e||\"object\"!=typeof e)return[e,r];(i&&(i.plainObjects||i.allowPrototypes)||!n.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||\"object\"!=typeof e)return[e].concat(r);var o=e;return s(e)&&!s(r)&&(o=a(e,i)),s(e)&&s(r)?(r.forEach(function(r,s){if(n.call(e,s)){var o=e[s];o&&\"object\"==typeof o&&r&&\"object\"==typeof r?e[s]=t(o,r,i):e.push(r)}else e[s]=r}),e):Object.keys(r).reduce(function(e,s){var o=r[s];return n.call(e,s)?e[s]=t(e[s],o,i):e[s]=o,e},o)}}},7758:(t,e,r)=>{var i;var n=r(113).F,s=n.ERR_MISSING_ARGS,o=n.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function h(t){t()}function u(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var f,l=function(t){return t.length?\"function\"!=typeof t[t.length-1]?a:t.pop():a}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new s(\"streams\");var c=e.map(function(t,n){var s=n<e.length-1;return function(t,e,n,s){s=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(s);var a=!1;t.on(\"close\",function(){a=!0}),void 0===i&&(i=r(6238)),i(t,{readable:e,writable:n},function(t){if(t)return s(t);a=!0,s()});var h=!1;return function(e){if(!a&&!h)return h=!0,function(t){return t.setHeader&&\"function\"==typeof t.abort}(t)?t.abort():\"function\"==typeof t.destroy?t.destroy():void s(e||new o(\"pipe\"))}}(t,s,n>0,function(t){f||(f=t),t&&c.forEach(h),s||(c.forEach(h),l(f))})});return e.reduce(u)}},7766:(t,e,r)=>{var i=r(7426),n=r(6166),s=r(3349),o=i.rotr64_hi,a=i.rotr64_lo,h=i.shr64_hi,u=i.shr64_lo,f=i.sum64,l=i.sum64_hi,c=i.sum64_lo,d=i.sum64_4_hi,p=i.sum64_4_lo,m=i.sum64_5_hi,g=i.sum64_5_lo,y=n.BlockHash,b=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;y.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b,this.W=new Array(160)}function w(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function _(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function M(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function S(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function k(t,e){var r=o(t,e,28)^o(e,t,2)^o(e,t,7);return r<0&&(r+=4294967296),r}function E(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function x(t,e){var r=o(t,e,14)^o(t,e,18)^o(e,t,9);return r<0&&(r+=4294967296),r}function A(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function I(t,e){var r=o(t,e,1)^o(t,e,8)^h(t,e,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=a(t,e,1)^a(t,e,8)^u(t,e,7);return r<0&&(r+=4294967296),r}function C(t,e){var r=o(t,e,19)^o(e,t,29)^h(t,e,6);return r<0&&(r+=4294967296),r}function P(t,e){var r=a(t,e,19)^a(e,t,29)^u(t,e,6);return r<0&&(r+=4294967296),r}i.inherits(v,y),t.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=C(r[i-4],r[i-3]),s=P(r[i-4],r[i-3]),o=r[i-14],a=r[i-13],h=I(r[i-30],r[i-29]),u=T(r[i-30],r[i-29]),f=r[i-32],l=r[i-31];r[i]=d(n,s,o,a,h,u,f,l),r[i+1]=p(n,s,o,a,h,u,f,l)}},v.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],o=this.h[2],a=this.h[3],h=this.h[4],u=this.h[5],d=this.h[6],p=this.h[7],y=this.h[8],b=this.h[9],v=this.h[10],I=this.h[11],T=this.h[12],C=this.h[13],P=this.h[14],R=this.h[15];s(this.k.length===r.length);for(var O=0;O<r.length;O+=2){var B=P,L=R,N=x(y,b),j=A(y,b),U=w(y,b,v,I,T),q=_(y,b,v,I,T,C),D=this.k[O],H=this.k[O+1],F=r[O],z=r[O+1],W=m(B,L,N,j,U,q,D,H,F,z),$=g(B,L,N,j,U,q,D,H,F,z);B=k(i,n),L=E(i,n),N=M(i,n,o,a,h),j=S(i,n,o,a,h,u);var V=l(B,L,N,j),K=c(B,L,N,j);P=T,R=C,T=v,C=I,v=y,I=b,y=l(d,p,W,$),b=c(p,p,W,$),d=h,p=u,h=o,u=a,o=i,a=n,i=l(W,$,V,K),n=c(W,$,V,K)}f(this.h,0,i,n),f(this.h,2,o,a),f(this.h,4,h,u),f(this.h,6,d,p),f(this.h,8,y,b),f(this.h,10,v,I),f(this.h,12,T,C),f(this.h,14,P,R)},v.prototype._digest=function(t){return\"hex\"===t?i.toHex32(this.h,\"big\"):i.split32(this.h,\"big\")}},7816:(t,e,r)=>{var i=r(6698),n=r(392),s=r(2861).Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function h(){this.init(),this._w=a,n.call(this,64,56)}function u(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function l(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}i(h,n),h.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},h.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,s=0|this._d,a=0|this._e,h=0;h<16;++h)e[h]=t.readInt32BE(4*h);for(;h<80;++h)e[h]=e[h-3]^e[h-8]^e[h-14]^e[h-16];for(var c=0;c<80;++c){var d=~~(c/20),p=u(r)+l(d,i,n,s)+a+e[c]+o[d]|0;a=s,s=n,n=f(i),i=r,r=p}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0},h.prototype._hash=function(){var t=s.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=h},7833:(t,e,r)=>{var i=r(717);e.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 r=\"color: \"+this.color;e.splice(1,0,r,\"color: inherit\");let i=0,n=0;e[0].replace(/%[a-zA-Z%]/g,t=>{\"%%\"!==t&&(i++,\"%c\"===t&&(n=i))}),e.splice(n,0,r)},e.save=function(t){try{t?e.storage.setItem(\"debug\",t):e.storage.removeItem(\"debug\")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem(\"debug\")||e.storage.getItem(\"DEBUG\")}catch(t){}!t&&void 0!==i&&\"env\"in i&&(t=i.env.DEBUG);return t},e.useColors=function(){if(\"undefined\"!=typeof window&&window.process&&(\"renderer\"===window.process.type||window.process.__nwjs))return!0;if(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))return!1;let t;return\"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&&(t=navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/))&&parseInt(t[1],10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),e.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\"],e.log=console.debug||console.log||(()=>{}),t.exports=r(736)(e);const{formatters:n}=t.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return\"[UnexpectedJSONParseError]: \"+t.message}}},7861:(t,e,r)=>{var i=r(8287).Buffer;e.Socket=u;var n=r(7007).EventEmitter,s=r(6698),o=r(1672),a=0,h={};function u(t,e){var r=this;if(n.call(r),\"string\"==typeof t&&(t={type:t}),\"udp4\"!==t.type)throw new Error(\"Bad socket type specified. Valid types are: udp4\");\"function\"==typeof e&&r.on(\"message\",e),r._destroyed=!1,r._bindState=a,r._bindTasks=[]}\"object\"==typeof chrome&&\"object\"==typeof chrome.runtime&&\"string\"==typeof chrome.runtime.id&&\"object\"==typeof chrome.sockets&&\"object\"==typeof chrome.sockets.udp&&(chrome.sockets.udp.onReceive.addListener(function(t){t.socketId in h?h[t.socketId]._onReceive(t):console.error(\"Unknown socket id: \"+t.socketId)}),chrome.sockets.udp.onReceiveError.addListener(function(t){t.socketId in h?h[t.socketId]._onReceiveError(t.resultCode):console.error(\"Unknown socket id: \"+t.socketId)})),e.createSocket=function(t,e){return new u(t,e)},s(u,n),u.prototype.bind=function(t,e,r){var i=this;if(\"function\"==typeof e&&(r=e,e=void 0),e||(e=\"0.0.0.0\"),t||(t=0),i._bindState!==a)throw new Error(\"Socket is already bound\");i._bindState=1,\"function\"==typeof r&&i.once(\"listening\",r),chrome.sockets.udp.create(function(r){i.id=r.socketId,h[i.id]=i;var n=i._bindTasks.map(function(t){return t.fn});o(n,function(r){if(r)return i.emit(\"error\",r);chrome.sockets.udp.bind(i.id,e,t,function(t){t<0?i.emit(\"error\",new Error(\"Socket \"+i.id+\" failed to bind. \"+chrome.runtime.lastError.message)):chrome.sockets.udp.getInfo(i.id,function(t){t.localPort&&t.localAddress?(i._port=t.localPort,i._address=t.localAddress,i._bindState=2,i.emit(\"listening\"),i._bindTasks.map(function(t){t.callback()})):i.emit(\"error\",new Error(\"Cannot get local port/address for Socket \"+i.id))})})})})},u.prototype._onReceive=function(t){var e=i.from(new Uint8Array(t.data)),r={address:t.remoteAddress,family:\"IPv4\",port:t.remotePort,size:e.length};this.emit(\"message\",e,r)},u.prototype._onReceiveError=function(t){this.emit(\"error\",new Error(\"Socket \"+this.id+\" receive error \"+t))},u.prototype.send=function(t,e,r,n,s,o){var h,u=this;if(s||n&&\"function\"!=typeof n?t=function(t,e,r){if(\"string\"==typeof t)t=i.from(t);else if(!(t instanceof i))throw new TypeError(\"First argument must be a buffer or string\");e>>>=0,r>>>=0;var n=t.buffer;(t.byteOffset||t.byteLength!==n.byteLength)&&(n=n.slice(t.byteOffset,t.byteOffset+t.byteLength));(e||r!==t.length)&&(n=n.slice(e,r));return i.from(n)}(t,e,r):(o=n,n=e,s=r),Array.isArray(t)){if(!(h=function(t){for(var e=new Array(t.length),r=0,n=t.length;r<n;r++){var s=t[r];if(\"string\"==typeof s)e[r]=i.from(s);else{if(!(s instanceof i))return null;e[r]=s}}return e}(t)))throw new TypeError(\"Buffer list arguments must be buffers or strings\")}else if(\"string\"==typeof t)h=[i.from(t)];else{if(!(t instanceof i))throw new TypeError(\"First argument must be a buffer or a string\");h=[t]}if(0===(n>>>=0)||n>65535)throw new RangeError(\"Port should be > 0 and < 65536\");if(\"function\"!=typeof o&&(o=function(){}),u._bindState===a&&u.bind(0),2!==u._bindState)return u._sendQueue||(u._sendQueue=[],u.once(\"listening\",function(){for(var t=0;t<u._sendQueue.length;t++)u.send.apply(u,u._sendQueue[t]);u._sendQueue=void 0})),void u._sendQueue.push([t,e,r,n,s,o]);var f=i.concat(h).buffer;chrome.sockets.udp.send(u.id,f,s,n,function(t){if(t.resultCode<0){var e=new Error(\"Socket \"+u.id+\" send error \"+t.resultCode);o(e),u.emit(\"error\",e)}else o(null)})},u.prototype.close=function(){var t=this;t._destroyed||(delete h[t.id],chrome.sockets.udp.close(t.id),t._destroyed=!0,t.emit(\"close\"))},u.prototype.address=function(){return{address:this._address,port:this._port,family:\"IPv4\"}},u.prototype.setBroadcast=function(t){},u.prototype.setTTL=function(t){},u.prototype.setMulticastTTL=function(t,e){var r=this;function i(e){chrome.sockets.udp.setMulticastTimeToLive(r.id,t,e)}e||(e=function(){}),2===r._bindState?i(e):r._bindTasks.push({fn:i,callback:e})},u.prototype.setMulticastLoopback=function(t,e){var r=this;function i(e){chrome.sockets.udp.setMulticastLoopbackMode(r.id,t,e)}e||(e=function(){}),2===r._bindState?i(e):r._bindTasks.push({fn:i,callback:e})},u.prototype.addMembership=function(t,e,r){r||(r=function(){}),chrome.sockets.udp.joinGroup(this.id,t,r)},u.prototype.dropMembership=function(t,e,r){r||(r=function(){}),chrome.sockets.udp.leaveGroup(this.id,t,r)},u.prototype.unref=function(){},u.prototype.ref=function(){}},7952:(t,e,r)=>{var i=e;i.utils=r(7426),i.common=r(6166),i.sha=r(8610),i.ripemd=r(6784),i.hmac=r(8948),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},7972:(t,e,r)=>{var i=r(8287).Buffer;const n=t.exports;n.digitCount=function(t){const e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e},n.getType=function(t){return i.isBuffer(t)?\"buffer\":ArrayBuffer.isView(t)?\"arraybufferview\":Array.isArray(t)?\"array\":t instanceof Number?\"number\":t instanceof Boolean?\"boolean\":t instanceof Set?\"set\":t instanceof Map?\"map\":t instanceof String?\"string\":t instanceof ArrayBuffer?\"arraybuffer\":typeof t}},8002:t=>{t.exports=Math.min},8068:t=>{t.exports=SyntaxError},8078:(t,e,r)=>{var i=r(2861).Buffer,n=r(8276);t.exports=function(t,e,r,s){if(i.isBuffer(t)||(t=i.from(t,\"binary\")),e&&(i.isBuffer(e)||(e=i.from(e,\"binary\")),8!==e.length))throw new RangeError(\"salt should be Buffer with 8 byte length\");for(var o=r/8,a=i.alloc(o),h=i.alloc(s||0),u=i.alloc(0);o>0||s>0;){var f=new n;f.update(u),f.update(t),e&&f.update(e),u=f.digest();var l=0;if(o>0){var c=a.length-o;l=Math.min(o,u.length),u.copy(a,c,0,l),o-=l}if(l<u.length&&s>0){var d=h.length-s,p=Math.min(s,u.length-l);u.copy(h,d,l,l+p),s-=p}}return u.fill(0),{key:a,iv:h}}},8093:(t,e,r)=>{t.exports=r(537).inspect},8158:(t,e,r)=>{t.exports=s;var i=r(5972),n=Object.create(r(5622));function s(t){if(!(this instanceof s))return new s(t);i.call(this,t)}n.inherits=r(6698),n.inherits(s,i),s.prototype._transform=function(t,e,r){r(null,t)}},8170:(t,e,r)=>{var i=r(1137),n=r(5579),s=r(4101),o=r(1241),a=r(5488).pbkdf2Sync,h=r(2861).Buffer;function u(t){var e;\"object\"!=typeof t||h.isBuffer(t)||(e=t.passphrase,t=t.key),\"string\"==typeof t&&(t=h.from(t));var r,u,f=s(t,e),l=f.tag,c=f.data;switch(l){case\"CERTIFICATE\":u=i.certificate.decode(c,\"der\").tbsCertificate.subjectPublicKeyInfo;case\"PUBLIC KEY\":switch(u||(u=i.PublicKey.decode(c,\"der\")),r=u.algorithm.algorithm.join(\".\")){case\"1.2.840.113549.1.1.1\":return i.RSAPublicKey.decode(u.subjectPublicKey.data,\"der\");case\"1.2.840.10045.2.1\":return u.subjectPrivateKey=u.subjectPublicKey,{type:\"ec\",data:u};case\"1.2.840.10040.4.1\":return u.algorithm.params.pub_key=i.DSAparam.decode(u.subjectPublicKey.data,\"der\"),{type:\"dsa\",data:u.algorithm.params};default:throw new Error(\"unknown key id \"+r)}case\"ENCRYPTED PRIVATE KEY\":c=function(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),s=n[t.algorithm.decrypt.cipher.algo.join(\".\")],u=t.algorithm.decrypt.cipher.iv,f=t.subjectPrivateKey,l=parseInt(s.split(\"-\")[1],10)/8,c=a(e,r,i,l,\"sha1\"),d=o.createDecipheriv(s,c,u),p=[];return p.push(d.update(f)),p.push(d.final()),h.concat(p)}(c=i.EncryptedPrivateKey.decode(c,\"der\"),e);case\"PRIVATE KEY\":switch(r=(u=i.PrivateKey.decode(c,\"der\")).algorithm.algorithm.join(\".\")){case\"1.2.840.113549.1.1.1\":return i.RSAPrivateKey.decode(u.subjectPrivateKey,\"der\");case\"1.2.840.10045.2.1\":return{curve:u.algorithm.curve,privateKey:i.ECPrivateKey.decode(u.subjectPrivateKey,\"der\").privateKey};case\"1.2.840.10040.4.1\":return u.algorithm.params.priv_key=i.DSAparam.decode(u.subjectPrivateKey,\"der\"),{type:\"dsa\",params:u.algorithm.params};default:throw new Error(\"unknown key id \"+r)}case\"RSA PUBLIC KEY\":return i.RSAPublicKey.decode(c,\"der\");case\"RSA PRIVATE KEY\":return i.RSAPrivateKey.decode(c,\"der\");case\"DSA PRIVATE KEY\":return{type:\"dsa\",params:i.DSAPrivateKey.decode(c,\"der\")};case\"EC PRIVATE KEY\":return{curve:(c=i.ECPrivateKey.decode(c,\"der\")).parameters.value,privateKey:c.privateKey};default:throw new Error(\"unknown key type \"+l)}}u.signature=i.signature,t.exports=u},8179:(t,e,r)=>{const{EventEmitter:i}=r(7007),n=new Error(\"Stream was destroyed\"),s=new Error(\"Premature close\"),o=r(6080),a=r(5335),h=\"undefined\"==typeof queueMicrotask?t=>globalThis.process.nextTick(t):queueMicrotask,u=536870911,f=1^u,l=2^u,c=32,d=64,p=128,m=256,g=1024,y=2048,b=4096,v=8192,w=16384,_=32768,M=131072,S=131328,k=16^u,E=536805375,x=768^u,A=536838143,I=536739839,T=1<<18,C=2<<18,P=4<<18,R=8<<18,O=16<<18,B=32<<18,L=64<<18,N=128<<18,j=256<<18,U=512<<18,q=1024<<18,D=535822335,H=503316479,F=268435455,z=262160,W=536608751,$=8404992,V=14,K=15,Z=8405006,G=33587200,Y=33587215,J=2359296,X=270794767,Q=Symbol.asyncIterator||Symbol(\"asyncIterator\");class tt{constructor(t,{highWaterMark:e=16384,map:r=null,mapWritable:i,byteLength:n,byteLengthWritable:s}={}){this.stream=t,this.queue=new o,this.highWaterMark=e,this.buffered=0,this.error=null,this.pipeline=null,this.drains=null,this.byteLength=s||n||kt,this.map=i||r,this.afterWrite=at.bind(this),this.afterUpdateNextTick=ft.bind(this)}get ended(){return 0!==(this.stream._duplexState&B)}push(t){return!(142606350&this.stream._duplexState)&&(null!==this.map&&(t=this.map(t)),this.buffered+=this.byteLength(t),this.queue.push(t),this.buffered<this.highWaterMark?(this.stream._duplexState|=R,!0):(this.stream._duplexState|=6291456,!1))}shift(){const t=this.queue.shift();return this.buffered-=this.byteLength(t),0===this.buffered&&(this.stream._duplexState&=534773759),t}end(t){\"function\"==typeof t?this.stream.once(\"finish\",t):null!=t&&this.push(t),this.stream._duplexState=(this.stream._duplexState|U)&D}autoBatch(t,e){const r=[],i=this.stream;for(r.push(t);(i._duplexState&X)===J;)r.push(i._writableState.shift());if(0!==(i._duplexState&K))return e(null);i._writev(r,e)}update(){const t=this.stream;t._duplexState|=C;do{for(;(t._duplexState&X)===R;){const e=this.shift();t._duplexState|=67371008,t._write(e,this.afterWrite)}1310720&t._duplexState||this.updateNonPrimary()}while(!0===this.continueUpdate());t._duplexState&=536346623}updateNonPrimary(){const t=this.stream;if((144965647&t._duplexState)===U)return t._duplexState=t._duplexState|T,void t._final(st.bind(this));4!==(t._duplexState&V)?1===(t._duplexState&Y)&&(t._duplexState=(t._duplexState|z)&f,t._open(lt.bind(this))):0===(t._duplexState&G)&&(t._duplexState|=z,t._destroy(ot.bind(this)))}continueUpdate(){return 0!==(this.stream._duplexState&N)&&(this.stream._duplexState&=H,!0)}updateCallback(){(35127311&this.stream._duplexState)===P?this.update():this.updateNextTick()}updateNextTick(){0===(this.stream._duplexState&N)&&(this.stream._duplexState|=N,0===(this.stream._duplexState&C)&&h(this.afterUpdateNextTick))}}class et{constructor(t,{highWaterMark:e=16384,map:r=null,mapReadable:i,byteLength:n,byteLengthReadable:s}={}){this.stream=t,this.queue=new o,this.highWaterMark=0===e?1:e,this.buffered=0,this.readAhead=e>0,this.error=null,this.pipeline=null,this.byteLength=s||n||kt,this.map=i||r,this.pipeTo=null,this.afterRead=ht.bind(this),this.afterUpdateNextTick=ut.bind(this)}get ended(){return 0!==(this.stream._duplexState&w)}pipe(t,e){if(null!==this.pipeTo)throw new Error(\"Can only pipe to one destination\");if(\"function\"!=typeof e&&(e=null),this.stream._duplexState|=512,this.pipeTo=t,this.pipeline=new it(this.stream,t,e),e&&this.stream.on(\"error\",Et),St(t))t._writableState.pipeline=this.pipeline,e&&t.on(\"error\",Et),t.on(\"finish\",this.pipeline.finished.bind(this.pipeline));else{const e=this.pipeline.done.bind(this.pipeline,t),r=this.pipeline.done.bind(this.pipeline,t,null);t.on(\"error\",e),t.on(\"close\",r),t.on(\"finish\",this.pipeline.finished.bind(this.pipeline))}t.on(\"drain\",nt.bind(this)),this.stream.emit(\"piping\",t),t.emit(\"pipe\",this.stream)}push(t){const e=this.stream;return null===t?(this.highWaterMark=0,e._duplexState=536805311&e._duplexState|1024,!1):null!==this.map&&null===(t=this.map(t))?(e._duplexState&=E,this.buffered<this.highWaterMark):(this.buffered+=this.byteLength(t),this.queue.push(t),e._duplexState=(e._duplexState|p)&E,this.buffered<this.highWaterMark)}shift(){const t=this.queue.shift();return this.buffered-=this.byteLength(t),0===this.buffered&&(this.stream._duplexState&=536862591),t}unshift(t){const e=[null!==this.map?this.map(t):t];for(;this.buffered>0;)e.push(this.shift());for(let t=0;t<e.length-1;t++){const r=e[t];this.buffered+=this.byteLength(r),this.queue.push(r)}this.push(e[e.length-1])}read(){const t=this.stream;if((16527&t._duplexState)===p){const e=this.shift();return null!==this.pipeTo&&!1===this.pipeTo.write(e)&&(t._duplexState&=x),0!==(t._duplexState&y)&&t.emit(\"data\",e),e}return!1===this.readAhead&&(t._duplexState|=M,this.updateNextTick()),null}drain(){const t=this.stream;for(;(16527&t._duplexState)===p&&768&t._duplexState;){const e=this.shift();null!==this.pipeTo&&!1===this.pipeTo.write(e)&&(t._duplexState&=x),0!==(t._duplexState&y)&&t.emit(\"data\",e)}}update(){const t=this.stream;t._duplexState|=c;do{for(this.drain();this.buffered<this.highWaterMark&&(214047&t._duplexState)===M;)t._duplexState|=65552,t._read(this.afterRead),this.drain();4224==(12431&t._duplexState)&&(t._duplexState|=v,t.emit(\"readable\")),80&t._duplexState||this.updateNonPrimary()}while(!0===this.continueUpdate());t._duplexState&=536870879}updateNonPrimary(){const t=this.stream;(1167&t._duplexState)===g&&(t._duplexState=536869887&t._duplexState|16384,t.emit(\"end\"),(t._duplexState&Z)===$&&(t._duplexState|=4),null!==this.pipeTo&&this.pipeTo.end()),4!==(t._duplexState&V)?1===(t._duplexState&Y)&&(t._duplexState=(t._duplexState|z)&f,t._open(lt.bind(this))):0===(t._duplexState&G)&&(t._duplexState|=z,t._destroy(ot.bind(this)))}continueUpdate(){return 0!==(this.stream._duplexState&_)&&(this.stream._duplexState&=A,!0)}updateCallback(){(32879&this.stream._duplexState)===d?this.update():this.updateNextTick()}updateNextTickIfOpen(){32769&this.stream._duplexState||(this.stream._duplexState|=_,0===(this.stream._duplexState&c)&&h(this.afterUpdateNextTick))}updateNextTick(){0===(this.stream._duplexState&_)&&(this.stream._duplexState|=_,0===(this.stream._duplexState&c)&&h(this.afterUpdateNextTick))}}class rt{constructor(t){this.data=null,this.afterTransform=ct.bind(t),this.afterFinal=null}}class it{constructor(t,e,r){this.from=t,this.to=e,this.afterPipe=r,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(t,e){e&&(this.error=e),t!==this.to||(this.to=null,null===this.from)?t!==this.from||(this.from=null,null===this.to)?(null!==this.afterPipe&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null):0===(t._duplexState&w)&&this.to.destroy(this.error||new Error(\"Readable stream closed before ending\")):0!==(this.from._duplexState&w)&&this.pipeToFinished||this.from.destroy(this.error||new Error(\"Writable stream closed prematurely\"))}}function nt(){this.stream._duplexState|=512,this.updateCallback()}function st(t){const e=this.stream;t&&e.destroy(t),0===(e._duplexState&V)&&(e._duplexState|=B,e.emit(\"finish\")),(e._duplexState&Z)===$&&(e._duplexState|=4),e._duplexState&=402391039,0===(e._duplexState&C)?this.update():this.updateNextTick()}function ot(t){const e=this.stream;t||this.error===n||(t=this.error),t&&e.emit(\"error\",t),e._duplexState|=8,e.emit(\"close\");const r=e._readableState,i=e._writableState;if(null!==r&&null!==r.pipeline&&r.pipeline.done(e,t),null!==i){for(;null!==i.drains&&i.drains.length>0;)i.drains.shift().resolve(!1);null!==i.pipeline&&i.pipeline.done(e,t)}}function at(t){const e=this.stream;t&&e.destroy(t),e._duplexState&=469499903,null!==this.drains&&function(t){for(let e=0;e<t.length;e++)0===--t[e].writes&&(t.shift().resolve(!0),e--)}(this.drains),(6553615&e._duplexState)===O&&(e._duplexState&=532676607,(e._duplexState&L)===L&&e.emit(\"drain\")),this.updateCallback()}function ht(t){t&&this.stream.destroy(t),this.stream._duplexState&=k,!1===this.readAhead&&0===(this.stream._duplexState&m)&&(this.stream._duplexState&=I),this.updateCallback()}function ut(){0===(this.stream._duplexState&c)&&(this.stream._duplexState&=A,this.update())}function ft(){0===(this.stream._duplexState&C)&&(this.stream._duplexState&=H,this.update())}function lt(t){const e=this.stream;t&&e.destroy(t),4&e._duplexState||(17423&e._duplexState||(e._duplexState|=d),142606351&e._duplexState||(e._duplexState|=P),e.emit(\"open\")),e._duplexState&=W,null!==e._writableState&&e._writableState.updateCallback(),null!==e._readableState&&e._readableState.updateCallback()}function ct(t,e){null!=e&&this.push(e),this._writableState.afterWrite(t)}function dt(t){null!==this._readableState&&(\"data\"===t&&(this._duplexState|=133376,this._readableState.updateNextTick()),\"readable\"===t&&(this._duplexState|=b,this._readableState.updateNextTick())),null!==this._writableState&&\"drain\"===t&&(this._duplexState|=L,this._writableState.updateNextTick())}class pt extends i{constructor(t){super(),this._duplexState=0,this._readableState=null,this._writableState=null,t&&(t.open&&(this._open=t.open),t.destroy&&(this._destroy=t.destroy),t.predestroy&&(this._predestroy=t.predestroy),t.signal&&t.signal.addEventListener(\"abort\",xt.bind(this))),this.on(\"newListener\",dt)}_open(t){t(null)}_destroy(t){t(null)}_predestroy(){}get readable(){return null!==this._readableState||void 0}get writable(){return null!==this._writableState||void 0}get destroyed(){return!!(8&this._duplexState)}get destroying(){return 0!==(this._duplexState&V)}destroy(t){0===(this._duplexState&V)&&(t||(t=n),this._duplexState=535822271&this._duplexState|4,null!==this._readableState&&(this._readableState.highWaterMark=0,this._readableState.error=t),null!==this._writableState&&(this._writableState.highWaterMark=0,this._writableState.error=t),this._duplexState|=2,this._predestroy(),this._duplexState&=l,null!==this._readableState&&this._readableState.updateNextTick(),null!==this._writableState&&this._writableState.updateNextTick())}}class mt extends pt{constructor(t){super(t),this._duplexState|=8519681,this._readableState=new et(this,t),t&&(!1===this._readableState.readAhead&&(this._duplexState&=I),t.read&&(this._read=t.read),t.eagerOpen&&this._readableState.updateNextTick(),t.encoding&&this.setEncoding(t.encoding))}setEncoding(t){const e=new a(t),r=this._readableState.map||_t;return this._readableState.map=function(t){const i=e.push(t);return\"\"===i&&(0!==t.byteLength||e.remaining>0)?null:r(i)},this}_read(t){t(null)}pipe(t,e){return this._readableState.updateNextTick(),this._readableState.pipe(t,e),t}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(t){return this._readableState.updateNextTickIfOpen(),this._readableState.push(t)}unshift(t){return this._readableState.updateNextTickIfOpen(),this._readableState.unshift(t)}resume(){return this._duplexState|=S,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=!1===this._readableState.readAhead?536739583:536870655,this}static _fromAsyncIterator(t,e){let r;const i=new mt({...e,read(e){t.next().then(n).then(e.bind(null,null)).catch(e)},predestroy(){r=t.return()},destroy(t){if(!r)return t(null);r.then(t.bind(null,null)).catch(t)}});return i;function n(t){t.done?i.push(null):i.push(t.value)}}static from(t,e){if(St(r=t)&&r.readable)return t;var r;if(t[Q])return this._fromAsyncIterator(t[Q](),e);Array.isArray(t)||(t=void 0===t?[]:[t]);let i=0;return new mt({...e,read(e){this.push(i===t.length?null:t[i++]),e(null)}})}static isBackpressured(t){return!!(17422&t._duplexState)||t._readableState.buffered>=t._readableState.highWaterMark}static isPaused(t){return 0===(t._duplexState&m)}[Q](){const t=this;let e=null,r=null,i=null;return this.on(\"error\",t=>{e=t}),this.on(\"readable\",function(){null!==r&&s(t.read())}),this.on(\"close\",function(){null!==r&&s(null)}),{[Q](){return this},next:()=>new Promise(function(e,n){r=e,i=n;const o=t.read();null!==o?s(o):8&t._duplexState&&s(null)}),return:()=>o(null),throw:t=>o(t)};function s(s){null!==i&&(e?i(e):null===s&&0===(t._duplexState&w)?i(n):r({value:s,done:null===s}),i=r=null)}function o(e){return t.destroy(e),new Promise((r,i)=>{if(8&t._duplexState)return r({value:void 0,done:!0});t.once(\"close\",function(){e?i(e):r({value:void 0,done:!0})})})}}}class gt extends pt{constructor(t){super(t),this._duplexState|=16385,this._writableState=new tt(this,t),t&&(t.writev&&(this._writev=t.writev),t.write&&(this._write=t.write),t.final&&(this._final=t.final),t.eagerOpen&&this._writableState.updateNextTick())}cork(){this._duplexState|=q}uncork(){this._duplexState&=F,this._writableState.updateNextTick()}_writev(t,e){e(null)}_write(t,e){this._writableState.autoBatch(t,e)}_final(t){t(null)}static isBackpressured(t){return!!(146800654&t._duplexState)}static drained(t){if(t.destroyed)return Promise.resolve(!1);const e=t._writableState;var r;const i=((r=t)._writev!==gt.prototype._writev&&r._writev!==yt.prototype._writev?Math.min(1,e.queue.length):e.queue.length)+(t._duplexState&j?1:0);return 0===i?Promise.resolve(!0):(null===e.drains&&(e.drains=[]),new Promise(t=>{e.drains.push({writes:i,resolve:t})}))}write(t){return this._writableState.updateNextTick(),this._writableState.push(t)}end(t){return this._writableState.updateNextTick(),this._writableState.end(t),this}}class yt extends mt{constructor(t){super(t),this._duplexState=1|this._duplexState&M,this._writableState=new tt(this,t),t&&(t.writev&&(this._writev=t.writev),t.write&&(this._write=t.write),t.final&&(this._final=t.final))}cork(){this._duplexState|=q}uncork(){this._duplexState&=F,this._writableState.updateNextTick()}_writev(t,e){e(null)}_write(t,e){this._writableState.autoBatch(t,e)}_final(t){t(null)}write(t){return this._writableState.updateNextTick(),this._writableState.push(t)}end(t){return this._writableState.updateNextTick(),this._writableState.end(t),this}}class bt extends yt{constructor(t){super(t),this._transformState=new rt(this),t&&(t.transform&&(this._transform=t.transform),t.flush&&(this._flush=t.flush))}_write(t,e){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=t:this._transform(t,this._transformState.afterTransform)}_read(t){if(null!==this._transformState.data){const e=this._transformState.data;this._transformState.data=null,t(null),this._transform(e,this._transformState.afterTransform)}else t(null)}destroy(t){super.destroy(t),null!==this._transformState.data&&(this._transformState.data=null,this._transformState.afterTransform())}_transform(t,e){e(null,t)}_flush(t){t(null)}_final(t){this._transformState.afterFinal=t,this._flush(vt.bind(this))}}function vt(t,e){const r=this._transformState.afterFinal;if(t)return r(t);null!=e&&this.push(e),this.push(null),r(null)}function wt(t,...e){const r=Array.isArray(t)?[...t,...e]:[t,...e],i=r.length&&\"function\"==typeof r[r.length-1]?r.pop():null;if(r.length<2)throw new Error(\"Pipeline requires at least 2 streams\");let n=r[0],o=null,a=null;for(let t=1;t<r.length;t++)o=r[t],St(n)?n.pipe(o,u):(h(n,!0,t>1,u),n.pipe(o)),n=o;if(i){let t=!1;const e=St(o)||!(!o._writableState||!o._writableState.autoDestroy);o.on(\"error\",t=>{null===a&&(a=t)}),o.on(\"finish\",()=>{t=!0,e||i(a)}),e&&o.on(\"close\",()=>i(a||(t?null:s)))}return o;function h(t,e,r,i){t.on(\"error\",i),t.on(\"close\",function(){if(e&&t._readableState&&!t._readableState.ended)return i(s);if(r&&t._writableState&&!t._writableState.ended)return i(s)})}function u(t){if(t&&!a){a=t;for(const e of r)e.destroy(t)}}}function _t(t){return t}function Mt(t){return!!t._readableState||!!t._writableState}function St(t){return\"number\"==typeof t._duplexState&&Mt(t)}function kt(t){return function(t){return\"object\"==typeof t&&null!==t&&\"number\"==typeof t.byteLength}(t)?t.byteLength:1024}function Et(){}function xt(){this.destroy(new Error(\"Stream aborted.\"))}t.exports={pipeline:wt,pipelinePromise:function(...t){return new Promise((e,r)=>wt(...t,t=>{if(t)return r(t);e()}))},isStream:Mt,isStreamx:St,isEnded:function(t){return!!t._readableState&&t._readableState.ended},isFinished:function(t){return!!t._writableState&&t._writableState.ended},isDisturbed:function(t){return!!(1&~t._duplexState)||0!==(t._duplexState&G)},getStreamError:function(t,e={}){const r=t._readableState&&t._readableState.error||t._writableState&&t._writableState.error;return e.all||r!==n?r:null},Stream:pt,Writable:gt,Readable:mt,Duplex:yt,Transform:bt,PassThrough:class extends bt{}}},8190:(t,e,r)=>{t.exports=function(t,e){let r,n,s,o=!0;Array.isArray(t)?(r=[],n=t.length):(s=Object.keys(t),r={},n=s.length);function a(t){function n(){e&&e(t,r),e=null}o?i(n):n()}function h(t,e,i){r[t]=i,(0===--n||e)&&a(e)}n?s?s.forEach(function(e){t[e](function(t,r){h(e,t,r)})}):t.forEach(function(t,e){t(function(t,r){h(e,t,r)})}):a(null);o=!1};const i=r(9596)},8206:(t,e,r)=>{var i=r(7108),n=r(2861).Buffer;function s(t){var e=n.allocUnsafe(4);return e.writeUInt32BE(t,0),e}t.exports=function(t,e){for(var r,o=n.alloc(0),a=0;o.length<e;)r=s(a++),o=n.concat([o,i(\"sha1\").update(t).update(r).digest()]);return o.slice(0,e)}},8276:(t,e,r)=>{var i=r(6698),n=r(4729),s=r(2861).Buffer,o=new Array(16);function a(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function h(t,e){return t<<e|t>>>32-e}function u(t,e,r,i,n,s,o){return h(t+(e&r|~e&i)+n+s|0,o)+e|0}function f(t,e,r,i,n,s,o){return h(t+(e&i|r&~i)+n+s|0,o)+e|0}function l(t,e,r,i,n,s,o){return h(t+(e^r^i)+n+s|0,o)+e|0}function c(t,e,r,i,n,s,o){return h(t+(r^(e|~i))+n+s|0,o)+e|0}i(a,n),a.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,i=this._b,n=this._c,s=this._d;r=u(r,i,n,s,t[0],3614090360,7),s=u(s,r,i,n,t[1],3905402710,12),n=u(n,s,r,i,t[2],606105819,17),i=u(i,n,s,r,t[3],3250441966,22),r=u(r,i,n,s,t[4],4118548399,7),s=u(s,r,i,n,t[5],1200080426,12),n=u(n,s,r,i,t[6],2821735955,17),i=u(i,n,s,r,t[7],4249261313,22),r=u(r,i,n,s,t[8],1770035416,7),s=u(s,r,i,n,t[9],2336552879,12),n=u(n,s,r,i,t[10],4294925233,17),i=u(i,n,s,r,t[11],2304563134,22),r=u(r,i,n,s,t[12],1804603682,7),s=u(s,r,i,n,t[13],4254626195,12),n=u(n,s,r,i,t[14],2792965006,17),r=f(r,i=u(i,n,s,r,t[15],1236535329,22),n,s,t[1],4129170786,5),s=f(s,r,i,n,t[6],3225465664,9),n=f(n,s,r,i,t[11],643717713,14),i=f(i,n,s,r,t[0],3921069994,20),r=f(r,i,n,s,t[5],3593408605,5),s=f(s,r,i,n,t[10],38016083,9),n=f(n,s,r,i,t[15],3634488961,14),i=f(i,n,s,r,t[4],3889429448,20),r=f(r,i,n,s,t[9],568446438,5),s=f(s,r,i,n,t[14],3275163606,9),n=f(n,s,r,i,t[3],4107603335,14),i=f(i,n,s,r,t[8],1163531501,20),r=f(r,i,n,s,t[13],2850285829,5),s=f(s,r,i,n,t[2],4243563512,9),n=f(n,s,r,i,t[7],1735328473,14),r=l(r,i=f(i,n,s,r,t[12],2368359562,20),n,s,t[5],4294588738,4),s=l(s,r,i,n,t[8],2272392833,11),n=l(n,s,r,i,t[11],1839030562,16),i=l(i,n,s,r,t[14],4259657740,23),r=l(r,i,n,s,t[1],2763975236,4),s=l(s,r,i,n,t[4],1272893353,11),n=l(n,s,r,i,t[7],4139469664,16),i=l(i,n,s,r,t[10],3200236656,23),r=l(r,i,n,s,t[13],681279174,4),s=l(s,r,i,n,t[0],3936430074,11),n=l(n,s,r,i,t[3],3572445317,16),i=l(i,n,s,r,t[6],76029189,23),r=l(r,i,n,s,t[9],3654602809,4),s=l(s,r,i,n,t[12],3873151461,11),n=l(n,s,r,i,t[15],530742520,16),r=c(r,i=l(i,n,s,r,t[2],3299628645,23),n,s,t[0],4096336452,6),s=c(s,r,i,n,t[7],1126891415,10),n=c(n,s,r,i,t[14],2878612391,15),i=c(i,n,s,r,t[5],4237533241,21),r=c(r,i,n,s,t[12],1700485571,6),s=c(s,r,i,n,t[3],2399980690,10),n=c(n,s,r,i,t[10],4293915773,15),i=c(i,n,s,r,t[1],2240044497,21),r=c(r,i,n,s,t[8],1873313359,6),s=c(s,r,i,n,t[15],4264355552,10),n=c(n,s,r,i,t[6],2734768916,15),i=c(i,n,s,r,t[13],1309151649,21),r=c(r,i,n,s,t[4],4149444226,6),s=c(s,r,i,n,t[11],3174756917,10),n=c(n,s,r,i,t[2],718787259,15),i=c(i,n,s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+s|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=s.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},8287:(t,e,r)=>{const i=r(7526),n=r(251),s=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;e.Buffer=h,e.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function a(t){if(t>o)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if(\"number\"==typeof t){if(\"string\"==typeof e)throw new TypeError('The \"string\" argument must be of type string. Received type number');return l(t)}return u(t,e,r)}function u(t,e,r){if(\"string\"==typeof t)return function(t,e){\"string\"==typeof e&&\"\"!==e||(e=\"utf8\");if(!h.isEncoding(e))throw new TypeError(\"Unknown encoding: \"+e);const r=0|m(t,e);let i=a(r);const n=i.write(t,e);n!==r&&(i=i.slice(0,n));return i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(G(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(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(G(t,ArrayBuffer)||t&&G(t.buffer,ArrayBuffer))return d(t,e,r);if(\"undefined\"!=typeof SharedArrayBuffer&&(G(t,SharedArrayBuffer)||t&&G(t.buffer,SharedArrayBuffer)))return d(t,e,r);if(\"number\"==typeof t)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,r);const n=function(t){if(h.isBuffer(t)){const e=0|p(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return\"number\"!=typeof t.length||Y(t.length)?a(0):c(t);if(\"Buffer\"===t.type&&Array.isArray(t.data))return c(t.data)}(t);if(n)return n;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive](\"string\"),e,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 f(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be of type number');if(t<0)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"')}function l(t){return f(t),a(t<0?0:0|p(t))}function c(t){const e=t.length<0?0:0|p(t.length),r=a(e);for(let i=0;i<e;i+=1)r[i]=255&t[i];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('\"offset\" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('\"length\" is outside of buffer bounds');let i;return i=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(i,h.prototype),i}function p(t){if(t>=o)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o.toString(16)+\" bytes\");return 0|t}function m(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||G(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);const r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case\"ascii\":case\"latin1\":case\"binary\":return r;case\"utf8\":case\"utf-8\":return V(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*r;case\"hex\":return r>>>1;case\"base64\":return K(t).length;default:if(n)return i?-1:V(t).length;e=(\"\"+e).toLowerCase(),n=!0}}function g(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return\"\";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return\"\";if((r>>>=0)<=(e>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return C(this,e,r);case\"utf8\":case\"utf-8\":return x(this,e,r);case\"ascii\":return I(this,e,r);case\"latin1\":case\"binary\":return T(this,e,r);case\"base64\":return E(this,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return P(this,e,r);default:if(i)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),i=!0}}function y(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function b(t,e,r,i,n){if(0===t.length)return-1;if(\"string\"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if(\"string\"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,i,n);if(\"number\"==typeof e)return e&=255,\"function\"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,i,n);throw new TypeError(\"val must be string, number or Buffer\")}function v(t,e,r,i,n){let s,o=1,a=t.length,h=e.length;if(void 0!==i&&(\"ucs2\"===(i=String(i).toLowerCase())||\"ucs-2\"===i||\"utf16le\"===i||\"utf-16le\"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){let i=-1;for(s=r;s<a;s++)if(u(t,s)===u(e,-1===i?0:s-i)){if(-1===i&&(i=s),s-i+1===h)return i*o}else-1!==i&&(s-=s-i),i=-1}else for(r+h>a&&(r=a-h),s=r;s>=0;s--){let r=!0;for(let i=0;i<h;i++)if(u(t,s+i)!==u(e,i)){r=!1;break}if(r)return s}return-1}function w(t,e,r,i){r=Number(r)||0;const n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;const s=e.length;let o;for(i>s/2&&(i=s/2),o=0;o<i;++o){const i=parseInt(e.substr(2*o,2),16);if(Y(i))return o;t[r+o]=i}return o}function _(t,e,r,i){return Z(V(e,t.length-r),t,r,i)}function M(t,e,r,i){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function S(t,e,r,i){return Z(K(e),t,r,i)}function k(t,e,r,i){return Z(function(t,e){let r,i,n;const s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),i=r>>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function E(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);const i=[];let n=e;for(;n<r;){const e=t[n];let s=null,o=e>239?4:e>223?3:e>191?2:1;if(n+o<=r){let r,i,a,h;switch(o){case 1:e<128&&(s=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(s=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:r=t[n+1],i=t[n+2],a=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&a)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&a,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),n+=o}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r=\"\",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=A));return r}(i)}e.kMaxLength=o,h.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),h.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(h.prototype,\"parent\",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,\"offset\",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(t,e,r){return function(t,e,r){return f(t),t<=0?a(t):void 0!==e?\"string\"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},h.allocUnsafe=function(t){return l(t)},h.allocUnsafeSlow=function(t){return l(t)},h.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==h.prototype},h.compare=function(t,e){if(G(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),G(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(t)||!h.isBuffer(e))throw new TypeError('The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let n=0,s=Math.min(r,i);n<s;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},h.isEncoding=function(t){switch(String(t).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}},h.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return h.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const i=h.allocUnsafe(e);let n=0;for(r=0;r<t.length;++r){let e=t[r];if(G(e,Uint8Array))n+e.length>i.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!h.isBuffer(e))throw new TypeError('\"list\" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},h.byteLength=m,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},h.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},h.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},h.prototype.toString=function(){const t=this.length;return 0===t?\"\":0===arguments.length?x(this,0,t):g.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){let t=\"\";const r=e.INSPECT_MAX_BYTES;return t=this.toString(\"hex\",0,r).replace(/(.{2})/g,\"$1 \").trim(),this.length>r&&(t+=\" ... \"),\"<Buffer \"+t+\">\"},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,r,i,n){if(G(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError(\"out of range index\");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(e>>>=0);const a=Math.min(s,o),u=this.slice(i,n),f=t.slice(e,r);for(let t=0;t<a;++t)if(u[t]!==f[t]){s=u[t],o=f[t];break}return s<o?-1:o<s?1:0},h.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},h.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},h.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},h.prototype.write=function(t,e,r,i){if(void 0===e)i=\"utf8\",r=this.length,e=0;else if(void 0===r&&\"string\"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");e>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i=\"utf8\")):(i=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");i||(i=\"utf8\");let s=!1;for(;;)switch(i){case\"hex\":return w(this,t,e,r);case\"utf8\":case\"utf-8\":return _(this,t,e,r);case\"ascii\":case\"latin1\":case\"binary\":return M(this,t,e,r);case\"base64\":return S(this,t,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return k(this,t,e,r);default:if(s)throw new TypeError(\"Unknown encoding: \"+i);i=(\"\"+i).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function I(t,e,r){let i=\"\";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function T(t,e,r){let i=\"\";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function C(t,e,r){const i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);let n=\"\";for(let i=e;i<r;++i)n+=J[t[i]];return n}function P(t,e,r){const i=t.slice(e,r);let n=\"\";for(let t=0;t<i.length-1;t+=2)n+=String.fromCharCode(i[t]+256*i[t+1]);return n}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+e>r)throw new RangeError(\"Trying to access beyond buffer length\")}function O(t,e,r,i,n,s){if(!h.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('\"value\" argument is out of bounds');if(r+i>t.length)throw new RangeError(\"Index out of range\")}function B(t,e,r,i,n){F(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,r}function L(t,e,r,i,n){F(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o>>=8,t[r+2]=o,o>>=8,t[r+1]=o,o>>=8,t[r]=o,r+8}function N(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError(\"Index out of range\");if(r<0)throw new RangeError(\"Index out of range\")}function j(t,e,r,i,s){return e=+e,r>>>=0,s||N(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function U(t,e,r,i,s){return e=+e,r>>>=0,s||N(t,0,r,8),n.write(t,e,r,i,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,h.prototype),i},h.prototype.readUintLE=h.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return i},h.prototype.readUintBE=h.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=X(function(t){z(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<<BigInt(32))}),h.prototype.readBigUInt64BE=X(function(t){z(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<<BigInt(32))+BigInt(n)}),h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let i=this[t],n=1,s=0;for(;++s<e&&(n*=256);)i+=this[t+s]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let i=e,n=1,s=this[t+--i];for(;i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=X(function(t){z(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),h.prototype.readBigInt64BE=X(function(t){z(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),h.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),n.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),n.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),n.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),n.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e>>>=0,r>>>=0,!i){O(this,t,e,r,Math.pow(2,8*r)-1,0)}let n=1,s=0;for(this[e]=255&t;++s<r&&(n*=256);)this[e+s]=t/n&255;return e+r},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e>>>=0,r>>>=0,!i){O(this,t,e,r,Math.pow(2,8*r)-1,0)}let n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=X(function(t,e=0){return B(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))}),h.prototype.writeBigUInt64BE=X(function(t,e=0){return L(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))}),h.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}let n=0,s=1,o=0;for(this[e]=255&t;++n<r&&(s*=256);)t<0&&0===o&&0!==this[e+n-1]&&(o=1),this[e+n]=(t/s|0)-o&255;return e+r},h.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}let n=r-1,s=1,o=0;for(this[e+n]=255&t;--n>=0&&(s*=256);)t<0&&0===o&&0!==this[e+n+1]&&(o=1),this[e+n]=(t/s|0)-o&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=X(function(t,e=0){return B(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))}),h.prototype.writeBigInt64BE=X(function(t,e=0){return L(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))}),h.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,i){if(!h.isBuffer(t))throw new TypeError(\"argument should be a Buffer\");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<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-e<i-r&&(i=t.length-e+r);const n=i-r;return this===t&&\"function\"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),n},h.prototype.fill=function(t,e,r,i){if(\"string\"==typeof t){if(\"string\"==typeof e?(i=e,e=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&&!h.isEncoding(i))throw new TypeError(\"Unknown encoding: \"+i);if(1===t.length){const e=t.charCodeAt(0);(\"utf8\"===i&&e<128||\"latin1\"===i)&&(t=e)}}else\"number\"==typeof t?t&=255:\"boolean\"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError(\"Out of range index\");if(r<=e)return this;let n;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),\"number\"==typeof t)for(n=e;n<r;++n)this[n]=t;else{const s=h.isBuffer(t)?t:h.from(t,i),o=s.length;if(0===o)throw new TypeError('The value \"'+t+'\" is invalid for argument \"value\"');for(n=0;n<r-e;++n)this[n+e]=s[n%o]}return this};const q={};function D(t,e,r){q[t]=class extends r{constructor(){super(),Object.defineProperty(this,\"message\",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,\"code\",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function H(t){let e=\"\",r=t.length;const i=\"-\"===t[0]?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,i,n,s){if(t>r||t<e){const i=\"bigint\"==typeof e?\"n\":\"\";let n;throw n=s>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new q.ERR_OUT_OF_RANGE(\"value\",n,t)}!function(t,e,r){z(e,\"offset\"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(i,n,s)}function z(t,e){if(\"number\"!=typeof t)throw new q.ERR_INVALID_ARG_TYPE(e,\"number\",t)}function W(t,e,r){if(Math.floor(t)!==t)throw z(t,r),new q.ERR_OUT_OF_RANGE(r||\"offset\",\"an integer\",t);if(e<0)throw new q.ERR_BUFFER_OUT_OF_BOUNDS;throw new q.ERR_OUT_OF_RANGE(r||\"offset\",`>= ${r?1:0} and <= ${e}`,t)}D(\"ERR_BUFFER_OUT_OF_BOUNDS\",function(t){return t?`${t} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"},RangeError),D(\"ERR_INVALID_ARG_TYPE\",function(t,e){return`The \"${t}\" argument must be of type number. Received type ${typeof e}`},TypeError),D(\"ERR_OUT_OF_RANGE\",function(t,e,r){let i=`The value of \"${t}\" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=H(String(r)):\"bigint\"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=H(n)),n+=\"n\"),i+=` It must be ${e}. Received ${n}`,i},RangeError);const $=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const i=t.length;let n=null;const s=[];for(let o=0;o<i;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error(\"Invalid code point\");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function K(t){return i.toByteArray(function(t){if((t=(t=t.split(\"=\")[0]).trim().replace($,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}(t))}function Z(t,e,r,i){let n;for(n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function G(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const J=function(){const t=\"0123456789abcdef\",e=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function X(t){return\"undefined\"==typeof BigInt?Q:t}function Q(){throw new Error(\"BigInt not supported\")}},8310:(t,e,r)=>{t.exports=n;var i=r(7007).EventEmitter;function n(){i.call(this)}r(6698)(n,i),n.Readable=r(5412),n.Writable=r(6708),n.Duplex=r(5382),n.Transform=r(4610),n.PassThrough=r(3600),n.finished=r(6238),n.pipeline=r(7758),n.Stream=n,n.prototype.pipe=function(t,e){var r=this;function n(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on(\"data\",n),t.on(\"drain\",s),t._isStdio||e&&!1===e.end||(r.on(\"end\",a),r.on(\"close\",h));var o=!1;function a(){o||(o=!0,t.end())}function h(){o||(o=!0,\"function\"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===i.listenerCount(this,\"error\"))throw t}function f(){r.removeListener(\"data\",n),t.removeListener(\"drain\",s),r.removeListener(\"end\",a),r.removeListener(\"close\",h),r.removeListener(\"error\",u),t.removeListener(\"error\",u),r.removeListener(\"end\",f),r.removeListener(\"close\",f),t.removeListener(\"close\",f)}return r.on(\"error\",u),t.on(\"error\",u),r.on(\"end\",f),r.on(\"close\",f),t.on(\"close\",f),t.emit(\"pipe\",r),t}},8330:t=>{t.exports={version:\"2.8.4\"}},8393:(t,e,r)=>{var i=r(8287),n=i.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),s(n,o),o.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return n(t,e,r)},o.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var i=n(t);return void 0!==e?\"string\"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n(t)},o.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i.SlowBuffer(t)}},8394:(t,e,r)=>{const i=t.exports;i.encode=r(8746),i.decode=r(4662),i.byteLength=i.encodingLength=r(6814)},8403:(t,e,r)=>{var i=r(1189),n=r(1333)(),s=r(6556),o=r(9612),a=s(\"Array.prototype.push\"),h=s(\"Object.prototype.propertyIsEnumerable\"),u=n?o.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError(\"target must be an object\");var r=o(t);if(1===arguments.length)return r;for(var s=1;s<arguments.length;++s){var f=o(arguments[s]),l=i(f),c=n&&(o.getOwnPropertySymbols||u);if(c)for(var d=c(f),p=0;p<d.length;++p){var m=d[p];h(f,m)&&a(l,m)}for(var g=0;g<l.length;++g){var y=l[g];if(h(f,y)){var b=f[y];r[y]=b}}}return r}},8419:(t,e,r)=>{var i=r(717);const n=r(4529).ok,s=r(8310),o=r(7103),a=r(537),h=a,u=r(8287).Buffer,f=r(2728),l=f.CRLF,c=f.chunkExpression,d=f.debug,p=/^Connection$/i,m=/^Transfer-Encoding$/i,g=/close/i,y=/^Content-Length$/i,b=/^Date$/i,v=/^Expect$/i,w=/^Trailer$/i,_={connection:!0,\"content-length\":!0,\"transfer-encoding\":!0,date:!0};var M;function S(){if(!M){var t=new Date;M=t.toUTCString(),o.enroll(S,1e3-t.getMilliseconds()),o._unrefActive(S)}return M}function k(){s.call(this),this.output=[],this.outputEncodings=[],this.outputCallbacks=[],this.outputSize=0,this.writable=!0,this._last=!1,this.chunkedEncoding=!1,this.shouldKeepAlive=!0,this.useChunkedEncodingByDefault=!0,this.sendDate=!1,this._removedHeader={},this._contentLength=null,this._hasBody=!0,this._trailer=\"\",this.finished=!1,this._headerSent=!1,this.socket=null,this.connection=null,this._header=null,this._headers=null,this._headerNames={},this._onPendingData=null}function E(t,e,r,i){if(!f._checkIsHttpToken(r))throw new TypeError('Header name must be a valid HTTP Token [\"'+r+'\"]');if(!0===f._checkInvalidHeaderChar(i))throw new TypeError(\"The header content contains invalid characters\");e.messageHeader+=r+\": \"+I(i)+l,p.test(r)?(e.sentConnectionHeader=!0,g.test(i)?t._last=!0:t.shouldKeepAlive=!0):m.test(r)?(e.sentTransferEncodingHeader=!0,c.test(i)&&(t.chunkedEncoding=!0)):y.test(r)?e.sentContentLengthHeader=!0:b.test(r)?e.sentDateHeader=!0:v.test(r)?e.sentExpect=!0:w.test(r)&&(e.sentTrailer=!0)}function x(t,e,r){t.emit(\"error\",e),r&&r(e)}function A(t){t.uncork()}function I(t){return/[\\r\\n]/.test(t)?t.replace(/[\\r\\n]+[ \\t]*/g,\"\"):t}S._onTimeout=function(){M=void 0},a.inherits(k,s),e.OutgoingMessage=k,k.prototype.setTimeout=function(t,e){return e&&this.on(\"timeout\",e),this.socket?this.socket.setTimeout(t):this.once(\"socket\",function(e){e.setTimeout(t)}),this},k.prototype.destroy=function(t){this.socket?this.socket.destroy(t):this.once(\"socket\",function(e){e.destroy(t)})},k.prototype._send=function(t,e,r){return this._headerSent||(\"string\"==typeof t&&\"hex\"!==e&&\"base64\"!==e?t=this._header+t:(this.output.unshift(this._header),this.outputEncodings.unshift(\"binary\"),this.outputCallbacks.unshift(null),this.outputSize+=this._header.length,\"function\"==typeof this._onPendingData&&this._onPendingData(this._header.length)),this._headerSent=!0),this._writeRaw(t,e,r)},k.prototype._writeRaw=function(t,e,r){\"function\"==typeof e&&(r=e,e=null);var n=this.connection;if(n&&n._httpMessage===this&&n.writable&&!n.destroyed){if(this.output.length>0)this._flushOutput(n);else if(0===t.length)return\"function\"==typeof r&&i.nextTick(r),!0;return n.write(t,e,r)}return(!n||!n.destroyed)&&this._buffer(t,e,r)},k.prototype._buffer=function(t,e,r){return this.output.push(t),this.outputEncodings.push(e),this.outputCallbacks.push(r),this.outputSize+=t.length,\"function\"==typeof this._onPendingData&&this._onPendingData(t.length),!1},k.prototype._storeHeader=function(t,e){var r={sentConnectionHeader:!1,sentContentLengthHeader:!1,sentTransferEncodingHeader:!1,sentDateHeader:!1,sentExpect:!1,sentTrailer:!1,messageHeader:t};if(e)for(var i,n,s=Object.keys(e),o=Array.isArray(e),a=0,h=s.length;a<h;a++){var u=s[a];if(o?(i=e[u][0],n=e[u][1]):(i=u,n=e[u]),Array.isArray(n))for(var f=0;f<n.length;f++)E(this,r,i,n[f]);else E(this,r,i,n)}!0===this.sendDate&&!1===r.sentDateHeader&&(r.messageHeader+=\"Date: \"+S()+l);var c=this.statusCode;if(204!==c&&304!==c||!0!==this.chunkedEncoding||(d(c+\" response should not use chunked encoding, closing connection.\"),this.chunkedEncoding=!1,this.shouldKeepAlive=!1),this._removedHeader.connection)this._last=!0,this.shouldKeepAlive=!1;else if(!1===r.sentConnectionHeader){this.shouldKeepAlive&&(r.sentContentLengthHeader||this.useChunkedEncodingByDefault||this.agent)?r.messageHeader+=\"Connection: keep-alive\\r\\n\":(this._last=!0,r.messageHeader+=\"Connection: close\\r\\n\")}!1===r.sentContentLengthHeader&&!1===r.sentTransferEncodingHeader&&(this._hasBody?this.useChunkedEncodingByDefault?r.sentTrailer||this._removedHeader[\"content-length\"]||\"number\"!=typeof this._contentLength?this._removedHeader[\"transfer-encoding\"]?d(\"Both Content-Length and Transfer-Encoding are removed\"):(r.messageHeader+=\"Transfer-Encoding: chunked\\r\\n\",this.chunkedEncoding=!0):r.messageHeader+=\"Content-Length: \"+this._contentLength+\"\\r\\n\":this._last=!0:this.chunkedEncoding=!1),this._header=r.messageHeader+l,this._headerSent=!1,r.sentExpect&&this._send(\"\")},k.prototype.setHeader=function(t,e){if(!f._checkIsHttpToken(t))throw new TypeError('Header name must be a valid HTTP Token [\"'+t+'\"]');if(\"string\"!=typeof t)throw new TypeError('\"name\" should be a string in setHeader(name, value)');if(void 0===e)throw new Error('\"value\" required in setHeader(\"'+t+'\", value)');if(this._header)throw new Error(\"Can't set headers after they are sent.\");if(!0===f._checkInvalidHeaderChar(e))throw new TypeError(\"The header content contains invalid characters\");null===this._headers&&(this._headers={});var r=t.toLowerCase();this._headers[r]=e,this._headerNames[r]=t,_[r]&&(this._removedHeader[r]=!1)},k.prototype.getHeader=function(t){if(arguments.length<1)throw new Error('\"name\" argument is required for getHeader(name)');if(this._headers){var e=t.toLowerCase();return this._headers[e]}},k.prototype.removeHeader=function(t){if(arguments.length<1)throw new Error('\"name\" argument is required for removeHeader(name)');if(this._header)throw new Error(\"Can't remove headers after they are sent\");var e=t.toLowerCase();\"date\"===e?this.sendDate=!1:_[e]&&(this._removedHeader[e]=!0),this._headers&&(delete this._headers[e],delete this._headerNames[e])},k.prototype._renderHeaders=function(){if(this._header)throw new Error(\"Can't render headers after they are sent to the client\");var t=this._headers;if(!t)return{};for(var e={},r=Object.keys(t),i=this._headerNames,n=0,s=r.length;n<s;n++){var o=r[n];e[i[o]]=t[o]}return e},Object.defineProperty(k.prototype,\"headersSent\",{configurable:!0,enumerable:!0,get:function(){return!!this._header}}),k.prototype.write=function(t,e,r){if(this.finished){var n=new Error(\"write after end\");return i.nextTick(x,this,n,r),!0}if(this._header||this._implicitHeader(),!this._hasBody)return d(\"This type of response MUST NOT have a body. Ignoring write() calls.\"),!0;if(\"string\"!=typeof t&&!(t instanceof u))throw new TypeError(\"First argument must be a string or Buffer\");return 0===t.length||(this.chunkedEncoding?\"string\"==typeof t&&\"hex\"!==e&&\"base64\"!==e&&\"binary\"!==e?(t=(s=u.byteLength(t,e)).toString(16)+l+t+l,o=this._send(t,e,r)):(s=\"string\"==typeof t?u.byteLength(t,e):t.length,this.connection&&!this.connection.corked&&(this.connection.cork(),i.nextTick(A,this.connection)),this._send(s.toString(16),\"binary\",null),this._send(T,null,null),this._send(t,e,null),o=this._send(T,null,r)):o=this._send(t,e,r),d(\"write ret = \"+o),o);var s,o},k.prototype.addTrailers=function(t){this._trailer=\"\";for(var e,r,i=Object.keys(t),n=Array.isArray(t),s=0,o=i.length;s<o;s++){var a=i[s];if(n?(e=t[a][0],r=t[a][1]):(e=a,r=t[a]),!f._checkIsHttpToken(e))throw new TypeError('Trailer name must be a valid HTTP Token [\"'+e+'\"]');if(!0===f._checkInvalidHeaderChar(r))throw new TypeError(\"The header content contains invalid characters\");this._trailer+=e+\": \"+I(r)+l}};const T=u.from(\"\\r\\n\");k.prototype.end=function(t,e,r){if(\"function\"==typeof t?(r=t,t=null):\"function\"==typeof e&&(r=e,e=null),t&&\"string\"!=typeof t&&!(t instanceof u))throw new TypeError(\"First argument must be a string or Buffer\");if(this.finished)return!1;var i;this._header||(this._contentLength=t?\"string\"==typeof t?u.byteLength(t,e):t.length:0,this._implicitHeader()),t&&!this._hasBody&&(d(\"This type of response MUST NOT have a body. Ignoring data passed to end().\"),t=null),this.connection&&t&&this.connection.cork(),t&&this.write(t,e),\"function\"==typeof r&&this.once(\"finish\",r);const n=()=>{this.emit(\"finish\")};return i=this._hasBody&&this.chunkedEncoding?this._send(\"0\\r\\n\"+this._trailer+\"\\r\\n\",\"binary\",n):this._send(\"\",\"binary\",n),this.connection&&t&&this.connection.uncork(),this.finished=!0,d(\"outgoing message end.\"),0===this.output.length&&this.connection&&this.connection._httpMessage===this&&this._finish(),i},k.prototype._finish=function(){n(this.connection),this.emit(\"prefinish\")},k.prototype._flush=function(){var t,e=this.socket;e&&e.writable&&(t=this._flushOutput(e),this.finished?this._finish():t&&this.emit(\"drain\"))},k.prototype._flushOutput=function(t){var e,r=this.output.length;if(r<=0)return e;var i=this.output,n=this.outputEncodings,s=this.outputCallbacks;t.cork();for(var o=0;o<r;o++)e=t.write(i[o],n[o],s[o]);return t.uncork(),this.output=[],this.outputEncodings=[],this.outputCallbacks=[],\"function\"==typeof this._onPendingData&&this._onPendingData(-this.outputSize),this.outputSize=0,e},k.prototype.flushHeaders=function(){this._header||this._implicitHeader(),this._send(\"\")},k.prototype.flush=h.deprecate(function(){this.flushHeaders()},\"OutgoingMessage.flush is deprecated. Use flushHeaders instead.\")},8444:t=>{t.exports=function(t){return Math.max(16384,1<<Math.log2(t<1024?1:t/1024)+.5)}},8446:t=>{t.exports={\"application/andrew-inset\":[\"ez\"],\"application/applixware\":[\"aw\"],\"application/atom+xml\":[\"atom\"],\"application/atomcat+xml\":[\"atomcat\"],\"application/atomdeleted+xml\":[\"atomdeleted\"],\"application/atomsvc+xml\":[\"atomsvc\"],\"application/atsc-dwd+xml\":[\"dwd\"],\"application/atsc-held+xml\":[\"held\"],\"application/atsc-rsat+xml\":[\"rsat\"],\"application/bdoc\":[\"bdoc\"],\"application/calendar+xml\":[\"xcs\"],\"application/ccxml+xml\":[\"ccxml\"],\"application/cdfx+xml\":[\"cdfx\"],\"application/cdmi-capability\":[\"cdmia\"],\"application/cdmi-container\":[\"cdmic\"],\"application/cdmi-domain\":[\"cdmid\"],\"application/cdmi-object\":[\"cdmio\"],\"application/cdmi-queue\":[\"cdmiq\"],\"application/cu-seeme\":[\"cu\"],\"application/dash+xml\":[\"mpd\"],\"application/davmount+xml\":[\"davmount\"],\"application/docbook+xml\":[\"dbk\"],\"application/dssc+der\":[\"dssc\"],\"application/dssc+xml\":[\"xdssc\"],\"application/ecmascript\":[\"es\",\"ecma\"],\"application/emma+xml\":[\"emma\"],\"application/emotionml+xml\":[\"emotionml\"],\"application/epub+zip\":[\"epub\"],\"application/exi\":[\"exi\"],\"application/express\":[\"exp\"],\"application/fdt+xml\":[\"fdt\"],\"application/font-tdpfr\":[\"pfr\"],\"application/geo+json\":[\"geojson\"],\"application/gml+xml\":[\"gml\"],\"application/gpx+xml\":[\"gpx\"],\"application/gxf\":[\"gxf\"],\"application/gzip\":[\"gz\"],\"application/hjson\":[\"hjson\"],\"application/hyperstudio\":[\"stk\"],\"application/inkml+xml\":[\"ink\",\"inkml\"],\"application/ipfix\":[\"ipfix\"],\"application/its+xml\":[\"its\"],\"application/java-archive\":[\"jar\",\"war\",\"ear\"],\"application/java-serialized-object\":[\"ser\"],\"application/java-vm\":[\"class\"],\"application/javascript\":[\"js\",\"mjs\"],\"application/json\":[\"json\",\"map\"],\"application/json5\":[\"json5\"],\"application/jsonml+json\":[\"jsonml\"],\"application/ld+json\":[\"jsonld\"],\"application/lgr+xml\":[\"lgr\"],\"application/lost+xml\":[\"lostxml\"],\"application/mac-binhex40\":[\"hqx\"],\"application/mac-compactpro\":[\"cpt\"],\"application/mads+xml\":[\"mads\"],\"application/manifest+json\":[\"webmanifest\"],\"application/marc\":[\"mrc\"],\"application/marcxml+xml\":[\"mrcx\"],\"application/mathematica\":[\"ma\",\"nb\",\"mb\"],\"application/mathml+xml\":[\"mathml\"],\"application/mbox\":[\"mbox\"],\"application/mediaservercontrol+xml\":[\"mscml\"],\"application/metalink+xml\":[\"metalink\"],\"application/metalink4+xml\":[\"meta4\"],\"application/mets+xml\":[\"mets\"],\"application/mmt-aei+xml\":[\"maei\"],\"application/mmt-usd+xml\":[\"musd\"],\"application/mods+xml\":[\"mods\"],\"application/mp21\":[\"m21\",\"mp21\"],\"application/mp4\":[\"mp4s\",\"m4p\"],\"application/msword\":[\"doc\",\"dot\"],\"application/mxf\":[\"mxf\"],\"application/n-quads\":[\"nq\"],\"application/n-triples\":[\"nt\"],\"application/node\":[\"cjs\"],\"application/octet-stream\":[\"bin\",\"dms\",\"lrf\",\"mar\",\"so\",\"dist\",\"distz\",\"pkg\",\"bpk\",\"dump\",\"elc\",\"deploy\",\"exe\",\"dll\",\"deb\",\"dmg\",\"iso\",\"img\",\"msi\",\"msp\",\"msm\",\"buffer\"],\"application/oda\":[\"oda\"],\"application/oebps-package+xml\":[\"opf\"],\"application/ogg\":[\"ogx\"],\"application/omdoc+xml\":[\"omdoc\"],\"application/onenote\":[\"onetoc\",\"onetoc2\",\"onetmp\",\"onepkg\"],\"application/oxps\":[\"oxps\"],\"application/p2p-overlay+xml\":[\"relo\"],\"application/patch-ops-error+xml\":[\"xer\"],\"application/pdf\":[\"pdf\"],\"application/pgp-encrypted\":[\"pgp\"],\"application/pgp-signature\":[\"asc\",\"sig\"],\"application/pics-rules\":[\"prf\"],\"application/pkcs10\":[\"p10\"],\"application/pkcs7-mime\":[\"p7m\",\"p7c\"],\"application/pkcs7-signature\":[\"p7s\"],\"application/pkcs8\":[\"p8\"],\"application/pkix-attr-cert\":[\"ac\"],\"application/pkix-cert\":[\"cer\"],\"application/pkix-crl\":[\"crl\"],\"application/pkix-pkipath\":[\"pkipath\"],\"application/pkixcmp\":[\"pki\"],\"application/pls+xml\":[\"pls\"],\"application/postscript\":[\"ai\",\"eps\",\"ps\"],\"application/provenance+xml\":[\"provx\"],\"application/pskc+xml\":[\"pskcxml\"],\"application/raml+yaml\":[\"raml\"],\"application/rdf+xml\":[\"rdf\",\"owl\"],\"application/reginfo+xml\":[\"rif\"],\"application/relax-ng-compact-syntax\":[\"rnc\"],\"application/resource-lists+xml\":[\"rl\"],\"application/resource-lists-diff+xml\":[\"rld\"],\"application/rls-services+xml\":[\"rs\"],\"application/route-apd+xml\":[\"rapd\"],\"application/route-s-tsid+xml\":[\"sls\"],\"application/route-usd+xml\":[\"rusd\"],\"application/rpki-ghostbusters\":[\"gbr\"],\"application/rpki-manifest\":[\"mft\"],\"application/rpki-roa\":[\"roa\"],\"application/rsd+xml\":[\"rsd\"],\"application/rss+xml\":[\"rss\"],\"application/rtf\":[\"rtf\"],\"application/sbml+xml\":[\"sbml\"],\"application/scvp-cv-request\":[\"scq\"],\"application/scvp-cv-response\":[\"scs\"],\"application/scvp-vp-request\":[\"spq\"],\"application/scvp-vp-response\":[\"spp\"],\"application/sdp\":[\"sdp\"],\"application/senml+xml\":[\"senmlx\"],\"application/sensml+xml\":[\"sensmlx\"],\"application/set-payment-initiation\":[\"setpay\"],\"application/set-registration-initiation\":[\"setreg\"],\"application/shf+xml\":[\"shf\"],\"application/sieve\":[\"siv\",\"sieve\"],\"application/smil+xml\":[\"smi\",\"smil\"],\"application/sparql-query\":[\"rq\"],\"application/sparql-results+xml\":[\"srx\"],\"application/srgs\":[\"gram\"],\"application/srgs+xml\":[\"grxml\"],\"application/sru+xml\":[\"sru\"],\"application/ssdl+xml\":[\"ssdl\"],\"application/ssml+xml\":[\"ssml\"],\"application/swid+xml\":[\"swidtag\"],\"application/tei+xml\":[\"tei\",\"teicorpus\"],\"application/thraud+xml\":[\"tfi\"],\"application/timestamped-data\":[\"tsd\"],\"application/toml\":[\"toml\"],\"application/trig\":[\"trig\"],\"application/ttml+xml\":[\"ttml\"],\"application/ubjson\":[\"ubj\"],\"application/urc-ressheet+xml\":[\"rsheet\"],\"application/urc-targetdesc+xml\":[\"td\"],\"application/voicexml+xml\":[\"vxml\"],\"application/wasm\":[\"wasm\"],\"application/widget\":[\"wgt\"],\"application/winhlp\":[\"hlp\"],\"application/wsdl+xml\":[\"wsdl\"],\"application/wspolicy+xml\":[\"wspolicy\"],\"application/xaml+xml\":[\"xaml\"],\"application/xcap-att+xml\":[\"xav\"],\"application/xcap-caps+xml\":[\"xca\"],\"application/xcap-diff+xml\":[\"xdf\"],\"application/xcap-el+xml\":[\"xel\"],\"application/xcap-ns+xml\":[\"xns\"],\"application/xenc+xml\":[\"xenc\"],\"application/xhtml+xml\":[\"xhtml\",\"xht\"],\"application/xliff+xml\":[\"xlf\"],\"application/xml\":[\"xml\",\"xsl\",\"xsd\",\"rng\"],\"application/xml-dtd\":[\"dtd\"],\"application/xop+xml\":[\"xop\"],\"application/xproc+xml\":[\"xpl\"],\"application/xslt+xml\":[\"*xsl\",\"xslt\"],\"application/xspf+xml\":[\"xspf\"],\"application/xv+xml\":[\"mxml\",\"xhvml\",\"xvml\",\"xvm\"],\"application/yang\":[\"yang\"],\"application/yin+xml\":[\"yin\"],\"application/zip\":[\"zip\"],\"audio/3gpp\":[\"*3gpp\"],\"audio/adpcm\":[\"adp\"],\"audio/amr\":[\"amr\"],\"audio/basic\":[\"au\",\"snd\"],\"audio/midi\":[\"mid\",\"midi\",\"kar\",\"rmi\"],\"audio/mobile-xmf\":[\"mxmf\"],\"audio/mp3\":[\"*mp3\"],\"audio/mp4\":[\"m4a\",\"mp4a\"],\"audio/mpeg\":[\"mpga\",\"mp2\",\"mp2a\",\"mp3\",\"m2a\",\"m3a\"],\"audio/ogg\":[\"oga\",\"ogg\",\"spx\",\"opus\"],\"audio/s3m\":[\"s3m\"],\"audio/silk\":[\"sil\"],\"audio/wav\":[\"wav\"],\"audio/wave\":[\"*wav\"],\"audio/webm\":[\"weba\"],\"audio/xm\":[\"xm\"],\"font/collection\":[\"ttc\"],\"font/otf\":[\"otf\"],\"font/ttf\":[\"ttf\"],\"font/woff\":[\"woff\"],\"font/woff2\":[\"woff2\"],\"image/aces\":[\"exr\"],\"image/apng\":[\"apng\"],\"image/avif\":[\"avif\"],\"image/bmp\":[\"bmp\"],\"image/cgm\":[\"cgm\"],\"image/dicom-rle\":[\"drle\"],\"image/emf\":[\"emf\"],\"image/fits\":[\"fits\"],\"image/g3fax\":[\"g3\"],\"image/gif\":[\"gif\"],\"image/heic\":[\"heic\"],\"image/heic-sequence\":[\"heics\"],\"image/heif\":[\"heif\"],\"image/heif-sequence\":[\"heifs\"],\"image/hej2k\":[\"hej2\"],\"image/hsj2\":[\"hsj2\"],\"image/ief\":[\"ief\"],\"image/jls\":[\"jls\"],\"image/jp2\":[\"jp2\",\"jpg2\"],\"image/jpeg\":[\"jpeg\",\"jpg\",\"jpe\"],\"image/jph\":[\"jph\"],\"image/jphc\":[\"jhc\"],\"image/jpm\":[\"jpm\"],\"image/jpx\":[\"jpx\",\"jpf\"],\"image/jxr\":[\"jxr\"],\"image/jxra\":[\"jxra\"],\"image/jxrs\":[\"jxrs\"],\"image/jxs\":[\"jxs\"],\"image/jxsc\":[\"jxsc\"],\"image/jxsi\":[\"jxsi\"],\"image/jxss\":[\"jxss\"],\"image/ktx\":[\"ktx\"],\"image/ktx2\":[\"ktx2\"],\"image/png\":[\"png\"],\"image/sgi\":[\"sgi\"],\"image/svg+xml\":[\"svg\",\"svgz\"],\"image/t38\":[\"t38\"],\"image/tiff\":[\"tif\",\"tiff\"],\"image/tiff-fx\":[\"tfx\"],\"image/webp\":[\"webp\"],\"image/wmf\":[\"wmf\"],\"message/disposition-notification\":[\"disposition-notification\"],\"message/global\":[\"u8msg\"],\"message/global-delivery-status\":[\"u8dsn\"],\"message/global-disposition-notification\":[\"u8mdn\"],\"message/global-headers\":[\"u8hdr\"],\"message/rfc822\":[\"eml\",\"mime\"],\"model/3mf\":[\"3mf\"],\"model/gltf+json\":[\"gltf\"],\"model/gltf-binary\":[\"glb\"],\"model/iges\":[\"igs\",\"iges\"],\"model/mesh\":[\"msh\",\"mesh\",\"silo\"],\"model/mtl\":[\"mtl\"],\"model/obj\":[\"obj\"],\"model/step+xml\":[\"stpx\"],\"model/step+zip\":[\"stpz\"],\"model/step-xml+zip\":[\"stpxz\"],\"model/stl\":[\"stl\"],\"model/vrml\":[\"wrl\",\"vrml\"],\"model/x3d+binary\":[\"*x3db\",\"x3dbz\"],\"model/x3d+fastinfoset\":[\"x3db\"],\"model/x3d+vrml\":[\"*x3dv\",\"x3dvz\"],\"model/x3d+xml\":[\"x3d\",\"x3dz\"],\"model/x3d-vrml\":[\"x3dv\"],\"text/cache-manifest\":[\"appcache\",\"manifest\"],\"text/calendar\":[\"ics\",\"ifb\"],\"text/coffeescript\":[\"coffee\",\"litcoffee\"],\"text/css\":[\"css\"],\"text/csv\":[\"csv\"],\"text/html\":[\"html\",\"htm\",\"shtml\"],\"text/jade\":[\"jade\"],\"text/jsx\":[\"jsx\"],\"text/less\":[\"less\"],\"text/markdown\":[\"markdown\",\"md\"],\"text/mathml\":[\"mml\"],\"text/mdx\":[\"mdx\"],\"text/n3\":[\"n3\"],\"text/plain\":[\"txt\",\"text\",\"conf\",\"def\",\"list\",\"log\",\"in\",\"ini\"],\"text/richtext\":[\"rtx\"],\"text/rtf\":[\"*rtf\"],\"text/sgml\":[\"sgml\",\"sgm\"],\"text/shex\":[\"shex\"],\"text/slim\":[\"slim\",\"slm\"],\"text/spdx\":[\"spdx\"],\"text/stylus\":[\"stylus\",\"styl\"],\"text/tab-separated-values\":[\"tsv\"],\"text/troff\":[\"t\",\"tr\",\"roff\",\"man\",\"me\",\"ms\"],\"text/turtle\":[\"ttl\"],\"text/uri-list\":[\"uri\",\"uris\",\"urls\"],\"text/vcard\":[\"vcard\"],\"text/vtt\":[\"vtt\"],\"text/xml\":[\"*xml\"],\"text/yaml\":[\"yaml\",\"yml\"],\"video/3gpp\":[\"3gp\",\"3gpp\"],\"video/3gpp2\":[\"3g2\"],\"video/h261\":[\"h261\"],\"video/h263\":[\"h263\"],\"video/h264\":[\"h264\"],\"video/iso.segment\":[\"m4s\"],\"video/jpeg\":[\"jpgv\"],\"video/jpm\":[\"*jpm\",\"jpgm\"],\"video/mj2\":[\"mj2\",\"mjp2\"],\"video/mp2t\":[\"ts\"],\"video/mp4\":[\"mp4\",\"mp4v\",\"mpg4\"],\"video/mpeg\":[\"mpeg\",\"mpg\",\"mpe\",\"m1v\",\"m2v\"],\"video/ogg\":[\"ogv\"],\"video/quicktime\":[\"qt\",\"mov\"],\"video/webm\":[\"webm\"]}},8454:(t,e,r)=>{var i=r(7007),n=r(6698);function s(t){if(!(this instanceof s))return new s(t);\"number\"==typeof t&&(t={max:t}),t||(t={}),i.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=t.max||1e3,this.maxAge=t.maxAge||0}t.exports=s,n(s,i.EventEmitter),Object.defineProperty(s.prototype,\"keys\",{get:function(){return Object.keys(this.cache)}}),s.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},s.prototype.remove=function(t){if(\"string\"!=typeof t&&(t=\"\"+t),this.cache.hasOwnProperty(t)){var e=this.cache[t];return delete this.cache[t],this._unlink(t,e.prev,e.next),e.value}},s.prototype._unlink=function(t,e,r){this.length--,0===this.length?this.head=this.tail=null:this.head===t?(this.head=e,this.cache[this.head].next=null):this.tail===t?(this.tail=r,this.cache[this.tail].prev=null):(this.cache[e].next=r,this.cache[r].prev=e)},s.prototype.peek=function(t){if(this.cache.hasOwnProperty(t)){var e=this.cache[t];if(this._checkAge(t,e))return e.value}},s.prototype.set=function(t,e){var r;if(\"string\"!=typeof t&&(t=\"\"+t),this.cache.hasOwnProperty(t)){if((r=this.cache[t]).value=e,this.maxAge&&(r.modified=Date.now()),t===this.head)return e;this._unlink(t,r.prev,r.next)}else r={value:e,modified:0,next:null,prev:null},this.maxAge&&(r.modified=Date.now()),this.cache[t]=r,this.length===this.max&&this.evict();return this.length++,r.next=null,r.prev=this.head,this.head&&(this.cache[this.head].next=t),this.head=t,this.tail||(this.tail=t),e},s.prototype._checkAge=function(t,e){return!(this.maxAge&&Date.now()-e.modified>this.maxAge)||(this.remove(t),this.emit(\"evict\",{key:t,value:e.value}),!1)},s.prototype.get=function(t){if(\"string\"!=typeof t&&(t=\"\"+t),this.cache.hasOwnProperty(t)){var e=this.cache[t];if(this._checkAge(t,e))return this.head!==t&&(t===this.tail?(this.tail=e.next,this.cache[this.tail].prev=null):this.cache[e.prev].next=e.next,this.cache[e.next].prev=e.prev,this.cache[this.head].next=t,e.prev=this.head,e.next=null,this.head=t),e.value}},s.prototype.evict=function(){if(this.tail){var t=this.tail,e=this.remove(this.tail);this.emit(\"evict\",{key:t,value:e})}}},8490:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"};var f=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],d=c[t];r=\"\";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:f[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\"),this.strip();var o,a,h=\"le\"===e,u=new t(s),f=this.clone();if(h){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a<s;a++)u[a]=0}else{for(a=0;a<s-n;a++)u[a]=0;for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[s-a-1]=o}return u},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},g.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),m(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i(\"number\"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a.strip(),i.strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new S(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function w(){b.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function _(){b.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function M(){b.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function S(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function k(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,b),n(_,b),n(M,b),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if(\"k256\"===t)e=new v;else if(\"p224\"===t)e=new w;else if(\"p192\"===t)e=new _;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new M}return y[t]=e,e},S.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},S.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new k(t)},n(k,S),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},8499:(t,e,r)=>{const{TokenBucket:i}=r(9439),n=r(8765);t.exports=class{constructor(t={}){if(\"object\"!=typeof t)throw new Error(\"Options must be an object\");this.throttles=[],this.setEnabled(t.enabled),this.setRate(t.rate,t.chunksize)}getEnabled(){return this._enabled}getRate(){return this.bucket.tokensPerInterval}getChunksize(){return this.chunksize}setEnabled(t=!0){if(\"boolean\"!=typeof t)throw new Error(\"Enabled must be a boolean\");this._enabled=t;for(const e of this.throttles)e.setEnabled(t)}setRate(t,e=null){if(!Number.isInteger(t)||t<0)throw new Error(\"Rate must be an integer bigger than zero\");if(t=parseInt(t),e&&(\"number\"!=typeof e||e<=0))throw new Error(\"Chunksize must be bigger than zero\");if(e=e||Math.max(parseInt(t/10),1),e=parseInt(e),t>0&&e>t)throw new Error(\"Chunk size must be smaller than rate\");this.bucket||(this.bucket=new i(t,t,\"second\",null)),this.bucket.bucketSize=t,this.bucket.tokensPerInterval=t,this.chunksize=e}setChunksize(t){if(!Number.isInteger(t)||t<=0)throw new Error(\"Chunk size must be an integer bigger than zero\");const e=this.getRate();if(t=parseInt(t),e>0&&t>e)throw new Error(\"Chunk size must be smaller than rate\");this.chunksize=t}throttle(t={}){if(\"object\"!=typeof t)throw new Error(\"Options must be an object\");return new n({...t,group:this})}destroy(){for(const t of this.throttles)t.destroy();this.throttles=[]}_addThrottle(t){if(!(t instanceof n))throw new Error(\"Throttle must be an instance of Throttle\");this.throttles.push(t)}_removeThrottle(t){const e=this.throttles.indexOf(t);e>-1&&this.throttles.splice(e,1)}}},8537:(t,e,r)=>{var i=r(2861).Buffer,n=r(5377),s=\"undefined\"!=typeof Uint8Array,o=s&&\"undefined\"!=typeof ArrayBuffer&&ArrayBuffer.isView;t.exports=function(t,e){if(\"string\"==typeof t||i.isBuffer(t)||s&&t instanceof Uint8Array||o&&o(t))return n(t,e);throw new TypeError('The \"data\" argument must be a string, a Buffer, a Uint8Array, or a DataView')}},8545:(t,e,r)=>{var i=r(8490),n=r(7011),s=n.assert;function o(t,e){if(t instanceof o)return t;this._importDER(t,e)||(s(t.r&&t.s,\"Signature without r or s\"),this.r=new i(t.r,16),this.s=new i(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function h(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;if(0===t[e.place])return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return!(n<=127)&&(e.place=o,n)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function f(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=o,o.prototype._importDER=function(t,e){t=n.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;var s=h(t,r);if(!1===s)return!1;if(s+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var o=h(t,r);if(!1===o)return!1;if(128&t[r.place])return!1;var u=t.slice(r.place,o+r.place);if(r.place+=o,2!==t[r.place++])return!1;var f=h(t,r);if(!1===f)return!1;if(t.length!==f+r.place)return!1;if(128&t[r.place])return!1;var l=t.slice(r.place,f+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new i(u),this.s=new i(l),this.recoveryParam=null,!0},o.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,e.length),(i=i.concat(e)).push(2),f(i,r.length);var s=i.concat(r),o=[48];return f(o,s.length),o=o.concat(s),n.encode(o,t)}},8610:(t,e,r)=>{e.sha1=r(3917),e.sha224=r(7714),e.sha256=r(2287),e.sha384=r(1911),e.sha512=r(7766)},8636:(t,e,r)=>{var i=r(920),n=r(7720),s=r(4765),o=Object.prototype.hasOwnProperty,a={brackets:function(t){return t+\"[]\"},comma:\"comma\",indices:function(t,e){return t+\"[\"+e+\"]\"},repeat:function(t){return t}},h=Array.isArray,u=Array.prototype.push,f=function(t,e){u.apply(t,h(e)?e:[e])},l=Date.prototype.toISOString,c=s.default,d={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:\"indices\",charset:\"utf-8\",charsetSentinel:!1,delimiter:\"&\",encode:!0,encodeDotInKeys:!1,encoder:n.encode,encodeValuesOnly:!1,format:c,formatter:s.formatters[c],indices:!1,serializeDate:function(t){return l.call(t)},skipNulls:!1,strictNullHandling:!1},p={},m=function t(e,r,s,o,a,u,l,c,m,g,y,b,v,w,_,M,S,k){for(var E,x=e,A=k,I=0,T=!1;void 0!==(A=A.get(p))&&!T;){var C=A.get(e);if(I+=1,void 0!==C){if(C===I)throw new RangeError(\"Cyclic object value\");T=!0}void 0===A.get(p)&&(I=0)}if(\"function\"==typeof g?x=g(r,x):x instanceof Date?x=v(x):\"comma\"===s&&h(x)&&(x=n.maybeMap(x,function(t){return t instanceof Date?v(t):t})),null===x){if(u)return m&&!M?m(r,d.encoder,S,\"key\",w):r;x=\"\"}if(\"string\"==typeof(E=x)||\"number\"==typeof E||\"boolean\"==typeof E||\"symbol\"==typeof E||\"bigint\"==typeof E||n.isBuffer(x))return m?[_(M?r:m(r,d.encoder,S,\"key\",w))+\"=\"+_(m(x,d.encoder,S,\"value\",w))]:[_(r)+\"=\"+_(String(x))];var P,R=[];if(void 0===x)return R;if(\"comma\"===s&&h(x))M&&m&&(x=n.maybeMap(x,m)),P=[{value:x.length>0?x.join(\",\")||null:void 0}];else if(h(g))P=g;else{var O=Object.keys(x);P=y?O.sort(y):O}var B=c?r.replace(/\\./g,\"%2E\"):r,L=o&&h(x)&&1===x.length?B+\"[]\":B;if(a&&h(x)&&0===x.length)return L+\"[]\";for(var N=0;N<P.length;++N){var j=P[N],U=\"object\"==typeof j&&void 0!==j.value?j.value:x[j];if(!l||null!==U){var q=b&&c?j.replace(/\\./g,\"%2E\"):j,D=h(x)?\"function\"==typeof s?s(L,q):L:L+(b?\".\"+q:\"[\"+q+\"]\");k.set(e,I);var H=i();H.set(p,k),f(R,t(U,D,s,o,a,u,l,c,\"comma\"===s&&M&&h(x)?null:m,g,y,b,v,w,_,M,S,H))}}return R};t.exports=function(t,e){var r,n=t,u=function(t){if(!t)return d;if(void 0!==t.allowEmptyArrays&&\"boolean\"!=typeof t.allowEmptyArrays)throw new TypeError(\"`allowEmptyArrays` option can only be `true` or `false`, when provided\");if(void 0!==t.encodeDotInKeys&&\"boolean\"!=typeof t.encodeDotInKeys)throw new TypeError(\"`encodeDotInKeys` option can only be `true` or `false`, when provided\");if(null!==t.encoder&&void 0!==t.encoder&&\"function\"!=typeof t.encoder)throw new TypeError(\"Encoder has to be a function.\");var e=t.charset||d.charset;if(void 0!==t.charset&&\"utf-8\"!==t.charset&&\"iso-8859-1\"!==t.charset)throw new TypeError(\"The charset option must be either utf-8, iso-8859-1, or undefined\");var r=s.default;if(void 0!==t.format){if(!o.call(s.formatters,t.format))throw new TypeError(\"Unknown format option provided.\");r=t.format}var i,n=s.formatters[r],u=d.filter;if((\"function\"==typeof t.filter||h(t.filter))&&(u=t.filter),i=t.arrayFormat in a?t.arrayFormat:\"indices\"in t?t.indices?\"indices\":\"repeat\":d.arrayFormat,\"commaRoundTrip\"in t&&\"boolean\"!=typeof t.commaRoundTrip)throw new TypeError(\"`commaRoundTrip` must be a boolean, or absent\");var f=void 0===t.allowDots?!0===t.encodeDotInKeys||d.allowDots:!!t.allowDots;return{addQueryPrefix:\"boolean\"==typeof t.addQueryPrefix?t.addQueryPrefix:d.addQueryPrefix,allowDots:f,allowEmptyArrays:\"boolean\"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:d.allowEmptyArrays,arrayFormat:i,charset:e,charsetSentinel:\"boolean\"==typeof t.charsetSentinel?t.charsetSentinel:d.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:void 0===t.delimiter?d.delimiter:t.delimiter,encode:\"boolean\"==typeof t.encode?t.encode:d.encode,encodeDotInKeys:\"boolean\"==typeof t.encodeDotInKeys?t.encodeDotInKeys:d.encodeDotInKeys,encoder:\"function\"==typeof t.encoder?t.encoder:d.encoder,encodeValuesOnly:\"boolean\"==typeof t.encodeValuesOnly?t.encodeValuesOnly:d.encodeValuesOnly,filter:u,format:r,formatter:n,serializeDate:\"function\"==typeof t.serializeDate?t.serializeDate:d.serializeDate,skipNulls:\"boolean\"==typeof t.skipNulls?t.skipNulls:d.skipNulls,sort:\"function\"==typeof t.sort?t.sort:null,strictNullHandling:\"boolean\"==typeof t.strictNullHandling?t.strictNullHandling:d.strictNullHandling}}(e);\"function\"==typeof u.filter?n=(0,u.filter)(\"\",n):h(u.filter)&&(r=u.filter);var l=[];if(\"object\"!=typeof n||null===n)return\"\";var c=a[u.arrayFormat],p=\"comma\"===c&&u.commaRoundTrip;r||(r=Object.keys(n)),u.sort&&r.sort(u.sort);for(var g=i(),y=0;y<r.length;++y){var b=r[y];u.skipNulls&&null===n[b]||f(l,m(n[b],b,c,p,u.allowEmptyArrays,u.strictNullHandling,u.skipNulls,u.encodeDotInKeys,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,g))}var v=l.join(u.delimiter),w=!0===u.addQueryPrefix?\"?\":\"\";return u.charsetSentinel&&(\"iso-8859-1\"===u.charset?w+=\"utf8=%26%2310003%3B&\":w+=\"utf8=%E2%9C%93&\"),v.length>0?w+v:\"\"}},8648:t=>{t.exports=\"undefined\"!=typeof Reflect&&Reflect.getPrototypeOf||null},8650:(t,e,r)=>{var i=r(7952),n=r(480),s=r(7011),o=s.assert,a=s.parseBytes,h=r(6661),u=r(220);function f(t){if(o(\"ed25519\"===t,\"only tested with ed25519 so far\"),!(this instanceof f))return new f(t);t=n[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=i.sha512}t.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),s=this.encodePoint(n),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),h=i.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:h,Rencoded:s})},f.prototype.verify=function(t,e,r){if(t=a(t),(e=this.makeSignature(e)).S().gte(e.eddsa.curve.n)||e.S().isNeg())return!1;var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(s)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e<arguments.length;e++)t.update(arguments[e]);return s.intFromLE(t.digest()).umod(this.curve.n)},f.prototype.keyFromPublic=function(t){return h.fromPublic(this,t)},f.prototype.keyFromSecret=function(t){return h.fromSecret(this,t)},f.prototype.makeSignature=function(t){return t instanceof u?t:new u(this,t)},f.prototype.encodePoint=function(t){var e=t.getY().toArray(\"le\",this.encodingLength);return e[this.encodingLength-1]|=t.getX().isOdd()?128:0,e},f.prototype.decodePoint=function(t){var e=(t=s.parseBytes(t)).length-1,r=t.slice(0,e).concat(-129&t[e]),i=!!(128&t[e]),n=s.intFromLE(r);return this.curve.pointFromY(n,i)},f.prototype.encodeInt=function(t){return t.toArray(\"le\",this.encodingLength)},f.prototype.decodeInt=function(t){return s.intFromLE(t)},f.prototype.isPoint=function(t){return t instanceof this.pointClass}},8673:t=>{function e(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}e.prototype.define=function(t,e){for(let r in t){let i=t[r].map(function(t){return t.toLowerCase()});r=r.toLowerCase();for(let t=0;t<i.length;t++){const n=i[t];if(\"*\"!==n[0]){if(!e&&n in this._types)throw new Error('Attempt to change mapping for \"'+n+'\" extension from \"'+this._types[n]+'\" to \"'+r+'\". Pass `force=true` to allow this, otherwise remove \"'+n+'\" from the list of extensions for \"'+r+'\".');this._types[n]=r}}if(e||!this._extensions[r]){const t=i[0];this._extensions[r]=\"*\"!==t[0]?t:t.substr(1)}}},e.prototype.getType=function(t){let e=(t=String(t)).replace(/^.*[/\\\\]/,\"\").toLowerCase(),r=e.replace(/^.*\\./,\"\").toLowerCase(),i=e.length<t.length;return(r.length<e.length-1||!i)&&this._types[r]||null},e.prototype.getExtension=function(t){return(t=/^\\s*([^;\\s]*)/.test(t)&&RegExp.$1)&&this._extensions[t.toLowerCase()]||null},t.exports=e},8727:t=>{function e(t){return parseInt(t,10)===t}function r(t){function r(e){if(void 0===e){e=new Array(t);for(var r=0;r<t;r++)e[r]=Math.floor(Math.random()*t)}else if(\"string\"==typeof e)e=(e=\"\"+e).split(\"\").map(function(e){return e.charCodeAt(0)%t});else{if(!Array.isArray(e))throw new TypeError(\"invalid seed key specified\");if(!e.every(function(t){return\"number\"==typeof t&&t===(0|t)}))throw new TypeError(\"invalid seed key specified: not array of integers\")}for(var i=e.length,n=function(){for(var e=new Array(t),r=0;r<t;r++)e[r]=r;return e}(),s=0,o=0;o<t;o++){s=(s+n[o]+e[o%i])%t;var a=n[o];n[o]=n[s],n[s]=a}return n}function i(t){this.s=r(t),this.i=0,this.j=0}return i.prototype.randomNative=function(){this.i=(this.i+1)%t,this.j=(this.j+this.s[this.i])%t;var e=this.s[this.i];return this.s[this.i]=this.s[this.j],this.s[this.j]=e,this.s[(this.s[this.i]+this.s[this.j])%t]},i.prototype.randomUInt32=function(){return 256*(256*(256*this.randomByte()+this.randomByte())+this.randomByte())+this.randomByte()},i.prototype.randomFloat=function(){return this.randomUInt32()/4294967296},i.prototype.random=function(){var t,r;if(1===arguments.length)t=0,r=arguments[0];else{if(2!==arguments.length)throw new TypeError(\"random takes one or two integer arguments\");t=arguments[0],r=arguments[1]}if(!e(t)||!e(r))throw new TypeError(\"random takes one or two integer arguments\");return t+this.randomUInt32()%(r-t+1)},i.prototype.currentState=function(){return{i:this.i,j:this.j,s:this.s.slice()}},i.prototype.setState=function(e){var r=e.s,i=e.i,n=e.j;if(!(i===(0|i)&&0<=i&&i<t))throw new Error(\"state.i should be integer [0, \"+(t-1)+\"]\");if(!(n===(0|n)&&0<=n&&n<t))throw new Error(\"state.j should be integer [0, \"+(t-1)+\"]\");if(!Array.isArray(r)||r.length!==t)throw new Error(\"state should be array of length \"+t);for(var s=0;s<t;s++)if(-1===r.indexOf(s))throw new Error(\"state should be permutation of 0..\"+(t-1)+\": \"+s+\" is missing\");this.i=i,this.j=n,this.s=r.slice()},i}var i=r(256);i.prototype.randomByte=i.prototype.randomNative;var n=r(16);n.prototype.randomByte=function(){return 16*this.randomNative()+this.randomNative()};var s=\"a\".charCodeAt(0),o=\"0\".charCodeAt(0);function a(t){return t<10?String.fromCharCode(o+t):String.fromCharCode(s+t-10)}function h(t){return parseInt(t,16)}n.prototype.currentStateString=function(){var t=this.currentState();return a(t.i)+a(t.j)+t.s.map(a).join(\"\")},n.prototype.setStateString=function(t){if(!t.match(/^[0-9a-f]{18}$/))throw new TypeError(\"RC4small stateString should be 18 hex character string\");var e=h(t[0]),r=h(t[1]),i=t.split(\"\").slice(2).map(h);this.setState({i:e,j:r,s:i})},i.RC4small=n,t.exports=i},8746:(t,e,r)=>{var i=r(8287).Buffer;const{getType:n}=r(7972);function s(t,e,r){const n=[];let o=null;return s._encode(n,t),o=i.concat(n),s.bytes=o.length,i.isBuffer(e)?(o.copy(e,r),e):o}s.bytes=-1,s._floatConversionDetected=!1,s._encode=function(t,e){if(null!=e)switch(n(e)){case\"buffer\":s.buffer(t,e);break;case\"object\":s.dict(t,e);break;case\"map\":s.dictMap(t,e);break;case\"array\":s.list(t,e);break;case\"set\":s.listSet(t,e);break;case\"string\":s.string(t,e);break;case\"number\":case\"boolean\":s.number(t,e);break;case\"arraybufferview\":s.buffer(t,i.from(e.buffer,e.byteOffset,e.byteLength));break;case\"arraybuffer\":s.buffer(t,i.from(e))}};const o=i.from(\"e\"),a=i.from(\"d\"),h=i.from(\"l\");s.buffer=function(t,e){t.push(i.from(e.length+\":\"),e)},s.string=function(t,e){t.push(i.from(i.byteLength(e)+\":\"+e))},s.number=function(t,e){const r=2147483648,n=(e/r|0)*r+(e%r|0);t.push(i.from(\"i\"+n+\"e\")),n===e||s._floatConversionDetected||(s._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value \"'+e+'\":','Bencoding only defines support for integers, value was converted to \"'+n+'\"'),console.trace())},s.dict=function(t,e){t.push(a);let r,i=0;const n=Object.keys(e).sort(),h=n.length;for(;i<h;i++)r=n[i],null!=e[r]&&(s.string(t,r),s._encode(t,e[r]));t.push(o)},s.dictMap=function(t,e){t.push(a);const r=Array.from(e.keys()).sort();for(const n of r)null!=e.get(n)&&(i.isBuffer(n)?s._encode(t,n):s.string(t,String(n)),s._encode(t,e.get(n)));t.push(o)},s.list=function(t,e){let r=0;const i=e.length;for(t.push(h);r<i;r++)null!=e[r]&&s._encode(t,e[r]);t.push(o)},s.listSet=function(t,e){t.push(h);for(const r of e)null!=r&&s._encode(t,r);t.push(o)},t.exports=s},8748:(t,e,r)=>{var i=r(717);const n=r(8957),s=r(537),o=r(7007),a=s.debuglog(\"http\");function h(t){if(!(this instanceof h))return new h(t);o.call(this);var e=this;e.defaultPort=80,e.protocol=\"http:\",e.options=s._extend({},t),e.options.path=null,e.requests={},e.sockets={},e.freeSockets={},e.keepAliveMsecs=e.options.keepAliveMsecs||1e3,e.keepAlive=e.options.keepAlive||!1,e.maxSockets=e.options.maxSockets||h.defaultMaxSockets,e.maxFreeSockets=e.options.maxFreeSockets||256,e.on(\"free\",function(t,r){var i=e.getName(r);if(a(\"agent.on(free)\",i),t.writable&&e.requests[i]&&e.requests[i].length)e.requests[i].shift().onSocket(t),0===e.requests[i].length&&delete e.requests[i];else{var n=t._httpMessage;if(n&&n.shouldKeepAlive&&t.writable&&e.keepAlive){var s=e.freeSockets[i],o=s?s.length:0,h=o;e.sockets[i]&&(h+=e.sockets[i].length),h>e.maxSockets||o>=e.maxFreeSockets?t.destroy():(s=s||[],e.freeSockets[i]=s,t.setKeepAlive(!0,e.keepAliveMsecs),t.unref(),t._httpMessage=null,e.removeSocket(t,r),s.push(t))}else t.destroy()}})}s.inherits(h,o),e.Agent=h,h.defaultMaxSockets=1/0,h.prototype.createConnection=n.createConnection,h.prototype.getName=function(t){var e=t.host||\"localhost\";return e+=\":\",t.port&&(e+=t.port),e+=\":\",t.localAddress&&(e+=t.localAddress),4!==t.family&&6!==t.family||(e+=\":\"+t.family),e},h.prototype.addRequest=function(t,e){\"string\"==typeof e&&(e={host:e,port:arguments[2],localAddress:arguments[3]}),e=s._extend({},e),e=s._extend(e,this.options);var r=this.getName(e);this.sockets[r]||(this.sockets[r]=[]);var n=this.freeSockets[r]?this.freeSockets[r].length:0,o=n+this.sockets[r].length;if(n){var h=this.freeSockets[r].shift();a(\"have free socket\"),this.freeSockets[r].length||delete this.freeSockets[r],h.ref(),t.onSocket(h),this.sockets[r].push(h)}else o<this.maxSockets?(a(\"call onSocket\",o,n),this.createSocket(t,e,function(e,r){e?i.nextTick(function(){t.emit(\"error\",e)}):t.onSocket(r)})):(a(\"wait for socket\"),this.requests[r]||(this.requests[r]=[]),this.requests[r].push(t))},h.prototype.createSocket=function(t,e,r){var i=this;if(e=s._extend({},e),!(e=s._extend(e,i.options)).servername){e.servername=e.host;const r=t.getHeader(\"host\");r&&(e.servername=r.replace(/:.*$/,\"\"))}var n=i.getName(e);e._agentKey=n,a(\"createConnection\",n,e),e.encoding=null;var o=!1;const h=i.createConnection(e,u);function u(t,s){if(!o){if(o=!0,t)return r(t);i.sockets[n]||(i.sockets[n]=[]),i.sockets[n].push(s),a(\"sockets\",n,i.sockets[n].length),s.on(\"free\",h),s.on(\"close\",u),s.on(\"agentRemove\",function t(){a(\"CLIENT socket onRemove\"),i.removeSocket(s,e),s.removeListener(\"close\",u),s.removeListener(\"free\",h),s.removeListener(\"agentRemove\",t)}),r(null,s)}function h(){i.emit(\"free\",s,e)}function u(t){a(\"CLIENT socket onClose\"),i.removeSocket(s,e)}}h&&u(null,h)},h.prototype.removeSocket=function(t,e){var r=this.getName(e);a(\"removeSocket\",r,\"writable:\",t.writable);var n=[this.sockets];t.writable||n.push(this.freeSockets);for(var s=0;s<n.length;s++){var o=n[s];if(o[r]){var h=o[r].indexOf(t);-1!==h&&(o[r].splice(h,1),0===o[r].length&&delete o[r])}}if(this.requests[r]&&this.requests[r].length){a(\"removeSocket, have a request, make a socket\");var u=this.requests[r][0];this.createSocket(u,e,function(t,e){t?i.nextTick(function(){u.emit(\"error\",t)}):e.emit(\"free\")})}},h.prototype.destroy=function(){for(var t=[this.freeSockets,this.sockets],e=0;e<t.length;e++)for(var r=t[e],i=Object.keys(r),n=0;n<i.length;n++)for(var s=r[i[n]],o=0;o<s.length;o++)s[o].destroy()},e.globalAgent=new h},8765:(t,e,r)=>{const{EventEmitter:i}=r(7007),{Transform:n}=r(8179),{wait:s}=r(2072);t.exports=class extends n{constructor(t={}){if(super(),\"object\"!=typeof t)throw new Error(\"Options must be an object\");const e=Object.assign({},t);if(e.group&&!(e.group instanceof o))throw new Error(\"Group must be an instanece of ThrottleGroup\");e.group||(e.group=new o(e)),this._setEnabled(e.enabled||e.group.enabled),this._group=e.group,this._emitter=new i,this._destroyed=!1,this._group._addThrottle(this)}getEnabled(){return this._enabled}getGroup(){return this._group}_setEnabled(t=!0){if(\"boolean\"!=typeof t)throw new Error(\"Enabled must be a boolean\");this._enabled=t}setEnabled(t){this._setEnabled(t),this._enabled?this._emitter.emit(\"enabled\"):this._emitter.emit(\"disabled\")}_transform(t,e){this._processChunk(t,e)}async _waitForTokens(t){return new Promise((e,r)=>{let i=!1;const n=this;function s(t){if(n._emitter.removeListener(\"disabled\",s),n._emitter.removeListener(\"destroyed\",s),!i){if(i=!0,t)return r(t);e()}}this._emitter.once(\"disabled\",s),this._emitter.once(\"destroyed\",s),this._group.bucket.removeTokens(t,s)})}_areBothEnabled(){return this._enabled&&this._group.getEnabled()}async _processChunk(t,e){if(!this._areBothEnabled())return e(null,t);let r=0,i=this._group.getChunksize(),n=t.slice(r,r+i);for(;n.length>0;){if(this._areBothEnabled())try{for(;0===this._group.getRate()&&!this._destroyed&&this._areBothEnabled();)if(await s(1e3),this._destroyed)return;if(this._areBothEnabled()&&!this._group.bucket.tryRemoveTokens(n.length)&&(await this._waitForTokens(n.length),this._destroyed))return}catch(t){return e(t)}this.push(n),r+=i,i=this._areBothEnabled()?this._group.getChunksize():t.length-r,n=t.slice(r,r+i)}return e()}destroy(...t){this._group._removeThrottle(this),this._destroyed=!0,this._emitter.emit(\"destroyed\"),super.destroy(...t)}};const o=r(8499)},8835:(t,e,r)=>{var i=r(9655);function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var s=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,a=/^(\\/\\/?(?!\\/)[^?\\s]*)(\\?[^\\s]*)?$/,h=[\"{\",\"}\",\"|\",\"\\\\\",\"^\",\"`\"].concat([\"<\",\">\",'\"',\"`\",\" \",\"\\r\",\"\\n\",\"\\t\"]),u=[\"'\"].concat(h),f=[\"%\",\"/\",\"?\",\";\",\"#\"].concat(u),l=[\"/\",\"?\",\"#\"],c=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,p={javascript:!0,\"javascript:\":!0},m={javascript:!0,\"javascript:\":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,\"http:\":!0,\"https:\":!0,\"ftp:\":!0,\"gopher:\":!0,\"file:\":!0},y=r(5373);function b(t,e,r){if(t&&\"object\"==typeof t&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}n.prototype.parse=function(t,e,r){if(\"string\"!=typeof t)throw new TypeError(\"Parameter 'url' must be a string, not \"+typeof t);var n=t.indexOf(\"?\"),o=-1!==n&&n<t.indexOf(\"#\")?\"?\":\"#\",h=t.split(o);h[0]=h[0].replace(/\\\\/g,\"/\");var b=t=h.join(o);if(b=b.trim(),!r&&1===t.split(\"#\").length){var v=a.exec(b);if(v)return this.path=b,this.href=b,this.pathname=v[1],v[2]?(this.search=v[2],this.query=e?y.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search=\"\",this.query={}),this}var w=s.exec(b);if(w){var _=(w=w[0]).toLowerCase();this.protocol=_,b=b.substr(w.length)}if(r||w||b.match(/^\\/\\/[^@/]+@[^@/]+/)){var M=\"//\"===b.substr(0,2);!M||w&&m[w]||(b=b.substr(2),this.slashes=!0)}if(!m[w]&&(M||w&&!g[w])){for(var S,k,E=-1,x=0;x<l.length;x++){-1!==(A=b.indexOf(l[x]))&&(-1===E||A<E)&&(E=A)}-1!==(k=-1===E?b.lastIndexOf(\"@\"):b.lastIndexOf(\"@\",E))&&(S=b.slice(0,k),b=b.slice(k+1),this.auth=decodeURIComponent(S)),E=-1;for(x=0;x<f.length;x++){var A;-1!==(A=b.indexOf(f[x]))&&(-1===E||A<E)&&(E=A)}-1===E&&(E=b.length),this.host=b.slice(0,E),b=b.slice(E),this.parseHost(),this.hostname=this.hostname||\"\";var I=\"[\"===this.hostname[0]&&\"]\"===this.hostname[this.hostname.length-1];if(!I)for(var T=this.hostname.split(/\\./),C=(x=0,T.length);x<C;x++){var P=T[x];if(P&&!P.match(c)){for(var R=\"\",O=0,B=P.length;O<B;O++)P.charCodeAt(O)>127?R+=\"x\":R+=P[O];if(!R.match(c)){var L=T.slice(0,x),N=T.slice(x+1),j=P.match(d);j&&(L.push(j[1]),N.unshift(j[2])),N.length&&(b=\"/\"+N.join(\".\")+b),this.hostname=L.join(\".\");break}}}this.hostname.length>255?this.hostname=\"\":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=i.toASCII(this.hostname));var U=this.port?\":\"+this.port:\"\",q=this.hostname||\"\";this.host=q+U,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),\"/\"!==b[0]&&(b=\"/\"+b))}if(!p[_])for(x=0,C=u.length;x<C;x++){var D=u[x];if(-1!==b.indexOf(D)){var H=encodeURIComponent(D);H===D&&(H=escape(D)),b=b.split(D).join(H)}}var F=b.indexOf(\"#\");-1!==F&&(this.hash=b.substr(F),b=b.slice(0,F));var z=b.indexOf(\"?\");if(-1!==z?(this.search=b.substr(z),this.query=b.substr(z+1),e&&(this.query=y.parse(this.query)),b=b.slice(0,z)):e&&(this.search=\"\",this.query={}),b&&(this.pathname=b),g[_]&&this.hostname&&!this.pathname&&(this.pathname=\"/\"),this.pathname||this.search){U=this.pathname||\"\";var W=this.search||\"\";this.path=U+W}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||\"\";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,\":\"),t+=\"@\");var e=this.protocol||\"\",r=this.pathname||\"\",i=this.hash||\"\",n=!1,s=\"\";this.host?n=t+this.host:this.hostname&&(n=t+(-1===this.hostname.indexOf(\":\")?this.hostname:\"[\"+this.hostname+\"]\"),this.port&&(n+=\":\"+this.port)),this.query&&\"object\"==typeof this.query&&Object.keys(this.query).length&&(s=y.stringify(this.query,{arrayFormat:\"repeat\",addQueryPrefix:!1}));var o=this.search||s&&\"?\"+s||\"\";return e&&\":\"!==e.substr(-1)&&(e+=\":\"),this.slashes||(!e||g[e])&&!1!==n?(n=\"//\"+(n||\"\"),r&&\"/\"!==r.charAt(0)&&(r=\"/\"+r)):n||(n=\"\"),i&&\"#\"!==i.charAt(0)&&(i=\"#\"+i),o&&\"?\"!==o.charAt(0)&&(o=\"?\"+o),e+n+(r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(o=o.replace(\"#\",\"%23\"))+i},n.prototype.resolve=function(t){return this.resolveObject(b(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(\"string\"==typeof t){var e=new n;e.parse(t,!1,!0),t=e}for(var r=new n,i=Object.keys(this),s=0;s<i.length;s++){var o=i[s];r[o]=this[o]}if(r.hash=t.hash,\"\"===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),h=0;h<a.length;h++){var u=a[h];\"protocol\"!==u&&(r[u]=t[u])}return g[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname=\"/\",r.path=r.pathname),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!g[t.protocol]){for(var f=Object.keys(t),l=0;l<f.length;l++){var c=f[l];r[c]=t[c]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||m[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||\"\").split(\"/\");d.length&&!(t.host=d.shift()););t.host||(t.host=\"\"),t.hostname||(t.hostname=\"\"),\"\"!==d[0]&&d.unshift(\"\"),d.length<2&&d.unshift(\"\"),r.pathname=d.join(\"/\")}if(r.search=t.search,r.query=t.query,r.host=t.host||\"\",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var p=r.pathname||\"\",y=r.search||\"\";r.path=p+y}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var b=r.pathname&&\"/\"===r.pathname.charAt(0),v=t.host||t.pathname&&\"/\"===t.pathname.charAt(0),w=v||b||r.host&&t.pathname,_=w,M=r.pathname&&r.pathname.split(\"/\")||[],S=(d=t.pathname&&t.pathname.split(\"/\")||[],r.protocol&&!g[r.protocol]);if(S&&(r.hostname=\"\",r.port=null,r.host&&(\"\"===M[0]?M[0]=r.host:M.unshift(r.host)),r.host=\"\",t.protocol&&(t.hostname=null,t.port=null,t.host&&(\"\"===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),w=w&&(\"\"===d[0]||\"\"===M[0])),v)r.host=t.host||\"\"===t.host?t.host:r.host,r.hostname=t.hostname||\"\"===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,M=d;else if(d.length)M||(M=[]),M.pop(),M=M.concat(d),r.search=t.search,r.query=t.query;else if(null!=t.search){if(S)r.host=M.shift(),r.hostname=r.host,(I=!!(r.host&&r.host.indexOf(\"@\")>0)&&r.host.split(\"@\"))&&(r.auth=I.shift(),r.hostname=I.shift(),r.host=r.hostname);return r.search=t.search,r.query=t.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:\"\")+(r.search?r.search:\"\")),r.href=r.format(),r}if(!M.length)return r.pathname=null,r.search?r.path=\"/\"+r.search:r.path=null,r.href=r.format(),r;for(var k=M.slice(-1)[0],E=(r.host||t.host||M.length>1)&&(\".\"===k||\"..\"===k)||\"\"===k,x=0,A=M.length;A>=0;A--)\".\"===(k=M[A])?M.splice(A,1):\"..\"===k?(M.splice(A,1),x++):x&&(M.splice(A,1),x--);if(!w&&!_)for(;x--;x)M.unshift(\"..\");!w||\"\"===M[0]||M[0]&&\"/\"===M[0].charAt(0)||M.unshift(\"\"),E&&\"/\"!==M.join(\"/\").substr(-1)&&M.push(\"\");var I,T=\"\"===M[0]||M[0]&&\"/\"===M[0].charAt(0);S&&(r.hostname=T?\"\":M.length?M.shift():\"\",r.host=r.hostname,(I=!!(r.host&&r.host.indexOf(\"@\")>0)&&r.host.split(\"@\"))&&(r.auth=I.shift(),r.hostname=I.shift(),r.host=r.hostname));return(w=w||r.host&&M.length)&&!T&&M.unshift(\"\"),M.length>0?r.pathname=M.join(\"/\"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:\"\")+(r.search?r.search:\"\")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=o.exec(t);e&&(\":\"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},e.parse=b,e.resolve=function(t,e){return b(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?b(t,!1,!0).resolveObject(e):e},e.format=function(t){return\"string\"==typeof t&&(t=b(t)),t instanceof n?t.format():n.prototype.format.call(t)},e.Url=n},8859:(t,e,r)=>{var i=\"function\"==typeof Map&&Map.prototype,n=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Map.prototype,\"size\"):null,s=i&&n&&\"function\"==typeof n.get?n.get:null,o=i&&Map.prototype.forEach,a=\"function\"==typeof Set&&Set.prototype,h=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,\"size\"):null,u=a&&h&&\"function\"==typeof h.get?h.get:null,f=a&&Set.prototype.forEach,l=\"function\"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,c=\"function\"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,d=\"function\"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,m=Object.prototype.toString,g=Function.prototype.toString,y=String.prototype.match,b=String.prototype.slice,v=String.prototype.replace,w=String.prototype.toUpperCase,_=String.prototype.toLowerCase,M=RegExp.prototype.test,S=Array.prototype.concat,k=Array.prototype.join,E=Array.prototype.slice,x=Math.floor,A=\"function\"==typeof BigInt?BigInt.prototype.valueOf:null,I=Object.getOwnPropertySymbols,T=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?Symbol.prototype.toString:null,C=\"function\"==typeof Symbol&&\"object\"==typeof Symbol.iterator,P=\"function\"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===C||\"symbol\")?Symbol.toStringTag:null,R=Object.prototype.propertyIsEnumerable,O=(\"function\"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function B(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||M.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(\"number\"==typeof t){var i=t<0?-x(-t):x(t);if(i!==t){var n=String(i),s=b.call(e,n.length+1);return v.call(n,r,\"$&_\")+\".\"+v.call(v.call(s,/([0-9]{3})/g,\"$&_\"),/_$/,\"\")}}return v.call(e,r,\"$&_\")}var L=r(8093),N=L.custom,j=$(N)?N:null,U={__proto__:null,double:'\"',single:\"'\"},q={__proto__:null,double:/([\"\\\\])/g,single:/(['\\\\])/g};function D(t,e,r){var i=r.quoteStyle||e,n=U[i];return n+t+n}function H(t){return v.call(String(t),/\"/g,\"&quot;\")}function F(t){return!P||!(\"object\"==typeof t&&(P in t||void 0!==t[P]))}function z(t){return\"[object Array]\"===Z(t)&&F(t)}function W(t){return\"[object RegExp]\"===Z(t)&&F(t)}function $(t){if(C)return t&&\"object\"==typeof t&&t instanceof Symbol;if(\"symbol\"==typeof t)return!0;if(!t||\"object\"!=typeof t||!T)return!1;try{return T.call(t),!0}catch(t){}return!1}t.exports=function t(e,r,i,n){var a=r||{};if(K(a,\"quoteStyle\")&&!K(U,a.quoteStyle))throw new TypeError('option \"quoteStyle\" must be \"single\" or \"double\"');if(K(a,\"maxStringLength\")&&(\"number\"==typeof a.maxStringLength?a.maxStringLength<0&&a.maxStringLength!==1/0:null!==a.maxStringLength))throw new TypeError('option \"maxStringLength\", if provided, must be a positive integer, Infinity, or `null`');var h=!K(a,\"customInspect\")||a.customInspect;if(\"boolean\"!=typeof h&&\"symbol\"!==h)throw new TypeError(\"option \\\"customInspect\\\", if provided, must be `true`, `false`, or `'symbol'`\");if(K(a,\"indent\")&&null!==a.indent&&\"\\t\"!==a.indent&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option \"indent\" must be \"\\\\t\", an integer > 0, or `null`');if(K(a,\"numericSeparator\")&&\"boolean\"!=typeof a.numericSeparator)throw new TypeError('option \"numericSeparator\", if provided, must be `true` or `false`');var m=a.numericSeparator;if(void 0===e)return\"undefined\";if(null===e)return\"null\";if(\"boolean\"==typeof e)return e?\"true\":\"false\";if(\"string\"==typeof e)return Y(e,a);if(\"number\"==typeof e){if(0===e)return 1/0/e>0?\"0\":\"-0\";var w=String(e);return m?B(e,w):w}if(\"bigint\"==typeof e){var M=String(e)+\"n\";return m?B(e,M):M}var x=void 0===a.depth?5:a.depth;if(void 0===i&&(i=0),i>=x&&x>0&&\"object\"==typeof e)return z(e)?\"[Array]\":\"[Object]\";var I=function(t,e){var r;if(\"\\t\"===t.indent)r=\"\\t\";else{if(!(\"number\"==typeof t.indent&&t.indent>0))return null;r=k.call(Array(t.indent+1),\" \")}return{base:r,prev:k.call(Array(e+1),r)}}(a,i);if(void 0===n)n=[];else if(G(n,e)>=0)return\"[Circular]\";function N(e,r,s){if(r&&(n=E.call(n)).push(r),s){var o={depth:a.depth};return K(a,\"quoteStyle\")&&(o.quoteStyle=a.quoteStyle),t(e,o,i+1,n)}return t(e,a,i+1,n)}if(\"function\"==typeof e&&!W(e)){var q=function(t){if(t.name)return t.name;var e=y.call(g.call(t),/^function\\s*([\\w$]+)/);if(e)return e[1];return null}(e),V=rt(e,N);return\"[Function\"+(q?\": \"+q:\" (anonymous)\")+\"]\"+(V.length>0?\" { \"+k.call(V,\", \")+\" }\":\"\")}if($(e)){var J=C?v.call(String(e),/^(Symbol\\(.*\\))_[^)]*$/,\"$1\"):T.call(e);return\"object\"!=typeof e||C?J:X(J)}if(function(t){if(!t||\"object\"!=typeof t)return!1;if(\"undefined\"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return\"string\"==typeof t.nodeName&&\"function\"==typeof t.getAttribute}(e)){for(var it=\"<\"+_.call(String(e.nodeName)),nt=e.attributes||[],st=0;st<nt.length;st++)it+=\" \"+nt[st].name+\"=\"+D(H(nt[st].value),\"double\",a);return it+=\">\",e.childNodes&&e.childNodes.length&&(it+=\"...\"),it+=\"</\"+_.call(String(e.nodeName))+\">\"}if(z(e)){if(0===e.length)return\"[]\";var ot=rt(e,N);return I&&!function(t){for(var e=0;e<t.length;e++)if(G(t[e],\"\\n\")>=0)return!1;return!0}(ot)?\"[\"+et(ot,I)+\"]\":\"[ \"+k.call(ot,\", \")+\" ]\"}if(function(t){return\"[object Error]\"===Z(t)&&F(t)}(e)){var at=rt(e,N);return\"cause\"in Error.prototype||!(\"cause\"in e)||R.call(e,\"cause\")?0===at.length?\"[\"+String(e)+\"]\":\"{ [\"+String(e)+\"] \"+k.call(at,\", \")+\" }\":\"{ [\"+String(e)+\"] \"+k.call(S.call(\"[cause]: \"+N(e.cause),at),\", \")+\" }\"}if(\"object\"==typeof e&&h){if(j&&\"function\"==typeof e[j]&&L)return L(e,{depth:x-i});if(\"symbol\"!==h&&\"function\"==typeof e.inspect)return e.inspect()}if(function(t){if(!s||!t||\"object\"!=typeof t)return!1;try{s.call(t);try{u.call(t)}catch(t){return!0}return t instanceof Map}catch(t){}return!1}(e)){var ht=[];return o&&o.call(e,function(t,r){ht.push(N(r,e,!0)+\" => \"+N(t,e))}),tt(\"Map\",s.call(e),ht,I)}if(function(t){if(!u||!t||\"object\"!=typeof t)return!1;try{u.call(t);try{s.call(t)}catch(t){return!0}return t instanceof Set}catch(t){}return!1}(e)){var ut=[];return f&&f.call(e,function(t){ut.push(N(t,e))}),tt(\"Set\",u.call(e),ut,I)}if(function(t){if(!l||!t||\"object\"!=typeof t)return!1;try{l.call(t,l);try{c.call(t,c)}catch(t){return!0}return t instanceof WeakMap}catch(t){}return!1}(e))return Q(\"WeakMap\");if(function(t){if(!c||!t||\"object\"!=typeof t)return!1;try{c.call(t,c);try{l.call(t,l)}catch(t){return!0}return t instanceof WeakSet}catch(t){}return!1}(e))return Q(\"WeakSet\");if(function(t){if(!d||!t||\"object\"!=typeof t)return!1;try{return d.call(t),!0}catch(t){}return!1}(e))return Q(\"WeakRef\");if(function(t){return\"[object Number]\"===Z(t)&&F(t)}(e))return X(N(Number(e)));if(function(t){if(!t||\"object\"!=typeof t||!A)return!1;try{return A.call(t),!0}catch(t){}return!1}(e))return X(N(A.call(e)));if(function(t){return\"[object Boolean]\"===Z(t)&&F(t)}(e))return X(p.call(e));if(function(t){return\"[object String]\"===Z(t)&&F(t)}(e))return X(N(String(e)));if(\"undefined\"!=typeof window&&e===window)return\"{ [object Window] }\";if(\"undefined\"!=typeof globalThis&&e===globalThis||\"undefined\"!=typeof globalThis&&e===globalThis)return\"{ [object globalThis] }\";if(!function(t){return\"[object Date]\"===Z(t)&&F(t)}(e)&&!W(e)){var ft=rt(e,N),lt=O?O(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?\"\":\"null prototype\",dt=!lt&&P&&Object(e)===e&&P in e?b.call(Z(e),8,-1):ct?\"Object\":\"\",pt=(lt||\"function\"!=typeof e.constructor?\"\":e.constructor.name?e.constructor.name+\" \":\"\")+(dt||ct?\"[\"+k.call(S.call([],dt||[],ct||[]),\": \")+\"] \":\"\");return 0===ft.length?pt+\"{}\":I?pt+\"{\"+et(ft,I)+\"}\":pt+\"{ \"+k.call(ft,\", \")+\" }\"}return String(e)};var V=Object.prototype.hasOwnProperty||function(t){return t in this};function K(t,e){return V.call(t,e)}function Z(t){return m.call(t)}function G(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}function Y(t,e){if(t.length>e.maxStringLength){var r=t.length-e.maxStringLength,i=\"... \"+r+\" more character\"+(r>1?\"s\":\"\");return Y(b.call(t,0,e.maxStringLength),e)+i}var n=q[e.quoteStyle||\"single\"];return n.lastIndex=0,D(v.call(v.call(t,n,\"\\\\$1\"),/[\\x00-\\x1f]/g,J),\"single\",e)}function J(t){var e=t.charCodeAt(0),r={8:\"b\",9:\"t\",10:\"n\",12:\"f\",13:\"r\"}[e];return r?\"\\\\\"+r:\"\\\\x\"+(e<16?\"0\":\"\")+w.call(e.toString(16))}function X(t){return\"Object(\"+t+\")\"}function Q(t){return t+\" { ? }\"}function tt(t,e,r,i){return t+\" (\"+e+\") {\"+(i?et(r,i):k.call(r,\", \"))+\"}\"}function et(t,e){if(0===t.length)return\"\";var r=\"\\n\"+e.prev+e.base;return r+k.call(t,\",\"+r)+\"\\n\"+e.prev}function rt(t,e){var r=z(t),i=[];if(r){i.length=t.length;for(var n=0;n<t.length;n++)i[n]=K(t,n)?e(t[n],t):\"\"}var s,o=\"function\"==typeof I?I(t):[];if(C){s={};for(var a=0;a<o.length;a++)s[\"$\"+o[a]]=o[a]}for(var h in t)K(t,h)&&(r&&String(Number(h))===h&&h<t.length||C&&s[\"$\"+h]instanceof Symbol||(M.call(/[^\\w$]/,h)?i.push(e(h,t)+\": \"+e(t[h],t)):i.push(h+\": \"+e(t[h],t))));if(\"function\"==typeof I)for(var u=0;u<o.length;u++)R.call(t,o[u])&&i.push(\"[\"+e(o[u])+\"]: \"+e(t[o[u]],t));return i}},8875:(t,e,r)=>{var i;if(!Object.keys){var n=Object.prototype.hasOwnProperty,s=Object.prototype.toString,o=r(1093),a=Object.prototype.propertyIsEnumerable,h=!a.call({toString:null},\"toString\"),u=a.call(function(){},\"prototype\"),f=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],l=function(t){var e=t.constructor;return e&&e.prototype===t},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(\"undefined\"==typeof window)return!1;for(var t in window)try{if(!c[\"$\"+t]&&n.call(window,t)&&null!==window[t]&&\"object\"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();i=function(t){var e=null!==t&&\"object\"==typeof t,r=\"[object Function]\"===s.call(t),i=o(t),a=e&&\"[object String]\"===s.call(t),c=[];if(!e&&!r&&!i)throw new TypeError(\"Object.keys called on a non-object\");var p=u&&r;if(a&&t.length>0&&!n.call(t,0))for(var m=0;m<t.length;++m)c.push(String(m));if(i&&t.length>0)for(var g=0;g<t.length;++g)c.push(String(g));else for(var y in t)p&&\"prototype\"===y||!n.call(t,y)||c.push(String(y));if(h)for(var b=function(t){if(\"undefined\"==typeof window||!d)return l(t);try{return l(t)}catch(t){return!1}}(t),v=0;v<f.length;++v)b&&\"constructor\"===f[v]||!n.call(t,f[v])||c.push(f[v]);return c}}t.exports=i},8902:(t,e,r)=>{var i=r(8170),n=r(3209),s=r(7108),o=r(8206),a=r(2061),h=r(2509),u=r(9247),f=r(7332),l=r(2861).Buffer;t.exports=function(t,e,r){var c;c=t.padding?t.padding:r?1:4;var d,p=i(t);if(4===c)d=function(t,e){var r=t.modulus.byteLength(),i=e.length,u=s(\"sha1\").update(l.alloc(0)).digest(),f=u.length,c=2*f;if(i>r-c-2)throw new Error(\"message too long\");var d=l.alloc(r-i-c-2),p=r-f-1,m=n(f),g=a(l.concat([u,d,l.alloc(1,1),e],p),o(m,p)),y=a(m,o(g,f));return new h(l.concat([l.alloc(1),y,g],r))}(p,e);else if(1===c)d=function(t,e,r){var i,s=e.length,o=t.modulus.byteLength();if(s>o-11)throw new Error(\"message too long\");i=r?l.alloc(o-s-3,255):function(t){var e,r=l.allocUnsafe(t),i=0,s=n(2*t),o=0;for(;i<t;)o===s.length&&(s=n(2*t),o=0),(e=s[o++])&&(r[i++]=e);return r}(o-s-3);return new h(l.concat([l.from([0,r?1:2]),i,l.alloc(1),e],o))}(p,e,r);else{if(3!==c)throw new Error(\"unknown padding\");if((d=new h(e)).cmp(p.modulus)>=0)throw new Error(\"data too long for modulus\")}return r?f(d,p):u(d,p)}},8903:(t,e,r)=>{var i=r(6698),n=r(8287).Buffer,s=r(2010);function o(t){s.call(this,t),this.enc=\"pem\"}i(o,s),t.exports=o,o.prototype.decode=function(t,e){for(var r=t.toString().split(/[\\r\\n]+/g),i=e.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/,a=-1,h=-1,u=0;u<r.length;u++){var f=r[u].match(o);if(null!==f&&f[2]===i){if(-1!==a){if(\"END\"!==f[1])break;h=u;break}if(\"BEGIN\"!==f[1])break;a=u}}if(-1===a||-1===h)throw new Error(\"PEM section not found for: \"+i);var l=r.slice(a+1,h).join(\"\");l.replace(/[^a-z0-9\\+\\/=]+/gi,\"\");var c=new n(l,\"base64\");return s.prototype.decode.call(this,c,e)}},8948:(t,e,r)=>{var i=r(7426),n=r(3349);function s(t,e,r){if(!(this instanceof s))return new s(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,r))}t.exports=s,s.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),n(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},s.prototype.update=function(t,e){return this.inner.update(t,e),this},s.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},8957:(t,e,r)=>{var i,n,s=r(717),o=r(7007),a=r(6698),h=r(8310),u=r(537).deprecate,f=r(7103),l=r(8287).Buffer,c={},d={};function p(t,e){if(!(this instanceof p))return new p(t,e);if(o.call(this),\"function\"==typeof t)e=t,t={},this.on(\"connection\",e);else{if(null!=t&&\"object\"!=typeof t)throw new TypeError(\"options must be an object\");t=t||{},\"function\"==typeof e&&this.on(\"connection\",e)}this._connections=0,Object.defineProperty(this,\"connections\",{get:u(()=>this._connections,\"Server.connections property is deprecated. Use Server.getConnections method instead.\"),set:u(t=>this._connections=t,\"Server.connections property is deprecated.\"),configurable:!0,enumerable:!1}),this.id=null,this.connecting=!1,this.allowHalfOpen=t.allowHalfOpen||!1,this.pauseOnConnect=!!t.pauseOnConnect,this._address=null,this._host=null,this._port=null,this._backlog=null}function m(t){t.id||t.connecting||t._connections||t.emit(\"close\")}function g(t){if(!(this instanceof g))return new g(t);if(\"number\"==typeof t?t={fd:t}:void 0===t&&(t={}),t.handle)throw new Error(\"handle is not supported in Chrome Apps.\");if(void 0!==t.fd)throw new Error(\"fd is not supported in Chrome Apps.\");t.decodeStrings=!0,t.objectMode=!1,h.Duplex.call(this,t),this.destroyed=!1,this._hadError=!1,this.id=null,this._parent=null,this._host=null,this._port=null,this._pendingData=null,this.ondata=null,this.onend=null,this._init(),this._reset(),this.allowHalfOpen=t.allowHalfOpen||!1,this.on(\"finish\",this.destroy),t.server&&(this.server=this._server=t.server,this.id=t.id,d[this.id]=this,t.pauseOnCreate&&(this._readableState.flowing=!1),this.connecting=!0,this.writable=!0,this._onConnect())}\"object\"==typeof chrome&&\"object\"==typeof chrome.runtime&&\"string\"==typeof chrome.runtime.id&&\"object\"==typeof chrome.sockets&&\"object\"==typeof chrome.sockets.tcpServer&&\"object\"==typeof chrome.sockets.tcp&&(chrome.sockets.tcpServer.onAccept.addListener(function(t){t.socketId in c?c[t.socketId]._onAccept(t.clientSocketId):console.error(\"Unknown server socket id: \"+t.socketId)}),chrome.sockets.tcpServer.onAcceptError.addListener(function(t){t.socketId in c?c[t.socketId]._onAcceptError(t.resultCode):console.error(\"Unknown server socket id: \"+t.socketId)}),chrome.sockets.tcp.onReceive.addListener(function(t){t.socketId in d?d[t.socketId]._onReceive(t.data):console.error(\"Unknown socket id: \"+t.socketId)}),chrome.sockets.tcp.onReceiveError.addListener(function(t){if(t.socketId in d)d[t.socketId]._onReceiveError(t.resultCode);else{if(-100===t.resultCode)return;console.error(\"Unknown socket id: \"+t.socketId)}})),e.createServer=function(t,e){return new p(t,e)},e.connect=e.createConnection=function(){const t=arguments.length;for(var e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i=new g((e=v(e))[0]);return g.prototype.connect.apply(i,e)},a(p,o),e.Server=p,p.prototype._usingSlaves=!1,p.prototype.listen=function(){var t=arguments[arguments.length-1];\"function\"==typeof t&&this.once(\"listening\",t);var e,r=w(arguments[0]),i=w(arguments[1])||w(arguments[2])||void 0;if(null!==arguments[0]&&\"object\"==typeof arguments[0]){var n=arguments[0];if(n._handle||n.handle)throw new Error(\"handle is not supported in Chrome Apps.\");if(\"number\"==typeof n.fd&&n.fd>=0)throw new Error(\"fd is not supported in Chrome Apps.\");if(n.backlog&&(i=n.backlog),!(\"number\"==typeof n.port||\"string\"==typeof n.port||void 0===n.port&&\"port\"in n))throw n.path&&_(n.path)?new Error(\"Pipes are not supported in Chrome Apps.\"):new Error(\"Invalid listen argument: \"+n);e=n.host||null,r=n.port}else{if(_(arguments[0]))throw new Error(\"Pipes are not supported in Chrome Apps.\");e=void 0===arguments[1]||\"function\"==typeof arguments[1]||\"number\"==typeof arguments[1]?null:arguments[1]}this.id&&this.close(),function(t){if(void 0!==t&&!M(t))throw new RangeError('\"port\" argument must be >= 0 and < 65536')}(r),this._port=0|r,this._host=e;var s=!this._host;return s&&(this._host=\"::\"),this._backlog=\"number\"==typeof i?i:void 0,this.connecting=!0,chrome.sockets.tcpServer.create(t=>{if(!this.connecting||this.id)return S(),void chrome.sockets.tcpServer.close(t.socketId);if(chrome.runtime.lastError)this.emit(\"error\",new Error(chrome.runtime.lastError.message));else{var e=this.id=t.socketId;c[this.id]=this;var r=()=>chrome.sockets.tcpServer.listen(this.id,this._host,this._port,this._backlog,t=>{if(this.id===e)return 0!==t&&s?(S(),this._host=\"0.0.0.0\",s=!1,r()):void this._onListen(t);S()});r()}}),this},p.prototype._onListen=function(t){if(this.connecting=!1,0===t){var e=this.id;chrome.sockets.tcpServer.getInfo(this.id,t=>{this.id===e?chrome.runtime.lastError?this._onListen(-2):(this._address={port:t.localPort,family:t.localAddress&&-1!==t.localAddress.indexOf(\":\")?\"IPv6\":\"IPv4\",address:t.localAddress},this.emit(\"listening\")):S()})}else this.emit(\"error\",I(t,\"listen\",this._host,this._port)),this.id&&(chrome.sockets.tcpServer.close(this.id),delete c[this.id],this.id=null)},p.prototype._onAccept=function(t){if(this.maxConnections&&this._connections>=this.maxConnections)return chrome.sockets.tcp.close(t),void console.warn(\"Rejected connection - hit `maxConnections` limit\");this._connections+=1;var e=new g({server:this,id:t,allowHalfOpen:this.allowHalfOpen,pauseOnCreate:this.pauseOnConnect});e.on(\"connect\",()=>this.emit(\"connection\",e))},p.prototype._onAcceptError=function(t){this.emit(\"error\",A(t,\"accept\")),this.close()},p.prototype.close=function(t){return\"function\"==typeof t&&(this.id?this.once(\"close\",t):this.once(\"close\",()=>t(new Error(\"Not running\")))),this.id&&(chrome.sockets.tcpServer.close(this.id),delete c[this.id],this.id=null),this._address=null,this.connecting=!1,this._emitCloseIfDrained(),this},p.prototype._emitCloseIfDrained=function(){this.id||this.connecting||this._connections||s.nextTick(m,this)},Object.defineProperty(p.prototype,\"listening\",{get:function(){return!!this._address},configurable:!0,enumerable:!0}),p.prototype.address=function(){return this._address},p.prototype.unref=p.prototype.ref=function(){return this},p.prototype.getConnections=function(t){s.nextTick(t,null,this._connections)},a(g,h.Duplex),e.Socket=g,g.prototype._init=function(){this.bytesRead=0,this._bytesDispatched=0,this.server=null,this._server=null},g.prototype._reset=function(){this.remoteAddress=this.remotePort=this.localAddress=this.localPort=null,this.remoteFamily=\"IPv4\",this.readable=this.writable=!1,this.connecting=!1},g.prototype.connect=function(){const t=arguments.length;for(var e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i=(e=v(e))[0],n=e[1];if(i.path)throw new Error(\"Pipes are not supported in Chrome Apps.\");if(this.id&&this.destroy(),this.destroyed&&(this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1,this._writableState.length=0,this.destroyed=!1),this.connecting=!0,this.writable=!0,this._host=i.host||\"localhost\",this._port=i.port,void 0!==this._port){if(\"number\"!=typeof this._port&&\"string\"!=typeof this._port)throw new TypeError('\"port\" option should be a number or string: '+this._port);if(!M(this._port))throw new RangeError('\"port\" option should be >= 0 and < 65536: '+this._port)}return this._port|=0,this._init(),this._unrefTimer(),\"function\"==typeof n&&this.once(\"connect\",n),chrome.sockets.tcp.create(t=>{if(!this.connecting||this.id)return S(),void chrome.sockets.tcp.close(t.socketId);chrome.runtime.lastError?this.destroy(new Error(chrome.runtime.lastError.message)):(this.id=t.socketId,d[this.id]=this,chrome.sockets.tcp.setPaused(this.id,!0),chrome.sockets.tcp.connect(this.id,this._host,this._port,e=>{this.id===t.socketId?0===e?(this._unrefTimer(),this._onConnect()):this.destroy(I(e,\"connect\",this._host,this._port)):S()}))}),this},g.prototype._onConnect=function(){var t=this.id;chrome.sockets.tcp.getInfo(this.id,e=>{this.id===t?chrome.runtime.lastError?this.destroy(new Error(chrome.runtime.lastError.message)):(this.remoteAddress=e.peerAddress,this.remoteFamily=e.peerAddress&&-1!==e.peerAddress.indexOf(\":\")?\"IPv6\":\"IPv4\",this.remotePort=e.peerPort,this.localAddress=e.localAddress,this.localPort=e.localPort,this.connecting=!1,this.readable=!0,this.emit(\"connect\"),this.isPaused()||this.read(0)):S()})},Object.defineProperty(g.prototype,\"bufferSize\",{get:function(){if(this.id){var t=this._writableState.length;return this._pendingData&&(t+=this._pendingData.length),t}}}),g.prototype.end=function(t,e){h.Duplex.prototype.end.call(this,t,e),this.writable=!1},g.prototype._write=function(t,e,r){if(r||(r=()=>{}),this.connecting)return this._pendingData=t,void this.once(\"connect\",()=>this._write(t,e,r));if(this._pendingData=null,this.id){var i=t.buffer;t.byteLength!==i.byteLength&&(i=i.slice(t.byteOffset,t.byteOffset+t.byteLength));var n=this.id;chrome.sockets.tcp.send(this.id,i,t=>{this.id===n?t.resultCode<0?this._destroy(I(t.resultCode,\"write\",this.remoteAddress,this.remotePort),r):(this._unrefTimer(),r(null)):S()}),this._bytesDispatched+=t.length}else r(new Error(\"This socket is closed\"))},g.prototype._read=function(t){if(!this.connecting&&this.id){chrome.sockets.tcp.setPaused(this.id,!1);var e=this.id;chrome.sockets.tcp.getInfo(this.id,t=>{this.id===e?!chrome.runtime.lastError&&t.connected||this._onReceiveError(-15):S()})}else this.once(\"connect\",()=>this._read(t))},g.prototype._onReceive=function(t){var e=l.from(t),r=this.bytesRead;this.bytesRead+=e.length,this._unrefTimer(),this.ondata&&(console.error(\"socket.ondata = func is non-standard, use socket.on('data', func)\"),this.ondata(e,r,this.bytesRead)),this.push(e)||chrome.sockets.tcp.setPaused(this.id,!0)},g.prototype._onReceiveError=function(t){-100===t?(this.onend&&(console.error(\"socket.onend = func is non-standard, use socket.on('end', func)\"),this.once(\"end\",this.onend)),this.push(null),this.destroy()):t<0&&this.destroy(A(t,\"read\"))},i=\"bytesWritten\",n=function(){if(this.id)return this._bytesDispatched+this.bufferSize},Object.defineProperty(g.prototype,i,{configurable:!1,enumerable:!0,get:n}),g.prototype.destroy=function(t){this._destroy(t)},g.prototype._destroy=function(t,e){var r=()=>{e&&e(t),t&&!this._writableState.errorEmitted&&(s.nextTick(E,this,t),this._writableState.errorEmitted=!0)};if(this.destroyed)r();else{this._server&&(this._server._connections-=1,this._server._emitCloseIfDrained&&this._server._emitCloseIfDrained()),this._reset();for(var i=this;null!==i;i=i._parent)f.unenroll(i);this.destroyed=!0,this.id&&(delete d[this.id],chrome.sockets.tcp.close(this.id,()=>{this.destroyed&&this.emit(\"close\",!!t)}),this.id=null),r()}},g.prototype.destroySoon=function(){this.writable&&this.end(),this._writableState.finished&&this.destroy()},g.prototype.setTimeout=function(t,e){return 0===t?(f.unenroll(this),e&&this.removeListener(\"timeout\",e)):(f.enroll(this,t),f._unrefActive(this),e&&this.once(\"timeout\",e)),this},g.prototype._onTimeout=function(){this.emit(\"timeout\")},g.prototype._unrefTimer=function(){for(var t=this;null!==t;t=t._parent)f._unrefActive(t)},g.prototype.setNoDelay=function(t,e){return this.id?(t=void 0===t||!!t,chrome.sockets.tcp.setNoDelay(this.id,t,k(e)),this):(this.once(\"connect\",()=>this.setNoDelay(t,e)),this)},g.prototype.setKeepAlive=function(t,e,r){return this.id?(chrome.sockets.tcp.setKeepAlive(this.id,!!t,~~(e/1e3),k(r)),this):(this.once(\"connect\",()=>this.setKeepAlive(t,e,r)),this)},g.prototype.address=function(){return{address:this.localAddress,port:this.localPort,family:this.localAddress&&-1!==this.localAddress.indexOf(\":\")?\"IPv6\":\"IPv4\"}},Object.defineProperty(g.prototype,\"_connecting\",{get:function(){return this.connecting}}),Object.defineProperty(g.prototype,\"readyState\",{get:function(){return this.connecting?\"opening\":this.readable&&this.writable?\"open\":\"closed\"}}),g.prototype.unref=g.prototype.ref=function(){return this};var y=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,b=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;function v(t){var e={};if(null!==t[0]&&\"object\"==typeof t[0])e=t[0];else{if(_(t[0]))throw new Error(\"Pipes are not supported in Chrome Apps.\");e.port=t[0],\"string\"==typeof t[1]&&(e.host=t[1])}var r=t[t.length-1];return\"function\"==typeof r?[e,r]:[e]}function w(t){return(t=Number(t))>=0&&t}function _(t){return\"string\"==typeof t&&!1===w(t)}function M(t){return!(\"number\"!=typeof t&&\"string\"!=typeof t||\"string\"==typeof t&&0===t.trim().length)&&(+t===+t>>>0&&t<=65535)}function S(){chrome.runtime.lastError}function k(t){return()=>{var e;chrome.runtime.lastError&&(console.error(chrome.runtime.lastError.message),e=new Error(chrome.runtime.lastError.message)),t&&t(e)}}function E(t,e){t.emit(\"error\",e)}e.isIPv4=y.test.bind(y),e.isIPv6=b.test.bind(b),e.isIP=function(t){return e.isIPv4(t)?4:e.isIPv6(t)?6:0};var x={\"-10\":\"EACCES\",\"-22\":\"EACCES\",\"-138\":\"EACCES\",\"-147\":\"EADDRINUSE\",\"-108\":\"EADDRNOTAVAIL\",\"-103\":\"ECONNABORTED\",\"-102\":\"ECONNREFUSED\",\"-101\":\"ECONNRESET\",\"-16\":\"EEXIST\",\"-8\":\"EFBIG\",\"-109\":\"EHOSTUNREACH\",\"-4\":\"EINVAL\",\"-23\":\"EISCONN\",\"-6\":\"ENOENT\",\"-13\":\"ENOMEM\",\"-106\":\"ENONET\",\"-18\":\"ENOSPC\",\"-11\":\"ENOSYS\",\"-15\":\"ENOTCONN\",\"-105\":\"ENOTFOUND\",\"-118\":\"ETIMEDOUT\",\"-100\":\"EOF\"};function A(t,e,r){var i=x[t]||\"UNKNOWN\",n=e+\" \"+t+\" \"+r;chrome.runtime.lastError&&(n+=\" \"+chrome.runtime.lastError.message),n+=\" (mapped uv code: \"+i+\")\";var s=new Error(n);return s.code=s.errno=i,s.syscall=e,s}function I(t,e,r,i,n){var s;s=i&&i>0?r+\":\"+i:r,n&&(s+=\" - Local (\"+n+\")\");var o=A(t,e,s);return o.address=r,i&&(o.port=i),o}},8968:t=>{t.exports=Math.floor},9092:(t,e,r)=>{var i=r(1333);t.exports=function(){return i()&&!!Symbol.toStringTag}},9106:t=>{var e=function(t){switch(typeof t){case\"string\":return t;case\"boolean\":return t?\"true\":\"false\";case\"number\":return isFinite(t)?t:\"\";default:return\"\"}};t.exports=function(t,r,i,n){return r=r||\"&\",i=i||\"=\",null===t&&(t=void 0),\"object\"==typeof t?Object.keys(t).map(function(n){var s=encodeURIComponent(e(n))+i;return Array.isArray(t[n])?t[n].map(function(t){return s+encodeURIComponent(e(t))}).join(r):s+encodeURIComponent(e(t[n]))}).filter(Boolean).join(r):n?encodeURIComponent(e(n))+i+encodeURIComponent(e(t)):\"\"}},9133:(t,e,r)=>{var i=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t=\"abcdefghijklmnopqrst\",e=t.split(\"\"),r={},i=0;i<e.length;++i)r[e[i]]=e[i];var n=Object.assign({},r),s=\"\";for(var o in n)s+=o;return t!==s}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,\"xy\")}catch(e){return\"y\"===t[1]}return!1}()?i:Object.assign:i}},9188:(t,e,r)=>{var i=r(7011),n=r(8490),s=r(6698),o=r(6677),a=i.assert;function h(t){o.call(this,\"short\",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(t,e,r,i){o.BasePoint.call(this,t,\"affine\"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new n(e,16),this.y=new n(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(t,e,r,i){o.BasePoint.call(this,t,\"jacobian\"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new n(0)):(this.x=new n(e,16),this.y=new n(r,16),this.z=new n(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(h,o),t.exports=h,h.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new n(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new n(t.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))?r=s[0]:(r=s[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new n(t.a,16),b:new n(t.b,16)}}):this._getEndoBasis(r)}}},h.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:n.mont(t),r=new n(2).toRed(e).redInvm(),i=r.redNeg(),s=new n(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(s).fromRed(),i.redSub(s).fromRed()]},h.prototype._getEndoBasis=function(t){for(var e,r,i,s,o,a,h,u,f,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=t,d=this.n.clone(),p=new n(1),m=new n(0),g=new n(0),y=new n(1),b=0;0!==c.cmpn(0);){var v=d.div(c);u=d.sub(v.mul(c)),f=g.sub(v.mul(p));var w=y.sub(v.mul(m));if(!i&&u.cmp(l)<0)e=h.neg(),r=p,i=u.neg(),s=f;else if(i&&2===++b)break;h=u,d=c,c=u,g=p,p=f,y=m,m=w}o=u.neg(),a=f;var _=i.sqr().add(s.sqr());return o.sqr().add(a.sqr()).cmp(_)>=0&&(o=e,a=r),i.negative&&(i=i.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:s},{a:o,b:a}]},h.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),h=n.mul(r.b),u=s.mul(i.b);return{k1:t.sub(o).sub(a),k2:h.add(u).neg()}},h.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error(\"invalid point\");var s=i.fromRed().isOdd();return(e&&!s||!e&&s)&&(i=i.redNeg()),this.point(t,i)},h.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},h.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),a=t[s],h=a._getBeta();o.k1.negative&&(o.k1.ineg(),a=a.neg(!0)),o.k2.negative&&(o.k2.ineg(),h=h.neg(!0)),i[2*s]=a,i[2*s+1]=h,n[2*s]=o.k1,n[2*s+1]=o.k2}for(var u=this._wnafMulAdd(1,i,n,2*s,r),f=0;f<2*s;f++)i[f]=null,n[f]=null;return u},s(u,o.BasePoint),h.prototype.point=function(t,e,r){return new u(this,t,e,r)},h.prototype.pointFromJSON=function(t,e){return u.fromJSON(this,t,e)},u.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(t,e,r){\"string\"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},u.prototype.inspect=function(){return this.isInfinity()?\"<EC Point Infinity>\":\"<EC Point x: \"+this.x.fromRed().toString(16,2)+\" y: \"+this.y.fromRed().toString(16,2)+\">\"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},u.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(t){return t=new n(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},u.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},u.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},u.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(f,o.BasePoint),h.prototype.jpoint=function(t,e,r){return new f(this,t,e,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),l=i.redMul(u),c=h.redSqr().redIAdd(f).redISub(l).redISub(l),d=h.redMul(l.redISub(c)).redISub(s.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},f.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),f=r.redMul(h),l=a.redSqr().redIAdd(u).redISub(f).redISub(f),c=a.redMul(f.redISub(l)).redISub(n.redMul(u)),d=this.z.redMul(o);return this.curve.jpoint(l,c,d)},f.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,s=this.x,o=this.y,a=this.z,h=a.redSqr().redSqr(),u=o.redAdd(o);for(e=0;e<t;e++){var f=s.redSqr(),l=u.redSqr(),c=l.redSqr(),d=f.redAdd(f).redIAdd(f).redIAdd(i.redMul(h)),p=s.redMul(l),m=d.redSqr().redISub(p.redAdd(p)),g=p.redISub(m),y=d.redMul(g);y=y.redIAdd(y).redISub(c);var b=u.redMul(a);e+1<t&&(h=h.redMul(c)),s=m,a=b,u=y}return this.curve.jpoint(s,u.redMul(n),a)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var a=i.redAdd(i).redIAdd(i),h=a.redSqr().redISub(o).redISub(o),u=s.redIAdd(s);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=a.redMul(o.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),l=this.y.redSqr(),c=l.redSqr(),d=this.x.redAdd(l).redSqr().redISub(f).redISub(c);d=d.redIAdd(d);var p=f.redAdd(f).redIAdd(f),m=p.redSqr(),g=c.redIAdd(c);g=(g=g.redIAdd(g)).redIAdd(g),t=m.redISub(d).redISub(d),e=p.redMul(d.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},f.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var a=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),h=a.redSqr().redISub(o).redISub(o);t=h;var u=s.redIAdd(s);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(o.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),l=this.y.redSqr(),c=this.x.redMul(l),d=this.x.redSub(f).redMul(this.x.redAdd(f));d=d.redAdd(d).redIAdd(d);var p=c.redIAdd(c),m=(p=p.redIAdd(p)).redAdd(p);t=d.redSqr().redISub(m),r=this.y.redAdd(this.z).redSqr().redISub(l).redISub(f);var g=l.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=d.redMul(p.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},f.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),a=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(n)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(o),f=a.redSqr().redISub(u.redAdd(u)),l=u.redISub(f),c=o.redSqr();c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=a.redMul(l).redISub(c),p=r.redAdd(r).redMul(i);return this.curve.jpoint(f,d,p)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),s=n.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(i),a=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(s)).redSqr(),h=i.redIAdd(i);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=n.redIAdd(o).redSqr().redISub(s).redISub(a).redISub(h),f=e.redMul(u);f=(f=f.redIAdd(f)).redIAdd(f);var l=this.x.redMul(a).redISub(f);l=(l=l.redIAdd(l)).redIAdd(l);var c=this.y.redMul(u.redMul(h.redISub(u)).redISub(o.redMul(a)));c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=this.z.redAdd(o).redSqr().redISub(r).redISub(a);return this.curve.jpoint(l,c,d)},f.prototype.mul=function(t,e){return t=new n(t,e),this.curve._wnafMul(this,t)},f.prototype.eq=function(t){if(\"affine\"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},f.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?\"<EC JPoint Infinity>\":\"<EC JPoint x: \"+this.x.toString(16,2)+\" y: \"+this.y.toString(16,2)+\" z: \"+this.z.toString(16,2)+\">\"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},9209:(t,e,r)=>{var i=r(6578),n=globalThis;t.exports=function(){for(var t=[],e=0;e<i.length;e++)\"function\"==typeof n[i[e]]&&(t[t.length]=i[e]);return t}},9220:(t,e,r)=>{var i=r(6698);function n(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function s(t,e){this.path=t,this.rethrow(e)}e.a=n,n.prototype.isError=function(t){return t instanceof s},n.prototype.save=function(){var t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},n.prototype.restore=function(t){var e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},n.prototype.enterKey=function(t){return this._reporterState.path.push(t)},n.prototype.exitKey=function(t){var e=this._reporterState;e.path=e.path.slice(0,t-1)},n.prototype.leaveKey=function(t,e,r){var i=this._reporterState;this.exitKey(t),null!==i.obj&&(i.obj[e]=r)},n.prototype.path=function(){return this._reporterState.path.join(\"/\")},n.prototype.enterObject=function(){var t=this._reporterState,e=t.obj;return t.obj={},e},n.prototype.leaveObject=function(t){var e=this._reporterState,r=e.obj;return e.obj=t,r},n.prototype.error=function(t){var e,r=this._reporterState,i=t instanceof s;if(e=i?t:new s(r.path.map(function(t){return\"[\"+JSON.stringify(t)+\"]\"}).join(\"\"),t.message||t,t.stack),!r.options.partial)throw e;return i||r.errors.push(e),e},n.prototype.wrapResult=function(t){var e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},i(s,Error),s.prototype.rethrow=function(t){if(this.message=t+\" at: \"+(this.path||\"(shallow)\"),Error.captureStackTrace&&Error.captureStackTrace(this,s),!this.stack)try{throw new Error(this.message)}catch(t){this.stack=t.stack}return this}},9247:(t,e,r)=>{var i=r(2509),n=r(2861).Buffer;t.exports=function(t,e){return n.from(t.toRed(i.mont(e.modulus)).redPow(new i(e.publicExponent)).fromRed().toArray())}},9290:t=>{t.exports=RangeError},9353:t=>{var e=Object.prototype.toString,r=Math.max,i=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r};t.exports=function(t){var n=this;if(\"function\"!=typeof n||\"[object Function]\"!==e.apply(n))throw new TypeError(\"Function.prototype.bind called on incompatible \"+n);for(var s,o=function(t,e){for(var r=[],i=e||0,n=0;i<t.length;i+=1,n+=1)r[n]=t[i];return r}(arguments,1),a=r(0,n.length-o.length),h=[],u=0;u<a;u++)h[u]=\"$\"+u;if(s=Function(\"binder\",\"return function (\"+function(t,e){for(var r=\"\",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r}(h,\",\")+\"){ return binder.apply(this,arguments); }\")(function(){if(this instanceof s){var e=n.apply(this,i(o,arguments));return Object(e)===e?e:this}return n.apply(t,i(o,arguments))}),n.prototype){var f=function(){};f.prototype=n.prototype,s.prototype=new f,f.prototype=null}return s}},9383:t=>{t.exports=Error},9404:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||\"Assertion failed\")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(\"le\"!==e&&\"be\"!==e||(r=e,e=10),this._init(t||0,e||10,r||\"be\"))}var o;\"object\"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=\"undefined\"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8287).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,\"Invalid character in \"+t)}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,n){for(var s=0,o=0,a=Math.min(t.length,r),h=e;h<a;h++){var u=t.charCodeAt(h)-48;s*=n,o=u>=49?u-49+10:u>=17?u-17+10:u,i(u>=0&&o<n,\"Invalid character\"),s+=o}return s}function f(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(s.isBN=function(t){return t instanceof s||null!==t&&\"object\"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if(\"number\"==typeof t)return this._initNumber(t,e,r);if(\"object\"==typeof t)return this._initArray(t,e,r);\"hex\"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;\"-\"===(t=t.toString().replace(/\\s+/g,\"\"))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),\"le\"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),\"le\"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i(\"number\"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if(\"be\"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if(\"le\"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if(\"be\"===r)for(i=t.length-1;i>=e;i-=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=h(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,f=r;f<a;f+=i)h=u(t,f,f+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var l=1;for(h=u(t,f,t.length,e),f=0;f<o;f++)l*=e;this.imuln(l),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype._move=function(t){f(t,this)},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},\"undefined\"!=typeof Symbol&&\"function\"==typeof Symbol.for)try{s.prototype[Symbol.for(\"nodejs.util.inspect.custom\")]=l}catch(t){s.prototype.inspect=l}else s.prototype.inspect=l;function l(){return(this.red?\"<BN-R: \":\"<BN: \")+this.toString(16)+\">\"}var c=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||\"hex\"===t){r=\"\";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?c[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],f=p[t];r=\"\";var l=this.clone();for(l.negative=0;!l.isZero();){var m=l.modrn(f).toString(t);r=(l=l.idivn(f)).isZero()?m+r:c[u-m.length]+m+r}for(this.isZero()&&(r=\"0\"+r);r.length%e!==0;)r=\"0\"+r;return 0!==this.negative&&(r=\"-\"+r),r}i(!1,\"Base should be between 2 and 36\")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,\"Number can only safely store up to 53 bits\"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=h>>>26,l=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|f}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}s.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,\"byte array longer than desired length\"),i(s>0,\"Requested array length <= 0\");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this[\"_toArrayLike\"+(\"le\"===e?\"LE\":\"BE\")](o,n),o},s.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|i;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===s?(r<t.length&&(t[r++]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},s.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|i;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},s.prototype.ior=function(t){return i(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},s.prototype.iand=function(t){return i(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},s.prototype.ixor=function(t){return i(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i(\"number\"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i(\"number\"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},s.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var g=function(t,e,r){var i,n,s,o=t.words,a=e.words,h=r.words,u=0,f=0|o[0],l=8191&f,c=f>>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,b=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,M=0|o[4],S=8191&M,k=M>>>13,E=0|o[5],x=8191&E,A=E>>>13,I=0|o[6],T=8191&I,C=I>>>13,P=0|o[7],R=8191&P,O=P>>>13,B=0|o[8],L=8191&B,N=B>>>13,j=0|o[9],U=8191&j,q=j>>>13,D=0|a[0],H=8191&D,F=D>>>13,z=0|a[1],W=8191&z,$=z>>>13,V=0|a[2],K=8191&V,Z=V>>>13,G=0|a[3],Y=8191&G,J=G>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,ct=ft>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(l,H))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(c,H)|0))<<13)|0;u=((s=Math.imul(c,F))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,H),n=(n=Math.imul(p,F))+Math.imul(m,H)|0,s=Math.imul(m,F);var yt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,H),n=(n=Math.imul(y,F))+Math.imul(b,H)|0,s=Math.imul(b,F),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0;var bt=(u+(i=i+Math.imul(l,K)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,K)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(w,H),n=(n=Math.imul(w,F))+Math.imul(_,H)|0,s=Math.imul(_,F),i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,$)|0,i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,Z)|0;var vt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,J)|0)+Math.imul(c,Y)|0))<<13)|0;u=((s=s+Math.imul(c,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,H),n=(n=Math.imul(S,F))+Math.imul(k,H)|0,s=Math.imul(k,F),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,K)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,J)|0;var wt=(u+(i=i+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,H),n=(n=Math.imul(x,F))+Math.imul(A,H)|0,s=Math.imul(A,F),i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,K)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,J)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((s=s+Math.imul(c,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(T,H),n=(n=Math.imul(T,F))+Math.imul(C,H)|0,s=Math.imul(C,F),i=i+Math.imul(x,W)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(A,W)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,K)|0,s=s+Math.imul(k,Z)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,J)|0,i=i+Math.imul(y,Q)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Mt=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(R,H),n=(n=Math.imul(R,F))+Math.imul(O,H)|0,s=Math.imul(O,F),i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(A,K)|0,s=s+Math.imul(A,Z)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,J)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,F))+Math.imul(N,H)|0,s=Math.imul(N,F),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,$)|0,i=i+Math.imul(T,K)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,Z)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,J)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,J)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,F))+Math.imul(q,H)|0,s=Math.imul(q,F),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(R,K)|0,n=(n=n+Math.imul(R,Z)|0)+Math.imul(O,K)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,J)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var Et=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,$))+Math.imul(q,W)|0,s=Math.imul(q,$),i=i+Math.imul(L,K)|0,n=(n=n+Math.imul(L,Z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,Z)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,J)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,ct)|0;var xt=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,Z))+Math.imul(q,K)|0,s=Math.imul(q,Z),i=i+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,J)|0,i=i+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(x,st)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,ht)|0,s=s+Math.imul(k,ut)|0,i=i+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ct)|0;var At=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,J))+Math.imul(q,Y)|0,s=Math.imul(q,J),i=i+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,i=i+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var It=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(q,Q)|0,s=Math.imul(q,tt),i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(x,lt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,ct)|0;var Tt=(u+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(q,rt)|0,s=Math.imul(q,it),i=i+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ct)|0;var Ct=(u+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(q,st)|0,s=Math.imul(q,ot),i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Pt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,ht),n=(n=Math.imul(U,ut))+Math.imul(q,ht)|0,s=Math.imul(q,ut),i=i+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,ct)|0)+Math.imul(N,lt)|0,s=s+Math.imul(N,ct)|0;var Rt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,lt),n=(n=Math.imul(U,ct))+Math.imul(q,lt)|0,s=Math.imul(q,ct);var Ot=(u+(i=i+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Bt=(u+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,mt))+Math.imul(q,pt)|0))<<13)|0;return u=((s=Math.imul(q,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=bt,h[3]=vt,h[4]=wt,h[5]=_t,h[6]=Mt,h[7]=St,h[8]=kt,h[9]=Et,h[10]=xt,h[11]=At,h[12]=It,h[13]=Tt,h[14]=Ct,h[15]=Pt,h[16]=Rt,h[17]=Ot,h[18]=Bt,0!==u&&(h[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,h=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var f=s-u,l=(0|t.words[f])*(0|e.words[u]),c=67108863&l;a=67108863&(c=c+a|0),n+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function b(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(g=m),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):r<63?m(this,t,e):r<1024?y(this,t,e):b(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},v.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},v.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var l=h,c=u,d=0;d<o;d++){var p=r[f+d],m=i[f+d],g=r[f+d+o],y=i[f+d+o],b=l*g-c*y;y=l*y+c*g,g=b,r[f+d]=p+g,i[f+d]=m+y,r[f+d+o]=p-g,i[f+d+o]=m-y,d!==a&&(b=h*l-u*c,c=h*c+u*l,l=b)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},v.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},v.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),l=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,u,i),this.transform(o,s,a,h,i,n),this.transform(u,s,f,l,i,n);for(var d=0;d<i;d++){var p=a[d]*f[d]-h[d]*l[d];h[d]=a[d]*l[d]+h[d]*f[d],a[d]=p}return this.conjugate(a,h,i),this.transform(a,h,c,s,i,n),this.conjugate(c,s,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),b(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i(\"number\"==typeof t),i(t<67108864);for(var r=0,n=0;n<this.length;n++){var s=(0|this.words[n])*t,o=(67108863&s)+(67108863&r);r>>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),this.length=0===t?1:this.length,e?this.ineg():this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i(\"number\"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,h=(0|this.words[e])-a<<r;this.words[e]=h|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i(\"number\"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var l=0|this.words[u];this.words[u]=f<<26-s|l>>>s,f=l&a}return h&&0!==f&&(h.words[h.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},s.prototype.imaskn=function(t){i(\"number\"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,\"imaskn works only with positive numbers\"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i(\"number\"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i(\"number\"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*e;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if(\"mod\"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,h);0===f.negative&&(i=f,a&&(a.words[h]=1));for(var l=h-1;l>=0;l--){var c=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,l);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=c)}return a&&a._strip(),i._strip(),\"div\"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),\"mod\"!==e&&(n=a.div.neg()),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),\"mod\"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),\"div\"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?\"div\"===e?{div:this.divn(t.words[0]),mod:null}:\"mod\"===e?{div:null,mod:new s(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,\"div\",!1).div},s.prototype.mod=function(t){return this.divmod(t,\"mod\",!1).mod},s.prototype.umod=function(t){return this.divmod(t,\"mod\",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%t;return e?-n:n},s.prototype.modn=function(t){return this.modrn(t)},s.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/t|0,r=s%t}return this._strip(),e?this.ineg():this},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),l=e.clone();!e.isZero();){for(var c=0,d=1;0===(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(f),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0===(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(f),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0===(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,c=1;0===(r.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i(\"number\"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,\"Number is too big\");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new x(t)},s.prototype.toRed=function(t){return i(!this.red,\"Already a number in reduction context\"),i(0===this.negative,\"red works only with positives\"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,\"Already a number in reduction context\"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,\"redAdd works only with red numbers\"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,\"redSub works only with red numbers\"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,\"redISub works only with red numbers\"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,\"redShl works only with red numbers\"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function _(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){_.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}function S(){_.call(this,\"p224\",\"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001\")}function k(){_.call(this,\"p192\",\"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff\")}function E(){_.call(this,\"25519\",\"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed\")}function x(t){if(\"string\"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),\"modulus must be greater than 1\"),this.m=t,this.prime=null}function A(t){x.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}_.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},_.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},_.prototype.split=function(t,e){t.iushrn(this.n,0,e)},_.prototype.imulK=function(t){return t.imul(this.k)},n(M,_),M.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},M.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(S,_),n(k,_),n(E,_),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(w[t])return w[t];var e;if(\"k256\"===t)e=new M;else if(\"p224\"===t)e=new S;else if(\"p192\"===t)e=new k;else{if(\"p25519\"!==t)throw new Error(\"Unknown prime \"+t);e=new E}return w[t]=e,e},x.prototype._verify1=function(t){i(0===t.negative,\"red works only with positives\"),i(t.red,\"red works only with red numbers\")},x.prototype._verify2=function(t,e){i(0===(t.negative|e.negative),\"red works only with positives\"),i(t.red&&t.red===e.red,\"red works only with red numbers\")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(f(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},x.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},x.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},x.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(h);)f.redIAdd(h);for(var l=this.pow(f,n),c=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var y=this.pow(l,new s(1).iushln(p-g-1));c=c.redMul(y),l=y.redSqr(),d=d.redMul(l),p=g}return c},x.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},x.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=h-1;f>=0;f--){var l=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},x.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},x.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new A(t)},n(A,x),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},9439:(t,e,r)=>{e.RateLimiter=r(3065),e.TokenBucket=r(5472)},9530:(t,e,r)=>{t.exports=r(8310)},9538:t=>{t.exports=ReferenceError},9560:(t,e,r)=>{e.utils=r(7626),e.Cipher=r(2808),e.DES=r(2211),e.CBC=r(3389),e.EDE=r(5279)},9596:t=>{let e;t.exports=\"function\"==typeof queueMicrotask?queueMicrotask.bind(\"undefined\"!=typeof window?window:globalThis):t=>(e||(e=Promise.resolve())).then(t).catch(t=>setTimeout(()=>{throw t},0))},9600:t=>{var e,r,i=Function.prototype.toString,n=\"object\"==typeof Reflect&&null!==Reflect&&Reflect.apply;if(\"function\"==typeof n&&\"function\"==typeof Object.defineProperty)try{e=Object.defineProperty({},\"length\",{get:function(){throw r}}),r={},n(function(){throw 42},null,e)}catch(t){t!==r&&(n=null)}else n=null;var s=/^\\s*class\\b/,o=function(t){try{var e=i.call(t);return s.test(e)}catch(t){return!1}},a=function(t){try{return!o(t)&&(i.call(t),!0)}catch(t){return!1}},h=Object.prototype.toString,u=\"function\"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),l=function(){return!1};if(\"object\"==typeof document){var c=document.all;h.call(c)===h.call(document.all)&&(l=function(t){if((f||!t)&&(void 0===t||\"object\"==typeof t))try{var e=h.call(t);return(\"[object HTMLAllCollection]\"===e||\"[object HTML document.all class]\"===e||\"[object HTMLCollection]\"===e||\"[object Object]\"===e)&&null==t(\"\")}catch(t){}return!1})}t.exports=n?function(t){if(l(t))return!0;if(!t)return!1;if(\"function\"!=typeof t&&\"object\"!=typeof t)return!1;try{n(t,null,e)}catch(t){if(t!==r)return!1}return!o(t)&&a(t)}:function(t){if(l(t))return!0;if(!t)return!1;if(\"function\"!=typeof t&&\"object\"!=typeof t)return!1;if(u)return a(t);if(o(t))return!1;var e=h.call(t);return!(\"[object Function]\"!==e&&\"[object GeneratorFunction]\"!==e&&!/^\\[object HTML/.test(e))&&a(t)}},9612:t=>{t.exports=Object},9639:(t,e,r)=>{r.d(e,{NJ:()=>y,V5:()=>o,dU:()=>p,HB:()=>b,xW:()=>h,LC:()=>u,tW:()=>k,fk:()=>a,Ht:()=>v,po:()=>E,L0:()=>g});const i=\"0123456789abcdef\",n=[],s=[];for(let t=0;t<256;t++)n[t]=i[t>>4&15]+i[15&t],t<16&&(t<10?s[48+t]=t:s[87+t]=t);const o=t=>{const e=t.length;let r=\"\",i=0;for(;i<e;)r+=n[t[i++]];return r},a=t=>{const e=t.length>>1,r=e<<1,i=new Uint8Array(e);let n=0,o=0;for(;o<r;)i[n++]=s[t.charCodeAt(o++)]<<4|s[t.charCodeAt(o++)];return i},h=(t,e=0)=>{const r=t.length||0;if(!e){let i=r;for(;i--;)e+=t[i].length}const i=new Uint8Array(e);let n=e,s=r;for(;s--;)n-=t[s].length,i.set(t[s],n);return i},u=(t,e)=>{if(t.length!==e.length)return!1;for(let r=t.length;r>-1;r-=1)if(t[r]!==e[r])return!1;return!0};for(var f=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",l=\"undefined\"==typeof Uint8Array?[]:new Uint8Array(256),c=0;c<64;c++)l[f.charCodeAt(c)]=c;const d=new TextDecoder,p=(t,e)=>{if(!e)return d.decode(t);return new TextDecoder(e).decode(t)},m=new TextEncoder,g=t=>m.encode(t),y=t=>function(t){var e,r=new Uint8Array(t),i=r.length,n=\"\";for(e=0;e<i;e+=3)n+=f[r[e]>>2],n+=f[(3&r[e])<<4|r[e+1]>>4],n+=f[(15&r[e+1])<<2|r[e+2]>>6],n+=f[63&r[e+2]];return i%3==2?n=n.substring(0,n.length-1)+\"=\":i%3==1&&(n=n.substring(0,n.length-2)+\"==\"),n}(t),b=t=>{let e,r=\"\",n=0;const s=t.length;for(;n<s;)e=t.charCodeAt(n++),r+=i[e>>4]+i[15&e];return r},v=t=>{const e=a(t);if(e.length<=65536)return String.fromCharCode(...e);let r=\"\",i=0;for(;i<e.length;)r+=String.fromCharCode(...e.subarray(i,i+=65536));return r},w=\"undefined\"!=typeof window?window:self,_=w.crypto||w.msCrypto||{},M=_.subtle||_.webkitSubtle,S={hex:o,base64:y},k=async(t,e,r=\"sha-1\")=>{if(!M)throw new Error(\"no web crypto support\");\"string\"==typeof t&&(t=g(t));const i=new Uint8Array(await M.digest(r,t));return e?S[e](i):i},E=t=>{const e=new Uint8Array(t);return _.getRandomValues(e)}},9655:function(t,e,r){var i;t=r.nmd(t),function(){e&&e.nodeType,t&&t.nodeType;var n=\"object\"==typeof globalThis&&globalThis;n.global!==n&&n.window!==n&&n.self;var s,o=2147483647,a=36,h=/^xn--/,u=/[^\\x20-\\x7E]/,f=/[\\x2E\\u3002\\uFF0E\\uFF61]/g,l={overflow:\"Overflow: input needs wider integers to process\",\"not-basic\":\"Illegal input >= 0x80 (not a basic code point)\",\"invalid-input\":\"Invalid input\"},c=Math.floor,d=String.fromCharCode;function p(t){throw new RangeError(l[t])}function m(t,e){for(var r=t.length,i=[];r--;)i[r]=e(t[r]);return i}function g(t,e){var r=t.split(\"@\"),i=\"\";return r.length>1&&(i=r[0]+\"@\",t=r[1]),i+m((t=t.replace(f,\".\")).split(\".\"),e).join(\".\")}function y(t){for(var e,r,i=[],n=0,s=t.length;n<s;)(e=t.charCodeAt(n++))>=55296&&e<=56319&&n<s?56320==(64512&(r=t.charCodeAt(n++)))?i.push(((1023&e)<<10)+(1023&r)+65536):(i.push(e),n--):i.push(e);return i}function b(t){return m(t,function(t){var e=\"\";return t>65535&&(e+=d((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=d(t)}).join(\"\")}function v(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:a}function w(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function _(t,e,r){var i=0;for(t=r?c(t/700):t>>1,t+=c(t/e);t>455;i+=a)t=c(t/35);return c(i+36*t/(t+38))}function M(t){var e,r,i,n,s,h,u,f,l,d,m=[],g=t.length,y=0,w=128,M=72;for((r=t.lastIndexOf(\"-\"))<0&&(r=0),i=0;i<r;++i)t.charCodeAt(i)>=128&&p(\"not-basic\"),m.push(t.charCodeAt(i));for(n=r>0?r+1:0;n<g;){for(s=y,h=1,u=a;n>=g&&p(\"invalid-input\"),((f=v(t.charCodeAt(n++)))>=a||f>c((o-y)/h))&&p(\"overflow\"),y+=f*h,!(f<(l=u<=M?1:u>=M+26?26:u-M));u+=a)h>c(o/(d=a-l))&&p(\"overflow\"),h*=d;M=_(y-s,e=m.length+1,0==s),c(y/e)>o-w&&p(\"overflow\"),w+=c(y/e),y%=e,m.splice(y++,0,w)}return b(m)}function S(t){var e,r,i,n,s,h,u,f,l,m,g,b,v,M,S,k=[];for(b=(t=y(t)).length,e=128,r=0,s=72,h=0;h<b;++h)(g=t[h])<128&&k.push(d(g));for(i=n=k.length,n&&k.push(\"-\");i<b;){for(u=o,h=0;h<b;++h)(g=t[h])>=e&&g<u&&(u=g);for(u-e>c((o-r)/(v=i+1))&&p(\"overflow\"),r+=(u-e)*v,e=u,h=0;h<b;++h)if((g=t[h])<e&&++r>o&&p(\"overflow\"),g==e){for(f=r,l=a;!(f<(m=l<=s?1:l>=s+26?26:l-s));l+=a)S=f-m,M=a-m,k.push(d(w(m+S%M,0))),f=c(S/M);k.push(d(w(f,0))),s=_(r,v,i==n),r=0,++i}++r,++e}return k.join(\"\")}s={version:\"1.4.1\",ucs2:{decode:y,encode:b},decode:M,encode:S,toASCII:function(t){return g(t,function(t){return u.test(t)?\"xn--\"+S(t):t})},toUnicode:function(t){return g(t,function(t){return h.test(t)?M(t.slice(4).toLowerCase()):t})}},void 0===(i=function(){return s}.call(e,r,e,t))||(t.exports=i)}()},9673:(t,e,r)=>{var i=e;i.Reporter=r(9220).a,i.DecoderBuffer=r(7227).t,i.EncoderBuffer=r(7227).d,i.Node=r(993)},9675:t=>{t.exports=TypeError},9860:t=>{var e={}.toString;t.exports=Array.isArray||function(t){return\"[object Array]\"==e.call(t)}},9957:(t,e,r)=>{var i=Function.prototype.call,n=Object.prototype.hasOwnProperty,s=r(6743);t.exports=s.call(i,n)},9971:(t,e,r)=>{const i=r(3209),{EventEmitter:n}=r(7007);function s(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0,i=t.length;r<i;++r)if(t[r]!==e[r])return!1;return!0}function o(t,e){if(!(e instanceof Uint8Array))throw new TypeError(t+\" is not a Uint8Array\")}class a extends n{constructor(t={}){super(),this.localNodeId=t.localNodeId||i(20),this.numberOfNodesPerKBucket=t.numberOfNodesPerKBucket||20,this.numberOfNodesToPing=t.numberOfNodesToPing||3,this.distance=t.distance||a.distance,this.arbiter=t.arbiter||a.arbiter,this.metadata=Object.assign({},t.metadata),o(\"option.localNodeId as parameter 1\",this.localNodeId),this.root={contacts:[],dontSplit:!1,left:null,right:null}}static arbiter(t,e){return t.vectorClock>e.vectorClock?t:e}static distance(t,e){let r=0,i=0;const n=Math.min(t.length,e.length),s=Math.max(t.length,e.length);for(;i<n;++i)r=256*r+(t[i]^e[i]);for(;i<s;++i)r=256*r+255;return r}add(t){o(\"contact.id\",(t||{}).id);let e=0,r=this.root;for(;null===r.contacts;)r=this._determineNode(r,t.id,e++);const i=this._indexOf(r,t.id);return i>=0?(this._update(r,i,t),this):r.contacts.length<this.numberOfNodesPerKBucket?(r.contacts.push(t),this.emit(\"added\",t),this):r.dontSplit?(this.emit(\"ping\",r.contacts.slice(0,this.numberOfNodesToPing),t),this):(this._split(r,e),this.add(t))}closest(t,e=1/0){if(o(\"id\",t),!Number.isInteger(e)&&e!==1/0||e<=0)throw new TypeError(\"n is not positive number\");let r=[];for(let i=[this.root],n=0;i.length>0&&r.length<e;){const e=i.pop();if(null===e.contacts){const r=this._determineNode(e,t,n++);i.push(e.left===r?e.right:e.left),i.push(r)}else r=r.concat(e.contacts)}return r.map(e=>[this.distance(e.id,t),e]).sort((t,e)=>t[0]-e[0]).slice(0,e).map(t=>t[1])}count(){let t=0;for(const e=[this.root];e.length>0;){const r=e.pop();null===r.contacts?e.push(r.right,r.left):t+=r.contacts.length}return t}_determineNode(t,e,r){const i=r>>3,n=r%8;if(e.length<=i&&0!==n)return t.left;return e[i]&1<<7-n?t.right:t.left}get(t){o(\"id\",t);let e=0,r=this.root;for(;null===r.contacts;)r=this._determineNode(r,t,e++);const i=this._indexOf(r,t);return i>=0?r.contacts[i]:null}_indexOf(t,e){for(let r=0;r<t.contacts.length;++r)if(s(t.contacts[r].id,e))return r;return-1}remove(t){o(\"the id as parameter 1\",t);let e=0,r=this.root;for(;null===r.contacts;)r=this._determineNode(r,t,e++);const i=this._indexOf(r,t);if(i>=0){const t=r.contacts.splice(i,1)[0];this.emit(\"removed\",t)}return this}_split(t,e){t.left={contacts:[],dontSplit:!1,left:null,right:null},t.right={contacts:[],dontSplit:!1,left:null,right:null};for(const r of t.contacts)this._determineNode(t,r.id,e).contacts.push(r);t.contacts=null;const r=this._determineNode(t,this.localNodeId,e);(t.left===r?t.right:t.left).dontSplit=!0}toArray(){let t=[];for(const e=[this.root];e.length>0;){const r=e.pop();null===r.contacts?e.push(r.right,r.left):t=t.concat(r.contacts)}return t}*toIterable(){for(const t=[this.root];t.length>0;){const e=t.pop();null===e.contacts?t.push(e.right,e.left):yield*e.contacts}}_update(t,e,r){if(!s(t.contacts[e].id,r.id))throw new Error(\"wrong index for _update\");const i=t.contacts[e],n=this.arbiter(i,r);n===i&&i!==r||(t.contacts.splice(e,1),t.contacts.push(n),this.emit(\"updated\",i,n))}}t.exports=a}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.loaded=!0,s.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var i={};r.r(i),r.d(i,{ACTIONS:()=>Gt,CONNECTION_ID:()=>Zt,DESTROY_TIMEOUT:()=>te,EVENTS:()=>Yt,EVENT_IDS:()=>Jt,EVENT_NAMES:()=>Xt,IPV4_RE:()=>$t,IPV6_RE:()=>Vt,REMOVE_IPV4_MAPPED_IPV6_RE:()=>Kt,REQUEST_TIMEOUT:()=>Qt,querystringParse:()=>re,querystringStringify:()=>ie,toUInt32:()=>ee});var n=r(7007);function s(t){if(\"string\"!=typeof t)throw new TypeError(\"Path must be a string. Received \"+JSON.stringify(t))}function o(t,e){let r,i=\"\",n=0,s=-1,o=0;for(let a=0;a<=t.length;++a){if(a<t.length)r=t.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===o);else if(s!==a-1&&2===o){if(i.length<2||2!==n||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){const t=i.lastIndexOf(\"/\");if(t!==i.length-1){-1===t?(i=\"\",n=0):(i=i.slice(0,t),n=i.length-1-i.lastIndexOf(\"/\")),s=a,o=0;continue}}else if(2===i.length||1===i.length){i=\"\",n=0,s=a,o=0;continue}e&&(i.length>0?i+=\"/..\":i=\"..\",n=2)}else i.length>0?i+=\"/\"+t.slice(s+1,a):i=t.slice(s+1,a),n=a-s-1;s=a,o=0}else 46===r&&-1!==o?++o:o=-1}return i}function a(t){if(s(t),0===t.length)return\".\";const e=47===t.charCodeAt(0),r=47===t.charCodeAt(t.length-1);return 0!==(t=o(t,!e)).length||e||(t=\".\"),t.length>0&&r&&(t+=\"/\"),e?\"/\"+t:t}function h(){if(0===arguments.length)return\".\";let t;for(let e=0;e<arguments.length;++e){const r=arguments[e];s(r),r.length>0&&(void 0===t?t=r:t+=\"/\"+r)}return void 0===t?\".\":a(t)}r(717);const u=\"/\";var f=r(988),l=r(1467),c=r(8444),d=r(7266);const p=new RegExp([\"^npm-debug\\\\.log$\",\"^\\\\..*\\\\.swp$\",\"^\\\\.DS_Store$\",\"^\\\\.AppleDouble$\",\"^\\\\.LSOverride$\",\"^Icon\\\\r$\",\"^\\\\._.*\",\"^\\\\.Spotlight-V100(?:$|\\\\/)\",\"\\\\.Trashes\",\"^__MACOSX$\",\"~$\",\"^Thumbs\\\\.db$\",\"^ehthumbs\\\\.db$\",\"^[Dd]esktop\\\\.ini$\",\"@eaDir$\"].join(\"|\"));function m(t){return p.test(t)}function g(t){return!m(t)}var y=r(405),b=r(8190),v=r(9596),w=r(9639),_=(r(3468),r(5185)),M=r(3519);function S(t){return\".\"!==t[0]}function k(t,e,r){_.stat(t,(i,n)=>{if(i)return r(i);n.isDirectory()?_.readdir(t,(i,n)=>{if(i)return r(i);b(n.filter(S).filter(g).map(r=>i=>{k(h(t,r),e,i)}),r)}):n.isFile()&&e(t,r)})}function E(t,e,r){k(t,x,(i,n)=>{if(i)return r(i);n=Array.isArray(n)?n.flat(1/0):[n],t=a(t),e&&(t=t.slice(0,t.lastIndexOf(u)+1)),t[t.length-1]!==u&&(t+=u),n.forEach(e=>{e.getStream=function(t){return()=>_.createReadStream(t)}(e.path),e.path=e.path.replace(t,\"\").split(u)}),r(null,n)})}function x(t,e){e=M(e),_.stat(t,(r,i)=>{if(r)return e(r);const n={length:i.size,path:t};e(null,n)})}const A=[[\"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.webtorrent.dev\"]];const I=Symbol(\"itemPath\");function T(t,e,r){var i;if(i=t,\"undefined\"!=typeof FileList&&i instanceof FileList&&(t=Array.from(t)),Array.isArray(t)||(t=[t]),0===t.length)throw new Error(\"invalid input type\");t.forEach(t=>{if(null==t)throw new Error(`invalid input type: ${t}`)}),1!==(t=t.map(t=>R(t)&&\"string\"==typeof t.path?t.path:t)).length||\"string\"==typeof t[0]||t[0].name||(t[0].name=e.name);let n=null;t.forEach((e,r)=>{if(\"string\"==typeof e)return;let i=e.fullPath||e.name;i||(i=`Unknown File ${r+1}`,e.unknownName=!0),e[I]=i.split(\"/\"),e[I][0]||e[I].shift(),e[I].length<2?n=null:0===r&&t.length>1?n=e[I][0]:e[I][0]!==n&&(n=null)});(void 0===e.filterJunkFiles||e.filterJunkFiles)&&(t=t.filter(t=>\"string\"==typeof t||!function(t){const e=t[t.length-1];return\".\"===e[0]&&m(e)}(t[I]))),n&&t.forEach(t=>{const e=(ArrayBuffer.isView(t)||O(t))&&!t[I];\"string\"==typeof t||e||t[I].shift()}),!e.name&&n&&(e.name=n),e.name||t.some(t=>\"string\"==typeof t?(e.name=function(t,e){if(void 0!==e&&\"string\"!=typeof e)throw new TypeError('\"ext\" argument must be a string');s(t);let r,i=0,n=-1,o=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return\"\";let s=e.length-1,a=-1;for(r=t.length-1;r>=0;--r){const h=t.charCodeAt(r);if(47===h){if(!o){i=r+1;break}}else-1===a&&(o=!1,a=r+1),s>=0&&(h===e.charCodeAt(s)?-1===--s&&(n=r):(s=-1,n=a))}return i===n?n=a:-1===n&&(n=t.length),t.slice(i,n)}for(r=t.length-1;r>=0;--r)if(47===t.charCodeAt(r)){if(!o){i=r+1;break}}else-1===n&&(o=!1,n=r+1);return-1===n?\"\":t.slice(i,n)}(t),!0):!t.unknownName&&(e.name=t[I][t[I].length-1],!0)),e.name||(e.name=`Unnamed Torrent ${Date.now()}`),e.maxPieceLength||(e.maxPieceLength=4194304);const o=t.reduce((t,e)=>t+Number(\"string\"==typeof e),0);let a=1===t.length;function h(){b(t.map(t=>e=>{const r={};if(R(t))r.getStream=t.stream(),r.length=t.size;else if(ArrayBuffer.isView(t))r.getStream=[t],r.length=t.length;else{if(!O(t)){if(\"string\"==typeof t){0;return void E(t,o>1||a,e)}throw new Error(\"invalid input type\")}r.getStream=async function*(t,e){for await(const r of t)e.length+=r.length,yield r}(t,r),r.length=0}r.path=t[I],e(null,r)}),(t,e)=>{if(t)return r(t);e=e.flat(),r(null,e,a)})}1===t.length&&\"string\"==typeof t[0]?d(t[0],(t,e)=>{if(t)return r(t);a=e,h()}):v(h)}const C=5;function P(t,e){return t+e.length}function R(t){return\"undefined\"!=typeof Blob&&t instanceof Blob}function O(t){return\"object\"==typeof t&&null!=t&&\"function\"==typeof t.pipe}const B=function(t,e,r){\"function\"==typeof e&&([e,r]=[r,e]),T(t,e=e?Object.assign({},e):{},(t,i,n)=>{if(t)return r(t);e.singleFileTorrent=n,function(t,e,r){let i=e.announceList;i||(\"string\"==typeof e.announce?i=[[e.announce]]:Array.isArray(e.announce)&&(i=e.announce.map(t=>[t])));i||(i=[]);globalThis.WEBTORRENT_ANNOUNCE&&(\"string\"==typeof globalThis.WEBTORRENT_ANNOUNCE?i.push([[globalThis.WEBTORRENT_ANNOUNCE]]):Array.isArray(globalThis.WEBTORRENT_ANNOUNCE)&&(i=i.concat(globalThis.WEBTORRENT_ANNOUNCE.map(t=>[t]))));void 0===e.announce&&void 0===e.announceList&&(i=i.concat(A));\"string\"==typeof e.urlList&&(e.urlList=[e.urlList]);const n={info:{name:e.name},\"creation date\":Math.ceil((Number(e.creationDate)||Date.now())/1e3),encoding:\"UTF-8\"};0!==i.length&&(n.announce=i[0][0],n[\"announce-list\"]=i);void 0!==e.comment&&(n.comment=e.comment);void 0!==e.createdBy&&(n[\"created by\"]=e.createdBy);void 0!==e.private&&(n.info.private=Number(e.private));void 0!==e.info&&Object.assign(n.info,e.info);void 0!==e.sslCert&&(n.info[\"ssl-cert\"]=e.sslCert);void 0!==e.urlList&&(n[\"url-list\"]=e.urlList);const s=t.reduce(P,0),o=e.pieceLength||Math.min(c(s),e.maxPieceLength);n.info[\"piece length\"]=o,async function(t,e,r,i,n){const s=[];let o=0,a=0;const h=t.map(t=>t.getStream),u=i.onProgress;let f=0,c=0,d=!1;const p=l(y(h),e,{zeroPadding:!1});try{for await(const t of p)await new Promise(e=>{o+=t.length;const i=c;++c,++f<C&&e(),(0,w.tW)(t,\"hex\").then(h=>{s[i]=h,--f,a+=t.length,u&&u(a,r),e(),d&&0===f&&n(null,(0,w.fk)(s.join(\"\")),o)})});if(0===f)return n(null,(0,w.fk)(s.join(\"\")),o);d=!0}catch(t){n(t)}}(t,o,s,e,(i,s,o)=>{if(i)return r(i);n.info.pieces=s,t.forEach(t=>{delete t.getStream}),e.singleFileTorrent?n.info.length=o:n.info.files=t,r(null,f.A.encode(n))})}(i,e,r)})};var L=r(7833),N=r(9971),j=r(4988),U=r(7180),q=r(8454),D=r(3209),H=r(5307),F=r(1565),z=r(8287).Buffer,W=r(717);const $=L(\"bittorrent-dht\"),V=3e5;class K extends n.EventEmitter{constructor(t={}){super(),this._tables=new q({maxAge:V,max:t.maxTables||1e3}),this._values=new q(t.maxValues||1e3),this._peers=H({maxAge:t.maxAge||0,maxSize:t.maxPeers||1e4}),this._secrets=null,this._hash=t.hash||G,this._hashLength=this._hash(z.from(\"\")).length,this._rpc=t.krpc||j(Object.assign({idLength:this._hashLength},t)),this._rpc.on(\"query\",function(t,e){r._onquery(t,e)}),this._rpc.on(\"node\",function(t){r.emit(\"node\",t)}),this._rpc.on(\"warning\",function(t){r.emit(\"warning\",t)}),this._rpc.on(\"error\",function(t){r.emit(\"error\",t)}),this._rpc.on(\"listening\",function(){r.listening=!0,r._debug(\"listening %d\",r.address().port),r.updateBucketTimestamp(),r._setBucketCheckInterval(),r.emit(\"listening\")}),this._rotateSecrets(),this._verify=t.verify||null,this._host=t.host||null,this._interval=setInterval(function(){r._rotateSecrets()},V),this._runningBucketCheck=!1,this._bucketCheckTimeout=null,this._bucketOutdatedTimeSpan=t.timeBucketOutdated||9e5,this.listening=!1,this.destroyed=!1,this.nodeId=this._rpc.id,this.nodes=this._rpc.nodes;const e=U(function(t,e){const i=t.older,n=t.swap;r._debug(\"received ping\",i),r._checkNodes(i,!1,(t,i)=>{if(i)return r._debug(\"swaping dead node with newer\",i),n(i),e();r._debug(\"no node added, all other nodes ok\"),e()})});this._rpc.on(\"ping\",(t,r)=>{e({older:t,swap:r})}),W.nextTick(function(){r.destroyed||r._bootstrap(!1!==t.bootstrap)}),this._debug(\"new DHT %s\",this.nodeId);const r=this}_setBucketCheckInterval(){const t=this;function e(){if(Date.now()-t._rpc.nodes.metadata.lastChange<t._bucketOutdatedTimeSpan)return r();t._pingAll(()=>{t.destroyed||(t.nodes.toArray().length<1&&t._bootstrap(!0),r())})}function r(){if(!t._runningBucketCheck||t.destroyed)return;const r=Math.floor(6e4*Math.random()+3e4);t._bucketCheckTimeout=setTimeout(e,r)}this._runningBucketCheck=!0,r()}_pingAll(t){this._checkAndRemoveNodes(this.nodes.toArray(),t)}removeBucketCheckInterval(){this._runningBucketCheck=!1,clearTimeout(this._bucketCheckTimeout)}updateBucketTimestamp(){this._rpc.nodes.metadata.lastChange=Date.now()}_checkAndRemoveNodes(t,e){const r=this;this._checkNodes(t,!0,(t,i)=>{i&&r.removeNode(i.id),e(null,i)})}_checkNodes(t,e,r){const i=this;!function t(n){let s=null;for(;n.length&&(s=n.pop(),s.id&&!e)&&!(Date.now()-(s.seen||0)>1e4);)s=null;if(!s)return r(null);i._sendPing(s,e=>{if(!e)return i.updateBucketTimestamp(),t(n);r(null,s)})}(t)}addNode(t){const e=this;if(t.id){t.id=tt(t.id);const e=!!this._rpc.nodes.get(t.id);return this._rpc.nodes.add(t),void(e||(this.emit(\"node\",t),this.updateBucketTimestamp()))}this._sendPing(t,(t,r)=>{r&&e.addNode(r)})}removeNode(t){this._rpc.nodes.remove(tt(t))}_sendPing(t,e){const r=this,i=t.id;this._rpc.query(t,{q:\"ping\"},(t,n,s)=>t?e(t):n.r&&n.r.id&&z.isBuffer(n.r.id)&&n.r.id.length===r._hashLength?z.isBuffer(i)&&!i.equals(n.r.id)?e(new Error(\"Unexpected node id\")):(r.updateBucketTimestamp(),void e(null,{id:n.r.id,host:s.host||s.address,port:s.port})):e(new Error(\"Bad reply\")))}toJSON(){const t=this,e={};return Object.keys(this._values.cache).forEach(r=>{const i=t._values.cache[r].value;e[r]={v:i.v.toString(\"hex\"),id:i.id.toString(\"hex\")},null!=i.seq&&(e[r].seq=i.seq),null!=i.sig&&(e[r].sig=i.sig.toString(\"hex\")),null!=i.k&&(e[r].k=i.k.toString(\"hex\"))}),{nodes:this._rpc.nodes.toArray().map(Q),values:e}}put(t,e){(z.isBuffer(t)||\"string\"==typeof t)&&(t={v:t});const r=!!t.k;if(void 0===t.v)throw new Error(\"opts.v not given\");if(t.v.length>=1e3)throw new Error(\"v must be less than 1000 bytes in put()\");if(r&&void 0!==t.cas&&\"number\"!=typeof t.cas)throw new Error(\"opts.cas must be an integer if provided\");if(r&&32!==t.k.length)throw new Error(\"opts.k ed25519 public key must be 32 bytes\");if(r&&\"function\"!=typeof t.sign&&!z.isBuffer(t.sig))throw new Error(\"opts.sign function or options.sig signature is required for mutable put\");if(r&&t.salt&&t.salt.length>64)throw new Error(\"opts.salt is > 64 bytes long\");if(r&&void 0===t.seq)throw new Error(\"opts.seq not provided for a mutable update\");if(r&&\"number\"!=typeof t.seq)throw new Error(\"opts.seq not an integer\");return this._put(t,e)}_put(t,e){e||(e=Z);const r=!!t.k,i=\"string\"==typeof t.v?z.from(t.v):t.v,n=r?this._hash(t.salt?z.concat([t.k,t.salt]):t.k):this._hash(f.A.encode(i)),s=this._tables.get(n.toString(\"hex\"));if(!s)return this._preput(n,t,e);const o={q:\"put\",a:{id:this._rpc.id,token:null,v:i}};return r?(\"number\"==typeof t.cas&&(o.a.cas=t.cas),t.salt&&(o.a.salt=t.salt),o.a.k=t.k,o.a.seq=t.seq,\"function\"==typeof t.sign?o.a.sig=t.sign(X(o.a)):z.isBuffer(t.sig)&&(o.a.sig=t.sig)):this._values.set(n.toString(\"hex\"),o.a),this._rpc.queryAll(s.closest(n),o,null,(t,r)=>{if(t)return e(t,n,r);e(null,n,r)}),n}_preput(t,e,r){const i=this;return this._closest(t,{q:\"get\",a:{id:this._rpc.id,target:t}},null,(t,n)=>{if(t)return r(t);i.put(e,r)}),t}get(t,e,r){t=tt(t),\"function\"==typeof e&&(r=e,e=null),e||(e={});const i=e.verify||this._verify,n=this._hash;let s=this._values.get(t.toString(\"hex\"))||null;if(s&&!1!==e.cache)return s=Y(this._rpc.id,null,s),W.nextTick(o);function o(t){if(t)return r(t);r(null,s)}this._closest(t,{q:\"get\",a:{id:this._rpc.id,target:t}},function(r){const o=r.r;if(!o||!o.v)return!0;const a=o.k||o.sig;e.salt&&(o.salt=z.from(e.salt));if(a){if(!i||!o.sig||!o.k)return!0;if(!i(o.sig,X(o),o.k))return!0;n(o.salt?z.concat([o.k,o.salt]):o.k).equals(t)&&(!s||o.seq>s.seq)&&(s=o)}else if(n(f.A.encode(o.v)).equals(t))return s=o,!1;return!0},o)}announce(t,e,r){if(\"function\"==typeof e)return this.announce(t,0,e);t=tt(t),r||(r=Z);const i=this._tables.get(t.toString(\"hex\"));if(!i)return this._preannounce(t,e,r);if(this._host){const r=this.listening?this.address().port:0;this._addPeer({host:this._host,port:e||r},t,{host:this._host,port:r})}const n={q:\"announce_peer\",a:{id:this._rpc.id,token:null,info_hash:t,port:e,implied_port:e?0:1}};this._debug(\"announce %s %d\",t,e),this._rpc.queryAll(i.closest(t),n,null,r)}_preannounce(t,e,r){const i=this;this.lookup(t,n=>i.destroyed?r(new Error(\"dht is destroyed\")):n?r(n):void i.announce(t,e,r))}lookup(t,e){t=tt(t),e||(e=Z);const r=this;let i=!1;function n(e,i){e||(e=r._peers.get(t.toString(\"hex\"),100));const n=function(t){const e=[];try{for(let r=0;r<t.length;r++){const i=t[r].readUInt16BE(4);i&&e.push({host:J(t[r],0),port:i})}}catch(t){}return e}(e);for(let e=0;e<n.length;e++)r.emit(\"peer\",n[e],t,i||null)}return this._debug(\"lookup %s\",t),W.nextTick(n),this._closest(t,{q:\"get_peers\",a:{id:this._rpc.id,info_hash:t}},function(t,e){if(i)return!1;t.r.values&&n(t.r.values,e)},e),function(){i=!0}}address(){return this._rpc.address()}listen(...t){this._rpc.bind(...t)}destroy(t){if(this.destroyed)return void(t&&W.nextTick(t));this.destroyed=!0;const e=this;clearInterval(this._interval),this.removeBucketCheckInterval(),this._peers.destroy(),this._debug(\"destroying\"),this._rpc.destroy(()=>{e.emit(\"close\"),t&&t()})}_onquery(t,e){if(void 0===t.q||null===t.q)return;const r=t.q.toString();if(this._debug(\"received %s query from %s:%d\",r,e.address,e.port),t.a)switch(r){case\"ping\":return this._rpc.response(e,t,{id:this._rpc.id});case\"find_node\":return this._onfindnode(t,e);case\"get_peers\":return this._ongetpeers(t,e);case\"announce_peer\":return this._onannouncepeer(t,e);case\"get\":return this._onget(t,e);case\"put\":return this._onput(t,e)}}_onfindnode(t,e){const r=t.a.target;if(!r)return this._rpc.error(e,t,[203,\"`find_node` missing required `a.target` field\"]);this.emit(\"find_node\",r);const i=this._rpc.nodes.closest(r);this._rpc.response(e,t,{id:this._rpc.id},i)}_ongetpeers(t,e){const r=e.address||e.host,i=t.a.info_hash;if(!i)return this._rpc.error(e,t,[203,\"`get_peers` missing required `a.info_hash` field\"]);this.emit(\"get_peers\",i);const n={id:this._rpc.id,token:this._generateToken(r)},s=this._peers.get(i.toString(\"hex\"));s.length?(n.values=s,this._rpc.response(e,t,n)):this._rpc.response(e,t,n,this._rpc.nodes.closest(i))}_onannouncepeer(t,e){const r=e.address||e.host,i=t.a.implied_port?e.port:t.a.port;if(!i||\"number\"!=typeof i||i<=0||i>65535)return;const n=t.a.info_hash,s=t.a.token;if(n&&s){if(!this._validateToken(r,s))return this._rpc.error(e,t,[203,\"cannot `announce_peer` with bad token\"]);this.emit(\"announce_peer\",n,{host:r,port:e.port}),this._addPeer({host:r,port:i},n,{host:r,port:e.port}),this._rpc.response(e,t,{id:this._rpc.id})}}_addPeer(t,e,r){this._peers.add(e.toString(\"hex\"),function(t,e){const r=z.allocUnsafe(6),i=t.split(\".\");for(let t=0;t<4;t++)r[t]=parseInt(i[t]||0,10);return r.writeUInt16BE(e,4),r}(t.host,t.port)),this.emit(\"announce\",t,e,r)}_onget(t,e){const r=e.address||e.host,i=t.a.target;if(!i)return;const n=this._generateToken(r),s=this._values.get(i.toString(\"hex\"));if(this.emit(\"get\",i,s),s)this._rpc.response(e,t,Y(this._rpc.id,n,s));else{const r=this._rpc.nodes.closest(i);this._rpc.response(e,t,{id:this._rpc.id,token:n},r)}}_onput(t,e){const r=e.address||e.host,i=t.a;if(!i)return;const n=t.a.v;if(!n)return;const s=t.a.id;if(!s)return;const o=i.token;if(!o)return;if(!this._validateToken(r,o))return this._rpc.error(e,t,[203,\"cannot `put` with bad token\"]);if(n.length>1e3)return this._rpc.error(e,t,[205,\"data payload too large\"]);const a=!(!i.k&&!i.sig);if(a&&!i.k&&!i.sig)return;const h=a?this._hash(i.salt?z.concat([i.k,i.salt]):i.k):this._hash(f.A.encode(n)),u=h.toString(\"hex\");if(this.emit(\"put\",h,n),a){if(!this._verify)return this._rpc.error(e,t,[400,\"verification not supported\"]);if(!this._verify(i.sig,X(i),i.k))return;const r=this._values.get(u);if(r&&\"number\"==typeof i.cas&&r.seq!==i.cas)return this._rpc.error(e,t,[301,\"CAS mismatch, re-read and try again\"]);if(r&&\"number\"==typeof r.seq&&!(i.seq>r.seq))return this._rpc.error(e,t,[302,\"sequence number less than current\"]);this._values.set(u,{v:n,k:i.k,salt:i.salt,sig:i.sig,seq:i.seq,id:s})}else this._values.set(u,{v:n,id:s});this._rpc.response(e,t,{id:this._rpc.id})}_bootstrap(t){const e=this;if(!t)return W.nextTick(r);function r(){e.ready||(e._debug(\"emit ready\"),e.ready=!0,e.emit(\"ready\"))}this._rpc.populate(e._rpc.id,{q:\"find_node\",a:{id:e._rpc.id,target:e._rpc.id}},r)}_closest(t,e,r,i){const n=this,s=new N({localNodeId:t,numberOfNodesPerKBucket:this._rpc.k});this._rpc.closest(t,e,function(e,i){if(!e.r)return!0;e.r.token&&e.r.id&&z.isBuffer(e.r.id)&&e.r.id.length===n._hashLength&&(n._debug(\"found node %s (target: %s)\",e.r.id,t),s.add({id:e.r.id,host:i.host||i.address,port:i.port,token:e.r.token}));return!r||r(e,i)},function(e,r){if(e)return i(e);n._tables.set(t.toString(\"hex\"),s),n._debug(\"visited %d nodes\",r),i(null,r)})}_debug(){if(!$.enabled)return;const t=[].slice.call(arguments);t[0]=`[${this.nodeId.toString(\"hex\").substring(0,7)}] ${t[0]}`;for(let e=1;e<t.length;e++)z.isBuffer(t[e])&&(t[e]=t[e].toString(\"hex\"));$(...t)}_validateToken(t,e){const r=this._generateToken(t,this._secrets[0]),i=this._generateToken(t,this._secrets[1]);return e.equals(r)||e.equals(i)}_generateToken(t,e){return e||(e=this._secrets[0]),this._hash(z.concat([z.from(t),e]))}_rotateSecrets(){this._secrets?(this._secrets[1]=this._secrets[0],this._secrets[0]=D(this._hashLength)):this._secrets=[D(this._hashLength),D(this._hashLength)]}}function Z(){}function G(t){return F.createHash(\"sha1\").update(t).digest()}function Y(t,e,r){const i={id:t,token:e,v:r.v};return r.sig&&(i.sig=r.sig,i.k=r.k,\"number\"==typeof r.seq&&(i.seq=r.seq)),i}function J(t,e){return`${t[e++]}.${t[e++]}.${t[e++]}.${t[e++]}`}function X(t){const e={seq:t.seq||0,v:t.v};return t.salt&&(e.salt=t.salt),f.A.encode(e).slice(1,-1)}function Q(t){return{host:t.host,port:t.port}}function tt(t){if(z.isBuffer(t))return t;if(ArrayBuffer.isView(t))return z.from(t.buffer,t.byteOffset,t.byteLength);if(\"string\"==typeof t)return z.from(t,\"hex\");throw new Error(\"Pass a buffer or a string\")}const et=K;var rt=r(1827),it=r(3208);self.Blob,self.File,self.FormData,self.Headers,self.Request,self.Response,self.AbortController,self.AbortSignal;const nt=self.fetch||(()=>{throw new Error(\"global fetch is not available!\")}),st=[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];const ot=function(t){if(!ArrayBuffer.isView(t)&&\"string\"!=typeof t)throw new TypeError(\"base32.decode only takes Buffer or string as parameter\");let e,r=0,i=0,n=0;ArrayBuffer.isView(t)||(t=(0,w.L0)(t));const s=new Uint8Array(Math.ceil(5*t.length/8));for(let o=0;o<t.length&&61!==t[o];o++){const a=t[o]-48;if(!(a<st.length))throw new Error(\"Invalid input - it is not base32 encoded string\");i=st[a],r<=3?(r=(r+5)%8,0===r?(e|=i,s[n]=e,n++,e=0):e|=255&i<<8-r):(r=(r+5)%8,e|=255&i>>>r,s[n]=e,n++,e=255&i<<8-r)}return s.subarray(0,n)};function at(t){return t.reduce((t,e,r,i)=>{const n=e.split(\"-\").map(t=>parseInt(t));return t.concat(((t,e=t)=>Array.from({length:e-t+1},(e,r)=>r+t))(...n))},[])}const ht=function(t){const e={},r=t.split(\"magnet:?\")[1];let i;if((r&&r.length>=0?r.split(\"&\"):[]).forEach(t=>{const r=t.split(\"=\");if(2!==r.length)return;const i=r[0];let n=r[1];\"dn\"===i&&(n=decodeURIComponent(n).replace(/\\+/g,\" \")),\"tr\"!==i&&\"xs\"!==i&&\"as\"!==i&&\"ws\"!==i||(n=decodeURIComponent(n)),\"kt\"===i&&(n=decodeURIComponent(n).split(\"+\")),\"ix\"===i&&(n=Number(n)),\"so\"===i&&(n=at(decodeURIComponent(n).split(\",\"))),e[i]?(Array.isArray(e[i])||(e[i]=[e[i]]),e[i].push(n)):e[i]=n}),e.xt){(Array.isArray(e.xt)?e.xt:[e.xt]).forEach(t=>{(i=t.match(/^urn:btih:(.{40})/))?e.infoHash=i[1].toLowerCase():(i=t.match(/^urn:btih:(.{32})/))?e.infoHash=(0,w.V5)(ot(i[1])):(i=t.match(/^urn:btmh:1220(.{64})/))&&(e.infoHashV2=i[1].toLowerCase())})}if(e.xs){(Array.isArray(e.xs)?e.xs:[e.xs]).forEach(t=>{(i=t.match(/^urn:btpk:(.{64})/))&&(e.publicKey=i[1].toLowerCase())})}return e.infoHash&&(e.infoHashBuffer=(0,w.fk)(e.infoHash)),e.infoHashV2&&(e.infoHashV2Buffer=(0,w.fk)(e.infoHashV2)),e.publicKey&&(e.publicKeyBuffer=(0,w.fk)(e.publicKey)),e.dn&&(e.name=e.dn),e.kt&&(e.keywords=e.kt),e.announce=[],(\"string\"==typeof e.tr||Array.isArray(e.tr))&&(e.announce=e.announce.concat(e.tr)),e.urlList=[],(\"string\"==typeof e.as||Array.isArray(e.as))&&(e.urlList=e.urlList.concat(e.as)),(\"string\"==typeof e.ws||Array.isArray(e.ws))&&(e.urlList=e.urlList.concat(e.ws)),e.peerAddresses=[],(\"string\"==typeof e[\"x.pe\"]||Array.isArray(e[\"x.pe\"]))&&(e.peerAddresses=e.peerAddresses.concat(e[\"x.pe\"])),e.announce=Array.from(new Set(e.announce)),e.urlList=Array.from(new Set(e.urlList)),e.peerAddresses=Array.from(new Set(e.peerAddresses)),e};async function ut(t){if(\"string\"==typeof t&&/^(stream-)?magnet:/.test(t)){const e=ht(t);if(!e.infoHash)throw new Error(\"Invalid torrent identifier\");return e}if(\"string\"==typeof t&&(/^[a-f0-9]{40}$/i.test(t)||/^[a-z2-7]{32}$/i.test(t)))return ht(`magnet:?xt=urn:btih:${t}`);if(ArrayBuffer.isView(t)&&20===t.length)return ht(`magnet:?xt=urn:btih:${(0,w.V5)(t)}`);if(ArrayBuffer.isView(t))return await async function(t){ArrayBuffer.isView(t)&&(t=f.A.decode(t));lt(t.info,\"info\"),lt(t.info[\"name.utf-8\"]||t.info.name,\"info.name\"),lt(t.info[\"piece length\"],\"info['piece length']\"),lt(t.info.pieces,\"info.pieces\"),t.info.files?t.info.files.forEach(t=>{lt(\"number\"==typeof t.length,\"info.files[0].length\"),lt(t[\"path.utf-8\"]||t.path,\"info.files[0].path\")}):lt(\"number\"==typeof t.info.length,\"info.length\");const e={info:t.info,infoBuffer:f.A.encode(t.info),name:(0,w.dU)(t.info[\"name.utf-8\"]||t.info.name),announce:[]};e.infoHashBuffer=await(0,w.tW)(e.infoBuffer),e.infoHash=(0,w.V5)(e.infoHashBuffer),void 0!==t.info.private&&(e.private=!!t.info.private);t[\"creation date\"]&&(e.created=new Date(1e3*t[\"creation date\"]));t[\"created by\"]&&(e.createdBy=(0,w.dU)(t[\"created by\"]));ArrayBuffer.isView(t.comment)&&(e.comment=(0,w.dU)(t.comment));Array.isArray(t[\"announce-list\"])&&t[\"announce-list\"].length>0?t[\"announce-list\"].forEach(t=>{t.forEach(t=>{e.announce.push((0,w.dU)(t))})}):t.announce&&e.announce.push((0,w.dU)(t.announce));ArrayBuffer.isView(t[\"url-list\"])&&(t[\"url-list\"]=t[\"url-list\"].length>0?[t[\"url-list\"]]:[]);e.urlList=(t[\"url-list\"]||[]).map(t=>(0,w.dU)(t)),e.announce=Array.from(new Set(e.announce)),e.urlList=Array.from(new Set(e.urlList));let r=0;const i=t.info.files||[t.info];e.files=i.map((t,i)=>{const n=[].concat(e.name,t[\"path.utf-8\"]||t.path||[]).map(t=>ArrayBuffer.isView(t)?(0,w.dU)(t):t);return r+=t.length,{path:h.apply(null,[u].concat(n)).slice(1),name:n[n.length-1],length:t.length,offset:r-t.length}}),e.length=r;const n=e.files[e.files.length-1];return e.pieceLength=t.info[\"piece length\"],e.lastPieceLength=(n.offset+n.length)%e.pieceLength||e.pieceLength,e.pieces=function(t){const e=[];for(let r=0;r<t.length;r+=20)e.push((0,w.V5)(t.slice(r,r+20)));return e}(t.info.pieces),e}(t);if(t&&t.infoHash)return t.infoHash=t.infoHash.toLowerCase(),t.announce||(t.announce=[]),\"string\"==typeof t.announce&&(t.announce=[t.announce]),t.urlList||(t.urlList=[]),t;throw new Error(\"Invalid torrent identifier\")}async function ft(t,e,r){if(\"function\"==typeof e)return ft(t,{},e);if(\"function\"!=typeof r)throw new Error(\"second argument must be a Function\");let i;try{i=await ut(t)}catch(t){}if(i&&i.infoHash)v(()=>{r(null,i)});else if(n=t,\"undefined\"!=typeof Blob&&n instanceof Blob)try{s(new Uint8Array(await t.arrayBuffer()))}catch(t){return r(new Error(`Error converting Blob: ${t.message}`))}else if(/^https?:/.test(t))try{const r=await nt(t,{headers:{\"user-agent\":\"WebTorrent (https://webtorrent.io)\"},signal:AbortSignal.timeout(3e4),...e});s(new Uint8Array(await r.arrayBuffer()))}catch(t){return r(new Error(`Error downloading torrent: ${t.message}`))}else\"function\"==typeof it.readFile&&\"string\"==typeof t?it.readFile(t,(t,e)=>{if(t)return r(new Error(\"Invalid torrent identifier\"));s(e)}):v(()=>{r(new Error(\"Invalid torrent identifier\"))});var n;async function s(t){try{i=await ut(t)}catch(t){return r(t)}i&&i.infoHash?r(null,i):r(new Error(\"Invalid torrent identifier\"))}}function lt(t,e){if(!t)throw new Error(`Torrent is missing required field: ${e}`)}const ct=ut,dt=function(t){t=Object.assign({},t);let e=new Set;t.xt&&\"string\"==typeof t.xt&&e.add(t.xt),t.xt&&Array.isArray(t.xt)&&(e=new Set(t.xt)),t.infoHashBuffer&&e.add(`urn:btih:${(0,w.V5)(t.infoHashBuffer)}`),t.infoHash&&e.add(`urn:btih:${t.infoHash}`),t.infoHashV2Buffer&&e.add(t.xt=`urn:btmh:1220${(0,w.V5)(t.infoHashV2Buffer)}`),t.infoHashV2&&e.add(`urn:btmh:1220${t.infoHashV2}`);const r=Array.from(e);1===r.length&&(t.xt=r[0]),r.length>1&&(t.xt=r),t.publicKeyBuffer&&(t.xs=`urn:btpk:${(0,w.V5)(t.publicKeyBuffer)}`),t.publicKey&&(t.xs=`urn:btpk:${t.publicKey}`),t.name&&(t.dn=t.name),t.keywords&&(t.kt=t.keywords),t.announce&&(t.tr=t.announce),t.urlList&&(t.ws=t.urlList,delete t.as),t.peerAddresses&&(t[\"x.pe\"]=t.peerAddresses);let i=\"magnet:?\";return Object.keys(t).filter(t=>2===t.length||\"x.pe\"===t).forEach((e,r)=>{const n=Array.isArray(t[e])?t[e]:[t[e]];var s;n.forEach((t,n)=>{(r>0||n>0)&&(\"kt\"!==e&&\"so\"!==e||0===n)&&(i+=\"&\"),\"dn\"===e&&(t=encodeURIComponent(t).replace(/%20/g,\"+\")),\"tr\"!==e&&\"as\"!==e&&\"ws\"!==e||(t=encodeURIComponent(t)),\"xs\"!==e||t.startsWith(\"urn:btpk:\")||(t=encodeURIComponent(t)),\"kt\"===e&&(t=encodeURIComponent(t)),\"so\"!==e&&(i+=\"kt\"===e&&n>0?`+${t}`:`${e}=${t}`)}),\"so\"===e&&(i+=`${e}=${s=n,s.reduce((t,e,r,i)=>(0!==r&&e===i[r-1]+1||t.push([]),t[t.length-1].push(e),t),[]).map(t=>t.length>1?`${t[0]}-${t[t.length-1]}`:`${t[0]}`)}`)}),i},pt=\"undefined\"!=typeof window?window:self,mt=pt.RTCPeerConnection||pt.mozRTCPeerConnection||pt.webkitRTCPeerConnection,gt=pt.RTCSessionDescription||pt.mozRTCSessionDescription||pt.webkitRTCSessionDescription,yt=pt.RTCIceCandidate||pt.mozRTCIceCandidate||pt.webkitRTCIceCandidate;pt.RTCIceTransport,pt.RTCDataChannel,pt.RTCSctpTransport,pt.RTCDtlsTransport,pt.RTCCertificate,pt.MediaStream,pt.MediaStreamTrack,pt.MediaStreamTrackEvent,pt.RTCPeerConnectionIceEvent,pt.RTCDataChannelEvent,pt.RTCTrackEvent,pt.RTCError,pt.RTCErrorEvent,pt.RTCRtpTransceiver,pt.RTCRtpReceiver,pt.RTCRtpSender;var bt=r(8179),vt=r(6310);const wt=L(\"simple-peer\"),_t=65536;function Mt(t){return t.replace(/a=ice-options:trickle\\s\\n/g,\"\")}class St extends bt.Duplex{_pc;constructor(t){if(super(t=Object.assign({allowHalfOpen:!1},t)),this.__objectMode=!!t.objectMode,this._id=(0,w.V5)((0,w.po)(4)).slice(0,7),this._debug(\"new peer %o\",t),this.channelName=t.initiator?t.channelName||(0,w.V5)((0,w.po)(20)):null,this.initiator=t.initiator||!1,this.channelConfig=t.channelConfig||St.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},St.config,t.config),this.offerOptions=t.offerOptions||{},this.answerOptions=t.answerOptions||{},this.sdpTransform=t.sdpTransform||(t=>t),this.trickle=void 0===t.trickle||t.trickle,this.allowHalfTrickle=void 0!==t.allowHalfTrickle&&t.allowHalfTrickle,this.iceCompleteTimeout=t.iceCompleteTimeout||5e3,this._destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,!mt)throw\"undefined\"==typeof window?vt(new Error(\"No WebRTC support: Specify `opts.wrtc` option in this environment\"),\"ERR_WEBRTC_SUPPORT\"):vt(new Error(\"No WebRTC support: Not a supported browser\"),\"ERR_WEBRTC_SUPPORT\");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new mt(this.config)}catch(t){return void this.__destroy(vt(t,\"ERR_PC_CONSTRUCTOR\"))}this._isReactNativeWebrtc=\"number\"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},\"object\"==typeof this._pc.peerIdentity&&this._pc.peerIdentity.catch(t=>{this.__destroy(vt(t,\"ERR_PC_PEER_IDENTITY\"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this._debug(\"initial negotiation\"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once(\"finish\",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&\"open\"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(t){if(!this._destroying){if(this.destroyed)throw vt(new Error(\"cannot signal after peer is destroyed\"),\"ERR_DESTROYED\");if(\"string\"==typeof t)try{t=JSON.parse(t)}catch(e){t={}}this._debug(\"signal()\"),t.renegotiate&&this.initiator&&(this._debug(\"got request to renegotiate\"),this._needsNegotiation()),t.transceiverRequest&&this.initiator&&(this._debug(\"got request for transceiver\"),this.addTransceiver(t.transceiverRequest.kind,t.transceiverRequest.init)),t.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(t.candidate):this._pendingCandidates.push(t.candidate)),t.sdp&&this._pc.setRemoteDescription(new gt(t)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],\"offer\"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(t=>{this.__destroy(vt(t,\"ERR_SET_REMOTE_DESCRIPTION\"))}),t.sdp||t.candidate||t.renegotiate||t.transceiverRequest||this.__destroy(vt(new Error(\"signal() called with invalid signal data\"),\"ERR_SIGNALING\"))}}_addIceCandidate(t){const e=new yt(t);this._pc.addIceCandidate(e).catch(t=>{var r;!e.address||e.address.endsWith(\".local\")?(r=\"Ignoring unsupported ICE candidate.\",console.warn(r)):this.__destroy(vt(t,\"ERR_ADD_ICE_CANDIDATE\"))})}send(t){if(!this._destroying){if(this.destroyed)throw vt(new Error(\"cannot send after peer is destroyed\"),\"ERR_DESTROYED\");this._channel.send(t)}}_needsNegotiation(){this._debug(\"_needsNegotiation\"),this._batchedNegotiation||(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug(\"starting batched negotiation\"),this.negotiate()):this._debug(\"non-initiator initial negotiation request discarded\"),this._firstNegotiation=!1}))}negotiate(){if(!this._destroying){if(this.destroyed)throw vt(new Error(\"cannot negotiate after peer is destroyed\"),\"ERR_DESTROYED\");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug(\"already negotiating, queueing\")):(this._debug(\"start negotiation\"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug(\"already negotiating, queueing\")):(this._debug(\"requesting negotiation from initiator\"),this.emit(\"signal\",{type:\"renegotiate\",renegotiate:!0})),this._isNegotiating=!0}}_final(t){this._readableState.ended||this.push(null),t(null)}__destroy(t){this.end(),this._destroy(()=>{},t)}_destroy(t,e){this.destroyed||this._destroying||(this._destroying=!0,this._debug(\"destroying (error: %s)\",e&&(e.message||e)),setTimeout(()=>{if(this._connected&&this.emit(\"disconnect\"),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(t){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(t){}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),t()},0))}_setupData(t){if(!t.channel)return this.__destroy(vt(new Error(\"Data channel event is missing `channel` property\"),\"ERR_DATA_CHANNEL\"));this._channel=t.channel,this._channel.binaryType=\"arraybuffer\",\"number\"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=_t),this.channelName=this._channel.label,this._channel.onmessage=t=>{this._onChannelMessage(t)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=t=>{const e=t.error instanceof Error?t.error:new Error(`Datachannel error: ${t.message} ${t.filename}:${t.lineno}:${t.colno}`);this.__destroy(vt(e,\"ERR_DATA_CHANNEL\"))};let e=!1;this._closingInterval=setInterval(()=>{this._channel&&\"closing\"===this._channel.readyState?(e&&this._onChannelClose(),e=!0):e=!1},5e3)}_write(t,e){if(this.destroyed)return e(vt(new Error(\"cannot write after peer is destroyed\"),\"ERR_DATA_CHANNEL\"));if(this._connected){try{this.send(t)}catch(t){return this.__destroy(vt(t,\"ERR_DATA_CHANNEL\"))}this._channel.bufferedAmount>_t?(this._debug(\"start backpressure: bufferedAmount %d\",this._channel.bufferedAmount),this._cb=e):e(null)}else this._debug(\"write before connect\"),this._chunk=t,this._cb=e}_onFinish(){if(this.destroyed)return;const t=()=>{setTimeout(()=>this.__destroy(),1e3)};this._connected?t():this.once(\"connect\",t)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug(\"started iceComplete timeout\"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug(\"iceComplete timeout completed\"),this.emit(\"iceTimeout\"),this.emit(\"_iceComplete\"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(t=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(t.sdp=Mt(t.sdp)),t.sdp=this.sdpTransform(t.sdp);const e=()=>{if(this.destroyed)return;const e=this._pc.localDescription||t;this._debug(\"signal\"),this.emit(\"signal\",{type:e.type,sdp:e.sdp})};this._pc.setLocalDescription(t).then(()=>{this._debug(\"createOffer success\"),this.destroyed||(this.trickle||this._iceComplete?e():this.once(\"_iceComplete\",e))}).catch(t=>{this.__destroy(vt(t,\"ERR_SET_LOCAL_DESCRIPTION\"))})}).catch(t=>{this.__destroy(vt(t,\"ERR_CREATE_OFFER\"))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(t=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(t.sdp=Mt(t.sdp)),t.sdp=this.sdpTransform(t.sdp);const e=()=>{if(this.destroyed)return;const e=this._pc.localDescription||t;this._debug(\"signal\"),this.emit(\"signal\",{type:e.type,sdp:e.sdp}),this.initiator||this._requestMissingTransceivers?.()};this._pc.setLocalDescription(t).then(()=>{this.destroyed||(this.trickle||this._iceComplete?e():this.once(\"_iceComplete\",e))}).catch(t=>{this.__destroy(vt(t,\"ERR_SET_LOCAL_DESCRIPTION\"))})}).catch(t=>{this.__destroy(vt(t,\"ERR_CREATE_ANSWER\"))})}_onConnectionStateChange(){this.destroyed||this._destroying||\"failed\"===this._pc.connectionState&&this.__destroy(vt(new Error(\"Connection failed.\"),\"ERR_CONNECTION_FAILURE\"))}_onIceStateChange(){if(this.destroyed)return;const t=this._pc.iceConnectionState,e=this._pc.iceGatheringState;this._debug(\"iceStateChange (connection: %s) (gathering: %s)\",t,e),this.emit(\"iceStateChange\",t,e),\"connected\"!==t&&\"completed\"!==t||(this._pcReady=!0,this._maybeReady()),\"failed\"===t&&this.__destroy(vt(new Error(\"Ice connection failed.\"),\"ERR_ICE_CONNECTION_FAILURE\")),\"closed\"===t&&this.__destroy(vt(new Error(\"Ice connection closed.\"),\"ERR_ICE_CONNECTION_CLOSED\"))}getStats(t){const e=t=>(\"[object Array]\"===Object.prototype.toString.call(t.values)&&t.values.forEach(e=>{Object.assign(t,e)}),t);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(r=>{const i=[];r.forEach(t=>{i.push(e(t))}),t(null,i)},e=>t(e)):this._pc.getStats.length>0?this._pc.getStats(r=>{if(this.destroyed)return;const i=[];r.result().forEach(t=>{const r={};t.names().forEach(e=>{r[e]=t.stat(e)}),r.id=t.id,r.type=t.type,r.timestamp=t.timestamp,i.push(e(r))}),t(null,i)},e=>t(e)):t(null,[])}_maybeReady(){if(this._debug(\"maybeReady pc %s channel %s\",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const t=()=>{this.destroyed||this._destroying||this.getStats((e,r)=>{if(this.destroyed||this._destroying)return;e&&(r=[]);const i={},n={},s={};let o=!1;r.forEach(t=>{\"remotecandidate\"!==t.type&&\"remote-candidate\"!==t.type||(i[t.id]=t),\"localcandidate\"!==t.type&&\"local-candidate\"!==t.type||(n[t.id]=t),\"candidatepair\"!==t.type&&\"candidate-pair\"!==t.type||(s[t.id]=t)});const a=t=>{o=!0;let e=n[t.localCandidateId];e&&(e.ip||e.address)?(this.localAddress=e.ip||e.address,this.localPort=Number(e.port)):e&&e.ipAddress?(this.localAddress=e.ipAddress,this.localPort=Number(e.portNumber)):\"string\"==typeof t.googLocalAddress&&(e=t.googLocalAddress.split(\":\"),this.localAddress=e[0],this.localPort=Number(e[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(\":\")?\"IPv6\":\"IPv4\");let r=i[t.remoteCandidateId];r&&(r.ip||r.address)?(this.remoteAddress=r.ip||r.address,this.remotePort=Number(r.port)):r&&r.ipAddress?(this.remoteAddress=r.ipAddress,this.remotePort=Number(r.portNumber)):\"string\"==typeof t.googRemoteAddress&&(r=t.googRemoteAddress.split(\":\"),this.remoteAddress=r[0],this.remotePort=Number(r[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(\":\")?\"IPv6\":\"IPv4\"),this._debug(\"connect local: %s:%s remote: %s:%s\",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(r.forEach(t=>{\"transport\"===t.type&&t.selectedCandidatePairId&&a(s[t.selectedCandidatePairId]),(\"googCandidatePair\"===t.type&&\"true\"===t.googActiveConnection||(\"candidatepair\"===t.type||\"candidate-pair\"===t.type)&&t.selected)&&a(t)}),o||Object.keys(s).length&&!Object.keys(n).length){if(this._connecting=!1,this._connected=!0,this.emit(\"connect\"),this._chunk){try{this.send(this._chunk)}catch(e){return this.__destroy(vt(e,\"ERR_DATA_CHANNEL\"))}this._chunk=null,this._debug('sent chunk from \"write before connect\"');const t=this._cb;this._cb=null,t(null)}\"number\"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug(\"connect\"),this.emit(\"connect\")}else setTimeout(t,100)})};t()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>_t||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(\"stable\"===this._pc.signalingState&&(this._isNegotiating=!1,this._debug(\"flushing sender queue\",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(t=>{this._pc.removeTrack(t),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug(\"flushing negotiation queue\"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug(\"negotiated\"),this.emit(\"negotiated\"))),this._debug(\"signalingStateChange %s\",this._pc.signalingState),this.emit(\"signalingStateChange\",this._pc.signalingState))}_onIceCandidate(t){this.destroyed||(t.candidate&&this.trickle?this.emit(\"signal\",{type:\"candidate\",candidate:{candidate:t.candidate.candidate,sdpMLineIndex:t.candidate.sdpMLineIndex,sdpMid:t.candidate.sdpMid}}):t.candidate||this._iceComplete||(this._iceComplete=!0,this.emit(\"_iceComplete\")),t.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(t){if(this.destroyed)return;let e=t.data;e instanceof ArrayBuffer?e=new Uint8Array(e):!1===this.__objectMode&&(e=(0,w.L0)(e)),this.push(e)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug(\"ending backpressure: bufferedAmount %d\",this._channel.bufferedAmount);const t=this._cb;this._cb=null,t(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug(\"on channel open\"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug(\"on channel close\"),this.__destroy())}_debug(){const t=[].slice.call(arguments);t[0]=\"[\"+this._id+\"] \"+t[0],wt.apply(null,t)}}St.WEBRTC_SUPPORT=!!mt,St.config={iceServers:[{urls:[\"stun:stun.l.google.com:19302\",\"stun:global.stun.twilio.com:3478\"]}],sdpSemantics:\"unified-plan\"},St.channelConfig={};const kt=St;var Et=r(1035),xt=r(7541),At=r(3278),It=r(8957),Tt=r(5658),Ct=r(4343);const Pt=L(\"webtorrent:conn-pool\");class Rt{constructor(t){Pt(\"create pool (port %s)\",t.torrentPort),this._client=t,this._pendingConns=new Set,this._onTCPConnectionBound=t=>{this._onConnection(t,\"tcp\")},this._onUTPConnectionBound=t=>{this._onConnection(t,\"utp\")},this._onListening=()=>{this._client._onListening()},this._onTCPError=t=>{this._client._destroy(t)},this._onUTPError=t=>{this._client.utp=!1,this._client.emit(\"error\",t),this._client.listening||this._onListening()},this.tcpServer=It.createServer(),this.tcpServer.on(\"connection\",this._onTCPConnectionBound),this.tcpServer.on(\"error\",this._onTCPError),this.tcpServer.listen(t.torrentPort,()=>{Pt(\"creating tcpServer in port %s\",this.tcpServer.address().port),this._client.utp?(this.utpServer=Ct.createServer(),this.utpServer.on(\"connection\",this._onUTPConnectionBound),this.utpServer.on(\"listening\",this._onListening),this.utpServer.on(\"error\",this._onUTPError),Pt(\"creating utpServer in port %s\",this.tcpServer.address().port),this.utpServer.listen(this.tcpServer.address().port)):this._onListening()})}destroy(t){if(Pt(\"destroy conn pool\"),this.utpServer&&(this.utpServer.removeListener(\"connection\",this._onUTPConnectionBound),this.utpServer.removeListener(\"listening\",this._onListening),this.utpServer.removeListener(\"error\",this._onUTPError)),this.tcpServer.removeListener(\"connection\",this._onTCPConnectionBound),this.tcpServer.removeListener(\"error\",this._onTCPError),this._pendingConns.forEach(t=>{t.on(\"error\",Ot),t.destroy()}),this.utpServer)try{this.utpServer.close(t)}catch(e){t&&v(t)}try{this.tcpServer.close(t)}catch(e){t&&v(t)}this.tcpServer=null,this.utpServer=null,this._client=null,this._pendingConns=null}_onConnection(t,e){const r=this;if(!t.remoteAddress)return t.on(\"error\",Ot),void t.destroy();r._pendingConns.add(t),t.once(\"close\",o);const i=\"utp\"===e?Tt.A.createUTPIncomingPeer(t,this._client.throttleGroups):Tt.A.createTCPIncomingPeer(t,this._client.throttleGroups),n=i.wire;async function s(t,e){o();const n=await r._client.get(t);if(n)i.swarm||(i.swarm=n,n._addIncomingPeer(i)),i.onHandshake(t,e);else{const e=new Error(`Unexpected info hash ${t} from incoming peer ${i.id}`);i.destroy(e)}}function o(){t.removeListener(\"close\",o),n.removeListener(\"handshake\",s),r._pendingConns&&r._pendingConns.delete(t)}n.once(\"pe3\",async function(t){const e=await r._client._getByHash(t);e?(i.swarm=e,e._addIncomingPeer(i),i.onPe3(t)):i.destroy(new Error(`Unexpected info hash hash ${t} from incoming peer ${i.id}`))}),n.once(\"handshake\",s)}}function Ot(){}Rt.UTP_SUPPORT=Object.keys(Ct).length>0;var Bt=r(6686),Lt=r(6889);const Nt=/^\\[?([^\\]]+)]?:(\\d+)$/;let jt=new Map;function Ut(t){if(1e5===jt.size&&jt.clear(),!jt.has(t)){const e=Nt.exec(t);if(!e)throw new Error(`invalid addr: ${t}`);jt.set(t,[e[1],Number(e[2])])}return jt.get(t)}var qt=r(3033),Dt=r(4497);async function*Ht(t,e={}){if(t?.[Symbol.asyncIterator])return void(yield*t[Symbol.asyncIterator](e.offset));if(!t?.get)throw new Error(\"First argument must be an abstract-chunk-store compliant store\");const r=e.chunkLength||t.chunkLength;if(!r)throw new Error(\"missing required `chunkLength` property\");let i=e.length||t.length;if(!Number.isFinite(i))throw new Error(\"missing required `length` property\");const n=e.offset||0,s=(e,r,i)=>new Promise((n,s)=>{t.get(e,{offset:i,length:r},(t,e)=>{t&&s(t),n(e)})});let o=Math.floor(n/r);const a=n%r;if(n){const t=Math.min(i,r-a);i-=t,yield s(o++,t,a)}for(let t=i;t>0;++o,t-=r)yield s(o,Math.min(t,r))}async function Ft(t,e,r={}){if(!t?.put)throw new Error(\"First argument must be an abstract-chunk-store compliant store\");const i=r.chunkLength||t.chunkLength;if(!i)throw new Error(\"missing required `chunkLength` property\");const n=r.storeMaxOutstandingPuts||16;let s=0,o=0,a=()=>{},h=!1;for await(const u of l(e,i,{zeroPadding:r.zeroPadding||!1}))await new Promise((e,r)=>{s++<=n&&e(),t.put(o++,u,t=>{if(t)return r(t);--s,e(),h&&0===s&&a()})});0!==s&&(h=new Promise(t=>{a=t}),await h)}var zt=r(4018),Wt=r(7186);const $t=/^[\\d.]+$/,Vt=/^[\\da-fA-F:]+$/,Kt=/^::ffff:/,Zt=(0,w.xW)([ee(1047),ee(655366528)]),Gt={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3},Yt={update:0,completed:1,started:2,stopped:3,paused:4},Jt={0:\"update\",1:\"completed\",2:\"started\",3:\"stopped\",4:\"paused\"},Xt={update:\"update\",completed:\"complete\",started:\"start\",stopped:\"stop\",paused:\"pause\"},Qt=15e3,te=1e3;function ee(t){const e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t),e}const re=t=>Wt.parse(t,null,null,{decodeURIComponent:unescape}),ie=t=>{let e=Wt.stringify(t,null,null,{encodeURIComponent:escape});return e=e.replace(/[@*/+]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),e},ne={DEFAULT_ANNOUNCE_PEERS:50,MAX_ANNOUNCE_PEERS:82,parseUrl:t=>{const e=new URL(t.replace(/^udp:/,\"http:\"));return t.match(/^udp:/)&&Object.defineProperties(e,{href:{value:e.href.replace(/^http/,\"udp\")},protocol:{value:e.protocol.replace(/^http/,\"udp\")},origin:{value:e.origin.replace(/^http/,\"udp\")}}),e},...i};var se=r(1314);const oe=class extends n{constructor(t,e){super(),this.client=t,this.announceUrl=e,this.interval=null,this.destroyed=!1}setInterval(t){null==t&&(t=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),t&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},t),this.interval.unref&&this.interval.unref())}};var ae=r(2085),he=r(8287).Buffer;const ue=L(\"bittorrent-tracker:http-tracker\"),fe=/\\/(announce)[^/]*$/;class le extends oe{constructor(t,e){super(t,e),ue(\"new http tracker %s\",e),this.scrapeUrl=null;const r=this.announceUrl.match(fe);if(r){const t=this.announceUrl.slice(0,r.index),e=this.announceUrl.slice(r.index+9);this.scrapeUrl=`${t}/scrape${e}`}this.cleanupFns=[],this.maybeDestroyCleanup=null}announce(t){if(this.destroyed)return;const e=Object.assign({},t,{compact:null==t.compact?1:t.compact,info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,port:this.client._port});0===e.left||e.left||(e.left=16384),this._trackerId&&(e.trackerid=this._trackerId),this._request(this.announceUrl,e,(t,e)=>{if(t)return this.client.emit(\"warning\",t);this._onAnnounceResponse(e)})}scrape(t){if(this.destroyed)return;if(!this.scrapeUrl)return void this.client.emit(\"error\",new Error(`scrape not supported ${this.announceUrl}`));const e={info_hash:Array.isArray(t.infoHash)&&t.infoHash.length>0?t.infoHash.map(t=>(0,w.Ht)(t)):t.infoHash&&(0,w.Ht)(t.infoHash)||this.client._infoHashBinary};this._request(this.scrapeUrl,e,(t,e)=>{if(t)return this.client.emit(\"warning\",t);this._onScrapeResponse(e)})}destroy(t){const e=this;if(this.destroyed)return t(null);let r;if(this.destroyed=!0,clearInterval(this.interval),0===this.cleanupFns.length)return i();function i(){r&&(clearTimeout(r),r=null),e.maybeDestroyCleanup=null,e.cleanupFns.slice(0).forEach(t=>{t()}),e.cleanupFns=[],t(null)}r=setTimeout(i,ne.DESTROY_TIMEOUT),this.maybeDestroyCleanup=()=>{0===this.cleanupFns.length&&i()}}async _request(t,e,r){const i=new URL(t+(-1===t.indexOf(\"?\")?\"?\":\"&\")+ne.querystringStringify(e));let n;this.client._proxyOpts&&(n=\"https:\"===i.protocol?this.client._proxyOpts.httpsAgent:this.client._proxyOpts.httpAgent,!n&&this.client._proxyOpts.socksProxy&&(n=this.client._proxyOpts.socksProxy));const s=()=>{a.signal.aborted||(se(this.cleanupFns,this.cleanupFns.indexOf(s)),a.abort(),a=null),this.maybeDestroyCleanup&&this.maybeDestroyCleanup()};let o;this.cleanupFns.push(s);let a=function(t){const e=new AbortController;return setTimeout(()=>{e.abort()},t).unref?.(),e}(ne.REQUEST_TIMEOUT);try{o=await nt(i.toString(),{agent:n,signal:a.signal,dispatcher:n,headers:{\"user-agent\":this.client._userAgent||\"\"}}),o.body.on&&o.body.on(\"error\",r)}catch(t){if(t)return r(t)}let h=new Uint8Array(await o.arrayBuffer());if(s(),this.destroyed)return;if(200!==o.status)return r(new Error(`Non-200 response code ${o.status} from ${this.announceUrl}`));if(!h||0===h.length)return r(new Error(`Invalid tracker response from${this.announceUrl}`));try{h=f.A.decode(h)}catch(t){return r(new Error(`Error decoding tracker response: ${t.message}`))}const u=h[\"failure reason\"]&&(0,w.dU)(h[\"failure reason\"]);if(u)return ue(`failure from ${t} (${u})`),r(new Error(u));const l=h[\"warning message\"]&&(0,w.dU)(h[\"warning message\"]);l&&(ue(`warning from ${t} (${l})`),this.client.emit(\"warning\",new Error(l))),ue(`response from ${t}`),r(null,h)}_onAnnounceResponse(t){const e=t.interval||t[\"min interval\"];e&&this.setInterval(1e3*e);const r=t[\"tracker id\"];r&&(this._trackerId=r);const i=Object.assign({},t,{announce:this.announceUrl,infoHash:(0,w.HB)(t.info_hash||String(t.info_hash))});let n;if(this.client.emit(\"update\",i),ArrayBuffer.isView(t.peers)){try{n=ae.multi(he.from(t.peers))}catch(t){return this.client.emit(\"warning\",t)}n.forEach(t=>{this.client.emit(\"peer\",t)})}else Array.isArray(t.peers)&&t.peers.forEach(t=>{this.client.emit(\"peer\",`${t.ip}:${t.port}`)});if(ArrayBuffer.isView(t.peers6)){try{n=ae.multi6(he.from(t.peers6))}catch(t){return this.client.emit(\"warning\",t)}n.forEach(t=>{this.client.emit(\"peer\",t)})}else Array.isArray(t.peers6)&&t.peers6.forEach(t=>{const e=/^\\[/.test(t.ip)||!/:/.test(t.ip)?t.ip:`[${t.ip}]`;this.client.emit(\"peer\",`${e}:${t.port}`)})}_onScrapeResponse(t){t=t.files||t.host||{};const e=Object.keys(t);0!==e.length?e.forEach(e=>{const r=20!==e.length?(0,w.V5)((0,w.L0)(e)):(0,w.HB)(e),i=Object.assign(t[e],{announce:this.announceUrl,infoHash:r});this.client.emit(\"scrape\",i)}):this.client.emit(\"warning\",new Error(\"invalid scrape response\"))}}le.prototype.DEFAULT_ANNOUNCE_INTERVAL=18e5;const ce=le;var de=r(7861),pe=r(4835);const me=L(\"bittorrent-tracker:udp-tracker\");class ge extends oe{constructor(t,e){super(t,e),me(\"new udp tracker %s\",e),this.cleanupFns=[],this.maybeDestroyCleanup=null}announce(t){this.destroyed||this._request(t)}scrape(t){this.destroyed||(t._scrape=!0,this._request(t))}destroy(t){const e=this;if(this.destroyed)return t(null);let r;if(this.destroyed=!0,clearInterval(this.interval),0===this.cleanupFns.length)return i();function i(){r&&(clearTimeout(r),r=null),e.maybeDestroyCleanup=null,e.cleanupFns.slice(0).forEach(t=>{t()}),e.cleanupFns=[],t(null)}r=setTimeout(i,ne.DESTROY_TIMEOUT),this.maybeDestroyCleanup=()=>{0===this.cleanupFns.length&&i()}}_request(t){const e=this;t||(t={});let r,i,n,s,{hostname:o,port:a}=ne.parseUrl(this.announceUrl);\"\"===a&&(a=80);let h=ye();const u=this.client._proxyOpts&&(f=this.client._proxyOpts.socksProxy,JSON.parse(JSON.stringify(f)));var f;function l(e,o,a){if(e)return d(e);i=o,n=de.createSocket(\"udp4\"),s=a,r=setTimeout(()=>{\"stopped\"===t.event?c():d(new Error(`tracker request timed out (${t.event})`)),r=null},ne.REQUEST_TIMEOUT),r.unref&&r.unref(),m((0,w.xW)([ne.CONNECTION_ID,ne.toUInt32(ne.ACTIONS.CONNECT),h]),s),n.once(\"error\",d),n.on(\"message\",p)}function c(){if(r&&(clearTimeout(r),r=null),n){se(e.cleanupFns,e.cleanupFns.indexOf(c)),n.removeListener(\"error\",d),n.removeListener(\"message\",p),n.on(\"error\",_e);try{n.close()}catch(t){}if(n=null,i){try{i.close()}catch(t){}i=null}}e.maybeDestroyCleanup&&e.maybeDestroyCleanup()}function d(t){if(c(),!e.destroyed){try{t.message&&(t.message+=` (${e.announceUrl})`)}catch(t){}e.client.emit(\"warning\",t)}}function p(r){i&&(r=r.slice(10));const n=new DataView(h.buffer);if(r.length<8||r.readUInt32BE(4)!==n.getUint32(0))return d(new Error(\"tracker sent invalid transaction id\"));const o=r.readUInt32BE(0);switch(me(\"UDP response %s, action %s\",e.announceUrl,o),o){case 0:if(r.length<16)return d(new Error(\"invalid udp handshake\"));t._scrape?function(r){h=ye();const i=Array.isArray(t.infoHash)&&t.infoHash.length>0?(0,w.xW)(t.infoHash):t.infoHash||e.client._infoHashBuffer;m((0,w.xW)([r,ne.toUInt32(ne.ACTIONS.SCRAPE),h,i]),s)}(r.slice(8,16)):function(t,r){h=ye(),m((0,w.xW)([t,ne.toUInt32(ne.ACTIONS.ANNOUNCE),h,e.client._infoHashBuffer,e.client._peerIdBuffer,we(r.downloaded),null!=r.left?we(r.left):(0,w.fk)(\"ffffffffffffffff\"),we(r.uploaded),ne.toUInt32(ne.EVENTS[r.event]||0),ne.toUInt32(0),ne.toUInt32(0),ne.toUInt32(r.numwant),be(e.client._port)]),s)}(r.slice(8,16),t);break;case 1:{if(c(),e.destroyed)return;if(r.length<20)return d(new Error(\"invalid announce message\"));const t=r.readUInt32BE(8);let i;t&&e.setInterval(1e3*t),e.client.emit(\"update\",{announce:e.announceUrl,complete:r.readUInt32BE(16),incomplete:r.readUInt32BE(12)});try{i=ae.multi(r.slice(20))}catch(t){return e.client.emit(\"warning\",t)}i.forEach(t=>{e.client.emit(\"peer\",t)});break}case 2:{if(c(),e.destroyed)return;if(r.length<20||(r.length-8)%12!=0)return d(new Error(\"invalid scrape message\"));const i=Array.isArray(t.infoHash)&&t.infoHash.length>0?t.infoHash.map(t=>t.toString(\"hex\")):[t.infoHash&&t.infoHash.toString(\"hex\")||e.client.infoHash];for(let t=0,n=(r.length-8)/12;t<n;t+=1)e.client.emit(\"scrape\",{announce:e.announceUrl,infoHash:i[t],complete:r.readUInt32BE(8+12*t),downloaded:r.readUInt32BE(12+12*t),incomplete:r.readUInt32BE(16+12*t)});break}case 3:if(c(),e.destroyed)return;if(r.length<8)return d(new Error(\"invalid error message\"));e.client.emit(\"warning\",new Error(r.slice(8).toString()));break;default:d(new Error(\"tracker sent invalid action\"))}}function m(t,e){if(e){const r=pe.createUDPFrame({host:o,port:a},t);n.send(r,0,r.length,e.port,e.host)}else n.send(t,0,t.length,a,o)}u?(u.proxy||(u.proxy={}),u.proxy.command=\"associate\",u.target||(u.target={host:\"0.0.0.0\",port:0}),5===u.proxy.type?pe.createConnection(u,l):(me(\"Ignoring Socks proxy for UDP request because type 5 is required\"),l(null))):l(null),this.cleanupFns.push(c)}}function ye(){return(0,w.po)(4)}function be(t){const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t),e}ge.prototype.DEFAULT_ANNOUNCE_INTERVAL=18e5;const ve=4294967295;function we(t){if(t>ve||\"string\"==typeof t){const e=new Uint8Array(8);return new DataView(e.buffer).setBigUint64(0,BigInt(t)),e}return(0,w.xW)([new Uint8Array(4),ne.toUInt32(t)])}function _e(){}const Me=ge;var Se=r(1591);const ke=L(\"simple-websocket\"),Ee=\"function\"!=typeof Se?WebSocket:Se;class xe extends bt.Duplex{constructor(t={}){if(\"string\"==typeof t&&(t={url:t}),super(t=Object.assign({allowHalfOpen:!1},t)),this.__objectMode=!!t.objectMode,null!=t.objectMode&&delete t.objectMode,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=(0,w.V5)((0,w.po)(4)).slice(0,7),this._debug(\"new websocket: %o\",t),this.connected=!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===Ee.OPEN;else{this.url=t.url;try{this._ws=\"function\"==typeof Se?new Ee(t.url,{...t,encoding:void 0}):new Ee(t.url)}catch(t){return void v(()=>this.destroy(t))}}this._ws.binaryType=\"arraybuffer\",t.socket&&this.connected?v(()=>this._handleOpen()):this._ws.onopen=()=>this._handleOpen(),this._ws.onmessage=t=>this._handleMessage(t),this._ws.onclose=()=>this._handleClose(),this._ws.onerror=t=>this._handleError(t),this._handleFinishBound=()=>this._handleFinish(),this.once(\"finish\",this._handleFinishBound)}send(t){this._ws.send(t)}_final(t){this._readableState.ended||this.push(null),t(null)}_destroy(t){if(!this.destroyed){if(this._writableState.ended||this.end(),this.connected=!1,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._handleFinishBound&&this.removeListener(\"finish\",this._handleFinishBound),this._handleFinishBound=null,this._ws){const t=this._ws,e=()=>{t.onclose=null};if(t.readyState===Ee.CLOSED)e();else try{t.onclose=e,t.close()}catch(t){e()}t.onopen=null,t.onmessage=null,t.onerror=()=>{}}this._ws=null,t()}}_write(t,e){if(this.destroyed)return e(new Error(\"cannot write after socket is destroyed\"));if(this.connected){try{this.send(t)}catch(t){return this.destroy(t)}\"function\"!=typeof Se&&this._ws.bufferedAmount>65536?(this._debug(\"start backpressure: bufferedAmount %d\",this._ws.bufferedAmount),this._cb=e):e(null)}else this._debug(\"write before connect\"),this._chunk=t,this._cb=e}_handleOpen(){if(!this.connected&&!this.destroyed){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(t){return this.destroy(t)}this._chunk=null,this._debug('sent chunk from \"write before connect\"');const t=this._cb;this._cb=null,t(null)}\"function\"!=typeof Se&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug(\"connect\"),this.emit(\"connect\")}}_handleMessage(t){if(this.destroyed)return;let e=t.data;e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!1===this.__objectMode&&(e=(0,w.L0)(e)),this.push(e)}_handleClose(){this.destroyed||(this._debug(\"on close\"),this.destroy())}_handleError(t){this.destroy(new Error(`Error connecting to ${this.url}`))}_handleFinish(){if(this.destroyed)return;const t=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?t():this.once(\"connect\",t)}_onInterval(){if(!this._cb||!this._ws||this._ws.bufferedAmount>65536)return;this._debug(\"ending backpressure: bufferedAmount %d\",this._ws.bufferedAmount);const t=this._cb;this._cb=null,t(null)}_debug(){const t=[].slice.call(arguments);t[0]=\"[\"+this._id+\"] \"+t[0],ke.apply(null,t)}}xe.WEBSOCKET_SUPPORT=!!Ee;const Ae=L(\"bittorrent-tracker:websocket-tracker\"),Ie={};class Te extends oe{constructor(t,e){super(t,e),Ae(\"new websocket tracker %s\",e),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(t){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once(\"connect\",()=>{this.announce(t)});const e=Object.assign({},t,{action:\"announce\",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(e.trackerid=this._trackerId),\"stopped\"===t.event||\"completed\"===t.event)this._send(e);else{const r=Math.min(t.numwant,5);this._generateOffers(r,t=>{e.numwant=r,e.offers=t,this._send(e)})}}scrape(t){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once(\"connect\",()=>{this.scrape(t)});const e={action:\"scrape\",info_hash:Array.isArray(t.infoHash)&&t.infoHash.length>0?t.infoHash.map(t=>(0,w.Ht)(t)):t.infoHash&&(0,w.Ht)(t.infoHash)||this.client._infoHashBinary};this._send(e)}destroy(t=Ce){if(this.destroyed)return t(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const t in this.peers){const e=this.peers[t];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,Ie[this.announceUrl]&&(Ie[this.announceUrl].consumers-=1),Ie[this.announceUrl].consumers>0)return t();let e,r=Ie[this.announceUrl];if(delete Ie[this.announceUrl],r.on(\"error\",Ce),r.once(\"close\",t),!this.expectingResponse)return i();function i(){e&&(clearTimeout(e),e=null),r.removeListener(\"data\",i),r.destroy(),r=null}e=setTimeout(i,ne.DESTROY_TIMEOUT),r.once(\"data\",i)}_openSocket(){if(this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=t=>{this._onSocketError(t)},this._onSocketDataBound=t=>{this._onSocketData(t)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=Ie[this.announceUrl],this.socket)Ie[this.announceUrl].consumers+=1,this.socket.connected&&this._onSocketConnectBound();else{const t=new URL(this.announceUrl);let e;this.client._proxyOpts&&(e=\"wss:\"===t.protocol?this.client._proxyOpts.httpsAgent:this.client._proxyOpts.httpAgent,!e&&this.client._proxyOpts.socksProxy&&(e=this.client._proxyOpts.socksProxy)),this.socket=Ie[this.announceUrl]=new xe({url:this.announceUrl,agent:e}),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(t){if(!this.destroyed){this.expectingResponse=!1;try{t=JSON.parse((0,w.dU)(t))}catch(t){return void this.client.emit(\"warning\",new Error(\"Invalid tracker response\"))}\"announce\"===t.action?this._onAnnounceResponse(t):\"scrape\"===t.action?this._onScrapeResponse(t):this._onSocketError(new Error(`invalid action in WS response: ${t.action}`))}}_onAnnounceResponse(t){if(t.info_hash!==this.client._infoHashBinary)return void Ae(\"ignoring websocket data from %s for %s (looking for %s: reused socket)\",this.announceUrl,(0,w.HB)(t.info_hash),this.client.infoHash);if(t.peer_id&&t.peer_id===this.client._peerIdBinary)return;Ae(\"received %s from %s for %s\",JSON.stringify(t),this.announceUrl,this.client.infoHash);const e=t[\"failure reason\"];if(e)return this.client.emit(\"warning\",new Error(e));const r=t[\"warning message\"];r&&this.client.emit(\"warning\",new Error(r));const i=t.interval||t[\"min interval\"];i&&this.setInterval(1e3*i);const n=t[\"tracker id\"];if(n&&(this._trackerId=n),null!=t.complete){const e=Object.assign({},t,{announce:this.announceUrl,infoHash:(0,w.HB)(t.info_hash)});this.client.emit(\"update\",e)}let s;if(t.offer&&t.peer_id&&(Ae(\"creating peer (from remote offer)\"),s=this._createPeer(),s.id=(0,w.HB)(t.peer_id),s.once(\"signal\",e=>{const r={action:\"announce\",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:t.peer_id,answer:e,offer_id:t.offer_id};this._trackerId&&(r.trackerid=this._trackerId),this._send(r)}),this.client.emit(\"peer\",s),s.signal(t.offer)),t.answer&&t.peer_id){const e=(0,w.HB)(t.offer_id);s=this.peers[e],s?(s.id=(0,w.HB)(t.peer_id),this.client.emit(\"peer\",s),s.signal(t.answer),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete this.peers[e]):Ae(`got unexpected answer: ${JSON.stringify(t.answer)}`)}}_onScrapeResponse(t){t=t.files||{};const e=Object.keys(t);0!==e.length?e.forEach(e=>{const r=Object.assign(t[e],{announce:this.announceUrl,infoHash:(0,w.HB)(e)});this.client.emit(\"scrape\",r)}):this.client.emit(\"warning\",new Error(\"invalid scrape response\"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(t){this.destroyed||(this.destroy(),this.client.emit(\"warning\",t),this._startReconnectTimer())}_startReconnectTimer(){const t=Math.floor(3e5*Math.random())+Math.min(1e4*Math.pow(2,this.retries),36e5);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},t),this.reconnectTimer.unref&&this.reconnectTimer.unref(),Ae(\"reconnecting socket in %s ms\",t)}_send(t){if(this.destroyed)return;this.expectingResponse=!0;const e=JSON.stringify(t);Ae(\"send %s\",e),this.socket.send(e)}_generateOffers(t,e){const r=this,i=[];Ae(\"generating %s offers\",t);for(let e=0;e<t;++e)n();function n(){const t=(0,w.V5)((0,w.po)(20));Ae(\"creating peer (from _generateOffers)\");const e=r.peers[t]=r._createPeer({initiator:!0});e.once(\"signal\",e=>{i.push({offer:e,offer_id:(0,w.Ht)(t)}),s()}),e.trackerTimeout=setTimeout(()=>{Ae(\"tracker timeout: destroying peer\"),e.trackerTimeout=null,delete r.peers[t],e.destroy()},5e4),e.trackerTimeout.unref&&e.trackerTimeout.unref()}function s(){i.length===t&&(Ae(\"generated %s offers\",t),e(i))}s()}_createPeer(t){const e=this;t=Object.assign({trickle:!1,config:e.client._rtcConfig,wrtc:e.client._wrtc},t);const r=new kt(t);return r.once(\"error\",i),r.once(\"connect\",function t(){r.removeListener(\"error\",i),r.removeListener(\"connect\",t)}),r;function i(t){e.client.emit(\"warning\",new Error(`Connection error: ${t.message}`)),r.destroy()}}}function Ce(){}Te.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,Te._socketPool=Ie;const Pe=Te;var Re=r(717);const Oe=L(\"bittorrent-tracker:client\");class Be 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(!t.announce)throw new Error(\"Option `announce` is required\");if(!Re.browser&&!t.port)throw new Error(\"Option `port` is required\");this.peerId=\"string\"==typeof t.peerId?t.peerId:(0,w.V5)(t.peerId),this._peerIdBuffer=(0,w.fk)(this.peerId),this._peerIdBinary=(0,w.Ht)(this.peerId),this.infoHash=\"string\"==typeof t.infoHash?t.infoHash.toLowerCase():(0,w.V5)(t.infoHash),this._infoHashBuffer=(0,w.fk)(this.infoHash),this._infoHashBinary=(0,w.Ht)(this.infoHash),Oe(\"new client %s\",this.infoHash),this.destroyed=!1,this._port=t.port,this._getAnnounceOpts=t.getAnnounceOpts,this._rtcConfig=t.rtcConfig,this._userAgent=t.userAgent,this._proxyOpts=t.proxyOpts,this._wrtc=\"function\"==typeof t.wrtc?t.wrtc():t.wrtc;let e=\"string\"==typeof t.announce?[t.announce]:null==t.announce?[]:t.announce;e=e.map(t=>(ArrayBuffer.isView(t)&&(t=(0,w.dU)(t)),\"/\"===t[t.length-1]&&(t=t.substring(0,t.length-1)),t)),e=Array.from(new Set(e));const r=!1!==this._wrtc&&(!!this._wrtc||kt.WEBRTC_SUPPORT),i=t=>{v(()=>{this.emit(\"warning\",t)})};this._trackers=e.map(t=>{let e;try{e=ne.parseUrl(t)}catch(e){return i(new Error(`Invalid tracker URL: ${t}`)),null}const n=e.port;if(n<0||n>65535)return i(new Error(`Invalid tracker port: ${t}`)),null;const s=e.protocol;return\"http:\"!==s&&\"https:\"!==s||\"function\"!=typeof ce?\"udp:\"===s&&\"function\"==typeof Me?new Me(this,t):\"ws:\"!==s&&\"wss:\"!==s||!r||\"ws:\"===s&&\"undefined\"!=typeof window&&\"https:\"===window.location.protocol?(i(new Error(`Unsupported tracker protocol: ${t}`)),null):new Pe(this,t):new ce(this,t)}).filter(Boolean)}start(t){(t=this._defaultAnnounceOpts(t)).event=\"started\",Oe(\"send `start` %o\",t),this._announce(t),this._trackers.forEach(t=>{t.setInterval()})}stop(t){(t=this._defaultAnnounceOpts(t)).event=\"stopped\",Oe(\"send `stop` %o\",t),this._announce(t)}complete(t){t||(t={}),(t=this._defaultAnnounceOpts(t)).event=\"completed\",Oe(\"send `complete` %o\",t),this._announce(t)}update(t){(t=this._defaultAnnounceOpts(t)).event&&delete t.event,Oe(\"send `update` %o\",t),this._announce(t)}_announce(t){this._trackers.forEach(e=>{e.announce(t)})}scrape(t){Oe(\"send `scrape`\"),t||(t={}),this._trackers.forEach(e=>{e.scrape(t)})}setInterval(t){Oe(\"setInterval %d\",t),this._trackers.forEach(e=>{e.setInterval(t)})}destroy(t){if(this.destroyed)return;this.destroyed=!0,Oe(\"destroy\");const e=this._trackers.map(t=>e=>{t.destroy(e)});b(e,t),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(t={}){return null==t.numwant&&(t.numwant=ne.DEFAULT_ANNOUNCE_PEERS),null==t.uploaded&&(t.uploaded=0),null==t.downloaded&&(t.downloaded=0),this._getAnnounceOpts&&(t=Object.assign({},t,this._getAnnounceOpts())),t}}Be.scrape=(t,e)=>{if(e=M(e),!t.infoHash)throw new Error(\"Option `infoHash` is required\");if(!t.announce)throw new Error(\"Option `announce` is required\");const r=Object.assign({},t,{infoHash:Array.isArray(t.infoHash)?t.infoHash[0]:t.infoHash,peerId:(0,w.L0)(\"01234567890123456789\"),port:6881}),i=new Be(r);i.once(\"error\",e),i.once(\"warning\",e);let n=Array.isArray(t.infoHash)?t.infoHash.length:1;const s={};return i.on(\"scrape\",t=>{if(n-=1,s[t.infoHash]=t,0===n){i.destroy();const t=Object.keys(s);1===t.length?e(null,s[t[0]]):e(null,s)}}),i.scrape({infoHash:t.infoHash}),i};const Le=Be,Ne=L(\"bittorrent-lsd\"),je=\"239.192.152.143\",Ue=6771;class qe extends n.EventEmitter{constructor(t={}){if(super(),!t.peerId)throw new Error(\"Option `peerId` is required\");if(!t.infoHash)throw new Error(\"Option `infoHash` is required\");if(!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=\"string\"==typeof t.port?t.port:t.port.toString(),this.cookie=`bittorrent-lsd-${this.peerId}`,this.destroyed=!1,this.annouceIntervalId=null,this.server=de.createSocket({type:\"udp4\",reuseAddr:!0});this.server.on(\"listening\",()=>{Ne(\"listening\");try{this.server.addMembership(je)}catch(t){this.emit(\"warning\",t)}}),this.server.on(\"message\",(t,e)=>{Ne(\"message\",t.toString(),`${e.address}:${e.port}`);const r=this._parseAnnounce(t.toString());null!==r&&r.cookie!==this.cookie&&r.infoHash.forEach(t=>{this.emit(\"peer\",`${e.address}:${r.port}`,t)})}),this.server.on(\"error\",t=>{this.emit(\"error\",t)})}_parseAnnounce(t){Ne(\"parse announce\",t);const e=t.split(\"\\r\\n\");if(\"BT-SEARCH * HTTP/1.1\"!==e[0])return this.emit(\"warning\",\"Invalid LSD announce (header)\"),null;const r=e[1].split(\"Host: \")[1];if(!(t=>/^(239.192.152.143|\\[ff15::efc0:988f]):6771$/.test(t))(r))return this.emit(\"warning\",\"Invalid LSD announce (host)\"),null;const i=e[2].split(\"Port: \")[1];if(!(t=>/^\\d+$/.test(t))(i))return this.emit(\"warning\",\"Invalid LSD announce (port)\"),null;const n=e.filter(t=>t.includes(\"Infohash: \")).map(t=>t.split(\"Infohash: \")[1]).filter(t=>(t=>/^[0-9a-fA-F]{40}$/.test(t))(t));if(0===n.length)return this.emit(\"warning\",\"Invalid LSD announce (infoHash)\"),null;return{host:r,port:i,infoHash:n,cookie:e.filter(t=>t.includes(\"cookie: \")).map(t=>t.split(\"cookie: \")[1]).reduce((t,e)=>e,null)}}destroy(t){this.destroyed||(this.destroyed=!0,Ne(\"destroy\"),clearInterval(this.annouceIntervalId),this.server.close(t))}start(){Ne(\"start\"),this.server.bind(Ue),this._announce(),this.annouceIntervalId=setInterval(()=>{this._announce()},3e5)}_announce(){Ne(\"send announce\");const t=`BT-SEARCH * HTTP/1.1\\r\\nHost: ${`${je}:6771`}\\r\\nPort: ${this.port}\\r\\nInfohash: ${this.infoHash}\\r\\ncookie: ${this.cookie}\\r\\n\\r\\n\\r\\n`;this.server.send(t,Ue,je)}}const De=qe;var He=r(717);const Fe=L(\"torrent-discovery\");class ze extends n.EventEmitter{constructor(t){if(super(),!t.peerId)throw new Error(\"Option `peerId` is required\");if(!t.infoHash)throw new Error(\"Option `infoHash` is required\");if(!He.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=t=>{this.emit(\"warning\",t)},this._onError=t=>{this.emit(\"error\",t)},this._onDHTPeer=(t,e)=>{e.toString(\"hex\")===this.infoHash&&this.emit(\"peer\",`${t.host}:${t.port}`,\"dht\")},this._onTrackerPeer=t=>{this.emit(\"peer\",t,\"tracker\")},this._onTrackerAnnounce=()=>{this.emit(\"trackerAnnounce\")},this._onLSDPeer=(t,e)=>{this.emit(\"peer\",t,\"lsd\")};const e=(t,e)=>{const r=new et(e);return r.on(\"warning\",this._onWarning),r.on(\"error\",this._onError),r.listen(t),this._internalDHT=!0,r};!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 et?this.dht=null:t.dht&&\"function\"==typeof t.dht.addNode?this.dht=t.dht:t.dht&&\"object\"==typeof t.dht?this.dht=e(t.dhtPort,t.dht):this.dht=e(t.dhtPort),this.dht&&(this.dht.on(\"peer\",this._onDHTPeer),this._dhtAnnounce()),!1===t.lsd||\"function\"!=typeof De?this.lsd=null:this.lsd=this._createLSD()}updatePort(t){t!==this._port&&(this._port=t,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(t){this.tracker&&this.tracker.complete(t)}destroy(t){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const e=[];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),e.push(t=>{this.tracker.destroy(t)})),this.dht&&this.dht.removeListener(\"peer\",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener(\"warning\",this._onWarning),this.dht.removeListener(\"error\",this._onError),e.push(t=>{this.dht.destroy(t)})),this.lsd&&(this.lsd.removeListener(\"warning\",this._onWarning),this.lsd.removeListener(\"error\",this._onError),this.lsd.removeListener(\"peer\",this._onLSDPeer),e.push(t=>{this.lsd.destroy(t)})),b(e,t),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}_createTracker(){const t=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),e=new Le(t);return e.on(\"warning\",this._onWarning),e.on(\"error\",this._onError),e.on(\"peer\",this._onTrackerPeer),e.on(\"update\",this._onTrackerAnnounce),e.setInterval(this._intervalMs),e.start(),e}_dhtAnnounce(){this._dhtAnnouncing||(Fe(\"dht announce\"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,t=>{this._dhtAnnouncing=!1,Fe(\"dht announce complete\"),t&&this.emit(\"warning\",t),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())}))}_createLSD(){const t=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),e=new De(t);return e.on(\"warning\",this._onWarning),e.on(\"error\",this._onError),e.on(\"peer\",this._onLSDPeer),e.start(),e}}const We=ze;var $e=r(4862),Ve=r(3714);const Ke=L(\"lt_donthave\"),Ze=()=>{class t extends n.EventEmitter{constructor(t){super(),this._peerSupports=!1,this._wire=t}onExtendedHandshake(){this._peerSupports=!0}onMessage(t){let e;try{e=new DataView(t.buffer).getUint32(0)}catch(t){return}this._wire.peerPieces.get(e)&&(Ke(\"got donthave %d\",e),this._wire.peerPieces.set(e,!1),this.emit(\"donthave\",e),this._failRequests(e))}donthave(t){if(!this._peerSupports)return;Ke(\"donthave %d\",t);const e=new Uint8Array(4);new DataView(e.buffer).setUint32(0,t),this._wire.extended(\"lt_donthave\",e)}_failRequests(t){const e=this._wire.requests;for(let r=0;r<e.length;r++){const i=e[r];i.piece===t&&(se(e,r),r-=1,this._wire._callback(i,new Error(\"peer sent donthave\"),null))}}}return t.prototype.name=\"lt_donthave\",t};var Ge=r(5372);const Ye=16384;class Je{constructor(t){this.length=t,this.missing=t,this.sources=null,this._chunks=Math.ceil(t/Ye),this._remainder=t%Ye||Ye,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(t){return t===this._chunks-1?this._remainder:Ye}chunkLengthRemaining(t){return this.length-t*Ye}chunkOffset(t){return t*Ye}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._cancellations.length||this._reservations<this._chunks){let t=this._reservations;for(;this._cancellations.length;)t=Math.min(t,this._cancellations.pop());return this._reservations=this._chunks,t}return-1}cancel(t){this.init()&&this._cancellations.push(t)}cancelRemaining(t){this.init()&&(this._reservations=t)}get(t){return this.init()?this._buffer[t]:null}set(t,e,r){if(!this.init())return!1;const i=e.length,n=Math.ceil(i/Ye);for(let i=0;i<n;i++)if(!this._buffer[t+i]){const n=i*Ye,s=e.subarray(n,n+Ye);this._buffered++,this._buffer[t+i]=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=(0,w.xW)(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)}}Je.BLOCK_LENGTH=Ye;var Xe=r(7373);const Qe=L(\"ut_metadata\"),tr=16384,er=t=>{class e extends n.EventEmitter{constructor(e){super(),this._wire=e,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new qt.A(0,{grow:1e3}),ArrayBuffer.isView(t)&&this.setMetadata(t)}onHandshake(t,e,r){this._infoHash=t}onExtendedHandshake(t){return t.m&&t.m.ut_metadata?t.metadata_size?\"number\"!=typeof t.metadata_size||1e7<t.metadata_size||t.metadata_size<=0?this.emit(\"warning\",new Error(\"Peer gave invalid metadata size\")):(this._metadataSize=t.metadata_size,this._numPieces=Math.ceil(this._metadataSize/tr),this._remainingRejects=2*this._numPieces,void this._requestPieces()):this.emit(\"warning\",new Error(\"Peer does not have metadata\")):this.emit(\"warning\",new Error(\"Peer does not support ut_metadata\"))}onMessage(t){let e,r;try{const i=(0,w.dU)(t),n=i.indexOf(\"ee\")+2;e=f.A.decode(i.substring(0,n)),r=t.slice(n)}catch(t){return}switch(e.msg_type){case 0:this._onRequest(e.piece);break;case 1:this._onData(e.piece,r,e.total_size);break;case 2:this._onReject(e.piece)}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}async setMetadata(t){if(this._metadataComplete)return!0;Qe(\"set metadata\");try{const e=f.A.decode(t).info;e&&(t=f.A.encode(e))}catch(t){}return(!this._infoHash||this._infoHash===await(0,w.tW)(t,\"hex\"))&&(this.cancel(),this.metadata=t,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit(\"metadata\",f.A.encode({info:f.A.decode(this.metadata)})),!0)}_send(t,e){let r=f.A.encode(t);ArrayBuffer.isView(e)&&(r=(0,w.xW)([r,e])),this._wire.extended(\"ut_metadata\",r)}_request(t){this._send({msg_type:0,piece:t})}_data(t,e,r){const i={msg_type:1,piece:t};\"number\"==typeof r&&(i.total_size=r),this._send(i,e)}_reject(t){this._send({msg_type:2,piece:t})}_onRequest(t){if(!this._metadataComplete)return void this._reject(t);const e=t*tr;let r=e+tr;r>this._metadataSize&&(r=this._metadataSize);const i=this.metadata.slice(e,r);this._data(t,i,this._metadataSize)}_onData(t,e,r){e.length>tr||!this._fetching||(this.metadata.set(e,t*tr),this._bitfield.set(t),this._checkDone())}_onReject(t){this._remainingRejects>0&&this._fetching?(this._request(t),this._remainingRejects-=1):this.emit(\"warning\",new Error('Peer sent \"reject\" too much'))}_requestPieces(){if(this._fetching){this.metadata=new Uint8Array(this._metadataSize);for(let t=0;t<this._numPieces;t++)this._request(t)}}async _checkDone(){let t=!0;for(let e=0;e<this._numPieces;e++)if(!this._bitfield.get(e)){t=!1;break}if(!t)return;await this.setMetadata(this.metadata)||this._failedMetadata()}_failedMetadata(){this._bitfield=new qt.A(0,{grow:1e3}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit(\"warning\",new Error(\"Peer sent invalid metadata\"))}}return e.prototype.name=\"ut_metadata\",e};var rr=r(640),ir=r(8287).Buffer;const nr=t=>(\"string\"==typeof t&&(t=[t]),ir.concat(t.map(t=>{const e=Ut(t);if(2!==e.length)throw new Error(\"invalid address format, expecting: 10.10.10.5:128\");const r=rr.parse(e[0]),i=ir.from(r.toByteArray()),n=e[1],s=ir.allocUnsafe(2);return s.writeUInt16BE(n,0),ir.concat([i,s])})));var sr=r(8287).Buffer;const or={prefersEncryption:1,isSender:2,supportsUtp:4,supportsUtHolepunch:8,isReachable:16},ar=()=>{class t extends n.EventEmitter{constructor(t){super(),this._wire=t,this._intervalId=null,this._lastMessageTimestamp=0,this.reset()}start(){clearInterval(this._intervalId),this._intervalId=setInterval(()=>this._sendMessage(),65e3),this._intervalId.unref&&this._intervalId.unref()}stop(){clearInterval(this._intervalId),this._intervalId=null}reset(){this._remoteAddedPeers={},this._remoteDroppedPeers={},this._localAddedPeers={},this._localDroppedPeers={},this.stop()}addPeer(t,e={}){this._addPeer(t,this._encodeFlags(e),4)}addPeer6(t,e={}){this._addPeer(t,this._encodeFlags(e),6)}_addPeer(t,e,r){t.includes(\":\")&&(t in this._remoteAddedPeers||(t in this._localDroppedPeers&&delete this._localDroppedPeers[t],this._localAddedPeers[t]={ip:r,flags:e}))}dropPeer(t){this._dropPeer(t,4)}dropPeer6(t){this._dropPeer(t,6)}_dropPeer(t,e){t.includes(\":\")&&(t in this._remoteDroppedPeers||(t in this._localAddedPeers&&delete this._localAddedPeers[t],this._localDroppedPeers[t]={ip:e}))}onExtendedHandshake(t){if(!t.m||!t.m.ut_pex)return this.emit(\"warning\",new Error(\"Peer does not support ut_pex\"))}onMessage(t){const e=Date.now();if(e-this._lastMessageTimestamp<6e4)return this.reset(),this._wire.destroy(),this.emit(\"warning\",new Error(\"Peer disconnected for sending PEX messages too frequently\"));let r;this._lastMessageTimestamp=e;try{r=f.A.decode(t),r.added&&ae.multi(sr.from(r.added)).forEach((t,e)=>{if(delete this._remoteDroppedPeers[t],!(t in this._remoteAddedPeers)){const i=r[\"added.f\"][e];this._remoteAddedPeers[t]={ip:4,flags:i},this.emit(\"peer\",t,this._decodeFlags(i))}}),r.added6&&ae.multi6(sr.from(r.added6)).forEach((t,e)=>{if(delete this._remoteDroppedPeers[t],!(t in this._remoteAddedPeers)){const i=r[\"added6.f\"][e];this._remoteAddedPeers[t]={ip:6,flags:i},this.emit(\"peer\",t,this._decodeFlags(i))}}),r.dropped&&ae.multi(sr.from(r.dropped)).forEach(t=>{delete this._remoteAddedPeers[t],t in this._remoteDroppedPeers||(this._remoteDroppedPeers[t]={ip:4},this.emit(\"dropped\",t))}),r.dropped6&&ae.multi6(sr.from(r.dropped6)).forEach(t=>{delete this._remoteAddedPeers[t],t in this._remoteDroppedPeers||(this._remoteDroppedPeers[t]={ip:6},this.emit(\"dropped\",t))})}catch(t){}}_decodeFlags(t){return{prefersEncryption:!!(t&or.prefersEncryption),isSender:!!(t&or.isSender),supportsUtp:!!(t&or.supportsUtp),supportsUtHolepunch:!!(t&or.supportsUtHolepunch),isReachable:!!(t&or.isReachable)}}_encodeFlags(t){return Object.keys(t).reduce((e,r)=>!0===t[r]?e|or[r]:e,0)}_sendMessage(){const t=Object.keys(this._localAddedPeers).slice(0,50),e=Object.keys(this._localDroppedPeers).slice(0,50),r=(t,e)=>4===t[e].ip,i=(t,e)=>6===t[e].ip,n=(t,e)=>t[e].flags,s=nr(t.filter(t=>r(this._localAddedPeers,t))),o=nr(t.filter(t=>i(this._localAddedPeers,t))),a=nr(e.filter(t=>r(this._localDroppedPeers,t))),h=nr(e.filter(t=>i(this._localDroppedPeers,t))),u=sr.from(t.filter(t=>r(this._localAddedPeers,t)).map(t=>n(this._localAddedPeers,t))),f=sr.from(t.filter(t=>i(this._localAddedPeers,t)).map(t=>n(this._localAddedPeers,t)));t.forEach(t=>delete this._localAddedPeers[t]),e.forEach(t=>delete this._localDroppedPeers[t]),this._wire.extended(\"ut_pex\",{added:s,\"added.f\":u,dropped:a,added6:o,\"added6.f\":f,dropped6:h})}}return t.prototype.name=\"ut_pex\",t};var hr=r(1133);const ur=L(\"webtorrent:file-iterator\");class fr extends n{constructor(t,{start:e,end:r}){super(),this._torrent=t._torrent,this._pieceLength=t._torrent.pieceLength,this._startPiece=(e+t.offset)/this._pieceLength|0,this._endPiece=(r+t.offset)/this._pieceLength|0,this._piece=this._startPiece,this._offset=e+t.offset-this._startPiece*this._pieceLength,this._missing=r-e+1,this._criticalLength=Math.min(1048576/this._pieceLength|0,2),this._torrent._select(this._startPiece,this._endPiece,1,null,!0),this.destroyed=!1}[Symbol.asyncIterator](){return this}next(){return new Promise((t,e)=>{if(0===this._missing||this.destroyed)return t({done:!0}),this.destroy();const r=(e,i)=>{if(!this._torrent.bitfield.get(e)){const n=s=>{(s===e||this.destroyed)&&(this._torrent.removeListener(\"verified\",n),s===e?r(e,i):t({done:!0}))};return this._torrent.on(\"verified\",n),this._torrent.critical(e,e+this._criticalLength)}if(this.destroyed)return t({done:!0});this._torrent.store.get(e,i,(r,i)=>this.destroyed?t({done:!0}):(ur(\"read %s and yielding (length %s) (err %s)\",e,i?.length,r?.message),r?(this.destroy(void 0,r),t({done:!0})):void t({value:i,done:!1})))},i=Math.min(this._missing,this._pieceLength-this._offset);r(this._piece++,{length:i,offset:this._offset}),this._missing-=i,this._offset=0})}async return(){return this.destroy(),{done:!0,value:void 0}}async throw(t){throw t}destroy(t=t=>{},e){this.destroyed||(this.destroyed=!0,this._torrent.destroyed||this._torrent._deselect(this._startPiece,this._endPiece,!0),this.emit(\"return\"),t(e))}}class lr extends n{constructor(t,e){super(),this._torrent=t,this._destroyed=!1,this._fileStreams=new Set,this._iterators=new Set,this.name=e.name,this.path=e.path,this.length=e.length,this.size=e.length,this.type=hr.getType(this.name)||\"application/octet-stream\",this.offset=e.offset,this.done=!1;const r=e.offset,i=r+e.length-1;this._startPiece=r/this._torrent.pieceLength|0,this._endPiece=i/this._torrent.pieceLength|0,0===this.length&&(this.done=!0,this.emit(\"done\")),this._client=t.client}get downloaded(){if(this._destroyed||!this._torrent.bitfield)return 0;const{pieces:t,bitfield:e,pieceLength:r,lastPieceLength:i}=this._torrent,{_startPiece:n,_endPiece:s}=this,o=e=>e===t.length-1?i:r,a=n=>{const s=n===t.length-1?i:r;return e.get(n)?s:s-t[n].missing};let h=0;for(let t=n;t<=s;t+=1){const e=a(t);if(h+=e,t===n){const t=this.offset%r;h-=Math.min(t,e)}if(t===s){const t=o(s)-(this.offset+this.length)%r;h-=Math.min(t,e)}}return h}get progress(){return this.length?this.downloaded/this.length:0}select(t){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,t)}deselect(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece)}[Symbol.asyncIterator](t={}){if(0===this.length||this._destroyed)return async function*(){}();const{start:e=0}=t??{},r=t?.end&&t.end<this.length?t.end:this.length-1;if(this.done)return Ht(this._torrent.store,{offset:e+this.offset,length:r-e+1});const i=new fr(this,{start:e,end:r});return this._iterators.add(i),i.once(\"return\",()=>{this._iterators.delete(i)}),i}createReadStream(t){if(this._destroyed)throw new Error(\"File is destroyed\");const e=this[Symbol.asyncIterator](t),r=bt.Readable.from(e);return this._fileStreams.add(r),r.once(\"close\",()=>{this._fileStreams.delete(r)}),r}async arrayBuffer(t={}){if(this._destroyed)throw new Error(\"File is destroyed\");const{start:e=0}=t,r=t?.end&&t.end<this.length?t.end:this.length-1,i=new Uint8Array(r-e+1);let n=0;for await(const t of this[Symbol.asyncIterator]({start:e,end:r}))i.set(t,n),n+=t.length;return i.buffer}async blob(t){if(this._destroyed)throw new Error(\"File is destroyed\");return new Blob([await this.arrayBuffer(t)],{type:this.type})}stream(t){if(this._destroyed)throw new Error(\"File is destroyed\");let e;return new ReadableStream({start:()=>{e=this[Symbol.asyncIterator](t)},async pull(t){const{value:r,done:i}=await e.next();i?t.close():t.enqueue(r)},cancel(){e.return()}})}get streamURL(){if(!this._client._server)throw new Error(\"No server created\");return`${this._client._server.pathname}/${this._torrent.infoHash}/${this.path}`}streamTo(t){return t.src=this.streamURL,t}includes(t){return this._startPiece<=t&&this._endPiece>=t}_destroy(){this._destroyed=!0,this._torrent=null;for(const t of this._fileStreams)t.destroy();this._fileStreams.clear();for(const t of this._iterators)t.destroy();this._iterators.clear()}}class cr{constructor(t){this._torrent=t,this._numPieces=t.pieces.length,this._pieces=new Array(this._numPieces),this._onWire=t=>{this.recalculate(),this._initWire(t)},this._onWireHave=t=>{this._pieces[t]+=1},this._onWireBitfield=()=>{this.recalculate()},this._torrent.wires.forEach(t=>{this._initWire(t)}),this._torrent.on(\"wire\",this._onWire),this.recalculate()}getRarestPiece(t){let e=[],r=1/0;for(let i=0;i<this._numPieces;++i){if(t&&!t(i))continue;const n=this._pieces[i];n===r?e.push(i):n<r&&(e=[i],r=n)}return e.length?e[Math.random()*e.length|0]:-1}destroy(){this._torrent.removeListener(\"wire\",this._onWire),this._torrent.wires.forEach(t=>{this._cleanupWireEvents(t)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(t){t._onClose=()=>{this._cleanupWireEvents(t);for(let e=0;e<this._numPieces;++e)this._pieces[e]-=t.peerPieces.get(e)},t.on(\"have\",this._onWireHave),t.on(\"bitfield\",this._onWireBitfield),t.once(\"close\",t._onClose)}recalculate(){this._pieces.fill(0);for(const t of this._torrent.wires)for(let e=0;e<this._numPieces;++e)this._pieces[e]+=t.peerPieces.get(e)}_cleanupWireEvents(t){t.removeListener(\"have\",this._onWireHave),t.removeListener(\"bitfield\",this._onWireBitfield),t._onClose&&t.removeListener(\"close\",t._onClose),t._onClose=null}}var dr=r(6458),pr=r(6819);const mr=L(\"webtorrent:webconn\");class gr extends dr.A{constructor(t,e){super(),this.url=t,this.connId=t,this._torrent=e,this._init(t)}_init(t){this.setKeepAlive(!0),this.use(Ze()),this.once(\"handshake\",async(e,r)=>{const i=await(0,w.tW)(t,\"hex\");if(this.destroyed)return;this.handshake(e,i);const n=this._torrent.pieces.length,s=new qt.A(n);for(let t=0;t<=n;t++)s.set(t,!0);this.bitfield(s)}),this.once(\"interested\",()=>{mr(\"interested\"),this.unchoke()}),this.on(\"uninterested\",()=>{mr(\"uninterested\")}),this.on(\"choke\",()=>{mr(\"choke\")}),this.on(\"unchoke\",()=>{mr(\"unchoke\")}),this.on(\"bitfield\",()=>{mr(\"bitfield\")}),this.lt_donthave.on(\"donthave\",()=>{mr(\"donthave\")}),this.on(\"request\",(t,e,r,i)=>{mr(\"request pieceIndex=%d offset=%d length=%d\",t,e,r),this.httpRequest(t,e,r,(e,r)=>{if(e){this.lt_donthave.donthave(t);const e=setTimeout(()=>{this.destroyed||this.have(t)},1e4);e.unref&&e.unref()}i(e,r)})})}async httpRequest(t,e,r,i){i=M(i);const n=t*this._torrent.pieceLength+e,s=n+r-1,o=this._torrent.files;let a,h;if(o.length<=1)a=[{url:this.url,start:n,end:s}];else{const t=o.filter(t=>t.offset<=s&&t.offset+t.length>n);if(t.length<1)return i(new Error(\"Could not find file corresponding to web seed range request\"));a=t.map(t=>{const e=t.offset+t.length-1;return{url:this.url+(\"/\"===this.url[this.url.length-1]?\"\":\"/\")+t.path.replace(this._torrent.path,\"\"),fileOffsetInRange:Math.max(t.offset-n,0),start:Math.max(n-t.offset,0),end:Math.min(e,s-t.offset)}})}try{h=await Promise.all(a.map(async({start:i,end:n,url:s})=>{mr(\"Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d\",s,t,e,r,i,n);const o=await nt(s,{cache:\"no-store\",method:\"GET\",headers:{\"Cache-Control\":\"no-store\",\"user-agent\":`WebTorrent/${pr} (https://webtorrent.io)`,range:`bytes=${i}-${n}`},signal:AbortSignal.timeout(6e4)});if(!o.ok)throw new Error(`Unexpected HTTP status code ${o.status}`);const a=new Uint8Array(await o.arrayBuffer());return mr(\"Got data of length %d\",a.length),a}))}catch(t){return i(t)}i(null,(0,w.xW)(h))}destroy(){super.destroy(),this._torrent=null}}class yr{_items=[];remove(t){for(let e=0;e<this._items.length;e++){const r=this._items[e];if(!r.isStreamSelection==!t.isStreamSelection)if(r.isStreamSelection){if(r.from===t.from&&r.to===t.to){this._items.splice(e,1);break}}else if(br(t,r))r.to=Math.max(t.from-1,0);else if(vr(t,r))r.from=t.to+1;else if(wr(t,r)){const i=[],n={...r,to:Math.max(t.from-1,0)};n.to-n.from>=0&&0!==t.from&&i.push(n);const s={...r,from:t.to+1};s.to-s.from>=0&&i.push(s),this._items.splice(e,1,...i),e=e-1+i.length}else _r(t,r)&&(this._items.splice(e,1),e--)}}_mergePriorityAndNotify(t,e){if((e.priority??0)>(t.priority??0)&&(t.priority=e.priority),t.notify&&e.notify){const r=t.notify;t.notify=()=>{r(),e.notify?.()}}else t.notify=e.notify||t.notify}concatenate(t){for(let e=0;e<this._items.length;e++){const r=this._items[e];if(!r.isStreamSelection){if(br(t,r))t.from=r.from;else if(vr(t,r))t.to=r.to;else{if(!wr(t,r)){if(_r(t,r))continue;continue}t.from=r.from,t.to=r.to}this._mergePriorityAndNotify(t,r)}}this.remove(t)}insert(t){if(t.from>t.to)throw new Error(\"Invalid interval\");t.isStreamSelection||this.concatenate(t),this._items.push(t)}sort(t=(t,e)=>t.from-e.from){this._items.sort(t)}get length(){return this._items.length}get(t){return this._items[t]}swap(t,e){const r=this._items[t];this._items[t]=this._items[e],this._items[e]=r}clear(){this._items.length=0}*[Symbol.iterator](){for(let t=0;t<this._items.length;t++){const e=this._items[t];e.remove=()=>{this._items.splice(t,1),t--},yield e,delete e.remove}}}function br(t,e){return t.from<=e.to+1&&t.from>e.from&&t.to>e.to}function vr(t,e){return t.to>=e.from-1&&t.to<e.to&&t.from<e.from}function wr(t,e){const r=e.to-e.from,i=t.to-t.from;return t.from>=e.from&&t.to<=e.to&&i<r}function _r(t,e){return t.from<=e.from&&t.to>=e.to}var Mr=r(717);const Sr=L(\"webtorrent:torrent\"),kr=5e3,Er=3*Je.BLOCK_LENGTH,xr=Mr.browser?zt().length:2,Ar=[1e3,5e3,15e3],Ir=`WebTorrent/${pr} (https://webtorrent.io)`,Tr=(globalThis.navigator?.storage?.getDirectory&&globalThis.FileSystemFileHandle,Mr.browser,$e);let Cr;try{Cr=h(Bt.statSync(\"/tmp\")&&\"/tmp\",\"webtorrent\")}catch(t){Cr=h(\"function\"==typeof Lt.tmpdir?Lt.tmpdir():\"/\",\"webtorrent\")}const Pr=\"undefined\"!=typeof window&&\"function\"==typeof window.requestIdleCallback&&window.requestIdleCallback;class Rr extends n{constructor(t,e,r){super(),this._debugId=\"unknown infohash\",this.client=e,this.announce=r.announce,this.urlList=r.urlList,this.path=r.path||Cr,this.addUID=r.addUID||!1,this.rootDir=r.rootDir||null,this.skipVerify=!!r.skipVerify,this._startupBitfield=r.bitfield,this._store=r.store||Tr,this._preloadedStore=r.preloadedStore||null,this._storeCacheSlots=void 0!==r.storeCacheSlots?r.storeCacheSlots:20,this._destroyStoreOnDestroy=r.destroyStoreOnDestroy||!1,this.store=null,this.storeOpts=r.storeOpts,this.alwaysChokeSeeders=r.alwaysChokeSeeders??!0,this._getAnnounceOpts=r.getAnnounceOpts,\"boolean\"==typeof r.private&&(this.private=r.private),this.strategy=r.strategy||\"sequential\",this.maxWebConns=r.maxWebConns||4,this._rechokeNumSlots=!1===r.uploads||0===r.uploads?0:+r.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this._noPeersIntervalId=null,this._noPeersIntervalTime=r.noPeersIntervalTime?1e3*r.noPeersIntervalTime:3e4,this._startAsDeselected=r.deselect||!1,this.ready=!1,this.destroyed=!1,this.paused=r.paused||!1,this.done=!1,this.metadata=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=new yr,this._critical=[],this.wires=[],this._queue=[],this._peers=new Map,this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=Et(),this._uploadSpeed=Et(),this._servers=[],this._xsRequests=[],this._fileModtimes=r.fileModtimes,null!==t&&this._onTorrentId(t),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 t=0;for(let e=0,r=this.pieces.length;e<r;++e)if(this.bitfield.get(e))t+=e===r-1?this.lastPieceLength:this.pieceLength;else{const r=this.pieces[e];t+=r.length-r.missing}return t}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||this.length)}get numPeers(){return this.wires.length}get torrentFileBlob(){return this.torrentFile?new Blob([this.torrentFile],{type:\"application/x-bittorrent\"}):null}get _numQueued(){return this._queue.length+(this._peersLength-this._numConns)}_numConns=0;async _onTorrentId(t){if(this.destroyed)return;let e;try{e=await ct(t)}catch(t){}e?(this.infoHash=e.infoHash,this._debugId=(0,w.V5)(e.infoHash).substring(0,7),v(()=>{this.destroyed||this._onParsedTorrent(e)})):ft(t,(t,e)=>{if(!this.destroyed)return t?this._destroy(t):void this._onParsedTorrent(e)})}_onParsedTorrent(t){if(!this.destroyed){if(this._processParsedTorrent(t),!this.infoHash)return this._destroy(new Error(\"Malformed torrent data: No info hash\"));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(t){this._debugId=(0,w.V5)(t.infoHash).substring(0,7),void 0!==this.private&&(t.private=this.private),Array.isArray(this.announce)&&(t.announce=t.announce.concat(this.announce)),this.client.tracker&&Array.isArray(this.client.tracker.announce)&&!t.private&&(t.announce=t.announce.concat(this.client.tracker.announce)),this.client.tracker&&globalThis.WEBTORRENT_ANNOUNCE&&!t.private&&(t.announce=t.announce.concat(globalThis.WEBTORRENT_ANNOUNCE)),this.urlList&&(t.urlList=t.urlList.concat(this.urlList)),t.announce=Array.from(new Set(t.announce)),t.urlList=Array.from(new Set(t.urlList)),Object.assign(this,t),this.magnetURI=dt(t),this.torrentFile=function(t){const e={info:t.info};return e[\"announce-list\"]=(t.announce||[]).map(t=>(e.announce||(e.announce=t),[t=(0,w.L0)(t)])),e[\"url-list\"]=t.urlList||[],void 0!==t.private&&(e.private=Number(t.private)),t.created&&(e[\"creation date\"]=t.created.getTime()/1e3|0),t.createdBy&&(e[\"created by\"]=t.createdBy),t.comment&&(e.comment=t.comment),f.A.encode(e)}(t)}_onListening(){this.destroyed||(this.info?this._onMetadata(this):(this.xs&&this._getMetadataFromServer(),this._startDiscovery()))}_startDiscovery(){if(this.discovery||this.destroyed)return;let t=this.client.tracker;t&&(t=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{if(this.destroyed)return;const t={uploaded:this.uploaded,downloaded:this.downloaded,left:Math.max(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(t,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(t,this._getAnnounceOpts()),t}})),this.peerAddresses&&this.peerAddresses.forEach(t=>this.addPeer(t,Tt.A.SOURCE_MANUAL)),this.discovery=new We({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:t,port:this.client.torrentPort,userAgent:Ir,lsd:this.client.lsd}),this.discovery.on(\"error\",t=>{this._destroy(t)}),this.discovery.on(\"peer\",(t,e)=>{this._debug(\"peer %s discovered via %s\",t,e),this.client.seedOutgoingConnections||!this.done?this.addPeer(t,e):this._debug(\"discovery ignoring peer %s: torrent is done and seedOutgoingConnections is false\",t)}),this.discovery.on(\"trackerAnnounce\",()=>{this.emit(\"trackerAnnounce\")}),this.discovery.on(\"dhtAnnounce\",()=>{this.emit(\"dhtAnnounce\")}),this.discovery.on(\"warning\",t=>{this.emit(\"warning\",t)}),this._noPeersIntervalId=setInterval(()=>{if(this.destroyed)return;const t={[Tt.A.SOURCE_TRACKER]:{enabled:!!this.client.tracker,numPeers:0},[Tt.A.SOURCE_DHT]:{enabled:!!this.client.dht,numPeers:0},[Tt.A.SOURCE_LSD]:{enabled:!!this.client.lsd,numPeers:0},[Tt.A.SOURCE_UT_PEX]:{enabled:this.client.utPex&&!0,numPeers:0}};for(const e of this._peers.values()){const r=t[e.source];void 0!==r&&r.numPeers++}for(const e of Object.keys(t)){const r=t[e];r.enabled&&0===r.numPeers&&this.emit(\"noPeers\",e)}},this._noPeersIntervalTime),this._noPeersIntervalId.unref&&this._noPeersIntervalId.unref()}_getMetadataFromServer(){const t=this,e=Array.isArray(this.xs)?this.xs:[this.xs];t._xsRequestsController=new AbortController;const r=t._xsRequestsController.signal,i=e.map(e=>i=>{!async function(e,i){if(0!==e.indexOf(\"http://\")&&0!==e.indexOf(\"https://\"))return t.emit(\"warning\",new Error(`skipping non-http xs param: ${e}`)),i(null);const n={method:\"GET\",headers:{\"user-agent\":Ir},signal:r};let s,o,a;try{s=await nt(e,n)}catch(r){return t.emit(\"warning\",new Error(`http error from xs param: ${e}`)),i(null)}if(t.destroyed)return i(null);if(t.metadata)return i(null);if(200!==s.status)return t.emit(\"warning\",new Error(`non-200 status code ${s.status} from xs param: ${e}`)),i(null);try{o=new Uint8Array(await s.arrayBuffer())}catch(e){return t.emit(\"warning\",e),i(null)}try{a=await ct(o)}catch(t){}if(!a)return t.emit(\"warning\",new Error(`got invalid torrent file from xs param: ${e}`)),i(null);if(a.infoHash!==t.infoHash)return t.emit(\"warning\",new Error(`got torrent file with incorrect info hash from xs param: ${e}`)),i(null);t._onMetadata(a),i(null)}(e,i)});b(i)}async _onMetadata(t){if(this.metadata||this.destroyed)return;let e;if(this._debug(\"got metadata\"),this._xsRequestsController?.abort(),this._xsRequestsController=null,t&&t.infoHash)e=t;else try{e=await ct(t)}catch(t){return this._destroy(t)}this._processParsedTorrent(e),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(t=>{this.addWebSeed(t)}),this._rarityMap=new cr(this),this.files=this.files.map(t=>new lr(this,t));let r=this._preloadedStore;if(r||(r=new this._store(this.pieceLength,{...this.storeOpts,torrent:this,path:this.path,files:this.files,length:this.length,name:this.name+\" - \"+this.infoHash.slice(0,8),addUID:this.addUID,rootDir:this.rootDir,max:this._storeCacheSlots})),this._storeCacheSlots>0&&!(r instanceof $e)&&(r=new Dt(r,{max:this._storeCacheSlots})),this.store=new Ve(r),this.so&&!this._startAsDeselected?this.files.forEach((t,e)=>{this.so.includes(e)&&this.files[e].select()}):0===this.pieces.length||this._startAsDeselected||this.select(0,this.pieces.length-1),this._hashes=this.pieces,this._hasStartupBitfield=this._startupBitfield&&this._startupBitfield.length===Math.ceil(this.pieces.length/8)&&!this.skipVerify,this.bitfield=new qt.A(this._hasStartupBitfield?new Uint8Array(this._startupBitfield):this.pieces.length),this._reservations=this._hasStartupBitfield?this.pieces.map((t,e)=>this.bitfield.get(e)?null:[]):this.pieces.map(()=>[]),this.pieces=this.pieces.map((t,e)=>{if(this._hasStartupBitfield&&this.bitfield.get(e))return null;const r=e===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new Je(r)}),this.emit(\"metadata\"),!this.destroyed)if(this.skipVerify)this._markAllVerified(),this._onStore();else{const t=t=>{if(t)return this._destroy(t);this._debug(\"done verifying\"),this._onStore()};this._debug(\"verifying existing torrent data\"),this._fileModtimes&&this._store===$e?this.getFileModtimes((e,r)=>{if(e)return this._destroy(e);this.files.map((t,e)=>r[e]===this._fileModtimes[e]).every(t=>t)?(this._markAllVerified(),this._onStore()):this._verifyPieces(t)}):this._verifyPieces(t)}}getFileModtimes(t){const e=[];Ge(this.files.map((t,r)=>i=>{const n=this.addUID?h(this.name+\" - \"+this.infoHash.slice(0,8)):h(this.path,t.path);Bt.stat(n,(t,n)=>{if(t&&\"ENOENT\"!==t.code)return i(t);e[r]=n&&n.mtime.getTime(),i(null)})}),xr,r=>{this._debug(\"done getting file modtimes\"),t(r,e)})}_verifyPiece(t,e){if(this.destroyed)return e(new Error(\"torrent is destroyed\"));const r={};t===this.pieces.length-1&&(r.length=this.lastPieceLength),this.store.get(t,r,async(r,i)=>{if(this.destroyed)return e(new Error(\"torrent is destroyed\"));if(r)return v(()=>e(null,!1));const n=await(0,w.tW)(i,\"hex\");if(this.destroyed)return e(new Error(\"torrent is destroyed\"));e(null,n===this._hashes[t])})}_verifyPiecesUsingBitfield(t){const e=new Set,r=new Map;for(const t of this.files){let i=2,n=null;for(let e=t._startPiece;e<=t._endPiece;++e)this.bitfield.get(e)&&(i&&(n=e,i--),r.has(e)||r.set(e,[]),r.get(e).push(t));null!==n&&e.add(n)}this._verifyPiecesUsingHash([...e],i=>{if(i)return t(i);const n=new Set;for(const t of e)if(!this.bitfield.get(t)){const e=r.get(t);for(const t of e)n.add(t)}if(n.size){const e=[];for(const t of n)for(let r=t._startPiece;r<=t._endPiece;++r)-1===e.indexOf(r)&&e.push(r);return this._verifyPiecesUsingHash(e,t)}t(null)})}_verifyPiecesUsingHash(t,e){Ge(t.map((t,e)=>r=>{const i=Number.isInteger(t)?t:e;this._verifyPiece(i,(t,e)=>{if(t)return r(t);e?(this._debug(\"piece verified %s\",i),this._markVerified(i)):(this._markUnverified(i),this._debug(\"piece invalid %s\",i)),r(null)})}),xr,e)}_verifyPieces(t){if(this._hasStartupBitfield)return this._verifyPiecesUsingBitfield(t);this._verifyPiecesUsingHash(this.pieces,t)}rescanFiles(t){if(this.destroyed)throw new Error(\"torrent is destroyed\");t||(t=Br),this._verifyPiecesUsingHash(this.pieces,e=>{if(e)return this._destroy(e),t(e);this._checkDone(),t(null)})}_markAllVerified(){for(let t=0;t<this.pieces.length;t++)this._markVerified(t)}_markVerified(t){this.pieces[t]=null,this._reservations[t]=null,this.bitfield.set(t,!0),this.emit(\"verified\",t)}_markUnverified(t){const e=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;this.pieces[t]=new Je(e),this.bitfield.set(t,!1),this._startAsDeselected||this.select(t,t);for(const e of this.files)e.done&&e.includes(t)&&(e.done=!1)}_hasAllPieces(){for(let t=0;t<this.pieces.length;t++)if(!this.bitfield.get(t))return!1;return!0}_hasNoPieces(){return!this._hasMorePieces(0)}_hasMorePieces(t){let e=0;for(let r=0;r<this.pieces.length;r++)if(this.bitfield.get(r)&&(e+=1,e>t))return!0;return!1}_onStore(){this.destroyed||(this._debug(\"on store\"),this._startDiscovery(),this.ready=!0,this.emit(\"ready\"),this._checkDone(),this._updateSelections(),this.wires.forEach(t=>{t.ut_metadata&&t.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(t)}))}destroy(t,e){if(\"function\"==typeof t)return this.destroy(null,t);this._destroy(null,t,e)}_destroy(t,e,r){if(\"function\"==typeof e)return this._destroy(t,null,e);if(this.destroyed)return;this.destroyed=!0,this._debug(\"destroy\"),this.client._remove(this),this._selections.clear(),clearInterval(this._rechokeIntervalId),clearInterval(this._noPeersIntervalId),this._xsRequestsController?.abort(),this._rarityMap&&this._rarityMap.destroy();for(const t of this._peers.keys())this.removePeer(t);for(const t of this.files)t instanceof lr&&t._destroy();const i=this._servers.map(t=>e=>{t.destroy(e)});if(this.discovery&&i.push(t=>{this.discovery.destroy(t)}),this.store){let t=this._destroyStoreOnDestroy;e&&void 0!==e.destroyStore&&(t=e.destroyStore),i.push(e=>{t?this.store.destroy(e):this.store.close(e)})}b(i,r),t&&(0===this.listenerCount(\"error\")?this.client.emit(\"error\",t):this.emit(\"error\",t)),this.emit(\"close\"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers.clear(),this._peers=null,this._servers=null,this._xsRequests=null,this._queue=null}addPeer(t,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\");let r;if(\"string\"==typeof t){let e;try{e=Ut(t)}catch(e){return this._debug(\"ignoring peer: invalid %s\",t),this.emit(\"invalidPeer\",t),!1}r=e[0]}else\"string\"==typeof t.remoteAddress&&(r=t.remoteAddress);if(this.client.blocked&&r&&this.client.blocked.contains(r))return this._debug(\"ignoring peer: blocked %s\",t),\"string\"!=typeof t&&t.destroy(),this.emit(\"blockedPeer\",t),!1;const i=this.client.utp&&this._isIPv4(r)?\"utp\":\"tcp\",n=!!this._addPeer(t,i,e);return n?this.emit(\"peer\",t):this.emit(\"invalidPeer\",t),n}_addPeer(t,e,r){if(this.destroyed)return\"string\"!=typeof t&&t.destroy(),null;if(\"string\"==typeof t&&!this._validAddr(t))return this._debug(\"ignoring peer: invalid %s\",t),null;const i=t&&t.id||t;if(this._peers.has(i))return this._debug(\"ignoring peer: duplicate (%s)\",i),\"string\"!=typeof t&&t.destroy(),null;if(this.paused)return this._debug(\"ignoring peer: torrent is paused\"),\"string\"!=typeof t&&t.destroy(),null;let n;return this._debug(\"add peer %s\",i),n=\"string\"==typeof t?\"utp\"===e?Tt.A.createUTPOutgoingPeer(t,this,this.client.throttleGroups,r):Tt.A.createTCPOutgoingPeer(t,this,this.client.throttleGroups,r):Tt.A.createWebRTCPeer(t,this,this.client.throttleGroups,r),this._registerPeer(n),\"string\"==typeof t&&(this._queue.push(n),this._drain()),n}addWebSeed(t){if(this.destroyed)throw new Error(\"torrent is destroyed\");let e,r;if(\"string\"==typeof t){if(e=t,!/^https?:\\/\\/.+/.test(e))return this.emit(\"warning\",new Error(`ignoring invalid web seed: ${e}`)),void this.emit(\"invalidPeer\",e);if(this._peers.has(e))return this.emit(\"warning\",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit(\"invalidPeer\",e);r=new gr(e,this)}else{if(!t||\"string\"!=typeof t.connId)return void this.emit(\"warning\",new Error(\"addWebSeed must be passed a string or connection object with id property\"));if(r=t,e=r.connId,this._peers.has(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 i=Tt.A.createWebSeedPeer(r,e,this,this.client.throttleGroups);this._registerPeer(i),this.emit(\"peer\",e)}_addIncomingPeer(t){return this.destroyed?t.destroy(new Error(\"torrent is destroyed\")):this.paused?t.destroy(new Error(\"torrent is paused\")):(this._debug(\"add incoming peer %s\",t.id),void this._registerPeer(t))}_registerPeer(t){t.on(\"download\",t=>{this.destroyed||(this.received+=t,this._downloadSpeed(t),this.client._downloadSpeed(t),this.emit(\"download\",t),this.destroyed||this.client.emit(\"download\",t))}),t.on(\"upload\",t=>{this.destroyed||(this.uploaded+=t,this._uploadSpeed(t),this.client._uploadSpeed(t),this.emit(\"upload\",t),this.destroyed||this.client.emit(\"upload\",t))}),t.connected?this._numConns+=1:t.once(\"connect\",()=>{this.destroyed||(this._numConns+=1)}),t.once(\"disconnect\",()=>{this._numConns-=1}),this._peers.set(t.id,t),this._peersLength+=1}removePeer(t){const e=t?.id||t;t&&!t.id&&(t=this._peers?.get(e)),t&&(t.destroy(),this.destroyed||(this._debug(\"removePeer %s\",e),this._peers.delete(e),this._peersLength-=1,this._drain()))}_select(t=0,e=this.pieces.length-1,r,i,n=!1){if(this.destroyed)throw new Error(\"torrent is destroyed\");if(t<0||e<t||this.pieces.length<=e)throw new Error(`invalid selection ${t} : ${e}`);r=Number(r)||0,this._debug(\"select %s-%s (priority %s)\",t,e,r),this._selections.insert({from:t,to:e,offset:0,priority:r,notify:i,isStreamSelection:n}),this._selections.sort((t,e)=>e.priority-t.priority),this._updateSelections()}select(t,e,r,i){this._select(t,e,r,i,!1)}_deselect(t,e,r=!1){if(this.destroyed)throw new Error(\"torrent is destroyed\");this._debug(\"deselect %s-%s\",t,e),this._selections.remove({from:t,to:e,isStreamSelection:r}),this._updateSelections()}deselect(t,e){this._deselect(t,e,!1)}critical(t,e){if(this.destroyed)throw new Error(\"torrent is destroyed\");this._debug(\"critical %s-%s\",t,e);for(let r=t;r<=e;++r)this._critical[r]=!0;this._updateSelections()}_onWire(t,e){if(this._debug(\"got wire %s (%s)\",t._debugId,e||\"Unknown\"),this.wires.push(t),e){const r=Ut(e);t.remoteAddress=r[0],t.remotePort=r[1]}this.client.dht&&this.client.dht.listening&&t.on(\"port\",r=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!t.remoteAddress)return this._debug(\"ignoring PORT from peer with no address\");if(0===r||r>65536)return this._debug(\"ignoring invalid PORT from peer\");this._debug(\"port: %s (from %s)\",r,e),this.client.dht.addNode({host:t.remoteAddress,port:r})}}),t.on(\"timeout\",()=>{this._debug(\"wire timeout (%s)\",e),t.destroy()}),\"webSeed\"!==t.type&&t.setTimeout(3e4,!0),t.setKeepAlive(!0),t.use(er(this.metadata)),t.ut_metadata.on(\"warning\",t=>{this._debug(\"ut_metadata warning: %s\",t.message)}),this.metadata||(t.ut_metadata.on(\"metadata\",t=>{this._debug(\"got metadata via ut_metadata\"),this._onMetadata(t)}),t.ut_metadata.fetch()),this.client.utPex&&!this.private&&(t.use(ar()),t.ut_pex.on(\"peer\",t=>{this.client.seedOutgoingConnections||!this.done?(this._debug(\"ut_pex: got peer: %s (from %s)\",t,e),this.addPeer(t,Tt.A.SOURCE_UT_PEX)):this._debug(\"ut_pex ignoring peer %s: torrent is done and seedOutgoingConnections is false\",t)}),t.ut_pex.on(\"dropped\",t=>{const r=this._peers.get(t);r&&!r.connected&&(this._debug(\"ut_pex: dropped peer: %s (from %s)\",t,e),this.removePeer(t))}),t.once(\"close\",()=>{t.ut_pex.reset()})),t.use(Ze()),this.emit(\"wire\",t,e),this.ready&&v(()=>{this._onWireWithMetadata(t)})}_onWireWithMetadata(t){let e=null;const r=()=>{this.destroyed||t.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&t.amInterested?t.destroy():(e=setTimeout(r,kr),e.unref&&e.unref()))};let i;const n=()=>{if(t.peerPieces.buffer.length&&t.peerPieces.setAll){if(t.peerPieces.buffer.length!==this.bitfield.buffer.length)return;for(i=0;i<this.pieces.length;++i)if(!t.peerPieces.get(i))return}t.isSeeder=!0,this.alwaysChokeSeeders&&t.choke()};t.on(\"bitfield\",()=>{n(),this._update(),this._updateWireInterest(t)}),t.on(\"have\",()=>{n(),this._update(),this._updateWireInterest(t)}),t.lt_donthave.on(\"donthave\",()=>{n(),this._update(),this._updateWireInterest(t)}),t.on(\"have-all\",()=>{t.isSeeder=!0,this.alwaysChokeSeeders&&t.choke(),this._update(),this._updateWireInterest(t)}),t.on(\"have-none\",()=>{t.isSeeder=!1,this._update(),this._updateWireInterest(t)}),t.on(\"allowed-fast\",t=>{this._update()}),t.once(\"interested\",()=>{t.unchoke()}),t.once(\"close\",()=>{clearTimeout(e)}),t.on(\"choke\",()=>{clearTimeout(e),e=setTimeout(r,kr),e.unref&&e.unref()}),t.on(\"unchoke\",()=>{clearTimeout(e),this._update()}),t.on(\"request\",(e,r,i,n)=>{if(i>131072)return t.destroy();this.pieces[e]||this.store.get(e,{offset:r,length:i},n)}),t.hasFast&&this._hasAllPieces()?t.haveAll():t.hasFast&&this._hasNoPieces()?t.haveNone():t.bitfield(this.bitfield),this._updateWireInterest(t),t.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&t.port(this.client.dht.address().port),\"webSeed\"!==t.type&&(e=setTimeout(r,kr),e.unref&&e.unref()),t.isSeeder=!1,n()}_updateSelections(){this.ready&&!this.destroyed&&(v(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(const t of this._selections){const e=t.offset;for(;this.bitfield.get(t.from+t.offset)&&t.from+t.offset<t.to;)t.offset+=1;e!==t.offset&&t.notify?.(),t.to===t.from+t.offset&&(this.bitfield.get(t.from+t.offset)&&(t.remove(),t.notify?.(),this._updateInterest()))}this._selections.length||this.emit(\"idle\")}_updateInterest(){const t=this._amInterested;this._amInterested=!!this._selections.length,this.wires.forEach(t=>this._updateWireInterest(t)),t!==this._amInterested&&(this._amInterested?this.emit(\"interested\"):this.emit(\"uninterested\"))}_updateWireInterest(t){let e=!1;for(let r=0;r<this.pieces.length;++r)if(this.pieces[r]&&t.peerPieces.get(r)){e=!0;break}e?t.interested():t.uninterested()}_update(){Pr?Pr(()=>this._updateWireWrapper(),{timeout:250}):this._updateWireWrapper()}_updateWireWrapper(){if(this.destroyed)return;const t=Xe(this.wires);let e;for(;e=t();)this._updateWire(e)}_updateWire(t){if(t.destroyed)return!1;const e=this,r=Or(t,.5);if(t.requests.length>=r)return;const i=Or(t,1);if(t.peerChoking)t.hasFast&&t.peerAllowedFastSet.length>0&&!this._hasMorePieces(t.peerAllowedFastSet.length-1)&&function(){if(t.requests.length>=i)return!1;for(const r of t.peerAllowedFastSet){if(t.peerPieces.get(r)&&!e.bitfield.get(r))for(;e._request(t,r,!1)&&t.requests.length<i;);if(!(t.requests.length<i))return!0}}();else{if(!t.downloaded)return function(){if(t.requests.length)return;let r=e._selections.length;for(;r--;){const i=e._selections.get(r);let s;if(\"rarest\"===e.strategy){const r=i.from+i.offset,o=i.to,a=o-r+1,h={};let u=0;const f=n(r,o,h);for(;u<a&&(s=e._rarityMap.getRarestPiece(f),!(s<0));){if(e._request(t,s,!1))return;h[s]=!0,u+=1}}else for(s=i.to;s>=i.from+i.offset;--s)if(t.peerPieces.get(s)&&e._request(t,s,!1))return}}();o(!1)||o(!0)}function n(e,r,i,n){return s=>s>=e&&s<=r&&!(s in i)&&t.peerPieces.get(s)&&(!n||n(s))}function s(t){let r=t;for(let i=t;i<e._selections.length&&e._selections.get(i).priority;i++)r=i;e._selections.swap(t,r)}function o(r){if(t.requests.length>=i)return!0;const o=function(){const r=t.downloadSpeed()||1;if(r>Er)return()=>!0;const i=Math.max(1,t.requests.length)*Je.BLOCK_LENGTH/r;let n=10,s=0;return t=>{if(!n||e.bitfield.get(t))return!0;let o=e.pieces[t].missing;for(;s<e.wires.length;s++){const a=e.wires[s],h=a.downloadSpeed();if(!(h<Er)&&!(h<=r)&&a.peerPieces.get(t)&&!((o-=h*i)>0))return n--,!1}return!0}}();for(let a=0;a<e._selections.length;a++){const h=e._selections.get(a);let u;if(\"rarest\"===e.strategy){const f=h.from+h.offset,l=h.to,c=l-f+1,d={};let p=0;const m=n(f,l,d,o);for(;p<c&&(u=e._rarityMap.getRarestPiece(m),!(u<0));){for(;e._request(t,u,e._critical[u]||r)&&t.requests.length<i;);if(!(t.requests.length<i))return h.priority&&s(a),!0;d[u]=!0,p++}}else for(u=h.from+h.offset;u<=h.to;u++)if(t.peerPieces.get(u)&&o(u)){for(;e._request(t,u,e._critical[u]||r)&&t.requests.length<i;);if(!(t.requests.length<i))return h.priority&&s(a),!0}}return!1}}_rechoke(){if(!this.ready)return;const t=this.wires.map(t=>({wire:t,random:Math.random()})).sort((t,e)=>{const r=t.wire,i=e.wire;return r.downloadSpeed()!==i.downloadSpeed()?r.downloadSpeed()-i.downloadSpeed():r.uploadSpeed()!==i.uploadSpeed()?r.uploadSpeed()-i.uploadSpeed():r.amChoking!==i.amChoking?r.amChoking?-1:1:t.random-e.random}).map(t=>t.wire);this._rechokeOptimisticTime<=0?this._rechokeOptimisticWire=null:this._rechokeOptimisticTime-=1;let e=0;for(;t.length>0&&e<this._rechokeNumSlots-1;){const r=t.pop();r.isSeeder||r===this._rechokeOptimisticWire||(r.unchoke(),r.peerInterested&&e++)}if(null===this._rechokeOptimisticWire&&this._rechokeNumSlots>0){const e=t.filter(t=>t.peerInterested);if(e.length>0){const t=e[(r=e.length,Math.random()*r|0)];t.unchoke(),this._rechokeOptimisticWire=t,this._rechokeOptimisticTime=2}}var r;t.filter(t=>t!==this._rechokeOptimisticWire).forEach(t=>t.choke())}_hotswap(t,e){const r=t.downloadSpeed();if(r<Je.BLOCK_LENGTH)return!1;if(!this._reservations[e])return!1;const i=this._reservations[e];if(!i)return!1;let n,s,o=1/0;for(s=0;s<i.length;s++){const e=i[s];if(!e||e===t)continue;const a=e.downloadSpeed();a>=Er||(2*a>r||a>o||(n=e,o=a))}if(!n)return!1;for(s=0;s<i.length;s++)i[s]===n&&(i[s]=null);for(s=0;s<n.requests.length;s++){const t=n.requests[s];t.piece===e&&this.pieces[e].cancel(t.offset/Je.BLOCK_LENGTH|0)}return this.emit(\"hotswap\",n,t,e),!0}_request(t,e,r){const i=this,n=t.requests.length,s=\"webSeed\"===t.type;if(i.bitfield.get(e))return!1;const o=s?Math.min(function(t,e,r){return 1+Math.ceil(e*t.downloadSpeed()/r)}(t,1,i.pieceLength),i.maxWebConns):Or(t,1);if(n>=o)return!1;const a=i.pieces[e];let h=s?a.reserveRemaining():a.reserve();if(-1===h&&r&&i._hotswap(t,e)&&(h=s?a.reserveRemaining():a.reserve()),-1===h)return!1;let u=i._reservations[e];u||(u=i._reservations[e]=[]);let f=u.indexOf(null);-1===f&&(f=u.length),u[f]=t;const l=a.chunkOffset(h),c=s?a.chunkLengthRemaining(h):a.chunkLength(h);function d(){v(()=>{i._update()})}return t.request(e,l,c,async function r(n,o){if(i.destroyed)return;if(!i.ready)return i.once(\"ready\",()=>{r(n,o)});if(u[f]===t&&(u[f]=null),a!==i.pieces[e])return d();if(n)return i._debug(\"error getting piece %s (offset: %s length: %s) from %s: %s\",e,l,c,`${t.remoteAddress}:${t.remotePort}`,n.message),s?a.cancelRemaining(h):a.cancel(h),void d();if(i._debug(\"got piece %s (offset: %s length: %s) from %s\",e,l,c,`${t.remoteAddress}:${t.remotePort}`),!a.set(h,o,t))return d();const p=a.flush(),m=await(0,w.tW)(p,\"hex\");i.destroyed||(m===i._hashes[e]?(i._debug(\"piece verified %s\",e),i.store.put(e,p,t=>{t?i._destroy(t):(i.pieces[e]=null,i._markVerified(e),i.wires.forEach(t=>{t.have(e)}),i._checkDone(),d())})):(i.pieces[e]=new Je(a.length),i.emit(\"warning\",new Error(`Piece ${e} failed verification`)),d()))}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(t=>{if(!t.done){for(let e=t._startPiece;e<=t._endPiece;++e)if(!this.bitfield.get(e))return;t.done=!0,t.emit(\"done\"),this._debug(`file done: ${t.name}`)}});const t=this.files.every(t=>t.done);return!this.done&&t?(this.done=!0,this._debug(`torrent done: ${this.infoHash}`),this.emit(\"done\"),this.destroyed||this.discovery.complete()):this.done&&!t&&(this.done=!1,this.discovery.tracker?.start()),this._gcSelections(),t}async load(t,e){if(this.destroyed)throw new Error(\"torrent is destroyed\");if(!this.ready)return this.once(\"ready\",()=>{this.load(t,e)});Array.isArray(t)||(t=[t]),e||(e=Br);try{await Ft(this.store,y(t),{chunkLength:this.pieceLength}),this._markAllVerified(),this._checkDone(),e(null)}catch(t){return e(t),t}}pause(){this.destroyed||(this._debug(\"pause\"),this.paused=!0)}resume(){this.destroyed||(this._debug(\"resume\"),this.paused=!1,this._drain())}_debug(...t){t[0]=`[${this.client._debugId}] [${this._debugId}] ${t[0]}`,Sr(...t)}_drain(){if(this._debug(\"_drain numConns %s maxConns %s _peersLength %s\",this._numConns,this.client.maxConns,this._peersLength),\"function\"!=typeof It.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 t=this._queue.shift();if(!t)return;this._debug(\"%s connect attempt to %s\",t.type,t.addr);const e=Ut(t.addr),r={host:e[0],port:e[1]};this.client.utp&&t.type===Tt.A.TYPE_UTP_OUTGOING?t.conn=Ct.connect(r.port,r.host):t.conn=It.connect(r);const i=t.conn;i.once(\"connect\",()=>{this.destroyed||t.onConnect()}),i.once(\"error\",e=>{t.destroy(e)}),t.startConnectTimeout(),i.on(\"close\",()=>{if(this.destroyed)return;if(t.retries>=Ar.length){if(this.client.utp){const e=this._addPeer(t.addr,\"tcp\",t.source);e&&(e.retries=0)}else this._debug(\"conn %s closed: will not re-add (max %s attempts)\",t.addr,Ar.length);return}const e=Ar[t.retries];this._debug(\"conn %s closed: will re-add to queue in %sms (attempt %s)\",t.addr,e,t.retries+1);const r=setTimeout(()=>{if(this.destroyed)return;const e=Ut(t.addr)[0],r=this.client.utp&&this._isIPv4(e)?\"utp\":\"tcp\",i=this._addPeer(t.addr,r,t.source);i&&(i.retries=t.retries+1)},e);r.unref&&r.unref()})}_validAddr(t){let e;try{e=Ut(t)}catch(t){return!1}const r=e[0],i=e[1];return i>0&&i<65535&&!(\"127.0.0.1\"===r&&i===this.client.torrentPort)}_isIPv4(t){return/^((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/.test(t)}}function Or(t,e){let r=2+Math.ceil(e*t.downloadSpeed()/Je.BLOCK_LENGTH);if(t.peerExtendedHandshake){const e=t.peerExtendedHandshake.reqq;\"number\"==typeof e&&e>0&&(r=Math.min(r,e))}return r}function Br(){}var Lr=r(2195),Nr=r(580),jr=r(815),Ur=r(2878);class qr{constructor(t,e={}){this.client=t,e.origin||(e.origin=\"*\"),this.opts=e,this.pendingReady=new Set}static serveIndexPage(t,e,r){const i=e.map(t=>`<li>\\n        <a href=\"${Nr(r)}/${t.infoHash}\">\\n          ${Nr(t.name)}\\n        </a>\\n        (${Nr(t.length)} bytes)\\n      </li>`).join(\"<br>\");return t.status=200,t.headers[\"Content-Type\"]=\"text/html\",t.body=Fr(\"WebTorrent\",`<h1>WebTorrent</h1>\\n       <ol>${i}</ol>`),t}isOriginAllowed(t){return!1!==this.opts.origin&&(\"*\"===this.opts.origin||t.headers.origin===this.opts.origin)}static serveMethodNotAllowed(t){return t.status=405,t.headers[\"Content-Type\"]=\"text/html\",t.body=Fr(\"405 - Method Not Allowed\",\"<h1>405 - Method Not Allowed</h1>\"),t}static serve404Page(t){return t.status=404,t.headers[\"Content-Type\"]=\"text/html\",t.body=Fr(\"404 - Not Found\",\"<h1>404 - Not Found</h1>\"),t}static serveTorrentPage(t,e,r){const i=t.files.map(e=>`<li>\\n        <a href=\"${Nr(r)}/${t.infoHash}/${Nr(e.path)}\">\\n          ${Nr(e.path)}\\n        </a>\\n        (${Nr(e.length)} bytes)\\n      </li>`).join(\"<br>\");return e.status=200,e.headers[\"Content-Type\"]=\"text/html\",e.body=Fr(`${Nr(t.name)} - WebTorrent`,`<h1>${Nr(t.name)}</h1>\\n      <ol>${i}</ol>`),e}static serveOptionsRequest(t,e){return e.status=204,e.headers[\"Access-Control-Max-Age\"]=\"600\",e.headers[\"Access-Control-Allow-Methods\"]=\"GET,HEAD\",t.headers[\"access-control-request-headers\"]&&(e.headers[\"Access-Control-Allow-Headers\"]=t.headers[\"access-control-request-headers\"]),e}static serveFile(t,e,r){r.status=200,r.headers.Expires=\"0\",r.headers[\"Cache-Control\"]=\"no-cache, no-store, must-revalidate, max-age=0\",r.headers[\"Accept-Ranges\"]=\"bytes\",r.headers[\"Content-Type\"]=t.type,r.headers[\"transferMode.dlna.org\"]=\"Streaming\",r.headers[\"contentFeatures.dlna.org\"]=\"DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000\",\"document\"===e.destination?(r.headers[\"Content-Type\"]=\"application/octet-stream\",r.headers[\"Content-Disposition\"]=`attachment; filename*=UTF-8''${zr(t.name)}`,r.body=\"DOWNLOAD\"):r.headers[\"Content-Disposition\"]=`inline; filename*=UTF-8''${zr(t.name)}`;let i=Ur(t.length,e.headers.range||\"\");if(Array.isArray(i)?(r.status=206,i=i[0],r.headers[\"Content-Range\"]=`bytes ${i.start}-${i.end}/${t.length}`,r.headers[\"Content-Length\"]=i.end-i.start+1):(r.statusCode=200,i=null,r.headers[\"Content-Length\"]=t.length),\"GET\"===e.method){const n=t[Symbol.asyncIterator](i);let s=null;t.emit(\"iterator\",{iterator:n,req:e,file:t},t=>{s=t});const o=bt.Readable.from(s||n);let a=null;t.emit(\"stream\",{stream:o,req:e,file:t},t=>{a=jr(o,t)}),r.body=a||o}else r.body=!1;return r}async onRequest(t,e){let r=new URL(t.url,\"http://example.com\").pathname;r=r.slice(r.indexOf(this.pathname)+this.pathname.length+1);const i={headers:{\"X-Content-Type-Options\":\"nosniff\",\"Content-Security-Policy\":\"base-uri 'none'; frame-ancestors 'none'; form-action 'none';\"}};if(this.isOriginAllowed(t)&&(i.headers[\"Access-Control-Allow-Origin\"]=\"*\"===this.opts.origin?\"*\":t.headers.origin),\"favicon.ico\"===r)return e(qr.serve404Page(i));if(\"OPTIONS\"===t.method)return this.isOriginAllowed(t)?e(qr.serveOptionsRequest(t,i)):e(qr.serveMethodNotAllowed(i));const n=async()=>{this.pendingReady.delete(n);const t=await s();e(t)},s=async()=>{if(\"\"===r)return qr.serveIndexPage(i,this.client.torrents,this.pathname);let[e,...n]=r.split(\"/\");n=decodeURI(n.join(\"/\"));const s=await this.client.get(e);if(!e||!s)return qr.serve404Page(i);if(!n)return qr.serveTorrentPage(s,i,this.pathname);const o=s.files.find(t=>t.path.replace(/\\\\/g,\"/\")===n);return o?qr.serveFile(o,t,i):qr.serve404Page(i)};if(\"GET\"===t.method||\"HEAD\"===t.method){if(this.client.ready){const t=await s();return e(t)}return this.pendingReady.add(n),void this.client.once(\"ready\",n)}return e(qr.serveMethodNotAllowed(i))}close(t=()=>{}){this.closed=!0,this.pendingReady.forEach(t=>{this.client.removeListener(\"ready\",t)}),this.pendingReady.clear(),v(t)}destroy(t=()=>{}){this.closed?v(t):this.close(t),this.client=null}}class Dr extends qr{constructor(t,e){super(t,e),this.server=Lr.createServer(),this._listen=this.server.listen,this.server.listen=this.listen.bind(this),this._close=this.server.close,this.server.close=this.close.bind(this),this.sockets=new Set,this.closed=!1,this.pathname=e?.pathname||\"/webtorrent\"}wrapRequest(t,e){return this.opts.hostname&&t.headers.host!==`${this.opts.hostname}:${this.server.address().port}`?t.destroy():new URL(t.url,\"http://example.com\").pathname.startsWith(this.pathname)?void this.onRequest(t,({status:t,headers:r,body:i})=>{e.writeHead(t,r),i?._readableState||i?._writableState?jr(i,e):e.end(i)}):t.destroy()}onConnection(t){t.setTimeout(36e6),this.sockets.add(t),t.once(\"close\",()=>{this.sockets.delete(t)})}address(){return this.server.address()}listen(...t){return this.closed=!1,this.server.on(\"connection\",this.onConnection.bind(this)),this.server.on(\"request\",this.wrapRequest.bind(this)),this._listen.apply(this.server,t)}close(t=()=>{}){this.server.removeAllListeners(\"connection\"),this.server.removeAllListeners(\"request\"),this.server.removeAllListeners(\"listening\"),super.close(),this._close.call(this.server,t)}destroy(t){this.sockets.forEach(t=>{t.destroy()}),super.destroy(t)}}class Hr extends qr{constructor(t,e){super(t,e),this.registration=e.controller,this.workerKeepAliveInterval=null,this.workerPortCount=0;const r=new URL(e.controller.scope);this.pathname=r.pathname+\"webtorrent\",this._address={port:r.port,family:\"IPv4\",address:r.hostname},this.boundHandler=this.wrapRequest.bind(this),navigator.serviceWorker.addEventListener(\"message\",this.boundHandler),fetch(`${this.pathname}/cancel/`).then(t=>{t.body.cancel()})}wrapRequest(t){const e=t.data;if(\"webtorrent\"===!e?.type||!e.url)return null;const[r]=t.ports;this.onRequest(e,({status:t,headers:e,body:i})=>{const n=i[Symbol.asyncIterator]?.(),s=()=>{r.onmessage=null,i?.destroy&&i.destroy(),this.workerPortCount--,this.workerPortCount||(clearInterval(this.workerKeepAliveInterval),this.workerKeepAliveInterval=null)};r.onmessage=async t=>{if(t.data){let t;try{t=(await n.next()).value}catch(t){}r.postMessage(t),t||s(),this.workerKeepAliveInterval||(this.workerKeepAliveInterval=setInterval(()=>fetch(`${this.pathname}/keepalive/`),2e4))}else s()},this.workerPortCount++,r.postMessage({status:t,headers:e,body:n?\"STREAM\":i})})}listen(t,e){e()}address(){return this._address}close(t){navigator.serviceWorker.removeEventListener(\"message\",this.boundHandler),super.close(t)}destroy(t){super.destroy(t)}}function Fr(t,e){return`\\n    <!DOCTYPE html>\\n    <html lang=\"en\">\\n      <head>\\n        <meta charset=\"utf-8\">\\n        <title>${t}</title>\\n      </head>\\n      <body>\\n        ${e}\\n      </body>\\n    </html>\\n  `}function zr(t){return encodeURIComponent(t).replace(/['()]/g,escape).replace(/\\*/g,\"%2A\").replace(/%(?:7C|60|5E)/g,unescape)}const Wr=L(\"webtorrent\"),$r=pr.replace(/\\d*./g,t=>(\"0\"+t%100).slice(-2)).slice(0,4),Vr=`-WW${$r}-`;class Kr extends n{constructor(t={}){super(),\"string\"==typeof t.peerId?this.peerId=t.peerId:ArrayBuffer.isView(t.peerId)?this.peerId=(0,w.V5)(t.peerId):this.peerId=(0,w.V5)((0,w.L0)(Vr+(0,w.NJ)((0,w.po)(9)))),this.peerIdBuffer=(0,w.fk)(this.peerId),\"string\"==typeof t.nodeId?this.nodeId=t.nodeId:ArrayBuffer.isView(t.nodeId)?this.nodeId=(0,w.V5)(t.nodeId):this.nodeId=(0,w.V5)((0,w.po)(20)),this.nodeIdBuffer=(0,w.fk)(this.nodeId),this._debugId=this.peerId.substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=t.torrentPort||0,this.dhtPort=t.dhtPort||0,this.tracker=void 0!==t.tracker?t.tracker:{},this.lsd=!1!==t.lsd,this.utPex=!1!==t.utPex,this.natUpnp=t.natUpnp??!0,this.natPmp=t.natPmp??!0,this.torrents=[],this.maxConns=Number(t.maxConns)||55,this.utp=Kr.UTP_SUPPORT&&!1!==t.utp,this.seedOutgoingConnections=t.seedOutgoingConnections??!0,this._downloadLimit=Math.max(\"number\"==typeof t.downloadLimit?t.downloadLimit:-1,-1),this._uploadLimit=Math.max(\"number\"==typeof t.uploadLimit?t.uploadLimit:-1,-1),(this.natUpnp||this.natPmp)&&\"function\"==typeof At&&(this.natTraversal=new At({enableUPNP:this.natUpnp,enablePMP:this.natPmp,upnpPermanentFallback:\"permanent\"===t.natUpnp})),!0===t.secure&&Promise.resolve().then(r.bind(r,5658)).then(({enableSecure:t})=>t()),this._debug(\"new webtorrent (peerId %s, nodeId %s, port %s)\",this.peerId,this.nodeId,this.torrentPort),this.throttleGroups={down:new xt.ThrottleGroup({rate:Math.max(this._downloadLimit,0),enabled:this._downloadLimit>=0}),up:new xt.ThrottleGroup({rate:Math.max(this._uploadLimit,0),enabled:this._uploadLimit>=0})},this.tracker&&(\"object\"!=typeof this.tracker&&(this.tracker={}),globalThis.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=globalThis.WRTC)),\"function\"==typeof Rt?this._connPool=new Rt(this):v(()=>{this._onListening()}),this._downloadSpeed=Et(),this._uploadSpeed=Et(),!1!==t.dht&&\"function\"==typeof et?(this.dht=new et(Object.assign({},{nodeId:this.nodeId},t.dht)),this.dht.once(\"error\",t=>{this._destroy(t)}),this.dht.once(\"listening\",()=>{const t=this.dht.address();t&&(this.dhtPort=t.port,this.natTraversal&&this.natTraversal.map({publicPort:this.dhtPort,privatePort:this.dhtPort,protocol:\"udp\",description:\"WebTorrent DHT\"}).catch(t=>{Wr(\"error mapping DHT port via UPnP/PMP: %o\",t)}))}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==t.webSeeds;const e=()=>{this.destroyed||(this.ready=!0,this.emit(\"ready\"))};\"function\"==typeof rt&&null!=t.blocklist?rt(t.blocklist,{headers:{\"user-agent\":`WebTorrent/${pr} (https://webtorrent.io)`}},(t,r)=>{if(t)return console.error(`Failed to load blocklist: ${t.message}`);this.blocked=r,e()}):v(e)}createServer(t,e){if(this.destroyed)throw new Error(\"torrent is destroyed\");if(this._server)throw new Error(\"server already created\");if(\"undefined\"!=typeof window&&\"node\"!==e||\"browser\"===e){if(!(t?.controller instanceof ServiceWorkerRegistration))throw new Error(\"Invalid worker registration\");if(\"activated\"!==t.controller.active.state)throw new Error(\"Worker isn't activated\");return this._server=new Hr(this,t),this._server}return this._server=new Dr(this,t),this._server}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const t=this.torrents.filter(t=>1!==t.progress);return t.reduce((t,e)=>t+e.downloaded,0)/(t.reduce((t,e)=>t+(e.length||0),0)||1)}get ratio(){return this.torrents.reduce((t,e)=>t+e.uploaded,0)/(this.torrents.reduce((t,e)=>t+e.received,0)||1)}async get(t){if(t instanceof Rr){if(this.torrents.includes(t))return t}else{const e=this.torrents;let r;try{r=await ct(t)}catch(t){}if(!r)return null;if(!r.infoHash)throw new Error(\"Invalid torrent identifier\");for(const t of e)if(t.infoHash===r.infoHash)return t}return null}add(t,e={},r=()=>{}){if(this.destroyed)throw new Error(\"client is destroyed\");\"function\"==typeof e&&([e,r]=[{},e]);const i=()=>{if(!this.destroyed)for(const t of this.torrents)if(t.infoHash===s.infoHash&&t!==s)return s._destroy(new Error(`Cannot add duplicate torrent ${s.infoHash}`)),void r(t)},n=()=>{this.destroyed||(r(s),this.emit(\"torrent\",s))};this._debug(\"add\"),e=e?Object.assign({},e):{};const s=new Rr(t,this,e);return this.torrents.push(s),s.once(\"_infoHash\",i),s.once(\"ready\",n),s.once(\"close\",function t(){s.removeListener(\"_infoHash\",i),s.removeListener(\"ready\",n),s.removeListener(\"close\",t)}),this.emit(\"add\",s),s}seed(t,e,r){if(this.destroyed)throw new Error(\"client is destroyed\");\"function\"==typeof e&&([e,r]=[{},e]),this._debug(\"seed\"),(e=e?Object.assign({},e):{}).skipVerify=!0;const i=\"string\"==typeof t;i&&(e.path=function(t){if(s(t),0===t.length)return\".\";let e=t.charCodeAt(0);const r=47===e;let i=-1,n=!0;for(let r=t.length-1;r>=1;--r)if(e=t.charCodeAt(r),47===e){if(!n){i=r;break}}else n=!1;return-1===i?r?\"/\":\".\":r&&1===i?\"//\":t.slice(0,i)}(t)),e.createdBy||(e.createdBy=`WebTorrent/${$r}`);const n=t=>{this._debug(\"on seed\"),\"function\"==typeof r&&r(t),t.emit(\"seed\"),this.emit(\"seed\",t)},o=this.add(null,e,t=>{const r=[r=>{if(i||e.preloadedStore)return r();t.load(a,r)}];this.dht&&r.push(e=>{t.once(\"dhtAnnounce\",e)}),b(r,e=>{if(!this.destroyed)return e?t._destroy(e):void n(t)})});let a;var h;return h=t,\"undefined\"!=typeof FileList&&h instanceof FileList?t=Array.from(t):Array.isArray(t)||(t=[t]),b(t.map(t=>async r=>{if(!e.preloadedStore&&function(t){return\"object\"==typeof t&&null!=t&&\"function\"==typeof t.pipe}(t)){const e=[];try{for await(const r of t)e.push(r)}catch(t){return r(t)}const i=(0,w.xW)(e);i.name=t.name,r(null,i)}else r(null,t)}),(t,i)=>{if(!this.destroyed)return t?o._destroy(t):void function(t,e,r){\"function\"==typeof e&&([e,r]=[r,e]),T(t,e=e?Object.assign({},e):{},r)}(i,e,(t,n)=>{if(!this.destroyed){if(t)return o._destroy(t);a=n.map(t=>t.getStream),B(i,e,async(t,e)=>{if(this.destroyed)return;if(t)return o._destroy(t);const i=await this.get(e);i?(console.warn(\"A torrent with the same id is already being seeded\"),o._destroy(),\"function\"==typeof r&&r(i)):o._onTorrentId(e)})}})}),o}async remove(t,e,r){if(\"function\"==typeof e)return this.remove(t,null,e);this._debug(\"remove\");const i=await this.get(t);if(!i)throw new Error(`No torrent with id ${t}`);this._remove(i,e,r)}_remove(t,e,r){if(!t)return;if(\"function\"==typeof e)return this._remove(t,null,e);const i=this.torrents.indexOf(t);-1!==i&&(this.torrents.splice(i,1),t.destroy(e,r),this.dht&&this.dht._tables.remove(t.infoHash),this.emit(\"remove\",t))}address(){return this.listening?this._connPool?this._connPool.tcpServer.address():{address:\"0.0.0.0\",family:\"IPv4\",port:0}:null}throttleDownload(t){return t=Number(t),!(isNaN(t)||!isFinite(t)||t<-1)&&(this._downloadLimit=t,this._downloadLimit<0?this.throttleGroups.down.setEnabled(!1):(this.throttleGroups.down.setEnabled(!0),void this.throttleGroups.down.setRate(this._downloadLimit)))}throttleUpload(t){return t=Number(t),!(isNaN(t)||!isFinite(t)||t<-1)&&(this._uploadLimit=t,this._uploadLimit<0?this.throttleGroups.up.setEnabled(!1):(this.throttleGroups.up.setEnabled(!0),void this.throttleGroups.up.setRate(this._uploadLimit)))}destroy(t){if(this.destroyed)throw new Error(\"client already destroyed\");this._destroy(null,t)}_destroy(t,e){this._debug(\"client destroy\"),this.destroyed=!0;const r=this.torrents.map(t=>e=>{t.destroy(e)});this._connPool&&r.push(t=>{this._connPool.destroy(t)}),this.dht&&r.push(t=>{this.dht.destroy(t)}),this._server&&r.push(t=>{this._server.destroy(t)}),this.natTraversal&&r.push(t=>{this.natTraversal.destroy().then(()=>t())}),b(r,e),t&&this.emit(\"error\",t),this.torrents=[],this._connPool=null,this.dht=null,this.throttleGroups.down.destroy(),this.throttleGroups.up.destroy()}_onListening(){if(this._debug(\"listening\"),this.listening=!0,this._connPool){const t=this._connPool.tcpServer.address();t&&(this.torrentPort=t.port,this.natTraversal&&this.natTraversal.map({publicPort:this.torrentPort,privatePort:this.torrentPort,protocol:this.utp?null:\"tcp\",description:\"WebTorrent Torrent\"}).catch(t=>{Wr(\"error mapping WebTorrent port via UPnP/PMP: %o\",t)}))}this.emit(\"listening\")}_debug(){const t=[].slice.call(arguments);t[0]=`[${this._debugId}] ${t[0]}`,Wr(...t)}async _getByHash(t){for(const e of this.torrents)if(e.infoHashHash||(e.infoHashHash=await(0,w.tW)((0,w.fk)(\"72657132\"+e.infoHash),\"hex\")),t===e.infoHashHash)return e;return null}}Kr.WEBRTC_SUPPORT=kt.WEBRTC_SUPPORT,Kr.UTP_SUPPORT=Rt.UTP_SUPPORT,Kr.VERSION=pr;export{Kr as default};\n//# sourceMappingURL=webtorrent.chromeapp.js.map"
  },
  {
    "path": "docs/api.md",
    "content": "# WebTorrent Documentation\n\nWebTorrent is a streaming torrent client for **Node.js** and the **web**. WebTorrent\nprovides the same API in both environments.\n\nTo use WebTorrent in the browser, [WebRTC] support is required (Chrome, Firefox, Opera, Safari).\n\n[webrtc]: https://en.wikipedia.org/wiki/WebRTC\n\n## Install\n\n```bash\nnpm install webtorrent\n```\n\n## Quick Example\n\n```js\nconst client = new WebTorrent()\n\nconst torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'\n\nconst controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\nawait navigator.serviceWorker.ready\nclient.createServer({ controller })\n\nclient.add(torrentId, torrent => {\n  // Torrents can contain many files. Let's use the .mp4 file\n  const file = torrent.files.find(file => {\n    return file.name.endsWith('.mp4')\n  })\n\n  // Display the file by adding it to the DOM. Supports video, audio, image, etc. files\n  file.streamTo(document.querySelector('video'))\n})\n```\n\n# WebTorrent API\n\n## `WebTorrent.WEBRTC_SUPPORT`\n\nIs WebRTC natively supported in the environment?\n\n```js\nif (WebTorrent.WEBRTC_SUPPORT) {\n  // WebRTC is supported\n} else {\n  // Use a fallback\n}\n```\n\n## `client = new WebTorrent([opts])`\n\nCreate a new `WebTorrent` instance.\n\nIf `opts` is specified, then the default options (shown below) will be overridden.\n\n```js\n{\n  maxConns: Number,        // Max number of connections per torrent (default=55)\n  nodeId: String|Uint8Array,   // DHT protocol node ID (default=randomly generated)\n  peerId: String|Uint8Array,   // Wire protocol peer ID (default=randomly generated)\n  tracker: Boolean|Object, // Enable trackers (default=true), or options object for Tracker\n  dht: Boolean|Object,     // Enable DHT (default=true), or options object for DHT\n  lsd: Boolean,            // Enable BEP14 local service discovery (default=true)\n  utPex: Boolean,          // Enable BEP11 Peer Exchange (default=true)\n  natUpnp: Boolean | String, // Enable NAT port mapping via NAT-UPnP (default=true). NodeJS only\n  natPmp: Boolean,         // Enable NAT port mapping via NAT-PMP (default=true). NodeJS only.\n  webSeeds: Boolean,       // Enable BEP19 web seeds (default=true)\n  utp: Boolean,            // Enable BEP29 uTorrent transport protocol (default=true)\n  seedOutgoingConnections: Boolean // Enable outgoing connections when seeding (default=true)\n  blocklist: Array|String, // List of IP's to block\n  downloadLimit: Number,   // Max download speed (bytes/sec) over all torrents (default=-1)\n  uploadLimit: Number,     // Max upload speed (bytes/sec) over all torrents (default=-1)\n}\n```\n\nFor possible values of `opts.dht` see the\n[`bittorrent-dht` documentation](https://github.com/webtorrent/bittorrent-dht#dht--new-dhtopts).\n\nFor possible values of `opts.tracker` see the\n[`bittorrent-tracker` documentation](https://github.com/webtorrent/bittorrent-tracker#client).\n\nFor possible values of `opts.blocklist` see the\n[`load-ip-set` documentation](https://github.com/webtorrent/load-ip-set#usage).\n\nFor `opts.natUpnp` and `opts.natPmp`, if both are set to `true`, PMP will be attempted first, then fallback to UPNP. NodeJS only.\n\nFor `opts.natUpnp`, if set to `true`, a temporary mapping is used, if set to `permanent`, a permanent TTL will be used for UPNP if the router only supports permanent leases. NodeJS only.\n\nFor `opts.seedOutgoingConnections`, if set `true`, outgoing connections will be established while seeding, otherwise, only inbound connections will be responded to.\n\nFor `downloadLimit` and `uploadLimit` the possible values can be:\n  - `> 0`. The client will set the throttle at that speed\n  - `0`. The client will block any data from being downloaded or uploaded\n  - `-1`. The client will is disable the throttling and use the whole bandwidth available\n\n## `client.add(torrentId, [opts], [function ontorrent (torrent) {}])`\n\nStart downloading a new torrent.\n\n`torrentId` can be one of:\n\n- magnet uri (string)\n- torrent file (Uint8Array)\n- info hash (hex string or Uint8Array)\n- parsed torrent (from [parse-torrent](https://github.com/webtorrent/parse-torrent))\n- http/https url to a torrent file (string)\n- filesystem path to a torrent file (string) *(Node.js only)*\n\nIf `opts` is specified, then the default options (shown below) will be overridden.\n\n```js\n{\n  announce: [String],        // Torrent trackers to use (added to list in .torrent or magnet uri)\n  getAnnounceOpts: Function, // Custom callback to allow sending extra parameters to the tracker\n  urlList: [String],         // Array of web seeds\n  maxWebConns: Number,       // Max number of simultaneous connections per web seed [default=4]\n  path: String,              // Folder to download files to (default=`/tmp/webtorrent/`)\n  private: Boolean,          // If true, client will not share the hash with the DHT nor with PEX (default is the privacy of the parsed torrent)\n  store: Function,           // Custom chunk store (must follow [abstract-chunk-store](https://www.npmjs.com/package/abstract-chunk-store) API)\n  destroyStoreOnDestroy: Boolean, // If truthy, client will delete the torrent's chunk store (e.g. files on disk) when the torrent is destroyed\n  storeCacheSlots: Number,   // Number of chunk store entries (torrent pieces) to cache in memory [default=20]; 0 to disable caching\n  storeOpts: Object,         // Custom options passed to the store\n  addUID: Boolean,           // (Node.js only) If true, the torrent will be stored in it's infoHash folder to prevent file name collisions (default=false)\n  skipVerify: Boolean,       // If true, client will skip verification of pieces for existing store and assume it's correct\n  bitfield: Uint8Array,      // Preloaded numerical array/buffer to use to know what pieces are already downloaded (any type accepted by UInt8Array constructor is valid)\n  preloadedStore: Function,  // Custom, pre-loaded chunk store (must follow [abstract-chunk-store](https://www.npmjs.com/package/abstract-chunk-store) API)\n  strategy: String,          // Piece selection strategy, `rarest` or `sequential`(defaut=`sequential`)\n  noPeersIntervalTime: Number, // The amount of time (in seconds) to wait between each check of the `noPeers` event (default=30)\n  paused: Boolean,           // If true, create the torrent in a paused state (default=false)\n  deselect: Boolean,         // If true, create the torrent with no pieces selected (default=false)\n  alwaysChokeSeeders: Boolean // If true, client will automatically choke seeders if it's seeding. (default=true)\n}\n```\n\nIf `ontorrent` is specified, then it will be called when **this** torrent is ready to be\nused (i.e. metadata is available). Note: this is distinct from the 'torrent' event which\nwill fire for **all** torrents.\n\nIf you want access to the torrent object immediately in order to listen to events as the\nmetadata is fetched from the network, then use the return value of `client.add`. If you\njust want the file data, then use `ontorrent` or the 'torrent' event.\n\nIf you provide `opts.store`, it will be called as\n`opts.store(chunkLength, storeOpts)` with:\n\n* `storeOpts` - custom `storeOpts` specified in `opts`\n* `storeOpts.length` - size of all the files in the torrent\n* `storeOpts.files` - an array of torrent file objects\n* `storeOpts.torrent` - the torrent instance being stored\n* `storeOpts.path` - path to the store, based on `opts.path`\n* `storeOpts.name` - the info hash of the torrent instance being stored\n* `storeOpts.addUID` - boolean which tells the store if it should include an UID in it's file paths\n* `storeOpts.rootDir` - *(browser only)* [FileSystemDirectoryHandle](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle) - if supported by the browser, allows the user to specify a custom directory to stores the files in, retaining the torrent's folder and file structure\n\n**Note (browser only):** If you don't want to retain data across sessions, make sure to manually destroy the torrent store when the page closes (More on how below). This has to happen on the `beforeunload` event at latest, in order for the data to be removed. [About page lifecycles.](https://developers.google.com/web/updates/2018/07/page-lifecycle-api)\n\n**Note:** Downloading a torrent automatically seeds it, making it available for download by other peers.\n\n## `client.seed(input, [opts], [function onseed (torrent) {}])`\n\nStart seeding a new torrent.\n\n`input` can be any of the following:\n\n- filesystem path to file or folder\n (string) *(Node.js only)*\n- W3C [FileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList) object (basically an array of `File` objects) *(browser only)*\n- W3C [File](https://developer.mozilla.org/en-US/docs/Web/API/File)/[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object (from an `<input>` or drag and drop)\n- typed array or array of numbers\n- Node [Buffer](https://nodejs.org/api/buffer.html) object\n- Node [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) object\n\nOr, an **array of of any of those values**.\n\nIf `opts` is specified, it should contain the following types of options:\n\n- options for [create-torrent](https://github.com/webtorrent/create-torrent#createtorrentinput-opts-function-callback-err-torrent-) (to allow configuration of the .torrent file that is created)\n- options for `client.add` (see above)\n\nIf `onseed` is specified, it will be called when the client has begun seeding the file.\n\n**Note:** Every torrent is required to have a name. If one is not explicitly provided\nthrough `opts.name`, one will be determined automatically using the following logic:\n\n- If all files share a common path prefix, that will be used. For example, if all file\n  paths start with `/imgs/` the torrent name will be `imgs`.\n- Otherwise, the first file that has a name will determine the torrent name. For example,\n  if the first file is `/foo/bar/baz.txt`, the torrent name will be `baz.txt`.\n- If no files have names (say that all files are Uint8Array or Stream objects), then a name\n  like \"Unnamed Torrent <id>\" will be generated.\n\n**Note:** Every file is required to have a name. For filesystem paths or W3C File objects,\nthe name is included in the object. For Uint8Array or Readable stream types, a `name` property\ncan be set on the object, like this:\n\n```js\nconst buf = new Uint8Array('Some file content')\nbuf.name = 'Some file name'\nclient.seed(buf, cb)\n```\n\n## `client.on('add', function (torrent) {})`\n\nEmitted when a torrent is added to client.torrents. This allows attaching to torrent events that may be emitted before the client 'torrent' event is emitted. See the torrent section for more info on what methods a `torrent` has.\n\n## `client.on('remove', function (torrent) {})`\n\nEmitted when a torrent is removed from client.torrents. See the torrent section for more info on what methods a `torrent` has.\n\n## `client.on('torrent', function (torrent) {})`\n\nEmitted when a torrent is ready to be used (i.e. metadata is available and store is\nready). See the torrent section for more info on what methods a `torrent` has.\n\n## `client.on('error', function (err) {})`\n\nEmitted when the client encounters a fatal error. The client is automatically\ndestroyed and all torrents are removed and cleaned up when this occurs.\n\nAlways listen for the 'error' event.\n\n## `await client.remove(torrentId, [opts], [function callback (err) {}])`\n\nRemove a torrent from the client. Destroy all connections to peers and delete all saved file metadata.\n\nIf `opts.destroyStore` is specified, it will override `opts.destroyStoreOnDestroy` passed when the torrent was added.\nIf truthy, `store.destroy()` will be called, which will delete the torrent's files from the disk.\n\nIf `callback` is provided, it will be called when the torrent is fully destroyed,\ni.e. all open sockets are closed, and the storage is either closed or destroyed.\n\n## `client.destroy([function callback (err) {}])`\n\nDestroy the client, including all torrents and connections to peers. If `callback` is specified, it will be called when the client has gracefully closed.\n\n## `client.torrents[...]`\n\nAn array of all torrents in the client.\n\n## `await client.get(torrentId)`\n\nReturns a promise which resolves the torrent with the given `torrentId`. Convenience method. Easier than searching\nthrough the `client.torrents` array. Returns `null` if no matching torrent found.\n\n## `client.downloadSpeed`\n\nTotal download speed for all torrents, in bytes/sec.\n\n## `client.uploadSpeed`\n\nTotal upload speed for all torrents, in bytes/sec.\n\n## `client.progress`\n\nTotal download progress for all **active** torrents, from 0 to 1.\n\n## `client.ratio`\n\nAggregate \"seed ratio\" for all torrents (uploaded / downloaded).\n\n## `client.throttleDownload(rate)`\n\nSets the maximum speed at which the client downloads the torrents, in bytes/sec.\n\n`rate` must be bigger or equal than zero, or `-1` to disable the download throttle and\nuse the whole bandwidth of the connection.\n\n## `client.throttleUpload(rate)`\n\nSets the maximum speed at which the client uploads the torrents, in bytes/sec.\n\n`rate` must be bigger or equal than zero, or `-1` to disable the upload throttle and\nuse the whole bandwidth of the connection.\n\n\n## `client.createServer([opts], force)`\n\nCreate an http server to serve the contents of this torrent, dynamically fetching the needed torrent pieces to satisfy http requests. Range requests are supported.\nIf `opts` is specified, it can have the following properties:\n```js\n{\n  origin: String // Allow requests from specific origin. `false` for same-origin. [default: '*']\n  hostname: String // If specified, only allow requests whose `Host` header matches this hostname. Note that you should not specify the port since this is automatically determined by the server. Ex: `localhost` [default: `undefined`]. NodeJS only.\n  path: String // Allows to overwrite the default `/webtorrent` base path. [default: '/webtorrent']. NodeJS only.\n  controller: ServiceWorkerRegistration // Accepts an existing service worker registration [await navigator.serviceWorker.getRegistration()]. Browser only. Required!\n}\n```\n\nIf `force` is specified, it can force WebTorrent to use a specific implementation for enviorments which run both Node and Browser like NW.js or Electron. Allowed values:\n```js\n'browser' || 'node'\n```\n\nVisiting the root of the server `/` won't show anything. Visiting `/webtorrent/` will list all torrents. Access individual torrents at `/webtorrent/<infohash>` where `infohash` is the hash of the torrent. To acceess individual files, go to `/webtorrent/<infoHash>/<filepath>` where filepath is the file's path in the torrent.\n\n\nHere is a usage example for Node.js:\n\n```js\nconst client = new WebTorrent()\nconst magnetURI = 'magnet: ...'\n\nconst instance = client.createServer()\ninstance.server.listen(0) // start the server listening to a port\n// 0 automatically finds an open port instead of forcing a potentially used one\nclient.add(magnetURI, torrent => {\n  // create HTTP server for this torrent\n\n  const url = torrent.files[0].streamURL\n  console.log(url)\n  // visit http://localhost:<port>/webtorrent/ to see a list of torrents\n\n  // access individual torrents at http://localhost:<port>/webtorrent/<infoHash> where infoHash is the hash of the torrent\n})\n\n// later, cleanup...\ninstance.close()\nclient.destroy()\n```\n\nIn browser needs either [this worker](https://github.com/webtorrent/webtorrent/blob/master/sw.min.js) to be used, or have [this functionality](https://github.com/webtorrent/webtorrent/blob/master/lib/worker.js) implemented.\n\nHere is a user example for browser:\n\n```js\nconst client = new WebTorrent()\nconst magnetURI = 'magnet: ...'\nconst player = document.querySelector('video')\n\nconst controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\nawait navigator.serviceWorker.ready\nclient.createServer({ controller })\n\nclient.add(magnetURI, torrent => {\n  const url = torrent.files[0].streamURL\n  console.log(url)\n  // visit <origin>/webtorrent/ to see a list of torrents, where origin is the worker registration scope.\n  // access individual torrents at /webtorrent/<infoHash> where infoHash is the hash of the torrent\n})\n\n// later, cleanup...\nclient._server.close()\nclient.destroy()\n```\nNeeds either [this worker](https://github.com/webtorrent/webtorrent/blob/master/sw.min.js) to be used, or have [this functionality](https://github.com/webtorrent/webtorrent/blob/master/lib/worker.js) implemented.\n\n# Torrent API\n\n## `torrent.name`\n\nName of the torrent (string).\n\n## `torrent.infoHash`\n\nInfo hash of the torrent (string).\n\n## `torrent.magnetURI`\n\nMagnet URI of the torrent (string).\n\n## `torrent.torrentFile`\n\n`.torrent` file of the torrent (Uint8Array).\n\n## `torrent.torrentFileBlob`\n\n`.torrent` file of the torrent (Blob). Useful for creating Blob URLs via `URL.createObjectURL(blob)`\n\n## `torrent.announce[...]`\n\nArray of all tracker servers. Each announce is an URL (string).\n\n## `torrent.files[...]`\n\nArray of all files in the torrent. See documentation for `File` below to learn what\nmethods/properties files have.\n\n## `torrent.pieces[...]`\n\nArray of all pieces in the torrent. See documentation for `Piece` below to learn what\nproperties pieces have. Some pieces can be null.\n\n## `torrent.pieceLength`\n\nLength in bytes of every piece but the last one.\n\n## `torrent.lastPieceLength`\n\nLength in bytes of the last piece (<= of `torrent.pieceLength`).\n\n## `torrent.timeRemaining`\n\nTime remaining for download to complete (in milliseconds).\n\n## `torrent.received`\n\nTotal bytes received from peers (*including* invalid data).\n\n## `torrent.downloaded`\n\nTotal *verified* bytes received from peers.\n\n## `torrent.uploaded`\n\nTotal bytes uploaded to peers.\n\n## `torrent.downloadSpeed`\n\nTorrent download speed, in bytes/sec.\n\n## `torrent.uploadSpeed`\n\nTorrent upload speed, in bytes/sec.\n\n## `torrent.progress`\n\nTorrent download progress, from 0 to 1.\n\n## `torrent.ratio`\n\nTorrent \"seed ratio\" (uploaded / downloaded).\n\n## `torrent.numPeers`\n\nNumber of peers in the torrent swarm.\n\n## `torrent.maxWebConns`\n\nMax number of simultaneous connections per web seed, as passed in the options.\n\n## `torrent.path`\n\nTorrent download location.\n\n## `torrent.ready`\n\nTrue when the torrent is ready to be used (i.e. metadata is available and store is\nready).\n\n## `torrent.paused`\n\nTrue when the torrent has stopped connecting to new peers. Note that this does\nnot pause new incoming connections, nor does it pause the streams of existing\nconnections or their wires.\n\n## `torrent.done`\n\nTrue when all the torrent files have been downloaded.\n\n## `torrent.length`\n\nSum of the files length (in bytes).\n\n## `torrent.created`\n\nDate of creation of the torrent (as a [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object).\n\n## `torrent.createdBy`\n\nAuthor of the torrent (string).\n\n## `torrent.comment`\n\nA comment optionnaly set by the author (string).\n\n## `torrent.destroy([opts], [callback])`\n\nRemove the torrent from its client. Destroy all connections to peers and delete all saved file metadata.\n\nIf `opts.destroyStore` is specified, it will override `opts.destroyStoreOnDestroy` passed when the torrent was added.\nIf truthy, `store.destroy()` will be called, which will delete the torrent's files from the disk.\n\nIf `callback` is provided, it will be called when the torrent is fully destroyed,\ni.e. all open sockets are closed, and the storage is either closed or destroyed.\n\n## `torrent.addPeer(peer)`\n\nAdd a peer to the torrent swarm. This is advanced functionality. Normally, you should not\nneed to call `torrent.addPeer()` manually. WebTorrent will automatically find peers using\nthe tracker servers or DHT. This is just for manually adding a peer to the client.\n\nThis method should not be called until the `infoHash` event has been emitted.\n\nReturns `true` if peer was added, `false` if peer was blocked by the loaded blocklist.\n\nThe `peer` argument must be an address string in the format `12.34.56.78:4444` (for\nnormal TCP/uTP peers), or a [`simple-peer`](https://github.com/feross/simple-peer)\ninstance (for WebRTC peers).\n\n## `torrent.addWebSeed(urlOrConn)`\n\nAdd a web seed to the torrent swarm. For more information on BitTorrent web seeds, see\n[BEP19](http://www.bittorrent.org/beps/bep_0019.html).\n\nIn the browser, web seed servers must have proper CORS (Cross-origin resource sharing)\nheaders so that data can be fetched across domain.\n\nThe `urlOrConn` argument is either the web seed URL, or an object that provides a custom\nweb seed implementation. A custom conn object is a duplex stream that speaks the bittorrent\nwire protocol and pretends to be a remote peer. It must have a `connId` property that\nuniquely identifies the custom web seed.\n\n## `torrent.removePeer(peer)`\n\nRemove a peer from the torrent swarm. This is advanced functionality. Normally, you should\nnot need to call `torrent.removePeer()` manually. WebTorrent will automatically remove\npeers from the torrent swarm when they're slow or don't have pieces that are needed.\n\nThe `peer` argument should be an address (i.e. \"ip:port\" string), a peer id (hex string),\nor `simple-peer` instance.\n\n## `torrent.select(start, end, [priority], [notify])`\n\nSelects a range of pieces to prioritize starting with `start` and ending with `end` (both\ninclusive) at the given `priority`. `notify` is an optional callback to be called when the\nselection is updated with new data.\n\n## `torrent.deselect(start, end)`\n\nDeprioritizes a range of previously selected pieces.\n\n## `torrent.critical(start, end)`\n\nMarks a range of pieces as critical priority to be downloaded ASAP. From `start` to `end`\n(both inclusive).\n\n\n## `torrent.pause()`\n\nTemporarily stop connecting to new peers. Note that this does not pause new incoming\nconnections, nor does it pause the streams of existing connections or their wires.\n\n## `torrent.resume()`\n\nResume connecting to new peers.\n\n## `torrent.rescanFiles([function callback (err) {}])`\n\nVerify the hashes of all pieces in the store and update the bitfield for any new valid\npieces. Useful if data has been added to the store outside WebTorrent, e.g. if another\nprocess puts a valid file in the right place. Once the scan is complete,\n`callback(null)` will be called (if provided), unless the torrent was destroyed during\nthe scan, in which case `callback` will be called with an error.\n\n## `torrent.on('infoHash', function () {})`\n\nEmitted when the info hash of the torrent has been determined.\n\n## `torrent.on('metadata', function () {})`\n\nEmitted when the metadata of the torrent has been determined. This includes the full\ncontents of the .torrent file, including list of files, torrent length, piece hashes,\npiece length, etc.\n\n## `torrent.on('ready', function () {})`\n\nEmitted when the torrent is ready to be used (i.e. metadata is available and store is\nready).\n\n## `torrent.on('warning', function (err) {})`\n\nEmitted when there is a warning. This is purely informational and it is not necessary to\nlisten to this event, but it may aid in debugging.\n\n## `torrent.on('error', function (err) {})`\n\nEmitted when the torrent encounters a fatal error. The torrent is automatically destroyed\nand removed from the client when this occurs.\n\n**Note:** Torrent errors are emitted at `torrent.on('error')`. If there are no\n'error' event handlers on the torrent instance, then the error will be emitted at\n`client.on('error')`. This prevents throwing an uncaught exception (unhandled\n'error' event), but it makes it impossible to distinguish client errors versus\ntorrent errors. Torrent errors are not fatal, and the client is still usable\nafterwards. Therefore, always listen for errors in both places\n(`client.on('error')` and `torrent.on('error')`).\n\n## `torrent.on('idle', function () {})`\n\nEmitted when the torrent has no more active selections to download, and starts idling \nor seeding. This can happen when a file is fully downloaded, or when the desired pieces\nhave been downloaded.\n\n## `torrent.on('done', function () {})`\n\nEmitted when all the torrent files have been downloaded.\n\nHere is a usage example:\n\n```js\ntorrent.on('done', () => {\n  console.log('torrent finished downloading')\n  for (const file of torrent.files) { \n    // do something with file\n  }\n})\n```\n\n## `torrent.on('download', function (bytes) {})`\n\nEmitted whenever data is downloaded. Useful for reporting the current torrent status, for\ninstance:\n\n```js\ntorrent.on('download', bytes => {\n  console.log('just downloaded: ' + bytes)\n  console.log('total downloaded: ' + torrent.downloaded)\n  console.log('download speed: ' + torrent.downloadSpeed)\n  console.log('progress: ' + torrent.progress)\n})\n```\n\n## `torrent.on('upload', function (bytes) {})`\n\nEmitted whenever data is uploaded. Useful for reporting the current torrent status.\n\n## `torrent.on('wire', function (wire) {})`\n\nEmitted whenever a new peer is connected for this torrent. `wire` is an instance of\n[`bittorrent-protocol`](https://github.com/webtorrent/bittorrent-protocol), which is a\nnode.js-style duplex stream to the remote peer. This event can be used to specify\n[custom BitTorrent protocol extensions](https://github.com/webtorrent/bittorrent-protocol#extension-api).\n\nHere is a usage example:\n\n```js\nimport MyExtension from './my-extension'\n\ntorrent1.on('wire', (wire, addr) => {\n  console.log('connected to peer with address ' + addr)\n  wire.use(MyExtension)\n})\n```\n\nSee the `bittorrent-protocol`\n[extension api docs](https://github.com/webtorrent/bittorrent-protocol#extension-api) for more\ninformation on how to define a protocol extension.\n\n## `torrent.on('noPeers', function (announceType) {})`\n\nEmitted every couple of seconds when no peers have been found. `announceType` is either `'tracker'`, `'dht'`, `'lsd'`, or `'ut_pex'` depending on which announce occurred to trigger this event. Note that if you're attempting to discover peers from a tracker, a DHT, a LSD, and PEX you'll see this event separately for each.\n\n## `torrent.on('verified', function (index) {})`\n\nEmitted every time a piece is verified, the value of the event is the index of the verified piece.\n\n# File API\n\nWebtorrent Files closely mimic W3C [Files](https://developer.mozilla.org/en-US/docs/Web/API/File)/[Blobs](https://developer.mozilla.org/en-US/docs/Web/API/Blob) except for `slice` where instead you pass the offsets as objects to the arrayBuffer/stream/createReadStream functions.\n\n## `file.name`\n\nFile name, as specified by the torrent. *Example: 'some-filename.txt'*\n\n## `file.path`\n\nFile path, as specified by the torrent. *Example: 'some-folder/some-filename.txt'*\n\n## `file.length` or `file.size`\n\nFile length (in bytes), as specified by the torrent. *Example: 12345*\n\n## `file.type`\n\nMime type of the file, falls back to `application/octet-stream` if the type is not recognized.\n\n## `file.downloaded`\n\nTotal *verified* bytes received from peers, for this file.\n\n## `file.progress`\n\nFile download progress, from 0 to 1.\n\n## `file.select([priority])`\n\nSelects the file to be downloaded, at the given `priority`.\nUseful if you know you need the file at a later stage.\n\n## `file.deselect()`\n\nDeselects the file's specific priority, which means it won't be downloaded unless someone creates a stream for it.\n\n## `stream = file.createReadStream([opts])`\n\nCreate a [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable)\nto the file. Pieces needed by the stream will be prioritized highly and fetched from the\nswarm first.\n\nYou can pass `opts` to stream only a slice of a file.\n\n```js\n{\n  start: startByte,\n  end: endByte\n}\n```\n\nBoth `start` and `end` are inclusive.\n\n## `stream = file.stream(opts)`\n\nCreate a W3C [ReadableStream](https://devdocs.io/dom/readablestream)\nto the file. Pieces needed by the stream will be prioritized highly and fetched from the\nswarm first.\n\nYou can pass `opts` to stream only a slice of a file.\n\n```js\n{\n  start: startByte,\n  end: endByte\n}\n```\n\nBoth `start` and `end` are inclusive.\n\n## `iterator = file[Symbol.asyncIterator]`\n\nCreate an [async iterator](https://devdocs.io/javascript/global_objects/symbol/asynciterator)\nto the file. Pieces needed by the stream will be prioritized highly and fetched from the\nswarm first.\n\nYou can pass `opts` to iterate only a slice of a file.\n\n```js\n{\n  start: startByte,\n  end: endByte\n}\n```\n\nBoth `start` and `end` are inclusive.\n\nExample:\n\n```js\nfor await (const chunk of file) {\n  // do something with chunk\n}\n```\n\n## `arrayBuffer = await file.arrayBuffer(opts)`\n\nGet the file contents as a `ArrayBuffer`.\n\nYou can pass `opts` to get only a part of an ArrayBuffer.\n\n```js\n{\n  start: startByte,\n  end: endByte\n}\n```\n\n```js\nconst data = await file.arrayBuffer()\nconsole.log(data) // ArrayBuffer { [Uint8Contents]: <00 62 00 01>, byteLength: 4 }\n```\n## `blob = await file.blob(opts)`\n\nGet a W3C `Blob` object which contains the file data.\n\nUseful for creating Blob URLs via `URL.createObjectURL(blob)`.\n\nYou can pass `opts` to get only a part of an Blob.\n\n```js\n{\n  start: startByte,\n  end: endByte\n}\n```\n## `file.streamTo(elem)` *(browser only)*\n\nRequires `client.createServer` to be ran beforehand. Sets the element source to the file's streaming URL. Supports streaming, seeking and all browser codecs and containers.\n\nSupport table:\n|Containers|Chromium|Mobile Chromium|Edge|Chrome|Firefox|\n|-|:-:|:-:|:-:|:-:|:-:|\n|3g2|✓|✓|✓|✓|✓|\n|3gp|✓|✓|✓|✓|✘|\n|avi|✘|✘|✘|✘|✘|\n|m2ts|✘|✘|✓**|✘|✘|\n|m4v etc.|✓*|✓*|✓*|✓*|✓*|\n|mp4|✓|✓|✓|✓|✓|\n|mpeg|✘|✘|✘|✘|✘|\n|mov|✓|✓|✓|✓|✓|\n|ogm ogv|✓|✓|✓|✓|✓|\n|webm|✓|✓|✓|✓|✓|\n|mkv|✓|✓|✓|✓|✘|\n\n\\* Container might be supported, but the container's codecs might not be.  \n\\*\\* Documented as working, but can't reproduce.  \n\n|Video Codecs|Chromium|Mobile Chromium|Edge|Chrome|Firefox|\n|-|:-:|:-:|:-:|:-:|:-:|\n|AV1|✓|✓|✓|✓|✓|\n|H.263|✘|✘|✘|✘|✘|\n|H.264|✓|✓|✓|✓|✓|\n|H.265|✘|✘|✓*|✓|✘|\n|MPEG-2/4|✘|✘|✘|✘|✘|\n|Theora|✓|✘|✓|✓|✓|\n|VP8/9|✓|✓|✓|✓|✓|\n\n\\* Requires MSStore extension which you can get by opening this link `ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq` while using Edge.\n\n|Audio Codecs|Chromium|Mobile Chromium|Edge|Chrome|Firefox|\n|-|:-:|:-:|:-:|:-:|:-:|\n|AAC|✓|✓|✓|✓|✓|\n|AC3|✘|✘|✓|✘|✘|\n|DTS|✘|✘|✘|✘|✘|\n|EAC3|✘|✘|✓|✘|✘|\n|FLAC|✓|✓*|✓|✓|✓|\n|MP3|✓|✓|✓|✓|✓|\n|Opus|✓|✓|✓|✓|✓|\n|TrueHD|✘|✘|✘|✘|✘|\n|Vorbis|✓|✓|✓|✓|✓*|\n\n\\* Might not work in some video containers.\n\nSince container and codec support is browser dependent these values might change over time.\n## `file.streamURL`\n\nRequires `client.createServer` to be ran beforehand.\n\nReturns the URL of the file which is recognized by the HTTP server.\n\nThis method is useful both for servers which run WebTorrent or client apps. A few examples:\n\n```js\nconst url = file.streamURL\n\n// create download link\nif (err) throw err\nconst a = document.createElement('a')\na.target = \"_blank\"\na.href = url\na.textContent = 'Download ' + file.name\ndocument.body.append(a)\n\n// render an image on a canvas\nconst canvas = document.getElementById('canvas')\nconst ctx = canvas.getContext('2d')\nconst img = new Image()\nconst loaded = new Promise(resolve => img.onload = resolve)\nimg.src = url\nawait loaded\nctx.drawImage(img)\n\n// send the file URL to another device on the network which can then display the file remotely [nodejs only]\nimport networkAddress from 'network-address'\n\nconst networkURL = `http://${networkAddress()}:${client._server.port}${url}`\nsendRemote(networkURL)\n```\n\n## `file.on('stream', function ({ stream, file, req }, function pipeCallback) {})`\n\nThis is advanced functionality.\n\nEmitted every time when the HTTP server creates a new read stream. For example every time the user seeks a video. This allows you to find out what parts of the file the browser is requesting, and how it's requesting them. Additionally it allows you to manipulate the data that's being streamed.\n\nYields an object with 3 values and a function:\n- object - information about the request,\n  - `stream` - a [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) which the user can manipulate,\n  - `file` - the file object that's being streamed,\n  - `req` - all the request information which the browser made when requesting the data.\n- function - if you pipe the `stream`, use this function to callback the piped stream **synchronously!** Otherwise the playback is likely to break.\n\nExample usage:\n```js\nfile.on('stream', ({ stream, file, req }, cb) => {\n  if (req.destination === 'audio' && file.name.endsWith('.dts')) {\n    const transcoder = new SomeAudioTranscoder()\n    cb(transcoder)\n    // do other things\n  }\n})\n```\n\n## `file.on('iterator', function ({ stream, file, req }, function transformCallback) {})`\n\nThis is advanced functionality.\n\nSame as with the `stream` event this is emitted by the HTTP server when it creates an async iterator for the file's data. This is used for very low-level manipulation of the incoming data and they way it's generated for example you could potentially accelerate how fast and how much data is pulled from the torrent.\n\nYields an object with 3 values and a function:\n- object - information about the request,\n  - `iterator` - an [async iterator](https://devdocs.io/javascript/global_objects/symbol/asynciterator) which the user can manipulate,\n  - `file` - the file object that's being streamed,\n  - `req` - all the request information which the browser made when requesting the data.\n- function - if you wish to transform the `iterator`, use this function to callback the transformed iterator **synchronously!** Otherwise the playback is likely to break.\n\nExample usage:\n```js\nimport par from 'it-parallel'\n\nfile.on('iterator', ({ iterator, file, req }, cb) => {\n  const transform = par(iterator, { concurrency: 5, ordered: true })\n  cb(transform)\n})\n```\n\n## `file.includes(piece)`\nCheck if the piece number contains this file's data.\n\n## `file.on('done', function () {})`\n\nEmitted when the file has been downloaded.\n\n# Piece API\n\n## `piece.length`\n\nPiece length (in bytes). *Example: 12345*\n\n## `piece.missing`\n\nPiece missing length (in bytes). *Example: 100*\n\n# Wire API\n\n## `wire.peerId`\n\nRemote peer id (hex string)\n\n## `wire.type`\n\nConnection type ('webrtc', 'tcpIncoming', 'tcpOutgoing', 'utpIncoming', 'utpOutgoing', 'webSeed')\n\n## `wire.uploaded`\n\nTotal bytes uploaded to peer.\n\n## `wire.downloaded`\n\nTotal bytes downloaded from peer.\n\n## `wire.uploadSpeed`\n\nPeer upload speed, in bytes/sec.\n\n## `wire.downloadSpeed`\n\nPeer download speed, in bytes/sec.\n\n## `wire.remoteAddress`\n\nPeer's remote address. Only exists for tcp/utp peers.\n\n## `wire.remotePort`\n\nPeer's remote port. Only exists for tcp/utp peers.\n\n## `wire.destroy()`\n\nClose the connection with the peer. This however doesn't prevent the peer from simply re-connecting.\n"
  },
  {
    "path": "docs/bep_support.md",
    "content": "# BEP Support\n\nThese are the [BitTorrent Extension Protocols (BEP)](https://www.bittorrent.org/beps/bep_0001.html) supported by Webtorrent:\n\n:white_check_mark: = implemented\n\n:heavy_minus_sign: = not implemented (feel free to open an issue)\n\n:x: = cannot be implemented\n\n| Name | Link | Node.js | Browser |\n|---|---|---|---|\n| Distributed hash table (DHT) | [BEP 5](https://www.bittorrent.org/beps/bep_0005.html) | :white_check_mark: | :heavy_minus_sign: |\n| Fast Extension | [BEP 6](https://www.bittorrent.org/beps/bep_0006.html) | :white_check_mark: | :white_check_mark: |\n| IPv6 Tracker Extension | [BEP 7](https://www.bittorrent.org/beps/bep_0007.html) | :heavy_minus_sign: | :heavy_minus_sign: |\n| Magnet links | [BEP 9](https://www.bittorrent.org/beps/bep_0009.html) | :white_check_mark: | :white_check_mark: |\n| Extension Protocol | [BEP 10](https://www.bittorrent.org/beps/bep_0010.html) | :white_check_mark: | :white_check_mark: |\n| Peer Exchange (PEX) | [BEP 11](https://www.bittorrent.org/beps/bep_0011.html) | :white_check_mark: | :heavy_minus_sign: [webtorrent#1191](https://github.com/webtorrent/webtorrent/issues/1191) |\n| Local Service Discovery (LSD) | [BEP 14](https://www.bittorrent.org/beps/bep_0014.html) | :white_check_mark: | :x: |\n| UDP Tracker Protocol | [BEP 15](https://www.bittorrent.org/beps/bep_0015.html) | :white_check_mark: | :x: |\n| WebSeed - HTTP/FTP Seeding (GetRight style) | [BEP 19](https://www.bittorrent.org/beps/bep_0019.html) | :white_check_mark: | :white_check_mark: |\n| Tracker Returns Compact Peer Lists | [BEP 23](https://www.bittorrent.org/beps/bep_0023.html) | :white_check_mark: | :heavy_minus_sign: |\n| Private Torrents | [BEP 27](https://www.bittorrent.org/beps/bep_0027.html) | :white_check_mark: | :white_check_mark: |\n| uTorrent transport protocol (uTP) | [BEP 29](https://www.bittorrent.org/beps/bep_0029.html) | :white_check_mark: | :x: |\n| DHT Extensions for IPv6 | [BEP 32](https://www.bittorrent.org/beps/bep_0032.html) | :heavy_minus_sign: [bittorrent-dht#88](https://github.com/webtorrent/bittorrent-dht/issues/88) | :heavy_minus_sign: |\n| Storing arbitrary data in the DHT | [BEP 44](https://www.bittorrent.org/beps/bep_0044.html) | :heavy_minus_sign: | :heavy_minus_sign: |\n| Updating Torrents Via DHT Mutable Items | [BEP 46](https://www.bittorrent.org/beps/bep_0046.html) | :heavy_minus_sign: [webtorrent#886](https://github.com/webtorrent/webtorrent/issues/886) | :heavy_minus_sign: [webtorrent#886](https://github.com/webtorrent/webtorrent/issues/886) |\n| Tracker Protocol Extension: Scrape | [BEP 48](https://www.bittorrent.org/beps/bep_0048.html) | :white_check_mark: | :white_check_mark: |\n| Magnet URI extension - Select specific file indices for download | [BEP 53](https://www.bittorrent.org/beps/bep_0053.html) | :white_check_mark: | :white_check_mark: |\n| BitTorrent Protocol v2 | [BEP 52](https://www.bittorrent.org/beps/bep_0052.html) | :heavy_minus_sign: [webtorrent#1117](https://github.com/webtorrent/webtorrent/issues/1117) | :heavy_minus_sign: [webtorrent#1117](https://github.com/webtorrent/webtorrent/issues/1117) |\n"
  },
  {
    "path": "docs/faq.md",
    "content": "# Frequently Asked Questions\n\n## What is WebTorrent?\n\n**WebTorrent** is the first torrent client that works in the **browser**. YEP,\nTHAT'S RIGHT. THE BROWSER.\n\nIt's written completely in JavaScript – the language of the web – and uses\n**WebRTC** for true peer-to-peer transport. No browser plugin, extension, or\ninstallation is required.\n\nUsing open web standards, WebTorrent connects website users together to form a\ndistributed, decentralized browser-to-browser network for efficient file transfer.\n\n## Why is this cool?\n\nImagine a video site like YouTube, where **visitors help to host the site's\ncontent**. The more people that use a WebTorrent-powered website, the faster and\nmore resilient it becomes.\n\nBrowser-to-browser communication **cuts out the middle-man** and lets people\ncommunicate on their own terms. No more client/server – just a network of peers,\nall equal. WebTorrent is the first step in the journey to\n[redecentralize][redecentralize] the Web.\n\n> The way we code the Web will determine the way we live online. So we need to bake\n> our values into our code. Freedom of expression needs to be baked into our code.\n> Privacy should be baked into our code. Universal access to all knowledge. But\n> right now, those values are not embedded in the Web.\n>\n> <cite>— Brewster Kahle, Founder of the Internet Archive (from [Locking the Web Open][brewster])\n\n## What are some use cases for WebTorrent?\n\nOne of the most exciting uses for WebTorrent is **peer-assisted delivery**.\nNon-profit projects like [Wikipedia][wikipedia] and the [Internet\nArchive][archive] could reduce bandwidth and hosting costs by letting visitors\nchip in. Popular content is served browser-to-browser, quickly and cheaply.\nRarely-accessed content is served reliably over HTTP from the origin server.\n\nThere are also exciting **business use cases**, from CDNs to app delivery.\n\n> WebTorrent has significant business potential to radically change the traditional\n> notion of client-server, with applications for internal infrastructure and\n> external closed user communications. WebTorrent has moved from an “idea” to a\n> science experiment to now on the edge of being viable. This is like really,\n> seriously cool.\n>\n> <cite>— Chris Kranky (from [\"WebTorrent: Rethinking Delivery\"][kranky-article])</cite>\n\n[wikipedia]: https://www.wikipedia.org/\n[archive]: https://archive.org/index.php\n[kranky-article]: https://www.chriskranky.com/webtorrent-rethinking-delivery/\n[redecentralize]: http://redecentralize.org/about/\n[brewster]: https://blog.archive.org/2015/02/11/locking-the-web-open-a-call-for-a-distributed-web/\n\n## Who is using WebTorrent today?\n\nWebTorrent is still pretty new, but it's already being used in cool ways:\n\n- **[WebTorrent Desktop][webtorrent-desktop]** - Streaming torrent app. For Mac, Windows, and Linux. ([source code][webtorrent-desktop-source])\n- **[Wormhole][wormhole]** – Simple, private file sharing (built by the WebTorrent team)\n- **[Instant.io][instant.io]** – Streaming file transfer over WebTorrent ([source code][instant.io-source])\n- **[GitTorrent][gittorrent]** - Decentralized GitHub using BitTorrent and Bitcoin ([source code][gittorrent-source])\n- **[File.pizza][filepizza]** - Free peer-to-peer file transfers in your browser ([source code][filepizza-source])\n- **[Webtorrentapp][webtorrentapp]** – Platform for launching web apps from torrents\n- **[Fastcast][fastcast]** – Gallery site with some videos ([source code][fastcast-source])\n- **[Tokenly Pockets][pockets]** - Digital token issuance with WebTorrent-based metadata ([source code][pockets-source])\n- **[βTorrent][btorrent]** - Fully-featured browser WebTorrent client ([source code][btorrent-source])\n- **[PeerWeb][peerweb]** - Fetch and render a static website from a torrent\n- **[YouShark][youshark]** - Web music player for WebTorrent ([source code][youshark-source])\n- **[Twister][twister]** - Decentralized microblogging service, using WebTorrent for media attachments ([source code][twister-source])\n- **[webtorrent-cljs][webtorrent-cljs]** - Clojurescript wrapper for WebTorrent\n- **[Squidlink][squidlink]** - Transfer files from A to B without the Cloud ([source code][squidlink-source])\n- **[Web2web][web2web]** - Server-less & domain-less websites updatable via torrents and bitcoin blockchain ([source code][web2web-source])\n- **[Magnet Player][magnet-player]** - Stream video torrents directly from your browser ([source code][magnet-player-source])\n- **[PeerFast][peerfast]** - First P2P Internet Speed Test ([source code][peerfast-source])\n- **[TorrentMedia][torrentmedia]** - Fully-featured desktop WebTorrent client\n- **[Gaia 3D Star Map][gaia]** - 2 million stars, rendered in 3D with WebGL, WebVR, and WebTorrent\n- **[Watchtor][watchtor]** - A minimalistic approach for online torrent watching ([source code][watchtor-source])\n- **[FileMap][filemap]** - Share files by pinning them to geographic locations\n- **[WebTorrent Google Cast (WTGC)][wtgc]** - Play WebTorrent media on Google Cast devices ([source code][wtgc-source])\n- **[CodeDump][codedump]** - A WebTorrent based code pastebin ([source code][codedump-source])\n- **[Lunik-Torrent][lunik-torrent]** - WebTorrent downloader and file manager. ([source code][lunik-torrent-source])\n- **[BitChute][bitchute]** - A decentralized video streaming social network\n- **[Planktos][planktos]** - Enables websites to serve their static content over BitTorrent ([source code][planktos-source])\n- **[P2P-CDN][p2pcdn]** - WebTorrent CDN with graceful degradation\n- **[PearPlayer][PearPlayer]** - A WebTorrent based multi-source and multi-protocol P2P streaming media player\n- **[Tcloud][tcloud]** - File sharing and torrent downloading\n- **[Webtorrent-webui][webtorrent-webui]** - A WebTorrent client with a simple web interface for easy remote usage\n- **[CineTimes][cinetimes]** - A streaming website of public domain movies\n- **[Bitlove.org][bitlove]** - Your favorite podcasts via BitTorrent\n- **[Live-torrent][live-torrent]** - Simple implementation of a webtorrent powered live streaming solution ([source code][live-torrent-source])\n- **[CDNBye][CDNBye]** -  CDNBye implements WebRTC datachannel to scale live/vod video streaming by peer-to-peer network using bittorrent-like protocol.\n- **[Files.fm][Files.fm]** - a fast file sharing and freemium cloud storage service that uses P2P technology to accelerate unlimited downloads and file distribution.\n- **[imgest][imgest]** - Serverless shareable image gallery built with JavaScript and WebTorrent.\n- **[Bugout][Bugout]** - build and run back-end web services in a browser tab.\n- **[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.\n- **[Hubzilla][hubzilla]** - WebTorrent player integration into posts ([source code][hubzilla-source])\n- **[Come Over][comeover]** - Video stream sharing to watch movies together ([source code][comeover-source])\n- **[PeerWebSite][peerwebsite]** - Peer to Peer Web Site hosting at your fingertips! Send full featured HTML (incl. CSS, JS) sites from your browser and attach files eg. videos, images, etc.\n- **[CipherTorrent][cipher-torrent]** - Online and offline browser torrent client ([source code][cipher-torrent-source])\n- **[Slingcode][Slingcode]** - make, run, and share web apps P2P in the browser.\n- **[Torrent🧲Parts][TorrentParts]** - A website to inspect and edit what's in your Torrent file or Magnet link\n- **[Live On Torrent][liveontorrent]** - A free plataform to live streaming on browser.\n- **[WebTorrentPlayer][webtorrentplayer]** - High performance, no compromise video player for WebTorrent ([source code][webtorrentplayer-source])\n- **[Storm][storm]** - A beautiful torrent client for desktop.\n- **[atorable-loader][atorable-loader-source]** - Resolves Webpack import/require() of a file into a Webtorrent magnet uri.\n- **[atorable-react][atorable-react]** -  React component that processes a Webtorrent magnet uri for viewing or other custom uses. ([source code][atorable-react-source])\n- **[Iris][iris-messenger]** - Decentralized social networking application. ([source code][iris-messenger-source])\n- **[Miru][miru-source]** - Stream anime torrents, real-time with no waiting for downloads. ([source code][miru-source])\n- **[Haven Torrent Client][haven-torrent-client]** - Simple and Fast Torrent Client for the web. ([source code][haven-torrent-client-source])\n- **[CrawFish][CrawFish]** - Desktop/Web/Server torrent client, with streaming support and integrated search (Works in docker, windows and has a WebUI that can be accessed by remote). ([source code][CrawFish-source])\n- **[Niwder][Niwder]** - Web based platform to transfer torrents to Mega.nz and Google Drive on the cloud. ([source code][Niwder-source])\n- **[Chitchatter][Chitchatter]** - A peer-to-peer chat app that is serverless, decentralized, and ephemeral. Uses WebTorrent to initiate peer connections. ([source code][Chitchatter-source])\n- **[P2PFileShare][P2PFileShare]** - A peer-to-peer file-sharing app that allows users to send and receive files directly from your browser.\n- **[anacrolix/torrent library][anacrolix-torrent-source]** - A full-featured BitTorrent Golang client package. Some popular torrent clients built with it, such as [distribyted][distribyted-source] and [confluence][confluence-source], enable WebTorrent support by default.\n- **[libtorrent library][libtorrent]** has experimental (disabled by default) support for WebTorrent ([tracking][libtorrent-tracking-pr]).\n- ***Your app here – [Send a pull request][pr] with your URL!***\n<!-- - **[PeerCloud][peercloud]** - Serverless websites via WebTorrent ([source code][peercloud-source]) -->\n<!-- - **[Niagara][niagara]** - Video player webtorrent with subtitles (zipped .srt(s)) -->\n<!-- - **[Vique][vique]** - Video player queue to share videos -->\n\n#### WebTorrent Product Alternatives\n\nThere's also a list of WebTorrent-powered alternatives to centralized services here: [WebTorrent Product Clones][webtorrent-clones]\n\n[webtorrent-clones]: https://github.com/DiegoRBaquero/awesome-webtorrent-clones\n[webtorrent-desktop]: https://webtorrent.io/desktop\n[webtorrent-desktop-source]: https://github.com/webtorrent/webtorrent-desktop\n[wormhole]: https://wormhole.app\n[instant.io-source]: https://github.com/webtorrent/instant.io\n[gittorrent]: http://blog.printf.net/articles/2015/05/29/announcing-gittorrent-a-decentralized-github/\n[gittorrent-source]: https://github.com/cjb/GitTorrent\n[filepizza]: http://file.pizza/\n[filepizza-source]: https://github.com/kern/filepizza\n[peercloud]: https://peercloud.io/\n[peercloud-source]: https://github.com/jhiesey/peercloud\n[webtorrentapp]: https://github.com/alexeisavca/webtorrentapp\n[fastcast]: http://fastcast.nz\n[fastcast-source]: https://github.com/fastcast/fastcast\n[pockets]: https://tokenly.com/\n[pockets-source]: https://github.com/loon3/Tokenly-Pockets\n[btorrent]: https://btorrent.xyz\n[btorrent-source]: https://github.com/DiegoRBaquero/bTorrent\n[peerweb]: https://github.com/retrohacker/peerweb.js\n[niagara]: https://andreapaiola.name/niagara/\n[vique]: https://andreapaiola.name/vique/\n[youshark]: http://youshark.neocities.org/\n[youshark-source]: https://github.com/enorrmann/youshark\n[twister]: http://twister.net.co/?p=589\n[twister-source]: https://github.com/miguelfreitas/twister-html\n[webtorrent-cljs]: https://github.com/cvillecsteele/webtorrent-cljs\n[squidlink]: http://squidl.ink\n[squidlink-source]: https://github.com/darkenvy/Squidl.ink\n[web2web]: https://elendirx.github.io/web2web\n[web2web-source]: https://github.com/elendirx/web2web\n[magnet-player]: https://ferrolho.github.io/magnet-player/\n[magnet-player-source]: https://github.com/ferrolho/magnet-player/\n[peerfast]: https://diegorbaquero.github.io/PeerFast/#\n[peerfast-source]: https://github.com/DiegoRBaquero/PeerFast\n[torrentmedia]: https://github.com/FaCuZ/torrentmedia\n[gaia]: http://charliehoey.com/threejs-demos/gaia_dr1.html\n[watchtor]: https://open-watchtor.hashbase.io\n[watchtor-source]: https://github.com/codealchemist/watchtor\n[filemap]: https://filemap.xyz\n[wtgc]: https://wtgc.firebaseapp.com\n[wtgc-source]: https://github.com/FluorescentHallucinogen/webtorrent-googlecast\n[codedump]: http://ronsoros.github.io\n[codedump-source]: https://github.com/ronsoros/ronsoros.github.io/blob/master/index.html\n[lunik-torrent]: https://tcloud-lunik.herokuapp.com\n[lunik-torrent-source]: https://github.com/Lunik/Lunik-Torrent\n[bitchute]: https://www.bitchute.com\n[planktos]: https://xuset.github.io/planktos/\n[planktos-source]: https://github.com/xuset/planktos\n[p2pcdn]: https://github.com/andreapaiola/P2P-CDN\n[PearPlayer]: https://github.com/PearInc/PearPlayer.js\n[tcloud]: https://github.com/Lunik/tcloud\n[webtorrent-webui]: https://github.com/pldubouilh/webtorrent-webui\n[cinetimes]: http://cinetimes.org/\n[bitlove]: https://bitlove.org/\n[live-torrent]: https://live.computer\n[live-torrent-source]: https://github.com/pldubouilh/live-torrent\n[CDNBye]: https://github.com/cdnbye/hlsjs-p2p-engine\n[Files.fm]: https://files.fm\n[imgest]: https://imgest.hashbase.io\n[Bugout]: https://github.com/chr15m/bugout\n[Slingcode]: https://github.com/chr15m/slingcode\n[p2p-media-loader]: https://github.com/novage/p2p-media-loader\n[hubzilla]: https://hubzilla.org\n[hubzilla-source]: https://github.com/demitas-ace/wtplayer/tree/master/wtplayer\n[comeover]: https://luccadoret.github.io/comeover/home\n[comeover-source]: https://github.com/LucCADORET/comeover\n[peerwebsite]: https://peerweb.site\n[cipher-torrent]: https://torrent.cipherdogs.net\n[cipher-torrent-source]: https://github.com/CipherDogs/cipher-torrent\n[TorrentParts]: https://torrent.parts\n[liveontorrent]: https://www.weboscoder.com/liveontorrent/\n[webtorrentplayer]: https://thaunknown.github.io/webtorrent-player/\n[webtorrentplayer-source]: https://github.com/ThaUnknown/webtorrent-player\n[storm]: https://github.com/nuzzesick/storm-desktop\n[atorable-loader-source]: https://github.com/Atorable/atorable-loader\n[atorable-react]: https://atorable.github.io/atorable-react/\n[atorable-react-source]: https://github.com/Atorable/atorable-react\n[iris-messenger]: https://iris.to\n[iris-messenger-source]: https://github.com/irislib/iris-messenger\n[CrawFish]: https://github.com/drakonkat/crawfish/blob/main/README.md\n[CrawFish-source]: https://github.com/drakonkat/crawfish\n[miru-source]: https://github.com/ThaUnknown/miru\n[haven-torrent-client]: https://haven.pages.dev/torrent-client/public/\n[haven-torrent-client-source]: https://github.com/ThaUnknown/pwa-haven/tree/main/torrent-client\n[Niwder]: https://niwder.niweera.gq\n[Niwder-source]: https://github.com/Niweera/niwder\n[Chitchatter]: https://chitchatter.im/\n[Chitchatter-source]: https://github.com/jeremyckahn/chitchatter\n[P2PFileShare]: https://p2pfileshare.com\n[anacrolix-torrent-source]: https://github.com/anacrolix/torrent\n[distribyted-source]: https://github.com/distribyted/distribyted\n[confluence-source]: https://github.com/anacrolix/confluence\n[libtorrent]: https://libtorrent.org/\n[libtorrent-tracking-pr]: https://github.com/arvidn/libtorrent/pull/4123\n\n## How does WebTorrent work?\n\nThe WebTorrent protocol works just like [BitTorrent protocol][bittorrent-protocol],\nexcept it uses [WebRTC][webrtc] instead of [TCP][tcp]/[uTP][utp] as the transport\nprotocol.\n\nIn order to support [WebRTC's connection model][webrtc-signaling], we made a few\nchanges to the tracker protocol. Therefore, a browser-based WebTorrent client or\n**\"web peer\"** can only connect to other clients that support WebTorrent/WebRTC.\n\nThe protocol changes we made will be published as a\n[BEP](http://www.bittorrent.org/beps/bep_0001.html). Until a spec is written, you\ncan view the source code of the [`bittorrent-tracker`][bittorrent-tracker] package.\n\nOnce peers are connected, the wire protocol used to communicate is exactly the same\nas in normal BitTorrent. This should make it easy for existing popular torrent\nclients like Transmission, and uTorrent to add support for WebTorrent. **Vuze**\n[already has support][vuze-support] for WebTorrent!\n\n![WebTorrent network diagram](https://webtorrent.io/img/network.png)\n\n[bittorrent-protocol]: https://wiki.theory.org/BitTorrentSpecification\n[webrtc-signaling]: http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/#what-is-signaling\n[tcp]: https://en.wikipedia.org/wiki/Transmission_Control_Protocol\n[utp]: https://en.wikipedia.org/wiki/Micro_Transport_Protocol\n[webrtc]: https://en.wikipedia.org/wiki/WebRTC\n[bittorrent-tracker]: https://npmjs.com/package/bittorrent-tracker\n[vuze-support]: https://wiki.vuze.com/w/WebTorrent\n\n## How do I get started?\n\nTo start using WebTorrent, simply include the\n[`webtorrent.min.js`](https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js)\nscript on your page. If you use [browserify](http://browserify.org/) or [webpack](https://webpack.js.org/), you can\n`npm install webtorrent` and `import WebTorrent from 'webtorrent'`.\n\nIt's easy to download a torrent and add it to the page.\n\n```js\nconst client = new WebTorrent()\n\nconst torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'\n\nconst controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\nawait navigator.serviceWorker.ready\nclient.createServer({ controller })\n\nclient.add(torrentId, torrent => {\n  // Torrents can contain many files. Let's use the .mp4 file\n  const file = torrent.files.find(file => {\n    return file.name.endsWith('.mp4')\n  })\n  file.streamTo(document.querySelector('video')) // append the file to the DOM\n})\n```\n\nThis supports video, audio, images, PDFs, Markdown, [and more][render-media], right\nout of the box. There are additional ways to access file content directly, including\nas a node-style stream, Buffer, or Blob URL.\n\nVideo and audio content can be streamed, i.e. playback will start before the full\nfile is downloaded. Seeking works too – WebTorrent dynamically fetches\nthe needed torrent pieces from the network on-demand.\n\n## What is WebRTC?\n\nWebRTC (Web Real-Time Communication) is an API defined by the World Wide Web\nConsortium (W3C) to support browser-to-browser applications like voice calling,\nvideo chat, and P2P file sharing without the need for browser plugins.\n\nWebRTC's `RTCDataChannel` API allows the transfer of data directly from one browser\nto another. This is distinct from `WebSocket` and `XMLHttpRequest` because these are\ndesigned for communication to/from a server, i.e. a client-server model. Data\nChannels allow for **direct browser-to-browser connections**.\n\nThis is revolutionary. Never before could websites connect their users directly to\neach other with super low-latency, encrypted, peer-to-peer connections. This will\nenable next-generation applications in healthcare, education, science, and more.\nWebTorrent is just one example.\n\nWebRTC [works everywhere][webrtc-everywhere], and browser support is excellent.\n**Chrome**, **Firefox**, and **Opera** for Desktop and Android, as well as\n**Microsoft Edge** and **Safari** have support.\n\nYou can learn more about WebRTC data channels at [HTML5Rocks][datachannel-intro].\n\n[webrtc-everywhere]: https://speakerdeck.com/feross/webrtc-everywhere-beyond-the-browser-at-data-terra-nemo-2015\n[datachannel-intro]: http://www.html5rocks.com/en/tutorials/webrtc/datachannels/\n\n## Can WebTorrent clients connect to normal BitTorrent clients?\n\nIn the browser, WebTorrent can only download torrents that are seeded by a\nWebRTC-capable torrent client.\n\nRight now, we know of these WebRTC-capable torrent clients:\n\n- **[WebTorrent Desktop][webtorrent-desktop]** - Open source streaming torrent client. For Mac, Windows, and Linux.\n- **[Vuze][vuze-support]** - Powerful, full-featured torrent client\n- **[Playback][playback]** - Open source JavaScript video player **(super cool!)**\n- **[`webtorrent-hybrid`][webtorrent-hybrid]** - Node.js package (command line and API)\n- **[Instant.io][instant.io]** - Simple WebTorrent client in a website\n- **[βTorrent][btorrent]** - Fully-featured browser WebTorrent client ([source code][btorrent-source])\n- **[TorrentMedia][torrentmedia]** - Desktop WebTorrent client\n- *More coming soon – [Send a PR][pr] to add your client to the list!*\n\n### A bit more about `webtorrent-hybrid`\n\nIn node.js, `webtorrent-hybrid` can download torrents from WebRTC peers or TCP peers\n(i.e. normal peers). You can use WebTorrent as a command line program, or\nprogrammatically as a node.js package.\n\nTo install `webtorrent-hybrid` run the following command in your terminal (add the\n`-g` flag to install the command line program, omit it to install locally):\n\n```\nnpm install webtorrent-hybrid -g\n```\n\nNote: If you just need to use WebTorrent in the browser (where WebRTC is available\nnatively) then use [`webtorrent`][webtorrent] instead, which is faster to install\nbecause it won't need to install a WebRTC implementation.\n\n## Can WebTorrent clients on different websites connect to each other?\n\nYes! **WebTorrent works across the entire web.** WebTorrent clients running on one\ndomain can connect to clients on any other domain. No silos!\n\nThe same-origin policy does not apply to WebRTC connections since they are not\nclient-to-server. Browser-to-browser connections require the cooperation of both\nwebsites (i.e. the WebTorrent script must be present on both sites).\n\n## Who builds WebTorrent?\n\nWebTorrent is built by [Feross Aboukhadijeh][feross] and hundreds of open source\ncontributors. The WebTorrent project is managed by\n[WebTorrent, LLC][webtorrent-io], as a non-profit project.\n\nFeross's other projects include [JavaScript Standard Style][standard],\n[PeerCDN][peercdn] (sold to Yahoo), [Study Notes][studynotes], and\n[YouTube Instant][ytinstant].\n\nIn the past, Feross attended [Stanford University][stanford], did research in the\n[Stanford Human-Computer Interaction][hci] and [Computer Security][seclab] labs,\nand worked at [Quora][quora], [Facebook][facebook], and [Intel][intel].\n\n[standard]: http://standardjs.com/\n[studynotes]: https://www.apstudynotes.org/\n[ytinstant]: http://ytinstant.com/\n[stanford]: http://www.stanford.edu/\n[hci]: http://hci.stanford.edu/\n[seclab]: http://seclab.stanford.edu/\n[quora]: https://www.quora.com/\n[facebook]: https://www.facebook.com/\n[intel]: http://intel.com/\n\n## What is WebTorrent, LLC?\n\n\"WebTorrent, LLC\" is the legal entity that owns WebTorrent. WebTorrent is, and\nalways will be, **non-profit, open source, and free software**.\n\nThere are no plans to make a profit from WebTorrent.\n\n## How is WebTorrent different from PeerCDN?\n\n[PeerCDN][peercdn] was a next-generation CDN powered by WebRTC for efficient\npeer-to-peer delivery of website content. PeerCDN was founded by\n[Feross Aboukhadijeh][feross], [Abi Raja][abi], and [John Hiesey][jhiesey] in\nMarch 2013 and was sold to [Yahoo][yahoo] in December 2013.\n\nWebTorrent is an independent project started by [Feross Aboukhadijeh][feross] in\nOctober 2013. Unlike PeerCDN, **WebTorrent is free software**, licensed under the\n[MIT License][license]. You're free to use it however you like!\n\n> \"Free software\" is a matter of liberty, not price. To understand the concept, you\n> should think of \"free\" as in \"free speech,\" not as in \"free beer.\"\n>\n> <cite>— Richard Stallman, software freedom activist</cite>\n\nOn a technical level, PeerCDN and WebTorrent were built with different goals in\nmind. PeerCDN was optimized for low-latency downloads and fast peer discovery. This\nmeant the client and site owner trusted centralized servers to map file URLs to\ncontent hashes.\n\nWebTorrent, on the other hand, doesn't require clients to trust a centralized\nserver. Given a `.torrent` file or magnet link, the WebTorrent client downloads the\nfile without trusting servers or peers at any point.\n\n[feross]: http://feross.org/\n[abi]: http://abiraja.com/\n[jhiesey]: https://github.com/jhiesey\n[yahoo]: https://www.yahoo.com/\n\n## How can I contribute?\n\nWebTorrent is an **OPEN Open Source Project**. Individuals who make significant and\nvaluable contributions are given commit access to the project to contribute as they\nsee fit. (See the full [contributor guidelines][contributing].)\n\nThere are many ways to help out!\n\n- Report bugs by [creating a GitHub issue][issues].\n- Write code to [fix an open issue][open-issues].\n\nIf you're looking for help getting started, come join us in [Gitter][gitter] or on\nIRC at `#webtorrent` (freenode) and how you can get started.\n\n\n[open-issues]: https://github.com/webtorrent/webtorrent/issues?state=open\n[contributing]: https://github.com/webtorrent/.github/blob/master/CONTRIBUTING.md\n\n## Where can I learn more?\n\nThere are many talks online about WebTorrent. Here are a few:\n\n### Intro to BitTorrent and WebTorrent (JSConf)\n\n<iframe width=\"853\" height=\"480\" src=\"https://www.youtube.com/embed/kxHRATfvnlw?rel=0\" frameborder=\"0\" allowfullscreen></iframe>\n\n### WebRTC Everywhere: Beyond the Browser (slides only)\n\n<script async class=\"speakerdeck-embed\" data-id=\"cb08869f2ac2445c99e8b73a4ac65d2b\" data-ratio=\"1.77777777777778\" src=\"//speakerdeck.com/assets/embed.js\"></script>\n\n## WebTorrent supports sequential streaming. How does this affect the network?\n\nBitTorrent clients select which file pieces to download using an algorithm called\n\"rarest-first\". With every peer in the system trying to download the rarest pieces\nfirst, on average most pieces will have approximately the same availability in the\nnetwork.\n\nIn practice, the rarest-first algorithm is most important on poorly-seeded\ntorrents, or in the first few hours of a torrent being published (when the ratio of\nseeders to leechers is bad).\n\nMost torrent clients support features that cause it to deviate from a pure rarest-\nfirst selection algorithm. For example, the ability to select/deselect or\nprioritize/deprioritize certain files in the torrent.\n\nWebTorrent supports streaming a torrent file \"in order\", which is useful for\nplaying back media files. We’re working on improving the algorithm to switch back\nto a rarest-first strategy when there is not a high-priority need for specific\npieces. In other words, when sufficient media is buffered, we can use the normal\n\"rarest-first\" piece selection algorithm.\n\nBut the fact is that with the speed of today’s internet connections, the user is\ngoing to finish fully downloading the torrent in a fraction of the time it takes to\nconsume it, so they will still spend more time seeding than downloading.\n\nAlso note: BitTorrent Inc.'s official torrent client, uTorrent, offers sequential\ndownloading, as well as selective file downloading, and the BitTorrent network\nremains very healthy.\n\n## Why wasn't WebTorrent designed as an entirely-new, modern protocol?\n\nBitTorrent is the most successful, most widely-deployed P2P protocol in existence.\nIt works really well. Our goal with WebTorrent was to bring BitTorrent to the web\nin a way that interoperates with the existing torrent network.\n\nRe-inventing the protocol would have made WebTorrent fundamentally incompatible\nwith existing clients and prevented adoption. The way we've done it is better. The\nwire protocol is exactly the same, but there's now a new way to connect to peers:\nWebRTC, in addition to the existing TCP and uTP.\n\nAlso, re-inventing the protocol is a huge rabbit hole. There was already a lot of\nrisk when we started the project -- will WebRTC get adopted by all the browser\nvendors? Will the Data Channel implementation stabilize and be performant? Is\nJavaScript fast enough to re-package MP4 videos on-the-fly for streaming playback\nwith the MediaSource API? Our thinking was: Why add inventing a new wire protocol\nand several algorithms to the table?\n\nIt's true that the BitTorrent protocol is dated in some ways. For example, it uses\nit's own strange data encoding called \"bencoding\". If it were invented today, it\nwould probably just use JSON or MessagePack. But, this doesn't matter -- BitTorrent\nworks really well, and we care more about building robust and useful software than\nconceptual purity or the latest software fashions.\n\n## Is it possible to do live streaming with WebTorrent?\n\nWebTorrent cannot do live streaming out-of-the-box, however you can build a live\nstreaming solution on top of WebTorrent.\n\nTorrents are immutable. That means that once a torrent file is created, it cannot\nbe changed without changing the info hash. So, how could one get around this\nlimitation?\n\nA naive approach would be this: The content producer could take every 10 seconds of\nlive content and create a torrent for it. Viewers would follow this \"feed\" of\ntorrent files (or info hashes) and download the content sequentially. Streamers\nwould be around 10-20 seconds behind the live stream.\n\nThis approach can definitely be improved, though! Why not give that a shot yourself\nand share the code?\n\n## Does WebTorrent leak your IP address when using a VPN? I heard that WebRTC leaks your IP address.\n\nNo.\n\nWebRTC data channels do not allow a website to discover your public IP address when\nthere is a VPN in use. The WebRTC discovery process will just find your VPN's IP\naddress and the local network IP address.\n\nLocal IP addresses (e.g. 10.x.x.x or 192.168.x.x) can potentially be used to\n\"fingerprint\" your browser and identify across different sites that you visit,\nlike a third-party tracking cookie. However, this is a separate issue than exposing\nyour real public IP address, and it's worth noting that the browser already\nprovides hundreds of vectors for fingerprinting you\n(e.g. your installed fonts, screen resolution, browser window size, OS version,\nlanguage, etc.).\n\nIf you have a VPN enabled, then WebRTC data channels will not connect to peers\nusing your true public IP address, nor will it be revealed to the JavaScript running\non the webpage.\n\nAt one point in time, WebRTC did have an issue where it would allow a website\nto discover your true public IP address, but this was fixed a long time ago. This\nunfortunate misinformation keeps bouncing around the internet.\n\nThere's now a spec that defines exactly which IP addresses are exposed with WebRTC.\nIf you're interested in further reading, you can read the\n[IP handling spec](https://tools.ietf.org/html/draft-ietf-rtcweb-ip-handling-01)\nfor yourself.\n\n# Troubleshooting\n\n## Why does browser downloading not work? I see no peers!\n\nIt does work! But you can't just use any random magnet uri or `.torrent` file. The\ntorrent must be seeded by a WebRTC-capable client, i.e.\n[WebTorrent Desktop][webtorrent-desktop], [Vuze][vuze-support],\n[webtorrent-hybrid][webtorrent-hybrid], [Playback][playback],\n[instant.io][instant.io], or [βTorrent][btorrent].\n\nIn the browser, WebTorrent can only download torrents that are explicitly seeded to\nweb peers via a WebRTC-capable client. Desktop torrent clients need to support\nWebRTC to connect to web browsers.\n\n## Why does video/audio streaming not work?\n\nStreaming support depends on support for `MediaSource` API in the browser. All\nmodern browsers have `MediaSource` support. In Firefox, support was added in\nFirefox 42 (i.e. Firefox Nightly).\n\n[Many file types][render-media] are supported (again, depending on browser support),\nbut only `.mp4`, `.m4v`, and `.m4a` have full support, including seeking.\n\nTo support video/audio streaming of arbitrary files, WebTorrent uses the\n[`videostream`][videostream] package, which in turn uses [`mp4box.js`][mp4box.js].\nIf you think there may be a bug in one of these packages, please file an issue on\nthe respective repository.\n\n[videostream]: https://npmjs.com/package/videostream\n[mp4box.js]: https://github.com/gpac/mp4box.js\n\n## Got more questions?\n\nOpen an issue on the WebTorrent [issue tracker][issues], or join us in\n[Gitter][gitter] or on IRC at `#webtorrent` (freenode).\n\n[webtorrent-io]: https://webtorrent.io\n[render-media]: https://github.com/feross/render-media/blob/master/index.js\n[gitter]: https://gitter.im/webtorrent/webtorrent\n[instant.io]: https://instant.io\n[issues]: https://github.com/webtorrent/webtorrent/issues\n[license]: https://github.com/webtorrent/webtorrent/blob/master/LICENSE\n[peercdn]: http://www.peercdn.com/\n[playback]: https://mafintosh.github.io/playback/\n[pr]: https://github.com/webtorrent/webtorrent\n[webtorrent-hybrid]: https://npmjs.com/package/webtorrent-hybrid\n[webtorrent]: https://npmjs.com/package/webtorrent\n"
  },
  {
    "path": "docs/free-torrents.md",
    "content": "# Free Torrents\n\nThis is a list of public domain and Creative Commons torrents, useful for testing\npurposes.\n\n- Big Buck Bunny [(torrent file)](https://webtorrent.io/torrents/big-buck-bunny.torrent) [(magnet link)](magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent)\n\n- Cosmos Laundromat [(torrent file)](https://webtorrent.io/torrents/cosmos-laundromat.torrent) [(magnet link)](magnet:?xt=urn:btih:c9e15763f722f23e98a29decdfae341b98d53056&dn=Cosmos+Laundromat&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fcosmos-laundromat.torrent)\n\n- Sintel [(torrent file)](https://webtorrent.io/torrents/sintel.torrent) [(magnet link)](magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent)\n\n- Tears of Steel [(torrent file)](https://webtorrent.io/torrents/tears-of-steel.torrent) [(magnet link)](magnet:?xt=urn:btih:209c8226b299b308beaf2b9cd3fb49212dbd13ec&dn=Tears+of+Steel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Ftears-of-steel.torrent)\n\n- The WIRED CD - Rip. Sample. Mash. Share [(torrent file)](https://webtorrent.io/torrents/wired-cd.torrent) [(magnet link)](magnet:?xt=urn:btih:a88fda5954e89178c372716a6a78b8180ed4dad3&dn=The+WIRED+CD+-+Rip.+Sample.+Mash.+Share&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fwired-cd.torrent)\n"
  },
  {
    "path": "docs/get-started.md",
    "content": "# Get Started with WebTorrent\n\n**WebTorrent** is the first torrent client that works in the **browser**. It's easy\nto get started!\n\n## Install\n\nTo start using WebTorrent, simply include the\n[`webtorrent`](https://esm.sh/webtorrent)\nscript on your page.\n\n```html\n<script type='module'>\n  import WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'\n</script>\n```\n\n### Browserify and Webpack\n\nWebTorrent also works great with [browserify](http://browserify.org/), [webpack](https://webpack.js.org/) and other bundlers, which let\nyou use [node.js](http://nodejs.org/) style `require()` to organize your browser\ncode, and load packages installed by [npm](https://npmjs.org/).\n\nFor an example webpack config see [the webpack bundle config used by webtorrent](/scripts/browser.webpack.js).\n\n```\nnpm install webtorrent\n```\n\nThen use `WebTorrent` like this:\n\n```js\nimport WebTorrent from 'webtorrent'\n```\n\n## Quick Examples\n\n### Downloading a torrent (in the browser)\n\n```js\nimport WebTorrent from 'webtorrent'\n\nconst client = new WebTorrent()\n\n// Sintel, a free, Creative Commons movie\nconst torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'\n\nconst controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\nawait navigator.serviceWorker.ready\nclient.createServer({ controller })\n\nclient.add(torrentId, torrent => {\n  // Torrents can contain many files. Let's use the .mp4 file\n  const file = torrent.files.find(file => {\n    return file.name.endsWith('.mp4')\n  })\n\n  // Display the file by adding it to the DOM.\n  // Supports video, audio, image files, and more!\n  file.streamTo(document.querySelector('video'))\n})\n```\n\nThis supports video, audio, images, PDFs, HTML, right out of the box. There are additional ways to access file content directly, including as a node-style stream, ArrayBuffer, or Blob.\n\nVideo and audio content can be streamed, i.e. playback will start before the full file is downloaded. Seeking works too – WebTorrent dynamically fetches\nthe needed torrent pieces from the network on-demand.\n\n**Note:** Downloading a torrent automatically seeds it, making it available for download by other peers.\n\n### Creating a new torrent and seed it (in the browser)\n\n```js\nimport dragDrop from 'drag-drop'\nimport WebTorrent from 'webtorrent'\n\nconst client = new WebTorrent()\n\n// When user drops files on the browser, create a new torrent and start seeding it!\ndragDrop('body', files => {\n  client.seed(files, torrent => {\n    console.log('Client is seeding ' + torrent.magnetURI)\n  })\n})\n```\n\nThis example uses the [`drag-drop`][drag-drop] package, to make the HTML5 Drag and\nDrop API easier to work with.\n\n**Note:** If you do not use browserify, use the standalone file\n[`dragdrop.min.js`](https://bundle.run/drag-drop).\nThis exports a `DragDrop` function on `window`.\n\n### Download and save a torrent (in Node.js)\n\n```js\nimport WebTorrent from 'webtorrent'\n\nconst client = new WebTorrent()\n\nconst magnetURI = 'magnet: ...'\n\nclient.add(magnetURI, { path: '/path/to/folder' }, torrent => {\n  torrent.on('done', () => {\n    console.log('torrent download finished')\n  })\n})\n```\n\n### Creating a new torrent and seed it (in Node.js)\n\n**Note:** Seeding a torrent that can be downloaded by browser peers (i.e. with support for WebRTC) requires [webtorrent-hybrid](https://github.com/webtorrent/webtorrent-hybrid).\n\n```js\nimport WebTorrent from 'webtorrent-hybrid'\nconst client = new WebTorrent()\n\nclient.seed('/seed-me.txt', torrent => {\n    console.log('Client is seeding ' + torrent.magnetURI)\n})\n```\n\nwhere **seed-me.txt** is a text file which is going to be seeded as a torrent.\n\n### Complete HTML page example\n\nLooking for a more complete example? Look no further! This HTML example has a form input\nwhere the user can paste a magnet link and start a download over WebTorrent.\n\nBest of all, it's a single HTML page, under 70 lines!\n\nIf the torrent contains images, videos, audio, or other playable files (with supported\ncodecs), they will be added to the DOM and streamed, even before the full content is\ndownloaded.\n\n```html\n<!doctype html>\n<html>\n  <body>\n    <h1>Download files using the WebTorrent protocol (BitTorrent over WebRTC).</h1>\n\n    <form>\n      <label for=\"torrentId\">Download from a magnet link: </label>\n      <input name=\"torrentId\", placeholder=\"magnet:\" value=\"magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent\">\n      <button type=\"submit\">Download</button>\n    </form>\n\n    <h2>Log</h2>\n    <div class=\"log\"></div>\n\n    <script type='module'>\n      // Include the latest version of WebTorrent\n      import WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'\n      \n      const client = new WebTorrent()\n\n      client.on('error', err => {\n        console.error('ERROR: ' + err.message)\n      })\n\n      document.querySelector('form').addEventListener('submit', e => {\n        e.preventDefault() // Prevent page refresh\n\n        const torrentId = document.querySelector('form input[name=torrentId]').value\n        log('Adding ' + torrentId)\n        client.add(torrentId, onTorrent)\n      })\n\n      async function onTorrent (torrent) {\n        log('Got torrent metadata!')\n        log(\n          'Torrent info hash: ' + torrent.infoHash + ' ' +\n          '<a href=\"' + torrent.magnetURI + '\" target=\"_blank\">[Magnet URI]</a> ' +\n          '<a href=\"' + URL.createObjectURL(torrent.torrentFileBlob) + '\" target=\"_blank\" download=\"' + torrent.name + '.torrent\">[Download .torrent]</a>'\n        )\n\n        // Print out progress every 5 seconds\n        const interval = setInterval(() => {\n          log('Progress: ' + (torrent.progress * 100).toFixed(1) + '%')\n        }, 5000)\n\n        torrent.on('done', () => {\n          log('Progress: 100%')\n          clearInterval(interval)\n        })\n\n        // Render all files into to the page\n        for (const file of torrent.files) {\n          try {\n            const blob = await file.blob()\n            document.querySelector('.log').append(file.name)\n            log('(Blob URLs only work if the file is loaded from a server. \"http//localhost\" works. \"file://\" does not.)')\n            log('File done.')\n            log('<a href=\"' + URL.createObjectURL(blob) + '\">Download full file: ' + file.name + '</a>')\n          } catch (err) {\n            if (err) log(err.message)\n          }\n        }\n      }\n\n      function log (str) {\n        const p = document.createElement('p')\n        p.innerHTML = str\n        document.querySelector('.log').appendChild(p)\n      }\n    </script>\n  </body>\n</html>\n```\n\n### HTML example with status showing UI\n\nThis complete HTML example mimics the UI of the\n[webtorrent.io](https://webtorrent.io) homepage. It downloads the\n[sintel.torrent](https://webtorrent.io/torrents/sintel.torrent) file, streams it in\nthe browser and outputs some statistics to the user (peers, progress, remaining\ntime, speed...).\n\nYou can try it right now on [CodePen](http://codepen.io/yciabaud/full/XdOeWM/) to\nsee what it looks like and play around with it!\n\nFeel free to replace `torrentId` with other torrent files, or magnet links, but\nkeep in mind that the browser can only download torrents that are seeded by\nWebRTC peers (web peers). Use [WebTorrent Desktop](https://webtorrent.io/desktop)\nor [Instant.io](https://instant.io) to seed torrents to the WebTorrent network.\n\n```html\n<!DOCTYPE html>\n<html>\n\n<head>\n  <meta charset=\"UTF-8\">\n  <title>WebTorrent video player</title>\n  <style>\n    #output video {\n      width: 100%;\n    }\n\n    #progressBar {\n      height: 5px;\n      width: 0%;\n      background-color: #35b44f;\n      transition: width .4s ease-in-out;\n    }\n\n    body.is-seed .show-seed {\n      display: inline;\n    }\n\n    body.is-seed .show-leech {\n      display: none;\n    }\n\n    .show-seed {\n      display: none;\n    }\n\n    #status code {\n      font-size: 90%;\n      font-weight: 700;\n      margin-left: 3px;\n      margin-right: 3px;\n      border-bottom: 1px dashed rgba(255, 255, 255, 0.3);\n    }\n\n    .is-seed {\n      background-color: #154820;\n      transition: .5s .5s background-color ease-in-out;\n    }\n\n    body {\n      background-color: #2a3749;\n      margin: 0;\n      height: 100%;\n    }\n\n    #status {\n      color: #fff;\n      font-size: 17px;\n      padding: 5px;\n    }\n\n    a:link,\n    a:visited {\n      color: #30a247;\n      text-decoration: none;\n    }\n  </style>\n</head>\n\n<body>\n  <div>\n    <div id=\"progressBar\"></div>\n    <video id=\"output\" controls></video>\n  </div>\n  <!-- Statistics -->\n  <div id=\"status\">\n    <div>\n      <span class=\"show-leech\">Downloading </span>\n      <span class=\"show-seed\">Seeding </span>\n      <code>\n          <!-- Informative link to the torrent file -->\n          <a id=\"torrentLink\" href=\"https://webtorrent.io/torrents/sintel.torrent\">sintel.torrent</a>\n        </code>\n      <span class=\"show-leech\"> from </span>\n      <span class=\"show-seed\"> to </span>\n      <code id=\"numPeers\">0 peers</code>.\n    </div>\n    <div>\n      <code id=\"downloaded\"></code>\n      of <code id=\"total\"></code>\n      — <span id=\"remaining\"></span><br />\n      &#x2198;<code id=\"downloadSpeed\">0 b/s</code>\n      / &#x2197;<code id=\"uploadSpeed\">0 b/s</code>\n    </div>\n  </div>\n\n  <!-- Moment is used to show a human-readable remaining time -->\n  <script src=\"http://momentjs.com/downloads/moment.min.js\"></script>\n\n  <script type=\"module\">\n    // Include the latest version of WebTorrent\n    import WebTorrent from './webtorrent.min.js'\n\n    const torrentId = 'https://webtorrent.io/torrents/sintel.torrent'\n\n    const client = new WebTorrent()\n\n    // HTML elements\n    const $body = document.body\n    const $progressBar = document.querySelector('#progressBar')\n    const $numPeers = document.querySelector('#numPeers')\n    const $downloaded = document.querySelector('#downloaded')\n    const $total = document.querySelector('#total')\n    const $remaining = document.querySelector('#remaining')\n    const $uploadSpeed = document.querySelector('#uploadSpeed')\n    const $downloadSpeed = document.querySelector('#downloadSpeed')\n\n    const controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\n    await navigator.serviceWorker.ready\n    client.createServer({ controller })\n\n    // Download the torrent\n    client.add(torrentId, torrent => {\n      // Torrents can contain many files. Let's use the .mp4 file\n      const file = torrent.files.find(file => {\n        return file.name.endsWith('.mp4')\n      })\n\n      // Stream the file in the browser\n      file.streamTo(document.querySelector('#output'))\n\n      // Trigger statistics refresh\n      torrent.on('done', onDone)\n      setInterval(onProgress, 500)\n      onProgress()\n\n      // Statistics\n      function onProgress () {\n        // Peers\n        $numPeers.innerHTML = torrent.numPeers + (torrent.numPeers === 1 ? ' peer' : ' peers')\n\n        // Progress\n        const percent = Math.round(torrent.progress * 100 * 100) / 100\n        $progressBar.style.width = percent + '%'\n        $downloaded.innerHTML = prettyBytes(torrent.downloaded)\n        $total.innerHTML = prettyBytes(torrent.length)\n\n        // Remaining time\n        let remaining\n        if (torrent.done) {\n          remaining = 'Done.'\n        } else {\n          remaining = moment.duration(torrent.timeRemaining / 1000, 'seconds').humanize()\n          remaining = remaining[0].toUpperCase() + remaining.substring(1) + ' remaining.'\n        }\n        $remaining.innerHTML = remaining\n\n        // Speed rates\n        $downloadSpeed.innerHTML = prettyBytes(torrent.downloadSpeed) + '/s'\n        $uploadSpeed.innerHTML = prettyBytes(torrent.uploadSpeed) + '/s'\n      }\n      function onDone () {\n        $body.className += ' is-seed'\n        onProgress()\n      }\n    })\n\n    // Human readable bytes util\n    function prettyBytes (num) {\n      const units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n      const neg = num < 0\n      if (neg) num = -num\n      if (num < 1) return (neg ? '-' : '') + num + ' B'\n      const exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1)\n      const unit = units[exponent]\n      num = Number((num / Math.pow(1000, exponent)).toFixed(2))\n      return (neg ? '-' : '') + num + ' ' + unit\n    }\n  </script>\n</body>\n\n</html>\n```\n\n## More Documentation\n\nCheck out the [API Documentation](//webtorrent.io/docs) and [FAQ](//webtorrent.io/faq) for more details.\n\n[drag-drop]: https://npmjs.com/package/drag-drop\n"
  },
  {
    "path": "docs/tutorials.md",
    "content": "# WebTorrent Tutorials\n\n## Integrate WebTorrent with Video Players\n\nWebTorrent can be used to stream videos. WebTorrent can render the incoming video to an HTML `<video>` element. Below are some examples for various video players.\n\n### [Service Worker Renderer](https://github.com/webtorrent/webtorrent/blob/master/docs/api.md#clientloadworkercontroller-function-callback-controller---browser-only)\n\nCode example:\n\n```js\nimport WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'\n\nconst client = new WebTorrent()\nconst torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'\nconst player = document.querySelector('video')\n\nconst controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\nawait navigator.serviceWorker.ready\nclient.createServer({ controller })\n\nclient.add(torrentId, torrent => {\n  // Torrents can contain many files. Let's use the .mp4 file\n  const file = torrent.files.find(file => file.name.endsWith('.mp4'))\n  // Log streams emitted by the video player\n  file.on('stream', ({ stream, file, req }) => {\n    if (req.destination === 'video') {\n      console.log(`Video player requested data from ${file.name}! Ranges: ${req.headers.range}`)\n    }\n  })\n  // Stream to a <video> element by providing an the DOM element\n  file.streamTo(player)\n  console.log('Ready to play!')\n})\n```\n\n### [Video.js](https://videojs.com/)\n\nVideo.js is an open source HTML5 & Flash video player. We include the dependencies for `video.js` using CDN. A normal `<video>` element is converted to `video.js` by passing `class=\"video-js\"` and `data-setup=\"{}\"`. For more information visit the [docs](https://docs.videojs.com/tutorial-setup.html).\n\n**Note**: Unlike in the Default HTML5 Video Player example we don't directly pass the ID of the `<video>` element but pass `` `video#${id}_html5_api` `` (JS String Literal). It is because `video.js` wraps the `<video>` element in a `<div>`.\n\nOriginal code:\n\n```html\n<video\n  id=\"video-container\"\n  class=\"video-js\"\n  data-setup=\"{}\"\n  controls=\"true\"\n></video>\n```\n\nCode rendered on the browser:\n\n```html\n<div>\n  <video id=\"video-container_html5_api\"></video>\n</div>\n```\n\nCode example:\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <title>Web Torrent Tutorial</title>\n    <meta charset=\"UTF-8\" />\n    <link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/video.js/7.8.1/video-js.min.css\" />\n    <script src=\"//cdnjs.cloudflare.com/ajax/libs/video.js/7.8.1/video.min.js\"></script>\n  </head>\n  <body>\n    <video id=\"video-container\" class=\"video-js\" data-setup=\"{}\" controls=\"true\"></video>\n    <script type='module'>   \n      import WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'\n      const client = new WebTorrent()\n      const torrentId = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'\n      const player = document.querySelector('video')\n\n      const controller = await navigator.serviceWorker.register('./sw.min.js', { scope: './' })\n      await navigator.serviceWorker.ready\n      client.createServer({ controller })\n\n      client.add(torrentId, torrent => {\n        // Torrents can contain many files. Let's use the .mp4 file\n        const file = torrent.files.find(file => file.name.endsWith('.mp4'))\n\n        // Stream to a <video> element by providing an the DOM element\n        file.streamTo(player)\n        console.log('Ready to play!')\n      })\n    </script>\n  </body>\n</html>\n\n```\n"
  },
  {
    "path": "index.js",
    "content": "/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */\nimport EventEmitter from 'events'\nimport path from 'path'\nimport createTorrent, { parseInput } from 'create-torrent'\nimport debugFactory from 'debug'\nimport { Client as DHT } from 'bittorrent-dht' // browser exclude\nimport loadIPSet from 'load-ip-set' // browser exclude\nimport parallel from 'run-parallel'\nimport parseTorrent from 'parse-torrent'\nimport Peer from '@thaunknown/simple-peer/lite.js'\nimport queueMicrotask from 'queue-microtask'\nimport { hash, hex2arr, arr2hex, arr2base, text2arr, randomBytes, concat } from 'uint8-util'\nimport throughput from 'throughput'\nimport { ThrottleGroup } from 'speed-limiter'\nimport NatAPI from '@silentbot1/nat-api' // browser exclude\nimport ConnPool from './lib/conn-pool.js' // browser exclude\nimport Torrent from './lib/torrent.js'\nimport { NodeServer, BrowserServer } from './lib/server.js'\n\nimport VERSION from './version.cjs'\n\nconst debug = debugFactory('webtorrent')\n\n/**\n * Version number in Azureus-style. Generated from major and minor semver version.\n * For example:\n *   '0.16.1' -> '0016'\n *   '1.2.5' -> '0102'\n */\nconst VERSION_STR = VERSION\n  .replace(/\\d*./g, v => `0${v % 100}`.slice(-2))\n  .slice(0, 4)\n\n/**\n * Version prefix string (used in peer ID). WebTorrent uses the Azureus-style\n * encoding: '-', two characters for client id ('WW'), four ascii digits for version\n * number, '-', followed by random numbers.\n * For example:\n *   '-WW0102-'...\n */\nconst VERSION_PREFIX = `-WW${VERSION_STR}-`\n\n/**\n * WebTorrent Client\n * @param {Object=} opts\n */\nexport default class WebTorrent extends EventEmitter {\n  constructor (opts = {}) {\n    super()\n\n    if (typeof opts.peerId === 'string') {\n      this.peerId = opts.peerId\n    } else if (ArrayBuffer.isView(opts.peerId)) {\n      this.peerId = arr2hex(opts.peerId)\n    } else {\n      this.peerId = arr2hex(text2arr(VERSION_PREFIX + arr2base(randomBytes(9))))\n    }\n    this.peerIdBuffer = hex2arr(this.peerId)\n\n    if (typeof opts.nodeId === 'string') {\n      this.nodeId = opts.nodeId\n    } else if (ArrayBuffer.isView(opts.nodeId)) {\n      this.nodeId = arr2hex(opts.nodeId)\n    } else {\n      this.nodeId = arr2hex(randomBytes(20))\n    }\n    this.nodeIdBuffer = hex2arr(this.nodeId)\n\n    this._debugId = this.peerId.substring(0, 7)\n\n    this.destroyed = false\n    this.listening = false\n    this.torrentPort = opts.torrentPort || 0\n    this.dhtPort = opts.dhtPort || 0\n    this.tracker = opts.tracker !== undefined ? opts.tracker : {}\n    this.lsd = opts.lsd !== false\n    this.utPex = opts.utPex !== false\n    this.natUpnp = opts.natUpnp ?? true\n    this.natPmp = opts.natPmp ?? true\n    this.torrents = []\n    this.maxConns = Number(opts.maxConns) || 55\n    this.utp = WebTorrent.UTP_SUPPORT && opts.utp !== false\n    this.seedOutgoingConnections = opts.seedOutgoingConnections ?? true\n\n    this._downloadLimit = Math.max((typeof opts.downloadLimit === 'number') ? opts.downloadLimit : -1, -1)\n    this._uploadLimit = Math.max((typeof opts.uploadLimit === 'number') ? opts.uploadLimit : -1, -1)\n\n    if ((this.natUpnp || this.natPmp) && typeof NatAPI === 'function') {\n      this.natTraversal = new NatAPI({\n        enableUPNP: this.natUpnp,\n        enablePMP: this.natPmp,\n        upnpPermanentFallback: opts.natUpnp === 'permanent'\n      })\n    }\n\n    if (opts.secure === true) {\n      import('./lib/peer.js').then(({ enableSecure }) => enableSecure())\n    }\n\n    this._debug(\n      'new webtorrent (peerId %s, nodeId %s, port %s)',\n      this.peerId, this.nodeId, this.torrentPort\n    )\n\n    this.throttleGroups = {\n      down: new ThrottleGroup({ rate: Math.max(this._downloadLimit, 0), enabled: this._downloadLimit >= 0 }),\n      up: new ThrottleGroup({ rate: Math.max(this._uploadLimit, 0), enabled: this._uploadLimit >= 0 })\n    }\n\n    if (this.tracker) {\n      if (typeof this.tracker !== 'object') this.tracker = {}\n      if (globalThis.WRTC && !this.tracker.wrtc) this.tracker.wrtc = globalThis.WRTC\n    }\n\n    if (typeof ConnPool === 'function') {\n      this._connPool = new ConnPool(this)\n    } else {\n      queueMicrotask(() => {\n        this._onListening()\n      })\n    }\n\n    // stats\n    this._downloadSpeed = throughput()\n    this._uploadSpeed = throughput()\n\n    if (opts.dht !== false && typeof DHT === 'function' /* browser exclude */) {\n      // use a single DHT instance for all torrents, so the routing table can be reused\n      this.dht = new DHT(Object.assign({}, { nodeId: this.nodeId }, opts.dht))\n\n      this.dht.once('error', err => {\n        this._destroy(err)\n      })\n\n      this.dht.once('listening', () => {\n        const address = this.dht.address()\n        if (address) {\n          this.dhtPort = address.port\n          if (this.natTraversal) {\n            this.natTraversal.map({\n              publicPort: this.dhtPort,\n              privatePort: this.dhtPort,\n              protocol: 'udp',\n              description: 'WebTorrent DHT'\n            }).catch(err => {\n              debug('error mapping DHT port via UPnP/PMP: %o', err)\n            })\n          }\n        }\n      })\n\n      // Ignore warning when there are > 10 torrents in the client\n      this.dht.setMaxListeners(0)\n\n      this.dht.listen(this.dhtPort)\n    } else {\n      this.dht = false\n    }\n\n    // Enable or disable BEP19 (Web Seeds). Enabled by default:\n    this.enableWebSeeds = opts.webSeeds !== false\n\n    const ready = () => {\n      if (this.destroyed) return\n      this.ready = true\n      this.emit('ready')\n    }\n\n    if (typeof loadIPSet === 'function' && opts.blocklist != null) {\n      loadIPSet(opts.blocklist, {\n        headers: {\n          'user-agent': `WebTorrent/${VERSION} (https://webtorrent.io)`\n        }\n      }, (err, ipSet) => {\n        if (err) return console.error(`Failed to load blocklist: ${err.message}`)\n        this.blocked = ipSet\n        ready()\n      })\n    } else {\n      queueMicrotask(ready)\n    }\n  }\n\n  /**\n   * Creates an http server to serve the contents of this torrent,\n   * dynamically fetching the needed torrent pieces to satisfy http requests.\n   * Range requests are supported.\n   *\n   * @param {{controller: ServiceWorkerRegistration}} options\n   * @param {'browser' | 'node'} [force]\n   * @return {BrowserServer | NodeServer}\n   */\n  createServer (options, force) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n    if (this._server) throw new Error('server already created')\n    if ((typeof window === 'undefined' || force === 'node') && force !== 'browser') {\n      // node implementation\n      this._server = new NodeServer(this, options)\n      return this._server\n    } else {\n      // browser implementation\n      if (!(options?.controller instanceof ServiceWorkerRegistration)) throw new Error('Invalid worker registration')\n      if (options.controller.active?.state !== 'activated' && options.controller.active?.state !== 'activating') throw new Error('Worker isn\\'t activated')\n      this._server = new BrowserServer(this, options)\n      return this._server\n    }\n  }\n\n  get downloadSpeed () { return this._downloadSpeed() }\n\n  get uploadSpeed () { return this._uploadSpeed() }\n\n  get progress () {\n    const torrents = this.torrents.filter(torrent => torrent.progress !== 1)\n    const downloaded = torrents.reduce((total, torrent) => total + torrent.downloaded, 0)\n    const length = torrents.reduce((total, torrent) => total + (torrent.length || 0), 0) || 1\n    return downloaded / length\n  }\n\n  get ratio () {\n    const uploaded = this.torrents.reduce((total, torrent) => total + torrent.uploaded, 0)\n    const received = this.torrents.reduce((total, torrent) => total + torrent.received, 0) || 1\n    return uploaded / received\n  }\n\n  /**\n   * Returns the torrent with the given `torrentId`. Convenience method. Easier than\n   * searching through the `client.torrents` array. Returns `null` if no matching torrent\n   * found.\n   *\n   * @param  {string|Buffer|Object|Torrent} torrentId\n   * @return {Promise<Torrent|null>}\n   */\n  async get (torrentId) {\n    if (torrentId instanceof Torrent) {\n      if (this.torrents.includes(torrentId)) return torrentId\n    } else {\n      const torrents = this.torrents\n      let parsed\n      try { parsed = await parseTorrent(torrentId) } catch (err) {}\n      if (!parsed) return null\n      if (!parsed.infoHash) throw new Error('Invalid torrent identifier')\n\n      for (const torrent of torrents) {\n        if (torrent.infoHash === parsed.infoHash) return torrent\n      }\n    }\n    return null\n  }\n\n  /**\n   * Start downloading a new torrent. Aliased as `client.download`.\n   * @param {string|Buffer|Object} torrentId\n   * @param {import('./lib/torrent.js').TorrentOpts | function(torrent: Torrent): void=} opts torrent-specific options\n   * @param {function(torrent: Torrent): void=} ontorrent called when the torrent is ready (has metadata)\n   */\n  add (torrentId, opts = {}, ontorrent = () => {}) {\n    if (this.destroyed) throw new Error('client is destroyed')\n    if (typeof opts === 'function') [opts, ontorrent] = [{}, opts]\n\n    const onInfoHash = () => {\n      if (this.destroyed) return\n      for (const t of this.torrents) {\n        if (t.infoHash === torrent.infoHash && t !== torrent) {\n          torrent._destroy(new Error(`Cannot add duplicate torrent ${torrent.infoHash}`))\n          ontorrent(t)\n          return\n        }\n      }\n    }\n\n    const onReady = () => {\n      if (this.destroyed) return\n      ontorrent(torrent)\n      this.emit('torrent', torrent)\n    }\n\n    function onClose () {\n      torrent.removeListener('_infoHash', onInfoHash)\n      torrent.removeListener('ready', onReady)\n      torrent.removeListener('close', onClose)\n    }\n\n    this._debug('add')\n    opts = opts ? Object.assign({}, opts) : {}\n\n    const torrent = new Torrent(torrentId, this, opts)\n    this.torrents.push(torrent)\n\n    torrent.once('_infoHash', onInfoHash)\n    torrent.once('ready', onReady)\n    torrent.once('close', onClose)\n\n    this.emit('add', torrent)\n    return torrent\n  }\n\n  /**\n   * Start seeding a new file/folder.\n   * @param  {string|File|FileList|Buffer|Array.<string|File|Buffer>} input\n   * @param  {Object=} opts\n   * @param  {function=} onseed called when torrent is seeding\n   */\n  seed (input, opts, onseed) {\n    if (this.destroyed) throw new Error('client is destroyed')\n    if (typeof opts === 'function') [opts, onseed] = [{}, opts]\n\n    this._debug('seed')\n    opts = opts ? Object.assign({}, opts) : {}\n\n    // no need to verify the hashes we create\n    opts.skipVerify = true\n\n    const isFilePath = typeof input === 'string'\n\n    // When seeding from fs path, initialize store from that path to avoid a copy\n    if (isFilePath) opts.path = path.dirname(input)\n    if (!opts.createdBy) opts.createdBy = `WebTorrent/${VERSION_STR}`\n\n    const onTorrent = torrent => {\n      const tasks = [\n        cb => {\n          // when a filesystem path is specified or the store is preloaded, files are already in the FS store\n          if (isFilePath || opts.preloadedStore) return cb()\n          torrent.load(streams, cb)\n        }\n      ]\n      if (this.dht) {\n        tasks.push(cb => {\n          torrent.once('dhtAnnounce', cb)\n        })\n      }\n      parallel(tasks, err => {\n        if (this.destroyed) return\n        if (err) return torrent._destroy(err)\n        _onseed(torrent)\n      })\n    }\n\n    const _onseed = torrent => {\n      this._debug('on seed')\n      if (typeof onseed === 'function') onseed(torrent)\n      torrent.emit('seed')\n      this.emit('seed', torrent)\n    }\n\n    const torrent = this.add(null, opts, onTorrent)\n    let streams\n\n    if (isFileList(input)) input = Array.from(input)\n    else if (!Array.isArray(input)) input = [input]\n\n    parallel(input.map(item => async cb => {\n      if (!opts.preloadedStore && isReadable(item)) {\n        const chunks = []\n        try {\n          for await (const chunk of item) {\n            chunks.push(chunk)\n          }\n        } catch (err) {\n          return cb(err)\n        }\n        const buf = concat(chunks)\n        buf.name = item.name\n        cb(null, buf)\n      } else {\n        cb(null, item)\n      }\n    }), (err, input) => {\n      if (this.destroyed) return\n      if (err) return torrent._destroy(err)\n\n      parseInput(input, opts, (err, files) => {\n        if (this.destroyed) return\n        if (err) return torrent._destroy(err)\n\n        streams = files.map(file => file.getStream)\n\n        createTorrent(input, opts, async (err, torrentBuf) => {\n          if (this.destroyed) return\n          if (err) return torrent._destroy(err)\n\n          const existingTorrent = await this.get(torrentBuf)\n          if (existingTorrent) {\n            console.warn('A torrent with the same id is already being seeded')\n            torrent._destroy()\n            if (typeof onseed === 'function') onseed(existingTorrent)\n          } else {\n            torrent._onTorrentId(torrentBuf)\n          }\n        })\n      })\n    })\n\n    return torrent\n  }\n\n  /**\n   * Remove a torrent from the client.\n   * @param  {string|Buffer|Torrent}   torrentId\n   * @param  {function} cb\n   */\n  async remove (torrentId, opts, cb) {\n    if (typeof opts === 'function') return this.remove(torrentId, null, opts)\n\n    this._debug('remove')\n    const torrent = await this.get(torrentId)\n    if (!torrent) throw new Error(`No torrent with id ${torrentId}`)\n    this._remove(torrent, opts, cb)\n  }\n\n  _remove (torrent, opts, cb) {\n    if (!torrent) return\n    if (typeof opts === 'function') return this._remove(torrent, null, opts)\n    const index = this.torrents.indexOf(torrent)\n    if (index === -1) return\n    this.torrents.splice(index, 1)\n    torrent.destroy(opts, cb)\n    if (this.dht) {\n      this.dht._tables.remove(torrent.infoHash)\n    }\n    this.emit('remove', torrent)\n  }\n\n  address () {\n    if (!this.listening) return null\n    return this._connPool\n      ? this._connPool.tcpServer.address()\n      : { address: '0.0.0.0', family: 'IPv4', port: 0 }\n  }\n\n  /**\n   * Set global download throttle rate.\n   * @param  {Number} rate (must be bigger or equal than zero, or -1 to disable throttling)\n   */\n  throttleDownload (rate) {\n    rate = Number(rate)\n    if (isNaN(rate) || !isFinite(rate) || (rate < 0 && rate !== -1)) return false\n    this._downloadLimit = Math.round(rate)\n    if (this._downloadLimit === -1) return this.throttleGroups.down.setEnabled(false)\n    this.throttleGroups.down.setEnabled(true)\n    this.throttleGroups.down.setRate(this._downloadLimit)\n  }\n\n  /**\n   * Set global upload throttle rate\n   * @param  {Number} rate (must be bigger or equal than zero, or -1 to disable throttling)\n   */\n  throttleUpload (rate) {\n    rate = Number(rate)\n    if (isNaN(rate) || !isFinite(rate) || (rate < 0 && rate !== -1)) return false\n    this._uploadLimit = Math.round(rate)\n    if (this._uploadLimit === -1) return this.throttleGroups.up.setEnabled(false)\n    this.throttleGroups.up.setEnabled(true)\n    this.throttleGroups.up.setRate(this._uploadLimit)\n  }\n\n  /**\n   * Destroy the client, including all torrents and connections to peers.\n   * @param  {function} cb\n   */\n  destroy (cb) {\n    if (this.destroyed) throw new Error('client already destroyed')\n    this._destroy(null, cb)\n  }\n\n  _destroy (err, cb) {\n    this._debug('client destroy')\n    this.destroyed = true\n\n    const tasks = this.torrents.map(torrent => cb => {\n      torrent.destroy(cb)\n    })\n\n    if (this._connPool) {\n      tasks.push(cb => {\n        this._connPool.destroy(cb)\n      })\n    }\n\n    if (this.dht) {\n      tasks.push(cb => {\n        this.dht.destroy(cb)\n      })\n    }\n\n    if (this._server) {\n      tasks.push(cb => {\n        this._server.destroy(cb)\n      })\n    }\n\n    if (this.natTraversal) {\n      tasks.push(cb => {\n        this.natTraversal.destroy()\n          .then(() => cb())\n      })\n    }\n\n    parallel(tasks, cb)\n\n    if (err) this.emit('error', err)\n\n    this.torrents = []\n    this._connPool = null\n    this.dht = null\n\n    this.throttleGroups.down.destroy()\n    this.throttleGroups.up.destroy()\n  }\n\n  _onListening () {\n    this._debug('listening')\n    this.listening = true\n\n    if (this._connPool) {\n      // Sometimes server.address() returns `null` in Docker.\n      const address = this._connPool.tcpServer.address()\n      if (address) {\n        this.torrentPort = address.port\n        if (this.natTraversal) {\n          this.natTraversal.map({\n            publicPort: this.torrentPort,\n            privatePort: this.torrentPort,\n            protocol: this.utp ? null : 'tcp',\n            description: 'WebTorrent Torrent'\n          }).catch(err => {\n            debug('error mapping WebTorrent port via UPnP/PMP: %o', err)\n          })\n        }\n      }\n    }\n\n    this.emit('listening')\n  }\n\n  _debug () {\n    const args = [].slice.call(arguments)\n    args[0] = `[${this._debugId}] ${args[0]}`\n    debug(...args)\n  }\n\n  async _getByHash (infoHashHash) {\n    for (const torrent of this.torrents) {\n      if (!torrent.infoHashHash) {\n        torrent.infoHashHash = await hash(hex2arr('72657132' /* 'req2' */ + torrent.infoHash), 'hex')\n      }\n      if (infoHashHash === torrent.infoHashHash) {\n        return torrent\n      }\n    }\n\n    return null\n  }\n}\n\nWebTorrent.WEBRTC_SUPPORT = Peer.WEBRTC_SUPPORT\nWebTorrent.UTP_SUPPORT = ConnPool.UTP_SUPPORT\nWebTorrent.VERSION = VERSION\n\n/**\n * Check if `obj` is a node Readable stream\n * @param  {*} obj\n * @return {boolean}\n */\nfunction isReadable (obj) {\n  return typeof obj === 'object' && obj != null && typeof obj.pipe === 'function'\n}\n\n/**\n * Check if `obj` is a W3C `FileList` object\n * @param  {*} obj\n * @return {boolean}\n */\nfunction isFileList (obj) {\n  return typeof FileList !== 'undefined' && obj instanceof FileList\n}\n"
  },
  {
    "path": "lib/conn-pool.js",
    "content": "import net from 'net' // browser exclude\nimport debugFactory from 'debug'\nimport queueMicrotask from 'queue-microtask'\n\nimport Peer from './peer.js'\nimport utp from './utp.cjs' // browser exclude\n\nconst debug = debugFactory('webtorrent:conn-pool')\n\n/**\n * Connection Pool\n *\n * A connection pool allows multiple swarms to listen on the same TCP/UDP port and determines\n * which swarm incoming connections are intended for by inspecting the bittorrent\n * handshake that the remote peer sends.\n *\n * @param {number} port\n */\nexport default class ConnPool {\n  constructor (client) {\n    debug('create pool (port %s)', client.torrentPort)\n\n    this._client = client\n\n    // Temporarily store incoming connections so they can be destroyed if the server is\n    // closed before the connection is passed off to a Torrent.\n    this._pendingConns = new Set()\n\n    this._onTCPConnectionBound = (conn) => {\n      this._onConnection(conn, 'tcp')\n    }\n\n    this._onUTPConnectionBound = (conn) => {\n      this._onConnection(conn, 'utp')\n    }\n\n    this._onListening = () => {\n      this._client._onListening()\n    }\n\n    this._onTCPError = (err) => {\n      this._client._destroy(err)\n    }\n\n    this._onUTPError = (err) => {\n      this._client.utp = false\n      this._client.emit('error', err)\n      if (!this._client.listening) this._onListening()\n    }\n\n    // Setup TCP\n    this.tcpServer = net.createServer()\n    this.tcpServer.on('connection', this._onTCPConnectionBound)\n    this.tcpServer.on('error', this._onTCPError)\n\n    // Start TCP\n    this.tcpServer.listen(client.torrentPort, () => {\n      debug('creating tcpServer in port %s', this.tcpServer.address().port)\n      if (this._client.utp) {\n        // Setup uTP\n        this.utpServer = utp.createServer()\n        this.utpServer.on('connection', this._onUTPConnectionBound)\n        this.utpServer.on('listening', this._onListening)\n        this.utpServer.on('error', this._onUTPError)\n\n        // Start uTP\n        debug('creating utpServer in port %s', this.tcpServer.address().port)\n        this.utpServer.listen(this.tcpServer.address().port)\n      } else {\n        this._onListening()\n      }\n    })\n  }\n\n  /**\n   * Destroy this Conn pool.\n   * @param  {function} cb\n   */\n  destroy (cb) {\n    debug('destroy conn pool')\n\n    if (this.utpServer) {\n      this.utpServer.removeListener('connection', this._onUTPConnectionBound)\n      this.utpServer.removeListener('listening', this._onListening)\n      this.utpServer.removeListener('error', this._onUTPError)\n    }\n\n    this.tcpServer.removeListener('connection', this._onTCPConnectionBound)\n    this.tcpServer.removeListener('error', this._onTCPError)\n\n    // Destroy all open connection objects so server can close gracefully without waiting\n    // for connection timeout or remote peer to disconnect.\n    this._pendingConns.forEach((conn) => {\n      conn.on('error', noop)\n      conn.destroy()\n    })\n\n    if (this.utpServer) {\n      try {\n        this.utpServer.close(cb)\n      } catch (err) {\n        if (cb) queueMicrotask(cb)\n      }\n    }\n\n    try {\n      this.tcpServer.close(cb)\n    } catch (err) {\n      if (cb) queueMicrotask(cb)\n    }\n\n    this.tcpServer = null\n    this.utpServer = null\n    this._client = null\n    this._pendingConns = null\n  }\n\n  /**\n   * On incoming connections, we expect the remote peer to send a handshake first. Based\n   * on the infoHash in that handshake, route the peer to the right swarm.\n   */\n  _onConnection (conn, type) {\n    const self = this\n\n    // If the connection has already been closed before the `connect` event is fired,\n    // then `remoteAddress` will not be available, and we can't use this connection.\n    // - Node.js issue: https://github.com/nodejs/node-v0.x-archive/issues/7566\n    // - WebTorrent issue: https://github.com/webtorrent/webtorrent/issues/398\n    if (!conn.remoteAddress) {\n      conn.on('error', noop)\n      conn.destroy()\n      return\n    }\n\n    self._pendingConns.add(conn)\n    conn.once('close', cleanupPending)\n\n    const peer = type === 'utp'\n      ? Peer.createUTPIncomingPeer(conn, this._client.throttleGroups)\n      : Peer.createTCPIncomingPeer(conn, this._client.throttleGroups)\n\n    const wire = peer.wire\n    wire.once('pe3', onPe3)\n    wire.once('handshake', onHandshake)\n\n    async function onPe3 (infoHashHash) {\n      const torrent = await self._client._getByHash(infoHashHash)\n      if (torrent) {\n        peer.swarm = torrent\n        torrent._addIncomingPeer(peer)\n        peer.onPe3(infoHashHash)\n      } else {\n        peer.destroy(new Error(`Unexpected info hash hash ${infoHashHash} from incoming peer ${peer.id}`))\n      }\n    }\n\n    async function onHandshake (infoHash, peerId) {\n      cleanupPending()\n\n      const torrent = await self._client.get(infoHash)\n      // only add incoming peer if didn't already do so in protocol encryption handshake\n      if (torrent) {\n        if (!peer.swarm) {\n          peer.swarm = torrent\n          torrent._addIncomingPeer(peer)\n        }\n        peer.onHandshake(infoHash, peerId)\n      } else {\n        const err = new Error(\n          `Unexpected info hash ${infoHash} from incoming peer ${peer.id}`\n        )\n        peer.destroy(err)\n      }\n    }\n\n    function cleanupPending () {\n      conn.removeListener('close', cleanupPending)\n      wire.removeListener('handshake', onHandshake)\n      if (self._pendingConns) {\n        self._pendingConns.delete(conn)\n      }\n    }\n  }\n}\n\nConnPool.UTP_SUPPORT = Object.keys(utp).length > 0\n\nfunction noop () {}\n"
  },
  {
    "path": "lib/file-iterator.js",
    "content": "import debugFactory from 'debug'\nimport EventEmitter from 'events'\n\nconst debug = debugFactory('webtorrent:file-iterator')\n\n/**\n * Async iterator of a torrent file\n *\n * @param {File} file\n * @param {Object} opts\n * @param {number} opts.start iterator slice of file, starting from this byte (inclusive)\n * @param {number} opts.end iterator slice of file, ending with this byte (inclusive)\n * @implements {AsyncIterator<Uint8Array>}\n */\nexport default class FileIterator extends EventEmitter {\n  constructor (file, { start, end }) {\n    super()\n\n    this._torrent = file._torrent\n\n    this._pieceLength = file._torrent.pieceLength\n\n    this._startPiece = (start + file.offset) / this._pieceLength | 0\n    this._endPiece = (end + file.offset) / this._pieceLength | 0\n\n    this._piece = this._startPiece\n    this._offset = (start + file.offset) - (this._startPiece * this._pieceLength)\n\n    this._missing = end - start + 1\n    this._criticalLength = Math.min((1024 * 1024 / this._pieceLength) | 0, 2)\n\n    this._torrent._select(this._startPiece, this._endPiece, 1, null, true)\n    this.destroyed = false\n  }\n\n  [Symbol.asyncIterator] () {\n    return this\n  }\n\n  next () {\n    return new Promise((resolve, reject) => {\n      if (this._missing === 0 || this.destroyed) {\n        resolve({ done: true })\n        return this.destroy()\n      }\n      const pump = (index, opts) => {\n        if (!this._torrent.bitfield.get(index)) {\n          const listener = i => {\n            if (i === index || this.destroyed) {\n              this._torrent.removeListener('verified', listener)\n              if (i === index) {\n                pump(index, opts)\n              } else {\n                resolve({ done: true })\n              }\n            }\n          }\n\n          this._torrent.on('verified', listener)\n          return this._torrent.critical(index, index + this._criticalLength)\n        }\n\n        if (this.destroyed) return resolve({ done: true })\n\n        this._torrent.store.get(index, opts, (err, buffer) => {\n          if (this.destroyed) return resolve({ done: true }) // prevent hanging\n          debug('read %s and yielding (length %s) (err %s)', index, buffer?.length, err?.message)\n\n          if (err) {\n            this.destroy(undefined, err)\n            return resolve({ done: true })\n          }\n\n          // prevent re-wrapping outside of promise\n          resolve({ value: buffer, done: false })\n        })\n      }\n\n      const length = Math.min(this._missing, this._pieceLength - this._offset)\n\n      pump(this._piece++, { length, offset: this._offset })\n      this._missing -= length\n      this._offset = 0\n    })\n  }\n\n  /**\n   * @returns {Promise<IteratorResult<Uint8Array>>}\n   */\n  async return () {\n    this.destroy()\n    return { done: true, value: undefined }\n  }\n\n  /**\n   * @param {Error} err\n   * @returns {Promise<IteratorResult<Uint8Array>>}\n   */\n  async throw (err) {\n    throw err\n  }\n\n  destroy (cb = _ => {}, err) {\n    if (this.destroyed) return\n    this.destroyed = true\n    if (!this._torrent.destroyed) {\n      this._torrent._deselect(this._startPiece, this._endPiece, true)\n    }\n    this.emit('return')\n    cb(err)\n  }\n}\n"
  },
  {
    "path": "lib/file.js",
    "content": "import EventEmitter from 'events'\nimport { Readable } from 'streamx'\nimport { chunkStoreRead } from 'chunk-store-iterator'\nimport mime from 'mime/lite.js'\nimport FileIterator from './file-iterator.js'\n\nexport default class File extends EventEmitter {\n  constructor (torrent, file) {\n    super()\n\n    this._torrent = torrent\n    this._destroyed = false\n    this._fileStreams = new Set()\n    this._iterators = new Set()\n\n    this.name = file.name\n    this.path = file.path\n    this.length = file.length\n    this.size = file.length\n    this.type = mime.getType(this.name) || 'application/octet-stream'\n    this.offset = file.offset\n\n    this.done = false\n\n    const start = file.offset\n    const end = start + file.length - 1\n\n    this._startPiece = start / this._torrent.pieceLength | 0\n    this._endPiece = end / this._torrent.pieceLength | 0\n\n    if (this.length === 0) {\n      this.done = true\n      this.emit('done')\n    }\n\n    this._client = torrent.client\n  }\n\n  get downloaded () {\n    if (this._destroyed || !this._torrent.bitfield) return 0\n\n    const { pieces, bitfield, pieceLength, lastPieceLength } = this._torrent\n    const { _startPiece: start, _endPiece: end } = this\n\n    const getPieceLength = (pieceIndex) => (\n      pieceIndex === pieces.length - 1 ? lastPieceLength : pieceLength\n    )\n\n    const getPieceDownloaded = (pieceIndex) => {\n      const len = pieceIndex === pieces.length - 1 ? lastPieceLength : pieceLength\n      if (bitfield.get(pieceIndex)) {\n        // verified data\n        return len\n      } else {\n        // \"in progress\" data\n        return len - pieces[pieceIndex].missing\n      }\n    }\n\n    let downloaded = 0\n    for (let index = start; index <= end; index += 1) {\n      const pieceDownloaded = getPieceDownloaded(index)\n      downloaded += pieceDownloaded\n\n      if (index === start) {\n        // First piece may have an offset, e.g. irrelevant bytes from the end of\n        // the previous file\n        const irrelevantFirstPieceBytes = this.offset % pieceLength\n        downloaded -= Math.min(irrelevantFirstPieceBytes, pieceDownloaded)\n      }\n\n      if (index === end) {\n        // Last piece may have an offset, e.g. irrelevant bytes from the start\n        // of the next file\n        const irrelevantLastPieceBytes = getPieceLength(end) - (this.offset + this.length) % pieceLength\n        downloaded -= Math.min(irrelevantLastPieceBytes, pieceDownloaded)\n      }\n    }\n\n    return downloaded\n  }\n\n  get progress () {\n    return this.length ? this.downloaded / this.length : 0\n  }\n\n  select (priority) {\n    if (this.length === 0) return\n    this._torrent.select(this._startPiece, this._endPiece, priority)\n  }\n\n  deselect () {\n    if (this.length === 0) return\n    this._torrent.deselect(this._startPiece, this._endPiece)\n  }\n\n  [Symbol.asyncIterator] (opts = {}) {\n    if (this.length === 0 || this._destroyed) return (async function * empty () {})()\n\n    const { start = 0 } = opts ?? {}\n    const end = (opts?.end && opts.end < this.length)\n      ? opts.end\n      : this.length - 1\n\n    if (this.done) {\n      return chunkStoreRead(this._torrent.store, { offset: start + this.offset, length: end - start + 1 })\n    }\n\n    const iterator = new FileIterator(this, { start, end })\n    this._iterators.add(iterator)\n    iterator.once('return', () => {\n      this._iterators.delete(iterator)\n    })\n\n    return iterator\n  }\n\n  createReadStream (opts) {\n    if (this._destroyed) throw new Error('File is destroyed')\n    const iterator = this[Symbol.asyncIterator](opts)\n    const fileStream = Readable.from(iterator)\n\n    this._fileStreams.add(fileStream)\n    fileStream.once('close', () => {\n      this._fileStreams.delete(fileStream)\n    })\n\n    return fileStream\n  }\n\n  async arrayBuffer (opts = {}) {\n    if (this._destroyed) throw new Error('File is destroyed')\n    const { start = 0 } = opts\n    const end = (opts?.end && opts.end < this.length)\n      ? opts.end\n      : this.length - 1\n\n    const data = new Uint8Array(end - start + 1)\n    let offset = 0\n    for await (const chunk of this[Symbol.asyncIterator]({ start, end })) {\n      data.set(chunk, offset)\n      offset += chunk.length\n    }\n    return data.buffer\n  }\n\n  async blob (opts) {\n    if (this._destroyed) throw new Error('File is destroyed')\n    return new Blob([await this.arrayBuffer(opts)], { type: this.type })\n  }\n\n  stream (opts) {\n    if (this._destroyed) throw new Error('File is destroyed')\n    let iterator\n    return new ReadableStream({\n      start: () => {\n        iterator = this[Symbol.asyncIterator](opts)\n      },\n      async pull (controller) {\n        const { value, done } = await iterator.next()\n        if (done) {\n          controller.close()\n        } else {\n          controller.enqueue(value)\n        }\n      },\n      cancel () {\n        iterator.return()\n      }\n    })\n  }\n\n  get streamURL () {\n    if (!this._client._server) throw new Error('No server created')\n    return `${this._client._server.pathname}/${this._torrent.infoHash}/${this.path}`\n  }\n\n  streamTo (elem) {\n    elem.src = this.streamURL\n    return elem\n  }\n\n  includes (piece) {\n    return this._startPiece <= piece && this._endPiece >= piece\n  }\n\n  _destroy () {\n    this._destroyed = true\n    this._torrent = null\n\n    for (const fileStream of this._fileStreams) {\n      fileStream.destroy()\n    }\n    this._fileStreams.clear()\n    for (const iterator of this._iterators) {\n      iterator.destroy()\n    }\n    this._iterators.clear()\n  }\n}\n"
  },
  {
    "path": "lib/peer.js",
    "content": "import EventEmitter from 'events'\nimport { Transform, pipeline } from 'streamx'\nimport arrayRemove from 'unordered-array-remove'\nimport debugFactory from 'debug'\nimport Wire from 'bittorrent-protocol'\n\nconst CONNECT_TIMEOUT_TCP = 5_000\nconst CONNECT_TIMEOUT_UTP = 5_000\nconst CONNECT_TIMEOUT_WEBRTC = 25_000\nconst HANDSHAKE_TIMEOUT = 25_000\n\n// Types of peers\nconst TYPE_TCP_INCOMING = 'tcpIncoming'\nconst TYPE_TCP_OUTGOING = 'tcpOutgoing'\nconst TYPE_UTP_INCOMING = 'utpIncoming'\nconst TYPE_UTP_OUTGOING = 'utpOutgoing'\nconst TYPE_WEBRTC = 'webrtc'\nconst TYPE_WEBSEED = 'webSeed'\n\n// Source used to obtain the peer\nconst SOURCE_MANUAL = 'manual'\nconst SOURCE_TRACKER = 'tracker'\nconst SOURCE_DHT = 'dht'\nconst SOURCE_LSD = 'lsd'\nconst SOURCE_UT_PEX = 'ut_pex'\n\nconst debug = debugFactory('webtorrent:peer')\n\nlet secure = false\n\nexport const enableSecure = () => {\n  secure = true\n}\n\n/**\n * Peer. Represents a peer in the torrent swarm.\n *\n * @param {string} id \"ip:port\" string, peer id (for WebRTC peers), or url (for Web Seeds)\n * @param {string} type the type of the peer\n */\nexport default class Peer extends EventEmitter {\n  constructor (id, type) {\n    super()\n\n    this.id = id\n    this.type = type\n\n    debug('new %s Peer %s', type, id)\n\n    this.addr = null\n    this.conn = null\n    this.swarm = null\n    this.wire = null\n    this.source = null\n\n    this.connected = false\n    this.destroyed = false\n    this.timeout = null // handshake timeout\n    this.retries = 0 // outgoing TCP connection retry count\n\n    this.sentPe1 = false\n    this.sentPe2 = false\n    this.sentPe3 = false\n    this.sentPe4 = false\n    this.sentHandshake = false\n  }\n\n  /**\n   * Called once the peer is connected (i.e. fired 'connect' event)\n   * @param {Socket} conn\n   */\n  onConnect () {\n    if (this.destroyed) return\n    this.connected = true\n    this.emit('connect')\n\n    debug('Peer %s connected', this.id)\n\n    clearTimeout(this.connectTimeout)\n\n    const conn = this.conn\n    conn.once('end', () => {\n      this.destroy()\n    })\n    conn.once('close', () => {\n      this.destroy()\n    })\n    conn.once('finish', () => {\n      this.destroy()\n    })\n    conn.once('error', err => {\n      this.destroy(err)\n    })\n\n    const wire = this.wire = new Wire(this.type, this.retries, secure)\n\n    wire.once('end', () => {\n      this.destroy()\n    })\n    wire.once('close', () => {\n      this.destroy()\n    })\n    wire.once('finish', () => {\n      this.destroy()\n    })\n    wire.once('error', err => {\n      this.destroy(err)\n    })\n\n    wire.once('pe1', () => {\n      this.onPe1()\n    })\n    wire.once('pe2', () => {\n      this.onPe2()\n    })\n    wire.once('pe3', () => {\n      this.onPe3()\n    })\n    wire.once('pe4', () => {\n      this.onPe4()\n    })\n    wire.once('handshake', (infoHash, peerId) => {\n      this.onHandshake(infoHash, peerId)\n    })\n    this.startHandshakeTimeout()\n\n    this.setThrottlePipes()\n\n    if (this.swarm) {\n      if (this.type === 'tcpOutgoing') {\n        if (secure && this.retries === 0 && !this.sentPe1) this.sendPe1()\n        else if (!this.sentHandshake) this.handshake()\n      } else if (this.type !== 'tcpIncoming' && !this.sentHandshake) this.handshake()\n    }\n  }\n\n  sendPe1 () {\n    this.wire.sendPe1()\n    this.sentPe1 = true\n  }\n\n  onPe1 () {\n    this.sendPe2()\n  }\n\n  sendPe2 () {\n    this.wire.sendPe2()\n    this.sentPe2 = true\n  }\n\n  onPe2 () {\n    this.sendPe3()\n  }\n\n  sendPe3 () {\n    this.wire.sendPe3(this.swarm.infoHash)\n    this.sentPe3 = true\n  }\n\n  onPe3 (infoHashHash) {\n    if (this.swarm) {\n      if (this.swarm.infoHashHash !== infoHashHash) {\n        this.destroy(new Error('unexpected crypto handshake info hash for this swarm'))\n      }\n      this.sendPe4()\n    }\n  }\n\n  sendPe4 () {\n    this.wire.sendPe4(this.swarm.infoHash)\n    this.sentPe4 = true\n  }\n\n  onPe4 () {\n    if (!this.sentHandshake) this.handshake()\n  }\n\n  clearPipes () {\n    this.conn.unpipe()\n    this.wire.unpipe()\n  }\n\n  setThrottlePipes () {\n    const self = this\n    pipeline(\n      this.conn,\n      this.throttleGroups.down.throttle(),\n      new Transform({\n        transform (chunk, callback) {\n          self.emit('download', chunk.length)\n          if (self.destroyed) return\n          callback(null, chunk)\n        }\n      }),\n      this.wire,\n      this.throttleGroups.up.throttle(),\n      new Transform({\n        transform (chunk, callback) {\n          self.emit('upload', chunk.length)\n          if (self.destroyed) return\n          callback(null, chunk)\n        }\n      }),\n      this.conn\n    )\n  }\n\n  /**\n   * Called when handshake is received from remote peer.\n   * @param {string} infoHash\n   * @param {string} peerId\n   */\n  onHandshake (infoHash, peerId) {\n    if (!this.swarm) return // `this.swarm` not set yet, so do nothing\n    if (this.destroyed) return\n\n    if (this.swarm.destroyed) {\n      return this.destroy(new Error('swarm already destroyed'))\n    }\n    if (infoHash !== this.swarm.infoHash) {\n      return this.destroy(new Error('unexpected handshake info hash for this swarm'))\n    }\n    if (peerId === this.swarm.peerId) {\n      return this.destroy(new Error('refusing to connect to ourselves'))\n    }\n\n    debug('Peer %s got handshake %s', this.id, infoHash)\n\n    clearTimeout(this.handshakeTimeout)\n\n    this.retries = 0\n\n    let addr = this.addr\n    if (!addr && this.conn.remoteAddress && this.conn.remotePort) {\n      addr = `${this.conn.remoteAddress}:${this.conn.remotePort}`\n    }\n    this.swarm._onWire(this.wire, addr)\n\n    // swarm could be destroyed in user's 'wire' event handler\n    if (!this.swarm || this.swarm.destroyed) return\n\n    if (!this.sentHandshake) this.handshake()\n  }\n\n  handshake () {\n    const opts = {\n      dht: this.swarm.private ? false : !!this.swarm.client.dht,\n      fast: true\n    }\n    this.wire.handshake(this.swarm.infoHash, this.swarm.client.peerId, opts)\n    this.sentHandshake = true\n  }\n\n  startConnectTimeout () {\n    clearTimeout(this.connectTimeout)\n\n    const connectTimeoutValues = {\n      webrtc: CONNECT_TIMEOUT_WEBRTC,\n      tcpOutgoing: CONNECT_TIMEOUT_TCP,\n      utpOutgoing: CONNECT_TIMEOUT_UTP\n    }\n\n    this.connectTimeout = setTimeout(() => {\n      this.destroy(new Error('connect timeout'))\n    }, connectTimeoutValues[this.type])\n    if (this.connectTimeout.unref) this.connectTimeout.unref()\n  }\n\n  startHandshakeTimeout () {\n    clearTimeout(this.handshakeTimeout)\n    this.handshakeTimeout = setTimeout(() => {\n      this.destroy(new Error('handshake timeout'))\n    }, HANDSHAKE_TIMEOUT)\n    if (this.handshakeTimeout.unref) this.handshakeTimeout.unref()\n  }\n\n  destroy (err) {\n    if (this.destroyed) return\n    this.destroyed = true\n    if (this.connected) this.emit('disconnect', err)\n    this.connected = false\n\n    debug('destroy %s %s (error: %s)', this.type, this.id, err && (err.message || err))\n\n    clearTimeout(this.connectTimeout)\n    clearTimeout(this.handshakeTimeout)\n\n    const swarm = this.swarm\n    const conn = this.conn\n    const wire = this.wire\n\n    this.swarm = null\n    this.conn = null\n    this.wire = null\n\n    if (swarm && wire) {\n      arrayRemove(swarm.wires, swarm.wires.indexOf(wire))\n    }\n    if (conn) {\n      conn.on('error', () => {})\n      conn.destroy()\n    }\n    if (wire) wire.destroy()\n    if (swarm) swarm.removePeer(this.id)\n  }\n}\n\nPeer.TYPE_TCP_INCOMING = TYPE_TCP_INCOMING\nPeer.TYPE_TCP_OUTGOING = TYPE_TCP_OUTGOING\nPeer.TYPE_UTP_INCOMING = TYPE_UTP_INCOMING\nPeer.TYPE_UTP_OUTGOING = TYPE_UTP_OUTGOING\nPeer.TYPE_WEBRTC = TYPE_WEBRTC\nPeer.TYPE_WEBSEED = TYPE_WEBSEED\n\nPeer.SOURCE_MANUAL = SOURCE_MANUAL\nPeer.SOURCE_TRACKER = SOURCE_TRACKER\nPeer.SOURCE_DHT = SOURCE_DHT\nPeer.SOURCE_LSD = SOURCE_LSD\nPeer.SOURCE_UT_PEX = SOURCE_UT_PEX\n\n/**\n * WebRTC peer connections start out connected, because WebRTC peers require an\n * \"introduction\" (i.e. WebRTC signaling), and there's no equivalent to an IP address\n * that lets you refer to a WebRTC endpoint.\n */\nPeer.createWebRTCPeer = (conn, swarm, throttleGroups, source = null) => {\n  const peer = new Peer(conn.id, 'webrtc')\n  peer.conn = conn\n  peer.swarm = swarm\n  peer.throttleGroups = throttleGroups\n  peer.source = source\n\n  if (peer.conn.connected) {\n    peer.onConnect()\n  } else {\n    const cleanup = () => {\n      peer.conn.removeListener('connect', onConnect)\n      peer.conn.removeListener('error', onError)\n    }\n    const onConnect = () => {\n      cleanup()\n      peer.onConnect()\n    }\n    const onError = err => {\n      cleanup()\n      peer.destroy(err)\n    }\n    peer.conn.once('connect', onConnect)\n    peer.conn.once('error', onError)\n    peer.startConnectTimeout()\n  }\n\n  return peer\n}\n\n/**\n * Incoming TCP peers start out connected, because the remote peer connected to the\n * listening port of the TCP server. Until the remote peer sends a handshake, we don't\n * know what swarm the connection is intended for.\n */\nPeer.createTCPIncomingPeer = (conn, throttleGroups) => {\n  return Peer._createIncomingPeer(conn, TYPE_TCP_INCOMING, throttleGroups)\n}\n\n/**\n * Incoming uTP peers start out connected, because the remote peer connected to the\n * listening port of the uTP server. Until the remote peer sends a handshake, we don't\n * know what swarm the connection is intended for.\n */\nPeer.createUTPIncomingPeer = (conn, throttleGroups) => {\n  return Peer._createIncomingPeer(conn, TYPE_UTP_INCOMING, throttleGroups)\n}\n\n/**\n * Outgoing TCP peers start out with just an IP address. At some point (when there is an\n * available connection), the client can attempt to connect to the address.\n */\nPeer.createTCPOutgoingPeer = (addr, swarm, throttleGroups, source) => {\n  return Peer._createOutgoingPeer(addr, swarm, TYPE_TCP_OUTGOING, throttleGroups, source)\n}\n\n/**\n * Outgoing uTP peers start out with just an IP address. At some point (when there is an\n * available connection), the client can attempt to connect to the address.\n */\nPeer.createUTPOutgoingPeer = (addr, swarm, throttleGroups, source) => {\n  return Peer._createOutgoingPeer(addr, swarm, TYPE_UTP_OUTGOING, throttleGroups, source)\n}\n\nPeer._createIncomingPeer = (conn, type, throttleGroups) => {\n  const addr = `${conn.remoteAddress}:${conn.remotePort}`\n  const peer = new Peer(addr, type)\n  peer.conn = conn\n  peer.addr = addr\n  peer.throttleGroups = throttleGroups\n\n  peer.onConnect()\n\n  return peer\n}\n\nPeer._createOutgoingPeer = (addr, swarm, type, throttleGroups, source = null) => {\n  const peer = new Peer(addr, type)\n  peer.addr = addr\n  peer.swarm = swarm\n  peer.throttleGroups = throttleGroups\n  peer.source = source\n\n  return peer\n}\n\n/**\n * Peer that represents a Web Seed (BEP17 / BEP19).\n */\n\nPeer.createWebSeedPeer = (conn, id, swarm, throttleGroups) => {\n  const peer = new Peer(id, TYPE_WEBSEED)\n\n  peer.swarm = swarm\n  peer.conn = conn\n  peer.throttleGroups = throttleGroups\n\n  peer.onConnect()\n\n  return peer\n}\n"
  },
  {
    "path": "lib/rarity-map.js",
    "content": "/**\n * Mapping of torrent pieces to their respective availability in the torrent swarm. Used\n * by the torrent manager for implementing the rarest piece first selection strategy.\n */\nexport default class RarityMap {\n  constructor (torrent) {\n    this._torrent = torrent\n    this._numPieces = torrent.pieces.length\n    this._pieces = new Array(this._numPieces)\n\n    this._onWire = wire => {\n      this.recalculate()\n      this._initWire(wire)\n    }\n    this._onWireHave = index => {\n      this._pieces[index] += 1\n    }\n    this._onWireBitfield = () => {\n      this.recalculate()\n    }\n\n    this._torrent.wires.forEach(wire => {\n      this._initWire(wire)\n    })\n    this._torrent.on('wire', this._onWire)\n    this.recalculate()\n  }\n\n  /**\n   * Get the index of the rarest piece. Optionally, pass a filter function to exclude\n   * certain pieces (for instance, those that we already have).\n   *\n   * @param {function} pieceFilterFunc\n   * @return {number} index of rarest piece, or -1\n   */\n  getRarestPiece (pieceFilterFunc) {\n    let candidates = []\n    let min = Infinity\n\n    for (let i = 0; i < this._numPieces; ++i) {\n      if (pieceFilterFunc && !pieceFilterFunc(i)) continue\n\n      const availability = this._pieces[i]\n      if (availability === min) {\n        candidates.push(i)\n      } else if (availability < min) {\n        candidates = [i]\n        min = availability\n      }\n    }\n\n    if (candidates.length) {\n      // if there are multiple pieces with the same availability, choose one randomly\n      return candidates[Math.random() * candidates.length | 0]\n    } else {\n      return -1\n    }\n  }\n\n  destroy () {\n    this._torrent.removeListener('wire', this._onWire)\n    this._torrent.wires.forEach(wire => {\n      this._cleanupWireEvents(wire)\n    })\n    this._torrent = null\n    this._pieces = null\n\n    this._onWire = null\n    this._onWireHave = null\n    this._onWireBitfield = null\n  }\n\n  _initWire (wire) {\n    wire._onClose = () => {\n      this._cleanupWireEvents(wire)\n      for (let i = 0; i < this._numPieces; ++i) {\n        this._pieces[i] -= wire.peerPieces.get(i)\n      }\n    }\n\n    wire.on('have', this._onWireHave)\n    wire.on('bitfield', this._onWireBitfield)\n    wire.once('close', wire._onClose)\n  }\n\n  /**\n   * Recalculates piece availability across all peers in the torrent.\n   */\n  recalculate () {\n    this._pieces.fill(0)\n\n    for (const wire of this._torrent.wires) {\n      for (let i = 0; i < this._numPieces; ++i) {\n        this._pieces[i] += wire.peerPieces.get(i)\n      }\n    }\n  }\n\n  _cleanupWireEvents (wire) {\n    wire.removeListener('have', this._onWireHave)\n    wire.removeListener('bitfield', this._onWireBitfield)\n    if (wire._onClose) wire.removeListener('close', wire._onClose)\n    wire._onClose = null\n  }\n}\n"
  },
  {
    "path": "lib/selections.js",
    "content": "/**\n * @typedef {Object} MinimalSelectionItem\n * @property {number} from\n * @property {number} to\n */\n\n/** A selection of pieces to download.\n * @typedef {MinimalSelectionItem & {\n *  offset: number,\n *  priority?: number,\n *  notify?: function\n *  remove?: function,\n *  isStreamSelection?: boolean\n * }} SelectionItem\n */\n\n/**\n * @typedef {MinimalSelectionItem & {notify: function}} NotificationItem\n */\n\nexport class Selections {\n  /** @type {Array<SelectionItem>} */\n  _items = []\n\n  /**\n   * @param {MinimalSelectionItem & {isStreamSelection?: boolean}} item Interval to be removed from the selection\n   */\n  remove (item) {\n    for (let i = 0; i < this._items.length; i++) {\n      const existing = this._items[i]\n      // we only remove stream selections when the `isStreamSelection` flag match, cast to boolean using !\n      if (!existing.isStreamSelection !== !item.isStreamSelection) continue\n\n      if (existing.isStreamSelection) {\n        // If both are stream selections and they match, then we remove the first matching item, then we break the loop\n        if (existing.from === item.from && existing.to === item.to) {\n          this._items.splice(i, 1)\n          // for stream selections, we only remove one item at a time\n          // ergo we break the loop after removing the first matching item\n          // stream selections are non-unique, so this is in a way a count\n          break\n        }\n      } else {\n        if (isLowerIntersecting(item, existing)) {\n          existing.to = Math.max(item.from - 1, 0)\n        } else if (isUpperIntersecting(item, existing)) {\n          existing.from = item.to + 1\n        } else if (isInsideExisting(item, existing)) {\n          const replacingItems = []\n          const existingStart = { ...existing, to: Math.max(item.from - 1, 0) }\n          if (existingStart.to - existingStart.from >= 0 && item.from !== 0) replacingItems.push(existingStart)\n          const existingEnd = { ...existing, from: item.to + 1 }\n          if (existingEnd.to - existingEnd.from >= 0) replacingItems.push(existingEnd)\n          this._items.splice(i, 1, ...replacingItems)\n          i = i - 1 + replacingItems.length // decrement i to offset splice\n        } else if (isCoveringExisting(item, existing)) {\n          this._items.splice(i, 1)\n          i--\n        }\n      }\n    }\n  }\n\n  /**\n   * Merges the priority and notify functions of two selection items.\n   * @param {SelectionItem} newItem\n   * @param {SelectionItem} existing\n   */\n  _mergePriorityAndNotify (newItem, existing) {\n    if ((existing.priority ?? 0) > (newItem.priority ?? 0)) {\n      newItem.priority = existing.priority\n    }\n\n    if (newItem.notify && existing.notify) {\n      const oldNotify = newItem.notify\n      newItem.notify = () => {\n        oldNotify()\n        existing.notify?.()\n      }\n    } else {\n      newItem.notify = existing.notify || newItem.notify\n    }\n  }\n\n  concatenate (newItem) {\n    for (let i = 0; i < this._items.length; i++) {\n      const existing = this._items[i]\n\n      if (!existing.isStreamSelection) {\n        if (isLowerIntersecting(newItem, existing)) {\n          newItem.from = existing.from\n        } else if (isUpperIntersecting(newItem, existing)) {\n          newItem.to = existing.to\n        } else if (isInsideExisting(newItem, existing)) {\n          newItem.from = existing.from\n          newItem.to = existing.to\n        } else if (isCoveringExisting(newItem, existing)) {\n          continue\n        } else {\n          continue\n        }\n        this._mergePriorityAndNotify(newItem, existing)\n      }\n    }\n\n    this.remove(newItem)\n  }\n\n  /**\n   * @param {SelectionItem & NotificationItem} newItem\n   */\n  insert (newItem) {\n    if (newItem.from > newItem.to) {\n      throw new Error('Invalid interval')\n    }\n    if (!newItem.isStreamSelection) this.concatenate(newItem)\n    this._items.push(newItem)\n  }\n\n  /** @param {(a: SelectionItem, b: SelectionItem) => number} sortFn */\n  sort (sortFn = (a, b) => a.from - b.from) {\n    this._items.sort(sortFn)\n  }\n\n  get length () {\n    return this._items.length\n  }\n\n  /**  @param {number} index */\n  get (index) {\n    return this._items[index]\n  }\n\n  swap (i, j) {\n    const temp = this._items[i]\n    this._items[i] = this._items[j]\n    this._items[j] = temp\n  }\n\n  clear () {\n    this._items.length = 0\n  }\n\n  /** @returns {Generator<SelectionItem & {remove: function}>} */\n  * [Symbol.iterator] () {\n    for (let i = 0; i < this._items.length; i++) {\n      const item = this._items[i]\n\n      item.remove = () => {\n        this._items.splice(i, 1)\n        i--\n      }\n      yield item\n      delete item.remove\n    }\n  }\n}\n\n/**\n * Examples:\n * existing: 1-10 | 1-10\n * new_item: 8-12 | 10-15\n * @param {MinimalSelectionItem} newItem\n * @param {MinimalSelectionItem} existing\n * @returns {boolean} returns true if the new item's lower end is intersecting with the existing item\n */\nexport function isLowerIntersecting (newItem, existing) {\n  return (newItem.from <= existing.to + 1) && (newItem.from > existing.from) && (newItem.to > existing.to)\n}\n\n/**\n * Examples:\n * existing: 20-25 | 20-25\n * new_item: 15-22 | 15-20\n * @param {MinimalSelectionItem} newItem\n * @param {MinimalSelectionItem} existing\n * @returns {boolean} returns true if the new item's upper end is intersecting with the existing item\n */\nexport function isUpperIntersecting (newItem, existing) {\n  return (newItem.to >= existing.from - 1) && (newItem.to < existing.to) && (newItem.from < existing.from)\n}\n\n/**\n * Examples:\n * existing: 10-20 | 10-20 | 10-20\n * new_item: 12-15 | 20-20 | 15-20\n * @param {MinimalSelectionItem} newItem\n * @param {MinimalSelectionItem} existing\n * @returns {boolean} returns true if the new item is completely inside the existing item\n */\nexport function isInsideExisting (newItem, existing) {\n  const existingIntervalSize = existing.to - existing.from\n  const newItemIntervalSize = newItem.to - newItem.from\n  return newItem.from >= existing.from && newItem.to <= existing.to && (newItemIntervalSize < existingIntervalSize)\n}\n\n/**\n * Examples:\n * existing: 10-20 | 10-20 | 10-20\n * new_item: 10-21 | 09-20 | 10-20\n * @param {MinimalSelectionItem} newItem\n * @param {MinimalSelectionItem} existing\n * @returns {boolean} returns true if the new item is covering the existing item\n */\nexport function isCoveringExisting (newItem, existing) {\n  return newItem.from <= existing.from && newItem.to >= existing.to\n}\n\nexport const isIntersecting = (newItem, existing) => () =>\n  isLowerIntersecting(newItem, existing) ||\n    isUpperIntersecting(newItem, existing) ||\n    isInsideExisting(newItem, existing) ||\n    isCoveringExisting(newItem, existing)\n"
  },
  {
    "path": "lib/server.js",
    "content": "import http from 'http'\nimport escapeHtml from 'escape-html'\nimport pump from 'pump'\nimport rangeParser from 'range-parser'\nimport queueMicrotask from 'queue-microtask'\nimport { Readable } from 'streamx'\n\nconst keepAliveTime = 20000\n\nclass ServerBase {\n  constructor (client, opts = {}) {\n    this.client = client\n    if (!opts.origin) opts.origin = '*' // allow all origins by default\n    this.opts = opts\n    this.pendingReady = new Set()\n  }\n\n  static serveIndexPage (res, torrents, pathname) {\n    const listHtml = torrents\n      .map(torrent => (\n      `<li>\n        <a href=\"${escapeHtml(pathname)}/${torrent.infoHash}\">\n          ${escapeHtml(torrent.name)}\n        </a>\n        (${escapeHtml(torrent.length)} bytes)\n      </li>`\n      ))\n      .join('<br>')\n\n    res.status = 200\n    res.headers['Content-Type'] = 'text/html'\n    res.body = getPageHTML(\n      'WebTorrent',\n      `<h1>WebTorrent</h1>\n       <ol>${listHtml}</ol>`\n    )\n\n    return res\n  }\n\n  isOriginAllowed (req) {\n    // When `origin` option is `false`, deny all cross-origin requests\n    if (this.opts.origin === false) return false\n\n    // The user allowed all origins\n    if (this.opts.origin === '*') return true\n\n    // Allow requests where the 'Origin' header matches the `opts.origin` setting\n    return req.headers.origin === this.opts.origin\n  }\n\n  static serveMethodNotAllowed (res) {\n    res.status = 405\n    res.headers['Content-Type'] = 'text/html'\n\n    res.body = getPageHTML(\n      '405 - Method Not Allowed',\n      '<h1>405 - Method Not Allowed</h1>'\n    )\n\n    return res\n  }\n\n  static serve404Page (res) {\n    res.status = 404\n    res.headers['Content-Type'] = 'text/html'\n\n    res.body = getPageHTML(\n      '404 - Not Found',\n      '<h1>404 - Not Found</h1>'\n    )\n    return res\n  }\n\n  static serveTorrentPage (torrent, res, pathname) {\n    const listHtml = torrent.files\n      .map(file => (\n      `<li>\n        <a href=\"${escapeHtml(pathname)}/${torrent.infoHash}/${escapeHtml(file.path)}\">\n          ${escapeHtml(file.path)}\n        </a>\n        (${escapeHtml(file.length)} bytes)\n      </li>`\n      ))\n      .join('<br>')\n\n    res.status = 200\n    res.headers['Content-Type'] = 'text/html'\n\n    res.body = getPageHTML(\n      `${escapeHtml(torrent.name)} - WebTorrent`,\n      `<h1>${escapeHtml(torrent.name)}</h1>\n      <ol>${listHtml}</ol>`\n    )\n\n    return res\n  }\n\n  static serveOptionsRequest (req, res) {\n    res.status = 204 // no content\n    res.headers['Access-Control-Max-Age'] = '600'\n    res.headers['Access-Control-Allow-Methods'] = 'GET,HEAD'\n\n    if (req.headers['access-control-request-headers']) {\n      res.headers['Access-Control-Allow-Headers'] = req.headers['access-control-request-headers']\n    }\n    return res\n  }\n\n  static serveFile (file, req, res) {\n    res.status = 200\n\n    // Disable caching as data is local anyways\n    res.headers.Expires = '0'\n    res.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate, max-age=0'\n    // Support range-requests\n    res.headers['Accept-Ranges'] = 'bytes'\n    res.headers['Content-Type'] = file.type\n    // Support DLNA streaming\n    res.headers['transferMode.dlna.org'] = 'Streaming'\n    res.headers['contentFeatures.dlna.org'] = 'DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000'\n\n    // Force the browser to download the file if if it's opened in a new tab\n    // Set name of file (for \"Save Page As...\" dialog)\n    if (req.destination === 'document') {\n      res.headers['Content-Type'] = 'application/octet-stream'\n      res.headers['Content-Disposition'] = `attachment; filename*=UTF-8''${encodeRFC5987(file.name)}`\n      res.body = 'DOWNLOAD'\n    } else {\n      res.headers['Content-Disposition'] = `inline; filename*=UTF-8''${encodeRFC5987(file.name)}`\n    }\n\n    // `rangeParser` returns an array of ranges, or an error code (number) if\n    // there was an error parsing the range.\n    let range = rangeParser(file.length, req.headers.range || '')\n\n    if (Array.isArray(range)) {\n      res.status = 206 // indicates that range-request was understood\n\n      // no support for multi-range request, just use the first range\n      range = range[0]\n\n      res.headers['Content-Range'] = `bytes ${range.start}-${range.end}/${file.length}`\n\n      res.headers['Content-Length'] = range.end - range.start + 1\n    } else {\n      res.statusCode = 200\n      range = null\n      res.headers['Content-Length'] = file.length\n    }\n\n    if (req.method === 'GET') {\n      const iterator = file[Symbol.asyncIterator](range)\n      let transform = null\n      file.emit('iterator', { iterator, req, file }, target => {\n        transform = target\n      })\n\n      const stream = Readable.from(transform || iterator)\n      let pipe = null\n      file.emit('stream', { stream, req, file }, target => {\n        pipe = pump(stream, target)\n      })\n\n      res.body = pipe || stream\n    } else {\n      res.body = false\n    }\n    return res\n  }\n\n  async onRequest (req, cb) {\n    let pathname = new URL(req.url, 'http://example.com').pathname\n    pathname = pathname.slice(pathname.indexOf(this.pathname) + this.pathname.length + 1)\n\n    const res = {\n      headers: {\n        // Prevent browser mime-type sniffing\n        'X-Content-Type-Options': 'nosniff',\n        // Defense-in-depth: Set a strict Content Security Policy to mitigate XSS\n        'Content-Security-Policy': \"base-uri 'none'; frame-ancestors 'none'; form-action 'none';\"\n      }\n    }\n\n    // Allow cross-origin requests (CORS)\n    if (this.isOriginAllowed(req)) {\n      res.headers['Access-Control-Allow-Origin'] = this.opts.origin === '*' ? '*' : req.headers.origin\n    }\n\n    if (pathname === 'favicon.ico') {\n      return cb(ServerBase.serve404Page(res))\n    }\n\n    // Allow CORS requests to specify arbitrary headers, e.g. 'Range',\n    // by responding to the OPTIONS preflight request with the specified\n    // origin and requested headers.\n    if (req.method === 'OPTIONS') {\n      if (this.isOriginAllowed(req)) return cb(ServerBase.serveOptionsRequest(req, res))\n      else return cb(ServerBase.serveMethodNotAllowed(res))\n    }\n\n    const onReady = async () => {\n      this.pendingReady.delete(onReady)\n      const res = await handleRequest()\n      cb(res)\n    }\n\n    const handleRequest = async () => {\n      if (pathname === '') {\n        return ServerBase.serveIndexPage(res, this.client.torrents, this.pathname)\n      }\n\n      let [infoHash, ...filePath] = pathname.split('/')\n      filePath = decodeURI(filePath.join('/'))\n\n      const torrent = await this.client.get(infoHash)\n      if (!infoHash || !torrent) {\n        return ServerBase.serve404Page(res)\n      }\n\n      if (!filePath) {\n        return ServerBase.serveTorrentPage(torrent, res, this.pathname)\n      }\n\n      const file = torrent.files.find(file => file.path.replace(/\\\\/g, '/') === filePath)\n      if (!file) {\n        return ServerBase.serve404Page(res)\n      }\n      return ServerBase.serveFile(file, req, res)\n    }\n\n    if (req.method === 'GET' || req.method === 'HEAD') {\n      if (this.client.ready) {\n        const res = await handleRequest()\n        return cb(res)\n      } else {\n        this.pendingReady.add(onReady)\n        this.client.once('ready', onReady)\n        return\n      }\n    }\n\n    return cb(ServerBase.serveMethodNotAllowed(res))\n  }\n\n  close (cb = () => {}) {\n    this.closed = true\n    this.pendingReady.forEach(onReady => {\n      this.client.removeListener('ready', onReady)\n    })\n    this.pendingReady.clear()\n    queueMicrotask(cb)\n  }\n\n  destroy (cb = () => {}) {\n    // Only call `server.close` if user has not called it already\n    if (this.closed) queueMicrotask(cb)\n    else this.close(cb)\n    this.client = null\n  }\n}\n\nclass NodeServer extends ServerBase {\n  constructor (client, opts) {\n    super(client, opts)\n\n    this.server = http.createServer()\n    this._listen = this.server.listen\n    this.server.listen = this.listen.bind(this)\n    this._close = this.server.close\n    this.server.close = this.close.bind(this)\n\n    this.sockets = new Set()\n    this.closed = false\n    this.pathname = opts?.pathname || '/webtorrent'\n  }\n\n  wrapRequest (req, res) {\n    // If a 'hostname' string is specified, deny requests with a 'Host'\n    // header that does not match the origin of the torrent server to prevent\n    // DNS rebinding attacks.\n    if (this.opts.hostname && req.headers.host !== `${this.opts.hostname}:${this.server.address().port}`) {\n      return req.destroy()\n    }\n\n    if (!new URL(req.url, 'http://example.com').pathname.startsWith(this.pathname)) {\n      return req.destroy()\n    }\n\n    this.onRequest(req, ({ status, headers, body }) => {\n      res.writeHead(status, headers)\n\n      if (!!body?._readableState || !!body?._writableState) { // this is probably a bad way of checking? idk\n        pump(body, res)\n      } else {\n        res.end(body)\n      }\n    })\n  }\n\n  onConnection (socket) {\n    socket.setTimeout(36000000)\n    this.sockets.add(socket)\n    socket.once('close', () => {\n      this.sockets.delete(socket)\n    })\n  }\n\n  address () {\n    return this.server.address()\n  }\n\n  listen (...args) {\n    this.closed = false\n    this.server.on('connection', this.onConnection.bind(this))\n    this.server.on('request', this.wrapRequest.bind(this))\n    return this._listen.apply(this.server, args)\n  }\n\n  close (cb = () => {}) {\n    this.server.removeAllListeners('connection')\n    this.server.removeAllListeners('request')\n    this.server.removeAllListeners('listening')\n    super.close()\n    this._close.call(this.server, cb)\n  }\n\n  destroy (cb) {\n    this.sockets.forEach(socket => {\n      socket.destroy()\n    })\n    super.destroy(cb)\n  }\n}\n\nclass BrowserServer extends ServerBase {\n  constructor (client, opts) {\n    super(client, opts)\n\n    this.registration = opts.controller\n    this.workerKeepAliveInterval = null\n    this.workerPortCount = 0\n\n    const scope = new URL(opts.controller.scope)\n    this.pathname = scope.pathname + 'webtorrent'\n    this._address = {\n      port: scope.port,\n      family: 'IPv4', // might be a bad idea?\n      address: scope.hostname\n    }\n\n    this.boundHandler = this.wrapRequest.bind(this)\n    navigator.serviceWorker.addEventListener('message', this.boundHandler)\n    // test if browser supports cancelling sw Readable Streams\n    fetch(`${this.pathname}/cancel/`).then(res => {\n      res.body.cancel()\n    })\n  }\n\n  wrapRequest (event) {\n    const req = event.data\n\n    if (!req?.type === 'webtorrent' || !req.url) return null\n\n    const [port] = event.ports\n    this.onRequest(req, ({ status, headers, body }) => {\n      const asyncIterator = body[Symbol.asyncIterator]?.()\n\n      const cleanup = () => {\n        port.onmessage = null\n        if (body?.destroy) body.destroy()\n        this.workerPortCount--\n        if (!this.workerPortCount) {\n          clearInterval(this.workerKeepAliveInterval)\n          this.workerKeepAliveInterval = null\n        }\n      }\n\n      port.onmessage = async msg => {\n        if (msg.data) {\n          let chunk\n          try {\n            chunk = (await asyncIterator.next()).value\n          } catch (e) {\n            // chunk is yet to be downloaded or it somehow failed, should this be logged?\n          }\n          port.postMessage(chunk)\n          if (!chunk) cleanup()\n          if (!this.workerKeepAliveInterval) {\n            this.workerKeepAliveInterval = setInterval(() => fetch(`${this.pathname}/keepalive/`), keepAliveTime)\n          }\n        } else {\n          cleanup()\n        }\n      }\n      this.workerPortCount++\n      port.postMessage({\n        status,\n        headers,\n        body: asyncIterator ? 'STREAM' : body\n      })\n    })\n  }\n\n  // for compatibility with node version\n  listen (_, cb) {\n    cb()\n  }\n\n  address () {\n    return this._address\n  }\n\n  close (cb) {\n    navigator.serviceWorker.removeEventListener('message', this.boundHandler)\n    super.close(cb)\n  }\n\n  destroy (cb) {\n    super.destroy(cb)\n  }\n}\n\n// NOTE: Arguments must already be HTML-escaped\nfunction getPageHTML (title, pageHtml) {\n  return `\n    <!DOCTYPE html>\n    <html lang=\"en\">\n      <head>\n        <meta charset=\"utf-8\">\n        <title>${title}</title>\n      </head>\n      <body>\n        ${pageHtml}\n      </body>\n    </html>\n  `\n}\n\n// From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent\nfunction encodeRFC5987 (str) {\n  return encodeURIComponent(str)\n    // Note that although RFC3986 reserves \"!\", RFC5987 does not,\n    // so we do not need to escape it\n    .replace(/['()]/g, escape) // i.e., %27 %28 %29\n    .replace(/\\*/g, '%2A')\n    // The following are not required for percent-encoding per RFC5987,\n    // so we can allow for a little better readability over the wire: |`^\n    .replace(/%(?:7C|60|5E)/g, unescape)\n}\n\nexport { NodeServer, BrowserServer }\n"
  },
  {
    "path": "lib/torrent.js",
    "content": "import EventEmitter from 'events'\nimport fs from 'fs'\nimport net from 'net' // browser exclude\nimport os from 'os' // browser exclude\nimport path from 'path'\nimport addrToIPPort from 'addr-to-ip-port'\nimport BitField from 'bitfield'\nimport CacheChunkStore from 'cache-chunk-store'\nimport { chunkStoreWrite } from 'chunk-store-iterator'\nimport cpus from 'cpus'\nimport debugFactory from 'debug'\nimport Discovery from 'torrent-discovery'\nimport FSChunkStore from 'fs-chunk-store' // browser: `fsa-chunk-store`\nimport fetch from 'cross-fetch-ponyfill'\nimport ImmediateChunkStore from 'immediate-chunk-store'\nimport ltDontHave from 'lt_donthave'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport joinIterator from 'join-async-iterator'\nimport parallel from 'run-parallel'\nimport parallelLimit from 'run-parallel-limit'\nimport parseTorrent, { toMagnetURI, toTorrentFile, remote } from 'parse-torrent'\nimport Piece from 'torrent-piece'\nimport queueMicrotask from 'queue-microtask'\nimport randomIterate from 'random-iterate'\nimport { hash, arr2hex } from 'uint8-util'\nimport throughput from 'throughput'\nimport utMetadata from 'ut_metadata'\nimport utPex from 'ut_pex' // browser exclude\n\nimport File from './file.js'\nimport Peer from './peer.js'\nimport RarityMap from './rarity-map.js'\nimport utp from './utp.cjs' // browser exclude\nimport WebConn from './webconn.js'\nimport { Selections } from './selections.js'\n\nimport VERSION from '../version.cjs'\n\n// The following JSDoc comments are global types that can be used across the project\n\n/**\n * This callback is called with an optional error, if the error is a falsy value the operation was executed successfully\n * @callback callbackWithError\n * @param {Error=} error\n */\n\n/**\n * @typedef TorrentOpts\n * @type {object}\n * @property {Array<string>=} announce - Torrent trackers to use (added to list in .torrent or magnet uri)\n * @property {Array<string>=} urlList - Array of web seeds\n * @property {string=} path - Folder to download files to (default=`/tmp/webtorrent/`)\n * @property {boolean=} addUID - (Node.js only) If true, the torrent will be stored in it's infoHash folder to prevent file name collisions (default=false)\n * @property {FileSystemDirectoryHandle=} rootDir - *(browser only)* if supported by the browser, allows the user to specify a custom directory to stores the files in, retaining the torrent's folder and file structure\n * @property {boolean=} skipVerify - If true, client will skip verification of pieces for existing store and assume it's correct\n * @property {Uint8Array|ArrayLike<number>=} bitfield -  Preloaded numerical array/buffer to use to know what pieces are already downloaded (any type accepted by UInt8Array constructor is valid)\n * @property {FSChunkStore|MemoryChunkStore|Function=} store - Custom chunk store\n * @property {FSChunkStore|MemoryChunkStore|Function=} preloadedStore -  Custom, pre-loaded chunk store\n * @property {number=} storeCacheSlots - Number of chunk store entries (torrent pieces) to cache in memory [default=20]; 0 to disable caching\n * @property {boolean=} destroyStoreOnDestroy - If truthy, client will delete the torrent's chunk store (e.g. files on disk) when the torrent is destroyed\n * @property {object=} storeOpts - Custom options passed to the store\n * @property {boolean=} alwaysChokeSeeders - If true, client will automatically choke seeders if it's seeding. (default=true)\n * @property {function(): object=} getAnnounceOpts - Custom callback to allow sending extra parameters to the tracker\n * @property {boolean=} private - If true, client will not share the hash with the DHT nor with PEX (default is the privacy of the parsed torrent)\n * @property {'rarest'|'sequential'=} strategy - Piece selection strategy, `rarest` or `sequential`(defaut=`sequential`)\n * @property {number=} maxWebConns - Max number of simultaneous connections per web seed [default=4]\n * @property {number|false=} uploads - [default=10]\n * @property {number=} noPeersIntervalTime - The amount of time (in seconds) to wait between each check of the `noPeers` event (default=30)\n * @property {boolean=} deselect - If true, create the torrent with no pieces selected (default=false)\n * @property {boolean=} paused - If true, create the torrent in a paused state (default=false)\n * @property {Array<number>=} fileModtimes - An array containing a UNIX timestamp indicating the last change for each file of the torrent\n */\n\n// End of JSDoc global declarations\n\nconst debug = debugFactory('webtorrent:torrent')\nconst MAX_BLOCK_LENGTH = 128 * 1024\nconst PIECE_TIMEOUT = 30_000\nconst CHOKE_TIMEOUT = 5_000\nconst SPEED_THRESHOLD = 3 * Piece.BLOCK_LENGTH\n\nconst PIPELINE_MIN_DURATION = 0.5\nconst PIPELINE_MAX_DURATION = 1\n\nconst RECHOKE_INTERVAL = 10_000 // 10 seconds\nconst RECHOKE_OPTIMISTIC_DURATION = 2 // 30 seconds\n\nconst DEFAULT_NO_PEERS_INTERVAL = 30_000 // 30 seconds\n\n// IndexedDB chunk stores used in the browser benefit from high concurrency\nconst FILESYSTEM_CONCURRENCY = process.browser ? cpus().length : 2\n\nconst RECONNECT_WAIT = [1_000, 5_000, 15_000]\n\nconst USER_AGENT = `WebTorrent/${VERSION} (https://webtorrent.io)`\n\n// if nodejs or browser that supports FSA\nconst SUPPORTS_FSA = globalThis.navigator?.storage?.getDirectory && globalThis.FileSystemFileHandle?.prototype?.createWritable\nconst FALLBACK_STORE = !process.browser || SUPPORTS_FSA\n  ? FSChunkStore // Node or browser with FSA\n  : MemoryChunkStore\n\nlet TMP\ntry {\n  TMP = path.join(fs.statSync('/tmp') && '/tmp', 'webtorrent')\n} catch (err) {\n  TMP = path.join(typeof os.tmpdir === 'function' ? os.tmpdir() : '/', 'webtorrent')\n}\n\nconst IDLE_CALLBACK = typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function' && window.requestIdleCallback\n\nexport default class Torrent extends EventEmitter {\n  /**\n   * Start downloading a new torrent.\n   * @param {string|ArrayBufferView|Object} torrentId\n   * @param {import('../index.js').default} client\n   * @param {TorrentOpts} opts\n   */\n  constructor (torrentId, client, opts) {\n    super()\n\n    this._debugId = 'unknown infohash'\n    this.client = client\n\n    this.announce = opts.announce\n    this.urlList = opts.urlList\n\n    this.path = opts.path || TMP\n    this.addUID = opts.addUID || false\n    this.rootDir = opts.rootDir || null\n    this.skipVerify = !!opts.skipVerify\n    this._startupBitfield = opts.bitfield\n    this._store = opts.store || FALLBACK_STORE\n    this._preloadedStore = opts.preloadedStore || null\n    this._storeCacheSlots = opts.storeCacheSlots !== undefined ? opts.storeCacheSlots : 20\n    this._destroyStoreOnDestroy = opts.destroyStoreOnDestroy || false\n    this.store = null\n    this.storeOpts = opts.storeOpts\n    this.alwaysChokeSeeders = opts.alwaysChokeSeeders ?? true\n\n    this._getAnnounceOpts = opts.getAnnounceOpts\n\n    // if defined, `opts.private` overrides default privacy of torrent\n    if (typeof opts.private === 'boolean') this.private = opts.private\n\n    this.strategy = opts.strategy || 'sequential'\n\n    this.maxWebConns = opts.maxWebConns || 4\n\n    this._rechokeNumSlots = (opts.uploads === false || opts.uploads === 0)\n      ? 0\n      : (+opts.uploads || 10)\n    this._rechokeOptimisticWire = null\n    this._rechokeOptimisticTime = 0\n    this._rechokeIntervalId = null\n    this._noPeersIntervalId = null\n    this._noPeersIntervalTime = opts.noPeersIntervalTime ? opts.noPeersIntervalTime * 1000 : DEFAULT_NO_PEERS_INTERVAL\n    this._startAsDeselected = opts.deselect || false\n\n    this.ready = false\n    this.destroyed = false\n    this.paused = opts.paused || false\n    this.done = false\n\n    this.metadata = null\n    /**\n     * Files of the torrent\n     * @type {File[]}\n     */\n    this.files = []\n\n    /**\n     * Pieces that need to be downloaded, indexed by piece index\n     * @type {Array<Piece|null>}\n     */\n    this.pieces = []\n\n    this._amInterested = false\n    this._selections = new Selections()\n    this._critical = []\n    /**\n     * open wires (added *after* handshake)\n     * @type {import('bittorrent-protocol').default[]}\n     */\n    this.wires = []\n\n    this._queue = [] // queue of outgoing tcp peers to connect to\n    /**\n     * connected peers (addr/peerId -> Peer)\n     * @type {Map<string, Peer>}\n     */\n    this._peers = new Map()\n    this._peersLength = 0 // number of elements in `this._peers` (cache, for perf)\n\n    // stats\n    this.received = 0\n    this.uploaded = 0\n    this._downloadSpeed = throughput()\n    this._uploadSpeed = throughput()\n\n    // for cleanup\n    this._servers = []\n    this._xsRequests = []\n\n    // TODO: remove this and expose a hook instead\n    // optimization: don't recheck every file if it hasn't changed\n    this._fileModtimes = opts.fileModtimes\n\n    if (torrentId !== null) this._onTorrentId(torrentId)\n\n    this._debug('new torrent')\n  }\n\n  get timeRemaining () {\n    if (this.done) return 0\n    if (this.downloadSpeed === 0) return Infinity\n    return ((this.length - this.downloaded) / this.downloadSpeed) * 1000\n  }\n\n  get downloaded () {\n    if (!this.bitfield) return 0\n    let downloaded = 0\n    for (let index = 0, len = this.pieces.length; index < len; ++index) {\n      if (this.bitfield.get(index)) { // verified data\n        downloaded += (index === len - 1) ? this.lastPieceLength : this.pieceLength\n      } else { // \"in progress\" data\n        const piece = this.pieces[index]\n        downloaded += (piece.length - piece.missing)\n      }\n    }\n    return downloaded\n  }\n\n  // TODO: re-enable this. The number of missing pieces. Used to implement 'end game' mode.\n  // Object.defineProperty(Storage.prototype, 'numMissing', {\n  //   get: function () {\n  //     var self = this\n  //     var numMissing = self.pieces.length\n  //     for (var index = 0, len = self.pieces.length; index < len; index++) {\n  //       numMissing -= self.bitfield.get(index)\n  //     }\n  //     return numMissing\n  //   }\n  // })\n\n  get downloadSpeed () { return this._downloadSpeed() }\n\n  get uploadSpeed () { return this._uploadSpeed() }\n\n  get progress () { return this.length ? this.downloaded / this.length : 0 }\n\n  get ratio () { return this.uploaded / (this.received || this.length) }\n\n  get numPeers () { return this.wires.length }\n\n  get torrentFileBlob () {\n    if (!this.torrentFile) return null\n    return new Blob([this.torrentFile], { type: 'application/x-bittorrent' })\n  }\n\n  get _numQueued () {\n    return this._queue.length + (this._peersLength - this._numConns)\n  }\n\n  _numConns = 0\n\n  /**\n   * Parse a torrent from its magnet/torrent file/remote url and kickstart downloading it\n   * @param {string|ArrayBufferView|Object} torrentId\n   * @returns {Promise<void>}\n   * @private\n   */\n  async _onTorrentId (torrentId) {\n    if (this.destroyed) return\n\n    let parsedTorrent\n    try { parsedTorrent = await parseTorrent(torrentId) } catch (err) {}\n    if (parsedTorrent) {\n      // Attempt to set infoHash property synchronously\n      this.infoHash = parsedTorrent.infoHash\n      this._debugId = arr2hex(parsedTorrent.infoHash).substring(0, 7)\n      queueMicrotask(() => {\n        if (this.destroyed) return\n        this._onParsedTorrent(parsedTorrent)\n      })\n    } else {\n      // If torrentId failed to parse, it could be in a form that requires an async\n      // operation, i.e. http/https link, filesystem path, or Blob.\n      remote(torrentId, (err, parsedTorrent) => {\n        if (this.destroyed) return\n        if (err) return this._destroy(err)\n        this._onParsedTorrent(parsedTorrent)\n      })\n    }\n  }\n\n  _onParsedTorrent (parsedTorrent) {\n    if (this.destroyed) return\n\n    this._processParsedTorrent(parsedTorrent)\n\n    if (!this.infoHash) {\n      return this._destroy(new Error('Malformed torrent data: No info hash'))\n    }\n\n    this._rechokeIntervalId = setInterval(() => {\n      this._rechoke()\n    }, RECHOKE_INTERVAL)\n    if (this._rechokeIntervalId.unref) this._rechokeIntervalId.unref()\n\n    // Private 'infoHash' event allows client.add to check for duplicate torrents and\n    // destroy them before the normal 'infoHash' event is emitted. Prevents user\n    // applications from needing to deal with duplicate 'infoHash' events.\n    this.emit('_infoHash', this.infoHash)\n    if (this.destroyed) return\n\n    this.emit('infoHash', this.infoHash)\n    if (this.destroyed) return // user might destroy torrent in event handler\n\n    if (this.client.listening) {\n      this._onListening()\n    } else {\n      this.client.once('listening', () => {\n        this._onListening()\n      })\n    }\n  }\n\n  _processParsedTorrent (parsedTorrent) {\n    this._debugId = arr2hex(parsedTorrent.infoHash).substring(0, 7)\n\n    if (typeof this.private !== 'undefined') {\n      // `private` option overrides default, only if it's defined\n      parsedTorrent.private = this.private\n    }\n\n    if (Array.isArray(this.announce)) {\n      // Allow specifying trackers via `opts` parameter\n      parsedTorrent.announce = parsedTorrent.announce.concat(this.announce)\n    }\n\n    if (this.client.tracker && Array.isArray(this.client.tracker.announce) && !parsedTorrent.private) {\n      // If the client has a default tracker, add it to the announce list if torrent is not private\n      parsedTorrent.announce = parsedTorrent.announce.concat(this.client.tracker.announce)\n    }\n\n    if (this.client.tracker && global.WEBTORRENT_ANNOUNCE && !parsedTorrent.private) {\n      // So `webtorrent-hybrid` can force specific trackers to be used\n      parsedTorrent.announce = parsedTorrent.announce.concat(global.WEBTORRENT_ANNOUNCE)\n    }\n\n    if (this.urlList) {\n      // Allow specifying web seeds via `opts` parameter\n      parsedTorrent.urlList = parsedTorrent.urlList.concat(this.urlList)\n    }\n\n    // remove duplicates by converting to Set and back\n    parsedTorrent.announce = Array.from(new Set(parsedTorrent.announce))\n    parsedTorrent.urlList = Array.from(new Set(parsedTorrent.urlList))\n\n    Object.assign(this, parsedTorrent)\n\n    this.magnetURI = toMagnetURI(parsedTorrent)\n    this.torrentFile = toTorrentFile(parsedTorrent)\n  }\n\n  _onListening () {\n    if (this.destroyed) return\n\n    if (this.info) {\n      // if full metadata was included in initial torrent id, use it immediately. Otherwise,\n      // wait for torrent-discovery to find peers and ut_metadata to get the metadata.\n      this._onMetadata(this)\n    } else {\n      if (this.xs) this._getMetadataFromServer()\n      this._startDiscovery()\n    }\n  }\n\n  _startDiscovery () {\n    if (this.discovery || this.destroyed) return\n\n    let trackerOpts = this.client.tracker\n    if (trackerOpts) {\n      trackerOpts = Object.assign({}, this.client.tracker, {\n        getAnnounceOpts: () => {\n          if (this.destroyed) return\n\n          const opts = {\n            uploaded: this.uploaded,\n            downloaded: this.downloaded,\n            left: Math.max(this.length - this.downloaded, 0)\n          }\n          if (this.client.tracker.getAnnounceOpts) {\n            Object.assign(opts, this.client.tracker.getAnnounceOpts())\n          }\n          if (this._getAnnounceOpts) {\n            // TODO: consider deprecating this, as it's redundant with the former case\n            Object.assign(opts, this._getAnnounceOpts())\n          }\n          return opts\n        }\n      })\n    }\n\n    // add BEP09 peer-address\n    if (this.peerAddresses) {\n      this.peerAddresses.forEach(peer => this.addPeer(peer, Peer.SOURCE_MANUAL))\n    }\n\n    // begin discovering peers via DHT and trackers\n    this.discovery = new Discovery({\n      infoHash: this.infoHash,\n      announce: this.announce,\n      peerId: this.client.peerId,\n      dht: !this.private && this.client.dht,\n      tracker: trackerOpts,\n      port: this.client.torrentPort,\n      userAgent: USER_AGENT,\n      lsd: this.client.lsd\n    })\n\n    this.discovery.on('error', (err) => {\n      this._destroy(err)\n    })\n\n    this.discovery.on('peer', (peer, source) => {\n      this._debug('peer %s discovered via %s', peer, source)\n      // Don't create new outgoing connections when torrent is done and seedOutgoingConnections is false.\n      if (!this.client.seedOutgoingConnections && this.done) {\n        this._debug('discovery ignoring peer %s: torrent is done and seedOutgoingConnections is false', peer)\n        return\n      }\n      this.addPeer(peer, source)\n    })\n\n    this.discovery.on('trackerAnnounce', () => {\n      this.emit('trackerAnnounce')\n    })\n\n    this.discovery.on('dhtAnnounce', () => {\n      this.emit('dhtAnnounce')\n    })\n\n    this.discovery.on('warning', (err) => {\n      this.emit('warning', err)\n    })\n\n    this._noPeersIntervalId = setInterval(() => {\n      if (this.destroyed) return\n\n      const counters = {\n        [Peer.SOURCE_TRACKER]: {\n          enabled: !!this.client.tracker,\n          numPeers: 0\n        },\n        [Peer.SOURCE_DHT]: {\n          enabled: !!this.client.dht,\n          numPeers: 0\n        },\n        [Peer.SOURCE_LSD]: {\n          enabled: !!this.client.lsd,\n          numPeers: 0\n        },\n        [Peer.SOURCE_UT_PEX]: {\n          enabled: (this.client.utPex && typeof utPex === 'function'),\n          numPeers: 0\n        }\n      }\n      for (const peer of this._peers.values()) {\n        const counter = counters[peer.source]\n        if (typeof counter !== 'undefined') counter.numPeers++\n      }\n      for (const source of Object.keys(counters)) {\n        const counter = counters[source]\n        if (counter.enabled && counter.numPeers === 0) this.emit('noPeers', source)\n      }\n    }, this._noPeersIntervalTime)\n    if (this._noPeersIntervalId.unref) this._noPeersIntervalId.unref()\n  }\n\n  _getMetadataFromServer () {\n    // to allow function hoisting\n    const self = this\n\n    const urls = Array.isArray(this.xs) ? this.xs : [this.xs]\n\n    self._xsRequestsController = new AbortController()\n\n    const signal = self._xsRequestsController.signal\n\n    const tasks = urls.map(url => cb => {\n      getMetadataFromURL(url, cb)\n    })\n    parallel(tasks)\n\n    async function getMetadataFromURL (url, cb) {\n      if (url.indexOf('http://') !== 0 && url.indexOf('https://') !== 0) {\n        self.emit('warning', new Error(`skipping non-http xs param: ${url}`))\n        return cb(null)\n      }\n\n      const opts = {\n        method: 'GET',\n        headers: {\n          'user-agent': USER_AGENT\n        },\n        signal\n      }\n      let res\n      try {\n        res = await fetch(url, opts)\n      } catch (err) {\n        self.emit('warning', new Error(`http error from xs param: ${url}`))\n        return cb(null)\n      }\n\n      if (self.destroyed) return cb(null)\n      if (self.metadata) return cb(null)\n\n      if (res.status !== 200) {\n        self.emit('warning', new Error(`non-200 status code ${res.status} from xs param: ${url}`))\n        return cb(null)\n      }\n      let torrent\n      try {\n        torrent = new Uint8Array(await res.arrayBuffer())\n      } catch (e) {\n        self.emit('warning', e)\n        return cb(null)\n      }\n\n      let parsedTorrent\n      try {\n        parsedTorrent = await parseTorrent(torrent)\n      } catch (err) {}\n\n      if (!parsedTorrent) {\n        self.emit('warning', new Error(`got invalid torrent file from xs param: ${url}`))\n        return cb(null)\n      }\n\n      if (parsedTorrent.infoHash !== self.infoHash) {\n        self.emit('warning', new Error(`got torrent file with incorrect info hash from xs param: ${url}`))\n        return cb(null)\n      }\n      self._onMetadata(parsedTorrent)\n      cb(null)\n    }\n  }\n\n  /**\n   * Called when the full torrent metadata is received.\n   */\n  async _onMetadata (metadata) {\n    if (this.metadata || this.destroyed) return\n    this._debug('got metadata')\n\n    this._xsRequestsController?.abort()\n    this._xsRequestsController = null\n\n    let parsedTorrent\n    if (metadata && metadata.infoHash) {\n      // `metadata` is a parsed torrent (from parse-torrent module)\n      parsedTorrent = metadata\n    } else {\n      try {\n        parsedTorrent = await parseTorrent(metadata)\n      } catch (err) {\n        return this._destroy(err)\n      }\n    }\n\n    this._processParsedTorrent(parsedTorrent)\n    this.metadata = this.torrentFile\n\n    // add web seed urls (BEP19)\n    if (this.client.enableWebSeeds) {\n      this.urlList.forEach(url => {\n        this.addWebSeed(url)\n      })\n    }\n\n    this._rarityMap = new RarityMap(this)\n\n    this.files = this.files.map(file => new File(this, file))\n\n    let rawStore = this._preloadedStore\n    if (!rawStore) {\n      rawStore = new this._store(this.pieceLength, {\n        ...this.storeOpts,\n        torrent: this,\n        path: this.path,\n        files: this.files,\n        length: this.length,\n        name: this.name + ' - ' + this.infoHash.slice(0, 8),\n        addUID: this.addUID,\n        rootDir: this.rootDir,\n        max: this._storeCacheSlots\n      })\n    }\n\n    // don't use the cache if the store is already in memory\n    if (this._storeCacheSlots > 0 && !(rawStore instanceof MemoryChunkStore)) {\n      rawStore = new CacheChunkStore(rawStore, {\n        max: this._storeCacheSlots\n      })\n    }\n\n    this.store = new ImmediateChunkStore(\n      rawStore\n    )\n\n    // Select only specified files (BEP53) http://www.bittorrent.org/beps/bep_0053.html\n    if (this.so && !this._startAsDeselected) {\n      this.files.forEach((v, i) => {\n        if (this.so.includes(i)) {\n          this.files[i].select()\n        }\n      })\n    } else {\n      // start off selecting the entire torrent with low priority\n      if (this.pieces.length !== 0 && !this._startAsDeselected) {\n        this.select(0, this.pieces.length - 1)\n      }\n    }\n\n    this._hashes = this.pieces\n    // A startup bitfield can be used only when all the conditions are right:\n    // - It exists\n    // - It's the correct size ( rounded to the first byte )\n    // - It will not be rewritten by _markAllVerified\n    this._hasStartupBitfield = this._startupBitfield && this._startupBitfield.length === Math.ceil(this.pieces.length / 8) && !this.skipVerify\n\n    this.bitfield = new BitField(this._hasStartupBitfield ? new Uint8Array(this._startupBitfield) : this.pieces.length)\n    this._reservations = this._hasStartupBitfield\n      ? this.pieces.map((_, index) => this.bitfield.get(index) ? null : [])\n      : this.pieces.map(() => [])\n\n    this.pieces = this.pieces.map((hash, i) => {\n      if (this._hasStartupBitfield && this.bitfield.get(i)) {\n        return null\n      }\n      const pieceLength = (i === this.pieces.length - 1)\n        ? this.lastPieceLength\n        : this.pieceLength\n      return new Piece(pieceLength)\n    })\n\n    // Emit 'metadata' before 'ready' and 'done'\n    this.emit('metadata')\n\n    // User might destroy torrent in response to 'metadata' event\n    if (this.destroyed) return\n\n    if (this.skipVerify) {\n      // Skip verifying exisitng data and just assume it's correct\n      this._markAllVerified()\n      this._onStore()\n    } else {\n      const onPiecesVerified = (err) => {\n        if (err) return this._destroy(err)\n        this._debug('done verifying')\n        this._onStore()\n      }\n\n      this._debug('verifying existing torrent data')\n      if (this._fileModtimes && this._store === FSChunkStore) {\n        // don't verify if the files haven't been modified since we last checked\n        this.getFileModtimes((err, fileModtimes) => {\n          if (err) return this._destroy(err)\n\n          const unchanged = this.files.map((_, index) => fileModtimes[index] === this._fileModtimes[index]).every(x => x)\n\n          if (unchanged) {\n            this._markAllVerified()\n            this._onStore()\n          } else {\n            this._verifyPieces(onPiecesVerified)\n          }\n        })\n      } else {\n        this._verifyPieces(onPiecesVerified)\n      }\n    }\n  }\n\n  /*\n   * TODO: remove this\n   * Gets the last modified time of every file on disk for this torrent.\n   * Only valid in Node, not in the browser.\n   */\n  getFileModtimes (cb) {\n    const ret = []\n    parallelLimit(this.files.map((file, index) => cb => {\n      const filePath = this.addUID ? path.join(this.name + ' - ' + this.infoHash.slice(0, 8)) : path.join(this.path, file.path)\n      fs.stat(filePath, (err, stat) => {\n        if (err && err.code !== 'ENOENT') return cb(err)\n        ret[index] = stat && stat.mtime.getTime()\n        cb(null)\n      })\n    }), FILESYSTEM_CONCURRENCY, err => {\n      this._debug('done getting file modtimes')\n      cb(err, ret)\n    })\n  }\n\n  /**\n   * Callback called after a piece is verified\n   * @callback verifyPieceCallback\n   * @param {Error=} error\n   * @param {boolean=} isValid\n   */\n  /**\n   * Verify a single piece using hashing\n   * @param index\n   * @param {verifyPieceCallback} cb\n   * @private\n   */\n  _verifyPiece (index, cb) {\n    if (this.destroyed) return cb(new Error('torrent is destroyed'))\n\n    const getOpts = {}\n    // Specify length for the last piece in case it is zero-padded\n    if (index === this.pieces.length - 1) {\n      getOpts.length = this.lastPieceLength\n    }\n    this.store.get(index, getOpts, async (err, buf) => {\n      if (this.destroyed) return cb(new Error('torrent is destroyed'))\n\n      if (err) return queueMicrotask(() => cb(null, false)) // ignore error\n\n      const hex = await hash(buf, 'hex')\n      if (this.destroyed) return cb(new Error('torrent is destroyed'))\n\n      cb(null, hex === this._hashes[index])\n    })\n  }\n\n  /**\n   * Verify pieces using bitfield, in case of in-congruences it will re-verify the file using hashing\n   * @param {callbackWithError} cb\n   * @private\n   */\n  _verifyPiecesUsingBitfield (cb) {\n    const piecesToCheck = new Set()\n    const piecesToFilesMap = new Map()\n    // First step, optimistically mark what is verified and what is not by blindly trusting the bitfield\n    // and construct a list of pieces to verify ( max 1 piece for each file, in some edge cases that piece could overlap )\n    for (const file of this.files) {\n      let checkFile = 2\n      let pieceToCheckForThisFile = null\n      for (let i = file._startPiece; i <= file._endPiece; ++i) {\n        if (this.bitfield.get(i)) {\n          if (checkFile) {\n            pieceToCheckForThisFile = i\n            checkFile--\n          }\n          if (!piecesToFilesMap.has(i)) {\n            piecesToFilesMap.set(i, [])\n          }\n          piecesToFilesMap.get(i).push(file)\n        }\n      }\n      if (pieceToCheckForThisFile !== null) {\n        piecesToCheck.add(pieceToCheckForThisFile)\n      }\n    }\n    // Second step, for each piece that needs to be verified we verify it using hashing\n    this._verifyPiecesUsingHash([...piecesToCheck], (err) => {\n      if (err) {\n        return cb(err)\n      }\n      const filesToCheck = new Set()\n      for (const piece of piecesToCheck) {\n        if (!this.bitfield.get(piece)) {\n          const filesOnPiece = piecesToFilesMap.get(piece)\n          for (const file of filesOnPiece) {\n            filesToCheck.add(file)\n          }\n        }\n      }\n      // Third step, if we need to recheck files we are going to fully recheck them\n      if (filesToCheck.size) {\n        const piecesToRecheck = []\n        for (const file of filesToCheck) {\n          for (let i = file._startPiece; i <= file._endPiece; ++i) {\n            if (piecesToRecheck.indexOf(i) === -1) {\n              piecesToRecheck.push(i)\n            }\n          }\n        }\n        return this._verifyPiecesUsingHash(piecesToRecheck, cb)\n      }\n      cb(null)\n    })\n  }\n\n  /**\n   * Verifies the pieces of the torrent using hashing ( it can be very slow )\n   * @param {Array<number>} pieces\n   * @param {callbackWithError} cb\n   * @private\n   */\n  _verifyPiecesUsingHash (pieces, cb) {\n    parallelLimit(pieces.map((piece, index) => cb => {\n      const target = Number.isInteger(piece) ? piece : index\n      this._verifyPiece(target, (err, isVerified) => {\n        if (err) return cb(err)\n        if (isVerified) {\n          this._debug('piece verified %s', target)\n          this._markVerified(target)\n        } else {\n          this._markUnverified(target)\n          this._debug('piece invalid %s', target)\n        }\n        cb(null)\n      })\n    }), FILESYSTEM_CONCURRENCY, cb)\n  }\n\n  /**\n   * Verifies the pieces of the torrent, if a startup bitfield is provided it will be used for verification\n   * @param {callbackWithError} cb\n   * @private\n   */\n  _verifyPieces (cb) {\n    if (this._hasStartupBitfield) {\n      return this._verifyPiecesUsingBitfield(cb)\n    }\n    this._verifyPiecesUsingHash(this.pieces, cb)\n  }\n\n  /**\n   * Verify the hashes of all pieces in the store and update the bitfield for any new valid\n   * pieces. Useful if data has been added to the store outside WebTorrent, e.g. if another\n   * process puts a valid file in the right place. Once the scan is complete,\n   * `callback(null)` will be called (if provided), unless the torrent was destroyed during\n   * the scan, in which case `callback` will be called with an error.\n   * @param  {callbackWithError=} cb\n   */\n  rescanFiles (cb) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n    if (!cb) cb = noop\n\n    this._verifyPiecesUsingHash(this.pieces, (err) => {\n      if (err) {\n        this._destroy(err)\n        return cb(err)\n      }\n\n      this._checkDone()\n      cb(null)\n    })\n  }\n\n  /**\n   * Mark the entire torrent as verified ( i.e. fully downloaded )\n   * @private\n   */\n  _markAllVerified () {\n    for (let index = 0; index < this.pieces.length; index++) {\n      this._markVerified(index)\n    }\n  }\n\n  /**\n   * Mark one piece as verified\n   * @param {number} index\n   * @private\n   */\n  _markVerified (index) {\n    this.pieces[index] = null\n    this._reservations[index] = null\n    this.bitfield.set(index, true)\n    this.emit('verified', index)\n  }\n\n  /**\n   * Mark one piece as unverified\n   * @param {number} index\n   * @private\n   */\n  _markUnverified (index) {\n    const len = (index === this.pieces.length - 1)\n      ? this.lastPieceLength\n      : this.pieceLength\n    this.pieces[index] = new Piece(len)\n    this.bitfield.set(index, false)\n    if (!this._startAsDeselected) this.select(index, index)\n    for (const file of this.files) {\n      if (file.done && file.includes(index)) file.done = false\n    }\n  }\n\n  _hasAllPieces () {\n    for (let index = 0; index < this.pieces.length; index++) {\n      if (!this.bitfield.get(index)) return false\n    }\n    return true\n  }\n\n  _hasNoPieces () {\n    return !this._hasMorePieces(0)\n  }\n\n  _hasMorePieces (threshold) {\n    let count = 0\n    for (let index = 0; index < this.pieces.length; index++) {\n      if (this.bitfield.get(index)) {\n        count += 1\n        if (count > threshold) return true\n      }\n    }\n    return false\n  }\n\n  /**\n   * Called when the metadata, listening server, and underlying chunk store is initialized.\n   */\n  _onStore () {\n    if (this.destroyed) return\n    this._debug('on store')\n\n    // Start discovery before emitting 'ready'\n    this._startDiscovery()\n\n    this.ready = true\n    this.emit('ready')\n\n    // Files may start out done if the file was already in the store\n    this._checkDone()\n\n    // In case any selections were made before torrent was ready\n    this._updateSelections()\n\n    // Start requesting pieces after we have initially verified them\n    this.wires.forEach(wire => {\n      // If we didn't have the metadata at the time ut_metadata was initialized for this\n      // wire, we still want to make it available to the peer in case they request it.\n      if (wire.ut_metadata) wire.ut_metadata.setMetadata(this.metadata)\n\n      this._onWireWithMetadata(wire)\n    })\n  }\n\n  destroy (opts, cb) {\n    if (typeof opts === 'function') return this.destroy(null, opts)\n\n    this._destroy(null, opts, cb)\n  }\n\n  _destroy (err, opts, cb) {\n    if (typeof opts === 'function') return this._destroy(err, null, opts)\n    if (this.destroyed) return\n    this.destroyed = true\n    this._debug('destroy')\n\n    this.client._remove(this)\n\n    this._selections.clear()\n\n    clearInterval(this._rechokeIntervalId)\n\n    clearInterval(this._noPeersIntervalId)\n\n    this._xsRequestsController?.abort()\n\n    if (this._rarityMap) {\n      this._rarityMap.destroy()\n    }\n\n    for (const id of this._peers.keys()) {\n      this.removePeer(id)\n    }\n\n    for (const file of this.files) {\n      if (file instanceof File) file._destroy()\n    }\n\n    const tasks = this._servers.map(server => cb => {\n      server.destroy(cb)\n    })\n\n    if (this.discovery) {\n      tasks.push(cb => {\n        this.discovery.destroy(cb)\n      })\n    }\n\n    if (this.store) {\n      let destroyStore = this._destroyStoreOnDestroy\n      if (opts && opts.destroyStore !== undefined) {\n        destroyStore = opts.destroyStore\n      }\n      tasks.push(cb => {\n        if (destroyStore) {\n          this.store.destroy(cb)\n        } else {\n          this.store.close(cb)\n        }\n      })\n    }\n\n    parallel(tasks, cb)\n\n    if (err) {\n      // Torrent errors are emitted at `torrent.on('error')`. If there are no 'error'\n      // event handlers on the torrent instance, then the error will be emitted at\n      // `client.on('error')`. This prevents throwing an uncaught exception\n      // (unhandled 'error' event), but it makes it impossible to distinguish client\n      // errors versus torrent errors. Torrent errors are not fatal, and the client\n      // is still usable afterwards. Therefore, always listen for errors in both\n      // places (`client.on('error')` and `torrent.on('error')`).\n      if (this.listenerCount('error') === 0) {\n        this.client.emit('error', err)\n      } else {\n        this.emit('error', err)\n      }\n    }\n\n    this.emit('close')\n\n    this.client = null\n    this.files = []\n    this.discovery = null\n    this.store = null\n    this._rarityMap = null\n    this._peers.clear()\n    this._peers = null\n    this._servers = null\n    this._xsRequests = null\n    this._queue = null\n  }\n\n  addPeer (peer, source) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n    if (!this.infoHash) throw new Error('addPeer() must not be called before the `infoHash` event')\n\n    let host\n\n    if (typeof peer === 'string') {\n      let parts\n      try {\n        parts = addrToIPPort(peer)\n      } catch (e) {\n        this._debug('ignoring peer: invalid %s', peer)\n        this.emit('invalidPeer', peer)\n        return false\n      }\n      host = parts[0]\n    } else if (typeof peer.remoteAddress === 'string') {\n      host = peer.remoteAddress\n    }\n\n    if (this.client.blocked && host && this.client.blocked.contains(host)) {\n      this._debug('ignoring peer: blocked %s', peer)\n      if (typeof peer !== 'string') peer.destroy()\n      this.emit('blockedPeer', peer)\n      return false\n    }\n\n    // if the utp connection fails to connect, then it is replaced with a tcp connection to the same ip:port\n\n    const type = (this.client.utp && this._isIPv4(host)) ? 'utp' : 'tcp'\n    const wasAdded = !!this._addPeer(peer, type, source)\n\n    if (wasAdded) {\n      this.emit('peer', peer)\n    } else {\n      this.emit('invalidPeer', peer)\n    }\n    return wasAdded\n  }\n\n  _addPeer (peer, type, source) {\n    if (this.destroyed) {\n      if (typeof peer !== 'string') peer.destroy()\n      return null\n    }\n    if (typeof peer === 'string' && !this._validAddr(peer)) {\n      this._debug('ignoring peer: invalid %s', peer)\n      return null\n    }\n\n    const id = (peer && peer.id) || peer\n    if (this._peers.has(id)) {\n      this._debug('ignoring peer: duplicate (%s)', id)\n      if (typeof peer !== 'string') peer.destroy()\n      return null\n    }\n\n    if (this.paused) {\n      this._debug('ignoring peer: torrent is paused')\n      if (typeof peer !== 'string') peer.destroy()\n      return null\n    }\n\n    this._debug('add peer %s', id)\n\n    let newPeer\n    if (typeof peer === 'string') {\n      // `peer` is an addr (\"ip:port\" string)\n      newPeer = type === 'utp'\n        ? Peer.createUTPOutgoingPeer(peer, this, this.client.throttleGroups, source)\n        : Peer.createTCPOutgoingPeer(peer, this, this.client.throttleGroups, source)\n    } else {\n      // `peer` is a WebRTC connection (simple-peer)\n      newPeer = Peer.createWebRTCPeer(peer, this, this.client.throttleGroups, source)\n    }\n\n    this._registerPeer(newPeer)\n\n    if (typeof peer === 'string') {\n      // `peer` is an addr (\"ip:port\" string)\n      this._queue.push(newPeer)\n      this._drain()\n    }\n\n    return newPeer\n  }\n\n  addWebSeed (urlOrConn) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n\n    let id\n    let conn\n    if (typeof urlOrConn === 'string') {\n      id = urlOrConn\n\n      if (!/^https?:\\/\\/.+/.test(id)) {\n        this.emit('warning', new Error(`ignoring invalid web seed: ${id}`))\n        this.emit('invalidPeer', id)\n        return\n      }\n\n      if (this._peers.has(id)) {\n        this.emit('warning', new Error(`ignoring duplicate web seed: ${id}`))\n        this.emit('invalidPeer', id)\n        return\n      }\n\n      conn = new WebConn(id, this)\n    } else if (urlOrConn && typeof urlOrConn.connId === 'string') {\n      conn = urlOrConn\n      id = conn.connId\n\n      if (this._peers.has(id)) {\n        this.emit('warning', new Error(`ignoring duplicate web seed: ${id}`))\n        this.emit('invalidPeer', id)\n        return\n      }\n    } else {\n      this.emit('warning', new Error('addWebSeed must be passed a string or connection object with id property'))\n      return\n    }\n\n    this._debug('add web seed %s', id)\n\n    const newPeer = Peer.createWebSeedPeer(conn, id, this, this.client.throttleGroups)\n\n    this._registerPeer(newPeer)\n\n    this.emit('peer', id)\n  }\n\n  /**\n   * Called whenever a new incoming TCP peer connects to this torrent swarm. Called with a\n   * peer that has already sent a handshake.\n   */\n  _addIncomingPeer (peer) {\n    if (this.destroyed) return peer.destroy(new Error('torrent is destroyed'))\n    if (this.paused) return peer.destroy(new Error('torrent is paused'))\n\n    this._debug('add incoming peer %s', peer.id)\n\n    this._registerPeer(peer)\n  }\n\n  /**\n   * @param {Peer} newPeer\n   */\n  _registerPeer (newPeer) {\n    newPeer.on('download', downloaded => {\n      if (this.destroyed) return\n      this.received += downloaded\n      this._downloadSpeed(downloaded)\n      this.client._downloadSpeed(downloaded)\n      this.emit('download', downloaded)\n      if (this.destroyed) return\n      this.client.emit('download', downloaded)\n    })\n\n    newPeer.on('upload', uploaded => {\n      if (this.destroyed) return\n      this.uploaded += uploaded\n      this._uploadSpeed(uploaded)\n      this.client._uploadSpeed(uploaded)\n      this.emit('upload', uploaded)\n      if (this.destroyed) return\n      this.client.emit('upload', uploaded)\n    })\n\n    if (newPeer.connected) {\n      this._numConns += 1\n    } else {\n      newPeer.once('connect', () => {\n        if (this.destroyed) return\n        this._numConns += 1\n      })\n    }\n    newPeer.once('disconnect', () => {\n      this._numConns -= 1\n    })\n\n    this._peers.set(newPeer.id, newPeer)\n    this._peersLength += 1\n  }\n\n  removePeer (peer) {\n    const id = peer?.id || peer\n    if (peer && !peer.id) peer = this._peers?.get(id)\n\n    if (!peer) return\n    peer.destroy()\n\n    if (this.destroyed) return\n\n    this._debug('removePeer %s', id)\n\n    this._peers.delete(id)\n    this._peersLength -= 1\n\n    // If torrent swarm was at capacity before, try to open a new connection now\n    this._drain()\n  }\n\n  _select (start = 0, end = this.pieces.length - 1, priority, notify, isStreamSelection = false) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n\n    if (start < 0 || end < start || this.pieces.length <= end) {\n      throw new Error(`invalid selection ${start} : ${end}`)\n    }\n    priority = Number(priority) || 0\n\n    this._debug('select %s-%s (priority %s)', start, end, priority)\n\n    this._selections.insert({\n      from: start,\n      to: end,\n      offset: 0,\n      priority,\n      notify,\n      isStreamSelection\n    })\n\n    this._selections.sort((a, b) => b.priority - a.priority)\n\n    this._updateSelections()\n  }\n\n  select (start, end, priority, notify) {\n    this._select(start, end, priority, notify, false)\n  }\n\n  _deselect (from, to, isStreamSelection = false) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n\n    this._debug('deselect %s-%s', from, to)\n\n    this._selections.remove({ from, to, isStreamSelection })\n\n    this._updateSelections()\n  }\n\n  deselect (start, end) {\n    this._deselect(start, end, false)\n  }\n\n  critical (start, end) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n\n    this._debug('critical %s-%s', start, end)\n\n    for (let i = start; i <= end; ++i) {\n      this._critical[i] = true\n    }\n\n    this._updateSelections()\n  }\n\n  _onWire (wire, addr) {\n    this._debug('got wire %s (%s)', wire._debugId, addr || 'Unknown')\n\n    this.wires.push(wire)\n\n    if (addr) {\n      // Sometimes RTCPeerConnection.getStats() doesn't return an ip:port for peers\n      const parts = addrToIPPort(addr)\n      wire.remoteAddress = parts[0]\n      wire.remotePort = parts[1]\n    }\n\n    // When peer sends PORT message, add that DHT node to routing table\n    if (this.client.dht && this.client.dht.listening) {\n      wire.on('port', port => {\n        if (this.destroyed || this.client.dht.destroyed) {\n          return\n        }\n        if (!wire.remoteAddress) {\n          return this._debug('ignoring PORT from peer with no address')\n        }\n        if (port === 0 || port > 65536) {\n          return this._debug('ignoring invalid PORT from peer')\n        }\n\n        this._debug('port: %s (from %s)', port, addr)\n        this.client.dht.addNode({ host: wire.remoteAddress, port })\n      })\n    }\n\n    wire.on('timeout', () => {\n      this._debug('wire timeout (%s)', addr)\n      // TODO: this might be destroying wires too eagerly\n      wire.destroy()\n    })\n\n    // Timeout for piece requests to this peer\n    if (wire.type !== 'webSeed') { // webseeds always send 'unhave' on http timeout\n      wire.setTimeout(PIECE_TIMEOUT, true)\n    }\n\n    // Send KEEP-ALIVE (every 60s) so peers will not disconnect the wire\n    wire.setKeepAlive(true)\n\n    // use ut_metadata extension\n    wire.use(utMetadata(this.metadata))\n\n    wire.ut_metadata.on('warning', err => {\n      this._debug('ut_metadata warning: %s', err.message)\n    })\n\n    if (!this.metadata) {\n      wire.ut_metadata.on('metadata', metadata => {\n        this._debug('got metadata via ut_metadata')\n        this._onMetadata(metadata)\n      })\n      wire.ut_metadata.fetch()\n    }\n\n    // use ut_pex extension if the torrent is not flagged as private\n    if (this.client.utPex && typeof utPex === 'function' && !this.private) {\n      wire.use(utPex())\n\n      wire.ut_pex.on('peer', peer => {\n        // Only add potential new peers when torrent is done and seedOutgoingConnections is false.\n        if (!this.client.seedOutgoingConnections && this.done) {\n          this._debug('ut_pex ignoring peer %s: torrent is done and seedOutgoingConnections is false', peer)\n          return\n        }\n        this._debug('ut_pex: got peer: %s (from %s)', peer, addr)\n        this.addPeer(peer, Peer.SOURCE_UT_PEX)\n      })\n\n      wire.ut_pex.on('dropped', peer => {\n        // the remote peer believes a given peer has been dropped from the torrent swarm.\n        // if we're not currently connected to it, then remove it from the queue.\n        const peerObj = this._peers.get(peer)\n        if (peerObj && !peerObj.connected) {\n          this._debug('ut_pex: dropped peer: %s (from %s)', peer, addr)\n          this.removePeer(peer)\n        }\n      })\n\n      wire.once('close', () => {\n        // Stop sending updates to remote peer\n        wire.ut_pex.reset()\n      })\n    }\n\n    wire.use(ltDontHave())\n\n    // Hook to allow user-defined `bittorrent-protocol` extensions\n    // More info: https://github.com/webtorrent/bittorrent-protocol#extension-api\n    this.emit('wire', wire, addr)\n\n    if (this.ready) {\n      queueMicrotask(() => {\n        // This allows wire.handshake() to be called (by Peer.onHandshake) before any\n        // messages get sent on the wire\n        this._onWireWithMetadata(wire)\n      })\n    }\n  }\n\n  /**\n   * @param {import('bittorrent-protocol').default} wire\n   */\n  _onWireWithMetadata (wire) {\n    let timeoutId = null\n\n    const onChokeTimeout = () => {\n      if (this.destroyed || wire.destroyed) return\n\n      if (this._numQueued > 2 * (this._numConns - this.numPeers) &&\n        wire.amInterested) {\n        wire.destroy()\n      } else {\n        timeoutId = setTimeout(onChokeTimeout, CHOKE_TIMEOUT)\n        if (timeoutId.unref) timeoutId.unref()\n      }\n    }\n\n    let i\n    const updateSeedStatus = () => {\n      // bittorrent-protocol will set use fake bitfield if it gets a have-all message, which means its a seeder\n      if (wire.peerPieces.buffer.length && !!wire.peerPieces.setAll) {\n        if (wire.peerPieces.buffer.length !== this.bitfield.buffer.length) return\n        for (i = 0; i < this.pieces.length; ++i) {\n          if (!wire.peerPieces.get(i)) return\n        }\n      }\n      wire.isSeeder = true\n      if (this.alwaysChokeSeeders) wire.choke() // always choke seeders\n    }\n\n    wire.on('bitfield', () => {\n      updateSeedStatus()\n      this._update()\n      this._updateWireInterest(wire)\n    })\n\n    wire.on('have', () => {\n      updateSeedStatus()\n      this._update()\n      this._updateWireInterest(wire)\n    })\n\n    wire.lt_donthave.on('donthave', () => {\n      updateSeedStatus()\n      this._update()\n      this._updateWireInterest(wire)\n    })\n\n    // fast extension (BEP6)\n    wire.on('have-all', () => {\n      wire.isSeeder = true\n      if (this.alwaysChokeSeeders) wire.choke() // always choke seeders\n      this._update()\n      this._updateWireInterest(wire)\n    })\n\n    // fast extension (BEP6)\n    wire.on('have-none', () => {\n      wire.isSeeder = false\n      this._update()\n      this._updateWireInterest(wire)\n    })\n\n    // fast extension (BEP6)\n    wire.on('allowed-fast', (index) => {\n      this._update()\n    })\n\n    wire.once('interested', () => {\n      wire.unchoke()\n    })\n\n    wire.once('close', () => {\n      clearTimeout(timeoutId)\n    })\n\n    wire.on('choke', () => {\n      clearTimeout(timeoutId)\n      timeoutId = setTimeout(onChokeTimeout, CHOKE_TIMEOUT)\n      if (timeoutId.unref) timeoutId.unref()\n    })\n\n    wire.on('unchoke', () => {\n      clearTimeout(timeoutId)\n      this._update()\n    })\n\n    wire.on('request', (index, offset, length, cb) => {\n      if (length > MAX_BLOCK_LENGTH) {\n        // Per spec, disconnect from peers that request >128KB\n        return wire.destroy()\n      }\n      if (this.pieces[index]) return\n      this.store.get(index, { offset, length }, cb)\n    })\n\n    // always send bitfield or equivalent fast extension message (required)\n    if (wire.hasFast && this._hasAllPieces()) wire.haveAll()\n    else if (wire.hasFast && this._hasNoPieces()) wire.haveNone()\n    else wire.bitfield(this.bitfield)\n\n    // initialize interest in case bitfield message was already received before above handler was registered\n    this._updateWireInterest(wire)\n\n    // Send PORT message to peers that support DHT\n    if (wire.peerExtensions.dht && this.client.dht && this.client.dht.listening) {\n      wire.port(this.client.dht.address().port)\n    }\n\n    if (wire.type !== 'webSeed') { // do not choke on webseeds\n      timeoutId = setTimeout(onChokeTimeout, CHOKE_TIMEOUT)\n      if (timeoutId.unref) timeoutId.unref()\n    }\n\n    wire.isSeeder = false\n    updateSeedStatus()\n  }\n\n  /**\n   * Called on selection changes.\n   */\n  _updateSelections () {\n    if (!this.ready || this.destroyed) return\n\n    queueMicrotask(() => {\n      this._gcSelections()\n    })\n    this._updateInterest()\n    this._update()\n  }\n\n  /**\n   * Garbage collect selections with respect to the store's current state.\n   */\n  _gcSelections () {\n    for (const s of this._selections) {\n      const oldOffset = s.offset\n\n      // check for newly downloaded pieces in selection\n      while (this.bitfield.get(s.from + s.offset) && s.from + s.offset < s.to) {\n        s.offset += 1\n      }\n\n      if (oldOffset !== s.offset) s.notify?.()\n      if (s.to !== s.from + s.offset) continue\n      if (!this.bitfield.get(s.from + s.offset)) continue\n\n      s.remove() // remove fully downloaded selection\n      s.notify?.()\n      this._updateInterest()\n    }\n\n    if (!this._selections.length) this.emit('idle')\n  }\n\n  /**\n   * Update interested status for all peers.\n   */\n  _updateInterest () {\n    const prev = this._amInterested\n    this._amInterested = !!this._selections.length\n\n    this.wires.forEach(wire => this._updateWireInterest(wire))\n\n    if (prev === this._amInterested) return\n    if (this._amInterested) this.emit('interested')\n    else this.emit('uninterested')\n  }\n\n  _updateWireInterest (wire) {\n    let interested = false\n    for (let index = 0; index < this.pieces.length; ++index) {\n      if (this.pieces[index] && wire.peerPieces.get(index)) {\n        interested = true\n        break\n      }\n    }\n\n    if (interested) wire.interested()\n    else wire.uninterested()\n  }\n\n  /**\n   * Heartbeat to update all peers and their requests.\n   */\n  _update () {\n    if (IDLE_CALLBACK) {\n      IDLE_CALLBACK(() => this._updateWireWrapper(), { timeout: 250 })\n    } else {\n      this._updateWireWrapper()\n    }\n  }\n\n  _updateWireWrapper () {\n    if (this.destroyed) return\n    // update wires in random order for better request distribution\n    const ite = randomIterate(this.wires)\n    let wire\n    while ((wire = ite())) {\n      this._updateWire(wire)\n    }\n  }\n\n  /**\n   * Attempts to update a peer's requests\n   * @param {import('bittorrent-protocol').default} wire\n   */\n  _updateWire (wire) {\n    if (wire.destroyed) return false\n    // to allow function hoisting\n    const self = this\n\n    const isWebSeed = wire.type === 'webSeed'\n\n    const minOutstandingRequests = isWebSeed\n      ? Math.min(\n        getPiecePipelineLength(wire, PIPELINE_MIN_DURATION, this.pieceLength),\n        self.maxWebConns\n      )\n      : getBlockPipelineLength(wire, PIPELINE_MIN_DURATION)\n    if (wire.requests.length >= minOutstandingRequests) return\n    const maxOutstandingRequests = isWebSeed\n      ? Math.min(\n        getPiecePipelineLength(wire, PIPELINE_MAX_DURATION, this.pieceLength),\n        self.maxWebConns\n      )\n      : getBlockPipelineLength(wire, PIPELINE_MAX_DURATION)\n\n    if (wire.peerChoking) {\n      if (wire.hasFast && wire.peerAllowedFastSet.length > 0 &&\n        !this._hasMorePieces(wire.peerAllowedFastSet.length - 1)) {\n        requestAllowedFastSet()\n      }\n      return\n    }\n\n    if (!wire.downloaded) return validateWire()\n\n    trySelectWire(false) || trySelectWire(true)\n\n    function requestAllowedFastSet () {\n      if (wire.requests.length >= maxOutstandingRequests) return false\n\n      for (const piece of wire.peerAllowedFastSet) {\n        if (wire.peerPieces.get(piece) && !self.bitfield.get(piece)) {\n          while (self._request(wire, piece, false) &&\n            wire.requests.length < maxOutstandingRequests) {\n            // body intentionally empty\n            // request all non-reserved blocks in this piece\n          }\n        }\n\n        if (wire.requests.length < maxOutstandingRequests) continue\n\n        return true\n      }\n\n      return false\n    }\n\n    function genPieceFilterFunc (start, end, tried, rank) {\n      return i => i >= start && i <= end && !(i in tried) && wire.peerPieces.get(i) && (!rank || rank(i))\n    }\n\n    // TODO: Do we need both validateWire and trySelectWire?\n    function validateWire () {\n      if (wire.requests.length) return\n\n      let i = self._selections.length\n      while (i--) {\n        const next = self._selections.get(i)\n        let piece\n        if (self.strategy === 'rarest') {\n          const start = next.from + next.offset\n          const end = next.to\n          const len = end - start + 1\n          const tried = {}\n          let tries = 0\n          const filter = genPieceFilterFunc(start, end, tried)\n\n          while (tries < len) {\n            piece = self._rarityMap.getRarestPiece(filter)\n            if (piece < 0) break\n            if (self._request(wire, piece, false)) return\n            tried[piece] = true\n            tries += 1\n          }\n        } else {\n          for (piece = next.to; piece >= next.from + next.offset; --piece) {\n            if (!wire.peerPieces.get(piece)) continue\n            if (self._request(wire, piece, false)) return\n          }\n        }\n      }\n\n      // TODO: wire failed to validate as useful; should we close it?\n      // probably not, since 'have' and 'bitfield' messages might be coming\n    }\n\n    function speedRanker () {\n      const speed = wire.downloadSpeed() || 1\n      if (speed > SPEED_THRESHOLD) return () => true\n\n      const secs = Math.max(1, wire.requests.length) * Piece.BLOCK_LENGTH / speed\n      let tries = 10\n      let ptr = 0\n\n      return index => {\n        if (!tries || self.bitfield.get(index)) return true\n\n        let missing = self.pieces[index].missing\n\n        for (; ptr < self.wires.length; ptr++) {\n          const otherWire = self.wires[ptr]\n          const otherSpeed = otherWire.downloadSpeed()\n\n          if (otherSpeed < SPEED_THRESHOLD) continue\n          if (otherSpeed <= speed) continue\n          if (!otherWire.peerPieces.get(index)) continue\n          if ((missing -= otherSpeed * secs) > 0) continue\n\n          tries--\n          return false\n        }\n\n        return true\n      }\n    }\n\n    function shufflePriority (i) {\n      let last = i\n      for (let j = i; j < self._selections.length && self._selections.get(j).priority; j++) {\n        last = j\n      }\n      self._selections.swap(i, last)\n    }\n\n    function trySelectWire (hotswap) {\n      if (wire.requests.length >= maxOutstandingRequests) return true\n      const rank = speedRanker()\n\n      for (let i = 0; i < self._selections.length; i++) {\n        const next = self._selections.get(i)\n\n        let piece\n        if (self.strategy === 'rarest') {\n          const start = next.from + next.offset\n          const end = next.to\n          const len = end - start + 1\n          const tried = {}\n          let tries = 0\n          const filter = genPieceFilterFunc(start, end, tried, rank)\n\n          while (tries < len) {\n            piece = self._rarityMap.getRarestPiece(filter)\n            if (piece < 0) break\n\n            while (self._request(wire, piece, self._critical[piece] || hotswap) &&\n              wire.requests.length < maxOutstandingRequests) {\n              // body intentionally empty\n              // request all non-reserved blocks in this piece\n            }\n\n            if (wire.requests.length < maxOutstandingRequests) {\n              tried[piece] = true\n              tries++\n              continue\n            }\n\n            if (next.priority) shufflePriority(i)\n            return true\n          }\n        } else {\n          for (piece = next.from + next.offset; piece <= next.to; piece++) {\n            if (!wire.peerPieces.get(piece) || !rank(piece)) continue\n\n            while (self._request(wire, piece, self._critical[piece] || hotswap) &&\n              wire.requests.length < maxOutstandingRequests) {\n              // body intentionally empty\n              // request all non-reserved blocks in piece\n            }\n\n            if (wire.requests.length < maxOutstandingRequests) continue\n\n            if (next.priority) shufflePriority(i)\n            return true\n          }\n        }\n      }\n\n      return false\n    }\n  }\n\n  /**\n   * Called periodically to update the choked status of all peers, handling optimistic\n   * unchoking as described in BEP3.\n   */\n  _rechoke () {\n    if (!this.ready) return\n\n    // wires in increasing order of quality (pop() gives next best peer)\n    const wireStack =\n      this.wires\n        .map(wire => ({ wire, random: Math.random(), downspeed: wire.downloadSpeed() })) // insert a random seed for randomizing the sort\n        .sort((objA, objB) => {\n          const wireA = objA.wire\n          const wireB = objB.wire\n\n          // prefer peers that send us data faster\n          if (objA.downspeed !== objB.downspeed) {\n            return objA.downspeed - objB.downspeed\n          }\n\n          // then prefer peers that can download data from us faster\n          const aup = wireA.uploadSpeed()\n          const bup = wireB.uploadSpeed()\n          if (aup !== bup) {\n            return aup - bup\n          }\n\n          // then prefer already unchoked peers (to minimize fibrillation)\n          if (wireA.amChoking !== wireB.amChoking) {\n            return wireA.amChoking ? -1 : 1 // choking < unchoked\n          }\n\n          // otherwise random order\n          return objA.random - objB.random\n        })\n        .map(obj => obj.wire) // return array of wires (remove random seed)\n\n    if (this._rechokeOptimisticTime <= 0) {\n      // clear old optimistic peer, so it can be rechoked normally and then replaced\n      this._rechokeOptimisticWire = null\n    } else {\n      this._rechokeOptimisticTime -= 1\n    }\n\n    let numInterestedUnchoked = 0\n    // leave one rechoke slot open for optimistic unchoking\n    while (wireStack.length > 0 && numInterestedUnchoked < this._rechokeNumSlots - 1) {\n      const wire = wireStack.pop() // next best quality peer\n\n      if (wire.isSeeder || wire === this._rechokeOptimisticWire) {\n        continue\n      }\n\n      wire.unchoke()\n\n      // only stop unchoking once we fill the slots with interested peers that will actually download\n      if (wire.peerInterested) {\n        numInterestedUnchoked++\n      }\n    }\n\n    // fill optimistic unchoke slot if empty\n    if (this._rechokeOptimisticWire === null && this._rechokeNumSlots > 0) {\n      // don't optimistically unchoke uninterested peers\n      const remaining = wireStack.filter(wire => wire.peerInterested)\n\n      if (remaining.length > 0) {\n        // select random remaining (not yet unchoked) peer\n        const newOptimisticPeer = remaining[randomInt(remaining.length)]\n\n        newOptimisticPeer.unchoke()\n\n        this._rechokeOptimisticWire = newOptimisticPeer\n\n        this._rechokeOptimisticTime = RECHOKE_OPTIMISTIC_DURATION\n      }\n    }\n\n    // choke the rest\n    wireStack\n      .filter(wire => wire !== this._rechokeOptimisticWire) // except the optimistically unchoked peer\n      .forEach(wire => wire.choke())\n  }\n\n  /**\n   * Attempts to cancel a slow block request from another wire such that the\n   * given wire may effectively swap out the request for one of its own.\n   */\n  _hotswap (wire, index) {\n    const speed = wire.downloadSpeed()\n    if (speed < Piece.BLOCK_LENGTH) return false\n    if (!this._reservations[index]) return false\n\n    const r = this._reservations[index]\n    if (!r) {\n      return false\n    }\n\n    let minSpeed = Infinity\n    let minWire\n\n    let i\n    for (i = 0; i < r.length; i++) {\n      const otherWire = r[i]\n      if (!otherWire || otherWire === wire) continue\n\n      const otherSpeed = otherWire.downloadSpeed()\n      if (otherSpeed >= SPEED_THRESHOLD) continue\n      if (2 * otherSpeed > speed || otherSpeed > minSpeed) continue\n\n      minWire = otherWire\n      minSpeed = otherSpeed\n    }\n\n    if (!minWire) return false\n\n    for (i = 0; i < r.length; i++) {\n      if (r[i] === minWire) r[i] = null\n    }\n\n    for (i = 0; i < minWire.requests.length; i++) {\n      const req = minWire.requests[i]\n      if (req.piece !== index) continue\n\n      this.pieces[index].cancel((req.offset / Piece.BLOCK_LENGTH) | 0)\n    }\n\n    this.emit('hotswap', minWire, wire, index)\n    return true\n  }\n\n  /**\n   * Attempts to request a block from the given wire.\n   */\n  _request (wire, index, hotswap) {\n    const self = this\n    const numRequests = wire.requests.length\n    const isWebSeed = wire.type === 'webSeed'\n\n    if (self.bitfield.get(index)) return false\n\n    const maxOutstandingRequests = isWebSeed\n      ? Math.min(\n        getPiecePipelineLength(wire, PIPELINE_MAX_DURATION, self.pieceLength),\n        self.maxWebConns\n      )\n      : getBlockPipelineLength(wire, PIPELINE_MAX_DURATION)\n\n    if (numRequests >= maxOutstandingRequests) return false\n    // var endGame = (wire.requests.length === 0 && self.store.numMissing < 30)\n\n    const piece = self.pieces[index]\n    let reservation = isWebSeed ? piece.reserveRemaining() : piece.reserve()\n\n    if (reservation === -1 && hotswap && self._hotswap(wire, index)) {\n      reservation = isWebSeed ? piece.reserveRemaining() : piece.reserve()\n    }\n    if (reservation === -1) return false\n\n    let r = self._reservations[index]\n    if (!r) r = self._reservations[index] = []\n    let i = r.indexOf(null)\n    if (i === -1) i = r.length\n    r[i] = wire\n\n    const chunkOffset = piece.chunkOffset(reservation)\n    const chunkLength = isWebSeed ? piece.chunkLengthRemaining(reservation) : piece.chunkLength(reservation)\n\n    wire.request(index, chunkOffset, chunkLength, async function onChunk (err, chunk) {\n      if (self.destroyed) return\n\n      // TODO: what is this for?\n      if (!self.ready) return self.once('ready', () => { onChunk(err, chunk) })\n\n      if (r[i] === wire) r[i] = null\n\n      if (piece !== self.pieces[index]) return onUpdateTick()\n\n      if (err) {\n        self._debug(\n          'error getting piece %s (offset: %s length: %s) from %s: %s',\n          index, chunkOffset, chunkLength, `${wire.remoteAddress}:${wire.remotePort}`,\n          err.message\n        )\n        isWebSeed ? piece.cancelRemaining(reservation) : piece.cancel(reservation)\n        onUpdateTick()\n        return\n      }\n\n      self._debug(\n        'got piece %s (offset: %s length: %s) from %s',\n        index, chunkOffset, chunkLength, `${wire.remoteAddress}:${wire.remotePort}`\n      )\n\n      if (!piece.set(reservation, chunk, wire)) return onUpdateTick()\n\n      const buf = piece.flush()\n\n      // TODO: might need to set self.pieces[index] = null here since sha1 is async\n\n      const hex = await hash(buf, 'hex')\n      if (self.destroyed) return\n\n      if (hex === self._hashes[index]) {\n        self._debug('piece verified %s', index)\n\n        self.store.put(index, buf, err => {\n          if (err) {\n            self._destroy(err)\n            return\n          } else {\n            self.pieces[index] = null\n            self._markVerified(index)\n            self.wires.forEach(wire => {\n              wire.have(index)\n            })\n          }\n          self._checkDone()\n          onUpdateTick()\n        })\n      } else {\n        self.pieces[index] = new Piece(piece.length)\n        self.emit('warning', new Error(`Piece ${index} failed verification`))\n        onUpdateTick()\n      }\n    })\n\n    function onUpdateTick () {\n      queueMicrotask(() => { self._update() })\n    }\n\n    return true\n  }\n\n  _checkDone () {\n    if (this.destroyed) return\n\n    // are any new files done?\n    this.files.forEach(file => {\n      if (file.done) return\n      for (let i = file._startPiece; i <= file._endPiece; ++i) {\n        if (!this.bitfield.get(i)) return\n      }\n      file.done = true\n      file.emit('done')\n      this._debug(`file done: ${file.name}`)\n    })\n\n    // is the torrent done? (if everything is downloaded)\n    const done = this.files.every(file => file.done)\n\n    if (!this.done && done) {\n      this.done = true\n      this._debug(`torrent done: ${this.infoHash}`)\n      this.emit('done')\n      // We also check `this.destroyed` since `torrent.destroy()` could have been\n      // called in the `torrent.on('done')` handler.\n      if (!this.destroyed) this.discovery.complete()\n    } else if (this.done && !done) {\n      this.done = false\n      // this isn't according to spec, once a torrent is done it's done, but we allow devs\n      // to unmark pieces, so to re-download them we need to re-announce to\n      // trackers that \"hey we need peers\". This means triggering complete multiple times\n      // thats bad, but can't do much about it.\n      this.discovery.tracker?.start()\n    }\n    this._gcSelections()\n\n    return done\n  }\n\n  async load (streams, cb) {\n    if (this.destroyed) throw new Error('torrent is destroyed')\n    if (!this.ready) return this.once('ready', () => { this.load(streams, cb) })\n\n    if (!Array.isArray(streams)) streams = [streams]\n    if (!cb) cb = noop\n\n    try {\n      await chunkStoreWrite(this.store, joinIterator(streams), { chunkLength: this.pieceLength })\n      this._markAllVerified()\n      this._checkDone()\n      cb(null)\n    } catch (err) {\n      cb(err)\n      return err\n    }\n  }\n\n  pause () {\n    if (this.destroyed) return\n    this._debug('pause')\n    this.paused = true\n  }\n\n  resume () {\n    if (this.destroyed) return\n    this._debug('resume')\n    this.paused = false\n    this._drain()\n  }\n\n  _debug (...args) {\n    args[0] = `[${this.client._debugId}] [${this._debugId}] ${args[0]}`\n    debug(...args)\n  }\n\n  /**\n   * Pop a peer off the FIFO queue and connect to it. When _drain() gets called,\n   * the queue will usually have only one peer in it, except when there are too\n   * many peers (over `this.maxConns`) in which case they will just sit in the\n   * queue until another connection closes.\n   */\n  _drain () {\n    this._debug('_drain numConns %s maxConns %s _peersLength %s', this._numConns, this.client.maxConns, this._peersLength)\n    if (typeof net.connect !== 'function' || this.destroyed || this.paused ||\n        this._numConns >= this.client.maxConns) {\n      return\n    }\n    this._debug('drain (%s queued, %s/%s peers)', this._numQueued, this.numPeers, this.client.maxConns)\n\n    const peer = this._queue.shift()\n    if (!peer) return // queue could be empty\n\n    this._debug('%s connect attempt to %s', peer.type, peer.addr)\n\n    const parts = addrToIPPort(peer.addr)\n    const opts = {\n      host: parts[0],\n      port: parts[1]\n    }\n\n    if (this.client.utp && peer.type === Peer.TYPE_UTP_OUTGOING) {\n      peer.conn = utp.connect(opts.port, opts.host)\n    } else {\n      peer.conn = net.connect(opts)\n    }\n\n    const conn = peer.conn\n\n    conn.once('connect', () => { if (!this.destroyed) peer.onConnect() })\n    conn.once('error', err => { peer.destroy(err) })\n    peer.startConnectTimeout()\n\n    // When connection closes, attempt reconnect after timeout (with exponential backoff)\n    conn.on('close', () => {\n      if (this.destroyed) return\n\n      if (peer.retries >= RECONNECT_WAIT.length) {\n        if (this.client.utp) {\n          const newPeer = this._addPeer(peer.addr, 'tcp', peer.source)\n          if (newPeer) newPeer.retries = 0\n        } else {\n          this._debug(\n            'conn %s closed: will not re-add (max %s attempts)',\n            peer.addr, RECONNECT_WAIT.length\n          )\n        }\n        return\n      }\n\n      const ms = RECONNECT_WAIT[peer.retries]\n      this._debug(\n        'conn %s closed: will re-add to queue in %sms (attempt %s)',\n        peer.addr, ms, peer.retries + 1\n      )\n\n      const reconnectTimeout = setTimeout(() => {\n        if (this.destroyed) return\n        const host = addrToIPPort(peer.addr)[0]\n        const type = (this.client.utp && this._isIPv4(host)) ? 'utp' : 'tcp'\n        const newPeer = this._addPeer(peer.addr, type, peer.source)\n        if (newPeer) newPeer.retries = peer.retries + 1\n      }, ms)\n      if (reconnectTimeout.unref) reconnectTimeout.unref()\n    })\n  }\n\n  /**\n   * Returns `true` if string is valid IPv4/6 address.\n   * @param {string} addr\n   * @return {boolean}\n   */\n  _validAddr (addr) {\n    let parts\n    try {\n      parts = addrToIPPort(addr)\n    } catch (e) {\n      return false\n    }\n    const host = parts[0]\n    const port = parts[1]\n    return port > 0 && port < 65535 &&\n      !(host === '127.0.0.1' && port === this.client.torrentPort)\n  }\n\n  /**\n   * Return `true` if string is a valid IPv4 address.\n   * @param {string} addr\n   * @return {boolean}\n   */\n  _isIPv4 (addr) {\n    const IPv4Pattern = /^((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/\n    return IPv4Pattern.test(addr)\n  }\n}\n\nfunction getBlockPipelineLength (wire, duration) {\n  let length = 2 + Math.ceil(duration * wire.downloadSpeed() / Piece.BLOCK_LENGTH)\n\n  // Honor reqq (maximum number of outstanding request messages) if specified by peer\n  if (wire.peerExtendedHandshake) {\n    const reqq = wire.peerExtendedHandshake.reqq\n    if (typeof reqq === 'number' && reqq > 0) {\n      length = Math.min(length, reqq)\n    }\n  }\n\n  return length\n}\n\nfunction getPiecePipelineLength (wire, duration, pieceLength) {\n  return 1 + Math.ceil(duration * wire.downloadSpeed() / pieceLength)\n}\n\n/**\n * Returns a random integer in [0,high)\n */\nfunction randomInt (high) {\n  return Math.random() * high | 0\n}\n\nfunction noop () {}\n"
  },
  {
    "path": "lib/utp.cjs",
    "content": "// this file needs to conditionally import a module, ESM doesn't support this synchronously\n// we could avoid .cjs by using node:module but that doesn't sit well with preprocessors like typescript\n// and bundlers which can bundle for node like webpack\n\nmodule.exports = (() => {\n  try {\n    return require('utp-native')\n  } catch (err) {\n    console.warn('WebTorrent: uTP not supported', err)\n    return {}\n  }\n})()\n"
  },
  {
    "path": "lib/webconn.js",
    "content": "import BitField from 'bitfield'\nimport debugFactory from 'debug'\nimport fetch from 'cross-fetch-ponyfill'\nimport ltDontHave from 'lt_donthave'\nimport { hash, concat } from 'uint8-util'\nimport Wire from 'bittorrent-protocol'\nimport once from 'once'\n\nimport VERSION from '../version.cjs'\n\nconst debug = debugFactory('webtorrent:webconn')\n\nconst SOCKET_TIMEOUT = 60000\nconst RETRY_DELAY = 10000\n\n/**\n * Converts requests for torrent blocks into http range requests.\n * @param {string} url web seed url\n * @param {Object} torrent\n */\nexport default class WebConn extends Wire {\n  constructor (url, torrent) {\n    super()\n\n    this.url = url\n    this.connId = url // Unique id to deduplicate web seeds\n    this._torrent = torrent\n\n    this._init(url)\n  }\n\n  _init (url) {\n    this.setKeepAlive(true)\n\n    this.use(ltDontHave())\n\n    this.once('handshake', async (infoHash, peerId) => {\n      const hex = await hash(url, 'hex') // Used as the peerId for this fake remote peer\n      if (this.destroyed) return\n      this.handshake(infoHash, hex)\n\n      const numPieces = this._torrent.pieces.length\n      const bitfield = new BitField(numPieces)\n      for (let i = 0; i <= numPieces; i++) {\n        bitfield.set(i, true)\n      }\n      this.bitfield(bitfield)\n    })\n\n    this.once('interested', () => {\n      debug('interested')\n      this.unchoke()\n    })\n\n    this.on('uninterested', () => { debug('uninterested') })\n    this.on('choke', () => { debug('choke') })\n    this.on('unchoke', () => { debug('unchoke') })\n    this.on('bitfield', () => { debug('bitfield') })\n    this.lt_donthave.on('donthave', () => { debug('donthave') })\n\n    this.on('request', (pieceIndex, offset, length, callback) => {\n      debug('request pieceIndex=%d offset=%d length=%d', pieceIndex, offset, length)\n      this.httpRequest(pieceIndex, offset, length, (err, data) => {\n        if (err) {\n          // Cancel all in progress requests for this piece\n          this.lt_donthave.donthave(pieceIndex)\n\n          // Wait a little while before saying the webseed has the failed piece again\n          const retryTimeout = setTimeout(() => {\n            if (this.destroyed) return\n\n            this.have(pieceIndex)\n          }, RETRY_DELAY)\n          if (retryTimeout.unref) retryTimeout.unref()\n        }\n\n        callback(err, data)\n      })\n    })\n  }\n\n  async httpRequest (pieceIndex, offset, length, cb) {\n    cb = once(cb)\n    const pieceOffset = pieceIndex * this._torrent.pieceLength\n    const rangeStart = pieceOffset + offset /* offset within whole torrent */\n    const rangeEnd = rangeStart + length - 1\n\n    // Web seed URL format:\n    // For single-file torrents, make HTTP range requests directly to the web seed URL\n    // For multi-file torrents, add the torrent folder and file name to the URL\n    const files = this._torrent.files\n    let requests\n    if (files.length <= 1) {\n      requests = [{\n        url: this.url,\n        start: rangeStart,\n        end: rangeEnd\n      }]\n    } else {\n      const requestedFiles = files.filter(file => file.offset <= rangeEnd && (file.offset + file.length) > rangeStart)\n      if (requestedFiles.length < 1) {\n        return cb(new Error('Could not find file corresponding to web seed range request'))\n      }\n\n      requests = requestedFiles.map(requestedFile => {\n        const fileEnd = requestedFile.offset + requestedFile.length - 1\n        const url = this.url +\n          (this.url[this.url.length - 1] === '/' ? '' : '/') +\n          requestedFile.path.replace(this._torrent.path, '')\n        return {\n          url,\n          fileOffsetInRange: Math.max(requestedFile.offset - rangeStart, 0),\n          start: Math.max(rangeStart - requestedFile.offset, 0),\n          end: Math.min(fileEnd, rangeEnd - requestedFile.offset)\n        }\n      })\n    }\n    let chunks\n    try {\n      chunks = await Promise.all(requests.map(async ({ start, end, url }) => {\n        debug(\n          'Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d',\n          url, pieceIndex, offset, length, start, end\n        )\n        const res = await fetch(url, {\n          cache: 'no-store',\n          method: 'GET',\n          headers: {\n            'Cache-Control': 'no-store',\n            'user-agent': `WebTorrent/${VERSION} (https://webtorrent.io)`,\n            range: `bytes=${start}-${end}`\n          },\n          signal: AbortSignal.timeout(SOCKET_TIMEOUT)\n        })\n        if (!res.ok) throw new Error(`Unexpected HTTP status code ${res.status}`)\n        const data = new Uint8Array(await res.arrayBuffer())\n\n        debug('Got data of length %d', data.length)\n\n        return data\n      }))\n    } catch (e) {\n      return cb(e)\n    }\n\n    cb(null, concat(chunks))\n  }\n\n  destroy () {\n    super.destroy()\n    this._torrent = null\n  }\n}\n"
  },
  {
    "path": "lib/worker-server.js",
    "content": "const portTimeoutDuration = 5000\nlet cancellable = false\n\nconst listener = event => {\n  const { url } = event.request\n  if (!url.includes(self.registration.scope + 'webtorrent/')) return null\n  if (url.includes(self.registration.scope + 'webtorrent/keepalive/')) return new Response()\n  if (url.includes(self.registration.scope + 'webtorrent/cancel/')) {\n    return new Response(new ReadableStream({\n      cancel () {\n        cancellable = true\n      }\n    }))\n  }\n  return serve(event)\n}\n\nexport default listener\n\nasync function serve ({ request }) {\n  const { url, method, headers, destination } = request\n  const clientlist = await clients.matchAll({ type: 'window', includeUncontrolled: true })\n\n  const [data, port] = await new Promise(resolve => {\n    // Use race condition for whoever controls the response stream\n    for (const client of clientlist) {\n      const messageChannel = new MessageChannel()\n      const { port1, port2 } = messageChannel\n      port1.onmessage = ({ data }) => {\n        resolve([data, port1])\n      }\n      client.postMessage({\n        url,\n        method,\n        headers: Object.fromEntries(headers.entries()),\n        scope: self.registration.scope,\n        destination,\n        type: 'webtorrent'\n      }, [port2])\n    }\n  })\n\n  let timeOut = null\n  const cleanup = () => {\n    port.postMessage(false) // send a cancel request\n    clearTimeout(timeOut)\n    port.onmessage = null\n  }\n\n  if (data.body !== 'STREAM') {\n    cleanup()\n    return new Response(data.body, data)\n  }\n\n  return new Response(new ReadableStream({\n    pull (controller) {\n      return new Promise(resolve => {\n        port.onmessage = ({ data }) => {\n          if (data) {\n            controller.enqueue(data) // data is Uint8Array\n          } else {\n            cleanup()\n            controller.close() // data is null, means the stream ended\n          }\n          resolve()\n        }\n        if (!cancellable) {\n          // firefox doesn't support cancelling of Readable Streams in service workers,\n          // so we just empty it after 5s of inactivity, the browser will request another port anyways\n          clearTimeout(timeOut)\n          if (destination !== 'document') {\n            timeOut = setTimeout(() => {\n              cleanup()\n              resolve()\n            }, portTimeoutDuration)\n          }\n        }\n        port.postMessage(true) // send a pull request\n      })\n    },\n    cancel () {\n      cleanup()\n    }\n  }), data)\n}\n"
  },
  {
    "path": "lib/worker.js",
    "content": "import fileResponse from './worker-server.js'\n\nself.addEventListener('install', () => {\n  self.skipWaiting()\n})\n\nself.addEventListener('fetch', event => {\n  const res = fileResponse(event)\n  if (res) event.respondWith(res)\n})\n\nself.addEventListener('activate', () => {\n  self.clients.claim()\n})\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"webtorrent\",\n  \"description\": \"Streaming torrent client\",\n  \"version\": \"2.8.5\",\n  \"author\": {\n    \"name\": \"WebTorrent LLC\",\n    \"email\": \"feross@webtorrent.io\",\n    \"url\": \"https://webtorrent.io\"\n  },\n  \"type\": \"module\",\n  \"browser\": {\n    \"./lib/conn-pool.js\": false,\n    \"./lib/utp.cjs\": false,\n    \"@silentbot1/nat-api\": false,\n    \"bittorrent-dht\": false,\n    \"crypto\": false,\n    \"fs\": false,\n    \"fs-chunk-store\": \"fsa-chunk-store\",\n    \"http\": false,\n    \"load-ip-set\": false,\n    \"net\": false,\n    \"os\": false,\n    \"ut_pex\": false\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/webtorrent/webtorrent/issues\"\n  },\n  \"chromeapp\": {\n    \"./lib/utp.cjs\": false,\n    \"@silentbot1/nat-api\": false,\n    \"fs\": false,\n    \"fs-chunk-store\": \"memory-chunk-store\",\n    \"http\": \"@webtorrent/http-node\",\n    \"https\": \"@webtorrent/http-node\",\n    \"load-ip-set\": false,\n    \"net\": \"chrome-net\",\n    \"os\": false\n  },\n  \"dependencies\": {\n    \"@silentbot1/nat-api\": \"^0.4.9\",\n    \"@thaunknown/simple-peer\": \"^10.0.11\",\n    \"@webtorrent/http-node\": \"^1.3.0\",\n    \"addr-to-ip-port\": \"^2.0.0\",\n    \"bitfield\": \"^4.2.0\",\n    \"bittorrent-dht\": \"^11.0.10\",\n    \"bittorrent-protocol\": \"^4.1.20\",\n    \"cache-chunk-store\": \"^3.2.2\",\n    \"chunk-store-iterator\": \"^1.0.4\",\n    \"cpus\": \"^1.0.3\",\n    \"create-torrent\": \"^6.1.0\",\n    \"cross-fetch-ponyfill\": \"^1.0.3\",\n    \"debug\": \"^4.4.3\",\n    \"escape-html\": \"^1.0.3\",\n    \"fs-chunk-store\": \"^5.0.0\",\n    \"fsa-chunk-store\": \"^1.3.0\",\n    \"immediate-chunk-store\": \"^2.2.0\",\n    \"join-async-iterator\": \"^1.1.1\",\n    \"load-ip-set\": \"^3.0.1\",\n    \"lt_donthave\": \"^2.0.5\",\n    \"memory-chunk-store\": \"^1.3.5\",\n    \"mime\": \"^3.0.0\",\n    \"once\": \"^1.4.0\",\n    \"parse-torrent\": \"^11.0.18\",\n    \"pump\": \"^3.0.2\",\n    \"queue-microtask\": \"^1.2.3\",\n    \"random-iterate\": \"^1.0.1\",\n    \"range-parser\": \"^1.2.1\",\n    \"run-parallel\": \"^1.2.0\",\n    \"run-parallel-limit\": \"^1.1.0\",\n    \"speed-limiter\": \"^1.0.2\",\n    \"streamx\": \"2.22.1\",\n    \"throughput\": \"^1.0.2\",\n    \"torrent-discovery\": \"^11.0.17\",\n    \"torrent-piece\": \"^3.0.2\",\n    \"uint8-util\": \"^2.2.5\",\n    \"unordered-array-remove\": \"^1.0.2\",\n    \"ut_metadata\": \"^4.0.3\",\n    \"ut_pex\": \"^4.0.4\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"7.28.5\",\n    \"@babel/eslint-parser\": \"^7.28.5\",\n    \"@babel/plugin-syntax-import-assertions\": \"7.27.1\",\n    \"@babel/preset-env\": \"7.28.5\",\n    \"@webtorrent/semantic-release-config\": \"1.0.10\",\n    \"airtap\": \"4.0.4\",\n    \"airtap-manual\": \"1.0.0\",\n    \"airtap-sauce\": \"1.1.2\",\n    \"airtap-system\": \"^0.1.0\",\n    \"babelify\": \"10.0.0\",\n    \"bittorrent-tracker\": \"11.2.1\",\n    \"buffer\": \"^6.0.3\",\n    \"chrome-net\": \"^3.3.4\",\n    \"crypto-browserify\": \"^3.12.1\",\n    \"disc\": \"1.3.3\",\n    \"eslint\": \"^8.57.1\",\n    \"eslint-config-standard\": \"^17.1.0\",\n    \"eslint-plugin-import\": \"^2.31.0\",\n    \"eslint-plugin-n\": \"^16.6.2\",\n    \"eslint-plugin-promise\": \"^6.6.0\",\n    \"finalhandler\": \"2.1.1\",\n    \"network-address\": \"1.1.2\",\n    \"pako\": \"^2.1.0\",\n    \"path-esm\": \"^1.0.0\",\n    \"querystring\": \"^0.2.1\",\n    \"run-series\": \"1.1.9\",\n    \"semantic-release\": \"22.0.12\",\n    \"serve-static\": \"2.2.0\",\n    \"stream-browserify\": \"^3.0.0\",\n    \"tap-parser\": \"^16.0.1\",\n    \"tap-spec\": \"^5.0.0\",\n    \"tape\": \"^5.9.0\",\n    \"terser-webpack-plugin\": \"^5.3.14\",\n    \"timers-browserify\": \"^2.0.12\",\n    \"webpack\": \"^5.99.5\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webtorrent-fixtures\": \"1.7.5\"\n  },\n  \"optionalDependencies\": {\n    \"utp-native\": \"^2.5.3\"\n  },\n  \"engines\": {\n    \"node\": \">=16\"\n  },\n  \"funding\": [\n    {\n      \"type\": \"github\",\n      \"url\": \"https://github.com/sponsors/feross\"\n    },\n    {\n      \"type\": \"patreon\",\n      \"url\": \"https://www.patreon.com/feross\"\n    },\n    {\n      \"type\": \"consulting\",\n      \"url\": \"https://feross.org/support\"\n    }\n  ],\n  \"homepage\": \"https://webtorrent.io\",\n  \"keywords\": [\n    \"bittorrent\",\n    \"bittorrent client\",\n    \"download\",\n    \"mad science\",\n    \"p2p\",\n    \"peer-to-peer\",\n    \"peers\",\n    \"streaming\",\n    \"swarm\",\n    \"torrent\",\n    \"web torrent\",\n    \"webrtc\",\n    \"webrtc data\",\n    \"webtorrent\"\n  ],\n  \"license\": \"MIT\",\n  \"main\": \"index.js\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/webtorrent/webtorrent.git\"\n  },\n  \"scripts\": {\n    \"build\": \"npm run build-js && npm run build-js-worker && npm run build-chromeapp\",\n    \"build-chromeapp\": \"webpack --config ./scripts/chromeapp.webpack.js\",\n    \"build-js\": \"webpack --config ./scripts/browser.webpack.js\",\n    \"build-js-worker\": \"webpack --config ./scripts/worker.webpack.js\",\n    \"prepublishOnly\": \"npm run build && npm run update-authors\",\n    \"preversion\": \"npm run build && npm run update-authors\",\n    \"size\": \"npm run size-js && npm run size-disc\",\n    \"size-disc\": \"npm run build-js && cat ./dist/webtorrent.min.js | discify --open\",\n    \"size-js\": \"npm run build-js && cat ./dist/webtorrent.min.js | gzip | wc -c\",\n    \"test\": \"eslint . && npm run test-node && npm run test-browser\",\n    \"test-browser\": \"airtap --concurrency 1 --all -- test/*.js test/browser/*.js | tap-spec\",\n    \"test-browser-local\": \"airtap --preset local -- test/*.js test/browser/*.js | tap-spec\",\n    \"test-node\": \"tape test/*.js test/node/*.js | tap-spec\",\n    \"test-single\": \"tape test/node/client-deselect.js | tap-spec\",\n    \"update-authors\": \"./scripts/update-authors.sh\"\n  },\n  \"renovate\": {\n    \"extends\": [\n      \"github>webtorrent/renovate-config\"\n    ],\n    \"rangeStrategy\": \"bump\"\n  },\n  \"release\": {\n    \"extends\": \"@webtorrent/semantic-release-config\"\n  }\n}\n"
  },
  {
    "path": "polyfills/inflate-sync-web.js",
    "content": "import { inflate } from 'pako'\n\nexport const inflateSync = (buffer) => inflate(buffer, { to: 'string' })\n"
  },
  {
    "path": "polyfills/process-fast.js",
    "content": "/*!\n * Fast node `require('process')` for modern browsers\n *\n * @author   Mathias Rasmussen <mathiasvr@gmail.com>\n * @license  MIT\n */\nimport queueMicrotask from 'queue-microtask'\n\nconst title = 'browser'\nconst browser = true\nconst env = {}\nconst argv = []\nconst version = ''\nconst versions = {}\n\nfunction noop () {}\n\nconst on = noop\nconst addListener = noop\nconst once = noop\nconst off = noop\nconst removeListener = noop\nconst removeAllListeners = noop\nconst emit = noop\nconst prependListener = noop\nconst prependOnceListener = noop\n\nconst nextTick = (func, ...args) => queueMicrotask(() => func(...args))\n\nconst listeners = (name) => []\n\nconst cwd = () => '/'\nconst umask = () => 0\nconst binding = (name) => { throw new Error('process.binding is not supported') }\nconst chdir = (dir) => { throw new Error('process.chdir is not supported') }\n\nexport {\n  title, browser, env, argv, version, versions, on, addListener, once, off, removeListener,\n  removeAllListeners, emit, prependListener, prependOnceListener, nextTick, listeners, cwd, umask, binding, chdir\n}\n"
  },
  {
    "path": "scripts/browser-serve.js",
    "content": "import serve from 'serve-static'\nimport finalhandler from 'finalhandler'\nimport { createServer } from 'http'\n\ncreateServer((req, res) => {\n  serve('./dist/')(req, res, finalhandler(req, res))\n}).listen(process.env.AIRTAP_SUPPORT_PORT)\n"
  },
  {
    "path": "scripts/browser.webpack.js",
    "content": "import webpack from 'webpack'\nimport TerserPlugin from 'terser-webpack-plugin'\nimport info from '../package.json' assert { type: 'json' }\n\n/** @type {import('webpack').Configuration} */\nexport default {\n  entry: './index.js',\n  devtool: 'source-map',\n  resolve: {\n    aliasFields: ['browser'],\n    alias: {\n      ...info.browser,\n      path: 'path-esm'\n    }\n  },\n  output: {\n    chunkFormat: 'module',\n    filename: 'webtorrent.min.js',\n    library: {\n      type: 'module'\n    }\n  },\n  mode: 'production',\n  target: 'web',\n  experiments: {\n    outputModule: true\n  },\n  plugins: [\n    new webpack.ProvidePlugin({\n      process: '/polyfills/process-fast.js'\n    }),\n    new webpack.DefinePlugin({\n      global: 'globalThis'\n    })\n  ],\n  optimization: {\n    minimize: true,\n    minimizer: [new TerserPlugin({\n      terserOptions: {\n        format: {\n          comments: false\n        }\n      },\n      extractComments: false\n    })]\n  }\n}\n"
  },
  {
    "path": "scripts/chromeapp.webpack.js",
    "content": "import webpack from 'webpack'\nimport TerserPlugin from 'terser-webpack-plugin'\nimport info from '../package.json' assert { type: 'json' }\n\n/** @type {import('webpack').Configuration} */\nexport default {\n  entry: './index.js',\n  devtool: 'source-map',\n  resolve: {\n    aliasFields: ['chromeapp'],\n    alias: {\n      ...info.chromeapp,\n      path: 'path-esm',\n      stream: 'stream-browserify',\n      timers: 'timers-browserify',\n      crypto: 'crypto-browserify',\n      buffer: 'buffer',\n      querystring: 'querystring',\n      zlib: '/polyfills/inflate-sync-web.js'\n    }\n  },\n  output: {\n    chunkFormat: 'module',\n    filename: 'webtorrent.chromeapp.js',\n    library: {\n      type: 'module'\n    }\n  },\n  mode: 'production',\n  target: 'web',\n  experiments: {\n    outputModule: true\n  },\n  plugins: [\n    new webpack.ProvidePlugin({\n      process: '/polyfills/process-fast.js',\n      Buffer: ['buffer', 'Buffer']\n    }),\n    new webpack.DefinePlugin({\n      global: 'globalThis'\n    })\n  ],\n  optimization: {\n    minimize: true,\n    minimizer: [new TerserPlugin({\n      terserOptions: {\n        format: {\n          comments: false\n        }\n      },\n      extractComments: false\n    })]\n  }\n}\n"
  },
  {
    "path": "scripts/update-authors.sh",
    "content": "#!/bin/sh\n# Update AUTHORS.md based on git history.\n\ngit log --reverse --format='%aN (%aE)' | perl -we '\nBEGIN {\n  %seen = (), @authors = ();\n}\nwhile (<>) {\n  next if $seen{$_};\n  next if /(support\\@greenkeeper.io)/;\n  next if /(badger\\@gitter.im)/;\n  next if /(y.ciabaud\\@free.fr)/;\n  next if /(DiegoRBaquero\\@users.noreply.github.com)/;\n  next if /(grunjol\\@users.noreply.github.com)/;\n  $seen{$_} = push @authors, \"- \", $_;\n}\nEND {\n  print \"# Authors\\n\\n\";\n  print \"#### Ordered by first contribution.\\n\\n\";\n  print @authors, \"\\n\";\n  print \"#### Generated by scripts/update-authors.sh.\\n\";\n}\n' > AUTHORS.md\n"
  },
  {
    "path": "scripts/worker.webpack.js",
    "content": "/** @type {import('webpack').Configuration} */\nexport default {\n  entry: './lib/worker.js',\n  devtool: 'source-map',\n  output: {\n    filename: 'sw.min.js'\n  },\n  mode: 'production',\n  target: 'web'\n}\n"
  },
  {
    "path": "test/bitfield.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('preloaded bitfield: load files into filesystem', t => {\n  t.plan(2)\n\n  const client = new WebTorrent({ dht: false, utp: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, () => {\n    t.ok('loaded files into filesystem')\n    client.destroy(err => { t.error(err, 'client 2 destroyed') })\n  })\n})\n\ntest('preloaded bitfield: full bitfield, files exist', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, utp: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent, { bitfield: new Uint8Array([255, 255, 254]) })\n  // torrent has only one file, so only one piece should be verified, checks if file exists.\n  torrent.on('verified', i => t.equal(i, 1, 'verified only piece'))\n\n  torrent.on('ready', () => {\n    t.ok(torrent._hasStartupBitfield, 'has startup bitfield')\n    client.destroy(err => t.error(err, 'client destroyed'))\n  })\n})\n\ntest('preloaded bitfield: partial bitfield, files exist', t => {\n  t.plan(4)\n\n  const client = new WebTorrent({ dht: false, utp: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent, { bitfield: new Uint8Array([0, 0, 255]) })\n  // torrent has only one file, so only one piece should be verified, checks if file exists, fails, unmarks entire file\n  torrent.on('verified', i => t.equal(i, 17, 'verified only piece'))\n\n  torrent.on('ready', () => {\n    t.ok(torrent._hasStartupBitfield, 'has startup bitfield')\n    t.ok(!torrent.done, 'torrent not done')\n    client.destroy(err => t.error(err, 'client destroyed'))\n  })\n})\n\ntest('preloaded bitfield: wrong size bitfield, files exist', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, utp: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent, { bitfield: new Uint8Array([255, 255]) })\n  // partial bitfield will fail because there's only one file, so it will re-scan all pieces once\n  let verifiedPieces = 0\n  torrent.on('verified', () => ++verifiedPieces)\n\n  torrent.on('ready', () => {\n    t.equal(verifiedPieces, torrent.pieces.length, 'verified only piece')\n    t.ok(!torrent._hasStartupBitfield, 'startup bitfield ignored because of miss-match')\n    torrent.destroy({ destroyStore: true }, () => {\n      client.destroy(err => t.error(err, 'client destroyed'))\n    })\n  })\n})\n\ntest('preloaded bitfield: full bitfield, files don\\'t exist', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, utp: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent, { bitfield: new Uint8Array([255, 255, 254]) })\n  // torrent has only one file, so only one piece should be verified, checks if file exists, then fails and rescans all pieces\n  let verifiedPieces = 0\n  torrent.on('verified', () => ++verifiedPieces)\n\n  torrent.on('ready', () => {\n    t.equal(verifiedPieces, 0, 'no pieces successfully verified')\n    t.ok(torrent._hasStartupBitfield, 'has startup bitfield')\n    client.destroy(err => t.error(err, 'client destroyed'))\n  })\n})\n\ntest('preloaded bitfield: wrong size bitfield, files don\\'t exist', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, utp: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent, { bitfield: new Uint8Array([255, 255]) })\n  // partial bitfield will fail because there's only one file, so it will re-scan all pieces once\n  let verifiedPieces = 0\n  torrent.on('verified', () => ++verifiedPieces)\n\n  torrent.on('ready', () => {\n    t.equal(verifiedPieces, 0, 'no pieces successfully verified')\n    t.ok(!torrent._hasStartupBitfield, 'startup bitfield ignored because of miss-match')\n    client.destroy(err => t.error(err, 'client destroyed'))\n  })\n})\n"
  },
  {
    "path": "test/browser/basic.js",
    "content": "import test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('WebTorrent.WEBRTC_SUPPORT', t => {\n  t.plan(2)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  t.equal(WebTorrent.WEBRTC_SUPPORT, true)\n\n  client.destroy(err => {\n    t.error(err, 'client destroyed')\n  })\n})\n"
  },
  {
    "path": "test/browser/server.js",
    "content": "import test from 'tape'\nimport WebTorrent from '../../index.js'\nimport fixtures from 'webtorrent-fixtures'\nimport get from 'simple-get'\n\n// The image append/render tests don't work in electron, so skip them\n// TODO get these working\n// logic taken from https://github.com/atom/electron/issues/2288#issuecomment-123147993\n\nif (!global?.process?.versions?.electron) {\n  const img = Buffer.from('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'base64')\n  img.name = 'img.png'\n  test('SW Registration and errors', t => {\n    const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n    client.on('error', err => { t.fail(err) })\n    client.on('warning', err => { t.fail(err) })\n\n    client.seed(img, torrent => {\n      t.throws(() => {\n        return torrent.files[0].streamURL\n      }, 'Stream URL without server')\n      function checkState (worker, controller) {\n        if (worker.state !== 'activated' && worker.state !== 'activating') {\n          t.throws(() => {\n            client.createServer({ controller })\n          }, 'Invalid worker state')\n        } else {\n          client.createServer({ controller })\n          t.throws(() => {\n            client.createServer({ controller })\n          }, 'Server already registered')\n          t.ok(torrent.files[0].streamURL, 'get file URL')\n          client.destroy(err => {\n            t.error(err, 'client destroyed')\n            controller.unregister().then(() => {\n              t.ok('service worker unregistered')\n              t.end()\n            }).catch(err => {\n              t.error(err, 'unregister error')\n            })\n          })\n\n          return true\n        }\n      }\n      try {\n        navigator.serviceWorker.register('./sw.min.js', { scope: './' }).then(() => {\n          navigator.serviceWorker.ready.then(controller => {\n            checkState(controller.active, controller)\n          })\n        })\n      } catch (e) {\n        t.err(e)\n      }\n    })\n  })\n  test('SW renderer image', t => {\n    t.plan(4)\n    const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n    client.on('error', err => { t.fail(err) })\n    client.on('warning', err => { t.fail(err) })\n    try {\n      navigator.serviceWorker.register('./sw.min.js', { scope: './' }).then(() => {\n        navigator.serviceWorker.ready.then(controller => {\n          client.createServer({ controller })\n          client.seed(img, async torrent => {\n            const src = torrent.files[0].streamURL\n            t.ok(typeof src === 'string', 'source is string')\n            t.ok(src.endsWith('/webtorrent/db19b51fe04aaf14fd4c9be77f5eeeb2d8789b5c/img.png'), 'source URL is correct')\n\n            const res = await fetch(torrent.files[0].streamURL)\n            const data = new Uint8Array(await res.arrayBuffer())\n            const original = new Uint8Array(img)\n            t.deepEqual(data, original)\n            client.destroy(err => {\n              t.error(err, 'client destroyed')\n            })\n          })\n        })\n      })\n    } catch (e) {\n      t.err(e)\n    }\n  })\n  // this hangs on CI\n  // test('SW renderer video', t => {\n  //   t.plan(4)\n  //   const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  //   client.on('error', err => { t.fail(err) })\n  //   client.on('warning', err => { t.fail(err) })\n  //   const video = document.createElement('video')\n  //   try {\n  //     navigator.serviceWorker.getRegistration().then(controller => {\n  //       client.createServer({ controller })\n  //       client.add('https://webtorrent.io/torrents/sintel.torrent', torrent => {\n  //         video.addEventListener('loadedmetadata', () => {\n  //           t.equal(Math.floor(video.duration), 888, 'Video metadata is ok')\n  //           client.destroy(err => {\n  //             t.error(err, 'client destroyed')\n  //           })\n  //         })\n  //         const file = torrent.files.find(file => file.name.endsWith('.mp4'))\n  //         file.streamTo(video)\n  //         t.ok(typeof video.src === 'string', 'source is string')\n  //         t.ok(video.src.endsWith('/webtorrent/08ada5a7a6183aae1e09d831df6748d566095a10/Sintel/Sintel.mp4'), 'source URL is correct')\n  //         video.load()\n  //       })\n  //     })\n  //   } catch (e) {\n  //     t.err(e)\n  //   }\n  // })\n\n  test('client.createServer: programmatic http server [node-like usage]', t => {\n    t.plan(8)\n\n    const client = new WebTorrent({ tracker: false, dht: false, lsd: false })\n\n    client.on('error', err => { t.fail(err) })\n    client.on('warning', err => { t.fail(err) })\n\n    client.seed(fixtures.leaves.content, torrent => {\n      t.pass('got \"torrent\" event')\n      navigator.serviceWorker.getRegistration().then(controller => {\n        const server = client.createServer({ controller })\n\n        server.listen(0, () => {\n          const port = server.address().port\n          t.pass(`server is listening on ${port}`)\n\n          // Seeding after server is created should work\n\n          const host = `http://localhost:${port}`\n          const path = `webtorrent/${torrent.infoHash}`\n\n          // Index page should list files in the torrent\n          get.concat(`${host}/${path}/`, (err, res, data) => {\n            t.error(err, `got http response for /${path}`)\n            data = data.toString()\n            t.ok(data.includes('Leaves of Grass by Walt Whitman.epub'))\n\n            // Verify file content for first (and only) file\n            get.concat(`${host}/${path}/${torrent.files[0].path}`, (err, res, data) => {\n              t.error(err, `got http response for /${path}/${torrent.files[0].path}`)\n              t.deepEqual(data, fixtures.leaves.content)\n\n              // test streamURL\n              get.concat(torrent.files[0].streamURL, (err, res, data) => {\n                t.error(err, `got http response for ${torrent.files[0].streamURL} via streamURL`)\n                t.deepEqual(data, fixtures.leaves.content)\n\n                server.close(() => {\n                  t.pass('server closed')\n                })\n                client.destroy(err => {\n                  t.error(err, 'client destroyed')\n                })\n              })\n            })\n          })\n        })\n      })\n    })\n  })\n}\n"
  },
  {
    "path": "test/client-add-duplicate-trackers.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('client.add: duplicate trackers', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent, {\n    announce: ['wss://example.com', 'wss://example.com', 'wss://example.com']\n  })\n\n  torrent.on('ready', async () => {\n    t.equal(torrent.magnetURI, `${fixtures.leaves.magnetURI}&tr=${encodeURIComponent('wss://example.com')}`)\n    await client.remove(fixtures.leaves.magnetURI, err => { t.error(err, 'torrent destroyed') })\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: duplicate trackers, with multiple torrents', t => {\n  t.plan(5)\n\n  // Re-use this object, in case webtorrent is changing it\n  const opts = {\n    announce: ['wss://example.com', 'wss://example.com', 'wss://example.com']\n  }\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent1 = client.add(fixtures.leaves.torrent, opts)\n\n  torrent1.on('ready', () => {\n    t.equal(torrent1.magnetURI, `${fixtures.leaves.magnetURI}&tr=${encodeURIComponent('wss://example.com')}`)\n\n    const torrent2 = client.add(fixtures.alice.torrent, opts)\n\n    torrent2.on('ready', async () => {\n      t.equal(torrent2.magnetURI, `${fixtures.alice.magnetURI}&tr=${encodeURIComponent('wss://example.com')}`)\n\n      await torrent1.destroy(err => { t.error(err, 'torrent1 destroyed') })\n      await torrent2.destroy(err => { t.error(err, 'torrent2 destroyed') })\n      client.destroy(err => { t.error(err, 'client destroyed') })\n    })\n  })\n})\n\ntest('client.add: duplicate trackers (including in .torrent file), multiple torrents', t => {\n  t.plan(5)\n\n  // Re-use this object, in case webtorrent is changing it\n  const opts = {\n    announce: ['wss://example.com', 'wss://example.com', 'wss://example.com']\n  }\n\n  // Include the duplicate trackers in the .torrent files\n  const parsedTorrentLeaves = Object.assign({}, fixtures.leaves.parsedTorrent)\n  parsedTorrentLeaves.announce = ['wss://example.com', 'wss://example.com', 'wss://example.com']\n\n  const parsedTorrentAlice = Object.assign({}, fixtures.alice.parsedTorrent)\n  parsedTorrentAlice.announce = ['wss://example.com', 'wss://example.com', 'wss://example.com']\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent1 = client.add(parsedTorrentLeaves, opts)\n\n  torrent1.on('ready', () => {\n    t.equal(torrent1.magnetURI, `${fixtures.leaves.magnetURI}&tr=${encodeURIComponent('wss://example.com')}`)\n\n    const torrent2 = client.add(parsedTorrentAlice, opts)\n\n    torrent2.on('ready', async () => {\n      t.equal(torrent2.magnetURI, `${fixtures.alice.magnetURI}&tr=${encodeURIComponent('wss://example.com')}`)\n\n      await torrent1.destroy(err => { t.error(err, 'torrent1 destroyed') })\n      await torrent2.destroy(err => { t.error(err, 'torrent2 destroyed') })\n      client.destroy(err => { t.error(err, 'client destroyed') })\n    })\n  })\n})\n"
  },
  {
    "path": "test/client-add.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('client.add: magnet uri, utf-8 string', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.magnetURI)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(fixtures.leaves.magnetURI, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: torrent file, buffer', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(fixtures.leaves.torrent, err => { t.error(err, 'torrent destroyed') })\n    console.log(client.torrents.length)\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: info hash, hex string', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.parsedTorrent.infoHash)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, `magnet:?xt=urn:btih:${fixtures.leaves.parsedTorrent.infoHash}`)\n\n    await client.remove(fixtures.leaves.parsedTorrent.infoHash, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: info hash, buffer', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.parsedTorrent.infoHashBuffer)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.ok(torrent.magnetURI.indexOf(`magnet:?xt=urn:btih:${fixtures.leaves.parsedTorrent.infoHash}`) === 0)\n\n    await client.remove(Buffer.from(fixtures.leaves.parsedTorrent.infoHash, 'hex'), err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: parsed torrent, from `parse-torrent`', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.parsedTorrent)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(fixtures.leaves.parsedTorrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: parsed torrent, with string type announce property', t => {\n  t.plan(7)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n  parsedTorrent.announce = 'http://tracker.local:80'\n\n  const torrent = client.add(parsedTorrent)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n\n    const expectedMagnetURI = `${fixtures.leaves.magnetURI}&tr=${encodeURIComponent('http://tracker.local:80')}`\n    t.equal(torrent.magnetURI, expectedMagnetURI)\n\n    // `torrent.announce` must always be an array\n    t.deepEqual(torrent.announce, ['http://tracker.local:80'])\n\n    await client.remove(fixtures.leaves.parsedTorrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: parsed torrent, with array type announce property', t => {\n  t.plan(7)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n  parsedTorrent.announce = ['http://tracker.local:80', 'http://tracker.local:81']\n\n  const torrent = client.add(parsedTorrent)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n\n    const expectedMagnetURI = `${fixtures.leaves.magnetURI}&tr=${encodeURIComponent('http://tracker.local:80')}&tr=${encodeURIComponent('http://tracker.local:81')}`\n    t.equal(torrent.magnetURI, expectedMagnetURI)\n\n    t.deepEqual(torrent.announce, ['http://tracker.local:80', 'http://tracker.local:81'])\n\n    await client.remove(fixtures.leaves.parsedTorrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: invalid torrent id: empty string', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => {\n    t.ok(err instanceof Error)\n    t.ok(err.message.includes('Invalid torrent identifier'))\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add('')\n})\n\ntest('client.add: invalid torrent id: short buffer', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => {\n    t.ok(err instanceof Error)\n    t.ok(err.message.includes('Invalid torrent identifier'))\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add(Buffer.from('abc'))\n})\n\ntest('client.add: paused torrent', t => {\n  t.plan(5)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', (err) => { t.fail(err) })\n  client.on('warning', (err) => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.magnetURI, { paused: true })\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.paused, true)\n\n    await client.remove(fixtures.leaves.magnetURI, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n"
  },
  {
    "path": "test/client-destroy.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('after client.destroy(), throw on client.add() or client.seed()', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.destroy(err => { t.error(err, 'client destroyed') })\n\n  t.throws(() => {\n    client.add(`magnet:?xt=urn:btih:${fixtures.leaves.parsedTorrent.infoHash}`)\n  })\n  t.throws(() => {\n    client.seed(Buffer.from('sup'))\n  })\n})\n\ntest('after client.destroy(), no \"torrent\" or \"ready\" events emitted', t => {\n  t.plan(1)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add(fixtures.leaves.torrent, { name: 'leaves' }, () => {\n    t.fail('unexpected \"torrent\" event (from add)')\n  })\n  client.seed(fixtures.leaves.content, { name: 'leaves' }, () => {\n    t.fail('unexpected \"torrent\" event (from seed)')\n  })\n  client.on('ready', () => {\n    t.fail('unexpected \"ready\" event')\n  })\n\n  client.destroy(err => { t.error(err, 'client destroyed') })\n})\n"
  },
  {
    "path": "test/client-remove.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('client.remove: remove by Torrent object', t => {\n  t.plan(5)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.parsedTorrent.infoHash)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n"
  },
  {
    "path": "test/client-seed.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('client.seed: torrent file (Buffer)', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent removed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.seed: torrent file (Buffer), set name on buffer', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const buf = Buffer.from(fixtures.leaves.content)\n  buf.name = 'Leaves of Grass by Walt Whitman.epub'\n\n  client.seed(buf, { announce: [] }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent removed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.seed: torrent file (Blob)', t => {\n  if (typeof Blob === 'undefined') return t.end()\n\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(new Blob([fixtures.leaves.content]), {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent removed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.seed: duplicate seed', t => {\n  t.plan(4)\n\n  const client = new WebTorrent()\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, function (torrent1) {\n    client.seed(fixtures.leaves.content, function (torrent2) {\n      t.equal(torrent1, torrent2)\n      t.equal(client.torrents.length, 1)\n\n      client.destroy(err => { t.error(err, 'client destroyed') })\n      t.equal(client.torrents.length, 0)\n    })\n  })\n})\n"
  },
  {
    "path": "test/common.js",
    "content": "import os from 'os'\nimport fs from 'fs'\nimport path from 'path'\n\nconst getDownloadPath = (infix, infoHash) => {\n  let tmpPath\n  try {\n    tmpPath = path.join(fs.statSync('/tmp') && '/tmp')\n  } catch (err) {\n    tmpPath = path.join(typeof os.tmpdir === 'function' ? os.tmpdir() : '/')\n  }\n  return path.join(tmpPath, 'webtorrent', 'test', infix, infoHash)\n}\n\nexport default { getDownloadPath }\n"
  },
  {
    "path": "test/duplicate.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('client.seed followed by duplicate client.add (sync)', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent1 => {\n    t.equal(client.torrents.length, 1)\n\n    const torrent2 = client.add(torrent1.infoHash)\n\n    torrent2.once('ready', () => {\n      t.fail('torrent ready is not called')\n    })\n\n    torrent2.once('error', err => {\n      t.ok(err, 'got expected error on duplicate add')\n      t.equal(client.torrents.length, 1)\n      t.ok(torrent2.destroyed)\n      client.destroy(err => {\n        t.error(err, 'destroyed client')\n        t.equal(client.torrents.length, 0)\n      })\n    })\n  })\n})\n\ntest('client.seed followed by duplicate client.add (async)', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent1 => {\n    t.equal(client.torrents.length, 1)\n\n    const torrent2 = client.add(fixtures.leaves.torrentPath)\n\n    torrent2.once('ready', () => {\n      t.fail('torrent ready is not called')\n    })\n\n    torrent2.once('error', err => {\n      t.ok(err, 'got expected error on duplicate add')\n      t.equal(client.torrents.length, 1)\n      t.ok(torrent2.destroyed)\n      client.destroy(err => {\n        t.error(err, 'destroyed client')\n        t.equal(client.torrents.length, 0)\n      })\n    })\n  })\n})\n\ntest('client.seed followed by two duplicate client.add calls (sync)', t => {\n  t.plan(9)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent1 => {\n    t.equal(client.torrents.length, 1)\n\n    const torrent2 = client.add(torrent1.infoHash)\n\n    torrent2.once('ready', () => {\n      t.fail('torrent ready is not called')\n    })\n\n    torrent2.once('error', err => {\n      t.ok(err, 'got expected error on duplicate add')\n      t.equal(client.torrents.length, 1)\n      t.ok(torrent2.destroyed)\n\n      const torrent3 = client.add(torrent1.infoHash)\n\n      torrent3.once('ready', () => {\n        t.fail('torrent ready is not called')\n      })\n\n      torrent3.once('error', err => {\n        t.ok(err, 'got expected error on duplicate add')\n        t.equal(client.torrents.length, 1)\n        t.ok(torrent3.destroyed)\n        client.destroy(err => {\n          t.error(err, 'destroyed client')\n          t.equal(client.torrents.length, 0)\n        })\n      })\n    })\n  })\n})\n\ntest('client.seed followed by two duplicate client.add calls (async)', t => {\n  t.plan(9)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent1 => {\n    t.equal(client.torrents.length, 1)\n\n    const torrent2 = client.add(fixtures.leaves.torrentPath)\n\n    torrent2.once('ready', () => {\n      t.fail('torrent ready is not called')\n    })\n\n    torrent2.once('error', err => {\n      t.ok(err, 'got expected error on duplicate add')\n      t.equal(client.torrents.length, 1)\n      t.ok(torrent2.destroyed)\n\n      const torrent3 = client.add(fixtures.leaves.torrentPath)\n\n      torrent3.once('ready', () => {\n        t.fail('torrent ready is not called')\n      })\n\n      torrent3.once('error', err => {\n        t.ok(err, 'got expected error on duplicate add')\n        t.equal(client.torrents.length, 1)\n        t.ok(torrent3.destroyed)\n        client.destroy(err => {\n          t.error(err, 'destroyed client')\n          t.equal(client.torrents.length, 0)\n        })\n      })\n    })\n  })\n})\n\ntest('successive sync client.add, client.remove, client.add, client.remove (sync)', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent1 => {\n    t.equal(client.torrents.length, 1)\n\n    client.remove(torrent1.infoHash, () => {\n      client.add(torrent1.infoHash)\n      client.remove(torrent1.infoHash, () => {\n        client.destroy(err => {\n          t.error(err, 'destroyed client')\n          t.equal(client.torrents.length, 0)\n        })\n      })\n    })\n  })\n})\n"
  },
  {
    "path": "test/file-buffer.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('file buffer: use chunk store iterator if done', t => {\n  t.plan(8)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    const buffer = await torrent.files[0].arrayBuffer({ start: 0, end: 99 }) // 100 bytes, node streams are end-inclusive\n    t.ok(buffer.byteLength === 100, 'buffer is 100 bytes')\n    const orig = fixtures.leaves.content.buffer.slice(0, 100) // 100 bytes, buffers are end-exclusive\n    t.deepEqual(new Uint8Array(orig), new Uint8Array(buffer), 'buffer from torrent file matches original')\n\n    await client.remove(torrent, err => { t.error(err, 'torrent removed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n"
  },
  {
    "path": "test/iterator.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport FileIterator from '../lib/file-iterator.js'\nimport WebTorrent from '../index.js'\n\ntest('file iterator: use chunk store iterator if done', t => {\n  t.plan(8)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    const iterator = torrent.files[0][Symbol.asyncIterator]()\n    t.ok(torrent.files[0].done, 'file finished downloading')\n    t.ok(!(iterator instanceof FileIterator), 'iterator isn\\'t FileIterator')\n    iterator.return()\n\n    await client.remove(torrent, err => { t.error(err, 'torrent removed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('file iterator: use file iterator if not done', t => {\n  t.plan(8)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.torrent)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('ready', async () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    t.ok(!torrent.files[0].done, 'file hasn\\'t finished downloading')\n    const iterator = torrent.files[0][Symbol.asyncIterator]()\n    t.ok(iterator instanceof FileIterator, 'iterator is FileIterator')\n    iterator.return()\n\n    await client.remove(fixtures.leaves.torrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n"
  },
  {
    "path": "test/node/basic.js",
    "content": "import fs from 'fs'\nimport path from 'path'\nimport http from 'http'\nimport fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('WebTorrent.WEBRTC_SUPPORT', t => {\n  t.plan(2)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  t.equal(WebTorrent.WEBRTC_SUPPORT, true)\n\n  client.destroy(err => {\n    t.error(err, 'client destroyed')\n  })\n})\n\ntest('client.add: http url to a torrent file, string', t => {\n  t.plan(8)\n\n  const server = http.createServer((req, res) => {\n    t.ok(req.headers['user-agent'].includes('WebTorrent'))\n    res.end(fixtures.leaves.torrent)\n  })\n\n  server.listen(0, () => {\n    const port = server.address().port\n    const url = `http://127.0.0.1:${port}`\n    const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n    client.on('error', err => { t.fail(err) })\n    client.on('warning', err => { t.fail(err) })\n\n    client.add(url, async torrent => {\n      t.equal(client.torrents.length, 1)\n      t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n      t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n      await client.remove(torrent, err => { t.error(err, 'torrent destroyed') })\n      t.equal(client.torrents.length, 0)\n\n      server.close(() => { t.pass('http server closed') })\n      client.destroy(err => { t.error(err, 'client destroyed') })\n    })\n  })\n})\n\ntest('client.add: filesystem path to a torrent file, string', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add(fixtures.leaves.torrentPath, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.seed: filesystem path to file, string', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.leaves.contentPath, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.seed: filesystem path to folder with one file, string', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.folder.contentPath, { announce: [] }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.folder.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.folder.magnetURI)\n\n    await client.remove(torrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.seed: filesystem path to folder with multiple files, string', t => {\n  t.plan(7)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.numbers.contentPath, { announce: [] }, async torrent => {\n    t.equal(client.torrents.length, 1)\n    t.equal(torrent.infoHash, fixtures.numbers.parsedTorrent.infoHash)\n    t.equal(torrent.magnetURI, fixtures.numbers.magnetURI)\n\n    const downloaded = torrent.files.map(file => ({\n      length: file.length,\n      downloaded: file.downloaded\n    }))\n\n    t.deepEqual(downloaded, [\n      { length: 1, downloaded: 1 },\n      { length: 2, downloaded: 2 },\n      { length: 3, downloaded: 3 }\n    ], 'expected downloaded to be calculated correctly')\n\n    await client.remove(torrent, err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('client.add: invalid torrent id: invalid filesystem path', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => {\n    t.ok(err instanceof Error)\n    t.ok(err.message.includes('Invalid torrent identifier'))\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add('/invalid/filesystem/path/123')\n})\n\ntest('client.remove: opts.destroyStore', t => {\n  t.plan(2)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.alice.content, { name: 'alice.txt', announce: [] }, torrent => {\n    const torrentPath = torrent.path\n    client.remove(torrent, { destroyStore: true }, err => {\n      if (err) t.fail(err)\n\n      fs.stat(path.join(torrentPath, 'alice.txt'), err => {\n        if (err && err.code === 'ENOENT') t.pass('file deleted')\n        else t.fail('file still exists')\n\n        client.destroy(err => { t.error(err, 'client destroyed') })\n      })\n    })\n  })\n})\n\ntest('torrent.destroy: opts.destroyStore', t => {\n  t.plan(2)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.seed(fixtures.alice.content, { name: 'alice.txt', announce: [] }, torrent => {\n    const torrentPath = torrent.path\n    torrent.destroy({ destroyStore: true }, err => {\n      if (err) t.fail(err)\n\n      fs.stat(path.join(torrentPath, 'alice.txt'), err => {\n        if (err && err.code === 'ENOENT') t.pass('file deleted')\n        else t.fail('file still exists')\n\n        client.destroy(err => { t.error(err, 'client destroyed') })\n      })\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/blocklist-dht.js",
    "content": "import { Server as DHT } from 'bittorrent-dht'\nimport fixtures from 'webtorrent-fixtures'\nimport series from 'run-series'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\nimport common from '../common.js'\n\ntest('blocklist blocks peers discovered via DHT', t => {\n  t.plan(8)\n\n  let dhtServer, client1, client2\n\n  series([\n    cb => {\n      dhtServer = new DHT({ bootstrap: false })\n      dhtServer.on('error', err => { t.fail(err) })\n      dhtServer.on('warning', err => { t.fail(err) })\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      let torrentReady = false\n      let announced = false\n\n      client1 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      const torrent1 = client1.add(fixtures.leaves.parsedTorrent, {\n        path: common.getDownloadPath('client_1', fixtures.leaves.parsedTorrent.infoHash)\n      })\n\n      torrent1.on('peer', () => {\n        t.fail('client1 should not find any peers')\n      })\n\n      torrent1.on('blockedPeer', () => {\n        t.fail('client1 should not block any peers')\n      })\n\n      torrent1.on('ready', () => {\n        t.pass('torrent1 ready')\n        torrentReady = true\n        maybeDone()\n      })\n\n      torrent1.on('dhtAnnounce', () => {\n        t.pass('client1 announced to dht')\n        announced = true\n        maybeDone()\n      })\n\n      function maybeDone () {\n        if (torrentReady && announced) cb(null)\n      }\n    },\n\n    cb => {\n      client2 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` },\n        blocklist: ['127.0.0.1']\n      })\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      const torrent2 = client2.add(fixtures.leaves.parsedTorrent, {\n        path: common.getDownloadPath('client_2', fixtures.leaves.parsedTorrent.infoHash)\n      })\n\n      torrent2.on('blockedPeer', addr => {\n        t.pass(`client2 blocked connection to client1: ${addr}`)\n        blockedPeer = true\n        maybeDone()\n      })\n\n      torrent2.on('dhtAnnounce', () => {\n        t.pass('client2 announced to dht')\n        announced = true\n        maybeDone()\n      })\n\n      torrent2.on('peer', addr => {\n        t.fail('client2 should not find any peers')\n      })\n\n      let blockedPeer, announced\n      function maybeDone () {\n        if (blockedPeer && announced) cb(null)\n      }\n    }\n\n  ], err => {\n    t.error(err)\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/blocklist-tracker.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport series from 'run-series'\nimport test from 'tape'\nimport { Server as TrackerServer } from 'bittorrent-tracker'\nimport WebTorrent from '../../index.js'\nimport common from '../common.js'\n\ntest('blocklist blocks peers discovered via tracker', t => {\n  t.plan(9)\n\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n  let tracker, client1, client2\n\n  series([\n    cb => {\n      tracker = new TrackerServer({ udp: false, ws: false })\n\n      tracker.listen(() => {\n        const port = tracker.http.address().port\n        const announceUrl = `http://127.0.0.1:${port}/announce`\n\n        // Overwrite announce with our local tracker\n        parsedTorrent.announce = announceUrl\n\n        cb(null)\n      })\n\n      tracker.once('start', () => {\n        t.pass('client1 connected to tracker')\n\n        tracker.once('start', () => {\n          t.pass('client2 connected to tracker')\n        })\n      })\n    },\n\n    cb => {\n      client1 = new WebTorrent({ dht: false, lsd: false })\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      const torrent1 = client1.add(parsedTorrent, {\n        path: common.getDownloadPath('client_1', parsedTorrent.infoHash)\n      })\n\n      torrent1.on('invalidPeer', () => {\n        t.pass('client1 found itself')\n        cb(null)\n      })\n\n      torrent1.on('blockedPeer', () => {\n        t.fail('client1 should not block any peers')\n      })\n    },\n\n    cb => {\n      client2 = new WebTorrent({\n        dht: false,\n        lsd: false,\n        blocklist: ['127.0.0.1']\n      })\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      const torrent2 = client2.add(parsedTorrent, {\n        path: common.getDownloadPath('client_2', parsedTorrent.infoHash)\n      })\n\n      torrent2.once('blockedPeer', () => {\n        t.pass('client2 blocked first peer')\n\n        torrent2.once('blockedPeer', () => {\n          t.pass('client2 blocked second peer')\n          cb(null)\n        })\n      })\n\n      torrent2.on('peer', () => {\n        t.fail('client2 should not find any peers')\n      })\n    }\n\n  ], err => {\n    t.error(err)\n    tracker.close(() => {\n      t.pass('tracker closed')\n    })\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/blocklist.js",
    "content": "import fs from 'fs'\nimport http from 'http'\nimport zlib from 'zlib'\nimport fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\nfunction assertBlocked (t, torrent, addr) {\n  torrent.once('blockedPeer', _addr => {\n    t.equal(addr, _addr)\n  })\n  t.notOk(torrent.addPeer(addr))\n}\n\nfunction assertReachable (t, torrent, addr) {\n  torrent.once('peer', _addr => {\n    t.equal(addr, _addr)\n  })\n  t.ok(torrent.addPeer(addr))\n}\n\ntest('blocklist (single IP)', t => {\n  t.plan(9)\n\n  const client = new WebTorrent({\n    dht: false,\n    tracker: false,\n    lsd: false,\n    blocklist: ['1.2.3.4']\n  })\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  // blocklist isn't fully loaded until `ready` event\n  client.on('ready', () => {\n    client.add(fixtures.leaves.parsedTorrent, torrent => {\n      assertBlocked(t, torrent, '1.2.3.4:1234')\n      assertBlocked(t, torrent, '1.2.3.4:6969')\n      assertReachable(t, torrent, '1.1.1.1:1234')\n      assertReachable(t, torrent, '1.1.1.1:6969')\n\n      client.destroy(err => {\n        t.error(err, 'client destroyed')\n      })\n    })\n  })\n})\n\ntest('blocklist (array of IPs)', t => {\n  t.plan(13)\n\n  const client = new WebTorrent({\n    dht: false,\n    tracker: false,\n    lsd: false,\n    blocklist: ['1.2.3.4', '5.6.7.8']\n  })\n    .on('error', err => { t.fail(err) })\n    .on('warning', err => { t.fail(err) })\n    .on('ready', () => {\n      client.add(fixtures.leaves.parsedTorrent, torrent => {\n        assertBlocked(t, torrent, '1.2.3.4:1234')\n        assertBlocked(t, torrent, '1.2.3.4:6969')\n        assertBlocked(t, torrent, '5.6.7.8:1234')\n        assertBlocked(t, torrent, '5.6.7.8:6969')\n        assertReachable(t, torrent, '1.1.1.1:1234')\n        assertReachable(t, torrent, '1.1.1.1:6969')\n\n        client.destroy(err => {\n          t.error(err, 'client destroyed')\n        })\n      })\n    })\n})\n\n// 48 asserts\nfunction assertList (t, torrent) {\n  assertBlocked(t, torrent, '1.2.3.0:1234')\n  assertBlocked(t, torrent, '1.2.3.0:6969')\n\n  assertBlocked(t, torrent, '1.2.3.1:1234')\n  assertBlocked(t, torrent, '1.2.3.1:6969')\n\n  assertBlocked(t, torrent, '1.2.3.1:1234')\n  assertBlocked(t, torrent, '1.2.3.1:6969')\n\n  assertBlocked(t, torrent, '1.2.3.254:1234')\n  assertBlocked(t, torrent, '1.2.3.254:6969')\n\n  assertBlocked(t, torrent, '1.2.3.255:1234')\n  assertBlocked(t, torrent, '1.2.3.255:6969')\n\n  assertBlocked(t, torrent, '5.6.7.0:1234')\n  assertBlocked(t, torrent, '5.6.7.0:6969')\n\n  assertBlocked(t, torrent, '5.6.7.128:1234')\n  assertBlocked(t, torrent, '5.6.7.128:6969')\n\n  assertBlocked(t, torrent, '5.6.7.255:1234')\n  assertBlocked(t, torrent, '5.6.7.255:6969')\n\n  assertReachable(t, torrent, '1.1.1.1:1234')\n  assertReachable(t, torrent, '1.1.1.1:6969')\n\n  assertReachable(t, torrent, '2.2.2.2:1234')\n  assertReachable(t, torrent, '2.2.2.2:6969')\n\n  assertReachable(t, torrent, '1.2.4.0:1234')\n  assertReachable(t, torrent, '1.2.4.0:6969')\n\n  assertReachable(t, torrent, '1.2.2.0:1234')\n  assertReachable(t, torrent, '1.2.2.0:6969')\n}\n\ntest('blocklist (array of IP ranges)', t => {\n  t.plan(49)\n  const client = new WebTorrent({\n    dht: false,\n    tracker: false,\n    lsd: false,\n    blocklist: [\n      { start: '1.2.3.0', end: '1.2.3.255' },\n      { start: '5.6.7.0', end: '5.6.7.255' }\n    ]\n  })\n    .on('error', err => { t.fail(err) })\n    .on('warning', err => { t.fail(err) })\n    .on('ready', () => {\n      client.add(fixtures.leaves.parsedTorrent, torrent => {\n        assertList(t, torrent)\n        client.destroy(err => {\n          t.error(err, 'client destroyed')\n        })\n      })\n    })\n})\n\ntest('blocklist (http url)', t => {\n  t.plan(51)\n  const server = http.createServer((req, res) => {\n    // Check that WebTorrent declares a user agent\n    t.ok(req.headers['user-agent'].includes('WebTorrent'))\n\n    fs.createReadStream(fixtures.blocklist.path).pipe(res)\n  })\n\n  server.listen(0, () => {\n    const port = server.address().port\n    const url = `http://127.0.0.1:${port}`\n    const client = new WebTorrent({\n      dht: false,\n      tracker: false,\n      lsd: false,\n      blocklist: url\n    })\n      .on('error', err => { t.fail(err) })\n      .on('warning', err => { t.fail(err) })\n      .on('ready', () => {\n        client.add(fixtures.leaves.parsedTorrent, torrent => {\n          assertList(t, torrent)\n          client.destroy(err => {\n            t.error(err, 'client destroyed')\n          })\n          server.close(() => {\n            t.pass('server closed')\n          })\n        })\n      })\n  })\n})\n\ntest('blocklist (http url with gzip encoding)', t => {\n  t.plan(51)\n  const server = http.createServer((req, res) => {\n    // Check that WebTorrent declares a user agent\n    t.ok(req.headers['user-agent'].includes('WebTorrent'))\n\n    res.setHeader('content-encoding', 'gzip')\n    fs.createReadStream(fixtures.blocklist.path)\n      .pipe(zlib.createGzip())\n      .pipe(res)\n  })\n\n  server.listen(0, () => {\n    const port = server.address().port\n    const url = `http://127.0.0.1:${port}`\n    const client = new WebTorrent({\n      dht: false,\n      tracker: false,\n      lsd: false,\n      blocklist: url\n    })\n      .on('error', err => { t.fail(err) })\n      .on('warning', err => { t.fail(err) })\n      .on('ready', () => {\n        client.add(fixtures.leaves.parsedTorrent, torrent => {\n          assertList(t, torrent)\n          client.destroy(err => {\n            t.error(err, 'client destroyed')\n          })\n          server.close(() => {\n            t.pass('server closed')\n          })\n        })\n      })\n  })\n})\n\ntest('blocklist (http url with deflate encoding)', t => {\n  t.plan(51)\n  const server = http.createServer((req, res) => {\n    // Check that WebTorrent declares a user agent\n    t.ok(req.headers['user-agent'].includes('WebTorrent'))\n\n    res.setHeader('content-encoding', 'deflate')\n    fs.createReadStream(fixtures.blocklist.path)\n      .pipe(zlib.createDeflate())\n      .pipe(res)\n  })\n\n  server.listen(0, () => {\n    const port = server.address().port\n    const url = `http://127.0.0.1:${port}`\n    const client = new WebTorrent({\n      dht: false,\n      tracker: false,\n      lsd: false,\n      blocklist: url\n    })\n      .on('error', err => { t.fail(err) })\n      .on('warning', err => { t.fail(err) })\n      .on('ready', () => {\n        client.add(fixtures.leaves.parsedTorrent, torrent => {\n          assertList(t, torrent)\n          client.destroy(err => {\n            t.error(err, 'client destroyed')\n          })\n          server.close(() => {\n            t.pass('server closed')\n          })\n        })\n      })\n  })\n})\n\ntest('blocklist (fs path)', t => {\n  t.plan(49)\n  const client = new WebTorrent({\n    dht: false,\n    tracker: false,\n    lsd: false,\n    blocklist: fixtures.blocklist.path\n  })\n    .on('error', err => { t.fail(err) })\n    .on('warning', err => { t.fail(err) })\n    .on('ready', () => {\n      client.add(fixtures.leaves.parsedTorrent, torrent => {\n        assertList(t, torrent)\n        client.destroy(err => {\n          t.error(err, 'client destroyed')\n        })\n      })\n    })\n})\n\ntest('blocklist (fs path with gzip)', t => {\n  t.plan(49)\n  const client = new WebTorrent({\n    dht: false,\n    tracker: false,\n    lsd: false,\n    blocklist: fixtures.blocklist.gzipPath\n  })\n    .on('error', err => { t.fail(err) })\n    .on('warning', err => { t.fail(err) })\n    .on('ready', () => {\n      client.add(fixtures.leaves.parsedTorrent, torrent => {\n        assertList(t, torrent)\n        client.destroy(err => {\n          t.error(err, 'client destroyed')\n        })\n      })\n    })\n})\n"
  },
  {
    "path": "test/node/client-deselect.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\nfunction setupClient ({ t, onTorrent, onIdle, addTorrentProps = {} }) {\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n  client1.on('error', function (err) { t.fail(err) })\n  client1.on('warning', function (err) { t.fail(err) })\n\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n  client2.on('error', function (err) { t.fail(err) })\n  client2.on('warning', function (err) { t.fail(err) })\n\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n\n  client1.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: [],\n    store: MemoryChunkStore\n  }, () => {\n    client2.add(parsedTorrent, { store: MemoryChunkStore, ...addTorrentProps }, (torrent) => {\n      onTorrent(torrent)\n\n      torrent.addPeer(`localhost:${client1.torrentPort}`)\n\n      torrent.once('idle', () => {\n        onIdle(torrent)\n\n        Promise.all([\n          new Promise((resolve) => client1.destroy(function (err) { t.error(err, 'client1 destroyed'); resolve() })),\n          new Promise((resolve) => client2.destroy(function (err) { t.error(err, 'client2 destroyed'); resolve() }))\n        ]).then(() => t.end())\n      })\n    })\n  })\n}\n\ntest('client.select: whole torrent', function (t) {\n  setupClient({\n    t,\n    onTorrent: (torrent) => {\n      torrent.select(0, torrent.pieces.length - 1)\n    },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, torrent.pieces.length)\n    }\n  })\n})\n\ntest('client.select: partial torrent', function (t) {\n  let lastPieceIndex\n  setupClient({\n    t,\n    onTorrent: (torrent) => {\n      lastPieceIndex = Math.floor((torrent.pieces.length - 1) / 2)\n      torrent.deselect(0, torrent.pieces.length - 1)\n      torrent.select(0, lastPieceIndex)\n    },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, (lastPieceIndex + 1))\n    }\n  })\n})\n\ntest('client.deselect: whole torrent', function (t) {\n  setupClient({\n    t,\n    onTorrent: (torrent) => {\n      torrent.deselect(0, torrent.pieces.length - 1)\n    },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, 0)\n    }\n  })\n})\n\ntest('client.deselect: whole torrent - start as deselected', function (t) {\n  setupClient({\n    t,\n    onTorrent: () => {},\n    addTorrentProps: { deselect: true },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, 0)\n    }\n  })\n})\n\ntest('client.deselect: partial torrent - second half deselected', function (t) {\n  let lastPieceIndex\n  setupClient({\n    t,\n    onTorrent: (torrent) => {\n      lastPieceIndex = Math.floor((torrent.pieces.length - 1) / 2)\n      torrent.deselect(0, lastPieceIndex)\n    },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, (torrent.pieces.length - 1 - lastPieceIndex))\n      // this test used to check the remaining selections, but now checking on idle removes the selections, so they don't exist\n      // assertSelectionsEquals(t, torrent._selections, [[lastPieceIndex + 1, torrent.pieces.length - 1]])\n    }\n  })\n})\n\ntest('client.deselect: partial torrent - second half deselected', function (t) {\n  let lastPieceIndex\n  setupClient({\n    t,\n    onTorrent: (torrent) => {\n      lastPieceIndex = Math.floor((torrent.pieces.length - 1) / 2)\n      torrent.deselect(lastPieceIndex, torrent.pieces.length - 1)\n    },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, (torrent.pieces.length - 1 - lastPieceIndex))\n      // this test used to check the remaining selections, but now checking on idle removes the selections, so they don't exist\n      // assertSelectionsEquals(t, torrent._selections, [[0, lastPieceIndex - 1]])\n    }\n  })\n})\n\ntest('client.deselect: multiple overlapping ranges', function (t) {\n  setupClient({\n    t,\n    addTorrentProps: { deselect: true },\n    onTorrent: (/** @type {import('../../lib/torrent.js').default} */torrent) => {\n      torrent.select(3, 10)\n      torrent.select(5, 12)\n      torrent.select(12, 18)\n      torrent.select(15, 22)\n      torrent.select(0, 4)\n      t.assert(torrent._selections.length === 1)\n      assertSelectionsEquals(t, torrent._selections, [[0, 22]])\n\n      torrent.deselect(4, 8)\n      torrent.deselect(14, 17)\n      torrent.deselect(20, 21)\n      t.assert(torrent._selections.length === 4)\n      assertSelectionsEquals(t, torrent._selections, [[0, 3], [9, 13], [18, 19], [22, 22]])\n    },\n    onIdle: (torrent) => {\n      t.equal(torrent.pieces.filter((a) => a === null).length, 12)\n    }\n  })\n})\n\n/**\n * @param {import('tape').Test} t\n * @param {import('../../lib/selections.js').Selections} selections\n * @param {[number,number][]} expected\n */\nfunction assertSelectionsEquals (t, selections, expected) {\n  t.equal(selections.length, expected.length)\n  const selectionItems = [...selections._items]\n  selectionItems.sort((a, b) => a.from - b.from)\n  expected.sort((a, b) => a[0] - b[0])\n\n  for (let i = 0; i < expected.length; i++) {\n    const actualRange = [selectionItems[i].from, selectionItems[i].to]\n    const expectedRange = expected[i]\n    t.deepEqual(actualRange, expectedRange)\n  }\n}\n"
  },
  {
    "path": "test/node/conn-pool.js",
    "content": "import test from 'tape'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport dgram from 'dgram'\nimport WebTorrent from '../../index.js'\n\ntest('client.conn-pool: use TCP when uTP disabled', t => {\n  t.plan(6)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('done', () => {\n      t.equal(++order, 4)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n})\n\ntest('client.conn-pool: use uTP when uTP enabled', t => {\n  t.plan(6)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('done', () => {\n      t.equal(++order, 4)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n})\n\ntest('client.conn-pool: adding IPv6 peer when uTP enabled should fallback to TCP', t => {\n  t.plan(6)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`[::1]:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('done', () => {\n      t.equal(++order, 4)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n})\n\n// Warning: slow test as we need to rely on connection timeouts\ntest('client.conn-pool: fallback to TCP when uTP server failed', t => {\n  t.plan(7)\n\n  // force uTP server failure\n  const server = dgram.createSocket('udp4')\n  server.bind(63000)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true, torrentPort: 63000 })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n\n  client1.on('error', err => { t.equal(err.toString(), 'Error: address already in use') })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('done', () => {\n      t.equal(++order, 4)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n\n      server.close()\n    })\n  })\n})\n\n// Warning: slow test as we need to rely on connection timeouts\ntest('client.conn-pool: fallback to TCP when remote client has uTP disabled', t => {\n  t.plan(6)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: true })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('done', () => {\n      t.equal(++order, 4)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/download-dht-magnet.js",
    "content": "import fs from 'fs'\nimport { Server as DHT } from 'bittorrent-dht'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport networkAddress from 'network-address'\nimport series from 'run-series'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Download using DHT (via magnet uri)', t => {\n  t.plan(11)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client1, client2\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      let announced = false\n      let loaded = false\n\n      client1 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}`, host: networkAddress.ipv4() }\n      })\n\n      client1.dht.on('listening', () => {\n        t.equal(client1.dhtPort, client1.dht.address().port)\n      })\n\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      const torrent = client1.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n      torrent.on('dhtAnnounce', () => {\n        t.pass('finished dht announce')\n        announced = true\n        maybeDone()\n      })\n\n      torrent.on('ready', () => {\n        // torrent metadata has been fetched -- sanity check it\n        t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n        const names = ['Leaves of Grass by Walt Whitman.epub']\n        t.deepEqual(torrent.files.map(file => file.name), names)\n      })\n\n      torrent.load(fs.createReadStream(fixtures.leaves.contentPath), err => {\n        t.error(err)\n        loaded = true\n        maybeDone()\n      })\n\n      function maybeDone () {\n        if (announced && loaded) cb(null)\n      }\n    },\n\n    cb => {\n      let gotBuffer = false\n      let gotDone = false\n\n      client2 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}`, host: networkAddress.ipv4() }\n      })\n\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      client2.on('torrent', async torrent => {\n        torrent.once('done', () => {\n          t.pass('client2 downloaded torrent from client1')\n\n          gotDone = true\n          maybeDone()\n        })\n\n        try {\n          const ab = await torrent.files[0].arrayBuffer()\n          t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n        } catch (err) {\n          t.error(err)\n        }\n\n        gotBuffer = true\n        maybeDone()\n      })\n\n      client2.add(fixtures.leaves.magnetURI, { store: MemoryChunkStore })\n\n      function maybeDone () {\n        if (gotBuffer && gotDone) cb(null)\n      }\n    }\n  ], err => {\n    t.error(err)\n\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/download-dht-torrent.js",
    "content": "import fs from 'fs'\nimport { Server as DHT } from 'bittorrent-dht'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Download using DHT (via .torrent file)', t => {\n  t.plan(10)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client1, client2\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      let announced = false\n      let loaded = false\n      let noPeersFound = false\n\n      client1 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` },\n        utPex: false\n      })\n\n      client1.dht.on('listening', () => {\n        t.equal(client1.dhtPort, client1.dht.address().port)\n      })\n\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      const torrent = client1.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n      torrent.on('ready', () => {\n        // torrent metadata has been fetched -- sanity check it\n        t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n        const names = ['Leaves of Grass by Walt Whitman.epub']\n        t.deepEqual(torrent.files.map(file => file.name), names)\n      })\n\n      torrent.load(fs.createReadStream(fixtures.leaves.contentPath), err => {\n        loaded = true\n        maybeDone(err)\n      })\n\n      torrent.on('dhtAnnounce', () => {\n        announced = true\n        maybeDone(null)\n      })\n\n      torrent.on('noPeers', announceType => {\n        t.equal(announceType, 'dht', 'noPeers event seen with correct announceType')\n        noPeersFound = true\n        maybeDone(null)\n      })\n\n      function maybeDone (err) {\n        if ((announced && loaded && noPeersFound) || err) cb(err, client1)\n      }\n    },\n\n    cb => {\n      client2 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` },\n        utPex: false\n      })\n\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      client2.on('torrent', async torrent => {\n        let torrentDone = false\n        let gotBuffer = false\n        function maybeDone () {\n          if (torrentDone && gotBuffer) cb(null)\n        }\n\n        torrent.once('done', () => {\n          t.pass('client2 downloaded torrent from client1')\n          torrentDone = true\n          maybeDone()\n        })\n\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n          gotBuffer = true\n          maybeDone()\n        }\n      })\n\n      client2.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n    }\n  ], err => {\n    t.error(err)\n\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/download-from-ip.js",
    "content": "import fs from 'fs'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Download via torrent.addPeer()', (t) => {\n  t.plan(6)\n  // if initial interest isn't set, then this test is delayed\n  t.timeoutAfter(5000)\n\n  const seeder = new WebTorrent({ tracker: false, dht: false, lsd: false })\n\n  seeder.on('error', (err) => t.fail(err))\n  seeder.on('warning', (err) => t.fail(err))\n\n  const torrent = seeder.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n  torrent.on('ready', () => {\n    // torrent metadata has been fetched -- sanity check it\n    t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n    const names = ['Leaves of Grass by Walt Whitman.epub']\n    t.deepEqual(torrent.files.map(file => file.name), names)\n  })\n\n  torrent.load(fs.createReadStream(fixtures.leaves.contentPath), (err) => {\n    t.error(err)\n\n    // torrent data now loaded into seeder\n\n    const downloader = new WebTorrent({ tracker: false, dht: false, lsd: false })\n\n    downloader.on('error', err => { t.fail(err) })\n    downloader.on('warning', err => { t.fail(err) })\n\n    downloader.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore }, (torrent) => {\n      torrent.addPeer(`localhost:${seeder.torrentPort}`)\n\n      torrent.once('done', async () => {\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n          seeder.destroy((err) => t.error(err, 'seeder destroyed'))\n          downloader.destroy((err) => t.error(err, 'downloader destroyed'))\n        }\n      })\n    })\n  })\n})\n\ntest('Download via magnet x.pe (BEP09)', (t) => {\n  t.plan(6)\n  // if initial interest isn't set, then this test is delayed\n  t.timeoutAfter(5000)\n\n  const seeder = new WebTorrent({ tracker: false, dht: false, lsd: false, torrentPort: 63000 })\n\n  seeder.on('error', (err) => t.fail(err))\n  seeder.on('warning', (err) => t.fail(err))\n\n  const torrent = seeder.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n  torrent.on('ready', () => {\n    // torrent metadata has been fetched -- sanity check it\n    t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n    const names = ['Leaves of Grass by Walt Whitman.epub']\n    t.deepEqual(torrent.files.map(file => file.name), names)\n  })\n\n  torrent.load(fs.createReadStream(fixtures.leaves.contentPath), (err) => {\n    t.error(err)\n\n    // torrent data now loaded into seeder\n\n    const downloader = new WebTorrent({ tracker: false, dht: false, lsd: false })\n\n    downloader.on('error', err => { t.fail(err) })\n    downloader.on('warning', err => { t.fail(err) })\n\n    // add x.pe to the magnet\n    const peerAddress = '127.0.0.1:63000'\n    const magnetURI = fixtures.leaves.magnetURI + `&x.pe=${peerAddress}`\n\n    downloader.add(magnetURI, { store: MemoryChunkStore }, (torrent) => {\n      torrent.once('done', async () => {\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n\n          seeder.destroy((err) => t.error(err, 'seeder destroyed'))\n          downloader.destroy((err) => t.error(err, 'downloader destroyed'))\n        }\n      })\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/download-lsd-magnet.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Download using LSD (via magnet uri)', t => {\n  t.plan(3)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: true })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: true })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  const torrent = client1.add(fixtures.leaves.magnetURI, { store: MemoryChunkStore })\n\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  torrent.on('done', () => {\n    t.pass()\n\n    client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n    client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n  })\n})\n"
  },
  {
    "path": "test/node/download-lsd-torrent.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Download using LSD (via .torrent file)', t => {\n  t.plan(3)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: true })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: true })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  const torrent = client1.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n  client1.on('torrent', () => {\n    client2.seed(fixtures.leaves.content, {\n      name: 'Leaves of Grass by Walt Whitman.epub',\n      announce: []\n    })\n  })\n\n  torrent.on('done', () => {\n    t.pass()\n\n    client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n    client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n  })\n})\n"
  },
  {
    "path": "test/node/download-metadata.js",
    "content": "import http from 'http'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\nfunction createServer (data, cb) {\n  const server = http.createServer((req, res) => {\n    if (req.url !== '/') {\n      res.statusCode = 404\n      res.end()\n    } else {\n      res.end(data)\n    }\n  })\n\n  server.on('listening', () => {\n    const address = server.address()\n    const url = `http://127.0.0.1:${address.port}/`\n    cb(url, server)\n  })\n\n  server.listen()\n}\n\ntest('Download metadata for magnet URI with xs parameter', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  createServer(fixtures.leaves.torrent, (url, server) => {\n    const encodedUrl = encodeURIComponent(url)\n    client.add(`${fixtures.leaves.magnetURI}&xs=${encodedUrl}`, { store: MemoryChunkStore }, torrent => {\n      t.equal(torrent.files[0].name, 'Leaves of Grass by Walt Whitman.epub')\n      client.destroy(err => { t.error(err, 'client destroyed') })\n      server.close(() => { t.pass('server closed') })\n    })\n  })\n})\n\ntest('Download metadata for magnet URI with 2 xs parameters', t => {\n  t.plan(4)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  createServer(fixtures.leaves.torrent, (url1, server1) => {\n    const encodedUrl1 = encodeURIComponent(url1)\n\n    createServer(fixtures.leaves.torrent, (url2, server2) => {\n      const encodedUrl2 = encodeURIComponent(url2)\n\n      const uri = `${fixtures.leaves.magnetURI}&xs=${encodedUrl1}&xs=${encodedUrl2}`\n\n      client.add(uri, { store: MemoryChunkStore }, torrent => {\n        t.equal(torrent.files[0].name, 'Leaves of Grass by Walt Whitman.epub')\n        client.destroy(err => { t.error(err, 'client destroyed') })\n        server1.close(() => { t.pass('server closed') })\n        server2.close(() => { t.pass('server closed') })\n      })\n    })\n  })\n})\n\ntest('Download metadata for magnet URI with 2 xs parameters, with 1 invalid protocol', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  createServer(fixtures.leaves.torrent, (url, server) => {\n    const encodedUrl1 = encodeURIComponent('invalidurl:example')\n    const encodedUrl2 = encodeURIComponent(url)\n    const uri = `${fixtures.leaves.magnetURI}&xs=${encodedUrl1}&xs=${encodedUrl2}`\n\n    client.add(uri, { store: MemoryChunkStore }, torrent => {\n      t.equal(torrent.files[0].name, 'Leaves of Grass by Walt Whitman.epub')\n      client.destroy(err => { t.error(err, 'client destroyed') })\n      server.close(() => { t.pass('server closed') })\n    })\n  })\n})\n\ntest('Download metadata for magnet URI with 2 xs parameters, with 1 404 URL', t => {\n  t.plan(3)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  createServer(fixtures.leaves.torrent, (url, server) => {\n    const encodedUrl1 = encodeURIComponent(`${url}blah_404`)\n    const encodedUrl2 = encodeURIComponent(url)\n    const uri = `${fixtures.leaves.magnetURI}&xs=${encodedUrl1}&xs=${encodedUrl2}`\n\n    client.add(uri, { store: MemoryChunkStore }, torrent => {\n      t.equal(torrent.files[0].name, 'Leaves of Grass by Walt Whitman.epub')\n      client.destroy(err => { t.error(err, 'client destroyed') })\n      server.close(() => { t.pass('server closed') })\n    })\n  })\n})\n\ntest('Download metadata magnet URI with unsupported protocol in xs parameter', t => {\n  t.plan(1)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add(`${fixtures.leaves.magnetURI}&xs=${encodeURIComponent('invalidurl:example')}`, { store: MemoryChunkStore })\n\n  setTimeout(() => {\n    // no crash by now\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  }, 100)\n})\n"
  },
  {
    "path": "test/node/download-private-dht.js",
    "content": "import { Server as DHT } from 'bittorrent-dht'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('private torrent should not use DHT', t => {\n  t.plan(4)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      client = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      const torrent = client.add(fixtures.bunny.parsedTorrent, { store: MemoryChunkStore })\n\n      torrent.on('dhtAnnounce', () => {\n        t.fail('client announced to dht')\n      })\n\n      client.on('torrent', () => {\n        if (!torrent.discovery.dht) {\n          t.pass('dht is disabled for this torrent')\n          cb(null)\n        }\n      })\n    }\n  ], err => {\n    t.error(err)\n\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n    client.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n  })\n})\n\ntest('public torrent should use DHT', t => {\n  t.plan(4)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      client = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      const torrent = client.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n      torrent.on('dhtAnnounce', () => {\n        t.pass('client announced to dht')\n        cb(null)\n      })\n\n      client.on('torrent', () => {\n        if (!torrent.client.dht) {\n          t.fail('dht server is null')\n        }\n      })\n    }\n  ], err => {\n    t.error(err)\n\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n    client.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n  })\n})\n\ntest('public torrent with forced private option should not use DHT', t => {\n  t.plan(4)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      client = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      const torrent = client.add(fixtures.leaves.parsedTorrent, {\n        private: true,\n        store: MemoryChunkStore\n      })\n\n      torrent.on('dhtAnnounce', () => {\n        t.fail('client announced to dht')\n      })\n\n      client.on('torrent', () => {\n        if (!torrent.discovery.dht) {\n          t.pass('dht is disabled for this torrent')\n          cb(null)\n        }\n      })\n    }\n  ], err => {\n    t.error(err)\n\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n    client.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n  })\n})\n\ntest('private torrent with forced public option should use DHT', t => {\n  t.plan(4)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      client = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      const torrent = client.add(fixtures.bunny.parsedTorrent, {\n        private: false,\n        store: MemoryChunkStore\n      })\n\n      torrent.on('dhtAnnounce', () => {\n        t.pass('client announced to dht')\n        cb(null)\n      })\n\n      client.on('torrent', () => {\n        if (!torrent.client.dht) {\n          t.fail('dht server is null')\n        }\n      })\n    }\n  ], err => {\n    t.error(err)\n\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n    client.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/download-tracker-magnet.js",
    "content": "import fs from 'fs'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport test from 'tape'\nimport { Server as TrackerServer } from 'bittorrent-tracker'\nimport WebTorrent from '../../index.js'\n\ntest('Download using UDP tracker (via magnet uri)', t => {\n  magnetDownloadTest(t, 'udp')\n})\n\ntest('Download using HTTP tracker (via magnet uri)', t => {\n  magnetDownloadTest(t, 'http')\n})\n\ntest('Download using WS tracker (via magnet uri)', t => {\n  magnetDownloadTest(t, 'ws')\n})\n\nconst TRACKER_CONFIG_MAP = {\n  udp: { http: false, ws: false },\n  http: { udp: false, ws: false },\n  ws: { udp: false, http: false, ws: true }\n}\n\nfunction magnetDownloadTest (t, serverType) {\n  t.plan(10)\n\n  const tracker = new TrackerServer(TRACKER_CONFIG_MAP[serverType])\n\n  tracker.on('error', err => { t.fail(err) })\n  tracker.on('warning', err => { t.fail(err) })\n\n  let trackerStartCount = 0\n  tracker.on('start', () => {\n    trackerStartCount += 1\n  })\n\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n  let magnetURI, client1, client2\n\n  series([\n    cb => {\n      tracker.listen(cb)\n    },\n\n    cb => {\n      const port = tracker[serverType].address().port\n      const announceUrl = `${serverType}://127.0.0.1:${port}/announce`\n\n      parsedTorrent.announce = [announceUrl]\n      magnetURI = `magnet:?xt=urn:btih:${parsedTorrent.infoHash}&tr=${encodeURIComponent(announceUrl)}`\n\n      client1 = new WebTorrent({ dht: false, lsd: false })\n\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      client1.on('torrent', torrent => {\n        let noPeersDone = false\n        let torrentLoaded = false\n\n        // torrent metadata has been fetched -- sanity check it\n        t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n        const names = [\n          'Leaves of Grass by Walt Whitman.epub'\n        ]\n\n        torrent.once('noPeers', announceType => {\n          t.equal(announceType, 'tracker', 'noPeers event seen with correct announceType')\n\n          noPeersDone = true\n          maybeDone()\n        })\n\n        t.deepEqual(torrent.files.map(file => file.name), names)\n\n        torrent.load(fs.createReadStream(fixtures.leaves.contentPath), () => {\n          torrentLoaded = true\n          maybeDone()\n        })\n\n        function maybeDone () {\n          if (noPeersDone && torrentLoaded) cb(null)\n        }\n      })\n\n      client1.add(parsedTorrent, { store: MemoryChunkStore })\n    },\n\n    cb => {\n      client2 = new WebTorrent({ dht: false, lsd: false })\n\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      client2.on('torrent', async torrent => {\n        let gotBuffer = false\n        let torrentDone = false\n        function maybeDone () {\n          if (gotBuffer && torrentDone) cb(null)\n        }\n\n        torrent.once('done', () => {\n          t.pass('client2 downloaded torrent from client1')\n          torrentDone = true\n          maybeDone()\n        })\n\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n\n          gotBuffer = true\n          maybeDone()\n        }\n      })\n\n      client2.add(magnetURI, { store: MemoryChunkStore })\n    }\n\n  ], err => {\n    t.error(err)\n\n    t.equal(trackerStartCount, 2)\n\n    tracker.close(() => {\n      t.pass('tracker closed')\n    })\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n  })\n}\n"
  },
  {
    "path": "test/node/download-tracker-torrent.js",
    "content": "import fs from 'fs'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport test from 'tape'\nimport { Server as TrackerServer } from 'bittorrent-tracker'\nimport WebTorrent from '../../index.js'\n\ntest('Download using UDP tracker (via .torrent file)', t => {\n  torrentDownloadTest(t, 'udp')\n})\n\ntest('Download using HTTP tracker (via .torrent file)', t => {\n  torrentDownloadTest(t, 'http')\n})\n\ntest('Download using WS tracker (via .torrent file)', t => {\n  torrentDownloadTest(t, 'ws')\n})\n\nconst TRACKER_CONFIG_MAP = {\n  udp: { http: false, ws: false },\n  http: { udp: false, ws: false },\n  ws: { udp: false, http: false, ws: true }\n}\n\nfunction torrentDownloadTest (t, serverType) {\n  t.plan(9)\n\n  let trackerStartCount = 0\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n\n  const tracker = new TrackerServer(TRACKER_CONFIG_MAP[serverType])\n\n  tracker.on('error', err => { t.fail(err) })\n  tracker.on('warning', err => { t.fail(err) })\n\n  tracker.on('start', () => {\n    trackerStartCount += 1\n  })\n\n  let client1, client2\n\n  series([\n    cb => {\n      tracker.listen(cb)\n    },\n\n    cb => {\n      client1 = new WebTorrent({ dht: false, lsd: false })\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      const port = tracker[serverType].address().port\n\n      const announceUrl = `${serverType}://127.0.0.1:${port}/announce`\n      // Overwrite announce with our local tracker\n      parsedTorrent.announce = [announceUrl]\n\n      client1.on('torrent', torrent => {\n        // torrent metadata has been fetched -- sanity check it\n        t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n        const names = [\n          'Leaves of Grass by Walt Whitman.epub'\n        ]\n\n        t.deepEqual(torrent.files.map(file => file.name), names)\n\n        torrent.load(fs.createReadStream(fixtures.leaves.contentPath), cb)\n      })\n\n      client1.add(parsedTorrent, { store: MemoryChunkStore })\n    },\n\n    cb => {\n      client2 = new WebTorrent({ dht: false, lsd: false })\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      client2.add(parsedTorrent, { store: MemoryChunkStore })\n\n      client2.on('torrent', async torrent => {\n        let gotBuffer = false\n        let torrentDone = false\n        function maybeDone () {\n          if (gotBuffer && torrentDone) cb(null)\n        }\n\n        torrent.once('done', () => {\n          t.pass('client2 downloaded torrent from client1')\n          torrentDone = true\n          maybeDone()\n        })\n\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n\n          gotBuffer = true\n          maybeDone()\n        }\n      })\n    }\n\n  ], err => {\n    t.error(err)\n    t.equal(trackerStartCount, 2)\n\n    tracker.close(() => {\n      t.pass('tracker closed')\n    })\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n  })\n}\n"
  },
  {
    "path": "test/node/download-webseed-magnet.js",
    "content": "import http from 'http'\nimport path from 'path'\nimport finalhandler from 'finalhandler'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport serveStatic from 'serve-static'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Download using webseed (via magnet uri)', t => {\n  t.plan(8)\n\n  const serve = serveStatic(path.dirname(fixtures.leaves.contentPath))\n  const httpServer = http.createServer((req, res) => {\n    const done = finalhandler(req, res)\n    serve(req, res, done)\n  })\n  let client1, client2\n\n  httpServer.on('error', err => { t.fail(err) })\n\n  series([\n    cb => {\n      httpServer.listen(cb)\n    },\n\n    cb => {\n      client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      let gotTorrent = false\n      let gotListening = false\n      function maybeDone () {\n        if (gotTorrent && gotListening) cb(null)\n      }\n\n      client1.on('torrent', torrent => {\n        // torrent metadata has been fetched -- sanity check it\n        t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub')\n\n        const names = [\n          'Leaves of Grass by Walt Whitman.epub'\n        ]\n\n        t.deepEqual(torrent.files.map(file => file.name), names)\n\n        // NOTE: client1 is *NOT* a seeder. Just has the metadata.\n        gotTorrent = true\n        maybeDone()\n      })\n\n      const torrent = client1.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore })\n\n      torrent.on('infoHash', () => {\n        gotListening = true\n        maybeDone()\n      })\n    },\n\n    cb => {\n      client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      const webSeedUrl = `http://localhost:${httpServer.address().port}/${fixtures.leaves.parsedTorrent.name}`\n      const magnetURI = `${fixtures.leaves.magnetURI}&ws=${encodeURIComponent(webSeedUrl)}`\n\n      client2.on('torrent', async torrent => {\n        let gotBuffer = false\n        let torrentDone = false\n        function maybeDone () {\n          if (gotBuffer && torrentDone) cb(null)\n        }\n\n        torrent.once('done', () => {\n          t.pass('client2 downloaded torrent from client1')\n          torrentDone = true\n          maybeDone()\n        })\n\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n\n          gotBuffer = true\n          maybeDone()\n        }\n      })\n\n      const torrent = client2.add(magnetURI, { store: MemoryChunkStore })\n\n      torrent.on('infoHash', () => {\n        torrent.addPeer(`127.0.0.1:${client1.address().port}`)\n      })\n    }\n  ], err => {\n    t.error(err)\n    client1.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n    httpServer.close(() => {\n      t.pass('http server closed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/download-webseed-torrent.js",
    "content": "import http from 'http'\nimport path from 'path'\nimport finalhandler from 'finalhandler'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport serveStatic from 'serve-static'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\n// it should be fast to download a small torrent over local HTTP\nconst WEB_SEED_TIMEOUT_MS = 500\n\ntest('Download using webseed (via .torrent file)', t => {\n  t.plan(5)\n  t.timeoutAfter(WEB_SEED_TIMEOUT_MS)\n\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n\n  const httpServer = http.createServer((req, res) => {\n    const done = finalhandler(req, res)\n    serveStatic(path.dirname(fixtures.leaves.contentPath))(req, res, done)\n  })\n  let client\n\n  httpServer.on('error', err => { t.fail(err) })\n\n  series([\n    cb => {\n      httpServer.listen(cb)\n    },\n\n    cb => {\n      parsedTorrent.urlList = [\n        `http://localhost:${httpServer.address().port}/${fixtures.leaves.parsedTorrent.name}`\n      ]\n\n      client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      client.on('torrent', async torrent => {\n        let gotBuffer = false\n        let torrentDone = false\n        function maybeDone () {\n          if (gotBuffer && torrentDone) cb(null)\n        }\n\n        torrent.once('done', () => {\n          t.pass('client downloaded torrent from webseed')\n          torrentDone = true\n          maybeDone()\n        })\n\n        for (const file of torrent.files) {\n          try {\n            const ab = await file.arrayBuffer()\n            t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'downloaded correct content')\n          } catch (err) {\n            t.error(err)\n          }\n\n          gotBuffer = true\n          maybeDone()\n        }\n      })\n\n      client.add(parsedTorrent, { store: MemoryChunkStore })\n    }\n  ], err => {\n    t.error(err)\n    client.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n    httpServer.close(() => {\n      // FIXME: t.pass was moved outside of this function because node native fetch keeps\n      // connections open for longer, this isn't an issue in the node-fetch package\n      // this causes the http server take much longer to close, even tho all request\n      // have already been settled\n    })\n    t.pass('http server closed')\n  })\n})\n\ntest('Disable webseeds', t => {\n  t.plan(3)\n  const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)\n\n  const httpServer = http.createServer((req, res) => {\n    t.fail('webseed http server should not get any requests')\n  })\n  let client\n\n  httpServer.on('error', err => { t.fail(err) })\n\n  series([\n    cb => {\n      httpServer.listen(cb)\n    },\n\n    cb => {\n      parsedTorrent.urlList = [\n        `http://localhost:${httpServer.address().port}/${fixtures.leaves.parsedTorrent.name}`\n      ]\n\n      client = new WebTorrent({ dht: false, tracker: false, lsd: false, webSeeds: false })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      client.add(parsedTorrent, { store: MemoryChunkStore })\n\n      // The test above ensures that we can download the whole torrent over webseeds within a\n      // short time. Here, we wait the same amount of time and make sure no HTTP requests happen.\n      setTimeout(cb, WEB_SEED_TIMEOUT_MS)\n    }\n  ], err => {\n    t.error(err)\n    client.destroy(err => {\n      t.error(err, 'client destroyed')\n    })\n    httpServer.close(() => {\n      t.pass('http server closed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/extensions.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('extension support', t => {\n  t.plan(6)\n  let extendedHandshakes = 0\n\n  class Extension {\n    constructor (wire) {\n      wire.extendedHandshake.test = 'Hello, World!'\n    }\n\n    onExtendedHandshake (extendedHandshake) {\n      extendedHandshakes += 1\n\n      t.equal(\n        Buffer.from(extendedHandshake.test).toString(), 'Hello, World!',\n        'handshake.test === Hello, World!'\n      )\n\n      if (extendedHandshakes === 2) {\n        client1.destroy(err => {\n          t.error(err, 'client1 destroyed')\n        })\n        client2.destroy(err => {\n          t.error(err, 'client2 destroyed')\n        })\n      }\n    }\n  }\n\n  Extension.prototype.name = 'wt_test'\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  client1.add(fixtures.leaves.parsedTorrent, torrent1 => {\n    torrent1.on('wire', wire => {\n      t.pass('client1 onWire')\n      wire.use(Extension)\n    })\n    const torrent2 = client2.add(fixtures.leaves.parsedTorrent.infoHash)\n    torrent2.on('wire', wire => {\n      t.pass('client2 onWire')\n      wire.use(Extension)\n    })\n    torrent2.on('infoHash', () => {\n      torrent2.addPeer(`127.0.0.1:${client1.address().port}`)\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/limit-download-upload.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport WebTorrent from '../../index.js'\n\nconst DOWNLOAD_SPEED_LIMIT = 200 * 1000 // 200 KB/s\nconst UPLOAD_SPEED_LIMIT = 200 * 1000 // 200 KB/s\n\nfunction testSpeed (t, downloaderOpts, uploaderOpts, cb) {\n  const client1 = new WebTorrent({ dht: false, tracker: false, ...downloaderOpts })\n  const client2 = new WebTorrent({ dht: false, tracker: false, ...uploaderOpts })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  const downloadSpeeds = []\n  const uploadSpeeds = []\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent => {\n    torrent.on('upload', () => {\n      uploadSpeeds.push(torrent.uploadSpeed)\n    })\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    torrent.once('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n    })\n\n    torrent.on('download', () => {\n      downloadSpeeds.push(torrent.downloadSpeed)\n    })\n\n    torrent.on('done', () => {\n      cb(downloadSpeeds, uploadSpeeds)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n}\n\ntest('Limit download speed by constructor when tcp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, { downloadLimit: DOWNLOAD_SPEED_LIMIT }, {}, downloadSpeeds => {\n    t.ok(downloadSpeeds.every(downloadSpeed => downloadSpeed <= DOWNLOAD_SPEED_LIMIT))\n  })\n})\n\ntest('Limit upload speed by constructor when tcp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, {}, { uploadLimit: UPLOAD_SPEED_LIMIT }, (_, uploadSpeeds) => {\n    t.ok(uploadSpeeds.every(uploadSpeed => uploadSpeed <= UPLOAD_SPEED_LIMIT))\n  })\n})\n\ntest('Limit download speed by constructor when utp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, { utp: true, downloadLimit: DOWNLOAD_SPEED_LIMIT }, { utp: true }, downloadSpeeds => {\n    t.ok(downloadSpeeds.every(downloadSpeed => downloadSpeed <= DOWNLOAD_SPEED_LIMIT))\n  })\n})\n\ntest('Limit upload speed by constructor when utp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, { utp: true }, { utp: true, uploadLimit: UPLOAD_SPEED_LIMIT }, (_, uploadSpeeds) => {\n    t.ok(uploadSpeeds.every(uploadSpeed => uploadSpeed <= UPLOAD_SPEED_LIMIT))\n  })\n})\n"
  },
  {
    "path": "test/node/limit-methods.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport WebTorrent from '../../index.js'\n\nconst DOWNLOAD_SPEED_LIMIT = 200 * 1000 // 200 KB/s\nconst UPLOAD_SPEED_LIMIT = 200 * 1000 // 200 KB/s\n\nfunction testSpeed (t, downloaderOpts, uploaderOpts, cb) {\n  const { downloadLimit, ...restDownloaderOpts } = downloaderOpts\n  const { uploadLimit, ...restUploaderOpts } = uploaderOpts\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, ...restDownloaderOpts })\n  const client2 = new WebTorrent({ dht: false, tracker: false, ...restUploaderOpts })\n\n  if (downloadLimit) client1.throttleDownload(downloadLimit)\n  if (uploadLimit) client2.throttleUpload(uploadLimit)\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  const downloadSpeeds = []\n  const uploadSpeeds = []\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  }, torrent => {\n    torrent.on('upload', () => {\n      uploadSpeeds.push(torrent.uploadSpeed)\n    })\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    torrent.once('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n    })\n\n    torrent.on('download', () => {\n      downloadSpeeds.push(torrent.downloadSpeed)\n    })\n\n    torrent.on('done', () => {\n      cb(downloadSpeeds, uploadSpeeds)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n}\n\ntest('Limit download speed by methods when tcp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, { downloadLimit: DOWNLOAD_SPEED_LIMIT }, {}, downloadSpeeds => {\n    t.ok(downloadSpeeds.every(downloadSpeed => downloadSpeed <= DOWNLOAD_SPEED_LIMIT))\n  })\n})\n\ntest('Limit upload speed by methods when tcp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, {}, { uploadLimit: UPLOAD_SPEED_LIMIT }, (_, uploadSpeeds) => {\n    t.ok(uploadSpeeds.every(uploadSpeed => uploadSpeed <= UPLOAD_SPEED_LIMIT))\n  })\n})\n\ntest('Limit download speed by methods when utp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, { utp: true, downloadLimit: DOWNLOAD_SPEED_LIMIT }, { utp: true }, downloadSpeeds => {\n    t.ok(downloadSpeeds.every(downloadSpeed => downloadSpeed <= DOWNLOAD_SPEED_LIMIT))\n  })\n})\n\ntest('Limit upload speed by methods when utp connection', t => {\n  t.plan(3)\n\n  testSpeed(t, { utp: true }, { utp: true, uploadLimit: UPLOAD_SPEED_LIMIT }, (_, uploadSpeeds) => {\n    t.ok(uploadSpeeds.every(uploadSpeed => uploadSpeed <= UPLOAD_SPEED_LIMIT))\n  })\n})\n"
  },
  {
    "path": "test/node/metadata.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('ut_metadata transfer', t => {\n  t.plan(6)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  client1.on('torrent', torrent => {\n    t.pass('client1 emits torrent event') // even though it started with metadata\n    t.ok(torrent.metadata, 'metadata exists')\n  })\n\n  // client1 starts with metadata from torrent file\n  client1.add(fixtures.leaves.torrent)\n\n  client1.on('torrent', torrent1 => {\n    // TODO: remove these 2 lines once we replace airtap\n    fixtures.leaves.parsedTorrent.info.name = new Uint8Array(fixtures.leaves.parsedTorrent.info.name)\n    fixtures.leaves.parsedTorrent.info.pieces = new Uint8Array(fixtures.leaves.parsedTorrent.info.pieces)\n    t.deepEqual(torrent1.info, fixtures.leaves.parsedTorrent.info)\n\n    // client2 starts with infohash\n    const torrent2 = client2.add(fixtures.leaves.parsedTorrent.infoHash)\n\n    torrent2.on('infoHash', () => {\n      // manually add the peer\n      torrent2.addPeer(`127.0.0.1:${client1.address().port}`)\n\n      client2.on('torrent', () => {\n        t.deepEqual(torrent1.info, torrent2.info)\n\n        client1.destroy(err => {\n          t.error(err, 'client1 destroyed')\n        })\n        client2.destroy(err => {\n          t.error(err, 'client2 destroyed')\n        })\n      })\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/seed-stream.js",
    "content": "import { Readable } from 'stream'\nimport series from 'run-series'\nimport test from 'tape'\nimport { Server as Tracker } from 'bittorrent-tracker'\nimport WebTorrent from '../../index.js'\n\ntest('client.seed: stream', t => {\n  t.plan(8)\n\n  const tracker = new Tracker({ udp: false, ws: false })\n\n  tracker.on('error', err => { t.fail(err) })\n  tracker.on('warning', err => { t.fail(err) })\n\n  let seeder, client, announceUrl, magnetURI\n\n  series([\n    cb => {\n      tracker.listen(cb)\n    },\n\n    cb => {\n      const port = tracker.http.address().port\n      announceUrl = `http://localhost:${port}/announce`\n\n      seeder = new WebTorrent({ dht: false, lsd: false })\n\n      seeder.on('error', err => { t.fail(err) })\n      seeder.on('warning', err => { t.fail(err) })\n\n      const stream = new Readable()\n      stream._read = () => {}\n      stream.push('HELLO WORLD\\n')\n      stream.push(null)\n\n      const seederOpts = {\n        name: 'hello.txt',\n        pieceLength: 5,\n        announce: [announceUrl]\n      }\n      seeder.seed([stream], seederOpts, torrent => {\n        magnetURI = torrent.magnetURI\n        cb(null)\n      })\n    },\n\n    cb => {\n      client = new WebTorrent({ dht: false, lsd: false })\n\n      client.on('error', err => { t.fail(err) })\n      client.on('warning', err => { t.fail(err) })\n\n      client.add(magnetURI, async dl => {\n        t.equal(dl.files.length, 1)\n        t.equal(dl.files[0].name, 'hello.txt')\n        t.equal(dl.files[0].length, 12)\n        try {\n          const buf = await dl.files[0].arrayBuffer()\n          t.equal(Buffer.from(buf).toString('utf8'), 'HELLO WORLD\\n', 'content')\n        } catch (err) {\n          t.error(err)\n        }\n\n        cb(null)\n      })\n    }\n  ], err => {\n    t.error(err)\n    seeder.destroy(err => { t.error(err, 'seeder destroyed') })\n    client.destroy(err => { t.error(err, 'client destroyed') })\n    tracker.close(() => { t.pass('tracker closed') })\n  })\n})\n"
  },
  {
    "path": "test/node/seed-while-download.js",
    "content": "import fs from 'fs'\nimport { Server as DHT } from 'bittorrent-dht'\nimport fixtures from 'webtorrent-fixtures'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport series from 'run-series'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('Seed and download a file at the same time', t => {\n  t.plan(12)\n\n  const dhtServer = new DHT({ bootstrap: false })\n\n  dhtServer.on('error', err => { t.fail(err) })\n  dhtServer.on('warning', err => { t.fail(err) })\n\n  let client1, client2\n\n  series([\n    cb => {\n      dhtServer.listen(cb)\n    },\n\n    cb => {\n      let announced = false\n      let loaded = false\n\n      client1 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n\n      client1.on('error', err => { t.fail(err) })\n      client1.on('warning', err => { t.fail(err) })\n\n      const torrent = client1.add(fixtures.leaves.torrent, { store: MemoryChunkStore })\n\n      torrent.on('dhtAnnounce', () => {\n        t.pass('client1 finished dht announce')\n        announced = true\n        maybeDone()\n      })\n\n      torrent.load(fs.createReadStream(fixtures.leaves.contentPath), err => {\n        t.error(err, 'client1 started seeding')\n        loaded = true\n        maybeDone()\n      })\n\n      function maybeDone () {\n        if (announced && loaded) cb(null)\n      }\n    },\n\n    cb => {\n      let announced = false\n      let loaded = false\n\n      client2 = new WebTorrent({\n        tracker: false,\n        lsd: false,\n        dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` }\n      })\n\n      client2.on('error', err => { t.fail(err) })\n      client2.on('warning', err => { t.fail(err) })\n\n      const torrent = client2.add(fixtures.alice.torrent, { store: MemoryChunkStore })\n\n      torrent.on('dhtAnnounce', () => {\n        t.pass('client2 finished dht announce')\n        announced = true\n        maybeDone()\n      })\n\n      torrent.load(fs.createReadStream(fixtures.alice.contentPath), err => {\n        t.error(err, 'client2 started seeding')\n        loaded = true\n        maybeDone()\n      })\n\n      function maybeDone () {\n        if (announced && loaded) cb(null)\n      }\n    },\n\n    cb => {\n      let gotBuffer1 = false\n      let gotBuffer2 = false\n      let gotDone1 = false\n      let gotDone2 = false\n\n      client1.add(fixtures.alice.magnetURI, { store: MemoryChunkStore })\n\n      client1.on('torrent', async torrent => {\n        torrent.once('done', () => {\n          t.pass('client1 downloaded torrent from client2')\n          gotDone1 = true\n          maybeDone()\n        })\n\n        try {\n          const ab = await torrent.files[0].arrayBuffer()\n          t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.alice.content), 'client1 downloaded correct content')\n        } catch (err) {\n          t.error(err)\n        }\n\n        gotBuffer1 = true\n        maybeDone()\n      })\n\n      client2.add(fixtures.leaves.magnetURI, { store: MemoryChunkStore })\n\n      client2.on('torrent', async torrent => {\n        torrent.once('done', () => {\n          t.pass('client2 downloaded torrent from client1')\n          gotDone2 = true\n          maybeDone()\n        })\n\n        try {\n          const ab = await torrent.files[0].arrayBuffer()\n          t.deepEqual(new Uint8Array(ab), new Uint8Array(fixtures.leaves.content), 'client1 downloaded correct content')\n        } catch (err) {\n          t.error(err)\n        }\n\n        gotBuffer2 = true\n        maybeDone()\n      })\n\n      function maybeDone () {\n        if (gotBuffer1 && gotBuffer2 && gotDone1 && gotDone2) cb(null)\n      }\n    }\n\n  ], err => {\n    t.error(err)\n\n    client1.destroy(err => {\n      t.error(err, 'client1 destroyed')\n    })\n    client2.destroy(err => {\n      t.error(err, 'client2 destroyed')\n    })\n    dhtServer.destroy(err => {\n      t.error(err, 'dht server destroyed')\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/server.js",
    "content": "import fs from 'fs'\nimport fixtures from 'webtorrent-fixtures'\nimport get from 'simple-get'\nimport test from 'tape'\nimport WebTorrent from '../../index.js'\n\ntest('client.createServer: programmatic http server', t => {\n  t.plan(11)\n\n  const client = new WebTorrent({ tracker: false, dht: false, lsd: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  client.add(fixtures.leaves.torrent, torrent => {\n    t.pass('got \"torrent\" event')\n    const server = client.createServer()\n\n    server.listen(0, () => {\n      const port = server.address().port\n      t.pass(`server is listening on ${port}`)\n\n      let open = 2\n      const close = () => {\n        if (--open === 0) {\n          server.close(() => {\n            t.pass('server closed')\n          })\n          client.destroy(err => {\n            t.error(err, 'client destroyed')\n          })\n        }\n      }\n\n      // Seeding after server is created should work\n      torrent.load(fs.createReadStream(fixtures.leaves.contentPath), err => {\n        t.error(err, 'loaded seed content into torrent')\n        close()\n      })\n\n      const host = `http://localhost:${port}`\n      const path = `webtorrent/${torrent.infoHash}`\n\n      // Index page should list files in the torrent\n      get.concat(`${host}/${path}/`, (err, res, data) => {\n        t.error(err, `got http response for /${path}`)\n        data = data.toString()\n        t.ok(data.includes('Leaves of Grass by Walt Whitman.epub'))\n\n        // Verify file content for first (and only) file\n        get.concat(`${host}/${path}/${torrent.files[0].path}`, (err, res, data) => {\n          t.error(err, `got http response for /${path}/${torrent.files[0].path}`)\n          t.deepEqual(data, fixtures.leaves.content)\n\n          // test streamURL\n          get.concat(host + torrent.files[0].streamURL, (err, res, data) => {\n            t.error(err, `got http response for ${torrent.files[0].streamURL} via streamURL`)\n            t.deepEqual(data, fixtures.leaves.content)\n\n            close()\n          })\n        })\n      })\n    })\n  })\n})\n"
  },
  {
    "path": "test/node/swarm-basic.js",
    "content": "// var randombytes = require('randombytes')\n// var Swarm = require('../../lib/swarm')\n// var test = require('tape')\n\n// var infoHash = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'\n// var infoHash2 = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa37'\n// var peerId = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n// var peerId2 = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n\n// test('two swarms listen on same port', function (t) {\n//   t.plan(2)\n\n//   var swarm1 = new Swarm(infoHash, peerId)\n//   swarm1.listen(0, function () {\n//     var port = swarm1.address().port\n//     t.ok(typeof port === 'number' && port !== 0)\n\n//     var swarm2 = new Swarm(infoHash2, peerId)\n//     swarm2.listen(port, function () {\n//       t.equal(swarm2.address().port, port, 'listened on requested port')\n//       swarm1.destroy()\n//       swarm2.destroy()\n//     })\n//   })\n// })\n\n// test('swarm join', function (t) {\n//   t.plan(10)\n\n//   var swarm1 = new Swarm(infoHash, peerId)\n//   swarm1.listen(0, function () {\n//     var swarm2 = new Swarm(infoHash, peerId2)\n\n//     t.equal(swarm1.wires.length, 0)\n//     t.equal(swarm2.wires.length, 0)\n\n//     swarm2.addPeer('127.0.0.1:' + swarm1.address().port)\n\n//     swarm1.on('wire', function (wire, addr) {\n//       t.ok(wire, 'Peer join our swarm via listening port')\n\n//       t.equal(swarm1.wires.length, 1)\n//       t.ok(/127\\.0\\.0\\.1:\\d{1,5}/.test(addr))\n//       t.equal(wire.peerId.toString('hex'), peerId2)\n//     })\n\n//     swarm2.on('wire', function (wire, addr) {\n//       t.ok(wire, 'Joined swarm, got wire')\n\n//       t.equal(swarm2.wires.length, 1)\n//       t.ok(/127\\.0\\.0\\.1:\\d{1,5}/.test(addr))\n//       t.equal(wire.peerId.toString('hex'), peerId)\n//     })\n\n//     t.on('end', function () {\n//       swarm1.destroy()\n//       swarm2.destroy()\n//     })\n//   })\n// })\n"
  },
  {
    "path": "test/node/swarm-reconnect.js",
    "content": "// var randombytes = require('randombytes')\n// var Swarm = require('../../lib/swarm')\n// var test = require('tape')\n\n// var infoHash = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'\n// var peerId1 = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n// var peerId2 = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n\n// test('reconnect when peer disconnects', function (t) {\n//   t.plan(10)\n\n//   var swarm1 = new Swarm(infoHash, peerId1)\n//   swarm1.listen(0, function () {\n//     var swarm2 = new Swarm(infoHash, peerId2)\n\n//     var time1 = 0\n//     swarm1.on('wire', function (wire) {\n//       if (time1 === 0) {\n//         t.ok(wire, 'Peer joined via listening port')\n//         t.equal(swarm1.wires.length, 1)\n\n//         // at some point in future, end wire\n//         setTimeout(function () {\n//           wire.destroy()\n//         }, 100)\n\n//         // ...and prevent reconnect\n//         swarm1._drain = function () {}\n//       } else if (time1 === 1) {\n//         t.ok(wire, 'Remote peer reconnected')\n//         t.equal(swarm1.wires.length, 1)\n//       } else {\n//         throw new Error('too many wire events (1)')\n//       }\n//       time1 += 1\n//     })\n\n//     var time2 = 0\n//     swarm2.on('wire', function (wire) {\n//       if (time2 === 0) {\n//         t.ok(wire, 'Joined swarm, got wire')\n//         t.equal(swarm2.wires.length, 1)\n\n//         wire.on('end', function () {\n//           t.pass('Wire ended by remote peer')\n//           t.equal(swarm1.wires.length, 0)\n//         })\n//       } else if (time2 === 1) {\n//         t.ok(wire, 'Reconnected to remote peer')\n//         t.equal(swarm2.wires.length, 1)\n\n//         swarm1.destroy()\n//         swarm2.destroy()\n//       } else {\n//         throw new Error('too many wire events (2)')\n//       }\n//       time2 += 1\n//     })\n\n//     swarm2.addPeer('127.0.0.1:' + swarm1.address().port)\n//   })\n// })\n"
  },
  {
    "path": "test/node/swarm-timeout.js",
    "content": "// var randombytes = require('randombytes')\n// var Swarm = require('../../lib/swarm')\n// var test = require('tape')\n\n// var infoHash = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'\n// var peerId1 = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n// var peerId2 = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n\n// test('timeout if no handshake in 25 seconds', function (t) {\n//   t.plan(4)\n\n//   var swarm1 = new Swarm(infoHash, peerId1)\n\n//   var _addIncomingPeer = swarm1._addIncomingPeer\n//   swarm1._addIncomingPeer = function (peer) {\n//     // Nuke the handshake function on swarm1's peer to test swarm2's\n//     // handshake timeout code\n//     peer.wire.handshake = function () {}\n//     _addIncomingPeer.call(swarm1, peer)\n//   }\n\n//   swarm1.listen(0, function () {\n//     var swarm2 = new Swarm(infoHash, peerId2)\n\n//     var numWires = 0\n//     swarm1.on('wire', function (wire) {\n//       numWires += 1\n//       if (numWires === 1) {\n//         t.ok(wire, 'Got wire via listening port')\n//         t.equal(swarm1.wires.length, 1)\n\n//         // swarm2 should never get a wire since swarm1 refuses to send it a\n//         // handshake\n//         t.equal(swarm2.wires.length, 0)\n//       } else if (numWires === 2) {\n//         t.pass('swarm2 reconnected after timeout')\n//         swarm1.destroy()\n//         swarm2.destroy()\n//       } else {\n//         t.fail('got wire after destroy')\n//       }\n//     })\n\n//     swarm2.on('wire', function (wire) {\n//       t.fail('Should not get a wire because peer did not handshake')\n//     })\n\n//     swarm2.addPeer('127.0.0.1:' + swarm1.address().port)\n//   })\n// })\n"
  },
  {
    "path": "test/node/torrent-events.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport MemoryChunkStore from 'memory-chunk-store'\nimport randombytes from 'randombytes'\nimport WebTorrent from '../../index.js'\n\ntest('client.add: emit torrent events in order', t => {\n  t.plan(6)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  // Start seeding\n  client2.seed(fixtures.leaves.content, {\n    name: 'Leaves of Grass by Walt Whitman.epub',\n    announce: []\n  })\n\n  client2.on('listening', () => {\n    // Start downloading\n    const torrent = client1.add(fixtures.leaves.parsedTorrent.infoHash, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('done', () => {\n      t.equal(++order, 4)\n\n      client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n      client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n    })\n  })\n})\n\ntest('client.seed: emit torrent events in order', t => {\n  t.plan(6)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.seed(fixtures.leaves.content)\n\n  let order = 0\n\n  torrent.on('infoHash', () => {\n    t.equal(++order, 1)\n  })\n\n  torrent.on('metadata', () => {\n    t.equal(++order, 2)\n  })\n\n  torrent.on('ready', () => {\n    t.equal(++order, 3)\n  })\n\n  torrent.on('done', () => {\n    t.equal(++order, 4)\n  })\n  torrent.on('seed', () => {\n    t.equal(++order, 5)\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n\ntest('file.select: check multiple idle events', t => {\n  t.plan(5)\n\n  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: false, utp: false })\n\n  client1.on('error', err => { t.fail(err) })\n  client1.on('warning', err => { t.fail(err) })\n\n  client2.on('error', err => { t.fail(err) })\n  client2.on('warning', err => { t.fail(err) })\n\n  const fileA = Buffer.from(randombytes(16 * 1024).toString('hex'))\n  const fileB = Buffer.from(randombytes(16 * 1024).toString('hex'))\n\n  // Start seeding\n  client2.seed([fileA, fileB], { announce: [] }, seedTorrent => {\n    // Select only fileA (index 0)\n    const magnet = seedTorrent.magnetURI + '&so=0'\n\n    // Start downloading\n    const torrent = client1.add(magnet, { store: MemoryChunkStore })\n\n    let order = 0\n\n    torrent.on('infoHash', () => {\n      // Manually connect peers\n      torrent.addPeer(`127.0.0.1:${client2.address().port}`)\n      t.equal(++order, 1)\n    })\n\n    torrent.on('metadata', () => {\n      t.equal(++order, 2)\n    })\n\n    torrent.on('ready', () => {\n      t.equal(++order, 3)\n    })\n\n    torrent.on('idle', () => {\n      ++order\n\n      if (order === 4) {\n        torrent.files[1].select(0)\n      } else if (order === 5) {\n        client1.destroy(err => { t.error(err, 'client 1 destroyed') })\n        client2.destroy(err => { t.error(err, 'client 2 destroyed') })\n      }\n    })\n  })\n})\n"
  },
  {
    "path": "test/rarity-map.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport randombytes from 'randombytes'\nimport test from 'tape'\nimport Wire from 'bittorrent-protocol'\nimport Torrent from '../lib/torrent.js'\n\ntest('Rarity map usage', t => {\n  t.plan(16)\n\n  const numPieces = 4\n  const torrentId = Object.assign({}, fixtures.numbers.parsedTorrent, {\n    pieces: Array(numPieces)\n  })\n  const client = {\n    listening: true,\n    peerId: randombytes(20).toString('hex'),\n    torrentPort: 6889,\n    dht: false,\n    tracker: false,\n    lsd: false,\n    _remove () {}\n  }\n  const opts = {}\n  const torrent = new Torrent(torrentId, client, opts)\n  torrent.on('metadata', () => {\n    torrent._onWire(new Wire())\n    torrent._onWire(new Wire())\n\n    const rarityMap = torrent._rarityMap\n\n    // test initial / empty case\n    validateInitial()\n\n    rarityMap.recalculate()\n\n    // test initial / empty case after recalc\n    validateInitial()\n\n    setPiece(torrent.wires[0], 0)\n    setPiece(torrent.wires[1], 0)\n\n    setPiece(torrent.wires[0], 1)\n    setPiece(torrent.wires[1], 3)\n\n    // test rarest piece after setting pieces and handling 'have' events\n    let piece = rarityMap.getRarestPiece()\n    t.equal(piece, 2)\n\n    rarityMap.recalculate()\n\n    // test rarest piece after recalc to ensure its the same\n    piece = rarityMap.getRarestPiece()\n    t.equal(piece, 2)\n\n    addWire()\n    addWire()\n\n    // test rarest piece after adding wires\n    piece = rarityMap.getRarestPiece()\n    t.equal(piece, 3)\n\n    rarityMap.recalculate()\n\n    // test rarest piece after adding wires and recalc\n    piece = rarityMap.getRarestPiece()\n    t.equal(piece, 3)\n\n    removeWire(3)\n    removeWire(1)\n\n    // test rarest piece after removing wires\n    piece = rarityMap.getRarestPiece()\n    t.equal(piece, 3)\n\n    rarityMap.recalculate()\n\n    // test rarest piece after removing wires and recalc\n    piece = rarityMap.getRarestPiece()\n    t.equal(piece, 3)\n\n    // test piece filter func\n    piece = rarityMap.getRarestPiece(i => i <= 1)\n    t.equal(piece, 0)\n\n    piece = rarityMap.getRarestPiece(i => i === 1 || i === 2)\n    t.equal(piece, 2)\n\n    function validateInitial () {\n      // note that getRarestPiece will return a random piece since they're all equal\n      // so repeat the test several times to reasonably ensure its correctness.\n      let piece = rarityMap.getRarestPiece()\n      t.ok(piece >= 0 && piece < numPieces)\n\n      piece = rarityMap.getRarestPiece()\n      t.ok(piece >= 0 && piece < numPieces)\n\n      piece = rarityMap.getRarestPiece()\n      t.ok(piece >= 0 && piece < numPieces)\n\n      piece = rarityMap.getRarestPiece()\n      t.ok(piece >= 0 && piece < numPieces)\n    }\n\n    function setPiece (wire, index) {\n      wire.peerPieces.set(index)\n      wire.emit('have', index)\n    }\n\n    function addWire () {\n      const wire = new Wire()\n      wire.peerPieces.set(1)\n      wire.peerPieces.set(2)\n      torrent._onWire(wire)\n    }\n\n    function removeWire (index) {\n      const wire = torrent.wires.splice(index, 1)[0]\n      wire.destroy()\n    }\n  })\n\n  t.on('end', () => {\n    torrent.wires.forEach(wire => {\n      wire.destroy()\n    })\n    torrent.destroy()\n  })\n})\n"
  },
  {
    "path": "test/selections.js",
    "content": "import { Selections, isCoveringExisting, isInsideExisting, isLowerIntersecting, isUpperIntersecting } from '../lib/selections.js'\nimport test from 'tape'\n\nconst testCases = {\n  isLowerIntersecting: {\n    fn: isLowerIntersecting,\n    cases: [\n      { newItem: { from: 8, to: 12 }, existing: { from: 1, to: 10 }, expectedRemoveResult: [{ from: 1, to: 7 }] },\n      { newItem: { from: 10, to: 15 }, existing: { from: 1, to: 10 }, expectedRemoveResult: [{ from: 1, to: 9 }] }\n    ]\n  },\n  isUpperIntersecting: {\n    fn: isUpperIntersecting,\n    cases: [\n      { newItem: { from: 15, to: 22 }, existing: { from: 20, to: 25 }, expectedRemoveResult: [{ from: 23, to: 25 }] },\n      { newItem: { from: 15, to: 20 }, existing: { from: 20, to: 25 }, expectedRemoveResult: [{ from: 21, to: 25 }] }\n    ]\n  },\n  isInsideExisting: {\n    fn: isInsideExisting,\n    cases: [\n      { newItem: { from: 12, to: 15 }, existing: { from: 10, to: 20 }, expectedRemoveResult: [{ from: 10, to: 11 }, { from: 16, to: 20 }] },\n      { newItem: { from: 20, to: 20 }, existing: { from: 10, to: 20 }, expectedRemoveResult: [{ from: 10, to: 19 }] },\n      { newItem: { from: 15, to: 20 }, existing: { from: 10, to: 20 }, expectedRemoveResult: [{ from: 10, to: 14 }] }\n    ]\n  },\n  isCoveringExisting: {\n    fn: isCoveringExisting,\n    cases: [\n      { newItem: { from: 10, to: 21 }, existing: { from: 10, to: 20 }, expectedRemoveResult: [] },\n      { newItem: { from: 9, to: 20 }, existing: { from: 10, to: 20 }, expectedRemoveResult: [] },\n      { newItem: { from: 10, to: 20 }, existing: { from: 10, to: 20 }, expectedRemoveResult: [] },\n      { newItem: { from: 0, to: 986 }, existing: { from: 15, to: 986 }, expectedRemoveResult: [] }\n    ]\n  }\n}\n\ntest('Selections', (t) => {\n  for (const [functionName, { fn, cases }] of Object.entries(testCases)) {\n    for (const { newItem, existing } of cases) {\n      t.test(`should return true for newItem: ${toString(newItem)} and existing: ${toString(existing)} and everything else should be false`, (s) => {\n        t.equal(fn(newItem, existing), true)\n        for (const otherFn of Object.keys(testCases)) {\n          if (otherFn !== functionName) {\n            t.equal(testCases[otherFn].fn(newItem, existing), false)\n          }\n        }\n        s.end()\n      })\n    }\n  }\n\n  /** @type {Selections} */\n  let selection\n\n  for (const { cases } of Object.values(testCases)) {\n    for (const { newItem, existing, expectedRemoveResult } of cases) {\n      t.test(`should remove the given item: ${toString(newItem)} from existing selection: ${toString(existing)} and leave: ${toString(expectedRemoveResult)}`, (s) => {\n        selection = new Selections()\n        selection.insert(existing)\n        selection.remove(newItem)\n        assertArrayContentsEqual(t, selection._items, expectedRemoveResult)\n        s.end()\n      })\n    }\n  }\n\n  for (const { cases } of Object.values(testCases)) {\n    for (const { newItem, existing, expectedRemoveResult } of cases) {\n      t.test(`should truncate the existing item: ${toString(existing)} to prevent overlapping with the new selection: ${toString(newItem)}`, (s) => {\n        selection = new Selections()\n        selection.insert(existing)\n        selection.insert(newItem)\n        const expected = { from: Infinity, to: 0 }\n        for (const item of [...expectedRemoveResult, newItem]) {\n          expected.from = Math.min(expected.from, item.from)\n          expected.to = Math.max(expected.to, item.to)\n        }\n        assertArrayContentsEqual(t, selection._items, [expected])\n        s.end()\n      })\n    }\n  }\n\n  t.test('should insert large selection and truncate or delete existing selections', (s) => {\n    selection = new Selections()\n    selection.insert({ from: 5, to: 10 })\n    selection.insert({ from: 11, to: 19 })\n    selection.insert({ from: 20, to: 40 })\n\n    selection.insert({ from: 9, to: 25 })\n\n    assertArrayContentsEqual(t, selection._items, [{ from: 5, to: 40 }])\n    s.end()\n  })\n})\n\n/**\n * Converts a selection or an array of selections to a human-readable string\n * @param {{from: number, to: number} | Array<{from: number, to: number}>} param\n * @returns {string}\n */\nfunction toString (param) {\n  if (!Array.isArray(param)) {\n    const { from, to } = param\n    return `[${from}-${to}]`\n  }\n  return `[${param.map(toString).join(', ')}]`\n}\n\n/**\n * Asserts that the given arrays of selections have the same from-to pairs, regardless of order\n * @param {import('tape').Test} t\n * @param {Array<Selections>} actual\n * @param {Array<Selections>} expected\n */\nfunction assertArrayContentsEqual (t, actual, expected) {\n  t.equal(actual.length, expected.length)\n  // assert that both have the same items regardless of order\n  for (const item of actual) {\n    t.ok(expected.some(e => e.from === item.from && e.to === item.to))\n  }\n}\n"
  },
  {
    "path": "test/swarm.js",
    "content": "// var randombytes from 'randombytes')\n// var Swarm from '../lib/swarm')\n// var test from 'tape')\n\n// var infoHash = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'\n// var infoHash2 = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa37'\n// var peerId = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n// var peerId2 = Buffer.from('-WW0001-' + randombytes(6).toString('hex'), 'utf8').toString('hex')\n\n// test('create swarm, check invariants', function (t) {\n//   var swarm = new Swarm(infoHash, peerId)\n\n//   t.equal(swarm.infoHash.toString('hex'), infoHash)\n//   t.equal(swarm.peerId.toString('hex'), peerId)\n//   t.equal(swarm.downloaded, 0)\n//   t.equal(swarm.uploaded, 0)\n//   t.ok(Array.isArray(swarm.wires))\n//   t.equal(swarm.wires.length, 0)\n//   t.end()\n// })\n\n// test('swarm listen(0) selects free port', function (t) {\n//   t.plan(2)\n\n//   var swarm = new Swarm(infoHash, peerId)\n//   swarm.listen(0)\n//   swarm.on('listening', function () {\n//     var port = swarm.address().port\n//     t.equal(typeof port, 'number', 'port is a number')\n//     if (process.browser) {\n//       t.equal(port, 0, 'port number is 0')\n//     } else {\n//       t.ok(port > 0 && port < 65535, 'valid port number')\n//     }\n//     swarm.destroy()\n//   })\n// })\n\n// test('two swarms listen on same port (implicit)', function (t) {\n//   t.plan(5)\n\n//   // When no port is specified and listen is called twice, they should get assigned the same port.\n\n//   var swarm1 = new Swarm(infoHash, peerId)\n//   var swarm2 = new Swarm(infoHash2, peerId2)\n\n//   var swarm1Port\n//   var swarm2Port\n\n//   function maybeDone () {\n//     if (swarm1.listening && swarm2.listening) {\n//       t.equal(swarm1Port, swarm2Port, 'swarms were given same port')\n\n//       t.equal(typeof swarm1Port, 'number', 'port is a number')\n//       if (process.browser) {\n//         t.equal(swarm1Port, 0, 'port number is 0')\n//       } else {\n//         t.ok(swarm1Port > 0 && swarm1Port < 65535, 'valid port number')\n//       }\n\n//       t.equal(typeof swarm2Port, 'number', 'port is a number')\n//       if (process.browser) {\n//         t.equal(swarm2Port, 0, 'port number is 0')\n//       } else {\n//         t.ok(swarm2Port > 0 && swarm2Port < 65535, 'valid port number')\n//       }\n\n//       swarm1.destroy()\n//       swarm2.destroy()\n//     }\n//   }\n\n//   swarm1.listen(0, function () {\n//     swarm1Port = swarm1.address().port\n//     maybeDone()\n//   })\n\n//   swarm2.listen(0, function (port2) {\n//     swarm2Port = swarm2.address().port\n//     maybeDone()\n//   })\n// })\n"
  },
  {
    "path": "test/torrent-destroy.js",
    "content": "import fixtures from 'webtorrent-fixtures'\nimport test from 'tape'\nimport WebTorrent from '../index.js'\n\ntest('torrent.destroy: destroy and remove torrent', t => {\n  t.plan(5)\n\n  const client = new WebTorrent({ dht: false, tracker: false, lsd: false, natUpnp: false, natPmp: false })\n\n  client.on('error', err => { t.fail(err) })\n  client.on('warning', err => { t.fail(err) })\n\n  const torrent = client.add(fixtures.leaves.parsedTorrent.infoHash)\n  t.equal(client.torrents.length, 1)\n\n  torrent.on('infoHash', () => {\n    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)\n\n    torrent.destroy(err => { t.error(err, 'torrent destroyed') })\n    t.equal(client.torrents.length, 0)\n\n    client.destroy(err => { t.error(err, 'client destroyed') })\n  })\n})\n"
  },
  {
    "path": "version.cjs",
    "content": "// Exports package.json to work around \"with\" and \"assert\" for backwards compatability.\nmodule.exports = require('./package.json').version\n"
  }
]