commit 9afc3ab3e426cd87e4e43233182546cfe1576e6c Author: Michał 'rysiek' Woźniak Date: Tue Apr 6 17:18:37 2021 +0000 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e361056 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +radata/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..6a24604 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,130 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +`rysiek+libresilient[at]hackerspace.pl`. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8d8b443 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + LibResilient + Copyright (C) 2019 libre + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9af8fa --- /dev/null +++ b/README.md @@ -0,0 +1,114 @@ +# LibResilient + +A browser-based decentralized content delivery network, implemented as a JavaScript library to be deployed easily on any website. LibResilient uses [ServiceWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) and a suite of non-standard in-browser delivery mechanisms, with a strong focus on decentralized tools like [IPFS](https://ipfs.io/). + +Ideally, users should not need to install any special software nor change any settings to continue being able to access an overloaded LibResilient-enabled site as soon as they are able to access it *once*. + +## Current status + +LibResilient is currently considered *alpha*: the code works, but major rewrites and API changes are coming. It has been tested on Firefox, Chromium and Chrome on desktop, as well as Firefox for mobile on Android, but it should work in any browser implementing the ServiceWorker API. + +Feel free to test it, but be aware that it might not work as expected. If you'd like to get in touch, please email us at `rysiek+libresilient[at]hackerspace.pl`, create an [issue](https://gitlab.com/rysiekpl/libresilient/-/issues/new). + +## Rationale + +While a number of content delivery technologies exist, these typically require enormous centralized services. This creates opportunities for gate-keeping, and [causes any disruption at these centralized providers to become a major problem for thousands of websites](https://blog.cloudflare.com/cloudflare-outage-on-july-17-2020/). + +This project explores the possibility of solving this in a way that would not require website visitors to install any special software or change any settings; the only things that are needed are a modern Web browser and the ability to visit a website once, so that the JavaScript ServiceWorker kicks in. + +You can read more in-depth overview of LibResilient [here](./docs/ARCHITECTURE.md). And [here](./docs/PHILOSOPHY.md) is a document describing the philosophy influencing project goals and relevant technical decisions. + +## Architecture + +A [ServiceWorker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) is used as a way to persist the library after the initial visit to the participating website. + +After the ServiceWorker is downloaded and activated, it handles all `fetch()` events by first trying to use the regular HTTPS request to the original website. If that fails for whatever reason (be it a timeout or a `4xx`/`5xx` error), the plugins kick in, attempting to fetch the content via any means available. + +A more complete overview of the architecture and technicalities of LibResilient is available [here](./docs/ARCHITECTURE.md). + +## Draft API + +The plan is to have an API to enable the use of different strategies for getting content. There are two basic functions a plugin needs to perform: + - **resolution** + *where* a given piece of content (image, stylesheet, script, HTML file, etc.) is to be found + - **delivery** + *how* to get it + +These need to be closely integrated. For example, if using Gun and IPFS, resolution is performed using Gun, and delivery is performed using IPFS. However, Gun needs to resolve content to something that is usable with IPFS. If, alternatively, we're also using Gun to resolve content available on BitTorrent, that will have to be a separate namespace in the Gun graph, since it will have to resolve to magnet links. + +Therefore, it doesn't seem to make sense to separate resolution and delivery. Thus, a LibResilient plugin would need to implement the whole pipeline, and work by receiving a URL and returning a Promise that resolves to a valid Response object containing the content. + +It should be possible to chain the plugins (try the first one, in case of error try the next, and so on), or run them in parallel (fire requests using all available plugins and return the first complete successful response). Running in parallel might offer a better user experience, but will also be more resource-intensive. + +An additional part of the API is going to deal with reporting the status of the plugins, their versions, and how a given piece of content was fetched (using which plugin). This will require modifying actual content from the ServiceWorker to pass that data to the DOM. + +### Content versioning + +Implementing content versioning might be necessary. Some delivery mechanisms (IPFS, BitTorrent) might be slow to pick up newly published content, and while information about this might be available, it might be faster to fetch and display older content that has already propagated across multiple peers or network nodes, with a message informing the reader that new content is available and that they might want to retry fetching it. + +An important consideration related to content versioning is that it needs to be consistent across a full set of published pieces of content. + +For example, consider a simple site that consists of an `index.html`, `style.css`, and `script.js`. Non-trivial changes in `index.html` will render older versions of `style.css` and `script.js` broken. A particular version of the whole published site needs to be fetched, otherwise things will not work as expected. + +This will probably need to be fleshed out later on, but the initial API needs to be designed in a way where content versioning can be introduced without breaking backwards compatibility with plugins. + +### Status information + +Status information should be available to users, informing them that the content is being retrieved using non-standard means that might take longer. + +LibResilient information is kept per-request in the ServiceWorker, meaning it is transient and does not survive ServiceWorker restarts, which might happen multiple times over the lifetime of an open tab. However, each update is communicated to the browser window context that is relevant for a given request via [`client.postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/Client/postMessage) calls. This is also how information on ServiceWorker commit SHAs and available plugins are made available to the browser window context. + +The data provided (per each requested URL handled by the ServiceWorker) is: + - `clientId` – the [Client ID](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/clientId) for the request (that is, the Client ID of this browser window) + - `url` – the URL of the request + - `serviceWorker` – the commit SHA of the ServiceWorker that handled the request + - `fetchError` – `null` if the request completed successfully via regular HTTPS; otherwise the error message + - `method` – the method by which the request was completed: "`fetch`" is regular HTTPS `fetch()`, `gun-ipfs` means Gun and IPFS were used, etc. + - `state` – the state of the request (`running`, `error`, `success`) + +The code in the browser window context is responsible for keeping a more permanent record of the URLs requested, the methods used, and the status of each, if needed. + +## Review of possible resolution/delivery methods + + - **[Gun](https//gun.eco/)** + Better suited for resolution than for delivery, although it could handle both. Pretty new project, dynamically developed. No global network of public peers available currently. Content is cryptographically signed. + + - **[IPNS](https://docs.ipfs.io/guides/concepts/ipns/)** + Only suitable for resolution. Experimental, not fully functional in the browser yet. Fits like a hand in a glove with IPFS. + + - **[DNSLink](https://docs.ipfs.io/guides/concepts/dnslink/)** + Only suitable for resolution. Deployed, stable, and well-documented. Fits like a hand in a glove with IPFS. The downside is that it requires publishing of DNS records to work (every time any new content is published), which means it might be difficult to implement by website admins. + + - **[IPFS](https://ipfs.io/)** + Only suitable for delivery, since it is content-addressed. Resolution of a content URI to an IPFS address needs to be handled by some other technology (like Gun or IPNS, or using [gateways](https://ipfs.github.io/public-gateway-checker/)). Deployed and well-documented, with a large community of developers. Redeploying a new content package with certain files unchanged does not change the addresses of the unchanged files, meaning that small changes in content do not lead to the whole content tree needing to be re-seeded. + + - **[WebTorrent](https://github.com/webtorrent/webtorrent)** + Only suitable for content delivery. It seems possible to fetch a particular file from a given torrent, so as not to have to download a torrent of the whole website just to display a single page with some CSS and JS. Requires a resolver to point to the newest torrent since torrents are immutable. Even small changes (for example, only a few files changed in the whole website tree) require creating a new torrent and re-seeding, which is obviously less than ideal. + + - **Plain files via HTTPS** + This delivery method is obvious if we're talking simply about the originating site and it serving the files, but this can also mean non-standard strategies like pushing static HTML+CSS+JS to CloudFront or Wasabi, and having a minimal resolver kick in if the originating site is unavailable, to fetch content seamlessly from alternative locations (effectively implementing domain fronting and collateral freedom in the browser). However, this will require some thought being put into somehow signing content deployed to third-party locations – perhaps the resolver (like Gun) could be responsible for keeping SHA sums of known good content, or perhaps we should just address it using the hashes, effectively imitating IPFS. + +## Limitations + +There are certain limitations to what can be done with LibResilient: + +### Service worker cannot be updated if origin is down + +ServiceWorker script apparently cannot be delivered using any of the transport plugins, [since](https://gist.github.com/Rich-Harris/fd6c3c73e6e707e312d7c5d7d0f3b2f9#the-new-service-worker-isnt-fetched-by-the-old-one): + +> when you call `navigator.serviceWorker.register('service-worker.js)` the request for service-worker.js isn't intercepted by any service worker's fetch event handler. + +So, the ServiceWorker script will be un-updateable via LibResilient in case the origin site is down, unless we find a way to hack around it with caches etc. + +### JS implementations of decentralized protocols are still bootstrapped using servers + +Gun and IPFS (and probably other potential LibResilient strategies) still use bootstrapping servers (STUN/TURN, and other kinds of public nodes), so technically it would be possible for all of these to be overwhelmed by traffic also, rendering LibResilient ineffective. This is a limitation of browsers and is related to IPv4 and NATs. + +One way to deal with this is to have a large list of such public nodes and send only 2-3 each time LibResilient calls home (including via already working decentralized means), so that the traffic is spread more evenly. + +Plus, the ever-increasing adoption of IPv6 will also partially fix this. + +## Related developments + + - https://ipfs.io/ipfs/QmNhFJjGcMPqpuYfxL62VVB9528NXqDNMFXiqN5bgFYiZ1/its-time-for-the-permanent-web.html + - https://blog.archive.org/2015/02/11/locking-the-web-open-a-call-for-a-distributed-web/ diff --git a/config.js b/config.js new file mode 100644 index 0000000..4833eba --- /dev/null +++ b/config.js @@ -0,0 +1,37 @@ +/* + * LibResilient config + * + * This is the config for LibResilient as deployed on the https://libresilient.is/ site + * + * When deploying LibResilient on your website you will need to create your own config, + * using this one as a template. + */ + +// plugins config +self.LibResilientConfig.plugins = { + 'fetch':{}, + 'cache':{}, + 'any-of': { + plugins: { + 'alt-fetch':{ + // configuring the alternate endpoints plugin to use IPNS gateways + // + // NOTICE: we cannot use gateways that use hash directly in the (sub)domain: + // https://github.com/node-fetch/node-fetch/issues/260 + endpoints: [ + 'https://ninetailed.ninja/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/', // Russia + 'https://10.via0.com/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/', // USA + 'https://ipfs.sloppyta.co/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/', // UK + 'https://gateway.temporal.cloud/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/', // Germany + 'https://ipfs.best-practice.se/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/' // Sweden + ] + }, + 'gun-ipfs': { + gunPubkey: 'WUK5ylwqqgUorceQRa84qfbBFhk7eNRDUoPbGK05SyE.-yohFhTzWPpDT-UDMuKGgemOUrw_cMMYWpy6plILqrg' + } + } + } + } + +// we need to explicitly list components we want to see debug messages from +self.LibResilientConfig.loggedComponents = ['service-worker', 'fetch', 'cache', 'any-of', 'alt-fetch', 'gun-ipfs'] diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md new file mode 100644 index 0000000..b2551df --- /dev/null +++ b/docs/ARCHITECTURE.md @@ -0,0 +1,101 @@ +# Architecture + +Eventually this will document the architecture of LibResilient. + +## Plugins + +There are three kinds of plugins: + +- **Transport plugins** + Plugins that *retrieve* website content, e.g. by using regular HTTPS [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), or by going through [IPFS](https://js.ipfs.io/). They *should* also offer a way to *publish* content by website admins (if relevant credentials or encryption keys are provided, depending on the method). +Methods these plugins implement: + - `fetch` - fetch content from an external source (e.g., from IPFS) + - `publish` - publish the content to the external source (e.g., to IPFS) + +- **Stashing plugins** + Plugins that *stash* content locally (e.g., in the [browser cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache)) for displaying when no *transport plugin* works, or before content is received via one of them. +Methods these plugins implement: + - `fetch` - fetch the locally stored content (e.g., from cache) + - `stash` - stash the content locally (e.g., in cache) + - `unstash` - clear the content from the local store (e.g., clear the cache) + +- **Composing plugins** + Plugins that *compose* other plugins, for example by running them simultaneously to retrieve content from whichever succeeds first. +Methods these plugins implement depend on which plugins they compose. Additionally, plugins being composed the `uses` key, providing the configuration for them the same way configuration is provided for plugins in the `plugins` key of `LibResilientConfig`. + +Any plugin needs to add itself to the LibResilientPlugins global variable, using a data structure as follows: + +```javascript +self.LibResilientPlugins.push({ + name: 'plugin-name', + description: 'Plugin description. Just a few words, ideally.', + version: 'any relevant plugin version information', + fetch: functionImplementingFetch, + publish|stash|unstash: functionsImplementingRelevantFunctionality, + uses: { + composed-plugin-1: { + configKey1: "whatever-data-here" + }, + composed-plugin-2: { + configKey2: "whatever-data-here" + }, + {...} + } +}) +``` + +### Transport plugins + +Transport plugins *must* add `X-LibResilient-Method` and `X-LibResilient-ETag` headers to the response they return, so as to facilitate informing the user about new content after content was displayed using a stashing plugin. + + - **`X-LibResilient-Method`**: + contains the name of the plugin used to fetch the content. + + - **`X-LibResilient-ETag`**: + contains the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) for the content; this can be an actual `ETag` header for HTTPS-based plugins, or some arbitrary string identifying a particular version of the resource (e.g., for IPFS-based plugins this can be the IPFS address, since that is based on content and different content results in a different IPFS address). + +### Stashing plugins + +Stashing plugins *must* stash the request along with the `X-LibResilient-Method` and `X-LibResilient-ETag` headers. + +### Composing plugins + +Composing plugins work by composing other plugins, for example to run them simultaneously and retrieve content from the first one that succeeds. A composing plugin needs to set the `uses` key in it's `LibResilientPlugins`. The key should contain mappings from plugin names to configuration: + +```javascript +uses: { + composed-plugin-1: { + configKey1: "whatever-data-here" + }, + composed-plugin-2: { + configKey2: "whatever-data-here" + }, + {...} +} +``` + +## Fetching a resource via LibResilient + +Whenever a resource is being fetched on a LibResilient-enabled site, the `service-worker.js` script dispatches plugins in the set order. Currently this order is hard-coded in `service-worker.js`, and is: + +1. `fetch`, to use the upstream site directly if it is available, +1. `cache`, to display the site immediately from the cache in case regular `fetch` fails, +1. `gun-ipfs`, in the background if `cache` call succeeded, otherwise as the active fetch handler. + +If a background plugin `fetch()` succeeds, the result is added to the cache and will be immediately available on page reload. + +## Stashed versions invalidation + +Invalidation heuristic is rather naïve, and boils down to checking if either of `X-LibResilient-Method` or `X-LibResilient-ETag` differs between the response from a transport plugin and whatever has already been stashed by a stashing plugin. If either differs, the transport plugin response is considered "*fresher*". + +This is far from ideal and will need improvements in the long-term. The difficulty is that different transport plugins can provide different ways of determining the "*freshness*" of fetched content -- HTTPS-based requests offer `ETag`, `Date`, `Last-Modified`, and other headers that can help with that; whereas IPFS can't really offer much apart from the address which itself is a hash of the content, so at least we know the content is *different* (but is it *fresher* though?). + +## Messaging + +The ServiceWorker can communicate with the browser window using the [`Client.postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/Client/postMessage) to post messages to the browser window context using the relevant [`Client ID`](https://developer.mozilla.org/en-US/docs/Web/API/Client/id), retrieved from the fetch event object. + +When the browser window context wants to message the service worker, it uses the [`Worker.postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage) call, with `clientId` field set to the relevant client ID if a response is expected. ServiceWorker then again responds using `Client.postMessage()` using the `clientId` field as source of the `Client ID`. + +### Messages + +This section is a work in progress. diff --git a/docs/PHILOSOPHY.md b/docs/PHILOSOPHY.md new file mode 100644 index 0000000..3a7e9ea --- /dev/null +++ b/docs/PHILOSOPHY.md @@ -0,0 +1,26 @@ +# Project's Philosophy + +LibResilient's philosophy can be boiled down to a single sentence: +**Information must remain easily accessible.** + +The choice of words here is very deliberate. + +## Information vs. communication + +LibResilient purposely focuses on ***making information accessible***, as opposed to facilitating *live two-way communication flow*. + +There is plenty of misinformation to go around, and plenty of communication that is meant solely to muddy the waters and create a toxic information environment. Those who organize such disingenuous communication and participate in it often rely on it being two-way, fast-paced, and emotional, intentionally leaving as little space for calm rational thought as possible. + +There is a meaningful difference between a debate of ideas, and a shouting match or a lynch mob. LibResilient is not interested in supporting the latter. While discriminatory content does also come in the form of articles on websites, it becomes truly toxic when live mass communication can be employed in an aggressive manner. + +This is where LibResilient draws a line by making specific architectural decisions. We cannot stop bigots from using LibResilient on their websites, but we can make LibResilient less useful for specific strategies often employed by them. + +## Centralization as a dis-service + +LibResilient grew out of the experience of managing websites that experience huge traffic spikes, and the frustration regarding options available to website admins in who find their websites became unavailable, entirely or only to certain groups of visitors, be it via direct malicious actions (like DDoS), or organic traffic overwhelming the webserver. + +These options tend to be limited to a few massive gatekeepers like CloudFlare, and a few smaller ethical providers like [Deflect](https://deflect.ca/). + +In practice, website owners are incentivised to use the massive gatekeepers' services, which [gradually centralizes the Internet](https://iscloudflaresafeyet.com/). Such centralization then becomes a problem itself, when these gatekeepers [find themselves under pressure to drop protection for specific sites](https://www.techrepublic.com/article/as-google-and-aws-kill-domain-fronting-users-must-find-a-new-way-to-fight-censorship/), leaving website owners with nowhere to go. + +LibResilient is explicitly focusing on decentralized tools like [IPFS](https://ipfs.io); in some cases and for certain very specific threats using the biggest gatekeepers might still make sense, and LibResilient might facilitate that. But whenever that is the case, care will be taken to do it in a way that is not tied to particular service or company. diff --git a/lib/gun.js b/lib/gun.js new file mode 100644 index 0000000..1a125c1 --- /dev/null +++ b/lib/gun.js @@ -0,0 +1,2451 @@ +;(function(){ + + /* UNBUILD */ + function USE(arg, req){ + return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){ + arg(mod = {exports: {}}); + USE[R(path)] = mod.exports; + } + function R(p){ + return p.split('/').slice(-1).toString().replace('.js',''); + } + } + if(typeof module !== "undefined"){ var MODULE = module } + /* UNBUILD */ + + ;USE(function(module){ + // Generic javascript utilities. + var Type = {}; + //Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }} + Type.fn = {is: function(fn){ return (!!fn && 'function' == typeof fn) }} + Type.bi = {is: function(b){ return (b instanceof Boolean || typeof b == 'boolean') }} + Type.num = {is: function(n){ return !list_is(n) && ((n - parseFloat(n) + 1) >= 0 || Infinity === n || -Infinity === n) }} + Type.text = {is: function(t){ return (typeof t == 'string') }} + Type.text.ify = function(t){ + if(Type.text.is(t)){ return t } + if(typeof JSON !== "undefined"){ return JSON.stringify(t) } + return (t && t.toString)? t.toString() : t; + } + Type.text.random = function(l, c){ + var s = ''; + l = l || 24; // you are not going to make a 0 length random number, so no need to check type + c = c || '0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz'; + while(l > 0){ s += c.charAt(Math.floor(Math.random() * c.length)); l-- } + return s; + } + Type.text.match = function(t, o){ var tmp, u; + if('string' !== typeof t){ return false } + if('string' == typeof o){ o = {'=': o} } + o = o || {}; + tmp = (o['='] || o['*'] || o['>'] || o['<']); + if(t === tmp){ return true } + if(u !== o['=']){ return false } + tmp = (o['*'] || o['>'] || o['<']); + if(t.slice(0, (tmp||'').length) === tmp){ return true } + if(u !== o['*']){ return false } + if(u !== o['>'] && u !== o['<']){ + return (t >= o['>'] && t <= o['<'])? true : false; + } + if(u !== o['>'] && t >= o['>']){ return true } + if(u !== o['<'] && t <= o['<']){ return true } + return false; + } + Type.text.hash = function(s, c){ // via SO + if(typeof s !== 'string'){ return } + c = c || 0; + if(!s.length){ return c } + for(var i=0,l=s.length,n; i B){ return 1 } + else { return 0 } + } + } + Type.list.map = function(l, c, _){ return obj_map(l, c, _) } + Type.list.index = 1; // change this to 0 if you want non-logical, non-mathematical, non-matrix, non-convenient array notation + Type.obj = {is: function(o){ return o? (o instanceof Object && o.constructor === Object) || Object.prototype.toString.call(o).match(/^\[object (\w+)\]$/)[1] === 'Object' : false }} + Type.obj.put = function(o, k, v){ return (o||{})[k] = v, o } + Type.obj.has = function(o, k){ return o && Object.prototype.hasOwnProperty.call(o, k) } + Type.obj.del = function(o, k){ + if(!o){ return } + o[k] = null; + delete o[k]; + return o; + } + Type.obj.as = function(o, k, v, u){ return o[k] = o[k] || (u === v? {} : v) } + Type.obj.ify = function(o){ + if(obj_is(o)){ return o } + try{o = JSON.parse(o); + }catch(e){o={}}; + return o; + } + ;(function(){ var u; + function map(v,k){ + if(obj_has(this,k) && u !== this[k]){ return } + this[k] = v; + } + Type.obj.to = function(from, to){ + to = to || {}; + obj_map(from, map, to); + return to; + } + }()); + Type.obj.copy = function(o){ // because http://web.archive.org/web/20140328224025/http://jsperf.com/cloning-an-object/2 + return !o? o : JSON.parse(JSON.stringify(o)); // is shockingly faster than anything else, and our data has to be a subset of JSON anyways! + } + ;(function(){ + function empty(v,i){ var n = this.n, u; + if(n && (i === n || (obj_is(n) && obj_has(n, i)))){ return } + if(u !== i){ return true } + } + Type.obj.empty = function(o, n){ + if(!o){ return true } + return obj_map(o,empty,{n:n})? false : true; + } + }()); + ;(function(){ + function t(k,v){ + if(2 === arguments.length){ + t.r = t.r || {}; + t.r[k] = v; + return; + } t.r = t.r || []; + t.r.push(k); + }; + var keys = Object.keys, map, u; + Object.keys = Object.keys || function(o){ return map(o, function(v,k,t){t(k)}) } + Type.obj.map = map = function(l, c, _){ + var u, i = 0, x, r, ll, lle, f = 'function' == typeof c; + t.r = u; + if(keys && obj_is(l)){ + ll = keys(l); lle = true; + } + _ = _ || {}; + if(list_is(l) || ll){ + x = (ll || l).length; + for(;i < x; i++){ + var ii = (i + Type.list.index); + if(f){ + r = lle? c.call(_, l[ll[i]], ll[i], t) : c.call(_, l[i], ii, t); + if(r !== u){ return r } + } else { + //if(Type.test.is(c,l[i])){ return ii } // should implement deep equality testing! + if(c === l[lle? ll[i] : i]){ return ll? ll[i] : ii } // use this for now + } + } + } else { + for(i in l){ + if(f){ + if(obj_has(l,i)){ + r = _? c.call(_, l[i], i, t) : c(l[i], i, t); + if(r !== u){ return r } + } + } else { + //if(a.test.is(c,l[i])){ return i } // should implement deep equality testing! + if(c === l[i]){ return i } // use this for now + } + } + } + return f? t.r : Type.list.index? 0 : -1; + } + }()); + Type.time = {}; + Type.time.is = function(t){ return t? t instanceof Date : (+new Date().getTime()) } + + var fn_is = Type.fn.is; + var list_is = Type.list.is; + var obj = Type.obj, obj_is = obj.is, obj_has = obj.has, obj_map = obj.map; + module.exports = Type; + })(USE, './type'); + + ;USE(function(module){ + // On event emitter generic javascript utility. + module.exports = function onto(tag, arg, as){ + if(!tag){ return {to: onto} } + var u, tag = (this.tag || (this.tag = {}))[tag] || + (this.tag[tag] = {tag: tag, to: onto._ = { + next: function(arg){ var tmp; + if((tmp = this.to)){ + tmp.next(arg); + }} + }}); + if('function' == typeof arg){ + var be = { + off: onto.off || + (onto.off = function(){ + if(this.next === onto._.next){ return !0 } + if(this === this.the.last){ + this.the.last = this.back; + } + this.to.back = this.back; + this.next = onto._.next; + this.back.to = this.to; + if(this.the.last === this.the){ + delete this.on.tag[this.the.tag]; + } + }), + to: onto._, + next: arg, + the: tag, + on: this, + as: as, + }; + (be.back = tag.last || tag).to = be; + return tag.last = be; + } + if((tag = tag.to) && u !== arg){ tag.next(arg) } + return tag; + }; + })(USE, './onto'); + + ;USE(function(module){ + var to = (typeof setImmediate !== "undefined")? setImmediate : setTimeout, puff = function(cb){ + if(Q.length){ Q.push(cb); return } Q = [cb]; + to(function go(S){ S = S || +new Date; + var i = 0, cb; while(i < 9 && (cb = Q[i++])){ cb() } + console.STAT && console.STAT(S, +new Date - S, 'puff'); + if(cb && !(+new Date - S)){ return go(S) } + if(!(Q = Q.slice(i)).length){ return } + to(go, 0); + }, 0); + }, Q = []; + module.exports = setTimeout.puff = puff; + })(USE, './puff'); + + ;USE(function(module){ + /* Based on the Hypothetical Amnesia Machine thought experiment */ + function HAM(machineState, incomingState, currentState, incomingValue, currentValue){ + if(machineState < incomingState){ + return {defer: true}; // the incoming value is outside the boundary of the machine's state, it must be reprocessed in another state. + } + if(incomingState < currentState){ + return {historical: true}; // the incoming value is within the boundary of the machine's state, but not within the range. + + } + if(currentState < incomingState){ + return {converge: true, incoming: true}; // the incoming value is within both the boundary and the range of the machine's state. + + } + if(incomingState === currentState){ + incomingValue = Lexical(incomingValue) || ""; + currentValue = Lexical(currentValue) || ""; + if(incomingValue === currentValue){ // Note: while these are practically the same, the deltas could be technically different + return {state: true}; + } + /* + The following is a naive implementation, but will always work. + Never change it unless you have specific needs that absolutely require it. + If changed, your data will diverge unless you guarantee every peer's algorithm has also been changed to be the same. + As a result, it is highly discouraged to modify despite the fact that it is naive, + because convergence (data integrity) is generally more important. + Any difference in this algorithm must be given a new and different name. + */ + if(incomingValue < currentValue){ // Lexical only works on simple value types! + return {converge: true, current: true}; + } + if(currentValue < incomingValue){ // Lexical only works on simple value types! + return {converge: true, incoming: true}; + } + } + return {err: "Invalid CRDT Data: "+ incomingValue +" to "+ currentValue +" at "+ incomingState +" to "+ currentState +"!"}; + } + if(typeof JSON === 'undefined'){ + throw new Error( + 'JSON is not included in this browser. Please load it first: ' + + 'ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js' + ); + } + var Lexical = JSON.stringify, undefined; + module.exports = HAM; + })(USE, './HAM'); + + ;USE(function(module){ + var Type = USE('./type'); + var Val = {}; + Val.is = function(v){ // Valid values are a subset of JSON: null, binary, number (!Infinity), text, or a soul relation. Arrays need special algorithms to handle concurrency, so they are not supported directly. Use an extension that supports them if needed but research their problems first. + if(v === u){ return false } + if(v === null){ return true } // "deletes", nulling out keys. + if(v === Infinity){ return false } // we want this to be, but JSON does not support it, sad face. + if(text_is(v) // by "text" we mean strings. + || bi_is(v) // by "binary" we mean boolean. + || num_is(v)){ // by "number" we mean integers or decimals. + return true; // simple values are valid. + } + return Val.link.is(v) || false; // is the value a soul relation? Then it is valid and return it. If not, everything else remaining is an invalid data type. Custom extensions can be built on top of these primitives to support other types. + } + Val.link = Val.rel = {_: '#'}; + ;(function(){ + Val.link.is = function(v){ // this defines whether an object is a soul relation or not, they look like this: {'#': 'UUID'} + if(v && v[rel_] && !v._ && obj_is(v)){ // must be an object. + var o = {}; + obj_map(v, map, o); + if(o.id){ // a valid id was found. + return o.id; // yay! Return it. + } + } + return false; // the value was not a valid soul relation. + } + function map(s, k){ var o = this; // map over the object... + if(o.id){ return o.id = false } // if ID is already defined AND we're still looping through the object, it is considered invalid. + if(k == rel_ && text_is(s)){ // the key should be '#' and have a text value. + o.id = s; // we found the soul! + } else { + return o.id = false; // if there exists anything else on the object that isn't the soul, then it is considered invalid. + } + } + }()); + Val.link.ify = function(t){ return obj_put({}, rel_, t) } // convert a soul into a relation and return it. + Type.obj.has._ = '.'; + var rel_ = Val.link._, u; + var bi_is = Type.bi.is; + var num_is = Type.num.is; + var text_is = Type.text.is; + var obj = Type.obj, obj_is = obj.is, obj_put = obj.put, obj_map = obj.map; + module.exports = Val; + })(USE, './val'); + + ;USE(function(module){ + var Type = USE('./type'); + var Val = USE('./val'); + var Node = {_: '_'}; + Node.soul = function(n, o){ return (n && n._ && n._[o || soul_]) } // convenience function to check to see if there is a soul on a node and return it. + Node.soul.ify = function(n, o){ // put a soul on an object. + o = (typeof o === 'string')? {soul: o} : o || {}; + n = n || {}; // make sure it exists. + n._ = n._ || {}; // make sure meta exists. + n._[soul_] = o.soul || n._[soul_] || text_random(); // put the soul on it. + return n; + } + Node.soul._ = Val.link._; + ;(function(){ + Node.is = function(n, cb, as){ var s; // checks to see if an object is a valid node. + if(!obj_is(n)){ return false } // must be an object. + if(s = Node.soul(n)){ // must have a soul on it. + return !obj_map(n, map, {as:as,cb:cb,s:s,n:n}); + } + return false; // nope! This was not a valid node. + } + function map(v, k){ // we invert this because the way we check for this is via a negation. + if(k === Node._){ return } // skip over the metadata. + if(!Val.is(v)){ return true } // it is true that this is an invalid node. + if(this.cb){ this.cb.call(this.as, v, k, this.n, this.s) } // optionally callback each key/value. + } + }()); + ;(function(){ + Node.ify = function(obj, o, as){ // returns a node from a shallow object. + if(!o){ o = {} } + else if(typeof o === 'string'){ o = {soul: o} } + else if('function' == typeof o){ o = {map: o} } + if(o.map){ o.node = o.map.call(as, obj, u, o.node || {}) } + if(o.node = Node.soul.ify(o.node || {}, o)){ + obj_map(obj, map, {o:o,as:as}); + } + return o.node; // This will only be a valid node if the object wasn't already deep! + } + function map(v, k){ var o = this.o, tmp, u; // iterate over each key/value. + if(o.map){ + tmp = o.map.call(this.as, v, ''+k, o.node); + if(u === tmp){ + obj_del(o.node, k); + } else + if(o.node){ o.node[k] = tmp } + return; + } + if(Val.is(v)){ + o.node[k] = v; + } + } + }()); + var obj = Type.obj, obj_is = obj.is, obj_del = obj.del, obj_map = obj.map; + var text = Type.text, text_random = text.random; + var soul_ = Node.soul._; + var u; + module.exports = Node; + })(USE, './node'); + + ;USE(function(module){ + var Type = USE('./type'); + var Node = USE('./node'); + function State(){ + var t; + /*if(perf){ + t = start + perf.now(); // Danger: Accuracy decays significantly over time, even if precise. + } else {*/ + t = +new Date; + //} + if(last < t){ + return N = 0, last = t + State.drift; + } + return last = t + ((N += 1) / D) + State.drift; + } + var time = Type.time.is, last = -Infinity, N = 0, D = 1000; // WARNING! In the future, on machines that are D times faster than 2016AD machines, you will want to increase D by another several orders of magnitude so the processing speed never out paces the decimal resolution (increasing an integer effects the state accuracy). + var perf = (typeof performance !== 'undefined')? (performance.timing && performance) : false, start = (perf && perf.timing && perf.timing.navigationStart) || (perf = false); + var S_ = State._ = '>'; + State.drift = 0; + State.is = function(n, k, o){ // convenience function to get the state on a key on a node and return it. + var tmp = (k && n && n[N_] && n[N_][S_]) || o; + if(!tmp){ return } + return num_is(tmp = tmp[k])? tmp : -Infinity; + } + State.lex = function(){ return State().toString(36).replace('.','') } + State.ify = function(n, k, s, v, soul){ // put a key's state on a node. + if(!n || !n[N_]){ // reject if it is not node-like. + if(!soul){ // unless they passed a soul + return; + } + n = Node.soul.ify(n, soul); // then make it so! + } + var tmp = obj_as(n[N_], S_); // grab the states data. + if(u !== k && k !== N_){ + if(num_is(s)){ + tmp[k] = s; // add the valid state. + } + if(u !== v){ // Note: Not its job to check for valid values! + n[k] = v; + } + } + return n; + } + State.to = function(from, k, to){ + var val = (from||{})[k]; + if(obj_is(val)){ + val = obj_copy(val); + } + return State.ify(to, k, State.is(from, k), val, Node.soul(from)); + } + ;(function(){ + State.map = function(cb, s, as){ var u; // for use with Node.ify + var o = obj_is(o = cb || s)? o : null; + cb = fn_is(cb = cb || s)? cb : null; + if(o && !cb){ + s = num_is(s)? s : State(); + o[N_] = o[N_] || {}; + obj_map(o, map, {o:o,s:s}); + return o; + } + as = as || obj_is(s)? s : u; + s = num_is(s)? s : State(); + return function(v, k, o, opt){ + if(!cb){ + map.call({o: o, s: s}, v,k); + return v; + } + cb.call(as || this || {}, v, k, o, opt); + if(obj_has(o,k) && u === o[k]){ return } + map.call({o: o, s: s}, v,k); + } + } + function map(v,k){ + if(N_ === k){ return } + State.ify(this.o, k, this.s) ; + } + }()); + var obj = Type.obj, obj_as = obj.as, obj_has = obj.has, obj_is = obj.is, obj_map = obj.map, obj_copy = obj.copy; + var num = Type.num, num_is = num.is; + var fn = Type.fn, fn_is = fn.is; + var N_ = Node._, u; + module.exports = State; + })(USE, './state'); + + ;USE(function(module){ + var Type = USE('./type'); + var Val = USE('./val'); + var Node = USE('./node'); + var Graph = {}; + ;(function(){ + Graph.is = function(g, cb, fn, as){ // checks to see if an object is a valid graph. + if(!g || !obj_is(g) || obj_empty(g)){ return false } // must be an object. + return !obj_map(g, map, {cb:cb,fn:fn,as:as}); // makes sure it wasn't an empty object. + } + function map(n, s){ // we invert this because the way'? we check for this is via a negation. + if(!n || s !== Node.soul(n) || !Node.is(n, this.fn, this.as)){ return true } // it is true that this is an invalid graph. + if(!this.cb){ return } + nf.n = n; nf.as = this.as; // sequential race conditions aren't races. + this.cb.call(nf.as, n, s, nf); + } + function nf(fn){ // optional callback for each node. + if(fn){ Node.is(nf.n, fn, nf.as) } // where we then have an optional callback for each key/value. + } + }()); + ;(function(){ + Graph.ify = function(obj, env, as){ + var at = {path: [], obj: obj}; + if(!env){ + env = {}; + } else + if(typeof env === 'string'){ + env = {soul: env}; + } else + if('function' == typeof env){ + env.map = env; + } + if(typeof as === 'string'){ + env.soul = env.soul || as; + as = u; + } + if(env.soul){ + at.link = Val.link.ify(env.soul); + } + env.shell = (as||{}).shell; + env.graph = env.graph || {}; + env.seen = env.seen || []; + env.as = env.as || as; + node(env, at); + env.root = at.node; + return env.graph; + } + function node(env, at){ var tmp; + if(tmp = seen(env, at)){ return tmp } + at.env = env; + at.soul = soul; + if(Node.ify(at.obj, map, at)){ + at.link = at.link || Val.link.ify(Node.soul(at.node)); + if(at.obj !== env.shell){ + env.graph[Val.link.is(at.link)] = at.node; + } + } + return at; + } + function map(v,k,n){ + var at = this, env = at.env, is, tmp; + if(Node._ === k && obj_has(v,Val.link._)){ + return n._; // TODO: Bug? + } + if(!(is = valid(v,k,n, at,env))){ return } + if(!k){ + at.node = at.node || n || {}; + if(obj_has(v, Node._) && Node.soul(v)){ // ? for safety ? + at.node._ = obj_copy(v._); + } + at.node = Node.soul.ify(at.node, Val.link.is(at.link)); + at.link = at.link || Val.link.ify(Node.soul(at.node)); + } + if(tmp = env.map){ + tmp.call(env.as || {}, v,k,n, at); + if(obj_has(n,k)){ + v = n[k]; + if(u === v){ + obj_del(n, k); + return; + } + if(!(is = valid(v,k,n, at,env))){ return } + } + } + if(!k){ return at.node } + if(true === is){ + return v; + } + tmp = node(env, {obj: v, path: at.path.concat(k)}); + if(!tmp.node){ return } + return tmp.link; //{'#': Node.soul(tmp.node)}; + } + function soul(id){ var at = this; + var prev = Val.link.is(at.link), graph = at.env.graph; + at.link = at.link || Val.link.ify(id); + at.link[Val.link._] = id; + if(at.node && at.node[Node._]){ + at.node[Node._][Val.link._] = id; + } + if(obj_has(graph, prev)){ + graph[id] = graph[prev]; + obj_del(graph, prev); + } + } + function valid(v,k,n, at,env){ var tmp; + if(Val.is(v)){ return true } + if(obj_is(v)){ return 1 } + if(tmp = env.invalid){ + v = tmp.call(env.as || {}, v,k,n); + return valid(v,k,n, at,env); + } + env.err = "Invalid value at '" + at.path.concat(k).join('.') + "'!"; + if(Type.list.is(v)){ env.err += " Use `.set(item)` instead of an Array." } + } + function seen(env, at){ + var arr = env.seen, i = arr.length, has; + while(i--){ has = arr[i]; + if(at.obj === has.obj){ return has } + } + arr.push(at); + } + }()); + Graph.node = function(node){ + var soul = Node.soul(node); + if(!soul){ return } + return obj_put({}, soul, node); + } + ;(function(){ + Graph.to = function(graph, root, opt){ + if(!graph){ return } + var obj = {}; + opt = opt || {seen: {}}; + obj_map(graph[root], map, {obj:obj, graph: graph, opt: opt}); + return obj; + } + function map(v,k){ var tmp, obj; + if(Node._ === k){ + if(obj_empty(v, Val.link._)){ + return; + } + this.obj[k] = obj_copy(v); + return; + } + if(!(tmp = Val.link.is(v))){ + this.obj[k] = v; + return; + } + if(obj = this.opt.seen[tmp]){ + this.obj[k] = obj; + return; + } + this.obj[k] = this.opt.seen[tmp] = Graph.to(this.graph, tmp, this.opt); + } + }()); + var fn_is = Type.fn.is; + var obj = Type.obj, obj_is = obj.is, obj_del = obj.del, obj_has = obj.has, obj_empty = obj.empty, obj_put = obj.put, obj_map = obj.map, obj_copy = obj.copy; + var u; + module.exports = Graph; + })(USE, './graph'); + + ;USE(function(module){ + // request / response module, for asking and acking messages. + USE('./onto'); // depends upon onto! + module.exports = function ask(cb, as){ + if(!this.on){ return } + if(!('function' == typeof cb)){ + if(!cb || !as){ return } + var id = cb['#'] || cb, tmp = (this.tag||'')[id]; + if(!tmp){ return } + tmp = this.on(id, as); + clearTimeout(tmp.err); + return true; + } + var id = (as && as['#']) || Math.random().toString(36).slice(2); + if(!cb){ return id } + var to = this.on(id, cb, as); + to.err = to.err || setTimeout(function(){ + to.next({err: "Error: No ACK yet.", lack: true}); + to.off(); + }, (this.opt||{}).lack || 9000); + return id; + } + })(USE, './ask'); + + ;USE(function(module){ + var Type = USE('./type'); + function Dup(opt){ + var dup = {s:{}}, s = dup.s; + opt = opt || {max: 1000, age: /*1000 * 9};//*/ 1000 * 9 * 3}; + dup.check = function(id){ + if(!s[id]){ return false } + return dt(id); + } + var dt = dup.track = function(id){ + var it = s[id] || (s[id] = {}); + it.was = +new Date; + if(!dup.to){ dup.to = setTimeout(dup.drop, opt.age + 9) } + return it; + } + dup.drop = function(age){ + var now = +new Date; + Type.obj.map(s, function(it, id){ + if(it && (age || opt.age) > (now - it.was)){ return } + delete s[id]; + }); + dup.to = null; + console.STAT && (age = +new Date - now) > 9 && console.STAT(now, age, 'dup drop'); + } + return dup; + } + module.exports = Dup; + })(USE, './dup'); + + ;USE(function(module){ + + function Gun(o){ + if(o instanceof Gun){ return (this._ = {$: this}).$ } + if(!(this instanceof Gun)){ return new Gun(o) } + return Gun.create(this._ = {$: this, opt: o}); + } + + Gun.is = function($){ return ($ instanceof Gun) || ($ && $._ && ($ === $._.$)) || false } + + Gun.version = 0.2020; + + Gun.chain = Gun.prototype; + Gun.chain.toJSON = function(){}; + + var Type = USE('./type'); + Type.obj.to(Type, Gun); + Gun.HAM = USE('./HAM'); + Gun.val = USE('./val'); + Gun.node = USE('./node'); + Gun.state = USE('./state'); + Gun.graph = USE('./graph'); + Gun.on = USE('./onto'); + Gun.ask = USE('./ask'); + Gun.dup = USE('./dup'); + Gun.puff = USE('./puff'); + + ;(function(){ + Gun.create = function(at){ + at.root = at.root || at; + at.graph = at.graph || {}; + at.on = at.on || Gun.on; + at.ask = at.ask || Gun.ask; + at.dup = at.dup || Gun.dup(); + var gun = at.$.opt(at.opt); + if(!at.once){ + at.on('in', universe, at); + at.on('out', universe, at); + at.on('put', map, at); + Gun.on('create', at); + at.on('create', at); + } + at.once = 1; + return gun; + } + function universe(msg){ + if(!msg){ return } + if(msg.out === universe){ this.to.next(msg); return } + var eve = this, as = eve.as, at = as.at || as, gun = at.$, dup = at.dup, tmp, DBG = msg.DBG; + (tmp = msg['#']) || (tmp = msg['#'] = text_rand(9)); + if(dup.check(tmp)){ return } dup.track(tmp); + tmp = msg._; msg._ = ('function' == typeof tmp)? tmp : function(){}; + (msg.$ && (msg.$ === (msg.$._||'').$)) || (msg.$ = gun); + if(!at.ask(msg['@'], msg)){ // is this machine listening for an ack? + DBG && (DBG.u = +new Date); + if(msg.get){ Gun.on._get(msg, gun) } + if(msg.put){ put(msg); return } + } + DBG && (DBG.uc = +new Date); + eve.to.next(msg); + DBG && (DBG.ua = +new Date); + msg.out = universe; at.on('out', msg); + DBG && (DBG.ue = +new Date); + } + function put(msg){ + if(!msg){ return } + var ctx = msg._||'', root = ctx.root = ((ctx.$ = msg.$||'')._||'').root; + var put = msg.put, id = msg['#'], err, tmp; + var DBG = ctx.DBG = msg.DBG; + if(put['#'] && put['.']){ root.on('put', msg); return } // TODO: BUG! This needs to call HAM instead. + /*root.on(id, function(m){ + console.log('ack:', m); + });*/ + ctx.out = msg; + ctx.lot = {s: 0, more: 1}; + var S = +new Date; + DBG && (DBG.p = S); + for(var soul in put){ // Gun.obj.native() makes this safe. + var node = put[soul], states; + if(!node){ err = ERR+cut(soul)+"no node."; break } + if(!(tmp = node._)){ err = ERR+cut(soul)+"no meta."; break } + if(soul !== tmp[_soul]){ err = ERR+cut(soul)+"soul not same."; break } + if(!(states = tmp[state_])){ err = ERR+cut(soul)+"no state."; break } + for(var key in node){ // double loop uncool, but have to support old format. + if(node_ === key){ continue } + var val = node[key], state = states[key]; + if(u === state){ err = ERR+cut(key)+"on"+cut(soul)+"no state."; break } + if(!val_is(val)){ err = ERR+cut(key)+"on"+cut(soul)+"bad "+(typeof val)+cut(val); break } + ham(val, key, soul, state, msg); + } + if(err){ break } + } + DBG && (DBG.pe = +new Date); + if(console.STAT){ console.STAT(S, +new Date - S, 'mix');console.STAT(S, ctx.lot.s, 'mix #') } + if(ctx.err = err){ root.on('in', {'@': id, err: Gun.log(err)}); return } + if(!(--ctx.lot.more)){ fire(ctx) } // if synchronous. + if(!ctx.stun && !msg['@']){ root.on('in', {'@': id, ok: -1}) } // in case no diff sent to storage, etc., still ack. + } Gun.on.put = put; + function ham(val, key, soul, state, msg){ + var ctx = msg._||'', root = ctx.root, graph = root.graph, lot; + var vertex = graph[soul] || empty, was = state_is(vertex, key, 1), known = vertex[key]; + var machine = State(), is = HAM(machine, state, was, val, known), u; + if(!is.incoming){ + if(is.defer){ + var to = state - machine; + setTimeout(function(){ + ham(val, key, soul, state, msg); + }, to > MD? MD : to); // setTimeout Max Defer 32bit :( + if(!ctx.to){ root.on('in', {'@': msg['#'], err: to}) } ctx.to = 1; // TODO: This causes too many problems unless sending peers auto-retry. + return to; + } + //return; // it should be this + if(!ctx.miss){ return } // but some chains have a cache miss that need to re-fire. // TODO: Improve in future. + } + (lot = ctx.lot||'').s++; lot.more++; + (ctx.stun || (ctx.stun = {}))[soul+key] = 1; + var DBG = ctx.DBG; DBG && (DBG.ph = DBG.ph || +new Date); + root.on('put', {'#': msg['#'], '@': msg['@'], put: {'#': soul, '.': key, ':': val, '>': state}, _: ctx}); + } + function map(msg){ + var DBG; if(DBG = (msg._||'').DBG){ DBG.pa = +new Date; DBG.pm = DBG.pm || +new Date} + var eve = this, root = eve.as, graph = root.graph, ctx = msg._, put = msg.put, soul = put['#'], key = put['.'], val = put[':'], state = put['>'], id = msg['#'], tmp; + graph[soul] = state_ify(graph[soul], key, state, val, soul); // TODO: Only put in graph if subscribed? Relays vs Browsers? + chain(ctx, soul, key, (u !== (tmp = put['=']))? tmp : val, state); // TODO: This should NOT be how the API works, this should be done at an extension layer, but hacky solution to migrate with old code for now. + if((tmp = ctx.out) && (tmp = tmp.put)){ + tmp[soul] = state_ify(tmp[soul], key, state, val, soul); // TODO: Hacky, fix & come back later, for actual pushing messages. + } + if(!(--ctx.lot.more)){ fire(ctx) } // TODO: 'forget' feature in SEA tied to this, bad approach, but hacked in for now. Any changes here must update there. + eve.to.next(msg); + } + function chain(ctx, soul, key,val, state){ + var root = ctx.root, put, tmp; + (root.opt||'').super && root.$.get(soul); // I think we need super for now, but since we are rewriting, should consider getting rid of it. + if(!root || !(tmp = root.next) || !(tmp = tmp[soul]) || !tmp.$){ return } + (put = ctx.put || (ctx.put = {}))[soul] = state_ify(put[soul], key, state, val, soul); + tmp.put = state_ify(tmp.put, key, state, val, soul); + } + function fire(ctx){ + if(ctx.err){ return } + var stop = {}; + var root = ((ctx.$||'')._||'').root, next = (root||'').next||'', put = ctx.put, tmp; + var S = +new Date; + //Gun.graph.is(put, function(node, soul){ + for(var soul in put){ var node = put[soul]; // Gun.obj.native() makes this safe. + if(!(tmp = next[soul]) || !tmp.$){ continue } + root.stop = stop; // temporary fix till a better solution? + tmp.on('in', {$: tmp.$, get: soul, put: node}); + root.stop = null; // temporary fix till a better solution? + } + console.STAT && console.STAT(S, +new Date - S, 'fire'); + ctx.DBG && (ctx.DBG.f = +new Date); + if(!(tmp = ctx.out)){ return } + tmp.out = universe; + root.on('out', tmp); + } + var ERR = "Error: Invalid graph!"; + var cut = function(s){ return " '"+(''+s).slice(0,9)+"...' " } + var HAM = Gun.HAM, MD = 2147483647, State = Gun.state; + }()); + + ;(function(){ + Gun.on._put = function(msg, gun){ + var at = gun._, ctx = {$: gun, graph: at.graph, put: {}, map: {}, souls: {}, machine: Gun.state(), ack: msg['@'], cat: at, stop: {}}; + if(!Gun.obj.map(msg.put, perf, ctx)){ return } // HNPERF: performance test, not core code, do not port. + if(!Gun.graph.is(msg.put, null, verify, ctx)){ ctx.err = "Error: Invalid graph!" } + if(ctx.err){ return at.on('in', {'@': msg['#'], err: Gun.log(ctx.err) }) } + obj_map(ctx.put, merge, ctx); + if(!ctx.async){ obj_map(ctx.map, map, ctx) } + if(u !== ctx.defer){ + var to = ctx.defer - ctx.machine; + setTimeout(function(){ + Gun.on._put(msg, gun); + }, to > MD? MD : to ); // setTimeout Max Defer 32bit :( + } + if(!ctx.diff){ return } + at.on('put', obj_to(msg, {put: ctx.diff})); + }; + function verify(val, key, node, soul){ var ctx = this; + var state = Gun.state.is(node, key), tmp; + if(!state){ return ctx.err = "Error: No state on '"+key+"' in node '"+soul+"'!" } + var vertex = ctx.graph[soul] || empty, was = Gun.state.is(vertex, key, true), known = vertex[key]; + var HAM = Gun.HAM(ctx.machine, state, was, val, known); + if(!HAM.incoming){ + if(HAM.defer){ // pick the lowest + ctx.defer = (state < (ctx.defer || Infinity))? state : ctx.defer; + } + return; + } + ctx.put[soul] = Gun.state.to(node, key, ctx.put[soul]); + (ctx.diff || (ctx.diff = {}))[soul] = Gun.state.to(node, key, ctx.diff[soul]); + ctx.souls[soul] = true; + } + function merge(node, soul){ + var ctx = this, cat = ctx.$._, at = (cat.next || empty)[soul]; + if(!at){ + if(!(cat.opt||empty).super){ + ctx.souls[soul] = false; + return; + } + at = (ctx.$.get(soul)._); + } + var msg = ctx.map[soul] = { + put: node, + get: soul, + $: at.$ + }, as = {ctx: ctx, msg: msg}; + ctx.async = !!cat.tag.node; + if(ctx.ack){ msg['@'] = ctx.ack } + obj_map(node, each, as); + if(!ctx.async){ return } + if(!ctx.and){ + // If it is async, we only need to setup one listener per context (ctx) + cat.on('node', function(m){ + this.to.next(m); // make sure to call other context's listeners. + if(m !== ctx.map[m.get]){ return } // filter out events not from this context! + ctx.souls[m.get] = false; // set our many-async flag + obj_map(m.put, patch, m); // merge into view + if(obj_map(ctx.souls, function(v){ if(v){ return v } })){ return } // if flag still outstanding, keep waiting. + if(ctx.c){ return } ctx.c = 1; // failsafe for only being called once per context. + this.off(); + obj_map(ctx.map, map, ctx); // all done, trigger chains. + }); + } + ctx.and = true; + cat.on('node', msg); // each node on the current context's graph needs to be emitted though. + } + function each(val, key){ + var ctx = this.ctx, graph = ctx.graph, msg = this.msg, soul = msg.get, node = msg.put, at = (msg.$._), tmp; + graph[soul] = Gun.state.to(node, key, graph[soul]); + if(ctx.async){ return } + at.put = Gun.state.to(node, key, at.put); + } + function patch(val, key){ + var msg = this, node = msg.put, at = (msg.$._); + at.put = Gun.state.to(node, key, at.put); + } + function map(msg, soul){ + if(!msg.$){ return } + this.cat.stop = this.stop; // temporary fix till a better solution? + (msg.$._).on('in', msg); + this.cat.stop = null; // temporary fix till a better solution? + } + function perf(node, soul){ if(node !== this.graph[soul]){ return true } } // HNPERF: do not port! + + Gun.on._get = function(msg, gun){ + var root = gun._, get = msg.get, soul = get[_soul], node = root.graph[soul], has = get[_has], tmp; + var next = root.next || (root.next = {}), at = next[soul]; + // queue concurrent GETs? + var ctx = msg._||'', DBG = ctx.DBG = msg.DBG; + DBG && (DBG.g = +new Date); + if(!node){ return root.on('get', msg) } + if(has){ + if('string' != typeof has || !obj_has(node, has)){ return root.on('get', msg) } + node = Gun.state.to(node, has); + // If we have a key in-memory, do we really need to fetch? + // Maybe... in case the in-memory key we have is a local write + // we still need to trigger a pull/merge from peers. + } else { + node = Gun.window? Gun.obj.copy(node) : node; // HNPERF: If !browser bump Performance? Is this too dangerous to reference root graph? Copy / shallow copy too expensive for big nodes. Gun.obj.to(node); // 1 layer deep copy // Gun.obj.copy(node); // too slow on big nodes + } + node = Gun.graph.node(node); + tmp = (at||empty).ack; + var faith = function(){}; faith.ram = faith.faith = true; // HNPERF: We're testing performance improvement by skipping going through security again, but this should be audited. + faith.$ = msg.$; + DBG && (DBG.ga = +new Date); + root.on('in', { + '@': msg['#'], + put: node, + ram: 1, + $: gun, + _: faith + }); + DBG && (DBG.gm = +new Date); + //if(0 < tmp){ return } + root.on('get', msg); + DBG && (DBG.gd = +new Date); + } + }()); + + ;(function(){ + Gun.chain.opt = function(opt){ + opt = opt || {}; + var gun = this, at = gun._, tmp = opt.peers || opt; + if(!obj_is(opt)){ opt = {} } + if(!obj_is(at.opt)){ at.opt = opt } + if(text_is(tmp)){ tmp = [tmp] } + if(list_is(tmp)){ + tmp = obj_map(tmp, function(url, i, map){ + i = {}; i.id = i.url = url; map(url, i); + }); + if(!obj_is(at.opt.peers)){ at.opt.peers = {}} + at.opt.peers = obj_to(tmp, at.opt.peers); + } + at.opt.peers = at.opt.peers || {}; + obj_map(opt, function each(v,k){ + if(!obj_has(this, k) || text.is(v) || obj.empty(v)){ this[k] = v ; return } + if(v && v.constructor !== Object && !list_is(v)){ return } + obj_map(v, each, this[k]); + }, at.opt); + Gun.on('opt', at); + //at.opt.uuid = at.opt.uuid || function(){ return state_lex() + text_rand(12) } + Gun.obj.native(); + return gun; + } + }()); + Gun.obj.native = function(){ var p = Object.prototype; for(var i in p){ console.log("Native Object.prototype polluted, reverting", i); delete p[i]; } }; + + var list_is = Gun.list.is; + var text = Gun.text, text_is = text.is, text_rand = text.random; + var obj = Gun.obj, obj_empty = obj.empty, obj_is = obj.is, obj_has = obj.has, obj_to = obj.to, obj_map = obj.map, obj_copy = obj.copy; + var state_lex = Gun.state.lex, state_ify = Gun.state.ify, state_is = Gun.state.is, _soul = Gun.val.link._, _has = '.', node_ = Gun.node._, val_is = Gun.val.is, rel_is = Gun.val.link.is, state_ = Gun.state._; + var empty = {}, u; + var C; + + Gun.log = function(){ return (!Gun.log.off && C.log.apply(C, arguments)), [].slice.call(arguments).join(' ') }; + Gun.log.once = function(w,s,o){ return (o = Gun.log.once)[w] = o[w] || 0, o[w]++ || Gun.log(s) }; + + if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window } + try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){} + module.exports = Gun; + + (Gun.window||'').console = (Gun.window||'').console || {log: function(){}}; + (C = console).only = function(i, s){ return (C.only.i && i === C.only.i && C.only.i++) && (C.log.apply(C, arguments) || s) }; + + ;"Please do not remove welcome log unless you are paying for a monthly sponsorship, thanks!"; + Gun.log.once("welcome", "Hello wonderful person! :) Thanks for using GUN, please ask for help on http://chat.gun.eco if anything takes you longer than 5min to figure out!"); + })(USE, './root'); + + ;USE(function(module){ + var Gun = USE('./root'); + Gun.chain.back = function(n, opt){ var tmp; + n = n || 1; + if(-1 === n || Infinity === n){ + return this._.root.$; + } else + if(1 === n){ + return (this._.back || this._).$; + } + var gun = this, at = gun._; + if(typeof n === 'string'){ + n = n.split('.'); + } + if(n instanceof Array){ + var i = 0, l = n.length, tmp = at; + for(i; i < l; i++){ + tmp = (tmp||empty)[n[i]]; + } + if(u !== tmp){ + return opt? gun : tmp; + } else + if((tmp = at.back)){ + return tmp.$.back(n, opt); + } + return; + } + if('function' == typeof n){ + var yes, tmp = {back: at}; + while((tmp = tmp.back) + && u === (yes = n(tmp, opt))){} + return yes; + } + if(Gun.num.is(n)){ + return (at.back || at).$.back(n - 1); + } + return this; + } + var empty = {}, u; + })(USE, './back'); + + ;USE(function(module){ + // WARNING: GUN is very simple, but the JavaScript chaining API around GUN + // is complicated and was extremely hard to build. If you port GUN to another + // language, consider implementing an easier API to build. + var Gun = USE('./root'); + Gun.chain.chain = function(sub){ + var gun = this, at = gun._, chain = new (sub || gun).constructor(gun), cat = chain._, root; + cat.root = root = at.root; + cat.id = ++root.once; + cat.back = gun._; + cat.on = Gun.on; + cat.on('in', input, cat); // For 'in' if I add my own listeners to each then I MUST do it before in gets called. If I listen globally for all incoming data instead though, regardless of individual listeners, I can transform the data there and then as well. + cat.on('out', output, cat); // However for output, there isn't really the global option. I must listen by adding my own listener individually BEFORE this one is ever called. + return chain; + } + + function output(msg){ + var put, get, at = this.as, back = at.back, root = at.root, tmp; + if(!msg.$){ msg.$ = at.$ } + this.to.next(msg); + if(get = msg.get){ + /*if(u !== at.put){ + at.on('in', at); + return; + }*/ + if(at.lex){ msg.get = obj_to(at.lex, msg.get) } + if(get['#'] || at.soul){ + get['#'] = get['#'] || at.soul; + msg['#'] || (msg['#'] = text_rand(9)); + back = (root.$.get(get['#'])._); + if(!(get = get['.'])){ + tmp = back.ack; + if(!tmp){ back.ack = -1 } + if(obj_has(back, 'put')){ + back.on('in', back); + } + if(tmp && u !== back.put){ return } //if(tmp){ return } + msg.$ = back.$; + } else + if(obj_has(back.put, get)){ // TODO: support #LEX ! + put = (back.$.get(get)._); + if(!(tmp = put.ack)){ put.ack = -1 } + back.on('in', { + $: back.$, + put: Gun.state.to(back.put, get), + get: back.get + }); + if(tmp){ return } + } else + if('string' != typeof get){ + var put = {}, meta = (back.put||{})._; + Gun.obj.map(back.put, function(v,k){ + if(!Gun.text.match(k, get)){ return } + put[k] = v; + }) + if(!Gun.obj.empty(put)){ + put._ = meta; + back.on('in', {$: back.$, put: put, get: back.get}) + } + if(tmp = at.lex){ + tmp = (tmp._) || (tmp._ = function(){}); + if(back.ack < tmp.ask){ tmp.ask = back.ack } + if(tmp.ask){ return } + tmp.ask = 1; + } + } + root.ask(ack, msg); + return root.on('in', msg); + } + if(root.now){ root.now[at.id] = root.now[at.id] || true; at.pass = {} } + if(get['.']){ + if(at.get){ + msg = {get: {'.': at.get}, $: at.$}; + //if(back.ask || (back.ask = {})[at.get]){ return } + (back.ask || (back.ask = {})); + back.ask[at.get] = msg.$._; // TODO: PERFORMANCE? More elegant way? + return back.on('out', msg); + } + msg = {get: {}, $: at.$}; + return back.on('out', msg); + } + at.ack = at.ack || -1; + if(at.get){ + msg.$ = at.$; + get['.'] = at.get; + (back.ask || (back.ask = {}))[at.get] = msg.$._; // TODO: PERFORMANCE? More elegant way? + return back.on('out', msg); + } + } + return back.on('out', msg); + } + + function input(msg){ + var eve = this, cat = eve.as, root = cat.root, gun = msg.$, at = (gun||empty)._ || empty, change = msg.put, rel, tmp; + if(cat.get && msg.get !== cat.get){ + msg = obj_to(msg, {get: cat.get}); + } + if(cat.has && at !== cat){ + msg = obj_to(msg, {$: cat.$}); + if(at.ack){ + cat.ack = at.ack; + //cat.ack = cat.ack || at.ack; + } + } + if(u === change){ + tmp = at.put; + eve.to.next(msg); + if(cat.soul){ return } // TODO: BUG, I believee the fresh input refactor caught an edge case that a `gun.get('soul').get('key')` that points to a soul that doesn't exist will not trigger val/get etc. + if(u === tmp && u !== at.put){ return } + echo(cat, msg, eve); + if(cat.has){ + not(cat, msg); + } + obj_del(at.echo, cat.id); + obj_del(cat.map, at.id); + return; + } + if(cat.soul){ + eve.to.next(msg); + echo(cat, msg, eve); + if(cat.next){ obj_map(change, map, {msg: msg, cat: cat}) } + return; + } + if(!(rel = Gun.val.link.is(change))){ + if(Gun.val.is(change)){ + if(cat.has || cat.soul){ + not(cat, msg); + } else + if(at.has || at.soul){ + (at.echo || (at.echo = {}))[cat.id] = at.echo[at.id] || cat; + (cat.map || (cat.map = {}))[at.id] = cat.map[at.id] || {at: at}; + //if(u === at.put){ return } // Not necessary but improves performance. If we have it but at does not, that means we got things out of order and at will get it. Once at gets it, it will tell us again. + } + eve.to.next(msg); + echo(cat, msg, eve); + return; + } + if(cat.has && at !== cat && obj_has(at, 'put')){ + cat.put = at.put; + }; + if((rel = Gun.node.soul(change)) && at.has){ + at.put = (cat.root.$.get(rel)._).put; + } + tmp = (root.stop || {})[at.id]; + //if(tmp && tmp[cat.id]){ } else { + eve.to.next(msg); + //} + relate(cat, msg, at, rel); + echo(cat, msg, eve); + if(cat.next){ obj_map(change, map, {msg: msg, cat: cat}) } + return; + } + var was = root.stop; + tmp = root.stop || {}; + tmp = tmp[at.id] || (tmp[at.id] = {}); + //if(tmp[cat.id]){ return } + tmp.is = tmp.is || at.put; + tmp[cat.id] = at.put || true; + //if(root.stop){ + eve.to.next(msg) + //} + relate(cat, msg, at, rel); + echo(cat, msg, eve); + } + + function relate(at, msg, from, rel){ + if(!rel || node_ === at.get){ return } + var tmp = (at.root.$.get(rel)._); + if(at.has){ + from = tmp; + } else + if(from.has){ + relate(from, msg, from, rel); + } + if(from === at){ return } + if(!from.$){ from = {} } + (from.echo || (from.echo = {}))[at.id] = from.echo[at.id] || at; + if(at.has && !(at.map||empty)[from.id]){ // if we haven't seen this before. + not(at, msg); + } + tmp = from.id? ((at.map || (at.map = {}))[from.id] = at.map[from.id] || {at: from}) : {}; + if(rel === tmp.link){ + if(!(tmp.pass || at.pass)){ + return; + } + } + if(at.pass){ + Gun.obj.map(at.map, function(tmp){ tmp.pass = true }) + obj_del(at, 'pass'); + } + if(tmp.pass){ obj_del(tmp, 'pass') } + if(at.has){ at.link = rel } + ask(at, tmp.link = rel); + } + function echo(at, msg, ev){ + if(!at.echo){ return } // || node_ === at.get ? + //if(at.has){ msg = obj_to(msg, {event: ev}) } + obj_map(at.echo, reverb, msg); + } + function reverb(to){ + if(!to || !to.on){ return } + to.on('in', this); + } + function map(data, key){ // Map over only the changes on every update. + var cat = this.cat, next = cat.next || empty, via = this.msg, chain, at, tmp; + if(node_ === key && !next[key]){ return } + if(!(at = next[key])){ + return; + } + //if(data && data[_soul] && (tmp = Gun.val.link.is(data)) && (tmp = (cat.root.$.get(tmp)._)) && obj_has(tmp, 'put')){ + // data = tmp.put; + //} + if(at.has){ + //if(!(data && data[_soul] && Gun.val.link.is(data) === Gun.node.soul(at.put))){ + if(u === at.put || !Gun.val.link.is(data)){ + at.put = data; + } + chain = at.$; + } else + if(tmp = via.$){ + tmp = (chain = via.$.get(key))._; + if(u === tmp.put || !Gun.val.link.is(data)){ + tmp.put = data; + } + } + at.on('in', { + put: data, + get: key, + $: chain, + via: via + }); + } + function not(at, msg){ + if(!(at.has || at.soul)){ return } + var tmp = at.map, root = at.root; + at.map = null; + if(at.has){ + if(at.dub && at.root.stop){ at.dub = null } + at.link = null; + } + //if(!root.now || !root.now[at.id]){ + if(!at.pass){ + if((!msg['@']) && null === tmp){ return } + //obj_del(at, 'pass'); + } + if(u === tmp && Gun.val.link.is(at.put)){ return } // This prevents the very first call of a thing from triggering a "clean up" call. // TODO: link.is(at.put) || !val.is(at.put) ? + obj_map(tmp, function(proxy){ + if(!(proxy = proxy.at)){ return } + obj_del(proxy.echo, at.id); + }); + tmp = at.put; + obj_map(at.next, function(neat, key){ + if(u === tmp && u !== at.put){ return true } + neat.put = u; + if(neat.ack){ + neat.ack = -1; // Shouldn't this be reset to 0? If we do that, SEA test `set user ref should be found` fails, odd. + } + neat.on('in', { + get: key, + $: neat.$, + put: u + }); + }); + } + function ask(at, soul){ + var tmp = (at.root.$.get(soul)._), lex = at.lex; + if(at.ack || lex){ + (lex = lex||{})['#'] = soul; + tmp.on('out', {get: lex}); + if(!at.ask){ return } // TODO: PERFORMANCE? More elegant way? + } + tmp = at.ask; Gun.obj.del(at, 'ask'); + obj_map(tmp || at.next, function(neat, key){ + var lex = neat.lex || {}; lex['#'] = soul; lex['.'] = lex['.'] || key; + neat.on('out', {get: lex}); + }); + Gun.obj.del(at, 'ask'); // TODO: PERFORMANCE? More elegant way? + } + function ack(msg, ev){ + var as = this.as, get = as.get||'', at = as.$._, tmp = (msg.put||'')[get['#']]; + if(at.ack){ at.ack = (at.ack + 1) || 1; } + if(!msg.put || ('string' == typeof get['.'] && !obj_has(tmp, at.get))){ + if(at.put !== u){ return } + at.on('in', { + get: at.get, + put: at.put = u, + $: at.$, + '@': msg['@'] + }); + return; + } + if(node_ == get['.']){ // is this a security concern? + at.on('in', {get: at.get, put: Gun.val.link.ify(get['#']), $: at.$, '@': msg['@']}); + return; + } + if(at.$ === (msg._||'').$){ // replying to self, for perf, skip ham/security tho needs audit. + (msg._).miss = (at.put === u); + } + Gun.on.put(msg); + } + var empty = {}, u; + var obj = Gun.obj, obj_has = obj.has, obj_put = obj.put, obj_del = obj.del, obj_to = obj.to, obj_map = obj.map; + var text_rand = Gun.text.random; + var _soul = Gun.val.link._, node_ = Gun.node._; + })(USE, './chain'); + + ;USE(function(module){ + var Gun = USE('./root'); + Gun.chain.get = function(key, cb, as){ + var gun, tmp; + if(typeof key === 'string'){ + var back = this, cat = back._; + var next = cat.next || empty; + if(!(gun = next[key])){ + gun = cache(key, back); + } + gun = gun.$; + } else + if('function' == typeof key){ + if(true === cb){ return soul(this, key, cb, as), this } + gun = this; + var at = gun._, root = at.root, tmp = root.now, ev; + as = cb || {}; + as.at = at; + as.use = key; + as.out = as.out || {}; + as.out.get = as.out.get || {}; + (ev = at.on('in', use, as)).rid = rid; + (root.now = {$:1})[as.now = at.id] = ev; + var mum = root.mum; root.mum = {}; + at.on('out', as.out); + root.mum = mum; + root.now = tmp; + return gun; + } else + if(num_is(key)){ + return this.get(''+key, cb, as); + } else + if(tmp = rel.is(key)){ + return this.get(tmp, cb, as); + } else + if(obj.is(key)){ + gun = this; + if(tmp = ((tmp = key['#'])||empty)['='] || tmp){ gun = gun.get(tmp) } + gun._.lex = key; + return gun; + } else { + (as = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP + if(cb){ cb.call(as, as._.err) } + return as; + } + if(tmp = this._.stun){ // TODO: Refactor? + gun._.stun = gun._.stun || tmp; + } + if(cb && 'function' == typeof cb){ + gun.get(cb, as); + } + return gun; + } + function cache(key, back){ + var cat = back._, next = cat.next, gun = back.chain(), at = gun._; + if(!next){ next = cat.next = {} } + next[at.get = key] = at; + if(back === cat.root.$){ + at.soul = key; + } else + if(cat.soul || cat.has){ + at.has = key; + //if(obj_has(cat.put, key)){ + //at.put = cat.put[key]; + //} + } + return at; + } + function soul(gun, cb, opt, as){ + var cat = gun._, acks = 0, tmp; + if(tmp = cat.soul || cat.link || cat.dub){ return cb(tmp, as, cat) } + if(cat.jam){ return cat.jam.push([cb, as]) } + cat.jam = [[cb,as]]; + gun.get(function go(msg, eve){ + if(u === msg.put && !cat.root.opt.super && (tmp = Object.keys(cat.root.opt.peers).length) && ++acks <= tmp){ // TODO: super should not be in core code, bring AXE up into core instead to fix? + return; + } + eve.rid(msg); + var at = ((at = msg.$) && at._) || {}, i = 0, as; + tmp = cat.jam; delete cat.jam; // tmp = cat.jam.splice(0, 100); + //if(tmp.length){ process.nextTick(function(){ go(msg, eve) }) } + while(as = tmp[i++]){ //Gun.obj.map(tmp, function(as, cb){ + var cb = as[0], id; as = as[1]; + cb && cb(id = at.link || at.soul || rel.is(msg.put) || node_soul(msg.put) || at.dub, as, msg, eve); + } //); + }, {out: {get: {'.':true}}}); + return gun; + } + function use(msg){ + var eve = this, as = eve.as, cat = as.at, root = cat.root, gun = msg.$, at = (gun||{})._ || {}, data = msg.put || at.put, tmp; + if((tmp = root.now) && eve !== tmp[as.now]){ return eve.to.next(msg) } + //if(at.async && msg.root){ return } + //if(at.async === 1 && cat.async !== true){ return } + //if(root.stop && root.stop[at.id]){ return } root.stop && (root.stop[at.id] = true); + //if(!at.async && !cat.async && at.put && msg.put === at.put){ return } + //else if(!cat.async && msg.put !== at.put && root.stop && root.stop[at.id]){ return } root.stop && (root.stop[at.id] = true); + + + //root.stop && (root.stop.id = root.stop.id || Gun.text.random(2)); + //if((tmp = root.stop) && (tmp = tmp[at.id] || (tmp[at.id] = {})) && tmp[cat.id]){ return } tmp && (tmp[cat.id] = true); + if(eve.seen && at.id && eve.seen[at.id]){ return eve.to.next(msg) } + //if((tmp = root.stop)){ if(tmp[at.id]){ return } tmp[at.id] = msg.root; } // temporary fix till a better solution? + if((tmp = data) && tmp[rel._] && (tmp = rel.is(tmp))){ + tmp = ((msg.$$ = at.root.$.get(tmp))._); + if(u !== tmp.put){ + msg = obj_to(msg, {put: data = tmp.put}); + } + } + if((tmp = root.mum) && at.id){ // TODO: can we delete mum entirely now? + var id = at.id + (eve.id || (eve.id = Gun.text.random(9))); + if(tmp[id]){ return } + if(u !== data && !rel.is(data)){ tmp[id] = true; } + } + as.use(msg, eve); + if(eve.stun){ + eve.stun = null; + return; + } + eve.to.next(msg); + } + function rid(at){ + var cat = this.on; + if(!at || cat.soul || cat.has){ return this.off() } + if(!(at = (at = (at = at.$ || at)._ || at).id)){ return } + var map = cat.map, tmp, seen; + //if(!map || !(tmp = map[at]) || !(tmp = tmp.at)){ return } + if(tmp = (seen = this.seen || (this.seen = {}))[at]){ return true } + seen[at] = true; + return; + //tmp.echo[cat.id] = {}; // TODO: Warning: This unsubscribes ALL of this chain's listeners from this link, not just the one callback event. + //obj.del(map, at); // TODO: Warning: This unsubscribes ALL of this chain's listeners from this link, not just the one callback event. + return; + } + var obj = Gun.obj, obj_map = obj.map, obj_has = obj.has, obj_to = Gun.obj.to; + var num_is = Gun.num.is; + var rel = Gun.val.link, node_soul = Gun.node.soul, node_ = Gun.node._; + var empty = {}, u; + })(USE, './get'); + + ;USE(function(module){ + var Gun = USE('./root'); + Gun.chain.put = function(data, cb, as){ + var gun = this, at = (gun._), root = at.root.$, ctx = root._, M = 100, tmp; + as = as || {}; + as.data = data; + as.via = as.$ = as.via || as.$ || gun; + if(typeof cb === 'string'){ + as.soul = cb; + } else { + as.ack = as.ack || cb; + } + if(at.soul){ + as.soul = at.soul; + } + if(as.soul || root === gun){ + if(!obj_is(as.data)){ + (as.ack||noop).call(as, as.out = {err: Gun.log("Data saved to the root level of the graph must be a node (an object), not a", (typeof as.data), 'of "' + as.data + '"!')}); + if(as.res){ as.res() } + return gun; + } + as.soul = as.soul || (as.not = Gun.node.soul(as.data) || (as.via.back('opt.uuid') || Gun.text.random)()); + as.via._.stun = {}; + if(!as.soul){ // polyfill async uuid for SEA + as.via.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback + if(err){ return Gun.log(err) } // TODO: Handle error! + (as.ref||as.$).put(as.data, as.soul = soul, as); + }); + return gun; + } + as.$ = root.get(as.soul); + as.ref = as.$; + ify(as); + return gun; + } + as.via._.stun = {}; + if(Gun.is(data)){ + data.get(function(soul, o, msg){ + if(!soul){ + delete as.via._.stun; + return Gun.log("The reference you are saving is a", typeof msg.put, '"'+ msg.put +'", not a node (object)!'); + } + gun.put(Gun.val.link.ify(soul), cb, as); + }, true); + return gun; + } + if(at.has && (tmp = Gun.val.link.is(data))){ at.dub = tmp } + as.ref = as.ref || (root._ === (tmp = at.back))? gun : tmp.$; + if(as.ref._.soul && Gun.val.is(as.data) && at.get){ + as.data = obj_put({}, at.get, as.data); + as.ref.put(as.data, as.soul, as); + return gun; + } + as.ref.get(any, true, {as: as}); + if(!as.out){ + // TODO: Perf idea! Make a global lock, that blocks everything while it is on, but if it is on the lock it does the expensive lookup to see if it is a dependent write or not and if not then it proceeds full speed. Meh? For write heavy async apps that would be terrible. + as.res = as.res || stun; // Gun.on.stun(as.ref); // TODO: BUG! Deal with locking? + as.$._.stun = as.ref._.stun; + } + return gun; + }; + /*Gun.chain.put = function(data, cb, as){ // don't rewrite! :( + var gun = this, at = gun._; + as = as || {}; + as.soul || (as.soul = at.soul || ('string' == typeof cb && cb)); + if(!as.soul){ return get(data, cb, as) } + + return gun; + }*/ + + function ify(as){ + as.batch = batch; + var opt = as.opt||{}, env = as.env = Gun.state.map(map, opt.state); + env.soul = as.soul; + as.graph = Gun.graph.ify(as.data, env, as); + if(env.err){ + (as.ack||noop).call(as, as.out = {err: Gun.log(env.err)}); + if(as.res){ as.res() } + return; + } + as.batch(); + } + + function stun(cb){ + if(cb){ cb() } + return; + var as = this; + if(!as.ref){ return } + if(cb){ + as.after = as.ref._.tag; + as.now = as.ref._.tag = {}; + cb(); + return; + } + if(as.after){ + as.ref._.tag = as.after; + } + } + + function batch(){ var as = this; + if(!as.graph || !obj_empty(as.stun)){ return } + as.res = as.res || function(cb){ if(cb){ cb() } }; + as.res(function(){ + delete as.via._.stun; + var cat = (as.$.back(-1)._), ask = cat.ask(function(ack){ + cat.root.on('ack', ack); + if(ack.err){ Gun.log(ack) } + if(++acks > (as.acks || 0)){ this.off() } // Adjustable ACKs! Only 1 by default. + if(!as.ack){ return } + as.ack(ack, this); + //--C; + }, as.opt), acks = 0; + //C++; + // NOW is a hack to get synchronous replies to correctly call. + // and STOP is a hack to get async behavior to correctly call. + // neither of these are ideal, need to be fixed without hacks, + // but for now, this works for current tests. :/ + var tmp = cat.root.now; obj.del(cat.root, 'now'); + var mum = cat.root.mum; cat.root.mum = {}; + (as.ref._).on('out', { + $: as.ref, put: as.out = as.env.graph, opt: as.opt, '#': ask + }); + cat.root.mum = mum? obj.to(mum, cat.root.mum) : mum; + cat.root.now = tmp; + as.via._.on('res', {}); delete as.via._.tag.res; // emitting causes mem leak? + }, as); + if(as.res){ as.res() } + } function no(v,k){ if(v){ return true } } + + function map(v,k,n, at){ var as = this; + var is = Gun.is(v); + if(k || !at.path.length){ return } + (as.res||iife)(function(){ + var path = at.path, ref = as.ref, opt = as.opt; + var i = 0, l = path.length; + for(i; i < l; i++){ + ref = ref.get(path[i]); + } + if(is){ ref = v } + //if(as.not){ (ref._).dub = Gun.text.random() } // This might optimize stuff? Maybe not needed anymore. Make sure it doesn't introduce bugs. + var id = (ref._).dub; + if(id || (id = Gun.node.soul(at.obj))){ + ref.back(-1).get(id); + at.soul(id); + return; + } + (as.stun = as.stun || {})[path] = 1; + ref.get(soul, true, {as: {at: at, as: as, p:path, ref: ref}}); + }, {as: as, at: at}); + //if(is){ return {} } + } + var G = String.fromCharCode(31); + function soul(id, as, msg, eve){ + var as = as.as, path = as.p, ref = as.ref, cat = as.at, pat = []; as = as.as; + ref.back(function(at){ + if(sat = at.soul || at.link || at.dub){ return sat } + pat.push(at.has || at.get); + }); + pat = [sat || as.soul].concat(pat.reverse()); + var at = ((msg || {}).$ || {})._ || {}; + id = at.dub = at.dub || id || Gun.node.soul(cat.obj) || Gun.node.soul(msg.put || at.put) || Gun.val.link.is(msg.put || at.put) || pat.join('/') /* || (function(){ + return (as.soul+'.')+Gun.text.hash(path.join(G)).toString(32); + })(); // TODO: BUG!? Do we really want the soul of the object given to us? Could that be dangerous? What about copy operations? */ + if(eve){ eve.stun = true } + if(!id){ // polyfill async uuid for SEA + as.via.back('opt.uuid')(function(err, id){ // TODO: improve perf without anonymous callback + if(err){ return Gun.log(err) } // TODO: Handle error. + solve(at, at.dub = at.dub || id, cat, as); + }); + return; + } + solve(at, at.dub = id, cat, as); + } + + function solve(at, id, cat, as){ + at.$.back(-1).get(id); + cat.soul(id); + delete as.stun[cat.path]; + as.batch(); + } + + function any(soul, as, msg, eve){ + as = as.as; + if(!msg.$ || !msg.$._){ return } // TODO: Handle + if(msg.err){ // TODO: Handle + Gun.log("Please report this as an issue! Put.any.err"); + return; + } + var at = (msg.$._), data = at.put, opt = as.opt||{}, root, tmp; + if((tmp = as.ref) && tmp._.now){ return } + if(eve){ eve.stun = true } + if(as.ref !== as.$){ + tmp = (as.$._).get || at.get; + if(!tmp){ // TODO: Handle + delete as.via._.stun; + Gun.log("Please report this as an issue! Put.no.get"); // TODO: BUG!?? + return; + } + as.data = obj_put({}, tmp, as.data); + tmp = null; + } + if(u === data){ + if(!at.get){ delete as.via._.stun; return } // TODO: Handle + if(!soul){ + tmp = at.$.back(function(at){ + if(at.link || at.soul){ return at.link || at.soul } + as.data = obj_put({}, at.get, as.data); + }); + as.not = true; // maybe consider this? + } + tmp = tmp || at.soul || at.link || at.dub;// || at.get; + at = tmp? (at.root.$.get(tmp)._) : at; + as.soul = tmp; + data = as.data; + } + if(!as.not && !(as.soul = as.soul || soul)){ + if(as.path && obj_is(as.data)){ + as.soul = (opt.uuid || as.via.back('opt.uuid') || Gun.text.random)(); + } else { + //as.data = obj_put({}, as.$._.get, as.data); + if(node_ == at.get){ + as.soul = (at.put||empty)['#'] || at.dub; + } + as.soul = as.soul || at.soul || at.link || (opt.uuid || as.via.back('opt.uuid') || Gun.text.random)(); + } + if(!as.soul){ // polyfill async uuid for SEA + as.via.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback + if(err){ delete as.via._.stun; return Gun.log(err) } // Handle error. + as.ref.put(as.data, as.soul = soul, as); + }); + return; + } + } + as.ref.put(as.data, as.soul, as); + } + var obj = Gun.obj, obj_is = obj.is, obj_put = obj.put, obj_map = obj.map, obj_empty = obj.empty; + var u, empty = {}, noop = function(){}, iife = function(fn,as){fn.call(as||empty)}; + var node_ = Gun.node._; + })(USE, './put'); + + ;USE(function(module){ + var Gun = USE('./root'); + USE('./chain'); + USE('./back'); + USE('./put'); + USE('./get'); + module.exports = Gun; + })(USE, './index'); + + ;USE(function(module){ + var Gun = USE('./index'); + Gun.chain.on = function(tag, arg, eas, as){ + var gun = this, at = gun._, tmp, act, off; + if(typeof tag === 'string'){ + if(!arg){ return at.on(tag) } + act = at.on(tag, arg, eas || at, as); + if(eas && eas.$){ + (eas.subs || (eas.subs = [])).push(act); + } + return gun; + } + var opt = arg; + opt = (true === opt)? {change: true} : opt || {}; + opt.at = at; + opt.ok = tag; + //opt.last = {}; + gun.get(ok, opt); // TODO: PERF! Event listener leak!!!? + return gun; + } + + function ok(msg, ev){ var opt = this; + var gun = msg.$, at = (gun||{})._ || {}, data = at.put || msg.put, cat = opt.at, tmp; + if(u === data){ + return; + } + if(tmp = msg.$$){ + tmp = (msg.$$._); + if(u === tmp.put){ + return; + } + data = tmp.put; + } + if(opt.change){ // TODO: BUG? Move above the undef checks? + data = msg.put; + } + // DEDUPLICATE // TODO: NEEDS WORK! BAD PROTOTYPE + //if(tmp.put === data && tmp.get === id && !Gun.node.soul(data)){ return } + //tmp.put = data; + //tmp.get = id; + // DEDUPLICATE // TODO: NEEDS WORK! BAD PROTOTYPE + //at.last = data; + if(opt.as){ + opt.ok.call(opt.as, msg, ev); + } else { + opt.ok.call(gun, data, msg.get, msg, ev); + } + } + + Gun.chain.val = function(cb, opt){ + Gun.log.once("onceval", "Future Breaking API Change: .val -> .once, apologies unexpected."); + return this.once(cb, opt); + } + Gun.chain.once = function(cb, opt){ + var gun = this, at = gun._, data = at.put; + if(0 < at.ack && u !== data){ + (cb || noop).call(gun, data, at.get); + return gun; + } + if(cb){ + (opt = opt || {}).ok = cb; + opt.at = at; + opt.out = {'#': Gun.text.random(9)}; + gun.get(val, {as: opt}); + opt.async = true; //opt.async = at.stun? 1 : true; + } else { + Gun.log.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."); + var chain = gun.chain(); + chain._.nix = gun.once(function(){ + chain._.on('in', gun._); + }); + return chain; + } + return gun; + } + + function val(msg, eve, to){ + if(!msg.$){ eve.off(); return } + var opt = this.as, cat = opt.at, gun = msg.$, at = gun._, data = at.put || msg.put, link, tmp; + if(tmp = msg.$$){ + link = tmp = (msg.$$._); + if(u !== link.put){ + data = link.put; + } + } + if((tmp = eve.wait) && (tmp = tmp[at.id])){ clearTimeout(tmp) } + eve.ack = (eve.ack||0)+1; + // TODO: super should not be in core code, bring AXE up into core instead to fix? + if(!to && u === data && !at.root.opt.super && eve.ack <= (opt.acks || Object.keys(at.root.opt.peers).length)){ return } + if((!to && (u === data || at.soul || at.link || (link && !(0 < link.ack)))) + || (u === data && !at.root.opt.super && (tmp = Object.keys(at.root.opt.peers).length) && (!to && (link||at).ack < tmp))){ + tmp = (eve.wait = {})[at.id] = setTimeout(function(){ + val.call({as:opt}, msg, eve, tmp || 1); + }, opt.wait || 99); + return; + } + if(link && u === link.put && (tmp = rel.is(data))){ data = Gun.node.ify({}, tmp) } + eve.rid? eve.rid(msg) : eve.off(); + opt.ok.call(gun || opt.$, data, msg.get); + } + + Gun.chain.off = function(){ + // make off more aggressive. Warning, it might backfire! + var gun = this, at = gun._, tmp; + var cat = at.back; + if(!cat){ return } + at.ack = 0; // so can resubscribe. + if(tmp = cat.next){ + if(tmp[at.get]){ + obj_del(tmp, at.get); + } else { + + } + } + if(tmp = cat.ask){ + obj_del(tmp, at.get); + } + if(tmp = cat.put){ + obj_del(tmp, at.get); + } + if(tmp = at.soul){ + obj_del(cat.root.graph, tmp); + } + if(tmp = at.map){ + obj_map(tmp, function(at){ + if(at.link){ + cat.root.$.get(at.link).off(); + } + }); + } + if(tmp = at.next){ + obj_map(tmp, function(neat){ + neat.$.off(); + }); + } + at.on('off', {}); + return gun; + } + var obj = Gun.obj, obj_map = obj.map, obj_has = obj.has, obj_del = obj.del, obj_to = obj.to; + var rel = Gun.val.link; + var empty = {}, noop = function(){}, u; + })(USE, './on'); + + ;USE(function(module){ + var Gun = USE('./index'); + Gun.chain.map = function(cb, opt, t){ + var gun = this, cat = gun._, chain; + if(!cb){ + if(chain = cat.each){ return chain } + cat.each = chain = gun.chain(); + chain._.nix = gun.back('nix'); + gun.on('in', map, chain._); + return chain; + } + Gun.log.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."); + chain = gun.chain(); + gun.map().on(function(data, key, at, ev){ + var next = (cb||noop).call(this, data, key, at, ev); + if(u === next){ return } + if(data === next){ return chain._.on('in', at) } + if(Gun.is(next)){ return chain._.on('in', next._) } + chain._.on('in', {get: key, put: next}); + }); + return chain; + } + function map(msg){ + if(!msg.put || Gun.val.is(msg.put)){ return this.to.next(msg) } + if(this.as.nix){ this.off() } // TODO: Ugly hack! + obj_map(msg.put, each, {at: this.as, msg: msg}); + this.to.next(msg); + } + function each(v,k){ + if(n_ === k){ return } + var msg = this.msg, gun = msg.$, at = gun._, cat = this.at, tmp = at.lex; + if(tmp && !Gun.text.match(k, tmp['.'] || tmp['#'] || tmp)){ return } // review? + ((tmp = gun.get(k)._).echo || (tmp.echo = {}))[cat.id] = tmp.echo[cat.id] || cat; + } + var obj_map = Gun.obj.map, noop = function(){}, event = {stun: noop, off: noop}, n_ = Gun.node._, u; + })(USE, './map'); + + ;USE(function(module){ + var Gun = USE('./index'); + Gun.chain.set = function(item, cb, opt){ + var gun = this, soul; + cb = cb || function(){}; + opt = opt || {}; opt.item = opt.item || item; + if(soul = Gun.node.soul(item)){ item = Gun.obj.put({}, soul, Gun.val.link.ify(soul)) } + if(!Gun.is(item)){ + if(Gun.obj.is(item)){ + //item = gun.back(-1).get(soul = soul || Gun.node.soul(item) || (gun.back('opt.uuid') || uuid)()).put(item); + soul = soul || Gun.node.soul(item) || uuid(); // this just key now, not a soul. + } + return gun.get(soul || uuid()).put(item, cb, opt); + } + item.get(function(soul, o, msg){ + if(!soul && item._.stun){ item._.on('res', function(){ this.off(); gun.set(item, cb, opt) }); return } + if(!soul){ return cb.call(gun, {err: Gun.log('Only a node can be linked! Not "' + msg.put + '"!')}) } + gun.put(Gun.obj.put({}, soul, Gun.val.link.ify(soul)), cb, opt); + },true); + return item; + } + function uuid(){ return Gun.state.lex() + Gun.text.random(7) } + })(USE, './set'); + + ;USE(function(module){ + if(typeof Gun === 'undefined'){ return } // TODO: localStorage is Browser only. But it would be nice if it could somehow plugin into NodeJS compatible localStorage APIs? + + var root, noop = function(){}, store, u; + try{store = (Gun.window||noop).localStorage}catch(e){} + if(!store){ + Gun.log("Warning: No localStorage exists to persist data to!"); + store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}}; + } + /* + NOTE: Both `lib/file.js` and `lib/memdisk.js` are based on this design! + If you update anything here, consider updating the other adapters as well. + */ + + Gun.on('create', function(root){ + // This code is used to queue offline writes for resync. + // See the next 'opt' code below for actual saving of data. + var ev = this.to, opt = root.opt; + if(root.once){ return ev.next(root) } + if(false === opt.localStorage){ return ev.next(root) } // we want offline resynce queue regardless! // actually, this doesn't help, per @go1dfish 's observation. Disabling for now, will need better solution later. + opt.prefix = opt.file || 'gun/'; + var gap = Gun.obj.ify(store.getItem('gap/'+opt.prefix)) || {}; + var empty = Gun.obj.empty, id, to, go; + // add re-sync command. + if(!empty(gap)){ + var disk = Gun.obj.ify(store.getItem(opt.prefix)) || {}, send = {}; + Gun.obj.map(gap, function(node, soul){ + Gun.obj.map(node, function(val, key){ + send[soul] = Gun.state.to(disk[soul], key, send[soul]); + }); + }); + setTimeout(function(){ + // TODO: Holy Grail dangling by this thread! If gap / offline resync doesn't trigger, it doesn't work. Ouch, and this is a localStorage specific adapter. :( + root.on('out', {put: send, '#': root.ask(ack)}); + },1); + } + + root.on('out', function(msg){ + if(msg.lS){ return } // TODO: for IndexedDB and others, shouldn't send to peers ACKs to our own GETs. // THIS IS BLOCKING BROWSERS REPLYING TO REQUESTS, NO??? CHANGE THIS SOON!! UNDER CONTROLLED CIRCUMSTANCES!! Or maybe in-memory already doe sit? + if(Gun.is(msg.$) && msg.put && !msg['@']){ + id = msg['#']; + Gun.graph.is(msg.put, null, map); + if(!to){ to = setTimeout(flush, opt.wait || 1) } + } + this.to.next(msg); + }); + root.on('ack', ack); + + function ack(ack){ // TODO: This is experimental, not sure if we should keep this type of event hook. + if(ack.err || !ack.ok){ return } + var id = ack['@']; + setTimeout(function(){ + Gun.obj.map(gap, function(node, soul){ + Gun.obj.map(node, function(val, key){ + if(id !== val){ return } + delete node[key]; + }); + if(empty(node)){ + delete gap[soul]; + } + }); + flush(); + }, opt.wait || 1); + }; + ev.next(root); + + var map = function(val, key, node, soul){ + (gap[soul] || (gap[soul] = {}))[key] = id; + } + var flush = function(){ + clearTimeout(to); + to = false; + try{store.setItem('gap/'+opt.prefix, JSON.stringify(gap)); + }catch(e){ Gun.log(err = e || "localStorage failure") } + } + }); + + Gun.on('create', function(root){ + this.to.next(root); + var opt = root.opt; + if(root.once){ return } + if(false === opt.localStorage){ return } + opt.prefix = opt.file || 'gun/'; + var graph = root.graph, acks = {}, count = 0, to; + var disk = Gun.obj.ify(store.getItem(opt.prefix)) || {}; + var lS = function(){}, u; + root.on('localStorage', disk); // NON-STANDARD EVENT! + + root.on('put', function(msg){ + this.to.next(msg); + var put = msg.put, soul = put['#'], key = put['.'], val = put[':'], state = put['>'], tmp; + disk[soul] = Gun.state.ify(disk[soul], key, state, val, soul); + if(!msg['@']){ (acks[msg['#']] = (tmp = (msg._||'').lot || {})).lS = (tmp.lS||0)+1; } // only ack non-acks. + count += 1; + if(count >= (opt.batch || 1000)){ + return flush(); + } + if(to){ return } + to = setTimeout(flush, opt.wait || 1); + }); + + root.on('get', function(msg){ + this.to.next(msg); + var lex = msg.get, soul, data, u; + function to(){ + if(!lex || !(soul = lex['#'])){ return } + //if(0 >= msg.cap){ return } + var has = lex['.']; + data = disk[soul] || u; + if(data && has){ + data = Gun.state.to(data, has); + } + //if(!data && !Gun.obj.empty(opt.peers)){ return } // if data not found, don't ack if there are peers. // Hmm, what if we have peers but we are disconnected? + root.on('in', {'@': msg['#'], put: Gun.graph.node(data), lS:1});// || root.$}); + }; + Gun.debug? setTimeout(to,1) : to(); + }); + + var map = function(val, key, node, soul){ + disk[soul] = Gun.state.to(node, key, disk[soul]); + } + + var flush = function(data){ + var err; + count = 0; + clearTimeout(to); + to = false; + var ack = acks; + acks = {}; + if(data){ disk = data } + try{store.setItem(opt.prefix, JSON.stringify(disk)); + }catch(e){ + Gun.log(err = (e || "localStorage failure") + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"); + root.on('localStorage:error', {err: err, file: opt.prefix, flush: disk, retry: flush}); + } + if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers. + Gun.obj.map(ack, function(yes, id){ + if(yes){ + if(yes.more){ acks[id] = yes; return } + if(yes.s !== yes.lS){ err = "localStorage batch not same." } + } + root.on('in', { + '@': id, + err: err, + ok: 0 // localStorage isn't reliable, so make its `ok` code be a low number. + }); + }); + } + }); + })(USE, './adapters/localStorage'); + + ;USE(function(module){ + var Type = USE('../type'); + + function Mesh(root){ + var mesh = function(){}; + var opt = root.opt || {}; + opt.log = opt.log || console.log; + opt.gap = opt.gap || opt.wait || 0; + opt.pack = opt.pack || (opt.memory? (opt.memory * 1000 * 1000) : 1399000000) * 0.3; // max_old_space_size defaults to 1400 MB. + opt.puff = opt.puff || 9; // IDEA: do a start/end benchmark, divide ops/result. + var puff = setTimeout.puff || setTimeout; + + var dup = root.dup, dup_check = dup.check, dup_track = dup.track; + + var hear = mesh.hear = function(raw, peer){ + if(!raw){ return } + if(opt.pack <= raw.length){ return mesh.say({dam: '!', err: "Message too big!"}, peer) } + var msg, id, hash, tmp = raw[0], DBG; + if(mesh === this){ hear.d += raw.length||0 ; ++hear.c } // STATS! + if('[' === tmp){ + try{msg = JSON.parse(raw)}catch(e){opt.log('DAM JSON parse error', e)} + raw = ''; + if(!msg){ return } + console.STAT && console.STAT(+new Date, msg.length, '# on hear batch'); + var P = opt.puff; + (function go(){ + var S = +new Date; + //var P = peer.puff || opt.puff, s = +new Date; // TODO: For future, but in mix? + var i = 0, m; while(i < P && (m = msg[i++])){ hear(m, peer) } + //peer.puff = Math.ceil((+new Date - s)? P * 1.1 : P * 0.9); + msg = msg.slice(i); // slicing after is faster than shifting during. + console.STAT && console.STAT(S, +new Date - S, 'hear loop'); + flush(peer); // force send all synchronously batched acks. + if(!msg.length){ return } + puff(go, 0); + }()); + return; + } + if('{' === tmp || ((raw['#'] || obj_is(raw)) && (msg = raw))){ + try{msg = msg || JSON.parse(raw); + }catch(e){return opt.log('DAM JSON parse error', e)} + if(!msg){ return } + if(msg.DBG){ msg.DBG = DBG = {DBG: msg.DBG} } + DBG && (DBG.hp = +new Date); + if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) } + if(tmp = dup_check(id)){ return } + /*if(!(hash = msg['##']) && u !== msg.put){ hash = msg['##'] = Type.obj.hash(msg.put) } + if(hash && (tmp = msg['@'] || (msg.get && id))){ // Reduces backward daisy in case varying hashes at different daisy depths are the same. + if(dup.check(tmp+hash)){ return } + dup.track(tmp+hash, true).it = it(msg); // GUN core also dedups, so `true` is needed. // Does GUN core need to dedup anymore? + } + if(tmp = msg['><']){ (msg._).to = Type.obj.map(tmp.split(','), tomap) } + */ // TOOD: COME BACK TO THIS LATER!!! IMPORTANT MESH STUFF!! + (msg._ = function(){}).via = mesh.leap = peer; + if(tmp = msg.dam){ + if(tmp = mesh.hear[tmp]){ + tmp(msg, peer, root); + } + dup_track(id); + return; + } + var S = +new Date, ST; + DBG && (DBG.is = S); + root.on('in', msg); + //ECHO = msg.put || ECHO; !(msg.ok !== -3740) && mesh.say({ok: -3740, put: ECHO, '@': msg['#']}, peer); + DBG && (DBG.hd = +new Date); + console.STAT && (ST = +new Date - S) > 9 && console.STAT(S, ST, 'msg'); // TODO: PERF: caught one > 1.5s on tgif + dup_track(id).via = peer; + mesh.leap = null; // warning! mesh.leap could be buggy. + } + } + var tomap = function(k,i,m){m(k,true)}; + var noop = function(){}; + hear.c = hear.d = 0; + + ;(function(){ + var SMIA = 0; + var message, loop; + function each(peer){ mesh.say(message, peer) } + var say = mesh.say = function(msg, peer){ var tmp; + if((tmp = this) && (tmp = tmp.to) && tmp.next){ tmp.next(msg) } // compatible with middleware adapters. + if(!msg){ return false } + var id, hash, raw; + var DBG = msg.DBG, S; if(!peer){ S = +new Date ; DBG && (DBG.y = S) } + var meta = msg._||(msg._=function(){}); + if(!(id = msg['#'])){ id = msg['#'] = Type.text.random(9) } + //if(!(hash = msg['##']) && u !== msg.put){ hash = msg['##'] = Type.obj.hash(msg.put) } + if(!(raw = meta.raw)){ + raw = mesh.raw(msg); + /*if(hash && (tmp = msg['@'])){ + dup.track(tmp+hash).it = it(msg); + if(tmp = (dup.s[tmp]||ok).it){ + if(hash === tmp['##']){ return false } + tmp['##'] = hash; + } + }*/ + } + S && console.STAT && console.STAT(S, +new Date - S, 'say prep'); + !loop && dup_track(id);//.it = it(msg); // track for 9 seconds, default. Earth<->Mars would need more! // always track, maybe move this to the 'after' logic if we split function. + //console.log("SEND!", JSON.parse(JSON.stringify(msg))); + if(!peer && (tmp = msg['@'])){ peer = ((tmp = dup.s[tmp]) && (tmp.via || ((tmp = tmp.it) && (tmp = tmp._) && tmp.via))) || mesh.leap } // warning! mesh.leap could be buggy! + if(!peer && msg['@']){ + console.STAT && console.STAT(+new Date, ++SMIA, 'total no peer to ack to'); + return false; + } // TODO: Temporary? If ack via trace has been lost, acks will go to all peers, which trashes browser bandwidth. Not relaying the ack will force sender to ask for ack again. Note, this is technically wrong for mesh behavior. + if(!peer && mesh.way){ return mesh.way(msg) } + if(!peer || !peer.id){ message = msg; + if(!Type.obj.is(peer || opt.peers)){ return false } + var P = opt.puff, ps = opt.peers, pl = Object.keys(peer || opt.peers || {}); // TODO: BETTER PERF? No object.keys? It is polyfilled by Type.js tho. + ;(function go(){ + var S = +new Date; + //Type.obj.map(peer || opt.peers, each); // in case peer is a peer list. + loop = 1; var wr = meta.raw; meta.raw = raw; // quick perf hack + var i = 0, p; while(i < 9 && (p = (pl||'')[i++])){ + if(!(p = ps[p])){ continue } + say(msg, p); + } + meta.raw = wr; loop = 0; + pl = pl.slice(i); // slicing after is faster than shifting during. + console.STAT && console.STAT(S, +new Date - S, 'say loop'); + if(!pl.length){ return } + puff(go, 0); + dup_track(msg['@']); // keep for later + }()); + return; + } + // TODO: PERF: consider splitting function here, so say loops do less work. + if(!peer.wire && mesh.wire){ mesh.wire(peer) } + if(id === peer.last){ return } peer.last = id; // was it just sent? + if(peer === meta.via){ return false } // don't send back to self. + if((tmp = meta.to) && (tmp[peer.url] || tmp[peer.pid] || tmp[peer.id]) /*&& !o*/){ return false } + if(peer.batch){ + peer.tail = (tmp = peer.tail || 0) + raw.length; + if(peer.tail <= opt.pack){ + //peer.batch.push(raw); + peer.batch += (tmp?',':'')+raw; // TODO: Prevent double JSON! // FOR v1.0 !? + return; + } + flush(peer); + } + //peer.batch = []; + peer.batch = '['; // TODO: Prevent double JSON! + var S = +new Date, ST; + setTimeout(function(){ + console.STAT && (ST = +new Date - S) > 9 && console.STAT(S, ST, '0ms TO', id, peer.id); + flush(peer); + }, opt.gap); + send(raw, peer); + } + mesh.say.c = mesh.say.d = 0; + }()); + + function flush(peer){ + var tmp = peer.batch, t = 'string' == typeof tmp, l; + if(t){ tmp += ']' }// TODO: Prevent double JSON! + peer.batch = peer.tail = null; + if(!tmp){ return } + if(t? 3 > tmp.length : !tmp.length){ return } // TODO: ^ + if(!t){try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp)); + }catch(e){return opt.log('DAM JSON stringify error', e)}} + if(!tmp){ return } + send(tmp, peer); + } + // for now - find better place later. + function send(raw, peer){ try{ + var wire = peer.wire; + if(peer.say){ + peer.say(raw); + } else + if(wire.send){ + wire.send(raw); + } + mesh.say.d += raw.length||0; ++mesh.say.c; // STATS! + }catch(e){ + (peer.queue = peer.queue || []).push(raw); + }} + + ;(function(){ + // TODO: this caused a out-of-memory crash! + mesh.raw = function(msg){ // TODO: Clean this up / delete it / move logic out! + if(!msg){ return '' } + var meta = (msg._) || {}, put, hash, tmp; + if(tmp = meta.raw){ return tmp } + if('string' == typeof msg){ return msg } + /*if(!msg.dam){ // TOOD: COME BACK TO THIS LATER!!! IMPORTANT MESH STUFF!! + var i = 0, to = []; Type.obj.map(opt.peers, function(p){ + to.push(p.url || p.pid || p.id); if(++i > 3){ return true } // limit server, fast fix, improve later! // For "tower" peer, MUST include 6 surrounding ids. // REDUCED THIS TO 3 for temporary relay peer performance, towers still should list neighbors. + }); if(i > 1){ msg['><'] = to.join() } + }*/ // TOOD: COME BACK TO THIS LATER!!! IMPORTANT MESH STUFF!! + var raw = $(msg); // optimize by reusing put = the JSON.stringify from .hash? + /*if(u !== put){ + tmp = raw.indexOf(_, raw.indexOf('put')); + raw = raw.slice(0, tmp-1) + put + raw.slice(tmp + _.length + 1); + //raw = raw.replace('"'+ _ +'"', put); // NEVER USE THIS! ALSO NEVER DELETE IT TO NOT MAKE SAME MISTAKE! https://github.com/amark/gun/wiki/@$$ Heisenbug + }*/ + // TODO: PERF: tgif, CPU way too much on re-JSONifying ^ it. + /* + // NOTE TO SELF: Switch NTS to DAM now. + */ + if(meta && (raw||'').length < (1000 * 100)){ meta.raw = raw } // HNPERF: If string too big, don't keep in memory. + return raw; + } + var $ = JSON.stringify, _ = ':])([:'; + + }()); + + mesh.hi = function(peer){ + var tmp = peer.wire || {}; + if(peer.id){ + opt.peers[peer.url || peer.id] = peer; + } else { + tmp = peer.id = peer.id || Type.text.random(9); + mesh.say({dam: '?', pid: root.opt.pid}, opt.peers[tmp] = peer); + delete dup.s[peer.last]; // IMPORTANT: see https://gun.eco/docs/DAM#self + } + peer.met = peer.met || +(new Date); + if(!tmp.hied){ root.on(tmp.hied = 'hi', peer) } + // @rogowski I need this here by default for now to fix go1dfish's bug + tmp = peer.queue; peer.queue = []; + Type.obj.map(tmp, function(msg){ + send(msg, peer); + }); + Type.obj.native && Type.obj.native(); // dirty place to check if other JS polluted. + } + mesh.bye = function(peer){ + root.on('bye', peer); + var tmp = +(new Date); tmp = (tmp - (peer.met||tmp)); + mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2; + } + mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) } + mesh.hear['?'] = function(msg, peer){ + if(msg.pid){ + if(!peer.pid){ peer.pid = msg.pid } + if(msg['@']){ return } + } + mesh.say({dam: '?', pid: opt.pid, '@': msg['#']}, peer); + delete dup.s[peer.last]; // IMPORTANT: see https://gun.eco/docs/DAM#self + } + + root.on('create', function(root){ + root.opt.pid = root.opt.pid || Type.text.random(9); + this.to.next(root); + root.on('out', mesh.say); + }); + + root.on('bye', function(peer, tmp){ + peer = opt.peers[peer.id || peer] || peer; + this.to.next(peer); + peer.bye? peer.bye() : (tmp = peer.wire) && tmp.close && tmp.close(); + Type.obj.del(opt.peers, peer.id); + peer.wire = null; + }); + + var gets = {}; + root.on('bye', function(peer, tmp){ this.to.next(peer); + if(!(tmp = peer.url)){ return } gets[tmp] = true; + setTimeout(function(){ delete gets[tmp] },opt.lack || 9000); + }); + root.on('hi', function(peer, tmp){ this.to.next(peer); + if(!(tmp = peer.url) || !gets[tmp]){ return } delete gets[tmp]; + if(opt.super){ return } // temporary (?) until we have better fix/solution? + Type.obj.map(root.next, function(node, soul){ + tmp = {}; tmp[soul] = root.graph[soul]; + mesh.say({'##': Type.obj.hash(tmp), get: {'#': soul}}, peer); + }) + }); + + return mesh; + } + + ;(function(){ + var $ = JSON.stringify, u; + + Type.obj.hash = function(obj, hash){ + if(!hash && u === (obj = $(obj, sort))){ return } + return Type.text.hash(hash || obj || ''); + } + + function sort(k, v){ var tmp; + if(!(v instanceof Object)){ return v } + var S = +new Date; + Type.obj.map(Object.keys(v).sort(), map, {to: tmp = {}, on: v}); + console.STAT && console.STAT(S, +new Date - S, 'sort'); + return tmp; + } + Type.obj.hash.sort = sort; + + function map(k){ + this.to[k] = this.on[k]; + } + }()); + + function it(msg){ return msg || {_: msg._, '##': msg['##']} } // HNPERF: Only need some meta data, not full reference (took up too much memory). // HNPERF: Garrrgh! We add meta data to msg over time, copying the object happens to early. + + var empty = {}, ok = true, u; + var obj_is = Type.obj.is, obj_map = Type.obj.map; + + try{ module.exports = Mesh }catch(e){} + + })(USE, './adapters/mesh'); + + ;USE(function(module){ + var Gun = USE('../index'); + Gun.Mesh = USE('./mesh'); + + Gun.on('opt', function(root){ + this.to.next(root); + var opt = root.opt; + if(root.once){ return } + if(false === opt.WebSocket){ return } + + var env; + if(typeof window !== "undefined"){ env = window } + if(typeof global !== "undefined"){ env = global } + env = env || {}; + + var websocket = opt.WebSocket || env.WebSocket || env.webkitWebSocket || env.mozWebSocket; + if(!websocket){ return } + opt.WebSocket = websocket; + + var mesh = opt.mesh = opt.mesh || Gun.Mesh(root); + + var wire = mesh.wire || opt.wire; + mesh.wire = opt.wire = open; + function open(peer){ try{ + if(!peer || !peer.url){ return wire && wire(peer) } + var url = peer.url.replace(/^http/, 'ws'); + var wire = peer.wire = new opt.WebSocket(url); + wire.onclose = function(){ + opt.mesh.bye(peer); + reconnect(peer); + }; + wire.onerror = function(error){ + reconnect(peer); + }; + wire.onopen = function(){ + opt.mesh.hi(peer); + } + wire.onmessage = function(msg){ + if(!msg){ return } + opt.mesh.hear(msg.data || msg, peer); + }; + return wire; + }catch(e){}} + + setTimeout(function(){ root.on('out', {dam:'hi'}) },1); // it can take a while to open a socket, so maybe no longer lazy load for perf reasons? + + var wait = 2 * 1000; + function reconnect(peer){ + clearTimeout(peer.defer); + if(doc && peer.retry <= 0){ return } peer.retry = (peer.retry || opt.retry || 60) - 1; + peer.defer = setTimeout(function to(){ + if(doc && doc.hidden){ return setTimeout(to,wait) } + open(peer); + }, wait); + } + var doc = 'undefined' !== typeof document && document; + }); + var noop = function(){}; + })(USE, './adapters/websocket'); + +}()); diff --git a/lib/ipfs.js b/lib/ipfs.js new file mode 100644 index 0000000..8736f4d --- /dev/null +++ b/lib/ipfs.js @@ -0,0 +1,2 @@ +/*! For license information please see index.min.js.LICENSE.txt */ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Ipfs=e():t.Ipfs=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=383)}([function(t,e,r){"use strict";function n(t,e){for(const r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}t.exports=function(t,e,r){if(!t||"string"==typeof t)throw new TypeError("Please pass an Error to err-code");r||(r={}),"object"==typeof e&&(r=e,e=void 0),null!=e&&(r.code=e);try{return n(t,r)}catch(i){r.message=t.message,r.stack=t.stack;const e=function(){};return e.prototype=Object.create(Object.getPrototypeOf(t)),n(new e,r)}}},function(t,e,r){"use strict";(function(n){e.log=function(...t){return"object"==typeof console&&console.log&&console.log(...t)},e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(n++,"%c"===t&&(i=n))}),e.splice(i,0,r)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(r){}},e.load=function(){let t;try{t=e.storage.getItem("debug")}catch(r){}!t&&void 0!==n&&"env"in n&&(t={NODE_ENV:"production"}.DEBUG);return t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=r(387)(e);const{formatters:i}=t.exports;i.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(12))},function(t,e,r){"use strict";const n=r(51),i=r(4),s=r(251),o=r(77),a=r(157).default,c=r(10).Key,{TimeoutError:u}=r(85),h=r(0),f=r(113);e.OFFLINE_ERROR="This command must be run in online mode. Try running 'ipfs daemon' first.",e.MFS_FILE_TYPES={file:0,directory:1,"hamt-sharded-directory":1},e.MFS_ROOT_KEY=new c("/local/filesroot"),e.MFS_MAX_CHUNK_SIZE=262144,e.MFS_MAX_LINKS=174;e.normalizePath=t=>{if(n.cid(t))return"/ipfs/"+new i(t);if(n.path(t))return t;throw h(new Error("invalid path: "+t),"ERR_BAD_PATH")},e.normalizeCidPath=t=>t instanceof Uint8Array?new i(t).toString():i.isCID(t)?t.toString():(0===t.indexOf("/ipfs/")&&(t=t.substring("/ipfs/".length)),"/"===t.charAt(t.length-1)&&(t=t.substring(0,t.length-1)),t),e.resolvePath=async function(t,e,r){if(r=r||{},n.cid(e))return new i(e);const{cid:s,path:o}=f(e);if(!o)return s;return(await t.resolve(s,{...r,path:o})).cid},e.mapFile=(t,e)=>{e=e||{};const r={cid:t.cid,path:t.path,name:t.name,depth:t.path.split("/").length,size:0,type:"file"};return t.unixfs&&(r.type="directory"===t.unixfs.type?"dir":"file","file"===t.unixfs.type&&(r.size=t.unixfs.fileSize(),e.includeContent&&(r.content=t.content())),r.mode=t.unixfs.mode,r.mtime=t.unixfs.mtime),r},e.withTimeoutOption=function(t,e){return(...r)=>{const n=r[null==e?r.length-1:e];if(!n||!n.timeout)return t(...r);const i="string"==typeof n.timeout?a(n.timeout):n.timeout,c=new s(i);n.signal=o([n.signal,c.signal]);const h=t(...r),f=new Promise((t,e)=>{c.signal.addEventListener("abort",()=>{e(new u)})}),l=Date.now(),d=()=>{if(c.signal.aborted)throw new u;if(Date.now()-l>i)throw c.abort(),new u};return h[Symbol.asyncIterator]?async function*(){const t=h[Symbol.asyncIterator]();try{for(;;){const{value:e,done:r}=await Promise.race([t.next(),f]);if(r)break;d(),yield e}}catch(e){throw d(),e}finally{c.clear(),t.return&&t.return()}}():(async()=>{try{const t=await Promise.race([h,f]);return d(),t}catch(t){throw d(),t}finally{c.clear()}})()}}},function(t,e,r){"use strict";(function(t){var n=r(386),i=r(222),s=r(223);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return z(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return R(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){var s,o=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var h=-1;for(s=r;sa&&(r=a-c),s=r;s>=0;s--){for(var f=!0,l=0;li&&(n=i):n=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(s=t[i+1]))&&(c=(31&u)<<6|63&s)>127&&(h=c);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},c.prototype.compare=function(t,e,r,n,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,i),h=t.slice(e,r),f=0;fi)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",s=e;sr)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function N(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function P(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function O(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,s){return s||O(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,s){return s||O(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t],i=1,s=0;++s=(i*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||x(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+i]=t/s&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):P(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):P(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);x(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);x(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):P(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):P(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(11))},function(t,e,r){"use strict";const n=r(49),i=r(31),s=r(19),o=r(80),a=r(412),c=r(27),u=r(26),h=r(5),f=r(20),l=Object.keys(o).reduce((t,e)=>(t[o[e]]=e,t),{});class d{constructor(t,e,r,o){if(p.isCID(t)){const e=t;return this.version=e.version,this.codec=e.codec,this.multihash=e.multihash,void(this.multibaseName=e.multibaseName||(0===e.version?"base58btc":"base32"))}if("string"==typeof t){const e=i.isEncoded(t);if(e){const r=i.decode(t);this.version=parseInt(r.slice(0,1).toString("hex"),16),this.codec=s.getCodec(r.slice(1)),this.multihash=s.rmPrefix(r.slice(1)),this.multibaseName=e}else this.version=0,this.codec="dag-pb",this.multihash=n.fromB58String(t),this.multibaseName="base58btc";return d.validateCID(this),void Object.defineProperty(this,"string",{value:t})}if(t instanceof Uint8Array){const e=t.slice(0,1),r=parseInt(e.toString("hex"),16);if(1===r){const e=t;this.version=r,this.codec=s.getCodec(e.slice(1)),this.multihash=s.rmPrefix(e.slice(1)),this.multibaseName="base32"}else this.version=0,this.codec="dag-pb",this.multihash=t,this.multibaseName="base58btc";d.validateCID(this)}else this.version=t,"number"==typeof e&&(e=l[e]),this.codec=e,this.multihash=r,this.multibaseName=o||(0===t?"base58btc":"base32"),d.validateCID(this)}get bytes(){let t=this._bytes;if(!t){if(0===this.version)t=this.multihash;else{if(1!==this.version)throw new Error("unsupported version");{const e=s.getCodeVarint(this.codec);t=u([[1],e,this.multihash],1+e.byteLength+this.multihash.byteLength)}}Object.defineProperty(this,"_bytes",{value:t})}return t}get prefix(){const t=s.getCodeVarint(this.codec),e=n.prefix(this.multihash);return u([[this.version],t,e],1+t.byteLength+e.byteLength)}get code(){return o[this.codec]}toV0(){if("dag-pb"!==this.codec)throw new Error("Cannot convert a non dag-pb CID to CIDv0");const{name:t,length:e}=n.decode(this.multihash);if("sha2-256"!==t)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");if(32!==e)throw new Error("Cannot convert non 32 byte multihash CID to CIDv0");return new p(0,this.codec,this.multihash)}toV1(){return new p(1,this.codec,this.multihash)}toBaseEncodedString(t=this.multibaseName){if(this.string&&t===this.multibaseName)return this.string;let e=null;if(0===this.version){if("base58btc"!==t)throw new Error("not supported with CIDv0, to support different bases, please migrate the instance do CIDv1, you can do that through cid.toV1()");e=n.toB58String(this.multihash)}else{if(1!==this.version)throw new Error("unsupported version");e=h(i.encode(t,this.bytes))}return t===this.multibaseName&&Object.defineProperty(this,"string",{value:e}),e}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}toString(t){return this.toBaseEncodedString(t)}toJSON(){return{codec:this.codec,version:this.version,hash:this.multihash}}equals(t){return this.codec===t.codec&&this.version===t.version&&f(this.multihash,t.multihash)}static validateCID(t){const e=a.checkCIDComponents(t);if(e)throw new Error(e)}}const p=c(d,{className:"CID",symbolName:"@ipld/js-cid/CID"});p.codecs=o,t.exports=p},function(t,e,r){"use strict";const{names:n}=r(78),{TextDecoder:i}=r(79),s=new i("utf8");t.exports=function(t,e="utf8"){if("utf8"===e||"utf-8"===e)return s.decode(t);if("ascii"===e)return function(t){let e="";for(let r=0;r"}toJSON(){return{id:this.toB58String(),privKey:p(this.marshalPrivKey()),pubKey:p(this.marshalPubKey())}}toHexString(){return n.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}toString(){if(!this._idCIDString){const t=new i(1,"libp2p-key",this.id,"base32");this._idCIDString=t.toBaseEncodedString("base32")}return this._idCIDString}equals(t){if(t instanceof Uint8Array)return c(this.id,t);if(t.id)return c(this.id,t.id);throw new Error("not valid Id")}isEqual(t){return this.equals(t)}isValid(){return Boolean(this.privKey&&this.privKey.public&&this.privKey.public.bytes&&this.pubKey.bytes instanceof Uint8Array&&c(this.privKey.public.bytes,this.pubKey.bytes))}},{className:"PeerId",symbolName:"@libp2p/js-peer-id/PeerId"});e=t.exports=f;const l=t=>t.bytes.length<=42?n.encode(t.bytes,"identity"):t.hash(),d=async(t,e)=>{const r=await l(e);return new f(r,t,e)};e.create=async t=>{(t=t||{}).bits=t.bits||2048,t.keyType=t.keyType||"RSA";const e=await s.generateKeyPair(t.keyType,t.bits);return d(e,e.public)},e.createFromHexString=t=>new f(n.fromHexString(t)),e.createFromBytes=t=>new f(t),e.createFromB58String=t=>e.createFromCID(t);function p(t){if(t)return h(t,"base64pad")}e.createFromCID=t=>{if(!(t=>"libp2p-key"===t.codec||"dag-pb"===t.codec)(t=i.isCID(t)?t:new i(t)))throw new Error("Supplied PeerID CID has invalid multicodec: "+t.codec);return new f(t.multihash)},e.createFromPubKey=async t=>{let e=t;if("string"==typeof e&&(e=u(t,"base64pad")),!(e instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const r=await s.unmarshalPublicKey(e);return d(null,r)},e.createFromPrivKey=async t=>{if("string"==typeof t&&(t=u(t,"base64pad")),!(t instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const e=await s.unmarshalPrivateKey(t);return d(e,e.public)},e.createFromJSON=async t=>{const e=n.fromB58String(t.id),r=t.privKey&&u(t.privKey,"base64pad"),i=t.pubKey&&u(t.pubKey,"base64pad"),o=i&&await s.unmarshalPublicKey(i);if(!r)return new f(e,null,o);const a=await s.unmarshalPrivateKey(r),h=await l(a.public);let d;if(o&&(d=await l(o)),o&&!c(h,d))throw new Error("Public and private key do not match");if(e&&!c(h,e))throw new Error("Id and private key do not match");return new f(e,a,o)},e.createFromProtobuf=async t=>{"string"==typeof t&&(t=u(t,"base16"));let e,r,{id:n,privKey:i,pubKey:o}=a.decode(t);if(i=!!i&&await s.unmarshalPrivateKey(i),o=!!o&&await s.unmarshalPublicKey(o),i&&(r=await l(i.public)),o&&(e=await l(o)),i){if(o&&!c(r,e))throw new Error("Public and private key do not match");return new f(r,i,i.public)}if(o)return new f(e,null,o);if(n)return new f(n);throw new Error("Protobuf did not contain any usable key material")},e.isPeerId=t=>Boolean("object"==typeof t&&t._id&&t._idB58String)},function(t,e,r){"use strict";t.exports={options:{usePureJavaScript:!1}}},function(t,e,r){"use strict";t.exports={options:{usePureJavaScript:!1}}},function(t,e,r){"use strict";const n=r(252),i=r(547),s=r(158),o=r(258),a=r(256);e.Key=n,e.MemoryDatastore=i,e.utils=s,e.Errors=o,e.Adapter=a},function(t,e,r){"use strict";var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(i){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,r){"use strict";var n,i,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(t){i=a}}();var u,h=[],f=!1,l=-1;function d(){f&&u&&(f=!1,u.length?h=u.concat(h):l=-1,h.length&&p())}function p(){if(!f){var t=c(d);f=!0;for(var e=h.length;e;){for(u=h,h=[];++l1)for(var r=1;r{const n=a.createHash(e),i=await n(t);return r?i.slice(0,r):i},a.createHash=function(t){if(!t)throw n(new Error("hash algorithm must be specified"),"ERR_HASH_ALGORITHM_NOT_SPECIFIED");if(t=i.coerceCode(t),!a.functions[t])throw n(new Error(`multihash function '${t}' not yet supported`),"ERR_HASH_ALGORITHM_NOT_SUPPORTED");return a.functions[t]},a.functions={0:s.identity,17:s.sha1,18:s.sha2256,19:s.sha2512,20:s.sha3512,21:s.sha3384,22:s.sha3256,23:s.sha3224,24:s.shake128,25:s.shake256,26:s.keccak224,27:s.keccak256,28:s.keccak384,29:s.keccak512,34:s.murmur3128,35:s.murmur332,86:s.dblSha2256},s.addBlake(a.functions),a.validate=async(t,e)=>{const r=await a(t,i.decode(e).name);return o(e,r)},t.exports=a},function(t,e,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(t,e){return new Promise((function(r,n){function i(){void 0!==s&&t.removeListener("error",s),r([].slice.call(arguments))}var s;"error"!==e&&(s=function(r){t.removeListener(e,i),n(r)},t.once("error",s)),t.once(e,i)}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var i,s,o,a;if(u(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),void 0===o)o=s[e]=r,++t._eventsCount;else if("function"==typeof o?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=h(t))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function p(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[t];if(void 0===c)return!1;if("function"==typeof c)s(c,this,e);else{var u=c.length,h=g(c,u);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return p(this,t,!0)},a.prototype.rawListeners=function(t){return p(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},a.prototype.listenerCount=y,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,r){"use strict";t.exports={encode:r(401),decode:r(402),encodingLength:r(403)}},function(t,e,r){"use strict";e.DAGNode=r(511),e.DAGLink=r(247),e.resolver=r(517),e.util=r(248),e.codec=e.util.codec,e.defaultHashAlg=e.util.defaultHashAlg},function(t,e,r){"use strict";const n=r(491),i=r(146),s=r(15),o=r(4),a=r(27),c=Symbol.for("nodejs.util.inspect.custom"),u=r(5),h=r(20),f=a.proto((function(t){if(!(this instanceof f))return new f(t);if(null==t&&(t=""),t instanceof Uint8Array)this.bytes=n.fromBytes(t);else if("string"==typeof t||t instanceof String){if(t.length>0&&"/"!==t.charAt(0))throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=n.fromString(t)}else{if(!(t.bytes&&t.protos&&t.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=n.fromBytes(t.bytes)}}),{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});f.prototype.toString=function(){return n.bytesToString(this.bytes)},f.prototype.toJSON=f.prototype.toString,f.prototype.toOptions=function(){const t={},e=this.toString().split("/");return t.family="ip4"===e[1]?"ipv4":"ipv6",t.host=e[2],t.transport=e[3],t.port=parseInt(e[4]),t},f.prototype[c]=function(){return""},f.prototype.inspect=function(){return""},f.prototype.protos=function(){return this.protoCodes().map(t=>Object.assign({},i(t)))},f.prototype.protoCodes=function(){const t=[],e=this.bytes;let r=0;for(;rt.name)},f.prototype.tuples=function(){return n.bytesToTuples(this.bytes)},f.prototype.stringTuples=function(){const t=n.bytesToTuples(this.bytes);return n.tuplesToStringTuples(t)},f.prototype.encapsulate=function(t){return t=f(t),f(this.toString()+t.toString())},f.prototype.decapsulate=function(t){t=t.toString();const e=this.toString(),r=e.lastIndexOf(t);if(r<0)throw new Error("Address "+this+" does not contain subaddress: "+t);return f(e.slice(0,r))},f.prototype.decapsulateCode=function(t){const e=this.tuples();for(let r=e.length-1;r>=0;r--)if(e[r][0]===t)return f(n.tuplesToBytes(e.slice(0,r)));return this},f.prototype.getPeerId=function(){let t=null;try{t=this.stringTuples().filter(t=>{if(t[0]===i.names.ipfs.code)return!0}).pop()[1],t=u(new o(t).multihash,"base58btc")}catch(e){t=null}return t},f.prototype.getPath=function(){let t=null;try{t=this.stringTuples().filter(t=>{if(i(t[0]).path)return!0})[0][1]}catch(e){t=null}return t},f.prototype.equals=function(t){return h(this.bytes,t.bytes)},f.prototype.nodeAddress=function(){const t=this.protoCodes(),e=this.protoNames(),r=this.toString().split("/").slice(1);if(r.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==t[0]&&41!==t[0]&&54!==t[0]&&55!==t[0])throw new Error(`no protocol with name: "'${e[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if("tcp"!==r[2]&&"udp"!==r[2])throw new Error(`no protocol with name: "'${e[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:41===t[0]||55===t[0]?6:4,address:r[1],port:parseInt(r[3])}},f.fromNodeAddress=function(t,e){if(!t)throw new Error("requires node address object");if(!e)throw new Error("requires transport protocol");let r;switch(t.family){case"IPv4":r="ip4";break;case"IPv6":r="ip6";break;default:throw Error(`Invalid addr family. Got '${t.family}' instead of 'IPv4' or 'IPv6'`)}return f("/"+[r,t.address,e,t.port].join("/"))},f.prototype.isThinWaistAddress=function(t){const e=(t||this).protos();return 2===e.length&&((4===e[0].code||41===e[0].code)&&(6===e[1].code||273===e[1].code))},f.protocols=i,f.isName=function(t){return!!f.isMultiaddr(t)&&t.protos().some(t=>t.resolvable)},f.resolve=function(t){return f.isMultiaddr(t)&&f.isName(t)?Promise.reject(new Error("not implemented yet")):Promise.reject(Error("not a valid name"))},t.exports=f},function(t,e,r){"use strict";(function(e,n,i){var s=r(9),o=r(810),a=t.exports=s.util=s.util||{};function c(t){if(8!==t&&16!==t&&24!==t&&32!==t)throw new Error("Only 8, 16, 24, or 32 bits supported: "+t)}function u(t){if(this.data="",this.read=0,"string"==typeof t)this.data=t;else if(a.isArrayBuffer(t)||a.isArrayBufferView(t))if(void 0!==i&&t instanceof i)this.data=t.toString("binary");else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch(n){for(var r=0;r15?(n=Date.now(),o(t)):(r.push(t),1===r.length&&s.setAttribute("a",i=!i))}}a.nextTick=a.setImmediate}(),a.isNodejs=void 0!==e&&e.versions&&e.versions.node,a.globalScope=a.isNodejs?n:"undefined"==typeof self?window:self,a.isArray=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},a.isArrayBuffer=function(t){return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer},a.isArrayBufferView=function(t){return t&&a.isArrayBuffer(t.buffer)&&void 0!==t.byteLength},a.ByteBuffer=u,a.ByteStringBuffer=u;a.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))},a.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this},a.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this},a.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(a.encodeUtf8(t))},a.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))},a.ByteStringBuffer.prototype.putInt=function(t,e){c(e);var r="";do{e-=8,r+=String.fromCharCode(t>>e&255)}while(e>0);return this.putBytes(r)},a.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<0);return e},a.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},a.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e="":(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},a.ByteStringBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},a.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)},a.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var t=a.createBuffer(this.data);return t.read=this.read,t},a.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){for(var t="",e=this.read;e=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+e);return n.set(r),this.data=new DataView(n.buffer),this},a.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this},a.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(t,e){c(e),this.accommodate(e/8);do{e-=8,this.data.setInt8(this.write++,t>>e&255)}while(e>0);return this},a.DataBuffer.prototype.putSignedInt=function(t,e){return c(e),this.accommodate(e/8),t<0&&(t+=2<0);return e},a.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},a.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e="":(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},a.DataBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},a.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)},a.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){for(var t="",e=this.read;e0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return r},a.xorBytes=function(t,e,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=t.charCodeAt(o)^e.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s},a.hexToBytes=function(t){var e="",r=0;for(!0&t.length&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t)};var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(t,e){for(var r,n,i,s="",o="",a=0;a>2),s+=h.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=h.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":h.charAt(63&i)),e&&s.length>e&&(o+=s.substr(0,e)+"\r\n",s=s.substr(e));return o+=s},a.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e,r,n,i,s="",o=0;o>4),64!==n&&(s+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(s+=String.fromCharCode((3&n)<<6|i)));return s},a.encodeUtf8=function(t){return unescape(encodeURIComponent(t))},a.decodeUtf8=function(t){return decodeURIComponent(escape(t))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:o.encode,decode:o.decode}},a.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)},a.binary.raw.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length));for(var i=r=r||0,s=0;s>2),s+=h.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=h.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":h.charAt(63&i)),e&&s.length>e&&(o+=s.substr(0,e)+"\r\n",s=s.substr(e));return o+=s},a.binary.base64.decode=function(t,e,r){var n,i,s,o,a=e;a||(a=new Uint8Array(3*Math.ceil(t.length/4))),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==s&&(a[u++]=(15&i)<<4|s>>2,64!==o&&(a[u++]=(3&s)<<6|o));return e?u-r:a.subarray(0,u)},a.binary.base58.encode=function(t,e){return a.binary.baseN.encode(t,l,e)},a.binary.base58.decode=function(t,e){return a.binary.baseN.decode(t,l,e)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(t,e,r){t=a.encodeUtf8(t);var n=e;n||(n=new Uint8Array(t.length));for(var i=r=r||0,s=0;s0?(i=r[n].substring(0,o),s=r[n].substring(o+1)):(i=r[n],s=null),i in e||(e[i]=[]),i in Object.prototype||null===s||e[i].push(unescape(s))}return e};return void 0===t?(null===w&&(w="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),e=w):e=r(t),e},a.parseFragment=function(t){var e=t,r="",n=t.indexOf("?");n>0&&(e=t.substring(0,n),r=t.substring(n+1));var i=e.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:e,queryString:r,path:i,query:""===r?{}:a.getQueryVariables(r)}},a.makeRequest=function(t){var e=a.parseFragment(t),r={path:e.pathString,query:e.queryString,getPath:function(t){return void 0===t?e.path:e.path[t]},getQuery:function(t,r){var n;return void 0===t?n=e.query:(n=e.query[t])&&void 0!==r&&(n=n[r]),n},getQueryLast:function(t,e){var n=r.getQuery(t);return n?n[n.length-1]:e}};return r},a.makeLink=function(t,e,r){t=jQuery.isArray(t)?t.join("/"):t;var n=jQuery.param(e||{});return r=r||"",t+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},a.setPath=function(t,e,r){if("object"==typeof t&&null!==t)for(var n=0,i=e.length;n0&&s.push(r),o=n.lastIndex;var a=e[0][1];switch(a){case"s":case"o":i");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(t.substring(o)),s.join("")},a.formatNumber=function(t,e,r,n){var i=t,s=isNaN(e=Math.abs(e))?2:e,o=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",h=u.length>3?u.length%3:0;return c+(h?u.substr(0,h)+a:"")+u.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-u).toFixed(s).slice(2):"")},a.formatSize=function(t){return t=t>=1073741824?a.formatNumber(t/1073741824,2,".","")+" GiB":t>=1048576?a.formatNumber(t/1048576,2,".","")+" MiB":t>=1024?a.formatNumber(t/1024,0)+" KiB":a.formatNumber(t,0)+" bytes"},a.bytesFromIP=function(t){return-1!==t.indexOf(".")?a.bytesFromIPv4(t):-1!==t.indexOf(":")?a.bytesFromIPv6(t):null},a.bytesFromIPv4=function(t){if(4!==(t=t.split(".")).length)return null;for(var e=a.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}e.push(s)}if(r.length>0){var u=r[n];u.end-u.start>0&&(e.splice(u.start,u.end-u.start+1,""),0===u.start&&e.unshift(""),7===u.end&&e.push(""))}return e.join(":")},a.estimateCores=function(t,e){if("function"==typeof t&&(e=t,t={}),t=t||{},"cores"in a&&!t.update)return e(null,a.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,e(null,a.cores);if("undefined"==typeof Worker)return a.cores=1,e(null,a.cores);if("undefined"==typeof Blob)return a.cores=2,e(null,a.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(t){for(var e=Date.now(),r=e+4;Date.now()a.st&&i.sti.st&&a.st{let r;if(t instanceof Uint8Array)r=o.varintUint8ArrayEncode(t);else{if(!s[t])throw new Error("multicodec not recognized");r=s[t]}return a([r,e],r.length+e.length)},e.rmPrefix=t=>(n.decode(t),t.slice(n.decode.bytes)),e.getCodec=t=>{const e=n.decode(t),r=i.get(e);if(void 0===r)throw new Error(`Code ${e} not found`);return r},e.getName=t=>i.get(t),e.getNumber=t=>{const e=s[t];if(void 0===e)throw new Error("Codec `"+t+"` not found");return n.decode(e)},e.getCode=t=>n.decode(t),e.getCodeVarint=t=>{const e=s[t];if(void 0===e)throw new Error("Codec `"+t+"` not found");return e},e.getVarint=t=>n.encode(t);const c=r(410);Object.assign(e,c),e.print=r(411)},function(t,e,r){"use strict";t.exports=function(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r15?(n=Date.now(),o(t)):(r.push(t),1===r.length&&s.setAttribute("a",i=!i))}}a.nextTick=a.setImmediate}(),a.isNodejs=void 0!==e&&e.versions&&e.versions.node,a.globalScope=a.isNodejs?n:"undefined"==typeof self?window:self,a.isArray=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},a.isArrayBuffer=function(t){return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer},a.isArrayBufferView=function(t){return t&&a.isArrayBuffer(t.buffer)&&void 0!==t.byteLength},a.ByteBuffer=u,a.ByteStringBuffer=u;a.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))},a.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this},a.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this},a.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(a.encodeUtf8(t))},a.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))},a.ByteStringBuffer.prototype.putInt=function(t,e){c(e);var r="";do{e-=8,r+=String.fromCharCode(t>>e&255)}while(e>0);return this.putBytes(r)},a.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<0);return e},a.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},a.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e="":(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},a.ByteStringBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},a.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)},a.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var t=a.createBuffer(this.data);return t.read=this.read,t},a.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){for(var t="",e=this.read;e=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+e);return n.set(r),this.data=new DataView(n.buffer),this},a.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this},a.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(t,e){c(e),this.accommodate(e/8);do{e-=8,this.data.setInt8(this.write++,t>>e&255)}while(e>0);return this},a.DataBuffer.prototype.putSignedInt=function(t,e){return c(e),this.accommodate(e/8),t<0&&(t+=2<0);return e},a.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},a.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e="":(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},a.DataBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},a.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)},a.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){for(var t="",e=this.read;e0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return r},a.xorBytes=function(t,e,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=t.charCodeAt(o)^e.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s},a.hexToBytes=function(t){var e="",r=0;for(!0&t.length&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t)};var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(t,e){for(var r,n,i,s="",o="",a=0;a>2),s+=h.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=h.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":h.charAt(63&i)),e&&s.length>e&&(o+=s.substr(0,e)+"\r\n",s=s.substr(e));return o+=s},a.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e,r,n,i,s="",o=0;o>4),64!==n&&(s+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(s+=String.fromCharCode((3&n)<<6|i)));return s},a.encodeUtf8=function(t){return unescape(encodeURIComponent(t))},a.decodeUtf8=function(t){return decodeURIComponent(escape(t))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:o.encode,decode:o.decode}},a.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)},a.binary.raw.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length));for(var i=r=r||0,s=0;s>2),s+=h.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=h.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":h.charAt(63&i)),e&&s.length>e&&(o+=s.substr(0,e)+"\r\n",s=s.substr(e));return o+=s},a.binary.base64.decode=function(t,e,r){var n,i,s,o,a=e;a||(a=new Uint8Array(3*Math.ceil(t.length/4))),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==s&&(a[u++]=(15&i)<<4|s>>2,64!==o&&(a[u++]=(3&s)<<6|o));return e?u-r:a.subarray(0,u)},a.binary.base58.encode=function(t,e){return a.binary.baseN.encode(t,l,e)},a.binary.base58.decode=function(t,e){return a.binary.baseN.decode(t,l,e)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(t,e,r){t=a.encodeUtf8(t);var n=e;n||(n=new Uint8Array(t.length));for(var i=r=r||0,s=0;s0?(i=r[n].substring(0,o),s=r[n].substring(o+1)):(i=r[n],s=null),i in e||(e[i]=[]),i in Object.prototype||null===s||e[i].push(unescape(s))}return e};return void 0===t?(null===w&&(w="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),e=w):e=r(t),e},a.parseFragment=function(t){var e=t,r="",n=t.indexOf("?");n>0&&(e=t.substring(0,n),r=t.substring(n+1));var i=e.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:e,queryString:r,path:i,query:""===r?{}:a.getQueryVariables(r)}},a.makeRequest=function(t){var e=a.parseFragment(t),r={path:e.pathString,query:e.queryString,getPath:function(t){return void 0===t?e.path:e.path[t]},getQuery:function(t,r){var n;return void 0===t?n=e.query:(n=e.query[t])&&void 0!==r&&(n=n[r]),n},getQueryLast:function(t,e){var n=r.getQuery(t);return n?n[n.length-1]:e}};return r},a.makeLink=function(t,e,r){t=jQuery.isArray(t)?t.join("/"):t;var n=jQuery.param(e||{});return r=r||"",t+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},a.setPath=function(t,e,r){if("object"==typeof t&&null!==t)for(var n=0,i=e.length;n0&&s.push(r),o=n.lastIndex;var a=e[0][1];switch(a){case"s":case"o":i");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(t.substring(o)),s.join("")},a.formatNumber=function(t,e,r,n){var i=t,s=isNaN(e=Math.abs(e))?2:e,o=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",h=u.length>3?u.length%3:0;return c+(h?u.substr(0,h)+a:"")+u.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-u).toFixed(s).slice(2):"")},a.formatSize=function(t){return t=t>=1073741824?a.formatNumber(t/1073741824,2,".","")+" GiB":t>=1048576?a.formatNumber(t/1048576,2,".","")+" MiB":t>=1024?a.formatNumber(t/1024,0)+" KiB":a.formatNumber(t,0)+" bytes"},a.bytesFromIP=function(t){return-1!==t.indexOf(".")?a.bytesFromIPv4(t):-1!==t.indexOf(":")?a.bytesFromIPv6(t):null},a.bytesFromIPv4=function(t){if(4!==(t=t.split(".")).length)return null;for(var e=a.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}e.push(s)}if(r.length>0){var u=r[n];u.end-u.start>0&&(e.splice(u.start,u.end-u.start+1,""),0===u.start&&e.unshift(""),7===u.end&&e.push(""))}return e.join(":")},a.estimateCores=function(t,e){if("function"==typeof t&&(e=t,t={}),t=t||{},"cores"in a&&!t.update)return e(null,a.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,e(null,a.cores);if("undefined"==typeof Worker)return a.cores=1,e(null,a.cores);if("undefined"==typeof Blob)return a.cores=2,e(null,a.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(t){for(var e=Date.now(),r=e+4;Date.now()a.st&&i.sti.st&&a.sti.digest(t,"sha2-256"),e.convertPeerId=t=>i.digest(t.id,"sha2-256"),e.bufferToKey=t=>new o("/"+e.encodeBase32(t),!1),e.keyForPublicKey=t=>d([p("/pk/"),t.id]),e.isPublicKeyKey=t=>"/pk/"===y(t.slice(0,4)),e.fromPublicKeyKey=t=>new f(t.slice(4)),e.now=()=>Date.now(),e.encodeBase32=t=>(new a.Encoder).write(t).finalize(),e.decodeBase32=t=>{const e=new a.Decoder;return Uint8Array.from(e.write(t).finalize())},e.sortClosestPeers=async(t,r)=>(await u(t,async t=>{const n=await e.convertPeerId(t);return{peer:t,distance:c(n,r)}})).sort(e.xorCompare).map(t=>t.peer),e.xorCompare=(t,e)=>c.compare(t.distance,e.distance),e.pathSize=(t,e)=>Math.ceil(t/e),e.createPutRecord=(t,e)=>{const r=new Date;return new h(t,e,r).serialize()},e.logger=(t,e)=>{const r=["libp2p","dht"];e&&r.push(e),t&&r.push(""+t.toB58String().slice(0,8)),n.formatters.b=t=>s.toB58String(t);const i=n(r.join(":"));return i.error=n(r.concat(["error"]).join(":")),i},e.TimeoutError=class extends Error{get code(){return"ETIMEDOUT"}},e.withTimeout=(t,e)=>async(...r)=>Promise.race([t(...r),new Promise((t,r)=>{setTimeout(()=>{r(l(new Error("Async function did not complete before timeout"),"ETIMEDOUT"))},e)})]),e.mapParallel=async function(t,e){const r=[];for await(const n of t)r.push(e(n));return Promise.all(r)}},function(t,e,r){"use strict";const n=(...t)=>{let e;for(;t.length;)e=t.shift()(e);return e},i=t=>t&&("function"==typeof t[Symbol.asyncIterator]||"function"==typeof t[Symbol.iterator]||"function"==typeof t.next),s=t=>t&&"function"==typeof t.sink&&i(t.source),o=t=>e=>(t.sink(e),t.source),a=(...t)=>{if(s(t[0])){const e=t[0];t[0]=()=>e.source}else if(i(t[0])){const e=t[0];t[0]=()=>e}if(t.length>1&&s(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let e=1;et+e.length,0));const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}},function(t,e,r){"use strict";t.exports=function(t,{className:e,symbolName:r}){const n=Symbol.for(r),i={[e]:class extends t{constructor(...t){super(...t),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return e}}}[e];return i["is"+e]=t=>!(!t||!t[n]),i},t.exports.proto=function(t,{className:e,symbolName:r,withoutNew:n}){const i=Symbol.for(r),s={[e]:function(...e){if(n&&!(this instanceof s))return new s(...e);const r=t.call(this,...e)||this;return r&&!r[i]&&Object.defineProperty(r,i,{value:!0}),r}}[e];return s.prototype=Object.create(t.prototype),s.prototype.constructor=s,Object.defineProperty(s.prototype,Symbol.toStringTag,{get:()=>e}),s["is"+e]=t=>!(!t||!t[i]),s}},function(t,e,r){"use strict";e.messages={NOT_STARTED_YET:"The libp2p node is not started yet",DHT_DISABLED:"DHT is not available",CONN_ENCRYPTION_REQUIRED:"At least one connection encryption module is required"},e.codes={DHT_DISABLED:"ERR_DHT_DISABLED",PUBSUB_NOT_STARTED:"ERR_PUBSUB_NOT_STARTED",DHT_NOT_STARTED:"ERR_DHT_NOT_STARTED",CONN_ENCRYPTION_REQUIRED:"ERR_CONN_ENCRYPTION_REQUIRED",ERR_CONNECTION_ENDED:"ERR_CONNECTION_ENDED",ERR_CONNECTION_FAILED:"ERR_CONNECTION_FAILED",ERR_NODE_NOT_STARTED:"ERR_NODE_NOT_STARTED",ERR_ALREADY_ABORTED:"ERR_ALREADY_ABORTED",ERR_NO_VALID_ADDRESSES:"ERR_NO_VALID_ADDRESSES",ERR_DISCOVERED_SELF:"ERR_DISCOVERED_SELF",ERR_DUPLICATE_TRANSPORT:"ERR_DUPLICATE_TRANSPORT",ERR_ENCRYPTION_FAILED:"ERR_ENCRYPTION_FAILED",ERR_HOP_REQUEST_FAILED:"ERR_HOP_REQUEST_FAILED",ERR_INVALID_KEY:"ERR_INVALID_KEY",ERR_INVALID_MESSAGE:"ERR_INVALID_MESSAGE",ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_INVALID_PEER:"ERR_INVALID_PEER",ERR_MUXER_UNAVAILABLE:"ERR_MUXER_UNAVAILABLE",ERR_TIMEOUT:"ERR_TIMEOUT",ERR_TRANSPORT_UNAVAILABLE:"ERR_TRANSPORT_UNAVAILABLE",ERR_TRANSPORT_DIAL_FAILED:"ERR_TRANSPORT_DIAL_FAILED",ERR_UNSUPPORTED_PROTOCOL:"ERR_UNSUPPORTED_PROTOCOL",ERR_INVALID_MULTIADDR:"ERR_INVALID_MULTIADDR",ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"}},function(t,e,r){"use strict";const n=r(21)(r(510)).Data,i=r(0),s=["raw","directory","file","metadata","symlink","hamt-sharded-directory"],o=["directory","hamt-sharded-directory"],a=parseInt("0644",8),c=parseInt("0755",8);function u(t){if(null!=t){if(Object.prototype.hasOwnProperty.call(t,"secs")&&(t={secs:t.secs,nsecs:t.nsecs}),Object.prototype.hasOwnProperty.call(t,"Seconds")&&(t={secs:t.Seconds,nsecs:t.FractionalNanoseconds}),Array.isArray(t)&&(t={secs:t[0],nsecs:t[1]}),t instanceof Date){const e=t.getTime(),r=Math.floor(e/1e3);t={secs:r,nsecs:1e3*(e-1e3*r)}}if(Object.prototype.hasOwnProperty.call(t,"secs")){if(t.nsecs<0||t.nsecs>999999999)throw i(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return t}}}function h(t){if(null!=t)return("string"==typeof t||t instanceof String)&&(t=parseInt(t,8)),4095&t}class f{static unmarshal(t){const e=n.decode(t),r=new f({type:s[e.Type],data:e.hasData()?e.Data:void 0,blockSizes:e.blocksizes,mode:e.hasMode()?e.mode:void 0,mtime:e.hasMtime()?e.mtime:void 0});return r._originalMode=e.hasMode()?e.mode:void 0,r}constructor(...t){const{type:e,data:r,blockSizes:n,hashType:o,fanout:f,mtime:l,mode:d}=function(t){return 0===t.length?{type:"file"}:2===t.length?{type:t[0],data:t[1]}:"string"==typeof t[0]||t[0]instanceof String?{type:t[0]}:t[0]}(t);if(!s.includes(e))throw i(new Error("Type: "+e+" is not valid"),"ERR_INVALID_TYPE");this.type=e,this.data=r,this.hashType=o,this.fanout=f,this.blockSizes=n||[];const p=h(d);void 0!==p&&(this.mode=p),void 0===this.mode&&"file"===e&&(this.mode=a),void 0===this.mode&&this.isDirectory()&&(this.mode=c);const y=u(l);y&&(this.mtime=y)}isDirectory(){return o.includes(this.type)}addBlockSize(t){this.blockSizes.push(t)}removeBlockSize(t){this.blockSizes.splice(t,1)}fileSize(){if(this.isDirectory())return;let t=0;return this.blockSizes.forEach(e=>{t+=e}),this.data&&(t+=this.data.length),t}marshal(){let t;switch(this.type){case"raw":t=n.DataType.Raw;break;case"directory":t=n.DataType.Directory;break;case"file":t=n.DataType.File;break;case"metadata":t=n.DataType.Metadata;break;case"symlink":t=n.DataType.Symlink;break;case"hamt-sharded-directory":t=n.DataType.HAMTShard;break;default:throw i(new Error("Type: "+t+" is not valid"),"ERR_INVALID_TYPE")}let e=this.data;this.data&&this.data.length||(e=void 0);let r,s,o=this.blockSizes;if(this.blockSizes&&this.blockSizes.length||(o=void 0),null!=this.mode&&(r=4294963200&this._originalMode|h(this.mode),r===a&&"file"===this.type&&(r=void 0),r===c&&this.isDirectory()&&(r=void 0)),null!=this.mtime){const t=u(this.mtime);t&&(s={Seconds:t.secs,FractionalNanoseconds:t.nsecs},0===s.FractionalNanoseconds&&delete s.FractionalNanoseconds)}return n.encode({Type:t,Data:e,filesize:this.fileSize(),blocksizes:o,hashType:this.hashType,fanout:this.fanout,mode:r,mtime:s})}}t.exports=f},function(t,e,r){"use strict";var n;!function(i){var s,o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",h=u+"Number primitive has more than 15 significant digits: ",f=1e14,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e9;function p(t){var e=0|t;return t>0||t===e?e:e-1}function y(t){for(var e,r,n=1,i=t.length,s=t[0]+"";nu^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;os[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function b(t,e,r,n){if(tr||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?tr?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function m(t){var e=t.c.length-1;return p(t.e/14)==e&&t.c[e]%2!=0}function v(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function w(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else eN?y.c=y.e=null:t.e=10;f/=10,u++);return void(u>N?y.c=y.e=null:(y.e=u,y.c=[t]))}p=String(t)}else{if(!o.test(p=String(t)))return i(y,p,l);y.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(u=p.indexOf("."))>-1&&(p=p.replace(".","")),(f=p.search(/e/i))>0?(u<0&&(u=f),u+=+p.slice(f+1),p=p.substring(0,f)):u<0&&(u=p.length)}else{if(b(e,2,U.length,"Base"),10==e)return q(y=new j(t),R+y.e+1,C);if(p=String(t),l="number"==typeof t){if(0*t!=0)return i(y,p,l,e);if(y.s=1/t<0?(p=p.slice(1),-1):1,j.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(h+t)}else y.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=U.slice(0,e),u=f=0,d=p.length;fu){u=d;continue}}else if(!a&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){a=!0,f=-1,u=0;continue}return i(y,String(t),l,e)}l=!1,(u=(p=n(p,e,10,y.s)).indexOf("."))>-1?p=p.replace(".",""):u=p.length}for(f=0;48===p.charCodeAt(f);f++);for(d=p.length;48===p.charCodeAt(--d););if(p=p.slice(f,++d)){if(d-=f,l&&j.DEBUG&&d>15&&(t>9007199254740991||t!==c(t)))throw Error(h+y.s*t);if((u=u-f-1)>N)y.c=y.e=null;else if(u=M)?v(c,o):w(c,o,"0");else if(s=(t=q(new j(t),e,r)).e,a=(c=y(t.c)).length,1==n||2==n&&(e<=s||s<=B)){for(;aa){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function F(t,e){for(var r,n=1,i=new j(t[0]);n=10;i/=10,n++);return(r=n+14*r-1)>N?t.c=t.e=null:r=10;u/=10,i++);if((s=e-i)<0)s+=14,o=e,p=(h=y[d=0])/g[i-o-1]%10|0;else if((d=a((s+1)/14))>=y.length){if(!n)break t;for(;y.length<=d;y.push(0));h=p=0,i=1,o=(s%=14)-14+1}else{for(h=u=y[d],i=1;u>=10;u/=10,i++);p=(o=(s%=14)-14+i)<0?0:h/g[i-o-1]%10|0}if(n=n||e<0||null!=y[d+1]||(o<0?h:h%g[i-o-1]),n=r<4?(p||n)&&(0==r||r==(t.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(s>0?o>0?h/g[i-o]:0:y[d-1])%10&1||r==(t.s<0?8:7)),e<1||!y[0])return y.length=0,n?(e-=t.e+1,y[0]=g[(14-e%14)%14],t.e=-e||0):y[0]=t.e=0,t;if(0==s?(y.length=d,u=1,d--):(y.length=d+1,u=g[14-s],y[d]=o>0?c(h/g[i-o]%g[o])*u:0),n)for(;;){if(0==d){for(s=1,o=y[0];o>=10;o/=10,s++);for(o=y[0]+=u,u=1;o>=10;o/=10,u++);s!=u&&(t.e++,y[0]==f&&(y[0]=1));break}if(y[d]+=u,y[d]!=f)break;y[d--]=0,u=1}for(s=y.length;0===y[--s];y.pop());}t.e>N?t.c=t.e=null:t.e=M?v(e,r):w(e,r,"0"),t.s<0?"-"+e:e)}return j.clone=t,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(b(r=t[e],0,d,e),R=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(b(r=t[e],0,8,e),C=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(b(r[0],-d,0,e),b(r[1],0,d,e),B=r[0],M=r[1]):(b(r,-d,d,e),B=-(M=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)b(r[0],-d,-1,e),b(r[1],1,d,e),x=r[0],N=r[1];else{if(b(r,-d,d,e),!r)throw Error(u+e+" cannot be zero: "+r);x=-(N=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw P=!r,Error(u+"crypto unavailable");P=r}else P=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(b(r=t[e],0,9,e),O=r),t.hasOwnProperty(e="POW_PRECISION")&&(b(r=t[e],0,d,e),D=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);U=r}}return{DECIMAL_PLACES:R,ROUNDING_MODE:C,EXPONENTIAL_AT:[B,M],RANGE:[x,N],CRYPTO:P,MODULO_MODE:O,POW_PRECISION:D,FORMAT:L,ALPHABET:U}},j.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!j.DEBUG)return!0;var e,r,n=t.c,i=t.e,s=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===s||-1===s)&&i>=-d&&i<=d&&i===c(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break t}if((e=(i+1)%14)<1&&(e+=14),String(n[0]).length==e){for(e=0;e=f||r!==c(r))break t;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===s||1===s||-1===s))return!0;throw Error(u+"Invalid BigNumber: "+t)},j.maximum=j.max=function(){return F(arguments,k.lt)},j.minimum=j.min=function(){return F(arguments,k.gt)},j.random=(s=9007199254740992*Math.random()&2097151?function(){return c(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,i,o,h=0,f=[],p=new j(T);if(null==t?t=R:b(t,0,d),i=a(t/14),P)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));h>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[h]=r[0],e[h+1]=r[1]):(f.push(o%1e14),h+=2);h=i/2}else{if(!crypto.randomBytes)throw P=!1,Error(u+"crypto unavailable");for(e=crypto.randomBytes(i*=7);h=9e15?crypto.randomBytes(7).copy(e,h):(f.push(o%1e14),h+=7);h=i/7}if(!P)for(;h=10;o/=10,h++);h<14&&(n-=14-h)}return p.e=n,p.c=f,p}),j.sum=function(){for(var t=1,e=arguments,r=new j(e[0]);tr-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(e,n,i,s,o){var a,c,u,h,f,l,d,p,g=e.indexOf("."),b=R,m=C;for(g>=0&&(h=D,D=0,e=e.replace(".",""),l=(p=new j(n)).pow(e.length-g),D=h,p.c=t(w(y(l.c),l.e,"0"),10,i,"0123456789"),p.e=p.c.length),u=h=(d=t(e,n,i,o?(a=U,"0123456789"):(a="0123456789",U))).length;0==d[--h];d.pop());if(!d[0])return a.charAt(0);if(g<0?--u:(l.c=d,l.e=u,l.s=s,d=(l=r(l,p,b,m,i)).c,f=l.r,u=l.e),g=d[c=u+b+1],h=i/2,f=f||c<0||null!=d[c+1],f=m<4?(null!=g||f)&&(0==m||m==(l.s<0?3:2)):g>h||g==h&&(4==m||f||6==m&&1&d[c-1]||m==(l.s<0?8:7)),c<1||!d[0])e=f?w(a.charAt(1),-b,a.charAt(0)):a.charAt(0);else{if(d.length=c,f)for(--i;++d[--c]>i;)d[c]=0,c||(++u,d=[1].concat(d));for(h=d.length;!d[--h];);for(g=0,e="";g<=h;e+=a.charAt(d[g++]));e=w(e,u,a.charAt(0))}return e}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%1e7,h=e/1e7|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%1e7)+(n=h*s+(o=t[c]/1e7|0)*u)%1e7*1e7+a)/r|0)+(n/1e7|0)+h*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;ie[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]1;t.splice(0,1));}return function(n,i,s,o,a){var u,h,l,d,y,g,b,m,v,w,_,E,S,I,A,k,T,R=n.s==i.s?1:-1,C=n.c,B=i.c;if(!(C&&C[0]&&B&&B[0]))return new j(n.s&&i.s&&(C?!B||C[0]!=B[0]:B)?C&&0==C[0]||!B?0*R:R/0:NaN);for(v=(m=new j(R)).c=[],R=s+(h=n.e-i.e)+1,a||(a=f,h=p(n.e/14)-p(i.e/14),R=R/14|0),l=0;B[l]==(C[l]||0);l++);if(B[l]>(C[l]||0)&&h--,R<0)v.push(1),d=!0;else{for(I=C.length,k=B.length,l=0,R+=2,(y=c(a/(B[0]+1)))>1&&(B=t(B,y,a),C=t(C,y,a),k=B.length,I=C.length),S=k,_=(w=C.slice(0,k)).length;_=a/2&&A++;do{if(y=0,(u=e(B,w,k,_))<0){if(E=w[0],k!=_&&(E=E*a+(w[1]||0)),(y=c(E/A))>1)for(y>=a&&(y=a-1),b=(g=t(B,y,a)).length,_=w.length;1==e(g,w,b,_);)y--,r(g,k=10;R/=10,l++);q(m,s+(m.e=l+14*h-1)+1,o,d)}else m.e=h,m.r=+d;return m}}(),_=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,S=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,A=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,r,n){var i,s=r?e:e.replace(A,"");if(I.test(s))t.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(_,(function(t,e,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?t:e})),n&&(i=n,s=s.replace(E,"$1").replace(S,"0.$1")),e!=s))return new j(s,i);if(j.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},k.absoluteValue=k.abs=function(){var t=new j(this);return t.s<0&&(t.s=1),t},k.comparedTo=function(t,e){return g(this,new j(t,e))},k.decimalPlaces=k.dp=function(t,e){var r,n,i,s=this;if(null!=t)return b(t,0,d),null==e?e=C:b(e,0,8),q(new j(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=14*((i=r.length-1)-p(this.e/14)),i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},k.dividedBy=k.div=function(t,e){return r(this,new j(t,e),R,C)},k.dividedToIntegerBy=k.idiv=function(t,e){return r(this,new j(t,e),0,1)},k.exponentiatedBy=k.pow=function(t,e){var r,n,i,s,o,h,f,l,d=this;if((t=new j(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+V(t));if(null!=e&&(e=new j(e)),o=t.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!t.c||!t.c[0])return l=new j(Math.pow(+V(d),o?2-m(t):+V(t))),e?l.mod(e):l;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new j(NaN);(n=!h&&d.isInteger()&&e.isInteger())&&(d=d.mod(e))}else{if(t.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||o&&d.c[1]>=24e7:d.c[0]<8e13||o&&d.c[0]<=9999975e7)))return s=d.s<0&&m(t)?-0:0,d.e>-1&&(s=1/s),new j(h?1/s:s);D&&(s=a(D/14+2))}for(o?(r=new j(.5),h&&(t.s=1),f=m(t)):f=(i=Math.abs(+V(t)))%2,l=new j(T);;){if(f){if(!(l=l.times(d)).c)break;s?l.c.length>s&&(l.c.length=s):n&&(l=l.mod(e))}if(i){if(0===(i=c(i/2)))break;f=i%2}else if(q(t=t.times(r),t.e+1,1),t.e>14)f=m(t);else{if(0===(i=+V(t)))break;f=i%2}d=d.times(d),s?d.c&&d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}return n?l:(h&&(l=T.div(l)),e?l.mod(e):s?q(l,D,C,void 0):l)},k.integerValue=function(t){var e=new j(this);return null==t?t=C:b(t,0,8),q(e,e.e+1,t)},k.isEqualTo=k.eq=function(t,e){return 0===g(this,new j(t,e))},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(t,e){return g(this,new j(t,e))>0},k.isGreaterThanOrEqualTo=k.gte=function(t,e){return 1===(e=g(this,new j(t,e)))||0===e},k.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},k.isLessThan=k.lt=function(t,e){return g(this,new j(t,e))<0},k.isLessThanOrEqualTo=k.lte=function(t,e){return-1===(e=g(this,new j(t,e)))||0===e},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&0==this.c[0]},k.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new j(t,e)).s,!a||!e)return new j(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/14,u=t.e/14,h=o.c,l=t.c;if(!c||!u){if(!h||!l)return h?(t.s=-e,t):new j(l?o:NaN);if(!h[0]||!l[0])return l[0]?(t.s=-e,t):new j(h[0]?o:3==C?-0:0)}if(c=p(c),u=p(u),h=h.slice(),a=c-u){for((s=a<0)?(a=-a,i=h):(u=c,i=l),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=h.length)<(e=l.length))?a:e,a=e=0;e0)for(;e--;h[r++]=0);for(e=f-1;n>a;){if(h[--n]=0;){for(r=0,d=w[i]%1e7,y=w[i]/1e7|0,s=i+(o=c);s>i;)r=((u=d*(u=v[--o]%1e7)+(a=y*u+(h=v[o]/1e7|0)*d)%1e7*1e7+g[s]+r)/b|0)+(a/1e7|0)+y*h,g[s--]=u%b;g[s]=r}return r?++n:g.splice(0,1),K(t,g,n)},k.negated=function(){var t=new j(this);return t.s=-t.s||null,t},k.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new j(t,e)).s,!i||!e)return new j(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/14,o=t.e/14,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new j(i/0);if(!a[0]||!c[0])return c[0]?t:new j(a[0]?n:0*i)}if(s=p(s),o=p(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/f|0,a[e]=f===a[e]?0:a[e]%f;return i&&(a=[i].concat(a),++o),K(t,a,o)},k.precision=k.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return b(t,1,d),null==e?e=C:b(e,0,8),q(new j(s),t,e);if(!(r=s.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},k.shiftedBy=function(t){return b(t,-9007199254740991,9007199254740991),this.times("1e"+t)},k.squareRoot=k.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,h=R+4,f=new j("0.5");if(1!==c||!a||!a[0])return new j(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+V(o)))||c==1/0?(((e=y(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=p((u+1)/2)-(u<0||u%2),n=new j(e=c==1/0?"1e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new j(c+""),n.c[0])for((c=(u=n.e)+h)<3&&(c=0);;)if(s=n,n=f.times(s.plus(r(o,s,h,1))),y(s.c).slice(0,c)===(e=y(n.c)).slice(0,c)){if(n.e0&&y>0){for(s=y%a||a,f=p.substr(0,s);s0&&(f+=h+p.slice(s)),d&&(f="-"+f)}n=l?f+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?l.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):l):f}return(r.prefix||"")+n+(r.suffix||"")},k.toFraction=function(t){var e,n,i,s,o,a,c,h,f,d,p,g,b=this,m=b.c;if(null!=t&&(!(c=new j(t)).isInteger()&&(c.c||1!==c.s)||c.lt(T)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+V(c));if(!m)return new j(b);for(e=new j(T),f=n=new j(T),i=h=new j(T),g=y(m),o=e.e=g.length-b.e-1,e.c[0]=l[(a=o%14)<0?14+a:a],t=!t||c.comparedTo(e)>0?o>0?e:f:c,a=N,N=1/0,c=new j(g),h.c[0]=0;d=r(c,e,0,1),1!=(s=n.plus(d.times(i))).comparedTo(t);)n=i,i=s,f=h.plus(d.times(s=f)),h=s,e=c.minus(d.times(s=e)),c=s;return s=r(t.minus(n),i,0,1),h=h.plus(s.times(f)),n=n.plus(s.times(i)),h.s=f.s=b.s,p=r(f,i,o*=2,C).minus(b).abs().comparedTo(r(h,n,o,C).minus(b).abs())<1?[f,i]:[h,n],N=a,p},k.toNumber=function(){return+V(this)},k.toPrecision=function(t,e){return null!=t&&b(t,1,d),z(this,t,e,2)},k.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=B||s>=M?v(y(r.c),s):w(y(r.c),s,"0"):10===t?e=w(y((r=q(new j(r),R+s+1,C)).c),r.e,"0"):(b(t,2,U.length,"Base"),e=n(w(y(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},k.valueOf=k.toJSON=function(){return V(this)},k._isBigNumber=!0,null!=e&&j.set(e),j}()).default=s.BigNumber=s,void 0===(n=function(){return s}.call(e,r,e,t))||(t.exports=n)}()},function(t,e,r){"use strict";const n=r(78),{encodeText:i,decodeText:s,concat:o}=r(134);function a(t){if(n.names[t])return n.names[t];if(n.codes[t])return n.codes[t];throw new Error("Unsupported encoding: "+t)}(e=t.exports=function(t,e){if(!e)throw new Error("requires an encoded Uint8Array");const{name:r,codeBuf:n}=a(t);return function(t,e){a(t).decode(s(e))}(r,e),o([n,e],n.length+e.length)}).encode=function(t,e){const r=a(t),n=i(r.encode(e));return o([r.codeBuf,n],r.codeBuf.length+n.length)},e.decode=function(t){t instanceof Uint8Array&&(t=s(t));const e=t[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(e)&&(t=t.toLowerCase()),a(t[0]).decode(t.substring(1))},e.isEncoded=function(t){if(t instanceof Uint8Array&&(t=s(t)),"[object String]"!==Object.prototype.toString.call(t))return!1;try{return a(t[0]).name}catch(e){return!1}},e.encoding=a,e.encodingFromData=function(t){return t instanceof Uint8Array&&(t=s(t)),a(t[0])},e.names=Object.freeze(n.names),e.codes=Object.freeze(n.codes)},function(t,e,r){"use strict";e.encode=r(753),e.decode=r(754),e.varintEncode=r(321),e.varintDecode=r(322),e.int32BEEncode=r(755),e.int32BEDecode=r(756)},function(t,e,r){"use strict";const n=r(389),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:s}=Object,o=(t,e,r)=>Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0}),a={concatArrays:!1,ignoreUndefined:!1},c=t=>{const e=[];for(const r in t)i.call(t,r)&&e.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(t);for(const n of r)s.call(t,n)&&e.push(n)}return e};function u(t){return Array.isArray(t)?function(t){const e=t.slice(0,0);return c(t).forEach(r=>{o(e,r,u(t[r]))}),e}(t):n(t)?function(t){const e=null===Object.getPrototypeOf(t)?Object.create(null):{};return c(t).forEach(r=>{o(e,r,u(t[r]))}),e}(t):t}const h=(t,e,r,n)=>(r.forEach(r=>{void 0===e[r]&&n.ignoreUndefined||(r in t&&t[r]!==Object.getPrototypeOf(t)?o(t,r,f(t[r],e[r],n)):o(t,r,u(e[r])))}),t);function f(t,e,r){return r.concatArrays&&Array.isArray(t)&&Array.isArray(e)?((t,e,r)=>{let n=t.slice(0,0),s=0;return[t,e].forEach(e=>{const a=[];for(let r=0;r!a.includes(t)),r)}),n})(t,e,r):n(e)&&n(t)?h(t,e,c(e),r):u(e)}t.exports=function(...t){const e=f(u(a),void 0!==this&&this||{},a);let r={_:{}};for(const i of t)if(void 0!==i){if(!n(i))throw new TypeError("`"+i+"` is not an Option Object");r=f(r,{_:i},e)}return r._}},function(t,e,r){"use strict";t.exports=function(t,e,r,n){return e.bytes=r.bytes=0,{type:t,encode:e,decode:r,encodingLength:n}}},function(t,e,r){"use strict";var n=e,i=r(40),s=r(50),o=r(233);n.assert=s,n.toArray=o.toArray,n.zero2=o.zero2,n.toHex=o.toHex,n.encode=o.encode,n.getNAF=function(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-c:c,s.isubn(a)):a=0,n[o]=a,s.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n=0,i=0;t.cmpn(-n)>0||e.cmpn(-i)>0;){var s,o,a,c=t.andln(3)+n&3,u=e.andln(3)+i&3;if(3===c&&(c=-1),3===u&&(u=-1),0==(1&c))s=0;else s=3!==(a=t.andln(7)+n&7)&&5!==a||2!==u?c:-c;if(r[0].push(s),0==(1&u))o=0;else o=3!==(a=e.andln(7)+i&7)&&5!==a||2!==c?u:-u;r[1].push(o),2*n===s+1&&(n=1-n),2*i===o+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=Symbol.for("BufferList");function s(t){if(!(this instanceof s))return new s(t);s._init.call(this,t)}s._init=function(t){Object.defineProperty(this,i,{value:!0}),this._bufs=[],this.length=0,t&&this.append(t)},s.prototype._new=function(t){return new s(t)},s.prototype._offset=function(t){if(0===t)return[0,0];let e=0;for(let r=0;rthis.length||t<0)return;const e=this._offset(t);return this._bufs[e[0]][e[1]]},s.prototype.slice=function(t,e){return"number"==typeof t&&t<0&&(t+=this.length),"number"==typeof e&&e<0&&(e+=this.length),this.copy(null,0,t,e)},s.prototype.copy=function(t,e,r,i){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return t||n.alloc(0);if(i<=0)return t||n.alloc(0);const s=!!t,o=this._offset(r),a=i-r;let c=a,u=s&&e||0,h=o[1];if(0===r&&i===this.length){if(!s)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let e=0;ee)){this._bufs[n].copy(t,u,h,h+c),u+=e;break}this._bufs[n].copy(t,u,h),u+=e,c-=e,h&&(h=0)}return t.length>u?t.slice(0,u):t},s.prototype.shallowSlice=function(t,e){if(t=t||0,e="number"!=typeof e?this.length:e,t<0&&(t+=this.length),e<0&&(e+=this.length),t===e)return this._new();const r=this._offset(t),n=this._offset(e),i=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!==r[1]&&(i[0]=i[0].slice(r[1])),this._new(i)},s.prototype.toString=function(t,e,r){return this.slice(e,r).toString(t)},s.prototype.consume=function(t){if(t=Math.trunc(t),Number.isNaN(t)||t<=0)return this;for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function(){const t=this._new();for(let e=0;ethis.length?this.length:e;const i=this._offset(e);let s=i[0],o=i[1];for(;s=t.length){const r=e.indexOf(t,o);if(-1!==r)return this._reverseOffset([s,r]);o=e.length-t.length+1}else{const e=this._reverseOffset([s,o]);if(this._match(e,t))return e;o++}}o=0}return-1},s.prototype._match=function(t,e){if(this.length-t=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function o(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=i,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&o|128):s(t,i)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i>>0}return o},e.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},e.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},e.sum64=function(t,e,r,n){var i=t[e],s=n+t[e+1]>>>0,o=(s>>0,t[e+1]=s},e.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},e.sum64_lo=function(t,e,r,n){return e+n>>>0},e.sum64_4_hi=function(t,e,r,n,i,s,o,a){var c=0,u=e;return c+=(u=u+n>>>0)>>0)>>0)>>0},e.sum64_4_lo=function(t,e,r,n,i,s,o,a){return e+n+s+a>>>0},e.sum64_5_hi=function(t,e,r,n,i,s,o,a,c,u){var h=0,f=e;return h+=(f=f+n>>>0)>>0)>>0)>>0)>>0},e.sum64_5_lo=function(t,e,r,n,i,s,o,a,c,u){return e+n+s+a+u>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},function(t,e,r){"use strict";const n=r(0),i=r(4),s=r(590),o=r(41),a=t=>{if(t instanceof Uint8Array)return{cid:new i(t),toResolve:[]};if(i.isCID(t))return{cid:t,toResolve:[]};if("string"==typeof t){0===t.indexOf("/ipfs/")&&(t=t.substring(6));const e=((t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean))(t);return{cid:new i(e[0]),toResolve:e.slice(1)}}throw n(new Error("Unknown path type "+t),"ERR_BAD_PATH")},c=async function*(t,e,r){let{cid:i,toResolve:o}=a(t),c=i.toBaseEncodedString(),u=c;const h=o.length;for(;;){const a=await s(i,c,u,o,h,e,r);if(!a.entry&&!a.next)throw n(new Error("Could not resolve "+t),"ERR_NOT_FOUND");if(a.entry&&(yield a.entry),!a.next)return;o=a.next.toResolve,i=a.next.cid,c=a.next.name,u=a.next.path}},u=(t,e,r)=>o(c(t,e,r));t.exports=u,t.exports.path=c,t.exports.recursive=async function*(t,e,r){const n=await u(t,e,r);if(yield n,n.unixfs&&n.unixfs.type.includes("dir"))for await(const i of async function*t(e,r){for await(const n of e.content(r))if(yield n,n.unixfs.type.includes("dir"))for await(const e of t(n,r))yield e}(n,r))yield i}},function(t,e,r){"use strict";(function(t){!function(t,e){function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:(void 0).BN=s,s.BN=s,s.wordSize=26;try{o=r(462).Buffer}catch(I){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function c(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return i}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(i=0,s=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-s&4194303,(s+=24)>=26&&(s-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,a=Math.min(s,s-o)+r,u=0,h=r;h1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var u=["","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],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 l(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,f=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;h+=(o=(i=0|t.words[p])*(s=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,c=0|h}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,s=0,o=0;o>>24-i&16777215)||o!==this.length-1?u[6-c.length]+c+r:c+r,(i+=2)>=26&&(i-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?y+r:u[l-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return n(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),s=r||Math.max(1,i);n(i<=s,"byte array longer than desired length"),n(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===e,u=new t(s),h=this.clone();if(c){for(a=0;!h.isZero();a++)o=h.andln(255),h.iushrn(8),u[a]=o;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s>>26;for(;0!==i&&s>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,y=d>>>13,g=0|o[2],b=8191&g,m=g>>>13,v=0|o[3],w=8191&v,_=v>>>13,E=0|o[4],S=8191&E,I=E>>>13,A=0|o[5],k=8191&A,T=A>>>13,R=0|o[6],C=8191&R,B=R>>>13,M=0|o[7],x=8191&M,N=M>>>13,P=0|o[8],O=8191&P,D=P>>>13,L=0|o[9],U=8191&L,j=L>>>13,z=0|a[0],F=8191&z,K=z>>>13,q=0|a[1],V=8191&q,H=q>>>13,G=0|a[2],W=8191&G,$=G>>>13,Y=0|a[3],J=8191&Y,X=Y>>>13,Z=0|a[4],Q=8191&Z,tt=Z>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ht=0|a[8],ft=8191&ht,lt=ht>>>13,dt=0|a[9],pt=8191&dt,yt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,F))|0)+((8191&(i=(i=Math.imul(f,K))+Math.imul(l,F)|0))<<13)|0;u=((s=Math.imul(l,K))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,F),i=(i=Math.imul(p,K))+Math.imul(y,F)|0,s=Math.imul(y,K);var bt=(u+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(l,V)|0))<<13)|0;u=((s=s+Math.imul(l,H)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(b,F),i=(i=Math.imul(b,K))+Math.imul(m,F)|0,s=Math.imul(m,K),n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0;var mt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(l,W)|0))<<13)|0;u=((s=s+Math.imul(l,$)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(w,F),i=(i=Math.imul(w,K))+Math.imul(_,F)|0,s=Math.imul(_,K),n=n+Math.imul(b,V)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,$)|0;var vt=(u+(n=n+Math.imul(f,J)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(l,J)|0))<<13)|0;u=((s=s+Math.imul(l,X)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(S,F),i=(i=Math.imul(S,K))+Math.imul(I,F)|0,s=Math.imul(I,K),n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,H)|0)+Math.imul(_,V)|0,s=s+Math.imul(_,H)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,$)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,$)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(y,J)|0,s=s+Math.imul(y,X)|0;var wt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((s=s+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,F),i=(i=Math.imul(k,K))+Math.imul(T,F)|0,s=Math.imul(T,K),n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,n=n+Math.imul(b,J)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0;var _t=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((s=s+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,F),i=(i=Math.imul(C,K))+Math.imul(B,F)|0,s=Math.imul(B,K),n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,V)|0,s=s+Math.imul(T,H)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,$)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,J)|0,s=s+Math.imul(_,X)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(y,rt)|0,s=s+Math.imul(y,nt)|0;var Et=(u+(n=n+Math.imul(f,st)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(l,st)|0))<<13)|0;u=((s=s+Math.imul(l,ot)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(x,F),i=(i=Math.imul(x,K))+Math.imul(N,F)|0,s=Math.imul(N,K),n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(B,V)|0,s=s+Math.imul(B,H)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(T,W)|0,s=s+Math.imul(T,$)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,s=s+Math.imul(_,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,nt)|0,n=n+Math.imul(p,st)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0;var St=(u+(n=n+Math.imul(f,ct)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((s=s+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(O,F),i=(i=Math.imul(O,K))+Math.imul(D,F)|0,s=Math.imul(D,K),n=n+Math.imul(x,V)|0,i=(i=i+Math.imul(x,H)|0)+Math.imul(N,V)|0,s=s+Math.imul(N,H)|0,n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,$)|0)+Math.imul(B,W)|0,s=s+Math.imul(B,$)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(T,J)|0,s=s+Math.imul(T,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,nt)|0,n=n+Math.imul(b,st)|0,i=(i=i+Math.imul(b,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(y,ct)|0,s=s+Math.imul(y,ut)|0;var It=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(l,ft)|0))<<13)|0;u=((s=s+Math.imul(l,lt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(U,F),i=(i=Math.imul(U,K))+Math.imul(j,F)|0,s=Math.imul(j,K),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,H)|0)+Math.imul(D,V)|0,s=s+Math.imul(D,H)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,$)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,X)|0)+Math.imul(B,J)|0,s=s+Math.imul(B,X)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,s=s+Math.imul(T,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,nt)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(m,ct)|0,s=s+Math.imul(m,ut)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(y,ft)|0,s=s+Math.imul(y,lt)|0;var At=(u+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,yt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((s=s+Math.imul(l,yt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(U,V),i=(i=Math.imul(U,H))+Math.imul(j,V)|0,s=Math.imul(j,H),n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(D,W)|0,s=s+Math.imul(D,$)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,X)|0,n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(B,Q)|0,s=s+Math.imul(B,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,s=s+Math.imul(T,nt)|0,n=n+Math.imul(S,st)|0,i=(i=i+Math.imul(S,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,s=s+Math.imul(_,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,lt)|0)+Math.imul(m,ft)|0,s=s+Math.imul(m,lt)|0;var kt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,yt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,$))+Math.imul(j,W)|0,s=Math.imul(j,$),n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(B,rt)|0,s=s+Math.imul(B,nt)|0,n=n+Math.imul(k,st)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(T,st)|0,s=s+Math.imul(T,ot)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ut)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ft)|0,s=s+Math.imul(_,lt)|0;var Tt=(u+(n=n+Math.imul(b,pt)|0)|0)+((8191&(i=(i=i+Math.imul(b,yt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(U,J),i=(i=Math.imul(U,X))+Math.imul(j,J)|0,s=Math.imul(j,X),n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(D,Q)|0,s=s+Math.imul(D,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,nt)|0,n=n+Math.imul(C,st)|0,i=(i=i+Math.imul(C,ot)|0)+Math.imul(B,st)|0,s=s+Math.imul(B,ot)|0,n=n+Math.imul(k,ct)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ct)|0,s=s+Math.imul(T,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(I,ft)|0,s=s+Math.imul(I,lt)|0;var Rt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,yt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,yt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(U,Q),i=(i=Math.imul(U,tt))+Math.imul(j,Q)|0,s=Math.imul(j,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,nt)|0,n=n+Math.imul(x,st)|0,i=(i=i+Math.imul(x,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,n=n+Math.imul(C,ct)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(B,ct)|0,s=s+Math.imul(B,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(T,ft)|0,s=s+Math.imul(T,lt)|0;var Ct=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,yt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,yt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(U,rt),i=(i=Math.imul(U,nt))+Math.imul(j,rt)|0,s=Math.imul(j,nt),n=n+Math.imul(O,st)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,ot)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,ut)|0,n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(B,ft)|0,s=s+Math.imul(B,lt)|0;var Bt=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,yt)|0)+Math.imul(T,pt)|0))<<13)|0;u=((s=s+Math.imul(T,yt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(U,st),i=(i=Math.imul(U,ot))+Math.imul(j,st)|0,s=Math.imul(j,ot),n=n+Math.imul(O,ct)|0,i=(i=i+Math.imul(O,ut)|0)+Math.imul(D,ct)|0,s=s+Math.imul(D,ut)|0,n=n+Math.imul(x,ft)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,lt)|0;var Mt=(u+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,yt)|0)+Math.imul(B,pt)|0))<<13)|0;u=((s=s+Math.imul(B,yt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(U,ct),i=(i=Math.imul(U,ut))+Math.imul(j,ct)|0,s=Math.imul(j,ut),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(D,ft)|0,s=s+Math.imul(D,lt)|0;var xt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,yt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,yt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(U,ft),i=(i=Math.imul(U,lt))+Math.imul(j,ft)|0,s=Math.imul(j,lt);var Nt=(u+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,yt)|0)+Math.imul(D,pt)|0))<<13)|0;u=((s=s+Math.imul(D,yt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Pt=(u+(n=Math.imul(U,pt))|0)+((8191&(i=(i=Math.imul(U,yt))+Math.imul(j,pt)|0))<<13)|0;return u=((s=Math.imul(j,yt))+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,c[0]=gt,c[1]=bt,c[2]=mt,c[3]=vt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=It,c[9]=At,c[10]=kt,c[11]=Tt,c[12]=Rt,c[13]=Ct,c[14]=Bt,c[15]=Mt,c[16]=xt,c[17]=Nt,c[18]=Pt,0!==u&&(c[19]=u,r.length++),r};function p(t,e,r){return(new y).mulp(t,e,r)}function y(t,e){this.x=t,this.y=e}Math.imul||(d=l),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?l(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},y.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;n>=1;return n},y.prototype.permute=function(t,e,r,n,i,s){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new s(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==h||u>=i);u--){var f=0|this.words[u];this.words[u]=h<<26-s|f>>>s,h=f&a}return c&&0!==h&&(c.words[c.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(c/67108864|0),this.words[i+r]=67108863&s}for(;i>26,this.words[i+r]=67108863&s;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,c=n.length-i.length;if("mod"!==e){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;f--){var l=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(l=Math.min(l/o|0,67108863),n._ishlnsubmul(i,l,f);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},s.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var h=r.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(h),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(h),c.isub(f)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),o.isub(c)):(r.isub(e),a.isub(i),c.isub(o))}return{a:a,b:c,gcd:r.iushln(u)}},s.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new s(1),a=new s(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,h=1;0==(e.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var f=0,l=1;0==(r.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new E(t)},s.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},i(m,b),m.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=s}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},m.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new m;else if("p224"===t)e=new v;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return g[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new s(2*h*h).toRed(this);0!==this.pow(h,u).cmp(c);)h.redIAdd(c);for(var f=this.pow(h,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(a);){for(var y=d,g=0;0!==y.cmp(a);g++)y=y.redSqr();n(g=0;n--){for(var u=e.words[n],h=c-1;h>=0;h--){var f=u>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++a||0===n&&0===h)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}c=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t)}).call(this,r(110)(t))},function(t,e,r){"use strict";t.exports=async t=>{let e;for await(const r of t)e=r;return e}},function(t,e,r){"use strict";const n=r(283),i=r(172),s=r(39),o=r(0),a=r(4);t.exports=async(t,e,r)=>{const c=Array.isArray(e);let u=Array.isArray(e)?e:[e];const h=await n(t,r);return u=u.map(t=>{if(a.isCID(t)&&(t="/ipfs/"+t),(t=(t=(t||"").trim()).replace(/(\/\/+)/g,"/")).endsWith("/")&&t.length>1&&(t=t.substring(0,t.length-1)),!t)throw o(new Error("paths must not be empty"),"ERR_NO_PATH");if("/"!==t.substring(0,1))throw o(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");"/"===t.substring(t.length-1)&&(t=t.substring(0,t.length-1));const e=i(t);if("ipfs"===e[0]){let t;return t=2===e.length?"/"+e.join("/"):"/"+e.slice(0,e.length-1).join("/"),{type:"ipfs",depth:e.length-2,mfsPath:"/"+e.join("/"),mfsDirectory:t,parts:e,path:"/"+e.join("/"),name:e[e.length-1]}}const r=`/ipfs/${h}${e.length?"/"+e.join("/"):""}`,n=`/ipfs/${h}/${e.slice(0,e.length-1).join("/")}`;return{type:"mfs",depth:e.length,mfsDirectory:n,mfsPath:r,parts:e,path:"/"+e.join("/"),name:e[e.length-1]}}),await Promise.all(u.map(async e=>{const r="mfs"===e.type?e.mfsPath:e.path;try{const n=await s(r,t.ipld);e.cid=n.cid,e.mfsPath="/ipfs/"+n.path,e.unixfs=n.unixfs,e.content=n.content}catch(n){if("ERR_NOT_FOUND"!==n.code)throw n}e.exists=Boolean(e.cid)})),c?u:u[0]}},function(t,e,r){"use strict";t.exports=function t(e,r){if(!e){const e=new Error(r||"Assertion failed");throw Error.captureStackTrace&&Error.captureStackTrace(e,t),e}}},function(t,e,r){"use strict";const n=r(7),i=r(17),s=r(21),{Record:o}=r(73),a=s(r(976)),c=a.Message.MessageType,u=a.Message.ConnectionType;class h{constructor(t,e,r){if(e&&!(e instanceof Uint8Array))throw new Error("Key must be a Uint8Array");this.type=t,this.key=e,this._clusterLevelRaw=r,this.closerPeers=[],this.providerPeers=[],this.record=null}get clusterLevel(){const t=this._clusterLevelRaw-1;return t<0?0:t}set clusterLevel(t){this._clusterLevelRaw=t}serialize(){const t={key:this.key,type:this.type,clusterLevelRaw:this._clusterLevelRaw,closerPeers:this.closerPeers.map(f),providerPeers:this.providerPeers.map(f)};return this.record&&(this.record instanceof Uint8Array?t.record=this.record:t.record=this.record.serialize()),a.Message.encode(t)}static deserialize(t){const e=a.Message.decode(t),r=new h(e.type,e.key,e.clusterLevelRaw);return r.closerPeers=e.closerPeers.map(l),r.providerPeers=e.providerPeers.map(l),e.record&&(r.record=o.deserialize(e.record)),r}}function f(t){return{id:t.id.id,addrs:(t.multiaddrs||[]).map(t=>t.bytes),connection:u.CONNECTED}}function l(t){return{id:new n(t.id),multiaddrs:t.addrs.map(t=>i(t))}}h.TYPES=c,h.CONNECTION_TYPES=u,t.exports=h},function(t,e,r){"use strict";const{AbortController:n,AbortSignal:i}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;t.exports=n,t.exports.AbortSignal=i,t.exports.default=n},function(t,e,r){"use strict";const n=r(0);t.exports=(t={},e)=>{Array.isArray(t)&&(t=t.filter(t=>"object"==typeof t).pop()||{});const r={};for(const n in e)null!==t[n]&&void 0!==t[n]?r[n]=t[n]:r[n]=e[n];if(void 0!==t.count&&(r.length=t.count),void 0!==t.p&&(r.parents=t.p),void 0!==t.l&&(r.long=t.l),r.length||0===r.length||(r.length=1/0),r.offset<0)throw n(new Error("cannot have negative write offset"),"ERR_INVALID_PARAMS");if(r.length<0)throw n(new Error("cannot have negative byte count"),"ERR_INVALID_PARAMS");return r}},function(t,e,r){"use strict";const n=r(190),i=r(757),s=(t,e,r)=>o(t,Array.isArray(e)?e:[{signal:e,options:r}]),o=(t,e)=>(t=n(t),e=e.map(({signal:t,options:e})=>({signal:t,options:e||{}})),async function*(){let r;const n=()=>{r&&r()};for(const{signal:t}of e)t.addEventListener("abort",n);for(;;){let o;try{for(const{signal:t,options:r}of e)if(t.aborted){const{abortMessage:t,abortCode:e}=r;throw new i(t,e)}const n=new Promise((t,n)=>{r=()=>{const{options:t}=e.find(({signal:t})=>t.aborted),{abortMessage:r,abortCode:s}=t;n(new i(r,s))}});o=await Promise.race([n,t.next()]),r=null}catch(s){for(const{signal:t}of e)t.removeEventListener("abort",n);const r=e.find(({signal:t})=>t.aborted),i="aborted"===s.type&&r;if(i&&r.options.onAbort&&await r.options.onAbort(t),"function"==typeof t.return&&await t.return(),i&&r.options.returnOnAbort)return;throw s}if(o.done)break;yield o.value}for(const{signal:t}of e)t.removeEventListener("abort",n)}()),a=(t,e,r)=>c(t,Array.isArray(e)?e:[{signal:e,options:r}]),c=(t,e)=>r=>t(o(r,e)),u=(t,e)=>({sink:c(t.sink,e),source:o(t.source,e)});t.exports=s,t.exports.AbortError=i,t.exports.source=s,t.exports.sink=a,t.exports.transform=a,t.exports.duplex=(t,e,r)=>u(t,Array.isArray(e)?e:[{signal:e,options:r}])},function(t,e,r){"use strict";const n=r(1),i=r(20),s=(t,e,r)=>{let n=0;const i=r.length;for(;n{const r=["bitswap"];e&&r.push(e),t&&r.push(""+t.toB58String().slice(0,8));const i=n(r.join(":"));return i.error=n(r.concat(["error"]).join(":")),i},includesWith:s,uniqWith:(t,e)=>{let r=0;const n=e.length,i=[];let o;for(;re.reduce((e,r)=>{const n=t(r);return e[n]?e[n].push(r):e[n]=[r],e},{}),pullAllWith:(t,e,r)=>e.filter(e=>!s(t,e,r)),sortBy:(t,e)=>Array.prototype.slice.call(e,0).sort((e,r)=>{const n=t(e),i=t(r);return ni?1:0}),isMapEqual:(t,e)=>{if(t.size!==e.size)return!1;for(const[r,n]of t){if(!e.has(r))return!1;const t=e.get(r);if("function"==typeof n.equals&&!n.equals(t))return!1;if(n._data&&!i(n._data,t._data))return!1}return!0}}},function(t,e,r){"use strict";const n=r(31),i=r(15),{names:s}=r(404),o=r(5),a=r(6),c=r(26),u={};for(const f in s)u[s[f]]=f;function h(t){e.decode(t)}e.names=s,e.codes=Object.freeze(u),e.toHexString=function(t){if(!(t instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return o(t,"base16")},e.fromHexString=function(t){return a(t,"base16")},e.toB58String=function(t){if(!(t instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return o(n.encode("base58btc",t)).slice(1)},e.fromB58String=function(t){const e=t instanceof Uint8Array?o(t):t;return n.decode("z"+e)},e.decode=function(t){if(!(t instanceof Uint8Array))throw new Error("multihash must be a Uint8Array");if(t.length<2)throw new Error("multihash too short. must be > 2 bytes.");const r=i.decode(t);if(!e.isValidCode(r))throw new Error("multihash unknown function code: 0x"+r.toString(16));t=t.slice(i.decode.bytes);const n=i.decode(t);if(n<0)throw new Error("multihash invalid length: "+n);if((t=t.slice(i.decode.bytes)).length!==n)throw new Error("multihash length inconsistent: 0x"+o(t,"base16"));return{code:r,name:u[r],length:n,digest:t}},e.encode=function(t,r,n){if(!t||void 0===r)throw new Error("multihash encode requires at least two args: digest, code");const s=e.coerceCode(r);if(!(t instanceof Uint8Array))throw new Error("digest should be a Uint8Array");if(null==n&&(n=t.length),n&&t.length!==n)throw new Error("digest length should be equal to specified length.");const o=i.encode(s),a=i.encode(n);return c([o,a,t],o.length+a.length+t.length)},e.coerceCode=function(t){let r=t;if("string"==typeof t){if(void 0===s[t])throw new Error("Unrecognized hash function named: "+t);r=s[t]}if("number"!=typeof r)throw new Error("Hash function code should be a number. Got: "+r);if(void 0===u[r]&&!e.isAppCode(r))throw new Error("Unrecognized function code: "+r);return r},e.isAppCode=function(t){return t>0&&t<16},e.isValidCode=function(t){return!!e.isAppCode(t)||!!u[t]},e.validate=h,e.prefix=function(t){return h(t),t.subarray(0,2)}},function(t,e,r){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=n,n.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e,r){"use strict";const n=r(49),i=r(31),s=r(17),o=r(61),a=r(4),{URL:c}=r(106),u=r(5),h=/^https?:\/\/[^/]+\/(ip[fn]s)\/([^/?#]+)/,f=/^\/(ip[fn]s)\/([^/?#]+)/,l=/^https?:\/\/([^/]+)\.(ip[fn]s)\.[^/?]+/,d=/^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)+([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$/;function p(t){try{return new a(t),!0}catch(e){return!1}}function y(t){if(!t)return!1;if(s.isMultiaddr(t))return!0;try{return new s(t),!0}catch(e){return!1}}function g(t,e,r=1,n=2){const i=v(t);if(!i)return!1;const s=i.match(e);if(!s)return!1;if("ipfs"!==s[r])return!1;let o=s[n];return o&&e===l&&(o=o.toLowerCase()),p(o)}function b(t,e,r=1,n){const i=v(t);if(!i)return!1;const s=i.match(e);if(!s)return!1;if("ipns"!==s[r])return!1;let o=s[n];if(o&&e===l){if(o=o.toLowerCase(),p(o))return!0;try{const{hostname:t}=new c("http://"+o);return d.test(t)}catch(a){return!1}}return!0}function m(t){return"string"==typeof t}function v(t){return t instanceof Uint8Array?u(t,"base58btc"):!!m(t)&&t}const w=t=>g(t,l,2,1),_=t=>b(t,l,2,1),E=t=>w(t)||_(t),S=t=>g(t,h)||w(t),I=t=>b(t,h)||_(t),A=t=>S(t)||I(t)||E(t),k=t=>g(t,f)||b(t,f);t.exports={multihash:function(t){const e=v(t);try{return n.decode(i.decode("z"+e)),!0}catch(r){return!1}},multiaddr:y,peerMultiaddr:function(t){return y(t)&&o.IPFS.matches(t)},cid:p,base32cid:t=>"base32"===function(t){try{return i.isEncoded(t)}catch(e){return!1}}(t)&&p(t),ipfsSubdomain:w,ipnsSubdomain:_,subdomain:E,subdomainGatewayPattern:l,ipfsUrl:S,ipnsUrl:I,url:A,pathGatewayPattern:h,ipfsPath:t=>g(t,f),ipnsPath:t=>b(t,f),path:k,pathPattern:f,urlOrPath:t=>A(t)||k(t),cidPath:t=>m(t)&&!p(t)&&g("/ipfs/"+t,f)}},function(t,e,r){"use strict";function n(t,e){return void 0===e?e=>n(t,e):e[Symbol.asyncIterator]?async function*(t,e){let r=[];for await(const n of e)r.push(n),r.length===t&&(yield r,r=[]);r.length>0&&(yield r)}(t,e):function*(t,e){let r=[];for(const n of e)r.push(n),r.length===t&&(yield r,r=[]);r.length>0&&(yield r)}(t,e)}function i(t){if("function"==typeof t.next)return t;if("function"==typeof t[Symbol.iterator])return t[Symbol.iterator]();if("function"==typeof t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();throw new TypeError('"values" does not to conform to any of the iterator or iterable protocols')}function s(){let t,e;return{promise:new Promise((r,n)=>{e=r,t=n}),reject:t,resolve:e}}function o(t,e){const r=i(e),n=[],o=[];let a=!1,c=!1;async function u(){if(!c&&!(a||n.length>=t)){a=!0;try{const{done:t,value:e}=await r.next();t?c=!0:n.push({value:e})}catch(e){c=!0,n.push({error:e})}!function(){for(;o.length>0&&n.length>0;){const t=o.shift(),{error:e,value:r}=n.shift();e?t.reject(e):t.resolve({done:!1,value:r})}for(;o.length>0&&c;){const{resolve:t}=o.shift();t({done:!0,value:void 0})}}(),a=!1,u()}}const h={next:async function(){if(n.length>0){const{error:t,value:e}=n.shift();if(t)throw t;return u(),{done:!1,value:e}}if(c)return{done:!0,value:void 0};const t=s();return o.push(t),u(),t.promise},[Symbol.asyncIterator]:()=>h};return h}function a(t,e){return void 0===e?e=>a(t,e):e[Symbol.asyncIterator]?o(t,e):function*(t,e){const r=[];let n;try{for(const n of e)r.push(n),r.length<=t||(yield r.shift())}catch(i){n=i}for(const s of r)yield s;if(n)throw n}(t,e)}function c(t){return t[Symbol.asyncIterator]?async function(t){const e=[];for await(const r of t)e.push(r);return e}(t):Array.from(t)}function u(...t){return t.find(t=>void 0!==t[Symbol.asyncIterator])?async function*(t){for await(const e of t)yield*e}(t):function*(t){for(const e of t)yield*e}(t)}function h(t){if(t[Symbol.asyncIterator])return async function(t){for await(const e of t);}(t);for(const e of t);}async function*f(t,e){for await(const r of e)await t(r)&&(yield r)}function l(t,e){return void 0===e?e=>f(t,e):f(t,e)}async function*d(t){for await(const e of t)e&&"string"!=typeof e&&(e[Symbol.iterator]||e[Symbol.asyncIterator])?yield*d(e):yield e}async function*p(t,e){for await(const r of e)yield await t(r)}function y(t,e){return void 0===e?e=>p(t,e):p(t,e)}function g(t,e){return void 0===e?e=>g(t,e):l(t=>null!=t,d(y(t,e)))}function b(t,e,r){const n=i(r),o=[],a=[];let c=!1,u=!1,h=0,f=null;function l(){for(;a.length>0&&o.length>0;){const{resolve:t}=a.shift();t({done:!1,value:o.shift()})}for(;a.length>0&&0===h&&c;){const{resolve:t,reject:e}=a.shift();f?(e(f),f=null):t({done:!0,value:void 0})}}async function d(){if(c)l();else if(!(u||h+o.length>=t)){u=!0,h++;try{const{done:t,value:r}=await n.next();t?(c=!0,h--,l()):async function(t){try{const r=await e(t);if(r&&r[Symbol.asyncIterator])for await(const t of r)o.push(t);else o.push(r)}catch(r){c=!0,f=r}h--,l(),d()}(r)}catch(r){c=!0,h--,f=r,l()}u=!1,d()}}const p={next:async function(){if(0===o.length){const t=s();return a.push(t),d(),t.promise}const t=o.shift();return d(),{done:!1,value:t}},[Symbol.asyncIterator]:()=>p};return p}function m(t,e,r){return void 0===e?(e,r)=>r?m(t,e,r):m(t,e):void 0===r?r=>m(t,e,r):l(t=>null!=t,d(b(t,e,r)))}async function v(t){return new Promise(e=>{t.once("readable",()=>{e()})})}function w(t){return"function"==typeof t[Symbol.asyncIterator]?t:async function*(t){for(;;){const e=t.read();if(null===e){if(t._readableState.ended)break;await v(t)}else yield e}}(t)}async function*_(...t){const e=new Set(t.map(i));for(;e.size>0;)for(const t of e){const r=await t.next();r.done?e.delete(t):yield r.value}}function E(t,...e){let r=t();for(const n of e)r=n(r);return r}function S(t,e,r){return void 0===e?(e,r)=>S(t,e,r):void 0===r?r=>S(t,e,r):async function*(t,e,r){let n=null;const s=i(E(()=>r,a(1),(async function*(t){for await(const e of t){if(n)return;yield e}}),y(t=>({value:e(t)})),a(t)));for(;;){const{value:t,done:e}=await s.next();if(e)break;try{const e=await t.value;n||(yield e)}catch(o){n=o}}if(n)throw n}(t,e,r)}function I(t,e,r){return void 0===e?(e,r)=>r?I(t,e,r):I(t,e):void 0===r?r=>I(t,e,r):l(t=>null!=t,d(S(t,e,r)))}async function*A(...t){const e=t.map(i),r=new Set,n=new Map;let s=null,o=null,a=null;const c=t=>{s=t,o&&o(t)},u=t=>{a&&a(t)},h=t=>{const e=Promise.resolve(t.next()).then(async({done:i,value:s})=>{i||n.set(t,s),r.delete(e)});r.add(e),e.then(u,c)};for(const i of e)h(i);for(;;){if(0===r.size&&0===n.size)return;await new Promise((t,e)=>{if(s&&e(s),n.size>0)return t();a=t,o=e});for(const[t,e]of n)n.delete(t),yield e,h(t)}}async function k(t,e,r){let n=e;for await(const i of r)n=await t(n,i);return n}function T(t,e,r){return void 0===e?(e,r)=>r?k(t,e,r):T(t,e):void 0===r?r=>T(t,e,r):k(t,e,r)}function R(t,e){return void 0===e?e=>R(t,e):e[Symbol.asyncIterator]?async function*(t,e){let r=0;for await(const n of e)if(yield await n,r++,r>=t)break}(t,e):function*(t,e){let r=0;for(const n of e)if(yield n,r++,r>=t)break}(t,e)}async function*C(t,e){for await(const r of e)await t(r),yield r}function B(t,e){return void 0===e?e=>C(t,e):C(t,e)}function M(t,e){let r=t[0]+e[0],n=t[1]+e[1];if(n>=1e9){const t=n%1e9;r+=(n-t)/1e9,n=t}return[r,n]}function x(t={},e){return void 0===e?e=>x(t,e):void 0!==e[Symbol.asyncIterator]?async function*(t,e){const r=e[Symbol.asyncIterator]();let n=[0,0];for(;;){const e=process.hrtime(),{value:i,done:s}=await r.next(),o=process.hrtime(e);if(n=M(n,o),t.progress&&t.progress(o,n),s)return t.total&&t.total(n),i;yield i}}(t,e):function*(t,e){const r=e[Symbol.iterator]();let n=[0,0];for(;;){const e=process.hrtime(),{value:i,done:s}=r.next(),o=process.hrtime(e);if(n=M(n,o),t.progress&&t.progress(o,n),s)return t.total&&t.total(n),i;yield i}}(t,e)}function N(t,e,r){const n=i(r),o=[],a=[];let c=!1,u=!1,h=0,f=null;function l(){for(;a.length>0&&o.length>0;){const{resolve:t}=a.shift();t({done:!1,value:o.shift()})}for(;a.length>0&&0===h&&c;){const{resolve:t,reject:e}=a.shift();f?(e(f),f=null):t({done:!0,value:void 0})}}async function d(){if(c)l();else if(!(u||h+o.length>=t)){u=!0,h++;try{const{done:t,value:r}=await n.next();t?(c=!0,h--,l()):async function(t){try{const r=await e(t);o.push(r)}catch(r){c=!0,f=r}h--,l(),d()}(r)}catch(r){c=!0,h--,f=r,l()}u=!1,d()}}const p={next:async function(){if(0===o.length){const t=s();return a.push(t),d(),t.promise}const t=o.shift();return d(),{done:!1,value:t}},[Symbol.asyncIterator]:()=>p};return p}function P(t,e,r){return void 0===e?(e,r)=>r?P(t,e,r):P(t,e):void 0===r?r=>P(t,e,r):N(t,e,r)}async function O(t,e){let r=null,n=null,i=null;const s=t=>{r=t,n&&n(t)},o=()=>{i&&i()};t.once("error",s);for await(const a of e)if(!1===t.write(a)&&await new Promise((e,s)=>{if(r)return s(r);t.once("drain",o),i=e,n=s}),r)break;if(t.removeListener("error",s),t.removeListener("drain",o),r)throw r}function D(t,e){return void 0===e?e=>O(t,e):O(t,e)}r.r(e),r.d(e,"batch",(function(){return n})),r.d(e,"buffer",(function(){return a})),r.d(e,"collect",(function(){return c})),r.d(e,"concat",(function(){return u})),r.d(e,"consume",(function(){return h})),r.d(e,"filter",(function(){return l})),r.d(e,"flatMap",(function(){return g})),r.d(e,"flatTransform",(function(){return m})),r.d(e,"flatten",(function(){return d})),r.d(e,"fromStream",(function(){return w})),r.d(e,"getIterator",(function(){return i})),r.d(e,"map",(function(){return y})),r.d(e,"merge",(function(){return _})),r.d(e,"parallelFlatMap",(function(){return I})),r.d(e,"parallelMap",(function(){return S})),r.d(e,"parallelMerge",(function(){return A})),r.d(e,"pipeline",(function(){return E})),r.d(e,"reduce",(function(){return T})),r.d(e,"take",(function(){return R})),r.d(e,"tap",(function(){return B})),r.d(e,"time",(function(){return x})),r.d(e,"transform",(function(){return P})),r.d(e,"writeToStream",(function(){return D}))},function(t,e,r){"use strict";var n=r(115),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var s=Object.create(r(89));s.inherits=r(23);var o=r(264),a=r(164);s.inherits(f,o);for(var c=i(a.prototype),u=0;u0)},n.Buffer=function(){try{var t=n.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(e){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(t){return"number"==typeof t?n.Buffer?n._Buffer_allocUnsafe(t):new n.Array(t):n.Buffer?n._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},n.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(t){return t?n.LongBits.from(t).toHash():n.LongBits.zeroHash},n.longFromHash=function(t,e){var r=n.LongBits.fromHash(t);return n.Long?n.Long.fromBits(r.lo,r.hi,e):r.toNumber(Boolean(e))},n.merge=i,n.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},n.newError=s,n.ProtocolError=s("ProtocolError"),n.oneOfGetter=function(t){for(var e={},r=0;r-1;--r)if(1===e[t[r]]&&void 0!==this[t[r]]&&null!==this[t[r]])return t[r]}},n.oneOfSetter=function(t){return function(e){for(var r=0;rs((async function(r,s){let a,c;s=s||{};try{a=function(t,e){if("string"==typeof t)return"base58"!==e&&e?o(t,e):t;if(t instanceof Uint8Array)return t;if(n.isCID(t))return t.bytes;throw new Error("unsupported multihash")}(r,s.enc)}catch(u){throw i(u,"ERR_INVALID_MULTIHASH")}try{c=new n(a)}catch(u){throw i(u,"ERR_INVALID_CID")}return 1===s.cidVersion&&(c=c.toV1()),!1!==s.preload&&e(c),t.get(c,{signal:s.signal})}))},function(t,e,r){"use strict";var n=r(8);t.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},function(t,e,r){"use strict";const n=r(17),i=R("dns4"),s=R("dns6"),o=T(R("dns"),R("dnsaddr"),i,s),a=T(R("ip4"),R("ip6")),c=T(k(a,R("tcp")),k(o,R("tcp"))),u=k(a,R("udp")),h=k(u,R("utp")),f=T(k(c,R("ws")),k(o,R("ws"))),l=T(k(c,R("wss")),k(o,R("wss"))),d=T(k(c,R("http")),k(a,R("http")),k(o,R("http"))),p=T(k(c,R("https")),k(a,R("https")),k(o,R("https"))),y=T(k(f,R("p2p-webrtc-star"),R("p2p")),k(l,R("p2p-webrtc-star"),R("p2p")),k(f,R("p2p-webrtc-star")),k(l,R("p2p-webrtc-star"))),g=T(k(f,R("p2p-websocket-star"),R("p2p")),k(l,R("p2p-websocket-star"),R("p2p")),k(f,R("p2p-websocket-star")),k(l,R("p2p-websocket-star"))),b=T(k(d,R("p2p-webrtc-direct")),k(p,R("p2p-webrtc-direct"))),m=T(f,l,d,p,y,b,c,h),v=T(k(m,R("p2p-stardust"),R("p2p")),k(m,R("p2p-stardust"))),w=T(k(m,R("p2p")),y,R("p2p")),_=T(k(w,R("p2p-circuit"),w),k(w,R("p2p-circuit")),k(R("p2p-circuit"),w),k(m,R("p2p-circuit")),k(R("p2p-circuit"),m),R("p2p-circuit")),E=()=>T(k(_,E),_),S=E(),I=T(k(S,w,S),k(w,S),k(S,w),S,w);function A(t){return function(e){if(!n.isMultiaddr(e))try{e=n(e)}catch(i){return!1}const r=t(e.protoNames());return null!==r&&0===r.length}}function k(){const t=Array.from(arguments);function e(e){return e.length{if(null===(e="function"==typeof t?t().partialMatch(e):t.partialMatch(e)))return!0}),e)}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:A(e),partialMatch:e}}function T(){const t=Array.from(arguments);function e(e){let r=null;return t.some(t=>{const n="function"==typeof t?t().partialMatch(e):t.partialMatch(e);if(n)return r=n,!0}),r}const r={toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:A(e),partialMatch:e};return r}function R(t){const e=t;return{toString:function(){return e},matches:function(t){if("string"==typeof t)try{t=n(t)}catch(i){return!1}const r=t.protoNames();return 1===r.length&&r[0]===e},partialMatch:function(t){return 0===t.length?null:t[0]===e?t.slice(1):null}}}e.DNS=o,e.DNS4=i,e.DNS6=s,e.IP=a,e.TCP=c,e.UDP=u,e.UTP=h,e.HTTP=d,e.HTTPS=p,e.WebSockets=f,e.WebSocketsSecure=l,e.WebSocketStar=g,e.WebRTCStar=y,e.WebRTCDirect=b,e.Reliable=m,e.Stardust=v,e.Circuit=S,e.P2P=I,e.IPFS=I},function(t,e,r){"use strict";const n=r(13),i=r(4);t.exports=async(t,e,r)=>{r.codec||(r.codec="dag-pb"),r.cidVersion||(r.cidVersion=0),r.hashAlg||(r.hashAlg="sha2-256"),"sha2-256"!==r.hashAlg&&(r.cidVersion=1);const s=await n(t,r.hashAlg),o=new i(r.cidVersion,r.codec,s);return r.onlyHash||await e.put(t,{...r,cid:o}),o}},function(t,e,r){"use strict";const n=r(4),i=r(27),s=r(6);t.exports=i(class{constructor(t,e,r){if(!r)throw new Error("A link requires a cid to point to");Object.defineProperties(this,{Name:{value:t||"",writable:!1,enumerable:!0},Tsize:{value:e,writable:!1,enumerable:!0},Hash:{value:new n(r),writable:!1,enumerable:!0},_nameBuf:{value:null,writable:!0,enumerable:!1}})}toString(){return`DAGLink <${this.Hash.toBaseEncodedString()} - name: "${this.Name}", size: ${this.Tsize}>`}toJSON(){return this._json||(this._json=Object.freeze({name:this.Name,size:this.Tsize,cid:this.Hash.toBaseEncodedString()})),Object.assign({},this._json)}get nameAsBuffer(){return null!==this._nameBuf||(this._nameBuf=s(this.Name)),this._nameBuf}},{className:"DAGLink",symbolName:"@ipld/js-ipld-dag-pb/daglink"})},function(t,e,r){"use strict";t.exports=i;var n=r(14).EventEmitter;function i(){n.call(this)}r(23)(i,n),i.Readable=r(162),i.Writable=r(565),i.Duplex=r(566),i.Transform=r(567),i.PassThrough=r(568),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",s),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",c));var o=!1;function a(){o||(o=!0,t.end())}function c(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function u(t){if(h(),0===n.listenerCount(this,"error"))throw t}function h(){r.removeListener("data",i),t.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",c),r.removeListener("error",u),t.removeListener("error",u),r.removeListener("end",h),r.removeListener("close",h),t.removeListener("close",h)}return r.on("error",u),t.on("error",u),r.on("end",h),r.on("close",h),t.on("close",h),t.emit("pipe",r),t}},function(t,e,r){"use strict";(function(t){var n=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n=s)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}})),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),h(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&S(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return b(i)||(i=h(t,i,n)),i}var s=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(b(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(g(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(y(e))return t.stylize("null","null")}(t,r);if(s)return s;var o=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),E(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(r);if(0===o.length){if(S(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return t.stylize(Date.prototype.toString.call(r),"date");if(E(r))return f(r)}var u,w="",I=!1,A=["{","}"];(d(r)&&(I=!0,A=["[","]"]),S(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(w=" "+RegExp.prototype.toString.call(r)),_(r)&&(w=" "+Date.prototype.toUTCString.call(r)),E(r)&&(w=" "+f(r)),0!==o.length||I&&0!=r.length?n<0?v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),u=I?function(t,e,r,n,i){for(var s=[],o=0,a=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,s){var o,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),R(n,i)||(o="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=y(r)?h(t,c.value,null):h(t,c.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(o)){if(s&&i.match(/^\d+$/))return a;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return"number"==typeof t}function b(t){return"string"==typeof t}function m(t){return void 0===t}function v(t){return w(t)&&"[object RegExp]"===I(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===I(t)}function E(t){return w(t)&&("[object Error]"===I(t)||t instanceof Error)}function S(t){return"function"==typeof t}function I(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(m(s)&&(s={NODE_ENV:"production"}.NODE_DEBUG||""),r=r.toUpperCase(),!o[r])if(new RegExp("\\b"+r+"\\b","i").test(s)){var n=t.pid;o[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,n,t)}}else o[r]=function(){};return o[r]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=p,e.isNull=y,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=b,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=v,e.isObject=w,e.isDate=_,e.isError=E,e.isFunction=S,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(569);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),k[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",T(),e.format.apply(e,arguments))},e.inherits=r(570),e._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var C="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function B(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(C&&t[C]){var e;if("function"!=typeof(e=t[C]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,C,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],s=0;st.decode(e),e.utf8.checksUTF8=!0}else e.utf8=t=>t.toString("utf8"),e.utf8.checksUTF8=!1;e.parseCBORint=function(t,e){switch(t){case o.ONE:return e.readUInt8(0);case o.TWO:return e.readUInt16BE(0);case o.FOUR:return e.readUInt32BE(0);case o.EIGHT:const r=e.readUInt32BE(0),n=e.readUInt32BE(4);return r>2097151?new i(r).times(a).plus(n):r*a+n;default:throw new Error("Invalid additional info for int: "+t)}},e.writeHalf=function(e,r){const n=t.allocUnsafe(4);n.writeFloatBE(r,0);const i=n.readUInt32BE(0);if(0!=(8191&i))return!1;let s=i>>16&32768;const o=i>>23&255,a=8388607&i;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else{if(!(o>=103&&o<113))return!1;if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}return e.writeUInt16BE(s),!0},e.parseHalf=function(t){const e=128&t[0]?-1:1,r=(124&t[0])>>2,n=(3&t[0])<<8|t[1];return r?31===r?e*(n?NaN:Infinity):e*Math.pow(2,r-25)*(1024+n):5.960464477539063e-8*e*n},e.parseCBORfloat=function(t){switch(t.length){case 2:return e.parseHalf(t);case 4:return t.readFloatBE(0);case 8:return t.readDoubleBE(0);default:throw new Error("Invalid float size: "+t.length)}},e.hex=function(e){return t.from(e.replace(/^0x/,""),"hex")},e.bin=function(e){let r=0,n=(e=e.replace(/\s/g,"")).length%8||8;const i=[];for(;n<=e.length;)i.push(parseInt(e.slice(r,n),2)),r=n,n+=8;return t.from(i)},e.extend=function(t={},...e){const r=e.length;for(let n=0;nt===e[r]))},e.bufferEqual=function(e,r){if(null==e&&null==r)return!0;if(null==e||null==r)return!1;if(!t.isBuffer(e)||!t.isBuffer(r)||e.length!==r.length)return!1;const n=e.length;let i,s,o=!0;for(i=s=0;s{const r=await f(t,e.parent.Links.map(t=>({name:t.Name,size:t.Tsize,cid:t.Hash})).concat({name:e.name,size:e.size,cid:e.cid}),e);return o("Converted directory to sharded directory "+r.cid),r},v=async(t,e)=>{e.parent.rmLink(e.name),e.parent.addLink(new n(e.name,e.size,e.cid));const r=a.unmarshal(e.parent.Data);r.mtime&&(r.mtime=new Date,e.parent=new i(r.marshal(),e.parent.Links));const s=g.names[e.hashAlg],o=await t.ipld.put(e.parent,y.DAG_PB,{cidVersion:e.cidVersion,hashAlg:s,onlyHash:!e.flush});return{node:e.parent,cid:o,size:e.parent.size}},w=async(t,e)=>{const{shard:r,path:n}=await _(t,e),i=await b(r.flush("",t.block)),s=await t.ipld.get(i.cid),o=e.parent.Links.find(t=>t.Name.substring(0,2)===n[0].prefix),a=s.Links.find(t=>t.Name.substring(0,2)===n[0].prefix);return o&&e.parent.rmLink(o.Name),e.parent.addLink(a),u(t,e.parent.Links,n[0].bucket,e)},_=async(t,e)=>{const r={name:e.name,cid:e.cid,size:e.size},n=await h(e.parent.Links),i=a.unmarshal(e.parent.Data),s=new c({root:!0,dir:!0,parent:null,parentKey:null,path:"",dirty:!0,flat:!1,mode:i.mode},e);s._bucket=n,i.mtime&&(s.mtime=new Date);const u=await n._findNewBucketAndPos(r.name),f=E(u);f[0].node=e.parent;let p=0;for(;pt.Name.substring(0,2)===e.prefix);if(!i){o(`Link ${e.prefix}${r.name} will be added`),p=f.length;break}if(i.Name===`${e.prefix}${r.name}`){o(`Link ${e.prefix}${r.name} will be replaced`),p=f.length;break}if(i.Name.length>2){o(`Link ${i.Name} ${i.Hash} will be replaced with a subshard`),p=f.length;break}o("Found subshard "+e.prefix);const s=await t.ipld.get(i.Hash);if(!f[p]){o("Loaded new subshard "+e.prefix),await h(s.Links,n,e.bucket,parseInt(e.prefix,16));const t=await n._findNewBucketAndPos(r.name);f.push({bucket:t.bucket,prefix:l(t.pos),node:s});break}const a=f[p];await d(s.Links,a.bucket,n),a.node=s}return await s._bucket.put(r.name,{size:r.size,cid:r.cid}),{shard:s,path:f}},E=t=>{let e=t.bucket,r=t.pos;const n=[{bucket:e,prefix:l(r)}];for(e=t.bucket._parent,r=t.bucket._posAtParent;e;)n.push({bucket:e,prefix:l(r)}),r=e._posAtParent,e=e._parent;return n.reverse(),n};t.exports=async(t,e)=>{if(!e.parentCid&&!e.parent)throw p(new Error("No parent node or CID passed to addLink"),"EINVALIDPARENT");if(e.parentCid&&!s.isCID(e.parentCid))throw p(new Error("Invalid CID passed to addLink"),"EINVALIDPARENTCID");if(e.parent||(o("Loading parent node "+e.parentCid),e.parent=await t.ipld.get(e.parentCid)),!e.cid)throw p(new Error("No child cid passed to addLink"),"EINVALIDCHILDCID");if(!e.name)throw p(new Error("No child name passed to addLink"),"EINVALIDCHILDNAME");if(s.isCID(e.cid)||(e.cid=new s(e.cid)),!e.size&&0!==e.size)throw p(new Error("No child size passed to addLink"),"EINVALIDCHILDSIZE");const r=a.unmarshal(e.parent.Data);return"hamt-sharded-directory"===r.type?(o("Adding link to sharded directory"),w(t,e)):e.parent.Links.length>=e.shardSplitThreshold?(o("Converting directory to sharded directory"),m(t,{...e,mtime:r.mtime,mode:r.mode})):(o(`Adding ${e.name} (${e.cid}) to regular directory`),v(t,e))}},function(t,e,r){"use strict";const n=r(1)("ipfs:mfs:utils:update-tree"),i=r(67),s={shardSplitThreshold:1e3};t.exports=async(t,e,r)=>{r=Object.assign({},s,r),n("Trail",e),e=e.slice().reverse();let o,a=0;for await(const n of t.ipld.getMany(e.map(t=>t.cid))){const s=e[a].cid,c=e[a].name;if(a++,!o){o={cid:s,name:c,size:n.size};continue}const u=await i(t,{parent:n,name:o.name,cid:o.cid,size:o.size,flush:r.flush,shardSplitThreshold:r.shardSplitThreshold,hashAlg:r.hashAlg,cidVersion:r.cidVersion});o={cid:u.cid,name:c,size:u.size}}return n("Final CID "+o.cid),o.cid}},function(t,e,r){"use strict";const n=r(1)("ipfs:mfs:utils:update-mfs-root"),{MFS_ROOT_KEY:i}=r(2),s=r(0);t.exports=async(t,e,r)=>{if(r&&r.signal&&r.signal.aborted)throw s(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});return n("New MFS root will be "+e),await t.repo.datastore.put(i,e.bytes),e}},function(t,e,r){"use strict";t.exports=function(){for(var t={},e=0;e2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(t,e,r){var n,i,o,a;if("string"==typeof e&&(i="not ",e.substr(!o||o<0?0:+o,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(s(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(c," ").concat(n," ").concat(s(e,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},function(t,e,r){"use strict";(function(e){var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=u;var i=r(298),s=r(302);r(23)(u,i);for(var o=n(s.prototype),a=0;a1?{type:d[i],data:t.substring(1)}:{type:d[i]}:p}i=new Uint8Array(t)[0];var s=o(t,1);return y&&"blob"===r&&(s=new y([s])),{type:d[i],data:s}},e.decodeBase64Packet=function(t,e){var r=d[t.charAt(0)];if(!n)return{type:r,data:{base64:!0,data:t.substr(1)}};var i=n.decode(t.substr(1));return"blob"===e&&y&&(i=new y([i])),{type:r,data:i}},e.encodePayload=function(t,r,n){"function"==typeof r&&(n=r,r=null);var i=s(t);if(r&&i)return y&&!f?e.encodePayloadAsBlob(t,n):e.encodePayloadAsArrayBuffer(t,n);if(!t.length)return n("0:");g(t,(function(t,n){e.encodePacket(t,!!i&&r,!1,(function(t){n(null,function(t){return t.length+":"+t}(t))}))}),(function(t,e){return n(e.join(""))}))},e.decodePayload=function(t,r,n){if("string"!=typeof t)return e.decodePayloadAsBinary(t,r,n);var i;if("function"==typeof r&&(n=r,r=null),""===t)return n(p,0,1);for(var s,o,a="",c=0,u=t.length;c0;){for(var a=new Uint8Array(i),c=0===a[0],u="",h=1;255!==a[h];h++){if(u.length>310)return n(p,0,1);u+=a[h]}i=o(i,2+u.length),u=parseInt(u);var f=o(i,0,u);if(c)try{f=String.fromCharCode.apply(null,new Uint8Array(f))}catch(y){var l=new Uint8Array(f);f="";for(h=0;h({encode:o,decode:a}),""],["base2","0",s(1),"01"],["base8","7",s(3),"01234567"],["base10","9",n,"0123456789"],["base16","f",s(4),"0123456789abcdef"],["base16upper","F",s(4),"0123456789ABCDEF"],["base32hex","v",s(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",s(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",s(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",s(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",s(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",s(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",s(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",s(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",s(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",n,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",n,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",n,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",n,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],u=c.reduce((t,e)=>(t[e[0]]=new i(e[0],e[1],e[2],e[3]),t),{}),h=c.reduce((t,e)=>(t[e[1]]=u[e[0]],t),{});t.exports={names:u,codes:h}},function(t,e,r){"use strict";e.TextEncoder=TextEncoder,e.TextDecoder=TextDecoder},function(t){t.exports=JSON.parse('{"identity":0,"ip4":4,"tcp":6,"sha1":17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,"blake3":30,"dccp":33,"murmur3-128":34,"murmur3-32":35,"ip6":41,"ip6zone":42,"path":47,"multicodec":48,"multihash":49,"multiaddr":50,"multibase":51,"dns":53,"dns4":54,"dns6":55,"dnsaddr":56,"protobuf":80,"cbor":81,"raw":85,"dbl-sha2-256":86,"rlp":96,"bencode":99,"dag-pb":112,"dag-cbor":113,"libp2p-key":114,"git-raw":120,"torrent-info":123,"torrent-file":124,"leofcoin-block":129,"leofcoin-tx":130,"leofcoin-pr":131,"sctp":132,"dag-jose":133,"dag-cose":134,"eth-block":144,"eth-block-list":145,"eth-tx-trie":146,"eth-tx":147,"eth-tx-receipt-trie":148,"eth-tx-receipt":149,"eth-state-trie":150,"eth-account-snapshot":151,"eth-storage-trie":152,"bitcoin-block":176,"bitcoin-tx":177,"bitcoin-witness-commitment":178,"zcash-block":192,"zcash-tx":193,"stellar-block":208,"stellar-tx":209,"md4":212,"md5":213,"bmt":214,"decred-block":224,"decred-tx":225,"ipld-ns":226,"ipfs-ns":227,"swarm-ns":228,"ipns-ns":229,"zeronet":230,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"x25519-pub":236,"ed25519-pub":237,"dash-block":240,"dash-tx":241,"swarm-manifest":250,"swarm-feed":251,"udp":273,"p2p-webrtc-star":275,"p2p-webrtc-direct":276,"p2p-stardust":277,"p2p-circuit":290,"dag-json":297,"udt":301,"utp":302,"unix":400,"p2p":421,"ipfs":421,"https":443,"onion":444,"onion3":445,"garlic64":446,"garlic32":447,"tls":448,"quic":460,"ws":477,"wss":478,"p2p-websocket-star":479,"http":480,"json":512,"messagepack":513,"libp2p-peer-record":769,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,"x11":4352,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46000,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082,"zeroxcert-imprint-256":52753,"fil-commitment-unsealed":61697,"fil-commitment-sealed":61698,"holochain-adr-v0":8417572,"holochain-adr-v1":8483108,"holochain-key-v0":9728292,"holochain-key-v1":9793828,"holochain-sig-v0":10645796,"holochain-sig-v1":10711332}')},function(t,e,r){"use strict";var n=r(8);r(22),r(138);var i=t.exports=n.asn1=n.asn1||{};function s(t,e,r){if(r>e){var n=new Error("Too few bytes to parse DER.");throw n.available=t.length(),n.remaining=e,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(t,e,r,s,o){if(n.util.isArray(s)){for(var a=[],c=0;cr){if(o.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=r,p.requested=d,p}d=r}var y=32==(32&c);if(y)if(f=[],void 0===d)for(;;){if(s(e,r,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),r-=2;break}a=e.length(),f.push(t(e,r,n+1,o)),r-=a-e.length()}else for(;d>0;)a=e.length(),f.push(t(e,d,n+1,o)),r-=a-e.length(),d-=a-e.length();void 0===f&&u===i.Class.UNIVERSAL&&h===i.Type.BITSTRING&&(l=e.bytes(d));if(void 0===f&&o.decodeBitStrings&&u===i.Class.UNIVERSAL&&h===i.Type.BITSTRING&&d>1){var g=e.read,b=r,m=0;if(h===i.Type.BITSTRING&&(s(e,r,1),m=e.getByte(),r--),0===m)try{a=e.length();var v={verbose:o.verbose,strict:!0,decodeBitStrings:!0},w=t(e,r,n+1,v),_=a-e.length();r-=_,h==i.Type.BITSTRING&&_++;var E=w.tagClass;_!==d||E!==i.Class.UNIVERSAL&&E!==i.Class.CONTEXT_SPECIFIC||(f=[w])}catch(I){}void 0===f&&(e.read=g,r=b)}if(void 0===f){if(void 0===d){if(o.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");d=r}if(h===i.Type.BMPSTRING)for(f="";d>0;d-=2)s(e,r,2),f+=String.fromCharCode(e.getInt16()),r-=2;else f=e.getBytes(d)}var S=void 0===l?null:{bitStringContents:l};return i.create(u,h,y,f,S)}(t,t.length(),0,e)},i.toDer=function(t){var e=n.util.createBuffer(),r=t.tagClass|t.type,s=n.util.createBuffer(),o=!1;if("bitStringContents"in t&&(o=!0,t.original&&(o=i.equals(t,t.original))),o)s.putBytes(t.bitStringContents);else if(t.composed){t.constructed?r|=32:s.putByte(0);for(var a=0;a1&&(0===t.value.charCodeAt(0)&&0==(128&t.value.charCodeAt(1))||255===t.value.charCodeAt(0)&&128==(128&t.value.charCodeAt(1)))?s.putBytes(t.value.substr(1)):s.putBytes(t.value);if(e.putByte(r),s.length()<=127)e.putByte(127&s.length());else{var c=s.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);e.putByte(128|u.length);for(a=u.length-1;a>=0;--a)e.putByte(u.charCodeAt(a))}return e.putBuffer(s),e},i.oidToDer=function(t){var e,r,i,s,o=t.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var c=2;c>>=7,e||(s|=128),r.push(s),e=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(t){var e;"string"==typeof t&&(t=n.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+"."+r%40;for(var i=0;t.length()>0;)i<<=7,128&(r=t.getByte())?i+=127&r:(e+="."+(i+r),i=0);return e},i.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(t.substr(2,2),10)-1,i=parseInt(t.substr(4,2),10),s=parseInt(t.substr(6,2),10),o=parseInt(t.substr(8,2),10),a=0;if(t.length>11){var c=t.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(t.substr(10,2),10),u+=2)}if(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,0),u&&("+"===(c=t.charAt(u))||"-"===c)){var h=60*parseInt(t.substr(u+1,2),10)+parseInt(t.substr(u+4,2),10);h*=6e4,"+"===c?e.setTime(+e-h):e.setTime(+e+h)}return e},i.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),n=parseInt(t.substr(4,2),10)-1,i=parseInt(t.substr(6,2),10),s=parseInt(t.substr(8,2),10),o=parseInt(t.substr(10,2),10),a=parseInt(t.substr(12,2),10),c=0,u=0,h=!1;"Z"===t.charAt(t.length-1)&&(h=!0);var f=t.length-5,l=t.charAt(f);"+"!==l&&"-"!==l||(u=60*parseInt(t.substr(f+1,2),10)+parseInt(t.substr(f+4,2),10),u*=6e4,"+"===l&&(u*=-1),h=!0);return"."===t.charAt(14)&&(c=1e3*parseFloat(t.substr(14),10)),h?(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,c),e.setTime(+e+u)):(e.setFullYear(r,n,i),e.setHours(s,o,a,c)),e},i.dateToUtcTime=function(t){if("string"==typeof t)return t;var e="",r=[];r.push((""+t.getUTCFullYear()).substr(2)),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=t,r},i.derToInteger=function(t){"string"==typeof t&&(t=n.util.createBuffer(t));var e=8*t.length();if(e>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(e)},i.validate=function(t,e,r,s){var o=!1;if(t.tagClass!==e.tagClass&&void 0!==e.tagClass||t.type!==e.type&&void 0!==e.type)s&&(t.tagClass!==e.tagClass&&s.push("["+e.name+'] Expected tag class "'+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&s.push("["+e.name+'] Expected type "'+e.type+'", got "'+t.type+'"'));else if(t.constructed===e.constructed||void 0===e.constructed){if(o=!0,e.value&&n.util.isArray(e.value))for(var a=0,c=0;o&&c0&&(s+="\n");for(var a="",c=0;c1?s+="0x"+n.util.bytesToHex(t.value.slice(1)):s+="(none)",t.value.length>0){var l=t.value.charCodeAt(0);1==l?s+=" (1 unused bit shown)":l>1&&(s+=" ("+l+" unused bits shown)")}}else t.type===i.Type.OCTETSTRING?(o.test(t.value)||(s+="("+t.value+") "),s+="0x"+n.util.bytesToHex(t.value)):t.type===i.Type.UTF8?s+=n.util.decodeUtf8(t.value):t.type===i.Type.PRINTABLESTRING||t.type===i.Type.IA5String?s+=t.value:o.test(t.value)?s+="0x"+n.util.bytesToHex(t.value):0===t.value.length?s+="[null]":s+=t.value}return s}},function(t,e,r){"use strict";var n=r(8);r(139),r(440),r(441),r(22),n.random&&n.random.getBytes?t.exports=n.random:function(e){var r={},i=new Array(4),s=n.util.createBuffer();function o(){var t=n.prng.create(r);return t.getBytes=function(e,r){return t.generate(e,r)},t.getBytesSync=function(e){return t.generate(e)},t}r.formatKey=function(t){var e=n.util.createBuffer(t);return(t=new Array(4))[0]=e.getInt32(),t[1]=e.getInt32(),t[2]=e.getInt32(),t[3]=e.getInt32(),n.aes._expandKey(t,!1)},r.formatSeed=function(t){var e=n.util.createBuffer(t);return(t=new Array(4))[0]=e.getInt32(),t[1]=e.getInt32(),t[2]=e.getInt32(),t[3]=e.getInt32(),t},r.cipher=function(t,e){return n.aes._updateBlock(t,e,i,!1),s.putInt32(i[0]),s.putInt32(i[1]),s.putInt32(i[2]),s.putInt32(i[3]),s.getBytes()},r.increment=function(t){return++t[3],t},r.md=n.md.sha256;var a=o(),c=null,u=n.util.globalScope,h=u.crypto||u.msCrypto;if(h&&h.getRandomValues&&(c=function(t){return h.getRandomValues(t)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"==typeof window||window.document,a.collectInt(+new Date,32),"undefined"!=typeof navigator){var f="";for(var l in navigator)try{"string"==typeof navigator[l]&&(f+=navigator[l])}catch(d){}a.collect(f),f=null}e&&(e().mousemove((function(t){a.collectInt(t.clientX,16),a.collectInt(t.clientY,16)})),e().keypress((function(t){a.collectInt(t.charCode,8)})))}if(n.random)for(var l in a)n.random[l]=a[l];else n.random=a;n.random.createInstance=o,t.exports=n.random}("undefined"!=typeof jQuery?jQuery:null)},function(t,e,r){"use strict";const n=r(49),i=self.crypto||self.msCrypto,s=async(t,e)=>{if("undefined"==typeof self||!self.crypto&&!self.msCrypto)throw new Error("Please use a browser with webcrypto support and ensure the code has been delivered securely via HTTPS/TLS and run within a Secure Context");switch(e){case"sha1":return new Uint8Array(await i.subtle.digest({name:"SHA-1"},t));case"sha2-256":return new Uint8Array(await i.subtle.digest({name:"SHA-256"},t));case"sha2-512":return new Uint8Array(await i.subtle.digest({name:"SHA-512"},t));case"dbl-sha2-256":{const e=await i.subtle.digest({name:"SHA-256"},t);return new Uint8Array(await i.subtle.digest({name:"SHA-256"},e))}default:throw new Error(e+" is not a supported algorithm")}};t.exports={factory:t=>async e=>s(e,t),digest:s,multihashing:async(t,e,r)=>{const i=await s(t,e);return n.encode(i,e,r)}}},function(t,e,r){"use strict";var n=r(38),i=r(50);function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=s,s.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,s=8;s{const e=[];for await(const r of t)e.push(r);return e}},function(t,e,r){"use strict";const n=r(4),i=r(27);t.exports=class{constructor(t,e){if(!(t&&t instanceof Uint8Array))throw new Error("first argument must be a Uint8Array");if(!e||!n.isCID(e))throw new Error("second argument must be a CID");this._data=t,this._cid=e}get data(){return this._data}set data(t){throw new Error("Tried to change an immutable block")}get cid(){return this._cid}set cid(t){throw new Error("Tried to change an immutable block")}static isBlock(t){}},t.exports=i(t.exports,{className:"Block",symbolName:"@ipld/js-ipld-block/block"})},function(t,e,r){"use strict";const n=r(4),i=r(0),s=r(551),o=r(1),a=r(153),c=r(86),u=r(263),h=r(31),f=r(19);const l=h.encoding("base32upper");function d(t){return"/"+l.encode(t.multihash)}function p(t){return l.decode(t.toString().slice(1))}const y={direct:"direct",recursive:"recursive",indirect:"indirect",all:"all"};class g{constructor(t,e){this.repo=t,this.dag=e,this.log=o("ipfs:pin"),this.directPins=new Set,this.recursivePins=new Set}async*_walkDag(t,{preload:e=!1}){const{value:r}=await this.dag.get(t,{preload:e});if("dag-pb"===t.codec)for(const n of r.Links)yield n.Hash,yield*this._walkDag(n.Hash,{preload:e});else if("dag-cbor"===t.codec)for(const[n,i]of s(r))yield i,yield*this._walkDag(i,{preload:e})}async pinDirectly(t,e={}){await this.dag.get(t,e);const r={depth:0};return 0!==t.version&&(r.version=t.version),"dag-pb"!==t.codec&&(r.codec=f.getNumber(t.codec)),e.metadata&&(r.metadata=e.metadata),this.repo.pins.put(d(t),u.encode(r))}async unpin(t){return this.repo.pins.delete(d(t))}async pinRecursively(t,e={}){await this.fetchCompleteDag(t,e);const r={depth:1/0};0!==t.version&&(r.version=t.version),"dag-pb"!==t.codec&&(r.codec=f.getNumber(t.codec)),e.metadata&&(r.metadata=e.metadata),await this.repo.pins.put(d(t),u.encode(r))}async*directKeys(){for await(const t of this.repo.pins.query({filters:[t=>0===u.decode(t.value).depth]})){const e=u.decode(t.value),r=e.version||0,i=e.codec?f.getName(e.codec):"dag-pb",s=p(t.key);yield{cid:new n(r,i,s),metadata:e.metadata}}}async*recursiveKeys(){for await(const t of this.repo.pins.query({filters:[t=>u.decode(t.value).depth===1/0]})){const e=u.decode(t.value),r=e.version||0,i=e.codec?f.getName(e.codec):"dag-pb",s=p(t.key);yield{cid:new n(r,i,s),metadata:e.metadata}}}async*indirectKeys({preload:t}){for await(const{cid:e}of this.recursiveKeys())for await(const r of this._walkDag(e,{preload:t})){const t=[y.recursive];(await this.isPinnedWithType(r,t)).pinned||(yield r)}}async isPinnedWithType(t,e){Array.isArray(e)||(e=[e]);const r=e.includes(y.all),n=e.includes(y.direct),i=e.includes(y.recursive),s=e.includes(y.indirect);if(i||n||r){const n=await a(this.repo.pins.query({prefix:d(t),filters:[t=>{if(r)return!0;const n=u.decode(t.value);return e.includes(0===n.depth?y.direct:y.recursive)}],limit:1}));if(n){const e=u.decode(n.value);return{cid:t,pinned:!0,reason:0===e.depth?y.direct:y.recursive,metadata:e.metadata}}}const o=this;if(r||s){const e=await a(async function*(t,e){for await(const{cid:r}of e)for await(const e of o._walkDag(r,{preload:!1}))if(e.equals(t))return void(yield r)}(t,this.recursiveKeys()));if(e)return{cid:t,pinned:!0,reason:y.indirect,parent:e}}return{cid:t,pinned:!1}}async fetchCompleteDag(t,e){await c(this._walkDag(t,{preload:e.preload}))}static checkPinType(t){if("string"!=typeof t||!Object.keys(y).includes(t))throw function(t){return i(new Error(`Invalid type '${t}', must be one of {direct, indirect, recursive, all}`),"ERR_INVALID_PIN_TYPE")}(t)}}g.PinTypes=y,t.exports=g},function(t,e,r){"use strict";(function(t){function r(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===r(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===r(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===r(t)},e.isError=function(t){return"[object Error]"===r(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,r(3).Buffer)},function(t,e,r){"use strict";const n=r(65),i=r(54),s=i.MT,o=i.SIMPLE,a=i.SYMS;class c{constructor(t){if("number"!=typeof t)throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(0|t)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}[n.inspect.custom](t,e){return"simple("+this.value+")"}inspect(t,e){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,s.SIMPLE_FLOAT)}static isSimple(t){return t instanceof c}static decode(t,e=!0,r=!1){switch(t){case o.FALSE:return!1;case o.TRUE:return!0;case o.NULL:return e?null:a.NULL;case o.UNDEFINED:return e?void 0:a.UNDEFINED;case-1:if(!e||!r)throw new Error("Invalid BREAK");return a.BREAK;default:return new c(t)}}}t.exports=c},function(t,e,r){"use strict";(function(e){const n=r(64),i=r(65);class s extends n.Transform{constructor(t,r,n){let i,s;switch(null==n&&(n={}),typeof t){case"object":e.isBuffer(t)?(i=t,null!=r&&"object"==typeof r&&(n=r)):n=t;break;case"string":i=t,null!=r&&"object"==typeof r?n=r:s=r}null==n&&(n={}),null==i&&(i=n.input),null==s&&(s=n.inputEncoding),delete n.input,delete n.inputEncoding;const o=null==n.watchPipe||n.watchPipe;delete n.watchPipe;const a=!!n.readError;delete n.readError,super(n),this.readError=a,o&&this.on("pipe",t=>{const e=t._readableState.objectMode;if(this.length>0&&e!==this._readableState.objectMode)throw new Error("Do not switch objectMode in the middle of the stream");return this._readableState.objectMode=e,this._writableState.objectMode=e}),null!=i&&this.end(i,s)}static isNoFilter(t){return t instanceof this}static compare(t,e){if(!(t instanceof this))throw new TypeError("Arguments must be NoFilters");return t===e?0:t.compare(e)}static concat(t,r){if(!Array.isArray(t))throw new TypeError("list argument must be an Array of NoFilters");if(0===t.length||0===r)return e.alloc(0);null==r&&(r=t.reduce((t,e)=>{if(!(e instanceof s))throw new TypeError("list argument must be an Array of NoFilters");return t+e.length},0));let n=!0,i=!0;const o=t.map(t=>{if(!(t instanceof s))throw new TypeError("list argument must be an Array of NoFilters");const r=t.slice();return e.isBuffer(r)?i=!1:n=!1,r});if(n)return e.concat(o,r);if(i)return[].concat(...o).slice(0,r);throw new Error("Concatenating mixed object and byte streams not supported")}_transform(t,r,n){this._readableState.objectMode||e.isBuffer(t)||(t=e.from(t,r)),this.push(t),n()}_bufArray(){let t=this._readableState.buffer;if(!Array.isArray(t)){let e=t.head;for(t=[];null!=e;)t.push(e.data),e=e.next}return t}read(t){const e=super.read(t);if(null!=e){if(this.emit("read",e),this.readError&&e.length{this.on("finish",()=>{const n=this.read();null==t||e||(e=!0,t(null,n)),r(n)}),this.on("error",r=>{null==t||e||(e=!0,t(r)),n(r)})})}compare(t){if(!(t instanceof s))throw new TypeError("Arguments must be NoFilters");if(this===t)return 0;{const r=this.slice(),n=t.slice();if(e.isBuffer(r)&&e.isBuffer(n))return r.compare(n);throw new Error("Cannot compare streams in object mode")}}equals(t){return 0===this.compare(t)}slice(t,r){if(this._readableState.objectMode)return this._bufArray().slice(t,r);const n=this._bufArray();switch(n.length){case 0:return e.alloc(0);case 1:return n[0].slice(t,r);default:return e.concat(n).slice(t,r)}}get(t){return this.slice()[t]}toJSON(){const t=this.slice();return e.isBuffer(t)?t.toJSON():t}toString(t,r,n){const s=this.slice(r,n);if(!e.isBuffer(s))return JSON.stringify(s);if((!t||"utf8"===t)&&i.TextDecoder){return new i.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(s)}return s.toString(t,r,n)}inspect(t,e){return this[i.inspect.custom](t,e)}[i.inspect.custom](t,r){const n=this._bufArray().map(t=>e.isBuffer(t)?(null!=r?r.stylize:void 0)?r.stylize(t.toString("hex"),"string"):t.toString("hex"):i.inspect(t,r)).join(", ");return`${this.constructor.name} [${n}]`}get length(){return this._readableState.length}writeBigInt(t){let r=t.toString(16);if(t<0){const e=BigInt(Math.floor(r.length/2));r=(t=(BigInt(1)<{},a=new i.TimeoutError;e.default=class extends n{constructor(t){var e,r,n,i;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=o,this._resolveIdle=o,!("number"==typeof(t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:s.default},t)).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==r?r:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(n=t.interval)||void 0===n?void 0:n.toString())&&void 0!==i?i:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||0===t.interval,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=!0===t.throwOnTimeout,this._isPaused=!1===t.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()},e)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother)return this.emit("active"),this._queue.dequeue()(),t&&this._initializeIntervalIfNeeded(),!0}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,e={}){return new Promise((r,n)=>{this._queue.enqueue(async()=>{this._pendingCount++,this._intervalCount++;try{const s=void 0===this._timeout&&void 0===e.timeout?t():i.default(Promise.resolve(t()),void 0===e.timeout?this._timeout:e.timeout,()=>{(void 0===e.throwOnTimeout?this._throwOnTimeout:e.throwOnTimeout)&&n(a)});r(await s)}catch(s){n(s)}this._next()},e),this._tryToStartAnother(),this.emit("add")})}async addAll(t,e){return Promise.all(t.map(async t=>this.add(t,e)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise(t=>{const e=this._resolveEmpty;this._resolveEmpty=()=>{e(),t()}})}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise(t=>{const e=this._resolveIdle;this._resolveIdle=()=>{e(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}}},function(t,e,r){"use strict";const n=r(39),i=r(1)("ipfs:mfs:utils:to-trail");t.exports=async(t,e)=>{i("Creating trail for path "+e);const r=[];for await(const i of n.path(e,t.ipld))r.push({name:i.name,cid:i.cid,size:i.node.size,type:i.unixfs?i.unixfs.type:void 0});return r}},function(t,e,r){"use strict";const n=r(293);t.exports=t=>{let e;"function"==typeof(t=t||{})?(e=t,t={}):e=t.onEnd;let r,i,s,o=new n;const a=t=>i?i(t):(o.push(t),r),c=t=>s?r:a({done:!1,value:t}),u=t=>s?r:(s=!0,t?(t=>(o=new n,i?i({error:t}):(o.push({error:t}),r)))(t):a({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:()=>{if(!o.isEmpty()){if(t.writev){let t;const e=[];for(;!o.isEmpty();){if(t=o.shift(),t.error)throw t.error;e.push(t.value)}return{done:t.done,value:e}}const e=o.shift();if(e.error)throw e.error;return e}return s?{done:!0}:new Promise((e,n)=>{i=s=>(i=null,s.error?n(s.error):t.writev&&!s.done?e({done:s.done,value:[s.value]}):e(s),r)})},return:()=>(o=new n,u(),{done:!0}),throw:t=>(u(t),{done:!0}),push:c,end:u},!e)return r;const h=r;return r={[Symbol.asyncIterator](){return this},next:()=>h.next(),throw:t=>(h.throw(t),e&&(e(t),e=null),{done:!0}),return:()=>(h.return(),e&&(e(),e=null),{done:!0}),push:c,end:t=>(h.end(t),e&&(e(t),e=null),r)},r}},function(t,e,r){"use strict";const{Key:n,Errors:i,Adapter:s,utils:{filter:o,map:a,take:c,sortAll:u}}=r(10);t.exports=class extends s{constructor(t,e){let n;super(),e&&e.db?(n=e.db,delete e.db):n=r(672),this.db=this._initDb(n,t,e)}_initDb(t,e,r){return t(e,{...r,valueEncoding:"binary",compression:!1})}async open(){try{await this.db.open()}catch(t){throw i.dbOpenFailedError(t)}}async put(t,e){try{await this.db.put(t.toString(),e)}catch(r){throw i.dbWriteFailedError(r)}}async get(t){let e;try{e=await this.db.get(t.toString())}catch(r){if(r.notFound)throw i.notFoundError(r);throw i.dbWriteFailedError(r)}return e}async has(t){try{await this.db.get(t.toString())}catch(e){if(e.notFound)return!1;throw e}return!0}async delete(t){try{await this.db.del(t.toString())}catch(e){throw i.dbDeleteFailedError(e)}}close(){return this.db.close()}batch(){const t=[];return{put:(e,r)=>{t.push({type:"put",key:e.toString(),value:r})},delete:e=>{t.push({type:"del",key:e.toString()})},commit:()=>this.db.batch(t)}}query(t){let e=!0;null!=t.keysOnly&&(e=!t.keysOnly);const r={keys:!0,values:e,keyAsBuffer:!0};if(null!=t.prefix){const e=t.prefix.toString();r.gte=e,r.lt=e+"ÿ"}let i=(s=this.db.iterator(r),{next:()=>new Promise((t,e)=>{s.next((r,n,i)=>r?e(r):null==n?s.end(r=>{if(r)return e(r);t({done:!0})}):void t({done:!1,value:{key:n,value:i}}))}),return:()=>new Promise((t,e)=>{s.end(r=>{if(r)return e(r);t({done:!0})})}),[Symbol.asyncIterator](){return this}});var s;if(i=a(i,({key:t,value:r})=>{const i={key:new n(t,!1)};return e&&(i.value=r),i}),Array.isArray(t.filters)&&(i=t.filters.reduce((t,e)=>o(t,e),i)),Array.isArray(t.orders)&&(i=t.orders.reduce((t,e)=>u(t,e),i)),null!=t.offset){let e=0;i=o(i,()=>e++>=t.offset)}return null!=t.limit&&(i=c(i,t.limit)),i}}},function(t,e,r){"use strict";const n=r(722),{Key:i}=r(10),s=r(37),o=r(7),a=r(49),c=r(0),u=r(31),h=r(6),f=r(5),l=r(26),d=r(1),p=d("jsipns");p.error=d("jsipns:error");const y=r(723),{parseRFC3339:g}=r(724),b=r(725),m=a.names.id,v=async(t,e,r,n,i)=>{const s=await S(t,e,i,n),o={value:h(e),signature:s,validityType:i,validity:h(n),sequence:r};return p(`ipns entry for ${e} created`),o},w=async(t,e)=>{const{value:r,validityType:n,validity:i}=e,s=I(r,n,i);let o;try{o=await t.verify(s,e.signature)}catch(a){o=!1}if(!o)throw p.error("record signature verification failed"),c(new Error("record signature verification failed"),b.ERR_SIGNATURE_VERIFICATION);if(n===y.ValidityType.EOL){let t;try{t=g(f(i))}catch(u){throw p.error("unrecognized validity format (not an rfc3339 format)"),c(new Error("unrecognized validity format (not an rfc3339 format)"),b.ERR_UNRECOGNIZED_FORMAT)}if(t{if(!e||!t){const t=new Error("one or more of the provided parameters are not defined");throw p.error(t),c(t,b.ERR_UNDEFINED_PARAMETER)}if(e.pubKey){let t;try{t=s.keys.unmarshalPublicKey(e.pubKey)}catch(r){throw p.error(r),r}return t}if(t.pubKey)return t.pubKey;throw Object.assign(new Error("no public key is available"),{code:b.ERR_UNDEFINED_PARAMETER})},E=t=>u.encode("base32",t).toString().slice(1).toUpperCase(),S=(t,e,r,n)=>{try{const i=I(e,r,n);return t.sign(i)}catch(i){throw p.error("record signature creation failed"),c(new Error("record signature creation failed: "+i.message),b.ERR_SIGNATURE_CREATION)}},I=(t,e,r)=>{t instanceof Uint8Array||(t=h(t)),r instanceof Uint8Array||(r=h(r));const n=h((t=>{if("0"===t.toString())return"EOL";const e=new Error("unrecognized validity type "+t.toString());throw p.error(e),c(e,b.ERR_UNRECOGNIZED_VALIDITY)})(e));return l([t,r,n])},A=t=>{const e=a.decode(t.id);return e.code!==m?null:s.keys.unmarshalPublicKey(e.digest)},k=y.encode,T=y.decode,R={validate:async(t,e)=>{const r=T(t),n=e.slice("/ipns/".length),i=o.createFromBytes(n),s=_(i,r);return await w(s,r),!0},select:(t,e)=>{const r=T(t),n=T(e);return r.sequence>n.sequence?0:1}};t.exports={create:(t,e,r,i)=>{const s=new n(Date.now()+Number(i)).toString(),o=y.ValidityType.EOL;return v(t,e,r,s,o)},createWithExpiration:(t,e,r,n)=>{const i=y.ValidityType.EOL;return v(t,e,r,n,i)},validate:w,embedPublicKey:async(t,e)=>{if(!t||!t.bytes||!e){const t=new Error("one or more of the provided parameters are not defined");throw p.error(t),c(t,b.ERR_UNDEFINED_PARAMETER)}let r,n;try{r=await o.createFromPubKey(t.bytes)}catch(i){throw c(i,b.ERR_PEER_ID_FROM_PUBLIC_KEY)}try{n=A(r)}catch(i){throw p.error(i),c(i,b.ERR_PUBLIC_KEY_FROM_ID)}if(n)return null;try{e.pubKey=s.keys.marshalPublicKey(t)}catch(i){throw p.error(i),i}return e},extractPublicKey:_,getLocalKey:t=>new i("/ipns/"+E(t)),getIdKeys:t=>{const e=h("/pk/"),r=h("/ipns/");return{routingPubKey:new i(l([e,t]),!1),pkKey:new i(E(l([e,t]))),routingKey:new i(l([r,t]),!1),ipnsKey:new i(E(l([r,t])))}},marshal:k,unmarshal:T,validator:R,namespace:"/ipns/",namespaceLength:"/ipns/".length}},function(t,e,r){"use strict";const n=r(21);t.exports=n("\nmessage CircuitRelay {\n\n enum Status {\n SUCCESS = 100;\n HOP_SRC_ADDR_TOO_LONG = 220;\n HOP_DST_ADDR_TOO_LONG = 221;\n HOP_SRC_MULTIADDR_INVALID = 250;\n HOP_DST_MULTIADDR_INVALID = 251;\n HOP_NO_CONN_TO_DST = 260;\n HOP_CANT_DIAL_DST = 261;\n HOP_CANT_OPEN_DST_STREAM = 262;\n HOP_CANT_SPEAK_RELAY = 270;\n HOP_CANT_RELAY_TO_SELF = 280;\n STOP_SRC_ADDR_TOO_LONG = 320;\n STOP_DST_ADDR_TOO_LONG = 321;\n STOP_SRC_MULTIADDR_INVALID = 350;\n STOP_DST_MULTIADDR_INVALID = 351;\n STOP_RELAY_REFUSED = 390;\n MALFORMED_MESSAGE = 400;\n }\n\n enum Type { // RPC identifier, either HOP, STOP or STATUS\n HOP = 1;\n STOP = 2;\n STATUS = 3;\n CAN_HOP = 4;\n }\n\n message Peer {\n required bytes id = 1; // peer id\n repeated bytes addrs = 2; // peer's known addresses\n }\n\n optional Type type = 1; // Type of the message\n\n optional Peer srcPeer = 2; // srcPeer and dstPeer are used when Type is HOP or STATUS\n optional Peer dstPeer = 3;\n\n optional Status code = 4; // Status code, used when Type is STATUS\n}\n")},function(t,e,r){"use strict";const n=r(330),i=r(94),s=r(99);t.exports=t=>{const e=i(),r=n(t.source),o=s();let a;const c=t.sink(async function*(){yield*e;const t=await o.promise;yield*t}());c.catch(t=>{a=t});return{reader:r,writer:e,stream:{sink:t=>a?Promise.reject(a):(o.resolve(t),c),source:r},rest:()=>e.end(),write:e.push,read:async()=>(await r.next()).value}}},function(t,e,r){"use strict";t.exports=()=>{const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}},function(t,e,r){"use strict";var n=r(9);r(18),r(101);var i=t.exports=n.asn1=n.asn1||{};function s(t,e,r){if(r>e){var n=new Error("Too few bytes to parse DER.");throw n.available=t.length(),n.remaining=e,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(t,e,r,s,o){if(n.util.isArray(s)){for(var a=[],c=0;cr){if(o.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=r,p.requested=d,p}d=r}var y=32==(32&c);if(y)if(f=[],void 0===d)for(;;){if(s(e,r,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),r-=2;break}a=e.length(),f.push(t(e,r,n+1,o)),r-=a-e.length()}else for(;d>0;)a=e.length(),f.push(t(e,d,n+1,o)),r-=a-e.length(),d-=a-e.length();void 0===f&&u===i.Class.UNIVERSAL&&h===i.Type.BITSTRING&&(l=e.bytes(d));if(void 0===f&&o.decodeBitStrings&&u===i.Class.UNIVERSAL&&h===i.Type.BITSTRING&&d>1){var g=e.read,b=r,m=0;if(h===i.Type.BITSTRING&&(s(e,r,1),m=e.getByte(),r--),0===m)try{a=e.length();var v={verbose:o.verbose,strict:!0,decodeBitStrings:!0},w=t(e,r,n+1,v),_=a-e.length();r-=_,h==i.Type.BITSTRING&&_++;var E=w.tagClass;_!==d||E!==i.Class.UNIVERSAL&&E!==i.Class.CONTEXT_SPECIFIC||(f=[w])}catch(I){}void 0===f&&(e.read=g,r=b)}if(void 0===f){if(void 0===d){if(o.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");d=r}if(h===i.Type.BMPSTRING)for(f="";d>0;d-=2)s(e,r,2),f+=String.fromCharCode(e.getInt16()),r-=2;else f=e.getBytes(d)}var S=void 0===l?null:{bitStringContents:l};return i.create(u,h,y,f,S)}(t,t.length(),0,e)},i.toDer=function(t){var e=n.util.createBuffer(),r=t.tagClass|t.type,s=n.util.createBuffer(),o=!1;if("bitStringContents"in t&&(o=!0,t.original&&(o=i.equals(t,t.original))),o)s.putBytes(t.bitStringContents);else if(t.composed){t.constructed?r|=32:s.putByte(0);for(var a=0;a1&&(0===t.value.charCodeAt(0)&&0==(128&t.value.charCodeAt(1))||255===t.value.charCodeAt(0)&&128==(128&t.value.charCodeAt(1)))?s.putBytes(t.value.substr(1)):s.putBytes(t.value);if(e.putByte(r),s.length()<=127)e.putByte(127&s.length());else{var c=s.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);e.putByte(128|u.length);for(a=u.length-1;a>=0;--a)e.putByte(u.charCodeAt(a))}return e.putBuffer(s),e},i.oidToDer=function(t){var e,r,i,s,o=t.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var c=2;c>>=7,e||(s|=128),r.push(s),e=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(t){var e;"string"==typeof t&&(t=n.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+"."+r%40;for(var i=0;t.length()>0;)i<<=7,128&(r=t.getByte())?i+=127&r:(e+="."+(i+r),i=0);return e},i.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(t.substr(2,2),10)-1,i=parseInt(t.substr(4,2),10),s=parseInt(t.substr(6,2),10),o=parseInt(t.substr(8,2),10),a=0;if(t.length>11){var c=t.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(t.substr(10,2),10),u+=2)}if(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,0),u&&("+"===(c=t.charAt(u))||"-"===c)){var h=60*parseInt(t.substr(u+1,2),10)+parseInt(t.substr(u+4,2),10);h*=6e4,"+"===c?e.setTime(+e-h):e.setTime(+e+h)}return e},i.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),n=parseInt(t.substr(4,2),10)-1,i=parseInt(t.substr(6,2),10),s=parseInt(t.substr(8,2),10),o=parseInt(t.substr(10,2),10),a=parseInt(t.substr(12,2),10),c=0,u=0,h=!1;"Z"===t.charAt(t.length-1)&&(h=!0);var f=t.length-5,l=t.charAt(f);"+"!==l&&"-"!==l||(u=60*parseInt(t.substr(f+1,2),10)+parseInt(t.substr(f+4,2),10),u*=6e4,"+"===l&&(u*=-1),h=!0);return"."===t.charAt(14)&&(c=1e3*parseFloat(t.substr(14),10)),h?(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,c),e.setTime(+e+u)):(e.setFullYear(r,n,i),e.setHours(s,o,a,c)),e},i.dateToUtcTime=function(t){if("string"==typeof t)return t;var e="",r=[];r.push((""+t.getUTCFullYear()).substr(2)),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=t,r},i.derToInteger=function(t){"string"==typeof t&&(t=n.util.createBuffer(t));var e=8*t.length();if(e>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(e)},i.validate=function(t,e,r,s){var o=!1;if(t.tagClass!==e.tagClass&&void 0!==e.tagClass||t.type!==e.type&&void 0!==e.type)s&&(t.tagClass!==e.tagClass&&s.push("["+e.name+'] Expected tag class "'+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&s.push("["+e.name+'] Expected type "'+e.type+'", got "'+t.type+'"'));else if(t.constructed===e.constructed||void 0===e.constructed){if(o=!0,e.value&&n.util.isArray(e.value))for(var a=0,c=0;o&&c0&&(s+="\n");for(var a="",c=0;c1?s+="0x"+n.util.bytesToHex(t.value.slice(1)):s+="(none)",t.value.length>0){var l=t.value.charCodeAt(0);1==l?s+=" (1 unused bit shown)":l>1&&(s+=" ("+l+" unused bits shown)")}}else t.type===i.Type.OCTETSTRING?(o.test(t.value)||(s+="("+t.value+") "),s+="0x"+n.util.bytesToHex(t.value)):t.type===i.Type.UTF8?s+=n.util.decodeUtf8(t.value):t.type===i.Type.PRINTABLESTRING||t.type===i.Type.IA5String?s+=t.value:o.test(t.value)?s+="0x"+n.util.bytesToHex(t.value):0===t.value.length?s+="[null]":s+=t.value}return s}},function(t,e,r){"use strict";var n=r(9);n.pki=n.pki||{};var i=t.exports=n.pki.oids=n.oids=n.oids||{};function s(t,e){i[t]=e,i[e]=t}function o(t,e){i[t]=e}s("1.2.840.113549.1.1.1","rsaEncryption"),s("1.2.840.113549.1.1.4","md5WithRSAEncryption"),s("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),s("1.2.840.113549.1.1.7","RSAES-OAEP"),s("1.2.840.113549.1.1.8","mgf1"),s("1.2.840.113549.1.1.9","pSpecified"),s("1.2.840.113549.1.1.10","RSASSA-PSS"),s("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),s("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),s("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),s("1.3.101.112","EdDSA25519"),s("1.2.840.10040.4.3","dsa-with-sha1"),s("1.3.14.3.2.7","desCBC"),s("1.3.14.3.2.26","sha1"),s("2.16.840.1.101.3.4.2.1","sha256"),s("2.16.840.1.101.3.4.2.2","sha384"),s("2.16.840.1.101.3.4.2.3","sha512"),s("1.2.840.113549.2.5","md5"),s("1.2.840.113549.1.7.1","data"),s("1.2.840.113549.1.7.2","signedData"),s("1.2.840.113549.1.7.3","envelopedData"),s("1.2.840.113549.1.7.4","signedAndEnvelopedData"),s("1.2.840.113549.1.7.5","digestedData"),s("1.2.840.113549.1.7.6","encryptedData"),s("1.2.840.113549.1.9.1","emailAddress"),s("1.2.840.113549.1.9.2","unstructuredName"),s("1.2.840.113549.1.9.3","contentType"),s("1.2.840.113549.1.9.4","messageDigest"),s("1.2.840.113549.1.9.5","signingTime"),s("1.2.840.113549.1.9.6","counterSignature"),s("1.2.840.113549.1.9.7","challengePassword"),s("1.2.840.113549.1.9.8","unstructuredAddress"),s("1.2.840.113549.1.9.14","extensionRequest"),s("1.2.840.113549.1.9.20","friendlyName"),s("1.2.840.113549.1.9.21","localKeyId"),s("1.2.840.113549.1.9.22.1","x509Certificate"),s("1.2.840.113549.1.12.10.1.1","keyBag"),s("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),s("1.2.840.113549.1.12.10.1.3","certBag"),s("1.2.840.113549.1.12.10.1.4","crlBag"),s("1.2.840.113549.1.12.10.1.5","secretBag"),s("1.2.840.113549.1.12.10.1.6","safeContentsBag"),s("1.2.840.113549.1.5.13","pkcs5PBES2"),s("1.2.840.113549.1.5.12","pkcs5PBKDF2"),s("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),s("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),s("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),s("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),s("1.2.840.113549.2.7","hmacWithSHA1"),s("1.2.840.113549.2.8","hmacWithSHA224"),s("1.2.840.113549.2.9","hmacWithSHA256"),s("1.2.840.113549.2.10","hmacWithSHA384"),s("1.2.840.113549.2.11","hmacWithSHA512"),s("1.2.840.113549.3.7","des-EDE3-CBC"),s("2.16.840.1.101.3.4.1.2","aes128-CBC"),s("2.16.840.1.101.3.4.1.22","aes192-CBC"),s("2.16.840.1.101.3.4.1.42","aes256-CBC"),s("2.5.4.3","commonName"),s("2.5.4.5","serialName"),s("2.5.4.6","countryName"),s("2.5.4.7","localityName"),s("2.5.4.8","stateOrProvinceName"),s("2.5.4.9","streetAddress"),s("2.5.4.10","organizationName"),s("2.5.4.11","organizationalUnitName"),s("2.5.4.13","description"),s("2.5.4.15","businessCategory"),s("2.5.4.17","postalCode"),s("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),s("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),s("2.16.840.1.113730.1.1","nsCertType"),s("2.16.840.1.113730.1.13","nsComment"),o("2.5.29.1","authorityKeyIdentifier"),o("2.5.29.2","keyAttributes"),o("2.5.29.3","certificatePolicies"),o("2.5.29.4","keyUsageRestriction"),o("2.5.29.5","policyMapping"),o("2.5.29.6","subtreesConstraint"),o("2.5.29.7","subjectAltName"),o("2.5.29.8","issuerAltName"),o("2.5.29.9","subjectDirectoryAttributes"),o("2.5.29.10","basicConstraints"),o("2.5.29.11","nameConstraints"),o("2.5.29.12","policyConstraints"),o("2.5.29.13","basicConstraints"),s("2.5.29.14","subjectKeyIdentifier"),s("2.5.29.15","keyUsage"),o("2.5.29.16","privateKeyUsagePeriod"),s("2.5.29.17","subjectAltName"),s("2.5.29.18","issuerAltName"),s("2.5.29.19","basicConstraints"),o("2.5.29.20","cRLNumber"),o("2.5.29.21","cRLReason"),o("2.5.29.22","expirationDate"),o("2.5.29.23","instructionCode"),o("2.5.29.24","invalidityDate"),o("2.5.29.25","cRLDistributionPoints"),o("2.5.29.26","issuingDistributionPoint"),o("2.5.29.27","deltaCRLIndicator"),o("2.5.29.28","issuingDistributionPoint"),o("2.5.29.29","certificateIssuer"),o("2.5.29.30","nameConstraints"),s("2.5.29.31","cRLDistributionPoints"),s("2.5.29.32","certificatePolicies"),o("2.5.29.33","policyMappings"),o("2.5.29.34","policyConstraints"),s("2.5.29.35","authorityKeyIdentifier"),o("2.5.29.36","policyConstraints"),s("2.5.29.37","extKeyUsage"),o("2.5.29.46","freshestCRL"),o("2.5.29.54","inhibitAnyPolicy"),s("1.3.6.1.4.1.11129.2.4.2","timestampList"),s("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),s("1.3.6.1.5.5.7.3.1","serverAuth"),s("1.3.6.1.5.5.7.3.2","clientAuth"),s("1.3.6.1.5.5.7.3.3","codeSigning"),s("1.3.6.1.5.5.7.3.4","emailProtection"),s("1.3.6.1.5.5.7.3.8","timeStamping")},function(t,e,r){"use strict";var n;!function(){var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function s(t){return a(u(t),arguments)}function o(t,e){return s.apply(null,[t].concat(e||[]))}function a(t,e){var r,n,o,a,c,u,h,f,l,d=1,p=t.length,y="";for(n=0;n=0),a.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,a.width?parseInt(a.width):0);break;case"e":r=a.precision?parseFloat(r).toExponential(a.precision):parseFloat(r).toExponential();break;case"f":r=a.precision?parseFloat(r).toFixed(a.precision):parseFloat(r);break;case"g":r=a.precision?String(Number(r.toPrecision(a.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=a.precision?r.substring(0,a.precision):r;break;case"t":r=String(!!r),r=a.precision?r.substring(0,a.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=a.precision?r.substring(0,a.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=a.precision?r.substring(0,a.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?y+=r:(!i.number.test(a.type)||f&&!a.sign?l="":(l=f?"+":"-",r=r.toString().replace(i.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",h=a.width-(l+r).length,c=a.width&&h>0?u.repeat(h):"",y+=a.align?l+r+c:"0"===u?l+c+r:c+l+r)}return y}var c=Object.create(null);function u(t){if(c[t])return c[t];for(var e,r=t,n=[],s=0;r;){if(null!==(e=i.text.exec(r)))n.push(e[0]);else if(null!==(e=i.modulo.exec(r)))n.push("%");else{if(null===(e=i.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){s|=1;var o=[],a=e[2],u=[];if(null===(u=i.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(u[1]);""!==(a=a.substring(u[0].length));)if(null!==(u=i.key_access.exec(a)))o.push(u[1]);else{if(null===(u=i.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(u[1])}e[2]=o}else s|=2;if(3===s)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}r=r.substring(e[0].length)}return c[t]=n}e.sprintf=s,e.vsprintf=o,"undefined"!=typeof window&&(window.sprintf=s,window.vsprintf=o,void 0===(n=function(){return{sprintf:s,vsprintf:o}}.call(e,r,e,t))||(t.exports=n))}()},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.logCipherState=e.logRemoteEphemeralKey=e.logRemoteStaticKey=e.logLocalEphemeralKeys=e.logLocalStaticKeys=e.logger=void 0;const i=n(r(1)),s=r(214);let o;e.logger=i.default("libp2p:noise"),o=s.DUMP_SESSION_KEYS?e.logger:()=>{},e.logLocalStaticKeys=function(t){o("LOCAL_STATIC_PUBLIC_KEY "+t.publicKey.toString("hex")),o("LOCAL_STATIC_PRIVATE_KEY "+t.privateKey.toString("hex"))},e.logLocalEphemeralKeys=function(t){t?(o("LOCAL_PUBLIC_EPHEMERAL_KEY "+t.publicKey.toString("hex")),o("LOCAL_PRIVATE_EPHEMERAL_KEY "+t.privateKey.toString("hex"))):o("Missing local ephemeral keys.")},e.logRemoteStaticKey=function(t){o("REMOTE_STATIC_PUBLIC_KEY "+t.toString("hex"))},e.logRemoteEphemeralKey=function(t){o("REMOTE_EPHEMERAL_PUBLIC_KEY "+t.toString("hex"))},e.logCipherState=function(t){t.cs1&&t.cs2?(o(`CIPHER_STATE_1 ${t.cs1.n} ${t.cs1.k.toString("hex")}`),o(`CIPHER_STATE_2 ${t.cs2.n} ${t.cs2.k.toString("hex")}`)):o("Missing cipher state.")}},function(t,e,r){"use strict";const n=r(16),i=n.DAGNode,s=n.DAGLink,o=r(13).multihash,a=r(19),{withTimeoutOption:c}=r(2),u=r(5),h=r(6);function f(t,e){switch(e){case"json":return function(t){let e,r;try{const n=JSON.parse(u(t));r=(n.Links||[]).map(t=>new s(t.Name||t.name,t.Size||t.size,o.fromB58String(t.Hash||t.hash||t.multihash))),e=h(n.Data)}catch(n){throw new Error("failed to parse JSON: "+n)}return new i(e,r)}(t);case"protobuf":return function(t){return n.util.deserialize(t)}(t);default:throw new Error("unkown encoding: "+e)}}t.exports=({ipld:t,gcLock:e,preload:r})=>c((async function(n,s){const o=(s=s||{}).enc;let c;if(n instanceof Uint8Array)c=o?await f(n,o):new i(n);else if(i.isDAGNode(n))c=n;else{if("object"!=typeof n)throw new Error("obj not recognized");c=new i(n.Data,n.Links)}const u=await e.readLock();try{const e=await t.put(c,a.DAG_PB,{cidVersion:0,hashAlg:a.SHA2_256});return!1!==s.preload&&r(e),e}finally{u()}}))},function(t,e,r){"use strict";const n=r(87),i=r(4),{getName:s}=r(19),o=r(1051),a=r(13),{isMapEqual:c}=r(48),{Message:u}=r(1052),h=r(1053);class f{constructor(t){this.full=t,this.wantlist=new Map,this.blocks=new Map,this.blockPresences=new Map,this.pendingBytes=0}get empty(){return 0===this.blocks.size&&0===this.wantlist.size&&0===this.blockPresences.size}addEntry(t,e,r,n,i){null==r&&(r=f.WantType.Block);const s=t.toString("base58btc"),o=this.wantlist.get(s);o?(o.wantType===r&&(o.priority=e),n&&(o.cancel=Boolean(n)),i&&(o.sendDontHave=Boolean(i)),r===f.WantType.Block&&o.wantType===f.WantType.Have&&(o.wantType=r)):this.wantlist.set(s,new h(t,e,r,n,i))}addBlock(t){const e=t.cid.toString("base58btc");this.blocks.set(e,t)}addHave(t){const e=t.toString("base58btc");this.blockPresences.has(e)||this.blockPresences.set(e,f.BlockPresenceType.Have)}addDontHave(t){const e=t.toString("base58btc");this.blockPresences.has(e)||this.blockPresences.set(e,f.BlockPresenceType.DontHave)}cancel(t){const e=t.toString("base58btc");this.wantlist.delete(e),this.addEntry(t,0,f.WantType.Block,!0,!1)}setPendingBytes(t){this.pendingBytes=t}serializeToBitswap100(){const t={wantlist:{entries:Array.from(this.wantlist.values()).map(t=>({block:t.cid.bytes,priority:Number(t.priority),cancel:Boolean(t.cancel)}))},blocks:Array.from(this.blocks.values()).map(t=>t.data)};return this.full&&(t.wantlist.full=!0),u.encode(t)}serializeToBitswap110(){const t={wantlist:{entries:Array.from(this.wantlist.values()).map(t=>({block:t.cid.bytes,priority:Number(t.priority),wantType:t.wantType,cancel:Boolean(t.cancel),sendDontHave:Boolean(t.sendDontHave)}))},blockPresences:[],payload:[]};this.full&&(t.wantlist.full=!0),this.blocks.forEach(e=>{t.payload.push({prefix:e.cid.prefix,data:e.data})});for(const[e,r]of this.blockPresences)t.blockPresences.push({cid:new i(e).bytes,type:r});return this.pendingBytes>0&&(t.pendingBytes=this.pendingBytes),u.encode(t)}equals(t){return!!(this.full===t.full&&this.pendingBytes===t.pendingBytes&&c(this.wantlist,t.wantlist)&&c(this.blocks,t.blocks)&&c(this.blockPresences,t.blockPresences))}get[Symbol.toStringTag](){const t=Array.from(this.wantlist.keys()),e=Array.from(this.blocks.keys());return`BitswapMessage `}}f.deserialize=async t=>{const e=u.decode(t),r=e.wantlist&&e.wantlist.full||!1,c=new f(r);return e.wantlist&&e.wantlist.entries.forEach(t=>{const e=new i(t.block);c.addEntry(e,t.priority,t.wantType,t.cancel,t.sendDontHave)}),e.blockPresences&&e.blockPresences.forEach(t=>{const e=new i(t.cid);t.type===f.BlockPresenceType.Have?c.addHave(e):c.addDontHave(e)}),e.blocks.length>0?(await Promise.all(e.blocks.map(async t=>{const e=await a(t,"sha2-256"),r=new i(e);c.addBlock(new n(t,r))})),c):e.payload.length>0?(await Promise.all(e.payload.map(async t=>{if(!t.prefix||!t.data)return;const e=o(t.prefix),r=e[0],u=e[1],h=e[2],f=await a(t.data,h),l=new i(r,s(u),f);c.addBlock(new n(t.data,l))})),c.setPendingBytes(e.pendingBytes),c):c},f.blockPresenceSize=t=>t.bytes.length+1,f.Entry=h,f.WantType={Block:u.Wantlist.WantType.Block,Have:u.Wantlist.WantType.Have},f.BlockPresenceType={Have:u.BlockPresenceType.Have,DontHave:u.BlockPresenceType.DontHave},t.exports=f},function(t,e,r){"use strict";const{URLWithLegacySupport:n,format:i,URLSearchParams:s,defaultBase:o}=r(224),a=r(395);t.exports={URL:n,URLSearchParams:s,format:i,relative:a,defaultBase:o}},function(t,e,r){"use strict";var n,i=r(8);t.exports=i.jsbn=i.jsbn||{};function s(t,e,r){this.data=[],null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function o(){return new s(null)}function a(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this.data[t],u=this.data[t++]>>14,h=a*c+u*o;i=((c=o*c+((16383&h)<<14)+r.data[n]+i)>>28)+(h>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=s,"undefined"==typeof navigator?(s.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(s.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var c=32767&this.data[t],u=this.data[t++]>>15,h=a*c+u*o;i=((c=o*c+((32767&h)<<15)+r.data[n]+(1073741823&i))>>>30)+(h>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(s.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this.data[t++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},n=26):(s.prototype.am=a,n=28),s.prototype.DB=n,s.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function y(t){this.m=t}function g(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function E(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function S(){}function I(t){return t}function A(t){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}y.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},y.prototype.revert=function(t){return t},y.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},y.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},y.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},g.prototype.convert=function(t){var e=o();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(s.ZERO)>0&&this.m.subTo(e,e),e},g.prototype.revert=function(t){var e=o();return t.copyTo(e),this.reduce(e),e},g.prototype.reduce=function(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},g.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},g.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},s.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s},s.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0},s.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var a=8==r?255&t[n]:l(t,n);a<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-o):this.data[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==t;)--this.t},s.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s},s.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e.data[r+o+1]=this.data[r]>>i|a,a=(this.data[r]&s)<=0;--r)e.data[r]=0;e.data[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},s.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e.data[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()},s.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i=0;)t.data[r]=0;for(r=0;r=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()},s.prototype.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(h,a),i.lShiftTo(h,r)):(n.copyTo(a),i.copyTo(r));var f=a.t,l=a.data[f-1];if(0!=l){var d=l*(1<1?a.data[f-2]>>this.F2:0),y=this.FV/d,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),s.ONE.dlShiftTo(f,w),w.subTo(a,a);a.t=0;){var _=r.data[--m]==l?this.DM:Math.floor(r.data[m]*y+(r.data[m-1]+b)*g);if((r.data[m]+=a.am(0,_,r,v,0,f))<_)for(a.dlShiftTo(v,w),r.subTo(w,r);r.data[m]<--_;)r.subTo(w,r)}null!=e&&(r.drShiftTo(f,e),c!=u&&s.ZERO.subTo(e,e)),r.t=f,r.clamp(),h>0&&r.rShiftTo(h,r),c<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var t=this.data[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(t,e){if(t>4294967295||t<1)return s.ONE;var r=o(),n=o(),i=e.convert(this),a=p(t)-1;for(i.copyTo(r);--a>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var c=r;r=n,n=c}return e.revert(r)},s.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=f(r));o>=0;)a>(a+=this.DB-e)):(r=this.data[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=f(r));return i?s:"0"},s.prototype.negate=function(){var t=o();return s.ZERO.subTo(this,t),t},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this.data[r]-t.data[r]))return e;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(t){var e=o();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(s.ZERO)>0&&t.subTo(e,e),e},s.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new y(e):new g(e),this.exp(t,r)},s.ZERO=d(0),s.ONE=d(1),S.prototype.convert=I,S.prototype.revert=I,S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},S.prototype.sqrTo=function(t,e){t.squareTo(e)},A.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=o();return t.copyTo(e),this.reduce(e),e},A.prototype.revert=function(t){return t},A.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},A.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},A.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],T=(1<<26)/k[k.length-1];s.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},s.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=d(r),i=o(),s=o(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(t).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(t)+a},s.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),i&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(s.ONE.shiftLeft(t-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(s.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()},s.prototype.dMultiply=function(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}},s.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r},s.prototype.millerRabin=function(t){var e=this.subtract(s.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n,i=e.shiftRight(r),o={nextBytes:function(t){for(var e=0;e=0);var c=n.modPow(i,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(e)){for(var u=1;u++>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this.data[t]&(1<>(n+=this.DB-8)):(r=this.data[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},s.prototype.equals=function(t){return 0==this.compareTo(t)},s.prototype.min=function(t){return this.compareTo(t)<0?this:t},s.prototype.max=function(t){return this.compareTo(t)>0?this:t},s.prototype.and=function(t){var e=o();return this.bitwiseTo(t,b,e),e},s.prototype.or=function(t){var e=o();return this.bitwiseTo(t,m,e),e},s.prototype.xor=function(t){var e=o();return this.bitwiseTo(t,v,e),e},s.prototype.andNot=function(t){var e=o();return this.bitwiseTo(t,w,e),e},s.prototype.not=function(){for(var t=o(),e=0;e=this.t?0!=this.s:0!=(this.data[e]&1<1){var f=o();for(n.sqrTo(a[1],f);c<=h;)a[c]=o(),n.mulTo(f,a[c-2],a[c]),c+=2}var l,b,m=t.t-1,v=!0,w=o();for(i=p(t.data[m])-1;m>=0;){for(i>=u?l=t.data[m]>>i-u&h:(l=(t.data[m]&(1<0&&(l|=t.data[m-1]>>this.DB+i-u)),c=r;0==(1&l);)l>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),v)a[l].copyTo(s),v=!1;else{for(;c>1;)n.sqrTo(s,w),n.sqrTo(w,s),c-=2;c>0?n.sqrTo(s,w):(b=s,s=w,w=b),n.mulTo(w,a[l],s)}for(;m>=0&&0==(t.data[m]&1<=0?(r.subTo(n,r),e&&i.subTo(a,i),o.subTo(c,o)):(n.subTo(r,n),e&&a.subTo(i,a),c.subTo(o,c))}return 0!=n.compareTo(s.ONE)?s.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},s.prototype.pow=function(t){return this.exp(t,new S)},s.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r.data[0]<=k[k.length-1]){for(e=0;e{const e=t.crypto||t.msCrypto;if(!e||!e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}},function(t,e,r){"use strict";const n=r(450),i=r(0);t.exports=function(t){if(isNaN(t)||t<=0)throw i(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return n(t)}},function(t,e,r){"use strict";t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";var n=r(40),i=r(35),s=i.getNAF,o=i.getJSF,a=i.assert;function c(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=s(e,1,this._bitLength),i=(1<=c;e--)u=(u<<1)+n[e];o.push(u)}for(var h=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(c=0;c=0;u--){for(e=0;u>=0&&0===o[u];u--)e++;if(u>=0&&e++,c=c.dblp(e),u<0)break;var h=o[u];a(0!==h),c="affine"===t.type?h>0?c.mixedAdd(i[h-1>>1]):c.mixedAdd(i[-h-1>>1].neg()):h>0?c.add(i[h-1>>1]):c.add(i[-h-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,n,i){for(var a=this._wnafT1,c=this._wnafT2,u=this._wnafT3,h=0,f=0;f=1;f-=2){var d=f-1,p=f;if(1===a[d]&&1===a[p]){var y=[e[d],null,null,e[p]];0===e[d].y.cmp(e[p].y)?(y[1]=e[d].add(e[p]),y[2]=e[d].toJ().mixedAdd(e[p].neg())):0===e[d].y.cmp(e[p].y.redNeg())?(y[1]=e[d].toJ().mixedAdd(e[p]),y[2]=e[d].add(e[p].neg())):(y[1]=e[d].toJ().mixedAdd(e[p]),y[2]=e[d].toJ().mixedAdd(e[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],b=o(r[d],r[p]);h=Math.max(b[0].length,h),u[d]=new Array(h),u[p]=new Array(h);for(var m=0;m=0;f--){for(var S=0;f>=0;){var I=!0;for(m=0;m=0&&S++,_=_.dblp(S),f<0)break;for(m=0;m0?A=c[m][k-1>>1]:k<0&&(A=c[m][-k-1>>1].neg()),_="affine"===A.type?_.mixedAdd(A):_.add(A))}}for(f=0;f=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i{if(t instanceof Uint8Array)try{t=new n(t)}catch(o){throw i(o,"ERR_INVALID_CID")}if(n.isCID(t))return{cid:t,path:void 0};t.startsWith("/ipfs/")&&(t=t.substring("/ipfs/".length));const e=t.split("/");let r,s;try{r=new n(e.shift())}catch(o){throw i(o,"ERR_INVALID_CID")}return e.length&&(s="/"+e.join("/")),{cid:r,path:s}}},function(t,e,r){"use strict";const n=r(30).BigNumber;e.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},e.SHIFT32=Math.pow(2,32),e.SHIFT16=Math.pow(2,16),e.MAX_SAFE_HIGH=2097151,e.NEG_ONE=new n(-1),e.TEN=new n(10),e.TWO=new n(2),e.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}},function(t,e,r){"use strict";(function(e){void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var s,o,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,n)}));case 4:return e.nextTick((function(){t.call(null,r,n,i)}));default:for(s=new Array(a-1),o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function h(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=s,s.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,r){"use strict";(function(e){const n=r(64),i=r(571),s=r(165),o=r(90),a=r(66),c=r(30).BigNumber,u=r(91),h=r(54),f=h.MT,l=h.NUMBYTES,d=(h.SIMPLE,h.SYMS),p=a.bigIntize(h.BI),y=h.BN,g=Symbol("count"),b=(Symbol("pending_key"),Symbol("major type")),m=Symbol("error"),v=Symbol("not found");function w(t,e,r){const n=[];return n[g]=r,n[d.PARENT]=t,n[b]=e,n}function _(t,e){const r=new u;return r[g]=-1,r[d.PARENT]=t,r[b]=e,r}function E(t){return a.bufferToBigInt(t)}function S(t){return p.MINUS_ONE-a.bufferToBigInt(t)}class I extends i{constructor(t){const e=(t=t||{}).tags;delete t.tags;const r=null!=t.max_depth?t.max_depth:-1;delete t.max_depth;const n=!!a.hasBigInt&&!!t.bigint;delete t.bigint,super(t),this.running=!0,this.max_depth=r,this.tags=e,n&&(null==this.tags&&(this.tags={}),null==this.tags[2]&&(this.tags[2]=E),null==this.tags[3]&&(this.tags[3]=S))}static nullcheck(t){switch(t){case d.NULL:return null;case d.UNDEFINED:return;case v:throw new Error("Value not found");default:return t}}static decodeFirstSync(t,e){let r,i={};switch(typeof(e=e||{encoding:"hex"})){case"string":r=e;break;case"object":i=a.extend({},e),r=i.encoding,delete i.encoding}const s=new I(i),o=t instanceof n.Readable?t:new u(t,null!=r?r:a.guessEncoding(t)),c=s._parse();let h=c.next();for(;!h.done;){const t=o.read(h.value);if(null==t||t.length!==h.value)throw new Error("Insufficient data");h=c.next(t)}const f=I.nullcheck(h.value);if(o.length>0){const t=o.read(1);o.unshift(t);const e=new Error("Unexpected data: 0x"+t[0].toString(16));throw e.value=f,e}return f}static decodeAllSync(t,e){let r,i={};switch(typeof(e=e||{encoding:"hex"})){case"string":r=e;break;case"object":i=a.extend({},e),r=i.encoding,delete i.encoding}const s=new I(i),o=t instanceof n.Readable?t:new u(t,null!=r?r:a.guessEncoding(t)),c=[];for(;o.length>0;){const t=s._parse();let e=t.next();for(;!e.done;){const r=o.read(e.value);if(null==r||r.length!==e.value)throw new Error("Insufficient data");e=t.next(r)}c.push(I.nullcheck(e.value))}return c}static decodeFirst(t,e,r){let n={},i=!1,s="hex";switch(typeof e){case"function":r=e,s=a.guessEncoding(t);break;case"string":s=e;break;case"object":n=a.extend({},e),s=null!=n.encoding?n.encoding:a.guessEncoding(t),delete n.encoding,i=null!=n.required&&n.required,delete n.required}const o=new I(n);let c=v;const u=new Promise((t,e)=>{o.on("data",t=>{c=I.nullcheck(t),o.close()}),o.once("error",t=>(c!==v&&(t.value=c),c=m,o.close(),e(t))),o.once("end",()=>{switch(c){case v:return i?e(new Error("No CBOR found")):t(c);case m:return;default:return t(c)}})});return"function"==typeof r&&u.then(t=>r(null,t),r),o.end(t,s),u}static decodeAll(t,e,r){let n={},i="hex";switch(typeof e){case"function":r=e,i=a.guessEncoding(t);break;case"string":i=e;break;case"object":n=a.extend({},e),i=null!=n.encoding?n.encoding:a.guessEncoding(t),delete n.encoding}const s=new I(n),o=[];s.on("data",t=>o.push(I.nullcheck(t)));const c=new Promise((t,e)=>{s.on("error",e),s.on("end",()=>t(o))});return"function"==typeof r&&c.then(t=>r(null,t),r),s.end(t,i),c}close(){this.running=!1,this.__fresh=!0}*_parse(){let t=null,r=0,n=null;for(;;){if(this.max_depth>=0&&r>this.max_depth)throw new Error("Maximum depth "+this.max_depth+" exceeded");const i=(yield 1)[0];if(!this.running)throw new Error("Unexpected data: 0x"+i.toString(16));const h=i>>5,p=31&i,m=null!=t?t[b]:void 0,v=null!=t?t.length:void 0;switch(p){case l.ONE:this.emit("more-bytes",h,1,m,v),n=(yield 1)[0];break;case l.TWO:case l.FOUR:case l.EIGHT:const t=1<0;)i=o.nextValue(),t=Math.floor(i*e.length),r.push(e.splice(t,1)[0]);return r.join("")}())}t.exports={get:function(){return n||a},characters:function(t){return u(t),n},seed:function(t){o.seed(t),i!==t&&(c(),i=t)},lookup:function(t){return h()[t]},shuffled:h}},function(t,e,r){"use strict";const n=r(46),i=r(42),s=r(39),o=r(1)("ipfs:mfs:stat"),a=r(0),{withTimeoutOption:c}=r(2),u={withLocal:!1,signal:void 0};t.exports=t=>c((async function(e,r){r=n(r,u),o("Fetching stats for "+e);const{type:c,cid:f,mfsPath:l}=await i(t,e,r),d="ipfs"===c&&f?f:l;let p;try{p=await s(d,t.ipld)}catch(y){if("ERR_NOT_FOUND"===y.code)throw a(new Error(e+" does not exist"),"ERR_NOT_FOUND");throw y}if(!h[p.cid.codec])throw new Error("Cannot stat codec "+p.cid.codec);return h[p.cid.codec](p,r)}));const h={raw:t=>({cid:t.cid,size:t.node.length,cumulativeSize:t.node.length,blocks:0,type:"file",local:void 0,sizeLocal:void 0,withLocality:!1}),"dag-pb":t=>{const e=t.node.Links.length,r=t.node.size,n=t.node.size,i={cid:t.cid,size:r,cumulativeSize:n,blocks:e,local:void 0,sizeLocal:void 0,withLocality:!1};return t.unixfs&&(i.size=t.unixfs.fileSize(),"hamt-sharded-directory"===t.unixfs.type?i.type="directory":i.type=t.unixfs.type,i.mode=t.unixfs.mode,t.unixfs.isDirectory()&&(i.size=0,i.cumulativeSize=t.node.size),"file"===i.type&&(i.blocks=t.unixfs.blockSizes.length),t.unixfs.mtime&&(i.mtime=t.unixfs.mtime)),i},"dag-cbor":t=>({cid:t.cid,local:void 0,sizeLocal:void 0,withLocality:!1}),identity:t=>({cid:t.cid,size:t.node.digest.length,cumulativeSize:t.node.digest.length,blocks:0,type:"file",local:void 0,sizeLocal:void 0,withLocality:!1})}},function(t,e,r){"use strict";const n=r(10).Key,i=r(178),s=i.ShardingDatastore;e.CONFIG_KEY=new n("/config"),e.VERSION_KEY=new n("/version"),e.createStore=async function(t,e,r){const{StorageBackend:n,storageOptions:o}=function(t,e){if(!e||!e.storageBackends)throw new Error("Please pass storage backend definitions");if(!e.storageBackends[t])throw new Error(`Storage backend '${t}' not defined in config`);const r=e.storageBackends[t];let n={};return void 0!==e.storageBackendOptions&&void 0!==e.storageBackendOptions[t]&&(n=e.storageBackendOptions[t]),{StorageBackend:r,storageOptions:n}}(e,r);"root"!==e&&(t=`${t}/${e}`);let a=new n(t,o);if(o.sharding){const t=new i.shard.NextToLast(2);a=await s.createOrOpen(a,t)}return await a.close(),a},e.containsIrreversibleMigration=function(t,e,r){return r.filter(r=>r.version>t&&r.version<=e).some(t=>void 0===t.revert)}},function(t,e,r){"use strict";const{Adapter:n,utils:i}=r(10),s=i.map;t.exports=class extends n{constructor(t,e){super(),this.child=t,this.transform=e}open(){return this.child.open()}put(t,e,r){return this.child.put(this.transform.convert(t),e,r)}get(t,e){return this.child.get(this.transform.convert(t),e)}has(t,e){return this.child.has(this.transform.convert(t),e)}delete(t,e){return this.child.delete(this.transform.convert(t),e)}batch(){const t=this.child.batch();return{put:(e,r)=>{t.put(this.transform.convert(e),r)},delete:e=>{t.delete(this.transform.convert(e))},commit:e=>t.commit(e)}}query(t,e){return s(this.child.query(t,e),t=>(t.key=this.transform.invert(t.key),t))}close(){return this.child.close()}}},function(t,e,r){"use strict";e.getCallback=function(t,e){return"function"==typeof t?t:e},e.getOptions=function(t){return"object"==typeof t&&null!==t?t:{}}},function(t,e,r){"use strict";var n=r(9);function i(t,e){n.cipher.registerAlgorithm(t,(function(){return new n.aes.Algorithm(t,e)}))}r(332),r(333),r(18),t.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(t,e,r,n){var i=p({key:t,output:r,decrypt:!1,mode:n});return i.start(e),i},n.aes.createEncryptionCipher=function(t,e){return p({key:t,output:null,decrypt:!1,mode:e})},n.aes.startDecrypting=function(t,e,r,n){var i=p({key:t,output:r,decrypt:!0,mode:n});return i.start(e),i},n.aes.createDecryptionCipher=function(t,e){return p({key:t,output:null,decrypt:!0,mode:e})},n.aes.Algorithm=function(t,e){h||f();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(t,e){return d(r._w,t,e,!1)},decrypt:function(t,e){return d(r._w,t,e,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e,r=t.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){e=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&f^99,s[y]=f,o[f]=y,d=(l=t[f])<<24^f<<16^f<<8^f^l,p=((r=t[y])^(n=t[r])^(i=t[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var b=0;b<4;++b)c[b][y]=d,u[b][f]=p,d=d<<24|d>>>8,p=p<<24|p>>>8;0===y?y=g=1:(y=r^t[t[t[r^i]]],g^=t[t[g]])}}function l(t,e){for(var r,n=t.slice(0),i=1,o=n.length,c=4*(o+6+1),h=o;h>>16&255]<<24^s[r>>>8&255]<<16^s[255&r]<<8^s[r>>>24]^a[i]<<24,i++):o>6&&h%o==4&&(r=s[r>>>24]<<24^s[r>>>16&255]<<16^s[r>>>8&255]<<8^s[255&r]),n[h]=n[h-o]^r;if(e){for(var f,l=u[0],d=u[1],p=u[2],y=u[3],g=n.slice(0),b=(h=0,(c=n.length)-4);h>>24]]^d[s[f>>>16&255]]^p[s[f>>>8&255]]^y[s[255&f]];n=g}return n}function d(t,e,r,n){var i,a,h,f,l,d,p,y,g,b,m,v,w=t.length/4-1;n?(i=u[0],a=u[1],h=u[2],f=u[3],l=o):(i=c[0],a=c[1],h=c[2],f=c[3],l=s),d=e[0]^t[0],p=e[n?3:1]^t[1],y=e[2]^t[2],g=e[n?1:3]^t[3];for(var _=3,E=1;E>>24]^a[p>>>16&255]^h[y>>>8&255]^f[255&g]^t[++_],m=i[p>>>24]^a[y>>>16&255]^h[g>>>8&255]^f[255&d]^t[++_],v=i[y>>>24]^a[g>>>16&255]^h[d>>>8&255]^f[255&p]^t[++_],g=i[g>>>24]^a[d>>>16&255]^h[p>>>8&255]^f[255&y]^t[++_],d=b,p=m,y=v;r[0]=l[d>>>24]<<24^l[p>>>16&255]<<16^l[y>>>8&255]<<8^l[255&g]^t[++_],r[n?3:1]=l[p>>>24]<<24^l[y>>>16&255]<<16^l[g>>>8&255]<<8^l[255&d]^t[++_],r[2]=l[y>>>24]<<24^l[g>>>16&255]<<16^l[d>>>8&255]<<8^l[255&p]^t[++_],r[n?1:3]=l[g>>>24]<<24^l[d>>>16&255]<<16^l[p>>>8&255]<<8^l[255&y]^t[++_]}function p(t){var e,r="AES-"+((t=t||{}).mode||"CBC").toUpperCase(),i=(e=t.decrypt?n.cipher.createDecipher(r,t.key):n.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=t,i.call(e,r)},e}},function(t,e,r){"use strict";const n=r(0),i=r(7),{codes:{ERR_INVALID_PARAMETERS:s}}=r(28),o=t=>t;t.exports=class{constructor({peerStore:t,eventName:e,eventProperty:r,eventTransformer:n=o}){this._ps=t,this.eventName=e,this.eventProperty=r,this.eventTransformer=n,this.data=new Map}set(t,e){throw n(new Error("set must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}_setData(t,e,{emit:r=!0}={}){const n=t.toB58String();this.data.set(n,e),r&&this._emit(t,e)}_emit(t,e){this._ps.emit(this.eventName,{peerId:t,[this.eventProperty]:this.eventTransformer(e)})}get(t){if(!i.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),s);const e=this.data.get(t.toB58String());return e?[...e]:void 0}delete(t){if(!i.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),s);return!!this.data.delete(t.toB58String())&&(this._emit(t,[]),!0)}}},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=r(36);t.exports=async function*(t){for await(const e of t)n.isBuffer(e)?yield e:i.isBufferList(e)?yield e.slice():yield n.from(e)},t.exports.toBuffer=t.exports,t.exports.toList=async function*(t){for await(const e of t)n.isBuffer(e)?yield(new i).append(e):i.isBufferList(e)?yield e:yield(new i).append(n.from(e))}},function(t,e,r){"use strict";e.encode=function(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e},e.decode=function(t){for(var e={},r=t.split("&"),n=0,i=r.length;n((e=e||n.Buffer.allocUnsafe(2)).writeUInt16BE(t,r),e),e.uint16BEEncode.bytes=2,e.uint16BEDecode=t=>{if(t.length<2)throw RangeError("Could not decode int16BE");return t.readUInt16BE(0)},e.uint16BEDecode.bytes=2,e.encode0=function(t){return n.Buffer.concat([t.ne,t.ciphertext])},e.encode1=function(t){return n.Buffer.concat([t.ne,t.ns,t.ciphertext])},e.encode2=function(t){return n.Buffer.concat([t.ns,t.ciphertext])},e.decode0=function(t){if(t.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:t.slice(0,32),ciphertext:t.slice(32,t.length),ns:n.Buffer.alloc(0)}},e.decode1=function(t){if(t.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:t.slice(0,32),ns:t.slice(32,80),ciphertext:t.slice(80,t.length)}},e.decode2=function(t){if(t.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:n.Buffer.alloc(0),ns:t.slice(0,48),ciphertext:t.slice(48,t.length)}}},function(t,e,r){"use strict";const n=r(171);class i extends Error{constructor(t){super(t),this.name="TimeoutError"}}const s=(t,e,r)=>new Promise((s,o)=>{if("number"!=typeof e||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0)return void s(t);const a=setTimeout(()=>{if("function"==typeof r){try{s(r())}catch(a){o(a)}return}const n=r instanceof Error?r:new i("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(n)},e);n(t.then(s,o),()=>{clearTimeout(a)})});t.exports=s,t.exports.default=s,t.exports.TimeoutError=i},function(t,e,r){"use strict";const{sortBy:n}=r(48),i=r(1054);class s{constructor(t){this.set=new Map,this._stats=t}get length(){return this.set.size}add(t,e,n){const s=r(105),o=t.toString("base58btc"),a=this.set.get(o);a?(a.inc(),a.priority=e,a.wantType===s.WantType.Have&&n===s.WantType.Block&&(a.wantType=n)):(this.set.set(o,new i(t,e,n)),this._stats&&this._stats.push(null,"wantListSize",1))}remove(t){const e=t.toString("base58btc"),r=this.set.get(e);r&&(r.dec(),r.hasRefs()||(this.set.delete(e),this._stats&&this._stats.push(null,"wantListSize",-1)))}removeForce(t){this.set.has(t)&&this.set.delete(t)}forEach(t){return this.set.forEach(t)}entries(){return this.set.entries()}sortedEntries(){return new Map(n(t=>t[1].key,Array.from(this.set.entries())))}contains(t){const e=t.toString("base58btc");return this.set.get(e)}}s.Entry=i,t.exports=s},function(t,e,r){"use strict";t.exports={maxProvidersPerRequest:3,providerRequestTimeout:1e4,hasBlockTimeout:15e3,provideTimeout:15e3,kMaxPriority:Math.pow(2,31)-1,maxListeners:1e3,wantlistSendDebounceMs:1}},function(t,e,r){"use strict";const n=r(394),i=r(33).bind({ignoreUndefined:!0}),{URL:s,URLSearchParams:o}=r(106),a=r(396),c=r(45),u=r(77),h=n.Request,f=n.Headers;class l extends Error{constructor(){super("Request timed out"),this.name="TimeoutError"}}class d extends Error{constructor(t){super(t.statusText),this.name="HTTPError",this.response=t}}const p={headers:{},throwHttpErrors:!0,credentials:"same-origin",transformSearchParams:t=>t};class y{constructor(t={}){this.opts=i(p,t)}async fetch(t,e={}){const r=i(this.opts,e);if(r.headers=new f(r.headers),"string"!=typeof t&&!(t instanceof s||t instanceof h))throw new TypeError("`resource` must be a string, URL, or Request");if(r.base&&"string"==typeof r.base&&"string"==typeof t){if(t.startsWith("/"))throw new Error("`resource` must not begin with a slash when using `base`");r.base.endsWith("/")||(r.base+="/"),t=r.base+t}const a=new s(t,r.base);r.searchParams&&(a.search=r.transformSearchParams(new o(r.searchParams))),void 0!==r.json&&(r.body=JSON.stringify(r.json),r.headers.set("content-type","application/json"));const p=new c,y=u([p.signal,r.signal]),v=await((t,e,r)=>{if(void 0===e)return t;const n=Date.now(),i=()=>Date.now()-n>=e;return new Promise((n,s)=>{const o=setTimeout(()=>{i()&&(s(new l),r.abort())},e),a=t=>e=>{clearTimeout(o),i()?s(new l):t(e)};t.then(a(n),a(s))})})(n(a,{...r,signal:y,timeout:void 0}),r.timeout,p);if(!v.ok&&r.throwHttpErrors)throw r.handleError&&await r.handleError(v),new d(v);return v.iterator=function(){const t=b(v.body);if(!m(t))throw new Error("Can't convert fetch body into a Async Iterator:");return t},v.ndjson=async function*(){for await(const t of g(v.iterator()))e.transform?yield e.transform(t):yield t},v}post(t,e={}){return this.fetch(t,{...e,method:"POST"})}get(t,e={}){return this.fetch(t,{...e,method:"GET"})}put(t,e={}){return this.fetch(t,{...e,method:"PUT"})}delete(t,e={}){return this.fetch(t,{...e,method:"DELETE"})}options(t,e={}){return this.fetch(t,{...e,method:"OPTIONS"})}}const g=async function*(t){const e=new a;let r="";for await(const n of t){r+=e.decode(n,{stream:!0});const t=r.split(/\r?\n/);for(let e=0;e0&&(yield JSON.parse(r))}r=t[t.length-1]}r+=e.decode(),r=r.trim(),0!==r.length&&(yield JSON.parse(r))},b=function(t){if(m(t)){if(Object.prototype.hasOwnProperty.call(t,"readable")&&Object.prototype.hasOwnProperty.call(t,"writable")){const e=t[Symbol.asyncIterator](),r={next:e.next.bind(e),return:()=>(t.destroy(),e.return()),[Symbol.asyncIterator]:()=>r};return r}return t}const e=t.getReader();return{next:()=>e.read(),return:()=>(e.releaseLock(),{}),[Symbol.asyncIterator](){return this}}},m=t=>"object"==typeof t&&null!==t&&"function"==typeof t[Symbol.asyncIterator];y.HTTPError=d,y.TimeoutError=l,y.streamToAsyncIterator=b,y.post=(t,e)=>new y(e).post(t,e),y.get=(t,e)=>new y(e).get(t,e),y.put=(t,e)=>new y(e).put(t,e),y.delete=(t,e)=>new y(e).delete(t,e),y.options=(t,e)=>new y(e).options(t,e),t.exports=y},function(t,e,r){"use strict";"object"!=typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),t.exports=globalThis},function(t,e,r){"use strict";const{TextEncoder:n,TextDecoder:i}=r(79),s=new i,o=new n;t.exports={decodeText:t=>s.decode(t),encodeText:t=>o.encode(t),concat:function(t,e){const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}}},function(t,e,r){"use strict";const n=r(21)(r(137));r(81),r(436);const i=r(8),s=r(0),o=r(6),a=r(446);e=t.exports;const c={rsa:r(447),ed25519:r(453),secp256k1:r(455)(n,r(109))};e.supportedKeys=c,e.keysPBM=n;const u="secp256k1 support requires libp2p-crypto-secp256k1 package",h="ERR_MISSING_PACKAGE";function f(t){const e=c[t.toLowerCase()];if(!e){const e=Object.keys(c).join(" / ");throw s(new Error(`invalid or unsupported key type ${t}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}return e}e.keyStretcher=r(481),e.generateEphemeralKeyPair=r(483),e.generateKeyPair=async(t,e)=>f(t).generateKeyPair(e),e.generateKeyPairFromSeed=async(t,e,r)=>{const n=f(t);if("ed25519"!==t.toLowerCase())throw s(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return n.generateKeyPairFromSeed(e,r)},e.unmarshalPublicKey=t=>{const e=n.PublicKey.decode(t),r=e.Data;switch(e.Type){case n.KeyType.RSA:return c.rsa.unmarshalRsaPublicKey(r);case n.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PublicKey(r);case n.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PublicKey(r);throw s(new Error(u),h);default:f(e.Type)}},e.marshalPublicKey=(t,e)=>(f(e=(e||"rsa").toLowerCase()),t.bytes),e.unmarshalPrivateKey=async t=>{const e=n.PrivateKey.decode(t),r=e.Data;switch(e.Type){case n.KeyType.RSA:return c.rsa.unmarshalRsaPrivateKey(r);case n.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PrivateKey(r);case n.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PrivateKey(r);throw s(new Error(u),h);default:f(e.Type)}},e.marshalPrivateKey=(t,e)=>(f(e=(e||"rsa").toLowerCase()),t.bytes),e.import=async(t,r)=>{try{const n=await a.import(t,r);return e.unmarshalPrivateKey(n)}catch(h){}const n=i.pki.decryptRsaPrivateKey(t,r);if(null===n)throw s(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let u=i.asn1.toDer(i.pki.privateKeyToAsn1(n));return u=o(u.getBytes(),"ascii"),c.rsa.unmarshalRsaPrivateKey(u)}},function(t,e,r){"use strict";e.defined=function(t){return null!=t&&("number"!=typeof t||!isNaN(t))}},function(t,e,r){"use strict";t.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(t,e,r){"use strict";var n=r(8);n.pki=n.pki||{};var i=t.exports=n.pki.oids=n.oids=n.oids||{};function s(t,e){i[t]=e,i[e]=t}function o(t,e){i[t]=e}s("1.2.840.113549.1.1.1","rsaEncryption"),s("1.2.840.113549.1.1.4","md5WithRSAEncryption"),s("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),s("1.2.840.113549.1.1.7","RSAES-OAEP"),s("1.2.840.113549.1.1.8","mgf1"),s("1.2.840.113549.1.1.9","pSpecified"),s("1.2.840.113549.1.1.10","RSASSA-PSS"),s("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),s("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),s("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),s("1.3.101.112","EdDSA25519"),s("1.2.840.10040.4.3","dsa-with-sha1"),s("1.3.14.3.2.7","desCBC"),s("1.3.14.3.2.26","sha1"),s("2.16.840.1.101.3.4.2.1","sha256"),s("2.16.840.1.101.3.4.2.2","sha384"),s("2.16.840.1.101.3.4.2.3","sha512"),s("1.2.840.113549.2.5","md5"),s("1.2.840.113549.1.7.1","data"),s("1.2.840.113549.1.7.2","signedData"),s("1.2.840.113549.1.7.3","envelopedData"),s("1.2.840.113549.1.7.4","signedAndEnvelopedData"),s("1.2.840.113549.1.7.5","digestedData"),s("1.2.840.113549.1.7.6","encryptedData"),s("1.2.840.113549.1.9.1","emailAddress"),s("1.2.840.113549.1.9.2","unstructuredName"),s("1.2.840.113549.1.9.3","contentType"),s("1.2.840.113549.1.9.4","messageDigest"),s("1.2.840.113549.1.9.5","signingTime"),s("1.2.840.113549.1.9.6","counterSignature"),s("1.2.840.113549.1.9.7","challengePassword"),s("1.2.840.113549.1.9.8","unstructuredAddress"),s("1.2.840.113549.1.9.14","extensionRequest"),s("1.2.840.113549.1.9.20","friendlyName"),s("1.2.840.113549.1.9.21","localKeyId"),s("1.2.840.113549.1.9.22.1","x509Certificate"),s("1.2.840.113549.1.12.10.1.1","keyBag"),s("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),s("1.2.840.113549.1.12.10.1.3","certBag"),s("1.2.840.113549.1.12.10.1.4","crlBag"),s("1.2.840.113549.1.12.10.1.5","secretBag"),s("1.2.840.113549.1.12.10.1.6","safeContentsBag"),s("1.2.840.113549.1.5.13","pkcs5PBES2"),s("1.2.840.113549.1.5.12","pkcs5PBKDF2"),s("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),s("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),s("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),s("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),s("1.2.840.113549.2.7","hmacWithSHA1"),s("1.2.840.113549.2.8","hmacWithSHA224"),s("1.2.840.113549.2.9","hmacWithSHA256"),s("1.2.840.113549.2.10","hmacWithSHA384"),s("1.2.840.113549.2.11","hmacWithSHA512"),s("1.2.840.113549.3.7","des-EDE3-CBC"),s("2.16.840.1.101.3.4.1.2","aes128-CBC"),s("2.16.840.1.101.3.4.1.22","aes192-CBC"),s("2.16.840.1.101.3.4.1.42","aes256-CBC"),s("2.5.4.3","commonName"),s("2.5.4.5","serialName"),s("2.5.4.6","countryName"),s("2.5.4.7","localityName"),s("2.5.4.8","stateOrProvinceName"),s("2.5.4.9","streetAddress"),s("2.5.4.10","organizationName"),s("2.5.4.11","organizationalUnitName"),s("2.5.4.13","description"),s("2.5.4.15","businessCategory"),s("2.5.4.17","postalCode"),s("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),s("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),s("2.16.840.1.113730.1.1","nsCertType"),s("2.16.840.1.113730.1.13","nsComment"),o("2.5.29.1","authorityKeyIdentifier"),o("2.5.29.2","keyAttributes"),o("2.5.29.3","certificatePolicies"),o("2.5.29.4","keyUsageRestriction"),o("2.5.29.5","policyMapping"),o("2.5.29.6","subtreesConstraint"),o("2.5.29.7","subjectAltName"),o("2.5.29.8","issuerAltName"),o("2.5.29.9","subjectDirectoryAttributes"),o("2.5.29.10","basicConstraints"),o("2.5.29.11","nameConstraints"),o("2.5.29.12","policyConstraints"),o("2.5.29.13","basicConstraints"),s("2.5.29.14","subjectKeyIdentifier"),s("2.5.29.15","keyUsage"),o("2.5.29.16","privateKeyUsagePeriod"),s("2.5.29.17","subjectAltName"),s("2.5.29.18","issuerAltName"),s("2.5.29.19","basicConstraints"),o("2.5.29.20","cRLNumber"),o("2.5.29.21","cRLReason"),o("2.5.29.22","expirationDate"),o("2.5.29.23","instructionCode"),o("2.5.29.24","invalidityDate"),o("2.5.29.25","cRLDistributionPoints"),o("2.5.29.26","issuingDistributionPoint"),o("2.5.29.27","deltaCRLIndicator"),o("2.5.29.28","issuingDistributionPoint"),o("2.5.29.29","certificateIssuer"),o("2.5.29.30","nameConstraints"),s("2.5.29.31","cRLDistributionPoints"),s("2.5.29.32","certificatePolicies"),o("2.5.29.33","policyMappings"),o("2.5.29.34","policyConstraints"),s("2.5.29.35","authorityKeyIdentifier"),o("2.5.29.36","policyConstraints"),s("2.5.29.37","extKeyUsage"),o("2.5.29.46","freshestCRL"),o("2.5.29.54","inhibitAnyPolicy"),s("1.3.6.1.4.1.11129.2.4.2","timestampList"),s("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),s("1.3.6.1.5.5.7.3.1","serverAuth"),s("1.3.6.1.5.5.7.3.2","clientAuth"),s("1.3.6.1.5.5.7.3.3","codeSigning"),s("1.3.6.1.5.5.7.3.4","emailProtection"),s("1.3.6.1.5.5.7.3.8","timeStamping")},function(t,e,r){"use strict";var n=r(8);function i(t,e){n.cipher.registerAlgorithm(t,(function(){return new n.aes.Algorithm(t,e)}))}r(227),r(228),r(22),t.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(t,e,r,n){var i=p({key:t,output:r,decrypt:!1,mode:n});return i.start(e),i},n.aes.createEncryptionCipher=function(t,e){return p({key:t,output:null,decrypt:!1,mode:e})},n.aes.startDecrypting=function(t,e,r,n){var i=p({key:t,output:r,decrypt:!0,mode:n});return i.start(e),i},n.aes.createDecryptionCipher=function(t,e){return p({key:t,output:null,decrypt:!0,mode:e})},n.aes.Algorithm=function(t,e){h||f();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(t,e){return d(r._w,t,e,!1)},decrypt:function(t,e){return d(r._w,t,e,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e,r=t.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){e=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&f^99,s[y]=f,o[f]=y,d=(l=t[f])<<24^f<<16^f<<8^f^l,p=((r=t[y])^(n=t[r])^(i=t[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var b=0;b<4;++b)c[b][y]=d,u[b][f]=p,d=d<<24|d>>>8,p=p<<24|p>>>8;0===y?y=g=1:(y=r^t[t[t[r^i]]],g^=t[t[g]])}}function l(t,e){for(var r,n=t.slice(0),i=1,o=n.length,c=4*(o+6+1),h=o;h>>16&255]<<24^s[r>>>8&255]<<16^s[255&r]<<8^s[r>>>24]^a[i]<<24,i++):o>6&&h%o==4&&(r=s[r>>>24]<<24^s[r>>>16&255]<<16^s[r>>>8&255]<<8^s[255&r]),n[h]=n[h-o]^r;if(e){for(var f,l=u[0],d=u[1],p=u[2],y=u[3],g=n.slice(0),b=(h=0,(c=n.length)-4);h>>24]]^d[s[f>>>16&255]]^p[s[f>>>8&255]]^y[s[255&f]];n=g}return n}function d(t,e,r,n){var i,a,h,f,l,d,p,y,g,b,m,v,w=t.length/4-1;n?(i=u[0],a=u[1],h=u[2],f=u[3],l=o):(i=c[0],a=c[1],h=c[2],f=c[3],l=s),d=e[0]^t[0],p=e[n?3:1]^t[1],y=e[2]^t[2],g=e[n?1:3]^t[3];for(var _=3,E=1;E>>24]^a[p>>>16&255]^h[y>>>8&255]^f[255&g]^t[++_],m=i[p>>>24]^a[y>>>16&255]^h[g>>>8&255]^f[255&d]^t[++_],v=i[y>>>24]^a[g>>>16&255]^h[d>>>8&255]^f[255&p]^t[++_],g=i[g>>>24]^a[d>>>16&255]^h[p>>>8&255]^f[255&y]^t[++_],d=b,p=m,y=v;r[0]=l[d>>>24]<<24^l[p>>>16&255]<<16^l[y>>>8&255]<<8^l[255&g]^t[++_],r[n?3:1]=l[p>>>24]<<24^l[y>>>16&255]<<16^l[g>>>8&255]<<8^l[255&d]^t[++_],r[2]=l[y>>>24]<<24^l[g>>>16&255]<<16^l[d>>>8&255]<<8^l[255&p]^t[++_],r[n?1:3]=l[g>>>24]<<24^l[d>>>16&255]<<16^l[p>>>8&255]<<8^l[255&y]^t[++_]}function p(t){var e,r="AES-"+((t=t||{}).mode||"CBC").toUpperCase(),i=(e=t.decrypt?n.cipher.createDecipher(r,t.key):n.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=t,i.call(e,r)},e}},function(t,e){},function(t,e,r){"use strict";var n=r(8);if(r(81),r(107),r(138),r(443),r(445),r(82),r(22),void 0===i)var i=n.jsbn.BigInteger;var s=n.util.isNodejs?r(140):null,o=n.asn1,a=n.util;n.pki=n.pki||{},t.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],h={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},f={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},l={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},d=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p=function(t){var e;if(!(t.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}e=c.oids[t.algorithm];var n=o.oidToDer(e).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);s.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),s.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var a=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(s),i.value.push(a),o.toDer(i).getBytes()},y=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);var s;e.dP||(e.dP=e.d.mod(e.p.subtract(i.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(i.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));do{s=new i(n.util.bytesToHex(n.random.getBytes(e.n.bitLength()/8)),16)}while(s.compareTo(e.n)>=0||!s.gcd(e.n).equals(i.ONE));for(var o=(t=t.multiply(s.modPow(e.e,e.n)).mod(e.n)).mod(e.p).modPow(e.dP,e.p),a=t.mod(e.q).modPow(e.dQ,e.q);o.compareTo(a)<0;)o=o.add(e.p);var c=o.subtract(a).multiply(e.qInv).mod(e.p).multiply(e.q).add(a);return c=c.multiply(s.modInverse(e.n)).mod(e.n)};function g(t,e,r){var i=n.util.createBuffer(),s=Math.ceil(e.n.bitLength()/8);if(t.length>s-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=t.length,o.max=s-11,o}i.putByte(0),i.putByte(r);var a,c=s-3-t.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var h=0,f=n.random.getBytes(c);for(u=0;u1;){if(255!==o.getByte()){--o.read;break}++u}else if(2===c)for(u=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++u}if(0!==o.getByte()||u!==s-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function m(t,e,r){"function"==typeof e&&(r=e,e={});var s={algorithm:{name:(e=e||{}).algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};function o(){a(t.pBits,(function(e,n){return e?r(e):(t.p=n,null!==t.q?u(e,t.q):void a(t.qBits,u))}))}function a(t,e){n.prime.generateProbablePrime(t,s,e)}function u(e,n){if(e)return r(e);if(t.q=n,t.p.compareTo(t.q)<0){var s=t.p;t.p=t.q,t.q=s}if(0!==t.p.subtract(i.ONE).gcd(t.e).compareTo(i.ONE))return t.p=null,void o();if(0!==t.q.subtract(i.ONE).gcd(t.e).compareTo(i.ONE))return t.q=null,void a(t.qBits,u);if(t.p1=t.p.subtract(i.ONE),t.q1=t.q.subtract(i.ONE),t.phi=t.p1.multiply(t.q1),0!==t.phi.gcd(t.e).compareTo(i.ONE))return t.p=t.q=null,void o();if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits)return t.q=null,void a(t.qBits,u);var h=t.e.modInverse(t.phi);t.keys={privateKey:c.rsa.setPrivateKey(t.n,t.e,h,t.p,t.q,h.mod(t.p1),h.mod(t.q1),t.q.modInverse(t.p)),publicKey:c.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}"prng"in e&&(s.prng=e.prng),o()}function v(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=n.util.hexToBytes(e);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function w(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function _(t){return n.util.isNodejs&&"function"==typeof s[t]}function E(t){return void 0!==a.globalScope&&"object"==typeof a.globalScope.crypto&&"object"==typeof a.globalScope.crypto.subtle&&"function"==typeof a.globalScope.crypto.subtle[t]}function S(t){return void 0!==a.globalScope&&"object"==typeof a.globalScope.msCrypto&&"object"==typeof a.globalScope.msCrypto.subtle&&"function"==typeof a.globalScope.msCrypto.subtle[t]}function I(t){for(var e=n.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),i=0;i0;)h.putByte(0),--f;return h.putBytes(n.util.hexToBytes(u)),h.getBytes()},c.rsa.decrypt=function(t,e,r,s){var o=Math.ceil(e.n.bitLength()/8);if(t.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=t.length,a.expected=o,a}var c=new i(n.util.createBuffer(t).toHex(),16);if(c.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,e,r).toString(16),h=n.util.createBuffer(),f=o-Math.ceil(u.length/2);f>0;)h.putByte(0),--f;return h.putBytes(n.util.hexToBytes(u)),!1!==s?b(h.getBytes(),e,r):h.getBytes()},c.rsa.createKeyPairGenerationState=function(t,e,r){"string"==typeof t&&(t=parseInt(t,10)),t=t||2048;var s,o=(r=r||{}).prng||n.random,a={nextBytes:function(t){for(var e=o.getBytesSync(t.length),r=0;r>1,pBits:t-(t>>1),pqState:0,num:null,keys:null}).e.fromInt(s.eInt),s},c.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,s=0,o=function(t,e){return t|e},a=+new Date,h=0;null===t.keys&&(e<=0||hf?t.pqState=0:t.num.isProbablePrime(w(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(u[s++%8],0):2===t.pqState?t.pqState=0===t.num.subtract(i.ONE).gcd(t.e).compareTo(i.ONE)?3:0:3===t.pqState&&(t.pqState=0,null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state,t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(i.ONE),t.q1=t.q.subtract(i.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(i.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var d=t.e.modInverse(t.phi);t.keys={privateKey:c.rsa.setPrivateKey(t.n,t.e,d,t.p,t.q,d.mod(t.p1),d.mod(t.q1),t.q.modInverse(t.p)),publicKey:c.rsa.setPublicKey(t.n,t.e)}}h+=(n=+new Date)-a,a=n}return null!==t.keys},c.rsa.generateKeyPair=function(t,e,r,i){if(1===arguments.length?"object"==typeof t?(r=t,t=void 0):"function"==typeof t&&(i=t,t=void 0):2===arguments.length?"number"==typeof t?"function"==typeof e?(i=e,e=void 0):"number"!=typeof e&&(r=e,e=void 0):(r=t,i=e,t=void 0,e=void 0):3===arguments.length&&("number"==typeof e?"function"==typeof r&&(i=r,r=void 0):(i=r,r=e,e=void 0)),r=r||{},void 0===t&&(t=r.bits||2048),void 0===e&&(e=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(65537===e||3===e))if(i){if(_("generateKeyPair"))return s.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(t,e,r){if(t)return i(t);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(e)})}));if(E("generateKey")&&E("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:I(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(t){return a.globalScope.crypto.subtle.exportKey("pkcs8",t.privateKey)})).then(void 0,(function(t){i(t)})).then((function(t){if(t){var e=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));i(null,{privateKey:e,publicKey:c.setRsaPublicKey(e.n,e.e)})}}));if(S("generateKey")&&S("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:I(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(t){var e=t.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",e.privateKey);r.oncomplete=function(t){var e=t.target.result,r=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(t){i(t)}},void(u.onerror=function(t){i(t)})}}else if(_("generateKeyPairSync")){var h=s.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(h.privateKey),publicKey:c.publicKeyFromPem(h.publicKey)}}var f=c.rsa.createKeyPairGenerationState(t,e,r);if(!i)return c.rsa.stepKeyPairGenerationState(f,0),f.keys;m(f,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(t,e){var r={n:t,e:e,encrypt:function(t,e,i){if("string"==typeof e?e=e.toUpperCase():void 0===e&&(e="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===e)e={encode:function(t,e,r){return g(t,e,2).getBytes()}};else if("RSA-OAEP"===e||"RSAES-OAEP"===e)e={encode:function(t,e){return n.pkcs1.encode_rsa_oaep(e,t,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(e))e={encode:function(t){return t}};else if("string"==typeof e)throw new Error('Unsupported encryption scheme: "'+e+'".');var s=e.encode(t,r,!0);return c.rsa.encrypt(s,r,!0)},verify:function(t,e,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(t,e){return e=b(e,r,!0),t===o.fromDer(e).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(t,e){return t===(e=b(e,r,!0))}});var i=c.rsa.decrypt(e,r,!0,!1);return n.verify(t,i,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(t,e,r,i,s,o,a,u){var h={n:t,e:e,d:r,p:i,q:s,dP:o,dQ:a,qInv:u,decrypt:function(t,e,r){"string"==typeof e?e=e.toUpperCase():void 0===e&&(e="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(t,h,!1,!1);if("RSAES-PKCS1-V1_5"===e)e={decode:b};else if("RSA-OAEP"===e||"RSAES-OAEP"===e)e={decode:function(t,e){return n.pkcs1.decode_rsa_oaep(e,t,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(e))throw new Error('Unsupported encryption scheme: "'+e+'".');e={decode:function(t){return t}}}return e.decode(i,h,!1)},sign:function(t,e){var r=!1;"string"==typeof e&&(e=e.toUpperCase()),void 0===e||"RSASSA-PKCS1-V1_5"===e?(e={encode:p},r=1):"NONE"!==e&&"NULL"!==e&&null!==e||(e={encode:function(){return t}},r=1);var n=e.encode(t,h.n.bitLength());return c.rsa.encrypt(n,h,r)}};return h},c.wrapRsaPrivateKey=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(t).getBytes())])},c.privateKeyFromAsn1=function(t){var e,r,s,a,u,l,d,p,y={},g=[];if(o.validate(t,h,y,g)&&(t=o.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!o.validate(t,f,y,g)){var b=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw b.errors=g,b}return e=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),s=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrime1).toHex(),u=n.util.createBuffer(y.privateKeyPrime2).toHex(),l=n.util.createBuffer(y.privateKeyExponent1).toHex(),d=n.util.createBuffer(y.privateKeyExponent2).toHex(),p=n.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(e,16),new i(r,16),new i(s,16),new i(a,16),new i(u,16),new i(l,16),new i(d,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.qInv))])},c.publicKeyFromAsn1=function(t){var e={},r=[];if(o.validate(t,d,e,r)){var s,a=o.derToOid(e.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(s=new Error("Cannot read public key. Unknown OID.")).oid=a,s;t=e.rsaPublicKey}if(r=[],!o.validate(t,l,e,r))throw(s=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,s;var u=n.util.createBuffer(e.publicKeyModulus).toHex(),h=n.util.createBuffer(e.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(h,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(t)])])},c.publicKeyToRSAPublicKey=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.e))])}},function(t,e,r){"use strict";r(22),r(107);const n=r(8),i=r(6),s=r(5),o=r(26);e.bigIntegerToUintBase64url=(t,e)=>{let r=Uint8Array.from(t.abs().toByteArray());if(r=0===r[0]?r.slice(1):r,null!=e){if(r.length>e)throw new Error("byte array longer than desired length");r=o([new Uint8Array(e-r.length),r])}return s(r,"base64url")},e.base64urlToBigInteger=t=>{const r=e.base64urlToBuffer(t);return new n.jsbn.BigInteger(s(r,"base16"),16)},e.base64urlToBuffer=(t,e)=>{let r=i(t,"base64urlpad");if(null!=e){if(r.length>e)throw new Error("byte array longer than desired length");r=o([new Uint8Array(e-r.length),r])}return r}},function(t,e,r){"use strict";const n=r(31),i=r(230);t.exports={export:async function(t,e){const r=i.create(),s=await r.encrypt(t,e);return n.names.base64.encode(s)}}},function(t,e,r){"use strict";var n,i=e,s=r(145),o=r(235),a=r(35).assert;function c(t){"short"===t.type?this.curve=new o.short(t):"edwards"===t.type?this.curve=new o.edwards(t):this.curve=new o.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:s.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:s.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(473)}catch(h){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(t,e,r){"use strict";var n=e;n.utils=r(38),n.common=r(84),n.sha=r(467),n.ripemd=r(471),n.hmac=r(472),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(t,e,r){"use strict";function n(t){if("number"==typeof t){if(n.codes[t])return n.codes[t];throw new Error("no protocol with code: "+t)}if("string"==typeof t||t instanceof String){if(n.names[t])return n.names[t];throw new Error("no protocol with name: "+t)}throw new Error("invalid protocol id type: "+t)}const i=-1;function s(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:Boolean(n),path:Boolean(i)}}n.lengthPrefixedVarSize=i,n.V=i,n.table=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,i,"ip6zone"],[53,i,"dns","resolvable"],[54,i,"dns4","resolvable"],[55,i,"dns6","resolvable"],[56,i,"dnsaddr","resolvable"],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,i,"unix",!1,"path"],[421,i,"ipfs"],[421,i,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,i,"garlic64"],[460,0,"quic"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,i,"memory"]],n.names={},n.codes={},n.table.map(t=>{const e=s.apply(null,t);n.codes[e.code]=e,n.names[e.name]=e}),n.object=s,t.exports=n},function(t,e,r){"use strict";const n=r(241),i=r(33).bind({ignoreUndefined:!0}),s={chunker:"fixed",strategy:"balanced",rawLeaves:!1,onlyHash:!1,reduceSingleLeafToSelf:!0,codec:"dag-pb",hashAlg:"sha2-256",leafType:"file",cidVersion:0,progress:()=>()=>{},shardSplitThreshold:1e3,fileImportConcurrency:50,blockWriteConcurrency:10,minChunkSize:262144,maxChunkSize:262144,avgChunkSize:262144,window:16,polynomial:0x3df305dfb2a804,maxChildrenPerNode:174,layerRepeat:4,wrapWithDirectory:!1,pin:!1,recursive:!1,hidden:!1,preload:!1,chunkValidator:null,importBuffer:null};t.exports=async function*(t,e,o={}){const a=i(s,o);let c,u;o.cidVersion>0&&void 0===o.rawLeaves&&(a.rawLeaves=!0),void 0!==o.hashAlg&&void 0===o.rawLeaves&&(a.rawLeaves=!0),"trickle"===o.strategy&&(a.leafType="raw",a.reduceSingleLeafToSelf=!1),o.format&&(a.codec=o.format),c="function"==typeof o.dagBuilder?o.dagBuilder:r(508),u="function"==typeof o.treeBuilder?o.treeBuilder:r(530);for await(const r of u(n(c(t,e,a),a.fileImportConcurrency),e,a))yield{cid:r.cid,path:r.path,unixfs:r.unixfs,size:r.size}}},function(t,e,r){"use strict";t.exports=async function*(t,e){e=parseInt(e),(isNaN(e)||e<1)&&(e=1);let r=[];for await(const n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length;)yield r.slice(0,e),r=r.slice(e)}},function(t,e,r){"use strict";t.exports=function(t,e){for(let r=0;re[r])return 1}return t.byteLength>e.byteLength?1:t.byteLengthe instanceof o?t+e.leafCount():t+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){const t=this._children.compactArray();for(const e of t)if(e instanceof o)for(const t of e.eachLeafSeries())yield t;else yield e}serialize(t,e){return e(this._children.reduce((r,n,i)=>(n&&(n instanceof o?r.push(n.serialize(t,e)):r.push(t(n,i))),r),[]))}asyncTransform(t,e){return async function t(e,r,n){const i=[];for(const s of e._children.compactArray()){if(s instanceof o)await t(s,r,n);else{const t=await r(s);i.push({bitField:e._children.bitField(),children:t})}return n(i)}}(this,t,e)}toJSON(){return this.serialize(c,u)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(t){const e=await this._findPlace(t),r=e.bucket._at(e.pos);if(r&&r.key===t)return r}async _findPlace(t){const e=this._options.hash(t),r=await e.take(this._options.bits),n=this._children.get(r);return n instanceof o?n._findPlace(e):{bucket:this,pos:r,hash:e}}async _findNewBucketAndPos(t){const e=await this._findPlace(t),r=e.bucket._at(e.pos);if(r&&r.key!==t){const t=new o(this._options,e.bucket,e.pos);e.bucket._putObjectAt(e.pos,t);const n=await t._findPlace(r.hash);return n.bucket._putAt(n,r.key,r.value),t._findNewBucketAndPos(e.hash)}return e}_putAt(t,e,r){this._putObjectAt(t.pos,{key:e,value:r,hash:t.hash})}_putObjectAt(t,e){this._children.get(t)||this._popCount++,this._children.set(t,e)}_delAt(t){this._children.get(t)&&this._popCount--,this._children.unset(t),this._level()}_level(){if(this._parent&&this._popCount<=1)if(1===this._popCount){const t=this._children.find(a);if(!(t instanceof o)){const e=t.hash;e.untake(this._options.bits);const r={pos:this._posAtParent,hash:e};this._parent._putAt(r,t.key,t.value)}}else this._parent._delAt(this._posAtParent)}_at(t){return this._children.get(t)}}function a(t){return Boolean(t)}function c(t,e){return t.key}function u(t){return t}t.exports=o},function(t,e,r){"use strict";t.exports=async t=>{for await(const e of t)return e}},function(t,e,r){"use strict";t.exports=async function*(t,e={}){const r=t.getReader();try{for(;;){const t=await r.read();if(t.done)return;yield t.value}}finally{!0!==e.preventCancel&&r.cancel(),r.releaseLock()}}},function(t,e,r){"use strict";t.exports=async function*(t,e){for await(const r of t)yield e(r)}},function(t,e,r){"use strict";var n=r(543);function i(t,e,r){var i=this;this._started=n(),this._rescheduled=0,this._scheduled=e,this._args=r,this._timer=setTimeout((function e(){i._rescheduled>0?(i._scheduled=i._rescheduled-(n()-i._started),i._timer=setTimeout(e,i._scheduled),i._rescheduled=0):t.apply(null,i._args)}),e)}i.prototype.reschedule=function(t){var e=n();return!(e+t-(this._started+this._scheduled)<0)&&(this._started=e,this._rescheduled=t,!0)},i.prototype.clear=function(){clearTimeout(this._timer)},t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");var t;if(arguments.length>0){t=new Array(arguments.length-2);for(var e=0;easync function*(){for await(const r of t){await e(r)&&(yield r)}}(),e.sortAll=(t,e)=>async function*(){let r=[];for await(const e of t)r.push(e);r=await e(r);for(const t of r)yield t}(),e.take=(t,e)=>async function*(){if(e<=0)return;let r=0;for await(const n of t)if(yield n,r++,r>=e)return}(),e.map=(t,e)=>async function*(){for await(const r of t)yield e(r)}(),e.replaceStartWith=function(t,e){const r=new RegExp("^"+e);return t.replace(r,"")},e.tmpdir=n},function(t,e,r){"use strict";const n=r(4),i=r(0);e.cleanCid=t=>{if(n.isCID(t))return t;try{return new n(t)}catch(e){throw i(e,"ERR_INVALID_CID")}}},function(t,e,r){"use strict";e.util=r(259),e.resolver=r(558),e.codec=e.util.codec,e.defaultHashAlg=e.util.defaultHashAlg},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=r(30).BigNumber,s=r(114),o=s.SHIFT32,a=s.SHIFT16;e.parseHalf=function(t){var e,r,n;return n=128&t[0]?-1:1,e=(124&t[0])>>2,r=(3&t[0])<<8|t[1],e?31===e?n*(r?NaN:Infinity):n*Math.pow(2,e-25)*(1024+r):5.960464477539063e-8*n*r},e.arrayBufferToBignumber=function(t){const e=t.byteLength;let r="";for(let i=0;i{const e=new Map,r=Object.keys(t),n=r.length;for(let i=0;it*a+e,e.buildInt64=(t,r,n,s)=>{const a=e.buildInt32(t,r),c=e.buildInt32(n,s);return a>2097151?new i(a).times(o).plus(c):a*o+c},e.writeHalf=function(t,e){const r=n.allocUnsafe(4);r.writeFloatBE(e,0);const i=r.readUInt32BE(0);if(0!=(8191&i))return!1;var s=i>>16&32768;const o=i>>23&255,a=8388607&i;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else{if(!(o>=103&&o<113))return!1;if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}return t.writeUInt16BE(s,0),!0},e.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])},e.isNegativeZero=t=>0===t&&1/t<0,e.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;0!==t;)t>>=1,e+=1;return 1<-1?setImmediate:i.nextTick;b.WritableState=g;var c=Object.create(r(89));c.inherits=r(23);var u={deprecate:r(267)},h=r(265),f=r(163).Buffer,l=n.Uint8Array||function(){};var d,p=r(266);function y(){}function g(t,e){o=o||r(53),t=t||{};var n=e instanceof o;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var c=t.highWaterMark,u=t.writableHighWaterMark,h=this.objectMode?16:16384;this.highWaterMark=c||0===c?c:n&&(u||0===u)?u:h,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 f=!1===t.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,s=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,s){--e.pendingcb,r?(i.nextTick(s,n),i.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(s(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,s);else{var o=_(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?a(v,t,r,o,s):v(t,r,o,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function b(t){if(o=o||r(53),!(d.call(b,this)||this instanceof o))return new b(t);this._writableState=new g(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function m(t,e,r,n,i,s,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function v(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,m(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,h=r.encoding,f=r.callback;if(m(t,e,!1,e.objectMode?1:u.length,u,h,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final((function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)}))}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,i.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(b,h),g.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(g.prototype,"buffer",{get:u.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===b&&(t&&t._writableState instanceof g)}})):d=function(t){return t instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(t,e,r){var n,s=this._writableState,o=!1,a=!s.objectMode&&(n=t,f.isBuffer(n)||n instanceof l);return a&&!f.isBuffer(t)&&(t=function(t){return f.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=s.defaultEncoding),"function"!=typeof r&&(r=y),s.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),i.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var s=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),i.nextTick(n,o),s=!1),s}(this,s,t,r))&&(s.pendingcb++,o=function(t,e,r,n,i,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=f.from(e,r));return e}(e,n,i);n!==o&&(r=!0,i="buffer",n=o)}var a=e.objectMode?1:n.length;e.length+=a;var c=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),b.prototype.destroy=p.destroy,b.prototype._undestroy=p.undestroy,b.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,r(12),r(11))},function(t,e,r){"use strict";const n=r(30).BigNumber,i=r(66),s=r(166),o=new n(-1),a=new n(10),c=new n(2);class u{constructor(t,e,r){if(this.tag=t,this.value=e,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){let e=null!=t?t[this.tag]:void 0;if("function"!=typeof e&&(e=u["_tag_"+this.tag],"function"!=typeof e))return this;try{return e.call(u,this.value)}catch(r){return this.err=r,this}}static _tag_0(t){return new Date(t)}static _tag_1(t){return new Date(1e3*t)}static _tag_2(t){return i.bufferToBignumber(t)}static _tag_3(t){return o.minus(i.bufferToBignumber(t))}static _tag_4(t){return a.pow(t[0]).times(t[1])}static _tag_5(t){return c.pow(t[0]).times(t[1])}static _tag_32(t){return s.parse(t)}static _tag_35(t){return new RegExp(t)}}t.exports=u},function(t,e,r){"use strict";var n=r(572),i=r(573);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=v,e.resolve=function(t,e){return v(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?v(t,!1,!0).resolveObject(e):e},e.format=function(t){i.isString(t)&&(t=v(t));return t instanceof s?t.format():s.prototype.format.call(t)},e.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(u),f=["%","/","?",";","#"].concat(h),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=r(574);function v(t,e,r){if(t&&i.isObject(t)&&t instanceof s)return t;var n=new s;return n.parse(t,e,r),n}s.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s127?N+="x":N+=x[P];if(!N.match(d)){var D=B.slice(0,T),L=B.slice(T+1),U=x.match(p);U&&(D.push(U[1]),L.unshift(U[2])),L.length&&(v="/"+L.join(".")+v),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=n.toASCII(this.hostname));var j=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+j,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!y[E])for(T=0,M=h.length;T0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],k=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,T=0,R=S.length;R>=0;R--)"."===(A=S[R])?S.splice(R,1):".."===A?(S.splice(R,1),T++):T&&(S.splice(R,1),T--);if(!_&&!E)for(;T--;T)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),k&&"/"!==S.join("/").substr(-1)&&S.push("");var C,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);I&&(r.hostname=r.host=B?"":S.length?S.shift():"",(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){"use strict";t.exports=()=>({Addresses:{Swarm:[],API:"",Gateway:"",Delegates:["/dns4/node0.delegate.ipfs.io/tcp/443/https","/dns4/node1.delegate.ipfs.io/tcp/443/https","/dns4/node2.delegate.ipfs.io/tcp/443/https","/dns4/node3.delegate.ipfs.io/tcp/443/https"]},Discovery:{MDNS:{Enabled:!1,Interval:10},webRTCStar:{Enabled:!0}},Bootstrap:["/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/dns4/node0.preload.ipfs.io/tcp/443/wss/p2p/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic","/dns4/node1.preload.ipfs.io/tcp/443/wss/p2p/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6","/dns4/node2.preload.ipfs.io/tcp/443/wss/p2p/QmV7gnbW5VTcJ3oyM2Xk1rdFBJ3kTkvxc87UFGsun29STS","/dns4/node3.preload.ipfs.io/tcp/443/wss/p2p/QmY7JB6MQXhxHvq7dBDh4HpbH29v4yE9JRadAVpndvzySN"],Pubsub:{Enabled:!0},Swarm:{ConnMgr:{LowWater:200,HighWater:500}},Routing:{Type:"none"}})},function(t,e,r){"use strict";t.exports=function(t,e,r,n){const i=e+t.length;return r>=i||n=e&&n=e&&r{if(e||(e=0),e<0)throw n(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(e>t)throw n(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(r||0===r||(r=t-e),r<0)throw n(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");return e+r>t&&(r=t-e),{offset:e,length:r}}},function(t,e,r){"use strict";t.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function i(i,s){r[i]=s,++e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(t){return void 0!==r[t]||void 0!==n[t]},remove:function(t){void 0!==r[t]&&(r[t]=void 0),void 0!==n[t]&&(n[t]=void 0)},get:function(t){var e=r[t];return void 0!==e?e:void 0!==(e=n[t])?(i(t,e),e):void 0},set:function(t,e){void 0!==r[t]?r[t]=e:i(t,e)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},function(t,e,r){"use strict";t.exports=(t,e)=>(e=e||(()=>{}),t.then(t=>new Promise(t=>{t(e())}).then(()=>t),t=>new Promise(t=>{t(e())}).then(()=>{throw t})))},function(t,e,r){"use strict";t.exports=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean)},function(t,e,r){"use strict";const n=r(174),i=r(119),s=r(1)("ipfs:mfs:cp"),o=r(0),a=r(68),c=r(69),u=r(67),h=r(42),f=r(628),l=r(93),{withTimeoutOption:d}=r(2),p={parents:!1,flush:!0,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3,signal:void 0};t.exports=t=>d((async function(...e){let{sources:r,destination:a,options:c}=await f(t,e,p);if(!r.length)throw o(new Error("Please supply at least one source"),"ERR_INVALID_PARAMS");c.parents=c.p||c.parents;const u=r.find(t=>!t.exists);if(u)throw o(new Error(u.path+" does not exist"),"ERR_INVALID_PARAMS");const d=y(a);if(a.exists){if(s("Destination exists"),1===r.length&&!d)throw o(new Error("directory already has entry by that name"),"ERR_ALREADY_EXISTS")}else if(s("Destination does not exist"),r.length>1){if(!c.parents)throw o(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await n(t)(a.path,c),a=await h(t,a.path,c)}else if(a.parts.length>1){const e="/"+a.parts.slice(0,-1).join("/");try{await i(t)(e,c)}catch(w){if("ERR_NOT_FOUND"!==w.code)throw w;if(!c.parents)throw o(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await n(t)(e,c),a=await h(t,a.path,c)}}const m=y(a)?a.mfsPath:a.mfsDirectory,v=await l(t,m,c);if(1===r.length){const e=r.pop(),n=d?e.name:a.name;return s(`Only one source, copying to destination ${d?"directory":"file"} ${n}`),g(t,e,n,v,c)}return s("Multiple sources, wrapping in a directory"),b(t,r,a,v,c)}));const y=t=>t.unixfs&&t.unixfs.type&&t.unixfs.type.includes("directory"),g=async(t,e,r,n,i)=>{let s=n.pop();s=await m(t,e,r,s,i),n.push(s);const o=await a(t,n,i);await c(t,o,i)},b=async(t,e,r,n,i)=>{for(let o=0;o{const s=await t.repo.blocks.get(e.cid),{node:o,cid:a}=await u(t,{parentCid:n.cid,size:s.data.length,cid:e.cid,name:r,hashAlg:i.hashAlg,cidVersion:i.cidVersion,flush:i.flush});return n.node=o,n.cid=a,n.size=o.size,n}},function(t,e,r){"use strict";const n=r(0),i=r(1)("ipfs:mfs:mkdir"),s=r(39),o=r(627),a=r(172),c=r(69),u=r(68),h=r(67),f=r(283),l=r(46),{withTimeoutOption:d}=r(2),p={parents:!1,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3,flush:!0,mode:null,mtime:null,signal:void 0};t.exports=t=>d((async function(e,r){if(r=l(r,p),!e)throw new Error("no path given to Mkdir");if("/"===(e=e.trim())){if(r.parents)return;throw n(new Error("cannot create directory '/': Already exists"),"ERR_INVALID_PATH")}if("/"!==e.substring(0,1))throw n(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");i("Creating "+e);const h=a(e);if("ipfs"===h[0])throw n(new Error("path cannot have the prefix 'ipfs'"),"ERR_INVALID_PATH");const d=await f(t,r);let g;const b=[],m=await o(t,"directory",r);for(let o=0;o<=h.length;o++){const e=h.slice(0,o),a=`/ipfs/${d}/${e.join("/")}`;try{if(g=await s(a,t.ipld),i(a+" existed"),i(`${a} had children ${g.node.Links.map(t=>t.Name)}`),o===h.length){if(r.parents)return;throw n(new Error("file already exists"),"ERR_ALREADY_EXISTS")}b.push({name:g.name,cid:g.cid})}catch(w){if("ERR_NOT_FOUND"!==w.code)throw w;if(o{i(`Adding empty dir called ${e} to ${n.cid}`);const a=await h(t,{parent:n.node,parentCid:n.cid,size:r.node.size,cid:r.cid,name:e,hashAlg:o.hashAlg,cidVersion:o.cidVersion,flush:o.flush});s[s.length-1].cid=a.cid,s.push({name:e,cid:r.cid})}},function(t,e,r){"use strict";const n=r(42),i=r(46);t.exports=async function(t,e,r){const s=[];let o;for(let n=0;nh((async function(...e){const{sources:r,options:i}=await o(t,e,f);if(!r.length)throw n(new Error("Please supply at least one path to remove"),"ERR_INVALID_PARAMS");r.forEach(t=>{if("/"===t.path)throw n(new Error("Cannot delete root"),"ERR_INVALID_PARAMS")});for(const n of r)await l(t,n.path,i)}));const l=async(t,e,r)=>{const o=await c(t,e,r),h=await u(t,o.mfsPath,r),f=h.pop(),l=h[h.length-1];if(!l)throw n(new Error(e+" does not exist"),"ERR_NOT_FOUND");if("directory"===f.type&&!r.recursive)throw n(new Error(e+" is a directory, use -r to remove directories"),"ERR_WAS_DIR");const{cid:d}=await a(t,{parentCid:l.cid,name:f.name,hashAlg:r.hashAlg,cidVersion:r.cidVersion,flush:r.flush});l.cid=d;const p=await i(t,h,r);await s(t,p,r)}},function(t,e,r){"use strict";const n=r(286),i=r(1),s=r(30),o=r(0),a=r(641),c=r(658),u=r(659),h=r(660),f=r(661),l=r(662),d=r(663),p=r(665),y=r(668),g=r(669),b=r(671),m=r(712),v=r(180),w=i("ipfs:repo"),_=Number.MAX_SAFE_INTEGER,E={memory:r(312),fs:r(312)};async function S(t){const e=new s(0);for await(const r of t.query({}))e.plus(r.value.byteLength).plus(r.key.uint8Array().byteLength);return e}t.exports=class{constructor(t,e){if("string"!=typeof t)throw new Error("missing repoPath");this.options=function(t){const e=Object.assign({},b,t);return e.storageBackends=Object.assign({},b.storageBackends,e.storageBackends),e.storageBackendOptions=Object.assign({},b.storageBackendOptions,e.storageBackendOptions),e}(e),this.closed=!0,this.path=t,this._locker=this._getLocker(),this.root=f.create("root",this.path,this.options),this.version=l(this.root),this.config=d(this.root),this.spec=p(this.root),this.apiAddr=y(this.root)}async init(t){var e;w("initializing at: %s",this.path),await this._openRoot(),await this.config.set((e=t,e.datastore=Object.assign({},m,n(e,"datastore",{})),e)),await this.spec.set(function(t){const e=Object.assign({},m.Spec,n(t,"datastore.Spec",{}));return{type:e.type,mounts:e.mounts.map(t=>({mountpoint:t.mountpoint,type:t.child.type,path:t.child.path,shardFunc:t.child.shardFunc}))}}(t)),await this.version.set(h.repoVersion)}async isInitialized(){if(!this.closed)return!0;try{return await this._openRoot(),await this._checkInitialized(),await this.root.close(),!0}catch(t){return!1}}async open(){if(!this.closed)throw o(new Error("repo is already open"),v.ERR_REPO_ALREADY_OPEN);w("opening at: %s",this.path);try{await this._openRoot(),await this._checkInitialized(),this.lockfile=await this._openLock(this.path),w("acquired repo.lock");if(!await this.version.check(h.repoVersion)){if(!await this._isAutoMigrationEnabled())throw new v.InvalidRepoVersionError("Incompatible repo versions. Automatic migrations disabled. Please migrate the repo manually.");await this._migrate(h.repoVersion)}w("creating datastore"),this.datastore=f.create("datastore",u(this.path,"datastore"),this.options),await this.datastore.open(),w("creating blocks");const t=f.create("blocks",u(this.path,"blocks"),this.options);await t.open(),this.blocks=await g(t,this.options.storageBackendOptions.blocks),w("creating keystore"),this.keys=f.create("keys",u(this.path,"keys"),this.options),await this.keys.open(),w("creating pins"),this.pins=f.create("pins",u(this.path,"pins"),this.options),await this.pins.open(),this.closed=!1,w("all opened")}catch(t){if(this.lockfile)try{await this._closeLock(),this.lockfile=null}catch(e){w("error removing lock",e)}throw t}}_getLocker(){if("string"==typeof this.options.lock){if(!E[this.options.lock])throw new Error("Unknown lock type: "+this.options.lock);return E[this.options.lock]}if(!this.options.lock)throw new Error("No lock provided");return this.options.lock}async _openRoot(){try{await this.root.open()}catch(t){if("Already open"!==t.message)throw t}}async _openLock(t){const e=await this._locker.lock(t);if("function"!=typeof e.close)throw o(new Error("Locks must have a close method"),"ERR_NO_CLOSE_FUNCTION");return e}_closeLock(){return this.lockfile.close()}async _checkInitialized(){let t;w("init check");try{[t]=await Promise.all([this.config.exists(),this.spec.exists(),this.version.exists()])}catch(e){if("ERR_NOT_FOUND"===e.code)throw o(new Error("repo is not initialized yet"),v.ERR_REPO_NOT_INITIALIZED,{path:this.path});throw e}if(!t)throw o(new Error("repo is not initialized yet"),v.ERR_REPO_NOT_INITIALIZED,{path:this.path})}async close(){if(this.closed)throw o(new Error("repo is already closed"),v.ERR_REPO_ALREADY_CLOSED);w("closing at: %s",this.path);try{await this.apiAddr.delete()}catch(t){if(t.code!==v.ERR_REPO_NOT_INITIALIZED&&!t.message.startsWith("ENOENT"))throw t}await Promise.all([this.root,this.blocks,this.keys,this.datastore,this.pins].map(t=>t.close())),w("unlocking"),this.closed=!0,await this._closeLock(),this.lockfile=null}async exists(){return this.version.exists()}async stat(){const[t,e,r,n,i]=await Promise.all([this._storageMaxStat(),this._blockStat(),this.version.get(),S(this.datastore),S(this.keys)]),s=e.size.plus(n).plus(i);return{repoPath:this.path,storageMax:t,version:r,numObjects:e.count,repoSize:s}}async _isAutoMigrationEnabled(){if(void 0!==this.options.autoMigrate)return this.options.autoMigrate;let t;try{t=await this.config.get("repoAutoMigrate")}catch(e){if(e.code!==v.NotFoundError.code)throw e;t=!0}return t}async _migrate(t){return await this.version.get()>t?(w("reverting to version "+t),a.revert(this.path,this.options,t,{ignoreLock:!0,onProgress:this.options.onMigrationProgress})):(w("migrating to version "+t),a.migrate(this.path,this.options,t,{ignoreLock:!0,onProgress:this.options.onMigrationProgress}))}async _storageMaxStat(){try{const t=await this.config.get("Datastore.StorageMax");return new s(c(t))}catch(t){return new s(_)}}async _blockStat(){let t=new s(0),e=new s(0);for await(const r of this.blocks.query({}))t=t.plus(1),e=e.plus(r.data.byteLength).plus(r.cid.bytes.byteLength);return{count:t,size:e}}},t.exports.utils={blockstore:r(292)},t.exports.repoVersion=h.repoVersion,t.exports.errors=v},function(t,e,r){"use strict";const n=r(121),i=r(644),s=r(648),o=r(649),a=r(650),c=r(287);e.KeytransformDatastore=n,e.ShardingDatastore=i,e.MountDatastore=s,e.TieredDatastore=o,e.NamespaceDatastore=a,e.shard=c},function(t,e,r){"use strict";class n extends Error{constructor(t){super(t),this.name="NonReversibleMigrationError",this.code="ERR_NON_REVERSIBLE_MIGRATION",this.message=t}}n.code="ERR_NON_REVERSIBLE_MIGRATION",e.NonReversibleMigrationError=n;class i extends Error{constructor(t){super(t),this.name="NotInitializedRepoError",this.code="ERR_NOT_INITIALIZED_REPO",this.message=t}}i.code="ERR_NOT_INITIALIZED_REPO",e.NotInitializedRepoError=i;class s extends Error{constructor(t){super(t),this.name="RequiredParameterError",this.code="ERR_REQUIRED_PARAMETER",this.message=t}}s.code="ERR_REQUIRED_PARAMETER",e.RequiredParameterError=s;class o extends Error{constructor(t){super(t),this.name="InvalidValueError",this.code="ERR_INVALID_VALUE",this.message=t}}o.code="ERR_INVALID_VALUE",e.InvalidValueError=o;class a extends Error{constructor(t){super(t),this.name="MissingRepoOptionsError",this.code="ERR_MISSING_REPO_OPTIONS",this.message=t}}a.code="ERR_MISSING_REPO_OPTIONS",e.MissingRepoOptionsError=a},function(t,e,r){"use strict";class n extends Error{constructor(t){super(t),this.name="LockExistsError",this.code=n.code}}n.code="ERR_LOCK_EXISTS",e.LockExistsError=n;class i extends Error{constructor(t){super(t),this.name="NotFoundError",this.code=i.code}}i.code="ERR_NOT_FOUND",e.NotFoundError=i;class s extends Error{constructor(t){super(t),this.name="InvalidRepoVersionError",this.code=s.code}}s.code="ERR_INVALID_REPO_VERSION",e.InvalidRepoVersionError=s,e.ERR_REPO_NOT_INITIALIZED="ERR_REPO_NOT_INITIALIZED",e.ERR_REPO_ALREADY_OPEN="ERR_REPO_ALREADY_OPEN",e.ERR_REPO_ALREADY_CLOSED="ERR_REPO_ALREADY_CLOSED"},function(t,e,r){"use strict";var n=r(70),i=r(677);t.exports=function(){var t=n.apply(null,arguments);return i(t,{bufferKeys:t.bufferKeys||!1,snapshots:t.snapshots||!1,permanence:t.permanence||!1,seek:t.seek||!1,clear:t.clear||!1,status:t.status||!1,createIfMissing:t.createIfMissing||!1,errorIfExists:t.errorIfExists||!1,deferredOpen:t.deferredOpen||!1,openCallback:t.openCallback||!1,promises:t.promises||!1,streams:t.streams||!1,encodings:t.encodings||!1,additionalMethods:n(t.additionalMethods)})}},function(t,e,r){"use strict";t.exports=r(183)},function(t,e,r){"use strict";var n,i,s,o=[r(678),r(679),r(680),r(681),r(682)],a=-1,c=[],u=!1;function h(){n&&i&&(n=!1,i.length?c=i.concat(c):a=-1,c.length&&f())}function f(){if(!n){u=!1,n=!0;for(var t=c.length,e=setTimeout(h);t;){for(i=c,c=[];i&&++a1)for(var r=1;r{t=o(t);const n=u.encode(t.byteLength),i=u.encode(e.length),a=u.encode(r.length);return s([new Uint8Array(n),t,new Uint8Array(i),e,new Uint8Array(a),r])};d.createFromProtobuf=async t=>{const e=l.decode(t),r=await c.createFromPubKey(e.public_key);return new d({peerId:r,payloadType:e.payload_type,payload:e.payload,signature:e.signature})},d.seal=async(t,e)=>{const r=t.domain,n=t.codec,i=t.marshal(),s=p(r,n,i),o=await e.privKey.sign(s);return new d({peerId:e,payloadType:n,payload:i,signature:o})},d.openAndCertify=async(t,e)=>{const r=await d.createFromProtobuf(t);if(!await r.validate(e))throw i(new Error("envelope signature is not valid for the given domain"),f.ERR_SIGNATURE_NOT_VALID);return r},t.exports=d},function(t,e,r){"use strict";"object"!=typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),t.exports=globalThis},function(t,e,r){"use strict";const n=r(780),i=r(785);t.exports=(t,e)=>{const r=n(t,{...e,count:1});return i.fn(async t=>{t(()=>{r.cancel()});const[e]=await r;return e})()},t.exports.AggregateError=n.AggregateError},function(t,e,r){"use strict";t.exports={DIAL_TIMEOUT:3e4,MAX_PARALLEL_DIALS:100,MAX_PER_PEER_DIALS:4,METRICS:{computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50}}},function(t,e,r){"use strict";t.exports={relay:"/libp2p/circuit/relay/0.1.0"}},function(t,e,r){"use strict";const n=r(32),i=r(98),{CircuitRelay:s}=r(97),o=r(1),a=o("libp2p:circuit:stream-handler");a.error=o("libp2p:circuit:stream-handler:error");t.exports=class{constructor({stream:t,maxLength:e=4096}){this.stream=t,this.shake=i(this.stream),this.decoder=n.decode.fromReader(this.shake.reader,{maxDataLength:e})}async read(){const t=await this.decoder.next();if(t.value){const e=s.decode(t.value.slice());return a("read message type",e.type),e}a("read received no value, closing stream"),this.close()}write(t){a("write message type %s",t.type),this.shake.write(n.encode.single(s.encode(t)))}rest(){return this.shake.rest(),this.shake.stream}end(t){this.write(t),this.close()}close(){a("closing the stream"),this.rest().sink([])}}},function(t,e,r){"use strict";var n=r(9);function i(t,e){n.cipher.registerAlgorithm(t,(function(){return new n.des.Algorithm(t,e)}))}r(332),r(333),r(18),t.exports=n.des=n.des||{},n.des.startEncrypting=function(t,e,r,n){var i=p({key:t,output:r,decrypt:!1,mode:n||(null===e?"ECB":"CBC")});return i.start(e),i},n.des.createEncryptionCipher=function(t,e){return p({key:t,output:null,decrypt:!1,mode:e})},n.des.startDecrypting=function(t,e,r,n){var i=p({key:t,output:r,decrypt:!0,mode:n||(null===e?"ECB":"CBC")});return i.start(e),i},n.des.createDecryptionCipher=function(t,e){return p({key:t,output:null,decrypt:!0,mode:e})},n.des.Algorithm=function(t,e){var r=this;r.name=t,r.mode=new e({blockSize:8,cipher:{encrypt:function(t,e){return d(r._keys,t,e,!1)},decrypt:function(t,e){return d(r._keys,t,e,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(t){if(!this._init){var e=n.util.createBuffer(t.key);if(0===this.name.indexOf("3DES")&&24!==e.length())throw new Error("Invalid Triple-DES key size: "+8*e.length());this._keys=function(t){for(var e,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],h=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],l=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],d=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=t.length()>8?3:1,b=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,w=0;w>>4^E))<<4,_^=e=65535&((E^=e)>>>-16^_),_^=(e=858993459&(_>>>2^(E^=e<<-16)))<<2,_^=e=65535&((E^=e)>>>-16^_),_^=(e=1431655765&(_>>>1^(E^=e<<-16)))<<1,_^=e=16711935&((E^=e)>>>8^_),e=(_^=(e=1431655765&(_>>>1^(E^=e<<8)))<<1)<<8|(E^=e)>>>20&240,_=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=e;for(var S=0;S>>26,E=E<<2|E>>>26):(_=_<<1|_>>>27,E=E<<1|E>>>27);var I=r[(_&=-15)>>>28]|n[_>>>24&15]|i[_>>>20&15]|s[_>>>16&15]|o[_>>>12&15]|a[_>>>8&15]|c[_>>>4&15],A=u[(E&=-15)>>>28]|h[E>>>24&15]|f[E>>>20&15]|l[E>>>16&15]|d[E>>>12&15]|p[E>>>8&15]|y[E>>>4&15];e=65535&(A>>>16^I),b[v++]=I^e,b[v++]=A^e<<16}}return b}(e),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],h=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],f=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],l=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function d(t,e,r,n){var i,d,p=32===t.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=e[0],g=e[1];y^=(d=252645135&(y>>>4^g))<<4,y^=(d=65535&(y>>>16^(g^=d)))<<16,y^=d=858993459&((g^=d)>>>2^y),y^=d=16711935&((g^=d<<2)>>>8^y),y=(y^=(d=1431655765&(y>>>1^(g^=d<<8)))<<1)<<1|y>>>31,g=(g^=d)<<1|g>>>31;for(var b=0;b>>4|g<<28)^t[w+1];d=y,y=g,g=d^(o[_>>>24&63]|c[_>>>16&63]|h[_>>>8&63]|l[63&_]|s[E>>>24&63]|a[E>>>16&63]|u[E>>>8&63]|f[63&E])}d=y,y=g,g=d}g=g>>>1|g<<31,g^=d=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(d=16711935&(g>>>8^(y^=d<<1)))<<8,g^=(d=858993459&(g>>>2^(y^=d)))<<2,g^=d=65535&((y^=d)>>>16^g),g^=d=252645135&((y^=d<<16)>>>4^g),y^=d<<4,r[0]=y,r[1]=g}function p(t){var e,r="DES-"+((t=t||{}).mode||"CBC").toUpperCase(),i=(e=t.decrypt?n.cipher.createDecipher(r,t.key):n.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=t,i.call(e,r)},e}},function(t,e,r){"use strict";var n=r(9);r(18);var i=t.exports=n.pem=n.pem||{};function s(t){for(var e=t.name+": ",r=[],n=function(t,e){return" "+e},i=0;i65&&-1!==o){var a=e[o];","===a?(++o,e=e.substr(0,o)+"\r\n "+e.substr(o)):e=e.substr(0,o)+"\r\n"+a+e.substr(o+1),s=i-o-1,o=-1,++i}else" "!==e[i]&&"\t"!==e[i]&&","!==e[i]||(o=i);return e}function o(t){return t.replace(/^\s+/,"")}i.encode=function(t,e){e=e||{};var r,i="-----BEGIN "+t.type+"-----\r\n";if(t.procType&&(i+=s(r={name:"Proc-Type",values:[String(t.procType.version),t.procType.type]})),t.contentDomain&&(i+=s(r={name:"Content-Domain",values:[t.contentDomain]})),t.dekInfo&&(r={name:"DEK-Info",values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&r.values.push(t.dekInfo.parameters),i+=s(r)),t.headers)for(var o=0;oi.encode.single(new n([t,a])),e.write=(t,r)=>t.push(e.encode(r)),e.writeAll=(t,r)=>{t.push(r.reduce((t,r)=>t.append(e.encode(r)),new n))},e.read=async t=>{let e=1;const r={[Symbol.asyncIterator](){return this},next:()=>t.next(e)},n=await s(r,i.decode({onLength:t=>{e=t}}),c);if(n.get(n.length-1)!==a[0])throw o(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return n.shallowSlice(0,-1)}},function(t,e,r){"use strict";e.BITS=32,e.GROUPS=4,e.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,e.RE_SUBNET_STRING=/\/\d{1,2}$/},function(t,e,r){"use strict";e.BITS=128,e.GROUPS=8,e.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},e.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},e.RE_BAD_CHARACTERS=/([^0-9a-f:\/%])/gi,e.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,e.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,e.RE_ZONE_STRING=/%.*$/,e.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),e.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)},function(t,e,r){"use strict";e.CODE_P2P=421,e.CODE_CIRCUIT=290,e.CLOSE_TIMEOUT=2e3},function(t,e,r){"use strict";var n=r(892)("socket.io-parser"),i=r(206),s=r(895),o=r(352),a=r(353);function c(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=c,e.Decoder=f;var u=e.ERROR+'"encode error"';function h(t){var r=""+t.type;if(e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(r+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(r+=t.nsp+","),null!=t.id&&(r+=t.id),null!=t.data){var i=function(t){try{return JSON.stringify(t)}catch(e){return!1}}(t.data);if(!1===i)return u;r+=i}return n("encoded %j as %s",t,r),r}function f(){this.reconstructor=null}function l(t){this.reconPack=t,this.buffers=[]}function d(t){return{type:e.ERROR,data:"parser error: "+t}}c.prototype.encode=function(t,r){(n("encoding packet %j",t),e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type)?function(t,e){s.removeBlobs(t,(function(t){var r=s.deconstructPacket(t),n=h(r.packet),i=r.buffers;i.unshift(n),e(i)}))}(t,r):r([h(t)])},i(f.prototype),f.prototype.add=function(t){var r;if("string"==typeof t)r=function(t){var r=0,i={type:Number(t.charAt(0))};if(null==e.types[i.type])return d("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s="";"-"!==t.charAt(++r)&&(s+=t.charAt(r),r!=t.length););if(s!=Number(s)||"-"!==t.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(s)}if("/"===t.charAt(r+1))for(i.nsp="";++r;){if(","===(c=t.charAt(r)))break;if(i.nsp+=c,r===t.length)break}else i.nsp="/";var a=t.charAt(r+1);if(""!==a&&Number(a)==a){for(i.id="";++r;){var c;if(null==(c=t.charAt(r))||Number(c)!=c){--r;break}if(i.id+=t.charAt(r),r===t.length)break}i.id=Number(i.id)}if(t.charAt(++r)){var u=function(t){try{return JSON.parse(t)}catch(e){return!1}}(t.substr(r));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return d("invalid payload");i.data=u}return n("decoded %s as %j",t,i),i}(t),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new l(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!a(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,this.emit("decoded",r))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},l.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=s.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},l.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,r){"use strict";function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i{if(t[Symbol.asyncIterator])return t;if(t.getReader)return async function*(){const e=t.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)return;yield r}}finally{e.releaseLock()}}();throw new Error("unknown stream")}},function(t,e,r){"use strict";const n=r(921),i=r(928);t.exports=new n("X25519","ED25519",i)},function(t,e,r){"use strict";const n=r(929),i=r(98),s=r(32);t.exports=(t,e={})=>{const r=i(t),o=s.decode.fromReader(r.reader,e);let a=!1;const c={read:async t=>{const{value:e,done:n}=await r.reader.next(t);if(n&&e.length{const{value:t,done:e}=await o.next();if(a=e,!t)throw new Error("Value is null");return t},readPB:async t=>{const e=await c.readLP();if(!e)throw new Error("Value is null");const r=n(e)?e:e.slice();return t.decode(r)},write:t=>{r.writer.push(t)},writeLP:t=>{c.write(s.encode.single(t,e))},writePB:(t,e)=>{c.writeLP(e.encode(t))},pb:t=>({read:()=>c.readPB(t),write:e=>c.writePB(e,t)}),unwrap:()=>(r.rest(),r.stream)};return c}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DUMP_SESSION_KEYS=e.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=e.NOISE_MSG_MAX_LENGTH_BYTES=void 0,e.NOISE_MSG_MAX_LENGTH_BYTES=65535,e.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=e.NOISE_MSG_MAX_LENGTH_BYTES-16,e.DUMP_SESSION_KEYS={NODE_ENV:"production"}.DUMP_SESSION_KEYS},function(t,e,r){"use strict";const n=r(7),i=r(37),s=r(1),o=r(26),a=r(20),c=r(5),u=s("libp2p:secio");u.error=s("libp2p:secio:error");const h=r(963),f=r(964),{UnexpectedPeerError:l}=r(216);e.createProposal=t=>(t.proposal.out={rand:i.randomBytes(16),pubkey:t.key.local.public.bytes,exchanges:f.exchanges.join(","),ciphers:f.ciphers.join(","),hashes:f.hashes.join(",")},t.proposalEncoded.out=h.Propose.encode(t.proposal.out),t.proposalEncoded.out),e.createExchange=async t=>{const e=await i.keys.generateEphemeralKeyPair(t.protocols.local.curveT);t.ephemeralKey.local=e.key,t.shared.generate=e.genSharedKey;const r=o([t.proposalEncoded.out,t.proposalEncoded.in,t.ephemeralKey.local]),n=await t.key.local.sign(r);return t.exchange.out={epubkey:t.ephemeralKey.local,signature:n},h.Exchange.encode(t.exchange.out)},e.identify=async(t,e)=>{u("1.1 identify"),t.proposalEncoded.in=e,t.proposal.in=h.Propose.decode(e);const r=t.proposal.in.pubkey;t.key.remote=i.keys.unmarshalPublicKey(r);const s=await n.createFromPubKey(c(r,"base64pad"));if(t.id.remote){if(t.id.remote.toString()!==s.toString())throw new l("Dialed to the wrong peer: IDs do not match!");t.id.remote.pubKey=t.key.remote}else t.id.remote=s;u("1.1 identify - %s - identified remote peer as %s",t.id.local.toB58String(),t.id.remote.toB58String())},e.selectProtocols=async t=>{u("1.2 selection");const e={pubKeyBytes:t.key.local.public.bytes,exchanges:f.exchanges,hashes:f.hashes,ciphers:f.ciphers,nonce:t.proposal.out.rand},r={pubKeyBytes:t.proposal.in.pubkey,exchanges:t.proposal.in.exchanges.split(","),hashes:t.proposal.in.hashes.split(","),ciphers:t.proposal.in.ciphers.split(","),nonce:t.proposal.in.rand},n=await f.selectBest(e,r);t.protocols.remote={order:n.order,curveT:n.curveT,cipherT:n.cipherT,hashT:n.hashT},t.protocols.local={order:n.order,curveT:n.curveT,cipherT:n.cipherT,hashT:n.hashT}},e.verify=async(t,e)=>{u("2.1. verify"),t.exchange.in=h.Exchange.decode(e),t.ephemeralKey.remote=t.exchange.in.epubkey;const r=o([t.proposalEncoded.in,t.proposalEncoded.out,t.ephemeralKey.remote]);if(!await t.key.remote.verify(r,t.exchange.in.signature))throw new Error("Bad signature");u("2.1. verify - signature verified")},e.generateKeys=async t=>{u("2.2. keys");const e=await t.shared.generate(t.exchange.in.epubkey);t.shared.secret=e;const r=await i.keys.keyStretcher(t.protocols.local.cipherT,t.protocols.local.hashT,t.shared.secret);if(t.protocols.local.order>0)t.protocols.local.keys=r.k1,t.protocols.remote.keys=r.k2;else{if(!(t.protocols.local.order<0))throw new Error("you are trying to talk to yourself");t.protocols.local.keys=r.k2,t.protocols.remote.keys=r.k1}u("2.3. mac + cipher"),await Promise.all([t.protocols.local,t.protocols.remote].map(t=>f.makeMacAndCipher(t)))},e.verifyNonce=(t,e)=>{const r=t.proposal.out.rand;if(!a(r,e))throw new Error(`Failed to read our encrypted nonce: ${c(r,"base16")} != ${c(e,"base16")}`)}},function(t,e,r){"use strict";class n extends Error{constructor(t="Unexpected Peer"){super(t),this.code=n.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class i extends Error{constructor(t="Invalid crypto exchange"){super(t),this.code=i.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}class s extends Error{constructor(t="Invalid crypto transmission"){super(t),this.code=s.code}static get code(){return"ERR_INVALID_CRYPTO_TRANSMISSION"}}t.exports={UnexpectedPeerError:n,InvalidCryptoExchangeError:i,InvalidCryptoTransmissionError:s}},function(t,e,r){"use strict";(function(e){function r(t,r){if(t.length!==r.length)throw new Error("Inputs should have the same length");for(var n=e.allocUnsafe(t.length),i=0;inew Promise((s,o)=>{if("function"!=typeof e)throw new TypeError("Mapper function is required");if(!Number.isSafeInteger(r)&&r!==1/0||!(r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);const a=[],c=[],u=t[Symbol.iterator]();let h=!1,f=!1,l=0,d=0;const p=()=>{if(h)return;const t=u.next(),r=d;if(d++,t.done)return f=!0,void(0===l&&(i||0===c.length?s(a):o(new n(c))));l++,(async()=>{try{const n=await t.value;a[r]=await e(n,r),l--,p()}catch(n){i?(h=!0,o(n)):(c.push(n),l--,p())}})()};for(let t=0;t{if(!t||!e.EXPERIMENTAL||!e.EXPERIMENTAL.ipnsPubsub)throw i(new Error("IPNS pubsub subsystem is not enabled"),"ERR_IPNS_PUBSUB_NOT_ENABLED");if(n.isIpnsPubsubDatastore(t.routing))return t.routing;const r=(t.routing.stores||[]).find(t=>n.isIpnsPubsubDatastore(t));if(!r)throw i(new Error("IPNS pubsub datastore not found"),"ERR_PUBSUB_DATASTORE_NOT_FOUND");return r}},function(t,e,r){"use strict";const n=r(0),i=r(4);function s(t){const e={path:t.cid||t.path,recursive:!1!==t.recursive};return null!=t.metadata&&(e.metadata=t.metadata),e}t.exports=function(t){if(null==t)throw n(new Error("Unexpected input: "+t,"ERR_UNEXPECTED_INPUT"));if(i.isCID(t)||t instanceof String||"string"==typeof t)return async function*(){yield s({cid:t})}();if(null!=t.cid||null!=t.path)return async function*(){yield s(t)}();if(t[Symbol.iterator])return async function*(){const e=t[Symbol.iterator](),r=e.next();if(r.done)return e;if(i.isCID(r.value)||r.value instanceof String||"string"==typeof r.value){yield s({cid:r.value});for(const t of e)yield s({cid:t})}else{if(null==r.value.cid&&null==r.value.path)throw n(new Error("Unexpected input: "+typeof t),"ERR_UNEXPECTED_INPUT");yield s(r.value);for(const t of e)yield s(t)}}();if(t[Symbol.asyncIterator])return async function*(){const e=t[Symbol.asyncIterator](),r=await e.next();if(r.done)return e;if(i.isCID(r.value)||r.value instanceof String||"string"==typeof r.value){yield s({cid:r.value});for await(const t of e)yield s({cid:t})}else{if(null==r.value.cid&&null==r.value.path)throw n(new Error("Unexpected input: "+typeof t),"ERR_UNEXPECTED_INPUT");yield s(r.value);for await(const t of e)yield s(t)}}();throw n(new Error("Unexpected input: "+typeof t),"ERR_UNEXPECTED_INPUT")}},function(t,e,r){"use strict";e.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,c=(1<>1,h=-7,f=r?i-1:0,l=r?-1:1,d=t[e+f];for(f+=l,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+t[e+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+t[e+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,r,n,i,s){var o,a,c,u=8*s-i-1,h=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*y}},function(t,e,r){"use strict";var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,r){"use strict";const n=self.location?self.location.protocol+"//"+self.location.host:"",i=self.URL;t.exports={URLWithLegacySupport:class{constructor(t="",e=n){this.super=new i(t,e),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:n,format:function(t){if("string"==typeof t){return new i(t).toString()}if(!(t instanceof i)){const e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",i=t.protocol?t.protocol+"//":"",s=t.host||"",o=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),c=t.hash||"",u=t.pathname||"";return`${i}${e||r}${s||o+n}${t.path||u+a}${c}`}}}},function(t,e,r){"use strict";var n=r(3),i=n.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=o),o.prototype=Object.create(i.prototype),s(i,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},function(t,e,r){"use strict";const n=r(15),i=r(407),s=r(408);function o(t){return parseInt(i(t,"base16"),16)}t.exports={numberToUint8Array:function(t){let e=t.toString(16);e.length%2==1&&(e="0"+e);return s(e,"base16")},uint8ArrayToNumber:o,varintUint8ArrayEncode:function(t){return Uint8Array.from(n.encode(o(t)))},varintEncode:function(t){return Uint8Array.from(n.encode(t))}}},function(t,e,r){"use strict";var n=r(8);r(22),t.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(t,e){var r=t;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+t);return new n.cipher.BlockCipher({algorithm:r,key:e,decrypt:!1})},n.cipher.createDecipher=function(t,e){var r=t;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+t);return new n.cipher.BlockCipher({algorithm:r,key:e,decrypt:!0})},n.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),n.cipher.algorithms[t]=e},n.cipher.getAlgorithm=function(t){return(t=t.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[t]:null};var i=n.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};i.prototype.start=function(t){t=t||{};var e={};for(var r in t)e[r]=t[r];e.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=t.output||n.util.createBuffer(),this.mode.start(e)},i.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(t){!t||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(e){return t(this.blockSize,e,!1)},this.mode.unpad=function(e){return t(this.blockSize,e,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,e)))}},function(t,e,r){"use strict";var n=r(8);r(22),n.cipher=n.cipher||{};var i=t.exports=n.cipher.modes=n.cipher.modes||{};function s(t,e){if("string"==typeof t&&(t=n.util.createBuffer(t)),n.util.isArray(t)&&t.length>4){var r=t;t=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=t.length(),n=t.at(r-1);return!(n>this.blockSize<<2)&&(t.truncate(n),!0)},i.cbc=function(t){t=t||{},this.name="CBC",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(t){if(null===t.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(t,e,r){if(t.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=t.length(),n=t.at(r-1);return!(n>this.blockSize<<2)&&(t.truncate(n),!0)},i.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)t.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)t.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(t,e,r){var n=t.length();if(0===t.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)t.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var e,r=n.util.createBuffer(t.iv);if(this._cipherLength=0,e="additionalData"in t?n.util.createBuffer(t.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in t?t.tagLength:128,this._tag=null,t.decrypt&&(this._tag=n.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,e=n.util.createBuffer(e),this._aDataLength=a(8*e.length());var s=e.length()%this.blockSize;for(s&&e.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];e.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()])},i.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},i.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)e[n]=t[n]>>>1|(1&t[n-1])<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)},i.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var n=t[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];e[0]^=i[0],e[1]^=i[1],e[2]^=i[2],e[3]^=i[3]}return e},i.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)},i.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,n=4*r,i=16*r,s=new Array(i),o=0;o>>1,i=new Array(r);i[n]=t.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),t=e.from(t,"binary"),r=e.from(r,"binary"),c?4===i.pbkdf2Sync.length?i.pbkdf2(t,r,s,o,(function(t,e){if(t)return c(t);c(null,e.toString("binary"))})):i.pbkdf2(t,r,s,o,a,(function(t,e){if(t)return c(t);c(null,e.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(t,r,s,o).toString("binary"):i.pbkdf2Sync(t,r,s,o,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in n.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=n.md[a].create()}var u=a.digestLength;if(o>4294967295*u){var h=new Error("Derived key is too long.");if(c)return c(h);throw h}var f=Math.ceil(o/u),l=o-(f-1)*u,d=n.hmac.create();d.start(a,t);var p,y,g,b="";if(!c){for(var m=1;m<=f;++m){d.start(null,null),d.update(r),d.update(n.util.int32ToBytes(m)),p=g=d.digest().getBytes();for(var v=2;v<=s;++v)d.start(null,null),d.update(g),y=d.digest().getBytes(),p=n.util.xorBytes(p,y,u),g=y;b+=mf)return c(null,b);d.start(null,null),d.update(r),d.update(n.util.int32ToBytes(m)),p=g=d.digest().getBytes(),v=2,_()}function _(){if(v<=s)return d.start(null,null),d.update(g),y=d.digest().getBytes(),p=n.util.xorBytes(p,y,u),g=y,++v,n.util.setImmediate(_);b+=m>>0,o>>>0];for(var a=d.fullMessageLength.length-1;a>=0;--a)d.fullMessageLength[a]+=o[1],o[1]=o[0]+(d.fullMessageLength[a]/4294967296>>>0),d.fullMessageLength[a]=d.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return i.putBytes(t),h(r,s,i),(i.read>2048||0===i.length())&&i.compact(),d},d.digest=function(){var e=n.util.createBuffer();e.putBytes(i.bytes());var a,c=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;e.putBytes(o.substr(0,d.blockLength-c));for(var u=8*d.fullMessageLength[0],f=0;f>>0,e.putInt32(u>>>0),u=a>>>0;e.putInt32(u);var l=new Array(r.length);for(f=0;f=128;){for(B=0;B<16;++B)e[B][0]=r.getInt32()>>>0,e[B][1]=r.getInt32()>>>0;for(;B<80;++B)n=(((M=(N=e[B-2])[0])>>>19|(x=N[1])<<13)^(x>>>29|M<<3)^M>>>6)>>>0,i=((M<<13|x>>>19)^(x<<3|M>>>29)^(M<<26|x>>>6))>>>0,s=(((M=(O=e[B-15])[0])>>>1|(x=O[1])<<31)^(M>>>8|x<<24)^M>>>7)>>>0,o=((M<<31|x>>>1)^(M<<24|x>>>8)^(M<<25|x>>>7))>>>0,P=e[B-7],D=e[B-16],x=i+P[1]+o+D[1],e[B][0]=n+P[0]+s+D[0]+(x/4294967296>>>0)>>>0,e[B][1]=x>>>0;for(p=t[0][0],y=t[0][1],g=t[1][0],b=t[1][1],m=t[2][0],v=t[2][1],w=t[3][0],_=t[3][1],E=t[4][0],S=t[4][1],I=t[5][0],A=t[5][1],k=t[6][0],T=t[6][1],R=t[7][0],C=t[7][1],B=0;B<80;++B)h=((E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23))>>>0,f=(k^E&(I^k))>>>0,a=((p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25))>>>0,u=((p<<4|y>>>28)^(y<<30|p>>>2)^(y<<25|p>>>7))>>>0,l=(p&g|m&(p^g))>>>0,d=(y&b|v&(y^b))>>>0,x=C+(((E<<18|S>>>14)^(E<<14|S>>>18)^(S<<23|E>>>9))>>>0)+((T^S&(A^T))>>>0)+c[B][1]+e[B][1],n=R+h+f+c[B][0]+e[B][0]+(x/4294967296>>>0)>>>0,i=x>>>0,s=a+l+((x=u+d)/4294967296>>>0)>>>0,o=x>>>0,R=k,C=T,k=I,T=A,I=E,A=S,E=w+n+((x=_+i)/4294967296>>>0)>>>0,S=x>>>0,w=m,_=v,m=g,v=b,g=p,b=y,p=n+s+((x=i+o)/4294967296>>>0)>>>0,y=x>>>0;x=t[0][1]+y,t[0][0]=t[0][0]+p+(x/4294967296>>>0)>>>0,t[0][1]=x>>>0,x=t[1][1]+b,t[1][0]=t[1][0]+g+(x/4294967296>>>0)>>>0,t[1][1]=x>>>0,x=t[2][1]+v,t[2][0]=t[2][0]+m+(x/4294967296>>>0)>>>0,t[2][1]=x>>>0,x=t[3][1]+_,t[3][0]=t[3][0]+w+(x/4294967296>>>0)>>>0,t[3][1]=x>>>0,x=t[4][1]+S,t[4][0]=t[4][0]+E+(x/4294967296>>>0)>>>0,t[4][1]=x>>>0,x=t[5][1]+A,t[5][0]=t[5][0]+I+(x/4294967296>>>0)>>>0,t[5][1]=x>>>0,x=t[6][1]+T,t[6][0]=t[6][0]+k+(x/4294967296>>>0)>>>0,t[6][1]=x>>>0,x=t[7][1]+C,t[7][0]=t[7][0]+R+(x/4294967296>>>0)>>>0,t[7][1]=x>>>0,L-=128}}},function(t,e,r){"use strict";(function(e){var n=r(8);r(107),r(82),r(231),r(22);var i=r(448),s=i.publicKeyValidator,o=i.privateKeyValidator;if(void 0===a)var a=n.jsbn.BigInteger;var c=n.util.ByteBuffer,u=void 0===e?Uint8Array:e;n.pki=n.pki||{},t.exports=n.pki.ed25519=n.ed25519=n.ed25519||{};var h=n.ed25519;function f(t){var r=t.message;if(r instanceof Uint8Array||r instanceof u)return r;var n=t.encoding;if(void 0===r){if(!t.md)throw new TypeError('"options.message" or "options.md" not specified.');r=t.md.digest().getBytes(),n="binary"}if("string"==typeof r&&!n)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof r){if(void 0!==e)return e.from(r,n);r=new c(r,n)}else if(!(r instanceof c))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var i=new u(r.length()),s=0;s=0;--r)U(n,n),1!==r&&j(n,n,e);for(r=0;r<16;++r)t[r]=n[r]}(r,r),j(r,r,i),j(r,r,s),j(r,r,s),j(t[0],r,s),U(n,t[0]),j(n,n,s),T(n,i)&&j(t[0],t[0],v);if(U(n,t[0]),j(n,n,s),T(n,i))return-1;C(t[0])===e[31]>>7&&L(t[0],l,t[0]);return j(t[3],t[0],t[1]),0}(a,n))return-1;for(i=0;i=0};var l=O(),d=O([1]),p=O([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),y=O([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=O([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),b=O([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),m=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),v=O([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(t,r){var i=n.md.sha512.create(),s=new c(t);i.update(s.getBytes(r),"binary");var o=i.digest().getBytes();if(void 0!==e)return e.from(o,"binary");for(var a=new u(h.constants.HASH_BYTE_LENGTH),f=0;f<64;++f)a[f]=o.charCodeAt(f);return a}function _(t,e){var r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i>8,e[i]-=256*r;e[i]+=r,e[n]=0}for(r=0,i=0;i<32;++i)e[i]+=r-(e[31]>>4)*m[i],r=e[i]>>8,e[i]&=255;for(i=0;i<32;++i)e[i]-=r*m[i];for(n=0;n<32;++n)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function E(t){for(var e=new Float64Array(64),r=0;r<64;++r)e[r]=t[r],t[r]=0;_(t,e)}function S(t,e){var r=O(),n=O(),i=O(),s=O(),o=O(),a=O(),c=O(),u=O(),h=O();L(r,t[1],t[0]),L(h,e[1],e[0]),j(r,r,h),D(n,t[0],t[1]),D(h,e[0],e[1]),j(n,n,h),j(i,t[3],e[3]),j(i,i,y),j(s,t[2],e[2]),D(s,s,s),L(o,n,r),L(a,s,i),D(c,s,i),D(u,n,r),j(t[0],o,a),j(t[1],u,c),j(t[2],c,a),j(t[3],o,u)}function I(t,e,r){for(var n=0;n<4;++n)P(t[n],e[n],r)}function A(t,e){var r=O(),n=O(),i=O();!function(t,e){var r,n=O();for(r=0;r<16;++r)n[r]=e[r];for(r=253;r>=0;--r)U(n,n),2!==r&&4!==r&&j(n,n,e);for(r=0;r<16;++r)t[r]=n[r]}(i,e[2]),j(r,e[0],i),j(n,e[1],i),k(t,n),t[31]^=C(r)<<7}function k(t,e){var r,n,i,s=O(),o=O();for(r=0;r<16;++r)o[r]=e[r];for(N(o),N(o),N(o),n=0;n<2;++n){for(s[0]=o[0]-65517,r=1;r<15;++r)s[r]=o[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,P(o,s,1-i)}for(r=0;r<16;r++)t[2*r]=255&o[r],t[2*r+1]=o[r]>>8}function T(t,e){var r=new u(32),n=new u(32);return k(r,t),k(n,e),R(r,0,n,0)}function R(t,e,r,n){return function(t,e,r,n,i){var s,o=0;for(s=0;s>>8)-1}(t,e,r,n,32)}function C(t){var e=new u(32);return k(e,t),1&e[0]}function B(t,e,r){var n,i;for(x(t[0],l),x(t[1],d),x(t[2],d),x(t[3],l),i=255;i>=0;--i)I(t,e,n=r[i/8|0]>>(7&i)&1),S(e,t),S(t,t),I(t,e,n)}function M(t,e){var r=[O(),O(),O(),O()];x(r[0],g),x(r[1],b),x(r[2],d),j(r[3],g,b),B(t,r,e)}function x(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function N(t){var e,r,n=1;for(e=0;e<16;++e)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function P(t,e,r){for(var n,i=~(r-1),s=0;s<16;++s)n=i&(t[s]^e[s]),t[s]^=n,e[s]^=n}function O(t){var e,r=new Float64Array(16);if(t)for(e=0;e>8,o=255&i;s?r.push(s,o):r.push(o)}return r},n.zero2=i,n.toHex=s,n.encode=function(t,e){return"hex"===e?s(t):t}},function(t,e,r){"use strict";var n;function i(t){this.rand=t}if(t.exports=function(t){return n||(n=new i(null)),n.generate(t)},t.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r>>3},e.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},function(t,e,r){"use strict";var n=r(38),i=r(84),s=r(236),o=r(50),a=n.sum32,c=n.sum32_4,u=n.sum32_5,h=s.ch32,f=s.maj32,l=s.s0_256,d=s.s1_256,p=s.g0_256,y=s.g1_256,g=i.BlockHash,b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}n.inherits(m,g),t.exports=m,m.blockSize=512,m.outSize=256,m.hmacStrength=192,m.padLength=64,m.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n(async(t,e)=>{const r=await n.get().subtle.sign({name:"HMAC"},t,e);return new Uint8Array(r,r.byteOffset,r.byteLength)})(o,t),length:i[t]}}},function(t,e,r){"use strict";(function(e){function r(t){return(4294967296+t).toString(16).substring(1)}t.exports={normalizeInput:function(t){var r;if(t instanceof Uint8Array)r=t;else if(t instanceof e)r=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");r=new Uint8Array(e.from(t,"utf8"))}return r},toHex:function(t){return Array.prototype.map.call(t,(function(t){return(t<16?"0":"")+t.toString(16)})).join("")},debugPrint:function(t,e,n){for(var i="\n"+t+" = ",s=0;st().then(t=>({res:t}),t=>({err:t})));for(let t=0;ts.isDAGLink(t)?t:s.util.createDagLinkFromB58EncodedHash(t)),i(e),Object.defineProperties(this,{Data:{value:t,writable:!1,enumerable:!0},Links:{value:e,writable:!1,enumerable:!0},_serializedSize:{value:r,writable:!0,enumerable:!1},_size:{value:null,writable:!0,enumerable:!1}})}toJSON(){return this._json||(this._json=Object.freeze({data:this.Data,links:this.Links.map(t=>t.toJSON()),size:this.size})),Object.assign({},this._json)}toString(){return`DAGNode `}_invalidateCached(){this._serializedSize=null,this._size=null}addLink(t){return this._invalidateCached(),c(this,t)}rmLink(t){return this._invalidateCached(),u(this,t)}toDAGLink(t){return a(this,t)}serialize(){return o(this)}get size(){return null===this._size&&(null===this._serializedSize&&(this._serializedSize=this.serialize().length),this._size=this.Links.reduce((t,e)=>t+e.Tsize,this._serializedSize)),this._size}set size(t){throw new Error("Can't set property: 'size' is immutable")}},{className:"DAGNode",symbolName:"@ipld/js-ipld-dag-pb/dagnode"})},function(t,e,r){"use strict";const n=r(512),i=r(149),s=(t,e)=>{const r=t.nameAsBuffer,n=e.nameAsBuffer;return i(r,n)};t.exports=t=>{n.inplace(t,s)}},function(t,e,r){"use strict";const n=r(21)(r(245)),i=r(63);e=t.exports;const s=t=>{const e=t.Data,r=t.Links||[];return n.PBNode.encode((t=>{const e={};return t.Data&&t.Data.byteLength>0?e.Data=t.Data:e.Data=null,t.Links&&t.Links.length>0?e.Links=t.Links.map(t=>({Hash:t.Hash.bytes,Name:t.Name,Tsize:t.Tsize})):e.Links=null,e})({Data:e,Links:r}))};e.serializeDAGNode=s,e.serializeDAGNodeLike=(t,e=[])=>{const r={Data:t};return r.Links=e.map(t=>i.isDAGLink(t)?t:i.util.createDagLinkFromB58EncodedHash(t)),s(r)}},function(t,e,r){"use strict";t.exports="// An IPFS MerkleDAG Link\nmessage PBLink {\n\n // multihash of the target object\n optional bytes Hash = 1;\n\n // utf string name. should be unique per object\n optional string Name = 2;\n\n // cumulative size of target object\n optional uint64 Tsize = 3;\n}\n\n// An IPFS MerkleDAG Node\nmessage PBNode {\n\n // refs to other objects\n repeated PBLink Links = 2;\n\n // opaque user data\n optional bytes Data = 1;\n}"},function(t,e,r){"use strict";const n=r(4),i=r(19),s=r(13);(e=t.exports).codec=i.DAG_PB,e.defaultHashAlg=i.SHA2_256;e.cid=async(t,r)=>{const o={cidVersion:1,hashAlg:e.defaultHashAlg},a=Object.assign(o,r),c=await s(t,a.hashAlg),u=i.print[e.codec];return new n(a.cidVersion,u,c)}},function(t,e,r){"use strict";(t.exports=r(63)).util=r(515)},function(t,e,r){"use strict";const n=r(21)(r(245)),i=r(63),s=r(242),{serializeDAGNodeLike:o}=r(244),a=r(246);(e=t.exports).codec=a.codec,e.defaultHashAlg=a.defaultHashAlg;e.serialize=t=>s.isDAGNode(t)?t.serialize():o(t.Data,t.Links),e.deserialize=t=>{const e=n.PBNode.decode(t),r=e.Links.map(t=>new i(t.Name,t.Tsize,t.Hash)),o=null==e.Data?new Uint8Array(0):e.Data;return new s(o,r,t.byteLength)},e.cid=(t,e)=>a.cid(t,e)},function(t,e,r){"use strict";t.exports=function(t){const e=t[Symbol.asyncIterator]?t[Symbol.asyncIterator]():t[Symbol.iterator](),r=[],n={peek:()=>e.next(),push:t=>{r.push(t)},next:()=>r.length?{done:!1,value:r.shift()}:e.next()};return t[Symbol.asyncIterator]?n[Symbol.asyncIterator]=()=>n:n[Symbol.iterator]=()=>n,n}},function(t,e,r){"use strict";const{Blob:n}=r(133);t.exports={isBytes:function(t){return ArrayBuffer.isView(t)||t instanceof ArrayBuffer},isBlob:function(t){return void 0!==n&&t instanceof n},isFileObject:function(t){return"object"==typeof t&&(t.path||t.content)}}},function(t,e,r){"use strict";const{AbortController:n}="undefined"!=typeof self?self:"undefined"!=typeof window?window:r(45),i=r(156);class s extends n{constructor(t){super(),this._ms=t,this._timer=i(()=>this.abort(),t),Object.setPrototypeOf(this,s.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=i(()=>this.abort(),this._ms)}}t.exports=s,t.exports.TimeoutController=s},function(t,e,r){"use strict";const{nanoid:n}=r(253),i=r(27),{utf8Encoder:s,utf8Decoder:o}=r(158),a=r(255),c=s.encode("/"),u=c[0];class h{constructor(t,e){if("string"==typeof t)this._buf=s.encode(t);else{if(!(t instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=t}if(null==e&&(e=!0),e&&this.clean(),0===this._buf.byteLength||this._buf[0]!==u)throw new Error("Invalid key")}toString(t="utf8"){return"utf8"===t||"utf-8"===t?o.decode(this._buf):new a(t).decode(this._buf)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new f(t.join("/"))}static random(){return new f(n().replace(/-/g,""))}clean(){if(this._buf&&0!==this._buf.byteLength||(this._buf=c),this._buf[0]!==u){const t=new Uint8Array(this._buf.byteLength+1);t.fill(u,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===u;)this._buf=this._buf.subarray(0,-1)}less(t){const e=this.list(),r=t.list();for(let n=0;ni)return!1}return e.lengtht.namespaces()),[].concat(...e))]);var e}}const f=i(h,{className:"Key",symbolName:"@ipfs/interface-datastore/key"});t.exports=f},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"urlAlphabet",{enumerable:!0,get:function(){return n.urlAlphabet}}),e.random=e.customRandom=e.customAlphabet=e.nanoid=void 0;var n=r(544);let i=t=>crypto.getRandomValues(new Uint8Array(t));e.random=i;let s=(t,e,r)=>{let n=(2<{let s="";for(;;){let o=r(i),a=i;for(;a--;)if(s+=t[o[a]&n]||"",s.length===+e)return s}}};e.customRandom=s;e.customAlphabet=(t,e)=>s(t,e,i);e.nanoid=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=63&r[t];e+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return e}},function(t,e,r){"use strict";"object"!=typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),t.exports=globalThis},function(t,e,r){"use strict";t.exports=r(254).TextDecoder},function(t,e,r){"use strict";const{filter:n,sortAll:i,take:s,map:o}=r(158),a=r(257);t.exports=class{async open(){}async close(){}async put(t,e,r={}){}async*putMany(t,e={}){for await(const{key:r,value:n}of t)await this.put(r,n,e),yield{key:r,value:n}}async get(t,e={}){}async*getMany(t,e={}){for await(const r of t)yield this.get(r,e)}async has(t){}async delete(t,e={}){}async*deleteMany(t,e={}){for await(const r of t)await this.delete(r,e),yield r}batch(){let t=[],e=[];return{put(e,r){t.push({key:e,value:r})},delete(t){e.push(t)},commit:async r=>{await a(this.putMany(t,r)),t=[],await a(this.deleteMany(e,r)),e=[]}}}async*_all(t,e){}async*query(t,e){let r=this._all(t,e);if(null!=t.prefix&&(r=n(r,e=>e.key.toString().startsWith(t.prefix))),Array.isArray(t.filters)&&(r=t.filters.reduce((t,e)=>n(t,e),r)),Array.isArray(t.orders)&&(r=t.orders.reduce((t,e)=>i(t,e),r)),null!=t.offset){let e=0;r=n(r,()=>e++>=t.offset)}null!=t.limit&&(r=s(r,t.limit)),!0===t.keysOnly&&(r=o(r,t=>({key:t.key}))),yield*r}}},function(t,e,r){"use strict";t.exports=async t=>{for await(const e of t);}},function(t,e,r){"use strict";const n=r(0);t.exports.dbOpenFailedError=t=>(t=t||new Error("Cannot open database"),n(t,"ERR_DB_OPEN_FAILED")),t.exports.dbDeleteFailedError=t=>(t=t||new Error("Delete failed"),n(t,"ERR_DB_DELETE_FAILED")),t.exports.dbWriteFailedError=t=>(t=t||new Error("Write failed"),n(t,"ERR_DB_WRITE_FAILED")),t.exports.notFoundError=t=>(t=t||new Error("Not Found"),n(t,"ERR_NOT_FOUND")),t.exports.abortedError=t=>(t=t||new Error("Aborted"),n(t,"ERR_ABORTED"))},function(t,e,r){"use strict";const n=r(552),i=r(19),s=r(13),o=r(4),a=r(556),c=r(26),u=r(6);function h(t){let e;try{e=a(t)}catch(r){e=!1}if(e)throw new Error("The object passed has circular references");return function t(e){if(!e||e instanceof Uint8Array||"string"==typeof e)return e;if(Array.isArray(e))return e.map(t);if(o.isCID(e))return"string"==typeof(r=e)?r=new o(r).bytes:o.isCID(r)&&(r=r.bytes),new n.Tagged(42,c([u("00","base16"),r],1+r.length));var r;const i=Object.keys(e);if(i.length>0){const r={};return i.forEach(n=>{"object"==typeof e[n]?r[n]=t(e[n]):r[n]=e[n]}),r}return e}(t)}(e=t.exports).codec=i.DAG_CBOR,e.defaultHashAlg=i.SHA2_256;const f={42:t=>(t=t.slice(1),new o(t))};let l=65536;let d=67108864,p=null;e.configureDecoder=t=>{let e=f;t?("number"==typeof t.size&&(l=t.size),"number"==typeof t.maxSize&&(d=t.maxSize),t.tags&&(e=Object.assign({},f,t&&t.tags))):(l=65536,d=67108864);const r={tags:e,size:l};p=new n.Decoder(r),l=r.size},e.configureDecoder(),e.serialize=t=>{const e=h(t);return n.encode(e)},e.deserialize=t=>{if(t.length>l&&t.length<=d&&e.configureDecoder({size:t.length}),t.length>l)throw new Error("Data is too large to deserialize with current decoder");const r=p.decodeAll(t);if(1!==r.length)throw new Error("Extraneous CBOR data found beyond initial top-level object");return r[0]},e.cid=async(t,r)=>{const n={cidVersion:1,hashAlg:e.defaultHashAlg},a=Object.assign(n,r),c=await s(t,a.hashAlg),u=i.print[e.codec];return new o(a.cidVersion,u,c)}},function(t,e,r){"use strict";(function(e){const{Buffer:n}=r(3),i=r(222),s=r(30).BigNumber,o=r(554),a=r(161),c=r(114),u=r(261),h=r(262),{URL:f}=r(106);class l{constructor(t){!(t=t||{}).size||t.size<65536?t.size=65536:t.size=a.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=n.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(1e3*t),2:t=>a.arrayBufferToBignumber(t),3:t=>c.NEG_ONE.minus(a.arrayBufferToBignumber(t)),4:t=>c.TEN.pow(t[0]).times(t[1]),5:t=>c.TWO.pow(t[0]).times(t[1]),32:t=>new f(t),35:t=>new RegExp(t)},t.tags),this.parser=o(e,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case c.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case c.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case c.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case c.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case c.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case c.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length))}this._currentParent&&this._currentParent.type===c.PARENT.TAG&&this._dec()}_dec(){const t=this._currentParent;t.length<0||(t.length--,0===t.length&&this._closeParent())}_push(t,e){const r=this._currentParent;switch(r.values++,r.type){case c.PARENT.ARRAY:case c.PARENT.BYTE_STRING:case c.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=t:this._ref.push(t),this._dec();break;case c.PARENT.OBJECT:null!=r.tmpKey?(this._ref[r.tmpKey]=t,r.tmpKey=null,this._dec()):(r.tmpKey=t,"string"!=typeof r.tmpKey&&(r.type=c.PARENT.MAP,r.ref=a.buildMap(r.ref)));break;case c.PARENT.MAP:null!=r.tmpKey?(this._ref.set(r.tmpKey,t),r.tmpKey=null,this._dec()):r.tmpKey=t;break;case c.PARENT.TAG:this._ref.push(t),e||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,e,r){this._parents[this._depth]={type:e,length:r,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:c.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,e){const r=this._knownTags[t];return r?r(e):new h(t,e)}createMap(t,e){return t}createObject(t,e){return t}createArray(t,e){return t}createByteString(t,e){return n.concat(t)}createByteStringFromHeap(t,e){return t===e?n.alloc(0):n.from(this._heap.slice(t,e))}createInt(t){return t}createInt32(t,e){return a.buildInt32(t,e)}createInt64(t,e,r,n){return a.buildInt64(t,e,r,n)}createFloat(t){return t}createFloatSingle(t,e,r,n){return i.read([t,e,r,n],0,!1,23,4)}createFloatDouble(t,e,r,n,s,o,a,c){return i.read([t,e,r,n,s,o,a,c],0,!1,52,8)}createInt32Neg(t,e){return-1-a.buildInt32(t,e)}createInt64Neg(t,e,r,n){const i=a.buildInt32(t,e),o=a.buildInt32(r,n);return i>c.MAX_SAFE_HIGH?c.NEG_ONE.minus(new s(i).times(c.SHIFT32).plus(o)):-1-(i*c.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(t,e){return t.join("")}createUtf8StringFromHeap(t,e){return t===e?"":this._buffer.toString("utf8",t,e)}createSimpleUnassigned(t){return new u(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,e){this._push(this.createInt32(t,e))}pushInt64(t,e,r,n){this._push(this.createInt64(t,e,r,n))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,e,r,n){this._push(this.createFloatSingle(t,e,r,n))}pushFloatDouble(t,e,r,n,i,s,o,a){this._push(this.createFloatDouble(t,e,r,n,i,s,o,a))}pushInt32Neg(t,e){this._push(this.createInt32Neg(t,e))}pushInt64Neg(t,e,r,n){this._push(this.createInt64Neg(t,e,r,n))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],c.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,e){const r=a.buildInt32(t,e);this._createArrayStartFixed(r)}pushArrayStartFixed64(t,e,r,n){const i=a.buildInt64(t,e,r,n);this._createArrayStartFixed(i)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,e){const r=a.buildInt32(t,e);this._createObjectStartFixed(r)}pushObjectStartFixed64(t,e,r,n){const i=a.buildInt64(t,e,r,n);this._createObjectStartFixed(i)}pushByteStringStart(){this._parents[this._depth]={type:c.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,e){this._push(this.createByteStringFromHeap(t,e))}pushUtf8StringStart(){this._parents[this._depth]={type:c.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,e){this._push(this.createUtf8StringFromHeap(t,e))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:c.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,e){this.pushTagStart(a.buildInt32(t,e))}pushTagStart8(t,e,r,n){this.pushTagStart(a.buildInt64(t,e,r,n))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){0!==t?this._createParent({},c.PARENT.OBJECT,t):this._push(this.createObject({}))}_createArrayStartFixed(t){0!==t?this._createParent(new Array(t),c.PARENT.ARRAY,t):this._push(this.createArray([]))}_decode(t){if(0===t.byteLength)throw new Error("Input too short");this._reset(),this._heap8.set(t);const e=this.parser.parse(t.byteLength);if(this._depth>1){for(;0===this._currentParent.length;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(e>0)throw new Error("Failed to parse");if(0===this._res.length)throw new Error("No valid result")}decodeFirst(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,e){"string"==typeof t&&(t=n.from(t,e||"hex"));return new l({size:t.length}).decodeFirst(t)}static decodeAll(t,e){"string"==typeof t&&(t=n.from(t,e||"hex"));return new l({size:t.length}).decodeAll(t)}}l.decodeFirst=l.decode,t.exports=l}).call(this,r(11))},function(t,e,r){"use strict";const n=r(114),i=n.MT,s=n.SIMPLE,o=n.SYMS;class a{constructor(t){if("number"!=typeof t)throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(0|t)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,i.SIMPLE_FLOAT)}static isSimple(t){return t instanceof a}static decode(t,e){switch(null==e&&(e=!0),t){case s.FALSE:return!1;case s.TRUE:return!0;case s.NULL:return e?null:o.NULL;case s.UNDEFINED:return e?void 0:o.UNDEFINED;case-1:if(!e)throw new Error("Invalid BREAK");return o.BREAK;default:return new a(t)}}}t.exports=a},function(t,e,r){"use strict";class n{constructor(t,e,r){if(this.tag=t,this.value=e,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var e,r;if("function"!=typeof(r=null!=t?t[this.tag]:void 0)&&"function"!=typeof(r=n["_tag"+this.tag]))return this;try{return r.call(n,this.value)}catch(i){return e=i,this.err=e,this}}}t.exports=n},function(t,e,r){"use strict";e.Commented=r(559),e.Diagnose=r(577),e.Decoder=r(117),e.Encoder=r(269),e.Simple=r(90),e.Tagged=r(165),e.Map=r(578),e.comment=e.Commented.comment,e.decodeAll=e.Decoder.decodeAll,e.decodeFirst=e.Decoder.decodeFirst,e.decodeAllSync=e.Decoder.decodeAllSync,e.decodeFirstSync=e.Decoder.decodeFirstSync,e.diagnose=e.Diagnose.diagnose,e.encode=e.Encoder.encode,e.encodeCanonical=e.Encoder.encodeCanonical,e.encodeOne=e.Encoder.encodeOne,e.encodeAsync=e.Encoder.encodeAsync,e.decode=e.Decoder.decodeFirstSync,e.leveldb={decode:e.Decoder.decodeAllSync,encode:e.Encoder.encode,buffer:!0,name:"cbor"},e.hasBigInt=r(66).hasBigInt},function(t,e,r){"use strict";(function(e,n){var i=r(115);t.exports=v;var s,o=r(223);v.ReadableState=m;r(14).EventEmitter;var a=function(t,e){return t.listeners(e).length},c=r(265),u=r(163).Buffer,h=e.Uint8Array||function(){};var f=Object.create(r(89));f.inherits=r(23);var l=r(560),d=void 0;d=l&&l.debuglog?l.debuglog("stream"):function(){};var p,y=r(561),g=r(266);f.inherits(v,c);var b=["error","close","destroy","pause","resume"];function m(t,e){t=t||{};var n=e instanceof(s=s||r(53));this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,o=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(o||0===o)?o:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new y,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=r(116).StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function v(t){if(s=s||r(53),!(this instanceof v))return new v(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),c.call(this)}function w(t,e,r,n,i){var s,o=t._readableState;null===e?(o.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,S(t)}(t,o)):(i||(s=function(t,e){var r;n=e,u.isBuffer(n)||n instanceof h||"string"==typeof e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(o,e)),s?t.emit("error",s):o.objectMode||e&&e.length>0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?_(t,o,e,!1):A(t,o)):_(t,o,e,!1))):n||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(d("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(I,t):I(t))}function I(t){d("emit readable"),t.emit("readable"),C(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(k,t,e))}function k(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;ts.length?s.length:t;if(o===s.length?i+=s:i+=s.slice(0,t),0===(t-=o)){o===s.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=u.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var s=n.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=s.slice(o));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(x,e,t))}function x(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function N(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return d("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return d("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var r=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,d("pipe count=%d opts=%j",s.pipesCount,e);var c=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?h:v;function u(e,n){d("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,d("cleanup"),t.removeListener("close",b),t.removeListener("finish",m),t.removeListener("drain",f),t.removeListener("error",g),t.removeListener("unpipe",u),r.removeListener("end",h),r.removeListener("end",v),r.removeListener("data",y),l=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function h(){d("onend"),t.end()}s.endEmitted?i.nextTick(c):r.once("end",c),t.on("unpipe",u);var f=function(t){return function(){var e=t._readableState;d("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",f);var l=!1;var p=!1;function y(e){d("ondata"),p=!1,!1!==t.write(e)||p||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==N(s.pipes,t))&&!l&&(d("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function g(e){d("onerror",e),v(),t.removeListener("error",g),0===a(t,"error")&&t.emit("error",e)}function b(){t.removeListener("finish",m),v()}function m(){d("onfinish"),t.removeListener("close",b),v()}function v(){d("unpipe"),r.unpipe(t)}return r.on("data",y),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",g),t.once("close",b),t.once("finish",m),t.emit("pipe",r),s.flowing||(d("pipe resume"),r.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s{n.pushAny(t);const r=i.read();n.pushAny(e);const s=i.read();return r.compare(s)});for(const[e,s]of r){if(t.disallowUndefinedKeys&&void 0===e)throw new Error("Invalid Map key: undefined");if(!t.pushAny(e)||!t.pushAny(s))return!1}}else for(const[r,n]of e){if(t.disallowUndefinedKeys&&void 0===r)throw new Error("Invalid Map key: undefined");if(!t.pushAny(r)||!t.pushAny(n))return!1}return!0}_pushUint8Array(t,r){return t._pushBuffer(t,e.from(r))}_pushFloat32Array(t,e){const r=e.length;if(!t._pushInt(r,u.ARRAY))return!1;for(let n=0;n{const r=n[t]||(n[t]=R.encode(t)),i=n[e]||(n[e]=R.encode(e));return r.compare(i)}),!this._pushInt(r.length,u.MAP))return!1;let i;for(let s=0,o=r.length;s{const s=[],o=new R(r);o.on("data",t=>s.push(t)),o.on("error",i),o.on("finish",()=>n(e.concat(s))),o.pushAny(t),o.end()})}}t.exports=R}).call(this,r(3).Buffer)},function(t,e,r){"use strict";const n=r(61).IPFS.matches;e.isValidMultiaddr=t=>{try{return n(t)}catch(e){return!1}}},function(t,e,r){"use strict";const n=r(168),i=r(169),s=r(29),o=r(0);t.exports=(t,e,r,a,c,u,h)=>(t={})=>{const a=r.fileSize(),{offset:c,length:u}=i(a,t.offset,t.length);return async function*t(e,r,i,a,c=0,u){if(r instanceof Uint8Array){const t=n(r,c,i,a);return t.length&&(yield t),c+=t.length}let h;try{h=s.unmarshal(r.Data)}catch(l){throw o(l,"ERR_NOT_UNIXFS")}if(Boolean(h.data&&h.data.length)){const t=n(h.data,c,i,a);t.length&&(yield t),c+=h.data.length}let f=c;for(let n=0;n=f&&if&&a<=o||io){const r=await e.get(s.Hash,u);for await(const n of t(e,r,i,a,c,u))c+=n.length,yield n}c=o,f=o+1}}(h,e,c,c+u,0,t)}},function(t,e,r){"use strict";const n=r(167),{withTimeoutOption:i}=r(2),s=r(1)("ipfs:core:config");async function o(t){return Object.keys(a).map(t=>({name:t,description:a[t].description}))}t.exports=({repo:t})=>({getAll:i(t.config.getAll),get:i((e,r)=>e?t.config.get(e,r):Promise.reject(new Error("key argument is required"))),set:i(t.config.set),replace:i(t.config.replace),profiles:{apply:i((async function(e,r={}){const{dryRun:n}=r,i=a[e];if(!i)throw new Error(`No profile with name '${e}' exists`);try{const e=await t.config.getAll(r);let s=JSON.parse(JSON.stringify(e));return s=i.transform(s),n||await t.config.replace(s,r),delete e.Identity.PrivKey,delete s.Identity.PrivKey,{original:e,updated:s}}catch(o){throw s(o),new Error(`Could not apply profile '${e}' to config: ${o.message}`)}})),list:i(o)}});const a={server:{description:"Recommended for nodes with public IPv4 address (servers, VPSes, etc.), disables host and content discovery in local networks.",transform:t=>(t.Discovery.MDNS.Enabled=!1,t.Discovery.webRTCStar.Enabled=!1,t)},"local-discovery":{description:"Sets default values to fields affected by `server` profile, enables discovery in local networks.",transform:t=>(t.Discovery.MDNS.Enabled=!0,t.Discovery.webRTCStar.Enabled=!0,t)},test:{description:"Reduces external interference, useful for running ipfs in test environments. Note that with these settings node won't be able to talk to the rest of the network without manual bootstrap.",transform:t=>{const e=n();return t.Addresses.API=e.Addresses.API?"/ip4/127.0.0.1/tcp/0":"",t.Addresses.Gateway=e.Addresses.Gateway?"/ip4/127.0.0.1/tcp/0":"",t.Addresses.Swarm=e.Addresses.Swarm.length?["/ip4/127.0.0.1/tcp/0"]:[],t.Addresses.Delegates=[],t.Bootstrap=[],t.Discovery.MDNS.Enabled=!1,t.Discovery.webRTCStar.Enabled=!1,t}},"default-networking":{description:"Restores default network settings. Inverse profile of the `test` profile.",transform:t=>{const e=n();return t.Addresses.API=e.Addresses.API,t.Addresses.Gateway=e.Addresses.Gateway,t.Addresses.Swarm=e.Addresses.Swarm,t.Addresses.Delegates=e.Addresses.Delegates,t.Bootstrap=e.Bootstrap,t.Discovery.MDNS.Enabled=e.Discovery.MDNS.Enabled,t.Discovery.webRTCStar.Enabled=e.Discovery.webRTCStar.Enabled,t}},lowpower:{description:"Reduces daemon overhead on the system. May affect node functionality,performance of content discovery and data fetching may be degraded. Recommended for low power systems.",transform:t=>(t.Swarm=t.Swarm||{},t.Swarm.ConnMgr=t.Swarm.ConnMgr||{},t.Swarm.ConnMgr.LowWater=20,t.Swarm.ConnMgr.HighWater=40,t)},"default-power":{description:'Inverse of "lowpower" profile.',transform:t=>{const e=n();return t.Swarm=e.Swarm,t}}};t.exports.profiles=a},function(t,e,r){"use strict";const n=r(170);t.exports=class{constructor(t){this.lru=n(t)}get(t){const e=this.lru.get(t);if(e)return e.expire&&e.expire{if(i)return i;const e=n({singleProcess:t});return i={readLock:t=>async(...r)=>{const n=await e.readLock();try{return await t.apply(null,r)}finally{n()}},writeLock:t=>async(...r)=>{const n=await e.writeLock();try{return await t.apply(null,r)}finally{n()}}},i}},function(t,e,r){"use strict";(function(e){const n=r(610),i=r(620),{default:s}=r(92),{timeout:o}=r(625),a=r(278),c={};let u;function h(t,e){let r;const n=new Promise(t=>{r=t});return t.add(()=>o(new Promise(t=>{r(()=>{t()})}),e.timeout)),n}const f={concurrency:1/0,timeout:846e5,global:e,singleProcess:!1};t.exports=(t,e)=>(e||(e={}),"object"==typeof t&&(e=t,t="lock"),t||(t="lock"),e=Object.assign({},f,e),u||(u=n(e)||i(e),u.isWorker||(u.on("requestReadLock",(t,e)=>{c[t]&&c[t].readLock().then(t=>e().finally(()=>t()))}),u.on("requestWriteLock",async(t,e)=>{c[t]&&c[t].writeLock().then(t=>e().finally(()=>t()))}))),c[t]||(c[t]=((t,e)=>{if(u.isWorker)return{readLock:u.readLock(t,e),writeLock:u.writeLock(t,e)};const r=new s({concurrency:1});let n=null;return{readLock:()=>{if(n)return h(n,e);n=new s({concurrency:e.concurrency,autoStart:!1});const t=n,i=h(n,e);return r.add(()=>(t.start(),t.onIdle().then(()=>{n===t&&(n=null)}))),i},writeLock:()=>(n=null,h(r,e))}})(t,e)),c[t]),t.exports.Worker=function(t,r){let n;r=r||e.Worker;try{n=new r(t)}catch(i){i.message.includes("not a constructor")&&(n=r(t))}if(!n)throw new Error("Could not create Worker from",r);return a(n),n}}).call(this,r(11))},function(t,e,r){"use strict";t.exports=r(611)},function(t,e,r){"use strict";t.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}},function(t,e,r){"use strict";const n={},i=t=>{t.addEventListener("message",e=>{i.dispatchEvent("message",t,e)}),t.port&&t.port.addEventListener("message",e=>{i.dispatchEvent("message",t,e)})};i.addEventListener=(t,e)=>{n[t]||(n[t]=[]),n[t].push(e)},i.removeEventListener=(t,e)=>{n[t]&&(n[t]=n[t].filter(t=>t===e))},i.dispatchEvent=function(){const t=Array.prototype.slice.call(arguments),e=t.shift();n[e]&&n[e].forEach(e=>e.apply(null,t))},t.exports=i},function(t,e,r){"use strict";var n=r(622),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),s=Object.prototype.toString,o=Array.prototype.concat,a=Object.defineProperty,c=a&&function(){var t={};try{for(var e in a(t,"x",{enumerable:!1,value:t}),t)return!1;return t.x===t}catch(r){return!1}}(),u=function(t,e,r,n){var i;(!(e in t)||"function"==typeof(i=n)&&"[object Function]"===s.call(i)&&n())&&(c?a(t,e,{configurable:!0,enumerable:!1,value:r,writable:!0}):t[e]=r)},h=function(t,e){var r=arguments.length>2?arguments[2]:{},s=n(e);i&&(s=o.call(s,Object.getOwnPropertySymbols(e)));for(var a=0;a=0&&"[object Function]"===n.call(t.callee)),r}},function(t,e,r){"use strict";"undefined"!=typeof self?t.exports=self:"undefined"!=typeof window?t.exports=window:t.exports=Function("return this")()},function(t,e,r){"use strict";(function(e){var n=r(281);t.exports=function(){return"object"==typeof e&&e&&e.Math===Math&&e.Array===Array?e:n}}).call(this,r(11))},function(t,e,r){"use strict";const n=r(4),i=r(29),{DAGNode:s}=r(16),o=r(1)("ipfs:mfs:utils:with-mfs-root"),a=r(19),c=r(13).multihash,u=r(0),{MFS_ROOT_KEY:h}=r(2);t.exports=async(t,e)=>{if(e&&e.signal&&e.signal.aborted)throw u(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});let r;await t.repo.datastore.open();try{const e=await t.repo.datastore.get(h);r=new n(e)}catch(f){if("ERR_NOT_FOUND"!==f.code)throw f;o("Creating new MFS root");const n=new s(new i({type:"directory"}).marshal());if(r=await t.ipld.put(n,a.DAG_PB,{cidVersion:0,hashAlg:c.names["sha2-256"]}),e&&e.signal&&e.signal.aborted)throw u(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});await t.repo.datastore.put(h,r.bytes)}return o("Loaded MFS root /ipfs/"+r),r}},function(t,e,r){"use strict";const{DAGNode:n}=r(16),i=r(152),s=r(151),o=r(1)("ipfs:mfs:core:utils:hamt-utils"),a=r(29),c=r(19),u=r(13).multihash,h=r(41),f=async(t,e,r,n)=>{const o=new i({hashFn:s.hashFn,hash:r?r._options.hash:void 0},r,n);return r&&r._putObjectAt(n,o),await l(t,o,e),o},l=async(t,e,r)=>{await Promise.all(t.map(t=>{if(2===t.Name.length){const r=parseInt(t.Name,16);return e._putObjectAt(r,new i({hashFn:s.hashFn},e,r)),Promise.resolve()}return(r||e).put(t.Name.substring(2),{size:t.Tsize,cid:t.Hash})}))},d=t=>t.toString("16").toUpperCase().padStart(2,"0").substring(0,2);t.exports={generatePath:async(t,e,r)=>{const n=await f(r.Links,null,null,null),i=await n._findNewBucketAndPos(e),s=[{bucket:i.bucket,prefix:d(i.pos)}];let a=i.bucket;for(;a!==n;)s.push({bucket:a,prefix:d(a._posAtParent)}),a=a._parent;s.reverse(),s[0].node=r;for(let c=0;ct.Name.substring(0,2)===r.prefix).pop();if(!i){o(`Link ${r.prefix}${e} will be added`);continue}if(i.Name===`${r.prefix}${e}`){o(`Link ${r.prefix}${e} will be replaced`);continue}o("Found subshard "+r.prefix);const a=await t.ipld.get(i.Hash);if(!s[c+1]){o("Loaded new subshard "+r.prefix),await f(a.Links,n,r.bucket,parseInt(r.prefix,16));const t=await n._findNewBucketAndPos(e);s.push({bucket:t.bucket,prefix:d(t.pos),node:a});continue}const u=s[c+1];await l(a.Links,u.bucket,n),u.node=a}return await n.put(e,!0),s.reverse(),{rootBucket:n,path:s}},updateHamtDirectory:async(t,e,r,i)=>{const o=Uint8Array.from(r._children.bitField().reverse()),h=a.unmarshal(i.parent.Data),f=new a({type:"hamt-sharded-directory",data:o,fanout:r.tableSize(),hashType:s.hashFn.code,mode:h.mode,mtime:h.mtime}),l=u.names[i.hashAlg],d=new n(f.marshal(),e);return{node:d,cid:await t.ipld.put(d,c.DAG_PB,{cidVersion:i.cidVersion,hashAlg:l,onlyHash:!i.flush}),size:d.size}},recreateHamtLevel:f,addLinksToHamtBucket:l,toPrefix:d,createShard:async(t,e,r)=>{const n=new s({root:!0,dir:!0,parent:null,parentKey:null,path:"",dirty:!0,flat:!1,mtime:r.mtime,mode:r.mode},{...r,codec:"dag-pb"});for(let i=0;i","files":["src","dist"],"main":"src/core/index.js","browser":{"./src/core/runtime/init-assets-nodejs.js":"./src/core/runtime/init-assets-browser.js","./src/core/runtime/config-nodejs.js":"./src/core/runtime/config-browser.js","./src/core/runtime/dns-nodejs.js":"./src/core/runtime/dns-browser.js","./src/core/runtime/libp2p-nodejs.js":"./src/core/runtime/libp2p-browser.js","./src/core/runtime/libp2p-pubsub-routers-nodejs.js":"./src/core/runtime/libp2p-pubsub-routers-browser.js","./src/core/runtime/preload-nodejs.js":"./src/core/runtime/preload-browser.js","./src/core/runtime/repo-nodejs.js":"./src/core/runtime/repo-browser.js","./src/core/runtime/ipld-nodejs.js":"./src/core/runtime/ipld-browser.js","./test/utils/create-repo-nodejs.js":"./test/utils/create-repo-browser.js","ipfs-utils/src/files/glob-source":false},"bin":{"jsipfs":"src/cli/bin.js"},"repository":{"type":"git","url":"git+https://github.com/ipfs/js-ipfs.git"},"scripts":{"lint":"aegir lint","build":"aegir build","test":"aegir test","test:node":"aegir test -t node","test:browser":"aegir test -t browser","test:browser:http":"aegir test -t browser -f test/http-api/index.js","test:webworker":"aegir test -t webworker -- --timeout 10000","test:electron":"aegir test -t electron-main -t electron-renderer","test:electron-main":"aegir test -t electron-main","test:electron-renderer":"aegir test -t electron-renderer","test:cli":"aegir test -t node -f test/cli/index.js","test:node:core":"aegir test -t node -f test/core/**/*.js","test:node:http":"aegir test -t node -f test/http-api/index.js","test:node:gateway":"aegir test -t node -f test/gateway/index.js","test:interface":"aegir test -f test/core/interface.spec.js","test:interface:http":"aegir test -f test/http-api/interface.js","test:bootstrapers":"IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js","test:interop":"cross-env IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop","test:interop:node":"cross-env IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop -- -t node","test:interop:browser":"cross-env IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop -- -t browser","test:interop:electron-main":"cross-env IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop -- -t electron-main -f ./test/node.js","test:interop:electron-renderer":"cross-env IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_JS_HTTP_MODULE=$PWD/../ipfs-http-client IPFS_REUSEPORT=false ipfs-interop -- -t electron-renderer -f ./test/browser.js","test:external":"aegir test-dependant","coverage":"nyc --reporter=text --reporter=lcov npm run test:node","clean":"rm -rf ./dist","dep-check":"aegir dep-check"},"dependencies":{"@hapi/ammo":"^5.0.1","@hapi/boom":"^9.1.0","@hapi/content":"^5.0.2","@hapi/hapi":"^20.0.0","abort-controller":"^3.0.0","any-signal":"^1.1.0","array-shuffle":"^1.0.1","bignumber.js":"^9.0.0","bl":"^4.0.2","byteman":"^1.3.5","cbor":"^5.0.1","cid-tool":"^1.0.0","cids":"^1.0.0","class-is":"^1.1.0","dag-cbor-links":"^2.0.0","datastore-core":"^2.0.0","datastore-pubsub":"^0.4.0","debug":"^4.1.0","dlv":"^1.1.3","err-code":"^2.0.0","execa":"^4.0.0","file-type":"^14.1.4","fnv1a":"^1.0.1","get-folder-size":"^2.0.0","hamt-sharding":"^1.0.0","hapi-pino":"^8.2.0","hashlru":"^2.3.0","interface-datastore":"^2.0.0","ipfs-bitswap":"^3.0.0","ipfs-block-service":"^0.18.0","ipfs-core-utils":"^0.4.0","ipfs-http-client":"^47.0.0","ipfs-http-response":"^0.6.0","ipfs-repo":"^6.0.3","ipfs-unixfs":"^2.0.2","ipfs-unixfs-exporter":"^3.0.2","ipfs-unixfs-importer":"^3.0.2","ipfs-utils":"^3.0.0","ipld":"^0.27.1","ipld-bitcoin":"^0.4.0","ipld-block":"^0.10.0","ipld-dag-cbor":"^0.17.0","ipld-dag-pb":"^0.20.0","ipld-ethereum":"^5.0.1","ipld-git":"^0.6.1","ipld-raw":"^6.0.0","ipld-zcash":"^0.5.0","ipns":"^0.8.0","is-domain-name":"^1.0.1","is-ipfs":"^2.0.0","iso-url":"^0.4.7","it-all":"^1.0.1","it-concat":"^1.0.0","it-drain":"^1.0.1","it-first":"^1.0.1","it-glob":"0.0.8","it-last":"^1.0.2","it-map":"^1.0.2","it-multipart":"^1.0.1","it-pipe":"^1.1.0","it-tar":"^1.2.2","it-to-stream":"^0.1.1","iterable-ndjson":"^1.1.0","joi":"^17.2.1","jsondiffpatch":"^0.4.1","just-safe-set":"^2.1.0","libp2p":"^0.29.0","libp2p-bootstrap":"^0.12.0","libp2p-crypto":"^0.18.0","libp2p-delegated-content-routing":"^0.7.0","libp2p-delegated-peer-routing":"^0.7.0","libp2p-floodsub":"^0.23.0","libp2p-gossipsub":"^0.6.0","libp2p-kad-dht":"^0.20.0","libp2p-mdns":"^0.15.0","libp2p-mplex":"^0.10.0","libp2p-noise":"^2.0.0","libp2p-record":"^0.9.0","libp2p-secio":"^0.13.0","libp2p-tcp":"^0.15.0","libp2p-webrtc-star":"^0.20.0","libp2p-websockets":"^0.14.0","mafmt":"^8.0.0","merge-options":"^2.0.0","mortice":"^2.0.0","multiaddr":"^8.0.0","multiaddr-to-uri":"^6.0.0","multibase":"^3.0.0","multicodec":"^2.0.0","multihashing-async":"^2.0.1","p-defer":"^3.0.0","p-queue":"^6.1.0","parse-duration":"^0.4.4","peer-id":"^0.14.0","pretty-bytes":"^5.3.0","progress":"^2.0.1","protons":"^2.0.0","semver":"^7.3.2","stream-to-it":"^0.2.1","streaming-iterables":"^5.0.0","temp":"^0.9.0","timeout-abort-controller":"^1.1.0","uint8arrays":"^1.1.0","update-notifier":"^4.0.0","uri-to-multiaddr":"^4.0.0","varint":"^5.0.0","yargs":"^15.1.0","yargs-promise":"^1.1.0"},"devDependencies":{"aegir":"^26.0.0","clear-module":"^4.0.0","cross-env":"^7.0.0","delay":"^4.3.0","form-data":"^3.0.0","go-ipfs":"^0.6.0","interface-ipfs-core":"^0.140.0","ipfs-interop":"^3.0.0","ipfsd-ctl":"^7.0.0","iso-random-stream":"^1.1.1","it-to-buffer":"^1.0.0","nanoid":"^3.0.2","ncp":"^2.0.0","p-event":"^4.1.0","p-map":"^4.0.0","qs":"^6.9.3","rimraf":"^3.0.0","sinon":"^9.0.1","stream-to-promise":"^3.0.0","string-argv":"^0.3.1","temp-write":"^4.0.0","wrtc":"^0.4.4"},"optionalDependencies":{"prom-client":"^12.0.0","prometheus-gc-stats":"^0.6.0"},"engines":{"node":">=10.0.0","npm":">=6.0.0"},"contributors":["0xflotus <0xflotus@gmail.com>","A_A <21040751+Otto-AA@users.noreply.github.com>","Adam Uhlíř ","Alan Shaw ","Alan Shaw ","Alex North ","Alex Potsides ","Andrew Nesbitt ","Andrew de Andrade ","André Cruz ","Arkadiy Kukarkin ","Arpit Agarwal <93arpit@gmail.com>","Arpit Agarwal ","Ayush Mahajan ","Bernard Mordan ","Brian Vander Schaaf ","Bruno Zell ","CHEVALAY JOSSELIN ","Caio Gondim ","Chance Hudson ","Chirag Shinde ","Christian Couder ","Dafeng ","Dan Ordille ","Dan Shields <35669742+NukeManDan@users.noreply.github.com>","Daniel Buchner ","Daniel J. O\'Quinn ","Daniela Borges Matos de Carvalho ","David Dias ","David Gilbertson ","David da Silva ","Diogo Silva ","Dmitriy Ryajov ","Dominic Della Valle ","Dzmitry Bachko ","Enrico Marino ","Faheel Ahmad ","Felix Yan ","Francisco Baio Dias ","Francisco Baio Dias ","Friedel Ziegelmayer ","Gabriel Garrido Calvo ","Gar ","Georgios Rassias ","Gorka Ludlow ","Grant Herman ","Greenkeeper ","Haad ","Haoliang Yu ","Harsh Vakharia ","Henrique Dias ","Henry Rodrick ","Heo Sangmin ","Hugo Dias ","Hugo Dias ","Irakli Gozalishvili ","Jacob Heun ","Jacob Heun ","Jade Meskill ","Jessica Schilling ","Johannes Wikner ","Jon Schlinkert ","Jonathan ","Jonybang ","Jorropo ","João Antunes ","João Santos ","Kevin Wang ","Lars Gierth ","Lukas Drgon ","Maciej Krüger ","Marcin Rataj ","Marcus Bernales ","Marius Darila ","Mark Robert Henderson ","Mat Kelly ","Michelle Lee ","Mikeal Rogers ","Mithgol ","Molly ","Mounish Sai ","My9Bot <34904312+My9Bot@users.noreply.github.com>","Nick Poulden ","Nitin Patel <31539366+niinpatel@users.noreply.github.com>","Nuno Nogueira ","Oli Evans ","Oskar Nyberg ","Pascal Precht ","Pau Ramon Revilla ","Paulo Rodrigues ","Pedro Santos ","Pedro Santos ","Pedro Teixeira ","Portia Burton ","Prabhakar Poudel ","Qmstream <51881352+Qmstream@users.noreply.github.com>","Raoul Millais ","RasmusErik Voel Jensen ","Richard Littauer ","Richard Schneider ","Rob Brackett ","Rod Keys ","Sangwon Hong ","Sid Harder ","SidHarder ","Stephen Whitmore ","Stephen Whitmore ","Steven Allen ","Tapasweni Pathak ","Terence Pae ","Teri Chadbourne ","Travis CI ","Uroš Jurglič ","Vasco Santos ","Vasco Santos ","Vincent Martin ","Volker Mische ","Xiao Liang ","Yahya ","Yole ","bitspill ","datafatmunger ","dirkmc ","dirkmc ","greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>","greenkeeper[bot] ","haad ","hapsody ","jbenet ","jonahweissman <19804455+jonahweissman@users.noreply.github.com>","kevingzhang ","kumavis ","nginnever ","npmcdn-to-unpkg-bot ","reasv <7143787+reasv@users.noreply.github.com>","robbsolter <35879806+robbsolter@users.noreply.github.com>","seungwon-kang ","swedneck <40505480+swedneck@users.noreply.github.com>","tcme ","victorbjelkholm ","Łukasz Magiera ","Максим Ильин ","Xmader "]}')},function(t,e,r){"use strict";t.exports=function(t,e,r){if(!t)return r;var n,i;Array.isArray(e)&&(n=e.slice(0));"string"==typeof e&&(n=e.split("."));"symbol"==typeof e&&(n=[e]);if(!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");for(;n.length;){if(i=n.shift(),!t)return r;if(void 0===(t=t[i]))return r}return t}},function(t,e,r){"use strict";const n=r(10).Key,{utf8Decoder:i}=r(288),s=r(647),o=e.PREFIX="/repo/flatfs/shard/",a=e.SHARDING_FN="SHARDING";e.README_FN="_README";class c{constructor(t){this.param=t}fun(t){throw new Error("implement me")}toString(){return`${o}v1/${this.name}/${this.param}`}}class u extends c{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="prefix"}fun(t){return(t+this._padding).slice(0,this.param)}}class h extends c{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="suffix"}fun(t){const e=this._padding+t;return e.slice(e.length-this.param)}}class f extends c{constructor(t){super(t),this._padding="".padStart(t+1,"_"),this.name="next-to-last"}fun(t){const e=this._padding+t,r=e.length-this.param-1;return e.slice(r,r+this.param)}}function l(t){if(0===(t=t.trim()).length)throw new Error("empty shard string");if(!t.startsWith(o))throw new Error("invalid or no path prefix: "+t);const e=t.slice(o.length).split("/"),r=e[0];if("v1"!==r)throw new Error(`expect 'v1' version, got '${r}'`);const n=e[1];if(!e[2])throw new Error("missing param");const i=parseInt(e[2],10);switch(n){case"prefix":return new u(i);case"suffix":return new h(i);case"next-to-last":return new f(i);default:throw new Error("unkown sharding function: "+n)}}e.readShardFun=async(t,e)=>{const r=new n(t).child(new n(a)),s="function"==typeof e.getRaw?e.getRaw.bind(e):e.get.bind(e),o=await s(r);return l(i.decode(o||"").trim())},e.readme=s,e.parseShardFun=l,e.Prefix=u,e.Suffix=h,e.NextToLast=f},function(t,e,r){"use strict";const n=r(645),i=r(646);t.exports.utf8Encoder=new n("utf8"),t.exports.utf8Decoder=new i("utf8")},function(t,e,r){"use strict";"object"!=typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),t.exports=globalThis},function(t,e,r){"use strict";t.exports=async t=>{let e=0;for await(const r of t)e++;return e}},function(t,e,r){"use strict";const n=r(31),{Key:i}=r(10),s=r(13).multihash,o=new i("/local/pins"),a=s.fromB58String("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n");t.exports={PIN_DS_KEY:o,DEFAULT_FANOUT:256,MAX_ITEMS:8192,EMPTY_KEY:a,PinTypes:{direct:"direct",recursive:"recursive"},cidToKey:function(t){return new i("/"+n.encoding("base32upper").encode(t.multihash))}}},function(t,e,r){"use strict";const{Key:n}=r(10),i=r(4),s=r(31),o=r(0),a=r(5);e.cidToKey=t=>{if(!i.isCID(t))throw o(new Error("Not a valid cid"),"ERR_INVALID_CID");return new n("/"+a(s.encode("base32",t.multihash)).slice(1).toUpperCase(),!1)},e.keyToCid=t=>new i(1,"raw",s.decode("b"+t.toString().slice(1).toLowerCase()))},function(t,e,r){"use strict";const n=r(670);t.exports=class{constructor(t){this.hwm=t||16,this.head=new n(this.hwm),this.tail=this.head}push(t){if(!this.head.push(t)){const e=this.head;this.head=e.next=new n(2*this.head.buffer.length),this.head.push(t)}}shift(){const t=this.tail.shift();if(void 0===t&&this.tail.next){const t=this.tail.next;return this.tail.next=null,this.tail=t,this.tail.shift()}return t}isEmpty(){return this.head.isEmpty()}}},function(t,e,r){"use strict";e.AbstractLevelDOWN=r(676),e.AbstractIterator=r(295),e.AbstractChainedBatch=r(296)},function(t,e,r){"use strict";var n=r(182);function i(t){if("object"!=typeof t||null===t)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=t,this._ended=!1,this._nexting=!1}i.prototype.next=function(t){var e=this;if("function"!=typeof t)throw new Error("next() requires a callback argument");return e._ended?(n(t,new Error("cannot call next() after end()")),e):e._nexting?(n(t,new Error("cannot call next() before previous next() has completed")),e):(e._nexting=!0,e._next((function(){e._nexting=!1,t.apply(null,arguments)})),e)},i.prototype._next=function(t){n(t)},i.prototype.seek=function(t){if(this._ended)throw new Error("cannot call seek() after end()");if(this._nexting)throw new Error("cannot call seek() before next() has completed");t=this.db._serializeKey(t),this._seek(t)},i.prototype._seek=function(t){},i.prototype.end=function(t){if("function"!=typeof t)throw new Error("end() requires a callback argument");if(this._ended)return n(t,new Error("end() already called on iterator"));this._ended=!0,this._end(t)},i.prototype._end=function(t){n(t)},i.prototype._nextTick=n,t.exports=i},function(t,e,r){"use strict";var n=r(182);function i(t){if("object"!=typeof t||null===t)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=t,this._operations=[],this._written=!1}i.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")},i.prototype.put=function(t,e){this._checkWritten();var r=this.db._checkKey(t)||this.db._checkValue(e);if(r)throw r;return t=this.db._serializeKey(t),e=this.db._serializeValue(e),this._put(t,e),this},i.prototype._put=function(t,e){this._operations.push({type:"put",key:t,value:e})},i.prototype.del=function(t){this._checkWritten();var e=this.db._checkKey(t);if(e)throw e;return t=this.db._serializeKey(t),this._del(t),this},i.prototype._del=function(t){this._operations.push({type:"del",key:t})},i.prototype.clear=function(){return this._checkWritten(),this._clear(),this},i.prototype._clear=function(){this._operations=[]},i.prototype.write=function(t,e){if(this._checkWritten(),"function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("write() requires a callback argument");"object"==typeof t&&null!==t||(t={}),this._written=!0,this._write(t,e)},i.prototype._write=function(t,e){this.db._batch(this._operations,t,e)},i.prototype._nextTick=n,t.exports=i},function(t,e,r){"use strict";(e=t.exports=r(298)).Stream=e,e.Readable=e,e.Writable=r(302),e.Duplex=r(72),e.Transform=r(303),e.PassThrough=r(690),e.finished=r(184),e.pipeline=r(691)},function(t,e,r){"use strict";(function(e,n){var i;t.exports=A,A.ReadableState=I;r(14).EventEmitter;var s=function(t,e){return t.listeners(e).length},o=r(299),a=r(3).Buffer,c=e.Uint8Array||function(){};var u,h=r(685);u=h&&h.debuglog?h.debuglog("stream"):function(){};var f,l,d,p=r(686),y=r(300),g=r(301).getHighWaterMark,b=r(71).codes,m=b.ERR_INVALID_ARG_TYPE,v=b.ERR_STREAM_PUSH_AFTER_EOF,w=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(23)(A,o);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function I(t,e,n){i=i||r(72),t=t||{},"boolean"!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(116).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function A(t){if(i=i||r(72),!(this instanceof A))return new A(t);var e=this instanceof i;this._readableState=new I(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function k(t,e,r,n,i){u("readableAddChunk",e);var s,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(u("onEofChunk"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?C(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}(t,o);else if(i||(s=function(t,e){var r;n=e,a.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new m("chunk",["string","Buffer","Uint8Array"],e));var n;return r}(o,e)),s)E(t,s);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=function(t){return a.from(t)}(e)),n)o.endEmitted?E(t,new _):T(t,o,e,!0);else if(o.ended)E(t,new v);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?T(t,o,e,!1):M(t,o)):T(t,o,e,!1)}else n||(o.reading=!1,M(t,o));return!o.ended&&(o.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,n.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,D(t)}function M(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(x,t,e))}function x(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function P(t){u("readable nexttick read 0"),t.read(0)}function O(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),D(t),e.flowing&&!e.reading&&t.read(0)}function D(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function L(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function U(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,n.nextTick(j,e,t))}function j(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function z(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):C(this),null;if(0===(t=R(t,e))&&e.ended)return 0===e.length&&U(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?L(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&U(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(t){E(this,new w("_read()"))},A.prototype.pipe=function(t,e){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var o=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?c:g;function a(e,n){u("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",y),t.removeListener("drain",h),t.removeListener("error",d),t.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",g),r.removeListener("data",l),f=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function c(){u("onend"),t.end()}i.endEmitted?n.nextTick(o):r.once("end",o),t.on("unpipe",a);var h=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,D(t))}}(r);t.on("drain",h);var f=!1;function l(e){u("ondata");var n=t.write(e);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==z(i.pipes,t))&&!f&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(e){u("onerror",e),g(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function p(){t.removeListener("finish",y),g()}function y(){u("onfinish"),t.removeListener("close",p),g()}function g(){u("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",y),t.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?C(this):i.reading||n.nextTick(P,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return"readable"===t&&n.nextTick(N,this),r},A.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||n.nextTick(N,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(O,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var s=0;s-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new y("_write()"))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var i=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,M(t,e),r&&(e.finished?n.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),A.prototype.destroy=f.destroy,A.prototype._undestroy=f.undestroy,A.prototype._destroy=function(t,e){e(t)}}).call(this,r(11),r(12))},function(t,e,r){"use strict";t.exports=h;var n=r(71).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,s=n.ERR_MULTIPLE_CALLBACK,o=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(72);function u(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new s);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{const e=t+"/repo.lock";if(i("locking %s",e),!0===s[e])throw new n.LockExistsError("Lock already being held for file: "+e);s[e]=!0;return{async close(){s[e]&&delete s[e]}}},e.locked=async t=>{const e=t+"/repo.lock";return i("checking lock: "+e),Boolean(s[e])}},function(t,e,r){"use strict";const n=r(4),i=r(13),s=r(19);t.exports={codec:s.RAW,defaultHashAlg:s.SHA2_256,resolver:{resolve:(t,e)=>{if("/"!==e)throw new Error("Only the root path / may be resolved");return{value:t,remainderPath:""}},tree:t=>({done:!0})},util:{deserialize:t=>t,serialize:t=>t,cid:async(e,r)=>{const o={cidVersion:1,hashAlg:t.exports.defaultHashAlg},a=Object.assign(o,r),c=await i(e,a.hashAlg),u=s.print[t.exports.codec];return new n(a.cidVersion,u,c)}}}},function(t,e,r){"use strict";const n=r(17),i=(t,e)=>e,s={ip4:i,ip6:(t,e,r,n)=>1===n.length&&"ip6"===n[0].protocol?e:`[${e}]`,tcp:(t,e,r,n,i)=>n.some(t=>["http","https","ws","wss"].includes(t.protocol))?`${t}:${e}`:((t,e,r,n)=>{if(n&&!1===n.assumeHttp)return`tcp://${t}:${e}`;let i="tcp",s=":"+e;return"tcp"===r[r.length-1].protocol&&(i="443"===e?"https":"http",s="443"===e||"80"===e?"":s),`${i}://${t}${s}`})(t,e,n,i),udp:(t,e)=>`udp://${t}:${e}`,dnsaddr:i,dns4:i,dns6:i,ipfs:(t,e)=>`${t}/ipfs/${e}`,p2p:(t,e)=>`${t}/p2p/${e}`,http:t=>"http://"+t,https:t=>"https://"+t,ws:t=>"ws://"+t,wss:t=>"wss://"+t,"p2p-websocket-star":t=>t+"/p2p-websocket-star","p2p-webrtc-star":t=>t+"/p2p-webrtc-star","p2p-webrtc-direct":t=>t+"/p2p-webrtc-direct"};t.exports=(t,e)=>{const r=n(t),i=t.toString().split("/").slice(1);return r.tuples().map(t=>({protocol:i.shift(),content:t[1]?i.shift():null})).reduce((t,r,n,i)=>{const o=s[r.protocol];if(!o)throw new Error("Unsupported protocol "+r.protocol);return o(t,r.content,n,i,e)},"")}},function(t,e,r){"use strict";const{createFromPrivKey:n}=r(7),i=r(0),s=r(1),o=s("ipfs:ipns");o.error=s("ipfs:ipns:error");const a=r(721),c=r(726),u=r(727),{normalizePath:h}=r(2),f=r(273);t.exports=class{constructor(t,e,r,n,i){this.publisher=new a(t,e),this.republisher=new c(this.publisher,e,r,n,i),this.resolver=new u(t),this.cache=new f(1e3),this.routing=t}async publish(t,e,r=a.defaultRecordLifetime){try{e=h(e);const i=await n(t.bytes);await this.publisher.publishWithEOL(t,e,r),o(`IPNS value ${e} was published correctly`);const s=i.toB58String(),a=parseFloat(r),c=a<6e4?a:6e4;return this.cache.set(s,e,c),o(`IPNS value ${e} was cached correctly`),{name:s,value:e}}catch(i){throw o.error(i),i}}async resolve(t,e){if("string"!=typeof t)throw i(new Error("name received is not valid"),"ERR_INVALID_NAME");if(!(e=e||{}).nocache&&!e.recursive){const e=t.split("/")[2],r=this.cache.get(e);if(r)return r}try{const r=await this.resolver.resolve(t,e);return o(`IPNS record from ${t} was resolved correctly`),r}catch(r){throw o.error(r),r}}async initializeKeyspace(t,e){return this.publish(t,e,a.defaultRecordLifetime)}}},function(t,e,r){"use strict";const{Key:n}=r(10),{Record:i}=r(73),{encodeBase32:s}=r(317),o=r(0),a=r(1),c=a("ipfs:ipns:offline-datastore");c.error=a("ipfs:ipns:offline-datastore:error");t.exports=class{constructor(t){this._repo=t}async put(t,e){if(!(t instanceof Uint8Array))throw o(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");if(!(e instanceof Uint8Array))throw o(new Error("Offline datastore value must be a Uint8Array"),"ERR_INVALID_VALUE");let r;try{r=this._routingKey(t)}catch(s){throw c.error(s),o(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}const n=new i(t,e);return this._repo.datastore.put(r,n.serialize())}async get(t){if(!(t instanceof Uint8Array))throw o(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");let e;try{e=this._routingKey(t)}catch(s){throw c.error(s),o(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}const r=await this._repo.datastore.get(e);let n;try{n=i.deserialize(r)}catch(s){throw c.error(s),s}return n.value}_routingKey(t){return new n("/"+s(t),!1)}}},function(t,e,r){"use strict";const n=r(96),i=r(5);t.exports={encodeBase32:t=>i(t,"base32upper"),validator:{func:(t,e,r)=>n.validator.validate(e,t,r)},selector:(t,e)=>n.validator.select(e[0],e[1])}},function(t,e,r){"use strict";var n=Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]},i=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},s=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return i(e,t),e},o=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(e){s(e)}}function a(t){try{c(n.throw(t))}catch(e){s(e)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};const a=r(319),c=r(760),u=r(761),h=s(r(74)),f=r(763),l=r(323),d=r(191),p=r(767),y=r(774),g=r(775),b=r(7),m=r(192),v=r(319);class w extends v{constructor(t,e={}){const r=[h.GossipsubIDv11,h.GossipsubIDv10],n=Object.assign(Object.assign({gossipIncoming:!0,fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:h.GossipsubD,Dlo:h.GossipsubDlo,Dhi:h.GossipsubDhi,Dscore:h.GossipsubDscore,Dout:h.GossipsubDout,Dlazy:h.GossipsubDlazy},e),{scoreParams:p.createPeerScoreParams(e.scoreParams),scoreThresholds:p.createPeerScoreThresholds(e.scoreThresholds)});n.fallbackToFloodsub&&r.push(h.FloodsubID),super(Object.assign({debugName:"libp2p:gossipsub",multicodecs:r,libp2p:t},n)),this._options=n,this.direct=new Set(n.directPeers.map(t=>t.id.toB58String())),n.directPeers.forEach(e=>{t.peerStore.addressBook.add(e.id,e.addrs)}),this.seenCache=new g,this.mesh=new Map,this.fanout=new Map,this.lastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.defaultMsgIdFn=t=>a.utils.msgId(t.from,t.seqno),this._msgIdFn=e.msgIdFn||this.defaultMsgIdFn,this.messageCache=e.messageCache||new c.MessageCache(h.GossipsubHistoryGossip,h.GossipsubHistoryLength,this._msgIdFn),this.heartbeat=new f.Heartbeat(this),this.heartbeatTicks=0,this.gossipTracer=new y.IWantTracer(this._msgIdFn),this._libp2p=t,this.score=new p.PeerScore(this._options.scoreParams,t.connectionManager,this._msgIdFn)}_decodeRpc(t){return u.RPCCodec.decode(t)}_encodeRpc(t){return u.RPCCodec.encode(t)}_addPeer(t,e){const r=super._addPeer(t,e);this.score.addPeer(t.toB58String());let n=!1;for(const i of this._libp2p.connectionManager.getAll(t))if("outbound"===i.stat.direction&&Array.from(i.registry.values()).some(t=>e===t.protocol)){n=!0;break}return this.outbound.set(r,n),r}_removePeer(t){const e=super._removePeer(t),r=t.toB58String();for(const n of this.mesh.values())n.delete(r);for(const n of this.fanout.values())n.delete(r);return this.gossip.delete(r),this.control.delete(r),this.outbound.delete(r),this.score.removePeer(r),e}_processRpc(t,e,r){return!!super._processRpc(t,e,r)&&(r.control&&this._processRpcControlMessage(t,r.control),!0)}_processRpcControlMessage(t,e){if(!e)return;const r=this._handleIHave(t,e.ihave),n=this._handleIWant(t,e.iwant),i=this._handleGraft(t,e.graft);if(this._handlePrune(t,e.prune),!r.length&&!n.length&&!i.length)return;const s=d.createGossipRpc(n,{iwant:r,prune:i});this._sendRpc(t,s)}_processRpcMessage(t){const e=Object.create(null,{_processRpcMessage:{get:()=>super._processRpcMessage}});return o(this,void 0,void 0,(function*(){const r=this.getMsgId(t);this.seenCache.has(r)?this.score.duplicateMessage(t):(this.seenCache.put(r),this.score.validateMessage(t),yield e._processRpcMessage.call(this,t))}))}_acceptFrom(t){return this.direct.has(t)||this.score.score(t)>=this._options.scoreThresholds.graylistThreshold}validate(t){const e=Object.create(null,{validate:{get:()=>super.validate}});return o(this,void 0,void 0,(function*(){try{yield e.validate.call(this,t)}catch(r){throw this.score.rejectMessage(t,r.code),this.gossipTracer.rejectMessage(t,r.code),r}}))}_handleIHave(t,e){if(!e.length)return[];const r=this.score.score(t);if(rh.GossipsubMaxIHaveMessages)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",t,n),[];const i=this.iasked.get(t)||0;if(i>=h.GossipsubMaxIHaveLength)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",t,i),[];const s=new Set;if(e.forEach(({topicID:t,messageIDs:e})=>{t&&this.mesh.has(t)&&e.forEach(t=>{this.seenCache.has(t)||s.add(t)})}),!s.size)return[];let o=s.size;o+i>h.GossipsubMaxIHaveLength&&(o=h.GossipsubMaxIHaveLength-i),this.log("IHAVE: Asking for %d out of %d messages from %s",o,s.size,t);let a=Array.from(s);return d.shuffle(a),a=a.slice(0,o),this.iasked.set(t,i+o),this.gossipTracer.addPromise(t,a),[{messageIDs:a}]}_handleIWant(t,e){if(!e.length)return[];const r=this.score.score(t);if(r{e.forEach(e=>{const[r,i]=this.messageCache.getForPeer(e,t);r&&(i>h.GossipsubGossipRetransmission?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",t,e):n.set(e,r))})}),n.size?(this.log("IWANT: Sending %d messages to %s",n.size,t),Array.from(n.values()).map(a.utils.normalizeOutRpcMessage)):[]}_handleGraft(t,e){const r=[],n=this.score.score(t),i=this._now();let s=this._options.doPX;return e.forEach(({topicID:e})=>{var o;if(!e)return;const a=this.mesh.get(e);if(!a)return void(s=!1);if(a.has(t))return;if(this.direct.has(t))return this.log("GRAFT: ignoring request from direct peer %s",t),r.push(e),void(s=!1);const c=null===(o=this.backoff.get(e))||void 0===o?void 0:o.get(t);if("number"==typeof c&&i=this._options.Dhi&&!this.outbound.get(t)?(r.push(e),void this._addBackoff(t,e)):(this.log("GRAFT: Add mesh link from %s in %s",t,e),this.score.graft(t,e),void a.add(t))}),r.length?r.map(e=>this._makePrune(t,e,s)):[]}_handlePrune(t,e){const r=this.score.score(t);e.forEach(({topicID:e,backoff:n,peers:i})=>{if(!e)return;const s=this.mesh.get(e);if(s&&(this.log("PRUNE: Remove mesh link to %s in %s",t,e),this.score.prune(t,e),s.delete(t),"number"==typeof n&&n>0?this._doAddBackoff(t,e,1e3*n):this._addBackoff(t,e),i&&i.length)){if(r{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",e,t),this.score.addPenalty(e,t)})}_clearBackoff(){if(this.heartbeatTicks%h.GossipsubPruneBackoffTicks!=0)return;const t=this._now();this.backoff.forEach((e,r)=>{e.forEach((r,n)=>{r{const r=this.peers.get(e);r&&r.isWritable||t.push(e)}),t.length&&t.forEach(t=>{this._connect(t)})}_pxConnect(t){return o(this,void 0,void 0,(function*(){t.length>h.GossipsubPrunePeers&&(d.shuffle(t),t=t.slice(0,h.GossipsubPrunePeers));const e=[];yield Promise.all(t.map(t=>o(this,void 0,void 0,(function*(){if(!t.peerID)return;const r=b.createFromBytes(t.peerID).toB58String();if(!this.peers.has(r))if(t.signedPeerRecord)try{const n=yield m.openAndCertify(t.signedPeerRecord,"libp2p-peer-record"),i=n.peerId.toB58String();if(r!==i)return void this.log("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s",i,r);if(!this._libp2p.peerStore.addressBook.consumePeerRecord(n))return void this.log("bogus peer record obtained through px: could not add peer record to address book");e.push(r)}catch(n){this.log("bogus peer record obtained through px: invalid signature or not a peer record")}else e.push(r)})))),e.length&&e.forEach(t=>this._connect(t))}))}start(){super.start(),this.heartbeat.start(),this.score.start(),this._directPeerInitial=setTimeout(()=>{this.direct.forEach(t=>{this._connect(t)})},h.GossipsubDirectConnectInitialDelay)}stop(){super.stop(),this.heartbeat.stop(),this.score.stop(),this.mesh=new Map,this.fanout=new Map,this.lastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.gossipTracer.clear(),clearTimeout(this._directPeerInitial)}_connect(t){this.log("Initiating connection with %s",t),this._libp2p.dialProtocol(b.createFromB58String(t),this.multicodecs)}subscribe(t){super.subscribe(t),this.join(t)}unsubscribe(t){super.unsubscribe(t),this.leave(t)}join(t){if(!this.started)throw new Error("Gossipsub has not started");this.log("JOIN %s",t);const e=this.fanout.get(t);if(e)e.forEach(t=>{this.score.score(t)<0&&e.delete(t)}),e.size!e.has(t)&&!this.direct.has(t)&&this.score.score(t)>=0).forEach(t=>e.add(t)),this.mesh.set(t,e),this.fanout.delete(t),this.lastpub.delete(t);else{const e=l.getGossipPeers(this,t,this._options.D,t=>!this.direct.has(t)&&this.score.score(t)>=0);this.mesh.set(t,e)}this.mesh.get(t).forEach(e=>{this.log("JOIN: Add mesh link to %s in %s",e,t),this._sendGraft(e,t)})}leave(t){if(!this.started)throw new Error("Gossipsub has not started");this.log("LEAVE %s",t);const e=this.mesh.get(t);e&&(e.forEach(e=>{this.log("LEAVE: Remove mesh link to %s in %s",e,t),this._sendPrune(e,t)}),this.mesh.delete(t))}getMsgId(t){return this._msgIdFn(t)}_publish(t){return o(this,void 0,void 0,(function*(){t.receivedFrom!==this.peerId.toB58String()&&(this.score.deliverMessage(t),this.gossipTracer.deliverMessage(t));const e=this.getMsgId(t);this.seenCache.put(e),this.messageCache.put(t);const r=new Set;t.topicIDs.forEach(e=>{const n=this.topics.get(e);if(n)if(this._options.floodPublish&&t.from===this.peerId.toB58String())n.forEach(t=>{(this.direct.has(t)||this.score.score(t)>=this._options.scoreThresholds.publishThreshold)&&r.add(t)});else{this.direct.forEach(t=>{r.add(t)}),n.forEach(t=>{const e=this.score.score(t),n=this.peers.get(t);n&&n.protocol===h.FloodsubID&&e>=this._options.scoreThresholds.publishThreshold&&r.add(t)});let t=this.mesh.get(e);if(!t||!t.size){if(t=this.fanout.get(e),!t){const r=l.getGossipPeers(this,e,this._options.D,t=>this.score.score(t)>=this._options.scoreThresholds.publishThreshold);r.size>0?(t=r,this.fanout.set(e,r)):t=new Set}this.lastpub.set(e,this._now())}t.forEach(t=>{r.add(t)})}});const n=d.createGossipRpc([a.utils.normalizeOutRpcMessage(t)]);r.forEach(e=>{e!==t.from&&this._sendRpc(e,n)})}))}_sendGraft(t,e){const r=[{topicID:e}],n=d.createGossipRpc([],{graft:r});this._sendRpc(t,n)}_sendPrune(t,e){const r=[this._makePrune(t,e,this._options.doPX)],n=d.createGossipRpc([],{prune:r});this._sendRpc(t,n)}_sendRpc(t,e){const r=this.peers.get(t);if(!r||!r.isWritable)return;const n=this.control.get(t);n&&(this._piggybackControl(t,e,n),this.control.delete(t));const i=this.gossip.get(t);i&&(this._piggybackGossip(t,e,i),this.gossip.delete(t)),r.write(u.RPCCodec.encode(e))}_piggybackControl(t,e,r){const n=(r.graft||[]).filter(({topicID:e})=>(e&&this.mesh.get(e)||new Set).has(t)),i=(r.prune||[]).filter(({topicID:e})=>!(e&&this.mesh.get(e)||new Set).has(t));(n.length||i.length)&&(e.control?(e.control.graft=e.control.graft.concat(n),e.control.prune=e.control.prune.concat(i)):e.control={ihave:[],iwant:[],graft:n,prune:i})}_piggybackGossip(t,e,r){e.control||(e.control={ihave:[],iwant:[],graft:[],prune:[]}),e.control.ihave=r}_sendGraftPrune(t,e,r){const n=this._options.doPX;for(const[i,s]of t){const t=s.map(t=>({topicID:t}));let o=[];const a=e.get(i);a&&(o=a.map(t=>this._makePrune(i,t,n&&!r.get(i))),e.delete(i));const c=d.createGossipRpc([],{graft:t,prune:o});this._sendRpc(i,c)}for(const[i,s]of e){const t=s.map(t=>this._makePrune(i,t,n&&!r.get(i))),e=d.createGossipRpc([],{prune:t});this._sendRpc(i,e)}}_emitGossip(t,e){const r=this.messageCache.getGossipIDs(t);if(!r.length)return;d.shuffle(r),r.length>h.GossipsubMaxIHaveLength&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length);const n=[],i=this.topics.get(t);if(!i)return;i.forEach(t=>{const r=this.peers.get(t);r&&!e.has(t)&&!this.direct.has(t)&&d.hasGossipProtocol(r.protocol)&&this.score.score(t)>=this._options.scoreThresholds.gossipThreshold&&n.push(t)});let s=this._options.Dlazy;const o=h.GossipsubGossipFactor*n.length;o>s&&(s=o),s>n.length?s=n.length:d.shuffle(n),n.slice(0,s).forEach(e=>{let n=r;r.length>h.GossipsubMaxIHaveLength&&(n=d.shuffle(n.slice()).slice(0,h.GossipsubMaxIHaveLength)),this._pushGossip(e,{topicID:t,messageIDs:n})})}_flush(){for(const[t,e]of this.gossip.entries()){this.gossip.delete(t);const r=d.createGossipRpc([],{ihave:e});this._sendRpc(t,r)}for(const[t,e]of this.control.entries()){this.control.delete(t);const r=d.createGossipRpc([],{graft:e.graft,prune:e.prune});this._sendRpc(t,r)}}_pushGossip(t,e){this.log("Add gossip to %s",t);const r=this.gossip.get(t)||[];this.gossip.set(t,r.concat(e))}_now(){return Date.now()}_makePrune(t,e,r){if(this.peers.get(t).protocol===h.GossipsubIDv10)return{topicID:e,peers:[]};const n=h.GossipsubPruneBackoff/1e3,i=[];if(r){l.getGossipPeers(this,e,h.GossipsubPrunePeers,e=>e!==t&&this.score.score(e)>=0).forEach(t=>{const e=b.createFromB58String(t);i.push({peerID:e.toBytes(),signedPeerRecord:this._libp2p.peerStore.addressBook.getRawEnvelope(e)})})}return{topicID:e,peers:i,backoff:n}}}w.multicodec=h.GossipsubIDv11,t.exports=w},function(t,e,r){"use strict";const n=r(1),i=r(14),s=r(0),o=r(25),a=r(748),{codes:c}=r(189),u=r(320),h=r(752),f=r(758),{signMessage:l,verifySignature:d}=r(759);t.exports=class extends i{constructor({debugName:t,multicodecs:e,libp2p:r,signMessages:i=!0,strictSigning:s=!0,canRelayMessage:o=!1,emitSelf:a=!1}){if("string"!=typeof t)throw new Error("a debugname `string` is required");if(!e)throw new Error("multicodecs are required");if(!r)throw new Error("libp2p is required");super(),this.log=n(t),this.log.err=n(t+":error"),this.multicodecs=f.ensureArray(e),this._libp2p=r,this.registrar=r.registrar,this.peerId=r.peerId,this.started=!1,this.topics=new Map,this.subscriptions=new Set,this.peers=new Map,this.signMessages=i,this.strictSigning=s,this.canRelayMessage=o,this.emitSelf=a,this.topicValidators=new Map,this._registrarId=void 0,this._onIncomingStream=this._onIncomingStream.bind(this),this._onPeerConnected=this._onPeerConnected.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this)}start(){if(this.started)return;this.log("starting"),this.registrar.handle(this.multicodecs,this._onIncomingStream);const t=new a({multicodecs:this.multicodecs,handlers:{onConnect:this._onPeerConnected,onDisconnect:this._onPeerDisconnected}});this._registrarId=this.registrar.register(t),this.log("started"),this.started=!0}stop(){this.started&&(this.registrar.unregister(this._registrarId),this.log("stopping"),this.peers.forEach(t=>t.close()),this.peers=new Map,this.subscriptions=new Set,this.started=!1,this.log("stopped"))}_onIncomingStream({protocol:t,stream:e,connection:r}){const n=r.remotePeer,i=n.toB58String(),s=this._addPeer(n,t);s.attachInboundStream(e),this._processMessages(i,s.inboundStream,s)}async _onPeerConnected(t,e){const r=t.toB58String();this.log("connected",r);try{const{stream:r,protocol:n}=await e.newStream(this.multicodecs),i=this._addPeer(t,n);await i.attachOutboundStream(r)}catch(n){this.log.err(n)}this._sendSubscriptions(r,Array.from(this.subscriptions),!0)}_onPeerDisconnected(t,e){const r=t.toB58String();this.log("connection ended",r,e?e.message:""),this._removePeer(t)}_addPeer(t,e){const r=t.toB58String(),n=this.peers.get(r);if(n)return n;this.log("new peer",r);const i=new h({id:t,protocol:e});return this.peers.set(r,i),i.once("close",()=>this._removePeer(t)),i}_removePeer(t){if(!t)return;const e=t.toB58String(),r=this.peers.get(e);if(r){r.removeAllListeners(),r.close(),this.log("delete peer",e),this.peers.delete(e);for(const t of this.topics.values())t.delete(e);return r}}async _processMessages(t,e,r){try{await o(e,async e=>{for await(const n of e){const e=n instanceof Uint8Array?n:n.slice(),i=this._decodeRpc(e);this._processRpc(t,r,i)}})}catch(n){this._onPeerDisconnected(r.id,n)}}_processRpc(t,e,r){this.log("rpc from",t);const n=r.subscriptions,i=r.msgs;return n.length&&(n.forEach(e=>this._processRpcSubOpt(t,e)),this.emit("pubsub:subscription-change",e.id,n)),this._acceptFrom(t)?(i.length&&i.forEach(e=>{if(!this.canRelayMessage&&!e.topicIDs.some(t=>this.subscriptions.has(t)))return void this.log("received message we didn't subscribe to. Dropping.");const r=f.normalizeInRpcMessage(e,t);this._processRpcMessage(r)}),!0):(this.log("received message from unacceptable peer %s",t),!1)}_processRpcSubOpt(t,e){const r=e.topicID;let n=this.topics.get(r);n||(n=new Set,this.topics.set(r,n)),e.subscribe?n.add(t):n.delete(t)}async _processRpcMessage(t){if(this.peerId.toB58String()!==t.from||this.emitSelf){try{await this.validate(t)}catch(e){return void this.log("Message is invalid, dropping it. %O",e)}this._emitMessage(t),this._publish(f.normalizeOutRpcMessage(t))}}_emitMessage(t){t.topicIDs.forEach(e=>{this.subscriptions.has(e)&&this.emit(e,t)})}getMsgId(t){return f.msgId(t.from,t.seqno)}_acceptFrom(t){return!0}_decodeRpc(t){return u.rpc.RPC.decode(t)}_encodeRpc(t){return u.rpc.RPC.encode(t)}_sendRpc(t,e){const r=this.peers.get(t);if(r&&r.isWritable)r.write(this._encodeRpc(e));else{const e=`Cannot send RPC to ${t} as there is no open stream to it available`;this.log.err(e)}}_sendSubscriptions(t,e,r){return this._sendRpc(t,{subscriptions:e.map(t=>({topicID:t,subscribe:r}))})}async validate(t){if(this.strictSigning&&!t.signature)throw s(new Error("Signing required and no signature was present"),c.ERR_MISSING_SIGNATURE);if(t.signature&&!await d(t))throw s(new Error("Invalid message signature"),c.ERR_INVALID_SIGNATURE);for(const e of t.topicIDs){const r=this.topicValidators.get(e);r&&await r(e,t)}}_buildMessage(t){const e=f.normalizeOutRpcMessage(t);return this.signMessages?l(this.peerId,e):t}getSubscribers(t){if(!this.started)throw s(new Error("not started yet"),"ERR_NOT_STARTED_YET");if(!t||"string"!=typeof t)throw s(new Error("a string topic must be provided"),"ERR_NOT_VALID_TOPIC");const e=this.topics.get(t);return e?Array.from(e):[]}async publish(t,e){if(!this.started)throw new Error("Pubsub has not started");this.log("publish",t,e);const r=this.peerId.toB58String();let n={receivedFrom:r,from:r,data:e,seqno:f.randomSeqno(),topicIDs:[t]};const i=await this._buildMessage(n);n=f.normalizeInRpcMessage(i),this.emitSelf&&this._emitMessage(n),await this._publish(n)}_publish(t){throw s(new Error("publish must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}subscribe(t){if(!this.started)throw new Error("Pubsub has not started");this.subscriptions.has(t)||(this.subscriptions.add(t),this.peers.forEach((e,r)=>this._sendSubscriptions(r,[t],!0)))}unsubscribe(t){if(!this.started)throw new Error("Pubsub is not started");this.subscriptions.has(t)&&0===this.listenerCount(t)&&(this.subscriptions.delete(t),this.peers.forEach((e,r)=>this._sendSubscriptions(r,[t],!1)))}getTopics(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.subscriptions)}},t.exports.message=u,t.exports.utils=f},function(t,e,r){"use strict";const n=r(21),i=n(r(750)),s=i.RPC,o=n(r(751));(e=t.exports).rpc=i,e.td=o,e.RPC=s,e.Message=s.Message,e.SubOpts=s.SubOpts},function(t,e,r){"use strict";const n=r(15),{Buffer:i}=r(3),s=(t,e,r)=>{const o=n.encode(t,e,r);return s.bytes=n.encode.bytes,e||i.from(o)};t.exports=s},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=r(15),s=t=>{const e=i.decode(n.isBuffer(t)?t:(r=t,new Proxy({},{get:(t,e)=>"l"===e[0]?r[e]:r.get(parseInt(e))})));var r;return s.bytes=i.decode.bytes,e};t.exports=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getGossipPeers=void 0;const n=r(191);e.getGossipPeers=function(t,e,r,i=(()=>!0)){const s=t.topics.get(e);if(!s)return new Set;let o=[];return s.forEach(e=>{const r=t.peers.get(e);r&&n.hasGossipProtocol(r.protocol)&&i(e)&&o.push(e)}),o=n.shuffle(o),r>0&&o.length>r&&(o=o.slice(0,r)),new Set(o)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateTopicScoreParams=e.validatePeerScoreParams=e.createTopicScoreParams=e.createPeerScoreParams=e.defaultTopicScoreParams=e.defaultPeerScoreParams=void 0;const n=r(325),i=r(0);function s(t={}){return Object.assign(Object.assign({},e.defaultTopicScoreParams),t)}function o(t){if(t.topicWeight<0)throw i(new Error("invalid topic weight; must be >= 0"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0===t.timeInMeshQuantum)throw i(new Error("invalid TimeInMeshQuantum; must be non zero"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.timeInMeshWeight<0)throw i(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.timeInMeshWeight&&t.timeInMeshQuantum<=0)throw i(new Error("invalid TimeInMeshQuantum; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.timeInMeshWeight&&t.timeInMeshCap<=0)throw i(new Error("invalid TimeInMeshCap; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.firstMessageDeliveriesWeight<0)throw i(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.firstMessageDeliveriesWeight&&(t.firstMessageDeliveriesDecay<=0||t.firstMessageDeliveriesDecay>=1))throw i(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.firstMessageDeliveriesWeight&&t.firstMessageDeliveriesCap<=0)throw i(new Error("invalid FirstMessageDeliveriesCap; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.meshMessageDeliveriesWeight>0)throw i(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.meshMessageDeliveriesWeight&&(t.meshMessageDeliveriesDecay<=0||t.meshMessageDeliveriesDecay>=1))throw i(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.meshMessageDeliveriesWeight&&t.meshMessageDeliveriesCap<=0)throw i(new Error("invalid MeshMessageDeliveriesCap; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.meshMessageDeliveriesWeight&&t.meshMessageDeliveriesThreshold<=0)throw i(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.meshMessageDeliveriesWindow<0)throw i(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.meshMessageDeliveriesWeight&&t.meshMessageDeliveriesActivation<1e3)throw i(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.meshFailurePenaltyWeight>0)throw i(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.meshFailurePenaltyWeight&&(t.meshFailurePenaltyDecay<=0||t.meshFailurePenaltyDecay>=1))throw i(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.invalidMessageDeliveriesWeight>0)throw i(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.invalidMessageDeliveriesDecay<=0||t.invalidMessageDeliveriesDecay>=1)throw i(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS)}e.defaultPeerScoreParams={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},e.defaultTopicScoreParams={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3},e.createPeerScoreParams=function(t={}){return Object.assign(Object.assign(Object.assign({},e.defaultPeerScoreParams),t),{topics:t.topics?Object.entries(t.topics).reduce((t,[e,r])=>(t[e]=s(r),t),{}):{}})},e.createTopicScoreParams=s,e.validatePeerScoreParams=function(t){for(const[r,s]of Object.entries(t.topics))try{o(s)}catch(e){throw i(new Error(`invalid score parameters for topic ${r}: ${e.message}`),n.ERR_INVALID_PEER_SCORE_PARAMS)}if(t.topicScoreCap<0)throw i(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(null===t.appSpecificScore||void 0===t.appSpecificScore)throw i(new Error("missing application specific score function"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.IPColocationFactorWeight>0)throw i(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.IPColocationFactorWeight&&t.IPColocationFactorThreshold<1)throw i(new Error("invalid IPColocationFactorThreshold; must be at least 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.behaviourPenaltyWeight>0)throw i(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==t.behaviourPenaltyWeight&&(t.behaviourPenaltyDecay<=0||t.behaviourPenaltyDecay>=1))throw i(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.decayInterval<1e3)throw i(new Error("invalid DecayInterval; must be at least 1s"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(t.decayToZero<=0||t.decayToZero>=1)throw i(new Error("invalid DecayToZero; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS)},e.validateTopicScoreParams=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERR_INVALID_PEER_SCORE_THRESHOLDS=e.ERR_INVALID_PEER_SCORE_PARAMS=void 0,e.ERR_INVALID_PEER_SCORE_PARAMS="ERR_INVALID_PEER_SCORE_PARAMS",e.ERR_INVALID_PEER_SCORE_THRESHOLDS="ERR_INVALID_PEER_SCORE_THRESHOLDS"},function(t,e,r){"use strict";const n=r(781),i=r(782);class s extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError("Expected input to be an Array, got "+typeof t);let e=(t=[...t].map(t=>t instanceof Error?t:null!==t&&"object"==typeof t?Object.assign(new Error(t.message),t):new Error(t))).map(t=>"string"==typeof t.stack?i(t.stack).replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""):String(t)).join("\n");e="\n"+n(e,4),super(e),this.name="AggregateError",Object.defineProperty(this,"_errors",{value:t})}*[Symbol.iterator](){for(const t of this._errors)yield t}}t.exports=s},function(t,e,r){"use strict";const n=r(7),i=r(17),s=r(0),{codes:o}=r(28);t.exports=function(t){let e;if("string"==typeof t&&(t=i(t)),i.isMultiaddr(t)){e=t;try{t=n.createFromB58String(t.getPeerId())}catch(r){throw s(new Error(t+" is not a valid peer type"),o.ERR_INVALID_MULTIADDR)}}return{id:t,multiaddrs:e?[e]:void 0}}},function(t,e,r){"use strict";const n=r(788),{codes:i}=r(28),s=r(0),o=r(1),a=o("libp2p:transports");a.error=o("libp2p:transports:error");class c{constructor({libp2p:t,upgrader:e,faultTolerance:r=u.FATAL_ALL}){this.libp2p=t,this.upgrader=e,this._transports=new Map,this._listeners=new Map,this.faultTolerance=r}add(t,e,r={}){if(a("adding %s",t),!t)throw s(new Error(`Transport must have a valid key, was given '${t}'`),i.ERR_INVALID_KEY);if(this._transports.has(t))throw s(new Error("There is already a transport with this key"),i.ERR_DUPLICATE_TRANSPORT);const n=new e({...r,libp2p:this.libp2p,upgrader:this.upgrader});this._transports.set(t,n),this._listeners.has(t)||this._listeners.set(t,[])}async close(){const t=[];for(const[e,r]of this._listeners)for(a("closing listeners for %s",e);r.length;){const e=r.pop();t.push(e.close())}await Promise.all(t),a("all listeners closed");for(const e of this._listeners.keys())this._listeners.set(e,[])}async dial(t,e){const r=this.transportForMultiaddr(t);if(!r)throw s(new Error("No transport available for address "+String(t)),i.ERR_TRANSPORT_UNAVAILABLE);try{return await r.dial(t,e)}catch(n){throw n.code||(n.code=i.ERR_TRANSPORT_DIAL_FAILED),n}}getAddrs(){let t=[];for(const e of this._listeners.values())for(const r of e)t=[...t,...r.getAddrs()];return t}getTransports(){return this._transports.values()}transportForMultiaddr(t){for(const e of this._transports.values()){if(e.filter([t]).length)return e}return null}async listen(){const t=this.libp2p.addressManager.getListenAddrs();if(0===t.length)return void a("no addresses were provided for listening, this node is dial only");const e=[];for(const[r,o]of this._transports.entries()){const c=o.filter(t),u=[];for(const t of c){a("creating listener for %s on %s",r,t);const e=o.createListener({},this.onConnection);this._listeners.get(r).push(e),u.push(e.listen(t))}if(0===u.length){e.push(r);continue}if(!(await n(u)).find(t=>!0===t.isFulfilled))throw s(new Error(`Transport (${r}) could not listen on any available address`),i.ERR_NO_VALID_ADDRESSES)}if(e.length===this._transports.size){const t=`no valid addresses were provided for transports [${e}]`;if(this.faultTolerance===u.FATAL_ALL)throw s(new Error(t),i.ERR_NO_VALID_ADDRESSES);a("libp2p in dial mode only: "+t)}}async remove(t){if(a("removing %s",t),this._listeners.has(t))for(const e of this._listeners.get(t))await e.close();this._transports.delete(t),this._listeners.delete(t)}async removeAll(){const t=[];for(const e of this._transports.keys())t.push(this.remove(e));await Promise.all(t)}}const u={FATAL_ALL:0,NO_FATAL:1};c.FaultTolerance=u,t.exports=c},function(t,e,r){"use strict";const n=r(17),{CircuitRelay:i}=r(97);function s(t,e){t.write({type:i.Type.STATUS,code:e})}t.exports={validateAddrs:function(t,e){try{t.dstPeer.addrs.forEach(t=>n(t))}catch(r){throw s(e,t.type===i.Type.HOP?i.Status.HOP_DST_MULTIADDR_INVALID:i.Status.STOP_DST_MULTIADDR_INVALID),r}try{t.srcPeer.addrs.forEach(t=>n(t))}catch(r){throw s(e,t.type===i.Type.HOP?i.Status.HOP_SRC_MULTIADDR_INVALID:i.Status.STOP_SRC_MULTIADDR_INVALID),r}}}},function(t,e,r){"use strict";const n=r(36);t.exports=t=>{const e=async function*(){let e=yield,r=new n;for await(const i of t)if(e)for(r.append(i);r.length>=e;){const t=r.shallowSlice(0,e);if(r.consume(e),e=yield t,!e){r.length&&(e=yield r,r=new n);break}}else e=yield r.append(i),r=new n;if(e)throw Object.assign(new Error(`stream ended before ${e} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})}();return e.next(),e}},function(t,e,r){"use strict";const{CircuitRelay:n}=r(97),i=r(196),s=r(197),{validateAddrs:o}=r(329),a=r(1),c=a("libp2p:circuit:stop");c.error=a("libp2p:circuit:stop:error"),t.exports.handleStop=function({connection:t,request:e,streamHandler:r}){try{o(e,r)}catch(i){return c.error("invalid stop request via peer %s",t.remotePeer.toB58String(),i)}return c("stop request is valid"),r.write({type:n.Type.STATUS,code:n.Status.SUCCESS}),r.rest()},t.exports.stop=async function({connection:t,request:e}){const{stream:r}=await t.newStream([i.relay]);c("starting stop request to %s",t.remotePeer.toB58String());const o=new s({stream:r});o.write(e);const a=await o.read();if(a.code===n.Status.SUCCESS)return c("stop request to %s was successful",t.remotePeer.toB58String()),o.rest();c("stop request failed with code %d",a.code),o.close()}},function(t,e,r){"use strict";var n=r(9);r(18),t.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(t,e){var r=t;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+t);return new n.cipher.BlockCipher({algorithm:r,key:e,decrypt:!1})},n.cipher.createDecipher=function(t,e){var r=t;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+t);return new n.cipher.BlockCipher({algorithm:r,key:e,decrypt:!0})},n.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),n.cipher.algorithms[t]=e},n.cipher.getAlgorithm=function(t){return(t=t.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[t]:null};var i=n.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};i.prototype.start=function(t){t=t||{};var e={};for(var r in t)e[r]=t[r];e.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=t.output||n.util.createBuffer(),this.mode.start(e)},i.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(t){!t||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(e){return t(this.blockSize,e,!1)},this.mode.unpad=function(e){return t(this.blockSize,e,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,e)))}},function(t,e,r){"use strict";var n=r(9);r(18),n.cipher=n.cipher||{};var i=t.exports=n.cipher.modes=n.cipher.modes||{};function s(t,e){if("string"==typeof t&&(t=n.util.createBuffer(t)),n.util.isArray(t)&&t.length>4){var r=t;t=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=t.length(),n=t.at(r-1);return!(n>this.blockSize<<2)&&(t.truncate(n),!0)},i.cbc=function(t){t=t||{},this.name="CBC",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(t){if(null===t.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(t,e,r){if(t.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=t.length(),n=t.at(r-1);return!(n>this.blockSize<<2)&&(t.truncate(n),!0)},i.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)t.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)t.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(t,e,r){var n=t.length();if(0===t.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)t.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=s(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var e,r=n.util.createBuffer(t.iv);if(this._cipherLength=0,e="additionalData"in t?n.util.createBuffer(t.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in t?t.tagLength:128,this._tag=null,t.decrypt&&(this._tag=n.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,e=n.util.createBuffer(e),this._aDataLength=a(8*e.length());var s=e.length()%this.blockSize;for(s&&e.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];e.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()])},i.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},i.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)e[n]=t[n]>>>1|(1&t[n-1])<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)},i.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var n=t[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];e[0]^=i[0],e[1]^=i[1],e[2]^=i[2],e[3]^=i[3]}return e},i.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)},i.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,n=4*r,i=16*r,s=new Array(i),o=0;o>>1,i=new Array(r);i[n]=t.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s128)throw new Error('Invalid "nsComment" content.');t.value=i.create(i.Class.UNIVERSAL,i.Type.IA5STRING,!1,t.comment)}else if("subjectKeyIdentifier"===t.name&&e.cert){var d=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=d.toHex(),t.value=i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,d.getBytes())}else if("authorityKeyIdentifier"===t.name&&e.cert){t.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);h=t.value.value;if(t.keyIdentifier){var p=!0===t.keyIdentifier?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;h.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!1,p))}if(t.authorityCertIssuer){var g=[i.create(i.Class.CONTEXT_SPECIFIC,4,!0,[y(!0===t.authorityCertIssuer?e.cert.issuer:t.authorityCertIssuer)])];h.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,g))}if(t.serialNumber){var b=n.util.hexToBytes(!0===t.serialNumber?e.cert.serialNumber:t.serialNumber);h.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!1,b))}}else if("cRLDistributionPoints"===t.name){t.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);h=t.value.value;var m,v=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]),w=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);for(l=0;l2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(f.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=f[0],c.validity.notAfter=f[1],c.tbsCertificate=r.tbsCertificate,e){var l;if(c.md=null,c.signatureOid in o)switch(o[c.signatureOid]){case"sha1WithRSAEncryption":c.md=n.md.sha1.create();break;case"md5WithRSAEncryption":c.md=n.md.md5.create();break;case"sha256WithRSAEncryption":c.md=n.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=n.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=n.md.sha512.create();break;case"RSASSA-PSS":c.md=n.md.sha256.create()}if(null===c.md)throw(l=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,l;var y=i.toDer(c.tbsCertificate);c.md.update(y.getBytes())}var b=n.md.sha1.create();c.issuer.getField=function(t){return d(c.issuer,t)},c.issuer.addField=function(t){g([t]),c.issuer.attributes.push(t)},c.issuer.attributes=s.RDNAttributesAsArray(r.certIssuer,b),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=b.digest().toHex();var m=n.md.sha1.create();return c.subject.getField=function(t){return d(c.subject,t)},c.subject.addField=function(t){g([t]),c.subject.attributes.push(t)},c.subject.attributes=s.RDNAttributesAsArray(r.certSubject,m),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=m.digest().toHex(),r.certExtensions?c.extensions=s.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=s.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},s.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r1&&(r=c.value.charCodeAt(1),s=c.value.length>2?c.value.charCodeAt(2):0),e.digitalSignature=128==(128&r),e.nonRepudiation=64==(64&r),e.keyEncipherment=32==(32&r),e.dataEncipherment=16==(16&r),e.keyAgreement=8==(8&r),e.keyCertSign=4==(4&r),e.cRLSign=2==(2&r),e.encipherOnly=1==(1&r),e.decipherOnly=128==(128&s)}else if("basicConstraints"===e.name){(c=i.fromDer(e.value)).value.length>0&&c.value[0].type===i.Type.BOOLEAN?e.cA=0!==c.value[0].value.charCodeAt(0):e.cA=!1;var a=null;c.value.length>0&&c.value[0].type===i.Type.INTEGER?a=c.value[0].value:c.value.length>1&&(a=c.value[1].value),null!==a&&(e.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===e.name)for(var c=i.fromDer(e.value),u=0;u1&&(r=c.value.charCodeAt(1)),e.client=128==(128&r),e.server=64==(64&r),e.email=32==(32&r),e.objsign=16==(16&r),e.reserved=8==(8&r),e.sslCA=4==(4&r),e.emailCA=2==(2&r),e.objCA=1==(1&r)}else if("subjectAltName"===e.name||"issuerAltName"===e.name){var f;e.altNames=[];c=i.fromDer(e.value);for(var l=0;l=w&&t<_?i.create(i.Class.UNIVERSAL,i.Type.UTCTIME,!1,i.dateToUtcTime(t)):i.create(i.Class.UNIVERSAL,i.Type.GENERALIZEDTIME,!1,i.dateToGeneralizedTime(t))}s.getTBSCertificate=function(t){var e=E(t.validity.notBefore),r=E(t.validity.notAfter),o=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(t.version).getBytes())]),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,n.util.hexToBytes(t.serialNumber)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(t.siginfo.algorithmOid).getBytes()),m(t.siginfo.algorithmOid,t.siginfo.parameters)]),y(t.issuer),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[e,r]),y(t.subject),s.publicKeyToAsn1(t.publicKey)]);return t.issuer.uniqueId&&o.value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+t.issuer.uniqueId)])),t.subject.uniqueId&&o.value.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!0,[i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+t.subject.uniqueId)])),t.extensions.length>0&&o.value.push(s.certificateExtensionsToAsn1(t.extensions)),o},s.getCertificationRequestInfo=function(t){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(t.version).getBytes()),y(t.subject),s.publicKeyToAsn1(t.publicKey),v(t)])},s.distinguishedNameToAsn1=function(t){return y(t)},s.certificateToAsn1=function(t){var e=t.tbsCertificate||s.getTBSCertificate(t);return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[e,i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(t.signatureOid).getBytes()),m(t.signatureOid,t.signatureParameters)]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])},s.certificateExtensionsToAsn1=function(t){var e=i.create(i.Class.CONTEXT_SPECIFIC,3,!0,[]),r=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);e.value.push(r);for(var n=0;nh.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:s.certificateError.certificate_expired,notBefore:h.validity.notBefore,notAfter:h.validity.notAfter,now:o}),null===c){if(null===(f=e[0]||t.getIssuer(h))&&h.isIssuer(h)&&(l=!0,f=h),f){var d=f;n.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){f=d.shift();try{p=f.verify(h)}catch(E){}}p||(c={message:"Certificate signature is invalid.",error:s.certificateError.bad_certificate})}null!==c||f&&!l||t.hasCertificate(h)||(c={message:"Certificate is not trusted.",error:s.certificateError.unknown_ca})}if(null===c&&f&&!h.isIssuer(f)&&(c={message:"Certificate issuer is invalid.",error:s.certificateError.bad_certificate}),null===c)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===c&&gm.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:s.certificateError.bad_certificate})}var w=null===c||c.error,_=r.verify?r.verify(w,u,i):w;if(!0!==_)throw!0===w&&(c={message:"The application rejected the certificate.",error:s.certificateError.bad_certificate}),(_||0===_)&&("object"!=typeof _||n.util.isArray(_)?"string"==typeof _&&(c.error=_):(_.message&&(c.message=_.message),_.error&&(c.error=_.error))),c;c=null,a=!1,++u}while(e.length>0);return!0}},function(t,e,r){"use strict";var n=r(9);if(r(100),r(336),r(101),r(817),r(819),r(75),r(18),void 0===i)var i=n.jsbn.BigInteger;var s=n.util.isNodejs?r(200):null,o=n.asn1,a=n.util;n.pki=n.pki||{},t.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],h={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},f={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},l={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},d=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p=function(t){var e;if(!(t.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}e=c.oids[t.algorithm];var n=o.oidToDer(e).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);s.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),s.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var a=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(s),i.value.push(a),o.toDer(i).getBytes()},y=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);var s;e.dP||(e.dP=e.d.mod(e.p.subtract(i.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(i.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));do{s=new i(n.util.bytesToHex(n.random.getBytes(e.n.bitLength()/8)),16)}while(s.compareTo(e.n)>=0||!s.gcd(e.n).equals(i.ONE));for(var o=(t=t.multiply(s.modPow(e.e,e.n)).mod(e.n)).mod(e.p).modPow(e.dP,e.p),a=t.mod(e.q).modPow(e.dQ,e.q);o.compareTo(a)<0;)o=o.add(e.p);var c=o.subtract(a).multiply(e.qInv).mod(e.p).multiply(e.q).add(a);return c=c.multiply(s.modInverse(e.n)).mod(e.n)};function g(t,e,r){var i=n.util.createBuffer(),s=Math.ceil(e.n.bitLength()/8);if(t.length>s-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=t.length,o.max=s-11,o}i.putByte(0),i.putByte(r);var a,c=s-3-t.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var h=0,f=n.random.getBytes(c);for(u=0;u1;){if(255!==o.getByte()){--o.read;break}++u}else if(2===c)for(u=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++u}if(0!==o.getByte()||u!==s-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function m(t,e,r){"function"==typeof e&&(r=e,e={});var s={algorithm:{name:(e=e||{}).algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};function o(){a(t.pBits,(function(e,n){return e?r(e):(t.p=n,null!==t.q?u(e,t.q):void a(t.qBits,u))}))}function a(t,e){n.prime.generateProbablePrime(t,s,e)}function u(e,n){if(e)return r(e);if(t.q=n,t.p.compareTo(t.q)<0){var s=t.p;t.p=t.q,t.q=s}if(0!==t.p.subtract(i.ONE).gcd(t.e).compareTo(i.ONE))return t.p=null,void o();if(0!==t.q.subtract(i.ONE).gcd(t.e).compareTo(i.ONE))return t.q=null,void a(t.qBits,u);if(t.p1=t.p.subtract(i.ONE),t.q1=t.q.subtract(i.ONE),t.phi=t.p1.multiply(t.q1),0!==t.phi.gcd(t.e).compareTo(i.ONE))return t.p=t.q=null,void o();if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits)return t.q=null,void a(t.qBits,u);var h=t.e.modInverse(t.phi);t.keys={privateKey:c.rsa.setPrivateKey(t.n,t.e,h,t.p,t.q,h.mod(t.p1),h.mod(t.q1),t.q.modInverse(t.p)),publicKey:c.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}"prng"in e&&(s.prng=e.prng),o()}function v(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=n.util.hexToBytes(e);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function w(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function _(t){return n.util.isNodejs&&"function"==typeof s[t]}function E(t){return void 0!==a.globalScope&&"object"==typeof a.globalScope.crypto&&"object"==typeof a.globalScope.crypto.subtle&&"function"==typeof a.globalScope.crypto.subtle[t]}function S(t){return void 0!==a.globalScope&&"object"==typeof a.globalScope.msCrypto&&"object"==typeof a.globalScope.msCrypto.subtle&&"function"==typeof a.globalScope.msCrypto.subtle[t]}function I(t){for(var e=n.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),i=0;i0;)h.putByte(0),--f;return h.putBytes(n.util.hexToBytes(u)),h.getBytes()},c.rsa.decrypt=function(t,e,r,s){var o=Math.ceil(e.n.bitLength()/8);if(t.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=t.length,a.expected=o,a}var c=new i(n.util.createBuffer(t).toHex(),16);if(c.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,e,r).toString(16),h=n.util.createBuffer(),f=o-Math.ceil(u.length/2);f>0;)h.putByte(0),--f;return h.putBytes(n.util.hexToBytes(u)),!1!==s?b(h.getBytes(),e,r):h.getBytes()},c.rsa.createKeyPairGenerationState=function(t,e,r){"string"==typeof t&&(t=parseInt(t,10)),t=t||2048;var s,o=(r=r||{}).prng||n.random,a={nextBytes:function(t){for(var e=o.getBytesSync(t.length),r=0;r>1,pBits:t-(t>>1),pqState:0,num:null,keys:null}).e.fromInt(s.eInt),s},c.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,s=0,o=function(t,e){return t|e},a=+new Date,h=0;null===t.keys&&(e<=0||hf?t.pqState=0:t.num.isProbablePrime(w(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(u[s++%8],0):2===t.pqState?t.pqState=0===t.num.subtract(i.ONE).gcd(t.e).compareTo(i.ONE)?3:0:3===t.pqState&&(t.pqState=0,null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state,t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(i.ONE),t.q1=t.q.subtract(i.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(i.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var d=t.e.modInverse(t.phi);t.keys={privateKey:c.rsa.setPrivateKey(t.n,t.e,d,t.p,t.q,d.mod(t.p1),d.mod(t.q1),t.q.modInverse(t.p)),publicKey:c.rsa.setPublicKey(t.n,t.e)}}h+=(n=+new Date)-a,a=n}return null!==t.keys},c.rsa.generateKeyPair=function(t,e,r,i){if(1===arguments.length?"object"==typeof t?(r=t,t=void 0):"function"==typeof t&&(i=t,t=void 0):2===arguments.length?"number"==typeof t?"function"==typeof e?(i=e,e=void 0):"number"!=typeof e&&(r=e,e=void 0):(r=t,i=e,t=void 0,e=void 0):3===arguments.length&&("number"==typeof e?"function"==typeof r&&(i=r,r=void 0):(i=r,r=e,e=void 0)),r=r||{},void 0===t&&(t=r.bits||2048),void 0===e&&(e=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(65537===e||3===e))if(i){if(_("generateKeyPair"))return s.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(t,e,r){if(t)return i(t);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(e)})}));if(E("generateKey")&&E("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:I(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(t){return a.globalScope.crypto.subtle.exportKey("pkcs8",t.privateKey)})).then(void 0,(function(t){i(t)})).then((function(t){if(t){var e=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));i(null,{privateKey:e,publicKey:c.setRsaPublicKey(e.n,e.e)})}}));if(S("generateKey")&&S("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:I(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(t){var e=t.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",e.privateKey);r.oncomplete=function(t){var e=t.target.result,r=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(t){i(t)}},void(u.onerror=function(t){i(t)})}}else if(_("generateKeyPairSync")){var h=s.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(h.privateKey),publicKey:c.publicKeyFromPem(h.publicKey)}}var f=c.rsa.createKeyPairGenerationState(t,e,r);if(!i)return c.rsa.stepKeyPairGenerationState(f,0),f.keys;m(f,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(t,e){var r={n:t,e:e,encrypt:function(t,e,i){if("string"==typeof e?e=e.toUpperCase():void 0===e&&(e="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===e)e={encode:function(t,e,r){return g(t,e,2).getBytes()}};else if("RSA-OAEP"===e||"RSAES-OAEP"===e)e={encode:function(t,e){return n.pkcs1.encode_rsa_oaep(e,t,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(e))e={encode:function(t){return t}};else if("string"==typeof e)throw new Error('Unsupported encryption scheme: "'+e+'".');var s=e.encode(t,r,!0);return c.rsa.encrypt(s,r,!0)},verify:function(t,e,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(t,e){return e=b(e,r,!0),t===o.fromDer(e).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(t,e){return t===(e=b(e,r,!0))}});var i=c.rsa.decrypt(e,r,!0,!1);return n.verify(t,i,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(t,e,r,i,s,o,a,u){var h={n:t,e:e,d:r,p:i,q:s,dP:o,dQ:a,qInv:u,decrypt:function(t,e,r){"string"==typeof e?e=e.toUpperCase():void 0===e&&(e="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(t,h,!1,!1);if("RSAES-PKCS1-V1_5"===e)e={decode:b};else if("RSA-OAEP"===e||"RSAES-OAEP"===e)e={decode:function(t,e){return n.pkcs1.decode_rsa_oaep(e,t,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(e))throw new Error('Unsupported encryption scheme: "'+e+'".');e={decode:function(t){return t}}}return e.decode(i,h,!1)},sign:function(t,e){var r=!1;"string"==typeof e&&(e=e.toUpperCase()),void 0===e||"RSASSA-PKCS1-V1_5"===e?(e={encode:p},r=1):"NONE"!==e&&"NULL"!==e&&null!==e||(e={encode:function(){return t}},r=1);var n=e.encode(t,h.n.bitLength());return c.rsa.encrypt(n,h,r)}};return h},c.wrapRsaPrivateKey=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(t).getBytes())])},c.privateKeyFromAsn1=function(t){var e,r,s,a,u,l,d,p,y={},g=[];if(o.validate(t,h,y,g)&&(t=o.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!o.validate(t,f,y,g)){var b=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw b.errors=g,b}return e=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),s=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrime1).toHex(),u=n.util.createBuffer(y.privateKeyPrime2).toHex(),l=n.util.createBuffer(y.privateKeyExponent1).toHex(),d=n.util.createBuffer(y.privateKeyExponent2).toHex(),p=n.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(e,16),new i(r,16),new i(s,16),new i(a,16),new i(u,16),new i(l,16),new i(d,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.qInv))])},c.publicKeyFromAsn1=function(t){var e={},r=[];if(o.validate(t,d,e,r)){var s,a=o.derToOid(e.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(s=new Error("Cannot read public key. Unknown OID.")).oid=a,s;t=e.rsaPublicKey}if(r=[],!o.validate(t,l,e,r))throw(s=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,s;var u=n.util.createBuffer(e.publicKeyModulus).toHex(),h=n.util.createBuffer(e.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(h,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(t)])])},c.publicKeyToRSAPublicKey=function(t){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(t.e))])}},function(t,e,r){"use strict";var n,i=r(9);t.exports=i.jsbn=i.jsbn||{};function s(t,e,r){this.data=[],null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function o(){return new s(null)}function a(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this.data[t],u=this.data[t++]>>14,h=a*c+u*o;i=((c=o*c+((16383&h)<<14)+r.data[n]+i)>>28)+(h>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=s,"undefined"==typeof navigator?(s.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(s.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var c=32767&this.data[t],u=this.data[t++]>>15,h=a*c+u*o;i=((c=o*c+((32767&h)<<15)+r.data[n]+(1073741823&i))>>>30)+(h>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(s.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this.data[t++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},n=26):(s.prototype.am=a,n=28),s.prototype.DB=n,s.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function y(t){this.m=t}function g(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function E(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function S(){}function I(t){return t}function A(t){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}y.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},y.prototype.revert=function(t){return t},y.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},y.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},y.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},g.prototype.convert=function(t){var e=o();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(s.ZERO)>0&&this.m.subTo(e,e),e},g.prototype.revert=function(t){var e=o();return t.copyTo(e),this.reduce(e),e},g.prototype.reduce=function(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},g.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},g.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},s.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s},s.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0},s.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var a=8==r?255&t[n]:l(t,n);a<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-o):this.data[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==t;)--this.t},s.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s},s.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e.data[r+o+1]=this.data[r]>>i|a,a=(this.data[r]&s)<=0;--r)e.data[r]=0;e.data[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},s.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e.data[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()},s.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i=0;)t.data[r]=0;for(r=0;r=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()},s.prototype.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(h,a),i.lShiftTo(h,r)):(n.copyTo(a),i.copyTo(r));var f=a.t,l=a.data[f-1];if(0!=l){var d=l*(1<1?a.data[f-2]>>this.F2:0),y=this.FV/d,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),s.ONE.dlShiftTo(f,w),w.subTo(a,a);a.t=0;){var _=r.data[--m]==l?this.DM:Math.floor(r.data[m]*y+(r.data[m-1]+b)*g);if((r.data[m]+=a.am(0,_,r,v,0,f))<_)for(a.dlShiftTo(v,w),r.subTo(w,r);r.data[m]<--_;)r.subTo(w,r)}null!=e&&(r.drShiftTo(f,e),c!=u&&s.ZERO.subTo(e,e)),r.t=f,r.clamp(),h>0&&r.rShiftTo(h,r),c<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var t=this.data[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(t,e){if(t>4294967295||t<1)return s.ONE;var r=o(),n=o(),i=e.convert(this),a=p(t)-1;for(i.copyTo(r);--a>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var c=r;r=n,n=c}return e.revert(r)},s.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=f(r));o>=0;)a>(a+=this.DB-e)):(r=this.data[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=f(r));return i?s:"0"},s.prototype.negate=function(){var t=o();return s.ZERO.subTo(this,t),t},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this.data[r]-t.data[r]))return e;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(t){var e=o();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(s.ZERO)>0&&t.subTo(e,e),e},s.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new y(e):new g(e),this.exp(t,r)},s.ZERO=d(0),s.ONE=d(1),S.prototype.convert=I,S.prototype.revert=I,S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},S.prototype.sqrTo=function(t,e){t.squareTo(e)},A.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=o();return t.copyTo(e),this.reduce(e),e},A.prototype.revert=function(t){return t},A.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},A.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},A.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],T=(1<<26)/k[k.length-1];s.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},s.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=d(r),i=o(),s=o(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(t).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(t)+a},s.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),i&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(s.ONE.shiftLeft(t-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(s.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()},s.prototype.dMultiply=function(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}},s.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r},s.prototype.millerRabin=function(t){var e=this.subtract(s.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n,i=e.shiftRight(r),o={nextBytes:function(t){for(var e=0;e=0);var c=n.modPow(i,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(e)){for(var u=1;u++>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this.data[t]&(1<>(n+=this.DB-8)):(r=this.data[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},s.prototype.equals=function(t){return 0==this.compareTo(t)},s.prototype.min=function(t){return this.compareTo(t)<0?this:t},s.prototype.max=function(t){return this.compareTo(t)>0?this:t},s.prototype.and=function(t){var e=o();return this.bitwiseTo(t,b,e),e},s.prototype.or=function(t){var e=o();return this.bitwiseTo(t,m,e),e},s.prototype.xor=function(t){var e=o();return this.bitwiseTo(t,v,e),e},s.prototype.andNot=function(t){var e=o();return this.bitwiseTo(t,w,e),e},s.prototype.not=function(){for(var t=o(),e=0;e=this.t?0!=this.s:0!=(this.data[e]&1<1){var f=o();for(n.sqrTo(a[1],f);c<=h;)a[c]=o(),n.mulTo(f,a[c-2],a[c]),c+=2}var l,b,m=t.t-1,v=!0,w=o();for(i=p(t.data[m])-1;m>=0;){for(i>=u?l=t.data[m]>>i-u&h:(l=(t.data[m]&(1<0&&(l|=t.data[m-1]>>this.DB+i-u)),c=r;0==(1&l);)l>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),v)a[l].copyTo(s),v=!1;else{for(;c>1;)n.sqrTo(s,w),n.sqrTo(w,s),c-=2;c>0?n.sqrTo(s,w):(b=s,s=w,w=b),n.mulTo(w,a[l],s)}for(;m>=0&&0==(t.data[m]&1<=0?(r.subTo(n,r),e&&i.subTo(a,i),o.subTo(c,o)):(n.subTo(r,n),e&&a.subTo(i,a),c.subTo(o,c))}return 0!=n.compareTo(s.ONE)?s.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},s.prototype.pow=function(t){return this.exp(t,new S)},s.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r.data[0]<=k[k.length-1]){for(e=0;e 0 to the moving average constructor");let e,r,i=0,s=0,o=0,a={};return a.push=function(a,c){if(r){const u=1-n(-(a-r)/t),h=c-e;e=u*c+(1-u)*e,i=(1-u)*(i+h*(u*h)),s=Math.sqrt(i),o=e+u*h}else e=c;r=a},a.movingAverage=function(){return e},a.variance=function(){return i},a.deviation=function(){return s},a.forecast=function(){return o},a}},function(t,e,r){"use strict";e.PROTOCOL_ID="/multistream/1.0.0"},function(t,e,r){"use strict";const n=r(0),i=r(1);i("libp2p:peer-store").error=i("libp2p:peer-store:error");const{EventEmitter:s}=r(14),o=r(7),a=r(838),c=r(843),u=r(844),h=r(845),{ERR_INVALID_PARAMETERS:f}=r(28);t.exports=class extends s{constructor({peerId:t}){super(),this._peerId=t,this.addressBook=new a(this),this.keyBook=new c(this),this.metadataBook=new u(this),this.protoBook=new h(this)}start(){}stop(){}get peers(){const t=new Set([...this.addressBook.data.keys(),...this.keyBook.data.keys(),...this.protoBook.data.keys(),...this.metadataBook.data.keys()]);this._peerId&&t.delete(this._peerId.toB58String());const e=new Map;return t.forEach(t=>{e.set(t,this.get(o.createFromCID(t)))}),e}delete(t){const e=this.addressBook.delete(t),r=this.keyBook.delete(t),n=this.protoBook.delete(t),i=this.metadataBook.delete(t);return e||r||n||i}get(t){if(!o.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),f);const e=this.keyBook.data.get(t.toB58String()),r=this.addressBook.get(t),i=this.metadataBook.get(t),s=this.protoBook.get(t);if(e||r||i||s)return{id:e||t,addresses:r||[],protocols:s||[],metadata:i}}}},function(t,e,r){"use strict";const n=r(17),i=r(7),s=r(839),o=r(840),a=r(841),{ENVELOPE_DOMAIN_PEER_RECORD:c,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:u}=r(842);class h extends s{constructor({peerId:t,multiaddrs:e=[],seqNumber:r=Date.now()}){super(c,u),this.peerId=t,this.multiaddrs=e,this.seqNumber=r,this._marshal=void 0}marshal(){return this._marshal||(this._marshal=a.encode({peer_id:this.peerId.toBytes(),seq:this.seqNumber,addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this._marshal}equals(t){return!!this.peerId.equals(t.peerId)&&(this.seqNumber===t.seqNumber&&!!o(this.multiaddrs,t.multiaddrs))}}h.createFromProtobuf=t=>{const e=a.decode(t),r=i.createFromBytes(e.peer_id),s=(e.addresses||[]).map(t=>n(t.multiaddr)),o=e.seq;return new h({peerId:r,multiaddrs:s,seqNumber:o})},h.DOMAIN=c,t.exports=h},function(t,e,r){"use strict";e.CODE_P2P=421,e.CODE_CIRCUIT=290,e.CLOSE_TIMEOUT=2e3},function(t,e,r){"use strict";const n=r(17),i=r(0),{Address4:s,Address6:o}=r(876),a={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};t.exports=(t,e)=>{if("string"!=typeof t)throw i(new Error("invalid ip provided: "+t),a.ERR_INVALID_IP_PARAMETER);if(e=parseInt(e),isNaN(e))throw i(new Error("invalid port provided: "+e),a.ERR_INVALID_PORT_PARAMETER);if(new s(t).isValid())return n(`/ip4/${t}/tcp/${e}`);const r=new o(t);if(r.isValid())return r.is4()?n(`/ip4/${r.to4().correctForm()}/tcp/${e}`):n(`/ip6/${t}/tcp/${e}`);throw i(new Error(`invalid ip:port for creating a multiaddr: ${t}:${e}`),a.ERR_INVALID_IP)},t.exports.Errors=a},function(t,e,r){"use strict";var n=r(344).BigInteger,i=r(345),s=r(102).sprintf,o=r(346),a=r(347),c=r(202);function u(t){this.valid=!1,this.address=t,this.groups=c.GROUPS,this.v4=!0,this.subnet="/32",this.subnetMask=32;var e=c.RE_SUBNET_STRING.exec(t);if(e){if(this.parsedSubnet=e[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,this.subnetMask<0||this.subnetMask>c.BITS)return this.valid=!1,void(this.error="Invalid subnet mask.");t=t.replace(c.RE_SUBNET_STRING,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}u.prototype.parse=function(t){var e=t.split(".");return t.match(c.RE_ADDRESS)?this.valid=!0:this.error="Invalid IPv4 address.",e},u.prototype.isValid=function(){return this.valid},u.prototype.correctForm=function(){return this.parsedAddress.map((function(t){return parseInt(t,10)})).join(".")},u.prototype.isCorrect=i.isCorrect(c.BITS),u.fromHex=function(t){var e,r=o(t.replace(/:/g,""),8,"0"),n=[];for(e=0;e<8;e+=2){var i=r.slice(e,e+2);n.push(parseInt(i,16))}return new u(n.join("."))},u.fromInteger=function(t){return u.fromHex(t.toString(16))},u.prototype.toHex=function(){return this.parsedAddress.map((function(t){return s("%02x",parseInt(t,10))})).join(":")},u.prototype.toArray=function(){return this.parsedAddress.map((function(t){return parseInt(t,10)}))},u.prototype.toGroup6=function(){var t,e=[];for(t=0;t>15;--s>=0;){var c=32767&this[t],u=this[t++]>>15,h=a*c+u*o;i=((c=o*c+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i},e=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},e=26):(r.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var c=16383&this[t],u=this[t++]>>14,h=a*c+u*o;i=((c=o*c+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*u,r[n++]=268435455&c}return i},e=28),r.prototype.DB=e,r.prototype.DM=(1<>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function l(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function v(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function w(){}function _(t){return t}function E(t){this.r2=n(),this.q3=n(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}l.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},l.prototype.revert=function(t){return t},l.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},l.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},l.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(r.ZERO)>0&&this.m.subTo(e,e),e},d.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},r.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var i=t.length,s=!1,o=0;--i>=0;){var a=8==n?255&t[i]:u(t,i);a<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+n>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==n&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},r.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},r.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(e[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},r.prototype.multiplyTo=function(t,e){var n=this.abs(),i=t.abs(),s=n.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,e,i){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(h,a),o.lShiftTo(h,i)):(s.copyTo(a),o.copyTo(i));var l=a.t,d=a[l-1];if(0!=d){var p=d*(1<1?a[l-2]>>this.F2:0),y=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(w,i)),r.ONE.dlShiftTo(l,w),w.subTo(a,a);a.t=0;){var _=i[--m]==d?this.DM:Math.floor(i[m]*y+(i[m-1]+b)*g);if((i[m]+=a.am(0,_,i,v,0,l))<_)for(a.dlShiftTo(v,w),i.subTo(w,i);i[m]<--_;)i.subTo(w,i)}null!=e&&(i.drShiftTo(l,e),c!=u&&r.ZERO.subTo(e,e)),i.t=l,i.clamp(),h>0&&i.rShiftTo(h,i),c<0&&r.ZERO.subTo(i,i)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,e){if(t>4294967295||t<1)return r.ONE;var i=n(),s=n(),o=e.convert(this),a=f(t)-1;for(o.copyTo(i);--a>=0;)if(e.sqrTo(i,s),(t&1<0)e.mulTo(s,o,i);else{var c=i;i=s,s=c}return e.revert(i)},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=c(r));o>=0;)a>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=c(r));return i?s:"0"},r.prototype.negate=function(){var t=n();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e},r.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new l(e):new d(e),this.exp(t,r)},r.ZERO=h(0),r.ONE=h(1),w.prototype.convert=_,w.prototype.revert=_,w.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},w.prototype.sqrTo=function(t,e){t.squareTo(e)},E.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e},E.prototype.revert=function(t){return t},E.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},E.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},E.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var S,I,A,k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],T=(1<<26)/k[k.length-1];function R(){var t;t=(new Date).getTime(),I[A++]^=255&t,I[A++]^=t>>8&255,I[A++]^=t>>16&255,I[A++]^=t>>24&255,A>=O&&(A-=O)}if(r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=h(r),s=n(),o=n(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(r+o.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(t)+a},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),i=Math.pow(e,n),s=!1,o=0,a=0,c=0;c=n&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),s&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},r.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},r.prototype.millerRabin=function(t){var e=this.subtract(r.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var s=e.shiftRight(i);(t=t+1>>1)>k.length&&(t=k.length);for(var o=n(),a=0;a>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var e=n();return this.bitwiseTo(t,p,e),e},r.prototype.or=function(t){var e=n();return this.bitwiseTo(t,y,e),e},r.prototype.xor=function(t){var e=n();return this.bitwiseTo(t,g,e),e},r.prototype.andNot=function(t){var e=n();return this.bitwiseTo(t,b,e),e},r.prototype.not=function(){for(var t=n(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var y=n();for(i.sqrTo(a[1],y);c<=p;)a[c]=n(),i.mulTo(y,a[c-2],a[c]),c+=2}var g,b,m=t.t-1,v=!0,w=n();for(s=f(t[m])-1;m>=0;){for(s>=u?g=t[m]>>s-u&p:(g=(t[m]&(1<0&&(g|=t[m-1]>>this.DB+s-u)),c=r;0==(1&g);)g>>=1,--c;if((s-=c)<0&&(s+=this.DB,--m),v)a[g].copyTo(o),v=!1;else{for(;c>1;)i.sqrTo(o,w),i.sqrTo(w,o),c-=2;c>0?i.sqrTo(o,w):(b=o,o=w,w=b),i.mulTo(w,a[g],o)}for(;m>=0&&0==(t[m]&1<=0?(n.subTo(i,n),e&&s.subTo(a,s),o.subTo(c,o)):(i.subTo(n,i),e&&a.subTo(s,a),c.subTo(o,c))}return 0!=i.compareTo(r.ONE)?r.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},r.prototype.pow=function(t){return this.exp(t,new w)},r.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},r.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e>>8,I[A++]=255&C;A=0,R()}function x(){if(null==S){for(R(),(S=new P).init(I),A=0;A9007199254740991)return r;do{e%2&&(r+=t),(e=C(e/2))&&(t+=t)}while(e);return r}function N(t){if("string"==typeof t)return t;if(D(t))return M?M.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function P(t,e,r){var n=t.length;return r=void 0===r?n:r,!e&&r>=n?t:function(t,e,r){var n=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var s=Array(i);++n-1&&t%1==0&&t<=9007199254740991}(t.length)&&!function(t){var e=b(t)?f.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)}(r)&&function(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||o.test(t))&&t>-1&&t%1==0&&t9007199254740991)return r;do{e%2&&(r+=t),(e=d(e/2))&&(t+=t)}while(e);return r}(w(t),e)}}).call(this,r(11))},function(t,e,r){"use strict";var n=r(102).sprintf,i=e.spanAllZeroes=function(t){return t.replace(/(0+)/g,'$1')};function s(t){return t.replace(/^(0+)/,'$1')}e.spanAll=function(t,e){return void 0===e&&(e=0),t.split("").map((function(t,r){return n('%s',t,r+e,i(t))})).join("")},e.spanLeadingZeroes=function(t){return t.split(":").map((function(t){return s(t)})).join(":")},e.simpleGroup=function(t,e){var r=t.split(":");return e||(e=0),r.map((function(t,r){return/group-v4/.test(t)?t:n('%s',r+e,s(t))})).join(":")}},function(t,e,r){"use strict";var n=r(1)("simple-peer"),i=r(886),s=r(350),o=r(297),a=r(887),c=r(0);function u(t){return t.replace(/a=ice-options:trickle\s\n/g,"")}class h extends o.Duplex{constructor(t){if(super(t=Object.assign({allowHalfOpen:!1},t)),this._id=s(4).toString("hex").slice(0,7),this._debug("new peer %o",t),this.channelName=t.initiator?t.channelName||s(20).toString("hex"):null,this.initiator=t.initiator||!1,this.channelConfig=t.channelConfig||h.channelConfig,this.negotiated=this.channelConfig.negotiated,this.config=Object.assign({},h.config,t.config),this.offerOptions=t.offerOptions||{},this.answerOptions=t.answerOptions||{},this.sdpTransform=t.sdpTransform||(t=>t),this.streams=t.streams||(t.stream?[t.stream]:[]),this.trickle=void 0===t.trickle||t.trickle,this.allowHalfTrickle=void 0!==t.allowHalfTrickle&&t.allowHalfTrickle,this.iceCompleteTimeout=t.iceCompleteTimeout||5e3,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=t.wrtc&&"object"==typeof t.wrtc?t.wrtc:i(),!this._wrtc)throw"undefined"==typeof window?c(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT"):c(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!this.negotiated&&!this.initiator,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._firstStable=!0,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(e){return void a(()=>this.destroy(c(e,"ERR_PC_CONSTRUCTOR")))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},this.initiator||this.negotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this.initiator&&this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(t){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_SIGNALING");if("string"==typeof t)try{t=JSON.parse(t)}catch(e){t={}}this._debug("signal()"),t.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),t.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(t.transceiverRequest.kind,t.transceiverRequest.init)),t.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(t.candidate):this._pendingCandidates.push(t.candidate)),t.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(t)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())}).catch(t=>{this.destroy(c(t,"ERR_SET_REMOTE_DESCRIPTION"))}),t.sdp||t.candidate||t.renegotiate||t.transceiverRequest||this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}_addIceCandidate(t){var e=new this._wrtc.RTCIceCandidate(t);this._pc.addIceCandidate(e).catch(t=>{var r;!e.address||e.address.endsWith(".local")?(r="Ignoring unsupported ICE candidate.",console.warn(r)):this.destroy(c(t,"ERR_ADD_ICE_CANDIDATE"))})}send(t){this._channel.send(t)}addTransceiver(t,e){if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(t,e),this._needsNegotiation()}catch(r){this.destroy(c(r,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{transceiverRequest:{kind:t,init:e}})}addStream(t){this._debug("addStream()"),t.getTracks().forEach(e=>{this.addTrack(e,t)})}addTrack(t,e){this._debug("addTrack()");var r=this._senderMap.get(t)||new Map,n=r.get(e);if(n)throw n.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED");n=this._pc.addTrack(t,e),r.set(e,n),this._senderMap.set(t,r),this._needsNegotiation()}replaceTrack(t,e,r){this._debug("replaceTrack()");var n=this._senderMap.get(t),i=n?n.get(r):null;if(!i)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");e&&this._senderMap.set(e,n),null!=i.replaceTrack?i.replaceTrack(e):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(t,e){this._debug("removeSender()");var r=this._senderMap.get(t),n=r?r.get(e):null;if(!n)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{n.removed=!0,this._pc.removeTrack(n)}catch(i){"NS_ERROR_UNEXPECTED"===i.name?this._sendersAwaitingStable.push(n):this.destroy(c(i,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(t){this._debug("removeSenders()"),t.getTracks().forEach(e=>{this.removeTrack(e,t)})}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,a(()=>{this._batchedNegotiation=!1,this._debug("starting batched negotiation"),this.negotiate()}))}negotiate(){this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{renegotiate:!0})),this._isNegotiating=!0}_destroy(t,e){if(this._debug("destroy (error: %s)",t&&(t.message||t)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(t){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(t){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e(t)}_setupData(t){if(!t.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=t.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=t=>{this._onChannelMessage(t)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=t=>{this.destroy(c(t,"ERR_DATA_CHANNEL"))};var e=!1;this._closingInterval=setInterval(()=>{this._channel&&"closing"===this._channel.readyState?(e&&this._onChannelClose(),e=!0):e=!1},5e3)}_read(){}_write(t,e,r){if(this.destroyed)return r(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(t)}catch(n){return this.destroy(c(n,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=r):r(null)}else this._debug("write before connect"),this._chunk=t,this._cb=r}_onFinish(){if(this.destroyed)return;const t=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?t():this.once("connect",t)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(t=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(t.sdp=u(t.sdp)),t.sdp=this.sdpTransform(t.sdp);const e=()=>{if(!this.destroyed){var e=this._pc.localDescription||t;this._debug("signal"),this.emit("signal",{type:e.type,sdp:e.sdp})}};this._pc.setLocalDescription(t).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?e():this.once("_iceComplete",e))}).catch(t=>{this.destroy(c(t,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(t=>{this.destroy(c(t,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(t=>{t.mid||!t.sender.track||t.requested||(t.requested=!0,this.addTransceiver(t.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(t=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(t.sdp=u(t.sdp)),t.sdp=this.sdpTransform(t.sdp);const e=()=>{if(!this.destroyed){var e=this._pc.localDescription||t;this._debug("signal"),this.emit("signal",{type:e.type,sdp:e.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(t).then(()=>{this.destroyed||(this.trickle||this._iceComplete?e():this.once("_iceComplete",e))}).catch(t=>{this.destroy(c(t,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(t=>{this.destroy(c(t,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(!this.destroyed){var t=this._pc.iceConnectionState,e=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",t,e),this.emit("iceStateChange",t,e),"connected"!==t&&"completed"!==t||(this._pcReady=!0,this._maybeReady()),"failed"===t&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===t&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}}getStats(t){const e=t=>("[object Array]"===Object.prototype.toString.call(t.values)&&t.values.forEach(e=>{Object.assign(t,e)}),t);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then(r=>{var n=[];r.forEach(t=>{n.push(e(t))}),t(null,n)},e=>t(e)):this._pc.getStats.length>0?this._pc.getStats(r=>{if(!this.destroyed){var n=[];r.result().forEach(t=>{var r={};t.names().forEach(e=>{r[e]=t.stat(e)}),r.id=t.id,r.type=t.type,r.timestamp=t.timestamp,n.push(e(r))}),t(null,n)}},e=>t(e)):t(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const t=()=>{this.destroyed||this.getStats((e,r)=>{if(this.destroyed)return;e&&(r=[]);var n={},i={},s={},o=!1;r.forEach(t=>{"remotecandidate"!==t.type&&"remote-candidate"!==t.type||(n[t.id]=t),"localcandidate"!==t.type&&"local-candidate"!==t.type||(i[t.id]=t),"candidatepair"!==t.type&&"candidate-pair"!==t.type||(s[t.id]=t)});const a=t=>{o=!0;var e=i[t.localCandidateId];e&&(e.ip||e.address)?(this.localAddress=e.ip||e.address,this.localPort=Number(e.port)):e&&e.ipAddress?(this.localAddress=e.ipAddress,this.localPort=Number(e.portNumber)):"string"==typeof t.googLocalAddress&&(e=t.googLocalAddress.split(":"),this.localAddress=e[0],this.localPort=Number(e[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");var r=n[t.remoteCandidateId];r&&(r.ip||r.address)?(this.remoteAddress=r.ip||r.address,this.remotePort=Number(r.port)):r&&r.ipAddress?(this.remoteAddress=r.ipAddress,this.remotePort=Number(r.portNumber)):"string"==typeof t.googRemoteAddress&&(r=t.googRemoteAddress.split(":"),this.remoteAddress=r[0],this.remotePort=Number(r[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(r.forEach(t=>{"transport"===t.type&&t.selectedCandidatePairId&&a(s[t.selectedCandidatePairId]),("googCandidatePair"===t.type&&"true"===t.googActiveConnection||("candidatepair"===t.type||"candidate-pair"===t.type)&&t.selected)&&a(t)}),o||Object.keys(s).length&&!Object.keys(i).length){if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(c(e,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');var u=this._cb;this._cb=null,u(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}else setTimeout(t,100)})};t()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"!==this._pc.signalingState||this._firstStable||(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(t=>{this._pc.removeTrack(t),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation&&(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()),this._debug("negotiate"),this.emit("negotiate")),this._firstStable=!1,this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(t){this.destroyed||(t.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:t.candidate.candidate,sdpMLineIndex:t.candidate.sdpMLineIndex,sdpMid:t.candidate.sdpMid}}):t.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),t.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(t){if(!this.destroyed){var e=t.data;e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this.push(e)}}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var t=this._cb;this._cb=null,t(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(t){this.destroyed||t.streams.forEach(e=>{this._debug("on track"),this.emit("track",t.track,e),this._remoteTracks.push({track:t.track,stream:e}),this._remoteStreams.some(t=>t.id===e.id)||(this._remoteStreams.push(e),a(()=>{this.emit("stream",e)}))})}_debug(){var t=[].slice.call(arguments);t[0]="["+this._id+"] "+t[0],n.apply(null,t)}}h.WEBRTC_SUPPORT=!!i(),h.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},h.channelConfig={},t.exports=h},function(t,e,r){"use strict";(function(e,n){var i=r(225).Buffer,s=e.crypto||e.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=i.allocUnsafe(t);if(t>0)if(t>65536)for(var o=0;o0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},d.prototype.cleanup=function(){u("cleanup");for(var t=this.subs.length,e=0;e=this._reconnectionAttempts)u("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();u("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var r=setTimeout((function(){t.skipReconnect||(u("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open((function(e){e?(u("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):(u("reconnect success"),t.onreconnect())})))}),e);this.subs.push({destroy:function(){clearTimeout(r)}})}},d.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,r){"use strict";var n=r(207),i=r(899),s=r(907),o=r(908);e.polling=function(t){var e=!1,r=!1,o=!1!==t.jsonp;if("undefined"!=typeof location){var a="https:"===location.protocol,c=location.port;c||(c=a?443:80),e=t.hostname!==location.hostname||c!==t.port,r=t.secure!==a}if(t.xdomain=e,t.xscheme=r,"open"in new n(t)&&!t.forceJSONP)return new i(t);if(!o)throw new Error("JSONP disabled");return new s(t)},e.websocket=o},function(t,e,r){"use strict";var n=r(209),i=r(126),s=r(76),o=r(127),a=r(358),c=r(1)("engine.io-client:polling");t.exports=h;var u=null!=new(r(207))({xdomain:!1}).responseType;function h(t){var e=t&&t.forceBase64;u&&!e||(this.supportsBinary=!1),n.call(this,t)}o(h,n),h.prototype.name="polling",h.prototype.doOpen=function(){this.poll()},h.prototype.pause=function(t){var e=this;function r(){c("paused"),e.readyState="paused",t()}if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(c("we are currently polling - waiting to pause"),n++,this.once("pollComplete",(function(){c("pre-pause polling complete"),--n||r()}))),this.writable||(c("we are currently writing - waiting to pause"),n++,this.once("drain",(function(){c("pre-pause writing complete"),--n||r()})))}else r()},h.prototype.poll=function(){c("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},h.prototype.onData=function(t){var e=this;c("polling got data %s",t);s.decodePayload(t,this.socket.binaryType,(function(t,r,n){if("opening"===e.readyState&&e.onOpen(),"close"===t.type)return e.onClose(),!1;e.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():c('ignoring poll - transport state "%s"',this.readyState))},h.prototype.doClose=function(){var t=this;function e(){c("writing close packet"),t.write([{type:"close"}])}"open"===this.readyState?(c("transport open - closing"),e()):(c("transport not open - deferring close"),this.once("open",e))},h.prototype.write=function(t){var e=this;this.writable=!1;var r=function(){e.writable=!0,e.emit("drain")};s.encodePayload(t,this.supportsBinary,(function(t){e.doWrite(t,r)}))},h.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",r="";return!1!==this.timestampRequests&&(t[this.timestampParam]=a()),this.supportsBinary||t.sid||(t.b64=1),t=i.encode(t),this.port&&("https"===e&&443!==Number(this.port)||"http"===e&&80!==Number(this.port))&&(r=":"+this.port),t.length&&(t="?"+t),e+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+r+this.path+t}},function(t,e,r){"use strict";(function(e){var n=r(901),i=Object.prototype.toString,s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),o="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);t.exports=function t(r){if(!r||"object"!=typeof r)return!1;if(n(r)){for(var i=0,a=r.length;i0);return e}function u(){var t=c(+new Date);return t!==n?(o=0,n=t):t+"."+c(o++)}for(;a<64;a++)s[i[a]]=a;u.encode=c,u.decode=function(t){var e=0;for(a=0;a{if(t&&e)try{return o(t,e)}catch(r){return c.error(r),o("0.0.0.0",e)}};t.exports=(t,e={})=>{const{sink:r,source:o}=i.duplex(t),a=e.remoteAddr||u(t.remoteAddress,t.remotePort),h=u(t.localAddress,t.localPort),f={async sink(t){e.signal&&(t=n(t,e.signal));try{await r(async function*(){for await(const e of t)yield e instanceof Uint8Array?e:e.slice()}())}catch(i){"aborted"!==i.type&&c.error(i)}},source:e.signal?n(o,e.signal):o,conn:t,localAddr:h,remoteAddr:a,timeline:{open:Date.now()},close(){if(!t.destroyed)return new Promise((e,r)=>{const n=Date.now(),i=setTimeout(()=>{if(f.remoteAddr){const{host:t,port:e}=f.remoteAddr.toOptions();c("timeout closing socket to %s:%s after %dms, destroying it manually",t,e,Date.now()-n)}t.destroyed||t.destroy()},s);t.once("close",()=>{e()}),t.end(t=>{if(clearTimeout(i),f.timeline.close=Date.now(),t)return r(t)})})}};return t.once("close",()=>{f.timeline.close||(f.timeline.close=Date.now())}),f}},function(t,e,r){"use strict";const n=r(190);t.exports=t=>async e=>{e=n(e);const r=t=>{"function"==typeof t.return&&t.return()};let i=null,s=null;const o=t=>{i=t,s&&s(t),r(e)};let a=null,c=!1;const u=()=>{c=!0,a&&a()};let h=null,f=!1;const l=()=>{f=!0,h&&h()};let d=null;const p=()=>{d&&d()};t.once("error",o),t.once("close",u),t.once("finish",l);try{for await(const r of e){if(!t.writable||t.destroyed||i)break;!1===t.write(r)&&await new Promise((e,r)=>{a=d=e,s=r,t.once("drain",p)})}}catch(y){i||t.destroy(),i=y}try{if(t.writable&&t.end(),await(r(e),new Promise((t,e)=>{if(c||f||i)return t();h=a=t,s=e})),i)throw i}finally{t.removeListener("error",o),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("drain",p)}}},function(t,e,r){"use strict";const n=r(364),i=r(211);t.exports=t=>({sink:n(t),source:i(t)})},function(t,e,r){"use strict";const n=r(17);(e=t.exports).cleanUrlSIO=function(t){const e=t.toString().split("/"),r=t.protos()[1].name,i=t.protos()[2].name,s=t.stringTuples()[1][1];if("tcp"!==r||"ws"!==i&&"wss"!==i)throw new Error("invalid multiaddr: "+t.toString());return n.isName(t)?"ws"===i?"http://"+e[2]+(80===s?"":":"+s):"wss"===i?"https://"+e[2]+(443===s?"":":"+s):void 0:"http://"+e[2]+":"+e[4]},e.cleanMultiaddr=function(t){const e="/libp2p-webrtc-star";if(-1!==t.indexOf(e)){t=t.substring(e.length,t.length);let r=n(t);const i=r.stringTuples().filter(t=>421===t[0])[0];r=r.decapsulate("p2p"),r=r.encapsulate("/p2p-webrtc-star"),r=r.encapsulate("/p2p/"+i[1]),t=r.toString()}return t}},function(t,e,r){"use strict";t.exports=t=>{t=t||1<<20;const e=e=>{if(e.data&&e.data.length>t)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return t=>async function*(){for await(const r of t)Array.isArray(r)?r.forEach(e):e(r),yield r}()},t.exports.MAX_MSG_SIZE=1<<20},function(t,e,r){"use strict";const n=Object.freeze({NEW_STREAM:0,MESSAGE_RECEIVER:1,MESSAGE_INITIATOR:2,CLOSE_RECEIVER:3,CLOSE_INITIATOR:4,RESET_RECEIVER:5,RESET_INITIATOR:6});e.MessageTypes=n,e.InitiatorMessageTypes=Object.freeze({NEW_STREAM:n.NEW_STREAM,MESSAGE:n.MESSAGE_INITIATOR,CLOSE:n.CLOSE_INITIATOR,RESET:n.RESET_INITIATOR}),e.ReceiverMessageTypes=Object.freeze({MESSAGE:n.MESSAGE_RECEIVER,CLOSE:n.CLOSE_RECEIVER,RESET:n.RESET_RECEIVER}),e.MessageTypeNames=Object.freeze(Object.entries(n).reduce((t,e)=>(t[e[1]]=e[0],t),{}))},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Noise=void 0;const i=n(r(212)),s=r(3),o=n(r(213)),a=n(r(371)),c=n(r(125)),u=n(r(25)),h=r(32),f=r(372),l=r(954),d=r(957),p=r(56),y=r(128),g=r(958),b=r(959),m=r(103),v=r(214);e.Noise=class{constructor(t,e){if(this.protocol="/noise",this.prologue=s.Buffer.alloc(0),this.earlyData=e||s.Buffer.alloc(0),this.useNoisePipes=!1,t){const e=i.default.publicKeyCreate(t);this.staticKeys={privateKey:t,publicKey:e}}else this.staticKeys=p.generateKeypair()}async secureOutbound(t,e,r){const n=o.default(e,{lengthEncoder:y.uint16BEEncode,lengthDecoder:y.uint16BEDecode,maxDataLength:v.NOISE_MSG_MAX_LENGTH_BYTES}),i=await this.performHandshake({connection:n,isInitiator:!0,localPeer:t,remotePeer:r});return{conn:await this.createSecureConnection(n,i),remoteEarlyData:i.remoteEarlyData,remotePeer:i.remotePeer}}async secureInbound(t,e,r){const n=o.default(e,{lengthEncoder:y.uint16BEEncode,lengthDecoder:y.uint16BEDecode,maxDataLength:v.NOISE_MSG_MAX_LENGTH_BYTES}),i=await this.performHandshake({connection:n,isInitiator:!1,localPeer:t,remotePeer:r});return{conn:await this.createSecureConnection(n,i),remoteEarlyData:i.remoteEarlyData,remotePeer:i.remotePeer}}async performHandshake(t){const e=await p.getPayload(t.localPeer,this.staticKeys.publicKey,this.earlyData);let r=this.useNoisePipes;if(t.isInitiator&&null===b.KeyCache.load(t.remotePeer)&&(r=!1),!r)return await this.performXXHandshake(t,e);{const{remotePeer:r,connection:i,isInitiator:o}=t,a=new l.IKHandshake(o,e,this.prologue,this.staticKeys,i,b.KeyCache.load(t.remotePeer)||s.Buffer.alloc(32),r);try{return await this.performIKHandshake(a)}catch(n){let r;return t.isInitiator&&(r=a.getLocalEphemeralKeys()),await this.performXXFallbackHandshake(t,e,n.initialMsg,r)}}}async performXXFallbackHandshake(t,e,r,n){const{isInitiator:i,remotePeer:s,connection:o}=t,a=new d.XXFallbackHandshake(i,e,this.prologue,this.staticKeys,o,r,s,n);try{await a.propose(),await a.exchange(),await a.finish()}catch(c){throw m.logger(c),new Error("Error occurred during XX Fallback handshake: "+c.message)}return a}async performXXHandshake(t,e){const{isInitiator:r,remotePeer:n,connection:i}=t,s=new f.XXHandshake(r,e,this.prologue,this.staticKeys,i,n);try{await s.propose(),await s.exchange(),await s.finish(),this.useNoisePipes&&s.remotePeer&&b.KeyCache.store(s.remotePeer,s.getRemoteStaticKey())}catch(o){throw new Error("Error occurred during XX handshake: "+o.message)}return s}async performIKHandshake(t){return await t.stage0(),await t.stage1(),t}async createSecureConnection(t,e){const[r,n]=a.default(),i=t.unwrap();return await u.default(r,c.default,g.encryptStream(e),h.encode({lengthEncoder:y.uint16BEEncode}),i,h.decode({lengthDecoder:y.uint16BEDecode}),c.default,g.decryptStream(e),r),n}}},function(t,e,r){"use strict";e.custom="inspect"},function(t,e,r){"use strict";var n=r(930);t.exports=function(){var t=n(),e=n();return[{source:t.source,sink:e.sink},{source:e.source,sink:t.sink}]}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.XXHandshake=void 0;const n=r(3),i=r(931),s=r(56),o=r(103),a=r(128);e.XXHandshake=class{constructor(t,e,r,s,o,a,c){this.isInitiator=t,this.payload=e,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=c||new i.XX,this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=n.Buffer.alloc(0)}async propose(){if(o.logLocalStaticKeys(this.session.hs.s),this.isInitiator){o.logger("Stage 0 - Initiator starting to send first message.");const t=this.xx.sendMessage(this.session,n.Buffer.alloc(0));this.connection.writeLP(a.encode0(t)),o.logger("Stage 0 - Initiator finished sending first message."),o.logLocalEphemeralKeys(this.session.hs.e)}else{o.logger("Stage 0 - Responder waiting to receive first message...");const t=a.decode0((await this.connection.readLP()).slice()),{valid:e}=this.xx.recvMessage(this.session,t);if(!e)throw new Error("xx handshake stage 0 validation fail");o.logger("Stage 0 - Responder received first message."),o.logRemoteEphemeralKey(this.session.hs.re)}}async exchange(){if(this.isInitiator){o.logger("Stage 1 - Initiator waiting to receive first message from responder...");const e=a.decode1((await this.connection.readLP()).slice()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new Error("xx handshake stage 1 validation fail");o.logger("Stage 1 - Initiator received the message."),o.logRemoteEphemeralKey(this.session.hs.re),o.logRemoteStaticKey(this.session.hs.rs),o.logger("Initiator going to check remote's signature...");try{const t=await s.decodePayload(r);this.remotePeer=this.remotePeer||await s.getPeerIdFromPayload(t),this.remotePeer=await s.verifySignedPayload(e.ns,t,this.remotePeer),this.setRemoteEarlyData(t.data)}catch(t){throw new Error("Error occurred while verifying signed payload: "+t.message)}o.logger("All good with the signature!")}else{o.logger("Stage 1 - Responder sending out first message with signed payload and static key.");const t=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(a.encode1(t)),o.logger("Stage 1 - Responder sent the second handshake message with signed payload."),o.logLocalEphemeralKeys(this.session.hs.e)}}async finish(){if(this.isInitiator){o.logger("Stage 2 - Initiator sending third handshake message.");const t=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(a.encode2(t)),o.logger("Stage 2 - Initiator sent message with signed payload.")}else{o.logger("Stage 2 - Responder waiting for third handshake message...");const e=a.decode2((await this.connection.readLP()).slice()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new Error("xx handshake stage 2 validation fail");o.logger("Stage 2 - Responder received the message, finished handshake.");try{const t=await s.decodePayload(r);this.remotePeer=this.remotePeer||await s.getPeerIdFromPayload(t),await s.verifySignedPayload(this.session.hs.rs,t,this.remotePeer),this.setRemoteEarlyData(t.data)}catch(t){throw new Error("Error occurred while verifying signed payload: "+t.message)}}o.logCipherState(this.session)}encrypt(t,e){const r=this.getCS(e);return this.xx.encryptWithAd(r,n.Buffer.alloc(0),t)}decrypt(t,e){const r=this.getCS(e,!1);return this.xx.decryptWithAd(r,n.Buffer.alloc(0),t)}getRemoteStaticKey(){return this.session.hs.rs}getCS(t,e=!0){if(!t.cs1||!t.cs2)throw new Error("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?e?t.cs1:t.cs2:e?t.cs2:t.cs1}setRemoteEarlyData(t){t&&(this.remoteEarlyData=n.Buffer.from(t.buffer,t.byteOffset,t.length))}}},function(t,e,r){"use strict";(function(e){const n=r(43),i=r(934),s=e.alloc(8,0),o=e.alloc(64,0);o[0]=128;const a=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);class c{constructor(){this.state=new Uint32Array(8),this.msg=new Uint32Array(64),this.block=e.alloc(64),this.size=-1}init(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.size=0,this}update(t){return n(e.isBuffer(t)),this._update(t,t.length),this}final(){return this._final(e.alloc(32))}_update(t,e){n(-1!==this.size,"Context is not initialized.");let r=63&this.size,i=0;if(this.size+=e,r>0){let n=64-r;if(n>e&&(n=e),t.copy(this.block,r,i,i+n),r+=n,e-=n,i+=n,r<64)return;this._transform(this.block,0)}for(;e>=64;)this._transform(t,i),i+=64,e-=64;e>0&&t.copy(this.block,0,i,i+e)}_final(t){n(-1!==this.size,"Context is not initialized.");const e=63&this.size,r=8*this.size;p(s,r*(1/4294967296)>>>0,0),p(s,r>>>0,4),this._update(o,1+(119-e&63)),this._update(s,8);for(let n=0;n<8;n++)p(t,this.state[n],4*n),this.state[n]=0;for(let n=0;n<64;n++)this.msg[n]=0;for(let n=0;n<64;n++)this.block[n]=0;return this.size=-1,t}_transform(t,e){const r=this.msg;let n=this.state[0],i=this.state[1],s=this.state[2],o=this.state[3],c=this.state[4],p=this.state[5],y=this.state[6],g=this.state[7],b=0;for(;b<16;b++)r[b]=(v=e+4*b,16777216*(m=t)[v++]+65536*m[v++]+256*m[v++]+m[v]);for(var m,v,w;b<64;b++)r[b]=(((w=r[b-2])>>>17|w<<15)^(w>>>19|w<<13)^w>>>10)+r[b-7]+f(r[b-15])+r[b-16];for(b=0;b<64;b++){const t=g+h(c)+l(c,p,y)+a[b]+r[b],e=u(n)+d(n,i,s);g=y,y=p,p=c,c=o+t>>>0,o=s,s=i,i=n,n=t+e>>>0}this.state[0]+=n,this.state[1]+=i,this.state[2]+=s,this.state[3]+=o,this.state[4]+=c,this.state[5]+=p,this.state[6]+=y,this.state[7]+=g}static hash(){return new c}static hmac(){return new i(c,64)}static digest(t){return c.ctx.init().update(t).final()}static root(t,r){return n(e.isBuffer(t)&&32===t.length),n(e.isBuffer(r)&&32===r.length),c.ctx.init().update(t).update(r).final()}static multi(t,e,r){const{ctx:n}=c;return n.init(),n.update(t),n.update(e),r&&n.update(r),n.final()}static mac(t,e){return c.hmac().init(e).update(t).final()}}function u(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function f(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function l(t,e,r){return r^t&(e^r)}function d(t,e,r){return t&e|r&(t|e)}function p(t,e,r){return t[r++]=e>>>24,t[r++]=e>>>16,t[r++]=e>>>8,t[r++]=e,r}c.native=0,c.id="SHA256",c.size=32,c.bits=256,c.blockSize=64,c.zero=e.alloc(32,0),c.ctx=new c,t.exports=c}).call(this,r(3).Buffer)},function(t,e,r){"use strict";t.exports=f;var n,i=r(57),s=i.LongBits,o=i.base64,a=i.utf8;function c(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function u(){}function h(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function f(){this.len=0,this.head=new c(u,0,0),this.tail=this.head,this.states=null}var l=function(){return i.Buffer?function(){return(f.create=function(){return new n})()}:function(){return new f}};function d(t,e,r){e[r]=255&t}function p(t,e){this.len=t,this.next=void 0,this.val=e}function y(t,e,r){for(;t.hi;)e[r++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=127&t.lo|128,t.lo=t.lo>>>7;e[r++]=t.lo}function g(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}f.create=l(),f.alloc=function(t){return new i.Array(t)},i.Array!==Array&&(f.alloc=i.pool(f.alloc,i.Array.prototype.subarray)),f.prototype._push=function(t,e,r){return this.tail=this.tail.next=new c(t,e,r),this.len+=e,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(t,e,r){for(;t>127;)e[r++]=127&t|128,t>>>=7;e[r]=t},f.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new p((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},f.prototype.int32=function(t){return t<0?this._push(y,10,s.fromNumber(t)):this.uint32(t)},f.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},f.prototype.uint64=function(t){var e=s.from(t);return this._push(y,e.length(),e)},f.prototype.int64=f.prototype.uint64,f.prototype.sint64=function(t){var e=s.from(t).zzEncode();return this._push(y,e.length(),e)},f.prototype.bool=function(t){return this._push(d,1,t?1:0)},f.prototype.fixed32=function(t){return this._push(g,4,t>>>0)},f.prototype.sfixed32=f.prototype.fixed32,f.prototype.fixed64=function(t){var e=s.from(t);return this._push(g,4,e.lo)._push(g,4,e.hi)},f.prototype.sfixed64=f.prototype.fixed64,f.prototype.float=function(t){return this._push(i.float.writeFloatLE,4,t)},f.prototype.double=function(t){return this._push(i.float.writeDoubleLE,8,t)};var b=i.Array.prototype.set?function(t,e,r){e.set(t,r)}:function(t,e,r){for(var n=0;n>>0;if(!e)return this._push(d,1,0);if(i.isString(t)){var r=f.alloc(e=o.length(t));o.decode(t,r,0),t=r}return this.uint32(e)._push(b,e,t)},f.prototype.string=function(t){var e=a.length(t);return e?this.uint32(e)._push(a.write,e,t):this._push(d,1,0)},f.prototype.fork=function(){return this.states=new h(this),this.head=this.tail=new c(u,0,0),this.len=0,this},f.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(u,0,0),this.len=0),this},f.prototype.ldelim=function(){var t=this.head,e=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=t.next,this.tail=e,this.len+=r),this},f.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),r=0;t;)t.fn(t.val,e,r),r+=t.len,t=t.next;return e},f._configure=function(t){n=t,f.create=l(),n._configure()}},function(t,e,r){"use strict";t.exports=c;var n,i=r(57),s=i.LongBits,o=i.utf8;function a(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function c(t){this.buf=t,this.pos=0,this.len=t.length}var u,h="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new c(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new c(t);throw Error("illegal buffer")},f=function(){return i.Buffer?function(t){return(c.create=function(t){return i.Buffer.isBuffer(t)?new n(t):h(t)})(t)}:h};function l(){var t=new s(0,0),e=0;if(!(this.len-this.pos>4)){for(;e<3;++e){if(this.pos>=this.len)throw a(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw a(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function d(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw a(this,8);return new s(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=f(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return u;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return u}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var t=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var t=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},c.prototype.bytes=function(){var t=this.uint32(),e=this.pos,r=this.pos+t;if(r>this.len)throw a(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,r):e===r?new this.buf.constructor(0):this._slice.call(this.buf,e,r)},c.prototype.string=function(){var t=this.bytes();return o.read(t,0,t.length)},c.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw a(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},c._configure=function(t){n=t,c.create=f(),n._configure();var e=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return l.call(this)[e](!1)},uint64:function(){return l.call(this)[e](!0)},sint64:function(){return l.call(this).zzDecode()[e](!1)},fixed64:function(){return p.call(this)[e](!0)},sfixed64:function(){return p.call(this)[e](!1)}})}},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractHandshake=e.MIN_NONCE=void 0;const i=r(3),s=n(r(951)),o=n(r(212)),a=n(r(373)),c=r(56),u=r(103);e.MIN_NONCE=0;e.AbstractHandshake=class{encryptWithAd(t,e,r){const n=this.encrypt(t.k,t.n,e,r);return this.setNonce(t,this.incrementNonce(t.n)),n}decryptWithAd(t,e,r){const{plaintext:n,valid:i}=this.decrypt(t.k,t.n,e,r);return this.setNonce(t,this.incrementNonce(t.n)),{plaintext:n,valid:i}}hasKey(t){return!this.isEmptyKey(t.k)}setNonce(t,e){t.n=e}createEmptyKey(){return i.Buffer.alloc(32)}isEmptyKey(t){return this.createEmptyKey().equals(t)}incrementNonce(t){return t+1}nonceToBytes(t){const e=i.Buffer.alloc(12);return e.writeUInt32LE(t,4),e}encrypt(t,e,r,n){const o=this.nonceToBytes(e),a=new s.default;return n=i.Buffer.from(n),a.init(t,o),a.aad(r),a.encrypt(n),i.Buffer.concat([n,a.final()])}encryptAndHash(t,e){let r;return r=this.hasKey(t.cs)?this.encryptWithAd(t.cs,t.h,e):e,this.mixHash(t,r),r}decrypt(t,e,r,n){const o=this.nonceToBytes(e),a=new s.default,c=(n=i.Buffer.from(n)).slice(n.length-16);return n=n.slice(0,n.length-16),a.init(t,o),a.aad(r),a.decrypt(n),{plaintext:n,valid:a.verify(c)}}decryptAndHash(t,e){let r,n=!0;return this.hasKey(t.cs)?({plaintext:r,valid:n}=this.decryptWithAd(t.cs,t.h,e)):r=e,this.mixHash(t,e),{plaintext:r,valid:n}}dh(t,e){try{const r=o.default.derive(e,t),n=i.Buffer.alloc(32);return r.copy(n),n}catch(r){return u.logger(r.message),i.Buffer.alloc(32)}}mixHash(t,e){t.h=this.getHash(t.h,e)}getHash(t,e){return a.default.digest(i.Buffer.from([...t,...e]))}mixKey(t,e){const[r,n]=c.getHkdf(t.ck,e);t.cs=this.initializeKey(n),t.ck=r}initializeKey(t){return{k:t,n:e.MIN_NONCE}}initializeSymmetric(t){const e=i.Buffer.from(t,"utf-8"),r=this.hashProtocolName(e),n=r,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:n,h:r}}hashProtocolName(t){if(t.length<=32){const e=i.Buffer.alloc(32);return t.copy(e),e}return this.getHash(t,i.Buffer.alloc(0))}split(t){const[e,r]=c.getHkdf(t.ck,i.Buffer.alloc(0));return{cs1:this.initializeKey(e),cs2:this.initializeKey(r)}}writeMessageRegular(t,e){const r=this.encryptWithAd(t,i.Buffer.alloc(0),e);return{ne:this.createEmptyKey(),ns:i.Buffer.alloc(0),ciphertext:r}}readMessageRegular(t,e){return this.decryptWithAd(t,i.Buffer.alloc(0),e.ciphertext)}}},function(t,e,r){"use strict";const n=r(27),i=r(974);t.exports=n(class extends i{constructor({min:t,max:e,multicodecs:r,handlers:n}){if(super({min:t,max:e,handlers:n}),!r)throw new Error("one or more multicodec should be provided");if(!n)throw new Error("the handlers should be provided");if("function"!=typeof n.onConnect)throw new Error("the 'onConnect' handler must be provided");if("function"!=typeof n.onDisconnect)throw new Error("the 'onDisconnect' handler must be provided");this.multicodecs=Array.isArray(r)?r:[r],this._registrar=void 0,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this)}set registrar(t){this._registrar=t,this._registrar.peerStore.on("change:protocols",this._onProtocolChange),this._registrar.connectionManager.on("peer:connect",this._onPeerConnect),this._updatePeers(this._registrar.peerStore.peers.values())}_updatePeers(t){for(const{id:e,protocols:r}of t)if(this.multicodecs.filter(t=>r.includes(t)).length){this.peers.add(e.toB58String());const t=this._registrar.getConnection(e);t&&this._onConnect(e,t)}else this.peers.delete(e.toB58String())}_onProtocolChange({peerId:t,protocols:e}){const r=this.peers.has(t.toB58String()),n=e.filter(t=>this.multicodecs.includes(t));r&&0===n.length&&this._onDisconnect(t);for(const i of e)if(this.multicodecs.includes(i)){const e=this._registrar.peerStore.get(t);return void this._updatePeers([e])}}_onPeerConnect(t){const e=t.remotePeer,r=this._registrar.peerStore.protoBook.get(e);r&&this.multicodecs.find(t=>r.includes(t))&&(this.peers.add(e.toB58String()),this._onConnect(e,t))}},{className:"MulticodecTopology",symbolName:"@libp2p/js-interfaces/topology/multicodec-topology"})},function(t,e,r){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.hasNextTick=e.hasSetImmediate=void 0,e.fallback=u,e.wrap=h;var n,i=r(379),s=(n=i)&&n.__esModule?n:{default:n};var o,a=e.hasSetImmediate="function"==typeof setImmediate&&setImmediate,c=e.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function u(t){setTimeout(t,0)}function h(t){return function(e){var r=(0,s.default)(arguments,1);t((function(){e.apply(null,r)}))}}o=a?setImmediate:c?t.nextTick:u,e.default=h(o)}).call(this,r(12))},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){e|=0;for(var r=Math.max(t.length-e,0),n=Array(r),i=0;i`${n.namespace}${t}`)}async cancel(t){if("string"!=typeof t)throw u(new Error("invalid subscription name"),"ERR_INVALID_SUBSCRIPTION_NAME");t.startsWith(n.namespace)&&(t=t.substring(n.namespaceLength));const e=Object.keys(this._subscriptions).find(e=>this._subscriptions[e]===t);if(!e)return{canceled:!1};const r=a(e);return this._pubsubDs.unsubscribe(r),this._subscriptions[e]=void 0,f(`unsubscribed pubsub ${e}: ${t}`),{canceled:!0}}},{className:"IpnsPubsubDatastore",symbolName:"@js-ipfs/ipns/IpnsPubsubDatastore"})},function(t,e,r){"use strict";const n=r(4);e.cidToString=(t,e)=>{if((e=e||{}).upgrade=!1!==e.upgrade,n.isCID(t)||(t=new n(t)),0===t.version&&e.base&&"base58btc"!==e.base){if(!e.upgrade)return t.toString();t=t.toV1()}return t.toBaseEncodedString(e.base)}},function(t,e,r){t.exports=r(384)},function(t,e,r){"use strict";const n=r(385);t.exports=n},function(t,e,r){"use strict";(function(e){const n=r(1)("ipfs"),i=r(33),{isTest:s}=r(390),o=r(392),a=r(393),c=r(7),u=r(37),h=r(51),f=r(17),l=r(31),d=r(19),p=r(13),y=p.multihash,g=r(4),{NotInitializedError:b}=r(85),m=r(112),v=r(1076);t.exports={create:async function(t){const e=(t=i({init:!0,start:!0,EXPERIMENTAL:{},preload:{enabled:!s,addresses:["/dns4/node0.preload.ipfs.io/https","/dns4/node1.preload.ipfs.io/https","/dns4/node2.preload.ipfs.io/https","/dns4/node3.preload.ipfs.io/https"]}},t)).silent?n:console.log,r=new v,{api:o}=r.update({init:m.init({apiManager:r,print:e,options:t}),dns:m.dns(),isOnline:m.isOnline({libp2p:void 0})},async()=>{throw new b}),a=t.init&&await o.init();return t.start&&a&&await a.start()||a||o},crypto:u,isIPFS:h,Buffer:e,CID:g,multiaddr:f,multibase:l,multihash:y,multihashing:p,multicodec:d,PeerId:c,globSource:o,urlSource:a}}).call(this,r(3).Buffer)},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=u(t),o=n[0],a=n[1],c=new s(function(t,e,r){return 3*(e+r)/4-r}(0,o,a)),h=0,f=a>0?o-4:o;for(r=0;r>16&255,c[h++]=e>>8&255,c[h++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[h++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[h++]=e>>8&255,c[h++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=0,a=r-i;oa?a:o+16383));1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e,r){"use strict";t.exports=function(t){function e(t){let e=0;for(let r=0;r{if("%%"===r)return r;a++;const s=n.formatters[i];if("function"==typeof s){const n=t[a];r=s.call(e,n),t.splice(a,1),a--}return r}),n.formatArgs.call(e,t);(e.log||n.log).apply(e,t)}return o.namespace=t,o.enabled=n.enabled(t),o.useColors=n.useColors(),o.color=e(t),o.destroy=i,o.extend=s,"function"==typeof n.init&&n.init(o),n.instances.push(o),o}function i(){const t=n.instances.indexOf(this);return-1!==t&&(n.instances.splice(t,1),!0)}function s(t,e){const r=n(this.namespace+(void 0===e?":":e)+t);return r.log=this.log,r}function o(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},n.disable=function(){const t=[...n.names.map(o),...n.skips.map(o).map(t=>"-"+t)].join(",");return n.enable(""),t},n.enable=function(t){let e;n.save(t),n.names=[],n.skips=[];const r=("string"==typeof t?t:"").split(/[\s,]+/),i=r.length;for(e=0;e{n[e]=t[e]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=e,n.enable(n.load()),n}},function(t,e,r){"use strict";var n=1e3,i=6e4,s=60*i,o=24*s;function a(t,e,r,n){var i=e>=1.5*r;return Math.round(t/r)+" "+n+(i?"s":"")}t.exports=function(t,e){e=e||{};var r=typeof t;if("string"===r&&t.length>0)return function(t){if((t=String(t)).length>100)return;var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===r&&isFinite(t))return e.long?function(t){var e=Math.abs(t);if(e>=o)return a(t,e,o,"day");if(e>=s)return a(t,e,s,"hour");if(e>=i)return a(t,e,i,"minute");if(e>=n)return a(t,e,n,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=o)return Math.round(t/o)+"d";if(e>=s)return Math.round(t/s)+"h";if(e>=i)return Math.round(t/i)+"m";if(e>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,r){"use strict";t.exports=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}},function(t,e,r){"use strict";(function(e){const n=r(391),i="object"==typeof window&&"object"==typeof document&&9===document.nodeType,s=n(),o=i&&!s,a=s&&!i,c=s&&i,u=void 0!==e&&void 0!==e.release&&"node"===e.release.name&&!s,h="function"==typeof importScripts&&"undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,f=void 0!==e&&void 0!=={NODE_ENV:"production"}&&!1;t.exports={isTest:f,isElectron:s,isElectronMain:a,isElectronRenderer:c,isNode:u,isBrowser:o,isWebWorker:h,isEnvWithDom:i}}).call(this,r(12))},function(t,e,r){"use strict";(function(e){t.exports=function(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!(void 0===e||"object"!=typeof e.versions||!e.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}}).call(this,r(12))},function(t,e){},function(t,e,r){"use strict";const n=r(132);t.exports=async function*(t,e){const r=new n,i=await r.get(t,e);yield{path:decodeURIComponent(new URL(t).pathname.split("/").pop()||""),content:i.iterator()}}},function(t,e,r){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,n.fetch&&(e.default=n.fetch.bind(n)),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e,r){"use strict";const{URLWithLegacySupport:n,format:i}=r(224);t.exports=(t,e={},r={},s)=>{let o,a=e.protocol?e.protocol.replace(":",""):"http";a=(r[a]||s||a)+":";try{o=new n(t)}catch(u){o={}}const c=Object.assign({},e,{protocol:a||o.protocol,host:e.host||o.host});return new n(t,i(c)).toString()}},function(t,e,r){"use strict";t.exports=r(133).TextDecoder},function(t,e,r){"use strict";t.exports=AbortController},function(t,e,r){"use strict";var n=r(225).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,h=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var l=0,d=o-1;(0!==f||l>>0,h[d]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");s=l,r++}if(" "!==t[r]){for(var p=o-s;p!==o&&0===h[p];)p++;var y=n.allocUnsafe(i+(o-p));y.fill(0,0,i);for(var g=i;p!==o;)y[g++]=h[p++];return y}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,s=0,o=e.length;s!==o&&0===e[s];)s++,r++;for(var u=(o-s)*h+1>>>0,f=new Uint8Array(u);s!==o;){for(var l=e[s],d=0,p=u-1;(0!==l||d>>0,f[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,s++}for(var y=u-i;y!==u&&0===f[y];)y++;for(var g=c.repeat(r);ye=>({encode:r=>((t,e,r)=>{const n="="===e[e.length-1],i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<((t,e,r)=>{const n={};for(let u=0;u=8&&(o-=8,s[c++]=255&a>>o)}if(o>=r||255&a<<8-o)throw new SyntaxError("Unexpected end of data");return s})(r,e,t)})},function(t,e,r){"use strict";t.exports=function t(e,r,i){r=r||[];var s=i=i||0;for(;e>=n;)r[i++]=255&e|128,e/=128;for(;-128&e;)r[i++]=255&e|128,e>>>=7;return r[i]=0|e,t.bytes=i-s+1,r};var n=Math.pow(2,31)},function(t,e,r){"use strict";t.exports=function t(e,r){var n,i=0,s=0,o=r=r||0,a=e.length;do{if(o>=a)throw t.bytes=0,new RangeError("Could not decode varint");n=e[o++],i+=s<28?(127&n)<=128);return t.bytes=o-r,i}},function(t,e,r){"use strict";var n=Math.pow(2,7),i=Math.pow(2,14),s=Math.pow(2,21),o=Math.pow(2,28),a=Math.pow(2,35),c=Math.pow(2,42),u=Math.pow(2,49),h=Math.pow(2,56),f=Math.pow(2,63);t.exports=function(t){return tt+e.length,0));const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}},function(t,e,r){"use strict";const n=r(80),i={};for(const[s,o]of Object.entries(n))i[s.toUpperCase().replace(/-/g,"_")]=o;t.exports=Object.freeze(i)},function(t,e,r){"use strict";const n=r(80),i={};for(const[s,o]of Object.entries(n))void 0===i[o]&&(i[o]=s);t.exports=Object.freeze(i)},function(t,e,r){"use strict";const n=r(49),i={checkCIDComponents:function(t){if(null==t)return"null values are not valid CIDs";if(0!==t.version&&1!==t.version)return"Invalid version, must be a number equal to 1 or 0";if("string"!=typeof t.codec)return"codec must be string";if(0===t.version){if("dag-pb"!==t.codec)return"codec must be 'dag-pb' for CIDv0";if("base58btc"!==t.multibaseName)return"multibaseName must be 'base58btc' for CIDv0"}if(!(t.multihash instanceof Uint8Array))return"multihash must be a Uint8Array";try{n.validate(t.multihash)}catch(e){let t=e.message;return t||(t="Multihash validation failed"),t}}};t.exports=i},function(t,e,r){"use strict";var n=r(414),i=r(416);t.exports=n,t.exports.parse=n,t.exports.stringify=i},function(t,e,r){"use strict";var n=r(415),i=["int32","int64","uint32","uint64","sint32","sint64","bool","fixed64","sfixed64","double","fixed32","sfixed32","float"],s=function(t){for(var e={};t.length;)switch(t[0]){case"[":case",":t.shift();var r=t.shift();if("("===r&&(r=t.shift(),t.shift()),"="!==t[0])throw new Error("Unexpected token in field options: "+t[0]);if(t.shift(),"]"===t[0])throw new Error("Unexpected ] in field option");e[r]=t.shift();break;case"]":return t.shift(),e;default:throw new Error("Unexpected token in field options: "+t[0])}throw new Error("No closing tag for field options")},o=function(t){for(var e={name:null,type:null,tag:-1,map:null,oneof:null,required:!1,repeated:!1,options:{}};t.length;)switch(t[0]){case"=":t.shift(),e.tag=Number(t.shift());break;case"map":if(e.type="map",e.map={from:null,to:null},t.shift(),"<"!==t[0])throw new Error("Unexpected token in map type: "+t[0]);if(t.shift(),e.map.from=t.shift(),","!==t[0])throw new Error("Unexpected token in map type: "+t[0]);if(t.shift(),e.map.to=t.shift(),">"!==t[0])throw new Error("Unexpected token in map type: "+t[0]);t.shift(),e.name=t.shift();break;case"repeated":case"required":case"optional":var r=t.shift();e.required="required"===r,e.repeated="repeated"===r,e.type=t.shift(),e.name=t.shift();break;case"[":e.options=s(t);break;case";":if(null===e.name)throw new Error("Missing field name");if(null===e.type)throw new Error("Missing type in message field: "+e.name);if(-1===e.tag)throw new Error("Missing tag number in message field: "+e.name);return t.shift(),e;default:throw new Error("Unexpected token in message field: "+t[0])}throw new Error("No ; found for message field")},a=function(t){for(var e={enums:[],options:{},messages:[],fields:[],extends:[],extensions:null};t.length;)switch(t[0]){case"map":case"repeated":case"optional":case"required":e.fields.push(o(t));break;case"enum":e.enums.push(p(t));break;case"message":e.messages.push(h(t));break;case"extensions":e.extensions=u(t);break;case"oneof":t.shift();var r=t.shift();if("{"!==t[0])throw new Error("Unexpected token in oneof: "+t[0]);for(t.shift();"}"!==t[0];){t.unshift("optional");var n=o(t);n.oneof=r,e.fields.push(n)}t.shift();break;case"extend":e.extends.push(c(t));break;case";":t.shift();break;case"reserved":for(t.shift();";"!==t[0];)t.shift();break;case"option":var i=y(t);if(void 0!==e.options[i.name])throw new Error("Duplicate option "+i.name);e.options[i.name]=i.value;break;default:t.unshift("optional"),e.fields.push(o(t))}return e},c=function(t){return{name:t[1],message:h(t)}},u=function(t){t.shift();var e=Number(t.shift());if(isNaN(e))throw new Error("Invalid from in extensions definition");if("to"!==t.shift())throw new Error("Expected keyword 'to' in extensions definition");var r=t.shift();if("max"===r&&(r=536870911),r=Number(r),isNaN(r))throw new Error("Invalid to in extensions definition");if(";"!==t.shift())throw new Error("Missing ; in extensions definition");return{from:e,to:r}},h=function(t){t.shift();var e=1,r=[],n={name:t.shift(),options:{},enums:[],extends:[],messages:[],fields:[]};if("{"!==t[0])throw new Error("Expected { but found "+t[0]);for(t.shift();t.length;){if("{"===t[0]?e++:"}"===t[0]&&e--,!e)return t.shift(),r=a(r),n.enums=r.enums,n.messages=r.messages,n.fields=r.fields,n.extends=r.extends,n.extensions=r.extensions,n.options=r.options,n;r.push(t.shift())}if(e)throw new Error("No closing tag for message")},f=function(t){t.shift();var e=t.shift();if(";"!==t[0])throw new Error("Expected ; but found "+t[0]);return t.shift(),e},l=function(t){if(t.shift(),"="!==t[0])throw new Error("Expected = but found "+t[0]);t.shift();var e=t.shift();switch(e){case'"proto2"':e=2;break;case'"proto3"':e=3;break;default:throw new Error("Expected protobuf syntax version but found "+e)}if(";"!==t[0])throw new Error("Expected ; but found "+t[0]);return t.shift(),e},d=function(t){if(t.length<4)throw new Error("Invalid enum value: "+t.slice(0,3).join(" "));if("="!==t[1])throw new Error("Expected = but found "+t[1]);if(";"!==t[3]&&"["!==t[3])throw new Error("Expected ; or [ but found "+t[1]);var e=t.shift();t.shift();var r={value:null,options:{}};return r.value=Number(t.shift()),"["===t[0]&&(r.options=s(t)),t.shift(),{name:e,val:r}},p=function(t){t.shift();var e={},r={name:t.shift(),values:{},options:{}};if("{"!==t[0])throw new Error("Expected { but found "+t[0]);for(t.shift();t.length;){if("}"===t[0])return t.shift(),";"===t[0]&&t.shift(),r;if("option"!==t[0]){var n=d(t);r.values[n.name]=n.val}else e=y(t),r.options[e.name]=e.value}throw new Error("No closing tag for enum")},y=function(t){for(var e=null,r=null,n=function(t){return"true"===t||"false"!==t&&t.replace(/^"+|"+$/gm,"")};t.length;){if(";"===t[0])return t.shift(),{name:e,value:r};switch(t[0]){case"option":t.shift();var i="("===t[0];if(i&&t.shift(),e=t.shift(),i){if(")"!==t[0])throw new Error("Expected ) but found "+t[0]);t.shift()}"."===t[0][0]&&(e+=t.shift());break;case"=":if(t.shift(),null===e)throw new Error("Expected key for option with value: "+t[0]);if(r=n(t.shift()),"optimize_for"===e&&!/^(SPEED|CODE_SIZE|LITE_RUNTIME)$/.test(r))throw new Error("Unexpected value for option optimize_for: "+r);"{"===r&&(r=g(t));break;default:throw new Error("Unexpected token in option: "+t[0])}}},g=function(t){for(var e=function(t){return"true"===t||"false"!==t&&t.replace(/^"+|"+$/gm,"")},r={};t.length;){if("}"===t[0])return t.shift(),r;var n="("===t[0];n&&t.shift();var i=t.shift();if(n){if(")"!==t[0])throw new Error("Expected ) but found "+t[0]);t.shift()}var s=null;switch(t[0]){case":":if(void 0!==r[i])throw new Error("Duplicate option map key "+i);t.shift(),"{"===(s=e(t.shift()))&&(s=g(t)),r[i]=s,";"===t[0]&&t.shift();break;case"{":if(t.shift(),s=g(t),void 0===r[i]&&(r[i]=[]),!Array.isArray(r[i]))throw new Error("Duplicate option map key "+i);r[i].push(s);break;default:throw new Error("Unexpected token in option map: "+t[0])}}throw new Error("No closing tag for option map")},b=function(t){t.shift();var e=t.shift().replace(/^"+|"+$/gm,"");if(";"!==t[0])throw new Error("Unexpected token: "+t[0]+'. Expected ";"');return t.shift(),e},m=function(t){t.shift();var e={name:t.shift(),methods:[],options:{}};if("{"!==t[0])throw new Error("Expected { but found "+t[0]);for(t.shift();t.length;){if("}"===t[0])return t.shift(),";"===t[0]&&t.shift(),e;switch(t[0]){case"option":var r=y(t);if(void 0!==e.options[r.name])throw new Error("Duplicate option "+r.name);e.options[r.name]=r.value;break;case"rpc":e.methods.push(v(t));break;default:throw new Error("Unexpected token in service: "+t[0])}}throw new Error("No closing tag for service")},v=function(t){t.shift();var e={name:t.shift(),input_type:null,output_type:null,client_streaming:!1,server_streaming:!1,options:{}};if("("!==t[0])throw new Error("Expected ( but found "+t[0]);if(t.shift(),"stream"===t[0]&&(t.shift(),e.client_streaming=!0),e.input_type=t.shift(),")"!==t[0])throw new Error("Expected ) but found "+t[0]);if(t.shift(),"returns"!==t[0])throw new Error("Expected returns but found "+t[0]);if(t.shift(),"("!==t[0])throw new Error("Expected ( but found "+t[0]);if(t.shift(),"stream"===t[0]&&(t.shift(),e.server_streaming=!0),e.output_type=t.shift(),")"!==t[0])throw new Error("Expected ) but found "+t[0]);if(t.shift(),";"===t[0])return t.shift(),e;if("{"!==t[0])throw new Error("Expected { but found "+t[0]);for(t.shift();t.length;){if("}"===t[0])return t.shift(),";"===t[0]&&t.shift(),e;if("option"!==t[0])throw new Error("Unexpected token in rpc options: "+t[0]);var r=y(t);if(void 0!==e.options[r.name])throw new Error("Duplicate option "+r.name);e.options[r.name]=r.value}throw new Error("No closing tag for rpc")};t.exports=function(t){for(var e=n(t.toString()),r=0;re.extensions.to)throw new Error(e.name+" does not declare "+t.tag+" as an extension number");e.fields.push(t)}))}))})),o.messages.forEach((function(t){t.fields.forEach((function(e){var r,n,s,a;if(e.options&&"true"===e.options.packed&&-1===i.indexOf(e.type)){if(-1===e.type.indexOf(".")){if(t.enums&&t.enums.some((function(t){return t.name===e.type})))return}else{if((r=e.type.split(".")).length>2)throw new Error("what is this?");if(n=r[0],s=r[1],o.messages.some((function(t){if(t.name===n)return a=t,t})),a&&a.enums&&a.enums.some((function(t){return t.name===s})))return}throw new Error("Fields of type "+e.type+' cannot be declared [packed=true]. Only repeated fields of primitive numeric types (types which use the varint, 32-bit, or 64-bit wire types) can be declared "packed". See https://developers.google.com/protocol-buffers/docs/encoding#optional')}}))})),o}},function(t,e,r){"use strict";t.exports=function(t){var e,r=function(t){return t.trim()};return t.replace(/([;,{}()=:[\]<>]|\/\*|\*\/)/g," $1 ").split(/\n/).map(r).filter(Boolean).map((function(t){var e=t.indexOf("//");return e>-1?t.slice(0,e):t})).map(r).filter(Boolean).join("\n").split(/\s+|\n+/gm).filter((e=!1,function(t){return"/*"===t?(e=!0,!1):"*/"===t?(e=!1,!1):!e}))}},function(t,e,r){"use strict";var n=function(t,e){var r=t.repeated?"repeated":t.required?"required":"optional";"map"===t.type&&(r="map<"+t.map.from+","+t.map.to+">"),t.oneof&&(r="");var n=Object.keys(t.options||{}).map((function(e){return e+" = "+t.options[e]})).join(",");return n&&(n=" ["+n+"]"),e.push((r?r+" ":"")+("map"===t.map?"":t.type+" ")+t.name+" = "+t.tag+n+";"),e},i=function(t,e){e.push("message "+t.name+" {"),t.options||(t.options={}),a(t.options,e),t.enums||(t.enums=[]),t.enums.forEach((function(t){e.push(s(t,[]))})),t.messages||(t.messages=[]),t.messages.forEach((function(t){e.push(i(t,[]))}));var r={};return t.fields||(t.fields=[]),t.fields.forEach((function(t){t.oneof?(r[t.oneof]||(r[t.oneof]=[]),r[t.oneof].push(n(t,[]))):e.push(n(t,[]))})),Object.keys(r).forEach((function(t){r[t].unshift("oneof "+t+" {"),r[t].push("}"),e.push(r[t])})),e.push("}",""),e},s=function(t,e){e.push("enum "+t.name+" {"),t.options||(t.options={});var r=a(t.options,[]);return r.length>1&&e.push(r.slice(0,-1)),Object.keys(t.values).map((function(r){var n=o(t.values[r]);e.push([r+" = "+n+";"])})),e.push("}",""),e},o=function(t,e){var r=Object.keys(t.options||{}).map((function(e){return e+" = "+t.options[e]})).join(",");return r&&(r=" ["+r+"]"),t.value+r},a=function(t,e){var r=Object.keys(t);return r.forEach((function(r){var n=t[r];~r.indexOf(".")&&(r="("+r+")");var i=typeof n;"object"===i?(n=c(n,[])).length&&e.push("option "+r+" = {",n,"};"):("string"===i&&"optimize_for"!==r&&(n='"'+n+'"'),e.push("option "+r+" = "+n+";"))})),r.length>0&&e.push(""),e},c=function(t,e){return Object.keys(t).forEach((function(r){var n=t[r],i=typeof n;"object"===i?Array.isArray(n)?n.forEach((function(t){(t=c(t,[])).length&&e.push(r+" {",t,"}")})):(n=c(n,[])).length&&e.push(r+" {",n,"}"):("string"===i&&(n='"'+n+'"'),e.push(r+": "+n))})),e},u=function(t,e){var r="rpc "+t.name+"(";t.client_streaming&&(r+="stream "),r+=t.input_type+") returns (",t.server_streaming&&(r+="stream "),r+=t.output_type+")",t.options||(t.options={});var n=a(t.options,[]);return n.length>1?e.push(r+" {",n.slice(0,-1),"}"):e.push(r+";"),e},h=function(t){return function(e){return Array.isArray(e)?e.map(h(t+" ")).join("\n"):t+e}};t.exports=function(t){var e=[];return e.push('syntax = "proto'+t.syntax+'";',""),t.package&&e.push("package "+t.package+";",""),t.options||(t.options={}),a(t.options,e),t.enums||(t.enums=[]),t.enums.forEach((function(t){s(t,e)})),t.messages||(t.messages=[]),t.messages.forEach((function(t){i(t,e)})),t.services&&t.services.forEach((function(t){!function(t,e){e.push("service "+t.name+" {"),t.options||(t.options={}),a(t.options,e),t.methods||(t.methods=[]),t.methods.forEach((function(t){e.push(u(t,[]))})),e.push("}","")}(t,e)})),e.map(h("")).join("\n")}},function(t,e,r){"use strict";const n=r(418),i=r(432),s=r(433),o=r(434),a=r(15);t.exports=function(t,e){const r={},c={},u={},h=function(t,e){t.enums&&t.enums.forEach((function(t){t.id=e+(e?".":"")+t.name,c[t.id]=t,h(t,t.id)})),t.messages&&t.messages.forEach((function(n){n.id=e+(e?".":"")+n.name,r[n.id]=n,n.fields.forEach((function(n){if(!n.map)return;const i="Map_"+n.map.from+"_"+n.map.to,s={name:i,enums:[],messages:[],fields:[{name:"key",type:n.map.from,tag:1,repeated:!1,required:!0},{name:"value",type:n.map.to,tag:2,repeated:!1,required:!1}],extensions:null,id:e+(e?".":"")+i};r[s.id]||(r[s.id]=s,t.messages.push(s)),n.type=i,n.repeated=!0})),h(n,n.id)}))};h(t,"");const f=function(t,e){t.messages.forEach((function(r){e[r.name]=l(r.name,t.id)})),t.enums.forEach((function(t){e[t.name]=function(t){if(!t)return null;const e={};return Object.keys(t).forEach((function(r){e[r]=t[r].value})),e}(t.values)})),e.type=2,e.message=!0,e.name=t.name;const r={};t.fields.forEach((function(t){t.oneof&&(r[t.oneof]||(r[t.oneof]=[]),r[t.oneof].push(t.name))}));const n=t.fields.map((function(e){return l(e.type,t.id)})),a=o(t,n,r),c=s(t,l,n,r,a),u=i(t,l,n);return c.bytes=u.bytes=0,e.buffer=!0,e.encode=c,e.decode=u,e.encodingLength=a,e},l=function(t,i,s){if(e&&e[t])return e[t];if(n[t])return n[t];const o=(i?i+"."+t:t).split(".").map((function(e,r,n){return n.slice(0,r).concat(t).join(".")})).reverse().reduce((function(t,e){return t||r[e]||c[e]}),null);if(!1===s)return o;if(!o)throw new Error("Could not resolve "+t);if(o.values)return function(t){const e=Object.keys(t.values||[]).map((function(e){return parseInt(t.values[e].value,10)}));return n.make(0,(function t(r,n,i,s){if(!e.length||-1===e.indexOf(r))throw new Error("Invalid enum value: "+r);return a.encode(r,n,s),t.bytes=a.encode.bytes,n}),(function t(r,n,i){var s=a.decode(r,i);if(!e.length||-1===e.indexOf(s))throw new Error("Invalid enum value: "+s);return t.bytes=a.decode.bytes,s}),a.encodingLength)}(o);return u[o.id]||f(o,u[o.id]={})};return(t.enums||[]).concat((t.messages||[]).map((function(t){return l(t.id)})))}},function(t,e,r){"use strict";e.make=r(34),e.bytes=r(419),e.string=r(420),e.bool=r(421),e.int32=r(422),e.int64=r(423),e.sint32=e.sint64=r(424),e.uint32=e.uint64=e.enum=e.varint=r(426),e.fixed64=e.sfixed64=r(427),e.double=r(428),e.fixed32=r(429),e.sfixed32=r(430),e.float=r(431)},function(t,e,r){"use strict";const n=r(15),i=r(34);function s(t){return t.byteLength}t.exports=i(2,(function t(e,r,i,o){const a=o,c=s(e);n.encode(c,r,o),o+=n.encode.bytes,r.set(e,o),t.bytes=(o+=c)-a}),(function t(e,r,i){const s=i,o=n.decode(e,i);i+=n.decode.bytes;const a=e.slice(i,i+o);return i+=a.length,t.bytes=i-s,a}),(function(t){const e=s(t);return n.encodingLength(e)+e}))},function(t,e,r){"use strict";const n=r(15),i=r(6),s=r(5),o=r(34);t.exports=o(2,(function t(e,r,s,o){const a=o,c=i(e).byteLength;n.encode(c,r,o,"utf-8"),o+=n.encode.bytes;const u=i(e);r.set(u,o),o+=u.length,t.bytes=o-a}),(function t(e,r,i){const o=i,a=n.decode(e,i);i+=n.decode.bytes;const c=s(e.subarray(i,i+a));return t.bytes=(i+=a)-o,c}),(function(t){const e=i(t).byteLength;return n.encodingLength(e)+e}))},function(t,e,r){"use strict";const n=r(34);t.exports=n(0,(function t(e,r,n,i){r[i]=e?1:0,t.bytes=1}),(function t(e,r,n){const i=e[n]>0;return t.bytes=1,i}),(function(){return 1}))},function(t,e,r){"use strict";const n=r(15),i=r(34);t.exports=i(0,(function t(e,r,i,s){n.encode(e<0?e+4294967296:e,r,s),t.bytes=n.encode.bytes}),(function t(e,r,i){const s=n.decode(e,i);return t.bytes=n.decode.bytes,s>2147483647?s-4294967296:s}),(function(t){return n.encodingLength(t<0?t+4294967296:t)}))},function(t,e,r){"use strict";const n=r(15),i=r(34);t.exports=i(0,(function t(e,r,i,s){if(e<0){const i=s+9;for(n.encode(-1*e,r,s),r[s+=n.encode.bytes-1]=128|r[s];s=Math.pow(2,63)){let r=9;for(;255===e[i+r-1];)r--;r=r||9;const o=e.subarray(i,i+r);o[r-1]=127&o[r-1],s=-1*n.decode(o,0),t.bytes=10}else t.bytes=n.decode.bytes;return s}),(function(t){return t<0?10:n.encodingLength(t)}))},function(t,e,r){"use strict";const n=r(425),i=r(34);t.exports=i(0,(function t(e,r,i,s){n.encode(e,r,s),t.bytes=n.encode.bytes}),(function t(e,r,i){const s=n.decode(e,i);return t.bytes=n.decode.bytes,s}),n.encodingLength)},function(t,e,r){"use strict";var n=r(15);e.encode=function t(e,r,i){e=e>=0?2*e:-2*e-1;var s=n.encode(e,r,i);return t.bytes=n.encode.bytes,s},e.decode=function t(e,r){var i=n.decode(e,r);return t.bytes=n.decode.bytes,1&i?(i+1)/-2:i/2},e.encodingLength=function(t){return n.encodingLength(t>=0?2*t:-2*t-1)}},function(t,e,r){"use strict";const n=r(15),i=r(34);t.exports=i(0,(function t(e,r,i,s){n.encode(e,r,s),t.bytes=n.encode.bytes}),(function t(e,r,i){const s=n.decode(e,i);return t.bytes=n.decode.bytes,s}),n.encodingLength)},function(t,e,r){"use strict";const n=r(34);t.exports=n(1,(function t(e,r,n,i){for(const s of e)r[i]=s,i++;t.bytes=8}),(function t(e,r,n){const i=e.slice(n,n+8);return t.bytes=8,i}),(function(){return 8}))},function(t,e,r){"use strict";const n=r(34);t.exports=n(1,(function t(e,r,n,i){n.setFloat64(i,e,!0),t.bytes=8}),(function t(e,r,n){const i=r.getFloat64(n,!0);return t.bytes=8,i}),(function(){return 8}))},function(t,e,r){"use strict";const n=r(34);t.exports=n(5,(function t(e,r,n,i){n.setUint32(i,e,!0),t.bytes=4}),(function t(e,r,n){const i=r.getUint32(n,!0);return t.bytes=4,i}),(function(t){return 4}))},function(t,e,r){"use strict";const n=r(34);t.exports=n(5,(function t(e,r,n,i){n.setInt32(i,e,!0),t.bytes=4}),(function t(e,r,n){const i=r.getInt32(n,!0);return t.bytes=4,i}),(function(t){return 4}))},function(t,e,r){"use strict";const n=r(34);t.exports=n(5,(function t(e,r,n,i){n.setFloat32(i,e,!0),t.bytes=4}),(function t(e,r,n){const i=r.getFloat32(n,!0);return t.bytes=4,i}),(function(){return 4}))},function(t,e,r){"use strict";const n=r(15),i=r(136).defined;function s(t){return`${t.substring(0,1).toUpperCase()}${t.substring(1)}`}function o(t,e,r,n){if(Object.prototype.hasOwnProperty.call(t,e))return;const i=s(e);Object.defineProperties(t,{[e]:{enumerable:!0,configurable:!0,set:t=>{r=t},get:()=>void 0===r?n:r},["has"+i]:{configurable:!0,value:()=>void 0!==r},["set"+i]:{configurable:!0,value:t=>{r=t}},["get"+i]:{configurable:!0,value:()=>r},["clear"+i]:{configurable:!0,value:()=>{r=void 0,t[e]=void 0}}})}var a=function(t,e,r,i){switch(t){case 0:return n.decode(e,i),i+n.decode.bytes;case 1:return i+8;case 2:var s=n.decode(e,i);return i+n.decode.bytes+s;case 3:case 4:throw new Error("Groups are not supported");case 5:return i+4;default:throw new Error("Unknown wire type: "+t)}},c=function(t){if(t.map)return{};if(t.repeated)return[];switch(t.type){case"string":return"";case"bool":return!1;case"float":case"double":case"sfixed32":case"fixed32":case"varint":case"enum":case"uint64":case"uint32":case"int64":case"int32":case"sint64":case"sint32":return 0;default:return null}},u=function(t,e){if(void 0===e)return e;switch(t.type){case"bool":return"true"===e;case"float":case"double":case"sfixed32":case"fixed32":case"varint":case"enum":case"uint64":case"uint32":case"int64":case"int32":case"sint64":case"sint32":return parseInt(e,10);default:return e}};t.exports=function(t,e,r){const h=[],f={},l=[],d=[];for(var p=0;p-1){const e=s(t[f]);delete r["has"+e],delete r["get"+e],delete r["set"+e],delete r["clear"+e],delete r[t[f]]}}let d;if(t.message){const s=n.decode(i,c);c+=n.decode.bytes;const o=t.decode(i,a,c,c+s);e.map?(d=r[h]||{},d[o.key]=o.value):e.repeated?(d=r[h]||[],d.push(o)):d=o}else e.repeated?(d=r[h]||[],d.push(t.decode(i,a,c))):d=t.decode(i,a,c);return o(r,h,d),c+=t.decode.bytes}return function e(s,p,g,b){if(null==g&&(g=0),null==b&&(b=s.length),!(b<=s.length&&g<=s.length))throw new Error("Decoded message is not valid");p||(p=new DataView(s.buffer,s.byteOffset,s.byteLength));for(var m,v=g,w={};;){if(b<=g){var _,E,S="",I=0;for(I=0;I-1){A=!0;break}A||(_?m.repeated?E=[]:(E=E&&_[E]?_[E].value:_[Object.keys(_)[0]].value,E=parseInt(E||0,10)):(e=c(m),E=u(m,E)),o(w,S,E,e))}}return e.bytes=g-v,w}var R=n.decode(s,g);g+=n.decode.bytes;var C=f[R>>3];if(null!=C){var B=r[C];if((m=t.fields[C]).packed){var M=n.decode(s,g);for(M+=g+=n.decode.bytes;g-1){if(m)throw new Error("only one of the properties defined in oneof "+t+" can be set");m=!0}}for(b=0;b0;)a.push(u%s),u=u/s|0}for(i=0;0===t[i]&&i=0;--i)n+=e[a[i]]}else n=function(t,e){var r=0,n=e.length,i=e.charAt(0),s=[0];for(r=0;r0;)s.push(a%n),a=a/n|0}var c="";for(r=0;0===t.at(r)&&r=0;--r)c+=e[s[r]];return c}(t,e);if(r){var h=new RegExp(".{1,"+r+"}","g");n=n.match(h).join("\r\n")}return n},r.decode=function(t,r){if("string"!=typeof t)throw new TypeError('"input" must be a string.');if("string"!=typeof r)throw new TypeError('"alphabet" must be a string.');var i=n[r];if(!i){i=n[r]=[];for(var s=0;s>=8;for(;f>0;)c.push(255&f),f>>=8}for(var l=0;t[l]===a&&l=0;c--)C>>=8,C+=A.at(c)+R.at(c),R.setAt(c,255&C);T.putBuffer(R)}w=T,f.putBuffer(S)}return f.truncate(f.length()-s),f},o.pbe.getCipher=function(t,e,r){switch(t){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(t,e,r);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},o.pbe.getCipherForPBES2=function(t,e,r){var i,a={},c=[];if(!s.validate(e,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((t=s.derToOid(a.kdfOid))!==o.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=t,i.supportedOids=["pkcs5PBKDF2"],i;if((t=s.derToOid(a.encOid))!==o.oids["aes128-CBC"]&&t!==o.oids["aes192-CBC"]&&t!==o.oids["aes256-CBC"]&&t!==o.oids["des-EDE3-CBC"]&&t!==o.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=t,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var h,f,d=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),o.oids[t]){case"aes128-CBC":h=16,f=n.aes.createDecryptionCipher;break;case"aes192-CBC":h=24,f=n.aes.createDecryptionCipher;break;case"aes256-CBC":h=32,f=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":h=24,f=n.des.createDecryptionCipher;break;case"desCBC":h=8,f=n.des.createDecryptionCipher}var y=l(a.prfOid),g=n.pkcs5.pbkdf2(r,d,p,h,y),b=a.encIv,m=f(g);return m.start(b),m},o.pbe.getCipherForPKCS12PBE=function(t,e,r){var i={},a=[];if(!s.validate(e,h,i,a))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,y;var c,u,f,d=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),t){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,f=n.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,f=function(t,e){var r=n.rc2.createDecryptionCipher(t,40);return r.start(e,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=t,y}var g=l(i.prfOid),b=o.pbe.generatePkcs12Key(r,d,1,p,c,g);return g.start(),f(b,o.pbe.generatePkcs12Key(r,d,2,p,u,g))},o.pbe.opensslDeriveBytes=function(t,e,r,i){if(null==i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===e&&(e="");for(var s=[f(i,t+e)],o=16,a=1;o8?3:1,b=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,w=0;w>>4^E))<<4,_^=e=65535&((E^=e)>>>-16^_),_^=(e=858993459&(_>>>2^(E^=e<<-16)))<<2,_^=e=65535&((E^=e)>>>-16^_),_^=(e=1431655765&(_>>>1^(E^=e<<-16)))<<1,_^=e=16711935&((E^=e)>>>8^_),e=(_^=(e=1431655765&(_>>>1^(E^=e<<8)))<<1)<<8|(E^=e)>>>20&240,_=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=e;for(var S=0;S>>26,E=E<<2|E>>>26):(_=_<<1|_>>>27,E=E<<1|E>>>27);var I=r[(_&=-15)>>>28]|n[_>>>24&15]|i[_>>>20&15]|s[_>>>16&15]|o[_>>>12&15]|a[_>>>8&15]|c[_>>>4&15],A=u[(E&=-15)>>>28]|h[E>>>24&15]|f[E>>>20&15]|l[E>>>16&15]|d[E>>>12&15]|p[E>>>8&15]|y[E>>>4&15];e=65535&(A>>>16^I),b[v++]=I^e,b[v++]=A^e<<16}}return b}(e),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],h=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],f=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],l=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function d(t,e,r,n){var i,d,p=32===t.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=e[0],g=e[1];y^=(d=252645135&(y>>>4^g))<<4,y^=(d=65535&(y>>>16^(g^=d)))<<16,y^=d=858993459&((g^=d)>>>2^y),y^=d=16711935&((g^=d<<2)>>>8^y),y=(y^=(d=1431655765&(y>>>1^(g^=d<<8)))<<1)<<1|y>>>31,g=(g^=d)<<1|g>>>31;for(var b=0;b>>4|g<<28)^t[w+1];d=y,y=g,g=d^(o[_>>>24&63]|c[_>>>16&63]|h[_>>>8&63]|l[63&_]|s[E>>>24&63]|a[E>>>16&63]|u[E>>>8&63]|f[63&E])}d=y,y=g,g=d}g=g>>>1|g<<31,g^=d=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(d=16711935&(g>>>8^(y^=d<<1)))<<8,g^=(d=858993459&(g>>>2^(y^=d)))<<2,g^=d=65535&((y^=d)>>>16^g),g^=d=252645135&((y^=d<<16)>>>4^g),y^=d<<4,r[0]=y,r[1]=g}function p(t){var e,r="DES-"+((t=t||{}).mode||"CBC").toUpperCase(),i=(e=t.decrypt?n.cipher.createDecipher(r,t.key):n.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=t,i.call(e,r)},e}},function(t,e,r){"use strict";var n=r(8);r(60),r(22),(t.exports=n.hmac=n.hmac||{}).create=function(){var t=null,e=null,r=null,i=null,s={start:function(s,o){if(null!==s)if("string"==typeof s){if(!((s=s.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+s+'"');e=n.md.algorithms[s].create()}else e=s;if(null===o)o=t;else{if("string"==typeof o)o=n.util.createBuffer(o);else if(n.util.isArray(o)){var a=o;o=n.util.createBuffer();for(var c=0;ce.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=o.length();for(c=0;c65&&-1!==o){var a=e[o];","===a?(++o,e=e.substr(0,o)+"\r\n "+e.substr(o)):e=e.substr(0,o)+"\r\n"+a+e.substr(o+1),s=i-o-1,o=-1,++i}else" "!==e[i]&&"\t"!==e[i]&&","!==e[i]||(o=i);return e}function o(t){return t.replace(/^\s+/,"")}i.encode=function(t,e){e=e||{};var r,i="-----BEGIN "+t.type+"-----\r\n";if(t.procType&&(i+=s(r={name:"Proc-Type",values:[String(t.procType.version),t.procType.type]})),t.contentDomain&&(i+=s(r={name:"Content-Domain",values:[t.contentDomain]})),t.dekInfo&&(r={name:"DEK-Info",values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&r.values.push(t.dekInfo.parameters),i+=s(r)),t.headers)for(var o=0;o>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return e.putBytes(s),c(t,r,e),(e.read>2048||0===e.length())&&e.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(e.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var h=8*i.fullMessageLength[0],f=0;f>>0,o.putInt32(h>>>0),h=a>>>0;o.putInt32(h);var l={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};c(l,r,o);var d=n.util.createBuffer();return d.putInt32(l.h0),d.putInt32(l.h1),d.putInt32(l.h2),d.putInt32(l.h3),d.putInt32(l.h4),d.putInt32(l.h5),d.putInt32(l.h6),d.putInt32(l.h7),d},i};var s=null,o=!1,a=null;function c(t,e,r){for(var n,i,s,o,c,u,h,f,l,d,p,y,g,b=r.length();b>=64;){for(c=0;c<16;++c)e[c]=r.getInt32();for(;c<64;++c)n=((n=e[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=e[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[c]=n+e[c-7]+i+e[c-16]|0;for(u=t.h0,h=t.h1,f=t.h2,l=t.h3,d=t.h4,p=t.h5,y=t.h6,g=t.h7,c=0;c<64;++c)s=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&h|f&(u^h),n=g+((d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(y^d&(p^y))+a[c]+e[c],g=y,y=p,p=d,d=l+n>>>0,l=f,f=h,h=u,u=n+(i=s+o)>>>0;t.h0=t.h0+u|0,t.h1=t.h1+h|0,t.h2=t.h2+f|0,t.h3=t.h3+l|0,t.h4=t.h4+d|0,t.h5=t.h5+p|0,t.h6=t.h6+y|0,t.h7=t.h7+g|0,b-=64}}},function(t,e,r){"use strict";(function(e){var n=r(8);r(22);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||e.versions["node-webkit"]||(i=r(140)),(t.exports=n.prng=n.prng||{}).create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,s=new Array(32),o=0;o<32;++o)s[o]=r.create();function a(){if(e.pools[0].messageLength>=32)return c();var t=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(t)),c()}function c(){e.reseeds=4294967295===e.reseeds?0:e.reseeds+1;var t=e.plugin.md.create();t.update(e.keyBytes);for(var r=1,n=0;n<32;++n)e.reseeds%r==0&&(t.update(e.pools[n].digest().getBytes()),e.pools[n].start()),r<<=1;e.keyBytes=t.digest().getBytes(),t.start(),t.update(e.keyBytes);var i=t.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(i),e.generated=0}function u(t){var e=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(e=function(t){return i.getRandomValues(t)});var s=n.util.createBuffer();if(e)for(;s.length()>16)))<<16,l=4294967295&(h=(2147483647&(h+=u>>15))+(h>>31));for(c=0;c<3;++c)f=l>>>(c<<3),f^=Math.floor(256*Math.random()),s.putByte(String.fromCharCode(255&f))}return s.getBytes(t)}return e.pools=s,e.pool=0,e.generate=function(t,r){if(!r)return e.generateSync(t);var i=e.plugin.cipher,s=e.plugin.increment,o=e.plugin.formatKey,a=e.plugin.formatSeed,u=n.util.createBuffer();e.key=null,function h(f){if(f)return r(f);if(u.length()>=t)return r(null,u.getBytes(t));e.generated>1048575&&(e.key=null);if(null===e.key)return n.util.nextTick((function(){!function(t){if(e.pools[0].messageLength>=32)return c(),t();var r=32-e.pools[0].messageLength<<5;e.seedFile(r,(function(r,n){if(r)return t(r);e.collect(n),c(),t()}))}(h)}));var l=i(e.key,e.seed);e.generated+=l.length,u.putBytes(l),e.key=o(i(e.key,s(e.seed))),e.seed=a(i(e.key,e.seed)),n.util.setImmediate(h)}()},e.generateSync=function(t){var r=e.plugin.cipher,i=e.plugin.increment,s=e.plugin.formatKey,o=e.plugin.formatSeed;e.key=null;for(var c=n.util.createBuffer();c.length()1048575&&(e.key=null),null===e.key&&a();var u=r(e.key,e.seed);e.generated+=u.length,c.putBytes(u),e.key=s(r(e.key,i(e.seed))),e.seed=o(r(e.key,e.seed))}return c.getBytes(t)},i?(e.seedFile=function(t,e){i.randomBytes(t,(function(t,r){if(t)return e(t);e(null,r.toString())}))},e.seedFileSync=function(t){return i.randomBytes(t).toString()}):(e.seedFile=function(t,e){try{e(null,u(t))}catch(r){e(r)}},e.seedFileSync=u),e.collect=function(t){for(var r=t.length,n=0;n>i&255);e.collect(n)},e.registerWorker=function(t){if(t===self)e.seedFile=function(t,e){self.addEventListener("message",(function t(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",t),e(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:t}}})};else{t.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&e.seedFile(n.forge.prng.needed,(function(e,r){t.postMessage({forge:{prng:{err:e,bytes:r}}})}))}))}},e}}).call(this,r(12))},function(t,e,r){"use strict";var n=r(8);r(22);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s=[1,2,3,5],o=function(t,e){return t<>16-e},a=function(t,e){return(65535&t)>>e|t<<16-e&65535};t.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(t,e){"string"==typeof t&&(t=n.util.createBuffer(t)),e=e||128;var r,s=t,o=t.length(),a=e,c=Math.ceil(a/8),u=255>>(7&a);for(r=o;r<128;r++)s.putByte(i[s.at(r-1)+s.at(r-o)&255]);for(s.setAt(128-c,i[s.at(128-c)&u]),r=127-c;r>=0;r--)s.setAt(r,i[s.at(r+1)^s.at(r+c)]);return s};var c=function(t,e,r){var i,c,u,h,f=!1,l=null,d=null,p=null,y=[];for(t=n.rc2.expandKey(t,e),u=0;u<64;u++)y.push(t.getInt16Le());r?(i=function(t){for(u=0;u<4;u++)t[u]+=y[h]+(t[(u+3)%4]&t[(u+2)%4])+(~t[(u+3)%4]&t[(u+1)%4]),t[u]=o(t[u],s[u]),h++},c=function(t){for(u=0;u<4;u++)t[u]+=y[63&t[(u+3)%4]]}):(i=function(t){for(u=3;u>=0;u--)t[u]=a(t[u],s[u]),t[u]-=y[h]+(t[(u+3)%4]&t[(u+2)%4])+(~t[(u+3)%4]&t[(u+1)%4]),h--},c=function(t){for(u=3;u>=0;u--)t[u]-=y[63&t[(u+3)%4]]});var g=function(t){var e=[];for(u=0;u<4;u++){var n=l.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),e.push(65535&n)}h=r?0:63;for(var i=0;i=8;)g([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(t){var e=!0;if(r)if(t)e=t(8,l,!r);else{var n=8===l.length()?8:8-l.length();l.fillWithByte(n,n)}if(e&&(f=!0,b.update()),!r&&(e=0===l.length()))if(t)e=t(8,d,!r);else{var i=d.length(),s=d.at(i-1);s>i?e=!1:d.truncate(s)}return e}}};n.rc2.startEncrypting=function(t,e,r){var i=n.rc2.createEncryptionCipher(t,128);return i.start(e,r),i},n.rc2.createEncryptionCipher=function(t,e){return c(t,e,!0)},n.rc2.startDecrypting=function(t,e,r){var i=n.rc2.createDecryptionCipher(t,128);return i.start(e,r),i},n.rc2.createDecryptionCipher=function(t,e){return c(t,e,!1)}},function(t,e,r){"use strict";var n=r(8);r(22),r(82),r(444);var i=t.exports=n.pkcs1=n.pkcs1||{};function s(t,e,r){r||(r=n.md.sha1.create());for(var i="",s=Math.ceil(e/r.digestLength),o=0;o>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(t+a),i+=r.digest().getBytes()}return i.substring(0,e)}i.encode_rsa_oaep=function(t,e,r){var i,o,a,c;"string"==typeof r?(i=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(t.n.bitLength()/8),h=u-2*a.digestLength-2;if(e.length>h)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=e.length,g.maxLength=h,g;i||(i=""),a.update(i,"raw");for(var f=a.digest(),l="",d=h-e.length,p=0;p>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return e.putBytes(s),a(t,r,e),(e.read>2048||0===e.length())&&e.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(e.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var h=8*i.fullMessageLength[0],f=0;f>>0,o.putInt32(h>>>0),h=c>>>0;o.putInt32(h);var l={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};a(l,r,o);var d=n.util.createBuffer();return d.putInt32(l.h0),d.putInt32(l.h1),d.putInt32(l.h2),d.putInt32(l.h3),d.putInt32(l.h4),d},i};var s=null,o=!1;function a(t,e,r){for(var n,i,s,o,a,c,u,h=r.length();h>=64;){for(i=t.h0,s=t.h1,o=t.h2,a=t.h3,c=t.h4,u=0;u<16;++u)n=r.getInt32(),e[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<20;++u)n=(n=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|n>>>31,e[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<32;++u)n=(n=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|n>>>31,e[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<40;++u)n=(n=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|n>>>30,e[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<60;++u)n=(n=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|n>>>30,e[u]=n,n=(i<<5|i>>>27)+(s&o|a&(s^o))+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<80;++u)n=(n=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|n>>>30,e[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+s|0,t.h2=t.h2+o|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,h-=64}}},function(t,e,r){"use strict";var n=r(8);r(22),r(107),r(82),function(){if(n.prime)t.exports=n.prime;else{var e=t.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],s=new r(null);s.fromInt(30);var o=function(t,e){return t|e};e.generateProbablePrime=function(t,e,i){"function"==typeof e&&(i=e,e={});var s=(e=e||{}).algorithm||"PRIMEINC";"string"==typeof s&&(s={name:s}),s.options=s.options||{};var o=e.prng||n.random,u={nextBytes:function(t){for(var e=o.getBytesSync(t.length),r=0;rt&&(o=c(t,e));var d=o.toString(16);i.target.postMessage({hex:d,workLoad:h}),o.dAddOffset(f,0)}}}d()}(t,e,i,s);return a(t,e,i,s)}(t,u,s.options,i);throw new Error("Invalid prime generation algorithm: "+s.name)}}function a(t,e,r,s){var o=c(t,e),a=function(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}(o.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),function t(e,r,s,o,a,u,h){var f=+new Date;do{if(e.bitLength()>r&&(e=c(r,s)),e.isProbablePrime(a))return h(null,e);e.dAddOffset(i[o++%8],0)}while(u<0||+new Date-fe.encrypt(t))},e.decrypt=function(t,e){return h(t,!1,e,(t,e)=>e.decrypt(t))}},function(t,e,r){"use strict";const n=self.crypto||self.msCrypto,{Buffer:i}=r(3);n&&n.getRandomValues?t.exports=function(t){const e=new Uint8Array(t);let r=0;if(t>0)if(t>65536)for(;rt?(n.getRandomValues(e.subarray(r,r+(t-r))),r+=t-r):(n.getRandomValues(e.subarray(r,r+65536)),r+=65536);else n.getRandomValues(e);return i.from(e)}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},function(t,e,r){"use strict";r(81),r(141);const n=r(8),{bigIntegerToUintBase64url:i,base64urlToBigInteger:s}=r(142),o=r(6),a=r(5);e.pkcs1ToJwk=function(t){const e=n.asn1.fromDer(a(t,"ascii")),r=n.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:i(r.n),e:i(r.e),d:i(r.d),p:i(r.p),q:i(r.q),dp:i(r.dP),dq:i(r.dQ),qi:i(r.qInv),alg:"RS256",kid:"2011-04-29"}},e.jwkToPkcs1=function(t){const e=n.pki.privateKeyToAsn1({n:s(t.n),e:s(t.e),d:s(t.d),p:s(t.p),q:s(t.q),dP:s(t.dp),dQ:s(t.dq),qInv:s(t.qi)});return o(n.asn1.toDer(e).getBytes(),"ascii")},e.pkixToJwk=function(t){const e=n.asn1.fromDer(a(t,"ascii")),r=n.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:i(r.n),e:i(r.e),alg:"RS256",kid:"2011-04-29"}},e.jwkToPkix=function(t){const e=n.pki.publicKeyToAsn1({n:s(t.n),e:s(t.e)});return o(n.asn1.toDer(e).getBytes(),"ascii")}},function(t,e,r){"use strict";r(141);const n=r(8),{base64urlToBigInteger:i}=r(142);function s(t,e){return e.map(e=>i(t[e]))}t.exports={jwk2pub:function(t){return n.pki.setRsaPublicKey(...s(t,["n","e"]))},jwk2priv:function(t){return n.pki.setRsaPrivateKey(...s(t,["n","e","d","p","q","dp","dq","qi"]))}}},function(t,e,r){"use strict";const n=r(83),i=r(21),s=r(31),o=r(0),a=r(20),c=r(454),u=i(r(137)),h=r(143);class f{constructor(t){this._key=d(t,c.publicKeyLength)}async verify(t,e){return c.hashAndVerify(this._key,e,t)}marshal(){return this._key}get bytes(){return u.PublicKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()})}equals(t){return a(this.bytes,t.bytes)}async hash(){return n.multihashing(this.bytes,"sha2-256")}}class l{constructor(t,e){this._key=d(t,c.privateKeyLength),this._publicKey=d(e,c.publicKeyLength)}async sign(t){return c.hashAndSign(this._key,t)}get public(){return new f(this._publicKey)}marshal(){return this._key}get bytes(){return u.PrivateKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()})}equals(t){return a(this.bytes,t.bytes)}async hash(){return n.multihashing(this.bytes,"sha2-256")}async id(){const t=await this.public.hash();return s.encode("base58btc",t).toString().slice(1)}async export(t,e="libp2p-key"){if("libp2p-key"===e)return h.export(this.bytes,t);throw o(new Error(`export format '${e}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}function d(t,e){if((t=Uint8Array.from(t||[])).length!==e)throw o(new Error(`Key must be a Uint8Array of length ${e}, got ${t.length}`),"ERR_INVALID_KEY_TYPE");return t}t.exports={Ed25519PublicKey:f,Ed25519PrivateKey:l,unmarshalEd25519PrivateKey:function(t){if(t.length>c.privateKeyLength){const e=(t=d(t,c.privateKeyLength+c.publicKeyLength)).slice(0,c.privateKeyLength),r=t.slice(c.privateKeyLength,t.length);return new l(e,r)}const e=(t=d(t,c.privateKeyLength)).slice(0,c.privateKeyLength),r=t.slice(c.publicKeyLength);return new l(e,r)},unmarshalEd25519PublicKey:function(t){return t=d(t,c.publicKeyLength),new f(t)},generateKeyPair:async function(){const{privateKey:t,publicKey:e}=await c.generateKey();return new l(t,e)},generateKeyPairFromSeed:async function(t){const{privateKey:e,publicKey:r}=await c.generateKeyFromSeed(t);return new l(e,r)}}},function(t,e,r){"use strict";r(232);const n=r(8);e.publicKeyLength=n.pki.ed25519.constants.PUBLIC_KEY_BYTE_LENGTH,e.privateKeyLength=n.pki.ed25519.constants.PRIVATE_KEY_BYTE_LENGTH,e.generateKey=async function(){return n.pki.ed25519.generateKeyPair()},e.generateKeyFromSeed=async function(t){return n.pki.ed25519.generateKeyPair({seed:t})},e.hashAndSign=async function(t,e){return n.pki.ed25519.sign({message:e,privateKey:t})},e.hashAndVerify=async function(t,e,r){return n.pki.ed25519.verify({signature:e,message:r,publicKey:t})}},function(t,e,r){"use strict";const n=r(83),i=r(0),s=r(20),o=r(5),a=r(143);t.exports=(t,e,c)=>{c=c||r(456)(e);class u{constructor(t){c.validatePublicKey(t),this._key=t}verify(t,e){return c.hashAndVerify(this._key,e,t)}marshal(){return c.compressPublicKey(this._key)}get bytes(){return t.PublicKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()})}equals(t){return s(this.bytes,t.bytes)}hash(){return n.multihashing(this.bytes,"sha2-256")}}class h{constructor(t,e){this._key=t,this._publicKey=e||c.computePublicKey(t),c.validatePrivateKey(this._key),c.validatePublicKey(this._publicKey)}sign(t){return c.hashAndSign(this._key,t)}get public(){return new u(this._publicKey)}marshal(){return this._key}get bytes(){return t.PrivateKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()})}equals(t){return s(this.bytes,t.bytes)}hash(){return n.multihashing(this.bytes,"sha2-256")}async id(){const t=await this.public.hash();return o(t,"base58btc")}async export(t,e="libp2p-key"){if("libp2p-key"===e)return a.export(this.bytes,t);throw i(new Error(`export format '${e}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}return{Secp256k1PublicKey:u,Secp256k1PrivateKey:h,unmarshalSecp256k1PrivateKey:function(t){return new h(t)},unmarshalSecp256k1PublicKey:function(t){return new u(t)},generateKeyPair:async function(){const t=await c.generateKey();return new h(t)}}}},function(t,e,r){"use strict";const n=r(457),i=r(83);t.exports=t=>{function e(t){if(!n.privateKeyVerify(t))throw new Error("Invalid private key")}return{generateKey:function(){let e;do{e=t(32)}while(!n.privateKeyVerify(e));return e},privateKeyLength:32,hashAndSign:async function(t,e){const r=await i.digest(e,"sha2-256"),s=n.ecdsaSign(r,t);return n.signatureExport(s.signature)},hashAndVerify:async function(t,e,r){const s=await i.digest(r,"sha2-256");return e=n.signatureImport(e),n.ecdsaVerify(e,s,t)},compressPublicKey:function(t){if(!n.publicKeyVerify(t))throw new Error("Invalid public key");return n.publicKeyConvert(t,!0)},decompressPublicKey:function(t){return n.publicKeyConvert(t,!1)},validatePrivateKey:e,validatePublicKey:function(t){if(!n.publicKeyVerify(t))throw new Error("Invalid public key")},computePublicKey:function(t){return e(t),n.publicKeyCreate(t)}}}},function(t,e,r){"use strict";t.exports=r(458)(r(459))},function(t,e,r){"use strict";const n="Impossible case. Please create issue.",i="The tweak was out of range or the resulted private key is invalid",s="The tweak was out of range or equal to zero",o="Unknow error on context randomization",a="Private Key is invalid",c="Public Key could not be parsed",u="Public Key serialization error",h="The sum of the public keys is not valid",f="Signature could not be parsed",l="The nonce generation function failed, or the private key was invalid",d="Public key could not be recover",p="Scalar was invalid (zero or overflow)";function y(t,e){if(!t)throw new Error(e)}function g(t,e,r){if(y(e instanceof Uint8Array,`Expected ${t} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${t} to be an Uint8Array with length [${r.join(", ")}]`;y(r.includes(e.length),n)}else{const n=`Expected ${t} to be an Uint8Array with length ${r}`;y(e.length===r,n)}}function b(t){y("Boolean"===v(t),"Expected compressed to be a Boolean")}function m(t=(t=>new Uint8Array(t)),e){return"function"==typeof t&&(t=t(e)),g("output",t,e),t}function v(t){return Object.prototype.toString.call(t).slice(8,-1)}t.exports=t=>({contextRandomize(e){switch(y(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&g("seed",e,32),t.contextRandomize(e)){case 1:throw new Error(o)}},privateKeyVerify:e=>(g("private key",e,32),0===t.privateKeyVerify(e)),privateKeyNegate(e){switch(g("private key",e,32),t.privateKeyNegate(e)){case 0:return e;case 1:throw new Error(n)}},privateKeyTweakAdd(e,r){switch(g("private key",e,32),g("tweak",r,32),t.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(i)}},privateKeyTweakMul(e,r){switch(g("private key",e,32),g("tweak",r,32),t.privateKeyTweakMul(e,r)){case 0:return e;case 1:throw new Error(s)}},publicKeyVerify:e=>(g("public key",e,[33,65]),0===t.publicKeyVerify(e)),publicKeyCreate(e,r=!0,n){switch(g("private key",e,32),b(r),n=m(n,r?33:65),t.publicKeyCreate(n,e)){case 0:return n;case 1:throw new Error(a);case 2:throw new Error(u)}},publicKeyConvert(e,r=!0,n){switch(g("public key",e,[33,65]),b(r),n=m(n,r?33:65),t.publicKeyConvert(n,e)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(u)}},publicKeyNegate(e,r=!0,i){switch(g("public key",e,[33,65]),b(r),i=m(i,r?33:65),t.publicKeyNegate(i,e)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(n);case 3:throw new Error(u)}},publicKeyCombine(e,r=!0,n){y(Array.isArray(e),"Expected public keys to be an Array"),y(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)g("public key",t,[33,65]);switch(b(r),n=m(n,r?33:65),t.publicKeyCombine(n,e)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(h);case 3:throw new Error(u)}},publicKeyTweakAdd(e,r,n=!0,s){switch(g("public key",e,[33,65]),g("tweak",r,32),b(n),s=m(s,n?33:65),t.publicKeyTweakAdd(s,e,r)){case 0:return s;case 1:throw new Error(c);case 2:throw new Error(i)}},publicKeyTweakMul(e,r,n=!0,i){switch(g("public key",e,[33,65]),g("tweak",r,32),b(n),i=m(i,n?33:65),t.publicKeyTweakMul(i,e,r)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(s)}},signatureNormalize(e){switch(g("signature",e,64),t.signatureNormalize(e)){case 0:return e;case 1:throw new Error(f)}},signatureExport(e,r){g("signature",e,64);const i={output:r=m(r,72),outputlen:72};switch(t.signatureExport(i,e)){case 0:return r.slice(0,i.outputlen);case 1:throw new Error(f);case 2:throw new Error(n)}},signatureImport(e,r){switch(g("signature",e),r=m(r,64),t.signatureImport(r,e)){case 0:return r;case 1:throw new Error(f);case 2:throw new Error(n)}},ecdsaSign(e,r,i={},s){g("message",e,32),g("private key",r,32),y("Object"===v(i),"Expected options to be an Object"),void 0!==i.data&&g("options.data",i.data),void 0!==i.noncefn&&y("Function"===v(i.noncefn),"Expected options.noncefn to be a Function");const o={signature:s=m(s,64),recid:null};switch(t.ecdsaSign(o,e,r,i.data,i.noncefn)){case 0:return o;case 1:throw new Error(l);case 2:throw new Error(n)}},ecdsaVerify(e,r,n){switch(g("signature",e,64),g("message",r,32),g("public key",n,[33,65]),t.ecdsaVerify(e,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(f);case 2:throw new Error(c)}},ecdsaRecover(e,r,i,s=!0,o){switch(g("signature",e,64),y("Number"===v(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),g("message",i,32),b(s),o=m(o,s?33:65),t.ecdsaRecover(o,e,r,i)){case 0:return o;case 1:throw new Error(f);case 2:throw new Error(d);case 3:throw new Error(n)}},ecdh(e,r,n={},i){switch(g("public key",e,[33,65]),g("private key",r,32),y("Object"===v(n),"Expected options to be an Object"),void 0!==n.data&&g("options.data",n.data),void 0!==n.hashfn?(y("Function"===v(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&g("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&g("options.ybuf",n.ybuf,32),g("output",i)):i=m(i,32),t.ecdh(i,e,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(p)}}})},function(t,e,r){"use strict";const n=new(0,r(460).ec)("secp256k1"),i=n.curve,s=i.n.constructor;function o(t){const e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){let r=new s(e);if(r.cmp(i.p)>=0)return null;r=r.toRed(i.red);let o=r.redSqr().redIMul(r).redIAdd(i.b).redSqrt();return 3===t!==o.isOdd()&&(o=o.redNeg()),n.keyPair({pub:{x:r,y:o}})}(e,t.subarray(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){let o=new s(e),a=new s(r);if(o.cmp(i.p)>=0||a.cmp(i.p)>=0)return null;if(o=o.toRed(i.red),a=a.toRed(i.red),(6===t||7===t)&&a.isOdd()!==(7===t))return null;const c=o.redSqr().redIMul(o);return a.redSqr().redISub(c.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:o,y:a}}):null}(e,t.subarray(1,33),t.subarray(33,65));default:return null}}function a(t,e){const r=e.encode(null,33===t.length);for(let n=0;n0,privateKeyVerify(t){const e=new s(t);return e.cmp(i.n)<0&&!e.isZero()?0:1},privateKeyNegate(t){const e=new s(t),r=i.n.sub(e).umod(i.n).toArrayLike(Uint8Array,"be",32);return t.set(r),0},privateKeyTweakAdd(t,e){const r=new s(e);if(r.cmp(i.n)>=0)return 1;if(r.iadd(new s(t)),r.cmp(i.n)>=0&&r.isub(i.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return t.set(n),0},privateKeyTweakMul(t,e){let r=new s(e);if(r.cmp(i.n)>=0||r.isZero())return 1;r.imul(new s(t)),r.cmp(i.n)>=0&&(r=r.umod(i.n));const n=r.toArrayLike(Uint8Array,"be",32);return t.set(n),0},publicKeyVerify:t=>null===o(t)?1:0,publicKeyCreate(t,e){const r=new s(e);if(r.cmp(i.n)>=0||r.isZero())return 1;return a(t,n.keyFromPrivate(e).getPublic()),0},publicKeyConvert(t,e){const r=o(e);if(null===r)return 1;return a(t,r.getPublic()),0},publicKeyNegate(t,e){const r=o(e);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),a(t,n),0},publicKeyCombine(t,e){const r=new Array(e.length);for(let i=0;i=0)return 2;const c=n.getPublic().add(i.g.mul(r));return c.isInfinity()?2:(a(t,c),0)},publicKeyTweakMul(t,e,r){const n=o(e);if(null===n)return 1;if((r=new s(r)).cmp(i.n)>=0||r.isZero())return 2;return a(t,n.getPublic().mul(r)),0},signatureNormalize(t){const e=new s(t.subarray(0,32)),r=new s(t.subarray(32,64));return e.cmp(i.n)>=0||r.cmp(i.n)>=0?1:(1===r.cmp(n.nh)&&t.set(i.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(t,e){const r=e.subarray(0,32),n=e.subarray(32,64);if(new s(r).cmp(i.n)>=0)return 1;if(new s(n).cmp(i.n)>=0)return 1;const{output:o}=t;let a=o.subarray(4,37);a[0]=0,a.set(r,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let h=o.subarray(39,72);h[0]=0,h.set(n,1);let f=33,l=0;for(;f>1&&0===h[l]&&!(128&h[l+1]);--f,++l);return h=h.subarray(l),128&h[0]||f>1&&0===h[0]&&!(128&h[1])?1:(t.outputlen=6+c+f,o[0]=48,o[1]=t.outputlen-2,o[2]=2,o[3]=a.length,o.set(a,4),o[4+c]=2,o[5+c]=h.length,o.set(h,6+c),0)},signatureImport(t,e){if(e.length<8)return 1;if(e.length>72)return 1;if(48!==e[0])return 1;if(e[1]!==e.length-2)return 1;if(2!==e[2])return 1;const r=e[3];if(0===r)return 1;if(5+r>=e.length)return 1;if(2!==e[4+r])return 1;const n=e[5+r];if(0===n)return 1;if(6+r+n!==e.length)return 1;if(128&e[4])return 1;if(r>1&&0===e[4]&&!(128&e[5]))return 1;if(128&e[r+6])return 1;if(n>1&&0===e[r+6]&&!(128&e[r+7]))return 1;let o=e.subarray(4,4+r);if(33===o.length&&0===o[0]&&(o=o.subarray(1)),o.length>32)return 1;let a=e.subarray(6+r);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new s(o);c.cmp(i.n)>=0&&(c=new s(0));let u=new s(e.subarray(6+r));return u.cmp(i.n)>=0&&(u=new s(0)),t.set(c.toArrayLike(Uint8Array,"be",32),0),t.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(t,e,r,o,a){if(a){const t=a;a=n=>{const i=t(e,r,null,o,n);if(!(i instanceof Uint8Array&&32===i.length))throw new Error("This is the way");return new s(i)}}const c=new s(r);if(c.cmp(i.n)>=0||c.isZero())return 1;let u;try{u=n.sign(e,r,{canonical:!0,k:a,pers:o})}catch(h){return 1}return t.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),t.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),t.recid=u.recoveryParam,0},ecdsaVerify(t,e,r){const a={r:t.subarray(0,32),s:t.subarray(32,64)},c=new s(a.r),u=new s(a.s);if(c.cmp(i.n)>=0||u.cmp(i.n)>=0)return 1;if(1===u.cmp(n.nh)||c.isZero()||u.isZero())return 3;const h=o(r);if(null===h)return 2;const f=h.getPublic();return n.verify(e,a,f)?0:3},ecdsaRecover(t,e,r,o){const c={r:e.slice(0,32),s:e.slice(32,64)},u=new s(c.r),h=new s(c.s);if(u.cmp(i.n)>=0||h.cmp(i.n)>=0)return 1;if(u.isZero()||h.isZero())return 2;let f;try{f=n.recoverPubKey(o,c,r)}catch(l){return 2}return a(t,f),0},ecdh(t,e,r,a,c,u,h){const f=o(e);if(null===f)return 1;const l=new s(r);if(l.cmp(i.n)>=0||l.isZero())return 2;const d=f.getPublic().mul(l);if(void 0===c){const e=d.encode(null,!0),r=n.hash().update(e).digest();for(let n=0;n<32;++n)t[n]=r[n]}else{u||(u=new Uint8Array(32));const e=d.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];h||(h=new Uint8Array(32));const r=d.getY().toArray("be",32);for(let t=0;t<32;++t)h[t]=r[t];const n=c(u,h,a);if(!(n instanceof Uint8Array&&n.length===t.length))return 2;t.set(n)}return 0}}},function(t,e,r){"use strict";var n=e;n.version=r(461).version,n.utils=r(35),n.rand=r(234),n.curve=r(235),n.curves=r(144),n.ec=r(474),n.eddsa=r(478)},function(t){t.exports=JSON.parse('{"_from":"elliptic@^6.5.3","_id":"elliptic@6.5.3","_inBundle":false,"_integrity":"sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==","_location":"/elliptic","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"elliptic@^6.5.3","name":"elliptic","escapedName":"elliptic","rawSpec":"^6.5.3","saveSpec":null,"fetchSpec":"^6.5.3"},"_requiredBy":["/browserify-sign","/create-ecdh","/ethereumjs-block/ethereumjs-util","/ethereumjs-util","/merkle-patricia-tree/ethereumjs-util","/secp256k1","/tiny-secp256k1"],"_resolved":"https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz","_shasum":"cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6","_spec":"elliptic@^6.5.3","_where":"/Users/alex/Documents/Workspaces/ipfs/js-ipfs/node_modules/browserify-sign","author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"bugs":{"url":"https://github.com/indutny/elliptic/issues"},"bundleDependencies":false,"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},"deprecated":false,"description":"EC cryptography","devDependencies":{"brfs":"^1.4.3","coveralls":"^3.0.8","grunt":"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.2","jscs":"^3.0.7","jshint":"^2.10.3","mocha":"^6.2.2"},"files":["lib"],"homepage":"https://github.com/indutny/elliptic","keywords":["EC","Elliptic","curve","Cryptography"],"license":"MIT","main":"lib/elliptic.js","name":"elliptic","repository":{"type":"git","url":"git+ssh://git@github.com/indutny/elliptic.git"},"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","test":"npm run lint && npm run unit","unit":"istanbul test _mocha --reporter=spec test/index.js","version":"grunt dist && git add dist/"},"version":"6.5.3"}')},function(t,e){},function(t,e){},function(t,e,r){"use strict";var n=r(35),i=r(40),s=r(23),o=r(111),a=n.assert;function c(t){o.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(t,e,r,n){o.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function h(t,e,r,n){o.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(c,o),t.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))?r=s[0]:(r=s[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new i(t.a,16),b:new i(t.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),s=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(s).fromRed(),n.redSub(s).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,n,s,o,a,c,u,h,f=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),y=new i(0),g=new i(0),b=new i(1),m=0;0!==l.cmpn(0);){var v=d.div(l);u=d.sub(v.mul(l)),h=g.sub(v.mul(p));var w=b.sub(v.mul(y));if(!n&&u.cmp(f)<0)e=c.neg(),r=p,n=u.neg(),s=h;else if(n&&2==++m)break;c=u,d=l,l=u,g=p,p=h,b=y,y=w}o=u.neg(),a=h;var _=n.sqr().add(s.sqr());return o.sqr().add(a.sqr()).cmp(_)>=0&&(o=e,a=r),n.negative&&(n=n.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:s},{a:o,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),c=i.mul(r.b),u=s.mul(n.b);return{k1:t.sub(o).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=n.fromRed().isOdd();return(e&&!s||!e&&s)&&(n=n.redNeg()),this.point(t,n)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,s=0;s":""},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},u.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(h,o.BasePoint),c.prototype.jpoint=function(t,e,r){return new h(this,t,e,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),h=u.redMul(a),f=n.redMul(u),l=c.redSqr().redIAdd(h).redISub(f).redISub(f),d=c.redMul(f.redISub(l)).redISub(s.redMul(h)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},h.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),u=c.redMul(o),h=r.redMul(c),f=a.redSqr().redIAdd(u).redISub(h).redISub(h),l=a.redMul(h.redISub(f)).redISub(i.redMul(u)),d=this.z.redMul(o);return this.curve.jpoint(f,l,d)},h.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(t,e,r){"use strict";var n=r(40),i=r(23),s=r(111),o=r(35);function a(t){s.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(t,e,r){s.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,s),t.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(c,s.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(o.toArray(t,e),1)},a.prototype.point=function(t,e){return new c(this,t,e)},a.prototype.pointFromJSON=function(t){return c.fromJSON(this,t)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(t,e){return new c(t,e[0],e[1]||t.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(r),o=i.redMul(n),a=e.z.redMul(s.redAdd(o).redSqr()),c=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var s=i.length-1;s>=0;s--)0===i[s]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(t,e,r){"use strict";var n=r(35),i=r(40),s=r(23),o=r(111),a=n.assert;function c(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,o.call(this,"edwards",t),this.a=new i(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function u(t,e,r,n,s){o.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(e,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=s&&new i(s,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(c,o),t.exports=c,c.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},c.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},c.prototype.jpoint=function(t,e,r,n){return this.point(t,e,r,n)},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(e&&!c||!e&&c)&&(a=a.redNeg()),this.point(t,a)},c.prototype.pointFromY=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(0===o.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},c.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),n=e.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===n.cmp(i)},s(u,o.BasePoint),c.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},c.prototype.point=function(t,e,r,n){return new u(this,t,e,r,n)},u.fromJSON=function(t,e){return new u(t,e[0],e[1],e[2])},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=n.redAdd(e),o=s.redSub(r),a=n.redSub(e),c=i.redMul(o),u=s.redMul(a),h=i.redMul(a),f=o.redMul(s);return this.curve.point(c,u,f,h)},u.prototype._projDbl=function(){var t,e,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=(u=this.curve._mulA(i)).redAdd(s);if(this.zOne)t=n.redSub(i).redSub(s).redMul(o.redSub(this.curve.two)),e=o.redMul(u.redSub(s)),r=o.redSqr().redSub(o).redSub(o);else{var a=this.z.redSqr(),c=o.redSub(a).redISub(a);t=n.redSub(i).redISub(s).redMul(c),e=o.redMul(u.redSub(s)),r=o.redMul(c)}}else{var u=i.redAdd(s);a=this.curve._mulC(this.z).redSqr(),c=u.redSub(a).redSub(a);t=this.curve._mulC(n.redISub(u)).redMul(c),e=this.curve._mulC(u).redMul(i.redISub(s)),r=u.redMul(c)}return this.curve.point(t,e,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),o=i.redSub(n),a=i.redAdd(n),c=r.redAdd(e),u=s.redMul(o),h=a.redMul(c),f=s.redMul(c),l=o.redMul(a);return this.curve.point(u,h,l,f)},u.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),c=i.redSub(a),u=i.redAdd(a),h=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),f=n.redMul(c).redMul(h);return this.curve.twisted?(e=n.redMul(u).redMul(o.redSub(this.curve._mulA(s))),r=c.redMul(u)):(e=n.redMul(u).redMul(o.redSub(s)),r=this.curve._mulC(c).redMul(u)),this.curve.point(f,e,r)},u.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},u.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},u.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},u.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(t,e,r){"use strict";e.sha1=r(468),e.sha224=r(469),e.sha256=r(237),e.sha384=r(470),e.sha512=r(238)},function(t,e,r){"use strict";var n=r(38),i=r(84),s=r(236),o=n.rotl32,a=n.sum32,c=n.sum32_5,u=s.ft_1,h=i.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function l(){if(!(this instanceof l))return new l;h.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(l,h),t.exports=l,l.blockSize=512,l.outSize=160,l.hmacStrength=80,l.padLength=64,l.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e0))return o.iaddn(1),this.keyFromPrivate(o)}},f.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},f.prototype.sign=function(t,e,r,s){"object"==typeof r&&(s=r,r=null),s||(s={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var o=this.n.byteLength(),a=e.getPrivate().toArray("be",o),c=t.toArray("be",o),u=new i({hash:this.hash,entropy:a,nonce:c,pers:s.pers,persEnc:s.persEnc||"utf8"}),f=this.n.sub(new n(1)),l=0;;l++){var d=s.k?s.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(f)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var y=p.getX(),g=y.umod(this.n);if(0!==g.cmpn(0)){var b=d.invm(this.n).mul(g.mul(e.getPrivate()).iadd(t));if(0!==(b=b.umod(this.n)).cmpn(0)){var m=(p.getY().isOdd()?1:0)|(0!==y.cmp(g)?2:0);return s.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),m^=1),new h({r:g,s:b,recoveryParam:m})}}}}}},f.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var s=(e=new h(e,"hex")).r,o=e.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,c=o.invm(this.n),u=c.mul(t).umod(this.n),f=c.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),f)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(u,r.getPublic(),f)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},f.prototype.recoverPubKey=function(t,e,r,i){c((3&r)===r,"The recovery param is more than two bits"),e=new h(e,i);var s=this.n,o=new n(t),a=e.r,u=e.s,f=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var d=e.r.invm(s),p=s.sub(o).mul(d).umod(s),y=u.mul(d).umod(s);return this.g.mulAdd(p,a,y)},f.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new h(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch(t){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(t,e,r){"use strict";var n=r(145),i=r(233),s=r(50);function o(t){if(!(this instanceof o))return new o(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");s(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}t.exports=o,o.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},o.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var s=[];s.length"}},function(t,e,r){"use strict";var n=r(40),i=r(35),s=i.assert;function o(t,e){if(t instanceof o)return t;this._importDER(t,e)||(s(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function c(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return!(i<=127)&&(e.place=o,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=o,o.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;var s=c(t,r);if(!1===s)return!1;if(s+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var o=c(t,r);if(!1===o)return!1;var u=t.slice(r.place,o+r.place);if(r.place+=o,2!==t[r.place++])return!1;var h=c(t,r);if(!1===h)return!1;if(t.length!==h+r.place)return!1;var f=t.slice(r.place,h+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},o.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];h(n,e.length),(n=n.concat(e)).push(2),h(n,r.length);var s=n.concat(r),o=[48];return h(o,s.length),o=o.concat(s),i.encode(o,t)}},function(t,e,r){"use strict";var n=r(145),i=r(144),s=r(35),o=s.assert,a=s.parseBytes,c=r(479),u=r(480);function h(t){if(o("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof h))return new h(t);t=i[t].curve;this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}t.exports=h,h.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),s=this.encodePoint(i),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),c=n.add(o).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:s})},h.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(s)},h.prototype.hashInt=function(){for(var t=this.hash(),e=0;e{const c=a[t];if(!c){const e=Object.keys(a).join(" / ");throw n(new Error(`unknown cipher type '${t}'. Must be ${e}`),"ERR_INVALID_CIPHER_TYPE")}if(!e)throw n(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");const u=c.keySize,h=c.ivSize,f=s("key expansion"),l=2*(h+u+20),d=await o.create(e,r);let p=await d.digest(f);const y=[];let g=0;for(;gl&&(e=l-g),y.push(t),g+=e,p=await d.digest(p)}const b=l/2,m=i(y),v=m.slice(0,b),w=m.slice(b,l),_=t=>({iv:t.slice(0,h),cipherKey:t.slice(h,h+u),macKey:t.slice(h+u)});return{k1:_(v),k2:_(w)}}},function(t,e,r){"use strict";t.exports={SHA1:20,SHA256:32,SHA512:64}},function(t,e,r){"use strict";const n=r(484);t.exports=async t=>n.generateEphmeralKeyPair(t)},function(t,e,r){"use strict";const n=r(0),i=r(108),{base64urlToBuffer:s}=r(142),o=r(485),a=r(5),c=r(26),u=r(20),h={"P-256":256,"P-384":384,"P-521":521};e.generateEphmeralKeyPair=async function(t){o(Object.keys(h),t);const e=await i.get().subtle.generateKey({name:"ECDH",namedCurve:t},!0,["deriveBits"]);return{key:l(await i.get().subtle.exportKey("jwk",e.publicKey)),genSharedKey:async(r,n)=>{let s;s=n?await i.get().subtle.importKey("jwk",p(t,n),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):e.privateKey;const o=[await i.get().subtle.importKey("jwk",d(t,r),{name:"ECDH",namedCurve:t},!1,[]),s],a=await i.get().subtle.deriveBits({name:"ECDH",namedCurve:t,public:o[0]},o[1],h[t]);return new Uint8Array(a,a.byteOffset,a.byteLength)}}};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const e=f[t.crv];return c([Uint8Array.from([4]),s(t.x,e),s(t.y,e)],1+2*e)}function d(t,e){const r=f[t];if(u(!e.slice(0,1),Uint8Array.from([4])))throw n(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:t,x:a(e.slice(1,r+1),"base64url"),y:a(e.slice(1+r),"base64url"),ext:!0}}const p=(t,e)=>({...d(t,e.public),d:a(e.private,"base64url")})},function(t,e,r){"use strict";const n=r(0);t.exports=function(t,e){if(!t.includes(e)){const r=t.join(" / ");throw n(new Error(`Unknown curve: ${e}. Must be ${r}`),"ERR_INVALID_CURVE")}}},function(t,e,r){"use strict";const n=r(21);t.exports=n("\n\nmessage PeerIdProto {\n required bytes id = 1;\n bytes pubKey = 2;\n bytes privKey = 3;\n}\n\n")},function(t,e,r){"use strict";const n=r(488),i=r(489);e.create=async function(t,e){const r=i(t),s=n.createCipheriv(r,t,e),o=n.createDecipheriv(r,t,e);return{encrypt:async t=>s.update(t),decrypt:async t=>o.update(t)}}},function(t,e,r){"use strict";r(139);const n=r(8),i=r(5),s=r(6);t.exports={createCipheriv:(t,e,r)=>{const o=n.cipher.createCipher("AES-CTR",i(e,"ascii"));return o.start({iv:i(r,"ascii")}),{update:t=>(o.update(n.util.createBuffer(i(t,"ascii"))),s(o.output.getBytes(),"ascii"))}},createDecipheriv:(t,e,r)=>{const o=n.cipher.createDecipher("AES-CTR",i(e,"ascii"));return o.start({iv:i(r,"ascii")}),{update:t=>(o.update(n.util.createBuffer(i(t,"ascii"))),s(o.output.getBytes(),"ascii"))}}}},function(t,e,r){"use strict";const n=r(0),i={16:"aes-128-ctr",32:"aes-256-ctr"};t.exports=function(t){const e=i[t.length];if(!e){const e=Object.entries(i).map(([t,e])=>`${t} (${e})`).join(" / ");throw n(new Error(`Invalid key length ${t.length} bytes. Must be ${e}`),"ERR_INVALID_KEY_LENGTH")}return e}},function(t,e,r){"use strict";const n=r(229),i=r(22),s=r(0),o={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};t.exports=function(t,e,r,a,c){const u=o[c];if(!u){const t=Object.keys(o).join(" / ");throw s(new Error(`Hash '${c}' is unknown or not supported. Must be ${t}`),"ERR_UNSUPPORTED_HASH_TYPE")}const h=n(t,e,r,a,u);return i.encode64(h)}},function(t,e,r){"use strict";const n=r(492),i=r(146),s=r(15),o=r(26),a=r(5);function c(t){const e=[],r=t.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+t);if(o.path){e.push([s,m(r.slice(n).join("/"))]);break}e.push([s,r[n]])}else e.push([s])}return e}function u(t){const e=[];return t.map(t=>{const r=w(t);e.push(r.name),t.length>1&&e.push(t[1])}),m(e.join("/"))}function h(t){return t.map(t=>{Array.isArray(t)||(t=[t]);const e=w(t);return t.length>1?[e.code,n.toBytes(e.code,t[1])]:[e.code]})}function f(t){return t.map(t=>{const e=w(t);return t.length>1?[e.code,n.toString(e.code,t[1])]:[e.code]})}function l(t){return g(o(t.map(t=>{const e=w(t);let r=Uint8Array.from(s.encode(e.code));return t.length>1&&(r=o([r,t[1]])),r})))}function d(t,e){if(t.size>0)return t.size/8;if(0===t.size)return 0;return s.decode(e)+s.decode.bytes}function p(t){const e=[];let r=0;for(;rt.length)throw v("Invalid address Uint8Array: "+a(t,"base16"));e.push([n,u])}return e}function y(t){return l(h(c(t=m(t))))}function g(t){const e=b(t);if(e)throw e;return Uint8Array.from(t)}function b(t){try{p(t)}catch(e){return e}}function m(t){return"/"+t.trim().split("/").filter(t=>t).join("/")}function v(t){return new Error("Error parsing address: "+t)}function w(t){return i(t[0])}t.exports={stringToStringTuples:c,stringTuplesToString:u,tuplesToStringTuples:f,stringTuplesToTuples:h,bytesToTuples:p,tuplesToBytes:l,bytesToString:function(t){const e=p(t);return u(f(e))},stringToBytes:y,fromString:function(t){return y(t)},fromBytes:g,validateBytes:b,isValidBytes:function(t){return void 0===b(t)},cleanPath:m,ParseError:v,protoFromTuple:w,sizeForAddr:d}},function(t,e,r){"use strict";const n=r(493),i=r(146),s=r(4),o=r(31),a=r(15),c=r(5),u=r(6),h=r(26);function f(t,e){return e instanceof Uint8Array?f.toString(t,e):f.toBytes(t,e)}function l(t){if(!n.isIP(t))throw new Error("invalid ip address");return n.toBytes(t)}function d(t){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function p(t){return new DataView(t.buffer).getUint16(0)}function y(t){const e=t.slice(0,t.length-2),r=t.slice(t.length-2);return c(e,"base32")+":"+p(r)}t.exports=f,f.toString=function(t,e){switch((t=i(t)).code){case 4:case 41:return function(t){const e=n.toString(t);if(!e||!n.isIP(e))throw new Error("invalid ip address");return e}(e);case 6:case 273:case 33:case 132:return p(e);case 53:case 54:case 55:case 56:case 400:case 777:return function(t){const e=a.decode(t);if((t=t.slice(a.decode.bytes)).length!==e)throw new Error("inconsistent lengths");return c(t)}(e);case 421:return function(t){const e=a.decode(t),r=t.slice(a.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return c(r,"base58btc")}(e);case 444:case 445:return y(e);default:return c(e,"base16")}},f.toBytes=function(t,e){switch((t=i(t)).code){case 4:case 41:return l(e);case 6:case 273:case 33:case 132:return d(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return function(t){const e=u(t),r=Uint8Array.from(a.encode(e.length));return h([r,e],r.length+e.length)}(e);case 421:return function(t){const e=new s(t).multihash,r=Uint8Array.from(a.encode(e.length));return h([r,e],r.length+e.length)}(e);case 444:return function(t){const e=t.split(":");if(2!==e.length)throw new Error("failed to parse onion addr: "+e+" does not contain a port number");if(16!==e[0].length)throw new Error("failed to parse onion addr: "+e[0]+" not a Tor onion address.");const r=o.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=d(n);return h([r,i],r.length+i.length)}(e);case 445:return function(t){const e=t.split(":");if(2!==e.length)throw new Error("failed to parse onion addr: "+e+" does not contain a port number");if(56!==e[0].length)throw new Error("failed to parse onion addr: "+e[0]+" not a Tor onion3 address.");const r=o.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=d(n);return h([r,i],r.length+i.length)}(e);default:return u(e,"base16")}}},function(t,e,r){"use strict";const n=r(494),i=r(5),s=n,o=n.v4,a=n.v6,c=function(t,e,r){var n;if(r=~~r,o(t))n=e||new Uint8Array(r+4),t.split(/\./g).map((function(t){n[r++]=255&parseInt(t,10)}));else if(a(t)){var s,u=t.split(":",8);for(s=0;s0;s--)f.push("0");u.splice.apply(u,f)}for(n=e||new Uint8Array(r+16),s=0;s>8&255,n[r++]=255&l}}if(!n)throw Error("Invalid ip address: "+t);return n};t.exports={isIP:s,isV4:o,isV6:a,toBytes:c,toString:function(t,e,r){e=~~e,r=r||t.length-e;var n,i=[];const s=new DataView(t.buffer);if(4===r){for(let n=0;nn({exact:!0}).test(t);i.v4=t=>n.v4({exact:!0}).test(t),i.v6=t=>n.v6({exact:!0}).test(t),i.version=t=>i(t)?i.v4(t)?4:6:void 0,t.exports=i},function(t,e,r){"use strict";const n=t=>t&&t.includeBoundaries?"(?:(?<=\\s|^)(?=[a-fA-F\\d:])|(?<=[a-fA-F\\d:])(?=\\s|$))":"",i="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",s="[a-fA-F\\d]{1,4}",o=`\n(\n(?:${s}:){7}(?:${s}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${s}:){6}(?:${i}|:${s}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${s}:){5}(?::${i}|(:${s}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${s}:){4}(?:(:${s}){0,1}:${i}|(:${s}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${s}:){3}(?:(:${s}){0,2}:${i}|(:${s}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${s}:){2}(?:(:${s}){0,3}:${i}|(:${s}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${s}:){1}(?:(:${s}){0,4}:${i}|(:${s}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::((?::${s}){0,5}:${i}|(?::${s}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),a=t=>t&&t.exact?new RegExp(`(?:^${i}$)|(?:^${o}$)`):new RegExp(`(?:${n(t)}${i}${n(t)})|(?:${n(t)}${o}${n(t)})`,"g");a.v4=t=>t&&t.exact?new RegExp(`^${i}$`):new RegExp(`${n(t)}${i}${n(t)}`,"g"),a.v6=t=>t&&t.exact?new RegExp(`^${o}$`):new RegExp(`${n(t)}${o}${n(t)}`,"g"),t.exports=a},function(t,e,r){"use strict";const n=r(497),i=r(499),{factory:s}=r(83),{fromNumberTo32BitBuf:o}=r(501),a=r(6),c=t=>async e=>{switch(t){case"sha3-224":return new Uint8Array(n.sha3_224.arrayBuffer(e));case"sha3-256":return new Uint8Array(n.sha3_256.arrayBuffer(e));case"sha3-384":return new Uint8Array(n.sha3_384.arrayBuffer(e));case"sha3-512":return new Uint8Array(n.sha3_512.arrayBuffer(e));case"shake-128":return new Uint8Array(n.shake128.create(128).update(e).arrayBuffer());case"shake-256":return new Uint8Array(n.shake256.create(256).update(e).arrayBuffer());case"keccak-224":return new Uint8Array(n.keccak224.arrayBuffer(e));case"keccak-256":return new Uint8Array(n.keccak256.arrayBuffer(e));case"keccak-384":return new Uint8Array(n.keccak384.arrayBuffer(e));case"keccak-512":return new Uint8Array(n.keccak512.arrayBuffer(e));case"murmur3-128":return a(i.x64.hash128(e),"base16");case"murmur3-32":return o(i.x86.hash32(e));default:throw new TypeError(t+" is not a supported algorithm")}};t.exports={identity:t=>t,sha1:s("sha1"),sha2256:s("sha2-256"),sha2512:s("sha2-512"),dblSha2256:s("dbl-sha2-256"),sha3224:c("sha3-224"),sha3256:c("sha3-256"),sha3384:c("sha3-384"),sha3512:c("sha3-512"),shake128:c("shake-128"),shake256:c("shake-256"),keccak224:c("keccak-224"),keccak256:c("keccak-256"),keccak384:c("keccak-384"),keccak512:c("keccak-512"),murmur3128:c("murmur3-128"),murmur332:c("murmur3-32"),addBlake:r(502)}},function(t,e,r){"use strict";(function(n,i){var s;!function(){var o="input is invalid type",a="object"==typeof window,c=a?window:{};c.JS_SHA3_NO_WINDOW&&(a=!1);var u=!a&&"object"==typeof self;!c.JS_SHA3_NO_NODE_JS&&"object"==typeof n&&n.versions&&n.versions.node?c=i:u&&(c=self);var h=!c.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,f=r(498),l=!c.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),p=[4,1024,262144,67108864],y=[0,8,16,24],g=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],b=[224,256,384,512],m=[128,256],v=["hex","buffer","arrayBuffer","array","digest"],w={128:168,256:136};!c.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!l||!c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var _=function(t,e,r){return function(n){return new D(t,e,t).update(n)[r]()}},E=function(t,e,r){return function(n,i){return new D(t,e,i).update(n)[r]()}},S=function(t,e,r){return function(e,n,i,s){return R["cshake"+t].update(e,n,i,s)[r]()}},I=function(t,e,r){return function(e,n,i,s){return R["kmac"+t].update(e,n,i,s)[r]()}},A=function(t,e,r,n){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function L(t,e,r){D.call(this,t,e,r)}D.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var e,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(o);if(null===t)throw new Error(o);if(l&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||l&&ArrayBuffer.isView(t)))throw new Error(o);e=!0}for(var n,i,s=this.blocks,a=this.byteCount,c=t.length,u=this.blockCount,h=0,f=this.s;h>2]|=t[h]<>2]|=i<>2]|=(192|i>>6)<>2]|=(128|63&i)<=57344?(s[n>>2]|=(224|i>>12)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<>2]|=(240|i>>18)<>2]|=(128|i>>12&63)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<=a){for(this.start=n-a,this.block=s[u],n=0;n>=8);r>0;)i.unshift(r),r=255&(t>>=8),++n;return e?i.push(n):i.unshift(n),this.update(i),i.length},D.prototype.encodeString=function(t){var e,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(o);if(null===t)throw new Error(o);if(l&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||l&&ArrayBuffer.isView(t)))throw new Error(o);e=!0}var n=0,i=t.length;if(e)n=i;else for(var s=0;s=57344?n+=3:(a=65536+((1023&a)<<10|1023&t.charCodeAt(++s)),n+=4)}return n+=this.encode(8*n),this.update(t),n},D.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+d[15&t]+d[t>>12&15]+d[t>>8&15]+d[t>>20&15]+d[t>>16&15]+d[t>>28&15]+d[t>>24&15];o%e==0&&(U(r),s=0)}return i&&(t=r[s],a+=d[t>>4&15]+d[15&t],i>1&&(a+=d[t>>12&15]+d[t>>8&15]),i>2&&(a+=d[t>>20&15]+d[t>>16&15])),a},D.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(t);o>8&255,c[t+2]=e>>16&255,c[t+3]=e>>24&255;a%r==0&&U(n)}return s&&(t=a<<2,e=n[o],c[t]=255&e,s>1&&(c[t+1]=e>>8&255),s>2&&(c[t+2]=e>>16&255)),c},L.prototype=new D,L.prototype.finalize=function(){return this.encode(this.outputBits,!0),D.prototype.finalize.call(this)};var U=function(t){var e,r,n,i,s,o,a,c,u,h,f,l,d,p,y,b,m,v,w,_,E,S,I,A,k,T,R,C,B,M,x,N,P,O,D,L,U,j,z,F,K,q,V,H,G,W,$,Y,J,X,Z,Q,tt,et,rt,nt,it,st,ot,at,ct,ut,ht;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],o=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],c=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],h=t[6]^t[16]^t[26]^t[36]^t[46],f=t[7]^t[17]^t[27]^t[37]^t[47],e=(l=t[8]^t[18]^t[28]^t[38]^t[48])^(o<<1|a>>>31),r=(d=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|o>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(c<<1|u>>>31),r=s^(u<<1|c>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=o^(h<<1|f>>>31),r=a^(f<<1|h>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=c^(l<<1|d>>>31),r=u^(d<<1|l>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=h^(i<<1|s>>>31),r=f^(s<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,p=t[0],y=t[1],W=t[11]<<4|t[10]>>>28,$=t[10]<<4|t[11]>>>28,C=t[20]<<3|t[21]>>>29,B=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ct=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,V=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,D=t[3]<<1|t[2]>>>31,b=t[13]<<12|t[12]>>>20,m=t[12]<<12|t[13]>>>20,Y=t[22]<<10|t[23]>>>22,J=t[23]<<10|t[22]>>>22,M=t[33]<<13|t[32]>>>19,x=t[32]<<13|t[33]>>>19,ut=t[42]<<2|t[43]>>>30,ht=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,L=t[14]<<6|t[15]>>>26,U=t[15]<<6|t[14]>>>26,v=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,X=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,N=t[45]<<29|t[44]>>>3,P=t[44]<<29|t[45]>>>3,A=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,j=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,E=t[37]<<21|t[36]>>>11,Q=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,H=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,T=t[18]<<20|t[19]>>>12,R=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,F=t[38]<<8|t[39]>>>24,K=t[39]<<8|t[38]>>>24,S=t[48]<<14|t[49]>>>18,I=t[49]<<14|t[48]>>>18,t[0]=p^~b&v,t[1]=y^~m&w,t[10]=A^~T&C,t[11]=k^~R&B,t[20]=O^~L&j,t[21]=D^~U&z,t[30]=H^~W&Y,t[31]=G^~$&J,t[40]=et^~nt&st,t[41]=rt^~it&ot,t[2]=b^~v&_,t[3]=m^~w&E,t[12]=T^~C&M,t[13]=R^~B&x,t[22]=L^~j&F,t[23]=U^~z&K,t[32]=W^~Y&X,t[33]=$^~J&Z,t[42]=nt^~st&at,t[43]=it^~ot&ct,t[4]=v^~_&S,t[5]=w^~E&I,t[14]=C^~M&N,t[15]=B^~x&P,t[24]=j^~F&q,t[25]=z^~K&V,t[34]=Y^~X&Q,t[35]=J^~Z&tt,t[44]=st^~at&ut,t[45]=ot^~ct&ht,t[6]=_^~S&p,t[7]=E^~I&y,t[16]=M^~N&A,t[17]=x^~P&k,t[26]=F^~q&O,t[27]=K^~V&D,t[36]=X^~Q&H,t[37]=Z^~tt&G,t[46]=at^~ut&et,t[47]=ct^~ht&rt,t[8]=S^~p&b,t[9]=I^~y&m,t[18]=N^~A&T,t[19]=P^~k&R,t[28]=q^~O&L,t[29]=V^~D&U,t[38]=Q^~H&W,t[39]=tt^~G&$,t[48]=ut^~et&nt,t[49]=ht^~rt&it,t[0]^=g[n],t[1]^=g[n+1]};if(h)t.exports=R;else{for(B=0;B255)return!1;return!0}function o(t,e){return(65535&t)*e+(((t>>>16)*e&65535)<<16)}function a(t,e){return t<>>32-e}function c(t){return t=o(t^=t>>>16,2246822507),t=o(t^=t>>>13,3266489909),t^=t>>>16}function u(t,e){t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]],e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]];var r=[0,0,0,0];return r[3]+=t[3]+e[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=t[2]+e[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=t[1]+e[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=t[0]+e[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function h(t,e){t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]],e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]];var r=[0,0,0,0];return r[3]+=t[3]*e[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=t[2]*e[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=t[3]*e[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=t[1]*e[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=t[2]*e[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=t[3]*e[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=t[0]*e[3]+t[1]*e[2]+t[2]*e[1]+t[3]*e[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function f(t,e){return 32===(e%=64)?[t[1],t[0]]:e<32?[t[0]<>>32-e,t[1]<>>32-e]:(e-=32,[t[1]<>>32-e,t[0]<>>32-e])}function l(t,e){return 0===(e%=64)?t:e<32?[t[0]<>>32-e,t[1]<>>1]),t=d(t=h(t,[4283543511,3981806797]),[0,t[0]>>>1]),t=d(t=h(t,[3301882366,444984403]),[0,t[0]>>>1])}i.x86.hash32=function(t,e){if(!i.inputValidation||s(t)){e=e||0;for(var r=t.length%4,n=t.length-r,u=e,h=0,f=3432918353,l=461845907,d=0;d>>0}},i.x86.hash128=function(t,e){if(!i.inputValidation||s(t)){e=e||0;for(var r=t.length%16,n=t.length-r,u=e,h=e,f=e,l=e,d=0,p=0,y=0,g=0,b=597399067,m=2869860233,v=951274213,w=2716044179,_=0;_>>0).toString(16)).slice(-8)+("00000000"+(h>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)+("00000000"+(l>>>0).toString(16)).slice(-8)}},i.x64.hash128=function(t,e){if(!i.inputValidation||s(t)){e=e||0;for(var r=t.length%16,n=t.length-r,o=[0,e],a=[0,e],c=[0,0],y=[0,0],g=[2277735313,289559509],b=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(o[1]>>>0).toString(16)).slice(-8)+("00000000"+(a[0]>>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)}},t.exports&&(e=t.exports=i),e.murmurHash3=i}()},function(t,e,r){"use strict";t.exports={fromNumberTo32BitBuf:t=>{const e=new Uint8Array(4);for(let r=0;r<4;r++)e[r]=255&t,t>>=8;return e}}},function(t,e,r){"use strict";const n=r(503),i={init:n.blake2bInit,update:n.blake2bUpdate,digest:n.blake2bFinal},s={init:n.blake2sInit,update:n.blake2sUpdate,digest:n.blake2sFinal},o=(t,e)=>async r=>{const n=e.init(t,null);return e.update(n,r),e.digest(n)};t.exports=t=>{for(let e=0;e<64;e++)t[45569+e]=o(e+1,i);for(let e=0;e<32;e++)t[45633+e]=o(e+1,s)}},function(t,e,r){"use strict";var n=r(504),i=r(505);t.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:i.blake2s,blake2sHex:i.blake2sHex,blake2sInit:i.blake2sInit,blake2sUpdate:i.blake2sUpdate,blake2sFinal:i.blake2sFinal}},function(t,e,r){"use strict";var n=r(240);function i(t,e,r){var n=t[e]+t[r],i=t[e+1]+t[r+1];n>=4294967296&&i++,t[e]=n,t[e+1]=i}function s(t,e,r,n){var i=t[e]+r;r<0&&(i+=4294967296);var s=t[e+1]+n;i>=4294967296&&s++,t[e]=i,t[e+1]=s}function o(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function a(t,e,r,n,o,a){var c=f[o],u=f[o+1],l=f[a],d=f[a+1];i(h,t,e),s(h,t,c,u);var p=h[n]^h[t],y=h[n+1]^h[t+1];h[n]=y,h[n+1]=p,i(h,r,n),p=h[e]^h[r],y=h[e+1]^h[r+1],h[e]=p>>>24^y<<8,h[e+1]=y>>>24^p<<8,i(h,t,e),s(h,t,l,d),p=h[n]^h[t],y=h[n+1]^h[t+1],h[n]=p>>>16^y<<16,h[n+1]=y>>>16^p<<16,i(h,r,n),p=h[e]^h[r],y=h[e+1]^h[r+1],h[e]=y>>>31^p<<1,h[e+1]=p>>>31^y<<1}var c=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(t){return 2*t}))),h=new Uint32Array(32),f=new Uint32Array(32);function l(t,e){var r=0;for(r=0;r<16;r++)h[r]=t.h[r],h[r+16]=c[r];for(h[24]=h[24]^t.t,h[25]=h[25]^t.t/4294967296,e&&(h[28]=~h[28],h[29]=~h[29]),r=0;r<32;r++)f[r]=o(t.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,u[16*r+0],u[16*r+1]),a(2,10,18,26,u[16*r+2],u[16*r+3]),a(4,12,20,28,u[16*r+4],u[16*r+5]),a(6,14,22,30,u[16*r+6],u[16*r+7]),a(0,10,20,30,u[16*r+8],u[16*r+9]),a(2,12,22,24,u[16*r+10],u[16*r+11]),a(4,14,16,26,u[16*r+12],u[16*r+13]),a(6,8,18,28,u[16*r+14],u[16*r+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^h[r]^h[r+16]}function d(t,e){if(0===t||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(e&&e.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t},n=0;n<16;n++)r.h[n]=c[n];var i=e?e.length:0;return r.h[0]^=16842752^i<<8^t,e&&(p(r,e),r.c=128),r}function p(t,e){for(var r=0;r>2]>>8*(3&r);return e}function g(t,e,r){r=r||64,t=n.normalizeInput(t);var i=d(r,e);return p(i,t),y(i)}t.exports={blake2b:g,blake2bHex:function(t,e,r){var i=g(t,e,r);return n.toHex(i)},blake2bInit:d,blake2bUpdate:p,blake2bFinal:y}},function(t,e,r){"use strict";var n=r(240);function i(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function s(t,e,r,n,i,s){u[t]=u[t]+u[e]+i,u[n]=o(u[n]^u[t],16),u[r]=u[r]+u[n],u[e]=o(u[e]^u[r],12),u[t]=u[t]+u[e]+s,u[n]=o(u[n]^u[t],8),u[r]=u[r]+u[n],u[e]=o(u[e]^u[r],7)}function o(t,e){return t>>>e^t<<32-e}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),u=new Uint32Array(16),h=new Uint32Array(16);function f(t,e){var r=0;for(r=0;r<8;r++)u[r]=t.h[r],u[r+8]=a[r];for(u[12]^=t.t,u[13]^=t.t/4294967296,e&&(u[14]=~u[14]),r=0;r<16;r++)h[r]=i(t.b,4*r);for(r=0;r<10;r++)s(0,4,8,12,h[c[16*r+0]],h[c[16*r+1]]),s(1,5,9,13,h[c[16*r+2]],h[c[16*r+3]]),s(2,6,10,14,h[c[16*r+4]],h[c[16*r+5]]),s(3,7,11,15,h[c[16*r+6]],h[c[16*r+7]]),s(0,5,10,15,h[c[16*r+8]],h[c[16*r+9]]),s(1,6,11,12,h[c[16*r+10]],h[c[16*r+11]]),s(2,7,8,13,h[c[16*r+12]],h[c[16*r+13]]),s(3,4,9,14,h[c[16*r+14]],h[c[16*r+15]]);for(r=0;r<8;r++)t.h[r]^=u[r]^u[r+8]}function l(t,e){if(!(t>0&&t<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=e?e.length:0;if(e&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:t};return n.h[0]^=16842752^r<<8^t,r>0&&(d(n,e),n.c=64),n}function d(t,e){for(var r=0;r>2]>>8*(3&r)&255;return e}function y(t,e,r){r=r||32,t=n.normalizeInput(t);var i=l(r,e);return d(i,t),p(i)}t.exports={blake2s:y,blake2sHex:function(t,e,r){var i=y(t,e,r);return n.toHex(i)},blake2sInit:l,blake2sUpdate:d,blake2sFinal:p}},function(t,e,r){"use strict";const n=r(41);t.exports=({addAll:t})=>async function(e,r){return n(t(e,r))}},function(t,e,r){"use strict";const n=r(147),i=r(538),{parseChunkerString:s}=r(542),{pipe:o}=r(25),{withTimeoutOption:a}=r(2);t.exports=({block:t,gcLock:e,preload:r,pin:c,options:u})=>{const h=u.EXPERIMENTAL&&u.EXPERIMENTAL.sharding;return a((async function*(a,u){u=u||{};const f={shardSplitThreshold:h?1e3:1/0,...u,strategy:"balanced",...s(u.chunker)};if(f.hashAlg&&"sha2-256"!==f.hashAlg&&1!==f.cidVersion&&(f.cidVersion=1),f.trickle&&(f.strategy="trickle"),delete f.trickle,f.progress){let t=0;const e=f.progress;f.progress=r=>{t+=r,e(t)}}const l=o(i(a),e=>n(e,t,{...f,pin:!1}),function(t){return async function*(e){for await(const r of e){let e=r.cid;1===t.cidVersion&&(e=e.toV1());let n=r.path?r.path:e.toString();t.wrapWithDirectory&&!r.path&&(n=""),yield{path:n,cid:e,size:r.size,mode:r.unixfs&&r.unixfs.mode,mtime:r.unixfs&&r.unixfs.mtime}}}}(f),function(t,e){return async function*(r){for await(const n of r){(!n.path||e.wrapWithDirectory?""===n.path:!n.path.includes("/"))&&!e.onlyHash&&!1!==e.preload&&t(n.cid),yield n}}}(r,f),function(t,e){return async function*(r){for await(const n of r){const r=!n.path.includes("/");(null==e.pin||e.pin)&&r&&!e.onlyHash&&await t.add(n.cid,{preload:!1,lock:!1}),yield n}}}(c,f)),d=await e.readLock();try{yield*l}finally{d()}}))}},function(t,e,r){"use strict";const n=r(509),i=r(518);t.exports=async function*(t,e,s){for await(const o of t)if(o.path&&("./"===o.path.substring(0,2)&&(s.wrapWithDirectory=!0),o.path=o.path.split("/").filter(t=>t&&"."!==t).join("/")),o.content){let t,n,a=o.content;(a[Symbol.asyncIterator]||a[Symbol.iterator])&&void 0===a.length||(a={[Symbol.iterator]:function*(){yield o.content}}),t="function"==typeof s.chunker?s.chunker:"rabin"===s.chunker?r(523):r(528),n="function"==typeof s.chunkValidator?s.chunkValidator:r(529),yield()=>i(o,t(n(a,s),s),e,s)}else yield()=>n(o,e,s)}},function(t,e,r){"use strict";const n=r(29),i=r(62),{DAGNode:s}=r(16);t.exports=async(t,e,r)=>{const o=new n({type:"directory",mtime:t.mtime,mode:t.mode}),a=new s(o.marshal()).serialize();return{cid:await i(a,e,r),path:t.path,unixfs:o,size:a.length}}},function(t,e,r){"use strict";t.exports='\nsyntax = "proto2";\n\nmessage Data {\n enum DataType {\n Raw = 0;\n Directory = 1;\n File = 2;\n Metadata = 3;\n Symlink = 4;\n HAMTShard = 5;\n }\n\n required DataType Type = 1;\n optional bytes Data = 2;\n optional uint64 filesize = 3;\n repeated uint64 blocksizes = 4;\n optional uint64 hashType = 5;\n optional uint64 fanout = 6;\n optional uint32 mode = 7;\n optional UnixTime mtime = 8;\n}\n\nmessage UnixTime {\n required int64 Seconds = 1;\n optional fixed32 FractionalNanoseconds = 2;\n}\n\nmessage Metadata {\n optional string MimeType = 1;\n}\n'},function(t,e,r){"use strict";t.exports=r(242)},function(t,e,r){"use strict";t.exports=function(){var t=function(t,r){return e(t.slice(),r)};function e(t,e){"function"!=typeof e&&(e=function(t,e){return String(t).localeCompare(e)});var n=t.length;if(n<=1)return t;for(var i=new Array(n),s=1;su&&(s=u),o>u&&(o=u),a=i,c=s;;)if(a{const r=await i.cid(t.serialize(),e);return new n(e.name||"",t.size,r)}},function(t,e,r){"use strict";const n=r(243),i=r(247);t.exports=(t,e)=>{const r=(t=>{if(i.isDAGLink(t))return t;if(!("cid"in t||"hash"in t||"Hash"in t||"multihash"in t))throw new Error("Link must be a DAGLink or DAGLink-like. Convert the DAGNode into a DAGLink via `node.toDAGLink()`.");return new i(t.Name||t.name,t.Tsize||t.size,t.Hash||t.multihash||t.hash||t.cid)})(e);t.Links.push(r),n(t.Links)}},function(t,e,r){"use strict";const n=r(63);t.exports.createDagLinkFromB58EncodedHash=function(t){return new n(t.Name||t.name||"",t.Tsize||t.Size||t.size||0,t.Hash||t.hash||t.multihash||t.cid)}},function(t,e,r){"use strict";const n=r(4),i=r(20);t.exports=(t,e)=>{let r=null;if("string"==typeof e?r=t=>t.Name===e:(e instanceof Uint8Array||n.isCID(e))&&(r=t=>i(t.Hash,e)),!r)throw new Error("second arg needs to be a name or CID");{const e=t.Links;let n=0;for(;n{let r=i.deserialize(t);const s=e.split("/").filter(Boolean);for(;s.length;){const t=s.shift();if(void 0===r[t]){for(const e of r.Links)if(e.Name===t)return{value:e.Hash,remainderPath:s.join("/")};throw new Error(`Object has no property '${t}'`)}if(r=r[t],n.isCID(r))return{value:r,remainderPath:s.join("/")}}return{value:r,remainderPath:""}},e.tree=function*(t){const e=i.deserialize(t);yield"Data",yield"Links";for(let r=0;r{const p=f[d.strategy];if(!p)throw n(new Error("Unknown importer build strategy name: "+d.strategy),"ERR_BAD_STRATEGY");const y=await c(p(async function*(t,e,n,i){let s,o,a=-1;o="function"==typeof i.bufferImporter?i.bufferImporter:r(522);for await(const r of u(o(t,e,n,i),i.blockWriteConcurrency))a++,0!==a?(1===a&&(yield s,s=null),yield r):s=r;s&&(s.single=!0,yield s)}(t,e,l,d),((t,e,r)=>async function(n){if(1===n.length&&n[0].single&&r.reduceSingleLeafToSelf){const a=n[0];if("raw"===a.cid.codec&&(void 0!==t.mtime||void 0!==t.mode)){let{data:n}=await e.get(a.cid,r);a.unixfs=new i({type:"file",mtime:t.mtime,mode:t.mode,data:n});const c=h.decode(a.cid.multihash);n=new o(a.unixfs.marshal()).serialize(),a.cid=await s(n,e,{...r,codec:"dag-pb",hashAlg:c.name,cidVersion:r.cidVersion}),a.size=n.length}return{cid:a.cid,path:t.path,unixfs:a.unixfs,size:a.size}}const c=new i({type:"file",mtime:t.mtime,mode:t.mode}),u=n.filter(t=>!("raw"!==t.cid.codec||!t.size)||(!(t.unixfs.data||!t.unixfs.fileSize())||Boolean(t.unixfs.data.length))).map(t=>"raw"===t.cid.codec?(c.addBlockSize(t.size),new a(t.name,t.size,t.cid)):(t.unixfs.data?c.addBlockSize(t.unixfs.data.length):c.addBlockSize(t.unixfs.fileSize()),new a(t.name,t.size,t.cid))),f=new o(c.marshal(),u),l=f.serialize();return{cid:await s(l,e,r),path:t.path,unixfs:c,size:l.length+f.Links.reduce((t,e)=>t+e.Tsize,0)}})(t,l,d),d));if(y.length>1)throw n(new Error("expected a maximum of 1 roots and got "+y.length),"ETOOMANYROOTS");return y[0]}},function(t,e,r){"use strict";const n=r(86);t.exports=async function*(t,e){yield await e(await n(t))}},function(t,e,r){"use strict";const n=r(148);t.exports=async function*(t,e,r){yield await async function t(e,r,i){const s=[];for await(const o of n(e,i.maxChildrenPerNode))s.push(await r(o));if(s.length>1)return t(s,r,i);return s[0]}(t,e,r)}},function(t,e,r){"use strict";const n=r(148);t.exports=function*(t,e,r){yield async function(t,e,r){let o,a=0,c=1,u=o=new s(r.layerRepeat);for await(const s of n(t,r.maxChildrenPerNode))u.isFull()&&(u!==o&&o.addChild(await u.reduce(e)),a&&a%r.layerRepeat==0&&c++,u=new i(c,r.layerRepeat,a),a++),u.append(s);u&&u!==o&&o.addChild(await u.reduce(e));return o.reduce(e)}(t,e,r)};class i{constructor(t,e,r){this.maxDepth=t,this.layerRepeat=e,this.currentDepth=1,this.iteration=r,this.root=this.node=this.parent={children:[],depth:this.currentDepth,maxDepth:t,maxChildren:(this.maxDepth-this.currentDepth)*this.layerRepeat}}isFull(){if(!this.root.data)return!1;if(this.currentDeptht.data).map(t=>this._reduce(t,e)))),e(t.data.concat(r))}_findParent(t,e){const r=t.parent;if(r&&0!==r.depth)return r.children.length!==r.maxChildren&&r.maxChildren?r:this._findParent(r,e)}}class s extends i{constructor(t){super(0,t),this.root.depth=0,this.currentDepth=1}addChild(t){this.root.children.push(t)}reduce(t){return t(this.root.data.concat(this.root.children))}}},function(t,e,r){"use strict";const n=r(29),i=r(62),{DAGNode:s}=r(16);t.exports=async function*(t,e,r,o){for await(let a of e)yield async()=>{let e;o.progress(a.length);const c={...o};return o.rawLeaves?(c.codec="raw",c.cidVersion=1):(e=new n({type:o.leafType,data:a,mtime:t.mtime,mode:t.mode}),a=new s(e.marshal()).serialize()),{cid:await i(a,r,c),unixfs:e,size:a.length}}}},function(t,e,r){"use strict";const n=r(36),{create:i}=r(524),s=r(0);t.exports=async function*(t,e){const r=o();let n,i,a;if(e.minChunkSize&&e.maxChunkSize&&e.avgChunkSize)a=e.avgChunkSize,n=e.minChunkSize,i=e.maxChunkSize;else{if(!e.avgChunkSize)throw s(new Error("please specify an average chunk size"),"ERR_INVALID_AVG_CHUNK_SIZE");a=e.avgChunkSize,n=a/3,i=a+a/2}if(n<16)throw s(new Error("rabin min must be greater than 16"),"ERR_INVALID_MIN_CHUNK_SIZE");iasync function*(t,e){const r=await i(e.bits,e.min,e.max,e.window),s=new n;for await(const n of t){s.append(n);const t=r.fingerprint(n);for(let e=0;e{const a=await i();return new n(a,t,e,r,s,o)}}},function(t,e,r){"use strict";t.exports=class{constructor(t,e=12,r=8192,n=32768,i=64,s){this.bits=e,this.min=r,this.max=n,this.asModule=t,this.rabin=new t.Rabin(e,r,n,i,s),this.polynomial=s}fingerprint(t){const{__retain:e,__release:r,__allocArray:n,__getInt32Array:i,Int32Array_ID:s,Uint8Array_ID:o}=this.asModule,a=e(n(s,new Int32Array(Math.ceil(t.length/this.min)))),c=e(n(o,t)),u=i(this.rabin.fingerprint(c,a));r(c),r(a);const h=[];for(let f=0;f>>2]>>>1,s=e>>>1;if(i<=1024)return String.fromCharCode.apply(String,n.subarray(s,s+i));const o=[];do{const t=n[s+1024-1],e=t>=55296&&t<56320?1023:1024;o.push(String.fromCharCode.apply(String,n.subarray(s,s+=e))),i-=e}while(i>1024);return o.join("")+String.fromCharCode.apply(String,n.subarray(s,s+i))}function o(t){const e={};function r(t,e){return t?s(t.buffer,e):""}const n=t.env=t.env||{};return n.abort=n.abort||function(t,i,s,o){const a=e.memory||n.memory;throw Error("abort: "+r(a,t)+" at "+r(a,i)+":"+s+":"+o)},n.trace=n.trace||function(t,i){const s=e.memory||n.memory;console.log("trace: "+r(s,t)+(i?" ":"")+Array.prototype.slice.call(arguments,2,2+i).join(", "))},t.Math=t.Math||Math,t.Date=t.Date||Date,e}function a(t,e){const r=e.exports,i=r.memory,o=r.table,a=r.__alloc,c=r.__retain,u=r.__rtti_base||-1;function h(t){const e=new Uint32Array(i.buffer);if((t>>>=0)>=e[u>>>2])throw Error("invalid id: "+t);return e[(u+4>>>2)+2*t]}function l(t){const e=new Uint32Array(i.buffer);if((t>>>=0)>=e[u>>>2])throw Error("invalid id: "+t);return e[(u+4>>>2)+2*t+1]}function d(t){return 31-Math.clz32(t>>>5&31)}function p(t,e,r){const n=i.buffer;if(r)switch(t){case 2:return new Float32Array(n);case 3:return new Float64Array(n)}else switch(t){case 0:return new(e?Int8Array:Uint8Array)(n);case 1:return new(e?Int16Array:Uint16Array)(n);case 2:return new(e?Int32Array:Uint32Array)(n);case 3:return new(e?BigInt64Array:BigUint64Array)(n)}throw Error("unsupported align: "+t)}function y(t){const e=new Uint32Array(i.buffer),r=e[t+-8>>>2],n=h(r);if(!(1&n))throw Error("not an array: "+r);const s=d(n);var o=e[t+4>>>2];const a=2&n?e[t+12>>>2]:e[o+-4>>>2]>>>s;return p(s,1024&n,2048&n).subarray(o>>>=s,o+a)}function g(t,e,r){return new t(b(t,e,r))}function b(t,e,r){const n=i.buffer,s=new Uint32Array(n),o=s[r+4>>>2];return new t(n,o,s[o+-4>>>2]>>>e)}return t.__allocString=function(t){const e=t.length,r=a(e<<1,1),n=new Uint16Array(i.buffer);for(var s=0,o=r>>>1;s>>2])throw Error("not a string: "+t);return s(e,t)},t.__allocArray=function(t,e){const r=h(t);if(!(3&r))throw Error("not an array: "+t+" @ "+r);const n=d(r),s=e.length,o=a(s<>>2]=c(o),f[u+4>>>2]=o,f[u+8>>>2]=s<>>2]=s);const l=p(n,1024&r,2048&r);if(8192&r)for(let i=0;i>>n)+i]=c(e[i]);else l.set(e,o>>>n);return u},t.__getArrayView=y,t.__getArray=function(t){const e=y(t),r=e.length,n=new Array(r);for(let i=0;i>>2];return e.slice(t,t+r)},t.__getInt8Array=g.bind(null,Int8Array,0),t.__getInt8ArrayView=b.bind(null,Int8Array,0),t.__getUint8Array=g.bind(null,Uint8Array,0),t.__getUint8ArrayView=b.bind(null,Uint8Array,0),t.__getUint8ClampedArray=g.bind(null,Uint8ClampedArray,0),t.__getUint8ClampedArrayView=b.bind(null,Uint8ClampedArray,0),t.__getInt16Array=g.bind(null,Int16Array,1),t.__getInt16ArrayView=b.bind(null,Int16Array,1),t.__getUint16Array=g.bind(null,Uint16Array,1),t.__getUint16ArrayView=b.bind(null,Uint16Array,1),t.__getInt32Array=g.bind(null,Int32Array,2),t.__getInt32ArrayView=b.bind(null,Int32Array,2),t.__getUint32Array=g.bind(null,Uint32Array,2),t.__getUint32ArrayView=b.bind(null,Uint32Array,2),n&&(t.__getInt64Array=g.bind(null,BigInt64Array,3),t.__getInt64ArrayView=b.bind(null,BigInt64Array,3),t.__getUint64Array=g.bind(null,BigUint64Array,3),t.__getUint64ArrayView=b.bind(null,BigUint64Array,3)),t.__getFloat32Array=g.bind(null,Float32Array,2),t.__getFloat32ArrayView=b.bind(null,Float32Array,2),t.__getFloat64Array=g.bind(null,Float64Array,3),t.__getFloat64ArrayView=b.bind(null,Float64Array,3),t.__instanceof=function(t,e){const r=new Uint32Array(i.buffer);var n=r[t+-8>>>2];if(n<=r[u>>>2])do{if(n==e)return!0}while(n=l(n));return!1},t.memory=t.memory||i,t.table=t.table||o,f(r,t)}function c(t){return"undefined"!=typeof Response&&t instanceof Response}async function u(t,e){return c(t=await t)?h(t,e):a(o(e||(e={})),await WebAssembly.instantiate(t instanceof WebAssembly.Module?t:await WebAssembly.compile(t),e))}async function h(t,e){return WebAssembly.instantiateStreaming?a(o(e||(e={})),(await WebAssembly.instantiateStreaming(t,e)).instance):u(c(t=await t)?t.arrayBuffer():t,e)}function f(t,e){var r=e?Object.create(e):{},n=t.__argumentsLength?function(e){t.__argumentsLength.value=e}:t.__setArgumentsLength||t.__setargc||function(){};for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const e=t[s];let o=s.split("."),a=r;for(;o.length>1;){let t=o.shift();Object.prototype.hasOwnProperty.call(a,t)||(a[t]={}),a=a[t]}let c=o[0],u=c.indexOf("#");if(u>=0){let r=c.substring(0,u),o=a[r];if(void 0===o||!o.prototype){let t=function(...e){return t.wrap(t.prototype.constructor(0,...e))};t.prototype={valueOf:function(){return this[i]}},t.wrap=function(e){return Object.create(t.prototype,{[i]:{value:e,writable:!1}})},o&&Object.getOwnPropertyNames(o).forEach(e=>Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))),a[r]=t}if(c=c.substring(u+1),a=a[r].prototype,/^(get|set):/.test(c)){if(!Object.prototype.hasOwnProperty.call(a,c=c.substring(4))){let e=t[s.replace("set:","get:")],r=t[s.replace("get:","set:")];Object.defineProperty(a,c,{get:function(){return e(this[i])},set:function(t){r(this[i],t)},enumerable:!0})}}else"constructor"===c?(a[c]=(...t)=>(n(t.length),e(...t))).original=e:(a[c]=function(...t){return n(t.length),e(this[i],...t)}).original=e}else/^(get|set):/.test(c)?Object.prototype.hasOwnProperty.call(a,c=c.substring(4))||Object.defineProperty(a,c,{get:t[s.replace("set:","get:")],set:t[s.replace("get:","set:")],enumerable:!0}):"function"==typeof e&&e!==n?(a[c]=(...t)=>(n(t.length),e(...t))).original=e:a[c]=e}return r}e.instantiate=u,e.instantiateSync=function(t,e){return a(o(e||(e={})),new WebAssembly.Instance(t instanceof WebAssembly.Module?t:new WebAssembly.Module(t),e))},e.instantiateStreaming=h,e.demangle=f},function(t,e,r){"use strict";const n=r(36);t.exports=async function*(t,e){let r=new n,i=0,s=!1;const o=e.maxChunkSize;for await(const a of t)for(r.append(a),i+=a.length;i>=o;)if(yield r.slice(0,o),s=!0,o===r.length)r=new n,i=0;else{const t=new n;t.append(r.shallowSlice(o)),r=t,i-=o}s&&!i||(yield r.slice(0,i))}},function(t,e,r){"use strict";const n=r(0),i=r(6);t.exports=async function*(t){for await(const e of t){if(void 0===e.length)throw n(new Error("Content was invalid"),"ERR_INVALID_CONTENT");"string"==typeof e||e instanceof String?yield i(e):Array.isArray(e)?yield Uint8Array.from(e):yield e}}},function(t,e,r){"use strict";const n=r(531),i=r(532),s=r(150),o=r(537),a=r(0),c=r(153);async function u(t,e,r){const a=o(t.path||""),c=a.length-1;let u=e,h="";for(let o=0;o1)throw a(new Error("detected more than one root"),"ERR_MORE_THAN_ONE_ROOT");const t=await c(i.eachChildSeries());if(!t)return;i=t.child}i instanceof s?yield*i.flush(i.path,e):i&&i.unixfs&&i.unixfs.isDirectory()&&(yield i)}},function(t,e,r){"use strict";const{DAGLink:n,DAGNode:i}=r(16),s=r(29),o=r(150),a=r(62);t.exports=class extends o{constructor(t,e){super(t,e),this._children={}}put(t,e){this.cid=void 0,this.size=void 0,this._children[t]=e}get(t){return this._children[t]}childCount(){return Object.keys(this._children).length}directChildrenCount(){return this.childCount()}onlyChild(){return this._children[Object.keys(this._children)[0]]}*eachChildSeries(){const t=Object.keys(this._children);for(let e=0;et+e.Tsize,0);this.cid=f,this.size=l,yield{cid:f,unixfs:c,path:t,size:l}}}},function(t,e,r){"use strict";const n=r(151);t.exports=async function t(e,r,i,s){let o=r;r.flat&&r.directChildrenCount()>=i&&(o=await async function(t,e){const r=new n({root:t.root,dir:!0,parent:t.parent,parentKey:t.parentKey,path:t.path,dirty:t.dirty,flat:!1,mtime:t.mtime,mode:t.mode},e);for await(const{key:n,child:i}of t.eachChildSeries())await r.put(n,i);return r}(r,s));const a=o.parent;return a?(o!==r&&(e&&(e.parent=o),await a.put(o.parentKey,o)),t(o,a,i,s)):o}},function(t,e,r){"use strict";const n=r(152);t.exports=function(t){return new n(t)},t.exports.isBucket=n.isBucket},function(t,e,r){"use strict";function n(t,e){return t+i(e)}function i(t){let e=t;return e-=e>>1&1431655765,e=(858993459&e)+(e>>2&858993459),16843009*(e+(e>>4)&252645135)>>24}function s(t,e){return t[0]-e[0]}function o(t){return t[1]}t.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(t,e){let r=this._internalPositionFor(t,!1);if(void 0===e)-1!==r&&(this._unsetInternalPos(r),this._unsetBit(t),this._changedLength=!0,this._changedData=!0);else{let n=!1;-1===r?(r=this._data.length,this._setBit(t),this._changedData=!0):n=!0,this._setInternalPos(r,t,e,n),this._changedLength=!0}}unset(t){this.set(t,void 0)}get(t){this._sortData();const e=this._internalPositionFor(t,!0);if(-1!==e)return this._data[e][1]}push(t){return this.set(this.length,t),this.length}get length(){if(this._sortData(),this._changedLength){const t=this._data[this._data.length-1];this._length=t?t[0]+1:0,this._changedLength=!1}return this._length}forEach(t){let e=0;for(;e=this._bitArrays.length)return-1;const s=this._bitArrays[r],o=t-7*r;if(!((s&1<0))return-1;return this._bitArrays.slice(0,r).reduce(n,0)+i(s&~(4294967295<=e)i.push(s);else if(i[0][0]<=e)i.unshift(s);else{const t=Math.round(i.length/2);this._data=i.slice(0,t).concat(s).concat(i.slice(t))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(t){this._data.splice(t,1)}_sortData(){this._changedData&&this._data.sort(s),this._changedData=!1}bitField(){const t=[];let e,r=8,n=0,i=0;const s=this._bitArrays.slice();for(;s.length||n;){0===n&&(e=s.shift(),n=7);const o=Math.min(n,r);i|=(e&~(255<>>=o,n-=o,r-=o,r&&(n||s.length)||(t.push(i),i=0,r=8)}for(var o=t.length-1;o>0;o--){if(0!==t[o])break;t.pop()}return t}compactArray(){return this._sortData(),this._data.map(o)}}},function(t,e,r){"use strict";(function(e){const n=r(536);t.exports=function(t){return function(e){return e instanceof i?e:new i(e,t)}};class i{constructor(t,r){if("string"!=typeof t&&!e.isBuffer(t))throw new Error("can only hash strings or buffers");this._value=t,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(t){let e=t;for(;this._availableBits0;){const t=this._buffers[this._currentBufferIndex],n=Math.min(t.availableBits(),e);r=(r<0;){const t=this._buffers[this._currentBufferIndex],r=Math.min(t.totalBits()-t.availableBits(),e);t.untake(r),e-=r,this._availableBits+=r,this._currentBufferIndex>0&&t.totalBits()===t.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;const t=this._depth?this._value+this._depth:this._value,e=await this._hashFn(t),r=new n(e);this._buffers.push(r),this._availableBits+=r.availableBits()}}}).call(this,r(3).Buffer)},function(t,e,r){"use strict";const n=[255,254,252,248,240,224,192,128],i=[1,3,7,15,31,63,127,255];function s(t,e,r){return(t&function(t,e){return n[t]&i[Math.min(e+t-1,7)]}(e,r))>>>e}t.exports=class{constructor(t){this._value=t,this._currentBytePos=t.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(t){let e=t,r=0;for(;e&&this._haveBits();){const t=this._value[this._currentBytePos],n=this._currentBitPos+1,i=Math.min(n,e);r=(r<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}},function(t,e,r){"use strict";t.exports=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean)},function(t,e,r){"use strict";const n=r(539),i=r(541);t.exports=t=>i(t,n)},function(t,e,r){"use strict";const n=r(0),i=r(6),s=r(154),o=r(540),a=r(249),c=r(86),u=r(155),{isBytes:h,isBlob:f}=r(250);function l(t){return h(t)?t:Array.isArray(t)?Uint8Array.from(t):i(t)}t.exports=async function*(t){if(h(t)||"string"==typeof t||t instanceof String)yield l(t);else{if(!f(t)){if("function"==typeof t.getReader&&(t=s(t)),t[Symbol.iterator]||t[Symbol.asyncIterator]){const e=a(t),{value:r,done:n}=await e.peek();if(n)return void(yield*e);if(e.push(r),Number.isInteger(r))return void(yield l(await c(e)));if(h(r)||"string"==typeof r||r instanceof String)return void(yield*u(e,t=>l(t)))}throw n(new Error("Unexpected input: "+t),"ERR_UNEXPECTED_INPUT")}yield*o(t)}}},function(t,e,r){"use strict";const n=r(154);t.exports=function(t){return"function"==typeof t.stream?n(t.stream()):n(new Response(t).body)}},function(t,e,r){"use strict";const n=r(0),i=r(154),s=r(249),o=r(155),{isBytes:a,isBlob:c,isFileObject:u}=r(250);async function h(t,e){const r={path:t.path||"",mode:t.mode,mtime:t.mtime};return t.content?r.content=await e(t.content):t.path||(r.content=await e(t)),r}t.exports=async function*(t,e){if(null==t)throw n(new Error("Unexpected input: "+t),"ERR_UNEXPECTED_INPUT");if("string"==typeof t||t instanceof String)yield h(t,e);else if(a(t)||c(t))yield h(t,e);else{if("function"==typeof t.getReader&&(t=i(t)),t[Symbol.iterator]||t[Symbol.asyncIterator]){const r=s(t),{value:n,done:i}=await r.peek();if(i)return void(yield*r);if(r.push(n),Number.isInteger(n)||a(n))return void(yield h(r,e));if(u(n)||c(n)||"string"==typeof n||n instanceof String)return void(yield*o(r,t=>h(t,e)));if(n[Symbol.iterator]||n[Symbol.asyncIterator]||"function"==typeof n.getReader)return void(yield*o(r,t=>h(t,e)))}if(!u(t))throw n(new Error("Unexpected input: "+typeof t),"ERR_UNEXPECTED_INPUT");yield h(t,e)}}},function(t,e,r){"use strict";const n=t=>{const e={},r=t.split("-");switch(r.length){case 1:e.avgChunkSize=262144;break;case 2:e.avgChunkSize=i(r[1],"avg");break;case 4:e.minChunkSize=i(r[1],"min"),e.avgChunkSize=i(r[2],"avg"),e.maxChunkSize=i(r[3],"max");break;default:throw new Error('Incorrect chunker format (expected "rabin" "rabin-[avg]" or "rabin-[min]-[avg]-[max]"')}return e},i=(t,e)=>{const r=parseInt(t);if(isNaN(r))throw new Error(`Chunker parameter ${e} must be an integer`);return r};t.exports={parseChunkSize:i,parseRabinString:n,parseChunkerString:t=>{if(t){if(t.startsWith("size-")){const e=t.split("-")[1],r=parseInt(e);if(isNaN(r))throw new Error("Chunker parameter size must be an integer");return{chunker:"fixed",maxChunkSize:r}}if(t.startsWith("rabin"))return{chunker:"rabin",...n(t)};throw new Error("Unrecognized chunker option: "+t)}return{chunker:"fixed"}}}},function(t,e,r){"use strict";t.exports=function(){return Date.now()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.urlAlphabet=void 0;e.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"},function(t,e,r){"use strict";const{nanoid:n}=r(253);t.exports=(t=(t=>t))=>t(n())},function(t,e,r){"use strict";t.exports=r(254).TextEncoder},function(t,e,r){"use strict";const n=r(252),i=r(256),s=r(258);t.exports=class extends i{constructor(){super(),this.data={}}async put(t,e){this.data[t.toString()]=e}async get(t){if(!await this.has(t))throw s.notFoundError();return this.data[t.toString()]}async has(t){return void 0!==this.data[t.toString()]}async delete(t){delete this.data[t.toString()]}*_all(){yield*Object.entries(this.data).map(([t,e])=>({key:new n(t),value:e}))}}},function(t,e,r){"use strict";const{cleanCid:n}=r(159),{withTimeoutOption:i}=r(2);t.exports=({blockService:t,preload:e})=>i((async function(r,i){return i=i||{},r=n(r),!1!==i.preload&&e(r),t.get(r,i)}))},function(t,e,r){"use strict";const n=r(87),i=r(13),s=r(4),o=r(51),{withTimeoutOption:a}=r(2);t.exports=({blockService:t,pin:e,gcLock:r,preload:c})=>a((async function(a,u){if(u=u||{},Array.isArray(a))throw new Error("Array is not supported");if(!n.isBlock(a))if(u.cid&&o.cid(u.cid))a=new n(a,s.isCID(u.cid)?u.cid:new s(u.cid));else{const t=u.mhtype||"sha2-256",e=u.format||"dag-pb";let r;r=null==u.version?"sha2-256"===t&&"dag-pb"===e?0:1:u.version;const o=await i(a,t),c=new s(r,e,o);a=new n(a,c)}const h=await r.readLock();try{return await t.put(a,{signal:u.signal}),!1!==u.preload&&c(a.cid),!0===u.pin&&await e.add(a.cid,{recursive:!0,signal:u.signal}),a}finally{h()}}))},function(t,e,r){"use strict";const n=r(4),i=r(0),{parallelMap:s,filter:o}=r(52),{pipe:a}=r(25),{PinTypes:c}=r(88),{cleanCid:u}=r(159),{withTimeoutOption:h}=r(2);t.exports=({blockService:t,gcLock:e,pinManager:r})=>h((async function*(h,f){f=f||{},Array.isArray(h)||(h=[h]);const l=await e.writeLock();try{yield*a(h,s(8,async e=>{const s={cid:e=u(e)};try{const s=await r.isPinnedWithType(e,c.all);if(s.pinned){if(n.isCID(s.reason))throw i(new Error("pinned via "+s.reason));throw i(new Error("pinned: "+s.reason))}if(!await t._repo.blocks.has(e))throw i(new Error("block not found"),"ERR_BLOCK_NOT_FOUND");await t.delete(e)}catch(o){f.force||(o.message=`cannot remove ${e}: ${o.message}`,s.error=o)}return s}),o(()=>!f.quiet))}finally{l()}}))},function(t,e,r){"use strict";(function(e){const n=r(160).util,i=r(4),s=(t,r=[])=>(e.isBuffer(t)&&(t=n.deserialize(t)),function*(){for(let e of Object.keys(t)){let n=r.slice();n.push(e);let o=t[e];if(o&&"object"==typeof o)if(Array.isArray(o))for(let t=0;te?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}t.exports=o},function(t,e,r){"use strict";t.exports=function(t,e,r){"use asm";var n=new t.Uint8Array(r);var i=e.pushInt;var s=e.pushInt32;var o=e.pushInt32Neg;var a=e.pushInt64;var c=e.pushInt64Neg;var u=e.pushFloat;var h=e.pushFloatSingle;var f=e.pushFloatDouble;var l=e.pushTrue;var d=e.pushFalse;var p=e.pushUndefined;var y=e.pushNull;var g=e.pushInfinity;var b=e.pushInfinityNeg;var m=e.pushNaN;var v=e.pushNaNNeg;var w=e.pushArrayStart;var _=e.pushArrayStartFixed;var E=e.pushArrayStartFixed32;var S=e.pushArrayStartFixed64;var I=e.pushObjectStart;var A=e.pushObjectStartFixed;var k=e.pushObjectStartFixed32;var T=e.pushObjectStartFixed64;var R=e.pushByteString;var C=e.pushByteStringStart;var B=e.pushUtf8String;var M=e.pushUtf8StringStart;var x=e.pushSimpleUnassigned;var N=e.pushTagStart;var P=e.pushTagStart4;var O=e.pushTagStart8;var D=e.pushTagUnassigned;var L=e.pushBreak;var U=t.Math.pow;var j=0;var z=0;var F=0;function K(t){t=t|0;j=0;z=t;while((j|0)<(z|0)){F=Jt[n[j]&255](n[j]|0)|0;if((F|0)>0){break}}return F|0}function q(t){t=t|0;if(((j|0)+(t|0)|0)<(z|0)){return 0}return 1}function V(t){t=t|0;return n[t|0]<<8|n[t+1|0]|0}function H(t){t=t|0;return n[t|0]<<24|n[t+1|0]<<16|n[t+2|0]<<8|n[t+3|0]|0}function G(t){t=t|0;i(t|0);j=j+1|0;return 0}function W(t){t=t|0;if(q(1)|0){return 1}i(n[j+1|0]|0);j=j+2|0;return 0}function $(t){t=t|0;if(q(2)|0){return 1}i(V(j+1|0)|0);j=j+3|0;return 0}function Y(t){t=t|0;if(q(4)|0){return 1}s(V(j+1|0)|0,V(j+3|0)|0);j=j+5|0;return 0}function J(t){t=t|0;if(q(8)|0){return 1}a(V(j+1|0)|0,V(j+3|0)|0,V(j+5|0)|0,V(j+7|0)|0);j=j+9|0;return 0}function X(t){t=t|0;i(-1-(t-32|0)|0);j=j+1|0;return 0}function Z(t){t=t|0;if(q(1)|0){return 1}i(-1-(n[j+1|0]|0)|0);j=j+2|0;return 0}function Q(t){t=t|0;var e=0;if(q(2)|0){return 1}e=V(j+1|0)|0;i(-1-(e|0)|0);j=j+3|0;return 0}function tt(t){t=t|0;if(q(4)|0){return 1}o(V(j+1|0)|0,V(j+3|0)|0);j=j+5|0;return 0}function et(t){t=t|0;if(q(8)|0){return 1}c(V(j+1|0)|0,V(j+3|0)|0,V(j+5|0)|0,V(j+7|0)|0);j=j+9|0;return 0}function rt(t){t=t|0;var e=0;var r=0;var n=0;n=t-64|0;if(q(n|0)|0){return 1}e=j+1|0;r=(j+1|0)+(n|0)|0;R(e|0,r|0);j=r|0;return 0}function nt(t){t=t|0;var e=0;var r=0;var i=0;if(q(1)|0){return 1}i=n[j+1|0]|0;e=j+2|0;r=(j+2|0)+(i|0)|0;if(q(i+1|0)|0){return 1}R(e|0,r|0);j=r|0;return 0}function it(t){t=t|0;var e=0;var r=0;var n=0;if(q(2)|0){return 1}n=V(j+1|0)|0;e=j+3|0;r=(j+3|0)+(n|0)|0;if(q(n+2|0)|0){return 1}R(e|0,r|0);j=r|0;return 0}function st(t){t=t|0;var e=0;var r=0;var n=0;if(q(4)|0){return 1}n=H(j+1|0)|0;e=j+5|0;r=(j+5|0)+(n|0)|0;if(q(n+4|0)|0){return 1}R(e|0,r|0);j=r|0;return 0}function ot(t){t=t|0;return 1}function at(t){t=t|0;C();j=j+1|0;return 0}function ct(t){t=t|0;var e=0;var r=0;var n=0;n=t-96|0;if(q(n|0)|0){return 1}e=j+1|0;r=(j+1|0)+(n|0)|0;B(e|0,r|0);j=r|0;return 0}function ut(t){t=t|0;var e=0;var r=0;var i=0;if(q(1)|0){return 1}i=n[j+1|0]|0;e=j+2|0;r=(j+2|0)+(i|0)|0;if(q(i+1|0)|0){return 1}B(e|0,r|0);j=r|0;return 0}function ht(t){t=t|0;var e=0;var r=0;var n=0;if(q(2)|0){return 1}n=V(j+1|0)|0;e=j+3|0;r=(j+3|0)+(n|0)|0;if(q(n+2|0)|0){return 1}B(e|0,r|0);j=r|0;return 0}function ft(t){t=t|0;var e=0;var r=0;var n=0;if(q(4)|0){return 1}n=H(j+1|0)|0;e=j+5|0;r=(j+5|0)+(n|0)|0;if(q(n+4|0)|0){return 1}B(e|0,r|0);j=r|0;return 0}function lt(t){t=t|0;return 1}function dt(t){t=t|0;M();j=j+1|0;return 0}function pt(t){t=t|0;_(t-128|0);j=j+1|0;return 0}function yt(t){t=t|0;if(q(1)|0){return 1}_(n[j+1|0]|0);j=j+2|0;return 0}function gt(t){t=t|0;if(q(2)|0){return 1}_(V(j+1|0)|0);j=j+3|0;return 0}function bt(t){t=t|0;if(q(4)|0){return 1}E(V(j+1|0)|0,V(j+3|0)|0);j=j+5|0;return 0}function mt(t){t=t|0;if(q(8)|0){return 1}S(V(j+1|0)|0,V(j+3|0)|0,V(j+5|0)|0,V(j+7|0)|0);j=j+9|0;return 0}function vt(t){t=t|0;w();j=j+1|0;return 0}function wt(t){t=t|0;var e=0;e=t-160|0;if(q(e|0)|0){return 1}A(e|0);j=j+1|0;return 0}function _t(t){t=t|0;if(q(1)|0){return 1}A(n[j+1|0]|0);j=j+2|0;return 0}function Et(t){t=t|0;if(q(2)|0){return 1}A(V(j+1|0)|0);j=j+3|0;return 0}function St(t){t=t|0;if(q(4)|0){return 1}k(V(j+1|0)|0,V(j+3|0)|0);j=j+5|0;return 0}function It(t){t=t|0;if(q(8)|0){return 1}T(V(j+1|0)|0,V(j+3|0)|0,V(j+5|0)|0,V(j+7|0)|0);j=j+9|0;return 0}function At(t){t=t|0;I();j=j+1|0;return 0}function kt(t){t=t|0;N(t-192|0|0);j=j+1|0;return 0}function Tt(t){t|0;N(t|0);j=j+1|0;return 0}function Rt(t){t|0;N(t|0);j=j+1|0;return 0}function Ct(t){t|0;N(t|0);j=j+1|0;return 0}function Bt(t){t|0;N(t|0);j=j+1|0;return 0}function Mt(t){t=t|0;N(t-192|0|0);j=j+1|0;return 0}function xt(t){t|0;N(t|0);j=j+1|0;return 0}function Nt(t){t|0;N(t|0);j=j+1|0;return 0}function Pt(t){t|0;N(t|0);j=j+1|0;return 0}function Ot(t){t=t|0;if(q(1)|0){return 1}N(n[j+1|0]|0);j=j+2|0;return 0}function Dt(t){t=t|0;if(q(2)|0){return 1}N(V(j+1|0)|0);j=j+3|0;return 0}function Lt(t){t=t|0;if(q(4)|0){return 1}P(V(j+1|0)|0,V(j+3|0)|0);j=j+5|0;return 0}function Ut(t){t=t|0;if(q(8)|0){return 1}O(V(j+1|0)|0,V(j+3|0)|0,V(j+5|0)|0,V(j+7|0)|0);j=j+9|0;return 0}function jt(t){t=t|0;x((t|0)-224|0);j=j+1|0;return 0}function zt(t){t=t|0;d();j=j+1|0;return 0}function Ft(t){t=t|0;l();j=j+1|0;return 0}function Kt(t){t=t|0;y();j=j+1|0;return 0}function qt(t){t=t|0;p();j=j+1|0;return 0}function Vt(t){t=t|0;if(q(1)|0){return 1}x(n[j+1|0]|0);j=j+2|0;return 0}function Ht(t){t=t|0;var e=0;var r=0;var i=1.0;var s=0.0;var o=0.0;var a=0.0;if(q(2)|0){return 1}e=n[j+1|0]|0;r=n[j+2|0]|0;if((e|0)&0x80){i=-1.0}s=+(((e|0)&0x7C)>>2);o=+(((e|0)&0x03)<<8|r);if(+s==0.0){u(+(+i*+5.9604644775390625e-8*+o))}else if(+s==31.0){if(+i==1.0){if(+o>0.0){m()}else{g()}}else{if(+o>0.0){v()}else{b()}}}else{u(+(+i*U(+2,+(+s-25.0))*+(1024.0+o)))}j=j+3|0;return 0}function Gt(t){t=t|0;if(q(4)|0){return 1}h(n[j+1|0]|0,n[j+2|0]|0,n[j+3|0]|0,n[j+4|0]|0);j=j+5|0;return 0}function Wt(t){t=t|0;if(q(8)|0){return 1}f(n[j+1|0]|0,n[j+2|0]|0,n[j+3|0]|0,n[j+4|0]|0,n[j+5|0]|0,n[j+6|0]|0,n[j+7|0]|0,n[j+8|0]|0);j=j+9|0;return 0}function $t(t){t=t|0;return 1}function Yt(t){t=t|0;L();j=j+1|0;return 0}var Jt=[G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,$,Y,J,$t,$t,$t,$t,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,Z,Q,tt,et,$t,$t,$t,$t,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,rt,nt,it,st,ot,$t,$t,$t,at,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ut,ht,ft,lt,$t,$t,$t,dt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,pt,yt,gt,bt,mt,$t,$t,$t,vt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,wt,_t,Et,St,It,$t,$t,$t,At,kt,kt,kt,kt,kt,kt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Mt,Ot,Dt,Lt,Ut,$t,$t,$t,$t,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,jt,zt,Ft,Kt,qt,Vt,Ht,Gt,Wt,$t,$t,$t,Yt];return{parse:K}}},function(t,e,r){"use strict";const{Buffer:n}=r(3),{URL:i}=r(106),s=r(30).BigNumber,o=r(161),a=r(114),c=a.MT,u=a.NUMBYTES,h=a.SHIFT32,f=a.SYMS,l=a.TAG,d=a.MT.SIMPLE_FLOAT<<5|a.NUMBYTES.TWO,p=a.MT.SIMPLE_FLOAT<<5|a.NUMBYTES.FOUR,y=a.MT.SIMPLE_FLOAT<<5|a.NUMBYTES.EIGHT,g=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.TRUE,b=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.FALSE,m=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.UNDEFINED,v=a.MT.SIMPLE_FLOAT<<5|a.SIMPLE.NULL,w=new s("0x20000000000000"),_=n.from("f97e00","hex"),E=n.from("f9fc00","hex"),S=n.from("f97c00","hex");class I{constructor(t){t=t||{},this.streaming="function"==typeof t.stream,this.onData=t.stream,this.semanticTypes=[[i,this._pushUrl],[s,this._pushBigNumber]];const e=t.genTypes||[],r=e.length;for(let n=0;n[e,t[e]]))}_pushRawMap(t,e){e=e.map((function(t){return t[0]=I.encode(t[0]),t})).sort(o.keySorter);for(var r=0;r{let r=i.deserialize(t);const s=e.split("/").filter(Boolean);for(;s.length;){const t=s.shift();if(void 0===r[t])throw new Error(`Object has no property '${t}'`);if(r=r[t],n.isCID(r))return{value:r,remainderPath:s.join("/")}}return{value:r,remainderPath:""}};const s=function*(t,e){if(!(t instanceof Uint8Array||n.isCID(t)||"string"==typeof t||null===t))for(const r of Object.keys(t)){const n=void 0===e?r:e+"/"+r;yield n,yield*s(t[r],n)}};e.tree=function*(t){const e=i.deserialize(t);yield*s(e)}},function(t,e,r){"use strict";(function(e){const n=r(64),i=r(65),s=(r(66),r(90),r(117)),o=r(54),a=r(30).BigNumber,c=r(91),u=o.MT,h=o.NUMBYTES,f=o.SYMS;function l(t){return t>1?"s":""}class d extends n.Transform{constructor(t){const e=Object.assign({max_depth:10},t,{readableObjectMode:!1,writableObjectMode:!1}),r=e.max_depth;delete e.max_depth,super(e),this.depth=1,this.max_depth=r,this.all=new c,this.parser=new s(e),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("start-string",this._on_start_string.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("error",this._on_error.bind(this)),this.parser.on("data",this._on_data.bind(this)),this.parser.bs.on("read",this._on_read.bind(this))}_transform(t,e,r){this.parser.write(t,e,r)}_flush(t){return this.parser._flush(t)}static comment(t,e,r){if(null==t)throw new Error("input required");let n="string"==typeof t?"hex":void 0,i=10;switch(typeof e){case"function":r=e;break;case"string":n=e;break;case"number":i=e;break;case"object":const t=e.encoding,s=e.max_depth;n=null!=t?t:n,i=null!=s?s:i;break;case"undefined":break;default:throw new Error("Unknown option type")}const s=new c,o=new d({max_depth:i});let a=null;return"function"==typeof r?(o.on("end",()=>{r(null,s.toString("utf8"))}),o.on("error",r)):a=new Promise((t,e)=>(o.on("end",()=>{t(s.toString("utf8"))}),o.on("error",e))),o.pipe(s),o.end(t,n),a}_on_error(t){return this.push("ERROR: ")&&this.push(t.toString())&&this.push("\n")}_on_read(t){this.all.write(t);const e=t.toString("hex");this.push(new Array(this.depth+1).join(" ")),this.push(e);let r=2*(this.max_depth-this.depth);return r-=e.length,r<1&&(r=1),this.push(new Array(r+1).join(" ")),this.push("-- ")}_on_more(t,e,r,n){this.depth++;let i="";switch(t){case u.POS_INT:i="Positive number,";break;case u.NEG_INT:i="Negative number,";break;case u.ARRAY:i="Array, length";break;case u.MAP:i="Map, count";break;case u.BYTE_STRING:i="Bytes, length";break;case u.UTF8_STRING:i="String, length";break;case u.SIMPLE_FLOAT:i=1===e?"Simple value,":"Float,"}return this.push(i+" next "+e+" byte"+l(e)+"\n")}_on_start_string(t,e,r,n){this.depth++;let i="";switch(t){case u.BYTE_STRING:i="Bytes, length: "+e;break;case u.UTF8_STRING:i="String, length: "+e.toString()}return this.push(i+"\n")}_on_start(t,e,r,n){if(this.depth++,e!==f.BREAK)switch(r){case u.ARRAY:this.push(`[${n}], `);break;case u.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(t){case u.TAG:this.push("Tag #"+e);break;case u.ARRAY:e===f.STREAM?this.push("Array (streaming)"):this.push(`Array, ${e} item${l(e)}`);break;case u.MAP:e===f.STREAM?this.push("Map (streaming)"):this.push(`Map, ${e} pair${l(e)}`);break;case u.BYTE_STRING:this.push("Bytes (streaming)");break;case u.UTF8_STRING:this.push("String (streaming)")}return this.push("\n")}_on_stop(t){return this.depth--}_on_value(t,r,n,s){if(t!==f.BREAK)switch(r){case u.ARRAY:this.push(`[${n}], `);break;case u.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(t===f.BREAK?this.push("BREAK\n"):t===f.NULL?this.push("null\n"):t===f.UNDEFINED?this.push("undefined\n"):"string"==typeof t?(this.depth--,t.length>0&&(this.push(JSON.stringify(t)),this.push("\n"))):e.isBuffer(t)?(this.depth--,t.length>0&&(this.push(t.toString("hex")),this.push("\n"))):t instanceof a?(this.push(t.toString()),this.push("\n")):(this.push(i.inspect(t)),this.push("\n")),s){case h.ONE:case h.TWO:case h.FOUR:case h.EIGHT:this.depth--}}_on_data(){return this.push("0x"),this.push(this.all.read().toString("hex")),this.push("\n")}}t.exports=d}).call(this,r(3).Buffer)},function(t,e){},function(t,e,r){"use strict";var n=r(163).Buffer,i=r(562);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e,r,i,s=n.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,r=s,i=a,e.copy(r,i),a+=o.data.length,o=o.next;return s},t}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,r){"use strict";var n=r(3),i=n.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=o),s(i,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},function(t,e,r){"use strict";t.exports=s;var n=r(268),i=Object.create(r(89));function s(t){if(!(this instanceof s))return new s(t);n.call(this,t)}i.inherits=r(23),i.inherits(s,n),s.prototype._transform=function(t,e,r){r(null,t)}},function(t,e,r){"use strict";t.exports=r(164)},function(t,e,r){"use strict";t.exports=r(53)},function(t,e,r){"use strict";t.exports=r(162).Transform},function(t,e,r){"use strict";t.exports=r(162).PassThrough},function(t,e,r){"use strict";t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";const n=r(64),i=r(91),s=n.Transform;t.exports=class extends s{constructor(t){super(t),this._writableState.objectMode=!1,this._readableState.objectMode=!0,this.bs=new i,this.__restart()}_transform(t,e,r){for(this.bs.write(t);this.bs.length>=this.__needed;){let t;const e=null===this.__needed?void 0:this.bs.read(this.__needed);try{t=this.__parser.next(e)}catch(n){return r(n)}this.__needed&&(this.__fresh=!1),t.done?(this.push(t.value),this.__restart()):this.__needed=t.value||0}return r()}*_parse(){throw new Error("Must be implemented in subclass")}__restart(){this.__needed=null,this.__parser=this._parse(),this.__fresh=!0}_flush(t){t(this.__fresh?null:new Error("unexpected end of input"))}}},function(t,e,r){"use strict";(function(t,n){var i;!function(s){e&&e.nodeType,t&&t.nodeType;var o="object"==typeof n&&n;o.global!==o&&o.window!==o&&o.self;var a,c=2147483647,u=/^xn--/,h=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},d=Math.floor,p=String.fromCharCode;function y(t){throw new RangeError(l[t])}function g(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function b(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+g((t=t.replace(f,".")).split("."),e).join(".")}function m(t){for(var e,r,n=[],i=0,s=t.length;i=55296&&e<=56319&&i65535&&(e+=p((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=p(t)})).join("")}function w(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function _(t,e,r){var n=0;for(t=r?d(t/700):t>>1,t+=d(t/e);t>455;n+=36)t=d(t/35);return d(n+36*t/(t+38))}function E(t){var e,r,n,i,s,o,a,u,h,f,l,p=[],g=t.length,b=0,m=128,w=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n=128&&y("not-basic"),p.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=g&&y("invalid-input"),((u=(l=t.charCodeAt(i++))-48<10?l-22:l-65<26?l-65:l-97<26?l-97:36)>=36||u>d((c-b)/o))&&y("overflow"),b+=u*o,!(u<(h=a<=w?1:a>=w+26?26:a-w));a+=36)o>d(c/(f=36-h))&&y("overflow"),o*=f;w=_(b-s,e=p.length+1,0==s),d(b/e)>c-m&&y("overflow"),m+=d(b/e),b%=e,p.splice(b++,0,m)}return v(p)}function S(t){var e,r,n,i,s,o,a,u,h,f,l,g,b,v,E,S=[];for(g=(t=m(t)).length,e=128,r=0,s=72,o=0;o=e&&ld((c-r)/(b=n+1))&&y("overflow"),r+=(a-e)*b,e=a,o=0;oc&&y("overflow"),l==e){for(u=r,h=36;!(u<(f=h<=s?1:h>=s+26?26:h-s));h+=36)E=u-f,v=36-f,S.push(p(w(f+E%v,0))),u=d(E/v);S.push(p(w(u,0))),s=_(r,b,n==i),r=0,++n}++r,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:m,encode:v},decode:E,encode:S,toASCII:function(t){return b(t,(function(t){return h.test(t)?"xn--"+S(t):t}))},toUnicode:function(t){return b(t,(function(t){return u.test(t)?E(t.slice(4).toLowerCase()):t}))}},void 0===(i=function(){return a}.call(e,r,e,t))||(t.exports=i)}()}).call(this,r(110)(t),r(11))},function(t,e,r){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,r){"use strict";e.decode=e.parse=r(575),e.encode=e.stringify=r(576)},function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,i){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var o=/\+/g;t=t.split(e);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var c=t.length;a>0&&c>a&&(c=a);for(var u=0;u=0?(h=p.substr(0,y),f=p.substr(y+1)):(h=p,f=""),l=decodeURIComponent(h),d=decodeURIComponent(f),n(s,l)?Array.isArray(s[l])?s[l].push(d):s[l]=[s[l],d]:s[l]=d}return s}},function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,i){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(i){var s=encodeURIComponent(n(i))+r;return Array.isArray(t[i])?t[i].map((function(t){return s+encodeURIComponent(n(t))})).join(e):s+encodeURIComponent(n(t[i]))})).join(e):i?encodeURIComponent(n(i))+r+encodeURIComponent(n(t)):""}},function(t,e,r){"use strict";(function(e){const n=r(64),i=r(65),s=r(117),o=(r(90),r(66)),a=r(54),c=r(30).BigNumber,u=r(91),h=a.MT,f=a.SYMS;class l extends n.Transform{constructor(t){const e=Object.assign({separator:"\n",stream_errors:!1},t,{readableObjectMode:!1,writableObjectMode:!1}),r=e.separator;delete e.separator;const n=e.stream_errors;delete e.stream_errors,super(e),this.float_bytes=-1,this.separator=r,this.stream_errors=n,this.parser=new s(e),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("data",this._on_data.bind(this)),this.parser.on("error",this._on_error.bind(this))}_transform(t,e,r){return this.parser.write(t,e,r)}_flush(t){return this.parser._flush(e=>this.stream_errors?(e&&this._on_error(e),t()):t(e))}static diagnose(t,e,r){if(null==t)throw new Error("input required");let n={},i="hex";switch(typeof e){case"function":r=e,i=o.guessEncoding(t);break;case"object":n=o.extend({},e),i=null!=n.encoding?n.encoding:o.guessEncoding(t),delete n.encoding;break;default:i=null!=e?e:"hex"}const s=new u,a=new l(n);let c=null;return"function"==typeof r?(a.on("end",()=>r(null,s.toString("utf8"))),a.on("error",r)):c=new Promise((t,e)=>(a.on("end",()=>t(s.toString("utf8"))),a.on("error",e))),a.pipe(s),a.end(t,i),c}_on_error(t){return this.stream_errors?this.push(t.toString()):this.emit("error",t)}_on_more(t,e,r,n){if(t===h.SIMPLE_FLOAT)return this.float_bytes={2:1,4:2,8:3}[e]}_fore(t,e){switch(t){case h.BYTE_STRING:case h.UTF8_STRING:case h.ARRAY:if(e>0)return this.push(", ");break;case h.MAP:if(e>0)return e%2?this.push(": "):this.push(", ")}}_on_value(t,r,n){if(t!==f.BREAK)return this._fore(r,n),this.push((()=>{switch(!1){case t!==f.NULL:return"null";case t!==f.UNDEFINED:return"undefined";case"string"!=typeof t:return JSON.stringify(t);case!(this.float_bytes>0):const r=this.float_bytes;return this.float_bytes=-1,i.inspect(t)+"_"+r;case!e.isBuffer(t):return"h'"+t.toString("hex")+"'";case!(t instanceof c):return t.toString();default:return i.inspect(t)}})())}_on_start(t,e,r,n){switch(this._fore(r,n),t){case h.TAG:this.push(e+"(");break;case h.ARRAY:this.push("[");break;case h.MAP:this.push("{");break;case h.BYTE_STRING:case h.UTF8_STRING:this.push("(")}if(e===f.STREAM)return this.push("_ ")}_on_stop(t){switch(t){case h.TAG:return this.push(")");case h.ARRAY:return this.push("]");case h.MAP:return this.push("}");case h.BYTE_STRING:case h.UTF8_STRING:return this.push(")")}}_on_data(){return this.push(this.separator)}}t.exports=l}).call(this,r(3).Buffer)},function(t,e,r){"use strict";(function(e){const n=r(269),i=r(117),s=r(54).MT;class o extends Map{constructor(t){super(t)}static _encode(t){return n.encodeCanonical(t).toString("base64")}static _decode(t){return i.decodeFirstSync(t,"base64")}get(t){return super.get(o._encode(t))}set(t,e){return super.set(o._encode(t),e)}delete(t){return super.delete(o._encode(t))}has(t){return super.has(o._encode(t))}*keys(){for(const t of super.keys())yield o._decode(t)}*entries(){for(const t of super.entries())yield[o._decode(t[0]),t[1]]}[Symbol.iterator](){return this.entries()}forEach(t,e){if("function"!=typeof t)throw new TypeError("Must be function");for(const r of super.entries())t.call(this,r[1],o._decode(r[0]),this)}encodeCBOR(t){if(!t._pushInt(this.size,s.MAP))return!1;if(t.canonical){const r=Array.from(super.entries()).map(t=>[e.from(t[0],"base64"),t[1]]);r.sort((t,e)=>t[0].compare(e[0]));for(const e of r)if(!t.push(e[0])||!t.pushAny(e[1]))return!1}else for(const r of super.entries())if(!t.push(e.from(r[0],"base64"))||!t.pushAny(r[1]))return!1;return!0}}t.exports=o}).call(this,r(3).Buffer)},function(t,e,r){"use strict";const{cleanCid:n}=r(159),{withTimeoutOption:i}=r(2);t.exports=({blockService:t,preload:e})=>i((async function(r,i){i=i||{},r=n(r),!1!==i.preload&&e(r);return{cid:r,size:(await t.get(r)).data.length}}))},function(t,e,r){"use strict";const n=r(30).default,i=r(4),{withTimeoutOption:s}=r(2);t.exports=({bitswap:t})=>s((async function(e){const r=t.stat().snapshot;return{provideBufLen:parseInt(r.providesBufferLength.toString()),blocksReceived:new n(r.blocksReceived),wantlist:Array.from(t.getWantlist()).map(t=>t[1].cid),peers:t.peers().map(t=>new i(t.toB58String())),dupBlksReceived:new n(r.dupBlksReceived),dupDataReceived:new n(r.dupDataReceived),dataReceived:new n(r.dataReceived),blocksSent:new n(r.blocksSent),dataSent:new n(r.dataSent)}}))},function(t,e,r){"use strict";const n=r(4),i=r(0),{withTimeoutOption:s}=r(2);t.exports=({bitswap:t})=>s((async function(e,r){Array.isArray(e)||(e=[e]);try{e=e.map(t=>new n(t))}catch(s){throw i(s,"ERR_INVALID_CID")}return t.unwant(e,r)}))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({bitswap:t})=>n((async function(e={}){const r=t.getWantlist(e);return Array.from(r).map(t=>t[1].cid)}))},function(t,e,r){"use strict";const n=r(7),{withTimeoutOption:i}=r(2);t.exports=({bitswap:t})=>i((async function(e,r={}){const i=t.wantlistForPeer(n.createFromCID(e),r);return Array.from(i).map(t=>t[1].cid)}))},function(t,e,r){"use strict";const{isValidMultiaddr:n}=r(270),{withTimeoutOption:i}=r(2);t.exports=({repo:t})=>i((async function(e,r={}){if(!n(e))throw new Error(e+" is not a valid Multiaddr");const i=await t.config.getAll(r);return-1===i.Bootstrap.indexOf(e)&&i.Bootstrap.push(e),await t.config.set(i),{Peers:[e]}}))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({repo:t})=>n((async function(e={}){const r=await t.config.getAll(e),n=r.Bootstrap||[];return r.Bootstrap=[],await t.config.set(r),{Peers:n}}))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({repo:t})=>n((async function(e){return{Peers:await t.config.get("Bootstrap",e)||[]}}))},function(t,e,r){"use strict";const n=r(167),{withTimeoutOption:i}=r(2);t.exports=({repo:t})=>i((async function(e={}){const r=await t.config.getAll(e);return r.Bootstrap=n().Bootstrap,await t.config.set(r),{Peers:n().Bootstrap}}))},function(t,e,r){"use strict";const{isValidMultiaddr:n}=r(270),{withTimeoutOption:i}=r(2);t.exports=({repo:t})=>i((async function(e,r={}){if(!n(e))throw new Error(e+" is not a valid Multiaddr");const i=await t.config.getAll(r);return i.Bootstrap=(i.Bootstrap||[]).filter(t=>t!==e),await t.config.set(i),{Peers:[e]}}))},function(t,e,r){"use strict";const n=r(39),{normalizeCidPath:i,withTimeoutOption:s}=r(2);t.exports=function({ipld:t,preload:e}){return s((async function*(r,s){if(s=s||{},r=i(r),!1!==s.preload){const t=r.split("/");e(t[0])}const o=await n(r,t,s);if(o.unixfs&&o.unixfs.type.includes("dir"))throw new Error("this dag node is a directory");if(!o.content)throw new Error("this dag node has no content");yield*o.content(s)}))}},function(t,e,r){"use strict";const n=r(0),i={"dag-pb":r(591),raw:r(595),"dag-cbor":r(596),identity:r(597)},s=(t,e,r,o,a,c,u)=>{const h=i[t.codec];if(!h)throw n(new Error("No resolver for codec "+t.codec),"ERR_NO_RESOLVER");return h(t,e,r,o,s,a,c,u)};t.exports=s},function(t,e,r){"use strict";const n=r(0),i=r(29),s=r(592),o={raw:r(271),file:r(271),directory:r(593),"hamt-sharded-directory":r(594),metadata:(t,e,r,n,i,s,o)=>{},symlink:(t,e,r,n,i,s,o)=>{}};t.exports=async(t,e,r,a,c,u,h,f)=>{const l=await h.get(t,f);let d,p;e||(e=t.toBaseEncodedString());try{d=i.unmarshal(l.Data)}catch(y){throw n(y,"ERR_NOT_UNIXFS")}if(r||(r=e),a.length){let t;if(t=d&&"hamt-sharded-directory"===d.type?await s(l,a[0],h):((t,e)=>{const r=t.Links.find(t=>t.Name===e);return r&&r.Hash})(l,a[0]),!t)throw n(new Error("file does not exist"),"ERR_NOT_FOUND");const e=a.shift();p={cid:t,toResolve:a,name:e,path:`${r}/${e}`}}return{entry:{name:e,path:r,cid:t,node:l,content:o[d.type](t,l,d,r,c,u,h,f),unixfs:d,depth:u},next:p}}},function(t,e,r){"use strict";const n=r(152),i=r(13),s=r(6),o=async function(t){const e=s(t),r=(await i(e,"murmur3-128")).slice(2,10),n=r.length,o=new Uint8Array(n);for(let i=0;it.toString("16").toUpperCase().padStart(2,"0").substring(0,2),c=async(t,e,r,i,s)=>{var u,h,f;i||((i={rootBucket:new n({hashFn:o}),hamtDepth:1}).lastBucket=i.rootBucket),await(u=t.Links,h=i.lastBucket,f=i.rootBucket,Promise.all(u.map(t=>{if(2===t.Name.length){const e=parseInt(t.Name,16);return h._putObjectAt(e,new n({hashFn:o},h,e))}return f.put(t.Name.substring(2),!0)})));const l=await i.rootBucket._findNewBucketAndPos(e);let d=a(l.pos);const p=(t=>{let e=t.bucket;const r=[];for(;e._parent;)r.push(e),e=e._parent;return r.push(e),r.reverse()})(l);p.length>i.hamtDepth&&(i.lastBucket=p[i.hamtDepth],d=a(i.lastBucket._posAtParent));const y=t.Links.find(t=>{const r=t.Name.substring(0,2),n=t.Name.substring(2);if(r===d&&(!n||n===e))return!0});return y?y.Name.substring(2)===e?y.Hash:(i.hamtDepth++,t=await r.get(y.Hash,s),c(t,e,r,i,s)):null};t.exports=c},function(t,e,r){"use strict";t.exports=(t,e,r,n,i,s,o,a)=>async function*(t={}){const r=t.offset||0,a=t.length||e.Links.length,c=e.Links.slice(r,a);for(const e of c){const r=await i(e.Hash,e.Name,`${n}/${e.Name}`,[],s+1,o,t);yield r.entry}}},function(t,e,r){"use strict";t.exports=(t,e,r,n,i,s,o)=>(t={})=>async function*t(e,r,n,i,s,o){const a=e.Links;for(const c of a){const a=c.Name.substring(2);if(a){const t=await n(c.Hash,a,`${r}/${a}`,[],i+1,s);yield t.entry}else{e=await s.get(c.Hash);for await(const a of t(e,r,n,i,s,o))yield a}}}(e,n,i,s,o,t)},function(t,e,r){"use strict";const n=r(0),i=r(168),s=r(169);t.exports=async(t,e,r,o,a,c,u,h)=>{if(o.length)throw n(new Error(`No link named ${r} found in raw node ${t.toBaseEncodedString()}`),"ERR_NOT_FOUND");const f=await u.get(t,h);return{entry:{name:e,path:r,cid:t,node:f,content:(l=f,function*(t={}){const{offset:e,length:r}=s(l.length,t.offset,t.length);yield i(l,0,e,e+r)}),depth:c}};var l}},function(t,e,r){"use strict";const n=r(4),i=r(0);t.exports=async(t,e,r,s,o,a,c,u)=>{const h=await c.get(t,u);let f=h,l=r;for(;s.length;){const o=s[0];if(!(o in f))throw i(new Error(`No property named ${o} found in cbor node ${t.toBaseEncodedString()}`),"ERR_NO_PROP");if(s.shift(),l=`${l}/${o}`,n.isCID(f[o]))return{entry:{name:e,path:r,cid:t,node:h,depth:a},next:{cid:f[o],name:o,path:l,toResolve:s}};f=f[o]}return{entry:{name:e,path:r,cid:t,node:h,depth:a}}}},function(t,e,r){"use strict";const n=r(0),i=r(168),s=r(169),o=r(13).multihash;t.exports=async(t,e,r,a,c,u,h,f)=>{if(a.length)throw n(new Error(`No link named ${r} found in raw node ${t.toBaseEncodedString()}`),"ERR_NOT_FOUND");const l=await o.decode(t.multihash);return{entry:{name:e,path:r,cid:t,node:l,content:(d=l.digest,function*(t={}){const{offset:e,length:r}=s(d.length,t.offset,t.length);yield i(d,0,e,e+r)}),depth:u}};var d}},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2),i=r(153),s=r(41),o=r(113);t.exports=({ipld:t,preload:e})=>n((async function(r,n={}){const{cid:a,path:c}=o(r);return c&&(n.path=c),!1!==n.preload&&e(a),n.path?n.localResolve?i(t.resolve(a,n.path)):s(t.resolve(a,n.path)):{value:await t.get(a,n),remainderPath:""}}))},function(t,e,r){"use strict";const n=r(19),i=t=>n[t.toUpperCase().replace(/-/g,"_")],{withTimeoutOption:s}=r(2);t.exports=({ipld:t,pin:e,gcLock:r,preload:o})=>s((async function(s,a){if((a=a||{}).cid&&(a.format||a.hashAlg))throw new Error("Can't put dag node. Please provide either `cid` OR `format` and `hashAlg` options.");if(a.format&&!a.hashAlg||!a.format&&a.hashAlg)throw new Error("Can't put dag node. Please provide `format` AND `hashAlg` options.");const c={format:n.DAG_CBOR,hashAlg:n.SHA2_256};let u;a.format&&"string"==typeof a.format&&(a.format=i(a.format)),a.hashAlg&&"string"==typeof a.hashAlg&&(a.hashAlg=i(a.hashAlg)),void 0===(a=a.cid?a:Object.assign({},c,a)).version&&(a.format===n.DAG_PB&&a.hashAlg===n.SHA2_256?a.version=0:a.version=1),a.pin&&(u=await r.readLock());try{const r=await t.put(s,a.format,{hashAlg:a.hashAlg,cidVersion:a.version,signal:a.signal});return a.pin&&await e.add(r,{lock:!1}),!1!==a.preload&&o(r),r}finally{u&&u()}}))},function(t,e,r){"use strict";const n=r(4),{withTimeoutOption:i}=r(2),s=r(113);t.exports=({ipld:t,preload:e})=>i((async function(r,i={}){const{cid:o,path:a}=s(r);!1!==i.preload&&e(o),a&&(i.path=a);let c=o,u=i.path||"";if(u.startsWith("/")&&(u=u.substring(1)),i.path)try{for await(const{value:e,remainderPath:r}of t.resolve(o,i.path,{signal:i.signal})){if(!n.isCID(e))break;u=r,c=e}}catch(h){throw h.message.startsWith("Object has no property")&&(h.message=`no link named "${u.split("/")[0]}" under ${c}`,h.code="ERR_NO_LINK"),h}return{cid:c,remainderPath:u||""}}))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2),i=r(113);t.exports=({ipld:t,preload:e})=>n((async function*(r,n={}){const{cid:s,path:o}=i(r);o&&(n.path=o),!1!==n.preload&&e(s),yield*t.tree(s,n.path,n)}))},function(t,e,r){"use strict";const n=r(7),i=r(4),s=r(0),{withTimeoutOption:o}=r(2);t.exports=({libp2p:t,repo:e})=>({get:o(async(e,r)=>{if(r=r||{},!(e instanceof Uint8Array))try{e=e.toString().split("/").filter(t=>t&&"ipfs"!==t&&"ipns"!==t).shift(),e=new i(e).bytes}catch(n){throw s(n,"ERR_INVALID_CID")}return t._dht.get(e,r)}),put:o(async(e,r)=>{if(!(e instanceof Uint8Array))try{e=e.toString().split("/").filter(t=>t&&"ipfs"!==t&&"ipns"!==t).shift(),e=new i(e).bytes}catch(n){throw s(n,"ERR_INVALID_CID")}return t._dht.put(e,r)}),findProvs:o((async function*(e,r){if(r=r||{},"string"==typeof e)try{e=new i(e)}catch(n){throw s(n,"ERR_INVALID_CID")}r.numProviders&&(r.maxNumProviders=r.numProviders);for await(const i of t._dht.findProviders(e,r))yield{id:i.id.toB58String(),addrs:i.addrs}})),findPeer:o(async e=>{"string"==typeof e&&(e=n.createFromCID(e));const r=await t._dht.findPeer(e);return{id:r.id.toB58String(),addrs:r.multiaddrs}}),provide:o((async function*(r,n){for(var o in n=n||{},r=Array.isArray(r)?r:[r])if("string"==typeof r[o])try{r[o]=new i(r[o])}catch(a){throw s(a,"ERR_INVALID_CID")}if(!(await Promise.all(r.map(t=>e.blocks.has(t)))).every(t=>t))throw s(new Error("block(s) not found locally, cannot provide"),"ERR_BLOCK_NOT_FOUND");if(n.recursive)throw s(new Error("not implemented yet"),"ERR_NOT_IMPLEMENTED_YET");for(const e of r)yield t._dht.provide(e)})),query:o((async function*(e){"string"==typeof e&&(e=n.createFromCID(e));for await(const r of t._dht.getClosestPeers(e.toBytes()))yield{id:r.toB58String(),addrs:[]}}))})},function(t,e,r){"use strict";const n=r(604),{withTimeoutOption:i}=r(2);t.exports=()=>i(async(t,e)=>{if(e=e||{},"string"!=typeof t)throw new Error("Invalid arguments, domain must be a string");return t=function(t){return t.endsWith(".eth")&&(t=t.replace(/.eth$/,".eth.link")),t}(t),n(t,e)})},function(t,e,r){"use strict";const n=r(273),{default:i}=r(92),s=r(132),o=new n(1e3),a=new i({concurrency:4}),c=t=>{if(t.Path)return t.Path;throw new Error(t.Message)};t.exports=async(t,e)=>(async(t,e)=>{e=e||{};const r=new URLSearchParams(e);r.set("arg",t);const n=r.toString();if(!e.nocache&&o.has(n)){const t=o.get(n);return c(t)}const i=await a.add(async()=>{const t=await s.get("https://ipfs.io/api/v0/dns",{searchParams:r}),e=new URL(t.url).search.slice(1),n=await t.json();return o.set(e,n,6e4),n});return c(i)})(t,e)},function(t,e,r){"use strict";var n=Object.prototype.hasOwnProperty,i="~";function s(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function a(t,e,r,n,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,n||t,s),c=i?i+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function c(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function u(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),u.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)n.call(t,e)&&r.push(i?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},u.prototype.listeners=function(t){var e=i?i+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,s=r.length,o=new Array(s);nnew Promise((s,o)=>{if("number"!=typeof e||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0)return void s(t);const a=setTimeout(()=>{if("function"==typeof r){try{s(r())}catch(a){o(a)}return}const n=r instanceof Error?r:new i("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(n)},e);n(t.then(s,o),()=>{clearTimeout(a)})});t.exports=s,t.exports.default=s,t.exports.TimeoutError=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(608);e.default=class{constructor(){this._queue=[]}enqueue(t,e){const r={priority:(e=Object.assign({priority:0},e)).priority,run:t};if(this.size&&this._queue[this.size-1].priority>=e.priority)return void this._queue.push(r);const i=n.default(this._queue,r,(t,e)=>e.priority-t.priority);this._queue.splice(i,0,r)}dequeue(){const t=this._queue.shift();return null==t?void 0:t.run}filter(t){return this._queue.filter(e=>e.priority===t.priority).map(t=>t.run)}get size(){return this._queue.length}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r){let n=0,i=t.length;for(;i>0;){const s=i/2|0;let o=n+s;r(t[o],e)<=0?(n=++o,i-=s+1):i=s}return n}},function(t,e,r){"use strict";const n=r(274),i=r(51),s={stat:r(119)},o={chmod:r(626),cp:r(173),flush:r(630),mkdir:r(174),mv:r(631),rm:r(176),touch:r(632)},a={write:r(633),read:r(635),ls:r(636)},c=({options:t,mfs:e,operations:r,lock:n})=>{Object.keys(r).forEach(i=>{e[i]=n(r[i](t))})},u={repoOwner:!0,ipld:null,repo:null};t.exports=({ipld:t,block:e,blockService:r,repo:h,preload:f,options:l})=>{const d=function(t){const{repoOwner:e}=Object.assign({},u||{},t);t.repo={blocks:t.blocks,datastore:t.datastore};const r=n(e),i={};return c({options:t,mfs:i,operations:s,lock:t=>r.readLock(t)}),c({options:t,mfs:i,operations:o,lock:t=>r.writeLock(t)}),Object.keys(a).forEach(e=>{i[e]=a[e](t)}),i}({ipld:t,block:e,blocks:r,datastore:h.root,repoOwner:l.repoOwner}),p=t=>(...e)=>{const r=e.filter(t=>i.ipfsPath(t)||i.cid(t));if(r.length){const t=e[e.length-1];t&&!1!==t.preload&&r.forEach(t=>f(t))}return t(...e)};return{...d,chmod:d.chmod,cp:p(d.cp),mkdir:d.mkdir,stat:p(d.stat),rm:d.rm,read:p(d.read),touch:d.touch,write:d.write,mv:p(d.mv),flush:d.flush,ls:p((async function*(...t){for await(const e of d.ls(...t))yield{...e,size:e.size||0}}))}}},function(t,e,r){"use strict";(function(e){const n=r(14).EventEmitter,i=r(276),{WORKER_REQUEST_READ_LOCK:s,WORKER_RELEASE_READ_LOCK:o,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:c,WORKER_RELEASE_WRITE_LOCK:u,MASTER_GRANT_WRITE_LOCK:h}=r(277);let f;const l=(t,e,r,n,i)=>(s,o)=>{o&&o.type===r&&t.emit(e,o.name,()=>(s.send({type:i,name:o.name,identifier:o.identifier}),new Promise(t=>{const e=r=>{r&&r.type===n&&r.identifier===o.identifier&&(s.removeListener("message",e),t())};s.on("message",e)})))},d=(t,r,n,s)=>()=>{const o=i.generate();return e.send({type:r,identifier:o,name:t}),new Promise(r=>{const i=a=>{a&&a.type===n&&a.identifier===o&&(e.removeListener("message",i),r(()=>{e.send({type:s,identifier:o,name:t})}))};e.on("message",i)})};t.exports=t=>{try{if(f=r(619),!Object.keys(f).length)return}catch(e){return}if(f.isMaster||t.singleProcess){const t=new n;return f.on("message",l(t,"requestReadLock",s,o,a)),f.on("message",l(t,"requestWriteLock",c,u,h)),t}return{isWorker:!0,readLock:t=>d(t,s,a,o),writeLock:t=>d(t,c,h,u)}}}).call(this,r(12))},function(t,e,r){"use strict";var n=r(118),i=r(613),s=r(617),o=r(618)||0;function a(){return i(o)}t.exports=a,t.exports.generate=a,t.exports.seed=function(e){return n.seed(e),t.exports},t.exports.worker=function(e){return o=e,t.exports},t.exports.characters=function(t){return void 0!==t&&n.characters(t),n.shuffled()},t.exports.isValid=s},function(t,e,r){"use strict";var n=1;t.exports={nextValue:function(){return(n=(9301*n+49297)%233280)/233280},seed:function(t){n=t}}},function(t,e,r){"use strict";var n,i,s=r(614);r(118);t.exports=function(t){var e="",r=Math.floor(.001*(Date.now()-1567752802062));return r===i?n++:(n=0,i=r),e+=s(7),e+=s(t),n>0&&(e+=s(n)),e+=s(r)}},function(t,e,r){"use strict";var n=r(118),i=r(615),s=r(616);t.exports=function(t){for(var e,r=0,o="";!e;)o+=s(i,n.get(),1),e=t(s,o)=>{if(!o||!o.data||o.data.type!==r)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};t.emit(e,a.name,()=>(s.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(t=>{const e=r=>{if(!r||!r.data)return;const i={type:r.data.type,name:r.data.name,identifier:r.data.identifier};i&&i.type===n&&i.identifier===a.identifier&&(s.removeEventListener("message",e),t())};s.addEventListener("message",e)})))},p=(t,e,r,n)=>()=>{const s=i.generate();return l.postMessage({type:e,identifier:s,name:t}),new Promise(e=>{const i=o=>{if(!o||!o.data)return;const a={type:o.data.type,identifier:o.data.identifier};a&&a.type===r&&a.identifier===s&&(l.removeEventListener("message",i),e(()=>{l.postMessage({type:n,identifier:s,name:t})}))};l.addEventListener("message",i)})},y={singleProcess:!1};t.exports=t=>{t=Object.assign({},y,t);if(!!l.document||t.singleProcess){const t=new n;return f.addEventListener("message",d(t,"requestReadLock",s,o,a)),f.addEventListener("message",d(t,"requestWriteLock",c,u,h)),t}return{isWorker:!0,readLock:t=>p(t,s,a,o),writeLock:t=>p(t,c,h,u)}}},function(t,e,r){"use strict";var n=r(279),i=r(281),s=r(282),o=r(624),a=s(),c=function(){return a};n(c,{getPolyfill:s,implementation:i,shim:o}),t.exports=c},function(t,e,r){"use strict";var n=Array.prototype.slice,i=r(280),s=Object.keys,o=s?function(t){return s(t)}:r(623),a=Object.keys;o.shim=function(){Object.keys?function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2)||(Object.keys=function(t){return i(t)?a(n.call(t)):a(t)}):Object.keys=o;return Object.keys||o},t.exports=o},function(t,e,r){"use strict";var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,s=Object.prototype.toString,o=r(280),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call((function(){}),"prototype"),h=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],f=function(t){var e=t.constructor;return e&&e.prototype===t},l={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!l["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{f(window[t])}catch(e){return!0}}catch(e){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===s.call(t),n=o(t),a=e&&"[object String]"===s.call(t),l=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var p=u&&r;if(a&&t.length>0&&!i.call(t,0))for(var y=0;y0)for(var g=0;gI(r,t,e.isDirectory()),e.mode)),t}t.exports=t=>E((async function(e,r,E){E=n(E,S),s("Fetching stats for "+e);const{cid:I,mfsDirectory:k,name:T}=await i(t,e,E);if("dag-pb"!==I.codec)throw o(new Error(e+" was not a UnixFS node"),"ERR_NOT_UNIXFS");if(E.recursive){const n=await y((async function*(){for await(const e of b.recursive(I,t.ipld)){let n=await t.ipld.get(e.cid);e.unixfs.mode=A(r,e.unixfs),n=new l(e.unixfs.marshal(),n.Links),yield{path:e.path,content:n}}}),e=>g(e,t.block,{...E,pin:!1,dagBuilder:async function*(t,e,r){for await(const n of t)yield async function(){return{cid:await _(n.content.serialize(),e,r),path:n.path,unixfs:a.unmarshal(n.content.Data),node:n.content}}}}),t=>m(t));return await w(t)(e,E),void await v(t)("/ipfs/"+n.cid,e,E)}let R=await t.ipld.get(I);const C=a.unmarshal(R.Data);C.mode=A(r,C),R=new l(C.marshal(),R.Links);const B=await t.ipld.put(R,d.DAG_PB,{cidVersion:I.version,hashAlg:p.names[E.hashAlg],onlyHash:!E.flush}),M=await c(t,k,E),x=M[M.length-1],N=await t.ipld.get(x.cid),P=await u(t,{parent:N,name:T,cid:B,size:R.serialize().length,flush:E.flush,hashAlg:E.hashAlg,cidVersion:I.version});x.cid=P.cid;const O=await h(t,M,E);await f(t,O,E)}))},function(t,e,r){"use strict";const n=r(29),{DAGNode:i}=r(16),s=r(19),o=r(13).multihash;t.exports=async(t,e,r)=>{const a=o.names[r.hashAlg],c=new n({type:e,mode:r.mode,mtime:r.mtime}),u=new i(c.marshal());return{cid:await t.ipld.put(u,s.DAG_PB,{cidVersion:r.cidVersion,hashAlg:a,onlyHash:!r.flush}),node:u}}},function(t,e,r){"use strict";const n=r(175);t.exports=async function(t,e,r){const{sources:i,options:s}=await n(t,e,r);return{destination:i.pop(),sources:i,options:s}}},function(t,e,r){"use strict";const{DAGNode:n,DAGLink:i}=r(16),s=r(4),o=r(1)("ipfs:mfs:core:utils:remove-link"),a=r(29),{generatePath:c,updateHamtDirectory:u}=r(284),h=r(0),f=r(19),l=r(13).multihash,d=async(t,e)=>{const r=l.names[e.hashAlg];e.parent.rmLink(e.name);const n=await t.ipld.put(e.parent,f.DAG_PB,{cidVersion:e.cidVersion,hashAlg:r});return o("Updated regular directory "+n),{node:e.parent,cid:n}},p=async(t,e)=>{const{rootBucket:r,path:n}=await c(t,e.name,e.parent);await r.del(e.name);const{node:i}=await y(t,n,{name:e.name,cid:e.cid,size:e.size,hashAlg:e.hashAlg,cidVersion:e.cidVersion,flush:e.flush},e);return u(t,i.Links,r,e)},y=async(t,e,r,i)=>{const{bucket:s,prefix:a,node:c}=e.pop(),f=c.Links.find(t=>t.Name.substring(0,2)===a);if(!f)throw h(new Error(`No link found with prefix ${a} for file ${r.name}`),"ERR_NOT_FOUND");if(f.Name===`${a}${r.name}`)return o("Removing existing link "+f.Name),c.rmLink(f.Name),await s.del(r.name),u(t,c.Links,s,i);o(`Descending into sub-shard ${f.Name} for ${a}${r.name}`);const l=await y(t,e,r,i);let d=a;1===l.node.Links.length&&(o("Removing subshard for "+a),l.cid=l.node.Links[0].Hash,l.node=l.node.Links[0],d=`${a}${l.node.Name.substring(2)}`),o(`Updating shard ${a} with name ${d}`);const p=n.isDAGNode(l.node)?l.node.size:l.node.Tsize;return g(t,s,c,a,d,p,l.cid,i)},g=(t,e,r,n,s,o,a,c)=>(r.rmLink(n),r.addLink(new i(s,o,a)),u(t,r.Links,e,c));t.exports=async(t,e)=>{if(!e.parentCid&&!e.parent)throw h(new Error("No parent node or CID passed to removeLink"),"EINVALIDPARENT");if(e.parentCid&&!s.isCID(e.parentCid))throw h(new Error("Invalid CID passed to removeLink"),"EINVALIDPARENTCID");if(e.parent||(o("Loading parent node "+e.parentCid),e.parent=await t.ipld.get(e.parentCid)),!e.name)throw h(new Error("No child name passed to removeLink"),"EINVALIDCHILDNAME");return"hamt-sharded-directory"===a.unmarshal(e.parent.Data).type?(o(`Removing ${e.name} from sharded directory`),p(t,e)):(o(`Removing link ${e.name} regular directory`),d(t,e))}},function(t,e,r){"use strict";const n=r(46),i=r(119),{withTimeoutOption:s}=r(2),o={signal:void 0};t.exports=t=>s((async function(e,r={}){r=n(r,o);const{cid:s}=await i(t)(e,r);return s}))},function(t,e,r){"use strict";const n=r(175),i=r(173),s=r(176),{withTimeoutOption:o}=r(2),a={parents:!1,recursive:!1,flush:!0,cidVersion:0,hashAlg:"sha2-256",shardSplitThreshold:1e3,signal:void 0};t.exports=t=>o((async function(...e){const{sources:r,options:o}=await n(t,e,a),c=r.map(t=>t.path).concat(o),u=r.slice(0,-1).map(t=>t.path).concat(Object.assign(o,{recursive:!0}));await i(t).apply(null,c),await s(t).apply(null,u)}))},function(t,e,r){"use strict";const n=r(46),i=r(42),s=r(1)("ipfs:mfs:touch"),o=r(0),a=r(29),c=r(93),u=r(67),h=r(68),f=r(69),{DAGNode:l}=r(16),d=r(19),p=r(13).multihash,{withTimeoutOption:y}=r(2),g={mtime:void 0,flush:!0,shardSplitThreshold:1e3,cidVersion:0,hashAlg:"sha2-256",signal:void 0};t.exports=t=>y((async function(e,r){(r=n(r=r||{},g)).mtime=r.mtime||new Date,s(`Touching ${e} mtime: ${r.mtime}`);const{cid:y,mfsDirectory:b,name:m,exists:v}=await i(t,e,r);let w,_,E=r.cidVersion;if(v){if("dag-pb"!==y.codec)throw o(new Error(e+" was not a UnixFS node"),"ERR_NOT_UNIXFS");E=y.version,w=await t.ipld.get(y);const n=a.unmarshal(w.Data);n.mtime=r.mtime,w=new l(n.marshal(),w.Links),_=await t.ipld.put(w,d.DAG_PB,{cidVersion:y.version,hashAlg:p.names["sha2-256"],onlyHash:!r.flush})}else{const e=new a({type:"file",mtime:r.mtime});w=new l(e.marshal()),_=await t.ipld.put(w,d.DAG_PB,{cidVersion:r.cidVersion,hashAlg:p.names["sha2-256"],onlyHash:!r.flush})}const S=await c(t,b,r),I=S[S.length-1],A=await t.ipld.get(I.cid),k=await u(t,{parent:A,name:m,cid:_,size:w.serialize().length,flush:r.flush,shardSplitThreshold:r.shardSplitThreshold,hashAlg:"sha2-256",cidVersion:E});I.cid=k.cid;const T=await h(t,S,r);await f(t,T,r)}))},function(t,e,r){"use strict";const n=r(1)("ipfs:mfs:write"),i=r(147),s=r(119),o=r(174),a=r(67),c=r(46),u=r(274),h=r(634),f=r(42),l=r(172),d=r(93),p=r(68),y=r(69),g=r(0),{MFS_MAX_CHUNK_SIZE:b}=r(2),m=r(41),{withTimeoutOption:v}=r(2),w={offset:0,length:void 0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",parents:!1,progress:()=>{},strategy:"trickle",flush:!0,leafType:"raw",shardSplitThreshold:1e3,mode:void 0,mtime:void 0,signal:void 0};t.exports=t=>v((async function(e,r,i){let s,o,a;if(i=c(i,w),n("Reading source, destination and parent"),await u().readLock(async()=>{s=await h(r,i),o=await f(t,e,i),a=await f(t,o.mfsDirectory,i)})(),n("Read source, destination and parent"),!i.parents&&!a.exists)throw g(new Error("directory does not exist"),"ERR_NO_EXIST");if(!i.create&&!o.exists)throw g(new Error("file does not exist"),"ERR_NO_EXIST");return _(t,e,s,o,i)}));const _=async(t,e,r,n,i)=>{const c=await E(t,r,n,i);await u().writeLock(async()=>{const r=l(e),n=r.pop();let u=!1;try{await s(t)("/"+r.join("/"),i),u=!0}catch(E){if("ERR_NOT_FOUND"!==E.code)throw E}u||await o(t)("/"+r.join("/"),i);const h=await f(t,e,i),b=await d(t,h.mfsDirectory,i),m=b[b.length-1];if(!m.type.includes("directory"))throw g(new Error(`cannot write to ${m.name}: Not a directory`),"ERR_NOT_A_DIRECTORY");const v=await t.ipld.get(m.cid),w=await a(t,{parent:v,name:n,cid:c.cid,size:c.size,flush:i.flush,shardSplitThreshold:i.shardSplitThreshold,hashAlg:i.hashAlg,cidVersion:i.cidVersion});m.cid=w.cid;const _=await p(t,b,i);await y(t,_,i)})()},E=async(t,e,r,s)=>{r.exists?n(`Overwriting file ${r.cid} offset ${s.offset} length ${s.length}`):n(`Writing file offset ${s.offset} length ${s.length}`);const o=[];if(s.offset>0)if(r.unixfs){if(n(`Writing first ${s.offset} bytes of original file`),o.push(()=>r.content({offset:0,length:s.offset})),r.unixfs.fileSize(){if(r.unixfs&&!s.truncate){const e=r.unixfs.fileSize();if(e>t)return n(`Writing last ${e-t} of ${e} bytes from original file starting at offset ${t}`),r.content({offset:t});n("Not writing last bytes from original file")}return{[Symbol.asyncIterator]:async function*(){}}});let c,u;void 0!==s.mode&&null!==s.mode?c=s.mode:r&&r.unixfs&&(c=r.unixfs.mode),void 0!==s.mtime&&null!==s.mtine?u=s.mtime:r&&r.unixfs&&(u=r.unixfs.mtime);const h=await m(i([{content:a,mode:c,mtime:u}],t.block,{progress:s.progress,hashAlg:s.hashAlg,cidVersion:s.cidVersion,strategy:s.strategy,rawLeaves:s.rawLeaves,reduceSingleLeafToSelf:s.reduceSingleLeafToSelf,leafType:s.leafType,pin:!1}));return n("Wrote "+h.cid),{cid:h.cid,size:h.size}},S=(t,e)=>async function*(){let r=0;for await(const n of t){if(r+=n.length,r>e)return void(yield n.slice(0,e-r));yield n}},I=(t,e=b)=>{const r=new Uint8Array(e,0),n={[Symbol.asyncIterator]:function*(){for(;;)yield r.slice()}};return S(n,t)},A=async function*(t){for(let e=0;e{if(!t)throw n(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");if(("string"==typeof t||t instanceof String)&&(i("Content was a string"),t=o(t)),t.length)return i("Content was array-like"),{[Symbol.asyncIterator]:function*(){yield t}};if(t[Symbol.asyncIterator])return i("Content was an async iterator"),t;if(t[Symbol.iterator])return i("Content was an iterator"),t;if(e.Blob&&t instanceof e.Blob){i("Content was an HTML5 Blob");let r=0;const n={next:()=>r>t.size?{done:!0}:new Promise((n,i)=>{const o=t.slice(r,s);r+=s;const a=new e.FileReader,c=t=>{if(a.removeEventListener("loadend",c,!1),t.error)return i(t.error);n({done:!1,value:new Uint8Array(a.result,a.result.byteOffset,a.result.byteLength)})};a.addEventListener("loadend",c),a.readAsArrayBuffer(o)})};return{[Symbol.asyncIterator]:()=>n}}throw n(new Error(`Don't know how to convert ${t} into an async iterator`),"ERR_INVALID_PARAMS")}}).call(this,r(11))},function(t,e,r){"use strict";const n=r(39),i=r(46),s=r(42),o=r(0),{withTimeoutOption:a}=r(2),c={offset:0,length:1/0,signal:void 0};t.exports=t=>a((function(e,r={}){return r=i(r,c),{[Symbol.asyncIterator]:async function*(){const i=await s(t,e,r),a=await n(i.mfsPath,t.ipld);if("file"!==a.unixfs.type)throw o(new Error(e+" was not a file"),"ERR_NOT_FILE");if(!a.content)throw o(new Error("Could not load content stream from "+e),"ERR_NO_CONTENT");for await(const t of a.content({offset:r.offset,length:r.length}))yield t}}}))},function(t,e,r){"use strict";const n=r(39),i=r(42),{MFS_FILE_TYPES:s,withTimeoutOption:o}=r(2),a=t=>{let e,r,n=0,i=t.node.size||t.node.length;t.unixfs&&(i=t.unixfs.fileSize(),n=s[t.unixfs.type],e=t.unixfs.mode,r=t.unixfs.mtime);const o={cid:t.cid,name:t.name,type:n,size:i};return void 0!==r&&(o.mtime=r),void 0!==e&&(o.mode=e),o};t.exports=t=>o((async function*(e,r={}){const s=await i(t,e,r),o=await n(s.mfsPath,t.ipld);if(o.unixfs&&o.unixfs.type.includes("directory"))for await(const t of o.content(r))yield a(t);else yield a(o)}))},function(t,e,r){"use strict";const n=r(39),i=r(0),{normalizeCidPath:s,mapFile:o,withTimeoutOption:a}=r(2);t.exports=function({ipld:t,preload:e}){return a((async function*(r,a){if(!1!==(a=a||{}).preload){let t;try{t=s(r).split("/")}catch(c){throw i(c,"ERR_INVALID_PATH")}e(t[0])}for await(const e of n.recursive(r,t,a))yield o(e,{...a,includeContent:!0})}))}},function(t,e,r){"use strict";const n=r(285).version,i=r(17),{withTimeoutOption:s}=r(2),o=r(5);t.exports=({peerId:t,libp2p:e})=>s((async function(r){const s=t.toB58String();let a=[],c=[];return e&&(a=e.transportManager.getAddrs(),c=Array.from(e.upgrader.protocols.keys())),{id:s,publicKey:o(t.pubKey.bytes,"base64pad"),addresses:a.map(t=>{const e=t.toString();return e.endsWith("/p2p/"+s)?e:`${e}/p2p/${s}`}).sort().map(t=>i(t)),agentVersion:"js-ipfs/"+n,protocolVersion:"9000",protocols:c.sort()}}))},function(t,e,r){"use strict";const n=r(1)("ipfs:components:init"),i=r(7),s=r(6),o=r(5),a=r(33),c=r(167),u=r(640),h=r(275),{DAGNode:f}=r(16),l=r(29),d=r(19),{AlreadyInitializingError:p,AlreadyInitializedError:y,NotStartedError:g,NotEnabledError:b}=r(85),m=r(713),v=r(714),w=r(717),_=r(718),{ERR_REPO_NOT_INITIALIZED:E}=r(177).errors,S=r(315),I=r(316),A=r(737),k=r(88),T=r(112);function R(t,e){return(t||[]).reduce((t,e)=>{const i=r(272).profiles[e];if(!i)throw new Error(`Could not find profile with name '${e}'`);return n("applying profile %s",e),i.transform(t)},e)}t.exports=({apiManager:t,print:e,options:r})=>async function(C){const{cancel:B}=t.update({init:()=>{throw new p}});try{C=C||{},"object"==typeof r.init&&(C=a(r.init,C)),C.pass=C.pass||r.pass,r.config&&(C.config=a(C.config,r.config)),C.repo=C.repo||r.repo,C.repoAutoMigrate=C.repoAutoMigrate||r.repoAutoMigrate;const p="string"==typeof C.repo||null==C.repo?u({path:C.repo,autoMigrate:C.repoAutoMigrate,silent:r.silent}):C.repo;let B=!0;if(p.closed)try{await p.open()}catch(M){if(M.code!==E)throw M;B=!1}if(!B&&!1===C.allowNew)throw new b("new repo initialization is not enabled");const{peerId:x,keychain:N}=B?await async function(t,{config:e,profiles:r,pass:n}){let s=await t.config.getAll();(e||r)&&(r&&(s=R(r,s)),e&&(s=a(s,e)),await t.config.set(s));const o=await i.createFromPrivKey(s.Identity.PrivKey),c=T.libp2p({peerId:o,repo:t,config:s,keychainConfig:{pass:n,...s.Keychain}});return c.keychain&&await c.loadKeychain(),{peerId:o,keychain:c.keychain}}(p,C):await async function(t,{privateKey:e,emptyRepo:r,algorithm:u,bits:h,profiles:f,config:l,pass:d,print:p}){r=r||!1,h=null==h?2048:Number(h),l=a(R(f,c()),l);const y=await t.exists();if(n("repo exists?",y),!0===y)throw new Error("repo already exists");const g=await function({privateKey:t,algorithm:e="rsa",bits:r,print:o}){return t?(n("using user-supplied private-key"),"object"==typeof t?t:i.createFromPrivKey(s(t,"base64pad"))):(o("generating %s-bit (rsa only) %s keypair...",r,e),i.create({keyType:e,bits:r}))}({privateKey:e,algorithm:u,bits:h,print:p});n("identity generated"),l.Identity={PeerID:g.toB58String(),PrivKey:o(g.privKey.bytes,"base64pad")},e=g.privKey,n("peer identity: %s",l.Identity.PeerID),await t.init(l),await t.open(),n("repo opened");const b=T.libp2p({peerId:g,repo:t,config:l,keychainConfig:{pass:d}});b.keychain&&b.keychain.opts&&(await b.loadKeychain(),await t.config.set("Keychain",{dek:b.keychain.opts.dek}));return{peerId:g,keychain:b.keychain}}(p,{...C,print:e});n("peer created");const P=new m(p),O=new v(w(P,r.ipld,n)),D=_(r.preload);await D.start();const L=h(p.path,{singleProcess:!1!==r.repoOwner}),U={get:T.dag.get({ipld:O,preload:D}),resolve:T.dag.resolve({ipld:O,preload:D}),tree:T.dag.tree({ipld:O,preload:D})},j={data:T.object.data({ipld:O,preload:D}),get:T.object.get({ipld:O,preload:D}),links:T.object.links({dag:U}),new:T.object.new({ipld:O,preload:D}),patch:{addLink:T.object.patch.addLink({ipld:O,gcLock:L,preload:D}),appendData:T.object.patch.appendData({ipld:O,gcLock:L,preload:D}),rmLink:T.object.patch.rmLink({ipld:O,gcLock:L,preload:D}),setData:T.object.patch.setData({ipld:O,gcLock:L,preload:D})},put:T.object.put({ipld:O,gcLock:L,preload:D}),stat:T.object.stat({ipld:O,preload:D})},z=new k(p,U),F=T.pin.addAll({pinManager:z,gcLock:L,dag:U}),K=T.pin.rmAll({pinManager:z,gcLock:L,dag:U}),q={add:T.pin.add({addAll:F}),addAll:F,ls:T.pin.ls({pinManager:z,dag:U}),rm:T.pin.rm({rmAll:K}),rmAll:K};U.put=T.dag.put({ipld:O,pin:q,gcLock:L,preload:D});const V={get:T.block.get({blockService:P,preload:D}),put:T.block.put({blockService:P,pin:q,gcLock:L,preload:D}),rm:T.block.rm({blockService:P,gcLock:L,pinManager:z}),stat:T.block.stat({blockService:P,preload:D})},H=T.addAll({block:V,preload:D,pin:q,gcLock:L,options:r});if(!B&&!C.emptyRepo){const t=await async function({dag:t,pin:e}){const r=new f(new l("directory").marshal()),n=await t.put(r,{version:0,format:d.DAG_PB,hashAlg:d.SHA2_256,preload:!1});return await e.add(n),n}({dag:U,pin:q});n("adding default assets"),await A({addAll:H,print:e}),n("initializing IPNS keyspace");const r=new I(p),i=new S(r,p.datastore,x,N,{pass:C.pass});await i.initializeKeyspace(x.privKey,t.toString())}const G=function({add:t,addAll:e,apiManager:r,constructorOptions:n,block:i,blockService:s,dag:o,gcLock:a,initOptions:c,ipld:u,keychain:h,object:f,peerId:l,pin:d,pinManager:p,preload:b,print:m,repo:v}){const w=async()=>{throw new g},_=T.resolve({ipld:u}),E=T.refs({ipld:u,resolve:_,preload:b});E.local=T.refs.local({repo:v});return{add:t,addAll:e,bitswap:{stat:w,unwant:w,wantlist:w,wantlistForPeer:w},bootstrap:{add:T.bootstrap.add({repo:v}),list:T.bootstrap.list({repo:v}),rm:T.bootstrap.rm({repo:v})},block:i,cat:T.cat({ipld:u,preload:b}),config:T.config({repo:v}),dag:o,dns:T.dns(),files:T.files({ipld:u,block:i,blockService:s,repo:v,preload:b,options:n}),get:T.get({ipld:u,preload:b}),id:T.id({peerId:l}),init:async()=>{throw new y},isOnline:T.isOnline({}),key:{export:T.key.export({keychain:h}),gen:T.key.gen({keychain:h}),import:T.key.import({keychain:h}),info:T.key.info({keychain:h}),list:T.key.list({keychain:h}),rename:T.key.rename({keychain:h}),rm:T.key.rm({keychain:h})},ls:T.ls({ipld:u,preload:b}),object:f,pin:d,refs:E,repo:{gc:T.repo.gc({gcLock:a,pin:d,pinManager:p,refs:E,repo:v}),stat:T.repo.stat({repo:v}),version:T.repo.version({repo:v})},resolve:_,start:T.start({apiManager:r,options:n,blockService:s,gcLock:a,initOptions:c,ipld:u,keychain:h,peerId:l,pinManager:p,preload:b,print:m,repo:v}),stats:{bitswap:w,bw:w,repo:T.repo.stat({repo:v})},stop:()=>{},swarm:{addrs:w,connect:w,disconnect:w,localAddrs:T.swarm.localAddrs({multiaddrs:[]}),peers:w},version:T.version({repo:v})}}({add:T.add({addAll:H}),addAll:H,apiManager:t,constructorOptions:r,block:V,blockService:P,dag:U,gcLock:L,initOptions:C,ipld:O,keychain:N,object:j,peerId:x,pin:q,pinManager:z,preload:D,print:e,repo:p});t.update(G,()=>{throw new g});return t.api}catch(M){throw B(),M}}},function(t,e,r){"use strict";const n=r(177);t.exports=t=>{const e=(t=t||{}).path||"ipfs";return new n(e,{autoMigrate:t.autoMigrate})}},function(t,e,r){"use strict";const n=r(642),i=r(655),s=r(657),o=r(179),a=r(1)("ipfs:repo:migrator");function c(t){return t=t||n,Array.isArray(t)&&0!==t.length?t[t.length-1].version:0}function u(t,e,r,n=!1){let i=0;for(const s of t){if(s.version>r)break;if(s.version>e){if(n&&!s.revert)throw new o.NonReversibleMigrationError(`It is not possible to revert to version ${e} because migration version ${s.version} is not reversible. Cancelling reversion.`);i++}}if(i!==r-e)throw new o.InvalidValueError(`The ipfs-repo-migrations package does not have all migration to migrate from version ${e} to ${r}`)}e.getCurrentRepoVersion=i.getVersion,e.errors=o,e.getLatestMigrationVersion=c,e.migrate=async function(t,e,r,{ignoreLock:h=!1,onProgress:f,isDryRun:l=!1,migrations:d}){if(d=d||n,!t)throw new o.RequiredParameterError("Path argument is required!");if(!e)throw new o.RequiredParameterError("repoOptions argument is required!");if(!r)throw new o.RequiredParameterError("toVersion argument is required!");if(!Number.isInteger(r)||r<=0)throw new o.InvalidValueError("Version has to be positive integer!");const p=await i.getVersion(t,e);if(p===r)return void a("Nothing to migrate.");if(p>r)throw new o.InvalidValueError(`Current repo's version (${p}) is higher then toVersion (${r}), you probably wanted to revert it?`);let y;u(d,p,r),l||h||(y=await s.lock(p,t));try{for(const n of d){if(void 0!==r&&n.version>r)break;if(!(n.version<=p)){a("Migrating version "+n.version);try{if(!l){let r;f&&(r=(t,e)=>f(n.version,t.toFixed(2),e)),await n.migrate(t,e,r)}}catch(g){const r=n.version-1;throw a("An exception was raised during execution of migration. Setting the repo's version to last successfully migrated version: "+r),await i.setVersion(t,r,e),new Error(`During migration to version ${n.version} exception was raised: ${g.stack||g.message||g}`)}a(`Migrating to version ${n.version} finished`)}}l||await i.setVersion(t,r||c(d),e),a("Repo successfully migrated ",void 0!==r?`to version ${r}!`:"to latest version!")}finally{l||h||await y.close()}},e.revert=async function(t,e,r,{ignoreLock:c=!1,onProgress:h,isDryRun:f=!1,migrations:l}){if(l=l||n,!t)throw new o.RequiredParameterError("Path argument is required!");if(!e)throw new o.RequiredParameterError("repoOptions argument is required!");if(!r)throw new o.RequiredParameterError("When reverting migrations, you have to specify to which version to revert!");if(!Number.isInteger(r)||r<=0)throw new o.InvalidValueError("Version has to be positive integer!");const d=await i.getVersion(t,e);if(d===r)return void a("Nothing to revert.");if(dd)){a("Reverting migration version "+s.version);try{if(!f){let r;h&&(r=(t,e)=>h(s.version,t.toFixed(2),e)),await s.revert(t,e,r)}}catch(y){const r=s.version;throw a("An exception was raised during execution of migration. Setting the repo's version to last successfully reverted version: "+r),await i.setVersion(t,r,e),y.message=`During reversion to version ${s.version} exception was raised: ${y.message}`,y}a(`Reverting to version ${s.version} finished`)}}f||await i.setVersion(t,r,e),a(`All migrations successfully reverted to version ${r}!`)}finally{f||c||await p.close()}}},function(t,e,r){"use strict";const n={description:"Empty migration.",migrate:()=>{},revert:()=>{},empty:!0};t.exports=[Object.assign({version:1},n),Object.assign({version:2},n),Object.assign({version:3},n),Object.assign({version:4},n),Object.assign({version:5},n),Object.assign({version:6},n),Object.assign({version:7},n),r(643),r(651)]},function(t,e,r){"use strict";const n=r(4),i=r(10).Key,s=r(31),o=r(1)("ipfs:repo:migrator:migration-8"),a=r(5),{createStore:c}=r(120),u=r(290);function h(t){const e=s.decode("b"+t.toString().slice(1));let r=new n(e).multihash;return r=s.encode("base32",r).slice(1),r=a(r).toUpperCase(),new i("/"+r,!1)}function f(t){const e=s.decode("b"+t.toString().slice(1)),r=s.encode("base32",new n(1,"raw",e).bytes).slice(1);return new i(("/"+a(r)).toUpperCase(),!1)}async function l(t,e,r,n){const i=await c(t,"blocks",e);let s;await i.open(),r&&(s=await u(i.query({keysOnly:!0,filters:[({key:t})=>n(t).toString()!==t.toString()]})));try{let t=0;for await(const e of i.query({})){const a=n(e.key);a.toString()!==e.key.toString()&&(t+=1,o(`Migrating Block from ${e.key} to ${a}`),await i.delete(e.key),await i.put(a,e.value),r&&r(t/s*100,`Migrated Block from ${e.key} to ${a}`))}}finally{await i.close()}}t.exports={version:8,description:"Transforms key names into base32 encoding and converts Block store to use bare multihashes encoded as base32",migrate:(t,e,r)=>l(t,e,r,h),revert:(t,e,r)=>l(t,e,r,f)}},function(t,e,r){"use strict";const{Adapter:n,Key:i}=r(10),s=r(287),o=r(121),{utf8Encoder:a}=r(288),c=new i(s.SHARDING_FN),u=new i(s.README_FN);class h extends n{constructor(t,e){super(),this.child=new o(t,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=e}open(){return this.child.open()}_convertKey(t){const e=t.toString();if(e===c.toString()||e===u.toString())return t;return new i(this.shard.fun(e)).child(t)}_invertKey(t){const e=t.toString();return e===c.toString()||e===u.toString()?t:i.withNamespaces(t.list().slice(1))}static async createOrOpen(t,e){try{await h.create(t,e)}catch(r){if(r&&"datastore exists"!==r.message)throw r}return h.open(t)}static async open(t){const e=await s.readShardFun("/",t);return new h(t,e)}static async create(t,e){if(!await t.has(c)){const r="function"==typeof t.putRaw?t.putRaw.bind(t):t.put.bind(t);return Promise.all([r(c,a.encode(e.toString()+"\n")),r(u,a.encode(s.readme))])}const r=(await s.readShardFun("/",t)||"").toString(),n=e.toString();if(r!==n)throw new Error(`specified fun ${n} does not match repo shard fun ${r}`);throw new Error("datastore exists")}put(t,e,r){return this.child.put(t,e,r)}get(t,e){return this.child.get(t,e)}has(t,e){return this.child.has(t,e)}delete(t,e){return this.child.delete(t,e)}batch(){return this.child.batch()}query(t,e){const r={keysOnly:t.keysOnly,offset:t.offset,limit:t.limit,filters:[t=>t.key.toString()!==c.toString(),t=>t.key.toString()!==u.toString()]};if(null!=t.prefix&&r.filters.push(e=>this._invertKey(e.key).toString().startsWith(t.prefix)),null!=t.filters){const e=t.filters.map(t=>e=>t(Object.assign({},e,{key:this._invertKey(e.key)})));r.filters=r.filters.concat(e)}return null!=t.orders&&(r.orders=t.orders.map(t=>async e=>{e.forEach(t=>{t.key=this._invertKey(t.key)});const r=await t(e);return r.forEach(t=>{t.key=this._convertKey(t.key)}),r})),this.child.query(r,e)}close(){return this.child.close()}}t.exports=h},function(t,e,r){"use strict";t.exports=r(289).TextEncoder},function(t,e,r){"use strict";t.exports=r(289).TextDecoder},function(t,e,r){"use strict";t.exports="This is a repository of IPLD objects. Each IPLD object is in a single file,\nnamed .data. Where is the\n\"base32\" encoding of the CID (as specified in\nhttps://github.com/multiformats/multibase) without the 'B' prefix.\nAll the object files are placed in a tree of directories, based on a\nfunction of the CID. This is a form of sharding similar to\nthe objects directory in git repositories. Previously, we used\nprefixes, we now use the next-to-last two charters.\n func NextToLast(base32cid string) {\n nextToLastLen := 2\n offset := len(base32cid) - nextToLastLen - 1\n return str[offset : offset+nextToLastLen]\n }\nFor example, an object with a base58 CIDv1 of\n zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f\nhas a base32 CIDv1 of\n BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA\nand will be placed at\n SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data\nwith 'SC' being the last-to-next two characters and the 'B' at the\nbeginning of the CIDv1 string is the multibase prefix that is not\nstored in the filename.\n"},function(t,e,r){"use strict";const{Adapter:n,Key:i,Errors:s,utils:{filter:o,take:a,sortAll:c,replaceStartWith:u}}=r(10),h=r(121);t.exports=class extends n{constructor(t){super(),this.mounts=t.slice()}open(){return Promise.all(this.mounts.map(t=>t.datastore.open()))}_lookup(t){for(const e of this.mounts)if(e.prefix.toString()===t.toString()||e.prefix.isAncestorOf(t)){const r=u(t.toString(),e.prefix.toString());return{datastore:e.datastore,mountpoint:e.prefix,rest:new i(r)}}}put(t,e,r){const n=this._lookup(t);if(null==n)throw s.dbWriteFailedError(new Error("No datastore mounted for this key"));return n.datastore.put(n.rest,e,r)}get(t,e){const r=this._lookup(t);if(null==r)throw s.notFoundError(new Error("No datastore mounted for this key"));return r.datastore.get(r.rest,e)}has(t,e){const r=this._lookup(t);return null!=r&&r.datastore.has(r.rest,e)}delete(t,e){const r=this._lookup(t);if(null==r)throw s.dbDeleteFailedError(new Error("No datastore mounted for this key"));return r.datastore.delete(r.rest,e)}close(){return Promise.all(this.mounts.map(t=>t.datastore.close()))}batch(){const t={},e=e=>{const r=this._lookup(e);if(null==r)throw new Error("No datastore mounted for this key");const n=r.mountpoint.toString();return null==t[n]&&(t[n]=r.datastore.batch()),{batch:t[n],rest:r.rest}};return{put:(t,r)=>{const n=e(t);n.batch.put(n.rest,r)},delete:t=>{const r=e(t);r.batch.delete(r.rest)},commit:e=>Promise.all(Object.keys(t).map(r=>t[r].commit(e)))}}query(t,e){const r=this.mounts.map(r=>{const n=new h(r.datastore,{convert:t=>{throw new Error("should never be called")},invert:t=>r.prefix.child(t)});let i;return null!=t.prefix&&(i=u(t.prefix,r.prefix.toString())),n.query({prefix:i,filters:t.filters,keysOnly:t.keysOnly},e)});let n=(i=r,async function*(){for(let t=0;t{n=o(n,t)}),t.orders&&t.orders.forEach(t=>{n=c(n,t)}),null!=t.offset){let e=0;n=o(n,()=>e++>=t.offset)}return null!=t.limit&&(n=a(n,t.limit)),n}}},function(t,e,r){"use strict";const{Adapter:n,Errors:i}=r(10),s=r(1)("datastore:core:tiered");t.exports=class extends n{constructor(t){super(),this.stores=t.slice()}async open(){try{await Promise.all(this.stores.map(t=>t.open()))}catch(t){throw i.dbOpenFailedError()}}async put(t,e){try{await Promise.all(this.stores.map(r=>r.put(t,e)))}catch(r){throw i.dbWriteFailedError()}}async get(t,e){for(const n of this.stores)try{const r=await n.get(t,e);if(r)return r}catch(r){s(r)}throw i.notFoundError()}async has(t,e){for(const r of this.stores)if(await r.has(t,e))return!0;return!1}async delete(t,e){try{await Promise.all(this.stores.map(r=>r.delete(t,e)))}catch(r){throw i.dbDeleteFailedError()}}async close(){await Promise.all(this.stores.map(t=>t.close()))}batch(){const t=this.stores.map(t=>t.batch());return{put:(e,r)=>{t.forEach(t=>t.put(e,r))},delete:e=>{t.forEach(t=>t.delete(e))},commit:async e=>{for(const r of t)await r.commit(e)}}}query(t,e){return this.stores[this.stores.length-1].query(t,e)}}},function(t,e,r){"use strict";const n=r(10).Key,i=r(121);t.exports=class extends i{constructor(t,e){super(t,{convert:t=>e.child(t),invert(t){if("/"===e.toString())return t;if(!e.isAncestorOf(t))throw new Error(`Expected prefix: (${e.toString()}) in key: ${t.toString()}`);return new n(t.toString().slice(e.toString().length),!1)}}),this.prefix=e}query(t){return t.prefix&&"/"!==this.prefix.toString()?super.query(Object.assign({},t,{prefix:this.prefix.child(new n(t.prefix)).toString()})):super.query(t)}}},function(t,e,r){"use strict";const n=r(4),i=r(16),s=r(263),o=r(19),a=r(31),c=r(652),{createStore:u}=r(120),{cidToKey:h,PIN_DS_KEY:f,PinTypes:l}=r(291),d=r(290);async function p(t,e,r,a){if(!await e.has(f))return;const u=await e.get(f),p=new n(u),y=await t.get(h(p)),g=i.util.deserialize(y);let b,m=0;a&&(b=await d(c.loadSet(t,g,l.recursive))+await d(c.loadSet(t,g,l.direct)));for await(const n of c.loadSet(t,g,l.recursive)){m++;const t={depth:1/0};0!==n.version&&(t.version=n.version),"dag-pb"!==n.codec&&(t.codec=o.getNumber(n.codec)),await r.put(h(n),s.encode(t)),a&&a(m/b*100,"Migrated recursive pin "+n)}for await(const n of c.loadSet(t,g,l.direct)){m++;const t={depth:0};0!==n.version&&(t.version=n.version),"dag-pb"!==n.codec&&(t.codec=o.getNumber(n.codec)),await r.put(h(n),s.encode(t)),a(m/b*100,"Migrated direct pin "+n)}await t.delete(h(p)),await e.delete(f)}async function y(t,e,r,u){let p,y=[],g=[],b=0;u&&(p=await d(r.query({keysOnly:!0})));for await(const{key:i,value:c}of r.query({})){b++;const t=s.decode(c),e=new n(t.version||0,t.codec&&o.getName(t.codec)||"dag-pb",a.decode("b"+i.toString().split("/").pop()));0===t.depth?(u&&u(b/p*100,"Reverted direct pin "+e),g.push(e)):(u&&u(b/p*100,"Reverted recursive pin "+e),y.push(e))}u(100,"Updating pin root");const m=new i.DAGNode(new Uint8Array,[await c.storeSet(t,l.recursive,y),await c.storeSet(t,l.direct,g)]).serialize(),v=await i.util.cid(m,{cidVersion:0,hashAlg:o.SHA2_256});await t.put(h(v),m),await e.put(f,v.multihash)}async function g(t,e,r,n){const i=await u(t,"blocks",e),s=await u(t,"datastore",e),o=await u(t,"pins",e);await i.open(),await s.open(),await o.open();try{await n(i,s,o,r)}finally{await o.close(),await s.close(),await i.close()}}t.exports={version:9,description:"Migrates pins to datastore",migrate:(t,e,r)=>g(t,e,r,p),revert:(t,e,r)=>g(t,e,r,y)}},function(t,e,r){"use strict";const n=r(4),i=r(21),s=r(653),o=r(15),a=r(16),{DAGNode:c,DAGLink:u}=a,h=r(19),f=r(654),{cidToKey:l,DEFAULT_FANOUT:d,MAX_ITEMS:p,EMPTY_KEY:y}=r(291),g=r(26),b=r(149),m=r(5),v=r(6),w=r(20),_=i(f);function E(t,e){const r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,t,!0);const i=v(function(t){return new n(t).toBaseEncodedString()}(e)),o=g([r,i],r.byteLength+i.byteLength);return s(m(o))}async function*S(t,e){const r=function(t){const e=t.Data,r=o.decode(e),n=o.decode.bytes;if(n<=0)throw new Error("Invalid Set header length");if(n+r>e.length)throw new Error("Impossibly large set header length");const i=e.slice(n,r+n),s=_.Set.decode(i);if(1!==s.version)throw new Error("Unsupported Set version: "+s.version);if(s.fanout>t.Links.length)throw new Error("Impossibly large fanout");return{header:s,data:e.slice(r+n)}}(e);let n=0;for(const i of e.Links){if(nt.Name===r);if(!n)throw new Error("No link found with name "+r);const i=await t.get(l(n.Hash)),s=a.util.deserialize(i);yield*S(t,s)},storeSet:async function(t,e,r){const n=await function(t,e){return async function e(r,n){const i=_.Set.encode({version:1,fanout:d,seed:n}),s=o.encode(i.length),f=g([s,i]),m=[];for(let t=0;t({link:new u("",1,t.key),data:t.data||new Uint8Array})).sort((t,e)=>b(t.link.Hash.bytes,e.link.Hash.bytes)),e=m.concat(t.map(t=>t.link)),n=g([f,...t.map(t=>t.data)]);return new c(n,e)}{const t=r.reduce((t,e)=>{const r=E(n,e.key)%d;return t[r]=r in t?t[r].concat([e]):[e],t},[]);let i=0;for(const r of t){const t=await e(r,n+1);await v(t,i),i++}return new c(f,m)}async function v(e,r){const n=a.util.serialize(e),i=await a.util.cid(n,{cidVersion:0,hashAlg:h.SHA2_256});await t.put(l(i),n),m[r]=new u("",e.size,i)}}(e,0)}(t,r.map(t=>({key:t,data:null}))),i=n.serialize(n),s=await a.util.cid(i,{cidVersion:0,hashAlg:h.SHA2_256});return await t.put(l(s),i),new u(e,n.size,s)}}},function(t,e,r){"use strict";function n(t){for(var e=n.BASE,r=0,i=t.length;r>>0}n.BASE=2166136261,t.exports=n},function(t,e,r){"use strict";t.exports='\n syntax = "proto2";\n\n package ipfs.pin;\n\n option go_package = "pb";\n\n message Set {\n optional uint32 version = 1;\n optional uint32 fanout = 2;\n optional fixed32 seed = 3;\n }\n'},function(t,e,r){"use strict";const n=r(656),{MissingRepoOptionsError:i,NotInitializedRepoError:s}=r(179),{VERSION_KEY:o,createStore:a}=r(120),c=r(6);e.getVersion=async function(t,e){if(!await n.isRepoInitialized(t,e))throw new s(`Repo in path ${t} is not initialized!`);if(!e)throw new i("Please pass repo options when trying to open a repo");const r=await a(t,"root",e);await r.open();const c=parseInt(await r.get(o));return await r.close(),c},e.setVersion=async function(t,e,r){if(!r)throw new i("Please pass repo options when trying to open a repo");const n=await a(t,"root",r);await n.open(),await n.put(o,c(String(e))),await n.close()}},function(t,e,r){"use strict";const n=r(1)("ipfs:repo:migrator:repo:init"),{CONFIG_KEY:i,VERSION_KEY:s,createStore:o}=r(120),{MissingRepoOptionsError:a}=r(179);e.isRepoInitialized=async function(t,e){if(!e)throw new a("Please pass repo options when trying to open a repo");let r;try{r=await o(t,"root",e),await r.open();const a=await r.has(s),c=await r.has(i);return!(!a||!c)||(n("Version entry present: "+a),n("Config entry present: "+c),!1)}catch(c){return n("While checking if repo is initialized error was thrown: "+c.message),!1}finally{void 0!==r&&await r.close()}}},function(t,e,r){"use strict";const n=r(1)("ipfs:repo:migrator:repo_mem_lock"),i={};e.lock=async function(t,e){const r=e+"/repo.lock";if(n("locking %s",r),!0===i[r])throw Error("There is already present lock for: "+r);return i[r]=!0,{close(){i[r]&&(n("releasing lock %s",r),delete i[r])}}}},function(t,e,r){"use strict";t.exports=function(t,e){if("string"==typeof t)return c(t);if("number"==typeof t)return a(t,e);return null},t.exports.format=a,t.exports.parse=c;var n=/\B(?=(\d{3})+(?!\d))/g,i=/(?:\.0*|(\.[^0]+)0+)$/,s={b:1,kb:1024,mb:1<<20,gb:1<<30,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},o=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function a(t,e){if(!Number.isFinite(t))return null;var r=Math.abs(t),o=e&&e.thousandsSeparator||"",a=e&&e.unitSeparator||"",c=e&&void 0!==e.decimalPlaces?e.decimalPlaces:2,u=Boolean(e&&e.fixedDecimals),h=e&&e.unit||"";h&&s[h.toLowerCase()]||(h=r>=s.pb?"PB":r>=s.tb?"TB":r>=s.gb?"GB":r>=s.mb?"MB":r>=s.kb?"KB":"B");var f=(t/s[h.toLowerCase()]).toFixed(c);return u||(f=f.replace(i,"$1")),o&&(f=f.replace(n,o)),f+a+h}function c(t){if("number"==typeof t&&!isNaN(t))return t;if("string"!=typeof t)return null;var e,r=o.exec(t),n="b";return r?(e=parseFloat(r[1]),n=r[4].toLowerCase()):(e=parseInt(t,10),n="b"),Math.floor(s[n]*e)}},function(t,e,r){"use strict";t.exports=function(...t){return 0===t.length?".":t.join("/")}},function(t,e,r){"use strict";t.exports={repoVersion:9}},function(t,e,r){"use strict";e.create=function(t,e,r){return new(0,r.storageBackends[t])(e,Object.assign({},r.storageBackendOptions[t]||{}))}},function(t,e,r){"use strict";const n=r(10).Key,i=r(1)("ipfs:repo:version"),s=r(5),o=r(6),a=new n("version");t.exports=t=>({exists:async()=>t.has(a),async get(){const e=await t.get(a);return parseInt(s(e),10)},set:async e=>t.put(a,o(String(e))),async check(t){const e=await this.get();i("comparing version: %s and %s",e,t);return e===t||(6===e&&7===t||6===t&&7===e)}})},function(t,e,r){"use strict";const n=r(10).Key,{default:i}=r(92),s=r(286),o=r(664),a=r(0),c=r(180),u=r(5),h=r(6),f=new n("config");t.exports=t=>{const e=new i({concurrency:1}),r={getAll:async(t={})=>r.get(void 0,t),async get(e,r={}){e||(e=void 0);const n=await t.get(f);if(r.signal&&r.signal.aborted)return;const i=JSON.parse(u(n));if(void 0!==e&&void 0===s(i,e))throw new c.NotFoundError(`Key ${e} does not exist in config`);return void 0!==e?s(i,e):i},async set(t,r,i={}){if(1===arguments.length)r=t,t=void 0;else if(!t||"string"!=typeof t)throw a(new Error("Invalid key type: "+typeof t),"ERR_INVALID_KEY");if(void 0===r||r instanceof Uint8Array)throw a(new Error("Invalid value type: "+typeof r),"ERR_INVALID_VALUE");return e.add(()=>n({key:t,value:r},i.signal))},async replace(t,r={}){if(!t||t instanceof Uint8Array)throw a(new Error("Invalid value type: "+typeof t),"ERR_INVALID_VALUE");return e.add(()=>n({key:void 0,value:t},r.signal))},exists:async()=>t.has(f)};return r;async function n(t,e){if(e&&e.aborted)return;const n=t.key,i=t.value;if(n){const t=await r.get();return o(t,n,i),l(t)}return l(i)}function l(e){const r=h(JSON.stringify(e,null,2));return t.put(f,r)}}},function(t,e,r){"use strict";t.exports=function(t,e,r){"string"==typeof e&&(e=e.split("."));"symbol"==typeof e&&(e=[e]);var n,i=e.pop();if(!i)return!1;for(;n=e.shift();)if(void 0===t[n]&&(t[n]={}),!(t=t[n])||"object"!=typeof t)return!1;return t[i]=r,!0}},function(t,e,r){"use strict";const n=r(10).Key,i=r(666),s=r(5),o=r(6),a=new n("datastore_spec");t.exports=t=>({exists:async()=>t.has(a),async get(){const e=await t.get(a);return JSON.parse(s(e))},set:async e=>t.put(a,o(JSON.stringify(i(e,{deep:!0}))))})},function(t,e,r){"use strict";const n=r(667);t.exports=(t,e={})=>{if(!n(t))throw new TypeError("Expected a plain object");const{deep:r}=e,i=[],s=[],o=t=>{const e=i.indexOf(t);if(-1!==e)return s[e];const r=[];return i.push(t),s.push(r),r.push(...t.map(t=>Array.isArray(t)?o(t):n(t)?a(t):t)),r},a=t=>{const c=i.indexOf(t);if(-1!==c)return s[c];const u={},h=Object.keys(t).sort(e.compare);i.push(t),s.push(u);for(const e of h){const i=t[e];r&&Array.isArray(i)?u[e]=o(i):u[e]=r&&n(i)?a(i):i}return u};return a(t)}},function(t,e,r){"use strict";t.exports=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}},function(t,e,r){"use strict";const n=r(10).Key,i=r(6),s=new n("api");t.exports=t=>({async get(){const e=await t.get(s);return e&&e.toString()},set:async e=>t.put(s,i(e.toString())),delete:async()=>t.delete(s)})},function(t,e,r){"use strict";(function(e){const n=r(178),i=n.ShardingDatastore,s=r(87),{cidToKey:o,keyToCid:a}=r(292),c=r(155),u=r(257),h=r(94);t.exports=async(t,r)=>function(t){return{async*query(e,r){for await(const{key:n,value:i}of t.query(e,r))e.keysOnly?yield a(n):yield new s(i,a(n))},async get(e,r){const n=o(e),i=await t.get(n,r);return new s(i,e)},async*getMany(t,e){for await(const r of t)yield this.get(r,e)},async put(e,r){if(!s.isBlock(e))throw new Error("invalid block");const n=o(e.cid);return await t.has(n,r)||await t.put(n,e.data,r),e},async*putMany(r,n){const i=h();(e&&e.nextTick?e.nextTick:setImmediate)(async()=>{try{await u(t.putMany(async function*(){for await(const e of r){const r=o(e.cid);await t.has(r,n)||(yield{key:r,value:e.data}),i.push(e)}}())),i.end()}catch(e){i.end(e)}}),yield*i},has:async(e,r)=>t.has(o(e),r),delete:async(e,r)=>t.delete(o(e),r),async*deleteMany(e,r){yield*t.deleteMany(c(e,t=>o(t)),r)},close:async()=>t.close()}}(await function(t,e){if(e.sharding){const e=new n.shard.NextToLast(2);return i.createOrOpen(t,e)}return t}(t,r))}).call(this,r(12))},function(t,e,r){"use strict";t.exports=class{constructor(t){if(!(t>0)||0!=(t-1&t))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){const t=this.buffer[this.btm];if(void 0!==t)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return void 0===this.buffer[this.btm]}}},function(t,e,r){"use strict";t.exports={lock:"memory",storageBackends:{root:r(95),blocks:r(95),keys:r(95),datastore:r(95),pins:r(95)},storageBackendOptions:{root:{extension:"",prefix:"",version:2},blocks:{sharding:!1,prefix:"",version:2},keys:{sharding:!1,prefix:"",version:2},datastore:{sharding:!1,prefix:"",version:2},pins:{sharding:!1,prefix:"",version:2}}}},function(t,e,r){"use strict";t.exports=r(673)(r(705))},function(t,e,r){"use strict";var n=r(674),i=r(701);t.exports=function(t){function e(e,s,o){return"function"==typeof e?o=e:"function"==typeof s&&(o=s),r(s)||(s=r(e)?e:{}),n(i(t(e,s),s),s,o)}function r(t){return"object"==typeof t&&null!==t}return["destroy","repair"].forEach((function(r){"function"==typeof t[r]&&(e[r]=function(){t[r].apply(t,arguments)})})),e.errors=n.errors,e}},function(t,e,r){"use strict";(function(e){var n=r(14).EventEmitter,i=r(65).inherits,s=r(70),o=r(675),a=r(684),c=r(692),u=r(185),h=r(181),f=r(696),l=r(304),d=r(122).getCallback,p=r(122).getOptions,y=u.WriteError,g=u.ReadError,b=u.NotFoundError,m=u.OpenError,v=u.InitializationError;function w(t,r,i){if(!(this instanceof w))return new w(t,r,i);var s,a=this;if(n.call(this),this.setMaxListeners(1/0),"function"==typeof r&&(i=r,r={}),r=r||{},!t||"object"!=typeof t){if(s=new v("First argument must be an abstract-leveldown compliant store"),"function"==typeof i)return e.nextTick(i,s);throw s}f.strictEqual(typeof t.status,"string",".status required, old abstract-leveldown"),this.options=p(r),this._db=t,this.db=new o(t),this.open(i||function(t){t&&a.emit("error",t)}),this.supports=h(this.db.supports,{status:!1,deferredOpen:!0,openCallback:!0,promises:!0,streams:!0}),Object.keys(this.supports.additionalMethods).forEach((function(t){null==this[t]&&(this[t]=function(){return this.db[t].apply(this.db,arguments)})}),this)}function _(t,r){if(!t._isOpening()&&!t.isOpen())return e.nextTick(r,new g("Database is not open")),!0}w.prototype.emit=n.prototype.emit,w.prototype.once=n.prototype.once,i(w,n),w.prototype.open=function(t,r){var n,i=this;return"function"==typeof t&&(r=t,t=null),r||(n=(r=l()).promise),t||(t=this.options),this.isOpen()?(e.nextTick(r,null,i),n):this._isOpening()?(this.once("open",(function(){r(null,i)})),n):(this.emit("opening"),this.db.open(t,(function(t){if(t)return r(new m(t));i.db=i._db,r(null,i),i.emit("open"),i.emit("ready")})),n)},w.prototype.close=function(t){var r,n=this;return t||(r=(t=l()).promise),this.isOpen()?(this.db.close((function(){n.emit("closed"),t.apply(null,arguments)})),this.emit("closing"),this.db=new o(this._db)):this.isClosed()?e.nextTick(t):"closing"===this.db.status?this.once("closed",t):this._isOpening()&&this.once("open",(function(){n.close(t)})),r},w.prototype.isOpen=function(){return"open"===this.db.status},w.prototype._isOpening=function(){return"opening"===this.db.status},w.prototype.isClosed=function(){return/^clos|new/.test(this.db.status)},w.prototype.get=function(t,e,r){var n;return(r=d(e,r))||(n=(r=l()).promise),_(this,r)||(e=p(e),this.db.get(t,e,(function(e,n){if(e)return e=/notfound/i.test(e)||e.notFound?new b("Key not found in database ["+t+"]",e):new g(e),r(e);r(null,n)}))),n},w.prototype.put=function(t,e,r,n){var i,s=this;return(n=d(r,n))||(i=(n=l()).promise),_(this,n)||(r=p(r),this.db.put(t,e,r,(function(r){if(r)return n(new y(r));s.emit("put",t,e),n()}))),i},w.prototype.del=function(t,e,r){var n,i=this;return(r=d(e,r))||(n=(r=l()).promise),_(this,r)||(e=p(e),this.db.del(t,e,(function(e){if(e)return r(new y(e));i.emit("del",t),r()}))),n},w.prototype.batch=function(t,e,r){if(!arguments.length)return new c(this);var n,i=this;return(r="function"==typeof t?t:d(e,r))||(n=(r=l()).promise),_(this,r)||(e=p(e),this.db.batch(t,e,(function(e){if(e)return r(new y(e));i.emit("batch",t),r()}))),n},w.prototype.iterator=function(t){return this.db.iterator(t)},w.prototype.clear=function(t,e){var r,n=this;return e=d(t,e),t=p(t),e||(r=(e=l()).promise),_(this,e)||this.db.clear(t,(function(r){if(r)return e(new y(r));n.emit("clear",t),e()})),r},w.prototype.readStream=w.prototype.createReadStream=function(t){return"number"!=typeof(t=s({keys:!0,values:!0},t)).limit&&(t.limit=-1),new a(this.db.iterator(t),t)},w.prototype.keyStream=w.prototype.createKeyStream=function(t){return this.createReadStream(s(t,{keys:!0,values:!1}))},w.prototype.valueStream=w.prototype.createValueStream=function(t){return this.createReadStream(s(t,{keys:!1,values:!0}))},w.prototype.toString=function(){return"LevelUP"},w.prototype.type="levelup",w.errors=u,t.exports=w.default=w}).call(this,r(12))},function(t,e,r){"use strict";var n=r(294).AbstractLevelDOWN,i=r(23),s=r(683),o="put get del batch clear".split(" "),a="approximateSize compactRange".split(" ");function c(t){n.call(this,t.supports||{}),a.forEach((function(e){"function"!=typeof t[e]||this.supports.additionalMethods[e]||(this.supports.additionalMethods[e]=!0)}),this),this._db=t,this._operations=[],u(this)}function u(t){o.forEach((function(e){t["_"+e]=function(){this._operations.push({method:e,args:arguments})}})),Object.keys(t.supports.additionalMethods).forEach((function(e){t[e]=function(){this._operations.push({method:e,args:arguments})}})),t._iterator=function(e){var r=new s(t,e);return this._operations.push({iterator:r}),r}}i(c,n),c.prototype.type="deferred-leveldown",c.prototype._open=function(t,e){var r=this;this._db.open(t,(function(t){if(t)return e(t);r._operations.forEach((function(t){t.iterator?t.iterator.setDb(r._db):r._db[t.method].apply(r._db,t.args)})),r._operations=[],function(t){o.concat("iterator").forEach((function(e){t["_"+e]=function(){return this._db[e].apply(this._db,arguments)}})),Object.keys(t.supports.additionalMethods).forEach((function(e){t[e]=function(){return this._db[e].apply(this._db,arguments)}}))}(r),e()}))},c.prototype._close=function(t){var e=this;this._db.close((function(r){if(r)return t(r);u(e),t()}))},c.prototype._serializeKey=function(t){return t},c.prototype._serializeValue=function(t){return t},t.exports=c,t.exports.DeferredIterator=s},function(t,e,r){"use strict";var n=r(70),i=r(181),s=r(3).Buffer,o=r(295),a=r(296),c=r(182),u=Object.prototype.hasOwnProperty,h="start end gt gte lt lte".split(" ");function f(t){this.status="new",this.supports=i(t,{status:!0})}function l(t,e){var r={};for(var n in e)if(u.call(e,n)){var i=e[n];d(n)&&(i=t._serializeKey(i)),r[n]=i}return r}function d(t){return-1!==h.indexOf(t)}f.prototype.open=function(t,e){var r=this,n=this.status;if("function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("open() requires a callback argument");"object"==typeof t&&null!==t||(t={}),t.createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists,this.status="opening",this._open(t,(function(t){if(t)return r.status=n,e(t);r.status="open",e()}))},f.prototype._open=function(t,e){c(e)},f.prototype.close=function(t){var e=this,r=this.status;if("function"!=typeof t)throw new Error("close() requires a callback argument");this.status="closing",this._close((function(n){if(n)return e.status=r,t(n);e.status="closed",t()}))},f.prototype._close=function(t){c(t)},f.prototype.get=function(t,e,r){if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("get() requires a callback argument");var n=this._checkKey(t);if(n)return c(r,n);t=this._serializeKey(t),"object"==typeof e&&null!==e||(e={}),e.asBuffer=!1!==e.asBuffer,this._get(t,e,r)},f.prototype._get=function(t,e,r){c((function(){r(new Error("NotFound"))}))},f.prototype.put=function(t,e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("put() requires a callback argument");var i=this._checkKey(t)||this._checkValue(e);if(i)return c(n,i);t=this._serializeKey(t),e=this._serializeValue(e),"object"==typeof r&&null!==r||(r={}),this._put(t,e,r,n)},f.prototype._put=function(t,e,r,n){c(n)},f.prototype.del=function(t,e,r){if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("del() requires a callback argument");var n=this._checkKey(t);if(n)return c(r,n);t=this._serializeKey(t),"object"==typeof e&&null!==e||(e={}),this._del(t,e,r)},f.prototype._del=function(t,e,r){c(r)},f.prototype.batch=function(t,e,r){if(!arguments.length)return this._chainedBatch();if("function"==typeof e&&(r=e),"function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(t))return c(r,new Error("batch(array) requires an array argument"));if(0===t.length)return c(r);"object"==typeof e&&null!==e||(e={});for(var i=new Array(t.length),s=0;s0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return o.alloc(0);for(var e,r,n,i=o.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,r=i,n=a,o.prototype.copy.call(e,r,n),a+=s.data.length,s=s.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(s===i.length?n+=i:n+=i.slice(0,t),0==(t-=s)){s===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(s));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=o.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,s=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,s),0==(t-=s)){s===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(s));break}++n}return this.length-=n,e}},{key:c,value:function(t,e){return a(this,function(t){for(var e=1;e0,(function(t){n||(n=t),t&&o.forEach(u),s||(o.forEach(u),i(n))}))}));return e.reduce(h)}},function(t,e,r){"use strict";var n=r(185).WriteError,i=r(304),s=r(122).getCallback,o=r(122).getOptions;function a(t){this.db=this._levelup=t,this.batch=t.db.batch(),this.ops=[],this.length=0}a.prototype.put=function(t,e){try{this.batch.put(t,e)}catch(r){throw new n(r)}return this.ops.push({type:"put",key:t,value:e}),this.length++,this},a.prototype.del=function(t){try{this.batch.del(t)}catch(e){throw new n(e)}return this.ops.push({type:"del",key:t}),this.length++,this},a.prototype.clear=function(){try{this.batch.clear()}catch(t){throw new n(t)}return this.ops=[],this.length=0,this},a.prototype.write=function(t,e){var r,a=this._levelup,c=this.ops;(e=s(t,e))||(r=(e=i()).promise),t=o(t);try{this.batch.write(t,(function(t){if(t)return e(new n(t));a.emit("batch",c),e()}))}catch(u){throw new n(u)}return r},t.exports=a},function(t,e,r){"use strict";var n=t.exports.all=[{errno:-2,code:"ENOENT",description:"no such file or directory"},{errno:-1,code:"UNKNOWN",description:"unknown error"},{errno:0,code:"OK",description:"success"},{errno:1,code:"EOF",description:"end of file"},{errno:2,code:"EADDRINFO",description:"getaddrinfo error"},{errno:3,code:"EACCES",description:"permission denied"},{errno:4,code:"EAGAIN",description:"resource temporarily unavailable"},{errno:5,code:"EADDRINUSE",description:"address already in use"},{errno:6,code:"EADDRNOTAVAIL",description:"address not available"},{errno:7,code:"EAFNOSUPPORT",description:"address family not supported"},{errno:8,code:"EALREADY",description:"connection already in progress"},{errno:9,code:"EBADF",description:"bad file descriptor"},{errno:10,code:"EBUSY",description:"resource busy or locked"},{errno:11,code:"ECONNABORTED",description:"software caused connection abort"},{errno:12,code:"ECONNREFUSED",description:"connection refused"},{errno:13,code:"ECONNRESET",description:"connection reset by peer"},{errno:14,code:"EDESTADDRREQ",description:"destination address required"},{errno:15,code:"EFAULT",description:"bad address in system call argument"},{errno:16,code:"EHOSTUNREACH",description:"host is unreachable"},{errno:17,code:"EINTR",description:"interrupted system call"},{errno:18,code:"EINVAL",description:"invalid argument"},{errno:19,code:"EISCONN",description:"socket is already connected"},{errno:20,code:"EMFILE",description:"too many open files"},{errno:21,code:"EMSGSIZE",description:"message too long"},{errno:22,code:"ENETDOWN",description:"network is down"},{errno:23,code:"ENETUNREACH",description:"network is unreachable"},{errno:24,code:"ENFILE",description:"file table overflow"},{errno:25,code:"ENOBUFS",description:"no buffer space available"},{errno:26,code:"ENOMEM",description:"not enough memory"},{errno:27,code:"ENOTDIR",description:"not a directory"},{errno:28,code:"EISDIR",description:"illegal operation on a directory"},{errno:29,code:"ENONET",description:"machine is not on the network"},{errno:31,code:"ENOTCONN",description:"socket is not connected"},{errno:32,code:"ENOTSOCK",description:"socket operation on non-socket"},{errno:33,code:"ENOTSUP",description:"operation not supported on socket"},{errno:34,code:"ENOENT",description:"no such file or directory"},{errno:35,code:"ENOSYS",description:"function not implemented"},{errno:36,code:"EPIPE",description:"broken pipe"},{errno:37,code:"EPROTO",description:"protocol error"},{errno:38,code:"EPROTONOSUPPORT",description:"protocol not supported"},{errno:39,code:"EPROTOTYPE",description:"protocol wrong type for socket"},{errno:40,code:"ETIMEDOUT",description:"connection timed out"},{errno:41,code:"ECHARSET",description:"invalid Unicode character"},{errno:42,code:"EAIFAMNOSUPPORT",description:"address family for hostname not supported"},{errno:44,code:"EAISERVICE",description:"servname not supported for ai_socktype"},{errno:45,code:"EAISOCKTYPE",description:"ai_socktype not supported"},{errno:46,code:"ESHUTDOWN",description:"cannot send after transport endpoint shutdown"},{errno:47,code:"EEXIST",description:"file already exists"},{errno:48,code:"ESRCH",description:"no such process"},{errno:49,code:"ENAMETOOLONG",description:"name too long"},{errno:50,code:"EPERM",description:"operation not permitted"},{errno:51,code:"ELOOP",description:"too many symbolic links encountered"},{errno:52,code:"EXDEV",description:"cross-device link not permitted"},{errno:53,code:"ENOTEMPTY",description:"directory not empty"},{errno:54,code:"ENOSPC",description:"no space left on device"},{errno:55,code:"EIO",description:"i/o error"},{errno:56,code:"EROFS",description:"read-only file system"},{errno:57,code:"ENODEV",description:"no such device"},{errno:58,code:"ESPIPE",description:"invalid seek"},{errno:59,code:"ECANCELED",description:"operation canceled"}];t.exports.errno={},t.exports.code={},n.forEach((function(e){t.exports.errno[e.errno]=e,t.exports.code[e.code]=e})),t.exports.custom=r(694)(t.exports),t.exports.create=t.exports.custom.createError},function(t,e,r){"use strict";var n=r(695);function i(t,e,r){e&&"string"!=typeof e&&(e=e.message||e.name),n(this,{type:t,name:t,cause:"string"!=typeof e?e:r,message:e},"ewr")}function s(t,e){Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),i.call(this,"CustomError",t,e)}s.prototype=new Error,t.exports=function(t){var e=function(e,r){return function(t,e,r){var n=function(r,s){i.call(this,e,r,s),"FilesystemError"==e&&(this.code=this.cause.code,this.path=this.cause.path,this.errno=this.cause.errno,this.message=(t.errno[this.cause.errno]?t.errno[this.cause.errno].description:this.cause.message)+(this.cause.path?" ["+this.cause.path+"]":"")),Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,n)};return n.prototype=r?new r:new s,n}(t,e,r)};return{CustomError:s,FilesystemError:e("FilesystemError"),createError:e}}},function(t,e,r){"use strict";var n;n=function(){var t="function"==typeof Object.defineProperty?function(t,e,r){return Object.defineProperty(t,e,r),t}:function(t,e,r){return t[e]=r.value,t};return function(e,r,n,i){var s;if(i=function(t,e){var r="object"==typeof e,n=!r&&"string"==typeof e,i=function(t){return r?!!e[t]:!!n&&e.indexOf(t[0])>-1};return{enumerable:i("enumerable"),configurable:i("configurable"),writable:i("writable"),value:t}}(n,i),"object"==typeof r){for(s in r)Object.hasOwnProperty.call(r,s)&&(i.value=r[s],t(e,s,i));return e}return t(e,r,i)}},t.exports?t.exports=n():(void 0).prr=n()},function(t,e,r){"use strict";(function(e){var n=r(697);function i(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i=0;u--)if(h[u]!==f[u])return!1;for(u=h.length-1;u>=0;u--)if(a=h[u],!v(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(r){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(r){e=r}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&b(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!t&&i&&!r;if((!t&&o.isError(i)&&s&&_(i,r)||a)&&b(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return y(g(t.actual),128)+" "+t.operator+" "+y(g(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=p(e),s=n.indexOf("\n"+i);if(s>=0){var o=n.indexOf("\n",s+1);n=n.substring(o+1)}this.stack=n}}},o.inherits(l.AssertionError,Error),l.fail=b,l.ok=m,l.equal=function(t,e,r){t!=e&&b(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&b(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){v(t,e,!1)||b(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){v(t,e,!0)||b(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){v(t,e,!1)&&b(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){v(e,r,!0)&&b(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&b(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&b(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n((function t(e,r){e||b(e,!0,r,"==",t)}),l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,r(11))},function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function o(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(t){n[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(t,e){for(var r,a,c=o(t),u=1;u=s)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}})),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),h(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&S(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return b(i)||(i=h(t,i,n)),i}var s=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(b(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(g(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(y(e))return t.stylize("null","null")}(t,r);if(s)return s;var o=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),E(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(r);if(0===o.length){if(S(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return t.stylize(Date.prototype.toString.call(r),"date");if(E(r))return f(r)}var u,w="",I=!1,A=["{","}"];(d(r)&&(I=!0,A=["[","]"]),S(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(w=" "+RegExp.prototype.toString.call(r)),_(r)&&(w=" "+Date.prototype.toUTCString.call(r)),E(r)&&(w=" "+f(r)),0!==o.length||I&&0!=r.length?n<0?v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),u=I?function(t,e,r,n,i){for(var s=[],o=0,a=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,s){var o,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),R(n,i)||(o="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=y(r)?h(t,c.value,null):h(t,c.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),m(o)){if(s&&i.match(/^\d+$/))return a;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return"number"==typeof t}function b(t){return"string"==typeof t}function m(t){return void 0===t}function v(t){return w(t)&&"[object RegExp]"===I(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===I(t)}function E(t){return w(t)&&("[object Error]"===I(t)||t instanceof Error)}function S(t){return"function"==typeof t}function I(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(m(s)&&(s={NODE_ENV:"production"}.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(s)){var r=n.pid;o[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else o[t]=function(){};return o[t]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=p,e.isNull=y,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=b,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=v,e.isObject=w,e.isDate=_,e.isError=E,e.isFunction=S,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(699);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),k[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",T(),e.format.apply(e,arguments))},e.inherits=r(700),e._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,r(11),r(12))},function(t,e,r){"use strict";t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";var n=r(186).AbstractLevelDOWN,i=r(186).AbstractChainedBatch,s=r(186).AbstractIterator,o=r(23),a=r(703),c=r(185).EncodingError,u=["approximateSize","compactRange"];function h(t,e){if(!(this instanceof h))return new h(t,e);var r=t.supports||{},i=r.additionalMethods||{};n.call(this,r),this.supports.encodings=!0,this.supports.additionalMethods={},u.forEach((function(e){var r="function"==typeof t[e];(i[e]||r)&&(this.supports.additionalMethods[e]=!0,this[e]=function(t,r,n,i){return t=this.codec.encodeKey(t,n),r=this.codec.encodeKey(r,n),this.db[e](t,r,n,i)})}),this),void 0===(e=e||{}).keyEncoding&&(e.keyEncoding="utf8"),void 0===e.valueEncoding&&(e.valueEncoding="utf8"),this.db=t,this.codec=new a(e)}function f(t,e){s.call(this,t),this.codec=t.codec,this.keys=e.keys,this.values=e.values,this.opts=this.codec.encodeLtgt(e),this.it=t.db.iterator(this.opts)}function l(t,e){i.call(this,t),this.codec=t.codec,this.batch=t.db.batch()}t.exports=h.default=h,o(h,n),h.prototype.type="encoding-down",h.prototype._serializeKey=h.prototype._serializeValue=function(t){return t},h.prototype._open=function(t,e){this.db.open(t,e)},h.prototype._close=function(t){this.db.close(t)},h.prototype._put=function(t,e,r,n){t=this.codec.encodeKey(t,r),e=this.codec.encodeValue(e,r),this.db.put(t,e,r,n)},h.prototype._get=function(t,e,r){var n=this;t=this.codec.encodeKey(t,e),e.asBuffer=this.codec.valueAsBuffer(e),this.db.get(t,e,(function(t,i){if(t)return r(t);try{i=n.codec.decodeValue(i,e)}catch(t){return r(new c(t))}r(null,i)}))},h.prototype._del=function(t,e,r){t=this.codec.encodeKey(t,e),this.db.del(t,e,r)},h.prototype._chainedBatch=function(){return new l(this)},h.prototype._batch=function(t,e,r){t=this.codec.encodeBatch(t,e),this.db.batch(t,e,r)},h.prototype._iterator=function(t){return t.keyAsBuffer=this.codec.keyAsBuffer(t),t.valueAsBuffer=this.codec.valueAsBuffer(t),new f(this,t)},h.prototype._clear=function(t,e){t=this.codec.encodeLtgt(t),this.db.clear(t,e)},o(f,s),f.prototype._next=function(t){var e=this;this.it.next((function(r,n,i){if(r)return t(r);try{n=e.keys&&void 0!==n?e.codec.decodeKey(n,e.opts):void 0,i=e.values&&void 0!==i?e.codec.decodeValue(i,e.opts):void 0}catch(r){return t(new c(r))}t(null,n,i)}))},f.prototype._seek=function(t){t=this.codec.encodeKey(t,this.opts),this.it.seek(t)},f.prototype._end=function(t){this.it.end(t)},o(l,i),l.prototype._put=function(t,e){t=this.codec.encodeKey(t),e=this.codec.encodeValue(e),this.batch.put(t,e)},l.prototype._del=function(t){t=this.codec.encodeKey(t),this.batch.del(t)},l.prototype._clear=function(){this.batch.clear()},l.prototype._write=function(t,e){this.batch.write(t,e)}},function(t,e,r){"use strict";var n=r(70),i=r(181),s=r(3).Buffer,o=r(305),a=r(306),c=r(187),u=Object.prototype.hasOwnProperty,h="start end gt gte lt lte".split(" ");function f(t){this.status="new",this.supports=i(t,{status:!0})}function l(t,e){var r={};for(var n in e)if(u.call(e,n)){var i=e[n];d(n)&&(i=t._serializeKey(i)),r[n]=i}return r}function d(t){return-1!==h.indexOf(t)}f.prototype.open=function(t,e){var r=this,n=this.status;if("function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("open() requires a callback argument");"object"==typeof t&&null!==t||(t={}),t.createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists,this.status="opening",this._open(t,(function(t){if(t)return r.status=n,e(t);r.status="open",e()}))},f.prototype._open=function(t,e){c(e)},f.prototype.close=function(t){var e=this,r=this.status;if("function"!=typeof t)throw new Error("close() requires a callback argument");this.status="closing",this._close((function(n){if(n)return e.status=r,t(n);e.status="closed",t()}))},f.prototype._close=function(t){c(t)},f.prototype.get=function(t,e,r){if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("get() requires a callback argument");var n=this._checkKey(t);if(n)return c(r,n);t=this._serializeKey(t),"object"==typeof e&&null!==e||(e={}),e.asBuffer=!1!==e.asBuffer,this._get(t,e,r)},f.prototype._get=function(t,e,r){c((function(){r(new Error("NotFound"))}))},f.prototype.put=function(t,e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("put() requires a callback argument");var i=this._checkKey(t)||this._checkValue(e);if(i)return c(n,i);t=this._serializeKey(t),e=this._serializeValue(e),"object"==typeof r&&null!==r||(r={}),this._put(t,e,r,n)},f.prototype._put=function(t,e,r,n){c(n)},f.prototype.del=function(t,e,r){if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("del() requires a callback argument");var n=this._checkKey(t);if(n)return c(r,n);t=this._serializeKey(t),"object"==typeof e&&null!==e||(e={}),this._del(t,e,r)},f.prototype._del=function(t,e,r){c(r)},f.prototype.batch=function(t,e,r){if(!arguments.length)return this._chainedBatch();if("function"==typeof e&&(r=e),"function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(t))return c(r,new Error("batch(array) requires an array argument"));if(0===t.length)return c(r);"object"==typeof e&&null!==e||(e={});for(var i=new Array(t.length),s=0;s-1?e.encodeKey(t[n],t):t[n]})),r},i.prototype.createStreamDecoder=function(t){var e=this;return t.keys&&t.values?function(r,n){return{key:e.decodeKey(r,t),value:e.decodeValue(n,t)}}:t.keys?function(r){return e.decodeKey(r,t)}:t.values?function(r,n){return e.decodeValue(n,t)}:function(){}},i.prototype.keyAsBuffer=function(t){return this._keyEncoding(t).buffer},i.prototype.valueAsBuffer=function(t){return this._valueEncoding(t).buffer}},function(t,e,r){"use strict";var n=r(3).Buffer;e.utf8=e["utf-8"]={encode:function(t){return s(t)?t:String(t)},decode:i,buffer:!1,type:"utf8"},e.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},e.binary={encode:function(t){return s(t)?t:n.from(t)},decode:i,buffer:!0,type:"binary"},e.none={encode:i,decode:i,buffer:!1,type:"id"},e.id=e.none;function i(t){return t}function s(t){return null==t||n.isBuffer(t)}["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach((function(t){e[t]={encode:function(e){return s(e)?e:n.from(e,t)},decode:function(e){return e.toString(t)},buffer:!0,type:t}}))},function(t,e,r){"use strict";(function(e){t.exports=u;var n=r(307).AbstractLevelDOWN,i=r(23),s=r(707),o=r(310),a=r(311),c=r(711);function u(t,e){if(!(this instanceof u))return new u(t,e);if(n.call(this),e=e||{},"string"!=typeof t)throw new Error("constructor requires a location string argument");this.location=t,this.prefix=null==e.prefix?"level-js-":e.prefix,this.version=parseInt(e.version||1,10)}i(u,n),u.binaryKeys=c.binaryKeys(indexedDB),u.arrayKeys=c.arrayKeys(indexedDB),u.prototype._open=function(t,e){var r=indexedDB.open(this.prefix+this.location,this.version),n=this;r.onerror=function(){e(r.error||new Error("unknown error"))},r.onsuccess=function(){n.db=r.result,e()},r.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(n.location)||e.createObjectStore(n.location)}},u.prototype.store=function(t){return this.db.transaction([this.location],t).objectStore(this.location)},u.prototype.await=function(t,e){var r=t.transaction;r.onabort=function(){e(r.error||new Error("aborted by user"))},r.oncomplete=function(){e(null,t.result)}},u.prototype._get=function(t,e,r){var n=this.store("readonly");try{var i=n.get(t)}catch(s){return a((function(){r(s)}))}this.await(i,(function(t,n){return t?r(t):void 0===n?r(new Error("NotFound")):(e.asBuffer&&(n=o(n)),void r(null,n))}))},u.prototype._del=function(t,e,r){var n=this.store("readwrite");try{var i=n.delete(t)}catch(s){return a((function(){r(s)}))}this.await(i,r)},u.prototype._put=function(t,e,r,n){var i=this.store("readwrite");try{var s=i.put(e,t)}catch(o){return a((function(){n(o)}))}this.await(s,n)},u.prototype._serializeKey=function(t){return e.isBuffer(t)?u.binaryKeys?t:t.toString():Array.isArray(t)?u.arrayKeys?t.map(this._serializeKey,this):String(t):t},u.prototype._serializeValue=function(t){return t},u.prototype._iterator=function(t){return new s(this,this.location,t)},u.prototype._batch=function(t,e,r){if(0===t.length)return a(r);var n,i=this.store("readwrite"),s=i.transaction,o=0;s.onabort=function(){r(n||s.error||new Error("aborted by user"))},s.oncomplete=function(){r()},function e(){var r=t[o++],a=r.key;try{var c="del"===r.type?i.delete(a):i.put(r.value,a)}catch(u){return n=u,void s.abort()}o0){var r=this._cache.shift(),n=this._cache.shift();this._keyAsBuffer&&(r=o(r)),this._valueAsBuffer&&(n=o(n)),a((function(){t(null,r,n)}))}else this._completed?a(t):this._callback=t},u.prototype._end=function(t){if(this._aborted||this._completed){var e=this._error;a((function(){t(e)}))}else this.onItem=c,this.onAbort=t,this.onComplete=t}},function(t,e,r){"use strict";(function(t){function r(t){return void 0!==t&&""!==t}function n(t,e){return Object.hasOwnProperty.call(t,e)}function i(t,e){return Object.hasOwnProperty.call(t,e)&&e}e.compare=function(e,r){if(t.isBuffer(e)){for(var n=Math.min(e.length,r.length),i=0;ir?1:0};var s=e.lowerBoundKey=function(t){return i(t,"gt")||i(t,"gte")||i(t,"min")||(t.reverse?i(t,"end"):i(t,"start"))||void 0},o=e.lowerBound=function(t,e){var r=s(t);return r?t[r]:e},a=e.lowerBoundInclusive=function(t){return!n(t,"gt")},c=e.upperBoundInclusive=function(t){return!n(t,"lt")},u=e.lowerBoundExclusive=function(t){return!a(t)},h=e.upperBoundExclusive=function(t){return!c(t)},f=e.upperBoundKey=function(t){return i(t,"lt")||i(t,"lte")||i(t,"max")||(t.reverse?i(t,"start"):i(t,"end"))||void 0},l=e.upperBound=function(t,e){var r=f(t);return r?t[r]:e};function d(t){return t}e.start=function(t,e){return t.reverse?l(t,e):o(t,e)},e.end=function(t,e){return t.reverse?o(t,e):l(t,e)},e.startInclusive=function(t){return t.reverse?c(t):a(t)},e.endInclusive=function(t){return t.reverse?a(t):c(t)},e.toLtgt=function(t,r,i,s,o){r=r||{},i=i||d;var a=arguments.length>3,c=e.lowerBoundKey(t),u=e.upperBoundKey(t);return c?"gt"===c?r.gt=i(t.gt,!1):r.gte=i(t[c],!1):a&&(r.gte=i(s,!1)),u?"lt"===u?r.lt=i(t.lt,!0):r.lte=i(t[u],!0):a&&(r.lte=i(o,!0)),null!=t.reverse&&(r.reverse=!!t.reverse),n(r,"max")&&delete r.max,n(r,"min")&&delete r.min,n(r,"start")&&delete r.start,n(r,"end")&&delete r.end,r},e.contains=function(t,n,i){i=i||e.compare;var s=o(t);if(r(s)&&((a=i(n,s))<0||0===a&&u(t)))return!1;var a,c=l(t);if(r(c)&&((a=i(n,c))>0||0===a&&h(t)))return!1;return!0},e.filter=function(t,r){return function(n){return e.contains(t,n,r)}}}).call(this,r(3).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(710).strict;t.exports=function(t){if(n(t)){var r=e.from(t.buffer);return t.byteLength!==t.buffer.byteLength&&(r=r.slice(t.byteOffset,t.byteOffset+t.byteLength)),r}return e.from(t)}}).call(this,r(3).Buffer)},function(t,e,r){"use strict";t.exports=s,s.strict=o,s.loose=a;var n=Object.prototype.toString,i={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function s(t){return o(t)||a(t)}function o(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function a(t){return i[n.call(t)]}},function(t,e,r){"use strict";e.test=function(t){return function(e){try{return e.cmp(t,0),!0}catch(r){return!1}}},e.binaryKeys=e.test(new Uint8Array(0)),e.arrayKeys=e.test([1])},function(t,e,r){"use strict";t.exports={Spec:{type:"mount",mounts:[{mountpoint:"/blocks",type:"measure",prefix:"flatfs.datastore",child:{type:"flatfs",path:"blocks",sync:!0,shardFunc:"/repo/flatfs/shard/v1/next-to-last/2"}},{mountpoint:"/",type:"measure",prefix:"leveldb.datastore",child:{type:"levelds",path:"datastore",compression:"none"}}]}}},function(t,e,r){"use strict";const{map:n}=r(52),i=r(0);t.exports=class{constructor(t){this._repo=t,this._bitswap=null}setExchange(t){this._bitswap=t}unsetExchange(){this._bitswap=null}hasExchange(){return null!=this._bitswap}put(t,e){return this.hasExchange()?this._bitswap.put(t,e):this._repo.blocks.put(t,e)}putMany(t,e){return this.hasExchange()?this._bitswap.putMany(t,e):this._repo.blocks.putMany(t,e)}get(t,e){return this.hasExchange()?this._bitswap.get(t,e):this._repo.blocks.get(t,e)}getMany(t,e){if(!Array.isArray(t))throw new Error("first arg must be an array of cids");if(this.hasExchange())return this._bitswap.getMany(t,e);return n(t=>this._repo.blocks.get(t,e))(t)}async delete(t,e){if(!await this._repo.blocks.has(t))throw i(new Error("blockstore: block not found"),"ERR_BLOCK_NOT_FOUND");return this._repo.blocks.delete(t,e)}deleteMany(t,e){const r=this._repo;return this._repo.blocks.deleteMany(async function*(){for await(const e of t){if(!await r.blocks.has(e))throw i(new Error("blockstore: block not found"),"ERR_BLOCK_NOT_FOUND");yield e}}(),e)}}},function(t,e,r){"use strict";const n=r(87),i=r(4),s=r(33),o=r(160),a=r(16),c=r(313),u=r(19),h=r(715),{extendIterator:f}=r(716);class l{constructor(t){const e=s(l.defaultOptions,t);if(!e.blockService)throw new Error("Missing blockservice");this.bs=e.blockService,this.resolvers={},"function"!=typeof e.loadFormat?this.loadFormat=t=>{const e=u.print[t];throw new Error(`No resolver found for codec "${e}"`)}:this.loadFormat=e.loadFormat;for(const r of e.formats)this.addFormat(r)}addFormat(t){const e=t.codec;if(this.resolvers[t.format]){const t=u.print[e];throw new Error(`Resolver already exists for codec "${t}"`)}return this.resolvers[e]=t,this}removeFormat(t){return this.resolvers[t]&&delete this.resolvers[t],this}resolve(t,e,r){if(!i.isCID(t))throw new Error("`cid` argument must be a CID");if("string"!=typeof e)throw new Error("`path` argument must be a string");const n=async function*(){for(;null!==t;){const s=await this._getFormat(t.codec),o=await this.bs.get(t,r),a=s.resolver.resolve(o.data,e);e=a.remainderPath;let c=a.value;if(1===Object.keys(c).length&&"/"in c)try{c=new i(c["/"])}catch(n){c=null}t=i.isCID(c)?c:null,yield{remainderPath:e,value:c}}}.bind(this);return f(n())}async get(t,e){const r=await this.bs.get(t,e);return(await this._getFormat(r.cid.codec)).util.deserialize(r.data)}getMany(t,e){if(!h.isIterable(t)||"string"==typeof t||t instanceof Uint8Array)throw new Error("`cids` must be an iterable of CIDs");const r=async function*(){for await(const r of t)yield this.get(r,e)}.bind(this);return f(r())}async put(t,e,r){if(void 0===e)throw new Error("`put` requires a format");if("number"!=typeof e)throw new Error("`format` parameter must be number (multicodec)");const i=await this._getFormat(e),o={hashAlg:i.defaultHashAlg,cidVersion:1,onlyHash:!1},a=s(o,r),c={cidVersion:a.cidVersion,hashAlg:a.hashAlg,onlyHash:a.onlyHash},u=i.util.serialize(t),h=await i.util.cid(u,c);if(!a.onlyHash){const t=new n(u,h);await this.bs.put(t,a)}return h}putMany(t,e,r){if(!h.isIterable(t)||"string"==typeof t||t instanceof Uint8Array)throw new Error("`nodes` must be an iterable");if(void 0===e)throw new Error("`put` requires a format");if("number"!=typeof e)throw new Error("`format` parameter must be number (multicodec)");let n,i;const o=async function*(){for await(const o of t){if(void 0===n){i=await this._getFormat(e);const t={hashAlg:i.defaultHashAlg,cidVersion:1,onlyHash:!1};n=s(t,r)}yield this.put(o,e,n)}}.bind(this);return f(o())}async remove(t,e){return this.bs.delete(t,e)}removeMany(t,e){if(!h.isIterable(t)||"string"==typeof t||t instanceof Uint8Array)throw new Error("`cids` must be an iterable of CIDs");const r=async function*(){for await(const r of t)yield this.remove(r,e)}.bind(this);return f(r())}tree(t,e,r){"object"==typeof e&&(r=e,e=void 0),e=e||"";const n=s({recursive:!1},r),o=async(t,e)=>{const r=(await this._getFormat(t.cid.codec)).resolver.resolve(t.data,e);return i.isCID(r.value)?r.value:null},a=async function*(){const r=[];let i;const s=[{cid:t,basePath:""}];let a;for(;r.length>0||s.length>0;){if(0===r.length&&s.length>0){({cid:t,basePath:a}=s.shift());const e=await this._getFormat(t.codec);i=await this.bs.get(t,n);const o=e.resolver.tree(i.data);r.push(...o)}const c=r.shift();let u=a+c;n.recursive&&null!==(t=await o(i,c))&&s.push({cid:t,basePath:u+"/"}),u.startsWith(e)&&u.length>e.length&&(e.length>0&&(u=u.slice(e.length+1)),yield u)}}.bind(this);return f(a())}async _getFormat(t){if("string"==typeof t){const e=t.toUpperCase().replace(/-/g,"_");t=u[e]}if(this.resolvers[t])return this.resolvers[t];const e=await this.loadFormat(t);return this.addFormat(e),e}}l.defaultOptions={formats:[o,a,c]},t.exports=l},function(t,e,r){"use strict";function n(t){return!isNaN(parseFloat(t))&&isFinite(t)}function i(t){return null!==t&&"object"==typeof t&&t.constructor===Object}function s(t){return o(t)&&"number"==typeof t.length}function o(t){return"object"==typeof t&&null!==t}function a(t){return void 0!==t}function c(t){return!a(t)}function u(t){return null===t}function h(t){return a(t)&&!u(t)&&!Number.isNaN(t)}function f(t){return"function"==typeof t&&/^class /.test(Function.prototype.toString.call(t))}function l(t){if(null===t)return!0;switch(typeof t){case"string":case"number":case"symbol":case"undefined":case"boolean":return!0;default:return!1}}function d(t){if(t){const e=a(Promise)&&t instanceof Promise,r=t.then&&"function"==typeof t.then;return!(!e&&!r)}return!1}function p(t){return!(null===t||!a(t))&&("function"==typeof t[Symbol.iterator]||"function"==typeof t[Symbol.asyncIterator])}function y(t){return"string"==typeof t}function g(t){return"function"==typeof t}r.r(e),r.d(e,"isNumber",(function(){return n})),r.d(e,"isPlainObject",(function(){return i})),r.d(e,"isArrayLike",(function(){return s})),r.d(e,"isObject",(function(){return o})),r.d(e,"isDefined",(function(){return a})),r.d(e,"isUndefined",(function(){return c})),r.d(e,"isNull",(function(){return u})),r.d(e,"isDefinedValue",(function(){return h})),r.d(e,"isClass",(function(){return f})),r.d(e,"isPrimitive",(function(){return l})),r.d(e,"isPromise",(function(){return d})),r.d(e,"isIterable",(function(){return p})),r.d(e,"isString",(function(){return y})),r.d(e,"isFunction",(function(){return g})),e.default={isNumber:n,isPlainObject:i,isArrayLike:s,isObject:o,isDefined:a,isUndefined:c,isNull:u,isDefinedValue:h,isClass:f,isPrimitive:l,isPromise:d,isIterable:p,isString:y,isFunction:g}},function(t,e,r){"use strict";e.first=async t=>{for await(const e of t)return e},e.last=async t=>{let e;for await(e of t);return e},e.all=async t=>{const e=[];for await(const r of t)e.push(r);return e},e.extendIterator=t=>(t.first=()=>e.first(t),t.last=()=>e.last(t),t.all=()=>e.all(t),t)},function(t,e,r){"use strict";const n=r(33),i=r(160),s=r(16),o=r(313);t.exports=(t,e)=>(e=e||{},n.call({concatArrays:!0},{blockService:t,formats:[i,s,o]},e))},function(t,e,r){"use strict";const n=r(314),i=r(1),s=r(4),o=r(719),a=r(45).default,c=r(720),u=Object.assign(i("ipfs:preload"),{error:i("ipfs:preload:error")});t.exports=t=>{if((t=t||{}).enabled=Boolean(t.enabled),t.addresses=t.addresses||[],!t.enabled||!t.addresses.length){u("preload disabled");const t=()=>{};return Object.assign(t,{start:()=>{},stop:()=>{}})}let e=!0,r=[];const i=t.addresses.map(n),h=async t=>{try{if(e)throw new Error(`preload ${t} but preloader is not started`);"string"!=typeof t&&(t=new s(t).toString());const h=o(i);let f=!1;const l=Date.now();for(const i of h){if(e)throw new Error("preload aborted for "+t);let s;try{s=new a,r=r.concat(s),await c(`${i}/api/v0/refs?r=true&arg=${encodeURIComponent(t)}`,{signal:s.signal}),f=!0}catch(n){"aborted"!==n.type&&u.error(n)}finally{r=r.filter(t=>t!==s)}if(f)break}u(`${f?"":"un"}successfully preloaded ${t} in ${Date.now()-l}ms`)}catch(n){u.error(n)}};return h.start=()=>{e=!1},h.stop=()=>{e=!0,u(`aborting ${r.length} pending preload request(s)`),r.forEach(t=>t.abort()),r=[]},h}},function(t,e,r){"use strict";t.exports=function(t){if(!Array.isArray(t))throw new TypeError("Expected Array, got "+typeof t);for(var e,r,n=t.length,i=t.slice();n;)e=Math.floor(Math.random()*n--),r=i[n],i[n]=i[e],i[e]=r;return i}},function(t,e,r){"use strict";const{default:n}=r(92),i=r(132),s=r(1),o=s("ipfs:preload");o.error=s("ipfs:preload:error");const a=new n({concurrency:4});t.exports=function(t,e){return o(t),e=e||{},a.add(async()=>{const r=(await i.post(t,{signal:e.signal})).body.getReader();try{for(;;){const{done:t}=await r.read();if(t)return}}finally{r.releaseLock()}})}},function(t,e,r){"use strict";const n=r(7),{Key:i,Errors:s}=r(10),o=r(0),a=r(1),c=a("ipfs:ipns:publisher");c.error=a("ipfs:ipns:publisher:error");const u=r(5),h=r(96),f=s.notFoundError().code;class l{constructor(t,e){this._routing=t,this._datastore=e}async publishWithEOL(t,e,r){if(!t||!t.bytes)throw o(new Error("invalid private key"),"ERR_INVALID_PRIVATE_KEY");const i=await n.createFromPrivKey(t.bytes),s=await this._updateOrCreateRecord(t,e,r,i);return this._putRecordToRouting(s,i)}publish(t,e){return this.publishWithEOL(t,e,36e5)}async _putRecordToRouting(t,e){if(!n.isPeerId(e)){const t="peerId received is not valid";throw c.error(t),o(new Error(t),"ERR_INVALID_PEER_ID")}const r=e._pubKey,i=await h.embedPublicKey(r,t),s=h.getIdKeys(e.toBytes());return await this._publishEntry(s.routingKey,i||t,e),await this._publishPublicKey(s.routingPubKey,r),i||t}async _publishEntry(t,e){if(!i.isKey(t)){const t="datastore key does not have a valid format";throw c.error(t),o(new Error(t),"ERR_INVALID_DATASTORE_KEY")}let r;try{r=h.marshal(e)}catch(n){throw c.error(n),n}try{const e=await this._routing.put(t.uint8Array(),r);return c(`ipns record for ${u(t.uint8Array(),"base64")} was stored in the routing`),e}catch(n){const e=`ipns record for ${u(t.uint8Array(),"base64")} could not be stored in the routing`;throw c.error(e),c.error(n),o(new Error(e),"ERR_PUTTING_TO_ROUTING")}}async _publishPublicKey(t,e){if(!i.isKey(t)){const t="datastore key does not have a valid format";throw c.error(t),o(new Error(t),"ERR_INVALID_DATASTORE_KEY")}if(!e||!e.bytes){const t="one or more of the provided parameters are not defined";throw c.error(t),o(new Error(t),"ERR_UNDEFINED_PARAMETER")}try{const r=await this._routing.put(t.uint8Array(),e.bytes);return c(`public key for ${u(t.uint8Array(),"base64")} was stored in the routing`),r}catch(r){const e=`public key for ${u(t.uint8Array(),"base64")} could not be stored in the routing`;throw c.error(e),c.error(r),o(new Error(e),"ERR_PUTTING_TO_ROUTING")}}async _getPublished(t,e){if(!n.isPeerId(t)){const t="peerId received is not valid";throw c.error(t),o(new Error(t),"ERR_INVALID_PEER_ID")}const r=!1!==(e=e||{}).checkRouting;try{const e=await this._datastore.get(h.getLocalKey(t.id));return this._unmarshalData(e)}catch(i){if(i.code!==f){const e=`unexpected error getting the ipns record ${t.id} from datastore`;throw c.error(e),o(new Error(e),"ERR_UNEXPECTED_DATASTORE_RESPONSE")}if(!r)throw o(i);try{const e=h.getIdKeys(t.toBytes()),r=await this._routing.get(e.routingKey.uint8Array());return this._unmarshalData(r)}catch(i){throw c.error(i),i}}}_unmarshalData(t){try{return h.unmarshal(t)}catch(e){throw o(e,"ERR_INVALID_RECORD_DATA")}}async _updateOrCreateRecord(t,e,r,i){if(!n.isPeerId(i)){const t="peerId received is not valid";throw c.error(t),o(new Error(t),"ERR_INVALID_PEER_ID")}const s={checkRouting:!0};let a;try{a=await this._getPublished(i,s)}catch(d){if(d.code!==f){const t=`unexpected error when determining the last published IPNS record for ${i.id} ${d.stack}`;throw c.error(t),o(new Error(t),"ERR_DETERMINING_PUBLISHED_RECORD")}}let u,l=0;a&&void 0!==a.sequence&&(l=a.value.toString()!==e?a.sequence+1:a.sequence);try{u=await h.create(t,e,l,r)}catch(d){const t=`ipns record for ${e} could not be created`;throw c.error(d),o(new Error(t),"ERR_CREATING_IPNS_RECORD")}try{const t=h.marshal(u);return await this._datastore.put(h.getLocalKey(i.id),t),c(`ipns record for ${e} was stored in the datastore`),u}catch(d){const t=`ipns record for ${e} could not be stored in the datastore`;throw c.error(t),o(new Error(t),"ERR_STORING_IN_DATASTORE")}}}l.defaultRecordLifetime=36e5,t.exports=l},function(t,e,r){"use strict";!function(){t.exports=u;var e=100982246400,r=864e13,n=4294967296,i=Math.trunc||function(t){var e=t-t%1;return 0===e&&(t<0||0===t&&1/t!=1/0)?-0:e},s=u.prototype;u.fromDate=function(t){return new u(+t)},u.fromInt64BE=p(0,1,2,3,0,4),u.fromInt64LE=p(3,2,1,0,4,0),u.fromString=function(t){var e,r=new u,n=(t+="").replace(/^\s*[+\-]?\d+/,(function(t){var e=+t,n=1970+(e-1970)%400;return r.year=e-n,n})).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,(function(t,r,n){return r<0&&(n*=-1),e=6e4*(60*+r+ +n),""})).replace(/\.\d+$/,(function(t){return r.nano=+(t+"000000000").substr(1,9),""})).split(/\D+/);n.length>1?n[1]--:n[1]=0;if(r.time=e=Date.UTC.apply(Date,n)-(e||0),isNaN(e))throw new TypeError("Invalid Date");return h(r)},u.fromTimeT=function(t){return l(t,0)},s.year=0,s.time=0,s.nano=0,s.addNano=function(t){return this.nano+=+t||0,this},s.getNano=function(){var t=h(this);return(t.time%1e3*1e6+ +t.nano+1e9)%1e9},s.getTimeT=function(){var t=h(this),e=Math.floor(t.time/1e3),r=t.year;r&&(e+=1168776*r*86400/3200);return e},s.getYear=function(){return this.toDate().getUTCFullYear()+this.year},s.toDate=function(){return f(h(this).time)},s.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},s.toString=function(t){var e=this,r=e.toDate(),n={H:function(){return g(r.getUTCHours())},L:function(){return b(r.getUTCMilliseconds(),3)},M:function(){return g(r.getUTCMinutes())},N:function(){return b(e.getNano(),9)},S:function(){return g(r.getUTCSeconds())},Y:function(){var t=e.getYear();return t>999999?"+"+t:t>9999?"+"+b(t,6):t>=0?b(t,4):t>=-999999?"-"+b(-t,6):t},a:function(){return a[r.getUTCDay()]},b:function(){return o[r.getUTCMonth()]},d:function(){return g(r.getUTCDate())},e:function(){return t=r.getUTCDate(),(t>9?"":" ")+(0|t);var t},m:function(){return g(r.getUTCMonth()+1)}};return function t(e){return e.replace(/%./g,(function(e){var r=e[1],i=c[r],s=n[r];return i?t(i):s?s():e}))}(t||"%Y-%m-%dT%H:%M:%S.%NZ")},s.writeInt64BE=d(0,1,2,3,0,4),s.writeInt64LE=d(3,2,1,0,4,0);var o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],c={"%":"%",F:"%Y-%m-%d",n:"\n",R:"%H:%M",T:"%H:%M:%S",t:"\t",X:"%T",Z:"GMT",z:"+0000"};return u;function u(t,e,r){var n=this;if(!(n instanceof u))return new u(t,e,r);n.time=+t||0,n.nano=+e||0,n.year=+r||0,h(n)}function h(t){var e,n,s=t.year,o=t.time,a=t.nano;if(a<0||1e6<=a){var c=Math.floor(a/1e6);a-=1e6*c,o+=c,e=1}var u=s%3200;if(o<-r||r>24&255,n[i+e]=o>>16&255,n[i+r]=o>>8&255,n[i+s]=255&o}}function p(t,e,r,n,i,s){return function(t,e){y(t,e|=0);var r=o(t,e+i);return l(o(t,e+s),r)};function o(i,s){return 16777216*i[s+t]+(i[s+e]<<16|i[s+r]<<8|i[s+n])}}function y(t,e){var r=t&&t.length;if(null==r)throw new TypeError("Invalid Buffer");if(r9?"":"0")+(0|t)}function b(t,e){return("000000000"+(0|t)).substr(-e)}}()},function(t,e,r){"use strict";const n=r(21);t.exports=n('\nmessage IpnsEntry {\n enum ValidityType {\n\t\tEOL = 0; // setting an EOL says "this record is valid until..."\n\t}\n\n required bytes value = 1;\n\trequired bytes signature = 2;\n\n\toptional ValidityType validityType = 3;\n\toptional bytes validity = 4;\n\n\toptional uint64 sequence = 5;\n\n\toptional uint64 ttl = 6;\n\n\t// in order for nodes to properly validate a record upon receipt, they need the public\n\t// key associated with it. For old RSA keys, its easiest if we just send this as part of\n\t// the record itself. For newer ed25519 keys, the public key can be embedded in the\n\t// peerID, making this field unnecessary.\n\toptional bytes pubKey = 7;\n}\n').IpnsEntry},function(t,e,r){"use strict";t.exports.toRFC3339=t=>`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}T${String(t.getUTCHours()).padStart(2,"0")}:${String(t.getUTCMinutes()).padStart(2,"0")}:${String(t.getUTCSeconds()).padStart(2,"0")}.${1e3*t.getUTCMilliseconds()*1e3}Z`,t.exports.parseRFC3339=t=>{const e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(!r)throw new Error("Invalid format");const n=parseInt(r[1],10),i=parseInt(r[2],10)-1,s=parseInt(r[3],10),o=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),u=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,i,s,o,a,c,u))}},function(t,e,r){"use strict";e.ERR_IPNS_EXPIRED_RECORD="ERR_IPNS_EXPIRED_RECORD",e.ERR_UNRECOGNIZED_VALIDITY="ERR_UNRECOGNIZED_VALIDITY",e.ERR_SIGNATURE_CREATION="ERR_SIGNATURE_CREATION",e.ERR_SIGNATURE_VERIFICATION="ERR_SIGNATURE_VERIFICATION",e.ERR_UNRECOGNIZED_FORMAT="ERR_UNRECOGNIZED_FORMAT",e.ERR_PEER_ID_FROM_PUBLIC_KEY="ERR_PEER_ID_FROM_PUBLIC_KEY",e.ERR_PUBLIC_KEY_FROM_ID="ERR_PUBLIC_KEY_FROM_ID",e.ERR_UNDEFINED_PARAMETER="ERR_UNDEFINED_PARAMETER"},function(t,e,r){"use strict";const n=r(96),i=r(37),s=r(7),o=r(0),a=r(1),c=a("ipfs:ipns:republisher");c.error=a("ipfs:ipns:republisher:error");t.exports=class{constructor(t,e,r,n,i){this._publisher=t,this._datastore=e,this._peerId=r,this._keychain=n,this._options=i||{},this._republishHandle=null}async start(){if(this._republishHandle)throw o(new Error("republisher is already running"),"ERR_REPUBLISH_ALREADY_RUNNING");const t={_task:null,_inflightTask:null,_timeoutId:null,runPeriodically:e=>{t._timeoutId=setTimeout(async()=>{t._timeoutId=null;try{t._inflightTask=t._task(),await t._inflightTask,t._task&&t.runPeriodically(e)}catch(r){c.error(r)}},e())},cancel:async()=>{clearTimeout(t._timeoutId),t._task=null,await t._inflightTask}},{privKey:e}=this._peerId,{pass:r}=this._options;let n=!0;t._task=()=>this._republishEntries(e,r),t.runPeriodically(()=>n?(n=!1,this._options.initialBroadcastInterval||6e4):this._options.broadcastInterval||144e5),this._republishHandle=t}async stop(){const t=this._republishHandle;if(!t)throw o(new Error("republisher is not running"),"ERR_REPUBLISH_NOT_RUNNING");this._republishHandle=null,await t.cancel()}async _republishEntries(t,e){try{await this._republishEntry(t)}catch(r){const t="cannot republish entry for the node's private key";return void c.error(t)}if(e)try{const t=await this._keychain.listKeys();for(const r of t){const t=await this._keychain.exportKey(r.name,e),n=await i.keys.import(t,e);await this._republishEntry(n)}}catch(r){c.error(r)}}async _republishEntry(t){if(!t||!t.bytes)throw o(new Error("invalid private key"),"ERR_INVALID_PRIVATE_KEY");try{const e=await s.createFromPrivKey(t.bytes),r=await this._getPreviousValue(e);await this._publisher.publishWithEOL(t,r,864e5)}catch(e){if("ERR_NO_ENTRY_FOUND"===e.code)return;throw e}}async _getPreviousValue(t){if(!s.isPeerId(t))throw o(new Error("invalid peer ID"),"ERR_INVALID_PEER_ID");try{const r=await this._datastore.get(n.getLocalKey(t.id));if(!(r instanceof Uint8Array))throw o(new Error("found ipns record that we couldn't process"),"ERR_INVALID_IPNS_RECORD");try{return n.unmarshal(r).value}catch(e){throw c.error(e),o(new Error("found ipns record that we couldn't convert to a value"),"ERR_INVALID_IPNS_RECORD")}}catch(e){if(e&&e.notFound)throw o(new Error("no previous entry for record with id: "+t.id),"ERR_NO_ENTRY_FOUND");throw e}}}},function(t,e,r){"use strict";const n=r(96),i=r(7),s=r(0),o=r(1),a=o("ipfs:ipns:resolver");a.error=o("ipfs:ipns:resolver:error");const c=r(5),{Errors:u}=r(10),h=u.notFoundError().code;t.exports=class{constructor(t){this._routing=t}async resolve(t,e){if(e=e||{},"string"!=typeof t)throw s(new Error("invalid name"),"ERR_INVALID_NAME");const r=(e=e||{}).recursive&&"true"===e.recursive.toString(),n=t.split("/");if(3!==n.length||""!==n[0])throw s(new Error("invalid name"),"ERR_INVALID_NAME");const i=n[2];let o;r&&(o=32);const c=await this.resolver(i,o);return a(t+" was locally resolved correctly"),c}async resolver(t,e){if(0===e){const t="could not resolve name (recursion limit of 32 exceeded)";throw a.error(t),s(new Error(t),"ERR_RESOLVE_RECURSION_LIMIT")}const r=await this._resolveName(t),n=r.split("/");return"ipfs"!==n[1]&&e?this.resolver(n[2],e-1):r}async _resolveName(t){const e=i.createFromCID(t),{routingKey:r}=n.getIdKeys(e.toBytes());let o,c;try{o=await this._routing.get(r.uint8Array())}catch(u){if(a.error("could not get record from routing",u),u.code===h)throw s(new Error(`record requested for ${t} was not found in the network`),"ERR_NO_RECORD_FOUND");throw s(new Error("unexpected error getting the ipns record "+e.toString()),"ERR_UNEXPECTED_ERROR_GETTING_RECORD")}try{c=n.unmarshal(o)}catch(u){throw a.error("could not unmarshal record",u),s(new Error("found ipns record that we couldn't convert to a value"),"ERR_INVALID_RECORD_RECEIVED")}return this._validateRecord(e,c)}async _validateRecord(t,e){const r=await n.extractPublicKey(t,e);return await n.validate(r,e),c(e.value)}}},function(t,e,r){"use strict";const n=r(21)(r(729)).Record,i=r(730);class s{constructor(t,e,r){if(!(t instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(e instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=t,this.value=e,this.timeReceived=r}serialize(){return n.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:this.timeReceived&&i.toRFC3339(this.timeReceived)}}static deserialize(t){const e=n.decode(t);return s.fromDeserialized(e)}static fromDeserialized(t){let e;t.timeReceived&&(e=i.parseRFC3339(t.timeReceived));return new s(t.key,t.value,e)}}t.exports=s},function(t,e,r){"use strict";t.exports="// Record represents a dht record that contains a value\n// for a key value pair\nmessage Record {\n // The key that references this record\n bytes key = 1;\n\n // The actual value this record is storing\n bytes value = 2;\n\n // Note: These fields were removed from the Record message\n // hash of the authors public key\n // optional bytes author = 3;\n // A PKI signature for the key+value+author\n // optional bytes signature = 4;\n\n // Time the record was received, set by receiver\n optional string timeReceived = 5;\n}"},function(t,e,r){"use strict";t.exports.toRFC3339=t=>`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}T${String(t.getUTCHours()).padStart(2,"0")}:${String(t.getUTCMinutes()).padStart(2,"0")}:${String(t.getUTCSeconds()).padStart(2,"0")}.${1e3*t.getUTCMilliseconds()*1e3}Z`,t.exports.parseRFC3339=t=>{const e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(!r)throw new Error("Invalid format");const n=parseInt(r[1],10),i=parseInt(r[2],10)-1,s=parseInt(r[3],10),o=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),u=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,i,s,o,a,c,u))}},function(t,e,r){"use strict";const n=r(0),i=r(5);t.exports={verifyRecord:(t,e)=>{const r=e.key,s=i(r).split("/");if(s.length<3)return;const o=t[s[1].toString()];if(!o){throw n(new Error("Invalid record keytype"),"ERR_INVALID_RECORD_KEY_TYPE")}return o.func(r,e.value)},validators:r(732)}},function(t,e,r){"use strict";t.exports={pk:r(733)}},function(t,e,r){"use strict";const n=r(13),i=r(0),s=r(5),o=r(20);t.exports={func:async(t,e)=>{if(!(t instanceof Uint8Array))throw i(new Error('"key" must be a Uint8Array'),"ERR_INVALID_RECORD_KEY_NOT_BUFFER");if(t.byteLength<5)throw i(new Error("invalid public key record"),"ERR_INVALID_RECORD_KEY_TOO_SHORT");if("/pk/"!==s(t.subarray(0,4)))throw i(new Error("key was not prefixed with /pk/"),"ERR_INVALID_RECORD_KEY_BAD_PREFIX");const r=t.slice(4),a=await n(e,"sha2-256");if(!o(r,a))throw i(new Error("public key does not match passed in key"),"ERR_INVALID_RECORD_HASH_MISMATCH")},sign:!1}},function(t,e,r){"use strict";const n=r(0),i=r(5);t.exports={bestRecord:(t,e,r)=>{if(0===r.length){throw n(new Error("No records given"),"ERR_NO_RECORDS_RECEIVED")}const s=i(e).split("/");if(s.length<3){throw n(new Error("Record key does not have a selector function"),"ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")}const o=t[s[1].toString()];if(!o){const t="Unrecognized key prefix: "+s[1];throw n(new Error(t),"ERR_UNRECOGNIZED_KEY_PREFIX")}return o(e,r)},selectors:r(735)}},function(t,e,r){"use strict";t.exports={pk:r(736)}},function(t,e,r){"use strict";t.exports=(t,e)=>0},function(t,e,r){"use strict";t.exports=()=>{}},function(t,e,r){"use strict";t.exports=({libp2p:t})=>()=>Boolean(t&&t.isStarted())},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n((e,r,n={})=>t.exportKey(e,r,n))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n((e,r)=>(r=r||{},t.createKey(e,r.type||"rsa",r.size||2048)))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n((e,r,n,i)=>t.importKey(e,r,n,i))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n((e,r)=>t.findKeyByName(e,r))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n(e=>t.listKeys(e))},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n(async(e,r,n)=>{const i=await t.renameKey(e,r,n);return{was:e,now:i.name,id:i.id,overwrite:!1}})},function(t,e,r){"use strict";const{withTimeoutOption:n}=r(2);t.exports=({keychain:t})=>n((e,r)=>t.removeKey(e,r))},function(t,e,r){"use strict";const n=r(188),i=r(33),s=r(0),o=r(747);t.exports=({options:t,peerId:e,multiaddrs:a=[],repo:c,keychainConfig:u={},config:h})=>{t=t||{},h=h||{};const{datastore:f,keys:l}=c,d=function({options:t,config:e,datastore:a,keys:c,keychainConfig:u,peerId:h,multiaddrs:f}){const l={datastore:a,peerId:h,modules:{}},d={modules:{pubsub:(()=>{const t=n(e,"Pubsub.Router")||"gossipsub";if(!o[t])throw s(new Error(`Router unavailable. Configure libp2p.modules.pubsub to use the ${t} router.`),"ERR_NOT_SUPPORTED");return o[t]})()},config:{peerDiscovery:{mdns:{enabled:n(t,"config.Discovery.MDNS.Enabled",n(e,"Discovery.MDNS.Enabled",!0))},webRTCStar:{enabled:n(t,"config.Discovery.webRTCStar.Enabled",n(e,"Discovery.webRTCStar.Enabled",!0))},bootstrap:{list:n(t,"config.Bootstrap",n(e,"Bootstrap",[]))}},relay:{enabled:n(t,"relay.enabled",n(e,"relay.enabled",!0)),hop:{enabled:n(t,"relay.hop.enabled",n(e,"relay.hop.enabled",!1)),active:n(t,"relay.hop.active",n(e,"relay.hop.active",!1))}},dht:{enabled:"none"!==n(e,"Routing.Type","none"),clientMode:"dhtserver"!==n(e,"Routing.Type","dht"),kBucketSize:n(t,"dht.kBucketSize",20)},pubsub:{enabled:n(t,"config.Pubsub.Enabled",n(e,"Pubsub.Enabled",!0))}},addresses:{listen:f},connectionManager:n(t,"connectionManager",{maxConnections:n(t,"config.Swarm.ConnMgr.HighWater",n(e,"Swarm.ConnMgr.HighWater")),minConnections:n(t,"config.Swarm.ConnMgr.LowWater",n(e,"Swarm.ConnMgr.LowWater"))}),keychain:{datastore:c,...u}},p=r(861);let y=n(t,"libp2p",{});"function"==typeof y&&(y={});const g=i(l,p(),d,y);n(g,"config.peerDiscovery.bootstrap.list",[]).length>0&&g.modules.peerDiscovery.push(r(1016));return g}({options:t,config:h,datastore:f,keys:l,keychainConfig:u,peerId:e,multiaddrs:a});if("function"==typeof t.libp2p)return t.libp2p({libp2pOptions:d,options:t,config:h,datastore:f,peerId:e});return new(r(778))(d)}},function(t,e,r){"use strict";t.exports={gossipsub:r(318)}},function(t,e,r){"use strict";const n=r(27),i=r(749);t.exports=n(class extends i{constructor({min:t,max:e,multicodecs:r,handlers:n}){if(super({min:t,max:e,handlers:n}),!r)throw new Error("one or more multicodec should be provided");if(!n)throw new Error("the handlers should be provided");if("function"!=typeof n.onConnect)throw new Error("the 'onConnect' handler must be provided");if("function"!=typeof n.onDisconnect)throw new Error("the 'onDisconnect' handler must be provided");this.multicodecs=Array.isArray(r)?r:[r],this._registrar=void 0,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this)}set registrar(t){this._registrar=t,this._registrar.peerStore.on("change:protocols",this._onProtocolChange),this._registrar.connectionManager.on("peer:connect",this._onPeerConnect),this._updatePeers(this._registrar.peerStore.peers.values())}_updatePeers(t){for(const{id:e,protocols:r}of t)if(this.multicodecs.filter(t=>r.includes(t)).length){this.peers.add(e.toB58String());const t=this._registrar.getConnection(e);t&&this._onConnect(e,t)}else this.peers.delete(e.toB58String())}_onProtocolChange({peerId:t,protocols:e}){const r=this.peers.has(t.toB58String()),n=e.filter(t=>this.multicodecs.includes(t));r&&0===n.length&&this._onDisconnect(t);for(const i of e)if(this.multicodecs.includes(i)){const e=this._registrar.peerStore.get(t);return void this._updatePeers([e])}}_onPeerConnect(t){const e=t.remotePeer,r=this._registrar.peerStore.protoBook.get(e);r&&this.multicodecs.find(t=>r.includes(t))&&(this.peers.add(e.toB58String()),this._onConnect(e,t))}},{className:"MulticodecTopology",symbolName:"@libp2p/js-interfaces/topology/multicodec-topology"})},function(t,e,r){"use strict";const n=r(27),i=()=>{};t.exports=n(class{constructor({min:t=0,max:e=1/0,handlers:r={}}){this.min=t,this.max=e,this._onConnect=r.onConnect||i,this._onDisconnect=r.onDisconnect||i,this.peers=new Set}set registrar(t){this._registrar=t}disconnect(t){this._onDisconnect(t)}},{className:"Topology",symbolName:"@libp2p/js-interfaces/topology"})},function(t,e,r){"use strict";t.exports="\nmessage RPC {\n repeated SubOpts subscriptions = 1;\n repeated Message msgs = 2;\n\n message SubOpts {\n optional bool subscribe = 1; // subscribe or unsubcribe\n optional string topicID = 2;\n }\n\n message Message {\n optional bytes from = 1;\n optional bytes data = 2;\n optional bytes seqno = 3;\n repeated string topicIDs = 4;\n optional bytes signature = 5;\n optional bytes key = 6;\n }\n}"},function(t,e,r){"use strict";t.exports="\n// topicCID = cid(merkledag_protobuf(topicDescriptor)); (not the topic.name)\nmessage TopicDescriptor {\n optional string name = 1;\n optional AuthOpts auth = 2;\n optional EncOpts enc = 2;\n\n message AuthOpts {\n optional AuthMode mode = 1;\n repeated bytes keys = 2; // root keys to trust\n\n enum AuthMode {\n NONE = 0; // no authentication, anyone can publish\n KEY = 1; // only messages signed by keys in the topic descriptor are accepted\n WOT = 2; // web of trust, certificates can allow publisher set to grow\n }\n }\n\n message EncOpts {\n optional EncMode mode = 1;\n repeated bytes keyHashes = 2; // the hashes of the shared keys used (salted)\n\n enum EncMode {\n NONE = 0; // no encryption, anyone can read\n SHAREDKEY = 1; // messages are encrypted with shared key\n WOT = 2; // web of trust, certificates can allow publisher set to grow\n }\n }\n}"},function(t,e,r){"use strict";const n=r(14),i=r(32),s=r(94),o=r(25),a=r(47),c=r(45),u=r(1),h=u("libp2p-pubsub:peer-streams");h.error=u("libp2p-pubsub:peer-streams:error");t.exports=class extends n{constructor({id:t,protocol:e}){super(),this.id=t,this.protocol=e,this._rawOutboundStream=null,this._rawInboundStream=null,this._inboundAbortController=null,this.outboundStream=null,this.inboundStream=null}get isReadable(){return Boolean(this.inboundStream)}get isWritable(){return Boolean(this.outboundStream)}write(t){if(!this.isWritable){const t=this.id.toB58String();throw new Error("No writable connection to "+t)}this.outboundStream.push(t)}attachInboundStream(t){this._inboundAbortController=new c,this._rawInboundStream=t,this.inboundStream=a(o(this._rawInboundStream,i.decode()),this._inboundAbortController.signal,{returnOnAbort:!0}),this.emit("stream:inbound")}async attachOutboundStream(t){const e=this.outboundStream;e&&await this.outboundStream.end(!1),this._rawOutboundStream=t,this.outboundStream=s({onEnd:t=>{this._rawOutboundStream.reset&&this._rawOutboundStream.reset(),this._rawOutboundStream=null,this.outboundStream=null,!1!==t&&this.emit("close")}}),o(this.outboundStream,i.encode(),this._rawOutboundStream).catch(t=>{h.error(t)}),e||this.emit("stream:outbound")}close(){this.outboundStream&&this.outboundStream.end(),this.inboundStream&&this._inboundAbortController.abort(),this._rawOutboundStream=null,this.outboundStream=null,this._rawInboundStream=null,this.inboundStream=null,this.emit("close")}}},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=r(36),s=r(321);function o(t){t=t||{};const e=Math.max(t.poolSize||10240,t.minPoolSize||8),r=t.lengthEncoder||s;return t=>async function*(){let s=n.alloc(e),o=0;for await(const a of t){r(a.length,s,o);const t=s.slice(o,o+r.bytes);o+=r.bytes,s.length-o<8&&(s=n.alloc(e),o=0),yield(new i).append(t).append(a)}}()}o.single=(t,e)=>{const r=(e=e||{}).lengthEncoder||s;return new i([r(t.length),t])},t.exports=o,t.exports.MIN_POOL_SIZE=8,t.exports.DEFAULT_POOL_SIZE=10240},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=r(36),s=r(322),o=n.alloc(0),a="readLength",c="readData",u={[a]:(t,e,r,n)=>{let s;e=e.append(t);try{s=n.lengthDecoder(e)}catch(u){if(e.length>n.maxLengthLength)throw Object.assign(u,{message:"message length too long",code:"ERR_MSG_LENGTH_TOO_LONG"});if(u instanceof RangeError)return{mode:a,buffer:e};throw u}if(s>n.maxDataLength)throw Object.assign(new Error("message data too long"),{code:"ERR_MSG_DATA_TOO_LONG"});return t=e.shallowSlice(n.lengthDecoder.bytes),e=new i,n.onLength&&n.onLength(s),s<=0?(n.onData&&n.onData(o),{mode:a,chunk:t,buffer:e,data:o}):{mode:c,chunk:t,buffer:e,state:{dataLength:s}}},[c]:(t,e,r,n)=>{if((e=e.append(t)).lengths?e.shallowSlice(s):null,e=new i,n.onData&&n.onData(o),{mode:a,chunk:t,buffer:e,data:o}}};function h(t){return(t=t||{}).lengthDecoder=t.lengthDecoder||s,t.maxLengthLength=t.maxLengthLength||8,t.maxDataLength=t.maxDataLength||4194304,e=>async function*(){let r,n=new i,s=a;for await(let i of e)for(;i;){const e=u[s](i,n,r,t);({mode:s,chunk:i,buffer:n,state:r}=e),e.data&&(yield e.data)}if(n.length)throw Object.assign(new Error("unexpected end of input"),{code:"ERR_UNEXPECTED_EOF"})}()}h.fromReader=(t,e)=>{e=e||{};let r=1;const n={[Symbol.asyncIterator](){return this},next:async()=>{try{return await t.next(r)}catch(e){if("ERR_UNDER_READ"===e.code)return{done:!0,value:null};throw e}finally{r=1}}};return e.onLength=t=>{r=t},h(e)(n)},t.exports=h,t.exports.MAX_LENGTH_LENGTH=8,t.exports.MAX_DATA_LENGTH=4194304},function(t,e,r){"use strict";const{Buffer:n}=r(3),i=(t,e,r)=>((e=e||n.allocUnsafe(4)).writeInt32BE(t,r),e);i.bytes=4,t.exports=i},function(t,e,r){"use strict";const n=t=>{if(t.length<4)throw RangeError("Could not decode int32BE");return t.readInt32BE(0)};n.bytes=4,t.exports=n},function(t,e,r){"use strict";t.exports=class extends Error{constructor(t,e){super(t||"The operation was aborted"),this.type="aborted",this.code=e||"ABORT_ERR"}}},function(t,e,r){"use strict";const n=r(109),i=r(5),s=r(6);(e=t.exports).randomSeqno=()=>n(8),e.msgId=(t,e)=>t+i(e,"base16"),e.anyMatch=(t,e)=>{let r;r=Array.isArray(e)?t=>e.indexOf(t)>-1:t=>e.has(t);for(const n of t)if(r(n))return!0;return!1},e.ensureArray=t=>Array.isArray(t)?t:[t],e.normalizeInRpcMessage=(t,e)=>{const r=Object.assign({},t);return t.from instanceof Uint8Array&&(r.from=i(t.from,"base58btc")),e&&(r.receivedFrom=e),r},e.normalizeOutRpcMessage=t=>{const e=Object.assign({},t);return("string"==typeof t.from||t.from instanceof String)&&(e.from=s(t.from,"base58btc")),("string"==typeof t.data||t.data instanceof String)&&(e.data=s(t.data)),e}},function(t,e,r){"use strict";const n=r(7),{Message:i}=r(320),s=r(26),o=r(6)("libp2p-pubsub:");async function a(t){const e=n.createFromCID(t.from);if(t.key){const r=await n.createFromPubKey(t.key);if(r.isEqual(e))return r.pubKey;throw new Error("Public Key does not match the originator")}if(e.pubKey)return e.pubKey;throw new Error("Could not get the public key from the originator id")}t.exports={messagePublicKey:a,signMessage:async function(t,e){const r=s([o,i.encode(e)]),n=await t.privKey.sign(r);return{...e,signature:n,key:t.pubKey.bytes}},SignPrefix:o,verifySignature:async function(t){const e={...t};delete e.signature,delete e.key,e.from=n.createFromCID(e.from).toBytes();const r=s([o,i.encode(e)]);return(await a(t)).verify(r,t.signature)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MessageCache=void 0;e.MessageCache=class{constructor(t,e,r){this.msgs=new Map,this.peertx=new Map,this.history=[];for(let n=0;n{for(const n of r.topics)if(n===t){e.push(r.msgID);break}});return e}shift(){this.history[this.history.length-1].forEach(t=>{this.msgs.delete(t.msgID),this.peertx.delete(t.msgID)}),this.history.pop(),this.history.unshift([])}}},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RPCCodec=void 0;const i=n(r(762)),s=r(21)(i.default);e.RPCCodec=s.RPC},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default="\nmessage RPC {\n repeated SubOpts subscriptions = 1;\n repeated Message msgs = 2;\n optional ControlMessage control = 3;\n\n message SubOpts {\n optional bool subscribe = 1; // subscribe or unsubcribe\n optional string topicID = 2;\n }\n\n message Message {\n optional bytes from = 1;\n optional bytes data = 2;\n optional bytes seqno = 3;\n repeated string topicIDs = 4; \n optional bytes signature = 5;\n optional bytes key = 6;\n }\n\n message ControlMessage {\n repeated ControlIHave ihave = 1;\n repeated ControlIWant iwant = 2;\n repeated ControlGraft graft = 3;\n repeated ControlPrune prune = 4;\n }\n\n message ControlIHave {\n optional string topicID = 1;\n repeated string messageIDs = 2;\n }\n\n message ControlIWant {\n repeated string messageIDs = 1; \n }\n\n message ControlGraft {\n optional string topicID = 1;\n }\n\n message ControlPrune {\n optional string topicID = 1;\n repeated PeerInfo peers = 2;\n optional uint64 backoff = 3;\n }\n\n message PeerInfo {\n optional bytes peerID = 1;\n optional bytes signedPeerRecord = 2;\n }\n}"},function(t,e,r){"use strict";var n=Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]},i=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},s=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&n(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.Heartbeat=void 0;const o=s(r(74)),a=r(323),c=r(191);e.Heartbeat=class{constructor(t){this.gossipsub=t}start(){if(this._heartbeatTimer)return;const t=this._heartbeat.bind(this),e=setTimeout(()=>{t(),this._heartbeatTimer.runPeriodically(t,o.GossipsubHeartbeatInterval)},o.GossipsubHeartbeatInitialDelay);this._heartbeatTimer={_intervalId:void 0,runPeriodically:(t,e)=>{this._heartbeatTimer._intervalId=setInterval(t,e)},cancel:()=>{clearTimeout(e),clearInterval(this._heartbeatTimer._intervalId)}}}stop(){this._heartbeatTimer&&(this._heartbeatTimer.cancel(),this._heartbeatTimer=null)}_heartbeat(){const{D:t,Dlo:e,Dhi:r,Dscore:n,Dout:i}=this.gossipsub._options;this.gossipsub.heartbeatTicks++;const s=new Map,u=t=>{let e=s.get(t);return void 0===e&&(e=this.gossipsub.score.score(t),s.set(t,e)),e},h=new Map,f=new Map,l=new Map;this.gossipsub._clearBackoff(),this.gossipsub.peerhave.clear(),this.gossipsub.iasked.clear(),this.gossipsub._applyIwantPenalties(),this.gossipsub._directConnect(),this.gossipsub.mesh.forEach((s,d)=>{const p=t=>{this.gossipsub.log("HEARTBEAT: Remove mesh link to %s in %s",t,d),this.gossipsub.score.prune(t,d),this.gossipsub._addBackoff(t,d),s.delete(t);const e=f.get(t);e?e.push(d):f.set(t,[d])},y=t=>{this.gossipsub.log("HEARTBEAT: Add mesh link to %s in %s",t,d),this.gossipsub.score.graft(t,d),s.add(t);const e=h.get(t);e?e.push(d):h.set(t,[d])};if(s.forEach(t=>{const e=u(t);e<0&&(this.gossipsub.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",t,e,d),p(t),l.set(t,!0))}),s.size!s.has(t)&&!this.gossipsub.direct.has(t)&&(!e||!e.has(t))&&u(t)>=0).forEach(y)}if(s.size>r){let e=Array.from(s);e.sort((t,e)=>u(e)-u(t)),e=e.slice(0,n).concat(c.shuffle(e.slice(n)));let r=0;if(e.slice(0,t).forEach(t=>{this.gossipsub.outbound.get(t)&&r++}),r{const r=e[t];for(let n=t;n>0;n--)e[n]=e[n-1];e[0]=r};if(r>0){let i=r;for(let r=1;r0;r++)this.gossipsub.outbound.get(e[r])&&(n(r),i--)}let i=t-r;for(let r=t;r0;r++)this.gossipsub.outbound.get(e[r])&&(n(r),i--)}e.slice(t).forEach(p)}if(s.size>=e){let t=0;if(s.forEach(e=>{this.gossipsub.outbound.get(e)&&t++}),t!s.has(t)&&!this.gossipsub.direct.has(t)&&(!r||!r.has(t))&&u(t)>=0).forEach(y)}}if(this.gossipsub.heartbeatTicks%o.GossipsubOpportunisticGraftTicks==0&&s.size>1){const t=Array.from(s).sort((t,e)=>u(t)-u(e)),e=s.size/2,r=u(t[e]);if(rs.has(e)&&!this.gossipsub.direct.has(e)&&(!t||!t.has(e))&&u(e)>r).forEach(t=>{this.gossipsub.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",t,d),y(t)})}}this.gossipsub._emitGossip(d,s)});const d=this.gossipsub._now();this.gossipsub.lastpub.forEach((t,e)=>{t+o.GossipsubFanoutTTL{const n=this.gossipsub.topics.get(r);if(e.forEach(t=>{(!n.has(t)||u(t)!e.has(t)&&!this.gossipsub.direct.has(t)&&u(t)>=this.gossipsub._options.scoreThresholds.publishThreshold).forEach(t=>{e.add(t)})}this.gossipsub._emitGossip(r,e)}),this.gossipsub._sendGraftPrune(h,f,l),this.gossipsub._flush(),this.gossipsub.messageCache.shift(),this.gossipsub.emit("gossipsub:heartbeat")}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createGossipRpc=void 0,e.createGossipRpc=function(t=[],e={}){return{subscriptions:[],msgs:t,control:Object.assign({ihave:[],iwant:[],graft:[],prune:[]},e)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shuffle=void 0,e.shuffle=function(t){if(t.length<=1)return t;for(let e=0;e0)throw i(new Error("invalid gossip threshold; it must be <= 0"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(t.publishThreshold>0||t.publishThreshold>t.gossipThreshold)throw i(new Error("invalid publish threshold; it must be <= 0 and <= gossip threshold"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(t.graylistThreshold>0||t.graylistThreshold>t.publishThreshold)throw i(new Error("invalid graylist threshold; it must be <= 0 and <= publish threshold"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(t.acceptPXThreshold<0)throw i(new Error("invalid accept PX threshold; it must be >= 0"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(t.opportunisticGraftThreshold<0)throw i(new Error("invalid opportunistic grafting threshold; it must be >= 0"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PeerScore=void 0;const n=r(324),i=r(770),s=r(771),o=r(772),a=r(74),c=r(7),u=r(1),h=r(189),{ERR_INVALID_SIGNATURE:f,ERR_MISSING_SIGNATURE:l}=h.codes,d=u("libp2p:gossipsub:score");e.PeerScore=class{constructor(t,e,r){n.validatePeerScoreParams(t),this.params=t,this._connectionManager=e,this.peerStats=new Map,this.peerIPs=new Map,this.deliveryRecords=new o.MessageDeliveries,this.msgId=r}start(){this._backgroundInterval?d("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),d("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),d("stopped")):d("Peer score already stopped")}background(){this._refreshScores(),this._updateIPs(),this.deliveryRecords.gc()}_refreshScores(){const t=Date.now(),e=this.params.decayToZero;this.peerStats.forEach((r,n)=>{r.connected?(Object.entries(r.topics).forEach(([r,n])=>{const i=this.params.topics[r];i&&(n.firstMessageDeliveries*=i.firstMessageDeliveriesDecay,n.firstMessageDeliveriesi.meshMessageDeliveriesActivation&&(n.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this._removeIPs(n,r.ips),this.peerStats.delete(n))})}score(t){const e=this.peerStats.get(t);return e?s.computeScore(t,e,this.params,this.peerIPs):0}addPenalty(t,e){const r=this.peerStats.get(t);r&&(r.behaviourPenalty+=e)}addPeer(t){const e=i.createPeerStats({connected:!0});this.peerStats.set(t,e);const r=this._getIPs(t);this._setIPs(t,r,e.ips),e.ips=r}removePeer(t){const e=this.peerStats.get(t);if(e){if(this.score(t)>0)return this._removeIPs(t,e.ips),void this.peerStats.delete(t);Object.entries(e.topics).forEach(([t,e])=>{e.firstMessageDeliveries=0;const r=this.params.topics[t].meshMessageDeliveriesThreshold;if(e.inMesh&&e.meshMessageDeliveriesActive&&e.meshMessageDeliveries{r!==e&&this._markDuplicateMessageDelivery(r,t)})):d("unexpected delivery: message from %s was first seen %s ago and has delivery status %d",e,n-r.firstSeen,o.DeliveryRecordStatus[r.status])}rejectMessage(t,e){const r=t.receivedFrom;switch(e){case l:case f:return void this._markInvalidMessageDelivery(r,t)}const n=this.deliveryRecords.ensureRecord(this.msgId(t));if(n.status===o.DeliveryRecordStatus.unknown){switch(e){case a.ERR_TOPIC_VALIDATOR_IGNORE:return void(n.status=o.DeliveryRecordStatus.ignored)}n.status=o.DeliveryRecordStatus.invalid,this._markInvalidMessageDelivery(r,t),n.peers.forEach(e=>{this._markInvalidMessageDelivery(e,t)})}else d("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",r,Date.now()-n.firstSeen,o.DeliveryRecordStatus[n.status])}duplicateMessage(t){const e=t.receivedFrom,r=this.deliveryRecords.ensureRecord(this.msgId(t));if(!r.peers.has(e))switch(r.status){case o.DeliveryRecordStatus.unknown:r.peers.add(e);break;case o.DeliveryRecordStatus.valid:r.peers.add(e),this._markDuplicateMessageDelivery(e,t,r.validated);break;case o.DeliveryRecordStatus.invalid:this._markInvalidMessageDelivery(e,t)}}_markInvalidMessageDelivery(t,e){const r=this.peerStats.get(t);r&&e.topicIDs.forEach(t=>{const e=i.ensureTopicStats(t,r,this.params);e&&(e.invalidMessageDeliveries+=1)})}_markFirstMessageDelivery(t,e){const r=this.peerStats.get(t);r&&e.topicIDs.forEach(t=>{const e=i.ensureTopicStats(t,r,this.params);if(!e)return;let n=this.params.topics[t].firstMessageDeliveriesCap;e.firstMessageDeliveries+=1,e.firstMessageDeliveries>n&&(e.firstMessageDeliveries=n),e.inMesh&&(n=this.params.topics[t].meshMessageDeliveriesCap,e.meshMessageDeliveries+=1,e.meshMessageDeliveries>n&&(e.meshMessageDeliveries=n))})}_markDuplicateMessageDelivery(t,e,r=0){const n=this.peerStats.get(t);if(!n)return;const s=r?Date.now():0;e.topicIDs.forEach(t=>{const e=i.ensureTopicStats(t,n,this.params);if(!e)return;if(!e.inMesh)return;const o=this.params.topics[t];if(r&&s>r+o.meshMessageDeliveriesWindow)return;const a=o.meshMessageDeliveriesCap;e.meshMessageDeliveries+=1,e.meshMessageDeliveries>a&&(e.meshMessageDeliveries=a)})}_getIPs(t){return this._connectionManager.getAll(c.createFromB58String(t)).map(t=>t.remoteAddr.toOptions().host)}_setIPs(t,e,r){t:for(const n of e){for(const t of r)if(n===t)continue t;let e=this.peerIPs.get(n);e||(e=new Set,this.peerIPs.set(n,e)),e.add(t)}t:for(const n of r){for(const t of e)if(n===t)continue t;const r=this.peerIPs.get(n);r&&(r.delete(t),r.size||this.peerIPs.delete(n))}}_removeIPs(t,e){e.forEach(e=>{const r=this.peerIPs.get(e);r&&(r.delete(t),r.size||this.peerIPs.delete(e))})}_updateIPs(){this.peerStats.forEach((t,e)=>{const r=this._getIPs(e);this._setIPs(e,r,t.ips),t.ips=r})}}},function(t,e,r){"use strict";function n(t={}){return Object.assign({inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},t)}Object.defineProperty(e,"__esModule",{value:!0}),e.ensureTopicStats=e.createTopicStats=e.createPeerStats=void 0,e.createPeerStats=function(t={}){return Object.assign(Object.assign({connected:!1,expire:0,ips:[],behaviourPenalty:0},t),{topics:t.topics?Object.entries(t.topics).reduce((t,[e,r])=>(t[e]=n(r),t),{}):{}})},e.createTopicStats=n,e.ensureTopicStats=function(t,e,r){let i=e.topics[t];return i||(r.topics[t]?(e.topics[t]=i=n(),i):void 0)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.computeScore=void 0,e.computeScore=function(t,e,r,n){let i=0;Object.entries(e.topics).forEach(([t,e])=>{const n=r.topics[t];if(!n)return;let s=0;if(e.inMesh){let t=e.meshTime/n.timeInMeshQuantum;t>n.timeInMeshCap&&(t=n.timeInMeshCap),s+=t*n.timeInMeshWeight}if(s+=e.firstMessageDeliveries*n.firstMessageDeliveriesWeight,e.meshMessageDeliveriesActive&&e.meshMessageDeliveries0&&i>r.topicScoreCap&&(i=r.topicScoreCap);const s=r.appSpecificScore(t);i+=s*r.appSpecificWeight,e.ips.forEach(t=>{if(r.IPColocationFactorWhitelist.has(t))return;const e=n.get(t),s=e?e.size:0;if(s>r.IPColocationFactorThreshold){const t=s-r.IPColocationFactorThreshold;i+=t*t*r.IPColocationFactorWeight}});const o=e.behaviourPenalty*e.behaviourPenalty;return i+=o*r.behaviourPenaltyWeight,i}},function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MessageDeliveries=e.DeliveryRecordStatus=void 0;const i=r(74),s=n(r(773));var o;!function(t){t[t.unknown=0]="unknown",t[t.valid=1]="valid",t[t.invalid=2]="invalid",t[t.ignored=3]="ignored"}(o=e.DeliveryRecordStatus||(e.DeliveryRecordStatus={}));e.MessageDeliveries=class{constructor(){this.records=new Map,this.queue=new s.default}ensureRecord(t){let e=this.records.get(t);if(e)return e;e={status:o.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(t,e);const r={msgId:t,expire:Date.now()+i.TimeCacheDuration};return this.queue.push(r),e}gc(){const t=Date.now();let e=this.queue.peekFront();for(;e&&e.expire=r||e<-r))return e<0&&(e+=r),e=this._head+e&this._capacityMask,this._list[e]}},n.prototype.get=function(t){return this.peekAt(t)},n.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},n.prototype.peekFront=function(){return this.peek()},n.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(n.prototype,"length",{get:function(){return this.size()}}),n.prototype.size=function(){return this._head===this._tail?0:this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),e}},n.prototype.push=function(t){if(void 0===t)return this.size();var e=this._tail;return this._list[e]=t,this._tail=e+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._head1e4&&t<=e>>>2&&this._shrinkArray(),r}},n.prototype.removeOne=function(t){var e=t;if(e===(0|e)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(e>=r||e<-r)){e<0&&(e+=r),e=this._head+e&this._capacityMask;var i,s=this._list[e];if(t0;i--)this._list[e]=this._list[e=e-1+n&this._capacityMask];this._list[e]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(i=r-1-t;i>0;i--)this._list[e]=this._list[e=e+1+n&this._capacityMask];this._list[e]=void 0,this._tail=this._tail-1+n&this._capacityMask}return s}}},n.prototype.remove=function(t,e){var r,n=t,i=e;if(n===(0|n)&&this._head!==this._tail){var s=this.size(),o=this._list.length;if(!(n>=s||n<-s||e<1)){if(n<0&&(n+=s),1===e||!e)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+e>=s)return r=this.toArray(),this.clear(),r;var a;for(n+e>s&&(e=s-n),r=new Array(e),a=0;a0;a--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(0===t){for(this._head=this._head+e+o&this._capacityMask,a=e-1;a>0;a--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(n0;a--)this.unshift(this._list[n=n-1+o&this._capacityMask]);for(n=this._head-1+o&this._capacityMask;i>0;)this._list[n=n-1+o&this._capacityMask]=void 0,i--;t<0&&(this._tail=n)}else{for(this._tail=n,n=n+e+o&this._capacityMask,a=s-(e+t);a>0;a--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+o&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=o>>>2&&this._shrinkArray(),r}}},n.prototype.splice=function(t,e){var r=t;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var i,s,o,a=arguments.length,c=this._list.length,u=2;if(!n||r0&&(this._head=this._head+r+c&this._capacityMask)):(o=this.remove(r,e),this._head=this._head+r+c&this._capacityMask);a>u;)this.unshift(arguments[--a]);for(i=r;i>0;i--)this.unshift(s[i-1])}else{var h=(s=new Array(n-(r+e))).length;for(i=0;ithis._tail){for(e=this._head;e>>=1,this._capacityMask>>>=1},t.exports=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IWantTracer=void 0;const n=r(74),i=r(189),{ERR_INVALID_SIGNATURE:s,ERR_MISSING_SIGNATURE:o}=i.codes;e.IWantTracer=class{constructor(t){this.getMsgId=t,this.promises=new Map}addPromise(t,e){const r=e[Math.floor(Math.random()*e.length)];let i=this.promises.get(r);i||(i=new Map,this.promises.set(r,i)),i.has(t)||i.set(t,Date.now()+n.GossipsubIWantFollowupTime)}getBrokenPromises(){const t=Date.now(),e=new Map;return this.promises.forEach((r,n)=>{r.forEach((n,i)=>{n{i.forEach((t,e)=>{const n=t.validity||r;(function(t){const e=(new Date).getTime()-t.getTime();return Math.floor(e/1e3)})(t.timestamp)>n&&i.delete(e)})},200);this.put=(t,e,r)=>{this.has(t)||i.set(t,{value:e,timestamp:new Date,validity:r}),s()},this.get=t=>{if(i.has(t))return i.get(t).value;throw new Error("key does not exist")},this.has=t=>i.has(t)}},function(t,e,r){"use strict";(function(e){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,o=parseInt,a="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,u=a||c||Function("return this")(),h=Object.prototype.toString,f=Math.max,l=Math.min,d=function(){return u.Date.now()};function p(t,e,r){var n,i,s,o,a,c,u=0,h=!1,p=!1,b=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function m(e){var r=n,s=i;return n=i=void 0,u=e,o=t.apply(s,r)}function v(t){return u=t,a=setTimeout(_,e),h?m(t):o}function w(t){var r=t-c;return void 0===c||r>=e||r<0||p&&t-u>=s}function _(){var t=d();if(w(t))return E(t);a=setTimeout(_,function(t){var r=e-(t-c);return p?l(r,s-(t-u)):r}(t))}function E(t){return a=void 0,b&&n?m(t):(n=i=void 0,o)}function S(){var t=d(),r=w(t);if(n=arguments,i=this,c=t,r){if(void 0===a)return v(c);if(p)return a=setTimeout(_,e),m(c)}return void 0===a&&(a=setTimeout(_,e)),o}return e=g(e)||0,y(r)&&(h=!!r.leading,s=(p="maxWait"in r)?f(g(r.maxWait)||0,e):s,b="trailing"in r?!!r.trailing:b),S.cancel=function(){void 0!==a&&clearTimeout(a),u=0,n=c=i=a=void 0},S.flush=function(){return void 0===a?o:E(d())},S}function y(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==h.call(t)}(t))return NaN;if(y(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=y(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(r,"");var a=i.test(t);return a||s.test(t)?o(t.slice(2),a?2:8):n.test(t)?NaN:+t}t.exports=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return y(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),p(t,e,{leading:n,maxWait:e,trailing:i})}}).call(this,r(11))},function(t,e,r){"use strict";const n=r(21);t.exports=n("\nmessage Envelope {\n // public_key is the public key of the keypair the enclosed payload was\n // signed with.\n bytes public_key = 1;\n\n // payload_type encodes the type of payload, so that it can be deserialized\n // deterministically.\n bytes payload_type = 2;\n\n // payload is the actual payload carried inside this envelope.\n bytes payload = 3;\n\n // signature is the signature produced by the private key corresponding to\n // the enclosed public key, over the payload, prefixing a domain string for\n // additional security.\n bytes signature = 5;\n}\n").Envelope},function(t,e,r){"use strict";const{EventEmitter:n}=r(14),i=r(1),s=r(193),o=i("libp2p");o.error=i("libp2p:error");const a=r(0),c=r(7),u=r(779),h=r(786),f=r(327),{validate:l}=r(787),{codes:d,messages:p}=r(28),y=r(792),g=r(793),b=r(796),m=r(800),v=r(803),w=r(826),_=r(328),E=r(829),S=r(339),I=r(846),A=r(847),k=r(851),T=r(853),{IdentifyService:R,multicodecs:C}=r(855);class B extends n{constructor(t){if(super(),this._options=l(t),this.peerId=this._options.peerId,this.datastore=this._options.datastore,this.peerStore=this.datastore&&this._options.peerStore.persistence?new A({peerId:this.peerId,datastore:this.datastore,...this._options.peerStore}):new S({peerId:this.peerId}),this.addresses=this._options.addresses,this.addressManager=new y(this._options.addresses),this._modules=this._options.modules,this._config=this._options.config,this._transport=[],this._discovery=new Map,this._options.connectionManager.minPeers&&(this._options.connectionManager.minConnections=this._options.connectionManager.minPeers),this.connectionManager=new g(this,{autoDial:this._config.peerDiscovery.autoDial,...this._options.connectionManager}),this._options.metrics.enabled&&(this.metrics=new w({...this._options.metrics,connectionManager:this.connectionManager})),this._options.keychain&&this._options.keychain.datastore){o("creating keychain");const t=v.generateOptions();this.keychain=new v(this._options.keychain.datastore,{passPhrase:this._options.keychain.pass,...t,...this._options.keychain}),o("keychain constructed")}if(this.upgrader=new E({localPeer:this.peerId,metrics:this.metrics,onConnection:t=>this.connectionManager.onConnect(t),onConnectionEnd:t=>this.connectionManager.onDisconnect(t)}),this.transportManager=new _({libp2p:this,upgrader:this.upgrader,faultTolerance:this._options.transportManager.faultTolerance}),this.registrar=new k({peerStore:this.peerStore,connectionManager:this.connectionManager}),this.handle=this.handle.bind(this),this.registrar.handle=this.handle,!this._modules.connEncryption||!this._modules.connEncryption.length)throw a(new Error(p.CONN_ENCRYPTION_REQUIRED),d.CONN_ENCRYPTION_REQUIRED);if(this._modules.connEncryption.forEach(t=>{this.upgrader.cryptos.set(t.protocol,t)}),this.dialer=new m({transportManager:this.transportManager,peerStore:this.peerStore,concurrency:this._options.dialer.maxParallelDials,perPeerLimit:this._options.dialer.maxDialsPerPeer,timeout:this._options.dialer.dialTimeout}),this._modules.transport.forEach(t=>{const e=t.prototype[Symbol.toStringTag],r=this._config.transport[e];this.transportManager.add(e,t,r)}),this._config.relay.enabled&&this.transportManager.add(b.prototype[Symbol.toStringTag],b),this._modules.streamMuxer){this._modules.streamMuxer.forEach(t=>{this.upgrader.muxers.set(t.multicodec,t)}),this.identifyService=new R({libp2p:this,protocols:this.upgrader.protocols}),this.handle(Object.values(C),this.identifyService.handleMessage)}if(this._modules.connProtector)this.upgrader.protector=this._modules.connProtector;else if(void 0!==s.process&&s.process.env&&s.process.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._modules.dht){const t=this._modules.dht;this._dht=new t({libp2p:this,dialer:this.dialer,peerId:this.peerId,peerStore:this.peerStore,registrar:this.registrar,datastore:this.datastore,...this._config.dht})}if(this._modules.pubsub){const t=this._modules.pubsub;this.pubsub=I(t,this,this._config.pubsub)}this.peerRouting=u(this),this.contentRouting=h(this),T.mount(this),this._onDiscoveryPeer=this._onDiscoveryPeer.bind(this)}emit(t,...e){"error"!==t||this._events.error?super.emit(t,...e):o.error(...e)}async start(){o("libp2p is starting");try{await this._onStarting(),await this._onDidStart(),o("libp2p has started")}catch(t){throw this.emit("error",t),o.error("An error occurred starting libp2p",t),await this.stop(),t}}async stop(){o("libp2p is stopping");try{for(const t of this._discovery.values())t.removeListener("peer",this._onDiscoveryPeer);await Promise.all(Array.from(this._discovery.values(),t=>t.stop())),this._discovery=new Map,await this.peerStore.stop(),await this.connectionManager.stop(),await Promise.all([this.pubsub&&this.pubsub.stop(),this._dht&&this._dht.stop(),this.metrics&&this.metrics.stop()]),await this.transportManager.close(),T.unmount(this),this.dialer.destroy()}catch(t){t&&(o.error(t),this.emit("error",t))}this._isStarted=!1,o("libp2p has stopped")}async loadKeychain(){try{await this.keychain.findKeyByName("self")}catch(t){await this.keychain.importPeer("self",this.peerId)}}isStarted(){return this._isStarted}get connections(){return this.connectionManager.connections}dial(t,e){return this.dialProtocol(t,null,e)}async dialProtocol(t,e,r){const{id:n,multiaddrs:i}=f(t);let s=this.connectionManager.get(n);return s?i&&this.peerStore.addressBook.add(n,i):s=await this.dialer.connectToPeer(t,r),e?s.newStream(e):s}get multiaddrs(){const t=this.addressManager.getNoAnnounceAddrs();return this.transportManager.getAddrs().concat(this.addressManager.getAnnounceAddrs()).filter((e,r,n)=>n.findIndex(t=>t.equals(e))===r&&!t.find(t=>t.equals(e)))}async hangUp(t){const{id:e}=f(t),r=this.connectionManager.connections.get(e.toB58String());r&&await Promise.all(r.map(t=>t.close()))}ping(t){const{id:e,multiaddrs:r}=f(t);return T(this,r?r[0]:e)}handle(t,e){(t=Array.isArray(t)?t:[t]).forEach(t=>{this.upgrader.protocols.set(t,e)}),this.isStarted()&&this.identifyService&&this.identifyService.pushToPeerStore(this.peerStore)}unhandle(t){(t=Array.isArray(t)?t:[t]).forEach(t=>{this.upgrader.protocols.delete(t)}),this.isStarted()&&this.identifyService&&this.identifyService.pushToPeerStore(this.peerStore)}async _onStarting(){await this.transportManager.listen(),await this.peerStore.start(),this._config.pubsub.enabled&&this.pubsub&&this.pubsub.start(),this._config.dht.enabled&&(this._dht&&this._dht.start(),this._dht.on("peer",this._onDiscoveryPeer)),this.metrics&&this.metrics.start()}async _onDidStart(){this._isStarted=!0,this.peerStore.on("peer",t=>{this.emit("peer:discovery",t),this._maybeConnect(t)});for(const t of this.peerStore.peers.values())this.emit("peer:discovery",t.id);this.connectionManager.start(),await this._setupPeerDiscovery()}_onDiscoveryPeer(t){t.id.toB58String()!==this.peerId.toB58String()?(t.multiaddrs&&this.peerStore.addressBook.add(t.id,t.multiaddrs),t.protocols&&this.peerStore.protoBook.set(t.id,t.protocols)):o.error(new Error(d.ERR_DISCOVERED_SELF))}async _maybeConnect(t){if(!0===this._config.peerDiscovery.autoDial&&!this.connectionManager.get(t)){if((this._options.connectionManager.minConnections||0)>this.connectionManager.size){o("connecting to discovered peer %s",t.toB58String());try{await this.dialer.connectToPeer(t)}catch(e){o.error("could not connect to discovered peer",e)}}}}async _setupPeerDiscovery(){const t=t=>{let e={enabled:!0};if(t.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[t.tag]&&(e={...e,...this._config.peerDiscovery[t.tag]}),e.enabled&&!this._discovery.has(t.tag)){let r;r="function"==typeof t?new t(Object.assign({},e,{peerId:this.peerId,libp2p:this})):t,r.on("peer",this._onDiscoveryPeer),this._discovery.set(t.tag,r)}};for(const e of this._modules.peerDiscovery||[])t(e);for(const e of this.transportManager.getTransports())e.discovery&&t(e.discovery);await Promise.all(Array.from(this._discovery.values(),t=>t.start()))}}B.create=async function(t={}){if(t.peerId)return new B(t);const e=await c.create();return t.peerId=e,new B(t)},t.exports=B},function(t,e,r){"use strict";const n=r(0),i=r(194);t.exports=t=>{const e=t._modules.peerRouting||[];return t._dht&&e.unshift(t._dht),{findPeer:async(t,r)=>{if(!e.length)throw n(new Error("No peer routers available"),"NO_ROUTERS_AVAILABLE");return i(e.map(async e=>{const i=await e.findPeer(t,r);if(!i||0===Object.keys(i).length)throw n(new Error("not found"),"NOT_FOUND");return i}))}}}},function(t,e,r){"use strict";const n=r(326),i=r(784);class s extends Error{}t.exports=(t,e)=>new i((r,i,o)=>{const{count:a,filter:c=(()=>!0)}=e;if(!Number.isFinite(a))return void i(new TypeError("Expected a finite number, got "+typeof e.count));const u=[],h=[];let f=0,l=!1;const d=new Set,p=()=>{for(const e of t)d.has(e)||"function"!=typeof e.cancel||e.cancel()};o(p);for(const e of t)f++,(async()=>{try{const t=await e;if(l)return;if(!c(t))throw new s("Value does not satisfy filter");u.push(t)}catch(t){h.push(t)}finally{d.add(e),!l&&(u.length===a&&(r(u),l=!0),f-h.lengthf&&(i(new RangeError(`Expected input to contain at least ${e.count} items, but contains ${f} items`)),p())}),t.exports.AggregateError=n,t.exports.FilterError=s},function(t,e,r){"use strict";t.exports=(t,e=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},"string"!=typeof t)throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if("number"!=typeof e)throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if("string"!=typeof r.indent)throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(0===e)return t;const n=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return t.replace(n,r.indent.repeat(e))}},function(t,e,r){"use strict";const n=r(783),i=/\s+at.*(?:\(|\s)(.*)\)?/,s=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,o=void 0===n.homedir?"":n.homedir();t.exports=(t,e)=>(e=Object.assign({pretty:!1},e),t.replace(/\\/g,"/").split("\n").filter(t=>{const e=t.match(i);if(null===e||!e[1])return!0;const r=e[1];return!r.includes(".app/Contents/Resources/electron.asar")&&!r.includes(".app/Contents/Resources/default_app.asar")&&!s.test(r)}).filter(t=>""!==t.trim()).map(t=>e.pretty?t.replace(i,(t,e)=>t.replace(e,e.replace(o,"~"))):t).join("\n"))},function(t,e){},function(t,e,r){"use strict";class n extends Error{constructor(t){super(t||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class i{static fn(t){return(...e)=>new i((r,n,i)=>{e.push(i),t(...e).then(r,n)})}constructor(t){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((e,r)=>{this._reject=r;const n=t=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(t)};return Object.defineProperties(n,{shouldReject:{get:()=>this._rejectOnCancel,set:t=>{this._rejectOnCancel=t}}}),t(t=>{this._isPending=!1,e(t)},t=>{this._isPending=!1,r(t)},n)})}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}cancel(t){if(this._isPending&&!this._isCanceled){if(this._cancelHandlers.length>0)try{for(const t of this._cancelHandlers)t()}catch(e){this._reject(e)}this._isCanceled=!0,this._rejectOnCancel&&this._reject(new n(t))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(i.prototype,Promise.prototype),t.exports=i,t.exports.CancelError=n},function(t,e,r){"use strict";class n extends Error{constructor(t){super(t||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class i{static fn(t){return(...e)=>new i((r,n,i)=>{e.push(i),t(...e).then(r,n)})}constructor(t){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((e,r)=>{this._reject=r;const n=t=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(t)};return Object.defineProperties(n,{shouldReject:{get:()=>this._rejectOnCancel,set:t=>{this._rejectOnCancel=t}}}),t(t=>{this._isPending=!1,e(t)},t=>{this._isPending=!1,r(t)},n)})}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}cancel(t){if(this._isPending&&!this._isCanceled){if(this._cancelHandlers.length>0)try{for(const t of this._cancelHandlers)t()}catch(e){this._reject(e)}this._isCanceled=!0,this._rejectOnCancel&&this._reject(new n(t))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(i.prototype,Promise.prototype),t.exports=i,t.exports.CancelError=n},function(t,e,r){"use strict";const n=r(0),{messages:i,codes:s}=r(28),o=r(86),a=r(194);t.exports=t=>{const e=t._modules.contentRouting||[],r=t._dht;return r&&e.unshift(r),{async*findProviders(t,r){if(!e.length)throw n(new Error("No content routers available"),"NO_ROUTERS_AVAILABLE");const i=await a(e.map(async e=>{const i=await o(e.findProviders(t,r));if(!i||!i.length)throw n(new Error("not found"),"NOT_FOUND");return i}));for(const e of i)yield e},async provide(t){if(!e.length)throw n(new Error("No content routers available"),"NO_ROUTERS_AVAILABLE");return Promise.all(e.map(e=>e.provide(t)))},async put(e,o,a){if(!t.isStarted()||!r.isStarted)throw n(new Error(i.NOT_STARTED_YET),s.DHT_NOT_STARTED);return r.put(e,o,a)},async get(e,o){if(!t.isStarted()||!r.isStarted)throw n(new Error(i.NOT_STARTED_YET),s.DHT_NOT_STARTED);return r.get(e,o)},async getMany(e,o,a){if(!t.isStarted()||!r.isStarted)throw n(new Error(i.NOT_STARTED_YET),s.DHT_NOT_STARTED);return r.getMany(e,o,a)}}}},function(t,e,r){"use strict";const n=r(33),i=r(195),{FaultTolerance:s}=r(328),o={addresses:{listen:[],announce:[],noAnnounce:[]},connectionManager:{minConnections:25},transportManager:{faultTolerance:s.FATAL_ALL},dialer:{maxParallelDials:i.MAX_PARALLEL_DIALS,maxDialsPerPeer:i.MAX_PER_PEER_DIALS,dialTimeout:i.DIAL_TIMEOUT},metrics:{enabled:!1},peerStore:{persistence:!1,threshold:5},config:{dht:{enabled:!1,kBucketSize:20,randomWalk:{enabled:!1,queriesPerPeriod:1,interval:3e5,timeout:1e4}},peerDiscovery:{autoDial:!0},pubsub:{enabled:!0,emitSelf:!0,signMessages:!0,strictSigning:!0},relay:{enabled:!0,hop:{enabled:!1,active:!1}},transport:{}}};t.exports.validate=t=>{if((t=n(o,t)).modules.transport.length<1)throw new Error("'options.modules.transport' must contain at least 1 transport");return t}},function(t,e,r){"use strict";const n=r(789),i=r(790);t.exports=async(t,e={})=>{const{concurrency:r=1/0}=e,s=i(r);return Promise.all(t.map(t=>t&&"function"==typeof t.then?n(t):n("function"==typeof t?s(()=>t()):Promise.resolve(t))))}},function(t,e,r){"use strict";const n=async t=>{try{return{isFulfilled:!0,isRejected:!1,value:await t}}catch(e){return{isFulfilled:!1,isRejected:!0,reason:e}}};t.exports=n,t.exports.default=n},function(t,e,r){"use strict";const n=r(791),i=t=>{if(!Number.isInteger(t)&&t!==1/0||!(t>0))return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));const e=[];let r=0;const i=()=>{r--,e.length>0&&e.shift()()},s=(t,e,...s)=>{r++;const o=n(t,...s);e(o),o.then(i,i)},o=(n,...i)=>new Promise(o=>((n,i,...o)=>{rr},pendingCount:{get:()=>e.length},clearQueue:{value:()=>{e.length=0}}}),o};t.exports=i,t.exports.default=i},function(t,e,r){"use strict";const n=(t,...e)=>new Promise(r=>{r(t(...e))});t.exports=n,t.exports.default=n},function(t,e,r){"use strict";const n=r(1);n("libp2p:addresses").error=n("libp2p:addresses:error");const i=r(17);t.exports=class{constructor({listen:t=[],announce:e=[],noAnnounce:r=[]}={}){this.listen=new Set(t),this.announce=new Set(e),this.noAnnounce=new Set(r)}getListenAddrs(){return Array.from(this.listen).map(t=>i(t))}getAnnounceAddrs(){return Array.from(this.announce).map(t=>i(t))}getNoAnnounceAddrs(){return Array.from(this.noAnnounce).map(t=>i(t))}}},function(t,e,r){"use strict";const n=r(1),i=n("libp2p:connection-manager");i.error=n("libp2p:connection-manager:error");const s=r(0),o=r(33),a=r(794),c=r(156),{EventEmitter:u}=r(14),h=r(7),{ERR_INVALID_PARAMETERS:f}=r(28),l={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,defaultPeerValue:1};function d(t,e){return t[1]-e[1]}t.exports=class extends u{constructor(t,e){if(super(),this._libp2p=t,this._peerId=t.peerId.toB58String(),this._options=o.call({ignoreUndefined:!0},l,e),this._options.maxConnectionst+e.length,0)}start(){this._libp2p.metrics&&(this._timer=this._timer||c(this._checkMetrics,this._options.pollInterval)),this._latencyMonitor=new a({latencyCheckIntervalMs:this._options.pollInterval,dataEmitIntervalMs:this._options.pollInterval}),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure),this._started=!0,i("started"),this._options.autoDial&&this._autoDial()}async stop(){this._autoDialTimeout&&this._autoDialTimeout.clear(),this._timer&&this._timer.clear(),this._latencyMonitor&&this._latencyMonitor.removeListener("data",this._onLatencyMeasure),this._started=!1,await this._close(),i("stopped")}async _close(){const t=[];for(const e of this.connections.values())for(const r of e)t.push(r.close());await t,this.connections.clear()}setPeerValue(t,e){if(e<0||e>1)throw new Error("value should be a number between 0 and 1");t.toB58String&&(t=t.toB58String()),this._peerValues.set(t,e)}_checkMetrics(){const t=this._libp2p.metrics.global.movingAverages,e=t.dataReceived[this._options.movingAverageInterval].movingAverage();this._checkMaxLimit("maxReceivedData",e);const r=t.dataSent[this._options.movingAverageInterval].movingAverage();this._checkMaxLimit("maxSentData",r);const n=e+r;this._checkMaxLimit("maxData",n),i("metrics update",n),this._timer=c(this._checkMetrics,this._options.pollInterval)}onConnect(t){const e=t.remotePeer,r=e.toB58String(),n=this.connections.get(r);this.emit("peer:connect",t),n?n.push(t):this.connections.set(r,[t]),this._libp2p.peerStore.keyBook.set(e,e.pubKey),this._peerValues.has(r)||this._peerValues.set(r,this._options.defaultPeerValue),this._checkMaxLimit("maxConnections",this.size)}onDisconnect(t){const e=t.remotePeer.toB58String();let r=this.connections.get(e);r&&r.length>1?(r=r.filter(e=>e.id!==t.id),this.connections.set(e,r)):r&&(this.connections.delete(e),this._peerValues.delete(t.remotePeer.toB58String()),this.emit("peer:disconnect",t))}get(t){const e=this.getAll(t);return e.length?e[0]:null}getAll(t){if(!h.isPeerId(t))throw s(new Error("peerId must be an instance of peer-id"),f);const e=t.toB58String(),r=this.connections.get(e);return r?r.filter(t=>"open"===t.stat.status):[]}_onLatencyMeasure(t){this._checkMaxLimit("maxEventLoopDelay",t.avgMs)}_checkMaxLimit(t,e){const r=this._options[t];i("checking limit of %s. current value: %d of %d",t,e,r),e>r&&(i("%s: limit exceeded: %s, %d",this._peerId,t,e),this._maybeDisconnectOne())}async _autoDial(){const t=this._options.minConnections;if(this.size>=t)return void(this._autoDialTimeout=c(this._autoDial,this._options.autoDialInterval));const e=Array.from(this._libp2p.peerStore.peers.values()).sort((t,e)=>!e.protocols||!e.protocols.length||t.protocols&&t.protocols.length?e.id.pubKey&&!t.id.pubKey?1:-1:1);for(let n=0;n{const e=a.now(t);return 1e3*e[0]+e[1]/1e6}):"undefined"!=typeof window&&window.performance&&window.performance.now?(o("Using performance.now for timing"),a.now=window.performance.now.bind(window.performance),a.getDeltaMS=t=>Math.round(a.now()-t)):(o("Using Date.now for timing"),a.now=Date.now,a.getDeltaMS=t=>a.now()-t),a._latencyData=a._initLatencyData(),"undefined"!=typeof window&&(a._visibilityChangeEmitter=new s,a._visibilityChangeEmitter.on("visibilityChange",t=>{t?a._startTimers():(a._emitSummary(),a._stopTimers())})),a._visibilityChangeEmitter&&!a._visibilityChangeEmitter.isVisible()||a._startTimers()}_startTimers(){this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),"function"==typeof this._emitIntervalID.unref&&this._emitIntervalID.unref()))}_stopTimers(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}_emitSummary(){const t=this.getSummary();t.events>0&&this.emit("data",t)}getSummary(){const t={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),o("Summary: %O",t),t}_checkLatency(){const t=this,e=Math.random()*t._latecyCheckMultiply-t._latecyCheckSubtract,r={deltaOffset:Math.ceil(t.latencyCheckIntervalMs+e),startTime:t.now()},n=()=>{if(!this._checkLatencyID)return;const e=t.getDeltaMS(r.startTime)-r.deltaOffset;t._checkLatency(),t._latencyData.events++,t._latencyData.minMs=Math.min(t._latencyData.minMs,e),t._latencyData.maxMs=Math.max(t._latencyData.maxMs,e),t._latencyData.totalMs+=e,o("MS: %s Data: %O",e,t._latencyData)};o("localData: %O",r),this._checkLatencyID=setTimeout(()=>{t.asyncTestFn?(r.deltaOffset=0,r.startTime=t.now(),t.asyncTestFn(n)):(r.deltaOffset-=1,n())},r.deltaOffset),"function"==typeof this._checkLatencyID.unref&&this._checkLatencyID.unref()}_initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}},function(t,e,r){"use strict";const n=r(14),i=r(1)("latency-monitor:VisibilityChangeEmitter");t.exports=class extends n{constructor(){super(),"undefined"!=typeof document?(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener()):i('This is not a browser, no "document" found. Stopping.')}_initializeVisibilityVarNames(){let t,e;void 0!==document.hidden?(t="hidden",e="visibilitychange"):void 0!==document.mozHidden?(t="mozHidden",e="mozvisibilitychange"):void 0!==document.msHidden?(t="msHidden",e="msvisibilitychange"):void 0!==document.webkitHidden&&(t="webkitHidden",e="webkitvisibilitychange"),this._hidden=t,this._visibilityChange=e}_addVisibilityChangeListener(){void 0===document.addEventListener||void 0===document[this._hidden]?i("Checking page visibility requires a browser that supports the Page Visibility API."):document.addEventListener(this._visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this._hidden&&void 0!==document[this._hidden])return!document[this._hidden]}_handleVisibilityChange(){const t=!document[this._hidden];i(t?"Page Visible":"Page Hidden"),this.emit("visibilityChange",t)}}},function(t,e,r){"use strict";const n=r(61),i=r(17),s=r(7),o=r(27),{CircuitRelay:a}=r(97),c=r(1),u=c("libp2p:circuit");u.error=c("libp2p:circuit:error");const h=r(797),{relay:f}=r(196),l=r(798),{handleCanHop:d,handleHop:p,hop:y}=r(799),{handleStop:g}=r(331),b=r(197);t.exports=o(class{constructor({libp2p:t,upgrader:e}){this._dialer=t.dialer,this._registrar=t.registrar,this._connectionManager=t.connectionManager,this._upgrader=e,this._options=t._config.relay,this._libp2p=t,this.peerId=t.peerId,this._registrar.handle(f,this._onProtocol.bind(this))}async _onProtocol({connection:t,stream:e,protocol:r}){const n=new b({stream:e}),s=await n.read(),o=this;let c;switch(s.type){case a.Type.CAN_HOP:u("received CAN_HOP request from %s",t.remotePeer.toB58String()),await d({circuit:o,connection:t,streamHandler:n});break;case a.Type.HOP:u("received HOP request from %s",t.remotePeer.toB58String()),c=await p({connection:t,request:s,streamHandler:n,circuit:o});break;case a.Type.STOP:u("received STOP request from %s",t.remotePeer.toB58String()),c=await g({connection:t,request:s,streamHandler:n,circuit:o});break;default:u("Request of type %s not supported",s.type)}if(c){const t=i(s.dstPeer.addrs[0]),e=i(s.srcPeer.addrs[0]),r=h({stream:c,remoteAddr:t,localAddr:e}),n=a.Type===a.Type.HOP?"relay":"inbound";u("new %s connection %s",n,r.remoteAddr);const o=await this._upgrader.upgradeInbound(r);u("%s connection %s upgraded",n,r.remoteAddr),this.handler&&this.handler(o)}}async dial(t,e){const r=t.toString().split("/p2p-circuit"),n=i(r[0]),o=i(r[r.length-1]),c=s.createFromCID(n.getPeerId()),f=s.createFromCID(o.getPeerId());let l=!1,d=this._connectionManager.get(c);d||(d=await this._dialer.connectToPeer(n,e),l=!0);try{const e=await y({connection:d,circuit:this,request:{type:a.Type.HOP,srcPeer:{id:this.peerId.toBytes(),addrs:this._libp2p.multiaddrs.map(t=>t.bytes)},dstPeer:{id:f.toBytes(),addrs:[i(o).bytes]}}}),r=n.encapsulate("/p2p-circuit/p2p/"+this.peerId.toB58String()),s=h({stream:e,remoteAddr:t,localAddr:r});return u("new outbound connection %s",s.remoteAddr),this._upgrader.upgradeOutbound(s)}catch(p){throw u.error("Circuit relay dial failed",p),l&&await d.close(),p}}createListener(t,e){return"function"==typeof t&&(e=t,t={}),this.handler=e,l(this,t)}filter(t){return(t=Array.isArray(t)?t:[t]).filter(t=>n.Circuit.matches(t))}},{className:"Circuit",symbolName:"@libp2p/js-libp2p-circuit/circuit"})},function(t,e,r){"use strict";const n=r(47),i=r(1)("libp2p:stream:converter");t.exports=({stream:t,remoteAddr:e,localAddr:r},s={})=>{const{sink:o,source:a}=t,c={async sink(t){s.signal&&(t=n(t,s.signal));try{await o(t)}catch(e){"aborted"!==e.type&&i(e)}u()},source:s.signal?n(a,s.signal):a,conn:t,localAddr:r,remoteAddr:e,timeline:{open:Date.now()},close(){o([]),u()}};function u(){c.timeline.close||(c.timeline.close=Date.now())}return c}},function(t,e,r){"use strict";const n=r(14),i=r(17),s=r(1);s("libp2p:circuit:listener").err=s("libp2p:circuit:error:listener"),t.exports=t=>{const e=new n,r=new Map;return e.listen=async n=>{const s=String(n).split("/p2p-circuit").find(t=>""!==t),o=await t._dialer.connectToPeer(i(s)),a=o.remoteAddr.encapsulate("/p2p-circuit");r.set(o.remotePeer.toB58String(),a),e.emit("listening")},e.close=()=>{},e.getAddrs=()=>{const t=[];for(const e of r.values())t.push(e);return t},e}},function(t,e,r){"use strict";const n=r(1),i=n("libp2p:circuit:hop");i.error=n("libp2p:circuit:hop:error");const s=r(7),{validateAddrs:o}=r(329),a=r(197),{CircuitRelay:c}=r(97),u=r(25),h=r(0),{codes:f}=r(28),{stop:l}=r(331),d=r(196);t.exports.handleHop=async function({connection:t,request:e,streamHandler:r,circuit:n}){if(!n._options.hop.enabled)return i("HOP request received but we are not acting as a relay"),r.end({type:c.Type.STATUS,code:c.Status.HOP_CANT_SPEAK_RELAY});try{o(e,r)}catch(y){return i.error("invalid hop request via peer %s",t.remotePeer.toB58String(),y)}const a=new s(e.dstPeer.id),h=n._connectionManager.get(a);if(!h&&!n._options.hop.active)return i("HOP request received but we are not connected to the destination peer"),r.end({type:c.Type.STATUS,code:c.Status.HOP_NO_CONN_TO_DST});const f={type:c.Type.STOP,dstPeer:e.dstPeer,srcPeer:e.srcPeer};let d;try{d=await l({connection:h,request:f,circuit:n})}catch(y){return i.error(y)}i("hop request from %s is valid",t.remotePeer.toB58String()),r.write({type:c.Type.STATUS,code:c.Status.SUCCESS});const p=r.rest();return u(p,d,p)},t.exports.hop=async function({connection:t,request:e}){const{stream:r}=await t.newStream([d.relay]),n=new a({stream:r});n.write(e);const s=await n.read();if(s.code===c.Status.SUCCESS)return i("hop request was successful"),n.rest();throw i("hop request failed with code %d, closing stream",s.code),n.close(),h(new Error("HOP request failed with code "+s.code),f.ERR_HOP_REQUEST_FAILED)},t.exports.handleCanHop=function({connection:t,streamHandler:e,circuit:r}){const n=r._options.hop.enabled;i("can hop (%s) request from %s",n,t.remotePeer.toB58String()),e.end({type:c.Type.STATUS,code:n?c.Status.SUCCESS:c.Status.HOP_CANT_SPEAK_RELAY})}},function(t,e,r){"use strict";const n=r(17),i=r(0),s=r(251),o=r(77),a=r(1),c=a("libp2p:dialer");c.error=a("libp2p:dialer:error");const{DialRequest:u}=r(801),h=r(327),{codes:f}=r(28),{DIAL_TIMEOUT:l,MAX_PARALLEL_DIALS:d,MAX_PER_PEER_DIALS:p}=r(195);t.exports=class{constructor({transportManager:t,peerStore:e,concurrency:r=d,timeout:n=l,perPeerLimit:i=p}){this.transportManager=t,this.peerStore=e,this.concurrency=r,this.timeout=n,this.perPeerLimit=i,this.tokens=[...new Array(r)].map((t,e)=>e),this._pendingDials=new Map}destroy(){for(const e of this._pendingDials.values())try{e.controller.abort()}catch(t){c.error(t)}this._pendingDials.clear()}async connectToPeer(t,e={}){const r=this._createDialTarget(t);if(!r.addrs.length)throw i(new Error("The dial request has no addresses"),f.ERR_NO_VALID_ADDRESSES);const n=this._pendingDials.get(r.id)||this._createPendingDial(r,e);try{const t=await n.promise;return c("dial succeeded to %s",r.id),t}catch(s){throw n.controller.signal.aborted&&(s.code=f.ERR_TIMEOUT),c.error(s),s}finally{n.destroy()}}_createDialTarget(t){const{id:e,multiaddrs:r}=h(t);r&&this.peerStore.addressBook.add(e,r);let i=this.peerStore.addressBook.getMultiaddrsForPeer(e)||[];return n.isMultiaddr(t)&&(i=i.filter(e=>!t.equals(e)),i.unshift(t)),{id:e.toB58String(),addrs:i}}_createPendingDial(t,e){const r=new u({addrs:t.addrs,dialAction:(t,e)=>{if(e.signal.aborted)throw i(new Error("already aborted"),f.ERR_ALREADY_ABORTED);return this.transportManager.dial(t,e)},dialer:this}),n=new s(this.timeout),a=[n.signal];e.signal&&a.push(e.signal);const c=o(a),h={dialRequest:r,controller:n,promise:r.run({...e,signal:c}),destroy:()=>{n.clear(),this._pendingDials.delete(t.id)}};return this._pendingDials.set(t.id,h),h}getTokens(t){const e=Math.min(t,this.perPeerLimit,this.tokens.length),r=this.tokens.splice(0,e);return c("%d tokens request, returning %d, %d remaining",t,e,this.tokens.length),r}releaseToken(t){this.tokens.indexOf(t)>-1||(c("token %d released",t),this.tokens.push(t))}}},function(t,e,r){"use strict";const n=r(45),i=r(77),s=r(1),o=r(0);s("libp2p:dialer:request").error=s("libp2p:dialer:request:error");const a=r(802),c=r(194);t.exports.DialRequest=class{constructor({addrs:t,dialAction:e,dialer:r}){this.addrs=t,this.dialer=r,this.dialAction=e}async run(t){const e=this.dialer.getTokens(this.addrs.length);if(e.length<1)throw o(new Error("No dial tokens available"),"ERR_NO_DIAL_TOKENS");const r=new a;e.forEach(t=>r.push(t));const s=this.addrs.map(()=>new n);let u=0;try{return await c(this.addrs.map(async(n,o)=>{const a=await r.shift();let c;try{const h=s[o].signal;c=await this.dialAction(n,{...t,signal:i([h,t.signal])}),s.splice(o,1)}finally{u++,this.addrs.length-u>=e.length?r.push(a):this.dialer.releaseToken(e.splice(e.indexOf(a),1)[0])}return c}))}finally{s.map(t=>t.abort()),e.forEach(t=>this.dialer.releaseToken(t))}}}},function(t,e,r){"use strict";const n=r(293),i=r(99);t.exports=class{constructor(){this._buffer=new n,this._waitingConsumers=new n}push(t){const{promise:e,resolve:r}=i();return this._buffer.push({chunk:t,resolve:r}),this._consume(),e}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const t=this._waitingConsumers.shift(),e=this._buffer.shift();t.resolve(e.chunk),e.resolve()}}shift(){const{promise:t,resolve:e}=i();return this._waitingConsumers.push({resolve:e}),this._consume(),t}isEmpty(){return this._buffer.isEmpty()}}},function(t,e,r){"use strict";const n=r(804),i=r(33),s=r(37),o=r(10),a=r(808),c=r(0),{Number:u}=r(193),h=r(5),f=r(6);r(825);const l=14,d=16,p=1e3,y={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function g(t){return!!t&&("string"==typeof t&&t===n(t.trim()))}async function b(t){const e=800*Math.random()+200;throw await new Promise(t=>setTimeout(t,e)),t}function m(t){return new o.Key("/pkcs8/"+t)}function v(t){return new o.Key("/info/"+t)}t.exports=class{constructor(t,e){if(!t)throw new Error("store is required");if(this.store=t,this.opts=i(y,e),this.opts.passPhrase&&this.opts.passPhrase.length<20)throw new Error("passPhrase must be least 20 characters");if(this.opts.dek.keyLengthr})}get cms(){return new a(this)}static generateOptions(){const t=Object.assign({},y),e=3*Math.ceil(d/3);return t.dek.salt=h(s.randomBytes(e),"base64"),t}static get options(){return y}async createKey(t,e,r){const n=this;if(!g(t)||"self"===t)return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));if("string"!=typeof e)return b(c(new Error(`Invalid key type '${e}'`),"ERR_INVALID_KEY_TYPE"));const i=m(t);if(await n.store.has(i))return b(c(new Error(`Key '${t}' already exists`),"ERR_KEY_ALREADY_EXISTS"));switch(e.toLowerCase()){case"rsa":if(!u.isSafeInteger(r)||r<2048)return b(c(new Error("Invalid RSA key size "+r),"ERR_INVALID_KEY_SIZE"))}let o;try{const a=await s.keys.generateKeyPair(e,r),c=await a.id(),u=await a.export(this._());o={name:t,id:c};const h=n.store.batch();h.put(i,f(u)),h.put(v(t),f(JSON.stringify(o))),await h.commit()}catch(a){return b(a)}return o}async listKeys(){const t=this,e={prefix:"/info/"},r=[];for await(const n of t.store.query(e))r.push(JSON.parse(h(n.value)));return r}async findKeyById(t){try{return(await this.listKeys()).find(e=>e.id===t)}catch(e){return b(e)}}async findKeyByName(t){if(!g(t))return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));const e=v(t);try{const t=await this.store.get(e);return JSON.parse(h(t))}catch(r){return b(c(new Error(`Key '${t}' does not exist. ${r.message}`),"ERR_KEY_NOT_FOUND"))}}async removeKey(t){if(!g(t)||"self"===t)return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));const e=m(t),r=await this.findKeyByName(t),n=this.store.batch();return n.delete(e),n.delete(v(t)),await n.commit(),r}async renameKey(t,e){const r=this;if(!g(t)||"self"===t)return b(c(new Error(`Invalid old key name '${t}'`),"ERR_OLD_KEY_NAME_INVALID"));if(!g(e)||"self"===e)return b(c(new Error(`Invalid new key name '${e}'`),"ERR_NEW_KEY_NAME_INVALID"));const n=m(t),i=m(e),s=v(t),o=v(e);if(await r.store.has(i))return b(c(new Error(`Key '${e}' already exists`),"ERR_KEY_ALREADY_EXISTS"));try{const t=await r.store.get(n),a=await r.store.get(s),c=JSON.parse(h(a));c.name=e;const u=r.store.batch();return u.put(i,t),u.put(o,f(JSON.stringify(c))),u.delete(n),u.delete(s),await u.commit(),c}catch(a){return b(a)}}async exportKey(t,e){if(!g(t))return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));if(!e)return b(c(new Error("Password is required"),"ERR_PASSWORD_REQUIRED"));const r=m(t);try{const t=await this.store.get(r),n=h(t);return(await s.keys.import(n,this._())).export(e)}catch(n){return b(n)}}async importKey(t,e,r){if(!g(t)||"self"===t)return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));if(!e)return b(c(new Error("PEM encoded key is required"),"ERR_PEM_REQUIRED"));const n=m(t);if(await this.store.has(n))return b(c(new Error(`Key '${t}' already exists`),"ERR_KEY_ALREADY_EXISTS"));let i,o;try{i=await s.keys.import(e,r)}catch(h){return b(c(new Error("Cannot read the key, most likely the password is wrong"),"ERR_CANNOT_READ_KEY"))}try{o=await i.id(),e=await i.export(this._())}catch(h){return b(h)}const a={name:t,id:o},u=this.store.batch();return u.put(n,f(e)),u.put(v(t),f(JSON.stringify(a))),await u.commit(),a}async importPeer(t,e){const r=this;if(!g(t))return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));if(!e||!e.privKey)return b(c(new Error("Peer.privKey is required"),"ERR_MISSING_PRIVATE_KEY"));const n=e.privKey,i=m(t);if(await r.store.has(i))return b(c(new Error(`Key '${t}' already exists`),"ERR_KEY_ALREADY_EXISTS"));try{const e=await n.id(),s=await n.export(this._()),o={name:t,id:e},a=r.store.batch();return a.put(i,f(s)),a.put(v(t),f(JSON.stringify(o))),await a.commit(),o}catch(s){return b(s)}}async _getPrivateKey(t){if(!g(t))return b(c(new Error(`Invalid key name '${t}'`),"ERR_INVALID_KEY_NAME"));try{const e=m(t),r=await this.store.get(e);return h(r)}catch(e){return b(c(new Error(`Key '${t}' does not exist. ${e.message}`),"ERR_KEY_NOT_FOUND"))}}}},function(t,e,r){"use strict";var n=r(805),i=/[\/\?<>\\:\*\|"]/g,s=/[\x00-\x1f\x80-\x9f]/g,o=/^\.+$/,a=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,c=/[\. ]+$/;function u(t,e){if("string"!=typeof t)throw new Error("Input must be string");var r=t.replace(i,e).replace(s,e).replace(o,e).replace(a,e).replace(c,e);return n(r,255)}t.exports=function(t,e){var r=e&&e.replacement||"",n=u(t,r);return""===r?n:u(n,"")}},function(t,e,r){"use strict";var n=r(806),i=r(807);t.exports=n.bind(null,i)},function(t,e,r){"use strict";function n(t){return t>=55296&&t<=56319}function i(t){return t>=56320&&t<=57343}t.exports=function(t,e,r){if("string"!=typeof e)throw new Error("Input must be string");for(var s,o,a=e.length,c=0,u=0;ur)return e.slice(0,u-o.length+1)}return e}},function(t,e,r){"use strict";function n(t){return t>=55296&&t<=56319}function i(t){return t>=56320&&t<=57343}t.exports=function(t){if("string"!=typeof t)throw new Error("Input must be string");for(var e=t.length,r=0,s=null,o=null,a=0;a=128&&s<=2047?r+=2:s>=2048&&s<=65535&&(r+=3),o=s;return r}},function(t,e,r){"use strict";r(809),r(820);const n=r(9),{certificateForKey:i,findAsync:s}=r(824),o=r(0),a=r(6),c=r(5);t.exports=class{constructor(t){if(!t)throw o(new Error("keychain is required"),"ERR_KEYCHAIN_REQUIRED");this.keychain=t}async encrypt(t,e){if(!(e instanceof Uint8Array))throw o(new Error("Plain data must be a Uint8Array"),"ERR_INVALID_PARAMS");const r=await this.keychain.findKeyByName(t),s=await this.keychain._getPrivateKey(t),c=n.pki.decryptRsaPrivateKey(s,this.keychain._()),u=await i(r,c),h=n.pkcs7.createEnvelopedData();h.addRecipient(u),h.content=n.util.createBuffer(e),h.encrypt();const f=n.asn1.toDer(h.toAsn1()).getBytes();return a(f,"ascii")}async decrypt(t){if(!(t instanceof Uint8Array))throw o(new Error("CMS data is required"),"ERR_INVALID_PARAMS");let e;try{const r=n.util.createBuffer(c(t,"ascii")),i=n.asn1.fromDer(r);e=n.pkcs7.messageFromAsn1(i)}catch(l){throw o(new Error("Invalid CMS: "+l.message),"ERR_INVALID_CMS")}const r=e.recipients.filter(t=>t.issuer.find(t=>"O"===t.shortName&&"ipfs"===t.value)).filter(t=>t.issuer.find(t=>"CN"===t.shortName)).map(t=>({recipient:t,keyId:t.issuer.find(t=>"CN"===t.shortName).value})),i=await s(r,async t=>{try{if(await this.keychain.findKeyById(t.keyId))return!0}catch(l){return!1}return!1});if(!i){const t=r.map(t=>t.keyId);throw o(new Error("Decryption needs one of the key(s): "+t.join(", ")),"ERR_MISSING_KEYS",{missingKeys:t})}const u=await this.keychain.findKeyById(i.keyId),h=await this.keychain._getPrivateKey(u.name),f=n.pki.decryptRsaPrivateKey(h,this.keychain._());return e.decrypt(i.recipient,f),a(e.content.getBytes(),"ascii")}}},function(t,e,r){"use strict";var n=r(9);r(123),r(100),r(198),r(101),r(199),r(811),r(75),r(18),r(334);var i=n.asn1,s=t.exports=n.pkcs7=n.pkcs7||{};function o(t){var e={},r=[];if(!i.validate(t,s.asn1.recipientInfoValidator,e,r)){var o=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw o.errors=r,o}return{version:e.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(e.issuer),serialNumber:n.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:i.derToOid(e.encAlgorithm),parameter:e.encParameter.value,content:e.encKey}}}function a(t){for(var e,r=[],s=0;s0){for(var r=i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[]),s=0;s=r&&o0&&o.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!0,e)),s.length>0&&o.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(i.create(i.Class.UNIVERSAL,i.Type.SET,!0,t.signerInfos)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(t.type).getBytes()),o])},addSigner:function(e){var r=e.issuer,i=e.serialNumber;if(e.certificate){var s=e.certificate;"string"==typeof s&&(s=n.pki.certificateFromPem(s)),r=s.issuer.attributes,i=s.serialNumber}var o=e.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof o&&(o=n.pki.privateKeyFromPem(o));var a=e.digestAlgorithm||n.pki.oids.sha1;switch(a){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var c=e.authenticatedAttributes||[];if(c.length>0){for(var u=!1,h=!1,f=0;f0;)a.push(u%s),u=u/s|0}for(i=0;0===t[i]&&i=0;--i)n+=e[a[i]]}else n=function(t,e){var r=0,n=e.length,i=e.charAt(0),s=[0];for(r=0;r0;)s.push(a%n),a=a/n|0}var c="";for(r=0;0===t.at(r)&&r=0;--r)c+=e[s[r]];return c}(t,e);if(r){var h=new RegExp(".{1,"+r+"}","g");n=n.match(h).join("\r\n")}return n},r.decode=function(t,r){if("string"!=typeof t)throw new TypeError('"input" must be a string.');if("string"!=typeof r)throw new TypeError('"alphabet" must be a string.');var i=n[r];if(!i){i=n[r]=[];for(var s=0;s>=8;for(;f>0;)c.push(255&f),f>>=8}for(var l=0;t[l]===a&&l>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return e.putBytes(s),c(t,r,e),(e.read>2048||0===e.length())&&e.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(e.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var h=8*i.fullMessageLength[0],f=0;f>>0,o.putInt32(h>>>0),h=a>>>0;o.putInt32(h);var l={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};c(l,r,o);var d=n.util.createBuffer();return d.putInt32(l.h0),d.putInt32(l.h1),d.putInt32(l.h2),d.putInt32(l.h3),d.putInt32(l.h4),d.putInt32(l.h5),d.putInt32(l.h6),d.putInt32(l.h7),d},i};var s=null,o=!1,a=null;function c(t,e,r){for(var n,i,s,o,c,u,h,f,l,d,p,y,g,b=r.length();b>=64;){for(c=0;c<16;++c)e[c]=r.getInt32();for(;c<64;++c)n=((n=e[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=e[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[c]=n+e[c-7]+i+e[c-16]|0;for(u=t.h0,h=t.h1,f=t.h2,l=t.h3,d=t.h4,p=t.h5,y=t.h6,g=t.h7,c=0;c<64;++c)s=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&h|f&(u^h),n=g+((d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(y^d&(p^y))+a[c]+e[c],g=y,y=p,p=d,d=l+n>>>0,l=f,f=h,h=u,u=n+(i=s+o)>>>0;t.h0=t.h0+u|0,t.h1=t.h1+h|0,t.h2=t.h2+f|0,t.h3=t.h3+l|0,t.h4=t.h4+d|0,t.h5=t.h5+p|0,t.h6=t.h6+y|0,t.h7=t.h7+g|0,b-=64}}},function(t,e,r){"use strict";(function(e){var n=r(9);r(18);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||e.versions["node-webkit"]||(i=r(200)),(t.exports=n.prng=n.prng||{}).create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,s=new Array(32),o=0;o<32;++o)s[o]=r.create();function a(){if(e.pools[0].messageLength>=32)return c();var t=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(t)),c()}function c(){e.reseeds=4294967295===e.reseeds?0:e.reseeds+1;var t=e.plugin.md.create();t.update(e.keyBytes);for(var r=1,n=0;n<32;++n)e.reseeds%r==0&&(t.update(e.pools[n].digest().getBytes()),e.pools[n].start()),r<<=1;e.keyBytes=t.digest().getBytes(),t.start(),t.update(e.keyBytes);var i=t.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(i),e.generated=0}function u(t){var e=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(e=function(t){return i.getRandomValues(t)});var s=n.util.createBuffer();if(e)for(;s.length()>16)))<<16,l=4294967295&(h=(2147483647&(h+=u>>15))+(h>>31));for(c=0;c<3;++c)f=l>>>(c<<3),f^=Math.floor(256*Math.random()),s.putByte(String.fromCharCode(255&f))}return s.getBytes(t)}return e.pools=s,e.pool=0,e.generate=function(t,r){if(!r)return e.generateSync(t);var i=e.plugin.cipher,s=e.plugin.increment,o=e.plugin.formatKey,a=e.plugin.formatSeed,u=n.util.createBuffer();e.key=null,function h(f){if(f)return r(f);if(u.length()>=t)return r(null,u.getBytes(t));e.generated>1048575&&(e.key=null);if(null===e.key)return n.util.nextTick((function(){!function(t){if(e.pools[0].messageLength>=32)return c(),t();var r=32-e.pools[0].messageLength<<5;e.seedFile(r,(function(r,n){if(r)return t(r);e.collect(n),c(),t()}))}(h)}));var l=i(e.key,e.seed);e.generated+=l.length,u.putBytes(l),e.key=o(i(e.key,s(e.seed))),e.seed=a(i(e.key,e.seed)),n.util.setImmediate(h)}()},e.generateSync=function(t){var r=e.plugin.cipher,i=e.plugin.increment,s=e.plugin.formatKey,o=e.plugin.formatSeed;e.key=null;for(var c=n.util.createBuffer();c.length()1048575&&(e.key=null),null===e.key&&a();var u=r(e.key,e.seed);e.generated+=u.length,c.putBytes(u),e.key=s(r(e.key,i(e.seed))),e.seed=o(r(e.key,e.seed))}return c.getBytes(t)},i?(e.seedFile=function(t,e){i.randomBytes(t,(function(t,r){if(t)return e(t);e(null,r.toString())}))},e.seedFileSync=function(t){return i.randomBytes(t).toString()}):(e.seedFile=function(t,e){try{e(null,u(t))}catch(r){e(r)}},e.seedFileSync=u),e.collect=function(t){for(var r=t.length,n=0;n>i&255);e.collect(n)},e.registerWorker=function(t){if(t===self)e.seedFile=function(t,e){self.addEventListener("message",(function t(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",t),e(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:t}}})};else{t.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&e.seedFile(n.forge.prng.needed,(function(e,r){t.postMessage({forge:{prng:{err:e,bytes:r}}})}))}))}},e}}).call(this,r(12))},function(t,e,r){"use strict";var n=r(9);r(815),t.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1},function(t,e,r){"use strict";var n=r(9);r(18),n.mgf=n.mgf||{},(t.exports=n.mgf.mgf1=n.mgf1=n.mgf1||{}).create=function(t){return{generate:function(e,r){for(var i=new n.util.ByteBuffer,s=Math.ceil(r/t.digestLength),o=0;o>8*l-f&255;return(w=String.fromCharCode(w.charCodeAt(0)&~_)+w.substr(1))+y+String.fromCharCode(188)},verify:function(t,o,a){var c,u=a-1,h=Math.ceil(u/8);if(o=o.substr(-h),h>8*h-u&255;if(0!=(l.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var y=i.generate(d,f),g="";for(c=0;c>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(t+a),i+=r.digest().getBytes()}return i.substring(0,e)}i.encode_rsa_oaep=function(t,e,r){var i,o,a,c;"string"==typeof r?(i=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(t.n.bitLength()/8),h=u-2*a.digestLength-2;if(e.length>h)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=e.length,g.maxLength=h,g;i||(i=""),a.update(i,"raw");for(var f=a.digest(),l="",d=h-e.length,p=0;p>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return e.putBytes(s),a(t,r,e),(e.read>2048||0===e.length())&&e.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(e.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var h=8*i.fullMessageLength[0],f=0;f>>0,o.putInt32(h>>>0),h=c>>>0;o.putInt32(h);var l={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};a(l,r,o);var d=n.util.createBuffer();return d.putInt32(l.h0),d.putInt32(l.h1),d.putInt32(l.h2),d.putInt32(l.h3),d.putInt32(l.h4),d},i};var s=null,o=!1;function a(t,e,r){for(var n,i,s,o,a,c,u,h=r.length();h>=64;){for(i=t.h0,s=t.h1,o=t.h2,a=t.h3,c=t.h4,u=0;u<16;++u)n=r.getInt32(),e[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<20;++u)n=(n=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|n>>>31,e[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<32;++u)n=(n=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|n>>>31,e[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<40;++u)n=(n=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|n>>>30,e[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<60;++u)n=(n=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|n>>>30,e[u]=n,n=(i<<5|i>>>27)+(s&o|a&(s^o))+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<80;++u)n=(n=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|n>>>30,e[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+s|0,t.h2=t.h2+o|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,h-=64}}},function(t,e,r){"use strict";var n=r(9);r(18),r(336),r(75),function(){if(n.prime)t.exports=n.prime;else{var e=t.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],s=new r(null);s.fromInt(30);var o=function(t,e){return t|e};e.generateProbablePrime=function(t,e,i){"function"==typeof e&&(i=e,e={});var s=(e=e||{}).algorithm||"PRIMEINC";"string"==typeof s&&(s={name:s}),s.options=s.options||{};var o=e.prng||n.random,u={nextBytes:function(t){for(var e=o.getBytesSync(t.length),r=0;rt&&(o=c(t,e));var d=o.toString(16);i.target.postMessage({hex:d,workLoad:h}),o.dAddOffset(f,0)}}}d()}(t,e,i,s);return a(t,e,i,s)}(t,u,s.options,i);throw new Error("Invalid prime generation algorithm: "+s.name)}}function a(t,e,r,s){var o=c(t,e),a=function(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}(o.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),function t(e,r,s,o,a,u,h){var f=+new Date;do{if(e.bitLength()>r&&(e=c(r,s)),e.isProbablePrime(a))return h(null,e);e.dAddOffset(i[o++%8],0)}while(u<0||+new Date-f=0;c--)C>>=8,C+=A.at(c)+R.at(c),R.setAt(c,255&C);T.putBuffer(R)}w=T,f.putBuffer(S)}return f.truncate(f.length()-s),f},o.pbe.getCipher=function(t,e,r){switch(t){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(t,e,r);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},o.pbe.getCipherForPBES2=function(t,e,r){var i,a={},c=[];if(!s.validate(e,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((t=s.derToOid(a.kdfOid))!==o.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=t,i.supportedOids=["pkcs5PBKDF2"],i;if((t=s.derToOid(a.encOid))!==o.oids["aes128-CBC"]&&t!==o.oids["aes192-CBC"]&&t!==o.oids["aes256-CBC"]&&t!==o.oids["des-EDE3-CBC"]&&t!==o.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=t,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var h,f,d=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),o.oids[t]){case"aes128-CBC":h=16,f=n.aes.createDecryptionCipher;break;case"aes192-CBC":h=24,f=n.aes.createDecryptionCipher;break;case"aes256-CBC":h=32,f=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":h=24,f=n.des.createDecryptionCipher;break;case"desCBC":h=8,f=n.des.createDecryptionCipher}var y=l(a.prfOid),g=n.pkcs5.pbkdf2(r,d,p,h,y),b=a.encIv,m=f(g);return m.start(b),m},o.pbe.getCipherForPKCS12PBE=function(t,e,r){var i={},a=[];if(!s.validate(e,h,i,a))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,y;var c,u,f,d=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),t){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,f=n.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,f=function(t,e){var r=n.rc2.createDecryptionCipher(t,40);return r.start(e,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=t,y}var g=l(i.prfOid),b=o.pbe.generatePkcs12Key(r,d,1,p,c,g);return g.start(),f(b,o.pbe.generatePkcs12Key(r,d,2,p,u,g))},o.pbe.opensslDeriveBytes=function(t,e,r,i){if(null==i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===e&&(e="");for(var s=[f(i,t+e)],o=16,a=1;o4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),t=e.from(t,"binary"),r=e.from(r,"binary"),c?4===i.pbkdf2Sync.length?i.pbkdf2(t,r,s,o,(function(t,e){if(t)return c(t);c(null,e.toString("binary"))})):i.pbkdf2(t,r,s,o,a,(function(t,e){if(t)return c(t);c(null,e.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(t,r,s,o).toString("binary"):i.pbkdf2Sync(t,r,s,o,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in n.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=n.md[a].create()}var u=a.digestLength;if(o>4294967295*u){var h=new Error("Derived key is too long.");if(c)return c(h);throw h}var f=Math.ceil(o/u),l=o-(f-1)*u,d=n.hmac.create();d.start(a,t);var p,y,g,b="";if(!c){for(var m=1;m<=f;++m){d.start(null,null),d.update(r),d.update(n.util.int32ToBytes(m)),p=g=d.digest().getBytes();for(var v=2;v<=s;++v)d.start(null,null),d.update(g),y=d.digest().getBytes(),p=n.util.xorBytes(p,y,u),g=y;b+=mf)return c(null,b);d.start(null,null),d.update(r),d.update(n.util.int32ToBytes(m)),p=g=d.digest().getBytes(),v=2,_()}function _(){if(v<=s)return d.start(null,null),d.update(g),y=d.digest().getBytes(),p=n.util.xorBytes(p,y,u),g=y,++v,n.util.setImmediate(_);b+=me.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=o.length();for(c=0;c>16-e},a=function(t,e){return(65535&t)>>e|t<<16-e&65535};t.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(t,e){"string"==typeof t&&(t=n.util.createBuffer(t)),e=e||128;var r,s=t,o=t.length(),a=e,c=Math.ceil(a/8),u=255>>(7&a);for(r=o;r<128;r++)s.putByte(i[s.at(r-1)+s.at(r-o)&255]);for(s.setAt(128-c,i[s.at(128-c)&u]),r=127-c;r>=0;r--)s.setAt(r,i[s.at(r+1)^s.at(r+c)]);return s};var c=function(t,e,r){var i,c,u,h,f=!1,l=null,d=null,p=null,y=[];for(t=n.rc2.expandKey(t,e),u=0;u<64;u++)y.push(t.getInt16Le());r?(i=function(t){for(u=0;u<4;u++)t[u]+=y[h]+(t[(u+3)%4]&t[(u+2)%4])+(~t[(u+3)%4]&t[(u+1)%4]),t[u]=o(t[u],s[u]),h++},c=function(t){for(u=0;u<4;u++)t[u]+=y[63&t[(u+3)%4]]}):(i=function(t){for(u=3;u>=0;u--)t[u]=a(t[u],s[u]),t[u]-=y[h]+(t[(u+3)%4]&t[(u+2)%4])+(~t[(u+3)%4]&t[(u+1)%4]),h--},c=function(t){for(u=3;u>=0;u--)t[u]-=y[63&t[(u+3)%4]]});var g=function(t){var e=[];for(u=0;u<4;u++){var n=l.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),e.push(65535&n)}h=r?0:63;for(var i=0;i=8;)g([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(t){var e=!0;if(r)if(t)e=t(8,l,!r);else{var n=8===l.length()?8:8-l.length();l.fillWithByte(n,n)}if(e&&(f=!0,b.update()),!r&&(e=0===l.length()))if(t)e=t(8,d,!r);else{var i=d.length(),s=d.at(i-1);s>i?e=!1:d.truncate(s)}return e}}};n.rc2.startEncrypting=function(t,e,r){var i=n.rc2.createEncryptionCipher(t,128);return i.start(e,r),i},n.rc2.createEncryptionCipher=function(t,e){return c(t,e,!0)},n.rc2.startDecrypting=function(t,e,r){var i=n.rc2.createDecryptionCipher(t,128);return i.start(e,r),i},n.rc2.createDecryptionCipher=function(t,e){return c(t,e,!1)}},function(t,e,r){"use strict";r(334);const n=r(9).pki;t.exports.certificateForKey=(t,e)=>{const r=n.setRsaPublicKey(e.n,e.e),i=n.createCertificate();i.publicKey=r,i.serialNumber="01",i.validity.notBefore=new Date,i.validity.notAfter=new Date,i.validity.notAfter.setFullYear(i.validity.notBefore.getFullYear()+10);const s=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:t.id}];return i.setSubject(s),i.setIssuer(s),i.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),i.sign(e),i},t.exports.findAsync=async function(t,e){const r=t.map(e);return t[(await Promise.all(r)).findIndex(t=>t)]}},function(t,e,r){"use strict";var n=r(9);r(55),r(18);var i=t.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var s=n.sha384=n.sha512.sha384=n.sha512.sha384||{};s.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=s,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(t){if(a||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),void 0===t&&(t="SHA-512"),!(t in u))throw new Error("Invalid SHA-512 algorithm: "+t);for(var e=u[t],r=null,i=n.util.createBuffer(),s=new Array(80),f=0;f<80;++f)s[f]=new Array(2);var l=64;switch(t){case"SHA-384":l=48;break;case"SHA-512/256":l=32;break;case"SHA-512/224":l=28}var d={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:l,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var t=d.messageLengthSize/4,s=0;s>>0,o>>>0];for(var a=d.fullMessageLength.length-1;a>=0;--a)d.fullMessageLength[a]+=o[1],o[1]=o[0]+(d.fullMessageLength[a]/4294967296>>>0),d.fullMessageLength[a]=d.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return i.putBytes(t),h(r,s,i),(i.read>2048||0===i.length())&&i.compact(),d},d.digest=function(){var e=n.util.createBuffer();e.putBytes(i.bytes());var a,c=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;e.putBytes(o.substr(0,d.blockLength-c));for(var u=8*d.fullMessageLength[0],f=0;f>>0,e.putInt32(u>>>0),u=a>>>0;e.putInt32(u);var l=new Array(r.length);for(f=0;f=128;){for(B=0;B<16;++B)e[B][0]=r.getInt32()>>>0,e[B][1]=r.getInt32()>>>0;for(;B<80;++B)n=(((M=(N=e[B-2])[0])>>>19|(x=N[1])<<13)^(x>>>29|M<<3)^M>>>6)>>>0,i=((M<<13|x>>>19)^(x<<3|M>>>29)^(M<<26|x>>>6))>>>0,s=(((M=(O=e[B-15])[0])>>>1|(x=O[1])<<31)^(M>>>8|x<<24)^M>>>7)>>>0,o=((M<<31|x>>>1)^(M<<24|x>>>8)^(M<<25|x>>>7))>>>0,P=e[B-7],D=e[B-16],x=i+P[1]+o+D[1],e[B][0]=n+P[0]+s+D[0]+(x/4294967296>>>0)>>>0,e[B][1]=x>>>0;for(p=t[0][0],y=t[0][1],g=t[1][0],b=t[1][1],m=t[2][0],v=t[2][1],w=t[3][0],_=t[3][1],E=t[4][0],S=t[4][1],I=t[5][0],A=t[5][1],k=t[6][0],T=t[6][1],R=t[7][0],C=t[7][1],B=0;B<80;++B)h=((E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23))>>>0,f=(k^E&(I^k))>>>0,a=((p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25))>>>0,u=((p<<4|y>>>28)^(y<<30|p>>>2)^(y<<25|p>>>7))>>>0,l=(p&g|m&(p^g))>>>0,d=(y&b|v&(y^b))>>>0,x=C+(((E<<18|S>>>14)^(E<<14|S>>>18)^(S<<23|E>>>9))>>>0)+((T^S&(A^T))>>>0)+c[B][1]+e[B][1],n=R+h+f+c[B][0]+e[B][0]+(x/4294967296>>>0)>>>0,i=x>>>0,s=a+l+((x=u+d)/4294967296>>>0)>>>0,o=x>>>0,R=k,C=T,k=I,T=A,I=E,A=S,E=w+n+((x=_+i)/4294967296>>>0)>>>0,S=x>>>0,w=m,_=v,m=g,v=b,g=p,b=y,p=n+s+((x=i+o)/4294967296>>>0)>>>0,y=x>>>0;x=t[0][1]+y,t[0][0]=t[0][0]+p+(x/4294967296>>>0)>>>0,t[0][1]=x>>>0,x=t[1][1]+b,t[1][0]=t[1][0]+g+(x/4294967296>>>0)>>>0,t[1][1]=x>>>0,x=t[2][1]+v,t[2][0]=t[2][0]+m+(x/4294967296>>>0)>>>0,t[2][1]=x>>>0,x=t[3][1]+_,t[3][0]=t[3][0]+w+(x/4294967296>>>0)>>>0,t[3][1]=x>>>0,x=t[4][1]+S,t[4][0]=t[4][0]+E+(x/4294967296>>>0)>>>0,t[4][1]=x>>>0,x=t[5][1]+A,t[5][0]=t[5][0]+I+(x/4294967296>>>0)>>>0,t[5][1]=x>>>0,x=t[6][1]+T,t[6][0]=t[6][0]+k+(x/4294967296>>>0)>>>0,t[6][1]=x>>>0,x=t[7][1]+C,t[7][0]=t[7][0]+R+(x/4294967296>>>0)>>>0,t[7][1]=x>>>0,L-=128}}},function(t,e,r){"use strict";const n=r(33),i=r(25),{tap:s}=r(52),o=r(827),{METRICS:a}=r(195),c=r(828),u=["dataReceived","dataSent"],h={in:"dataReceived",out:"dataSent"};class f{constructor(t){this._options=n(a,t),this._globalStats=new c(u,this._options),this._peerStats=new Map,this._protocolStats=new Map,this._oldPeers=o(this._options.maxOldPeersRetention),this._running=!1,this._onMessage=this._onMessage.bind(this),this._connectionManager=t.connectionManager,this._connectionManager.on("peer:disconnect",t=>{this.onPeerDisconnected(t.remotePeer)})}start(){this._running=!0}stop(){this._running=!1,this._globalStats.stop();for(const t of this._peerStats.values())t.stop();for(const t of this._protocolStats.values())t.stop()}get global(){return this._globalStats}get peers(){return Array.from(this._peerStats.keys())}forPeer(t){const e=t.toB58String();return this._peerStats.get(e)||this._oldPeers.get(e)}get protocols(){return Array.from(this._protocolStats.keys())}forProtocol(t){return this._protocolStats.get(t)}onPeerDisconnected(t){const e=t.toB58String(),r=this._peerStats.get(e);r&&(r.stop(),this._peerStats.delete(e),this._oldPeers.set(e,r))}_onMessage({remotePeer:t,protocol:e,direction:r,dataLength:n}){if(!this._running)return;const i=h[r];let s=this.forPeer(t);if(s||(s=new c(u,this._options),this._peerStats.set(t.toB58String(),s)),s.push(i,n),this._globalStats.push(i,n),e){let t=this.forProtocol(e);t||(t=new c(u,this._options),this._protocolStats.set(e,t)),t.push(i,n)}}updatePlaceholder(t,e){if(!this._running)return;const r=this.forPeer(t),n=e.toB58String(),i=this.forPeer(e);let s=r;i&&(s=f.mergeStats(i,s),this._oldPeers.delete(n)),this._peerStats.delete(t.toB58String()),this._peerStats.set(n,s),s.start()}trackStream({stream:t,remotePeer:e,protocol:r}){const n=this,o=t.source;t.source=s(t=>n._onMessage({remotePeer:e,protocol:r,direction:"in",dataLength:t.length}))(o);const a=t.sink;return t.sink=t=>i(t,s(t=>n._onMessage({remotePeer:e,protocol:r,direction:"out",dataLength:t.length})),a),t}static mergeStats(t,e){return t.stop(),e.stop(),t._queue=[...t._queue,...e._queue],t}}t.exports=f},function(t,e,r){"use strict";const n=r(170);t.exports=t=>{const e=n(t);return e.delete=e.remove,e}},function(t,e,r){"use strict";const n=r(14),i=r(30),s=r(337),o=r(156);t.exports=class extends n{constructor(t,e){super(),this._options=e,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this);const r=this._options.movingAverageIntervals;for(var n=0;n{this._updateFrequencyFor(r,e,t)}),this._frequencyLastTime=t}_updateFrequencyFor(t,e,r){const n=this._frequencyAccumulators[t]||0;this._frequencyAccumulators[t]=0;const i=n/(e||1)*1e3;let o=this._movingAverages[t];o||(o=this._movingAverages[t]={});const a=this._options.movingAverageIntervals;for(var c=0;c{}),onConnection:s=(()=>{})}){this.localPeer=t,this.metrics=e,this.cryptos=r||new Map,this.muxers=n||new Map,this.protector=null,this.protocols=new Map,this.onConnection=s,this.onConnectionEnd=i}async upgradeInbound(t){let e,r,n,s,o,a,c;if(this.metrics){({setTarget:a,proxy:c}=h());const e=parseInt(1e9*Math.random()).toString(36)+Date.now();a({toB58String:()=>e}),t=this.metrics.trackStream({stream:t,remotePeer:c})}i("Starting the inbound connection upgrade");let u=t;this.protector&&(u=await this.protector.protect(t));try{({conn:e,remotePeer:r,protocol:o}=await this._encryptInbound(this.localPeer,u,this.cryptos)),this.muxers.size?({stream:n,Muxer:s}=await this._multiplexInbound(e,this.muxers)):n=e}catch(f){throw i.error("Failed to upgrade inbound connection",f),await t.close(f),f}return this.metrics&&(this.metrics.updatePlaceholder(c,r),a(r)),i("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:t,upgradedConn:n,Muxer:s,remotePeer:r})}async upgradeOutbound(t){let e,r,n,s,o,c,u,f;try{e=a.createFromB58String(t.remoteAddr.getPeerId())}catch(d){i.error("multiaddr did not contain a valid peer id",d)}if(this.metrics){({setTarget:u,proxy:f}=h());const e=parseInt(1e9*Math.random()).toString(36)+Date.now();u({toB58String:()=>e}),t=this.metrics.trackStream({stream:t,remotePeer:f})}i("Starting the outbound connection upgrade");let l=t;this.protector&&(l=await this.protector.protect(t));try{({conn:r,remotePeer:n,protocol:o}=await this._encryptOutbound(this.localPeer,l,e,this.cryptos)),this.muxers.size?({stream:s,Muxer:c}=await this._multiplexOutbound(r,this.muxers)):s=r}catch(d){throw i.error("Failed to upgrade outbound connection",d),await t.close(d),d}return this.metrics&&(this.metrics.updatePlaceholder(f,n),u(n)),i("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:o,direction:"outbound",maConn:t,upgradedConn:s,Muxer:c,remotePeer:n})}_createConnection({cryptoProtocol:t,direction:e,maConn:r,upgradedConn:n,Muxer:a,remotePeer:h}){let l,d,p;a&&(l=new a({onStream:async t=>{const r=new s.Listener(t);try{const{stream:n,protocol:s}=await r.handle(Array.from(this.protocols.keys()));i("%s: incoming stream opened on %s",e,s),this.metrics&&this.metrics.trackStream({stream:n,remotePeer:h,protocol:s}),p.addStream(t,{protocol:s}),this._onStream({connection:p,stream:{...t,...n},protocol:s})}catch(n){i.error(n)}},onStreamEnd:t=>{p.removeStream(t.id)}}),d=async t=>{i("%s: starting new stream on %s",e,t);const r=l.newStream(),n=new s.Dialer(r);try{const{stream:e,protocol:i}=await n.select(t);return this.metrics&&this.metrics.trackStream({stream:e,remotePeer:h,protocol:i}),{stream:{...r,...e},protocol:i}}catch(o){throw i.error("could not create new stream",o),u(o,f.ERR_UNSUPPORTED_PROTOCOL)}},c(n,l,n).catch(i.error));const y=r.timeline;r.timeline=new Proxy(y,{set:(...t)=>(p&&"close"===t[1]&&t[2]&&!y.close&&(p.stat.status="closed",this.onConnectionEnd(p)),Reflect.set(...t))}),r.timeline.upgraded=Date.now();const g=()=>{throw u(new Error("connection is not multiplexed"),"ERR_CONNECTION_NOT_MULTIPLEXED")};return p=new o({localAddr:r.localAddr,remoteAddr:r.remoteAddr,localPeer:this.localPeer,remotePeer:h,stat:{direction:e,timeline:r.timeline,multiplexer:a&&a.multicodec,encryption:t},newStream:d||g,getStreams:()=>l?l.streams:g,close:t=>r.close(t)}),this.onConnection(p),p}_onStream({connection:t,stream:e,protocol:r}){this.protocols.get(r)({connection:t,stream:e,protocol:r})}async _encryptInbound(t,e,r){const n=new s.Listener(e),o=Array.from(r.keys());i("handling inbound crypto protocol selection",o);try{const{stream:e,protocol:s}=await n.handle(o),a=r.get(s);return i("encrypting inbound connection..."),{...await a.secureInbound(t,e),protocol:s}}catch(a){throw u(a,f.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(t,e,r,n){const o=new s.Dialer(e),a=Array.from(n.keys());i("selecting outbound crypto protocol",a);try{const{stream:e,protocol:s}=await o.select(a),c=n.get(s);return i("encrypting outbound connection to %j",r),{...await c.secureOutbound(t,e,r),protocol:s}}catch(c){throw u(c,f.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(t,e){const r=new s.Dialer(t),n=Array.from(e.keys());i("outbound selecting muxer %s",n);try{const{stream:t,protocol:s}=await r.select(n);i("%s selected as muxer protocol",s);return{stream:t,Muxer:e.get(s)}}catch(o){throw u(o,f.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(t,e){const r=new s.Listener(t),n=Array.from(e.keys());i("inbound handling muxers %s",n);try{const{stream:t,protocol:i}=await r.handle(n);return{stream:t,Muxer:e.get(i)}}catch(o){throw u(o,f.ERR_MUXER_UNAVAILABLE)}}}},function(t,e,r){"use strict";const n=r(831),i=r(832),s=r(833),{PROTOCOL_ID:o}=r(338);e.PROTOCOL_ID=o;class a{constructor(t){this._stream=t,this._shaken=!1}async _handshake(){if(this._shaken)return;const{stream:t}=await n(this._stream,o);this._stream=t,this._shaken=!0}}e.Dialer=class extends a{select(t){return n(this._stream,t,this._shaken?null:o)}async ls(){await this._handshake();const{stream:t,protocols:e}=await s(this._stream);return this._stream=t,e}};e.Listener=class extends a{handle(t){return i(this._stream,t)}}},function(t,e,r){"use strict";const n=r(1)("mss:select"),i=r(0),s=r(201),o=r(98);t.exports=async(t,e,r)=>{e=Array.isArray(e)?[...e]:[e];const{reader:a,writer:c,rest:u,stream:h}=o(t),f=e.shift();r?(n('select: write ["%s", "%s"]',r,f),s.writeAll(c,[r,f])):(n('select: write "%s"',f),s.write(c,f));let l=(await s.read(a)).toString();if(n('select: read "%s"',l),l===r&&(l=(await s.read(a)).toString(),n('select: read "%s"',l)),l===f)return u(),{stream:h,protocol:f};for(const i of e){n('select: write "%s"',i),s.write(c,i);const t=(await s.read(a)).toString();if(n('select: read "%s" for "%s"',t,i),t===i)return u(),{stream:h,protocol:i}}throw u(),i(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}},function(t,e,r){"use strict";const n=r(1)("mss:handle"),i=r(36),s=r(201),o=r(98),{PROTOCOL_ID:a}=r(338);t.exports=async(t,e)=>{e=Array.isArray(e)?e:[e];const{writer:r,reader:c,rest:u,stream:h}=o(t);for(;;){const t=(await s.read(c)).toString();if(n('read "%s"',t),t!==a){if(e.includes(t))return s.write(r,t),n('respond with "%s" for "%s"',t,t),u(),{stream:h,protocol:t};"ls"!==t?(s.write(r,"na"),n('respond with "na" for "%s"',t)):(s.write(r,new i(e.map(t=>s.encode(t)))),n('respond with "%s" for %s',e,t))}else n('respond with "%s" for "%s"',a,t),s.write(r,a)}}},function(t,e,r){"use strict";const n=r(330),i=r(1)("it-multistream-select:ls"),s=r(201),o=r(98),a=r(32),c=r(25);t.exports=async t=>{const{reader:e,writer:r,rest:u,stream:h}=o(t);i('write "ls"'),s.write(r,"ls"),u();const f=await s.read(e),l=n([f]),d=[];return await c(l,a.decode(),async t=>{for await(const e of t)d.push(e.shallowSlice(0,-1).toString())}),{stream:h,protocols:d}}},function(t,e,r){"use strict";e.Connection=r(835)},function(t,e,r){"use strict";const n=r(7),i=r(17),s=r(27),o=r(0),a=r(836);t.exports=s(class{constructor({localAddr:t,remoteAddr:e,localPeer:r,remotePeer:s,newStream:c,close:u,getStreams:h,stat:f}){!function(t,e,r,s,a,c,u){if(t&&!i.isMultiaddr(t))throw o(new Error("localAddr must be an instance of multiaddr"),"ERR_INVALID_PARAMETERS");if(!n.isPeerId(e))throw o(new Error("localPeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(!n.isPeerId(r))throw o(new Error("remotePeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if("function"!=typeof s)throw o(new Error("new stream must be a function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof a)throw o(new Error("close must be a function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof c)throw o(new Error("getStreams must be a function"),"ERR_INVALID_PARAMETERS");if(!u)throw o(new Error("connection metadata object must be provided"),"ERR_INVALID_PARAMETERS");if("inbound"!==u.direction&&"outbound"!==u.direction)throw o(new Error('direction must be "inbound" or "outbound"'),"ERR_INVALID_PARAMETERS");if(!u.timeline)throw o(new Error("connection timeline object must be provided in the stat object"),"ERR_INVALID_PARAMETERS");if(!u.timeline.open)throw o(new Error("connection open timestamp must be provided"),"ERR_INVALID_PARAMETERS");if(!u.timeline.upgraded)throw o(new Error("connection upgraded timestamp must be provided"),"ERR_INVALID_PARAMETERS")}(t,r,s,c,u,h,f),this.id=parseInt(1e9*Math.random()).toString(36)+Date.now(),this.localAddr=t,this.remoteAddr=e,this.localPeer=r,this.remotePeer=s,this._stat={...f,status:a.OPEN},this._newStream=c,this._close=u,this._getStreams=h,this.registry=new Map,this.tags=[]}get stat(){return this._stat}get streams(){return this._getStreams()}async newStream(t){if(this.stat.status===a.CLOSING)throw o(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===a.CLOSED)throw o(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(t)||(t=[t]);const{stream:e,protocol:r}=await this._newStream(t);return this.addStream(e,{protocol:r}),{stream:e,protocol:r}}addStream(t,{protocol:e,metadata:r={}}){this.registry.set(t.id,{protocol:e,...r})}removeStream(t){this.registry.delete(t)}async close(){if(this.stat.status!==a.CLOSED){if(this._closing)return this._closing;this.stat.status=a.CLOSING,this._closing=await this._close(),this._stat.timeline.close=Date.now(),this.stat.status=a.CLOSED}}},{className:"Connection",symbolName:"@libp2p/interface-connection/connection"})},function(t,e,r){"use strict";t.exports={OPEN:"open",CLOSING:"closing",CLOSED:"closed"}},function(t,e,r){"use strict";function n(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);et.addresses?t.addresses.map(t=>t.multiaddr):[]}),this.data=new Map}consumePeerRecord(t){let e;try{e=u.createFromProtobuf(t.payload)}catch(a){return s.error("invalid peer record received"),!1}if(!e.peerId.equals(t.peerId))return s("signing key does not match PeerId in the PeerRecord"),!1;if(!e.multiaddrs||!e.multiaddrs.length)return!1;const r=e.peerId,n=r.toB58String(),i=(this.data.get(n)||{}).record;if(i&&i.seqNumber>=e.seqNumber)return!1;const o=this._toAddresses(e.multiaddrs,!0);return this._setData(r,{addresses:o,record:{raw:t.marshal(),seqNumber:e.seqNumber}}),s("stored provided peer record for "+n),!0}getRawEnvelope(t){const e=this.data.get(t.toB58String());if(e&&e.record&&e.record.raw)return e.record.raw}getPeerRecord(t){const e=this.getRawEnvelope(t);if(e)return f.createFromProtobuf(e)}set(t,e){if(!a.isPeerId(t))throw s.error("peerId must be an instance of peer-id to store data"),n(new Error("peerId must be an instance of peer-id"),h);const r=this._toAddresses(e),i=t.toB58String(),o=this.data.get(i)||{},c=o.addresses;if(!r.length)return this;if(c&&c.length===r.length){if(c.filter(t=>r.some(e=>t.multiaddr.equals(e.multiaddr))).length===c.length)return s("the addresses provided to store are equal to the already stored for "+i),this}return this._setData(t,{addresses:r,record:o.record}),s("stored provided multiaddrs for "+i),c||this._ps.emit("peer",t),this}add(t,e){if(!a.isPeerId(t))throw s.error("peerId must be an instance of peer-id to store data"),n(new Error("peerId must be an instance of peer-id"),h);const r=this._toAddresses(e),i=t.toB58String(),o=this.data.get(i)||{},c=o.addresses||[];return c.forEach(t=>{r.find(e=>e.multiaddr.equals(t.multiaddr))||r.push(t)}),c&&c.length===r.length?(s("the addresses provided to store are already stored for "+i),this):(this._setData(t,{addresses:r,record:o.record}),s("added provided multiaddrs for "+i),o.addresses||this._ps.emit("peer",t),this)}get(t){if(!a.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),h);const e=this.data.get(t.toB58String());return e&&e.addresses?[...e.addresses]:void 0}_toAddresses(t,e=!1){if(!t)throw s.error("multiaddrs must be provided to store data"),n(new Error("multiaddrs must be provided"),h);const r=[];return t.forEach(t=>{if(!o.isMultiaddr(t))throw s.error(`multiaddr ${t} must be an instance of multiaddr`),n(new Error(`multiaddr ${t} must be an instance of multiaddr`),h);r.push({multiaddr:t,isCertified:e})}),r}getMultiaddrsForPeer(t){if(!a.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),h);const e=this.data.get(t.toB58String());if(e&&e.addresses)return e.addresses.map(e=>{const r=e.multiaddr,n=r.getPeerId();return n&&n===t.toB58String()?r:r.encapsulate("/p2p/"+t.toB58String())})}}},function(t,e,r){"use strict";const n=r(0);t.exports=class{constructor(t,e){this.domain=t,this.codec=e}marshal(){throw n(new Error("marshal must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}equals(t){throw n(new Error("equals must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}}},function(t,e,r){"use strict";t.exports=function(t,e){return t.length===e.length&&e.sort()&&t.sort().every((t,r)=>e[r].equals(t))}},function(t,e,r){"use strict";const n=r(21);t.exports=n("\nmessage PeerRecord {\n // AddressInfo is a wrapper around a binary multiaddr. It is defined as a\n // separate message to allow us to add per-address metadata in the future.\n message AddressInfo {\n bytes multiaddr = 1;\n }\n\n // peer_id contains a libp2p peer id in its binary representation.\n bytes peer_id = 1;\n\n // seq contains a monotonically-increasing sequence counter to order PeerRecords in time.\n uint64 seq = 2;\n\n // addresses is a list of public listen addresses for the peer.\n repeated AddressInfo addresses = 3;\n}\n").PeerRecord},function(t,e,r){"use strict";const n=r(19);t.exports.ENVELOPE_DOMAIN_PEER_RECORD=n.getName(n.LIBP2P_PEER_RECORD),t.exports.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD=Uint8Array.from([3,1])},function(t,e,r){"use strict";const n=r(0),i=r(1),s=i("libp2p:peer-store:key-book");s.error=i("libp2p:peer-store:key-book:error");const o=r(7),a=r(124),{codes:{ERR_INVALID_PARAMETERS:c}}=r(28);t.exports=class extends a{constructor(t){super({peerStore:t,eventName:"change:pubkey",eventProperty:"pubkey",eventTransformer:t=>t.pubKey}),this.data=new Map}set(t,e){if(!o.isPeerId(t))throw s.error("peerId must be an instance of peer-id to store data"),n(new Error("peerId must be an instance of peer-id"),c);const r=t.toB58String();return!this.data.get(r)&&e&&(t.pubKey=e,this._setData(t,t),s("stored provided public key for "+r)),this}get(t){if(!o.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),c);const e=this.data.get(t.toB58String());return e?e.pubKey:void 0}}},function(t,e,r){"use strict";const n=r(0),i=r(1),s=i("libp2p:peer-store:proto-book");s.error=i("libp2p:peer-store:proto-book:error");const o=r(20),a=r(7),c=r(124),{codes:{ERR_INVALID_PARAMETERS:u}}=r(28);t.exports=class extends c{constructor(t){super({peerStore:t,eventName:"change:metadata",eventProperty:"metadata"}),this.data=new Map}set(t,e,r){if(!a.isPeerId(t))throw s.error("peerId must be an instance of peer-id to store data"),n(new Error("peerId must be an instance of peer-id"),u);if("string"!=typeof e||!(r instanceof Uint8Array))throw s.error("valid key and value must be provided to store data"),n(new Error("valid key and value must be provided"),u);return this._setValue(t,e,r),this}_setValue(t,e,r,{emit:n=!0}={}){const i=t.toB58String(),a=this.data.get(i)||new Map,c=a.get(e);c&&o(r,c)?s(`the metadata provided to store is equal to the already stored for ${i} on ${e}`):(a.set(e,r),this.data.set(i,a),n&&this._emit(t,e))}get(t){if(!a.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),u);return this.data.get(t.toB58String())}getValue(t,e){if(!a.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),u);const r=this.data.get(t.toB58String());return r&&r.get(e)}delete(t){if(!a.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),u);return!!this.data.delete(t.toB58String())&&(this._emit(t),!0)}deleteValue(t,e){if(!a.isPeerId(t))throw n(new Error("peerId must be an instance of peer-id"),u);const r=this.data.get(t.toB58String());return!(!r||!r.delete(e))&&(this._emit(t,e),!0)}}},function(t,e,r){"use strict";const n=r(0),i=r(1),s=i("libp2p:peer-store:proto-book");s.error=i("libp2p:peer-store:proto-book:error");const o=r(7),a=r(124),{codes:{ERR_INVALID_PARAMETERS:c}}=r(28);t.exports=class extends a{constructor(t){super({peerStore:t,eventName:"change:protocols",eventProperty:"protocols",eventTransformer:t=>Array.from(t)}),this.data=new Map}set(t,e){if(!o.isPeerId(t))throw s.error("peerId must be an instance of peer-id to store data"),n(new Error("peerId must be an instance of peer-id"),c);if(!e)throw s.error("protocols must be provided to store data"),n(new Error("protocols must be provided"),c);const r=t.toB58String(),i=this.data.get(r),a=new Set(e);return i&&(h=a,(u=i).size===h.size&&[...u].every(t=>h.has(t)))?(s("the protocols provided to store are equal to the already stored for "+r),this):(this._setData(t,a),s("stored provided protocols for "+r),this);var u,h}add(t,e){if(!o.isPeerId(t))throw s.error("peerId must be an instance of peer-id to store data"),n(new Error("peerId must be an instance of peer-id"),c);if(!e)throw s.error("protocols must be provided to store data"),n(new Error("protocols must be provided"),c);const r=t.toB58String(),i=this.data.get(r)||new Set,a=new Set([...i,...e]);return i.size===a.size?(s("the protocols provided to store are already stored for "+r),this):(e=[...a],this._setData(t,a),s("added provided protocols for "+r),this)}}},function(t,e,r){"use strict";t.exports=(t,e,r)=>new class extends t{subscribe(t,e){e&&this.on(t,e),super.subscribe(t)}unsubscribe(t,e){e?this.removeListener(t,e):this.removeAllListeners(t),0===this.listenerCount(t)&&super.unsubscribe(t)}}(e,r)},function(t,e,r){"use strict";const n=r(1),i=n("libp2p:persistent-peer-store");i.error=n("libp2p:persistent-peer-store:error");const{Key:s}=r(10),o=r(17),a=r(7),c=r(339),{NAMESPACE_ADDRESS:u,NAMESPACE_COMMON:h,NAMESPACE_KEYS:f,NAMESPACE_METADATA:l,NAMESPACE_PROTOCOL:d}=r(848),p=r(849),y=r(850);t.exports=class extends c{constructor({peerId:t,datastore:e,threshold:r=5}){super({peerId:t}),this._datastore=e,this._dirtyPeers=new Set,this._dirtyMetadata=new Map,this.threshold=r,this._addDirtyPeer=this._addDirtyPeer.bind(this)}async start(){i("PeerStore is starting"),this.on("change:protocols",this._addDirtyPeer),this.on("change:multiaddrs",this._addDirtyPeer),this.on("change:pubkey",this._addDirtyPeer),this.on("change:metadata",this._addDirtyPeerMetadata);for await(const t of this._datastore.query({prefix:h}))await this._processDatastoreEntry(t);i("PeerStore started")}async stop(){i("PeerStore is stopping"),this.removeAllListeners(),await this._commitData(),i("PeerStore stopped")}_addDirtyPeer({peerId:t}){const e=t.toB58String();i("add dirty peer",e),this._dirtyPeers.add(e),this._dirtyPeers.size>=this.threshold&&this._commitData().catch(t=>{i.error("error committing data",t)})}_addDirtyPeerMetadata({peerId:t,metadata:e}){const r=t.toB58String();i("add dirty metadata peer",r),this._dirtyPeers.add(r);const n=this._dirtyMetadata.get(r)||new Set;n.add(e),this._dirtyMetadata.set(r,n),this._dirtyPeers.size>=this.threshold&&this._commitData().catch(t=>{i.error("error committing data",t)})}async _commitData(){const t=Array.from(this._dirtyPeers);if(!t.length)return;this._dirtyPeers.clear(),i("create batch commit");const e=this._datastore.batch();for(const r of t){const t=this.keyBook.data.get(r)||a.createFromCID(r);this._batchAddressBook(t,e),this._batchKeyBook(t,e),this._batchMetadataBook(t,e),this._batchProtoBook(t,e)}await e.commit(),i("batch committed")}_batchAddressBook(t,e){const r=t.toString(),n=new s(`${u}${r}`),o=this.addressBook.data.get(t.toB58String());try{if(!o)return void e.delete(n);const t=p.encode({addrs:o.addresses.map(t=>({multiaddr:t.multiaddr.bytes,isCertified:t.isCertified})),certified_record:o.record?{seq:o.record.seqNumber,raw:o.record.raw}:void 0});e.put(n,t)}catch(a){i.error(a)}}_batchKeyBook(t,e){const r=t.toString(),n=new s(`${f}${r}`);try{if(!t.pubKey)return void e.delete(n);const r=t.marshalPubKey();e.put(n,r)}catch(o){i.error(o)}}_batchMetadataBook(t,e){const r=t.toString(),n=this._dirtyMetadata.get(t.toB58String())||[];try{n.forEach(n=>{const i=new s(`${l}${r}/${n}`),o=this.metadataBook.getValue(t,n);o?e.put(i,o):e.delete(i)})}catch(o){i.error(o)}}_batchProtoBook(t,e){const r=t.toString(),n=new s(`${d}${r}`),o=this.protoBook.get(t);try{if(!o)return void e.delete(n);const t=y.encode({protocols:o});e.put(n,t)}catch(a){i.error(a)}}async _processDatastoreEntry({key:t,value:e}){try{const r=t.toString().split("/"),n=a.createFromCID(r[3]);let s;switch(r[2]){case"addrs":s=p.decode(e),this.addressBook._setData(n,{addresses:s.addrs.map(t=>({multiaddr:o(t.multiaddr),isCertified:Boolean(t.isCertified)})),record:s.certified_record?{raw:s.certified_record.raw,seqNumber:s.certified_record.seq}:void 0},{emit:!1});break;case"keys":s=await a.createFromPubKey(e),this.keyBook._setData(s,s,{emit:!1});break;case"metadata":this.metadataBook._setValue(n,r[4],e,{emit:!1});break;case"protos":s=y.decode(e),this.protoBook._setData(n,new Set(s.protocols),{emit:!1});break;default:i("invalid data persisted for: ",t.toString())}}catch(r){i.error(r)}}}},function(t,e,r){"use strict";t.exports.NAMESPACE_COMMON="/peers/",t.exports.NAMESPACE_ADDRESS="/peers/addrs/",t.exports.NAMESPACE_KEYS="/peers/keys/",t.exports.NAMESPACE_METADATA="/peers/metadata/",t.exports.NAMESPACE_PROTOCOL="/peers/protos/"},function(t,e,r){"use strict";const n=r(21);t.exports=n("\nmessage Addresses {\n // Address represents a single multiaddr.\n message Address {\n required bytes multiaddr = 1;\n\n // Flag to indicate if the address comes from a certified source.\n optional bool isCertified = 2;\n }\n\n // CertifiedRecord contains a serialized signed PeerRecord used to\n // populate the signedAddrs list.\n message CertifiedRecord {\n // The Seq counter from the signed PeerRecord envelope\n uint64 seq = 1;\n\n // The serialized bytes of the SignedEnvelope containing the PeerRecord.\n bytes raw = 2;\n }\n\n // The known multiaddrs.\n repeated Address addrs = 1;\n\n // The most recently received signed PeerRecord.\n CertifiedRecord certified_record = 2;\n}\n").Addresses},function(t,e,r){"use strict";const n=r(21);t.exports=n("\nmessage Protocols {\n repeated string protocols = 1;\n}\n").Protocols},function(t,e,r){"use strict";const n=r(1),i=r(0);n("libp2p:peer-store").error=n("libp2p:peer-store:error");const{ERR_INVALID_PARAMETERS:s}=r(28),o=r(852);t.exports=class{constructor({peerStore:t,connectionManager:e}){this.peerStore=t,this.connectionManager=e,this.topologies=new Map,this._handle=void 0,this._onDisconnect=this._onDisconnect.bind(this),this.connectionManager.on("peer:disconnect",this._onDisconnect)}get handle(){return this._handle}set handle(t){this._handle=t}getConnection(t){return this.connectionManager.get(t)}register(t){if(!o.isTopology(t))throw i(new Error("topology must be an instance of interfaces/topology"),s);const e=parseInt(1e9*Math.random()).toString(36)+Date.now();return this.topologies.set(e,t),t.registrar=this,e}unregister(t){return this.topologies.delete(t)}_onDisconnect(t,e){for(const[,r]of this.topologies)r.disconnect(t.remotePeer,e)}}},function(t,e,r){"use strict";const n=r(27),i=()=>{};t.exports=n(class{constructor({min:t=0,max:e=1/0,handlers:r={}}){this.min=t,this.max=e,this._onConnect=r.onConnect||i,this._onDisconnect=r.onDisconnect||i,this.peers=new Set}set registrar(t){this._registrar=t}disconnect(t){this._onDisconnect(t)}},{className:"Topology",symbolName:"@libp2p/js-interfaces/topology"})},function(t,e,r){"use strict";const n=r(1),i=n("libp2p-ping");i.error=n("libp2p-ping:error");const s=r(0),o=r(37),a=r(25),{toBuffer:c}=r(125),{collect:u,take:h}=r(52),{PROTOCOL:f,PING_LENGTH:l}=r(854);(e=t.exports=async function(t,e){i("dialing %s to %s",f,e.toB58String?e.toB58String():e);const{stream:r}=await t.dialProtocol(e,f),n=new Date,d=o.randomBytes(l),[p]=await a([d],r,t=>h(1,t),c,u),y=Date.now();if(!d.equals(p))throw s(new Error("Received wrong ping ack"),"ERR_WRONG_PING_ACK");return y-n}).mount=function(t){t.handle(f,({stream:t})=>a(t,t))},e.unmount=function(t){t.unhandle(f)}},function(t,e,r){"use strict";t.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32}},function(t,e,r){"use strict";const n=r(1),i=n("libp2p:identify");i.error=n("libp2p:identify:error");const s=r(0),o=r(856),a=r(32),c=r(25),{collect:u,take:h,consume:f}=r(52),l=r(6),d=r(7),p=r(17),{toBuffer:y}=r(125),g=r(858),b=r(192),m=r(340),{MULTICODEC_IDENTIFY:v,MULTICODEC_IDENTIFY_PUSH:w,AGENT_VERSION:_,PROTOCOL_VERSION:E}=r(859),{codes:S}=r(28);class I{static getCleanMultiaddr(t){if(t&&t.length>0)try{return p(t)}catch(e){return null}return null}constructor({libp2p:t,protocols:e}){this.peerStore=t.peerStore,this.connectionManager=t.connectionManager,this.connectionManager.on("peer:connect",t=>{const e=t.remotePeer;this.identify(t,e).catch(i.error)}),this.peerId=t.peerId,this._libp2p=t,this._protocols=e,this.handleMessage=this.handleMessage.bind(this)}async push(t){const e=await this._getSelfPeerRecord(),r=this._libp2p.multiaddrs.map(t=>t.bytes),n=Array.from(this._protocols.keys()),s=t.map(async t=>{try{const{stream:i}=await t.newStream(w);await c([{listenAddrs:r,signedPeerRecord:e,protocols:n}],o.encode(g),i,f)}catch(s){i.error("could not push identify update to peer",s)}});return Promise.all(s)}pushToPeerStore(t){const e=[];let r;for(const n of t.peers.values())n.protocols.includes(w)&&(r=this.connectionManager.get(n.id))&&e.push(r);this.push(e)}async identify(t){const{stream:e}=await t.newStream(v),[r]=await c([],e,a.decode(),h(1),y,u);if(!r)throw s(new Error("No data could be retrieved"),S.ERR_CONNECTION_ENDED);let n;try{n=g.decode(r)}catch(k){throw s(k,S.ERR_INVALID_MESSAGE)}let{publicKey:o,listenAddrs:f,protocols:w,observedAddr:_,signedPeerRecord:E}=n;const A=await d.createFromPubKey(o);if(t.remotePeer.toB58String()!==A.toB58String())throw s(new Error("identified peer does not match the expected peer"),S.ERR_INVALID_PEER);_=I.getCleanMultiaddr(_);try{const t=await b.openAndCertify(E,m.DOMAIN);if(this.peerStore.addressBook.consumePeerRecord(t))return void this.peerStore.protoBook.set(A,w)}catch(k){i("received invalid envelope, discard it and fallback to listenAddrs is available",k)}try{this.peerStore.addressBook.set(A,f.map(t=>p(t)))}catch(k){i.error("received invalid addrs",k)}this.peerStore.protoBook.set(A,w),this.peerStore.metadataBook.set(A,"AgentVersion",l(n.agentVersion)),i("received observed address of %s",_)}handleMessage({connection:t,stream:e,protocol:r}){switch(r){case v:return this._handleIdentify({connection:t,stream:e});case w:return this._handlePush({connection:t,stream:e});default:i.error("cannot handle unknown protocol %s",r)}}async _handleIdentify({connection:t,stream:e}){let r=new Uint8Array(0);this.peerId.pubKey&&(r=this.peerId.pubKey.bytes);const n=await this._getSelfPeerRecord(),s=g.encode({protocolVersion:E,agentVersion:_,publicKey:r,listenAddrs:this._libp2p.multiaddrs.map(t=>t.bytes),signedPeerRecord:n,observedAddr:t.remoteAddr.bytes,protocols:Array.from(this._protocols.keys())});try{await c([s],a.encode(),e,f)}catch(o){i.error("could not respond to identify request",o)}}async _handlePush({connection:t,stream:e}){let r;try{const[t]=await c([],e,a.decode(),h(1),y,u);r=g.decode(t)}catch(s){return i.error("received invalid message",s)}const n=t.remotePeer;try{const t=await b.openAndCertify(r.signedPeerRecord,m.DOMAIN);if(this.peerStore.addressBook.consumePeerRecord(t))return void this.peerStore.protoBook.set(n,r.protocols)}catch(s){i("received invalid envelope, discard it and fallback to listenAddrs is available",s)}try{this.peerStore.addressBook.set(n,r.listenAddrs.map(t=>p(t)))}catch(s){i.error("received invalid addrs",s)}this.peerStore.protoBook.set(n,r.protocols)}async _getSelfPeerRecord(){const t=this.peerStore.addressBook.getRawEnvelope(this.peerId);if(t)return t;try{const t=new m({peerId:this.peerId,multiaddrs:this._libp2p.multiaddrs}),e=await b.seal(t,this.peerId);return this.peerStore.addressBook.consumePeerRecord(e),this.peerStore.addressBook.getRawEnvelope(this.peerId)}catch(e){i.error("failed to get self peer record")}return null}}t.exports.IdentifyService=I,t.exports.multicodecs={IDENTIFY:v,IDENTIFY_PUSH:w},t.exports.Message=g},function(t,e,r){"use strict";const n=r(32),i=r(857),s=r(125);t.exports.encode=t=>e=>n.encode()(i.encode(t)(e)),t.exports.decode=t=>e=>i.decode(t)(s(n.decode()(e))),t.exports.it=i},function(t,e,r){"use strict";t.exports.encode=t=>e=>async function*(){for await(const r of e)yield t.encode(r)}(),t.exports.decode=t=>e=>async function*(){for await(const r of e)yield t.decode(r)}()},function(t,e,r){"use strict";const n=r(21);t.exports=n("\nmessage Identify {\n // protocolVersion determines compatibility between peers\n optional string protocolVersion = 5; // e.g. ipfs/1.0.0\n\n // agentVersion is like a UserAgent string in browsers, or client version in bittorrent\n // includes the client name and client.\n optional string agentVersion = 6; // e.g. go-ipfs/0.1.0\n\n // publicKey is this node's public key (which also gives its node.ID)\n // - may not need to be sent, as secure channel implies it has been sent.\n // - then again, if we change / disable secure channel, may still want it.\n optional bytes publicKey = 1;\n\n // listenAddrs are the multiaddrs the sender node listens for open connections on\n repeated bytes listenAddrs = 2;\n\n // oservedAddr is the multiaddr of the remote endpoint that the sender node perceives\n // this is useful information to convey to the other side, as it helps the remote endpoint\n // determine whether its connection to the local peer goes through NAT.\n optional bytes observedAddr = 4;\n\n repeated string protocols = 3;\n\n // signedPeerRecord contains a serialized SignedEnvelope containing a PeerRecord,\n // signed by the sending node. It contains the same addresses as the listenAddrs field, but\n // in a form that lets us share authenticated addrs with other peers.\n optional bytes signedPeerRecord = 8;\n}\n").Identify},function(t,e,r){"use strict";const n=r(860).version;t.exports.PROTOCOL_VERSION="ipfs/0.1.0",t.exports.AGENT_VERSION="js-libp2p/"+n,t.exports.MULTICODEC_IDENTIFY="/ipfs/id/1.0.0",t.exports.MULTICODEC_IDENTIFY_PUSH="/ipfs/id/push/1.0.0"},function(t){t.exports=JSON.parse('{"_from":"libp2p@^0.29.0","_id":"libp2p@0.29.0","_inBundle":false,"_integrity":"sha512-eALoJ0vpsonRwzLpdPY2/272RIl2MImIg2QToqLb+wBChcSQFB4U/r3LU8rZqEaDfRNupOBG/rx67gJTWC0h2Q==","_location":"/libp2p","_phantomChildren":{"abort-controller":"3.0.0","abortable-iterator":"3.0.0","any-signal":"1.2.0","base64-js":"1.3.1","chai":"4.2.0","chai-checkmark":"1.0.1","class-is":"1.1.0","debug":"4.1.1","delay":"4.4.0","detect-node":"2.0.4","dirty-chai":"2.0.1","err-code":"2.0.3","fs-extra":"9.0.1","ieee754":"1.1.13","is-electron":"2.2.0","iso-url":"0.4.7","it-glob":"0.0.8","it-goodbye":"2.0.2","it-length-prefixed":"3.1.0","it-pair":"1.0.0","it-pipe":"1.1.0","it-pushable":"1.4.0","it-to-stream":"0.1.2","libp2p-crypto":"0.18.0","libp2p-tcp":"0.15.1","merge-options":"2.0.0","multiaddr":"8.0.0","multibase":"3.0.0","nanoid":"3.1.12","node-fetch":"2.6.1","p-defer":"3.0.0","p-limit":"2.3.0","p-wait-for":"3.1.0","peer-id":"0.14.1","protons":"2.0.0","sinon":"9.0.3","stream-to-it":"0.2.2","streaming-iterables":"5.0.2","uint8arrays":"1.1.0"},"_requested":{"type":"range","registry":true,"raw":"libp2p@^0.29.0","name":"libp2p","escapedName":"libp2p","rawSpec":"^0.29.0","saveSpec":null,"fetchSpec":"^0.29.0"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/libp2p/-/libp2p-0.29.0.tgz","_shasum":"56d55630b834111b8d0c62724e139461672d5bfd","_spec":"libp2p@^0.29.0","_where":"/Users/alex/Documents/Workspaces/ipfs/js-ipfs","bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"bundleDependencies":false,"contributors":[{"name":"David Dias","email":"daviddias.p@gmail.com"},{"name":"Jacob Heun","email":"jacobheun@gmail.com"},{"name":"Vasco Santos","email":"vasco.santos@moxy.studio"},{"name":"Alan Shaw","email":"alan@tableflip.io"},{"name":"Alex Potsides","email":"alex@achingbrain.net"},{"name":"Cayman","email":"caymannava@gmail.com"},{"name":"Pedro Teixeira","email":"i@pgte.me"},{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},{"name":"Maciej Krüger","email":"mkg20001@gmail.com"},{"name":"Hugo Dias","email":"mail@hugodias.me"},{"name":"Volker Mische","email":"volker.mische@gmail.com"},{"name":"dirkmc","email":"dirkmdev@gmail.com"},{"name":"Richard Littauer","email":"richard.littauer@gmail.com"},{"name":"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ","email":"victorbjelkholm@gmail.com"},{"name":"Andrew Nesbitt","email":"andrewnez@gmail.com"},{"name":"Elven","email":"mon.samuel@qq.com"},{"name":"Giovanni T. Parra","email":"fiatjaf@gmail.com"},{"name":"Ryan Bell","email":"ryan@piing.net"},{"name":"Thomas Eizinger","email":"thomas@eizinger.io"},{"name":"Didrik Nordström","email":"didrik@betamos.se"},{"name":"Francis Gulotta","email":"wizard@roborooter.com"},{"name":"Florian-Merle","email":"florian.david.merle@gmail.com"},{"name":"Joel Gustafson","email":"joelg@mit.edu"},{"name":"Julien Bouquillon","email":"contact@revolunet.com"},{"name":"Kevin Kwok","email":"antimatter15@gmail.com"},{"name":"Felipe Martins","email":"felipebrasil93@gmail.com"},{"name":"Nuno Nogueira","email":"nunofmn@gmail.com"},{"name":"Fei Liu","email":"liu.feiwood@gmail.com"},{"name":"RasmusErik Voel Jensen","email":"github@solsort.com"},{"name":"Dmitriy Ryajov","email":"dryajov@gmail.com"},{"name":"Soeren","email":"nikorpoulsen@gmail.com"},{"name":"Sönke Hahn","email":"soenkehahn@gmail.com"},{"name":"Tiago Alves","email":"alvesjtiago@gmail.com"},{"name":"Diogo Silva","email":"fsdiogo@gmail.com"},{"name":"Yusef Napora","email":"yusef@napora.org"},{"name":"Zane Starr","email":"zcstarr@gmail.com"},{"name":"Daijiro Wachi","email":"daijiro.wachi@gmail.com"},{"name":"Chris Bratlien","email":"chrisbratlien@gmail.com"},{"name":"ebinks","email":"elizabethjbinks@gmail.com"},{"name":"Bernd Strehl","email":"bernd.strehl@gmail.com"},{"name":"isan_rivkin","email":"isanrivkin@gmail.com"},{"name":"Henrique Dias","email":"hacdias@gmail.com"},{"name":"robertkiel","email":"robert.kiel@validitylabs.org"},{"name":"Irakli Gozalishvili","email":"rfobic@gmail.com"}],"dependencies":{"abort-controller":"^3.0.0","aggregate-error":"^3.0.1","any-signal":"^1.1.0","bignumber.js":"^9.0.0","class-is":"^1.1.0","debug":"^4.1.1","err-code":"^2.0.0","events":"^3.1.0","hashlru":"^2.3.0","interface-datastore":"^2.0.0","ipfs-utils":"^2.2.0","it-all":"^1.0.1","it-buffer":"^0.1.2","it-handshake":"^1.0.1","it-length-prefixed":"^3.0.1","it-pipe":"^1.1.0","it-protocol-buffers":"^0.2.0","libp2p-crypto":"^0.18.0","libp2p-interfaces":"^0.5.1","libp2p-utils":"^0.2.0","mafmt":"^8.0.0","merge-options":"^2.0.0","moving-average":"^1.0.0","multiaddr":"^8.0.0","multicodec":"^2.0.0","multistream-select":"^1.0.0","mutable-proxy":"^1.0.0","node-forge":"^0.9.1","p-any":"^3.0.0","p-fifo":"^1.0.0","p-settle":"^4.0.1","peer-id":"^0.14.0","protons":"^2.0.0","retimer":"^2.0.0","sanitize-filename":"^1.6.3","streaming-iterables":"^5.0.2","timeout-abort-controller":"^1.1.1","varint":"^5.0.0","xsalsa20":"^1.0.2"},"deprecated":false,"description":"JavaScript implementation of libp2p, a modular peer to peer network stack","devDependencies":{"@nodeutils/defaults-deep":"^1.1.0","abortable-iterator":"^3.0.0","aegir":"^26.0.0","chai":"^4.2.0","chai-as-promised":"^7.1.1","chai-bytes":"^0.1.2","chai-string":"^1.5.0","cids":"^1.0.0","delay":"^4.3.0","dirty-chai":"^2.0.1","interop-libp2p":"^0.3.0","ipfs-http-client":"^46.0.0","it-concat":"^1.0.0","it-pair":"^1.0.0","it-pushable":"^1.4.0","libp2p":".","libp2p-bootstrap":"^0.12.0","libp2p-delegated-content-routing":"^0.6.0","libp2p-delegated-peer-routing":"^0.6.0","libp2p-floodsub":"^0.23.0","libp2p-gossipsub":"^0.6.0","libp2p-kad-dht":"^0.20.0","libp2p-mdns":"^0.15.0","libp2p-mplex":"^0.10.0","libp2p-noise":"^2.0.0","libp2p-secio":"^0.13.1","libp2p-tcp":"^0.15.1","libp2p-webrtc-star":"^0.20.0","libp2p-websockets":"^0.14.0","multihashes":"^3.0.1","nock":"^13.0.3","p-defer":"^3.0.0","p-times":"^3.0.0","p-wait-for":"^3.1.0","promisify-es6":"^1.0.3","rimraf":"^3.0.2","sinon":"^9.0.2","uint8arrays":"^1.1.0"},"engines":{"node":">=12.0.0","npm":">=6.0.0"},"files":["dist","src"],"homepage":"https://libp2p.io","keywords":["libp2p","network","p2p","peer","peer-to-peer","IPFS"],"leadMaintainer":"Jacob Heun ","license":"MIT","main":"src/index.js","name":"libp2p","repository":{"type":"git","url":"git+https://github.com/libp2p/js-libp2p.git"},"scripts":{"build":"aegir build","coverage":"nyc --reporter=text --reporter=lcov npm run test:node","lint":"aegir lint","release":"aegir release -t node -t browser","release-major":"aegir release --type major -t node -t browser","release-minor":"aegir release --type minor -t node -t browser","test":"npm run test:node && npm run test:browser","test:browser":"aegir test -t browser","test:node":"aegir test -t node -f \\"./test/**/*.{node,spec}.js\\""},"version":"0.29.0"}')},function(t,e,r){"use strict";const n=r(862),i=r(885),s=r(914),{NOISE:o}=r(920),a=r(960),c=r(969),u=r(318),h=r(317);t.exports=()=>({dialer:{maxParallelDials:150,maxDialsPerPeer:4,dialTimeout:1e4},modules:{transport:[n,i],streamMuxer:[s],connEncryption:[o,a],peerDiscovery:[],dht:c,pubsub:u},config:{peerDiscovery:{autoDial:!0,bootstrap:{enabled:!0},webRTCStar:{enabled:!0}},dht:{kBucketSize:20,enabled:!1,clientMode:!0,randomWalk:{enabled:!1},validators:{ipns:h.validator},selectors:{ipns:h.selector}},pubsub:{enabled:!0,emitSelf:!0}},metrics:{enabled:!0},peerStore:{persistence:!0,threshold:1}})},function(t,e,r){"use strict";const n=r(863),i=r(61),s=r(27),o=r(314),{AbortError:a}=r(47),c=r(1)("libp2p:websockets"),u=r(874),h=r(875),{CODE_CIRCUIT:f,CODE_P2P:l}=r(341);t.exports=s(class{constructor({upgrader:t}){if(!t)throw new Error("An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.");this._upgrader=t}async dial(t,e={}){c("dialing %s",t);const r=await this._connect(t,e),n=h(r,{remoteAddr:t,signal:e.signal});c("new outbound connection %s",n.remoteAddr);const i=await this._upgrader.upgradeOutbound(n);return c("outbound connection %s upgraded",n.remoteAddr),i}async _connect(t,e={}){if(e.signal&&e.signal.aborted)throw new a;const r=t.toOptions();c("dialing %s:%s",r.host,r.port);const i=n(o(t),Object.assign({binary:!0},e));if(!e.signal)return await i.connected(),c("connected %s",t),i;let s;const u=new Promise((t,r)=>{if(s=()=>{r(new a),i.close()},e.signal.aborted)return s();e.signal.addEventListener("abort",s)});try{await Promise.race([u,i.connected()])}finally{e.signal.removeEventListener("abort",s)}return c("connected %s",t),i}createListener(t={},e){return"function"==typeof t&&(e=t,t={}),u({handler:e,upgrader:this._upgrader},t)}filter(t){return(t=Array.isArray(t)?t:[t]).filter(t=>!t.protoCodes().includes(f)&&(i.WebSockets.matches(t.decapsulateCode(l))||i.WebSocketsSecure.matches(t.decapsulateCode(l))))}},{className:"WebSockets",symbolName:"@libp2p/js-libp2p-websockets/websockets"})},function(t,e,r){"use strict";var n=r(864),i=r(866),s=r(872);t.exports=function(t,e={}){const r="undefined"==typeof window?{}:window.location,o=s(t,r),a=new n(o,e.websocket),c=i(a,e);return c.remoteAddress=o,c.close=()=>new Promise((t,e)=>{a.addEventListener("close",t),a.close()}),c.destroy=()=>{a.terminate?a.terminate():a.close()},c.socket=a,c},t.exports.connect=t.exports},function(t,e,r){"use strict";t.exports="undefined"==typeof WebSocket?r(865):WebSocket},function(t,e){},function(t,e,r){"use strict";const n=r(867),i=r(870);t.exports=(t,e)=>{(e=e||{}).binaryType?t.binaryType=e.binaryType:e.binary&&(t.binaryType="arraybuffer");const r={sink:i(t,e),source:n(t,e),connected:()=>r.source.connected()};return r}},function(t,e,r){"use strict";const{Buffer:n}=r(3),{EventIterator:i}=r(868);t.exports=t=>{const e=t.removeEventListener||t.removeListener,r=async function*(){const r=new i(({push:r,stop:n,fail:i})=>(t.addEventListener("message",r),t.addEventListener("error",i),t.addEventListener("close",n),()=>{e.call(t,"message",r),e.call(t,"error",i),e.call(t,"close",n)}),{highWaterMark:1/0});for await(const{data:t}of r)yield(s=t,s instanceof ArrayBuffer||null!=s&&null!=s.constructor&&"ArrayBuffer"===s.constructor.name&&"number"==typeof s.byteLength?n.from(t):t);var s}();let s,o=1===t.readyState;return t.addEventListener("open",()=>{o=!0,s=null}),t.addEventListener("close",()=>{o=!1,s=null}),t.addEventListener("error",t=>{o||(s=t)}),r.connected=()=>new Promise((r,n)=>{if(o)return r();if(s)return n(s);const i=r=>{e.call(t,"open",a),e.call(t,"error",c),r()},a=()=>i(r),c=t=>i(()=>n(t));t.addEventListener("open",a),t.addEventListener("error",c)}),r}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(869);e.EventIterator=n.EventIterator,e.subscribe=function(t,e,r){return new n.EventIterator(({push:r})=>(this.addEventListener(t,r,e),()=>this.removeEventListener(t,r,e)),r)},e.default=n.EventIterator},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(t){if(this.isStopped)return;const e={value:t,done:!1};if(this.pullQueue.length){const t=this.pullQueue.shift();t&&t.resolve(e)}else this.pushQueue.push(Promise.resolve(e)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const t of this.pullQueue)t.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(t){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const e of this.pullQueue)e.reject(t);this.pullQueue.length=0}else{const e=Promise.reject(t);e.catch(()=>{}),this.pushQueue.push(e)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:t=>{const e=this.pushQueue.shift();return e?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),e):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((t,e)=>{this.pullQueue.push({resolve:t,reject:e})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class i{constructor(t,{highWaterMark:e=100,lowWaterMark:r=1}={}){const i=new n;i.highWaterMark=e,i.lowWaterMark=r,i.removeCallback=t({push:t=>i.push(t),stop:()=>i.stop(),fail:t=>i.fail(t),on:(t,e)=>{i.eventHandlers[t]=e}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}}e.EventIterator=i,e.default=i},function(t,e,r){"use strict";const n=r(871);t.exports=(t,e)=>((e=e||{}).closeOnEnd=!1!==e.closeOnEnd,async r=>{for await(const e of r){try{await n(t)}catch(i){if("socket closed"===i.message)break;throw i}t.send(e)}if(e.closeOnEnd&&t.readyState<=1)return new Promise((e,r)=>{t.addEventListener("close",t=>{if(t.wasClean||1006===t.code)e();else{const e=Object.assign(new Error("ws error"),{event:t});r(e)}}),setTimeout(()=>t.close())})})},function(t,e,r){"use strict";t.exports=async t=>{if(t.readyState>=2)throw new Error("socket closed");if(1!==t.readyState)return new Promise((e,r)=>{const n=t&&(t.removeEventListener||t.removeListener);function i(){"function"==typeof n&&(n.call(t,"open",s),n.call(t,"error",o))}function s(){i(),e()}function o(t){i(),r(t)}t.addEventListener("open",s),t.addEventListener("error",o)})}},function(t,e,r){"use strict";const n=r(873),i={http:"ws",https:"wss"};t.exports=(t,e)=>n(t,e,i,"ws")},function(t,e,r){"use strict";var n=r(166);t.exports=function(t,e,r,i){var s;return r=r||{},s=(t=n.parse(t,!1,!0)).protocol?t.protocol:(r[s=e.protocol?e.protocol.replace(/:$/,""):"http"]||i||s)+":",t.host&&":"===t.host[0]&&(t.host=null),t.hostname?n.format({protocol:s,slashes:!0,hostname:t.hostname,port:t.port,pathname:t.pathname,search:t.search}):(t.host=e.host,t.port?n.format({protocol:s,slashes:!0,host:e.hostname+":"+t.port,port:t.port,pathname:t.pathname,search:t.search}):t.pathname?n.format({protocol:s,slashes:!0,host:t.host,pathname:t.pathname,search:t.search}):(t.pathname=e.pathname,t.search?n.format({protocol:s,slashes:!0,host:t.host,pathname:t.pathname,search:t.search}):(t.search=e.search,t.format(t))))}},function(t,e,r){"use strict";t.exports=function(){throw new Error("WebSocket Servers can not be created in the browser!")}},function(t,e,r){"use strict";const n=r(47),{CLOSE_TIMEOUT:i}=r(341),s=r(342),o=r(884),a=r(1),c=a("libp2p:websockets:socket");c.error=a("libp2p:websockets:socket:error"),t.exports=(t,e={})=>{const r={async sink(r){e.signal&&(r=n(r,e.signal));try{await t.sink(async function*(){for await(const t of r)yield t instanceof Uint8Array?t:t.slice()}())}catch(i){"aborted"!==i.type&&c.error(i)}},source:e.signal?n(t.source,e.signal):t.source,conn:t,localAddr:e.localAddr||(t.localAddress&&t.localPort?s(t.localAddress,t.localPort):void 0),remoteAddr:e.remoteAddr||s(t.remoteAddress,t.remotePort),timeline:{open:Date.now()},async close(){const e=Date.now();try{await o(t.close(),i)}catch(n){const{host:i,port:s}=r.remoteAddr.toOptions();c("timeout closing stream to %s:%s after %dms, destroying it manually",i,s,Date.now()-e),t.destroy()}finally{r.timeline.close=Date.now()}}};return t.socket.once&&t.socket.once("close",()=>{r.timeline.close||(r.timeline.close=Date.now())}),r}},function(t,e,r){"use strict";e.Address4=r(343),e.Address6=r(877),e.v6={helpers:r(348)}},function(t,e,r){"use strict";var n=r(344).BigInteger,i=r(102).sprintf,s=r(878),o=r(346),a=r(347),c=r(879),u=r(880),h=r(202),f=r(203),l=r(343);function d(t){return t=(t=t.replace(/^(0{1,})([1-9]+)$/,'$1$2')).replace(/^(0{1,})(0)$/,'$1$2')}function p(t,e){this.groups=void 0===e?f.GROUPS:e,this.v4=!1,this.subnet="/128",this.subnetMask=128,this.zone="",this.address=t;var r=f.RE_SUBNET_STRING.exec(t);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>f.BITS)return this.valid=!1,void(this.error="Invalid subnet mask.");t=t.replace(f.RE_SUBNET_STRING,"")}else if(/\//.test(t))return this.valid=!1,void(this.error="Invalid subnet mask.");var n=f.RE_ZONE_STRING.exec(t);n&&(this.zone=n[0],t=t.replace(f.RE_ZONE_STRING,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}function y(t){return i("%04x",parseInt(t,16))}function g(t){return 255&t}s(p.prototype,r(881)),s(p.prototype,r(882)),s(p.prototype,r(883)),p.fromBigInteger=function(t){var e,r=o(t.toString(16),32,"0"),n=[];for(e=0;e65536)&&(r=null):r=null,{address:new p(e),port:r}},p.fromAddress4=function(t){t=new l(t);var e=f.BITS-(h.BITS-t.subnetMask);return new p("::ffff:"+t.correctForm()+"/"+e)},p.fromArpa=function(t){var e=t.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==e.length)return e={error:"Not Valid 'ip6.arpa' form",address:null};e=e.split(".").reverse();for(var r=7;r>0;r--){var n=4*r;e.splice(n,0,":")}return new p(e=e.join(""))},p.prototype.microsoftTranscription=function(){return i("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))},p.prototype.mask=function(t){return void 0===t&&(t=this.subnetMask),this.getBitsBase2(0,t)},p.prototype.possibleSubnets=function(t){void 0===t&&(t=128);var e=f.BITS-this.subnetMask-Math.abs(t-f.BITS);return e<0?"0":function(t){for(var e=/(\d+)(\d{3})/;e.test(t);)t=t.replace(e,"$1,$2");return t}(new n("2",10).pow(e).toString(10))},p.prototype._startAddress=function(){return new n(this.mask()+a("0",f.BITS-this.subnetMask),2)},p.prototype.startAddress=function(){return p.fromBigInteger(this._startAddress())},p.prototype.startAddressExclusive=function(){var t=new n("1");return p.fromBigInteger(this._startAddress().add(t))},p.prototype._endAddress=function(){return new n(this.mask()+a("1",f.BITS-this.subnetMask),2)},p.prototype.endAddress=function(){return p.fromBigInteger(this._endAddress())},p.prototype.endAddressExclusive=function(){var t=new n("1");return p.fromBigInteger(this._endAddress().subtract(t))},p.prototype.getScope=function(){var t=f.SCOPES[this.getBits(12,16)];return"Global unicast"===this.getType()&&"Link local"!==t&&(t="Global"),t},p.prototype.getType=function(){var t=this;return c(f.TYPES,(function(e,r){return t.isInSubnet(new p(r))}))||"Global unicast"},p.prototype.getBits=function(t,e){return new n(this.getBitsBase2(t,e),2)},p.prototype.getBitsBase2=function(t,e){return this.binaryZeroPad().slice(t,e)},p.prototype.getBitsBase16=function(t,e){var r=e-t;return r%4!=0?null:o(this.getBits(t,e).toString(16),r/4,"0")},p.prototype.getBitsPastSubnet=function(){return this.getBitsBase2(this.subnetMask,f.BITS)},p.prototype.reverseForm=function(t){t||(t={});var e=Math.floor(this.subnetMask/4),r=this.canonicalForm().replace(/:/g,"").split("").slice(0,e).reverse().join(".");return e>0?t.omitSuffix?r:i("%s.ip6.arpa.",r):t.omitSuffix?"":"ip6.arpa."},p.prototype.correctForm=function(){if(!this.parsedAddress)return null;var t,e=[],r=0,n=[];for(t=0;t0&&(r>1&&n.push([t-r,t-1]),r=0)}r>1&&n.push([this.parsedAddress.length-r,this.parsedAddress.length-1]);var s=n.map((function(t){return t[1]-t[0]+1}));if(n.length>0){var o=s.indexOf(u(s));e=function(t,e){var r,n=[],i=[];for(r=0;re[1]&&i.push(t[r]);return n.concat(["compact"]).concat(i)}(this.parsedAddress,n[o])}else e=this.parsedAddress;for(t=0;t1?"s":"",e.join("")),this.parseError=t.replace(f.RE_BAD_CHARACTERS,'$1'),null;var r=t.match(f.RE_BAD_ADDRESS);if(r)return this.valid=!1,this.error=i("Address failed regex: %s",r.join("")),this.parseError=t.replace(f.RE_BAD_ADDRESS,'$1'),null;var n=[],s=t.split("::");if(2===s.length){var o=s[0].split(":"),a=s[1].split(":");1===o.length&&""===o[0]&&(o=[]),1===a.length&&""===a[0]&&(a=[]);var c=this.groups-(o.length+a.length);if(!c)return this.valid=!1,this.error="Error parsing groups",null;this.elidedGroups=c,this.elisionBegin=o.length,this.elisionEnd=o.length+this.elidedGroups,o.forEach((function(t){n.push(t)}));for(var u=0;u=0;s--)r=r.add(i.multiply(new n(t[s].toString(10),10))),i=i.multiply(e);return p.fromBigInteger(r)},t.exports=p},function(t,e,r){"use strict";(function(t,r){var n=/^\[object .+?Constructor\]$/,i=/^(?:0|[1-9]\d*)$/,s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1;var o="object"==typeof t&&t&&t.Object===Object&&t,a="object"==typeof self&&self&&self.Object===Object&&self,c=o||a||Function("return this")(),u=e&&!e.nodeType&&e,h=u&&"object"==typeof r&&r&&!r.nodeType&&r,f=h&&h.exports===u,l=f&&o.process,d=function(){try{var t=h&&h.require&&h.require("util").types;return t||l&&l.binding&&l.binding("util")}catch(e){}}(),p=d&&d.isTypedArray;function y(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var g,b,m,v=Array.prototype,w=Function.prototype,_=Object.prototype,E=c["__core-js_shared__"],S=w.toString,I=_.hasOwnProperty,A=(g=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+g:"",k=_.toString,T=S.call(Object),R=RegExp("^"+S.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),C=f?c.Buffer:void 0,B=c.Symbol,M=c.Uint8Array,x=C?C.allocUnsafe:void 0,N=(b=Object.getPrototypeOf,m=Object,function(t){return b(m(t))}),P=Object.create,O=_.propertyIsEnumerable,D=v.splice,L=B?B.toStringTag:void 0,U=function(){try{var t=ut(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),j=C?C.isBuffer:void 0,z=Math.max,F=Date.now,K=ut(c,"Map"),q=ut(Object,"create"),V=function(){function t(){}return function(e){if(!_t(e))return{};if(P)return P(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function H(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e-1},G.prototype.set=function(t,e){var r=this.__data__,n=Z(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},W.prototype.clear=function(){this.size=0,this.__data__={hash:new H,map:new(K||G),string:new H}},W.prototype.delete=function(t){var e=ct(this,t).delete(t);return this.size-=e?1:0,e},W.prototype.get=function(t){return ct(this,t).get(t)},W.prototype.has=function(t){return ct(this,t).has(t)},W.prototype.set=function(t,e){var r=ct(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},$.prototype.clear=function(){this.__data__=new G,this.size=0},$.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},$.prototype.get=function(t){return this.__data__.get(t)},$.prototype.has=function(t){return this.__data__.has(t)},$.prototype.set=function(t,e){var r=this.__data__;if(r instanceof G){var n=r.__data__;if(!K||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new W(n)}return r.set(t,e),this.size=r.size,this};var tt,et=function(t,e,r){for(var n=-1,i=Object(t),s=r(t),o=s.length;o--;){var a=s[tt?o:++n];if(!1===e(i[a],a,i))break}return t};function rt(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":L&&L in Object(t)?function(t){var e=I.call(t,L),r=t[L];try{t[L]=void 0;var n=!0}catch(s){}var i=k.call(t);n&&(e?t[L]=r:delete t[L]);return i}(t):function(t){return k.call(t)}(t)}function nt(t){return Et(t)&&"[object Arguments]"==rt(t)}function it(t){return!(!_t(t)||function(t){return!!A&&A in t}(t))&&(vt(t)?R:n).test(function(t){if(null!=t){try{return S.call(t)}catch(e){}try{return t+""}catch(e){}}return""}(t))}function st(t){if(!_t(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ft(t),r=[];for(var n in t)("constructor"!=n||!e&&I.call(t,n))&&r.push(n);return r}function ot(t,e,r,n,i){t!==e&&et(e,(function(s,o){if(i||(i=new $),_t(s))!function(t,e,r,n,i,s,o){var a=lt(t,r),c=lt(e,r),u=o.get(c);if(u)return void J(t,r,u);var h=s?s(a,c,r+"",t,e,o):void 0,f=void 0===h;if(f){var l=gt(c),d=!l&&mt(c),p=!l&&!d&&St(c);h=c,l||d||p?gt(a)?h=a:Et(v=a)&&bt(v)?h=function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r-1&&t%1==0&&t0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:Tt);function pt(t,e){return t===e||t!=t&&e!=e}var yt=nt(function(){return arguments}())?nt:function(t){return Et(t)&&I.call(t,"callee")&&!O.call(t,"callee")},gt=Array.isArray;function bt(t){return null!=t&&wt(t.length)&&!vt(t)}var mt=j||function(){return!1};function vt(t){if(!_t(t))return!1;var e=rt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function wt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function _t(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Et(t){return null!=t&&"object"==typeof t}var St=p?function(t){return function(e){return t(e)}}(p):function(t){return Et(t)&&wt(t.length)&&!!s[rt(t)]};function It(t){return bt(t)?Y(t,!0):st(t)}var At,kt=(At=function(t,e,r){ot(t,e,r)},at((function(t,e){var r=-1,n=e.length,i=n>1?e[n-1]:void 0,s=n>2?e[2]:void 0;for(i=At.length>3&&"function"==typeof i?(n--,i):void 0,s&&function(t,e,r){if(!_t(r))return!1;var n=typeof e;return!!("number"==n?bt(r)&&ht(e,r.length):"string"==n&&e in r)&&pt(r[e],t)}(e[0],e[1],s)&&(i=n<3?void 0:i,n=1),t=Object(t);++ra))return!1;var u=s.get(t);if(u&&s.get(e))return u==e;var h=-1,f=!0,l=1&i?new dt:void 0;for(s.set(t,e),s.set(e,t);++h-1},ft.prototype.set=function(t,e){var r=this.__data__,n=gt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},lt.prototype.clear=function(){this.__data__={hash:new ht,map:new(X||ft),string:new ht}},lt.prototype.delete=function(t){return At(this,t).delete(t)},lt.prototype.get=function(t){return At(this,t).get(t)},lt.prototype.has=function(t){return At(this,t).has(t)},lt.prototype.set=function(t,e){return At(this,t).set(t,e),this},dt.prototype.add=dt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},dt.prototype.has=function(t){return this.__data__.has(t)},pt.prototype.clear=function(){this.__data__=new ft},pt.prototype.delete=function(t){return this.__data__.delete(t)},pt.prototype.get=function(t){return this.__data__.get(t)},pt.prototype.has=function(t){return this.__data__.has(t)},pt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof ft){var n=r.__data__;if(!X||n.length<199)return n.push([t,e]),this;r=this.__data__=new lt(n)}return r.set(t,e),this};var Tt=function(t){return K.call(t)};function Rt(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||b.test(t))&&t>-1&&t%1==0&&t-1?n[i?t[s]:s]:void 0});function Lt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=t.apply(this,n);return r.cache=s.set(i,o),o};return r.cache=new(Lt.Cache||lt),r}function Ut(t,e){return t===e||t!=t&&e!=e}function jt(t){return function(t){return Ht(t)&&Ft(t)}(t)&&F.call(t,"callee")&&(!G.call(t,"callee")||K.call(t)==n)}Lt.Cache=lt;var zt=Array.isArray;function Ft(t){return null!=t&&qt(t.length)&&!Kt(t)}function Kt(t){var e=Vt(t)?K.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}function qt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function Vt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ht(t){return!!t&&"object"==typeof t}function Gt(t){return"symbol"==typeof t||Ht(t)&&"[object Symbol]"==K.call(t)}var Wt=T?function(t){return function(e){return t(e)}}(T):function(t){return Ht(t)&&qt(t.length)&&!!m[K.call(t)]};function $t(t){return Ft(t)?yt(t):Et(t)}function Yt(t){return t}r.exports=Dt}).call(this,r(11),r(110)(t))},function(t,e,r){"use strict";var n=Object.prototype.toString;function i(t,e){return t>e}function s(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==n.call(t)}function o(t){return t}t.exports=function(t){return t&&t.length?function(t,e,r){for(var n=-1,i=t.length;++n%2$s',t.prefix,e.call(this),t.className):s('%2$s',t.prefix,e.call(this))},e.group=function(){var t,e=this.address.match(n.RE_ADDRESS);if(e){var r=e[0].split(".");this.address=this.address.replace(n.RE_ADDRESS,s('%s.%s',r.slice(0,2).join("."),r.slice(2,4).join(".")))}if(0===this.elidedGroups)return i.simpleGroup(this.address);var o=[],a=this.address.split("::");a[0].length?o.push(i.simpleGroup(a[0])):o.push("");var c=["hover-group"];for(t=this.elisionBegin;t',c.join(" "))),a[1].length?o.push(i.simpleGroup(a[1],this.elisionEnd)):o.push(""),o.join(":")}},function(t,e,r){"use strict";var n=r(102).sprintf,i=r(203);function s(t){return n("(%s)",t.join("|"))}function o(t){return t.length<4?n("0{0,%d}%s",4-t.length,t):t}function a(t){var e=[];t.forEach((function(t,r){0===parseInt(t,16)&&e.push(r)}));var r=e.map((function(e){return t.map((function(t,r){if(r===e){var n=0===r||r===i.GROUPS-1?":":"";return s([o(t),n])}return o(t)})).join(":")}));return r.push(t.map(o).join(":")),s(r)}function c(t,e,r){var i=e?"":":",o=r?"":":",a=[];e||r||a.push("::"),e&&r&&a.push(""),(r&&!e||!r&&e)&&a.push(":"),a.push(n("%s(:0{1,4}){1,%d}",i,t-1)),a.push(n("(0{1,4}:){1,%d}%s",t-1,o)),a.push(n("(0{1,4}:){%d}0{1,4}",t-1));for(var c=1;cnew Promise((s,o)=>{if("number"!=typeof e||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0)return void s(t);const a=setTimeout(()=>{if("function"==typeof r){try{s(r())}catch(a){o(a)}return}const n=r instanceof Error?r:new i("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(n)},e);n(t.then(s,o),()=>{clearTimeout(a)})});t.exports=s,t.exports.default=s,t.exports.TimeoutError=i},function(t,e,r){"use strict";const n=r(1),i=n("libp2p:webrtc-star");i.error=n("libp2p:webrtc-star:error");const{EventEmitter:s}=r(14),o=r(0),a=r(27),{AbortError:c}=r(47),u=r(349),{supportsWebRTCDataChannels:h}=r(888),f=r(17),l=r(61),d=r(7),{CODE_CIRCUIT:p}=r(204),y=r(889),g=r(363),{cleanMultiaddr:b}=r(366);function m(){}t.exports=a(class{constructor(t={}){if(!t.upgrader)throw new Error("An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.");this._upgrader=t.upgrader,this._signallingAddr=void 0,this.sioOptions={transports:["websocket"],"force new connection":!0},t.wrtc&&(this.wrtc=t.wrtc),this.listenersRefs={},this.discovery=new s,this.discovery.tag="webRTCStar",this.discovery._isStarted=!1,this.discovery.start=()=>{this.discovery._isStarted=!0},this.discovery.stop=()=>{this.discovery._isStarted=!1},this._peerDiscovered=this._peerDiscovered.bind(this)}async dial(t,e={}){const r=await this._connect(t,e),n=g(r,{remoteAddr:t,signal:e.signal});i("new outbound connection %s",n.remoteAddr);const s=await this._upgrader.upgradeOutbound(n);return i("outbound connection %s upgraded",n.remoteAddr),s}_connect(t,e={}){if(e.signal&&e.signal.aborted)throw new c;const r={initiator:!0,trickle:!1};this.wrtc&&(r.wrtc=this.wrtc);const n=t.toOptions(),s=(~~(1e9*Math.random())).toString(36)+Date.now(),a=this.listenersRefs[Object.keys(this.listenersRefs)[0]].io;return new Promise((h,f)=>{const l=Date.now();let d;i("dialing %s:%s",n.host,n.port);const p=new u(r),y=t=>{if(!d){const e=`connection error ${n.host}:${n.port}: ${t.message}`;t.message=e,i.error(e),v(t)}},g=()=>{i("connnection timeout %s:%s",n.host,n.port);const t=o(new Error(`connection timeout after ${Date.now()-l}ms`),"ERR_CONNECT_TIMEOUT");p.emit("error",t)},b=()=>{d=!0,i("connection opened %s:%s",n.host,n.port),v(null)},m=()=>{i.error("connection aborted %s:%s",n.host,n.port),p.destroy(),v(new c)},v=t=>{p.removeListener("timeout",g),p.removeListener("connect",b),e.signal&&e.signal.removeEventListener("abort",m),t?f(t):h(p)};p.on("error",y),p.once("timeout",g),p.once("connect",b),p.on("close",()=>{p.removeListener("error",y)}),e.signal&&e.signal.addEventListener("abort",m),p.on("signal",e=>{a.emit("ss-handshake",{intentId:s,srcMultiaddr:this._signallingAddr.toString(),dstMultiaddr:t.toString(),signal:e})}),a.on("ws-handshake",t=>{t.intentId===s&&t.err&&f(o(t.err instanceof Error?t.err:new Error(t.err),"ERR_SIGNALLING_FAILED")),t.intentId===s&&t.answer&&!p.destroyed&&p.signal(t.signal)})})}createListener(t={},e){if(!h&&!this.wrtc)throw o(new Error("no WebRTC support"),"ERR_NO_WEBRTC_SUPPORT");return"function"==typeof t&&(e=t,t={}),y({handler:e=e||m,upgrader:this._upgrader},this,t)}filter(t){return(t=Array.isArray(t)?t:[t]).filter(t=>!t.protoCodes().includes(p)&&l.WebRTCStar.matches(t))}_peerDiscovered(t){if(!this.discovery._isStarted)return;i("Peer Discovered:",t),t=b(t);const e=f(t),r=d.createFromB58String(e.getPeerId());this.discovery.emit("peer",{id:r,multiaddrs:[e]})}},{className:"WebRTCStar",symbolName:"@libp2p/js-libp2p-webrtc-star/webrtcstar"})},function(t,e,r){"use strict";t.exports=function(){if("undefined"==typeof window)return null;var t={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return t.RTCPeerConnection?t:null}},function(t,e,r){"use strict";let n;t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>(n||(n=Promise.resolve())).then(t).catch(t=>setTimeout(()=>{throw t},0))},function(t,e,r){"use strict";const n=r(133);t.exports={supportsFileReader:"undefined"!=typeof self&&"FileReader"in self,supportsWebRTC:"RTCPeerConnection"in n&&"undefined"!=typeof navigator&&void 0!==navigator.mediaDevices&&"getUserMedia"in navigator.mediaDevices,supportsWebRTCDataChannels:"RTCPeerConnection"in n}},function(t,e,r){"use strict";const n=r(14),i=r(1),s=i("libp2p:webrtc-star:listener");s.error=i("libp2p:webrtc-star:listener:error");const o=r(17),a=r(890),c=r(349),u=r(99),h=r(363),{cleanUrlSIO:f}=r(366),{CODE_P2P:l}=r(204),d={transports:["websocket"],"force new connection":!0};t.exports=({handler:t,upgrader:e},r,i={})=>{const p=new n;let y;return p.__connections=[],p.listen=n=>{const o=u();y=n,!n.protoCodes().includes(l)&&e.localPeer?r._signallingAddr=n.encapsulate("/p2p/"+e.localPeer.toB58String()):r._signallingAddr=n;const g=f(n);s("Dialing to Signalling Server on: "+g),p.io=a.connect(g,d);return p.io.once("connect_error",t=>o.reject(t)),p.io.once("error",t=>{p.emit("error",t),p.emit("close")}),p.io.on("ws-handshake",o=>{if(o.answer||o.err)return;const a={trickle:!1,...i};r.wrtc&&(a.wrtc=r.wrtc);const u=new c(a),f=t=>{s.error("incoming connectioned errored",t)};u.on("error",f),u.once("close",(...t)=>{u.removeListener("error",f)}),u.once("signal",t=>{o.signal=t,o.answer=!0,p.io.emit("ss-handshake",o)}),u.signal(o.signal),u.once("connect",async()=>{const r=h(u);let i;s("new inbound connection %s",r.remoteAddr);try{i=await e.upgradeInbound(r)}catch(o){return s.error("inbound connection failed to upgrade",o),r.close()}if(!i.remoteAddr)try{i.remoteAddr=n.decapsulateCode(l).encapsulate("/p2p/"+i.remotePeer.toB58String())}catch(o){s.error("could not determine remote address",o)}s("inbound connection %s upgraded",r.remoteAddr),function(t,e){t.__connections.push(e);e.conn.once("close",()=>{t.__connections=t.__connections.filter(t=>t!==e)})}(p,r),p.emit("connection",i),t(i)})}),p.io.on("ws-peer",r._peerDiscovered),p.io.on("connect",()=>{p.io.emit("ss-join",r._signallingAddr.toString())}),p.io.once("connect",()=>{p.emit("listening"),o.resolve()}),o.promise},p.close=async()=>{p.io&&p.io.emit("ss-leave"),await Promise.all(p.__connections.map(t=>t.close())),p.emit("close")},p.getAddrs=()=>[y],r.listenersRefs[o.toString()]=p,p}},function(t,e,r){"use strict";var n=r(891),i=r(205),s=r(354),o=r(1)("socket.io-client");t.exports=e=c;var a=e.managers={};function c(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};var r,i=n(t),c=i.source,u=i.id,h=i.path,f=a[u]&&h in a[u].nsps;return e.forceNew||e["force new connection"]||!1===e.multiplex||f?(o("ignoring socket cache for %s",c),r=s(c,e)):(a[u]||(o("new io instance for %s",c),a[u]=s(c,e)),r=a[u]),i.query&&!e.query&&(e.query=i.query),r.socket(i.path,e)}e.protocol=i.protocol,e.connect=c,e.Manager=r(354),e.Socket=r(360)},function(t,e,r){"use strict";var n=r(351),i=r(1)("socket.io-client:url");t.exports=function(t,e){var r=t;e=e||"undefined"!=typeof location&&location,null==t&&(t=e.protocol+"//"+e.host);"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?e.protocol+t:e.host+t),/^(https?|wss?):\/\//.test(t)||(i("protocol-less url %s",t),t=void 0!==e?e.protocol+"//"+t:"https://"+t),i("parse %s",t),r=n(t));r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443"));r.path=r.path||"/";var s=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port,r.href=r.protocol+"://"+s+(e&&e.port===r.port?"":":"+r.port),r}},function(t,e,r){"use strict";(function(n){function i(){var t;try{t=e.storage.debug}catch(r){}return!t&&void 0!==n&&"env"in n&&(t={NODE_ENV:"production"}.DEBUG),t}(e=t.exports=r(893)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},e.formatArgs=function(t){var r=this.useColors;if(t[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+t[0]+(r?"%c ":" ")+"+"+e.humanize(this.diff),!r)return;var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var i=0,s=0;t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(i++,"%c"===t&&(s=i))})),t.splice(s,0,n)},e.save=function(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(r){}},e.load=i,e.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},e.enable(i())}).call(this,r(12))},function(t,e,r){"use strict";function n(t){var r;function n(){if(n.enabled){var t=n,i=+new Date,s=i-(r||i);t.diff=s,t.prev=r,t.curr=i,r=i;for(var o=new Array(arguments.length),a=0;a0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?a(r=t,o,"day")||a(r,s,"hour")||a(r,i,"minute")||a(r,n,"second")||r+" ms":function(t){if(t>=o)return Math.round(t/o)+"d";if(t>=s)return Math.round(t/s)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,r){"use strict";var n=r(352),i=r(353),s=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),a="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);e.deconstructPacket=function(t){var e=[],r=t.data,s=t;return s.data=function t(e,r){if(!e)return e;if(i(e)){var s={_placeholder:!0,num:r.length};return r.push(e),s}if(n(e)){for(var o=new Array(e.length),a=0;a0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}t.exports=h,h.priorWebsocketSuccess=!1,i(h.prototype),h.protocol=a.protocol,h.Socket=h,h.Transport=r(209),h.transports=r(355),h.parser=r(76),h.prototype.createTransport=function(t){s('creating transport "%s"',t);var e=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}(this.query);e.EIO=a.protocol,e.transport=t;var r=this.transportOptions[t]||{};return this.id&&(e.sid=this.id),new n[t]({query:e,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,withCredentials:r.withCredentials||this.withCredentials,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0,isReactNative:this.isReactNative})},h.prototype.open=function(){var t;if(this.rememberUpgrade&&h.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout((function(){e.emit("error","No transports available")}),0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(r){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},h.prototype.setTransport=function(t){s("setting transport %s",t.name);var e=this;this.transport&&(s("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",(function(){e.onDrain()})).on("packet",(function(t){e.onPacket(t)})).on("error",(function(t){e.onError(t)})).on("close",(function(){e.onClose("transport close")}))},h.prototype.probe=function(t){s('probing transport "%s"',t);var e=this.createTransport(t,{probe:1}),r=!1,n=this;function i(){if(n.onlyBinaryUpgrades){var i=!this.supportsBinary&&n.transport.supportsBinary;r=r||i}r||(s('probe transport "%s" opened',t),e.send([{type:"ping",data:"probe"}]),e.once("packet",(function(i){if(!r)if("pong"===i.type&&"probe"===i.data){if(s('probe transport "%s" pong',t),n.upgrading=!0,n.emit("upgrading",e),!e)return;h.priorWebsocketSuccess="websocket"===e.name,s('pausing current transport "%s"',n.transport.name),n.transport.pause((function(){r||"closed"!==n.readyState&&(s("changing transport and sending upgrade packet"),l(),n.setTransport(e),e.send([{type:"upgrade"}]),n.emit("upgrade",e),e=null,n.upgrading=!1,n.flush())}))}else{s('probe transport "%s" failed',t);var o=new Error("probe error");o.transport=e.name,n.emit("upgradeError",o)}})))}function o(){r||(r=!0,l(),e.close(),e=null)}function a(r){var i=new Error("probe error: "+r);i.transport=e.name,o(),s('probe transport "%s" failed because of error: %s',t,r),n.emit("upgradeError",i)}function c(){a("transport closed")}function u(){a("socket closed")}function f(t){e&&t.name!==e.name&&(s('"%s" works - aborting "%s"',t.name,e.name),o())}function l(){e.removeListener("open",i),e.removeListener("error",a),e.removeListener("close",c),n.removeListener("close",u),n.removeListener("upgrading",f)}h.priorWebsocketSuccess=!1,e.once("open",i),e.once("error",a),e.once("close",c),this.once("close",u),this.once("upgrading",f),e.open()},h.prototype.onOpen=function(){if(s("socket open"),this.readyState="open",h.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){s("starting upgrade probes");for(var t=0,e=this.upgrades.length;tn&&(r=n),e>=n||e>=r||0===n)return new ArrayBuffer(0);for(var i=new Uint8Array(t),s=new Uint8Array(r-e),o=e,a=0;o=55296&&e<=56319&&i=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function u(t,e){return o(t>>e&63|128)}function h(t,e){if(0==(4294967168&t))return o(t);var r="";return 0==(4294965248&t)?r=o(t>>6&31|192):0==(4294901760&t)?(c(t,e)||(t=65533),r=o(t>>12&15|224),r+=u(t,6)):0==(4292870144&t)&&(r=o(t>>18&7|240),r+=u(t,12),r+=u(t,6)),r+=o(63&t|128)}function f(){if(s>=i)throw Error("Invalid byte index");var t=255&n[s];if(s++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function l(t){var e,r;if(s>i)throw Error("Invalid byte index");if(s==i)return!1;if(e=255&n[s],s++,0==(128&e))return e;if(192==(224&e)){if((r=(31&e)<<6|f())>=128)return r;throw Error("Invalid continuation byte")}if(224==(240&e)){if((r=(15&e)<<12|f()<<6|f())>=2048)return c(r,t)?r:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(r=(7&e)<<18|f()<<12|f()<<6|f())>=65536&&r<=1114111)return r;throw Error("Invalid UTF-8 detected")}t.exports={version:"2.1.2",encode:function(t,e){for(var r=!1!==(e=e||{}).strict,n=a(t),i=n.length,s=-1,o="";++s65535&&(i+=o((e-=65536)>>>10&1023|55296),e=56320|1023&e),i+=o(e);return i}(u)}}},function(t,e,r){"use strict";!function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n>2],s+=t[(3&n[r])<<4|n[r+1]>>4],s+=t[(15&n[r+1])<<2|n[r+2]>>6],s+=t[63&n[r+2]];return i%3==2?s=s.substring(0,s.length-1)+"=":i%3==1&&(s=s.substring(0,s.length-2)+"=="),s},e.decode=function(t){var e,n,i,s,o,a=.75*t.length,c=t.length,u=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var h=new ArrayBuffer(a),f=new Uint8Array(h);for(e=0;e>4,f[u++]=(15&i)<<4|s>>2,f[u++]=(3&s)<<6|63&o;return h}}()},function(t,e,r){"use strict";var n=void 0!==n?n:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,i=function(){try{return 2===new Blob(["hi"]).size}catch(t){return!1}}(),s=i&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(t){return!1}}(),o=n&&n.prototype.append&&n.prototype.getBlob;function a(t){return t.map((function(t){if(t.buffer instanceof ArrayBuffer){var e=t.buffer;if(t.byteLength!==e.byteLength){var r=new Uint8Array(t.byteLength);r.set(new Uint8Array(e,t.byteOffset,t.byteLength)),e=r.buffer}return e}return t}))}function c(t,e){e=e||{};var r=new n;return a(t).forEach((function(t){r.append(t)})),e.type?r.getBlob(e.type):r.getBlob()}function u(t,e){return new Blob(a(t),e||{})}"undefined"!=typeof Blob&&(c.prototype=Blob.prototype,u.prototype=Blob.prototype),t.exports=i?s?Blob:u:o?c:void 0},function(t,e,r){"use strict";var n=r(356),i=r(127),s=r(208);t.exports=h;var o,a=/\n/g,c=/\\n/g;function u(){}function h(t){n.call(this,t),this.query=this.query||{},o||(o=s.___eio=s.___eio||[]),this.index=o.length;var e=this;o.push((function(t){e.onData(t)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){e.script&&(e.script.onerror=u)}),!1)}i(h,n),h.prototype.supportsBinary=!1,h.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),n.prototype.doClose.call(this)},h.prototype.doPoll=function(){var t=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(e){t.onError("jsonp poll error",e)};var r=document.getElementsByTagName("script")[0];r?r.parentNode.insertBefore(e,r):(document.head||document.body).appendChild(e),this.script=e,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var t=document.createElement("iframe");document.body.appendChild(t),document.body.removeChild(t)}),100)},h.prototype.doWrite=function(t,e){var r=this;if(!this.form){var n,i=document.createElement("form"),s=document.createElement("textarea"),o=this.iframeId="eio_iframe_"+this.index;i.className="socketio",i.style.position="absolute",i.style.top="-1000px",i.style.left="-1000px",i.target=o,i.method="POST",i.setAttribute("accept-charset","utf-8"),s.name="d",i.appendChild(s),document.body.appendChild(i),this.form=i,this.area=s}function u(){h(),e()}function h(){if(r.iframe)try{r.form.removeChild(r.iframe)}catch(e){r.onError("jsonp polling iframe removal error",e)}try{var t='