diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..173a6f10
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+aar/* filter=lfs diff=lfs merge=lfs -text
+app/aar/* filter=lfs diff=lfs merge=lfs -text
diff --git a/.github/ISSUE_TEMPLATE/1-bug_report.yml b/.github/ISSUE_TEMPLATE/1-bug_report.yml
new file mode 100644
index 00000000..e2108e3e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/1-bug_report.yml
@@ -0,0 +1,166 @@
+name: Bug Report
+description: Let us know about an unexpected error, a crash, or an incorrect behavior.
+labels: ["Bug", "Android"]
+title: "Bug: "
+type: bug
+projects: ["futo-org/19"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ # Thank you for taking the time to fill out this bug report.
+
+ The [grayjay-android](https://github.com/futo-org/grayjay-android) issue tracker is reserved for issues relating to the Grayjay Android Application
+
+ For general usage questions, please see: [The Official FUTO Grayjay Zulip Channel](https://chat.futo.org/#narrow/stream/46-Grayjay)
+
+ ## Filing a bug report
+
+ To fix your issues faster, we need clear reproduction cases - ideally allowing us to make it happen locally.
+ * Please include all needed context. For example, Device, OS, Application, your Grayjay Configurations and Plugin versioning info.
+ * if you've found out a particular series of UI interactions can introduce buggy behavior, please label those steps 1-n with markdown
+
+ - type: textarea
+ id: reproduction-steps
+ attributes:
+ label: Reproduction steps
+ description: Please provide us with the steps to reproduce the issue if possible. This step makes a big difference if we are going to be able to fix it so be as precise as possible.
+ placeholder: |
+ 0. Play a Youtube video
+ 1. Press on Download button
+ 2. Select quality 1440p
+ 3. Grayjay crashes when attempting to download
+ validations:
+ required: true
+
+ - type: textarea
+ id: actual-result
+ attributes:
+ label: Actual result
+ description: What happend?
+ placeholder: Tell us what you saw!
+ validations:
+ required: true
+
+ - type: textarea
+ id: expected-result
+ attributes:
+ label: Expected result
+ description: What was suppose to happen?
+ placeholder: Tell us what you expected to happen!
+ validations:
+ required: true
+
+ - type: input
+ id: grayjay-version
+ attributes:
+ label: Grayjay Version
+ description: In the application, select More > Settings, scroll to the bottom and locate the value next to "Version Name".
+ placeholder: "311"
+ validations:
+ required: true
+
+ - type: dropdown
+ id: plugin
+ attributes:
+ label: What plugins are you seeing the problem on?
+ multiple: true
+ options:
+ - "All"
+ - "Apple Podcasts"
+ - "BiliBili (CN)"
+ - "Bitchute"
+ - "Crunchyroll"
+ - "CuriosityStream"
+ - "Dailymotion"
+ - "Kick"
+ - "Nebula"
+ - "Odysee"
+ - "Patreon"
+ - "PeerTube"
+ - "Rumble"
+ - "SoundCloud"
+ - "Spotify"
+ - "TedTalks"
+ - "Twitch"
+ - "Youtube"
+ - "Other"
+ validations:
+ required: true
+
+ - type: input
+ id: plugin-version
+ attributes:
+ label: Plugin Version
+ description: In the application, select Sources > [the broken plugin], write down the value under "Version".
+ placeholder: "12"
+
+ - type: input
+ id: android-version
+ attributes:
+ label: Which android version are you using?
+ placeholder: "Android 15"
+ validations:
+ required: true
+
+ - type: input
+ id: phone-model
+ attributes:
+ label: Which device are you using?
+ placeholder: "Google Pixel 9"
+ validations:
+ required: true
+
+ - type: input
+ id: os-version
+ attributes:
+ label: Which operating system are you using?
+ placeholder: "GrapheneOS/CalyxOS/Tizen/HyperOS 2/..."
+ validations:
+ required: true
+
+ - type: checkboxes
+ id: login
+ attributes:
+ label: When do you experience the issue?
+ options:
+ - label: While logged in
+ - label: While logged out
+ - label: N/A
+
+ - type: dropdown
+ id: vpn
+ attributes:
+ label: Are you using a VPN?
+ multiple: false
+ options:
+ - "No"
+ - "Yes"
+ validations:
+ required: true
+
+ - type: textarea
+ id: grayjay-references
+ attributes:
+ label: References
+ description: |
+ Are there any other GitHub issues, whether open or closed, that are related to the problem you've described above? If so, please create a list below that mentions each of them. For example:
+ ```
+ - #10
+ ```
+ placeholder:
+ value:
+ validations:
+ required: false
+
+ - type: textarea
+ id: logs
+ attributes:
+ label: Relevant log output
+ description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
+ render: shell
+
+ - type: markdown
+ attributes:
+ value: |
+ **Note:** If the submit button is disabled and you have filled out all required fields, please check that you did not forget a **Title** for the issue.
diff --git a/.github/ISSUE_TEMPLATE/2-feature_request.yml b/.github/ISSUE_TEMPLATE/2-feature_request.yml
new file mode 100644
index 00000000..2058150f
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/2-feature_request.yml
@@ -0,0 +1,59 @@
+name: Feature Request
+description: Suggest a new feature or other enhancement.
+labels: ["Enhancement", "Android"]
+title: "Feature request: "
+type: feature
+projects: ["futo-org/19"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ # Thank you for opening a feature request.
+
+ The [grayjay-android](https://github.com/futo-org/grayjay-android) issue tracker is reserved for issues and feature requests relating to the Grayjay android application
+
+ For discussion related to enhancements, please see: [The FUTO Grayjay Zulip Channel](https://chat.futo.org/#narrow/stream/46-Grayjay)
+
+ - type: textarea
+ id: grayjay-use-case
+ attributes:
+ label: Use Cases
+ description: |
+ In order to properly evaluate a feature request, it is necessary to understand the use cases for it. Please describe below the _end goal_ you are trying to achieve that has led you to request this feature. Please keep this section focused on the problem and not on the suggested solution.
+ placeholder:
+ value:
+ validations:
+ required: true
+
+ - type: textarea
+ id: grayjay-proposal
+ attributes:
+ label: Proposal
+ description: |
+ If you have an idea for a way to address the problem via a change to Grayjay features, please describe it below.
+
+ In this section, it's helpful to include specific examples of how what you are suggesting might look in the application, this allows us to understand the full picture of what you are proposing. If you're not sure of some details, don't worry! When we evaluate the feature request we may suggest modifications as necessary to work within the design constraints of the Grayjay Core Application.
+ placeholder:
+ value:
+ validations:
+ required: false
+
+ - type: textarea
+ id: grayjay-references
+ attributes:
+ label: References
+ description: |
+ Are there any other GitHub issues, whether open or closed, that are related to the problem you've described above or to the suggested solution? If so, please create a list below that mentions each of them. For example:
+ ```
+ - #10
+ ```
+ placeholder:
+ value:
+ validations:
+ required: false
+
+ - type: markdown
+ attributes:
+ value: |
+ **Note:** If the submit button is disabled and you have filled out all required fields, please check that you did not forget a **Title** for the issue.
+
diff --git a/.github/ISSUE_TEMPLATE/3-documentation_issue.yml b/.github/ISSUE_TEMPLATE/3-documentation_issue.yml
new file mode 100644
index 00000000..40d245dc
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/3-documentation_issue.yml
@@ -0,0 +1,66 @@
+name: Documentation Issue
+description: Report an issue or suggest a change in the documentation.
+labels: ["Documentation"]
+title: "Documentation: "
+type: task
+projects: ["futo-org/19"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ # Thank you for opening a documentation change request.
+
+ The [grayjay-android](https://github.com/futo-org/grayjay-android) issue tracker is reserved for issues relating to the Grayjay android application. Use the `Documentation` issue type to report problems with the documentation in our code repositories, inside the application, or on [https://grayjay.app](https://grayjay.app)
+ Technical writers monitor this issue type, so report Grayjay bugs or feature requests with the `Bug report` or `Feature Request` issue types instead to get engineering attention.
+
+ For general usage questions, please see: [The Official FUTO Grayjay Zulip Channel](https://chat.futo.org/#narrow/stream/46-Grayjay)
+
+ - type: textarea
+ id: grayjay-affected-pages
+ attributes:
+ label: Affected Pages
+ description: |
+ Link to or describe the pages relevant to your documentation change request.
+ placeholder:
+ value:
+ validations:
+ required: false
+
+ - type: textarea
+ id: grayjay-problem
+ attributes:
+ label: What is the docs issue?
+ description: What problems or suggestions do you have about the documentation?
+ placeholder:
+ value:
+ validations:
+ required: true
+
+ - type: textarea
+ id: grayjay-proposal
+ attributes:
+ label: Proposal
+ description: What documentation changes would fix this issue and where would you expect to find them? Are one or more page headings unclear? Do one or more pages need additional context, examples, or warnings? Do we need a new page or section dedicated to a specific topic? Your ideas help us understand what you and other users need from our documentation and how we can improve the content.
+ placeholder:
+ value:
+ validations:
+ required: false
+
+ - type: textarea
+ id: grayjay-references
+ attributes:
+ label: References
+ description: |
+ Are there any other open or closed GitLab/GitHub issues related to the problem or solution you described? If so, list them below. For example:
+ ```
+ - #6017
+ ```
+ placeholder:
+ value:
+ validations:
+ required: false
+
+ - type: markdown
+ attributes:
+ value: |
+ **Note:** If the submit button is disabled and you have filled out all required fields, please check that you did not forget a **Title** for the issue.
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 00000000..1f51bd8f
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,8 @@
+blank_issues_enabled: false
+contact_links:
+ - name: Need a Grayjay License?
+ url: https://pay.futo.org/api/PaymentPortal
+ about: Purchase a Grayjay license with FutoPay
+ - name: Plugin Building, Usage, or other Questions
+ url: https://chat.futo.org/#narrow/stream/46-Grayjay
+ about: Grayjays Community Chat
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index 2e67308c..00037939 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -64,3 +64,45 @@
[submodule "app/src/stable/assets/sources/bilibili"]
path = app/src/stable/assets/sources/bilibili
url = ../plugins/bilibili.git
+[submodule "app/src/stable/assets/sources/spotify"]
+ path = app/src/stable/assets/sources/spotify
+ url = ../plugins/spotify.git
+[submodule "app/src/unstable/assets/sources/spotify"]
+ path = app/src/unstable/assets/sources/spotify
+ url = ../plugins/spotify.git
+[submodule "app/src/stable/assets/sources/bitchute"]
+ path = app/src/stable/assets/sources/bitchute
+ url = ../plugins/bitchute.git
+[submodule "app/src/unstable/assets/sources/bitchute"]
+ path = app/src/unstable/assets/sources/bitchute
+ url = ../plugins/bitchute.git
+[submodule "app/src/unstable/assets/sources/dailymotion"]
+ path = app/src/unstable/assets/sources/dailymotion
+ url = ../plugins/dailymotion.git
+[submodule "app/src/stable/assets/sources/dailymotion"]
+ path = app/src/stable/assets/sources/dailymotion
+ url = ../plugins/dailymotion.git
+[submodule "app/src/stable/assets/sources/apple-podcast"]
+ path = app/src/stable/assets/sources/apple-podcasts
+ url = ../plugins/apple-podcasts.git
+[submodule "app/src/unstable/assets/sources/apple-podcasts"]
+ path = app/src/unstable/assets/sources/apple-podcasts
+ url = ../plugins/apple-podcasts.git
+[submodule "app/src/stable/assets/sources/tedtalks"]
+ path = app/src/stable/assets/sources/tedtalks
+ url = ../plugins/tedtalks.git
+[submodule "app/src/unstable/assets/sources/tedtalks"]
+ path = app/src/unstable/assets/sources/tedtalks
+ url = ../plugins/tedtalks.git
+[submodule "app/src/stable/assets/sources/curiositystream"]
+ path = app/src/stable/assets/sources/curiositystream
+ url = ../plugins/curiositystream.git
+[submodule "app/src/unstable/assets/sources/curiositystream"]
+ path = app/src/unstable/assets/sources/curiositystream
+ url = ../plugins/curiositystream.git
+[submodule "app/src/unstable/assets/sources/crunchyroll"]
+ path = app/src/unstable/assets/sources/crunchyroll
+ url = ../plugins/crunchyroll.git
+[submodule "app/src/stable/assets/sources/crunchyroll"]
+ path = app/src/stable/assets/sources/crunchyroll
+ url = ../plugins/crunchyroll.git
diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md
index 23cc959e..8af2e2f5 100644
--- a/CONTRIBUTION.md
+++ b/CONTRIBUTION.md
@@ -49,9 +49,23 @@ We encourage developers to write their own plugins. Please refer to the "Getting
## Contributing to Core
-**We are currently not accepting contributions to the core.**
-The core is currently licensed under the FUTO Temporary License (FTL). The licensing and ownership of contributions to the core are complex topics that we are still working on. We'll update these guidelines when we have more clarity.
+### License
+
+The core is currently licensed under the [Source First License 1.1](./LICENSE.md). All contributors have to sign FUTO Individual Contributor License Agreement before contributions can be accepted. You can read more about it at [https://cla.futo.org/](https://cla.futo.org/).
+
+### How to Contribute
+
+1. Fork the core repository.
+2. Clone your fork.
+3. Make your changes.
+4. Commit and push your changes.
+5. Open a pull request.
+
+### Guidelines
+
+- Ensure your code adheres to the existing style.
+- Include documentation and unit tests (where applicable).
---
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index a3d0f019..00000000
--- a/LICENSE
+++ /dev/null
@@ -1,32 +0,0 @@
-# FUTO TEMPORARY LICENSE
-This license grants you the rights, and only the rights, set out below in respect of the source code provided. If you take advantage of these rights, you accept this license. If you do not accept the license, do not access the code.
-
-Words used in the Terms of Service have the same meaning in this license. Where there is any inconsistency between this license and those Terms of Service, these terms prevail.
-
-## Section 1: Definitions
-- "code" means the source code made available from time, in our sole discretion, for access under this license. Reference to code in this license means the code and any part of it and any derivative of it.
-- “compilation” means to compile the code from ‘source code’ to ‘machine code’.
-- "defect" means a defect, bug, backdoor, security issue or other deficiency in the code.
-- “non-commercial distribution” means distribution of the code or any compilation of the code, or of any other application or program containing the code or any compilation of the code, where such distribution is not intended for or directed towards commercial advantage or monetary compensation.
-- "review" means to access, analyse, test and otherwise review the code as a reference, for the sole purpose of analysing it for defects.
-- "you" means the licensee of rights set out in this license.
-
-## Section 2: Grant of Rights
-1. Subject to the terms of this license, we grant you a non-transferable, non-exclusive, worldwide, royalty-free license to access and use the code solely for the purposes of review, compilation and non-commercial distribution.
-2. You may provide the code to anyone else and publish excerpts of it for the purposes of review, compilation and non-commercial distribution, provided that when you do so you make any recipient of the code aware of the terms of this license, they must agree to be bound by the terms of this license and you must attribute the code to the provider.
-3. Other than in respect of those parts of the code that were developed by other parties and as specified strictly in accordance with the open source and other licenses under which those parts of the code have been made available, as set out on our website or in those items of code, you are not entitled to use or do anything with the code for any commercial or other purpose, other than review, compilation and non-commercial distribution in accordance with the terms of this license.
-4. Subject to the terms of this license, you must at all times comply with and shall be bound by our Terms of Use, Privacy and Data Policy.
-
-## Section 3: Limitations
-1. This license does not grant you any rights to use the provider's name, logo, or trademarks and you must not in any way indicate you are authorised to speak on behalf of the provider.
-2. If you issue proceedings in any jurisdiction against the provider because you consider the provider has infringed copyright or any patent right in respect of the code (including any joinder or counterclaim), your license to the code is automatically terminated.
-3. THE CODE IS MADE AVAILABLE "AS-IS" AND WITHOUT ANY EXPRESS OR IMPLIED GUARANTEES AS TO FITNESS, MERCHANTABILITY, NON-INFRINGEMENT OR OTHERWISE. IT IS NOT BEING PROVIDED IN TRADE BUT ON A VOLUNTARY BASIS ON OUR PART AND IS NOT MADE AVAILABLE FOR ANY USE OUTSIDE THE TERMS OF THIS LICENSE. ANYONE ACCESSING THE CODE MUST ENSURE THEY HAVE THE REQUISITE EXPERTISE TO SECURE THEIR OWN SYSTEM AND DEVICES AND TO ACCESS AND USE THE CODE IN ACCORDANCE WITH THE TERMS OF THIS LICENSE. YOU BEAR THE RISK OF ACCESSING AND USING THE CODE. IN PARTICULAR, THE PROVIDER BEARS NO LIABILITY FOR ANY INTERFERENCE WITH OR ADVERSE EFFECT ON YOUR SYSTEM OR DEVICES AS A RESULT OF YOUR ACCESSING AND USING THE CODE IN ACCORDANCE WITH THE TERMS OF THIS LICENSE OR OTHERWISE.
-
-## Section 4: Termination, suspension and variation
-1. We may suspend, terminate or vary the terms of this license and any access to the code at any time, without notice, for any reason or no reason, in respect of any licensee, group of licensees or all licensees including as may be applicable any sub-licensees.
-
-## Section 5: General
-1. This license and its interpretation and operation are governed solely by the local law. You agree to submit to the exclusive jurisdiction of the local arbitral tribunals as further described in our Terms of Service and you agree not to raise any jurisdictional issue if we need to enforce an arbitral award or judgment in our jurisdiction or another country.
-2. Questions and comments regarding this license are welcomed and should be addressed at https://chat.futo.org/login/.
-
-Last updated 7 June 2023.
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 00000000..2cc664ad
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,43 @@
+# Source First License 1.1
+
+## Acceptance
+By using the software, you agree to all of the terms and conditions below.
+
+## Copyright License
+FUTO Holdings, Inc. (the “Licensor”) grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations below.
+
+## Limitations
+You may use or modify the software only for non-commercial purposes such as personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, all without any anticipated commercial application.
+
+You may distribute the software or provide it to others only if you do so free of charge for non-commercial purposes.
+
+Notwithstanding the above, you may not remove or obscure any functionality in the software related to payment to the Licensor in any copy you distribute to others.
+
+You may not alter, remove, or obscure any licensing, copyright, or other notices of the Licensor in the software. Any use of the Licensor’s trademarks is subject to applicable law.
+
+## Patents
+If you make any written claim that the software infringes or contributes to infringement of any patent, your license for the software granted under these terms ends immediately. If your company makes such a claim, your license ends immediately for work on behalf of your company.
+
+## Notices
+You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. If you modify the software, you must include in any modified copies of the software a prominent notice stating that you have modified the software, such as but not limited to, a statement in a readme file or an in-application about section.
+
+## Fair Use
+You may have "fair use" rights for the software under the law. These terms do not limit them.
+
+## No Other Rights
+These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the Licensor from granting licenses to anyone else. These terms do not imply any other licenses.
+
+## Termination
+If you use the software in violation of these terms, such use is not licensed, and your license will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your license will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your license to terminate automatically and permanently.
+
+## No Liability
+As far as the law allows, the software comes as is, without any warranty or condition, and the Licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
+
+## Definitions
+- The “Licensor” is the entity offering these terms, FUTO Holdings, Inc.
+- The “software” is the software the licensor makes available under these terms, including any portion of it.
+- “You” refers to the individual or entity agreeing to these terms.
+- “Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. Control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
+- “Your license” is the license granted to you for the software under these terms.
+- “Use” means anything you do with the software requiring your license.
+- “Trademark” means trademarks, service marks, and similar rights.
diff --git a/README.md b/README.md
index 263689a2..b05b5b82 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,8 @@ technologies that frustrate centralization and industry consolidation.
-  |
-  |
+  |
+  |
Video |
@@ -24,12 +24,10 @@ The FUTO media app is a player that exposes multiple video websites as sources i
-  |
-  |
+  |
- Sources (all enabled) |
- Sources (one disabled) |
+ Sources |
@@ -38,7 +36,7 @@ Additional sources can also be installed. These sources are JavaScript sources,
 |
-  |
+  |
Install a new source |
@@ -54,8 +52,8 @@ When a user enters a search term into the search bar, the query is posted to th
-  |
-  |
+  |
+  |
Search (list) |
@@ -71,7 +69,7 @@ Creators are able to configure their profile using NeoPass.
-  |
+  |
Channel |
@@ -112,7 +110,7 @@ The app offers a lot of settings customizing how the app looks and feels. An exa
-  |
+  |
Settings |
@@ -125,8 +123,8 @@ Playlists allow you to make a collection of videos that you can create and custo
-  |
-  |
+  |
+  |
Playlists |
@@ -142,7 +140,7 @@ Both individual videos and playlists can be downloaded for local, offline playba
-  |
+  |
Downloads |
@@ -157,7 +155,7 @@ For more information about casting please click [here](./docs/casting.md).
-  |
+  |
Casting |
@@ -182,6 +180,12 @@ In the future we hope to offer users the choice of their desired recommendation
1. Download a copy of the repository.
2. Open the project in Android Studio: Once the repository is cloned, you can open it in Android Studio by selecting "Open an Existing Project" from the welcome screen and navigating to the directory where you cloned the repository.
+3. Open the terminal in Android Studio by clicking on the terminal icon on bottom left and run the following command:
+
+```sh
+git submodule update --init --recursive
+```
+
3. Build the project: With the project open in Android Studio, you can build it by selecting "Build > Make Project" from the main menu. This will compile the code and generate an APK file that you can install on your device or emulator.
4. Run the project: To run the project, select "Run > Run 'app'" from the main menu. This will launch the app on your device or emulator, allowing you to test it and make any necessary changes.
@@ -199,7 +203,6 @@ Create a tag on the master branch, incrementing the last version number by 1 (fo
Click on the CI/CD tab, you should now see the tests and build are in progress. If the build succeeds the last step will become available. The last step is a manual action which can be triggered by clicking the run button on the action. This action will deploy the build to all users using the app through auto-update.
-
## Documentation
The documentation can be found [here](https://gitlab.futo.org/videostreaming/documents/-/wikis/API-Overview).
diff --git a/app/aar/ffmpeg-kit-full-6.0-2.LTS.aar b/app/aar/ffmpeg-kit-full-6.0-2.LTS.aar
new file mode 100644
index 00000000..27b62b35
--- /dev/null
+++ b/app/aar/ffmpeg-kit-full-6.0-2.LTS.aar
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ea10d3c5562c9f449a4e89e9c3dfcf881ed79a952f3409bc005bcc62c2cf4b81
+size 65512557
diff --git a/app/build.gradle b/app/build.gradle
index ecde6342..25d458d4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,7 +2,7 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.21'
- id 'org.ajoberstar.grgit' version '1.7.2'
+ id 'org.ajoberstar.grgit' version '5.2.2'
id 'com.google.protobuf'
id 'kotlin-parcelize'
id 'com.google.devtools.ksp'
@@ -144,9 +144,20 @@ android {
buildFeatures {
buildConfig true
}
+ sourceSets {
+ main {
+ assets {
+ srcDirs 'src/main/assets', 'src/tests/assets', 'src/test/assets'
+ }
+ }
+ }
}
dependencies {
+ implementation 'com.google.dagger:dagger:2.48'
+ implementation 'androidx.test:monitor:1.7.2'
+ implementation 'com.google.android.material:material:1.12.0'
+ annotationProcessor 'com.google.dagger:dagger-compiler:2.48'
//Core
implementation 'androidx.core:core-ktx:1.12.0'
@@ -170,6 +181,7 @@ dependencies {
//JS
implementation("com.caoccao.javet:javet-android:3.0.2")
+ //implementation 'com.caoccao.javet:javet-v8-android:4.1.4' //Change after extensive testing the freezing edge cases are solved.
//Exoplayer
implementation 'androidx.media3:media3-exoplayer:1.2.1'
@@ -184,11 +196,11 @@ dependencies {
implementation 'androidx.media:media:1.7.0'
//Other
- implementation 'org.jmdns:jmdns:3.5.1'
implementation 'org.jsoup:jsoup:1.15.3'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
- implementation 'com.arthenica:ffmpeg-kit-full:5.1'
+ implementation fileTree(dir: 'aar', include: ['*.aar'])
+ implementation 'com.arthenica:smart-exception-java:0.2.1'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.9.0'
implementation 'com.github.dhaval2404:imagepicker:2.1'
implementation 'com.google.zxing:core:3.4.1'
diff --git a/app/src/androidTest/java/com/futo/platformplayer/CSSColorTests.kt b/app/src/androidTest/java/com/futo/platformplayer/CSSColorTests.kt
new file mode 100644
index 00000000..66686260
--- /dev/null
+++ b/app/src/androidTest/java/com/futo/platformplayer/CSSColorTests.kt
@@ -0,0 +1,38 @@
+package com.futo.platformplayer
+
+import android.graphics.Color
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import toAndroidColor
+
+class CSSColorTests {
+ @Test
+ fun test1() {
+ val androidHex = "#80336699"
+ val androidColorInt = Color.parseColor(androidHex)
+
+ val cssHex = "#33669980"
+ val cssColor = CSSColor.parseColor(cssHex)
+
+ assertEquals(
+ "CSSColor($cssHex).toAndroidColor() should equal Color.parseColor($androidHex)",
+ androidColorInt,
+ cssColor.toAndroidColor(),
+ )
+ }
+
+ @Test
+ fun test2() {
+ val androidHex = "#123ABC"
+ val androidColorInt = Color.parseColor(androidHex)
+
+ val cssHex = "#123ABCFF"
+ val cssColor = CSSColor.parseColor(cssHex)
+
+ assertEquals(
+ "CSSColor($cssHex).toAndroidColor() should equal Color.parseColor($androidHex)",
+ androidColorInt,
+ cssColor.toAndroidColor()
+ )
+ }
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/futo/platformplayer/SyncServerTests.kt b/app/src/androidTest/java/com/futo/platformplayer/SyncServerTests.kt
new file mode 100644
index 00000000..f3e12645
--- /dev/null
+++ b/app/src/androidTest/java/com/futo/platformplayer/SyncServerTests.kt
@@ -0,0 +1,338 @@
+package com.futo.platformplayer
+
+import com.futo.platformplayer.noise.protocol.Noise
+import com.futo.platformplayer.sync.internal.*
+import kotlinx.coroutines.*
+import kotlinx.coroutines.selects.select
+import org.junit.Assert.*
+import org.junit.Test
+import java.net.Socket
+import java.nio.ByteBuffer
+import kotlin.random.Random
+import kotlin.time.Duration.Companion.milliseconds
+import kotlin.time.Duration.Companion.seconds
+/*
+class SyncServerTests {
+
+ //private val relayHost = "relay.grayjay.app"
+ //private val relayKey = "xGbHRzDOvE6plRbQaFgSen82eijF+gxS0yeUaeEErkw="
+ private val relayKey = "XlUaSpIlRaCg0TGzZ7JYmPupgUHDqTZXUUBco2K7ejw="
+ private val relayHost = "192.168.1.138"
+ private val relayPort = 9000
+
+ /** Creates a client connected to the live relay server. */
+ private suspend fun createClient(
+ onHandshakeComplete: ((SyncSocketSession) -> Unit)? = null,
+ onData: ((SyncSocketSession, UByte, UByte, ByteBuffer) -> Unit)? = null,
+ onNewChannel: ((SyncSocketSession, ChannelRelayed) -> Unit)? = null,
+ isHandshakeAllowed: ((LinkType, SyncSocketSession, String, String?, UInt) -> Boolean)? = null,
+ onException: ((Throwable) -> Unit)? = null
+ ): SyncSocketSession = withContext(Dispatchers.IO) {
+ val p = Noise.createDH("25519")
+ p.generateKeyPair()
+ val socket = Socket(relayHost, relayPort)
+ val inputStream = LittleEndianDataInputStream(socket.getInputStream())
+ val outputStream = LittleEndianDataOutputStream(socket.getOutputStream())
+ val tcs = CompletableDeferred()
+ val socketSession = SyncSocketSession(
+ relayHost,
+ p,
+ inputStream,
+ outputStream,
+ onClose = { socket.close() },
+ onHandshakeComplete = { s ->
+ onHandshakeComplete?.invoke(s)
+ tcs.complete(true)
+ },
+ onData = onData ?: { _, _, _, _ -> },
+ onNewChannel = onNewChannel ?: { _, _ -> },
+ isHandshakeAllowed = isHandshakeAllowed ?: { _, _, _, _, _ -> true }
+ )
+ socketSession.authorizable = AlwaysAuthorized()
+ try {
+ socketSession.startAsInitiator(relayKey)
+ } catch (e: Throwable) {
+ onException?.invoke(e)
+ }
+ withTimeout(5000.milliseconds) { tcs.await() }
+ return@withContext socketSession
+ }
+
+ @Test
+ fun multipleClientsHandshake_Success() = runBlocking {
+ val client1 = createClient()
+ val client2 = createClient()
+ assertNotNull(client1.remotePublicKey, "Client 1 handshake failed")
+ assertNotNull(client2.remotePublicKey, "Client 2 handshake failed")
+ client1.stop()
+ client2.stop()
+ }
+
+ @Test
+ fun publishAndRequestConnectionInfo_Authorized_Success() = runBlocking {
+ val clientA = createClient()
+ val clientB = createClient()
+ val clientC = createClient()
+ clientA.publishConnectionInformation(arrayOf(clientB.localPublicKey), 12345, true, true, true, true)
+ delay(100.milliseconds)
+ val infoB = clientB.requestConnectionInfo(clientA.localPublicKey)
+ val infoC = clientC.requestConnectionInfo(clientA.localPublicKey)
+ assertNotNull("Client B should receive connection info", infoB)
+ assertEquals(12345.toUShort(), infoB!!.port)
+ assertNull("Client C should not receive connection info (unauthorized)", infoC)
+ clientA.stop()
+ clientB.stop()
+ clientC.stop()
+ }
+
+ @Test
+ fun relayedTransport_Bidirectional_Success() = runBlocking {
+ val tcsA = CompletableDeferred()
+ val tcsB = CompletableDeferred()
+ val clientA = createClient(onNewChannel = { _, c -> tcsA.complete(c) })
+ val clientB = createClient(onNewChannel = { _, c -> tcsB.complete(c) })
+ val channelTask = async { clientA.startRelayedChannel(clientB.localPublicKey) }
+ val channelA = withTimeout(5000.milliseconds) { tcsA.await() }
+ channelA.authorizable = AlwaysAuthorized()
+ val channelB = withTimeout(5000.milliseconds) { tcsB.await() }
+ channelB.authorizable = AlwaysAuthorized()
+ channelTask.await()
+
+ val tcsDataB = CompletableDeferred()
+ channelB.setDataHandler { _, _, o, so, d ->
+ val b = ByteArray(d.remaining())
+ d.get(b)
+ if (o == Opcode.DATA.value && so == 0u.toUByte()) tcsDataB.complete(b)
+ }
+ channelA.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(byteArrayOf(1, 2, 3)))
+
+ val tcsDataA = CompletableDeferred()
+ channelA.setDataHandler { _, _, o, so, d ->
+ val b = ByteArray(d.remaining())
+ d.get(b)
+ if (o == Opcode.DATA.value && so == 0u.toUByte()) tcsDataA.complete(b)
+ }
+ channelB.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(byteArrayOf(4, 5, 6)))
+
+ val receivedB = withTimeout(5000.milliseconds) { tcsDataB.await() }
+ val receivedA = withTimeout(5000.milliseconds) { tcsDataA.await() }
+ assertArrayEquals(byteArrayOf(1, 2, 3), receivedB)
+ assertArrayEquals(byteArrayOf(4, 5, 6), receivedA)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun relayedTransport_MaximumMessageSize_Success() = runBlocking {
+ val MAX_DATA_PER_PACKET = SyncSocketSession.MAXIMUM_PACKET_SIZE - SyncSocketSession.HEADER_SIZE - 8 - 16 - 16
+ val maxSizeData = ByteArray(MAX_DATA_PER_PACKET).apply { Random.nextBytes(this) }
+ val tcsA = CompletableDeferred()
+ val tcsB = CompletableDeferred()
+ val clientA = createClient(onNewChannel = { _, c -> tcsA.complete(c) })
+ val clientB = createClient(onNewChannel = { _, c -> tcsB.complete(c) })
+ val channelTask = async { clientA.startRelayedChannel(clientB.localPublicKey) }
+ val channelA = withTimeout(5000.milliseconds) { tcsA.await() }
+ channelA.authorizable = AlwaysAuthorized()
+ val channelB = withTimeout(5000.milliseconds) { tcsB.await() }
+ channelB.authorizable = AlwaysAuthorized()
+ channelTask.await()
+
+ val tcsDataB = CompletableDeferred()
+ channelB.setDataHandler { _, _, o, so, d ->
+ val b = ByteArray(d.remaining())
+ d.get(b)
+ if (o == Opcode.DATA.value && so == 0u.toUByte()) tcsDataB.complete(b)
+ }
+ channelA.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(maxSizeData))
+ val receivedData = withTimeout(5000.milliseconds) { tcsDataB.await() }
+ assertArrayEquals(maxSizeData, receivedData)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun publishAndGetRecord_Success() = runBlocking {
+ val clientA = createClient()
+ val clientB = createClient()
+ val clientC = createClient()
+ val data = byteArrayOf(1, 2, 3)
+ val success = clientA.publishRecords(listOf(clientB.localPublicKey), "testKey", data)
+ val recordB = clientB.getRecord(clientA.localPublicKey, "testKey")
+ val recordC = clientC.getRecord(clientA.localPublicKey, "testKey")
+ assertTrue(success)
+ assertNotNull(recordB)
+ assertArrayEquals(data, recordB!!.first)
+ assertNull("Unauthorized client should not access record", recordC)
+ clientA.stop()
+ clientB.stop()
+ clientC.stop()
+ }
+
+ @Test
+ fun getNonExistentRecord_ReturnsNull() = runBlocking {
+ val clientA = createClient()
+ val clientB = createClient()
+ val record = clientB.getRecord(clientA.localPublicKey, "nonExistentKey")
+ assertNull("Getting non-existent record should return null", record)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun updateRecord_TimestampUpdated() = runBlocking {
+ val clientA = createClient()
+ val clientB = createClient()
+ val key = "updateKey"
+ val data1 = byteArrayOf(1)
+ val data2 = byteArrayOf(2)
+ clientA.publishRecords(listOf(clientB.localPublicKey), key, data1)
+ val record1 = clientB.getRecord(clientA.localPublicKey, key)
+ delay(1000.milliseconds)
+ clientA.publishRecords(listOf(clientB.localPublicKey), key, data2)
+ val record2 = clientB.getRecord(clientA.localPublicKey, key)
+ assertNotNull(record1)
+ assertNotNull(record2)
+ assertTrue(record2!!.second > record1!!.second)
+ assertArrayEquals(data2, record2.first)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun deleteRecord_Success() = runBlocking {
+ val clientA = createClient()
+ val clientB = createClient()
+ val data = byteArrayOf(1, 2, 3)
+ clientA.publishRecords(listOf(clientB.localPublicKey), "toDelete", data)
+ val success = clientB.deleteRecords(clientA.localPublicKey, clientB.localPublicKey, listOf("toDelete"))
+ val record = clientB.getRecord(clientA.localPublicKey, "toDelete")
+ assertTrue(success)
+ assertNull(record)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun listRecordKeys_Success() = runBlocking {
+ val clientA = createClient()
+ val clientB = createClient()
+ val keys = arrayOf("key1", "key2", "key3")
+ keys.forEach { key ->
+ clientA.publishRecords(listOf(clientB.localPublicKey), key, byteArrayOf(1))
+ }
+ val listedKeys = clientB.listRecordKeys(clientA.localPublicKey, clientB.localPublicKey)
+ assertArrayEquals(keys, listedKeys.map { it.first }.toTypedArray())
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun singleLargeMessageViaRelayedChannel_Success() = runBlocking {
+ val largeData = ByteArray(100000).apply { Random.nextBytes(this) }
+ val tcsA = CompletableDeferred()
+ val tcsB = CompletableDeferred()
+ val clientA = createClient(onNewChannel = { _, c -> tcsA.complete(c) })
+ val clientB = createClient(onNewChannel = { _, c -> tcsB.complete(c) })
+ val channelTask = async { clientA.startRelayedChannel(clientB.localPublicKey) }
+ val channelA = withTimeout(5000.milliseconds) { tcsA.await() }
+ channelA.authorizable = AlwaysAuthorized()
+ val channelB = withTimeout(5000.milliseconds) { tcsB.await() }
+ channelB.authorizable = AlwaysAuthorized()
+ channelTask.await()
+
+ val tcsDataB = CompletableDeferred()
+ channelB.setDataHandler { _, _, o, so, d ->
+ val b = ByteArray(d.remaining())
+ d.get(b)
+ if (o == Opcode.DATA.value && so == 0u.toUByte()) tcsDataB.complete(b)
+ }
+ channelA.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(largeData))
+ val receivedData = withTimeout(10000.milliseconds) { tcsDataB.await() }
+ assertArrayEquals(largeData, receivedData)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun publishAndGetLargeRecord_Success() = runBlocking {
+ val largeData = ByteArray(1000000).apply { Random.nextBytes(this) }
+ val clientA = createClient()
+ val clientB = createClient()
+ val success = clientA.publishRecords(listOf(clientB.localPublicKey), "largeRecord", largeData)
+ val record = clientB.getRecord(clientA.localPublicKey, "largeRecord")
+ assertTrue(success)
+ assertNotNull(record)
+ assertArrayEquals(largeData, record!!.first)
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun relayedTransport_WithValidAppId_Success() = runBlocking {
+ // Arrange: Set up clients
+ val allowedAppId = 1234u
+ val tcsB = CompletableDeferred()
+
+ // Client B requires appId 1234
+ val clientB = createClient(
+ onNewChannel = { _, c -> tcsB.complete(c) },
+ isHandshakeAllowed = { linkType, _, _, _, appId -> linkType == LinkType.Relayed && appId == allowedAppId }
+ )
+
+ val clientA = createClient()
+
+ // Act: Start relayed channel with valid appId
+ val channelTask = async { clientA.startRelayedChannel(clientB.localPublicKey, appId = allowedAppId) }
+ val channelB = withTimeout(5.seconds) { tcsB.await() }
+ withTimeout(5.seconds) { channelTask.await() }
+
+ // Assert: Channel is established
+ assertNotNull("Channel should be created on target with valid appId", channelB)
+
+ // Clean up
+ clientA.stop()
+ clientB.stop()
+ }
+
+ @Test
+ fun relayedTransport_WithInvalidAppId_Fails() = runBlocking {
+ // Arrange: Set up clients
+ val allowedAppId = 1234u
+ val invalidAppId = 5678u
+ val tcsB = CompletableDeferred()
+
+ // Client B requires appId 1234
+ val clientB = createClient(
+ onNewChannel = { _, c -> tcsB.complete(c) },
+ isHandshakeAllowed = { linkType, _, _, _, appId -> linkType == LinkType.Relayed && appId == allowedAppId },
+ onException = { }
+ )
+
+ val clientA = createClient()
+
+ // Act & Assert: Attempt with invalid appId should fail
+ try {
+ withTimeout(5.seconds) {
+ clientA.startRelayedChannel(clientB.localPublicKey, appId = invalidAppId)
+ }
+ fail("Starting relayed channel with invalid appId should fail")
+ } catch (e: Throwable) {
+ // Expected: The channel creation should time out or fail
+ }
+
+ // Ensure no channel was created on client B
+ val completedTask = select {
+ tcsB.onAwait { "channel" }
+ async { delay(1.seconds); "timeout" }.onAwait { "timeout" }
+ }
+ assertEquals("No channel should be created with invalid appId", "timeout", completedTask)
+
+ // Clean up
+ clientA.stop()
+ clientB.stop()
+ }
+}
+
+class AlwaysAuthorized : IAuthorizable {
+ override val isAuthorized: Boolean get() = true
+}*/
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/futo/platformplayer/SyncTests.kt b/app/src/androidTest/java/com/futo/platformplayer/SyncTests.kt
new file mode 100644
index 00000000..d34bfad4
--- /dev/null
+++ b/app/src/androidTest/java/com/futo/platformplayer/SyncTests.kt
@@ -0,0 +1,512 @@
+package com.futo.platformplayer
+
+import com.futo.platformplayer.noise.protocol.DHState
+import com.futo.platformplayer.noise.protocol.Noise
+import com.futo.platformplayer.sync.internal.*
+import kotlinx.coroutines.*
+import org.junit.Assert.*
+import org.junit.Test
+import java.io.PipedInputStream
+import java.io.PipedOutputStream
+import java.nio.ByteBuffer
+import kotlin.random.Random
+import java.io.InputStream
+import java.io.OutputStream
+import kotlin.time.Duration.Companion.seconds
+/*
+data class PipeStreams(
+ val initiatorInput: LittleEndianDataInputStream,
+ val initiatorOutput: LittleEndianDataOutputStream,
+ val responderInput: LittleEndianDataInputStream,
+ val responderOutput: LittleEndianDataOutputStream
+)
+
+typealias OnHandshakeComplete = (SyncSocketSession) -> Unit
+typealias IsHandshakeAllowed = (LinkType, SyncSocketSession, String, String?, UInt) -> Boolean
+typealias OnClose = (SyncSocketSession) -> Unit
+typealias OnData = (SyncSocketSession, UByte, UByte, ByteBuffer) -> Unit
+
+class SyncSocketTests {
+ private fun createPipeStreams(): PipeStreams {
+ val initiatorOutput = PipedOutputStream()
+ val responderOutput = PipedOutputStream()
+ val responderInput = PipedInputStream(initiatorOutput)
+ val initiatorInput = PipedInputStream(responderOutput)
+ return PipeStreams(
+ LittleEndianDataInputStream(initiatorInput), LittleEndianDataOutputStream(initiatorOutput),
+ LittleEndianDataInputStream(responderInput), LittleEndianDataOutputStream(responderOutput)
+ )
+ }
+
+ fun generateKeyPair(): DHState {
+ val p = Noise.createDH("25519")
+ p.generateKeyPair()
+ return p
+ }
+
+ private fun createSessions(
+ initiatorInput: LittleEndianDataInputStream,
+ initiatorOutput: LittleEndianDataOutputStream,
+ responderInput: LittleEndianDataInputStream,
+ responderOutput: LittleEndianDataOutputStream,
+ initiatorKeyPair: DHState,
+ responderKeyPair: DHState,
+ onInitiatorHandshakeComplete: OnHandshakeComplete,
+ onResponderHandshakeComplete: OnHandshakeComplete,
+ onInitiatorClose: OnClose? = null,
+ onResponderClose: OnClose? = null,
+ onClose: OnClose? = null,
+ isHandshakeAllowed: IsHandshakeAllowed? = null,
+ onDataA: OnData? = null,
+ onDataB: OnData? = null
+ ): Pair {
+ val initiatorSession = SyncSocketSession(
+ "", initiatorKeyPair, initiatorInput, initiatorOutput,
+ onClose = {
+ onClose?.invoke(it)
+ onInitiatorClose?.invoke(it)
+ },
+ onHandshakeComplete = onInitiatorHandshakeComplete,
+ onData = onDataA,
+ isHandshakeAllowed = isHandshakeAllowed
+ )
+
+ val responderSession = SyncSocketSession(
+ "", responderKeyPair, responderInput, responderOutput,
+ onClose = {
+ onClose?.invoke(it)
+ onResponderClose?.invoke(it)
+ },
+ onHandshakeComplete = onResponderHandshakeComplete,
+ onData = onDataB,
+ isHandshakeAllowed = isHandshakeAllowed
+ )
+
+ return Pair(initiatorSession, responderSession)
+ }
+
+ @Test
+ fun handshake_WithValidPairingCode_Succeeds(): Unit = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+ val validPairingCode = "secret"
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ isHandshakeAllowed = { _, _, _, pairingCode, _ -> pairingCode == validPairingCode }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey, pairingCode = validPairingCode)
+ responderSession.startAsResponder()
+
+ withTimeout(5.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+ }
+
+ @Test
+ fun handshake_WithInvalidPairingCode_Fails() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+ val validPairingCode = "secret"
+ val invalidPairingCode = "wrong"
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val initiatorClosed = CompletableDeferred()
+ val responderClosed = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onInitiatorClose = {
+ initiatorClosed.complete(true)
+ },
+ onResponderClose = {
+ responderClosed.complete(true)
+ },
+ isHandshakeAllowed = { _, _, _, pairingCode, _ -> pairingCode == validPairingCode }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey, pairingCode = invalidPairingCode)
+ responderSession.startAsResponder()
+
+ withTimeout(100.seconds) {
+ initiatorClosed.await()
+ responderClosed.await()
+ }
+
+ assertFalse(handshakeInitiatorCompleted.isCompleted)
+ assertFalse(handshakeResponderCompleted.isCompleted)
+ }
+
+ @Test
+ fun handshake_WithoutPairingCodeWhenRequired_Fails() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+ val validPairingCode = "secret"
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val initiatorClosed = CompletableDeferred()
+ val responderClosed = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onInitiatorClose = {
+ initiatorClosed.complete(true)
+ },
+ onResponderClose = {
+ responderClosed.complete(true)
+ },
+ isHandshakeAllowed = { _, _, _, pairingCode, _ -> pairingCode == validPairingCode }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey) // No pairing code
+ responderSession.startAsResponder()
+
+ withTimeout(5.seconds) {
+ initiatorClosed.await()
+ responderClosed.await()
+ }
+
+ assertFalse(handshakeInitiatorCompleted.isCompleted)
+ assertFalse(handshakeResponderCompleted.isCompleted)
+ }
+
+ @Test
+ fun handshake_WithPairingCodeWhenNotRequired_Succeeds(): Unit = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+ val pairingCode = "unnecessary"
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ isHandshakeAllowed = { _, _, _, _, _ -> true } // Always allow
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey, pairingCode = pairingCode)
+ responderSession.startAsResponder()
+
+ withTimeout(10.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+ }
+
+ @Test
+ fun sendAndReceive_SmallDataPacket_Succeeds() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val tcsDataReceived = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onDataB = { _, opcode, subOpcode, data ->
+ if (opcode == Opcode.DATA.value && subOpcode == 0u.toUByte()) {
+ val b = ByteArray(data.remaining())
+ data.get(b)
+ tcsDataReceived.complete(b)
+ }
+ }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey)
+ responderSession.startAsResponder()
+
+ withTimeout(10.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+
+ // Ensure both sessions are authorized
+ initiatorSession.authorizable = Authorized()
+ responderSession.authorizable = Authorized()
+
+ val smallData = byteArrayOf(1, 2, 3)
+ initiatorSession.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(smallData))
+
+ val receivedData = withTimeout(10.seconds) { tcsDataReceived.await() }
+ assertArrayEquals(smallData, receivedData)
+ }
+
+ @Test
+ fun sendAndReceive_ExactlyMaximumPacketSize_Succeeds() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val tcsDataReceived = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onDataB = { _, opcode, subOpcode, data ->
+ if (opcode == Opcode.DATA.value && subOpcode == 0u.toUByte()) {
+ val b = ByteArray(data.remaining())
+ data.get(b)
+ tcsDataReceived.complete(b)
+ }
+ }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey)
+ responderSession.startAsResponder()
+
+ withTimeout(10.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+
+ // Ensure both sessions are authorized
+ initiatorSession.authorizable = Authorized()
+ responderSession.authorizable = Authorized()
+
+ val maxData = ByteArray(SyncSocketSession.MAXIMUM_PACKET_SIZE - SyncSocketSession.HEADER_SIZE).apply { Random.nextBytes(this) }
+ initiatorSession.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(maxData))
+
+ val receivedData = withTimeout(10.seconds) { tcsDataReceived.await() }
+ assertArrayEquals(maxData, receivedData)
+ }
+
+ @Test
+ fun stream_LargeData_Succeeds() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val tcsDataReceived = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onDataB = { _, opcode, subOpcode, data ->
+ if (opcode == Opcode.DATA.value && subOpcode == 0u.toUByte()) {
+ val b = ByteArray(data.remaining())
+ data.get(b)
+ tcsDataReceived.complete(b)
+ }
+ }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey)
+ responderSession.startAsResponder()
+
+ withTimeout(10.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+
+ // Ensure both sessions are authorized
+ initiatorSession.authorizable = Authorized()
+ responderSession.authorizable = Authorized()
+
+ val largeData = ByteArray(2 * (SyncSocketSession.MAXIMUM_PACKET_SIZE - SyncSocketSession.HEADER_SIZE)).apply { Random.nextBytes(this) }
+ initiatorSession.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(largeData))
+
+ val receivedData = withTimeout(10.seconds) { tcsDataReceived.await() }
+ assertArrayEquals(largeData, receivedData)
+ }
+
+ @Test
+ fun authorizedSession_CanSendData() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val tcsDataReceived = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onDataB = { _, opcode, subOpcode, data ->
+ if (opcode == Opcode.DATA.value && subOpcode == 0u.toUByte()) {
+ val b = ByteArray(data.remaining())
+ data.get(b)
+ tcsDataReceived.complete(b)
+ }
+ }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey)
+ responderSession.startAsResponder()
+
+ withTimeout(10.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+
+ // Authorize both sessions
+ initiatorSession.authorizable = Authorized()
+ responderSession.authorizable = Authorized()
+
+ val data = byteArrayOf(1, 2, 3)
+ initiatorSession.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(data))
+
+ val receivedData = withTimeout(10.seconds) { tcsDataReceived.await() }
+ assertArrayEquals(data, receivedData)
+ }
+
+ @Test
+ fun unauthorizedSession_CannotSendData() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val tcsDataReceived = CompletableDeferred()
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onDataB = { _, _, _, _ -> }
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey)
+ responderSession.startAsResponder()
+
+ withTimeout(10.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+
+ // Authorize initiator but not responder
+ initiatorSession.authorizable = Authorized()
+ responderSession.authorizable = Unauthorized()
+
+ val data = byteArrayOf(1, 2, 3)
+ initiatorSession.send(Opcode.DATA.value, 0u, ByteBuffer.wrap(data))
+
+ delay(1.seconds)
+ assertFalse(tcsDataReceived.isCompleted)
+ }
+
+ @Test
+ fun directHandshake_WithValidAppId_Succeeds() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+ val allowedAppId = 1234u
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+
+ val responderIsHandshakeAllowed = { linkType: LinkType, _: SyncSocketSession, _: String, _: String?, appId: UInt ->
+ linkType == LinkType.Direct && appId == allowedAppId
+ }
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ isHandshakeAllowed = responderIsHandshakeAllowed
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey, appId = allowedAppId)
+ responderSession.startAsResponder()
+
+ withTimeout(5.seconds) {
+ handshakeInitiatorCompleted.await()
+ handshakeResponderCompleted.await()
+ }
+
+ assertNotNull(initiatorSession.remotePublicKey)
+ assertNotNull(responderSession.remotePublicKey)
+ }
+
+ @Test
+ fun directHandshake_WithInvalidAppId_Fails() = runBlocking {
+ val (initiatorInput, initiatorOutput, responderInput, responderOutput) = createPipeStreams()
+ val initiatorKeyPair = generateKeyPair()
+ val responderKeyPair = generateKeyPair()
+ val allowedAppId = 1234u
+ val invalidAppId = 5678u
+
+ val handshakeInitiatorCompleted = CompletableDeferred()
+ val handshakeResponderCompleted = CompletableDeferred()
+ val initiatorClosed = CompletableDeferred()
+ val responderClosed = CompletableDeferred()
+
+ val responderIsHandshakeAllowed = { linkType: LinkType, _: SyncSocketSession, _: String, _: String?, appId: UInt ->
+ linkType == LinkType.Direct && appId == allowedAppId
+ }
+
+ val (initiatorSession, responderSession) = createSessions(
+ initiatorInput, initiatorOutput, responderInput, responderOutput,
+ initiatorKeyPair, responderKeyPair,
+ { handshakeInitiatorCompleted.complete(true) },
+ { handshakeResponderCompleted.complete(true) },
+ onInitiatorClose = {
+ initiatorClosed.complete(true)
+ },
+ onResponderClose = {
+ responderClosed.complete(true)
+ },
+ isHandshakeAllowed = responderIsHandshakeAllowed
+ )
+
+ initiatorSession.startAsInitiator(responderSession.localPublicKey, appId = invalidAppId)
+ responderSession.startAsResponder()
+
+ withTimeout(5.seconds) {
+ initiatorClosed.await()
+ responderClosed.await()
+ }
+
+ assertFalse(handshakeInitiatorCompleted.isCompleted)
+ assertFalse(handshakeResponderCompleted.isCompleted)
+ }
+}
+
+class Authorized : IAuthorizable {
+ override val isAuthorized: Boolean = true
+}
+
+class Unauthorized : IAuthorizable {
+ override val isAuthorized: Boolean = false
+}*/
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 49076988..ea6f3e5b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -11,6 +11,7 @@
+
@@ -35,15 +36,18 @@
+
+
+
+
+
+
-
@@ -51,11 +55,10 @@
@@ -148,34 +151,30 @@
-
-
@@ -189,44 +188,55 @@
-
+
+
+
-
\ No newline at end of file
+
diff --git a/app/src/main/assets/devportal/plugin.d.ts b/app/src/main/assets/devportal/plugin.d.ts
index 23db7d2f..702fb745 100644
--- a/app/src/main/assets/devportal/plugin.d.ts
+++ b/app/src/main/assets/devportal/plugin.d.ts
@@ -127,7 +127,7 @@ declare class PlatformVideoDetails extends PlatformVideo {
}
declare interface PlatformPostDef extends PlatformContentDef {
- thumbnails: string[],
+ thumbnails: Thumbnails[],
images: string[],
description: string
}
diff --git a/app/src/main/assets/scripts/JSDOM.js b/app/src/main/assets/scripts/JSDOM.js
new file mode 100644
index 00000000..63311d2c
--- /dev/null
+++ b/app/src/main/assets/scripts/JSDOM.js
@@ -0,0 +1,11 @@
+
+
+
+
+//#region JSDOM
+
+/*! Custom compilation of JSDOM, original License: https://raw.githubusercontent.com/jsdom/jsdom/refs/heads/main/LICENSE.txt */
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSDOM=t():e.JSDOM=t()}(self,(()=>(()=>{var __webpack_modules__={20544:function(e,t,n){"use strict";var r=n(48287).Buffer,o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.req=t.json=t.toBuffer=void 0;const s=a(n(11568)),l=a(n(11083));async function u(e){let t=0;const n=[];for await(const r of e)t+=r.length,n.push(r);return r.concat(n,t)}t.toBuffer=u,t.json=async function(e){const t=(await u(e)).toString("utf8");try{return JSON.parse(t)}catch(e){const n=e;throw n.message+=` (input: ${t})`,n}},t.req=function(e,t={}){const n=(("string"==typeof e?e:e.href).startsWith("https:")?l:s).request(e,t),r=new Promise(((e,t)=>{n.once("response",e).once("error",t).end()}));return n.then=r.then.bind(r),n}},20917:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.Agent=void 0;const s=i(n(59452)),l=i(n(11568)),u=n(11083);a(n(20544),t);const c=Symbol("AgentBaseInternalState");class h extends l.Agent{constructor(e){super(e),this[c]={}}isSecureEndpoint(e){if(e){if("boolean"==typeof e.secureEndpoint)return e.secureEndpoint;if("string"==typeof e.protocol)return"https:"===e.protocol}const{stack:t}=new Error;return"string"==typeof t&&t.split("\n").some((e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:")))}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[e]||(this.sockets[e]=[]);const t=new s.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||null===t)return;const n=this.sockets[e],r=n.indexOf(t);-1!==r&&(n.splice(r,1),this.totalSocketCount--,0===n.length&&delete this.sockets[e])}getName(e){return("boolean"==typeof e.secureEndpoint?e.secureEndpoint:this.isSecureEndpoint(e))?u.Agent.prototype.getName.call(this,e):super.getName(e)}createSocket(e,t,n){const r={...t,secureEndpoint:this.isSecureEndpoint(t)},o=this.getName(r),i=this.incrementSockets(o);Promise.resolve().then((()=>this.connect(e,r))).then((a=>{if(this.decrementSockets(o,i),a instanceof l.Agent)try{return a.addRequest(e,r)}catch(e){return n(e)}this[c].currentSocket=a,super.createSocket(e,t,n)}),(e=>{this.decrementSockets(o,i),n(e)}))}createConnection(){const e=this[c].currentSocket;if(this[c].currentSocket=void 0,!e)throw new Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[c].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(e){this[c]&&(this[c].defaultPort=e)}get protocol(){return this[c].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){this[c]&&(this[c].protocol=e)}}t.Agent=h},87568:(e,t,n)=>{var r=t;r.bignum=n(72344),r.define=n(47363).define,r.base=n(9673),r.constants=n(22153),r.decoders=n(22853),r.encoders=n(24669)},47363:(e,t,n)=>{var r=n(87568),o=n(56698);function i(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new i(e,t)},i.prototype._createNamed=function(e){var t;try{t=n(68961).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return o(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},i.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r.decoders[e])),this.decoders[e]},i.prototype.decode=function(e,t,n){return this._getDecoder(t).decode(e,n)},i.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(r.encoders[e])),this.encoders[e]},i.prototype.encode=function(e,t,n){return this._getEncoder(t).encode(e,n)}},47227:(e,t,n)=>{var r=n(56698),o=n(9673).Reporter,i=n(48287).Buffer;function a(e,t){o.call(this,t),i.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=i.byteLength(e);else{if(!i.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}r(a,o),t.t=a,a.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,o.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var n=new a(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.d=s,s.prototype.join=function(e,t){return e||(e=new i(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(n){n.join(e,t),t+=n.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):i.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},9673:(e,t,n)=>{var r=t;r.Reporter=n(89220).a,r.DecoderBuffer=n(47227).t,r.EncoderBuffer=n(47227).d,r.Node=n(90993)},90993:(e,t,n)=>{var r=n(9673).Reporter,o=n(9673).EncoderBuffer,i=n(9673).DecoderBuffer,a=n(43349),s=["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"],l=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function u(e,t){var n={};this._baseState=n,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}e.exports=u;var c=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){var e=this._baseState,t={};c.forEach((function(n){t[n]=e[n]}));var n=new this.constructor(t.parent);return n._baseState=t,n},u.prototype._wrap=function(){var e=this._baseState;l.forEach((function(t){this[t]=function(){var n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}}),this)},u.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),a.equal(t.children.length,1,"Root node can have only one child")},u.prototype._useArgs=function(e){var t=this._baseState,n=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==n.length&&(a(null===t.children),t.children=n,n.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(n){n==(0|n)&&(n|=0);var r=e[n];t[r]=n})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){u.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),s.forEach((function(e){u.prototype[e]=function(){var t=this._baseState,n=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(n),this}})),u.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},u.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},u.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},u.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},u.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},u.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},u.prototype._decode=function(e,t){var n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));var r,o=n.default,a=!0,s=null;if(null!==n.key&&(s=e.enterKey(n.key)),n.optional){var l=null;if(null!==n.explicit?l=n.explicit:null!==n.implicit?l=n.implicit:null!==n.tag&&(l=n.tag),null!==l||n.any){if(a=this._peekTag(e,l,n.any),e.isError(a))return a}else{var u=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(u)}}if(n.obj&&a&&(r=e.enterObject()),a){if(null!==n.explicit){var c=this._decodeTag(e,n.explicit);if(e.isError(c))return c;e=c}var h=e.offset;if(null===n.use&&null===n.choice){n.any&&(u=e.save());var d=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(d))return d;n.any?o=e.raw(u):e=d}if(t&&t.track&&null!==n.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(o=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(o))return o;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(n){n._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){var p=new i(o);o=this._getUse(n.contains,e._reporterState.obj)._decode(p,t)}}return n.obj&&a&&(o=e.leaveObject(r)),null===n.key||null===o&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,n.key,o),o},u.prototype._decodeGeneric=function(e,t,n){var r=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,r.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):"objid"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1],n):"objid"===e?this._decodeObjid(t,null,null,n):"gentime"===e||"utctime"===e?this._decodeTime(t,e,n):"null_"===e?this._decodeNull(t,n):"bool"===e?this._decodeBool(t,n):"objDesc"===e?this._decodeStr(t,e,n):"int"===e||"enum"===e?this._decodeInt(t,r.args&&r.args[0],n):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t,n):t.error("unknown tag: "+e)},u.prototype._getUse=function(e,t){var n=this._baseState;return n.useDecoder=this._use(e,t),a(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},u.prototype._decodeChoice=function(e,t){var n=this._baseState,r=null,o=!1;return Object.keys(n.choice).some((function(i){var a=e.save(),s=n.choice[i];try{var l=s._decode(e,t);if(e.isError(l))return!1;r={type:i,value:l},o=!0}catch(t){return e.restore(a),!1}return!0}),this),o?r:e.error("Choice not matched")},u.prototype._createEncoderBuffer=function(e){return new o(e,this.reporter)},u.prototype._encode=function(e,t,n){var r=this._baseState;if(null===r.default||r.default!==e){var o=this._encodeValue(e,t,n);if(void 0!==o&&!this._skipDefault(o,t,n))return o}},u.prototype._encodeValue=function(e,t,n){var o=this._baseState;if(null===o.parent)return o.children[0]._encode(e,t||new r);var i=null;if(this.reporter=t,o.optional&&void 0===e){if(null===o.default)return;e=o.default}var a=null,s=!1;if(o.any)i=this._createEncoderBuffer(e);else if(o.choice)i=this._encodeChoice(e,t);else if(o.contains)a=this._getUse(o.contains,n)._encode(e,t),s=!0;else if(o.children)a=o.children.map((function(n){if("null_"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error("Child should have a key");var r=t.enterKey(n._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var o=n._encode(e[n._baseState.key],t,e);return t.leaveKey(r),o}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return t.error("Too many args for : "+o.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var l=this.clone();l._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(n){var r=this._baseState;return this._getUse(r.args[0],e)._encode(n,t)}),l))}else null!==o.use?i=this._getUse(o.use,n)._encode(e,t):(a=this._encodePrimitive(o.tag,e),s=!0);if(!o.any&&null===o.choice){var u=null!==o.implicit?o.implicit:o.tag,c=null===o.implicit?"universal":"context";null===u?null===o.use&&t.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(u,s,c,a))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},u.prototype._encodeChoice=function(e,t){var n=this._baseState,r=n.choice[e.type];return r||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),r._encode(e.value,t)},u.prototype._encodePrimitive=function(e,t){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},u.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},u.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},89220:(e,t,n)=>{var r=n(56698);function o(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function i(e,t){this.path=e,this.rethrow(t)}t.a=o,o.prototype.isError=function(e){return e instanceof i},o.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},o.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},o.prototype.enterKey=function(e){return this._reporterState.path.push(e)},o.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},o.prototype.leaveKey=function(e,t,n){var r=this._reporterState;this.exitKey(e),null!==r.obj&&(r.obj[t]=n)},o.prototype.path=function(){return this._reporterState.path.join("/")},o.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},o.prototype.leaveObject=function(e){var t=this._reporterState,n=t.obj;return t.obj=e,n},o.prototype.error=function(e){var t,n=this._reporterState,r=e instanceof i;if(t=r?e:new i(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return r||n.errors.push(t),t},o.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},r(i,Error),i.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,i),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},74598:(e,t,n)=>{var r=n(22153);t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=r._reverse(t.tagClass),t.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"},t.tagByName=r._reverse(t.tag)},22153:(e,t,n)=>{var r=t;r._reverse=function(e){var t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);var r=e[n];t[r]=n})),t},r.der=n(74598)},62010:(e,t,n)=>{var r=n(56698),o=n(87568),i=o.base,a=o.bignum,s=o.constants.der;function l(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new u,this.tree._init(e.body)}function u(e){i.Node.call(this,"der",e)}function c(e,t){var n=e.readUInt8(t);if(e.isError(n))return n;var r=s.tagClass[n>>6],o=!(32&n);if(31&~n)n&=31;else{var i=n;for(n=0;!(128&~i);){if(i=e.readUInt8(t),e.isError(i))return i;n<<=7,n|=127&i}}return{cls:r,primitive:o,tag:n,tagStr:s.tag[n]}}function h(e,t,n){var r=e.readUInt8(n);if(e.isError(r))return r;if(!t&&128===r)return null;if(!(128&r))return r;var o=127&r;if(o>4)return e.error("length octect is too long");r=0;for(var i=0;i{var r=t;r.der=n(62010),r.pem=n(58903)},58903:(e,t,n)=>{var r=n(56698),o=n(48287).Buffer,i=n(62010);function a(e){i.call(this,e),this.enc="pem"}r(a,i),e.exports=a,a.prototype.decode=function(e,t){for(var n=e.toString().split(/[\r\n]+/g),r=t.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,l=-1,u=0;u{var r=n(56698),o=n(48287).Buffer,i=n(87568),a=i.base,s=i.constants.der;function l(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new u,this.tree._init(e.body)}function u(e){a.Node.call(this,"der",e)}function c(e){return e<10?"0"+e:e}e.exports=l,l.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},r(u,a.Node),u.prototype._encodeComposite=function(e,t,n,r){var i,a=function(e,t,n,r){var o;if("seqof"===e?e="seq":"setof"===e&&(e="set"),s.tagByName.hasOwnProperty(e))o=s.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return r.error("Unknown tag: "+e);o=e}return o>=31?r.error("Multi-octet tag encoding unsupported"):(t||(o|=32),o|=s.tagClassByName[n||"universal"]<<6)}(e,t,n,this.reporter);if(r.length<128)return(i=new o(2))[0]=a,i[1]=r.length,this._createEncoderBuffer([i,r]);for(var l=1,u=r.length;u>=256;u>>=8)l++;(i=new o(2+l))[0]=a,i[1]=128|l,u=1+l;for(var c=r.length;c>0;u--,c>>=8)i[u]=255&c;return this._createEncoderBuffer([i,r])},u.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var n=new o(2*e.length),r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var i=0;for(r=0;r=128;a>>=7)i++}var s=new o(i),l=s.length-1;for(r=e.length-1;r>=0;r--)for(a=e[r],s[l--]=127&a;(a>>=7)>0;)s[l--]=128|127&a;return this._createEncoderBuffer(s)},u.prototype._encodeTime=function(e,t){var n,r=new Date(e);return"gentime"===t?n=[c(r.getFullYear()),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[c(r.getFullYear()%100),c(r.getUTCMonth()+1),c(r.getUTCDate()),c(r.getUTCHours()),c(r.getUTCMinutes()),c(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!o.isBuffer(e)){var n=e.toArray();!e.sign&&128&n[0]&&n.unshift(0),e=new o(n)}if(o.isBuffer(e)){var r=e.length;0===e.length&&r++;var i=new o(r);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);r=1;for(var a=e;a>=256;a>>=8)r++;for(a=(i=new Array(r)).length-1;a>=0;a--)i[a]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new o(i))},u.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},u.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},u.prototype._skipDefault=function(e,t,n){var r,o=this._baseState;if(null===o.default)return!1;var i=e.join();if(void 0===o.defaultBuffer&&(o.defaultBuffer=this._encodeValue(o.default,t,n).join()),i.length!==o.defaultBuffer.length)return!1;for(r=0;r{var r=t;r.der=n(70082),r.pem=n(90735)},90735:(e,t,n)=>{var r=n(56698),o=n(70082);function i(e){o.call(this,e),this.enc="pem"}r(i,o),e.exports=i,i.prototype.encode=function(e,t){for(var n=o.prototype.encode.call(this,e).toString("base64"),r=["-----BEGIN "+t.label+"-----"],i=0;i=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function l(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,r){for(var o=0,i=Math.min(e.length,n),a=t;a=49?s-49+10:s>=17?s-17+10:s}return o}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)o=l(e,t,r)<=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,a=i%r,s=Math.min(i,i-a)+n,l=0,c=n;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};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"],h=[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],d=[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 p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,l=a/67108864|0;n.words[0]=s;for(var u=1;u>>26,h=67108863&l,d=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=d;p++){var f=u-p|0;c+=(a=(o=0|e.words[f])*(i=0|t.words[p])+h)/67108864|0,h=67108863&a}n.words[u]=0|h,l=0|c}return 0!==l?n.words[u]=0|l:n.length--,n.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var o=0,i=0,a=0;a>>24-o&16777215,(o+=2)>=26&&(o-=26,a--),n=0!==i||a!==this.length-1?c[6-l.length]+l+n:l+n}for(0!==i&&(n=i.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=h[e],p=d[e];n="";var f=this.clone();for(f.negative=0;!f.isZero();){var m=f.modn(p).toString(e);n=(f=f.idivn(p)).isZero()?m+n:c[u-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0"),this.strip();var a,s,l="le"===t,u=new e(i),c=this.clone();if(l){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),u[s]=a;for(;s=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 8191&t||(n+=13,t>>>=13),127&t||(n+=7,t>>>=7),15&t||(n+=4,t>>>=4),3&t||(n+=2,t>>>=2),1&t||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var o=0;o0&&(this.words[o]=~this.words[o]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,o=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i>>26;for(;0!==o&&i>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;ie.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==i&&a>26,this.words[a]=67108863&t;if(0===i&&a>>13,p=0|a[1],f=8191&p,m=p>>>13,b=0|a[2],g=8191&b,y=b>>>13,v=0|a[3],w=8191&v,E=v>>>13,T=0|a[4],_=8191&T,S=T>>>13,A=0|a[5],M=8191&A,C=A>>>13,O=0|a[6],D=8191&O,x=O>>>13,N=0|a[7],k=8191&N,F=N>>>13,I=0|a[8],j=8191&I,R=I>>>13,L=0|a[9],P=8191&L,B=L>>>13,H=0|s[0],U=8191&H,G=H>>>13,W=0|s[1],V=8191&W,q=W>>>13,z=0|s[2],$=8191&z,Y=z>>>13,X=0|s[3],K=8191&X,Z=X>>>13,Q=0|s[4],J=8191&Q,ee=Q>>>13,te=0|s[5],ne=8191&te,re=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],le=8191&se,ue=se>>>13,ce=0|s[8],he=8191&ce,de=ce>>>13,pe=0|s[9],fe=8191&pe,me=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(r=Math.imul(h,U))|0)+((8191&(o=(o=Math.imul(h,G))+Math.imul(d,U)|0))<<13)|0;u=((i=Math.imul(d,G))+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(f,U),o=(o=Math.imul(f,G))+Math.imul(m,U)|0,i=Math.imul(m,G);var ge=(u+(r=r+Math.imul(h,V)|0)|0)+((8191&(o=(o=o+Math.imul(h,q)|0)+Math.imul(d,V)|0))<<13)|0;u=((i=i+Math.imul(d,q)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,U),o=(o=Math.imul(g,G))+Math.imul(y,U)|0,i=Math.imul(y,G),r=r+Math.imul(f,V)|0,o=(o=o+Math.imul(f,q)|0)+Math.imul(m,V)|0,i=i+Math.imul(m,q)|0;var ye=(u+(r=r+Math.imul(h,$)|0)|0)+((8191&(o=(o=o+Math.imul(h,Y)|0)+Math.imul(d,$)|0))<<13)|0;u=((i=i+Math.imul(d,Y)|0)+(o>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(w,U),o=(o=Math.imul(w,G))+Math.imul(E,U)|0,i=Math.imul(E,G),r=r+Math.imul(g,V)|0,o=(o=o+Math.imul(g,q)|0)+Math.imul(y,V)|0,i=i+Math.imul(y,q)|0,r=r+Math.imul(f,$)|0,o=(o=o+Math.imul(f,Y)|0)+Math.imul(m,$)|0,i=i+Math.imul(m,Y)|0;var ve=(u+(r=r+Math.imul(h,K)|0)|0)+((8191&(o=(o=o+Math.imul(h,Z)|0)+Math.imul(d,K)|0))<<13)|0;u=((i=i+Math.imul(d,Z)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(_,U),o=(o=Math.imul(_,G))+Math.imul(S,U)|0,i=Math.imul(S,G),r=r+Math.imul(w,V)|0,o=(o=o+Math.imul(w,q)|0)+Math.imul(E,V)|0,i=i+Math.imul(E,q)|0,r=r+Math.imul(g,$)|0,o=(o=o+Math.imul(g,Y)|0)+Math.imul(y,$)|0,i=i+Math.imul(y,Y)|0,r=r+Math.imul(f,K)|0,o=(o=o+Math.imul(f,Z)|0)+Math.imul(m,K)|0,i=i+Math.imul(m,Z)|0;var we=(u+(r=r+Math.imul(h,J)|0)|0)+((8191&(o=(o=o+Math.imul(h,ee)|0)+Math.imul(d,J)|0))<<13)|0;u=((i=i+Math.imul(d,ee)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(M,U),o=(o=Math.imul(M,G))+Math.imul(C,U)|0,i=Math.imul(C,G),r=r+Math.imul(_,V)|0,o=(o=o+Math.imul(_,q)|0)+Math.imul(S,V)|0,i=i+Math.imul(S,q)|0,r=r+Math.imul(w,$)|0,o=(o=o+Math.imul(w,Y)|0)+Math.imul(E,$)|0,i=i+Math.imul(E,Y)|0,r=r+Math.imul(g,K)|0,o=(o=o+Math.imul(g,Z)|0)+Math.imul(y,K)|0,i=i+Math.imul(y,Z)|0,r=r+Math.imul(f,J)|0,o=(o=o+Math.imul(f,ee)|0)+Math.imul(m,J)|0,i=i+Math.imul(m,ee)|0;var Ee=(u+(r=r+Math.imul(h,ne)|0)|0)+((8191&(o=(o=o+Math.imul(h,re)|0)+Math.imul(d,ne)|0))<<13)|0;u=((i=i+Math.imul(d,re)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(D,U),o=(o=Math.imul(D,G))+Math.imul(x,U)|0,i=Math.imul(x,G),r=r+Math.imul(M,V)|0,o=(o=o+Math.imul(M,q)|0)+Math.imul(C,V)|0,i=i+Math.imul(C,q)|0,r=r+Math.imul(_,$)|0,o=(o=o+Math.imul(_,Y)|0)+Math.imul(S,$)|0,i=i+Math.imul(S,Y)|0,r=r+Math.imul(w,K)|0,o=(o=o+Math.imul(w,Z)|0)+Math.imul(E,K)|0,i=i+Math.imul(E,Z)|0,r=r+Math.imul(g,J)|0,o=(o=o+Math.imul(g,ee)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,ee)|0,r=r+Math.imul(f,ne)|0,o=(o=o+Math.imul(f,re)|0)+Math.imul(m,ne)|0,i=i+Math.imul(m,re)|0;var Te=(u+(r=r+Math.imul(h,ie)|0)|0)+((8191&(o=(o=o+Math.imul(h,ae)|0)+Math.imul(d,ie)|0))<<13)|0;u=((i=i+Math.imul(d,ae)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(k,U),o=(o=Math.imul(k,G))+Math.imul(F,U)|0,i=Math.imul(F,G),r=r+Math.imul(D,V)|0,o=(o=o+Math.imul(D,q)|0)+Math.imul(x,V)|0,i=i+Math.imul(x,q)|0,r=r+Math.imul(M,$)|0,o=(o=o+Math.imul(M,Y)|0)+Math.imul(C,$)|0,i=i+Math.imul(C,Y)|0,r=r+Math.imul(_,K)|0,o=(o=o+Math.imul(_,Z)|0)+Math.imul(S,K)|0,i=i+Math.imul(S,Z)|0,r=r+Math.imul(w,J)|0,o=(o=o+Math.imul(w,ee)|0)+Math.imul(E,J)|0,i=i+Math.imul(E,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(y,ne)|0,i=i+Math.imul(y,re)|0,r=r+Math.imul(f,ie)|0,o=(o=o+Math.imul(f,ae)|0)+Math.imul(m,ie)|0,i=i+Math.imul(m,ae)|0;var _e=(u+(r=r+Math.imul(h,le)|0)|0)+((8191&(o=(o=o+Math.imul(h,ue)|0)+Math.imul(d,le)|0))<<13)|0;u=((i=i+Math.imul(d,ue)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(j,U),o=(o=Math.imul(j,G))+Math.imul(R,U)|0,i=Math.imul(R,G),r=r+Math.imul(k,V)|0,o=(o=o+Math.imul(k,q)|0)+Math.imul(F,V)|0,i=i+Math.imul(F,q)|0,r=r+Math.imul(D,$)|0,o=(o=o+Math.imul(D,Y)|0)+Math.imul(x,$)|0,i=i+Math.imul(x,Y)|0,r=r+Math.imul(M,K)|0,o=(o=o+Math.imul(M,Z)|0)+Math.imul(C,K)|0,i=i+Math.imul(C,Z)|0,r=r+Math.imul(_,J)|0,o=(o=o+Math.imul(_,ee)|0)+Math.imul(S,J)|0,i=i+Math.imul(S,ee)|0,r=r+Math.imul(w,ne)|0,o=(o=o+Math.imul(w,re)|0)+Math.imul(E,ne)|0,i=i+Math.imul(E,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0,r=r+Math.imul(f,le)|0,o=(o=o+Math.imul(f,ue)|0)+Math.imul(m,le)|0,i=i+Math.imul(m,ue)|0;var Se=(u+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,de)|0)+Math.imul(d,he)|0))<<13)|0;u=((i=i+Math.imul(d,de)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(P,U),o=(o=Math.imul(P,G))+Math.imul(B,U)|0,i=Math.imul(B,G),r=r+Math.imul(j,V)|0,o=(o=o+Math.imul(j,q)|0)+Math.imul(R,V)|0,i=i+Math.imul(R,q)|0,r=r+Math.imul(k,$)|0,o=(o=o+Math.imul(k,Y)|0)+Math.imul(F,$)|0,i=i+Math.imul(F,Y)|0,r=r+Math.imul(D,K)|0,o=(o=o+Math.imul(D,Z)|0)+Math.imul(x,K)|0,i=i+Math.imul(x,Z)|0,r=r+Math.imul(M,J)|0,o=(o=o+Math.imul(M,ee)|0)+Math.imul(C,J)|0,i=i+Math.imul(C,ee)|0,r=r+Math.imul(_,ne)|0,o=(o=o+Math.imul(_,re)|0)+Math.imul(S,ne)|0,i=i+Math.imul(S,re)|0,r=r+Math.imul(w,ie)|0,o=(o=o+Math.imul(w,ae)|0)+Math.imul(E,ie)|0,i=i+Math.imul(E,ae)|0,r=r+Math.imul(g,le)|0,o=(o=o+Math.imul(g,ue)|0)+Math.imul(y,le)|0,i=i+Math.imul(y,ue)|0,r=r+Math.imul(f,he)|0,o=(o=o+Math.imul(f,de)|0)+Math.imul(m,he)|0,i=i+Math.imul(m,de)|0;var Ae=(u+(r=r+Math.imul(h,fe)|0)|0)+((8191&(o=(o=o+Math.imul(h,me)|0)+Math.imul(d,fe)|0))<<13)|0;u=((i=i+Math.imul(d,me)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(P,V),o=(o=Math.imul(P,q))+Math.imul(B,V)|0,i=Math.imul(B,q),r=r+Math.imul(j,$)|0,o=(o=o+Math.imul(j,Y)|0)+Math.imul(R,$)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(k,K)|0,o=(o=o+Math.imul(k,Z)|0)+Math.imul(F,K)|0,i=i+Math.imul(F,Z)|0,r=r+Math.imul(D,J)|0,o=(o=o+Math.imul(D,ee)|0)+Math.imul(x,J)|0,i=i+Math.imul(x,ee)|0,r=r+Math.imul(M,ne)|0,o=(o=o+Math.imul(M,re)|0)+Math.imul(C,ne)|0,i=i+Math.imul(C,re)|0,r=r+Math.imul(_,ie)|0,o=(o=o+Math.imul(_,ae)|0)+Math.imul(S,ie)|0,i=i+Math.imul(S,ae)|0,r=r+Math.imul(w,le)|0,o=(o=o+Math.imul(w,ue)|0)+Math.imul(E,le)|0,i=i+Math.imul(E,ue)|0,r=r+Math.imul(g,he)|0,o=(o=o+Math.imul(g,de)|0)+Math.imul(y,he)|0,i=i+Math.imul(y,de)|0;var Me=(u+(r=r+Math.imul(f,fe)|0)|0)+((8191&(o=(o=o+Math.imul(f,me)|0)+Math.imul(m,fe)|0))<<13)|0;u=((i=i+Math.imul(m,me)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(P,$),o=(o=Math.imul(P,Y))+Math.imul(B,$)|0,i=Math.imul(B,Y),r=r+Math.imul(j,K)|0,o=(o=o+Math.imul(j,Z)|0)+Math.imul(R,K)|0,i=i+Math.imul(R,Z)|0,r=r+Math.imul(k,J)|0,o=(o=o+Math.imul(k,ee)|0)+Math.imul(F,J)|0,i=i+Math.imul(F,ee)|0,r=r+Math.imul(D,ne)|0,o=(o=o+Math.imul(D,re)|0)+Math.imul(x,ne)|0,i=i+Math.imul(x,re)|0,r=r+Math.imul(M,ie)|0,o=(o=o+Math.imul(M,ae)|0)+Math.imul(C,ie)|0,i=i+Math.imul(C,ae)|0,r=r+Math.imul(_,le)|0,o=(o=o+Math.imul(_,ue)|0)+Math.imul(S,le)|0,i=i+Math.imul(S,ue)|0,r=r+Math.imul(w,he)|0,o=(o=o+Math.imul(w,de)|0)+Math.imul(E,he)|0,i=i+Math.imul(E,de)|0;var Ce=(u+(r=r+Math.imul(g,fe)|0)|0)+((8191&(o=(o=o+Math.imul(g,me)|0)+Math.imul(y,fe)|0))<<13)|0;u=((i=i+Math.imul(y,me)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(P,K),o=(o=Math.imul(P,Z))+Math.imul(B,K)|0,i=Math.imul(B,Z),r=r+Math.imul(j,J)|0,o=(o=o+Math.imul(j,ee)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(k,ne)|0,o=(o=o+Math.imul(k,re)|0)+Math.imul(F,ne)|0,i=i+Math.imul(F,re)|0,r=r+Math.imul(D,ie)|0,o=(o=o+Math.imul(D,ae)|0)+Math.imul(x,ie)|0,i=i+Math.imul(x,ae)|0,r=r+Math.imul(M,le)|0,o=(o=o+Math.imul(M,ue)|0)+Math.imul(C,le)|0,i=i+Math.imul(C,ue)|0,r=r+Math.imul(_,he)|0,o=(o=o+Math.imul(_,de)|0)+Math.imul(S,he)|0,i=i+Math.imul(S,de)|0;var Oe=(u+(r=r+Math.imul(w,fe)|0)|0)+((8191&(o=(o=o+Math.imul(w,me)|0)+Math.imul(E,fe)|0))<<13)|0;u=((i=i+Math.imul(E,me)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(P,J),o=(o=Math.imul(P,ee))+Math.imul(B,J)|0,i=Math.imul(B,ee),r=r+Math.imul(j,ne)|0,o=(o=o+Math.imul(j,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(k,ie)|0,o=(o=o+Math.imul(k,ae)|0)+Math.imul(F,ie)|0,i=i+Math.imul(F,ae)|0,r=r+Math.imul(D,le)|0,o=(o=o+Math.imul(D,ue)|0)+Math.imul(x,le)|0,i=i+Math.imul(x,ue)|0,r=r+Math.imul(M,he)|0,o=(o=o+Math.imul(M,de)|0)+Math.imul(C,he)|0,i=i+Math.imul(C,de)|0;var De=(u+(r=r+Math.imul(_,fe)|0)|0)+((8191&(o=(o=o+Math.imul(_,me)|0)+Math.imul(S,fe)|0))<<13)|0;u=((i=i+Math.imul(S,me)|0)+(o>>>13)|0)+(De>>>26)|0,De&=67108863,r=Math.imul(P,ne),o=(o=Math.imul(P,re))+Math.imul(B,ne)|0,i=Math.imul(B,re),r=r+Math.imul(j,ie)|0,o=(o=o+Math.imul(j,ae)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,ae)|0,r=r+Math.imul(k,le)|0,o=(o=o+Math.imul(k,ue)|0)+Math.imul(F,le)|0,i=i+Math.imul(F,ue)|0,r=r+Math.imul(D,he)|0,o=(o=o+Math.imul(D,de)|0)+Math.imul(x,he)|0,i=i+Math.imul(x,de)|0;var xe=(u+(r=r+Math.imul(M,fe)|0)|0)+((8191&(o=(o=o+Math.imul(M,me)|0)+Math.imul(C,fe)|0))<<13)|0;u=((i=i+Math.imul(C,me)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(P,ie),o=(o=Math.imul(P,ae))+Math.imul(B,ie)|0,i=Math.imul(B,ae),r=r+Math.imul(j,le)|0,o=(o=o+Math.imul(j,ue)|0)+Math.imul(R,le)|0,i=i+Math.imul(R,ue)|0,r=r+Math.imul(k,he)|0,o=(o=o+Math.imul(k,de)|0)+Math.imul(F,he)|0,i=i+Math.imul(F,de)|0;var Ne=(u+(r=r+Math.imul(D,fe)|0)|0)+((8191&(o=(o=o+Math.imul(D,me)|0)+Math.imul(x,fe)|0))<<13)|0;u=((i=i+Math.imul(x,me)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,r=Math.imul(P,le),o=(o=Math.imul(P,ue))+Math.imul(B,le)|0,i=Math.imul(B,ue),r=r+Math.imul(j,he)|0,o=(o=o+Math.imul(j,de)|0)+Math.imul(R,he)|0,i=i+Math.imul(R,de)|0;var ke=(u+(r=r+Math.imul(k,fe)|0)|0)+((8191&(o=(o=o+Math.imul(k,me)|0)+Math.imul(F,fe)|0))<<13)|0;u=((i=i+Math.imul(F,me)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(P,he),o=(o=Math.imul(P,de))+Math.imul(B,he)|0,i=Math.imul(B,de);var Fe=(u+(r=r+Math.imul(j,fe)|0)|0)+((8191&(o=(o=o+Math.imul(j,me)|0)+Math.imul(R,fe)|0))<<13)|0;u=((i=i+Math.imul(R,me)|0)+(o>>>13)|0)+(Fe>>>26)|0,Fe&=67108863;var Ie=(u+(r=Math.imul(P,fe))|0)+((8191&(o=(o=Math.imul(P,me))+Math.imul(B,fe)|0))<<13)|0;return u=((i=Math.imul(B,me))+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,l[0]=be,l[1]=ge,l[2]=ye,l[3]=ve,l[4]=we,l[5]=Ee,l[6]=Te,l[7]=_e,l[8]=Se,l[9]=Ae,l[10]=Me,l[11]=Ce,l[12]=Oe,l[13]=De,l[14]=xe,l[15]=Ne,l[16]=ke,l[17]=Fe,l[18]=Ie,0!==u&&(l[19]=u,n.length++),n};function m(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(f=p),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?f(this,e,t):r<63?p(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i>>26)|0)>>>26,a&=67108863}n.words[i]=s,r=a,a=o}return 0!==r?n.words[i]=r:n.length--,n.strip()}(this,e,t):m(this,e,t),n},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r>=1;return r},b.prototype.permute=function(e,t,n,r,o,i){for(var a=0;a>>=1)o++;return 1<>>=13,n[2*a+1]=8191&i,i>>>=13;for(a=2*t;a>=26,t+=o/67108864|0,t+=i>>>26,this.words[n]=67108863&i}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>o}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r=0);var t,n=e%26,o=(e-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<a)for(this.length-=a,u=0;u=0&&(0!==c||u>=o);u--){var h=0|this.words[u];this.words[u]=c<<26-i|h>>>i,c=h&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,o=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var o=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(l/67108864|0),this.words[o+n]=67108863&i}for(;o>26,this.words[o+n]=67108863&i;if(0===s)return this.strip();for(r(-1===s),s=0,o=0;o>26,this.words[o]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!=(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,l=r.length-o.length;if("mod"!==t){(s=new i(null)).length=l+1,s.words=new Array(s.length);for(var u=0;u=0;h--){var d=67108864*(0|r.words[o.length+h])+(0|r.words[o.length+h-1]);for(d=Math.min(d/a|0,67108863),r._ishlnsubmul(o,d,h);0!==r.negative;)d--,r.negative=0,r._ishlnsubmul(o,1,h),r.isZero()||(r.negative^=1);s&&(s.words[h]=d)}return s&&s.strip(),r.strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):this.negative&e.negative?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,o=this.length-1;o>=0;o--)n=(t*n+(0|this.words[o]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*t;this.words[n]=o/e|0,t=o%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),l=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var c=n.clone(),h=t.clone();!t.isZero();){for(var d=0,p=1;!(t.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(h)),o.iushrn(1),a.iushrn(1);for(var f=0,m=1;!(n.words[0]&m)&&f<26;++f,m<<=1);if(f>0)for(n.iushrn(f);f-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(c),l.isub(h)),s.iushrn(1),l.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(l)):(n.isub(t),s.isub(o),l.isub(a))}return{a:s,b:l,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),l=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,c=1;!(t.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(l),a.iushrn(1);for(var h=0,d=1;!(n.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(n.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,o=1<>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:oe.length)return 1;if(this.length=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){ro&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new _(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function T(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function S(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},o(v,y),v.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o>>22,i=a}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new w;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new T}return g[e]=t,t},_.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){r(!(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},_.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),l=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var h=this.pow(c,o),d=this.pow(e,o.addn(1).iushrn(1)),p=this.pow(e,o),f=a;0!==p.cmp(s);){for(var m=p,b=0;0!==m.cmp(s);b++)m=m.redSqr();r(b=0;r--){for(var u=t.words[r],c=l-1;c>=0;c--){var h=u>>c&1;o!==n[0]&&(o=this.sqr(o)),0!==h||0!==a?(a<<=1,a|=h,(4==++s||0===r&&0===c)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}l=26}return o},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new S(e)},o(S,_),S.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},S.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},S.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},S.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},S.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},94148:(e,t,n)=>{"use strict";var r=n(65606);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){for(var n=0;n1?n-1:0),o=1;o1?n-1:0),o=1;o1?n-1:0),o=1;o1?n-1:0),o=1;o{"use strict";var r=n(65606);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;te.length)&&(n=e.length),e.substring(n-t.length,n)===t}var v="",w="",E="",T="",_={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function S(e){var t=Object.keys(e),n=Object.create(Object.getPrototypeOf(e));return t.forEach((function(t){n[t]=e[t]})),Object.defineProperty(n,"message",{value:e.message}),n}function A(e){return b(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var M=function(e,t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(M,e);var n,o,s,c,h=(n=M,o=d(),function(){var e,t=f(n);if(o){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return l(this,e)});function M(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,M),"object"!==m(e)||null===e)throw new g("options","Object",e);var n=e.message,o=e.operator,i=e.stackStartFn,a=e.actual,s=e.expected,c=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=n)t=h.call(this,String(n));else if(r.stderr&&r.stderr.isTTY&&(r.stderr&&r.stderr.getColorDepth&&1!==r.stderr.getColorDepth()?(v="[34m",w="[32m",T="[39m",E="[31m"):(v="",w="",T="",E="")),"object"===m(a)&&null!==a&&"object"===m(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=S(a),s=S(s)),"deepStrictEqual"===o||"strictEqual"===o)t=h.call(this,function(e,t,n){var o="",i="",a=0,s="",l=!1,u=A(e),c=u.split("\n"),h=A(t).split("\n"),d=0,p="";if("strictEqual"===n&&"object"===m(e)&&"object"===m(t)&&null!==e&&null!==t&&(n="strictEqualObject"),1===c.length&&1===h.length&&c[0]!==h[0]){var f=c[0].length+h[0].length;if(f<=10){if(!("object"===m(e)&&null!==e||"object"===m(t)&&null!==t||0===e&&0===t))return"".concat(_[n],"\n\n")+"".concat(c[0]," !== ").concat(h[0],"\n")}else if("strictEqualObject"!==n&&f<(r.stderr&&r.stderr.isTTY?r.stderr.columns:80)){for(;c[0][d]===h[0][d];)d++;d>2&&(p="\n ".concat(function(e,t){if(t=Math.floor(t),0==e.length||0==t)return"";var n=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+e.substring(0,n-e.length)}(" ",d),"^"),d=0)}}for(var b=c[c.length-1],g=h[h.length-1];b===g&&(d++<2?s="\n ".concat(b).concat(s):o=b,c.pop(),h.pop(),0!==c.length&&0!==h.length);)b=c[c.length-1],g=h[h.length-1];var S=Math.max(c.length,h.length);if(0===S){var M=u.split("\n");if(M.length>30)for(M[26]="".concat(v,"...").concat(T);M.length>27;)M.pop();return"".concat(_.notIdentical,"\n\n").concat(M.join("\n"),"\n")}d>3&&(s="\n".concat(v,"...").concat(T).concat(s),l=!0),""!==o&&(s="\n ".concat(o).concat(s),o="");var C=0,O=_[n]+"\n".concat(w,"+ actual").concat(T," ").concat(E,"- expected").concat(T),D=" ".concat(v,"...").concat(T," Lines skipped");for(d=0;d1&&d>2&&(x>4?(i+="\n".concat(v,"...").concat(T),l=!0):x>3&&(i+="\n ".concat(h[d-2]),C++),i+="\n ".concat(h[d-1]),C++),a=d,o+="\n".concat(E,"-").concat(T," ").concat(h[d]),C++;else if(h.length1&&d>2&&(x>4?(i+="\n".concat(v,"...").concat(T),l=!0):x>3&&(i+="\n ".concat(c[d-2]),C++),i+="\n ".concat(c[d-1]),C++),a=d,i+="\n".concat(w,"+").concat(T," ").concat(c[d]),C++;else{var N=h[d],k=c[d],F=k!==N&&(!y(k,",")||k.slice(0,-1)!==N);F&&y(N,",")&&N.slice(0,-1)===k&&(F=!1,k+=","),F?(x>1&&d>2&&(x>4?(i+="\n".concat(v,"...").concat(T),l=!0):x>3&&(i+="\n ".concat(c[d-2]),C++),i+="\n ".concat(c[d-1]),C++),a=d,i+="\n".concat(w,"+").concat(T," ").concat(k),o+="\n".concat(E,"-").concat(T," ").concat(N),C+=2):(i+=o,o="",1!==x&&0!==d||(i+="\n ".concat(k),C++))}if(C>20&&d30)for(p[26]="".concat(v,"...").concat(T);p.length>27;)p.pop();t=1===p.length?h.call(this,"".concat(d," ").concat(p[0])):h.call(this,"".concat(d,"\n\n").concat(p.join("\n"),"\n"))}else{var f=A(a),b="",C=_[o];"notDeepEqual"===o||"notEqual"===o?(f="".concat(_[o],"\n\n").concat(f)).length>1024&&(f="".concat(f.slice(0,1021),"...")):(b="".concat(A(s)),f.length>512&&(f="".concat(f.slice(0,509),"...")),b.length>512&&(b="".concat(b.slice(0,509),"...")),"deepEqual"===o||"equal"===o?f="".concat(C,"\n\n").concat(f,"\n\nshould equal\n\n"):b=" ".concat(o," ").concat(b)),t=h.call(this,"".concat(f).concat(b))}return Error.stackTraceLimit=c,t.generatedMessage=!n,Object.defineProperty(u(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),t.code="ERR_ASSERTION",t.actual=a,t.expected=s,t.operator=o,Error.captureStackTrace&&Error.captureStackTrace(u(t),i),t.stack,t.name="AssertionError",l(t)}return s=M,(c=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(e,t){return b(this,i(i({},t),{},{customInspect:!1,depth:0}))}}])&&a(s.prototype,c),Object.defineProperty(s,"prototype",{writable:!1}),M}(c(Error),b.custom);e.exports=M},69597:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}var a,s,l={};function u(e,t,n){n||(n=Error);var a=function(n){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}(c,n);var a,s,l,u=(s=c,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=i(s);if(l){var n=i(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function c(n,r,o){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),i=u.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,o)),i.code=e,i}return a=c,Object.defineProperty(a,"prototype",{writable:!1}),a}(n);l[e]=a}function c(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}u("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),u("ERR_INVALID_ARG_TYPE",(function(e,t,o){var i,s,l,u,h;if(void 0===a&&(a=n(94148)),a("string"==typeof e,"'name' must be a string"),"string"==typeof t&&(s="not ",t.substr(0,4)===s)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-9,n)===t}(e," argument"))l="The ".concat(e," ").concat(i," ").concat(c(t,"type"));else{var d=("number"!=typeof h&&(h=0),h+1>(u=e).length||-1===u.indexOf(".",h)?"argument":"property");l='The "'.concat(e,'" ').concat(d," ").concat(i," ").concat(c(t,"type"))}return l+". Received type ".concat(r(o))}),TypeError),u("ERR_INVALID_ARG_VALUE",(function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===s&&(s=n(40537));var o=s.inspect(t);return o.length>128&&(o="".concat(o.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(o)}),TypeError,RangeError),u("ERR_INVALID_RETURN_VALUE",(function(e,t,n){var o;return o=n&&n.constructor&&n.constructor.name?"instance of ".concat(n.constructor.name):"type ".concat(r(n)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(o,".")}),TypeError),u("ERR_MISSING_ARGS",(function(){for(var e=arguments.length,t=new Array(e),r=0;r0,"At least one arg needs to be specified");var o="The ",i=t.length;switch(t=t.map((function(e){return'"'.concat(e,'"')})),i){case 1:o+="".concat(t[0]," argument");break;case 2:o+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:o+=t.slice(0,i-1).join(", "),o+=", and ".concat(t[i-1]," arguments")}return"".concat(o," must be specified")}),TypeError),e.exports.codes=l},82299:(e,t,n)=>{"use strict";function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],l=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n10)return!0;for(var t=0;t57)return!0}return 10===e.length&&e>=Math.pow(2,32)}function F(e){return Object.keys(e).filter(k).concat(c(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function I(e,t){if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o{var r=n(81102).JSDOM;e.exports=r},67526:(e,t)=>{"use strict";t.byteLength=function(e){var t=s(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,i=s(e),a=i[0],l=i[1],u=new o(function(e,t,n){return 3*(t+n)/4-n}(0,a,l)),c=0,h=l>0?a-4:a;for(n=0;n>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===l&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[c++]=255&t),1===l&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],a=16383,s=0,u=r-o;su?u:s+a));return 1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),i.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=i[a],r[i.charCodeAt(a)]=a;function s(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,r){for(var o,i,a=[],s=t;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},39404:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(47790).Buffer}catch(e){}function s(e,t){var n=e.charCodeAt(t);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+e)}function l(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,o){for(var i=0,a=0,s=Math.min(e.length,n),l=t;l=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this._strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=2)o=l(e,t,r)<=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,a=i%r,s=Math.min(i,i-a)+n,l=0,c=n;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(e){i.prototype.inspect=h}else i.prototype.inspect=h;function h(){return(this.red?""}var d=["","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"],p=[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],f=[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 m(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,l=a/67108864|0;n.words[0]=s;for(var u=1;u>>26,h=67108863&l,d=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=d;p++){var f=u-p|0;c+=(a=(o=0|e.words[f])*(i=0|t.words[p])+h)/67108864|0,h=67108863&a}n.words[u]=0|h,l=0|c}return 0!==l?n.words[u]=0|l:n.length--,n._strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var o=0,i=0,a=0;a>>24-o&16777215,(o+=2)>=26&&(o-=26,a--),n=0!==i||a!==this.length-1?d[6-l.length]+l+n:l+n}for(0!==i&&(n=i.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=p[e],c=f[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var m=h.modrn(c).toString(e);n=(h=h.idivn(c)).isZero()?m+n:d[u-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16,2)},a&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(a,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){this._strip();var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,i);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,o),a},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,o=0,i=0;o>8&255),n>16&255),6===i?(n>24&255),r=0,i=0):(r=a>>>24,i+=2)}if(n=0&&(e[n--]=a>>8&255),n>=0&&(e[n--]=a>>16&255),6===i?(n>=0&&(e[n--]=a>>24&255),r=0,i=0):(r=a>>>24,i+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 8191&t||(n+=13,t>>>=13),127&t||(n+=7,t>>>=7),15&t||(n+=4,t>>>=4),3&t||(n+=2,t>>>=2),1&t||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;ne.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;re.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var o=0;o0&&(this.words[o]=~this.words[o]&67108863>>26-n),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,o=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i>>26;for(;0!==o&&i>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;ie.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==i&&a>26,this.words[a]=67108863&t;if(0===i&&a>>13,p=0|a[1],f=8191&p,m=p>>>13,b=0|a[2],g=8191&b,y=b>>>13,v=0|a[3],w=8191&v,E=v>>>13,T=0|a[4],_=8191&T,S=T>>>13,A=0|a[5],M=8191&A,C=A>>>13,O=0|a[6],D=8191&O,x=O>>>13,N=0|a[7],k=8191&N,F=N>>>13,I=0|a[8],j=8191&I,R=I>>>13,L=0|a[9],P=8191&L,B=L>>>13,H=0|s[0],U=8191&H,G=H>>>13,W=0|s[1],V=8191&W,q=W>>>13,z=0|s[2],$=8191&z,Y=z>>>13,X=0|s[3],K=8191&X,Z=X>>>13,Q=0|s[4],J=8191&Q,ee=Q>>>13,te=0|s[5],ne=8191&te,re=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],le=8191&se,ue=se>>>13,ce=0|s[8],he=8191&ce,de=ce>>>13,pe=0|s[9],fe=8191&pe,me=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(r=Math.imul(h,U))|0)+((8191&(o=(o=Math.imul(h,G))+Math.imul(d,U)|0))<<13)|0;u=((i=Math.imul(d,G))+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(f,U),o=(o=Math.imul(f,G))+Math.imul(m,U)|0,i=Math.imul(m,G);var ge=(u+(r=r+Math.imul(h,V)|0)|0)+((8191&(o=(o=o+Math.imul(h,q)|0)+Math.imul(d,V)|0))<<13)|0;u=((i=i+Math.imul(d,q)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,U),o=(o=Math.imul(g,G))+Math.imul(y,U)|0,i=Math.imul(y,G),r=r+Math.imul(f,V)|0,o=(o=o+Math.imul(f,q)|0)+Math.imul(m,V)|0,i=i+Math.imul(m,q)|0;var ye=(u+(r=r+Math.imul(h,$)|0)|0)+((8191&(o=(o=o+Math.imul(h,Y)|0)+Math.imul(d,$)|0))<<13)|0;u=((i=i+Math.imul(d,Y)|0)+(o>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(w,U),o=(o=Math.imul(w,G))+Math.imul(E,U)|0,i=Math.imul(E,G),r=r+Math.imul(g,V)|0,o=(o=o+Math.imul(g,q)|0)+Math.imul(y,V)|0,i=i+Math.imul(y,q)|0,r=r+Math.imul(f,$)|0,o=(o=o+Math.imul(f,Y)|0)+Math.imul(m,$)|0,i=i+Math.imul(m,Y)|0;var ve=(u+(r=r+Math.imul(h,K)|0)|0)+((8191&(o=(o=o+Math.imul(h,Z)|0)+Math.imul(d,K)|0))<<13)|0;u=((i=i+Math.imul(d,Z)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(_,U),o=(o=Math.imul(_,G))+Math.imul(S,U)|0,i=Math.imul(S,G),r=r+Math.imul(w,V)|0,o=(o=o+Math.imul(w,q)|0)+Math.imul(E,V)|0,i=i+Math.imul(E,q)|0,r=r+Math.imul(g,$)|0,o=(o=o+Math.imul(g,Y)|0)+Math.imul(y,$)|0,i=i+Math.imul(y,Y)|0,r=r+Math.imul(f,K)|0,o=(o=o+Math.imul(f,Z)|0)+Math.imul(m,K)|0,i=i+Math.imul(m,Z)|0;var we=(u+(r=r+Math.imul(h,J)|0)|0)+((8191&(o=(o=o+Math.imul(h,ee)|0)+Math.imul(d,J)|0))<<13)|0;u=((i=i+Math.imul(d,ee)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(M,U),o=(o=Math.imul(M,G))+Math.imul(C,U)|0,i=Math.imul(C,G),r=r+Math.imul(_,V)|0,o=(o=o+Math.imul(_,q)|0)+Math.imul(S,V)|0,i=i+Math.imul(S,q)|0,r=r+Math.imul(w,$)|0,o=(o=o+Math.imul(w,Y)|0)+Math.imul(E,$)|0,i=i+Math.imul(E,Y)|0,r=r+Math.imul(g,K)|0,o=(o=o+Math.imul(g,Z)|0)+Math.imul(y,K)|0,i=i+Math.imul(y,Z)|0,r=r+Math.imul(f,J)|0,o=(o=o+Math.imul(f,ee)|0)+Math.imul(m,J)|0,i=i+Math.imul(m,ee)|0;var Ee=(u+(r=r+Math.imul(h,ne)|0)|0)+((8191&(o=(o=o+Math.imul(h,re)|0)+Math.imul(d,ne)|0))<<13)|0;u=((i=i+Math.imul(d,re)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(D,U),o=(o=Math.imul(D,G))+Math.imul(x,U)|0,i=Math.imul(x,G),r=r+Math.imul(M,V)|0,o=(o=o+Math.imul(M,q)|0)+Math.imul(C,V)|0,i=i+Math.imul(C,q)|0,r=r+Math.imul(_,$)|0,o=(o=o+Math.imul(_,Y)|0)+Math.imul(S,$)|0,i=i+Math.imul(S,Y)|0,r=r+Math.imul(w,K)|0,o=(o=o+Math.imul(w,Z)|0)+Math.imul(E,K)|0,i=i+Math.imul(E,Z)|0,r=r+Math.imul(g,J)|0,o=(o=o+Math.imul(g,ee)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,ee)|0,r=r+Math.imul(f,ne)|0,o=(o=o+Math.imul(f,re)|0)+Math.imul(m,ne)|0,i=i+Math.imul(m,re)|0;var Te=(u+(r=r+Math.imul(h,ie)|0)|0)+((8191&(o=(o=o+Math.imul(h,ae)|0)+Math.imul(d,ie)|0))<<13)|0;u=((i=i+Math.imul(d,ae)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(k,U),o=(o=Math.imul(k,G))+Math.imul(F,U)|0,i=Math.imul(F,G),r=r+Math.imul(D,V)|0,o=(o=o+Math.imul(D,q)|0)+Math.imul(x,V)|0,i=i+Math.imul(x,q)|0,r=r+Math.imul(M,$)|0,o=(o=o+Math.imul(M,Y)|0)+Math.imul(C,$)|0,i=i+Math.imul(C,Y)|0,r=r+Math.imul(_,K)|0,o=(o=o+Math.imul(_,Z)|0)+Math.imul(S,K)|0,i=i+Math.imul(S,Z)|0,r=r+Math.imul(w,J)|0,o=(o=o+Math.imul(w,ee)|0)+Math.imul(E,J)|0,i=i+Math.imul(E,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(y,ne)|0,i=i+Math.imul(y,re)|0,r=r+Math.imul(f,ie)|0,o=(o=o+Math.imul(f,ae)|0)+Math.imul(m,ie)|0,i=i+Math.imul(m,ae)|0;var _e=(u+(r=r+Math.imul(h,le)|0)|0)+((8191&(o=(o=o+Math.imul(h,ue)|0)+Math.imul(d,le)|0))<<13)|0;u=((i=i+Math.imul(d,ue)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(j,U),o=(o=Math.imul(j,G))+Math.imul(R,U)|0,i=Math.imul(R,G),r=r+Math.imul(k,V)|0,o=(o=o+Math.imul(k,q)|0)+Math.imul(F,V)|0,i=i+Math.imul(F,q)|0,r=r+Math.imul(D,$)|0,o=(o=o+Math.imul(D,Y)|0)+Math.imul(x,$)|0,i=i+Math.imul(x,Y)|0,r=r+Math.imul(M,K)|0,o=(o=o+Math.imul(M,Z)|0)+Math.imul(C,K)|0,i=i+Math.imul(C,Z)|0,r=r+Math.imul(_,J)|0,o=(o=o+Math.imul(_,ee)|0)+Math.imul(S,J)|0,i=i+Math.imul(S,ee)|0,r=r+Math.imul(w,ne)|0,o=(o=o+Math.imul(w,re)|0)+Math.imul(E,ne)|0,i=i+Math.imul(E,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0,r=r+Math.imul(f,le)|0,o=(o=o+Math.imul(f,ue)|0)+Math.imul(m,le)|0,i=i+Math.imul(m,ue)|0;var Se=(u+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,de)|0)+Math.imul(d,he)|0))<<13)|0;u=((i=i+Math.imul(d,de)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(P,U),o=(o=Math.imul(P,G))+Math.imul(B,U)|0,i=Math.imul(B,G),r=r+Math.imul(j,V)|0,o=(o=o+Math.imul(j,q)|0)+Math.imul(R,V)|0,i=i+Math.imul(R,q)|0,r=r+Math.imul(k,$)|0,o=(o=o+Math.imul(k,Y)|0)+Math.imul(F,$)|0,i=i+Math.imul(F,Y)|0,r=r+Math.imul(D,K)|0,o=(o=o+Math.imul(D,Z)|0)+Math.imul(x,K)|0,i=i+Math.imul(x,Z)|0,r=r+Math.imul(M,J)|0,o=(o=o+Math.imul(M,ee)|0)+Math.imul(C,J)|0,i=i+Math.imul(C,ee)|0,r=r+Math.imul(_,ne)|0,o=(o=o+Math.imul(_,re)|0)+Math.imul(S,ne)|0,i=i+Math.imul(S,re)|0,r=r+Math.imul(w,ie)|0,o=(o=o+Math.imul(w,ae)|0)+Math.imul(E,ie)|0,i=i+Math.imul(E,ae)|0,r=r+Math.imul(g,le)|0,o=(o=o+Math.imul(g,ue)|0)+Math.imul(y,le)|0,i=i+Math.imul(y,ue)|0,r=r+Math.imul(f,he)|0,o=(o=o+Math.imul(f,de)|0)+Math.imul(m,he)|0,i=i+Math.imul(m,de)|0;var Ae=(u+(r=r+Math.imul(h,fe)|0)|0)+((8191&(o=(o=o+Math.imul(h,me)|0)+Math.imul(d,fe)|0))<<13)|0;u=((i=i+Math.imul(d,me)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(P,V),o=(o=Math.imul(P,q))+Math.imul(B,V)|0,i=Math.imul(B,q),r=r+Math.imul(j,$)|0,o=(o=o+Math.imul(j,Y)|0)+Math.imul(R,$)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(k,K)|0,o=(o=o+Math.imul(k,Z)|0)+Math.imul(F,K)|0,i=i+Math.imul(F,Z)|0,r=r+Math.imul(D,J)|0,o=(o=o+Math.imul(D,ee)|0)+Math.imul(x,J)|0,i=i+Math.imul(x,ee)|0,r=r+Math.imul(M,ne)|0,o=(o=o+Math.imul(M,re)|0)+Math.imul(C,ne)|0,i=i+Math.imul(C,re)|0,r=r+Math.imul(_,ie)|0,o=(o=o+Math.imul(_,ae)|0)+Math.imul(S,ie)|0,i=i+Math.imul(S,ae)|0,r=r+Math.imul(w,le)|0,o=(o=o+Math.imul(w,ue)|0)+Math.imul(E,le)|0,i=i+Math.imul(E,ue)|0,r=r+Math.imul(g,he)|0,o=(o=o+Math.imul(g,de)|0)+Math.imul(y,he)|0,i=i+Math.imul(y,de)|0;var Me=(u+(r=r+Math.imul(f,fe)|0)|0)+((8191&(o=(o=o+Math.imul(f,me)|0)+Math.imul(m,fe)|0))<<13)|0;u=((i=i+Math.imul(m,me)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(P,$),o=(o=Math.imul(P,Y))+Math.imul(B,$)|0,i=Math.imul(B,Y),r=r+Math.imul(j,K)|0,o=(o=o+Math.imul(j,Z)|0)+Math.imul(R,K)|0,i=i+Math.imul(R,Z)|0,r=r+Math.imul(k,J)|0,o=(o=o+Math.imul(k,ee)|0)+Math.imul(F,J)|0,i=i+Math.imul(F,ee)|0,r=r+Math.imul(D,ne)|0,o=(o=o+Math.imul(D,re)|0)+Math.imul(x,ne)|0,i=i+Math.imul(x,re)|0,r=r+Math.imul(M,ie)|0,o=(o=o+Math.imul(M,ae)|0)+Math.imul(C,ie)|0,i=i+Math.imul(C,ae)|0,r=r+Math.imul(_,le)|0,o=(o=o+Math.imul(_,ue)|0)+Math.imul(S,le)|0,i=i+Math.imul(S,ue)|0,r=r+Math.imul(w,he)|0,o=(o=o+Math.imul(w,de)|0)+Math.imul(E,he)|0,i=i+Math.imul(E,de)|0;var Ce=(u+(r=r+Math.imul(g,fe)|0)|0)+((8191&(o=(o=o+Math.imul(g,me)|0)+Math.imul(y,fe)|0))<<13)|0;u=((i=i+Math.imul(y,me)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(P,K),o=(o=Math.imul(P,Z))+Math.imul(B,K)|0,i=Math.imul(B,Z),r=r+Math.imul(j,J)|0,o=(o=o+Math.imul(j,ee)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(k,ne)|0,o=(o=o+Math.imul(k,re)|0)+Math.imul(F,ne)|0,i=i+Math.imul(F,re)|0,r=r+Math.imul(D,ie)|0,o=(o=o+Math.imul(D,ae)|0)+Math.imul(x,ie)|0,i=i+Math.imul(x,ae)|0,r=r+Math.imul(M,le)|0,o=(o=o+Math.imul(M,ue)|0)+Math.imul(C,le)|0,i=i+Math.imul(C,ue)|0,r=r+Math.imul(_,he)|0,o=(o=o+Math.imul(_,de)|0)+Math.imul(S,he)|0,i=i+Math.imul(S,de)|0;var Oe=(u+(r=r+Math.imul(w,fe)|0)|0)+((8191&(o=(o=o+Math.imul(w,me)|0)+Math.imul(E,fe)|0))<<13)|0;u=((i=i+Math.imul(E,me)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(P,J),o=(o=Math.imul(P,ee))+Math.imul(B,J)|0,i=Math.imul(B,ee),r=r+Math.imul(j,ne)|0,o=(o=o+Math.imul(j,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(k,ie)|0,o=(o=o+Math.imul(k,ae)|0)+Math.imul(F,ie)|0,i=i+Math.imul(F,ae)|0,r=r+Math.imul(D,le)|0,o=(o=o+Math.imul(D,ue)|0)+Math.imul(x,le)|0,i=i+Math.imul(x,ue)|0,r=r+Math.imul(M,he)|0,o=(o=o+Math.imul(M,de)|0)+Math.imul(C,he)|0,i=i+Math.imul(C,de)|0;var De=(u+(r=r+Math.imul(_,fe)|0)|0)+((8191&(o=(o=o+Math.imul(_,me)|0)+Math.imul(S,fe)|0))<<13)|0;u=((i=i+Math.imul(S,me)|0)+(o>>>13)|0)+(De>>>26)|0,De&=67108863,r=Math.imul(P,ne),o=(o=Math.imul(P,re))+Math.imul(B,ne)|0,i=Math.imul(B,re),r=r+Math.imul(j,ie)|0,o=(o=o+Math.imul(j,ae)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,ae)|0,r=r+Math.imul(k,le)|0,o=(o=o+Math.imul(k,ue)|0)+Math.imul(F,le)|0,i=i+Math.imul(F,ue)|0,r=r+Math.imul(D,he)|0,o=(o=o+Math.imul(D,de)|0)+Math.imul(x,he)|0,i=i+Math.imul(x,de)|0;var xe=(u+(r=r+Math.imul(M,fe)|0)|0)+((8191&(o=(o=o+Math.imul(M,me)|0)+Math.imul(C,fe)|0))<<13)|0;u=((i=i+Math.imul(C,me)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(P,ie),o=(o=Math.imul(P,ae))+Math.imul(B,ie)|0,i=Math.imul(B,ae),r=r+Math.imul(j,le)|0,o=(o=o+Math.imul(j,ue)|0)+Math.imul(R,le)|0,i=i+Math.imul(R,ue)|0,r=r+Math.imul(k,he)|0,o=(o=o+Math.imul(k,de)|0)+Math.imul(F,he)|0,i=i+Math.imul(F,de)|0;var Ne=(u+(r=r+Math.imul(D,fe)|0)|0)+((8191&(o=(o=o+Math.imul(D,me)|0)+Math.imul(x,fe)|0))<<13)|0;u=((i=i+Math.imul(x,me)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,r=Math.imul(P,le),o=(o=Math.imul(P,ue))+Math.imul(B,le)|0,i=Math.imul(B,ue),r=r+Math.imul(j,he)|0,o=(o=o+Math.imul(j,de)|0)+Math.imul(R,he)|0,i=i+Math.imul(R,de)|0;var ke=(u+(r=r+Math.imul(k,fe)|0)|0)+((8191&(o=(o=o+Math.imul(k,me)|0)+Math.imul(F,fe)|0))<<13)|0;u=((i=i+Math.imul(F,me)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(P,he),o=(o=Math.imul(P,de))+Math.imul(B,he)|0,i=Math.imul(B,de);var Fe=(u+(r=r+Math.imul(j,fe)|0)|0)+((8191&(o=(o=o+Math.imul(j,me)|0)+Math.imul(R,fe)|0))<<13)|0;u=((i=i+Math.imul(R,me)|0)+(o>>>13)|0)+(Fe>>>26)|0,Fe&=67108863;var Ie=(u+(r=Math.imul(P,fe))|0)+((8191&(o=(o=Math.imul(P,me))+Math.imul(B,fe)|0))<<13)|0;return u=((i=Math.imul(B,me))+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,l[0]=be,l[1]=ge,l[2]=ye,l[3]=ve,l[4]=we,l[5]=Ee,l[6]=Te,l[7]=_e,l[8]=Se,l[9]=Ae,l[10]=Me,l[11]=Ce,l[12]=Oe,l[13]=De,l[14]=xe,l[15]=Ne,l[16]=ke,l[17]=Fe,l[18]=Ie,0!==u&&(l[19]=u,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i>>26)|0)>>>26,a&=67108863}n.words[i]=s,r=a,a=o}return 0!==r?n.words[i]=r:n.length--,n._strip()}function y(e,t,n){return g(e,t,n)}function v(e,t){this.x=e,this.y=t}Math.imul||(b=m),i.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?b(this,e,t):n<63?m(this,e,t):n<1024?g(this,e,t):y(this,e,t)},v.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r>=1;return r},v.prototype.permute=function(e,t,n,r,o,i){for(var a=0;a>>=1)o++;return 1<>>=13,n[2*a+1]=8191&i,i>>>=13;for(a=2*t;a>=26,n+=i/67108864|0,n+=a>>>26,this.words[o]=67108863&a}return 0!==n&&(this.words[o]=n,this.length++),t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n>>o&1}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r=0);var t,n=e%26,o=(e-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<a)for(this.length-=a,u=0;u=0&&(0!==c||u>=o);u--){var h=0|this.words[u];this.words[u]=c<<26-i|h>>>i,c=h&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,o=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var o=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(l/67108864|0),this.words[o+n]=67108863&i}for(;o>26,this.words[o+n]=67108863&i;if(0===s)return this._strip();for(r(-1===s),s=0,o=0;o>26,this.words[o]=67108863&i;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!=(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,l=r.length-o.length;if("mod"!==t){(s=new i(null)).length=l+1,s.words=new Array(s.length);for(var u=0;u=0;h--){var d=67108864*(0|r.words[o.length+h])+(0|r.words[o.length+h-1]);for(d=Math.min(d/a|0,67108863),r._ishlnsubmul(o,d,h);0!==r.negative;)d--,r.negative=0,r._ishlnsubmul(o,1,h),r.isZero()||(r.negative^=1);s&&(s.words[h]=d)}return s&&s._strip(),r._strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):this.negative&e.negative?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),r(e<=67108863);for(var n=(1<<26)%e,o=0,i=this.length-1;i>=0;i--)o=(n*o+(0|this.words[i]))%e;return t?-o:o},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),r(e<=67108863);for(var n=0,o=this.length-1;o>=0;o--){var i=(0|this.words[o])+67108864*n;this.words[o]=i/e|0,n=i%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),l=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var c=n.clone(),h=t.clone();!t.isZero();){for(var d=0,p=1;!(t.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(h)),o.iushrn(1),a.iushrn(1);for(var f=0,m=1;!(n.words[0]&m)&&f<26;++f,m<<=1);if(f>0)for(n.iushrn(f);f-- >0;)(s.isOdd()||l.isOdd())&&(s.iadd(c),l.isub(h)),s.iushrn(1),l.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(l)):(n.isub(t),s.isub(o),l.isub(a))}return{a:s,b:l,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),l=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,c=1;!(t.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(l),a.iushrn(1);for(var h=0,d=1;!(n.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(n.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,o=1<>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:oe.length)return 1;if(this.length=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){ro&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new M(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function E(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function T(){E.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){E.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){E.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){E.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function C(e){M.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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)}E.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},E.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},E.prototype.split=function(e,t){e.iushrn(this.n,0,t)},E.prototype.imulK=function(e){return e.imul(this.k)},o(T,E),T.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o>>22,i=a}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},T.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new T;else if("p224"===e)t=new _;else if("p192"===e)t=new S;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new A}return w[e]=t,t},M.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},M.prototype._verify2=function(e,t){r(!(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},M.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(c(e,e.umod(this.m)._forceRed(this)),e)},M.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},M.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},M.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},M.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},M.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},M.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},M.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},M.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},M.prototype.isqr=function(e){return this.imul(e,e.clone())},M.prototype.sqr=function(e){return this.mul(e,e)},M.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),l=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,u).cmp(l);)c.redIAdd(l);for(var h=this.pow(c,o),d=this.pow(e,o.addn(1).iushrn(1)),p=this.pow(e,o),f=a;0!==p.cmp(s);){for(var m=p,b=0;0!==m.cmp(s);b++)m=m.redSqr();r(b=0;r--){for(var u=t.words[r],c=l-1;c>=0;c--){var h=u>>c&1;o!==n[0]&&(o=this.sqr(o)),0!==h||0!==a?(a<<=1,a|=h,(4==++s||0===r&&0===c)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}l=26}return o},M.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},M.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new C(e)},o(C,M),C.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},C.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},C.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},C.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},C.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},15037:(e,t,n)=>{var r;function o(e){this.rand=e}if(e.exports=function(e){return r||(r=new o(null)),r.generate(e)},e.exports.Rand=o,o.prototype.generate=function(e){return this._rand(e)},o.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n{var r=n(92861).Buffer;function o(e){r.isBuffer(e)||(e=r.from(e));for(var t=e.length/4|0,n=new Array(t),o=0;o>>24]^c[f>>>16&255]^h[m>>>8&255]^d[255&b]^t[g++],a=u[f>>>24]^c[m>>>16&255]^h[b>>>8&255]^d[255&p]^t[g++],s=u[m>>>24]^c[b>>>16&255]^h[p>>>8&255]^d[255&f]^t[g++],l=u[b>>>24]^c[p>>>16&255]^h[f>>>8&255]^d[255&m]^t[g++],p=i,f=a,m=s,b=l;return i=(r[p>>>24]<<24|r[f>>>16&255]<<16|r[m>>>8&255]<<8|r[255&b])^t[g++],a=(r[f>>>24]<<24|r[m>>>16&255]<<16|r[b>>>8&255]<<8|r[255&p])^t[g++],s=(r[m>>>24]<<24|r[b>>>16&255]<<16|r[p>>>8&255]<<8|r[255&f])^t[g++],l=(r[b>>>24]<<24|r[p>>>16&255]<<16|r[f>>>8&255]<<8|r[255&m])^t[g++],[i>>>=0,a>>>=0,s>>>=0,l>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],l=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var n=[],r=[],o=[[],[],[],[]],i=[[],[],[],[]],a=0,s=0,l=0;l<256;++l){var u=s^s<<1^s<<2^s<<3^s<<4;u=u>>>8^255&u^99,n[a]=u,r[u]=a;var c=e[a],h=e[c],d=e[h],p=257*e[u]^16843008*u;o[0][a]=p<<24|p>>>8,o[1][a]=p<<16|p>>>16,o[2][a]=p<<8|p>>>24,o[3][a]=p,p=16843009*d^65537*h^257*c^16843008*a,i[0][u]=p<<24|p>>>8,i[1][u]=p<<16|p>>>16,i[2][u]=p<<8|p>>>24,i[3][u]=p,0===a?a=s=1:(a=c^e[e[e[d^c]]],s^=e[e[s]])}return{SBOX:n,INV_SBOX:r,SUB_MIX:o,INV_SUB_MIX:i}}();function u(e){this._key=o(e),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var e=this._key,t=e.length,n=t+6,r=4*(n+1),o=[],i=0;i>>24,a=l.SBOX[a>>>24]<<24|l.SBOX[a>>>16&255]<<16|l.SBOX[a>>>8&255]<<8|l.SBOX[255&a],a^=s[i/t|0]<<24):t>6&&i%t==4&&(a=l.SBOX[a>>>24]<<24|l.SBOX[a>>>16&255]<<16|l.SBOX[a>>>8&255]<<8|l.SBOX[255&a]),o[i]=o[i-t]^a}for(var u=[],c=0;c>>24]]^l.INV_SUB_MIX[1][l.SBOX[d>>>16&255]]^l.INV_SUB_MIX[2][l.SBOX[d>>>8&255]]^l.INV_SUB_MIX[3][l.SBOX[255&d]]}this._nRounds=n,this._keySchedule=o,this._invKeySchedule=u},u.prototype.encryptBlockRaw=function(e){return a(e=o(e),this._keySchedule,l.SUB_MIX,l.SBOX,this._nRounds)},u.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),n=r.allocUnsafe(16);return n.writeUInt32BE(t[0],0),n.writeUInt32BE(t[1],4),n.writeUInt32BE(t[2],8),n.writeUInt32BE(t[3],12),n},u.prototype.decryptBlock=function(e){var t=(e=o(e))[1];e[1]=e[3],e[3]=t;var n=a(e,this._invKeySchedule,l.INV_SUB_MIX,l.INV_SBOX,this._nRounds),i=r.allocUnsafe(16);return i.writeUInt32BE(n[0],0),i.writeUInt32BE(n[3],4),i.writeUInt32BE(n[2],8),i.writeUInt32BE(n[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},92356:(e,t,n)=>{var r=n(50462),o=n(92861).Buffer,i=n(56168),a=n(56698),s=n(25892),l=n(30295),u=n(45122);function c(e,t,n,a){i.call(this);var l=o.alloc(4,0);this._cipher=new r.AES(t);var c=this._cipher.encryptBlock(l);this._ghash=new s(c),n=function(e,t,n){if(12===t.length)return e._finID=o.concat([t,o.from([0,0,0,1])]),o.concat([t,o.from([0,0,0,2])]);var r=new s(n),i=t.length,a=i%16;r.update(t),a&&(a=16-a,r.update(o.alloc(a,0))),r.update(o.alloc(8,0));var l=8*i,c=o.alloc(8);c.writeUIntBE(l,0,8),r.update(c),e._finID=r.state;var h=o.from(e._finID);return u(h),h}(this,n,c),this._prev=o.from(n),this._cache=o.allocUnsafe(0),this._secCache=o.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}a(c,i),c.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=o.alloc(t,0),this._ghash.update(t))}this._called=!0;var n=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(n),this._len+=e.length,n},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=l(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var n=0;e.length!==t.length&&n++;for(var r=Math.min(e.length,t.length),o=0;o{var r=n(25799),o=n(36171),i=n(3219);t.createCipher=t.Cipher=r.createCipher,t.createCipheriv=t.Cipheriv=r.createCipheriv,t.createDecipher=t.Decipher=o.createDecipher,t.createDecipheriv=t.Decipheriv=o.createDecipheriv,t.listCiphers=t.getCiphers=function(){return Object.keys(i)}},36171:(e,t,n)=>{var r=n(92356),o=n(92861).Buffer,i=n(530),a=n(50650),s=n(56168),l=n(50462),u=n(68078);function c(e,t,n){s.call(this),this._cache=new h,this._last=void 0,this._cipher=new l.AES(t),this._prev=o.from(n),this._mode=e,this._autopadding=!0}function h(){this.cache=o.allocUnsafe(0)}function d(e,t,n){var s=i[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof n&&(n=o.from(n)),"GCM"!==s.mode&&n.length!==s.iv)throw new TypeError("invalid iv length "+n.length);if("string"==typeof t&&(t=o.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===s.type?new a(s.module,t,n,!0):"auth"===s.type?new r(s.module,t,n,!0):new c(s.module,t,n)}n(56698)(c,s),c.prototype._update=function(e){var t,n;this._cache.add(e);for(var r=[];t=this._cache.get(this._autopadding);)n=this._mode.decrypt(this,t),r.push(n);return o.concat(r)},c.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");for(var n=-1;++n16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(e,t){var n=i[e.toLowerCase()];if(!n)throw new TypeError("invalid suite type");var r=u(t,!1,n.key,n.iv);return d(e,r.key,r.iv)},t.createDecipheriv=d},25799:(e,t,n)=>{var r=n(530),o=n(92356),i=n(92861).Buffer,a=n(50650),s=n(56168),l=n(50462),u=n(68078);function c(e,t,n){s.call(this),this._cache=new d,this._cipher=new l.AES(t),this._prev=i.from(n),this._mode=e,this._autopadding=!0}n(56698)(c,s),c.prototype._update=function(e){var t,n;this._cache.add(e);for(var r=[];t=this._cache.get();)n=this._mode.encrypt(this,t),r.push(n);return i.concat(r)};var h=i.alloc(16,16);function d(){this.cache=i.allocUnsafe(0)}function p(e,t,n){var s=r[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=i.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof n&&(n=i.from(n)),"GCM"!==s.mode&&n.length!==s.iv)throw new TypeError("invalid iv length "+n.length);return"stream"===s.type?new a(s.module,t,n):"auth"===s.type?new o(s.module,t,n):new c(s.module,t,n)}c.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},d.prototype.add=function(e){this.cache=i.concat([this.cache,e])},d.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},d.prototype.flush=function(){for(var e=16-this.cache.length,t=i.allocUnsafe(e),n=-1;++n{var r=n(92861).Buffer,o=r.alloc(16,0);function i(e){var t=r.allocUnsafe(16);return t.writeUInt32BE(e[0]>>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function a(e){this.h=e,this.state=r.alloc(16,0),this.cache=r.allocUnsafe(0)}a.prototype.ghash=function(e){for(var t=-1;++t0;t--)r[t]=r[t]>>>1|(1&r[t-1])<<31;r[0]=r[0]>>>1,n&&(r[0]=r[0]^225<<24)}this.state=i(o)},a.prototype.update=function(e){var t;for(this.cache=r.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},a.prototype.final=function(e,t){return this.cache.length&&this.ghash(r.concat([this.cache,o],16)),this.ghash(i([0,e,0,t])),this.state},e.exports=a},45122:e=>{e.exports=function(e){for(var t,n=e.length;n--;){if(255!==(t=e.readUInt8(n))){t++,e.writeUInt8(t,n);break}e.writeUInt8(0,n)}}},92884:(e,t,n)=>{var r=n(30295);t.encrypt=function(e,t){var n=r(t,e._prev);return e._prev=e._cipher.encryptBlock(n),e._prev},t.decrypt=function(e,t){var n=e._prev;e._prev=t;var o=e._cipher.decryptBlock(t);return r(o,n)}},46383:(e,t,n)=>{var r=n(92861).Buffer,o=n(30295);function i(e,t,n){var i=t.length,a=o(t,e._cache);return e._cache=e._cache.slice(i),e._prev=r.concat([e._prev,n?t:a]),a}t.encrypt=function(e,t,n){for(var o,a=r.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=r.allocUnsafe(0)),!(e._cache.length<=t.length)){a=r.concat([a,i(e,t,n)]);break}o=e._cache.length,a=r.concat([a,i(e,t.slice(0,o),n)]),t=t.slice(o)}return a}},55264:(e,t,n)=>{var r=n(92861).Buffer;function o(e,t,n){for(var r,o,a=-1,s=0;++a<8;)r=t&1<<7-a?128:0,s+=(128&(o=e._cipher.encryptBlock(e._prev)[0]^r))>>a%8,e._prev=i(e._prev,n?r:o);return s}function i(e,t){var n=e.length,o=-1,i=r.allocUnsafe(e.length);for(e=r.concat([e,r.from([t])]);++o>7;return i}t.encrypt=function(e,t,n){for(var i=t.length,a=r.allocUnsafe(i),s=-1;++s{var r=n(92861).Buffer;function o(e,t,n){var o=e._cipher.encryptBlock(e._prev)[0]^t;return e._prev=r.concat([e._prev.slice(1),r.from([n?t:o])]),o}t.encrypt=function(e,t,n){for(var i=t.length,a=r.allocUnsafe(i),s=-1;++s{var r=n(30295),o=n(92861).Buffer,i=n(45122);function a(e){var t=e._cipher.encryptBlockRaw(e._prev);return i(e._prev),t}t.encrypt=function(e,t){var n=Math.ceil(t.length/16),i=e._cache.length;e._cache=o.concat([e._cache,o.allocUnsafe(16*n)]);for(var s=0;s{t.encrypt=function(e,t){return e._cipher.encryptBlock(t)},t.decrypt=function(e,t){return e._cipher.decryptBlock(t)}},530:(e,t,n)=>{var r={ECB:n(52632),CBC:n(92884),CFB:n(46383),CFB8:n(86975),CFB1:n(55264),OFB:n(46843),CTR:n(63053),GCM:n(63053)},o=n(3219);for(var i in o)o[i].module=r[o[i].mode];e.exports=o},46843:(e,t,n)=>{var r=n(48287).Buffer,o=n(30295);function i(e){return e._prev=e._cipher.encryptBlock(e._prev),e._prev}t.encrypt=function(e,t){for(;e._cache.length{var r=n(50462),o=n(92861).Buffer,i=n(56168);function a(e,t,n,a){i.call(this),this._cipher=new r.AES(t),this._prev=o.from(n),this._cache=o.allocUnsafe(0),this._secCache=o.allocUnsafe(0),this._decrypt=a,this._mode=e}n(56698)(a,i),a.prototype._update=function(e){return this._mode.encrypt(this,e,this._decrypt)},a.prototype._final=function(){this._cipher.scrub()},e.exports=a},30125:(e,t,n)=>{var r=n(84050),o=n(1241),i=n(530),a=n(32438),s=n(68078);function l(e,t,n){if(e=e.toLowerCase(),i[e])return o.createCipheriv(e,t,n);if(a[e])return new r({key:t,iv:n,mode:e});throw new TypeError("invalid suite type")}function u(e,t,n){if(e=e.toLowerCase(),i[e])return o.createDecipheriv(e,t,n);if(a[e])return new r({key:t,iv:n,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}t.createCipher=t.Cipher=function(e,t){var n,r;if(e=e.toLowerCase(),i[e])n=i[e].key,r=i[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");n=8*a[e].key,r=a[e].iv}var o=s(t,!1,n,r);return l(e,o.key,o.iv)},t.createCipheriv=t.Cipheriv=l,t.createDecipher=t.Decipher=function(e,t){var n,r;if(e=e.toLowerCase(),i[e])n=i[e].key,r=i[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");n=8*a[e].key,r=a[e].iv}var o=s(t,!1,n,r);return u(e,o.key,o.iv)},t.createDecipheriv=t.Decipheriv=u,t.listCiphers=t.getCiphers=function(){return Object.keys(a).concat(o.getCiphers())}},84050:(e,t,n)=>{var r=n(56168),o=n(29560),i=n(56698),a=n(92861).Buffer,s={"des-ede3-cbc":o.CBC.instantiate(o.EDE),"des-ede3":o.EDE,"des-ede-cbc":o.CBC.instantiate(o.EDE),"des-ede":o.EDE,"des-cbc":o.CBC.instantiate(o.DES),"des-ecb":o.DES};function l(e){r.call(this);var t,n=e.mode.toLowerCase(),o=s[n];t=e.decrypt?"decrypt":"encrypt";var i=e.key;a.isBuffer(i)||(i=a.from(i)),"des-ede"!==n&&"des-ede-cbc"!==n||(i=a.concat([i,i.slice(0,8)]));var l=e.iv;a.isBuffer(l)||(l=a.from(l)),this._des=o.create({key:i,iv:l,type:t})}s.des=s["des-cbc"],s.des3=s["des-ede3-cbc"],e.exports=l,i(l,r),l.prototype._update=function(e){return a.from(this._des.update(e))},l.prototype._final=function(){return a.from(this._des.final())}},32438:(e,t)=>{t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}},67332:(e,t,n)=>{"use strict";var r=n(39404),o=n(53209),i=n(92861).Buffer;function a(e){var t,n=e.modulus.byteLength();do{t=new r(o(n))}while(t.cmp(e.modulus)>=0||!t.umod(e.prime1)||!t.umod(e.prime2));return t}function s(e,t){var n=function(e){var t=a(e);return{blinder:t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed(),unblinder:t.invm(e.modulus)}}(t),o=t.modulus.byteLength(),s=new r(e).mul(n.blinder).umod(t.modulus),l=s.toRed(r.mont(t.prime1)),u=s.toRed(r.mont(t.prime2)),c=t.coefficient,h=t.prime1,d=t.prime2,p=l.redPow(t.exponent1).fromRed(),f=u.redPow(t.exponent2).fromRed(),m=p.isub(f).imul(c).umod(h).imul(d);return f.iadd(m).imul(n.unblinder).umod(t.modulus).toArrayLike(i,"be",o)}s.getr=a,e.exports=s},55715:(e,t,n)=>{"use strict";e.exports=n(62951)},20:(e,t,n)=>{"use strict";var r=n(92861).Buffer,o=n(47108),i=n(46737),a=n(56698),s=n(35359),l=n(74847),u=n(62951);function c(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=o(t.hash),this._tag=t.id,this._signType=t.sign}function h(e){i.Writable.call(this);var t=u[e];if(!t)throw new Error("Unknown message digest");this._hash=o(t.hash),this._tag=t.id,this._signType=t.sign}function d(e){return new c(e)}function p(e){return new h(e)}Object.keys(u).forEach((function(e){u[e].id=r.from(u[e].id,"hex"),u[e.toLowerCase()]=u[e]})),a(c,i.Writable),c.prototype._write=function(e,t,n){this._hash.update(e),n()},c.prototype.update=function(e,t){return this._hash.update("string"==typeof e?r.from(e,t):e),this},c.prototype.sign=function(e,t){this.end();var n=this._hash.digest(),r=s(n,e,this._hashType,this._signType,this._tag);return t?r.toString(t):r},a(h,i.Writable),h.prototype._write=function(e,t,n){this._hash.update(e),n()},h.prototype.update=function(e,t){return this._hash.update("string"==typeof e?r.from(e,t):e),this},h.prototype.verify=function(e,t,n){var o="string"==typeof t?r.from(t,n):t;this.end();var i=this._hash.digest();return l(o,i,e,this._signType,this._tag)},e.exports={Sign:d,Verify:p,createSign:d,createVerify:p}},35359:(e,t,n)=>{"use strict";var r=n(92861).Buffer,o=n(83507),i=n(67332),a=n(86729).ec,s=n(39404),l=n(78170),u=n(64589);function c(e,t,n,i){if((e=r.from(e.toArray())).length0&&n.ishrn(r),n}function d(e,t,n){var i,a;do{for(i=r.alloc(0);8*i.length{"use strict";var r=n(92861).Buffer,o=n(39404),i=n(86729).ec,a=n(78170),s=n(64589);function l(e,t){if(e.cmpn(0)<=0)throw new Error("invalid sig");if(e.cmp(t)>=0)throw new Error("invalid sig")}e.exports=function(e,t,n,u,c){var h=a(n);if("ec"===h.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(e,t,n){var r=s[n.data.algorithm.curve.join(".")];if(!r)throw new Error("unknown curve "+n.data.algorithm.curve.join("."));var o=new i(r),a=n.data.subjectPrivateKey.data;return o.verify(t,e,a)}(e,t,h)}if("dsa"===h.type){if("dsa"!==u)throw new Error("wrong public key type");return function(e,t,n){var r=n.data.p,i=n.data.q,s=n.data.g,u=n.data.pub_key,c=a.signature.decode(e,"der"),h=c.s,d=c.r;l(h,i),l(d,i);var p=o.mont(r),f=h.invm(i);return 0===s.toRed(p).redPow(new o(t).mul(f).mod(i)).fromRed().mul(u.toRed(p).redPow(d.mul(f).mod(i)).fromRed()).mod(r).mod(i).cmp(d)}(e,t,h)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");t=r.concat([c,t]);for(var d=h.modulus.byteLength(),p=[1],f=0;t.length+p.length+2{"use strict";var r=n(33225),o=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=h;var i=Object.create(n(15622));i.inherits=n(56698);var a=n(30206),s=n(7314);i.inherits(h,a);for(var l=o(s.prototype),u=0;u{"use strict";e.exports=i;var r=n(81816),o=Object.create(n(15622));function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}o.inherits=n(56698),o.inherits(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},30206:(e,t,n)=>{"use strict";var r=n(65606),o=n(33225);e.exports=v;var i,a=n(64634);v.ReadableState=y,n(37007).EventEmitter;var s=function(e,t){return e.listeners(t).length},l=n(5567),u=n(24116).Buffer,c=(void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},h=Object.create(n(15622));h.inherits=n(56698);var d=n(92668),p=void 0;p=d&&d.debuglog?d.debuglog("stream"):function(){};var f,m=n(20672),b=n(36278);h.inherits(v,l);var g=["error","close","destroy","pause","resume"];function y(e,t){e=e||{};var r=t instanceof(i=i||n(26248));this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var o=e.highWaterMark,a=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=o||0===o?o:r&&(a||0===a)?a:s,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=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=n(6427).I),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function v(e){if(i=i||n(26248),!(this instanceof v))return new v(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),l.call(this)}function w(e,t,n,r,o){var i,a=e._readableState;return null===t?(a.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,S(e)}}(e,a)):(o||(i=function(e,t){var n,r;return r=t,u.isBuffer(r)||r instanceof c||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}(a,t)),i?e.emit("error",i):a.objectMode||t&&t.length>0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),r?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):E(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?E(e,a,t,!1):M(e,a)):E(e,a,t,!1))):r||(a.reading=!1)),function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=T?e=T:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?o.nextTick(A,e):A(e))}function A(e){p("emit readable"),e.emit("readable"),x(e)}function M(e,t){t.readingMore||(t.readingMore=!0,o.nextTick(C,e,t))}function C(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;return ei.length?i.length:e;if(a===i.length?o+=i:o+=i.slice(0,e),0==(e-=a)){a===i.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(a));break}++r}return t.length-=r,o}(e,t):function(e,t){var n=u.allocUnsafe(e),r=t.head,o=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var i=r.data,a=e>i.length?i.length:e;if(i.copy(n,n.length-e,0,a),0==(e-=a)){a===i.length?(++o,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(a));break}++o}return t.length-=o,n}(e,t),r}(e,t.buffer,t.decoder),n);var n}function k(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,o.nextTick(F,t,e))}function F(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function I(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?k(this):S(this),null;if(0===(e=_(e,t))&&t.ended)return 0===t.length&&k(this),null;var r,o=t.needReadable;return p("need readable",o),(0===t.length||t.length-e0?N(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&k(this)),null!==r&&this.emit("data",r),r},v.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(e,t){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,p("pipe count=%d opts=%j",i.pipesCount,t);var l=t&&!1===t.end||e===r.stdout||e===r.stderr?y:u;function u(){p("onend"),e.end()}i.endEmitted?o.nextTick(l):n.once("end",l),e.on("unpipe",(function t(r,o){p("onunpipe"),r===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,p("cleanup"),e.removeListener("close",b),e.removeListener("finish",g),e.removeListener("drain",c),e.removeListener("error",m),e.removeListener("unpipe",t),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",f),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}));var c=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,x(e))}}(n);e.on("drain",c);var h=!1,d=!1;function f(t){p("ondata"),d=!1,!1!==e.write(t)||d||((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==I(i.pipes,e))&&!h&&(p("false write response, pause",i.awaitDrain),i.awaitDrain++,d=!0),n.pause())}function m(t){p("onerror",t),y(),e.removeListener("error",m),0===s(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",g),y()}function g(){p("onfinish"),e.removeListener("close",b),y()}function y(){p("unpipe"),n.unpipe(e)}return n.on("data",f),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",m),e.once("close",b),e.once("finish",g),e.emit("pipe",n),i.flowing||(p("pipe resume"),n.resume()),e},v.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i{"use strict";e.exports=a;var r=n(26248),o=Object.create(n(15622));function i(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length{"use strict";var r=n(65606),o=n(33225);function i(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t){var n=e.entry;for(e.entry=null;n;){var r=n.callback;t.pendingcb--,r(undefined),n=n.next}t.corkedRequestsFree.next=e}(t,e)}}e.exports=g;var a,s=!r.browser&&["v0.10","v0.9."].indexOf(r.version.slice(0,5))>-1?setImmediate:o.nextTick;g.WritableState=b;var l=Object.create(n(15622));l.inherits=n(56698);var u,c={deprecate:n(94643)},h=n(5567),d=n(24116).Buffer,p=(void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=n(36278);function m(){}function b(e,t){a=a||n(26248),e=e||{};var r=t instanceof a;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var l=e.highWaterMark,u=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=l||0===l?l:r&&(u||0===u)?u:c,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 h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(_,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),_(e,t))}(e,n,r,t,i);else{var a=E(n);a||n.corked||n.bufferProcessing||!n.bufferedRequest||w(e,n),r?s(v,e,n,a,i):v(e,n,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function g(e){if(a=a||n(26248),!(u.call(g,this)||this instanceof a))return new g(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function y(e,t,n,r,o,i,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function v(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),_(e,t)}function w(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,o=new Array(r),a=t.corkedRequestsFree;a.entry=n;for(var s=0,l=!0;n;)o[s]=n,n.isBuf||(l=!1),n=n.next,s+=1;o.allBuffers=l,y(e,t,!0,t.length,o,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new i(t),t.bufferedRequestCount=0}else{for(;n;){var u=n.chunk,c=n.encoding,h=n.callback;if(y(e,t,!1,t.objectMode?1:u.length,u,c,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function E(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function T(e,t){e._final((function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),_(e,t)}))}function _(e,t){var n=E(t);return n&&(function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(T,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}l.inherits(g,h),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(e){return!!u.call(this,e)||this===g&&e&&e._writableState instanceof b}})):u=function(e){return e instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,s=!i.objectMode&&(r=e,d.isBuffer(r)||r instanceof p);return s&&!d.isBuffer(e)&&(e=function(e){return d.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=m),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var i=!0,a=!1;return null===n?a=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(r,a),i=!1),i}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,o,i){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=d.from(t,n)),t}(t,r,o);r!==a&&(n=!0,o="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var l=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,_(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),g.prototype.destroy=f.destroy,g.prototype._undestroy=f.undestroy,g.prototype._destroy=function(e,t){this.end(),t(e)}},20672:(e,t,n)=>{"use strict";var r=n(24116).Buffer,o=n(21638);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);for(var t,n,o=r.allocUnsafe(e>>>0),i=this.head,a=0;i;)t=o,n=a,i.data.copy(t,n),a+=i.data.length,i=i.next;return o},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},36278:(e,t,n)=>{"use strict";var r=n(33225);function o(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(o,this,e)):r.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,r.nextTick(o,n,e)):r.nextTick(o,n,e):t&&t(e)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},5567:(e,t,n)=>{e.exports=n(37007).EventEmitter},24116:(e,t,n)=>{var r=n(48287),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=a),i(o,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},46737:(e,t,n)=>{(t=e.exports=n(30206)).Stream=t,t.Readable=t,t.Writable=n(7314),t.Duplex=n(26248),t.Transform=n(81816),t.PassThrough=n(75242)},6427:(e,t,n)=>{"use strict";var r=n(88393).Buffer,o=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=u,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=c,this.end=h,t=3;break;default:return this.write=d,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,n=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function c(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}t.I=i,i.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(o>0&&(e.lastNeed=o-1),o):--r=0?(o>0&&(e.lastNeed=o-2),o):--r=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},88393:(e,t,n)=>{var r=n(48287),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=a),i(o,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},5974:(e,t,n)=>{"use strict";var r=n(48287).Buffer,o=n(65606),i=n(94148),a=n(44442),s=n(58411),l=n(71447),u=n(19681);for(var c in u)t[c]=u[c];function h(e){if("number"!=typeof e||et.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=e,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}t.NONE=0,t.DEFLATE=1,t.INFLATE=2,t.GZIP=3,t.GUNZIP=4,t.DEFLATERAW=5,t.INFLATERAW=6,t.UNZIP=7,h.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,i(this.init_done,"close before init"),i(this.mode<=t.UNZIP),this.mode===t.DEFLATE||this.mode===t.GZIP||this.mode===t.DEFLATERAW?s.deflateEnd(this.strm):this.mode!==t.INFLATE&&this.mode!==t.GUNZIP&&this.mode!==t.INFLATERAW&&this.mode!==t.UNZIP||l.inflateEnd(this.strm),this.mode=t.NONE,this.dictionary=null)},h.prototype.write=function(e,t,n,r,o,i,a){return this._write(!0,e,t,n,r,o,i,a)},h.prototype.writeSync=function(e,t,n,r,o,i,a){return this._write(!1,e,t,n,r,o,i,a)},h.prototype._write=function(e,n,a,s,l,u,c,h){if(i.equal(arguments.length,8),i(this.init_done,"write before init"),i(this.mode!==t.NONE,"already finalized"),i.equal(!1,this.write_in_progress,"write already in progress"),i.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,i.equal(!1,void 0===n,"must provide flush value"),this.write_in_progress=!0,n!==t.Z_NO_FLUSH&&n!==t.Z_PARTIAL_FLUSH&&n!==t.Z_SYNC_FLUSH&&n!==t.Z_FULL_FLUSH&&n!==t.Z_FINISH&&n!==t.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=r.alloc(0),l=0,s=0),this.strm.avail_in=l,this.strm.input=a,this.strm.next_in=s,this.strm.avail_out=h,this.strm.output=u,this.strm.next_out=c,this.flush=n,!e)return this._process(),this._checkError()?this._afterSync():void 0;var d=this;return o.nextTick((function(){d._process(),d._after()})),this},h.prototype._afterSync=function(){var e=this.strm.avail_out,t=this.strm.avail_in;return this.write_in_progress=!1,[t,e]},h.prototype._process=function(){var e=null;switch(this.mode){case t.DEFLATE:case t.GZIP:case t.DEFLATERAW:this.err=s.deflate(this.strm,this.flush);break;case t.UNZIP:switch(this.strm.avail_in>0&&(e=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===e)break;if(31!==this.strm.input[e]){this.mode=t.INFLATE;break}if(this.gzip_id_bytes_read=1,e++,1===this.strm.avail_in)break;case 1:if(null===e)break;139===this.strm.input[e]?(this.gzip_id_bytes_read=2,this.mode=t.GUNZIP):this.mode=t.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case t.INFLATE:case t.GUNZIP:case t.INFLATERAW:for(this.err=l.inflate(this.strm,this.flush),this.err===t.Z_NEED_DICT&&this.dictionary&&(this.err=l.inflateSetDictionary(this.strm,this.dictionary),this.err===t.Z_OK?this.err=l.inflate(this.strm,this.flush):this.err===t.Z_DATA_ERROR&&(this.err=t.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===t.GUNZIP&&this.err===t.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=l.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},h.prototype._checkError=function(){switch(this.err){case t.Z_OK:case t.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===t.Z_FINISH)return this._error("unexpected end of file"),!1;break;case t.Z_STREAM_END:break;case t.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},h.prototype._after=function(){if(this._checkError()){var e=this.strm.avail_out,t=this.strm.avail_in;this.write_in_progress=!1,this.callback(t,e),this.pending_close&&this.close()}},h.prototype._error=function(e){this.strm.msg&&(e=this.strm.msg),this.onerror(e,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},h.prototype.init=function(e,n,r,o,a){i(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),i(e>=8&&e<=15,"invalid windowBits"),i(n>=-1&&n<=9,"invalid compression level"),i(r>=1&&r<=9,"invalid memlevel"),i(o===t.Z_FILTERED||o===t.Z_HUFFMAN_ONLY||o===t.Z_RLE||o===t.Z_FIXED||o===t.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(n,e,r,o,a),this._setDictionary()},h.prototype.params=function(){throw new Error("deflateParams Not supported")},h.prototype.reset=function(){this._reset(),this._setDictionary()},h.prototype._init=function(e,n,r,o,i){switch(this.level=e,this.windowBits=n,this.memLevel=r,this.strategy=o,this.flush=t.Z_NO_FLUSH,this.err=t.Z_OK,this.mode!==t.GZIP&&this.mode!==t.GUNZIP||(this.windowBits+=16),this.mode===t.UNZIP&&(this.windowBits+=32),this.mode!==t.DEFLATERAW&&this.mode!==t.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case t.DEFLATE:case t.GZIP:case t.DEFLATERAW:this.err=s.deflateInit2(this.strm,this.level,t.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case t.INFLATE:case t.GUNZIP:case t.INFLATERAW:case t.UNZIP:this.err=l.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==t.Z_OK&&this._error("Init error"),this.dictionary=i,this.write_in_progress=!1,this.init_done=!0},h.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=t.Z_OK,this.mode){case t.DEFLATE:case t.DEFLATERAW:this.err=s.deflateSetDictionary(this.strm,this.dictionary)}this.err!==t.Z_OK&&this._error("Failed to set dictionary")}},h.prototype._reset=function(){switch(this.err=t.Z_OK,this.mode){case t.DEFLATE:case t.DEFLATERAW:case t.GZIP:this.err=s.deflateReset(this.strm);break;case t.INFLATE:case t.INFLATERAW:case t.GUNZIP:this.err=l.inflateReset(this.strm)}this.err!==t.Z_OK&&this._error("Failed to reset stream")},t.Zlib=h},78559:(e,t,n)=>{"use strict";var r=n(65606),o=n(48287).Buffer,i=n(88310).Transform,a=n(5974),s=n(40537),l=n(94148).ok,u=n(48287).kMaxLength,c="Cannot create final Buffer. It would be larger than 0x"+u.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var h=Object.keys(a),d=0;d=u?a=new RangeError(c):t=o.concat(r,i),r=[],e.close(),n(a,t)}e.on("error",(function(t){e.removeListener("end",s),e.removeListener("readable",a),n(t)})),e.on("end",s),e.end(t),a()}function v(e,t){if("string"==typeof t&&(t=o.from(t)),!o.isBuffer(t))throw new TypeError("Not a string or buffer");var n=e._finishFlushFlag;return e._processChunk(t,n)}function w(e){if(!(this instanceof w))return new w(e);O.call(this,e,a.DEFLATE)}function E(e){if(!(this instanceof E))return new E(e);O.call(this,e,a.INFLATE)}function T(e){if(!(this instanceof T))return new T(e);O.call(this,e,a.GZIP)}function _(e){if(!(this instanceof _))return new _(e);O.call(this,e,a.GUNZIP)}function S(e){if(!(this instanceof S))return new S(e);O.call(this,e,a.DEFLATERAW)}function A(e){if(!(this instanceof A))return new A(e);O.call(this,e,a.INFLATERAW)}function M(e){if(!(this instanceof M))return new M(e);O.call(this,e,a.UNZIP)}function C(e){return e===a.Z_NO_FLUSH||e===a.Z_PARTIAL_FLUSH||e===a.Z_SYNC_FLUSH||e===a.Z_FULL_FLUSH||e===a.Z_FINISH||e===a.Z_BLOCK}function O(e,n){var r=this;if(this._opts=e=e||{},this._chunkSize=e.chunkSize||t.Z_DEFAULT_CHUNK,i.call(this,e),e.flush&&!C(e.flush))throw new Error("Invalid flush flag: "+e.flush);if(e.finishFlush&&!C(e.finishFlush))throw new Error("Invalid flush flag: "+e.finishFlush);if(this._flushFlag=e.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==e.finishFlush?e.finishFlush:a.Z_FINISH,e.chunkSize&&(e.chunkSizet.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitst.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelt.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelt.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=t.Z_FILTERED&&e.strategy!=t.Z_HUFFMAN_ONLY&&e.strategy!=t.Z_RLE&&e.strategy!=t.Z_FIXED&&e.strategy!=t.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!o.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(n);var s=this;this._hadError=!1,this._handle.onerror=function(e,n){D(s),s._hadError=!0;var r=new Error(e);r.errno=n,r.code=t.codes[n],s.emit("error",r)};var l=t.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(l=e.level);var u=t.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(u=e.strategy),this._handle.init(e.windowBits||t.Z_DEFAULT_WINDOWBITS,l,e.memLevel||t.Z_DEFAULT_MEMLEVEL,u,e.dictionary),this._buffer=o.allocUnsafe(this._chunkSize),this._offset=0,this._level=l,this._strategy=u,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!r._handle},configurable:!0,enumerable:!0})}function D(e,t){t&&r.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}function x(e){e.emit("close")}Object.defineProperty(t,"codes",{enumerable:!0,value:Object.freeze(f),writable:!1}),t.Deflate=w,t.Inflate=E,t.Gzip=T,t.Gunzip=_,t.DeflateRaw=S,t.InflateRaw=A,t.Unzip=M,t.createDeflate=function(e){return new w(e)},t.createInflate=function(e){return new E(e)},t.createDeflateRaw=function(e){return new S(e)},t.createInflateRaw=function(e){return new A(e)},t.createGzip=function(e){return new T(e)},t.createGunzip=function(e){return new _(e)},t.createUnzip=function(e){return new M(e)},t.deflate=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new w(t),e,n)},t.deflateSync=function(e,t){return v(new w(t),e)},t.gzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new T(t),e,n)},t.gzipSync=function(e,t){return v(new T(t),e)},t.deflateRaw=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new S(t),e,n)},t.deflateRawSync=function(e,t){return v(new S(t),e)},t.unzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new M(t),e,n)},t.unzipSync=function(e,t){return v(new M(t),e)},t.inflate=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new E(t),e,n)},t.inflateSync=function(e,t){return v(new E(t),e)},t.gunzip=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new _(t),e,n)},t.gunzipSync=function(e,t){return v(new _(t),e)},t.inflateRaw=function(e,t,n){return"function"==typeof t&&(n=t,t={}),y(new A(t),e,n)},t.inflateRawSync=function(e,t){return v(new A(t),e)},s.inherits(O,i),O.prototype.params=function(e,n,o){if(et.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(n!=t.Z_FILTERED&&n!=t.Z_HUFFMAN_ONLY&&n!=t.Z_RLE&&n!=t.Z_FIXED&&n!=t.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+n);if(this._level!==e||this._strategy!==n){var i=this;this.flush(a.Z_SYNC_FLUSH,(function(){l(i._handle,"zlib binding closed"),i._handle.params(e,n),i._hadError||(i._level=e,i._strategy=n,o&&o())}))}else r.nextTick(o)},O.prototype.reset=function(){return l(this._handle,"zlib binding closed"),this._handle.reset()},O.prototype._flush=function(e){this._transform(o.alloc(0),"",e)},O.prototype.flush=function(e,t){var n=this,i=this._writableState;("function"==typeof e||void 0===e&&!t)&&(t=e,e=a.Z_FULL_FLUSH),i.ended?t&&r.nextTick(t):i.ending?t&&this.once("end",t):i.needDrain?t&&this.once("drain",(function(){return n.flush(e,t)})):(this._flushFlag=e,this.write(o.alloc(0),"",t))},O.prototype.close=function(e){D(this,e),r.nextTick(x,this)},O.prototype._transform=function(e,t,n){var r,i=this._writableState,s=(i.ending||i.ended)&&(!e||i.length===e.length);return null===e||o.isBuffer(e)?this._handle?(s?r=this._finishFlushFlag:(r=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(e,r,n)):n(new Error("zlib binding closed")):n(new Error("invalid input"))},O.prototype._processChunk=function(e,t,n){var r=e&&e.length,i=this._chunkSize-this._offset,a=0,s=this,h="function"==typeof n;if(!h){var d,p=[],f=0;this.on("error",(function(e){d=e})),l(this._handle,"zlib binding closed");do{var m=this._handle.writeSync(t,e,a,r,this._buffer,this._offset,i)}while(!this._hadError&&y(m[0],m[1]));if(this._hadError)throw d;if(f>=u)throw D(this),new RangeError(c);var b=o.concat(p,f);return D(this),b}l(this._handle,"zlib binding closed");var g=this._handle.write(t,e,a,r,this._buffer,this._offset,i);function y(u,c){if(this&&(this.buffer=null,this.callback=null),!s._hadError){var d=i-c;if(l(d>=0,"have should not go down"),d>0){var m=s._buffer.slice(s._offset,s._offset+d);s._offset+=d,h?s.push(m):(p.push(m),f+=m.length)}if((0===c||s._offset>=s._chunkSize)&&(i=s._chunkSize,s._offset=0,s._buffer=o.allocUnsafe(s._chunkSize)),0===c){if(a+=r-u,r=u,!h)return!0;var b=s._handle.write(t,e,a,r,s._buffer,s._offset,s._chunkSize);return b.callback=y,void(b.buffer=e)}if(!h)return!1;n()}}g.buffer=e,g.callback=y},s.inherits(w,O),s.inherits(E,O),s.inherits(T,O),s.inherits(_,O),s.inherits(S,O),s.inherits(A,O),s.inherits(M,O)},30295:(e,t,n)=>{var r=n(48287).Buffer;e.exports=function(e,t){for(var n=Math.min(e.length,t.length),o=new r(n),i=0;i{"use strict";const r=n(67526),o=n(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=function(e){return+e!=e&&(e=0),l.alloc(+e)},t.INSPECT_MAX_BYTES=50;const a=2147483647;function s(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,n)}function u(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=0|m(e,t);let r=s(n);const o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(X(e,Uint8Array)){const t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return p(e,t,n);if("undefined"!=typeof SharedArrayBuffer&&(X(e,SharedArrayBuffer)||e&&X(e.buffer,SharedArrayBuffer)))return p(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return l.from(r,t,n);const o=function(e){if(l.isBuffer(e)){const t=0|f(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||K(e.length)?s(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),s(e<0?0:0|f(e))}function d(e){const t=e.length<0?0:0|f(e.length),n=s(t);for(let r=0;r=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function m(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(o)return r?-1:z(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,n){let r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,n);case"utf8":case"utf-8":return M(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return D(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function y(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),K(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,o){let i,a=1,s=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){let r=-1;for(i=n;is&&(n=s-l),i=n;i>=0;i--){let n=!0;for(let r=0;ro&&(r=o):r=o;const i=t.length;let a;for(r>i/2&&(r=i/2),a=0;a>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function A(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function M(e,t,n){n=Math.min(e.length,n);const r=[];let o=t;for(;o239?4:t>223?3:t>191?2:1;if(o+a<=n){let n,r,s,l;switch(a){case 1:t<128&&(i=t);break;case 2:n=e[o+1],128==(192&n)&&(l=(31&t)<<6|63&n,l>127&&(i=l));break;case 3:n=e[o+1],r=e[o+2],128==(192&n)&&128==(192&r)&&(l=(15&t)<<12|(63&n)<<6|63&r,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:n=e[o+1],r=e[o+2],s=e[o+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(l=(15&t)<<18|(63&n)<<12|(63&r)<<6|63&s,l>65535&&l<1114112&&(i=l))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),o+=a}return function(e){const t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);let n="",r=0;for(;rr.length?(l.isBuffer(t)||(t=l.from(t)),t.copy(r,o)):Uint8Array.prototype.set.call(r,t,o);else{if(!l.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(r,o)}o+=t.length}return r},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tn&&(e+=" ... "),""},i&&(l.prototype[i]=l.prototype.inspect),l.prototype.compare=function(e,t,n,r,o){if(X(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;let i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0);const s=Math.min(i,a),u=this.slice(r,o),c=e.slice(t,n);for(let e=0;e>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let i=!1;for(;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return E(this,e,t,n);case"ascii":case"latin1":case"binary":return T(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const C=4096;function O(e,t,n){let r="";n=Math.min(e.length,n);for(let o=t;or)&&(n=r);let o="";for(let r=t;rn)throw new RangeError("Trying to access beyond buffer length")}function F(e,t,n,r,o,i){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function I(e,t,n,r,o){G(t,r,o,e,n,7);let i=Number(t&BigInt(4294967295));e[n++]=i,i>>=8,e[n++]=i,i>>=8,e[n++]=i,i>>=8,e[n++]=i;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,n}function j(e,t,n,r,o){G(t,r,o,e,n,7);let i=Number(t&BigInt(4294967295));e[n+7]=i,i>>=8,e[n+6]=i,i>>=8,e[n+5]=i,i>>=8,e[n+4]=i;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=a,a>>=8,e[n+2]=a,a>>=8,e[n+1]=a,a>>=8,e[n]=a,n+8}function R(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,i){return t=+t,n>>>=0,i||R(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function P(e,t,n,r,i){return t=+t,n>>>=0,i||R(e,0,n,8),o.write(e,t,n,r,52,8),n+8}l.prototype.slice=function(e,t){const n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t>>=0,t>>>=0,n||k(e,t,this.length);let r=this[e],o=1,i=0;for(;++i>>=0,t>>>=0,n||k(e,t,this.length);let r=this[e+--t],o=1;for(;t>0&&(o*=256);)r+=this[e+--t]*o;return r},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||k(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||k(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||k(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||k(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e>>>=0,t||k(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readBigUInt64LE=Q((function(e){W(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||V(e,this.length-8);const r=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+n*2**24;return BigInt(r)+(BigInt(o)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||V(e,this.length-8);const r=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+n;return(BigInt(r)<>>=0,t>>>=0,n||k(e,t,this.length);let r=this[e],o=1,i=0;for(;++i=o&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||k(e,t,this.length);let r=t,o=1,i=this[e+--r];for(;r>0&&(o*=256);)i+=this[e+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},l.prototype.readInt8=function(e,t){return e>>>=0,t||k(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||k(e,2,this.length);const n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){e>>>=0,t||k(e,2,this.length);const n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return e>>>=0,t||k(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return e>>>=0,t||k(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readBigInt64LE=Q((function(e){W(e>>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||V(e,this.length-8);const r=this[e+4]+256*this[e+5]+65536*this[e+6]+(n<<24);return(BigInt(r)<>>=0,"offset");const t=this[e],n=this[e+7];void 0!==t&&void 0!==n||V(e,this.length-8);const r=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(r)<>>=0,t||k(e,4,this.length),o.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||k(e,4,this.length),o.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||k(e,8,this.length),o.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||k(e,8,this.length),o.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||F(this,e,t,n,Math.pow(2,8*n)-1,0);let o=1,i=0;for(this[t]=255&e;++i>>=0,n>>>=0,r||F(this,e,t,n,Math.pow(2,8*n)-1,0);let o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeBigUInt64LE=Q((function(e,t=0){return I(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeBigUInt64BE=Q((function(e,t=0){return j(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){const r=Math.pow(2,8*n-1);F(this,e,t,n,r-1,-r)}let o=0,i=1,a=0;for(this[t]=255&e;++o>>=0,!r){const r=Math.pow(2,8*n-1);F(this,e,t,n,r-1,-r)}let o=n-1,i=1,a=0;for(this[t+o]=255&e;--o>=0&&(i*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/i|0)-a&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeBigInt64LE=Q((function(e,t=0){return I(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeBigInt64BE=Q((function(e,t=0){return j(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return P(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return P(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,r){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function G(e,t,n,r,o,i){if(e>n||e3?0===t||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(i+1)}${r}`:`>= -(2${r} ** ${8*(i+1)-1}${r}) and < 2 ** ${8*(i+1)-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new B.ERR_OUT_OF_RANGE("value",o,e)}!function(e,t,n){W(t,"offset"),void 0!==e[t]&&void 0!==e[t+n]||V(t,e.length-(n+1))}(r,o,i)}function W(e,t){if("number"!=typeof e)throw new B.ERR_INVALID_ARG_TYPE(t,"number",e)}function V(e,t,n){if(Math.floor(e)!==e)throw W(e,n),new B.ERR_OUT_OF_RANGE(n||"offset","an integer",e);if(t<0)throw new B.ERR_BUFFER_OUT_OF_BOUNDS;throw new B.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}H("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),H("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),H("ERR_OUT_OF_RANGE",(function(e,t,n){let r=`The value of "${e}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=U(String(n)):"bigint"==typeof n&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=U(o)),o+="n"),r+=` It must be ${t}. Received ${o}`,r}),RangeError);const q=/[^+/0-9A-Za-z-_]/g;function z(e,t){let n;t=t||1/0;const r=e.length;let o=null;const i=[];for(let a=0;a55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function $(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,n,r){let o;for(o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let o=0;o<16;++o)t[r+o]=e[n]+e[o]}return t}();function Q(e){return"undefined"==typeof BigInt?J:e}function J(){throw new Error("BigInt not supported")}},86866:e=>{e.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},13144:(e,t,n)=>{"use strict";var r=n(66743),o=n(11002),i=n(10076),a=n(47119);e.exports=a||r.call(i,o)},12205:(e,t,n)=>{"use strict";var r=n(66743),o=n(11002),i=n(13144);e.exports=function(){return i(r,o,arguments)}},11002:e=>{"use strict";e.exports=Function.prototype.apply},10076:e=>{"use strict";e.exports=Function.prototype.call},73126:(e,t,n)=>{"use strict";var r=n(66743),o=n(69675),i=n(10076),a=n(13144);e.exports=function(e){if(e.length<1||"function"!=typeof e[0])throw new o("a function is required");return a(r,i,e)}},47119:e=>{"use strict";e.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},38075:(e,t,n)=>{"use strict";var r=n(70453),o=n(10487),i=o(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&i(e,".prototype.")>-1?o(n):n}},10487:(e,t,n)=>{"use strict";var r=n(96897),o=n(30655),i=n(73126),a=n(12205);e.exports=function(e){var t=i(arguments),n=e.length-(arguments.length-1);return r(t,1+(n>0?n:0),!0)},o?o(e.exports,"apply",{value:a}):e.exports.apply=a},36556:(e,t,n)=>{"use strict";var r=n(70453),o=n(73126),i=o([r("%String.prototype.indexOf%")]);e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&i(e,".prototype.")>-1?o([n]):n}},56168:(e,t,n)=>{"use strict";var r=n(92861).Buffer,o=n(88310).Transform,i=n(83141).I;function a(e){o.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}n(56698)(a,o);var s="undefined"!=typeof Uint8Array,l="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(r.prototype instanceof Uint8Array||r.TYPED_ARRAY_SUPPORT);a.prototype.update=function(e,t,n){var o=function(e,t){if(e instanceof r)return e;if("string"==typeof e)return r.from(e,t);if(l&&ArrayBuffer.isView(e)){if(0===e.byteLength)return r.alloc(0);var n=r.from(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength===e.byteLength)return n}if(s&&e instanceof Uint8Array)return r.from(e);if(r.isBuffer(e)&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e))return r.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(e,t),i=this._update(o);return this.hashMode?this:(n&&(i=this._toString(i,n)),i)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.prototype._transform=function(e,t,n){var r;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){r=e}finally{n(r)}},a.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},a.prototype._finalOrDigest=function(e){var t=this.__final()||r.alloc(0);return e&&(t=this._toString(t,e,!0)),t},a.prototype._toString=function(e,t,n){if(this._decoder||(this._decoder=new i(t),this._encoding=t),this._encoding!==t)throw new Error("can’t switch encodings");var r=this._decoder.write(e);return n&&(r+=this._decoder.end()),r},e.exports=a},15622:(e,t,n)=>{function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(48287).Buffer.isBuffer},61324:(e,t,n)=>{var r=n(48287).Buffer,o=n(86729),i=n(92801);e.exports=function(e){return new s(e)};var a={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 s(e){this.curveType=a[e],this.curveType||(this.curveType={name:e}),this.curve=new o.ec(this.curveType.name),this.keys=void 0}function l(e,t,n){Array.isArray(e)||(e=e.toArray());var o=new r(e);if(n&&o.length=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function l(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,r){for(var o=0,i=Math.min(e.length,n),a=t;a=49?s-49+10:s>=17?s-17+10:s}return o}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r