diff --git a/LICENSE b/LICENSE index f288702d..ac183cac 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 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 General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - 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 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. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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 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 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 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. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - 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 GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +MIT License + +Copyright (c) 2023 toncenter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..034e8480 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :white_check_mark: | +| < 4.0 | :x: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. diff --git a/dist/tonweb.js b/dist/tonweb.js index c21d3cdc..2a710dfd 100644 --- a/dist/tonweb.js +++ b/dist/tonweb.js @@ -1,2 +1,2 @@ /*! For license information please see tonweb.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.tonweb=e():t.TonWeb=e()}(self,(function(){return(()=>{var t=[(t,e,r)=>{const i=r(1),n=i.Address,o=r(19),s=r(22),a=r(24).default,{Contract:h}=r(23),u=r(27).default,l=r(34).default,c=r(35).default,f=r(41).default,{BlockSubscription:d,InMemoryBlockStorage:p}=r(44),{SubscriptionContract:m}=r(47),g=r(48).default,v=r(103).default,y=r(104).default,w="0.0.40";class b{constructor(t){this.version=w,this.utils=i,this.Address=n,this.boc=o,this.Contract=h,this.BlockSubscription=d,this.InMemoryBlockStorage=p,this.provider=t||new a,this.wallet=new u(this.provider),this.lockupWallet=l}async getTransactions(t,e=20,r,i,n){return this.provider.getTransactions(t.toString(),e,r,i,n)}async getBalance(t){return this.provider.getBalance(t.toString())}async sendBoc(t){return this.provider.sendBoc(i.bytesToBase64(t))}async call(t,e,r=[]){return this.provider.call(t.toString(),e,r)}}b.version=w,b.utils=i,b.Address=n,b.boc=o,b.HttpProvider=a,b.Contract=h,b.Wallets=u,b.LockupWallets=l,b.SubscriptionContract=m,b.BlockSubscription=d,b.InMemoryBlockStorage=p,b.ledger={TransportWebUSB:g,TransportWebHID:v,BluetoothTransport:y,AppTon:s},b.token={nft:c,ft:f,jetton:f},t.exports=b},(t,e,r)=>{const{BN:i,nacl:n,sha256:o,fromNano:s,toNano:a,bytesToHex:h,hexToBytes:u,stringToBytes:l,crc32c:c,crc16:f,concatBytes:d,bytesToBase64:p,base64ToBytes:m,base64toString:g,stringToBase64:v,compareBytes:y,readNBytesUIntFromArray:w}=r(2),b=r(18).default;t.exports={Address:b,BN:i,nacl:n,sha256:o,fromNano:s,toNano:a,bytesToHex:h,hexToBytes:u,stringToBytes:l,crc32c:c,crc16:f,concatBytes:d,bytesToBase64:p,base64ToBytes:m,base64toString:g,stringToBase64:v,compareBytes:y,readNBytesUIntFromArray:w,parseTransferUrl:function(t){const e="ton://transfer/";if(!t.startsWith(e))throw new Error("must starts with "+e);const r=t.substring(e.length).split("?");if(r.length>2)throw new Error('multiple "?"');const n=r[0];if(!b.isValid(n))throw new Error("invalid address format "+n);const o={address:n},s=r[1];if(s&&s.length){const t=s.split("&").map((t=>t.split("=")));for(const e of t){if(2!==e.length)throw new Error("invalid url pair");const t=e[0],r=e[1];if("amount"===t){if(o.amount)throw new Error("amount already set");if(new i(r).isNeg())throw new Error("negative amount");o.amount=r}else{if("text"!==t)throw new Error("unknown url var "+t);if(o.text)throw new Error("text already set");o.text=decodeURIComponent(r)}}}return o},formatTransferUrl:function(t,e,r){let i="ton://transfer/"+t;const n=[];return e&&n.push("amount="+e),r&&n.push("text="+encodeURIComponent(r)),0===n.length?i:i+"?"+n.join("&")}}},(t,e,r)=>{var i=r(9).Buffer;const n=r(3),o=r(5),s=r(7),a="undefined"!=typeof self&&self.crypto&&self.crypto.subtle;let h=null;a||(h=r(16));const u=[],l={};for(let t=0;t<=255;t++){let e=t.toString(16);e.length<2&&(e="0"+e),u.push(e),l[e]=t}const c=(()=>{const t=[],e="A".charCodeAt(0),r="a".charCodeAt(0),i="0".charCodeAt(0);for(let r=0;r<26;++r)t.push(String.fromCharCode(e+r));for(let e=0;e<26;++e)t.push(String.fromCharCode(r+e));for(let e=0;e<10;++e)t.push(String.fromCharCode(i+e));return t.push("+"),t.push("/"),t})();function f(t){return"undefined"==typeof self?i.from(t,"base64").toString("binary"):atob(t)}t.exports={BN:n,nacl:o,sha256:function(t){return a?crypto.subtle.digest("SHA-256",t):h.subtle.digest({name:"SHA-256"},t)},fromNano:function(t){return s.fromWei(t,"gwei")},toNano:function(t){return s.toWei(t,"gwei")},bytesToHex:function(t){const e=[];for(let r=0;r>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1;return 4294967295^t}(0,t),r=new ArrayBuffer(4);return new DataView(r).setUint32(0,e,!1),new Uint8Array(r).reverse()},crc16:function(t){let e=0;const r=new Uint8Array(t.length+2);r.set(t);for(let t of r){let r=128;for(;r>0;)e<<=1,t&r&&(e+=1),r>>=1,e>65535&&(e&=65535,e^=4129)}return new Uint8Array([Math.floor(e/256),e%256])},concatBytes:function(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r},bytesToBase64:function(t){let e,r="";const i=t.length;for(e=2;e>2],r+=c[(3&t[e-2])<<4|t[e-1]>>4],r+=c[(15&t[e-1])<<2|t[e]>>6],r+=c[63&t[e]];return e===i+1&&(r+=c[t[e-2]>>2],r+=c[(3&t[e-2])<<4],r+="=="),e===i&&(r+=c[t[e-2]>>2],r+=c[(3&t[e-2])<<4|t[e-1]>>4],r+=c[(15&t[e-1])<<2],r+="="),r},base64ToBytes:function(t){const e=f(t),r=e.length,i=new Uint8Array(r);for(let t=0;t=49&&u<=54?u-49+10:u>=17&&u<=22?u-17+10:u,s|=h}return i(!(240&s),"Invalid character in "+t),n}function h(t,e,r,n){for(var o=0,s=0,a=Math.min(t.length,r),h=e;h=49?u-49+10:u>=17?u-17+10:u,i(u>=0&&s"}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===t[0]&&(this.negative=1),this._strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.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)n=a(t,r,r+6),this.words[i]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<>>26-o&4194303),this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?o.prototype[Symbol.for("nodejs.util.inspect.custom")]=l:o.prototype.inspect=l;var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(s=(n=0|t.words[p])*(o=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s>>24-n&16777215)||s!==this.length-1?c[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=f[t],l=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(l).toString(t);r=(p=p.idivn(l)).isZero()?m+r:c[u-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,n),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n>8&255),r>16&255),6===o?(r>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.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},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.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)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o>>26;for(;0!==n&&o>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],v=8191&g,y=g>>>13,w=0|s[3],b=8191&w,M=w>>>13,E=0|s[4],A=8191&E,C=E>>>13,B=0|s[5],F=8191&B,_=B>>>13,S=0|s[6],D=8191&S,x=S>>>13,I=0|s[7],T=8191&I,R=I>>>13,N=0|s[8],O=8191&N,U=N>>>13,k=0|s[9],L=8191&k,P=k>>>13,j=0|a[0],$=8191&j,q=j>>>13,K=0|a[1],H=8191&K,G=K>>>13,z=0|a[2],V=8191&z,W=z>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,$))|0)+((8191&(n=(n=Math.imul(c,q))+Math.imul(f,$)|0))<<13)|0;u=((o=Math.imul(f,q))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,q))+Math.imul(m,$)|0,o=Math.imul(m,q);var vt=(u+(i=i+Math.imul(c,H)|0)|0)+((8191&(n=(n=n+Math.imul(c,G)|0)+Math.imul(f,H)|0))<<13)|0;u=((o=o+Math.imul(f,G)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(v,$),n=(n=Math.imul(v,q))+Math.imul(y,$)|0,o=Math.imul(y,q),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,G)|0;var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,W)|0)+Math.imul(f,V)|0))<<13)|0;u=((o=o+Math.imul(f,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,q))+Math.imul(M,$)|0,o=Math.imul(M,q),i=i+Math.imul(v,H)|0,n=(n=n+Math.imul(v,G)|0)+Math.imul(y,H)|0,o=o+Math.imul(y,G)|0,i=i+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,W)|0;var wt=(u+(i=i+Math.imul(c,Y)|0)|0)+((8191&(n=(n=n+Math.imul(c,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((o=o+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,$),n=(n=Math.imul(A,q))+Math.imul(C,$)|0,o=Math.imul(C,q),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(M,H)|0,o=o+Math.imul(M,G)|0,i=i+Math.imul(v,V)|0,n=(n=n+Math.imul(v,W)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,W)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,X)|0;var bt=(u+(i=i+Math.imul(c,Q)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,Q)|0))<<13)|0;u=((o=o+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(F,$),n=(n=Math.imul(F,q))+Math.imul(_,$)|0,o=Math.imul(_,q),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,G)|0,i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,W)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,W)|0,i=i+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((o=o+Math.imul(f,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(D,$),n=(n=Math.imul(D,q))+Math.imul(x,$)|0,o=Math.imul(x,q),i=i+Math.imul(F,H)|0,n=(n=n+Math.imul(F,G)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,G)|0,i=i+Math.imul(A,V)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,W)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,X)|0,i=i+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,it)|0;var Et=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,st)|0)+Math.imul(f,ot)|0))<<13)|0;u=((o=o+Math.imul(f,st)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,q))+Math.imul(R,$)|0,o=Math.imul(R,q),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,G)|0,i=i+Math.imul(F,V)|0,n=(n=n+Math.imul(F,W)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,W)|0,i=i+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,X)|0,i=i+Math.imul(b,Q)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,i=i+Math.imul(v,rt)|0,n=(n=n+Math.imul(v,it)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var At=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((o=o+Math.imul(f,ut)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,q))+Math.imul(U,$)|0,o=Math.imul(U,q),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,G)|0,i=i+Math.imul(D,V)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,W)|0,i=i+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,X)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,X)|0,i=i+Math.imul(A,Q)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,it)|0,i=i+Math.imul(v,ot)|0,n=(n=n+Math.imul(v,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,ut)|0;var Ct=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;u=((o=o+Math.imul(f,ft)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(L,$),n=(n=Math.imul(L,q))+Math.imul(P,$)|0,o=Math.imul(P,q),i=i+Math.imul(O,H)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(U,H)|0,o=o+Math.imul(U,G)|0,i=i+Math.imul(T,V)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,W)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,X)|0,i=i+Math.imul(F,Q)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,i=i+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,ut)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var Bt=(u+(i=i+Math.imul(c,pt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((o=o+Math.imul(f,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,G))+Math.imul(P,H)|0,o=Math.imul(P,G),i=i+Math.imul(O,V)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(U,V)|0,o=o+Math.imul(U,W)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,X)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,it)|0,i=i+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,ut)|0,i=i+Math.imul(v,ct)|0,n=(n=n+Math.imul(v,ft)|0)+Math.imul(y,ct)|0,o=o+Math.imul(y,ft)|0;var Ft=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((o=o+Math.imul(m,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(L,V),n=(n=Math.imul(L,W))+Math.imul(P,V)|0,o=Math.imul(P,W),i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(U,Y)|0,o=o+Math.imul(U,X)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(F,ot)|0,n=(n=n+Math.imul(F,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ft)|0;var _t=(u+(i=i+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((o=o+Math.imul(y,mt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(P,Y)|0,o=Math.imul(P,X),i=i+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,it)|0,i=i+Math.imul(D,ot)|0,n=(n=n+Math.imul(D,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,ut)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,ut)|0,i=i+Math.imul(A,ct)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ft)|0;var St=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,Q),n=(n=Math.imul(L,tt))+Math.imul(P,Q)|0,o=Math.imul(P,tt),i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(U,rt)|0,o=o+Math.imul(U,it)|0,i=i+Math.imul(T,ot)|0,n=(n=n+Math.imul(T,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ft)|0;var Dt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(P,rt)|0,o=Math.imul(P,it),i=i+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(U,ot)|0,o=o+Math.imul(U,st)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ft)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ft)|0;var xt=(u+(i=i+Math.imul(F,pt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,ot),n=(n=Math.imul(L,st))+Math.imul(P,ot)|0,o=Math.imul(P,st),i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,ut)|0)+Math.imul(U,ht)|0,o=o+Math.imul(U,ut)|0,i=i+Math.imul(T,ct)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(R,ct)|0,o=o+Math.imul(R,ft)|0;var It=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(x,pt)|0))<<13)|0;u=((o=o+Math.imul(x,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,ut))+Math.imul(P,ht)|0,o=Math.imul(P,ut),i=i+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(U,ct)|0,o=o+Math.imul(U,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((o=o+Math.imul(R,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ft))+Math.imul(P,ct)|0,o=Math.imul(P,ft);var Rt=(u+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((o=o+Math.imul(U,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Nt=(u+(i=Math.imul(L,pt))|0)+((8191&(n=(n=Math.imul(L,mt))+Math.imul(P,pt)|0))<<13)|0;return u=((o=Math.imul(P,mt))+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h[0]=gt,h[1]=vt,h[2]=yt,h[3]=wt,h[4]=bt,h[5]=Mt,h[6]=Et,h[7]=At,h[8]=Ct,h[9]=Bt,h[10]=Ft,h[11]=_t,h[12]=St,h[13]=Dt,h[14]=xt,h[15]=It,h[16]=Tt,h[17]=Rt,h[18]=Nt,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function v(t,e,r){return g(t,e,r)}function y(t,e){this.x=t,this.y=e}Math.imul||(m=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):v(this,t,e)},y.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i>=1;return i},y.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s>>=1)n++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[n]=67108863&s}return 0!==r&&(this.words[n]=r,this.length++),e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=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},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&o}for(;n>26,this.words[n+r]=67108863&o;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!=(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new o(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var f=67108864*(0|i.words[n.length+c])+(0|i.words[n.length+c-1]);for(f=Math.min(f/s|0,67108863),i._ishlnsubmul(n,f,c);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=f)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(r*n+(0|this.words[o]))%t;return e?-n:n},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*r;this.words[n]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),h=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(l),s.isub(c)),n.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(c)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(h)):(r.isub(e),a.isub(n),h.isub(s))}return{a,b:h,gcd:r.iushln(u)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var c=0,f=1;0==(r.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new B(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(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 E(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function C(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function B(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function F(t){B.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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 o(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(M,b),M.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,o=s}o>>>=22,t.words[n-10]=o,0===o&&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]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new M;else if("p224"===t)e=new E;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new C}return w[t]=e,e},B.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},B.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},B.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},B.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},B.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)},B.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},B.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)},B.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},B.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},B.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},B.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},B.prototype.isqr=function(t){return this.imul(t,t.clone())},B.prototype.sqr=function(t){return this.mul(t,t)},B.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==c||0!==s?(s<<=1,s|=c,(4==++a||0===i&&0===l)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}h=26}return n},B.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},B.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new F(t)},n(F,B),F.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},F.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},F.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},F.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},F.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},()=>{},(t,e,r)=>{!function(t){"use strict";var e=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=i>>24&255,t[e+5]=i>>16&255,t[e+6]=i>>8&255,t[e+7]=255&i}function m(t,e,r,i,n){var o,s=0;for(o=0;o>>8)-1}function g(t,e,r,i){return m(t,e,r,i,16)}function v(t,e,r,i){return m(t,e,r,i,32)}function y(t,e,r,i){!function(t,e,r,i){for(var n,o=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,h=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,l=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,m=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,v=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,w=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,M=o,E=s,A=a,C=h,B=u,F=l,_=c,S=f,D=d,x=p,I=m,T=g,R=v,N=y,O=w,U=b,k=0;k<20;k+=2)M^=(n=(R^=(n=(D^=(n=(B^=(n=M+R|0)<<7|n>>>25)+M|0)<<9|n>>>23)+B|0)<<13|n>>>19)+D|0)<<18|n>>>14,F^=(n=(E^=(n=(N^=(n=(x^=(n=F+E|0)<<7|n>>>25)+F|0)<<9|n>>>23)+x|0)<<13|n>>>19)+N|0)<<18|n>>>14,I^=(n=(_^=(n=(A^=(n=(O^=(n=I+_|0)<<7|n>>>25)+I|0)<<9|n>>>23)+O|0)<<13|n>>>19)+A|0)<<18|n>>>14,U^=(n=(T^=(n=(S^=(n=(C^=(n=U+T|0)<<7|n>>>25)+U|0)<<9|n>>>23)+C|0)<<13|n>>>19)+S|0)<<18|n>>>14,M^=(n=(C^=(n=(A^=(n=(E^=(n=M+C|0)<<7|n>>>25)+M|0)<<9|n>>>23)+E|0)<<13|n>>>19)+A|0)<<18|n>>>14,F^=(n=(B^=(n=(S^=(n=(_^=(n=F+B|0)<<7|n>>>25)+F|0)<<9|n>>>23)+_|0)<<13|n>>>19)+S|0)<<18|n>>>14,I^=(n=(x^=(n=(D^=(n=(T^=(n=I+x|0)<<7|n>>>25)+I|0)<<9|n>>>23)+T|0)<<13|n>>>19)+D|0)<<18|n>>>14,U^=(n=(O^=(n=(N^=(n=(R^=(n=U+O|0)<<7|n>>>25)+U|0)<<9|n>>>23)+R|0)<<13|n>>>19)+N|0)<<18|n>>>14;M=M+o|0,E=E+s|0,A=A+a|0,C=C+h|0,B=B+u|0,F=F+l|0,_=_+c|0,S=S+f|0,D=D+d|0,x=x+p|0,I=I+m|0,T=T+g|0,R=R+v|0,N=N+y|0,O=O+w|0,U=U+b|0,t[0]=M>>>0&255,t[1]=M>>>8&255,t[2]=M>>>16&255,t[3]=M>>>24&255,t[4]=E>>>0&255,t[5]=E>>>8&255,t[6]=E>>>16&255,t[7]=E>>>24&255,t[8]=A>>>0&255,t[9]=A>>>8&255,t[10]=A>>>16&255,t[11]=A>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=B>>>0&255,t[17]=B>>>8&255,t[18]=B>>>16&255,t[19]=B>>>24&255,t[20]=F>>>0&255,t[21]=F>>>8&255,t[22]=F>>>16&255,t[23]=F>>>24&255,t[24]=_>>>0&255,t[25]=_>>>8&255,t[26]=_>>>16&255,t[27]=_>>>24&255,t[28]=S>>>0&255,t[29]=S>>>8&255,t[30]=S>>>16&255,t[31]=S>>>24&255,t[32]=D>>>0&255,t[33]=D>>>8&255,t[34]=D>>>16&255,t[35]=D>>>24&255,t[36]=x>>>0&255,t[37]=x>>>8&255,t[38]=x>>>16&255,t[39]=x>>>24&255,t[40]=I>>>0&255,t[41]=I>>>8&255,t[42]=I>>>16&255,t[43]=I>>>24&255,t[44]=T>>>0&255,t[45]=T>>>8&255,t[46]=T>>>16&255,t[47]=T>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=N>>>0&255,t[53]=N>>>8&255,t[54]=N>>>16&255,t[55]=N>>>24&255,t[56]=O>>>0&255,t[57]=O>>>8&255,t[58]=O>>>16&255,t[59]=O>>>24&255,t[60]=U>>>0&255,t[61]=U>>>8&255,t[62]=U>>>16&255,t[63]=U>>>24&255}(t,e,r,i)}function w(t,e,r,i){!function(t,e,r,i){for(var n,o=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,h=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,l=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,m=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,v=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,w=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,M=0;M<20;M+=2)o^=(n=(v^=(n=(d^=(n=(u^=(n=o+v|0)<<7|n>>>25)+o|0)<<9|n>>>23)+u|0)<<13|n>>>19)+d|0)<<18|n>>>14,l^=(n=(s^=(n=(y^=(n=(p^=(n=l+s|0)<<7|n>>>25)+l|0)<<9|n>>>23)+p|0)<<13|n>>>19)+y|0)<<18|n>>>14,m^=(n=(c^=(n=(a^=(n=(w^=(n=m+c|0)<<7|n>>>25)+m|0)<<9|n>>>23)+w|0)<<13|n>>>19)+a|0)<<18|n>>>14,b^=(n=(g^=(n=(f^=(n=(h^=(n=b+g|0)<<7|n>>>25)+b|0)<<9|n>>>23)+h|0)<<13|n>>>19)+f|0)<<18|n>>>14,o^=(n=(h^=(n=(a^=(n=(s^=(n=o+h|0)<<7|n>>>25)+o|0)<<9|n>>>23)+s|0)<<13|n>>>19)+a|0)<<18|n>>>14,l^=(n=(u^=(n=(f^=(n=(c^=(n=l+u|0)<<7|n>>>25)+l|0)<<9|n>>>23)+c|0)<<13|n>>>19)+f|0)<<18|n>>>14,m^=(n=(p^=(n=(d^=(n=(g^=(n=m+p|0)<<7|n>>>25)+m|0)<<9|n>>>23)+g|0)<<13|n>>>19)+d|0)<<18|n>>>14,b^=(n=(w^=(n=(y^=(n=(v^=(n=b+w|0)<<7|n>>>25)+b|0)<<9|n>>>23)+v|0)<<13|n>>>19)+y|0)<<18|n>>>14;t[0]=o>>>0&255,t[1]=o>>>8&255,t[2]=o>>>16&255,t[3]=o>>>24&255,t[4]=l>>>0&255,t[5]=l>>>8&255,t[6]=l>>>16&255,t[7]=l>>>24&255,t[8]=m>>>0&255,t[9]=m>>>8&255,t[10]=m>>>16&255,t[11]=m>>>24&255,t[12]=b>>>0&255,t[13]=b>>>8&255,t[14]=b>>>16&255,t[15]=b>>>24&255,t[16]=c>>>0&255,t[17]=c>>>8&255,t[18]=c>>>16&255,t[19]=c>>>24&255,t[20]=f>>>0&255,t[21]=f>>>8&255,t[22]=f>>>16&255,t[23]=f>>>24&255,t[24]=d>>>0&255,t[25]=d>>>8&255,t[26]=d>>>16&255,t[27]=d>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,r,i)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function M(t,e,r,i,n,o,s){var a,h,u=new Uint8Array(16),l=new Uint8Array(64);for(h=0;h<16;h++)u[h]=0;for(h=0;h<8;h++)u[h]=o[h];for(;n>=64;){for(y(l,u,s,b),h=0;h<64;h++)t[e+h]=r[i+h]^l[h];for(a=1,h=8;h<16;h++)a=a+(255&u[h])|0,u[h]=255&a,a>>>=8;n-=64,e+=64,i+=64}if(n>0)for(y(l,u,s,b),h=0;h=64;){for(y(h,a,n,b),s=0;s<64;s++)t[e+s]=h[s];for(o=1,s=8;s<16;s++)o=o+(255&a[s])|0,a[s]=255&o,o>>>=8;r-=64,e+=64}if(r>0)for(y(h,a,n,b),s=0;s>>13|r<<3),i=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|i<<6),n=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(i>>>7|n<<9),o=255&t[8]|(255&t[9])<<8,this.r[4]=255&(n>>>4|o<<12),this.r[5]=o>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(o>>>14|s<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function F(t,e,r,i,n,o){var s=new B(o);return s.update(r,i,n),s.finish(t,e),0}function _(t,e,r,i,n,o){var s=new Uint8Array(16);return F(s,0,r,i,n,o),g(t,e,s,0)}function S(t,e,r,i,n){var o;if(r<32)return-1;for(C(t,0,e,0,r,i,n),F(t,16,t,32,r-32,t),o=0;o<16;o++)t[o]=0;return 0}function D(t,e,r,i,n){var o,s=new Uint8Array(32);if(r<32)return-1;if(A(s,0,32,i,n),0!==_(e,16,e,32,r-32,s))return-1;for(C(t,0,e,0,r,i,n),o=0;o<32;o++)t[o]=0;return 0}function x(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function I(t){var e,r,i=1;for(e=0;e<16;e++)r=t[e]+i+65535,i=Math.floor(r/65536),t[e]=r-65536*i;t[0]+=i-1+37*(i-1)}function T(t,e,r){for(var i,n=~(r-1),o=0;o<16;o++)i=n&(t[o]^e[o]),t[o]^=i,e[o]^=i}function R(t,r){var i,n,o,s=e(),a=e();for(i=0;i<16;i++)a[i]=r[i];for(I(a),I(a),I(a),n=0;n<2;n++){for(s[0]=a[0]-65517,i=1;i<15;i++)s[i]=a[i]-65535-(s[i-1]>>16&1),s[i-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),o=s[15]>>16&1,s[14]&=65535,T(a,s,1-o)}for(i=0;i<16;i++)t[2*i]=255&a[i],t[2*i+1]=a[i]>>8}function N(t,e){var r=new Uint8Array(32),i=new Uint8Array(32);return R(r,t),R(i,e),v(r,0,i,0)}function O(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function U(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function k(t,e,r){for(var i=0;i<16;i++)t[i]=e[i]+r[i]}function L(t,e,r){for(var i=0;i<16;i++)t[i]=e[i]-r[i]}function P(t,e,r){var i,n,o=0,s=0,a=0,h=0,u=0,l=0,c=0,f=0,d=0,p=0,m=0,g=0,v=0,y=0,w=0,b=0,M=0,E=0,A=0,C=0,B=0,F=0,_=0,S=0,D=0,x=0,I=0,T=0,R=0,N=0,O=0,U=r[0],k=r[1],L=r[2],P=r[3],j=r[4],$=r[5],q=r[6],K=r[7],H=r[8],G=r[9],z=r[10],V=r[11],W=r[12],Z=r[13],Y=r[14],X=r[15];o+=(i=e[0])*U,s+=i*k,a+=i*L,h+=i*P,u+=i*j,l+=i*$,c+=i*q,f+=i*K,d+=i*H,p+=i*G,m+=i*z,g+=i*V,v+=i*W,y+=i*Z,w+=i*Y,b+=i*X,s+=(i=e[1])*U,a+=i*k,h+=i*L,u+=i*P,l+=i*j,c+=i*$,f+=i*q,d+=i*K,p+=i*H,m+=i*G,g+=i*z,v+=i*V,y+=i*W,w+=i*Z,b+=i*Y,M+=i*X,a+=(i=e[2])*U,h+=i*k,u+=i*L,l+=i*P,c+=i*j,f+=i*$,d+=i*q,p+=i*K,m+=i*H,g+=i*G,v+=i*z,y+=i*V,w+=i*W,b+=i*Z,M+=i*Y,E+=i*X,h+=(i=e[3])*U,u+=i*k,l+=i*L,c+=i*P,f+=i*j,d+=i*$,p+=i*q,m+=i*K,g+=i*H,v+=i*G,y+=i*z,w+=i*V,b+=i*W,M+=i*Z,E+=i*Y,A+=i*X,u+=(i=e[4])*U,l+=i*k,c+=i*L,f+=i*P,d+=i*j,p+=i*$,m+=i*q,g+=i*K,v+=i*H,y+=i*G,w+=i*z,b+=i*V,M+=i*W,E+=i*Z,A+=i*Y,C+=i*X,l+=(i=e[5])*U,c+=i*k,f+=i*L,d+=i*P,p+=i*j,m+=i*$,g+=i*q,v+=i*K,y+=i*H,w+=i*G,b+=i*z,M+=i*V,E+=i*W,A+=i*Z,C+=i*Y,B+=i*X,c+=(i=e[6])*U,f+=i*k,d+=i*L,p+=i*P,m+=i*j,g+=i*$,v+=i*q,y+=i*K,w+=i*H,b+=i*G,M+=i*z,E+=i*V,A+=i*W,C+=i*Z,B+=i*Y,F+=i*X,f+=(i=e[7])*U,d+=i*k,p+=i*L,m+=i*P,g+=i*j,v+=i*$,y+=i*q,w+=i*K,b+=i*H,M+=i*G,E+=i*z,A+=i*V,C+=i*W,B+=i*Z,F+=i*Y,_+=i*X,d+=(i=e[8])*U,p+=i*k,m+=i*L,g+=i*P,v+=i*j,y+=i*$,w+=i*q,b+=i*K,M+=i*H,E+=i*G,A+=i*z,C+=i*V,B+=i*W,F+=i*Z,_+=i*Y,S+=i*X,p+=(i=e[9])*U,m+=i*k,g+=i*L,v+=i*P,y+=i*j,w+=i*$,b+=i*q,M+=i*K,E+=i*H,A+=i*G,C+=i*z,B+=i*V,F+=i*W,_+=i*Z,S+=i*Y,D+=i*X,m+=(i=e[10])*U,g+=i*k,v+=i*L,y+=i*P,w+=i*j,b+=i*$,M+=i*q,E+=i*K,A+=i*H,C+=i*G,B+=i*z,F+=i*V,_+=i*W,S+=i*Z,D+=i*Y,x+=i*X,g+=(i=e[11])*U,v+=i*k,y+=i*L,w+=i*P,b+=i*j,M+=i*$,E+=i*q,A+=i*K,C+=i*H,B+=i*G,F+=i*z,_+=i*V,S+=i*W,D+=i*Z,x+=i*Y,I+=i*X,v+=(i=e[12])*U,y+=i*k,w+=i*L,b+=i*P,M+=i*j,E+=i*$,A+=i*q,C+=i*K,B+=i*H,F+=i*G,_+=i*z,S+=i*V,D+=i*W,x+=i*Z,I+=i*Y,T+=i*X,y+=(i=e[13])*U,w+=i*k,b+=i*L,M+=i*P,E+=i*j,A+=i*$,C+=i*q,B+=i*K,F+=i*H,_+=i*G,S+=i*z,D+=i*V,x+=i*W,I+=i*Z,T+=i*Y,R+=i*X,w+=(i=e[14])*U,b+=i*k,M+=i*L,E+=i*P,A+=i*j,C+=i*$,B+=i*q,F+=i*K,_+=i*H,S+=i*G,D+=i*z,x+=i*V,I+=i*W,T+=i*Z,R+=i*Y,N+=i*X,b+=(i=e[15])*U,s+=38*(E+=i*L),a+=38*(A+=i*P),h+=38*(C+=i*j),u+=38*(B+=i*$),l+=38*(F+=i*q),c+=38*(_+=i*K),f+=38*(S+=i*H),d+=38*(D+=i*G),p+=38*(x+=i*z),m+=38*(I+=i*V),g+=38*(T+=i*W),v+=38*(R+=i*Z),y+=38*(N+=i*Y),w+=38*(O+=i*X),o=(i=(o+=38*(M+=i*k))+(n=1)+65535)-65536*(n=Math.floor(i/65536)),s=(i=s+n+65535)-65536*(n=Math.floor(i/65536)),a=(i=a+n+65535)-65536*(n=Math.floor(i/65536)),h=(i=h+n+65535)-65536*(n=Math.floor(i/65536)),u=(i=u+n+65535)-65536*(n=Math.floor(i/65536)),l=(i=l+n+65535)-65536*(n=Math.floor(i/65536)),c=(i=c+n+65535)-65536*(n=Math.floor(i/65536)),f=(i=f+n+65535)-65536*(n=Math.floor(i/65536)),d=(i=d+n+65535)-65536*(n=Math.floor(i/65536)),p=(i=p+n+65535)-65536*(n=Math.floor(i/65536)),m=(i=m+n+65535)-65536*(n=Math.floor(i/65536)),g=(i=g+n+65535)-65536*(n=Math.floor(i/65536)),v=(i=v+n+65535)-65536*(n=Math.floor(i/65536)),y=(i=y+n+65535)-65536*(n=Math.floor(i/65536)),w=(i=w+n+65535)-65536*(n=Math.floor(i/65536)),b=(i=b+n+65535)-65536*(n=Math.floor(i/65536)),o=(i=(o+=n-1+37*(n-1))+(n=1)+65535)-65536*(n=Math.floor(i/65536)),s=(i=s+n+65535)-65536*(n=Math.floor(i/65536)),a=(i=a+n+65535)-65536*(n=Math.floor(i/65536)),h=(i=h+n+65535)-65536*(n=Math.floor(i/65536)),u=(i=u+n+65535)-65536*(n=Math.floor(i/65536)),l=(i=l+n+65535)-65536*(n=Math.floor(i/65536)),c=(i=c+n+65535)-65536*(n=Math.floor(i/65536)),f=(i=f+n+65535)-65536*(n=Math.floor(i/65536)),d=(i=d+n+65535)-65536*(n=Math.floor(i/65536)),p=(i=p+n+65535)-65536*(n=Math.floor(i/65536)),m=(i=m+n+65535)-65536*(n=Math.floor(i/65536)),g=(i=g+n+65535)-65536*(n=Math.floor(i/65536)),v=(i=v+n+65535)-65536*(n=Math.floor(i/65536)),y=(i=y+n+65535)-65536*(n=Math.floor(i/65536)),w=(i=w+n+65535)-65536*(n=Math.floor(i/65536)),b=(i=b+n+65535)-65536*(n=Math.floor(i/65536)),o+=n-1+37*(n-1),t[0]=o,t[1]=s,t[2]=a,t[3]=h,t[4]=u,t[5]=l,t[6]=c,t[7]=f,t[8]=d,t[9]=p,t[10]=m,t[11]=g,t[12]=v,t[13]=y,t[14]=w,t[15]=b}function j(t,e){P(t,e,e)}function $(t,r){var i,n=e();for(i=0;i<16;i++)n[i]=r[i];for(i=253;i>=0;i--)j(n,n),2!==i&&4!==i&&P(n,n,r);for(i=0;i<16;i++)t[i]=n[i]}function q(t,r){var i,n=e();for(i=0;i<16;i++)n[i]=r[i];for(i=250;i>=0;i--)j(n,n),1!==i&&P(n,n,r);for(i=0;i<16;i++)t[i]=n[i]}function K(t,r,i){var n,o,s=new Uint8Array(32),a=new Float64Array(80),u=e(),l=e(),c=e(),f=e(),d=e(),p=e();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,U(a,i),o=0;o<16;o++)l[o]=a[o],f[o]=u[o]=c[o]=0;for(u[0]=f[0]=1,o=254;o>=0;--o)T(u,l,n=s[o>>>3]>>>(7&o)&1),T(c,f,n),k(d,u,c),L(u,u,c),k(c,l,f),L(l,l,f),j(f,d),j(p,u),P(u,c,u),P(c,l,d),k(d,u,c),L(u,u,c),j(l,u),L(c,f,p),P(u,c,h),k(u,u,f),P(c,c,u),P(u,f,p),P(f,l,a),j(l,d),T(u,l,n),T(c,f,n);for(o=0;o<16;o++)a[o+16]=u[o],a[o+32]=c[o],a[o+48]=l[o],a[o+64]=f[o];var m=a.subarray(32),g=a.subarray(16);return $(m,m),P(g,g,m),R(t,g),0}function H(t,e){return K(t,e,o)}function G(t,e){return i(e,32),H(t,e)}function z(t,e,r){var i=new Uint8Array(32);return K(i,r,e),w(t,n,i,b)}B.prototype.blocks=function(t,e,r){for(var i,n,o,s,a,h,u,l,c,f,d,p,m,g,v,y,w,b,M,E=this.fin?0:2048,A=this.h[0],C=this.h[1],B=this.h[2],F=this.h[3],_=this.h[4],S=this.h[5],D=this.h[6],x=this.h[7],I=this.h[8],T=this.h[9],R=this.r[0],N=this.r[1],O=this.r[2],U=this.r[3],k=this.r[4],L=this.r[5],P=this.r[6],j=this.r[7],$=this.r[8],q=this.r[9];r>=16;)f=c=0,f+=(A+=8191&(i=255&t[e+0]|(255&t[e+1])<<8))*R,f+=(C+=8191&(i>>>13|(n=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),f+=(B+=8191&(n>>>10|(o=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*$),f+=(F+=8191&(o>>>7|(s=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*j),c=(f+=(_+=8191&(s>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*P))>>>13,f&=8191,f+=(S+=a>>>1&8191)*(5*L),f+=(D+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*k),f+=(x+=8191&(h>>>11|(u=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*U),f+=(I+=8191&(u>>>8|(l=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*O),d=c+=(f+=(T+=l>>>5|E)*(5*N))>>>13,d+=A*N,d+=C*R,d+=B*(5*q),d+=F*(5*$),c=(d+=_*(5*j))>>>13,d&=8191,d+=S*(5*P),d+=D*(5*L),d+=x*(5*k),d+=I*(5*U),c+=(d+=T*(5*O))>>>13,d&=8191,p=c,p+=A*O,p+=C*N,p+=B*R,p+=F*(5*q),c=(p+=_*(5*$))>>>13,p&=8191,p+=S*(5*j),p+=D*(5*P),p+=x*(5*L),p+=I*(5*k),m=c+=(p+=T*(5*U))>>>13,m+=A*U,m+=C*O,m+=B*N,m+=F*R,c=(m+=_*(5*q))>>>13,m&=8191,m+=S*(5*$),m+=D*(5*j),m+=x*(5*P),m+=I*(5*L),g=c+=(m+=T*(5*k))>>>13,g+=A*k,g+=C*U,g+=B*O,g+=F*N,c=(g+=_*R)>>>13,g&=8191,g+=S*(5*q),g+=D*(5*$),g+=x*(5*j),g+=I*(5*P),v=c+=(g+=T*(5*L))>>>13,v+=A*L,v+=C*k,v+=B*U,v+=F*O,c=(v+=_*N)>>>13,v&=8191,v+=S*R,v+=D*(5*q),v+=x*(5*$),v+=I*(5*j),y=c+=(v+=T*(5*P))>>>13,y+=A*P,y+=C*L,y+=B*k,y+=F*U,c=(y+=_*O)>>>13,y&=8191,y+=S*N,y+=D*R,y+=x*(5*q),y+=I*(5*$),w=c+=(y+=T*(5*j))>>>13,w+=A*j,w+=C*P,w+=B*L,w+=F*k,c=(w+=_*U)>>>13,w&=8191,w+=S*O,w+=D*N,w+=x*R,w+=I*(5*q),b=c+=(w+=T*(5*$))>>>13,b+=A*$,b+=C*j,b+=B*P,b+=F*L,c=(b+=_*k)>>>13,b&=8191,b+=S*U,b+=D*O,b+=x*N,b+=I*R,M=c+=(b+=T*(5*q))>>>13,M+=A*q,M+=C*$,M+=B*j,M+=F*P,c=(M+=_*L)>>>13,M&=8191,M+=S*k,M+=D*U,M+=x*O,M+=I*N,A=f=8191&(c=(c=((c+=(M+=T*R)>>>13)<<2)+c|0)+(f&=8191)|0),C=d+=c>>>=13,B=p&=8191,F=m&=8191,_=g&=8191,S=v&=8191,D=y&=8191,x=w&=8191,I=b&=8191,T=M&=8191,e+=16,r-=16;this.h[0]=A,this.h[1]=C,this.h[2]=B,this.h[3]=F,this.h[4]=_,this.h[5]=S,this.h[6]=D,this.h[7]=x,this.h[8]=I,this.h[9]=T},B.prototype.finish=function(t,e){var r,i,n,o,s=new Uint16Array(10);if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,o=1;o<10;o++)s[o]=this.h[o]+r,r=s[o]>>>13,s[o]&=8191;for(s[9]-=8192,i=(1^r)-1,o=0;o<10;o++)s[o]&=i;for(i=~i,o=0;o<10;o++)this.h[o]=this.h[o]&i|s[o];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),n=this.h[0]+this.pad[0],this.h[0]=65535&n,o=1;o<8;o++)n=(this.h[o]+this.pad[o]|0)+(n>>>16)|0,this.h[o]=65535&n;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},B.prototype.update=function(t,e,r){var i,n;if(this.leftover){for((n=16-this.leftover)>r&&(n=r),i=0;i=16&&(n=r-r%16,this.blocks(t,e,n),e+=n,r-=n),r){for(i=0;i=128;){for(E=0;E<16;E++)A=8*E+W,x[E]=r[A+0]<<24|r[A+1]<<16|r[A+2]<<8|r[A+3],I[E]=r[A+4]<<24|r[A+5]<<16|r[A+6]<<8|r[A+7];for(E=0;E<80;E++)if(n=T,o=R,s=N,a=O,h=U,u=k,l=L,f=j,d=$,p=q,m=K,g=H,v=G,y=z,F=65535&(B=V),_=B>>>16,S=65535&(C=P),D=C>>>16,F+=65535&(B=(H>>>14|U<<18)^(H>>>18|U<<14)^(U>>>9|H<<23)),_+=B>>>16,S+=65535&(C=(U>>>14|H<<18)^(U>>>18|H<<14)^(H>>>9|U<<23)),D+=C>>>16,F+=65535&(B=H&G^~H&z),_+=B>>>16,S+=65535&(C=U&k^~U&L),D+=C>>>16,F+=65535&(B=Z[2*E+1]),_+=B>>>16,S+=65535&(C=Z[2*E]),D+=C>>>16,C=x[E%16],_+=(B=I[E%16])>>>16,S+=65535&C,D+=C>>>16,S+=(_+=(F+=65535&B)>>>16)>>>16,F=65535&(B=M=65535&F|_<<16),_=B>>>16,S=65535&(C=b=65535&S|(D+=S>>>16)<<16),D=C>>>16,F+=65535&(B=(j>>>28|T<<4)^(T>>>2|j<<30)^(T>>>7|j<<25)),_+=B>>>16,S+=65535&(C=(T>>>28|j<<4)^(j>>>2|T<<30)^(j>>>7|T<<25)),D+=C>>>16,_+=(B=j&$^j&q^$&q)>>>16,S+=65535&(C=T&R^T&N^R&N),D+=C>>>16,c=65535&(S+=(_+=(F+=65535&B)>>>16)>>>16)|(D+=S>>>16)<<16,w=65535&F|_<<16,F=65535&(B=m),_=B>>>16,S=65535&(C=a),D=C>>>16,_+=(B=M)>>>16,S+=65535&(C=b),D+=C>>>16,R=n,N=o,O=s,U=a=65535&(S+=(_+=(F+=65535&B)>>>16)>>>16)|(D+=S>>>16)<<16,k=h,L=u,P=l,T=c,$=f,q=d,K=p,H=m=65535&F|_<<16,G=g,z=v,V=y,j=w,E%16==15)for(A=0;A<16;A++)C=x[A],F=65535&(B=I[A]),_=B>>>16,S=65535&C,D=C>>>16,C=x[(A+9)%16],F+=65535&(B=I[(A+9)%16]),_+=B>>>16,S+=65535&C,D+=C>>>16,b=x[(A+1)%16],F+=65535&(B=((M=I[(A+1)%16])>>>1|b<<31)^(M>>>8|b<<24)^(M>>>7|b<<25)),_+=B>>>16,S+=65535&(C=(b>>>1|M<<31)^(b>>>8|M<<24)^b>>>7),D+=C>>>16,b=x[(A+14)%16],_+=(B=((M=I[(A+14)%16])>>>19|b<<13)^(b>>>29|M<<3)^(M>>>6|b<<26))>>>16,S+=65535&(C=(b>>>19|M<<13)^(M>>>29|b<<3)^b>>>6),D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,x[A]=65535&S|D<<16,I[A]=65535&F|_<<16;F=65535&(B=j),_=B>>>16,S=65535&(C=T),D=C>>>16,C=t[0],_+=(B=e[0])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[0]=T=65535&S|D<<16,e[0]=j=65535&F|_<<16,F=65535&(B=$),_=B>>>16,S=65535&(C=R),D=C>>>16,C=t[1],_+=(B=e[1])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[1]=R=65535&S|D<<16,e[1]=$=65535&F|_<<16,F=65535&(B=q),_=B>>>16,S=65535&(C=N),D=C>>>16,C=t[2],_+=(B=e[2])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[2]=N=65535&S|D<<16,e[2]=q=65535&F|_<<16,F=65535&(B=K),_=B>>>16,S=65535&(C=O),D=C>>>16,C=t[3],_+=(B=e[3])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[3]=O=65535&S|D<<16,e[3]=K=65535&F|_<<16,F=65535&(B=H),_=B>>>16,S=65535&(C=U),D=C>>>16,C=t[4],_+=(B=e[4])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[4]=U=65535&S|D<<16,e[4]=H=65535&F|_<<16,F=65535&(B=G),_=B>>>16,S=65535&(C=k),D=C>>>16,C=t[5],_+=(B=e[5])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[5]=k=65535&S|D<<16,e[5]=G=65535&F|_<<16,F=65535&(B=z),_=B>>>16,S=65535&(C=L),D=C>>>16,C=t[6],_+=(B=e[6])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[6]=L=65535&S|D<<16,e[6]=z=65535&F|_<<16,F=65535&(B=V),_=B>>>16,S=65535&(C=P),D=C>>>16,C=t[7],_+=(B=e[7])>>>16,S+=65535&C,D+=C>>>16,D+=(S+=(_+=(F+=65535&B)>>>16)>>>16)>>>16,t[7]=P=65535&S|D<<16,e[7]=V=65535&F|_<<16,W+=128,i-=128}return i}function X(t,e,r){var i,n=new Int32Array(8),o=new Int32Array(8),s=new Uint8Array(256),a=r;for(n[0]=1779033703,n[1]=3144134277,n[2]=1013904242,n[3]=2773480762,n[4]=1359893119,n[5]=2600822924,n[6]=528734635,n[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,Y(n,o,e,r),r%=128,i=0;i=0;--n)Q(t,e,i=r[n/8|0]>>(7&n)&1),J(e,t),J(t,t),Q(t,e,i)}function rt(t,r){var i=[e(),e(),e(),e()];x(i[0],c),x(i[1],f),x(i[2],a),P(i[3],c,f),et(t,i,r)}function it(t,r,n){var o,s=new Uint8Array(64),a=[e(),e(),e(),e()];for(n||i(r,32),X(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,rt(a,s),tt(t,a),o=0;o<32;o++)r[o+32]=t[o];return 0}var nt=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]);function ot(t,e){var r,i,n,o;for(i=63;i>=32;--i){for(r=0,n=i-32,o=i-12;n>4)*nt[n],r=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=r*nt[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,t[i]=255&e[i]}function st(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;ot(t,r)}function at(t,r,i,n){var o,s,a=new Uint8Array(64),h=new Uint8Array(64),u=new Uint8Array(64),l=new Float64Array(64),c=[e(),e(),e(),e()];X(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=i+64;for(o=0;o>7&&L(t[0],s,t[0]),P(t[3],t[0],t[1]),0)}(f,n))return-1;for(o=0;o=0},t.sign.keyPair=function(){var t=new Uint8Array(lt),e=new Uint8Array(ct);return it(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(dt(t),t.length!==ct)throw new Error("bad secret key size");for(var e=new Uint8Array(lt),r=0;r{},(t,e,r)=>{"use strict";var i=r(8),n=r(12),o=new i(0),s=new i(-1),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function h(t){var e=t?t.toLowerCase():"ether",r=a[e];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+t+" doesn't exists, please use the one of the following units "+JSON.stringify(a,null,2));return new i(r,10)}function u(t){if("string"==typeof t){if(!t.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+t+"', should be a number matching (^-?[0-9.]+).");return t}if("number"==typeof t)return String(t);if("object"==typeof t&&t.toString&&(t.toTwos||t.dividedToIntegerBy))return t.toPrecision?String(t.toPrecision()):t.toString(10);throw new Error("while converting number to string, invalid number value '"+t+"' type "+typeof t+".")}t.exports={unitMap:a,numberToString:u,getValueOfUnit:h,fromWei:function(t,e,r){var i=n(t),u=i.lt(o),l=h(e),c=a[e].length-1||1,f=r||{};u&&(i=i.mul(s));for(var d=i.mod(l).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+t+" to wei, too many decimal points");var f=c[0],d=c[1];if(f||(f="0"),d||(d="0"),d.length>o)throw new Error("[ethjs-unit] while converting number "+t+" to wei, too many decimal places");for(;d.length=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return i}function h(t,e,r,i){for(var n=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}return n}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.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)n=a(t,r,r+6),this.words[i]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(s=(n=0|t.words[p])*(o=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s>>24-n&16777215)||s!==this.length-1?u[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,s--)}for(0!==o&&(r=o.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 f=l[t],d=c[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:u[f-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return i(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;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},o.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},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.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)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o>>26;for(;0!==n&&o>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],v=8191&g,y=g>>>13,w=0|s[3],b=8191&w,M=w>>>13,E=0|s[4],A=8191&E,C=E>>>13,B=0|s[5],F=8191&B,_=B>>>13,S=0|s[6],D=8191&S,x=S>>>13,I=0|s[7],T=8191&I,R=I>>>13,N=0|s[8],O=8191&N,U=N>>>13,k=0|s[9],L=8191&k,P=k>>>13,j=0|a[0],$=8191&j,q=j>>>13,K=0|a[1],H=8191&K,G=K>>>13,z=0|a[2],V=8191&z,W=z>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,$))|0)+((8191&(n=(n=Math.imul(c,q))+Math.imul(f,$)|0))<<13)|0;u=((o=Math.imul(f,q))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,q))+Math.imul(m,$)|0,o=Math.imul(m,q);var vt=(u+(i=i+Math.imul(c,H)|0)|0)+((8191&(n=(n=n+Math.imul(c,G)|0)+Math.imul(f,H)|0))<<13)|0;u=((o=o+Math.imul(f,G)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(v,$),n=(n=Math.imul(v,q))+Math.imul(y,$)|0,o=Math.imul(y,q),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,G)|0;var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,W)|0)+Math.imul(f,V)|0))<<13)|0;u=((o=o+Math.imul(f,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,q))+Math.imul(M,$)|0,o=Math.imul(M,q),i=i+Math.imul(v,H)|0,n=(n=n+Math.imul(v,G)|0)+Math.imul(y,H)|0,o=o+Math.imul(y,G)|0,i=i+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,W)|0;var wt=(u+(i=i+Math.imul(c,Y)|0)|0)+((8191&(n=(n=n+Math.imul(c,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((o=o+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,$),n=(n=Math.imul(A,q))+Math.imul(C,$)|0,o=Math.imul(C,q),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(M,H)|0,o=o+Math.imul(M,G)|0,i=i+Math.imul(v,V)|0,n=(n=n+Math.imul(v,W)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,W)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,X)|0;var bt=(u+(i=i+Math.imul(c,Q)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,Q)|0))<<13)|0;u=((o=o+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(F,$),n=(n=Math.imul(F,q))+Math.imul(_,$)|0,o=Math.imul(_,q),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,G)|0,i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,W)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,W)|0,i=i+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((o=o+Math.imul(f,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(D,$),n=(n=Math.imul(D,q))+Math.imul(x,$)|0,o=Math.imul(x,q),i=i+Math.imul(F,H)|0,n=(n=n+Math.imul(F,G)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,G)|0,i=i+Math.imul(A,V)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,W)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,X)|0,i=i+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,it)|0;var Et=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,st)|0)+Math.imul(f,ot)|0))<<13)|0;u=((o=o+Math.imul(f,st)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,q))+Math.imul(R,$)|0,o=Math.imul(R,q),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,G)|0,i=i+Math.imul(F,V)|0,n=(n=n+Math.imul(F,W)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,W)|0,i=i+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,X)|0,i=i+Math.imul(b,Q)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,i=i+Math.imul(v,rt)|0,n=(n=n+Math.imul(v,it)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var At=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((o=o+Math.imul(f,ut)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,q))+Math.imul(U,$)|0,o=Math.imul(U,q),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,G)|0,i=i+Math.imul(D,V)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,W)|0,i=i+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,X)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,X)|0,i=i+Math.imul(A,Q)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,it)|0,i=i+Math.imul(v,ot)|0,n=(n=n+Math.imul(v,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,ut)|0;var Ct=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;u=((o=o+Math.imul(f,ft)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(L,$),n=(n=Math.imul(L,q))+Math.imul(P,$)|0,o=Math.imul(P,q),i=i+Math.imul(O,H)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(U,H)|0,o=o+Math.imul(U,G)|0,i=i+Math.imul(T,V)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,W)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,X)|0,i=i+Math.imul(F,Q)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,i=i+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,ut)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var Bt=(u+(i=i+Math.imul(c,pt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((o=o+Math.imul(f,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,G))+Math.imul(P,H)|0,o=Math.imul(P,G),i=i+Math.imul(O,V)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(U,V)|0,o=o+Math.imul(U,W)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,X)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,it)|0,i=i+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,ut)|0,i=i+Math.imul(v,ct)|0,n=(n=n+Math.imul(v,ft)|0)+Math.imul(y,ct)|0,o=o+Math.imul(y,ft)|0;var Ft=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((o=o+Math.imul(m,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(L,V),n=(n=Math.imul(L,W))+Math.imul(P,V)|0,o=Math.imul(P,W),i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(U,Y)|0,o=o+Math.imul(U,X)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(F,ot)|0,n=(n=n+Math.imul(F,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ft)|0;var _t=(u+(i=i+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((o=o+Math.imul(y,mt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(P,Y)|0,o=Math.imul(P,X),i=i+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,it)|0,i=i+Math.imul(D,ot)|0,n=(n=n+Math.imul(D,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,ut)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,ut)|0,i=i+Math.imul(A,ct)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ft)|0;var St=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,Q),n=(n=Math.imul(L,tt))+Math.imul(P,Q)|0,o=Math.imul(P,tt),i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(U,rt)|0,o=o+Math.imul(U,it)|0,i=i+Math.imul(T,ot)|0,n=(n=n+Math.imul(T,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ft)|0;var Dt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(P,rt)|0,o=Math.imul(P,it),i=i+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(U,ot)|0,o=o+Math.imul(U,st)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ft)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ft)|0;var xt=(u+(i=i+Math.imul(F,pt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,ot),n=(n=Math.imul(L,st))+Math.imul(P,ot)|0,o=Math.imul(P,st),i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,ut)|0)+Math.imul(U,ht)|0,o=o+Math.imul(U,ut)|0,i=i+Math.imul(T,ct)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(R,ct)|0,o=o+Math.imul(R,ft)|0;var It=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(x,pt)|0))<<13)|0;u=((o=o+Math.imul(x,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,ut))+Math.imul(P,ht)|0,o=Math.imul(P,ut),i=i+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(U,ct)|0,o=o+Math.imul(U,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((o=o+Math.imul(R,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ft))+Math.imul(P,ct)|0,o=Math.imul(P,ft);var Rt=(u+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((o=o+Math.imul(U,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Nt=(u+(i=Math.imul(L,pt))|0)+((8191&(n=(n=Math.imul(L,mt))+Math.imul(P,pt)|0))<<13)|0;return u=((o=Math.imul(P,mt))+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h[0]=gt,h[1]=vt,h[2]=yt,h[3]=wt,h[4]=bt,h[5]=Mt,h[6]=Et,h[7]=At,h[8]=Ct,h[9]=Bt,h[10]=Ft,h[11]=_t,h[12]=St,h[13]=Dt,h[14]=xt,h[15]=It,h[16]=Tt,h[17]=Rt,h[18]=Nt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=f),o.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s>>=1)n++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,e+=n/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=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},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&o}for(;n>26,this.words[n+r]=67108863&o;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!=(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new o(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var f=67108864*(0|i.words[n.length+c])+(0|i.words[n.length+c-1]);for(f=Math.min(f/s|0,67108863),i._ishlnsubmul(n,f,c);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=f)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},o.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),h=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(l),s.isub(c)),n.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(c)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(h)):(r.isub(e),a.isub(n),h.isub(s))}return{a,b:h,gcd:r.iushln(u)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var c=0,f=1;0==(r.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new E(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(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 v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):r.strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(y,v),y.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,o=s}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},y.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]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return g[t]=e,e},E.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},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(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==c||0!==s?(s<<=1,s|=c,(4==++a||0===i&&0===l)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}h=26}return n},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},o.mont=function(t){return new A(t)},n(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},(t,e,r)=>{"use strict";const i=r(10),n=r(11),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|m(t,e);let i=a(r);const n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,r);const n=function(t){if(h.isBuffer(t)){const e=0|p(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return l(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),r=a(e);for(let i=0;i=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function m(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(n)return i?-1:z(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return F(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return D(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function v(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function y(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:w(t,e,r,i,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,i,n){let o,s=1,a=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,h/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){let i=-1;for(o=r;oa&&(r=a-h),o=r;o>=0;o--){let r=!0;for(let i=0;in&&(i=n):i=n;const o=e.length;let s;for(i>o/2&&(i=o/2),s=0;s>8,n=r%256,o.push(n),o.push(i);return o}(e,t.length-r),t,r,i)}function B(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function F(t,e,r){r=Math.min(t.length,r);const i=[];let n=e;for(;n239?4:e>223?3:e>191?2:1;if(n+s<=r){let r,i,a,h;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(o=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:r=t[n+1],i=t[n+2],a=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&a)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&a,h>65535&&h<1114112&&(o=h))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=s}return function(t){const e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);let r="",i=0;for(;ii.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},h.byteLength=m,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},o&&(h.prototype[o]=h.prototype.inspect),h.prototype.compare=function(t,e,r,i,n){if(Z(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(i,n),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return M(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const _=4096;function S(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;ni)&&(r=i);let n="";for(let i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function R(t,e,r,i,n,o){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError("Index out of range")}function N(t,e,r,i,n){q(e,i,n,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function O(t,e,r,i,n){q(e,i,n,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function U(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,i,o){return e=+e,r>>>=0,o||U(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function L(t,e,r,i,o){return e=+e,r>>>=0,o||U(t,0,r,8),n.write(t,e,r,i,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);let i=this[t],n=1,o=0;for(;++o>>=0,e>>>=0,r||T(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=J((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<>>=0,e>>>=0,r||T(t,e,this.length);let i=this[t],n=1,o=0;for(;++o=n&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let i=e,n=1,o=this[t+--i];for(;i>0&&(n*=256);)o+=this[t+--i]*n;return n*=128,o>=n&&(o-=Math.pow(2,8*e)),o},h.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=J((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||R(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,i||R(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,o=1;for(this[e+n]=255&t;--n>=0&&(o*=256);)this[e+n]=t/o&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=J((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=J((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);R(this,t,e,r,i-1,-i)}let n=0,o=1,s=0;for(this[e]=255&t;++n>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);R(this,t,e,r,i-1,-i)}let n=r-1,o=1,s=0;for(this[e+n]=255&t;--n>=0&&(o*=256);)t<0&&0===s&&0!==this[e+n+1]&&(s=1),this[e+n]=(t/o>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=J((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function q(t,e,r,i,n,o){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){K(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||H(e,t.length-(r+1))}(i,n,o)}function K(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new P.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=$(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=$(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function z(t,e){let r;e=e||1/0;const i=t.length;let n=null;const o=[];for(let s=0;s55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.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;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function V(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function W(t,e,r,i){let n;for(n=0;n=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},(t,e)=>{"use strict";e.byteLength=function(t){var e=h(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,o=h(t),s=o[0],a=o[1],u=new n(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),l=0,c=a>0?s-4:s;for(r=0;r>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,o=[],s=16383,a=0,h=i-n;ah?h:a+s));return 1===n?(e=t[i-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[i-2]<<8)+t[i-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s0)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 u(t,e,i){for(var n,o,s=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},(t,e)=>{e.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,h=(1<>1,l=-7,c=r?n-1:0,f=r?-1:1,d=t[e+c];for(c+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+c],c+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=256*s+t[e+c],c+=f,l-=8);if(0===o)o=1-u;else{if(o===h)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,i),o-=u}return(d?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,r,i,n,o){var s,a,h,u=8*o-n-1,l=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-s))<1&&(s--,h*=2),(e+=s+c>=1?f/h:f*Math.pow(2,1-c))*h>=2&&(s++,h/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(e*h-1)*Math.pow(2,n),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;t[r+d]=255&a,d+=p,a/=256,n-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*m}},(t,e,r)=>{var i=r(13),n=r(14);t.exports=function(t){if("string"==typeof t||"number"==typeof t){var e=new i(1),r=String(t).toLowerCase().trim(),o="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),s=n(r);if("-"===s.substr(0,1)&&(s=n(s.slice(1)),e=new i(-1,10)),!(s=""===s?"0":s).match(/^-?[0-9]+$/)&&s.match(/^[0-9A-Fa-f]+$/)||s.match(/^[a-fA-F]+$/)||!0===o&&s.match(/^[0-9A-Fa-f]+$/))return new i(s,16).mul(e);if((s.match(/^-?[0-9]+$/)||""===s)&&!1===o)return new i(s,10).mul(e)}else if("object"==typeof t&&t.toString&&!t.pop&&!t.push&&t.toString(10).match(/^-?[0-9]+$/)&&(t.mul||t.dividedToIntegerBy))return new i(t.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(t)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},function(t,e,r){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.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 s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=r(9).Buffer}catch(t){}function a(t,e,r){for(var i=0,n=Math.min(t.length,r),o=e;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return i}function h(t,e,r,i){for(var n=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}return n}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.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)n=a(t,r,r+6),this.words[i]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(s=(n=0|t.words[p])*(o=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s>>24-n&16777215)||s!==this.length-1?u[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,s--)}for(0!==o&&(r=o.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 f=l[t],d=c[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:u[f-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return i(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;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},o.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},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.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)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o>>26;for(;0!==n&&o>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],v=8191&g,y=g>>>13,w=0|s[3],b=8191&w,M=w>>>13,E=0|s[4],A=8191&E,C=E>>>13,B=0|s[5],F=8191&B,_=B>>>13,S=0|s[6],D=8191&S,x=S>>>13,I=0|s[7],T=8191&I,R=I>>>13,N=0|s[8],O=8191&N,U=N>>>13,k=0|s[9],L=8191&k,P=k>>>13,j=0|a[0],$=8191&j,q=j>>>13,K=0|a[1],H=8191&K,G=K>>>13,z=0|a[2],V=8191&z,W=z>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,$))|0)+((8191&(n=(n=Math.imul(c,q))+Math.imul(f,$)|0))<<13)|0;u=((o=Math.imul(f,q))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,q))+Math.imul(m,$)|0,o=Math.imul(m,q);var vt=(u+(i=i+Math.imul(c,H)|0)|0)+((8191&(n=(n=n+Math.imul(c,G)|0)+Math.imul(f,H)|0))<<13)|0;u=((o=o+Math.imul(f,G)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(v,$),n=(n=Math.imul(v,q))+Math.imul(y,$)|0,o=Math.imul(y,q),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,G)|0;var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,W)|0)+Math.imul(f,V)|0))<<13)|0;u=((o=o+Math.imul(f,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,q))+Math.imul(M,$)|0,o=Math.imul(M,q),i=i+Math.imul(v,H)|0,n=(n=n+Math.imul(v,G)|0)+Math.imul(y,H)|0,o=o+Math.imul(y,G)|0,i=i+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,W)|0;var wt=(u+(i=i+Math.imul(c,Y)|0)|0)+((8191&(n=(n=n+Math.imul(c,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((o=o+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,$),n=(n=Math.imul(A,q))+Math.imul(C,$)|0,o=Math.imul(C,q),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(M,H)|0,o=o+Math.imul(M,G)|0,i=i+Math.imul(v,V)|0,n=(n=n+Math.imul(v,W)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,W)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,X)|0;var bt=(u+(i=i+Math.imul(c,Q)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,Q)|0))<<13)|0;u=((o=o+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(F,$),n=(n=Math.imul(F,q))+Math.imul(_,$)|0,o=Math.imul(_,q),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,G)|0,i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,W)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,W)|0,i=i+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((o=o+Math.imul(f,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(D,$),n=(n=Math.imul(D,q))+Math.imul(x,$)|0,o=Math.imul(x,q),i=i+Math.imul(F,H)|0,n=(n=n+Math.imul(F,G)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,G)|0,i=i+Math.imul(A,V)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,W)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,X)|0,i=i+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,it)|0;var Et=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,st)|0)+Math.imul(f,ot)|0))<<13)|0;u=((o=o+Math.imul(f,st)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,q))+Math.imul(R,$)|0,o=Math.imul(R,q),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,G)|0,i=i+Math.imul(F,V)|0,n=(n=n+Math.imul(F,W)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,W)|0,i=i+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,X)|0,i=i+Math.imul(b,Q)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,i=i+Math.imul(v,rt)|0,n=(n=n+Math.imul(v,it)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var At=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((o=o+Math.imul(f,ut)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,q))+Math.imul(U,$)|0,o=Math.imul(U,q),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,G)|0,i=i+Math.imul(D,V)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,W)|0,i=i+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,X)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,X)|0,i=i+Math.imul(A,Q)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,it)|0,i=i+Math.imul(v,ot)|0,n=(n=n+Math.imul(v,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,ut)|0;var Ct=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;u=((o=o+Math.imul(f,ft)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(L,$),n=(n=Math.imul(L,q))+Math.imul(P,$)|0,o=Math.imul(P,q),i=i+Math.imul(O,H)|0,n=(n=n+Math.imul(O,G)|0)+Math.imul(U,H)|0,o=o+Math.imul(U,G)|0,i=i+Math.imul(T,V)|0,n=(n=n+Math.imul(T,W)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,W)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,X)|0,i=i+Math.imul(F,Q)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,i=i+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,ut)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var Bt=(u+(i=i+Math.imul(c,pt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((o=o+Math.imul(f,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,G))+Math.imul(P,H)|0,o=Math.imul(P,G),i=i+Math.imul(O,V)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(U,V)|0,o=o+Math.imul(U,W)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,X)|0,i=i+Math.imul(D,Q)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,it)|0,i=i+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,ut)|0,i=i+Math.imul(v,ct)|0,n=(n=n+Math.imul(v,ft)|0)+Math.imul(y,ct)|0,o=o+Math.imul(y,ft)|0;var Ft=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((o=o+Math.imul(m,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(L,V),n=(n=Math.imul(L,W))+Math.imul(P,V)|0,o=Math.imul(P,W),i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(U,Y)|0,o=o+Math.imul(U,X)|0,i=i+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(F,ot)|0,n=(n=n+Math.imul(F,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ft)|0;var _t=(u+(i=i+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((o=o+Math.imul(y,mt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(P,Y)|0,o=Math.imul(P,X),i=i+Math.imul(O,Q)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,it)|0,i=i+Math.imul(D,ot)|0,n=(n=n+Math.imul(D,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,ut)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,ut)|0,i=i+Math.imul(A,ct)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ft)|0;var St=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,Q),n=(n=Math.imul(L,tt))+Math.imul(P,Q)|0,o=Math.imul(P,tt),i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(U,rt)|0,o=o+Math.imul(U,it)|0,i=i+Math.imul(T,ot)|0,n=(n=n+Math.imul(T,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ft)|0;var Dt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(P,rt)|0,o=Math.imul(P,it),i=i+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,st)|0)+Math.imul(U,ot)|0,o=o+Math.imul(U,st)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ft)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ft)|0;var xt=(u+(i=i+Math.imul(F,pt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,ot),n=(n=Math.imul(L,st))+Math.imul(P,ot)|0,o=Math.imul(P,st),i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,ut)|0)+Math.imul(U,ht)|0,o=o+Math.imul(U,ut)|0,i=i+Math.imul(T,ct)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(R,ct)|0,o=o+Math.imul(R,ft)|0;var It=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(x,pt)|0))<<13)|0;u=((o=o+Math.imul(x,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,ut))+Math.imul(P,ht)|0,o=Math.imul(P,ut),i=i+Math.imul(O,ct)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(U,ct)|0,o=o+Math.imul(U,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((o=o+Math.imul(R,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ft))+Math.imul(P,ct)|0,o=Math.imul(P,ft);var Rt=(u+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((o=o+Math.imul(U,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Nt=(u+(i=Math.imul(L,pt))|0)+((8191&(n=(n=Math.imul(L,mt))+Math.imul(P,pt)|0))<<13)|0;return u=((o=Math.imul(P,mt))+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h[0]=gt,h[1]=vt,h[2]=yt,h[3]=wt,h[4]=bt,h[5]=Mt,h[6]=Et,h[7]=At,h[8]=Ct,h[9]=Bt,h[10]=Ft,h[11]=_t,h[12]=St,h[13]=Dt,h[14]=xt,h[15]=It,h[16]=Tt,h[17]=Rt,h[18]=Nt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=f),o.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s>>=1)n++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,e+=n/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=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},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&o}for(;n>26,this.words[n+r]=67108863&o;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!=(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new o(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var f=67108864*(0|i.words[n.length+c])+(0|i.words[n.length+c-1]);for(f=Math.min(f/s|0,67108863),i._ishlnsubmul(n,f,c);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=f)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},o.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),h=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(l),s.isub(c)),n.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(c)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(h)):(r.isub(e),a.isub(n),h.isub(s))}return{a,b:h,gcd:r.iushln(u)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var c=0,f=1;0==(r.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new E(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(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 v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):r.strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(y,v),y.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,o=s}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},y.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]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return g[t]=e,e},E.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},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(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==c||0!==s?(s<<=1,s|=c,(4==++a||0===i&&0===l)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}h=26}return n},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},o.mont=function(t){return new A(t)},n(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},(t,e,r)=>{var i=r(15);t.exports=function(t){return"string"!=typeof t?t:i(t)?t.slice(2):t}},t=>{t.exports=function(t){if("string"!=typeof t)throw new Error("[is-hex-prefixed] value must be type 'string', is currently type "+typeof t+", while checking isHexPrefixed.");return"0x"===t.slice(0,2)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i}),r(17);const i=window.crypto},(t,e,r)=>{"use strict";var i,n;r.r(e),r.d(e,{default:()=>o}),i="undefined"!=typeof self?self:void 0,n=function(t){if("function"!=typeof Promise)throw"Promise support required";var e=t.crypto||t.msCrypto;if(e){var r=e.subtle||e.webkitSubtle;if(r){var i=t.Crypto||e.constructor||Object,n=t.SubtleCrypto||r.constructor||Object,o=(t.CryptoKey||t.Key,t.navigator.userAgent.indexOf("Edge/")>-1),s=!!t.msCrypto&&!o,a=!e.subtle&&!!e.webkitSubtle;if(s||a){var h={KoZIhvcNAQEB:"1.2.840.113549.1.1.1"},u={"1.2.840.113549.1.1.1":"KoZIhvcNAQEB"};if(["generateKey","importKey","unwrapKey"].forEach((function(t){var i=r[t];r[t]=function(n,o,h){var u,l,c,p,b=[].slice.call(arguments);switch(t){case"generateKey":u=m(n),l=o,c=h;break;case"importKey":u=m(h),l=b[3],c=b[4],"jwk"===n&&((o=v(o)).alg||(o.alg=g(u)),o.key_ops||(o.key_ops="oct"!==o.kty?"d"in o?c.filter(B):c.filter(C):c.slice()),b[1]=y(o));break;case"unwrapKey":u=b[4],l=b[5],c=b[6],b[2]=h._key}if("generateKey"===t&&"HMAC"===u.name&&u.hash)return u.length=u.length||{"SHA-1":512,"SHA-256":512,"SHA-384":1024,"SHA-512":1024}[u.hash.name],r.importKey("raw",e.getRandomValues(new Uint8Array(u.length+7>>3)),u,l,c);if(a&&"generateKey"===t&&"RSASSA-PKCS1-v1_5"===u.name&&(!u.modulusLength||u.modulusLength>=2048))return(n=m(n)).name="RSAES-PKCS1-v1_5",delete n.hash,r.generateKey(n,!0,["encrypt","decrypt"]).then((function(t){return Promise.all([r.exportKey("jwk",t.publicKey),r.exportKey("jwk",t.privateKey)])})).then((function(t){return t[0].alg=t[1].alg=g(u),t[0].key_ops=c.filter(C),t[1].key_ops=c.filter(B),Promise.all([r.importKey("jwk",t[0],u,!0,t[0].key_ops),r.importKey("jwk",t[1],u,l,t[1].key_ops)])})).then((function(t){return{publicKey:t[0],privateKey:t[1]}}));if((a||s&&"SHA-1"===(u.hash||{}).name)&&"importKey"===t&&"jwk"===n&&"HMAC"===u.name&&"oct"===o.kty)return r.importKey("raw",d(f(o.k)),h,b[3],b[4]);if(a&&"importKey"===t&&("spki"===n||"pkcs8"===n))return r.importKey("jwk",w(o),h,b[3],b[4]);if(s&&"unwrapKey"===t)return r.decrypt(b[3],h,o).then((function(t){return r.importKey(n,t,b[4],b[5],b[6])}));try{p=i.apply(r,b)}catch(t){return Promise.reject(t)}return s&&(p=new Promise((function(t,e){p.onabort=p.onerror=function(t){e(t)},p.oncomplete=function(e){t(e.target.result)}}))),p=p.then((function(t){return"HMAC"===u.name&&(u.length||(u.length=8*t.algorithm.length)),0==u.name.search("RSA")&&(u.modulusLength||(u.modulusLength=(t.publicKey||t).algorithm.modulusLength),u.publicExponent||(u.publicExponent=(t.publicKey||t).algorithm.publicExponent)),t.publicKey&&t.privateKey?{publicKey:new A(t.publicKey,u,l,c.filter(C)),privateKey:new A(t.privateKey,u,l,c.filter(B))}:new A(t,u,l,c)}))}})),["exportKey","wrapKey"].forEach((function(t){var e=r[t];r[t]=function(i,n,o){var h,u=[].slice.call(arguments);switch(t){case"exportKey":u[1]=n._key;break;case"wrapKey":u[1]=n._key,u[2]=o._key}if((a||s&&"SHA-1"===(n.algorithm.hash||{}).name)&&"exportKey"===t&&"jwk"===i&&"HMAC"===n.algorithm.name&&(u[0]="raw"),!a||"exportKey"!==t||"spki"!==i&&"pkcs8"!==i||(u[0]="jwk"),s&&"wrapKey"===t)return r.exportKey(i,n).then((function(t){return"jwk"===i&&(t=d(unescape(encodeURIComponent(JSON.stringify(v(t)))))),r.encrypt(u[3],o,t)}));try{h=e.apply(r,u)}catch(t){return Promise.reject(t)}return s&&(h=new Promise((function(t,e){h.onabort=h.onerror=function(t){e(t)},h.oncomplete=function(e){t(e.target.result)}}))),"exportKey"===t&&"jwk"===i&&(h=h.then((function(t){return(a||s&&"SHA-1"===(n.algorithm.hash||{}).name)&&"HMAC"===n.algorithm.name?{kty:"oct",alg:g(n.algorithm),key_ops:n.usages.slice(),ext:!0,k:c(p(t))}:((t=v(t)).alg||(t.alg=g(n.algorithm)),t.key_ops||(t.key_ops="public"===n.type?n.usages.filter(C):"private"===n.type?n.usages.filter(B):n.usages.slice()),t)}))),!a||"exportKey"!==t||"spki"!==i&&"pkcs8"!==i||(h=h.then((function(t){return b(v(t))}))),h}})),["encrypt","decrypt","sign","verify"].forEach((function(t){var e=r[t];r[t]=function(i,n,o,a){if(s&&(!o.byteLength||a&&!a.byteLength))throw new Error("Empy input is not allowed");var h,u=[].slice.call(arguments),l=m(i);if(s&&"decrypt"===t&&"AES-GCM"===l.name){var c=i.tagLength>>3;u[2]=(o.buffer||o).slice(0,o.byteLength-c),i.tag=(o.buffer||o).slice(o.byteLength-c)}u[1]=n._key;try{h=e.apply(r,u)}catch(t){return Promise.reject(t)}return s&&(h=new Promise((function(e,r){h.onabort=h.onerror=function(t){r(t)},h.oncomplete=function(r){if(r=r.target.result,"encrypt"===t&&r instanceof AesGcmEncryptResult){var i=r.ciphertext,n=r.tag;(r=new Uint8Array(i.byteLength+n.byteLength)).set(new Uint8Array(i),0),r.set(new Uint8Array(n),i.byteLength),r=r.buffer}e(r)}}))),h}})),s){var l=r.digest;r.digest=function(t,e){if(!e.byteLength)throw new Error("Empy input is not allowed");var i;try{i=l.call(r,t,e)}catch(t){return Promise.reject(t)}return i=new Promise((function(t,e){i.onabort=i.onerror=function(t){e(t)},i.oncomplete=function(e){t(e.target.result)}}))},t.crypto=Object.create(e,{getRandomValues:{value:function(t){return e.getRandomValues(t)}},subtle:{value:r}}),t.CryptoKey=A}a&&(e.subtle=r,t.Crypto=i,t.SubtleCrypto=n,t.CryptoKey=A)}}}function c(t){return btoa(t).replace(/\=+$/,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(t){return t=(t+="===").slice(0,-t.length%4),atob(t.replace(/-/g,"+").replace(/_/g,"/"))}function d(t){for(var e=new Uint8Array(t.length),r=0;r2&&(r=!0,e.shift());var i={ext:!0};if("1.2.840.113549.1.1.1"!==e[0][0])throw new TypeError("Unsupported key type");var n=["n","e","d","p","q","dp","dq","qi"],o=M(e[1]);r&&o.shift();for(var s=0;s2&&(i=!0,o.unshift(new Uint8Array([0]))),r[0][0]="1.2.840.113549.1.1.1",e=o,r.push(new Uint8Array(E(e)).buffer),i?r.unshift(new Uint8Array([0])):r[1]={tag:3,value:r[1]},new Uint8Array(E(r)).buffer}function M(t,e){if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),e||(e={pos:0,end:t.length}),e.end-e.pos<2||e.end>t.length)throw new RangeError("Malformed DER");var r,i=t[e.pos++],n=t[e.pos++];if(n>=128){if(n&=127,e.end-e.pos=128){var a=i;for(i=4,e.splice(n,0,a>>24&255,a>>16&255,a>>8&255,255&a);i>1&&!(a>>24);)a<<=8,i--;i<4&&e.splice(n,4-i),i|=128}return e.splice(n-2,2,r,i),e}function A(t,e,r,i){Object.defineProperties(this,{_key:{value:t},type:{value:t.type,enumerable:!0},extractable:{value:void 0===r?t.extractable:r,enumerable:!0},algorithm:{value:void 0===e?t.algorithm:e,enumerable:!0},usages:{value:void 0===i?t.usages:i,enumerable:!0}})}function C(t){return"verify"===t||"encrypt"===t||"wrapKey"===t}function B(t){return"sign"===t||"decrypt"===t||"unwrapKey"===t}},"function"==typeof define&&define.amd?define([],(function(){return n(i)})):"object"==typeof module&&module.exports?module.exports=n(i):n(i);const o={}},(t,e,r)=>{const{crc16:i,hexToBytes:n,bytesToHex:o,stringToBytes:s,base64toString:a,stringToBase64:h}=r(2);class u{static isValid(t){try{return new u(t),!0}catch(t){return!1}}constructor(t){if(null==t)throw"Invalid address";if(t instanceof u)return this.wc=t.wc,this.hashPart=t.hashPart,this.isTestOnly=t.isTestOnly,this.isUserFriendly=t.isUserFriendly,this.isBounceable=t.isBounceable,void(this.isUrlSafe=t.isUrlSafe);if(t.search(/\-/)>0||t.search(/_/)>0?(this.isUrlSafe=!0,t=t.replace(/\-/g,"+").replace(/_/g,"/")):this.isUrlSafe=!1,t.indexOf(":")>-1){const e=t.split(":");if(2!==e.length)throw new Error("Invalid address "+t);const r=parseInt(e[0]);if(0!==r&&-1!==r)throw new Error("Invalid address wc "+t);const i=e[1];if(64!==i.length)throw new Error("Invalid address hex "+t);this.isUserFriendly=!1,this.wc=r,this.hashPart=n(i),this.isTestOnly=!1,this.isBounceable=!1}else{this.isUserFriendly=!0;const e=function(t){if(48!==t.length)throw new Error("User-friendly address should contain strictly 48 characters");const e=s(a(t));if(36!==e.length)throw"Unknown address type: byte length is not equal to 36";const r=e.slice(0,34),n=e.slice(34,36),o=i(r);if(o[0]!==n[0]||o[1]!==n[1])throw"Wrong crc16 hashsum";let h=r[0],u=!1,l=!1;if(128&h&&(u=!0,h^=128),17!==h&&81!==h)throw"Unknown address tag";l=17===h;let c=null;if(c=255===r[1]?-1:r[1],0!==c&&-1!==c)throw new Error("Invalid address wc "+c);return{isTestOnly:u,isBounceable:l,workchain:c,hashPart:r.slice(2,34)}}(t);this.wc=e.workchain,this.hashPart=e.hashPart,this.isTestOnly=e.isTestOnly,this.isBounceable=e.isBounceable}}toString(t,e,r,n){if(void 0===t&&(t=this.isUserFriendly),void 0===e&&(e=this.isUrlSafe),void 0===r&&(r=this.isBounceable),void 0===n&&(n=this.isTestOnly),t){let t=r?17:81;n&&(t|=128);const o=new Int8Array(34);o[0]=t,o[1]=this.wc,o.set(this.hashPart,2);const s=new Uint8Array(36);s.set(o),s.set(i(o),34);let a=h(String.fromCharCode.apply(null,new Uint8Array(s)));return e&&(a=a.replace(/\+/g,"-").replace(/\//g,"_")),a}return this.wc+":"+o(this.hashPart)}}t.exports.default=u},(t,e,r)=>{const{BitString:i}=r(20),{Cell:n}=r(21);t.exports={BitString:i,Cell:n}},(t,e,r)=>{const{BN:i,bytesToHex:n}=r(1);class o{constructor(t){this.array=Uint8Array.from({length:Math.ceil(t/8)},(()=>0)),this.cursor=0,this.length=t}getFreeBits(){return this.length-this.cursor}getUsedBits(){return this.cursor}getUsedBytes(){return Math.ceil(this.cursor/8)}get(t){return(this.array[t/8|0]&1<<7-t%8)>0}checkRange(t){if(t>this.length)throw Error("BitString overflow")}on(t){this.checkRange(t),this.array[t/8|0]|=1<<7-t%8}off(t){this.checkRange(t),this.array[t/8|0]&=~(1<<7-t%8)}toggle(t){this.checkRange(t),this.array[t/8|0]^=1<<7-t%8}forEach(t){const e=this.cursor;for(let r=0;r0?this.on(this.cursor):this.off(this.cursor),this.cursor=this.cursor+1}writeBitArray(t){for(let e=0;ee){if(0==t)return;throw Error("bitLength is too small for number, got number="+t+",bitLength="+e)}const r=t.toString(2,e);for(let t=0;t{this.writeBit(t)}))}clone(){const t=new o(0);return t.array=this.array.slice(0),t.length=this.length,t.cursor=this.cursor,t}toString(){return this.toHex()}getTopUppedArray(){const t=this.clone();let e=8*Math.ceil(t.cursor/8)-t.cursor;if(e>0)for(e-=1,t.writeBit(!0);e>0;)e-=1,t.writeBit(!1);return t.array=t.array.slice(0,Math.ceil(t.cursor/8)),t.array}toHex(){if(this.cursor%4==0){const t=n(this.array.slice(0,Math.ceil(this.cursor/8))).toUpperCase();return this.cursor%8==0?t:t.substr(0,t.length-1)}{const t=this.clone();for(t.writeBit(1);t.cursor%4!=0;)t.writeBit(0);return t.toHex().toUpperCase()+"_"}}setTopUppedArray(t,e=!0){if(this.length=8*t.length,this.array=t,this.cursor=this.length,!e&&this.length){let r=!1;for(let t=0;t<7;t++)if(this.cursor-=1,this.get(this.cursor)){r=!0,this.off(this.cursor);break}if(!r)throw console.log(t,e),new Error("Incorrect TopUppedArray")}}}t.exports={BitString:o}},(t,e,r)=>{const{BitString:i}=r(20),{bytesToBase64:n,compareBytes:o,concatBytes:s,crc32c:a,hexToBytes:h,readNBytesUIntFromArray:u,sha256:l,bytesToHex:c}=r(1),f=h("B5EE9C72"),d=h("68ff65f3"),p=h("acc3a728");class m{constructor(){this.bits=new i(1023),this.refs=[],this.isExotic=!1}static fromBoc(t){return w(t)}static oneFromBoc(t){const e=w(t);if(1!==e.length)throw new Error("expected 1 root cell but have "+e.length);return e[0]}writeCell(t){this.bits.writeBitString(t.bits),this.refs=this.refs.concat(t.refs)}getMaxLevel(){let t=0;for(let e in this.refs){const r=this.refs[e];r.getMaxLevel()>t&&(t=r.getMaxLevel())}return t}isExplicitlyStoredHashes(){return 0}getMaxDepth(){let t=0;if(this.refs.length>0){for(let e in this.refs){const r=this.refs[e];r.getMaxDepth()>t&&(t=r.getMaxDepth())}t+=1}return t}getMaxDepthAsArray(){const t=this.getMaxDepth(),e=Uint8Array.from({length:2},(()=>0));return e[1]=t%256,e[0]=Math.floor(t/256),e}getRefsDescriptor(){const t=Uint8Array.from({length:1},(()=>0));return t[0]=this.refs.length+8*this.isExotic+32*this.getMaxLevel(),t}getBitsDescriptor(){const t=Uint8Array.from({length:1},(()=>0));return t[0]=Math.ceil(this.bits.cursor/8)+Math.floor(this.bits.cursor/8),t}getDataWithDescriptors(){const t=this.getRefsDescriptor(),e=this.getBitsDescriptor(),r=this.bits.getTopUppedArray();return s(s(t,e),r)}async getRepr(){const t=[];t.push(this.getDataWithDescriptors());for(let e in this.refs){const r=this.refs[e];t.push(r.getMaxDepthAsArray())}for(let e in this.refs){const r=this.refs[e];t.push(await r.hash())}let e=new Uint8Array;for(let r in t){const i=t[r];e=s(e,i)}return e}async hash(){return new Uint8Array(await l(await this.getRepr()))}print(t){let e=(t=t||"")+"x{"+this.bits.toHex()+"}\n";for(let r in this.refs)e+=this.refs[r].print(t+" ");return e}async toBoc(t=!0,e=!0,r=!1,n=0){const o=await this.treeWalk(),h=o[0],u=o[1],l=h.length,c=l.toString(2).length,d=Math.min(Math.ceil(c/8),1);let p=0,m=[];for(let t of h)m.push(p),p+=await t[1].bocSerializationSize(u,d);const g=p.toString(2).length,v=Math.max(Math.ceil(g/8),1),y=new i(1247*h.length);y.writeBytes(f),y.writeBitArray([t,e,r]),y.writeUint(n,2),y.writeUint(d,3),y.writeUint8(v),y.writeUint(l,8*d),y.writeUint(1,8*d),y.writeUint(0,8*d),y.writeUint(p,8*v),y.writeUint(0,8*d),t&&h.forEach(((t,e)=>y.writeUint(m[e],8*v)));for(let t of h){const e=await t[1].serializeForBoc(u,d);y.writeBytes(e)}let w=y.getTopUppedArray();return e&&(w=s(w,a(w))),w}async serializeForBoc(t,e){const r=[];if(r.push(this.getDataWithDescriptors()),this.isExplicitlyStoredHashes())throw new Error("Cell hashes explicit storing is not implemented");for(let e in this.refs){const i=this.refs[e];let n=t[await i.hash()].toString(16);n.length%2&&(n="0"+n);const o=h(n);r.push(o)}let i=new Uint8Array;for(let t in r){const e=r[t];i=s(i,e)}return i}async bocSerializationSize(t,e){return(await this.serializeForBoc(t,e)).length}async treeWalk(){return v(this,[],{})}}async function g(t,e,r){const i=t[r];for(let e in t)t[e]>i&&(t[e]=t[e]-1);t[r]=e.length-1;const n=e.splice(i,1)[0];e.push(n);for(let r of n[1].refs)await g(t,e,await r.hash())}async function v(t,e,r,i=null){const n=await t.hash();if(n in r)return i&&r[i]>r[n]&&await g(r,e,n),[e,r];r[n]=e.length,e.push([n,t]);for(let i of t.refs){const t=await v(i,e,r,n);e=t[0],r=t[1]}return[e,r]}function y(t,e){if(t.length<2)throw"Not enough bytes to encode cell descriptors";const r=t[0],i=t[1];t=t.slice(2),Math.floor(r/32);const n=8&r,o=r%8,s=Math.ceil(i/2),a=!(i%2);let h=new m;if(h.isExotic=n,t.length=0;t--){let e=i[t];for(let r=0;r{var i=r(9).Buffer;const{Cell:n}=r(19),{Address:o,BN:s,bytesToHex:a}=r(1),{Contract:h}=r(23);t.exports=class{constructor(t,e){this.transport=t,this.ton=e,this.ADDRESS_FORMAT_HEX=0,this.ADDRESS_FORMAT_USER_FRIENDLY=1,this.ADDRESS_FORMAT_URL_SAFE=2,this.ADDRESS_FORMAT_BOUNCEABLE=4,this.ADDRESS_FORMAT_TEST_ONLY=8}async getAppConfiguration(){const t=await this.transport.send(224,1,0,0);return{version:t[0]+"."+t[1]+"."+t[2]}}async getPublicKey(t,e){const r=i.alloc(4);r.writeInt32BE(t);const n=await this.transport.send(224,2,e?1:0,0,r),o=n[0];return{publicKey:new Uint8Array(n.slice(1,1+o))}}async getAddress(t,e,r){const n=i.alloc(4);n.writeInt32BE(t);const s=await this.transport.send(224,5,e?1:0,r,n),h=s[0],u=new Uint8Array(s.slice(1,1+h));return{address:new o("0:"+a(u))}}async sign(t,e){const r=i.alloc(4);r.writeInt32BE(t);const n=i.concat([r,i.from(e)]),o=await this.transport.send(224,3,0,0,n),s=o[0];return{signature:o.slice(1,1+s)}}async transfer(t,e,r,o,s,a){const u=await e.createTransferMessage(null,r,o,s,null,3,!0),l=i.alloc(4);l.writeInt32BE(t);const c=i.concat([l,i.from(await u.signingMessage.toBoc())]),f=await this.transport.send(224,4,a,0,c),d=f[0],p=f.slice(1,1+d),m=new Uint8Array(p),g=new n;g.bits.writeBytes(m),g.writeCell(u.signingMessage);let v=null,y=null,w=null;if(0===s){const t=await e.createStateInit();v=t.stateInit,y=t.code,w=t.data}const b=await e.getAddress(),M=h.createExternalMessageHeader(b),E=h.createCommonMsgInfo(M,v,g),A=new Promise((t=>{t({address:b,message:E,body:g,signature:m,signingMessage:u.signingMessage,stateInit:v,code:y,data:w})}));return h.createMethod(this.ton.provider,A)}}},(t,e,r)=>{const{Cell:i}=r(19),{Address:n,bytesToBase64:o,bytesToHex:s}=r(1);class a{constructor(t,e){this.provider=t,this.options=e,this.address=e.address?new n(e.address):null,e.wc||(e.wc=this.address?this.address.wc:0),this.methods={}}async getAddress(){return this.address||(this.address=(await this.createStateInit()).address),this.address}createCodeCell(){if(!this.options.code)throw new Error("Contract: options.code is not defined");return this.options.code}createDataCell(){return new i}async createStateInit(){const t=this.createCodeCell(),e=this.createDataCell(),r=a.createStateInit(t,e),i=await r.hash();return{stateInit:r,address:new n(this.options.wc+":"+s(i)),code:t,data:e}}static createStateInit(t,e,r=null,n=null,o=null){if(r)throw"Library in state init is not implemented";if(n)throw"Split depth in state init is not implemented";if(o)throw"Ticktock in state init is not implemented";const s=new i;return s.bits.writeBitArray([Boolean(n),Boolean(o),Boolean(t),Boolean(e),Boolean(r)]),t&&s.refs.push(t),e&&s.refs.push(e),r&&s.refs.push(r),s}static createInternalMessageHeader(t,e=0,r=!0,o=null,s=!1,a=null,h=null,u=0,l=0,c=0,f=0){const d=new i;if(d.bits.writeBit(!1),d.bits.writeBit(r),null!==o?d.bits.writeBit(o):d.bits.writeBit(new n(t).isBounceable),d.bits.writeBit(s),d.bits.writeAddress(a?new n(a):null),d.bits.writeAddress(new n(t)),d.bits.writeGrams(e),h)throw"Currency collections are not implemented yet";return d.bits.writeBit(Boolean(h)),d.bits.writeGrams(u),d.bits.writeGrams(l),d.bits.writeUint(c,64),d.bits.writeUint(f,32),d}static createExternalMessageHeader(t,e=null,r=0){const o=new i;return o.bits.writeUint(2,2),o.bits.writeAddress(e?new n(e):null),o.bits.writeAddress(new n(t)),o.bits.writeGrams(r),o}static createCommonMsgInfo(t,e=null,r=null){const n=new i;return n.writeCell(t),e?(n.bits.writeBit(!0),n.bits.getFreeBits()-1>=e.bits.getUsedBits()?(n.bits.writeBit(!1),n.writeCell(e)):(n.bits.writeBit(!0),n.refs.push(e))):n.bits.writeBit(!1),r?n.bits.getFreeBits()>=r.bits.getUsedBits()?(n.bits.writeBit(!1),n.writeCell(r)):(n.bits.writeBit(!0),n.refs.push(r)):n.bits.writeBit(!1),n}static createMethod(t,e){return{getQuery:async()=>(await e).message,send:async()=>{const r=await e,i=o(await r.message.toBoc(!1));return t.sendBoc(i)},estimateFee:async()=>{const r=await e,i=r.code?{address:r.address.toString(!0,!0,!1),body:o(await r.body.toBoc(!1)),init_code:o(await r.code.toBoc(!1)),init_data:o(await r.data.toBoc(!1))}:{address:r.address.toString(!0,!0,!0),body:o(await r.body.toBoc(!1))};return t.getEstimateFee(i)}}}}t.exports={Contract:a}},(t,e,r)=>{const i=r(25).default;"undefined"==typeof fetch&&(fetch=r(26));const n="-9223372036854775808";class o{constructor(t,e){this.host=t||"https://toncenter.com/api/v2/jsonRPC",this.options=e||{}}sendImpl(t,e){const r={"Content-Type":"application/json"};return this.options.apiKey&&(r["X-API-Key"]=this.options.apiKey),fetch(t,{method:"POST",headers:r,body:JSON.stringify(e)}).then((t=>t.json())).then((({result:t,error:e})=>t||Promise.reject(e)))}send(t,e){return this.sendImpl(this.host,{id:1,jsonrpc:"2.0",method:t,params:e})}async getAddressInfo(t){return this.send("getAddressInformation",{address:t})}async getExtendedAddressInfo(t){return this.send("getExtendedAddressInformation",{address:t})}async getWalletInfo(t){return this.send("getWalletInformation",{address:t})}async getTransactions(t,e=20,r,i,n,o){return this.send("getTransactions",{address:t,limit:e,lt:r,hash:i,to_lt:n,archival:o})}async getBalance(t){return this.send("getAddressBalance",{address:t})}async sendBoc(t){return this.send("sendBoc",{boc:t})}async sendQuery(t){return this.send("sendQuerySimple",t)}async getEstimateFee(t){return this.send("estimateFee",t)}async call(t,e,r=[]){return this.send("runGetMethod",{address:t,method:e,stack:r})}async call2(t,e,r=[]){const n=await this.send("runGetMethod",{address:t,method:e,stack:r});return i.parseResponse(n)}async getMasterchainInfo(){return this.send("getMasterchainInfo",{})}async getBlockShards(t){return this.send("shards",{seqno:t})}async getBlockTransactions(t,e,r){return this.send("getBlockTransactions",{workchain:t,shard:e,seqno:r})}async getMasterchainBlockTransactions(t){return this.getBlockTransactions(-1,n,t)}async getBlockHeader(t,e,r){return this.send("getBlockHeader",{workchain:t,shard:e,seqno:r})}async getMasterchainBlockHeader(t){return this.getBlockHeader(-1,n,t)}}o.SHARD_ID_ALL=n,t.exports.default=o},(t,e,r)=>{const{BN:i,base64ToBytes:n}=r(1),{Cell:o}=r(19);class s{static parseObject(t){const e=t["@type"];switch(e){case"tvm.list":case"tvm.tuple":return t.elements.map(s.parseObject);case"tvm.stackEntryTuple":return s.parseObject(t.tuple);case"tvm.stackEntryNumber":return s.parseObject(t.number);case"tvm.numberDecimal":return new i(t.number,10);default:throw new Error("unknown type "+e)}}static parseResponseStack(t){const e=t[0],r=t[1];switch(e){case"num":return new i(r.replace(/0x/,""),16);case"list":case"tuple":return s.parseObject(r);case"cell":const t=n(r.bytes);return o.oneFromBoc(t);default:throw new Error("unknown type "+e)}}static parseResponse(t){if(0!==t.exit_code){const e=new Error("http provider parse response error");throw e.result=t,e}const e=t.stack.map(s.parseResponseStack);return 1===e.length?e[0]:e}static makeArg(t){if(t instanceof i||t instanceof Number)return["num",t];throw new Error("unknown arg type "+t)}static makeArgs(t){return t.map(this.makeArg)}}t.exports.default=s},()=>{},(t,e,r)=>{const{Cell:i}=r(19),{Address:n,BN:o,toNano:s,bytesToHex:a,hexToBytes:h,nacl:u,stringToBytes:l,bytesToBase64:c}=r(1),{Contract:f}=r(23),{SimpleWalletContractR1:d,SimpleWalletContractR2:p,SimpleWalletContractR3:m}=r(28),{WalletV2ContractR1:g,WalletV2ContractR2:v}=r(30),{WalletV3ContractR1:y,WalletV3ContractR2:w}=r(31),{WalletV4ContractR1:b}=r(32),{WalletV4ContractR2:M}=r(33),E={simpleR1:d,simpleR2:p,simpleR3:m,v2R1:g,v2R2:v,v3R1:y,v3R2:w,v4R1:b,v4R2:M},A=[d,p,m,g,v,y,w,b,M];class C{constructor(t){this.provider=t,this.all=E,this.list=A,this.defaultVersion="v3R1",this.default=this.all[this.defaultVersion]}create(t){return new this.default(this.provider,t)}}C.all=E,C.list=A,t.exports.default=C},(t,e,r)=>{const{Cell:i}=r(19),{WalletContract:n}=r(29);t.exports={SimpleWalletContractR1:class extends n{constructor(t,e){e.code=i.oneFromBoc("B5EE9C72410101010044000084FF0020DDA4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED5441FDF089"),super(t,e)}getName(){return"simpleR1"}},SimpleWalletContractR2:class extends n{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100530000A2FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54D0E2786F"),super(t,e)}getName(){return"simpleR2"}},SimpleWalletContractR3:class extends n{constructor(t,e){e.code=i.oneFromBoc("B5EE9C7241010101005F0000BAFF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54B5B86E42"),super(t,e)}getName(){return"simpleR3"}}}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{nacl:o,stringToBytes:s,Address:a,BN:h}=r(1);t.exports={WalletContract:class extends i{constructor(t,e){if(!e.publicKey&&!e.address)throw new Error("WalletContract required publicKey or address in options");super(t,e),this.methods={transfer:e=>i.createMethod(t,this.createTransferMessage(e.secretKey,e.toAddress,e.amount,e.seqno,e.payload,e.sendMode,!Boolean(e.secretKey),e.stateInit)),seqno:()=>({call:async()=>{const e=await this.getAddress();let r=null;try{r=(await t.call2(e.toString(),"seqno")).toNumber()}catch(t){}return r}})},this.deploy=e=>i.createMethod(t,this.createInitExternalMessage(e))}getName(){throw new Error("override me")}createDataCell(){const t=new n;return t.bits.writeUint(0,32),t.bits.writeBytes(this.options.publicKey),t}createSigningMessage(t){t=t||0;const e=new n;return e.bits.writeUint(t,32),e}async createInitExternalMessage(t){if(!this.options.publicKey){const e=o.sign.keyPair.fromSecretKey(t);this.options.publicKey=e.publicKey}const{stateInit:e,address:r,code:s,data:a}=await this.createStateInit(),h=this.createSigningMessage(),u=o.sign.detached(await h.hash(),t),l=new n;l.bits.writeBytes(u),l.writeCell(h);const c=i.createExternalMessageHeader(r);return{address:r,message:i.createCommonMsgInfo(c,e,l),body:l,signingMessage:h,stateInit:e,code:s,data:a}}async createExternalMessage(t,e,r,s=!1){const a=s?new Uint8Array(64):o.sign.detached(await t.hash(),e),h=new n;h.bits.writeBytes(a),h.writeCell(t);let u=null,l=null,c=null;if(0===r){if(!this.options.publicKey){const t=o.sign.keyPair.fromSecretKey(e);this.options.publicKey=t.publicKey}const t=await this.createStateInit();u=t.stateInit,l=t.code,c=t.data}const f=await this.getAddress(),d=i.createExternalMessageHeader(f);return{address:f,message:i.createCommonMsgInfo(d,u,h),body:h,signature:a,signingMessage:t,stateInit:u,code:l,data:c}}async createTransferMessage(t,e,r,o,s="",u=3,l=!1,c=null){let f=new n;s&&(s.refs?f=s:"string"==typeof s?s.length>0&&(f.bits.writeUint(0,32),f.bits.writeString(s)):f.bits.writeBytes(s));const d=i.createInternalMessageHeader(new a(e),new h(r)),p=i.createCommonMsgInfo(d,c,f),m=this.createSigningMessage(o);return m.bits.writeUint8(u),m.refs.push(p),this.createExternalMessage(m,t,o,l)}}}},(t,e,r)=>{const{Cell:i}=r(19),{WalletContract:n}=r(29);class o extends n{createSigningMessage(t){t=t||0;const e=new i;if(e.bits.writeUint(t,32),0===t)for(let t=0;t<32;t++)e.bits.writeBit(1);else{const t=new Date,r=Math.floor(t.getTime()/1e3);e.bits.writeUint(r+60,32)}return e}}t.exports={WalletV2ContractR1:class extends o{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100570000AAFF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31F01F823BBF263ED44D0D31FD3FFD15131BAF2A103F901541042F910F2A2F800029320D74A96D307D402FB00E8D1A4C8CB1FCBFFC9ED54A1370BB6"),super(t,e)}getName(){return"v2R1"}},WalletV2ContractR2:class extends o{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100630000C2FF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F2608308D71820D31FD31F01F823BBF263ED44D0D31FD3FFD15131BAF2A103F901541042F910F2A2F800029320D74A96D307D402FB00E8D1A4C8CB1FCBFFC9ED54044CD7A1"),super(t,e)}getName(){return"v2R2"}}}},(t,e,r)=>{const{Cell:i}=r(19),{WalletContract:n}=r(29);class o extends n{createSigningMessage(t){t=t||0;const e=new i;if(e.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)e.bits.writeBit(1);else{const t=new Date,r=Math.floor(t.getTime()/1e3);e.bits.writeUint(r+60,32)}return e.bits.writeUint(t,32),e}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t}}t.exports={WalletV3ContractR1:class extends o{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100620000C0FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED543FBE6EE0"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc)}getName(){return"v3R1"}},WalletV3ContractR2:class extends o{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100710000DEFF0020DD2082014C97BA218201339CBAB19F71B0ED44D0D31FD31F31D70BFFE304E0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED5410BD6DAD"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc)}getName(){return"v3R2"}}}},(t,e,r)=>{const{Cell:i}=r(19),{Contract:n}=r(23),{Address:o,bytesToHex:s,BN:a}=r(1),{WalletContract:h}=r(29);t.exports={WalletV4ContractR1:class extends h{constructor(t,e){e.code=i.oneFromBoc("B5EE9C72410215010002F5000114FF00F4A413F4BCF2C80B010201200203020148040504F8F28308D71820D31FD31FD31F02F823BBF263ED44D0D31FD31FD3FFF404D15143BAF2A15151BAF2A205F901541064F910F2A3F80024A4C8CB1F5240CB1F5230CBFF5210F400C9ED54F80F01D30721C0009F6C519320D74A96D307D402FB00E830E021C001E30021C002E30001C0039130E30D03A4C8CB1F12CB1FCBFF1112131403EED001D0D3030171B0915BE021D749C120915BE001D31F218210706C7567BD228210626C6E63BDB022821064737472BDB0925F03E002FA403020FA4401C8CA07CBFFC9D0ED44D0810140D721F404305C810108F40A6FA131B3925F05E004D33FC8258210706C7567BA9131E30D248210626C6E63BAE30004060708020120090A005001FA00F404308210706C7567831EB17080185005CB0527CF165003FA02F40012CB69CB1F5210CB3F0052F8276F228210626C6E63831EB17080185005CB0527CF1624FA0214CB6A13CB1F5230CB3F01FA02F4000092821064737472BA8E3504810108F45930ED44D0810140D720C801CF16F400C9ED54821064737472831EB17080185004CB0558CF1622FA0212CB6ACB1FCB3F9410345F04E2C98040FB000201200B0C0059BD242B6F6A2684080A06B90FA0218470D4080847A4937D29910CE6903E9FF9837812801B7810148987159F31840201580D0E0011B8C97ED44D0D70B1F8003DB29DFB513420405035C87D010C00B23281F2FFF274006040423D029BE84C600201200F100019ADCE76A26840206B90EB85FFC00019AF1DF6A26840106B90EB858FC0006ED207FA00D4D422F90005C8CA0715CBFFC9D077748018C8CB05CB0222CF165005FA0214CB6B12CCCCC971FB00C84014810108F451F2A702006C810108D718C8542025810108F451F2A782106E6F746570748018C8CB05CB025004CF16821005F5E100FA0213CB6A12CB1FC971FB00020072810108D718305202810108F459F2A7F82582106473747270748018C8CB05CB025005CF16821005F5E100FA0214CB6A13CB1F12CB3FC973FB00000AF400C9ED5446A9F34F"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc),this.methods.getPublicKey=this.getPublicKey.bind(this)}getName(){return"v4R1"}createSigningMessage(t,e){t=t||0;const r=new i;if(r.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)r.bits.writeBit(1);else{const t=new Date,e=Math.floor(t.getTime()/1e3);r.bits.writeUint(e+60,32)}return r.bits.writeUint(t,32),e||r.bits.writeUint(0,8),r}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t.bits.writeUint(0,1),t}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}}}},(t,e,r)=>{const{Cell:i}=r(19),{Contract:n}=r(23),{Address:o,bytesToHex:s,BN:a,toNano:h}=r(1),{WalletContract:u}=r(29);t.exports={WalletV4ContractR2:class extends u{constructor(t,e){e.code=i.oneFromBoc("B5EE9C72410214010002D4000114FF00F4A413F4BCF2C80B010201200203020148040504F8F28308D71820D31FD31FD31F02F823BBF264ED44D0D31FD31FD3FFF404D15143BAF2A15151BAF2A205F901541064F910F2A3F80024A4C8CB1F5240CB1F5230CBFF5210F400C9ED54F80F01D30721C0009F6C519320D74A96D307D402FB00E830E021C001E30021C002E30001C0039130E30D03A4C8CB1F12CB1FCBFF1011121302E6D001D0D3032171B0925F04E022D749C120925F04E002D31F218210706C7567BD22821064737472BDB0925F05E003FA403020FA4401C8CA07CBFFC9D0ED44D0810140D721F404305C810108F40A6FA131B3925F07E005D33FC8258210706C7567BA923830E30D03821064737472BA925F06E30D06070201200809007801FA00F40430F8276F2230500AA121BEF2E0508210706C7567831EB17080185004CB0526CF1658FA0219F400CB6917CB1F5260CB3F20C98040FB0006008A5004810108F45930ED44D0810140D720C801CF16F400C9ED540172B08E23821064737472831EB17080185005CB055003CF1623FA0213CB6ACB1FCB3FC98040FB00925F03E20201200A0B0059BD242B6F6A2684080A06B90FA0218470D4080847A4937D29910CE6903E9FF9837812801B7810148987159F31840201580C0D0011B8C97ED44D0D70B1F8003DB29DFB513420405035C87D010C00B23281F2FFF274006040423D029BE84C600201200E0F0019ADCE76A26840206B90EB85FFC00019AF1DF6A26840106B90EB858FC0006ED207FA00D4D422F90005C8CA0715CBFFC9D077748018C8CB05CB0222CF165005FA0214CB6B12CCCCC973FB00C84014810108F451F2A7020070810108D718FA00D33FC8542047810108F451F2A782106E6F746570748018C8CB05CB025006CF165004FA0214CB6A12CB1FCB3FC973FB0002006C810108D718FA00D33F305224810108F459F2A782106473747270748018C8CB05CB025005CF165003FA0213CB6ACB1F12CB3FC973FB00000AF400C9ED54696225E5"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc),this.methods.deployAndInstallPlugin=e=>n.createMethod(t,this.deployAndInstallPlugin(e)),this.methods.installPlugin=e=>n.createMethod(t,this.installPlugin(e)),this.methods.removePlugin=e=>n.createMethod(t,this.removePlugin(e)),this.methods.getPublicKey=this.getPublicKey.bind(this),this.methods.getWalletId=this.getWalletId.bind(this),this.methods.isPluginInstalled=this.isPluginInstalled.bind(this),this.methods.getPluginsList=this.getPluginsList.bind(this)}getName(){return"v4R2"}createSigningMessage(t,e){t=t||0;const r=new i;if(r.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)r.bits.writeBit(1);else{const t=new Date,e=Math.floor(t.getTime()/1e3);r.bits.writeUint(e+60,32)}return r.bits.writeUint(t,32),e||r.bits.writeUint(0,8),r}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t.bits.writeUint(0,1),t}async deployAndInstallPlugin(t){const{secretKey:e,seqno:r,pluginWc:i,amount:n,stateInit:o,body:s}=t,a=this.createSigningMessage(r,!0);return a.bits.writeUint(1,8),a.bits.writeInt(i,8),a.bits.writeGrams(n),a.refs.push(o),a.refs.push(s),this.createExternalMessage(a,e,r,!1)}async _setPlugin(t,e){const{secretKey:r,seqno:i,amount:n,queryId:s}=t,a=new o(t.pluginAddress),u=this.createSigningMessage(i,!0);return u.bits.writeUint(e?2:3,8),u.bits.writeInt(a.wc,8),u.bits.writeBytes(a.hashPart),u.bits.writeGrams(n||h(.1)),u.bits.writeUint(s||0,64),this.createExternalMessage(u,r,i,!1)}async installPlugin(t){return this._setPlugin(t,!0)}async removePlugin(t){return this._setPlugin(t,!1)}async getWalletId(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_subwallet_id")).toNumber()}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}async isPluginInstalled(t){t=new o(t);const e="0x"+s(t.hashPart),r=await this.getAddress();return!(await this.provider.call2(r.toString(),"is_plugin_installed",[["num",t.wc],["num",e]])).isZero()}async getPluginsList(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_plugin_list")).map((t=>t[0].toNumber()+":"+t[1].toString(16)))}}}},(t,e,r)=>{const{Cell:i}=r(19),{Address:n,BN:o,toNano:s,bytesToHex:a,hexToBytes:h,nacl:u,stringToBytes:l,bytesToBase64:c,base64ToBytes:f}=r(1),{Contract:d}=r(23),{WalletContract:p}=r(29);class m extends p{constructor(t,e){e.code=i.oneFromBoc("B5EE9C7241021E01000261000114FF00F4A413F4BCF2C80B010201200203020148040501F2F28308D71820D31FD31FD31F802403F823BB13F2F2F003802251A9BA1AF2F4802351B7BA1BF2F4801F0BF9015410C5F9101AF2F4F8005057F823F0065098F823F0062071289320D74A8E8BD30731D4511BDB3C12B001E8309229A0DF72FB02069320D74A96D307D402FB00E8D103A4476814154330F004ED541D0202CD0607020120131402012008090201200F100201200A0B002D5ED44D0D31FD31FD3FFD3FFF404FA00F404FA00F404D1803F7007434C0C05C6C2497C0F83E900C0871C02497C0F80074C7C87040A497C1383C00D46D3C00608420BABE7114AC2F6C2497C338200A208420BABE7106EE86BCBD20084AE0840EE6B2802FBCBD01E0C235C62008087E4055040DBE4404BCBD34C7E00A60840DCEAA7D04EE84BCBD34C034C7CC0078C3C412040DD78CA00C0D0E00130875D27D2A1BE95B0C60000C1039480AF00500161037410AF0050810575056001010244300F004ED540201201112004548E1E228020F4966FA520933023BB9131E2209835FA00D113A14013926C21E2B3E6308003502323287C5F287C572FFC4F2FFFD00007E80BD00007E80BD00326000431448A814C4E0083D039BE865BE803444E800A44C38B21400FE809004E0083D10C06002012015160015BDE9F780188242F847800C02012017180201481B1C002DB5187E006D88868A82609E00C6207E00C63F04EDE20B30020158191A0017ADCE76A268699F98EB85FFC00017AC78F6A268698F98EB858FC00011B325FB513435C2C7E00017B1D1BE08E0804230FB50F620002801D0D3030178B0925B7FE0FA4031FA403001F001A80EDAA4"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc),this.methods.getPublicKey=this.getPublicKey.bind(this),this.methods.getWalletId=this.getWalletId.bind(this),this.methods.getLiquidBalance=this.getLiquidBalance.bind(this),this.methods.getNominalRestrictedBalance=this.getNominalRestrictedBalance.bind(this),this.methods.getNominalLockedBalance=this.getNominalLockedBalance.bind(this)}getName(){return"lockup-0.1"}createSigningMessage(t,e){t=t||0;const r=new i;if(r.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)r.bits.writeBit(1);else{const t=new Date,e=Math.floor(t.getTime()/1e3);r.bits.writeUint(e+60,32)}return r.bits.writeUint(t,32),r}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t.bits.writeBytes(f(this.options.config.config_public_key)),this.options.config.allowed_destinations?(t.bits.writeUint(1,1),t.refs.push(i.oneFromBoc(f(this.options.config.allowed_destinations)))):t.bits.writeUint(0,1),t.bits.writeGrams(0),t.bits.writeUint(0,1),t.bits.writeGrams(0),t.bits.writeUint(0,1),t}async getWalletId(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_subwallet_id")).toNumber()}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}async getLiquidBalance(){const t=await this.getBalances();return t[0]-t[1]-t[2]}async getNominalRestrictedBalance(){return await this.getBalances()[1]}async getNominalLockedBalance(){return await this.getBalances()[2]}async getBalances(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_balances")}}t.exports.default={LockupWalletV1:m,all:{"lockup-0.1":m},list:[m]}},(t,e,r)=>{const{NftCollection:i}=r(36),{NftItem:n}=r(38),{NftMarketplace:o}=r(39),{NftSale:s}=r(40);t.exports.default={NftCollection:i,NftItem:n,NftMarketplace:o,NftSale:s}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{Address:o,bytesToBase64:s}=r(1),{parseAddress:a}=r(37),{createOffchainUriCell:h,serializeUri:u,parseOffchainUriCell:l,getRoyaltyParams:c}=r(37);t.exports={NftCollection:class extends i{constructor(t,e){if(e.wc=0,e.code=e.code||n.oneFromBoc("B5EE9C724102140100021F000114FF00F4A413F4BCF2C80B0102016202030202CD04050201200E0F04E7D10638048ADF000E8698180B8D848ADF07D201800E98FE99FF6A2687D20699FEA6A6A184108349E9CA829405D47141BAF8280E8410854658056B84008646582A802E78B127D010A65B509E58FE59F80E78B64C0207D80701B28B9E382F970C892E000F18112E001718112E001F181181981E0024060708090201200A0B00603502D33F5313BBF2E1925313BA01FA00D43028103459F0068E1201A44343C85005CF1613CB3FCCCCCCC9ED54925F05E200A6357003D4308E378040F4966FA5208E2906A4208100FABE93F2C18FDE81019321A05325BBF2F402FA00D43022544B30F00623BA9302A402DE04926C21E2B3E6303250444313C85005CF1613CB3FCCCCCCC9ED54002C323401FA40304144C85005CF1613CB3FCCCCCCC9ED54003C8E15D4D43010344130C85005CF1613CB3FCCCCCCC9ED54E05F04840FF2F00201200C0D003D45AF0047021F005778018C8CB0558CF165004FA0213CB6B12CCCCC971FB008002D007232CFFE0A33C5B25C083232C044FD003D0032C03260001B3E401D3232C084B281F2FFF2742002012010110025BC82DF6A2687D20699FEA6A6A182DE86A182C40043B8B5D31ED44D0FA40D33FD4D4D43010245F04D0D431D430D071C8CB0701CF16CCC980201201213002FB5DAFDA89A1F481A67FA9A9A860D883A1A61FA61FF480610002DB4F47DA89A1F481A67FA9A9A86028BE09E008E003E00B01A500C6E"),e.royalty>1)throw new Error("royalty > 1");e.royaltyBase=1e3,e.royaltyFactor=Math.floor(e.royalty*e.royaltyBase),super(t,e),this.methods.getCollectionData=this.getCollectionData.bind(this),this.methods.getNftItemAddressByIndex=this.getNftItemAddressByIndex.bind(this),this.methods.getNftItemContent=this.getNftItemContent.bind(this),this.methods.getRoyaltyParams=this.getRoyaltyParams.bind(this)}createContentCell(t){const e=h(t.collectionContentUri),r=new n;r.bits.writeBytes(u(t.nftItemContentBaseUri));const i=new n;return i.refs[0]=e,i.refs[1]=r,i}createRoyaltyCell(t){const e=new n;return e.bits.writeUint(t.royaltyFactor,16),e.bits.writeUint(t.royaltyBase,16),e.bits.writeAddress(t.royaltyAddress),e}createDataCell(){const t=new n;return t.bits.writeAddress(this.options.ownerAddress),t.bits.writeUint(0,64),t.refs[0]=this.createContentCell(this.options),t.refs[1]=n.oneFromBoc(this.options.nftItemCodeHex),t.refs[2]=this.createRoyaltyCell(this.options),t}createMintBody(t){const e=new n;e.bits.writeUint(1,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeUint(t.itemIndex,64),e.bits.writeCoins(t.amount);const r=new n;r.bits.writeAddress(t.itemOwnerAddress);const i=new n;return i.bits.writeBytes(u(t.itemContentUri)),r.refs[0]=i,e.refs[0]=r,e}createGetRoyaltyParamsBody(t){const e=new n;return e.bits.writeUint(1765620048,32),e.bits.writeUint(t.queryId||0,64),e}createChangeOwnerBody(t){const e=new n;return e.bits.writeUint(3,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.newOwnerAddress),e}createEditContentBody(t){if(t.royalty>1)throw new Error("royalty > 1");t.royaltyBase=1e3,t.royaltyFactor=Math.floor(t.royalty*t.royaltyBase);const e=new n;return e.bits.writeUint(4,32),e.bits.writeUint(t.queryId||0,64),e.refs[0]=this.createContentCell(t),e.refs[1]=this.createRoyaltyCell(t),e}async getCollectionData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_collection_data"),r=e[0].toNumber(),i=l(e[1]);return{nextItemIndex:r,ownerAddress:a(e[2]),collectionContentUri:i}}async getNftItemContent(t){const e=await this.getAddress(),r=await t.getData();if(r.isInitialized){const t=await this.provider.call2(e.toString(),"get_nft_content",[["num",r.index],["tvm.Cell",s(await r.contentCell.toBoc(!1))]]);r.contentUri=l(t),delete r.contentCell}return r}async getNftItemAddressByIndex(t){const e=await this.getAddress(),r=await this.provider.call2(e.toString(),"get_nft_address_by_index",[["num",t]]);return a(r)}async getRoyaltyParams(){const t=await this.getAddress();return c(this.provider,t.toString())}}}},(t,e,r)=>{const{base64ToBytes:i,Address:n}=r(1),{Cell:o}=r(19),s=t=>(new TextEncoder).encode(encodeURI(t)),a=t=>(new TextDecoder).decode(t),h=(t,e,r)=>{let i=BigInt(0);for(let n=0;n{let e=h(t.bits,3,8);e>BigInt(127)&&(e-=BigInt(256));const r=h(t.bits,11,256);if(e.toString(10)+":"+r.toString(16)=="0:0")return null;const i=e.toString(10)+":"+r.toString(16).padStart(64,"0");return new n(i)};t.exports={SNAKE_DATA_PREFIX:0,CHUNK_DATA_PREFIX:1,ONCHAIN_CONTENT_PREFIX:0,OFFCHAIN_CONTENT_PREFIX:1,parseAddress:u,serializeUri:s,parseUri:a,createOffchainUriCell:t=>{const e=new o;return e.bits.writeUint(1,8),e.bits.writeBytes(s(t)),e},parseOffchainUriCell:t=>{let e=0,r=t;for(;r;)e+=r.bits.array.length,r=r.refs[0];const i=new Uint8Array(e);for(e=0,r=t;r;)i.set(r.bits.array,e),e+=r.bits.array.length,r=r.refs[0];return a(i.slice(1))},getRoyaltyParams:async(t,e)=>{const r=await t.call2(e,"royalty_params"),i=r[0].toNumber(),n=r[1].toNumber();return{royalty:i/n,royaltyBase:n,royaltyFactor:i,royaltyAddress:u(r[2])}}}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{Address:o,BN:s}=r(1),{parseAddress:a,getRoyaltyParams:h}=r(37),{parseOffchainUriCell:u}=r(37),l="B5EE9C7241020D010001D0000114FF00F4A413F4BCF2C80B0102016202030202CE04050009A11F9FE00502012006070201200B0C02D70C8871C02497C0F83434C0C05C6C2497C0F83E903E900C7E800C5C75C87E800C7E800C3C00812CE3850C1B088D148CB1C17CB865407E90350C0408FC00F801B4C7F4CFE08417F30F45148C2EA3A1CC840DD78C9004F80C0D0D0D4D60840BF2C9A884AEB8C097C12103FCBC20080900113E910C1C2EBCB8536001F65135C705F2E191FA4021F001FA40D20031FA00820AFAF0801BA121945315A0A1DE22D70B01C300209206A19136E220C2FFF2E192218E3E821005138D91C85009CF16500BCF16712449145446A0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00104794102A375BE20A00727082108B77173505C8CBFF5004CF1610248040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB000082028E3526F0018210D53276DB103744006D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093303234E25502F003003B3B513434CFFE900835D27080269FC07E90350C04090408F80C1C165B5B60001D00F232CFD633C58073C5B3327B5520BF75041B";class c extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc(l),super(t,e),this.methods.getData=this.getData.bind(this)}createDataCell(){const t=new n;return t.bits.writeUint(this.options.index,64),t.bits.writeAddress(this.options.collectionAddress),t}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_nft_data"),r=-1===e[0].toNumber(),i=e[1].toNumber(),n=a(e[2]),o=r?a(e[3]):null,s=e[4];return{isInitialized:r,index:i,collectionAddress:n,ownerAddress:o,contentCell:s,contentUri:r&&null===n?u(s):null}}async createTransferBody(t){const e=new n;return e.bits.writeUint(1607220500,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.newOwnerAddress),e.bits.writeAddress(t.responseAddress),e.bits.writeBit(!1),e.bits.writeCoins(t.forwardAmount||new s(0)),e.bits.writeBit(!1),t.forwardPayload&&e.bits.writeBytes(t.forwardPayload),e}createGetStaticDataBody(t){const e=new n;return e.bits.writeUint(801842850,32),e.bits.writeUint(t.queryId||0,64),e}async getRoyaltyParams(){const t=await this.getAddress();return h(this.provider,t.toString())}}c.codeHex=l,t.exports={NftItem:c}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{Address:o}=r(1),{parseAddress:s}=r(37);t.exports={NftMarketplace:class extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc("B5EE9C7241010401006D000114FF00F4A413F4BCF2C80B01020120020300AAD23221C700915BE0D0D3030171B0915BE0FA40ED44D0FA403012C705F2E19101D31F01C0018E2BFA003001D4D43021F90070C8CA07CBFFC9D077748018C8CB05CB0258CF165004FA0213CB6BCCCCC971FB00915BE20004F2308EF7CCE7"),super(t,e)}createDataCell(){const t=new n;return t.bits.writeAddress(this.options.ownerAddress),t}}}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{parseAddress:o}=r(37),{BN:s}=r(1),a="B5EE9C7241020A010001B4000114FF00F4A413F4BCF2C80B01020120020302014804050004F2300202CD0607002FA03859DA89A1F481F481F481F401A861A1F401F481F4006101F7D00E8698180B8D8492F82707D201876A2687D207D207D207D006A18116BA4E10159C71D991B1B2990E382C92F837028916382F970FA01698FC1080289C6C8895D7970FAE99F98FD2018201A642802E78B2801E78B00E78B00FD016664F6AA701363804C9B081B2299823878027003698FE99F9810E000C92F857010C0801F5D41081DCD650029285029185F7970E101E87D007D207D0018384008646582A804E78B28B9D090D0A85AD08A500AFD010AE5B564B8FD80384008646582AC678B2803FD010B65B564B8FD80384008646582A802E78B00FD0109E5B564B8FD80381041082FE61E8A10C00C646582A802E78B117D010A65B509E58F8A40900C8C0029A3110471036454012F004E032363704C0038E4782103B9ACA0015BEF2E1C95312C70559C705B1F2E1CA702082105FCC3D14218010C8CB055006CF1622FA0215CB6A14CB1F14CB3F21CF1601CF16CA0021FA02CA00C98100A0FB00E05F06840FF2F0002ACB3F22CF1658CF16CA0021FA02CA00C98100A0FB00AECABAD1";class h extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc(a),super(t,e),this.methods.getData=this.getData.bind(this)}createDataCell(){const t=new n;t.bits.writeAddress(this.options.marketplaceAddress),t.bits.writeAddress(this.options.nftAddress),t.bits.writeAddress(null),t.bits.writeCoins(this.options.fullPrice);const e=new n;return e.bits.writeCoins(this.options.marketplaceFee),e.bits.writeAddress(this.options.royaltyAddress),e.bits.writeCoins(this.options.royaltyAmount),t.refs[0]=e,t}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_sale_data");return{marketplaceAddress:o(e[0]),nftAddress:o(e[1]),nftOwnerAddress:o(e[2]),fullPrice:e[3],marketplaceFee:e[4],royaltyAddress:o(e[5]),royaltyAmount:e[6]}}async createCancelBody(t){const e=new n;return e.bits.writeUint(3,32),e.bits.writeUint(t.queryId||0,64),e}}h.codeHex=a,t.exports={NftSale:h}},(t,e,r)=>{const{JettonMinter:i}=r(42),{JettonWallet:n}=r(43);t.exports.default={JettonMinter:i,JettonWallet:n}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{createOffchainUriCell:o,parseOffchainUriCell:s,parseAddress:a}=r(37),{Address:h,BN:u,bytesToBase64:l}=r(1);t.exports={JettonMinter:class extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc("B5EE9C72410209010001AA000114FF00F4A413F4BCF2C80B0102016202030202CC040502037A60070801D5D9910E38048ADF068698180B8D848ADF07D201800E98FE99FF6A2687D007D206A6A18400AA9385D47181A9AA8AAE382F9702480FD207D006A18106840306B90FD001812881A28217804502A906428027D012C678B666664F6AA7041083DEECBEF0BDD71812F83C207F9784060093DFC142201B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064907C80383A6465816503E5FFE4E83BC00C646582AC678B28027D0109E5B589666664B8FD80400FC03FA00FA40F82854120870542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D05008C705F2E04A12A1035024C85004FA0258CF16CCCCC9ED5401FA403020D70B01C3008E1F8210D53276DB708010C8CB055003CF1622FA0212CB6ACB1FCB3FC98042FB00915BE2007DADBCF6A2687D007D206A6A183618FC1400B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064FC80383A6465816503E5FFE4E840001FAF16F6A2687D007D206A6A183FAA9040F6B06B3C"),super(t,e)}createDataCell(){const t=new n;return t.bits.writeCoins(0),t.bits.writeAddress(this.options.adminAddress),t.refs[0]=o(this.options.jettonContentUri),t.refs[1]=n.oneFromBoc(this.options.jettonWalletCodeHex),t}createMintBody(t){const e=new n;e.bits.writeUint(21,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.destination),e.bits.writeCoins(t.amount);const r=new n;return r.bits.writeUint(395134233,32),r.bits.writeUint(t.queryId||0,64),r.bits.writeCoins(t.jettonAmount),r.bits.writeAddress(null),r.bits.writeAddress(null),r.bits.writeCoins(new u(0)),r.bits.writeBit(!1),e.refs[0]=r,e}async getJettonData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_jetton_data");return{totalSupply:e[0],isMutable:-1===e[1].toNumber(),adminAddress:a(e[2]),jettonContentUri:s(e[3]),tokenWalletCode:e[4]}}async getJettonWalletAddress(t){const e=await this.getAddress(),r=new n;r.bits.writeAddress(t);const i=await this.provider.call2(e.toString(),"get_wallet_address",[["tvm.Slice",l(await r.toBoc(!1))]]);return a(i)}}}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{parseAddress:o}=r(37),{BN:s}=r(1),a="B5EE9C7241021101000319000114FF00F4A413F4BCF2C80B0102016202030202CC0405001BA0F605DA89A1F401F481F481A8610201D40607020148080900BB0831C02497C138007434C0C05C6C2544D7C0FC02F83E903E900C7E800C5C75C87E800C7E800C00B4C7E08403E29FA954882EA54C4D167C0238208405E3514654882EA58C4CD00CFC02780D60841657C1EF2EA4D67C02B817C12103FCBC2000113E910C1C2EBCB853600201200A0B0201200F1001F500F4CFFE803E90087C007B51343E803E903E90350C144DA8548AB1C17CB8B04A30BFFCB8B0950D109C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C032483E401C1D3232C0B281F2FFF274013E903D010C7E801DE0063232C1540233C59C3E8085F2DAC4F3208405E351467232C7C6600C02F13B51343E803E903E90350C01F4CFFE80145468017E903E9014D6B1C1551CDB1C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C0327E401C1D3232C0B281F2FFF274140331C146EC7CB8B0C27E8020822625A020822625A02806A8486544124E17C138C34975C2C070C00930802C200D0E008ECB3F5007FA0222CF165006CF1625FA025003CF16C95005CC07AA0013A08208989680AA008208989680A0A014BCF2E2C504C98040FB001023C85004FA0258CF1601CF16CCC9ED54006C5219A018A182107362D09CC8CB1F5240CB3F5003FA0201CF165007CF16C9718018C8CB0525CF165007FA0216CB6A15CCC971FB00103400828E2A820898968072FB028210D53276DB708010C8CB055008CF165005FA0216CB6A13CB1F13CB3FC972FB0058926C33E25502C85004FA0258CF1601CF16CCC9ED5400DB3B51343E803E903E90350C01F4CFFE803E900C145468549271C17CB8B049F0BFFCB8B0A0822625A02A8005A805AF3CB8B0E0841EF765F7B232C7C572CFD400FE8088B3C58073C5B25C60043232C14933C59C3E80B2DAB33260103EC01004F214013E809633C58073C5B3327B55200083200835C87B51343E803E903E90350C0134C7E08405E3514654882EA0841EF765F784EE84AC7CB8B174CFCC7E800C04E81408F214013E809633C58073C5B3327B55204F664B79";class h extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc(a),super(t,e)}async createTransferBody(t){const e=new n;return e.bits.writeUint(260734629,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeCoins(t.jettonAmount),e.bits.writeAddress(t.toAddress),e.bits.writeAddress(t.responseAddress),e.bits.writeBit(!1),e.bits.writeCoins(t.forwardAmount||new s(0)),e.bits.writeBit(!1),t.forwardPayload&&e.bits.writeBytes(t.forwardPayload),e}async createBurnBody(t){const e=new n;return e.bits.writeUint(1499400124,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeCoins(t.jettonAmount),e.bits.writeAddress(t.responseAddress),e}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_wallet_data");return{balance:e[0],ownerAddress:o(e[1]),jettonMinterAddress:o(e[2]),jettonWalletCode:e[3]}}}h.codeHex=a,t.exports={JettonWallet:h}},(t,e,r)=>{const{BlockSubscription:i}=r(45),{InMemoryBlockStorage:n}=r(46);t.exports={BlockSubscription:i,InMemoryBlockStorage:n}},t=>{const e=t=>({workchain:t.workchain,shardId:t.shard,shardBlockNumber:t.seqno});t.exports={BlockSubscription:class{constructor(t,e,r,i){this.provider=t,this.storage=e,this.onBlock=r,this.startMcBlockNumber=i?i.startMcBlockNumber:void 0,this.mcInterval=(i?i.mcInterval:void 0)||1e4,this.shardsInterval=(i?i.shardsInterval:void 0)||1e3}async start(){if(this.stop(),!this.startMcBlockNumber&&(this.startMcBlockNumber=(await this.provider.getMasterchainInfo()).last.seqno,!this.startMcBlockNumber))throw new Error("Cannot get start mc block number from provider");const t=await this.provider.getMasterchainBlockHeader(this.startMcBlockNumber);if(this.startLT=t.end_lt,!this.startLT)throw new Error("Cannot get startLT from provider");let r=!1;const i=async()=>{if(!r){r=!0;try{const t=await this.storage.getLastMasterchainBlockNumber()||this.startMcBlockNumber;if(!t)throw new Error("no init masterchain block in storage");const r=(await this.provider.getMasterchainInfo()).last.seqno;if(!r)throw new Error("invalid last masterchain block from provider");for(let i=t+1;ii()),this.mcInterval),i();let n=!1;const o=async()=>{if(!n){n=!0;try{const t=await this.storage.getUnprocessedShardBlock();if(t){const{workchain:r,shardId:i,shardBlockNumber:n}=t,o=await this.provider.getBlockHeader(r,i,n);if(o.end_lto()),this.shardsInterval)}stop(){clearInterval(this.mcIntervalId),clearInterval(this.shardsIntervalId)}}}},t=>{t.exports={InMemoryBlockStorage:class{constructor(t){this.masterchainBlocks={},this.shardchainBlocks={},this.logFunction=t}async insertShardBlocks(t){for(const{workchain:e,shardId:r,shardBlockNumber:i}of t)void 0===this.shardchainBlocks[e+"_"+r+"_"+i]&&(this.logFunction&&this.logFunction("insert shard "+e+" "+r+" "+i),this.shardchainBlocks[e+"_"+r+"_"+i]=!1)}async insertBlocks(t,e){if(this.logFunction&&this.logFunction("mc processed "+t),void 0!==this.masterchainBlocks[t])throw new Error("mc already exists "+t);this.masterchainBlocks[t]=!0,await this.insertShardBlocks(e)}async getLastMasterchainBlockNumber(){return Object.keys(this.masterchainBlocks).map((t=>Number(t))).sort(((t,e)=>e-t))[0]}async setBlockProcessed(t,e,r,i){if(this.logFunction&&this.logFunction("shard processed "+t+" "+e+" "+r),void 0===this.shardchainBlocks[t+"_"+e+"_"+r])throw new Error("shard not exists "+t+"_"+e+"_"+r);this.shardchainBlocks[t+"_"+e+"_"+r]=!0,await this.insertShardBlocks(i)}async getUnprocessedShardBlock(){for(let t in this.shardchainBlocks)if(!1===this.shardchainBlocks[t]){const e=t.split("_");return{workchain:Number(e[0]),shardId:e[1],shardBlockNumber:Number(e[2])}}}}}},(t,e,r)=>{const{Contract:i}=r(23),{Cell:n}=r(19),{hexToBytes:o,BN:s,nacl:a,bytesToBase64:h}=r(1);t.exports={SubscriptionContract:class extends i{constructor(t,e){e.code=n.oneFromBoc("B5EE9C7241020F01000262000114FF00F4A413F4BCF2C80B0102012002030201480405036AF230DB3C5335A127A904F82327A128A90401BC5135A0F823B913B0F29EF800725210BE945387F0078E855386DB3CA4E2F82302DB3C0B0C0D0202CD06070121A0D0C9B67813F488DE0411F488DE0410130B048FD6D9E05E8698198FD201829846382C74E2F841999E98F9841083239BA395D497803F018B841083AB735BBED9E702984E382D9C74688462F863841083AB735BBED9E70156BA4E09040B0A0A080269F10FD22184093886D9E7C12C1083239BA39384008646582A803678B2801FD010A65B5658F89659FE4B9FD803FC1083239BA396D9E40E0A04F08E8D108C5F0C708210756E6B77DB3CE00AD31F308210706C7567831EB15210BA8F48305324A126A904F82326A127A904BEF27109FA4430A619F833D078D721D70B3F5260A11BBE8E923036F82370708210737562732759DB3C5077DE106910581047103645135042DB3CE0395F076C2232821064737472BA0A0A0D09011A8E897F821064737472DB3CE0300A006821B39982100400000072FB02DE70F8276F118010C8CB055005CF1621FA0214F40013CB6912CB1F830602948100A032DEC901FB000030ED44D0FA40FA40FA00D31FD31FD31FD31FD31FD307D31F30018021FA443020813A98DB3C01A619F833D078D721D70B3FA070F8258210706C7567228018C8CB055007CF165004FA0215CB6A12CB1F13CB3F01FA02CB00C973FB000E0040C8500ACF165008CF165006FA0214CB1F12CB1FCB1FCB1FCB1FCB07CB1FC9ED54005801A615F833D020D70B078100D1BA95810088D721DED307218100DDBA028100DEBA12B1F2E047D33F30A8AB0FE5855AB4"),super(t,e),this.methods.pay=()=>i.createMethod(t,this.createPayExternalMessage()),this.methods.getSubscriptionData=this.getSubscriptionData.bind(this)}createDataCell(){const t=new n;return t.bits.writeAddress(this.options.wallet),t.bits.writeAddress(this.options.beneficiary),t.bits.writeGrams(this.options.amount),t.bits.writeUint(this.options.period,32),t.bits.writeUint(this.options.startAt,32),t.bits.writeUint(this.options.timeout,32),t.bits.writeUint(0,32),t.bits.writeUint(0,32),t.bits.writeUint(0,8),t.bits.writeUint(this.options.subscriptionId,32),t}createBody(){const t=new n;return t.bits.writeUint(new s(1886156135).add(new s(2147483648)),32),t}createSelfDestructBody(){const t=new n;return t.bits.writeUint(1685288050,32),t}async getSubscriptionData(){const t=t=>t[0].toNumber()+":"+t[1].toString(16),e=await this.getAddress(),r=await this.provider.call2(e.toString(),"get_subscription_data");return{wallet:t(r[0]),beneficiary:t(r[1]),amount:r[2],period:r[3].toNumber(),startAt:r[4].toNumber(),timeout:r[5].toNumber(),lastPayment:r[6].toNumber(),lastRequest:r[7].toNumber(),failedAttempts:r[8].toNumber(),subscriptionId:r[9].toNumber()}}async createPayExternalMessage(){const t=await this.getAddress(),e=i.createExternalMessageHeader(t),r=i.createCommonMsgInfo(e,null,null),o=new n;return o.bits.writeUint(Math.floor(Date.now()/1e3),64),{address:t,message:r,body:o}}}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>l});var i=r(49),n=r(52),o=r(53),s=r(101),a=r(51),h=r(102),u=r(9).Buffer;class l extends i.default{constructor(t,e){super(),this.device=void 0,this.deviceModel=void 0,this.channel=Math.floor(65535*Math.random()),this.packetSize=64,this.interfaceNumber=void 0,this._disconnectEmitted=!1,this._emitDisconnect=t=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",t))},this.exchange=t=>this.exchangeAtomicImpl((async()=>{const{channel:e,packetSize:r}=this;(0,s.log)("apdu","=> "+t.toString("hex"));const i=(0,n.default)(e,r),o=i.makeBlocks(t);for(let t=0;t{if(t&&t.message&&t.message.includes("disconnected"))throw this._emitDisconnect(t),new a.DisconnectedDeviceDuringOperation(t.message);throw t})),this.device=t,this.interfaceNumber=e,this.deviceModel=(0,o.identifyUSBProductId)(t.productId)}static async request(){const t=await(0,h.requestLedgerDevice)();return l.open(t)}static async openConnected(){const t=await(0,h.getLedgerDevices)();return 0===t.length?null:l.open(t[0])}static async open(t){await t.open(),null===t.configuration&&await t.selectConfiguration(1),await c(t);const e=t.configurations[0].interfaces.find((({alternates:t})=>t.some((t=>255===t.interfaceClass))));if(!e)throw new a.TransportInterfaceNotAvailable("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.");const r=e.interfaceNumber;try{await t.claimInterface(r)}catch(e){throw await t.close(),new a.TransportInterfaceNotAvailable(e.message)}const i=new l(t,r),n=e=>{t===e.device&&(navigator.usb.removeEventListener("disconnect",n),i._emitDisconnect(new a.DisconnectedDevice))};return navigator.usb.addEventListener("disconnect",n),i}async close(){await this.exchangeBusyPromise,await this.device.releaseInterface(this.interfaceNumber),await c(this.device),await this.device.close()}setScrambleKey(){}}async function c(t){try{await t.reset()}catch(t){console.warn(t)}}l.isSupported=h.isSupported,l.list=h.getLedgerDevices,l.listen=t=>{let e=!1;return(0,h.getFirstLedgerDevice)().then((r=>{if(!e){const e=(0,o.identifyUSBProductId)(r.productId);t.next({type:"add",descriptor:r,deviceModel:e}),t.complete()}}),(e=>{window.DOMException&&e instanceof window.DOMException&&18===e.code?t.error(new a.TransportWebUSBGestureRequired(e.message)):t.error(new a.TransportOpenUserCancelled(e.message))})),{unsubscribe:function(){e=!0}}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{StatusCodes:()=>o.StatusCodes,TransportError:()=>o.TransportError,TransportStatusError:()=>o.TransportStatusError,default:()=>a,getAltStatusMessage:()=>o.getAltStatusMessage});var i=r(50),n=r.n(i),o=r(51),s=r(9).Buffer;class a{constructor(){this.exchangeTimeout=3e4,this.unresponsiveTimeout=15e3,this.deviceModel=null,this._events=new(n()),this.send=async(t,e,r,i,n=s.alloc(0),a=[o.StatusCodes.OK])=>{if(n.length>=256)throw new o.TransportError("data.length exceed 256 bytes limit. Got: "+n.length,"DataLengthTooBig");const h=await this.exchange(s.concat([s.from([t,e,r,i]),s.from([n.length]),n])),u=h.readUInt16BE(h.length-2);if(!a.some((t=>t===u)))throw new o.TransportStatusError(u);return h},this.exchangeBusyPromise=void 0,this.exchangeAtomicImpl=async t=>{if(this.exchangeBusyPromise)throw new o.TransportRaceCondition("An action was already pending on the Ledger device. Please deny or reconnect.");let e;const r=new Promise((t=>{e=t}));this.exchangeBusyPromise=r;let i=!1;const n=setTimeout((()=>{i=!0,this.emit("unresponsive")}),this.unresponsiveTimeout);try{const r=await t();return i&&this.emit("responsive"),r}finally{clearTimeout(n),e&&e(),this.exchangeBusyPromise=null}},this._appAPIlock=null}exchange(t){throw new Error("exchange not implemented")}setScrambleKey(t){}close(){return Promise.resolve()}on(t,e){this._events.on(t,e)}off(t,e){this._events.removeListener(t,e)}emit(t,...e){this._events.emit(t,...e)}setDebugMode(){console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.")}setExchangeTimeout(t){this.exchangeTimeout=t}setExchangeUnresponsiveTimeout(t){this.unresponsiveTimeout=t}static create(t=3e3,e){return new Promise(((r,i)=>{let n=!1;const s=this.listen({next:e=>{n=!0,s&&s.unsubscribe(),a&&clearTimeout(a),this.open(e.descriptor,t).then(r,i)},error:t=>{a&&clearTimeout(a),i(t)},complete:()=>{a&&clearTimeout(a),n||i(new o.TransportError(this.ErrorMessage_NoDeviceFound,"NoDeviceFound"))}}),a=e?setTimeout((()=>{s.unsubscribe(),i(new o.TransportError(this.ErrorMessage_ListenTimeout,"ListenTimeout"))}),e):null}))}decorateAppAPIMethods(t,e,r){for(let i of e)t[i]=this.decorateAppAPIMethod(i,t[i],t,r)}decorateAppAPIMethod(t,e,r,i){return async(...n)=>{const{_appAPIlock:s}=this;if(s)return Promise.reject(new o.TransportError("Ledger Device is busy (lock "+s+")","TransportLocked"));try{return this._appAPIlock=t,this.setScrambleKey(i),await e.apply(r,n)}finally{this._appAPIlock=null}}}}a.isSupported=void 0,a.list=void 0,a.listen=void 0,a.open=void 0,a.ErrorMessage_ListenTimeout="No Ledger device found (timeout)",a.ErrorMessage_NoDeviceFound="No Ledger device found"},t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,o),i(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),r([].slice.call(arguments))}m(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&m(t,"error",e,{once:!0})}(t,n)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(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?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,i){var n,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=h(t))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}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 c(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=l.bind(i);return n.listener=r,i.wrapFn=n,n}function f(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var h=o[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var u=h.length,l=p(h,u);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return f(this,t,!0)},o.prototype.rawListeners=function(t){return f(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AccountNameRequiredError:()=>l,AccountNotSupported:()=>c,AmountRequired:()=>f,BluetoothRequired:()=>d,BtcUnmatchedApp:()=>p,CantOpenDevice:()=>m,CantScanQRCode:()=>kt,CashAddrNotSupported:()=>g,CurrencyNotSupported:()=>v,DBNotReset:()=>Zt,DBWrongPassword:()=>Wt,DeviceAppVerifyNotSupported:()=>y,DeviceGenuineSocketEarlyClose:()=>w,DeviceHalted:()=>C,DeviceInOSUExpected:()=>A,DeviceNameInvalid:()=>B,DeviceNotGenuineError:()=>b,DeviceOnDashboardExpected:()=>M,DeviceOnDashboardUnexpected:()=>E,DeviceShouldStayInApp:()=>It,DeviceSocketFail:()=>F,DeviceSocketNoBulkStatus:()=>_,DisconnectedDevice:()=>S,DisconnectedDeviceDuringOperation:()=>D,ETHAddressNonEIP:()=>Ut,EnpointConfigError:()=>x,EthAppPleaseEnableContractData:()=>I,FeeEstimationFailed:()=>T,FeeNotLoaded:()=>Lt,FeeRequired:()=>Pt,FeeTooHigh:()=>jt,FirmwareNotRecognized:()=>R,FirmwareOrAppUpdateRequired:()=>zt,GasLessThanEstimate:()=>at,GenuineCheckFailed:()=>Kt,HardResetFail:()=>N,InvalidAddress:()=>U,InvalidAddressBecauseDestinationIsAlsoSource:()=>k,InvalidXRPTag:()=>O,LatestMCUInstalledError:()=>L,LedgerAPI4xx:()=>Ht,LedgerAPI5xx:()=>Gt,LedgerAPIError:()=>j,LedgerAPIErrorWithMessage:()=>$,LedgerAPINotAvailable:()=>q,MCUNotGenuineToDashboard:()=>pt,ManagerAppAlreadyInstalledError:()=>K,ManagerAppDepInstallRequired:()=>G,ManagerAppDepUninstallRequired:()=>z,ManagerAppRelyOnBTCError:()=>H,ManagerDeviceLockedError:()=>V,ManagerFirmwareNotEnoughSpaceError:()=>W,ManagerNotEnoughSpaceError:()=>Z,ManagerUninstallBTCDep:()=>Y,NetworkDown:()=>X,NoAccessToCamera:()=>nt,NoAddressesFound:()=>J,NoDBPathGiven:()=>Vt,NotEnoughBalance:()=>Q,NotEnoughBalanceBecauseDestinationNotCreated:()=>it,NotEnoughBalanceInParentAccount:()=>et,NotEnoughBalanceToDelegate:()=>tt,NotEnoughGas:()=>ot,NotEnoughSpendableBalance:()=>rt,NotSupportedLegacyAddress:()=>st,PairingFailed:()=>qt,PasswordIncorrectError:()=>ut,PasswordsDontMatchError:()=>ht,RecipientRequired:()=>mt,RecommendSubAccountsToEmpty:()=>lt,RecommendUndelegation:()=>ct,StatusCodes:()=>Xt,SyncError:()=>$t,TimeoutTagged:()=>ft,TransportError:()=>Yt,TransportInterfaceNotAvailable:()=>St,TransportOpenUserCancelled:()=>_t,TransportRaceCondition:()=>Dt,TransportStatusError:()=>Qt,TransportWebUSBGestureRequired:()=>xt,UnavailableTezosOriginatedAccountReceive:()=>gt,UnavailableTezosOriginatedAccountSend:()=>vt,UnexpectedBootloader:()=>dt,UnknownMCU:()=>P,UpdateFetchFileFail:()=>yt,UpdateIncorrectHash:()=>wt,UpdateIncorrectSig:()=>bt,UpdateYourApp:()=>Mt,UserRefusedAddress:()=>At,UserRefusedAllowManager:()=>Bt,UserRefusedDeviceNameChange:()=>Et,UserRefusedFirmwareUpdate:()=>Ct,UserRefusedOnDevice:()=>Ft,WebsocketConnectionError:()=>Tt,WebsocketConnectionFailed:()=>Rt,WrongAppForCurrency:()=>Ot,WrongDeviceForAccount:()=>Nt,addCustomErrorDeserializer:()=>o,createCustomErrorClass:()=>s,deserializeError:()=>a,getAltStatusMessage:()=>Jt,serializeError:()=>h});var i={},n={},o=function(t,e){n[t]=e},s=function(t){var e=function(e,r){Object.assign(this,r),this.name=t,this.message=e||t,this.stack=(new Error).stack};return e.prototype=new Error,i[t]=e,e},a=function(t){if("object"==typeof t&&t){try{var e=JSON.parse(t.message);e.message&&e.name&&(t=e)}catch(t){}var r=void 0;if("string"==typeof t.name){var o=t.name,h=n[o];if(h)r=h(t);else{var u="Error"===o?Error:i[o];u||(console.warn("deserializing an unknown class '"+o+"'"),u=s(o)),r=Object.create(u.prototype);try{for(var l in t)t.hasOwnProperty(l)&&(r[l]=t[l])}catch(t){}}}else r=new Error(t.message);return!r.stack&&Error.captureStackTrace&&Error.captureStackTrace(r,a),r}return new Error(String(t))},h=function(t){return t?"object"==typeof t?u(t,[]):"function"==typeof t?"[Function: "+(t.name||"anonymous")+"]":t:t};function u(t,e){var r={};e.push(t);for(var i=0,n=Object.keys(t);i{"use strict";var i=r(9).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(51);function o(t){const e=i.alloc(2);return e.writeUInt16BE(t,0),e}const s={data:i.alloc(0),dataLength:0,sequence:0};e.default=(t,e)=>({makeBlocks(r){let n=i.concat([o(r.length),r]);const s=e-5,a=Math.ceil(n.length/s);n=i.concat([n,i.alloc(a*s-n.length+1).fill(0)]);const h=[];for(let e=0;ea&&(o=o.slice(0,a)),{data:o,dataLength:a,sequence:h}},getReducedResult(t){if(t&&t.dataLength===t.data.length)return t.data}})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{IICCID:()=>h,IIGenericHID:()=>o,IIKeyboardHID:()=>s,IIU2F:()=>a,IIWebUSB:()=>u,getBluetoothServiceUuids:()=>w,getDeviceModel:()=>p,getInfosForServiceUuid:()=>b,identifyProductName:()=>g,identifyUSBProductId:()=>m,ledgerUSBVendorId:()=>d});var i=r(54),n=r.n(i);const o=1,s=2,a=4,h=8,u=16,l={blue:{id:"blue",productName:"Ledger Blue",productIdMM:0,legacyUsbProductId:0,usbOnly:!0,memorySize:491520,blockSize:4096,getBlockSize:t=>4096},nanoS:{id:"nanoS",productName:"Ledger Nano S",productIdMM:16,legacyUsbProductId:1,usbOnly:!0,memorySize:327680,blockSize:4096,getBlockSize:t=>n().lt(n().coerce(t),"2.0.0")?4096:2048},nanoX:{id:"nanoX",productName:"Ledger Nano X",productIdMM:64,legacyUsbProductId:4,usbOnly:!1,memorySize:2097152,blockSize:4096,getBlockSize:t=>4096,bluetoothSpec:[{serviceUuid:"d973f2e0-b19e-11e2-9e96-0800200c9a66",notifyUuid:"d973f2e1-b19e-11e2-9e96-0800200c9a66",writeUuid:"d973f2e2-b19e-11e2-9e96-0800200c9a66"},{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572"}]}},c={Blue:"blue","Nano S":"nanoS","Nano X":"nanoX"},f=Object.values(l),d=11415,p=t=>{const e=l[t];if(!e)throw new Error("device '"+t+"' does not exist");return e},m=t=>{const e=f.find((e=>e.legacyUsbProductId===t));if(e)return e;const r=t>>8;return f.find((t=>t.productIdMM===r))},g=t=>{const e=c[t];return f.find((t=>t.id===e))},v=[],y={};for(let t in l){const e=l[t],{bluetoothSpec:r}=e;if(r)for(let t=0;tv,b=t=>y[t.toLowerCase()]},(t,e,r)=>{const i=r(55);t.exports={re:i.re,src:i.src,tokens:i.t,SEMVER_SPEC_VERSION:r(56).SEMVER_SPEC_VERSION,SemVer:r(58),compareIdentifiers:r(60).compareIdentifiers,rcompareIdentifiers:r(60).rcompareIdentifiers,parse:r(61),valid:r(62),clean:r(63),inc:r(64),diff:r(65),major:r(68),minor:r(69),patch:r(70),prerelease:r(71),compare:r(67),rcompare:r(72),compareLoose:r(73),compareBuild:r(74),sort:r(75),rsort:r(76),gt:r(77),lt:r(78),eq:r(66),neq:r(79),gte:r(80),lte:r(81),cmp:r(82),coerce:r(83),Comparator:r(84),Range:r(85),satisfies:r(89),toComparators:r(90),maxSatisfying:r(91),minSatisfying:r(92),minVersion:r(93),validRange:r(94),outside:r(95),gtr:r(96),ltr:r(97),intersects:r(98),simplifyRange:r(99),subset:r(100)}},(t,e,r)=>{const{MAX_SAFE_COMPONENT_LENGTH:i}=r(56),n=r(57),o=(e=t.exports={}).re=[],s=e.src=[],a=e.t={};let h=0;const u=(t,e,r)=>{const i=h++;n(i,e),a[t]=i,s[i]=e,o[i]=new RegExp(e,r?"g":void 0)};u("NUMERICIDENTIFIER","0|[1-9]\\d*"),u("NUMERICIDENTIFIERLOOSE","[0-9]+"),u("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),u("MAINVERSION",`(${s[a.NUMERICIDENTIFIER]})\\.(${s[a.NUMERICIDENTIFIER]})\\.(${s[a.NUMERICIDENTIFIER]})`),u("MAINVERSIONLOOSE",`(${s[a.NUMERICIDENTIFIERLOOSE]})\\.(${s[a.NUMERICIDENTIFIERLOOSE]})\\.(${s[a.NUMERICIDENTIFIERLOOSE]})`),u("PRERELEASEIDENTIFIER",`(?:${s[a.NUMERICIDENTIFIER]}|${s[a.NONNUMERICIDENTIFIER]})`),u("PRERELEASEIDENTIFIERLOOSE",`(?:${s[a.NUMERICIDENTIFIERLOOSE]}|${s[a.NONNUMERICIDENTIFIER]})`),u("PRERELEASE",`(?:-(${s[a.PRERELEASEIDENTIFIER]}(?:\\.${s[a.PRERELEASEIDENTIFIER]})*))`),u("PRERELEASELOOSE",`(?:-?(${s[a.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${s[a.PRERELEASEIDENTIFIERLOOSE]})*))`),u("BUILDIDENTIFIER","[0-9A-Za-z-]+"),u("BUILD",`(?:\\+(${s[a.BUILDIDENTIFIER]}(?:\\.${s[a.BUILDIDENTIFIER]})*))`),u("FULLPLAIN",`v?${s[a.MAINVERSION]}${s[a.PRERELEASE]}?${s[a.BUILD]}?`),u("FULL",`^${s[a.FULLPLAIN]}$`),u("LOOSEPLAIN",`[v=\\s]*${s[a.MAINVERSIONLOOSE]}${s[a.PRERELEASELOOSE]}?${s[a.BUILD]}?`),u("LOOSE",`^${s[a.LOOSEPLAIN]}$`),u("GTLT","((?:<|>)?=?)"),u("XRANGEIDENTIFIERLOOSE",`${s[a.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),u("XRANGEIDENTIFIER",`${s[a.NUMERICIDENTIFIER]}|x|X|\\*`),u("XRANGEPLAIN",`[v=\\s]*(${s[a.XRANGEIDENTIFIER]})(?:\\.(${s[a.XRANGEIDENTIFIER]})(?:\\.(${s[a.XRANGEIDENTIFIER]})(?:${s[a.PRERELEASE]})?${s[a.BUILD]}?)?)?`),u("XRANGEPLAINLOOSE",`[v=\\s]*(${s[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${s[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${s[a.XRANGEIDENTIFIERLOOSE]})(?:${s[a.PRERELEASELOOSE]})?${s[a.BUILD]}?)?)?`),u("XRANGE",`^${s[a.GTLT]}\\s*${s[a.XRANGEPLAIN]}$`),u("XRANGELOOSE",`^${s[a.GTLT]}\\s*${s[a.XRANGEPLAINLOOSE]}$`),u("COERCE",`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?(?:$|[^\\d])`),u("COERCERTL",s[a.COERCE],!0),u("LONETILDE","(?:~>?)"),u("TILDETRIM",`(\\s*)${s[a.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",u("TILDE",`^${s[a.LONETILDE]}${s[a.XRANGEPLAIN]}$`),u("TILDELOOSE",`^${s[a.LONETILDE]}${s[a.XRANGEPLAINLOOSE]}$`),u("LONECARET","(?:\\^)"),u("CARETTRIM",`(\\s*)${s[a.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",u("CARET",`^${s[a.LONECARET]}${s[a.XRANGEPLAIN]}$`),u("CARETLOOSE",`^${s[a.LONECARET]}${s[a.XRANGEPLAINLOOSE]}$`),u("COMPARATORLOOSE",`^${s[a.GTLT]}\\s*(${s[a.LOOSEPLAIN]})$|^$`),u("COMPARATOR",`^${s[a.GTLT]}\\s*(${s[a.FULLPLAIN]})$|^$`),u("COMPARATORTRIM",`(\\s*)${s[a.GTLT]}\\s*(${s[a.LOOSEPLAIN]}|${s[a.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",u("HYPHENRANGE",`^\\s*(${s[a.XRANGEPLAIN]})\\s+-\\s+(${s[a.XRANGEPLAIN]})\\s*$`),u("HYPHENRANGELOOSE",`^\\s*(${s[a.XRANGEPLAINLOOSE]})\\s+-\\s+(${s[a.XRANGEPLAINLOOSE]})\\s*$`),u("STAR","(<|>)?=?\\s*\\*"),u("GTE0","^\\s*>=\\s*0.0.0\\s*$"),u("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")},t=>{const e=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:e,MAX_SAFE_COMPONENT_LENGTH:16}},t=>{const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};t.exports=e},(t,e,r)=>{const i=r(57),{MAX_LENGTH:n,MAX_SAFE_INTEGER:o}=r(56),{re:s,t:a}=r(55),h=r(59),{compareIdentifiers:u}=r(60);class l{constructor(t,e){if(e=h(e),t instanceof l){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if("string"!=typeof t)throw new TypeError(`Invalid Version: ${t}`);if(t.length>n)throw new TypeError(`version is longer than ${n} characters`);i("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;const r=t.trim().match(e.loose?s[a.LOOSE]:s[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError("Invalid major version");if(this.minor>o||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>o||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}}t.exports=l},t=>{const e=["includePrerelease","loose","rtl"];t.exports=t=>t?"object"!=typeof t?{loose:!0}:e.filter((e=>t[e])).reduce(((t,e)=>(t[e]=!0,t)),{}):{}},t=>{const e=/^[0-9]+$/,r=(t,r)=>{const i=e.test(t),n=e.test(r);return i&&n&&(t=+t,r=+r),t===r?0:i&&!n?-1:n&&!i?1:tr(e,t)}},(t,e,r)=>{const{MAX_LENGTH:i}=r(56),{re:n,t:o}=r(55),s=r(58),a=r(59);t.exports=(t,e)=>{if(e=a(e),t instanceof s)return t;if("string"!=typeof t)return null;if(t.length>i)return null;if(!(e.loose?n[o.LOOSE]:n[o.FULL]).test(t))return null;try{return new s(t,e)}catch(t){return null}}},(t,e,r)=>{const i=r(61);t.exports=(t,e)=>{const r=i(t,e);return r?r.version:null}},(t,e,r)=>{const i=r(61);t.exports=(t,e)=>{const r=i(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null}},(t,e,r)=>{const i=r(58);t.exports=(t,e,r,n)=>{"string"==typeof r&&(n=r,r=void 0);try{return new i(t,r).inc(e,n).version}catch(t){return null}}},(t,e,r)=>{const i=r(61),n=r(66);t.exports=(t,e)=>{if(n(t,e))return null;{const r=i(t),n=i(e),o=r.prerelease.length||n.prerelease.length,s=o?"pre":"",a=o?"prerelease":"";for(const t in r)if(("major"===t||"minor"===t||"patch"===t)&&r[t]!==n[t])return s+t;return a}}},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>0===i(t,e,r)},(t,e,r)=>{const i=r(58);t.exports=(t,e,r)=>new i(t,r).compare(new i(e,r))},(t,e,r)=>{const i=r(58);t.exports=(t,e)=>new i(t,e).major},(t,e,r)=>{const i=r(58);t.exports=(t,e)=>new i(t,e).minor},(t,e,r)=>{const i=r(58);t.exports=(t,e)=>new i(t,e).patch},(t,e,r)=>{const i=r(61);t.exports=(t,e)=>{const r=i(t,e);return r&&r.prerelease.length?r.prerelease:null}},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>i(e,t,r)},(t,e,r)=>{const i=r(67);t.exports=(t,e)=>i(t,e,!0)},(t,e,r)=>{const i=r(58);t.exports=(t,e,r)=>{const n=new i(t,r),o=new i(e,r);return n.compare(o)||n.compareBuild(o)}},(t,e,r)=>{const i=r(74);t.exports=(t,e)=>t.sort(((t,r)=>i(t,r,e)))},(t,e,r)=>{const i=r(74);t.exports=(t,e)=>t.sort(((t,r)=>i(r,t,e)))},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>i(t,e,r)>0},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>i(t,e,r)<0},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>0!==i(t,e,r)},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>i(t,e,r)>=0},(t,e,r)=>{const i=r(67);t.exports=(t,e,r)=>i(t,e,r)<=0},(t,e,r)=>{const i=r(66),n=r(79),o=r(77),s=r(80),a=r(78),h=r(81);t.exports=(t,e,r,u)=>{switch(e){case"===":return"object"==typeof t&&(t=t.version),"object"==typeof r&&(r=r.version),t===r;case"!==":return"object"==typeof t&&(t=t.version),"object"==typeof r&&(r=r.version),t!==r;case"":case"=":case"==":return i(t,r,u);case"!=":return n(t,r,u);case">":return o(t,r,u);case">=":return s(t,r,u);case"<":return a(t,r,u);case"<=":return h(t,r,u);default:throw new TypeError(`Invalid operator: ${e}`)}}},(t,e,r)=>{const i=r(58),n=r(61),{re:o,t:s}=r(55);t.exports=(t,e)=>{if(t instanceof i)return t;if("number"==typeof t&&(t=String(t)),"string"!=typeof t)return null;let r=null;if((e=e||{}).rtl){let e;for(;(e=o[s.COERCERTL].exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&e.index+e[0].length===r.index+r[0].length||(r=e),o[s.COERCERTL].lastIndex=e.index+e[1].length+e[2].length;o[s.COERCERTL].lastIndex=-1}else r=t.match(o[s.COERCE]);return null===r?null:n(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,e)}},(t,e,r)=>{const i=Symbol("SemVer ANY");class n{static get ANY(){return i}constructor(t,e){if(e=o(e),t instanceof n){if(t.loose===!!e.loose)return t;t=t.value}u("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===i?this.value="":this.value=this.operator+this.semver.version,u("comp",this)}parse(t){const e=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new l(r[2],this.options.loose):this.semver=i}toString(){return this.value}test(t){if(u("Comparator.test",t,this.options.loose),this.semver===i||t===i)return!0;if("string"==typeof t)try{t=new l(t,this.options)}catch(t){return!1}return h(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof n))throw new TypeError("a Comparator is required");if(e&&"object"==typeof e||(e={loose:!!e,includePrerelease:!1}),""===this.operator)return""===this.value||new c(t.value,e).test(this.value);if(""===t.operator)return""===t.value||new c(this.value,e).test(t.semver);const r=!(">="!==this.operator&&">"!==this.operator||">="!==t.operator&&">"!==t.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==t.operator&&"<"!==t.operator),o=this.semver.version===t.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==t.operator&&"<="!==t.operator),a=h(this.semver,"<",t.semver,e)&&(">="===this.operator||">"===this.operator)&&("<="===t.operator||"<"===t.operator),u=h(this.semver,">",t.semver,e)&&("<="===this.operator||"<"===this.operator)&&(">="===t.operator||">"===t.operator);return r||i||o&&s||a||u}}t.exports=n;const o=r(59),{re:s,t:a}=r(55),h=r(82),u=r(57),l=r(58),c=r(85)},(t,e,r)=>{class i{constructor(t,e){if(e=o(e),t instanceof i)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new i(t.raw,e);if(t instanceof s)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map((t=>this.parseRange(t.trim()))).filter((t=>t.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter((t=>!p(t[0]))),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&m(t[0])){this.set=[t];break}}this.format()}format(){return this.range=this.set.map((t=>t.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(t){t=t.trim();const e=`parseRange:${Object.keys(this.options).join(",")}:${t}`,r=n.get(e);if(r)return r;const i=this.options.loose,o=i?u[l.HYPHENRANGELOOSE]:u[l.HYPHENRANGE];t=t.replace(o,_(this.options.includePrerelease)),a("hyphen replace",t),t=t.replace(u[l.COMPARATORTRIM],c),a("comparator trim",t,u[l.COMPARATORTRIM]),t=(t=(t=t.replace(u[l.TILDETRIM],f)).replace(u[l.CARETTRIM],d)).split(/\s+/).join(" ");const h=i?u[l.COMPARATORLOOSE]:u[l.COMPARATOR],m=t.split(" ").map((t=>v(t,this.options))).join(" ").split(/\s+/).map((t=>F(t,this.options))).filter(this.options.loose?t=>!!t.match(h):()=>!0).map((t=>new s(t,this.options))),g=(m.length,new Map);for(const t of m){if(p(t))return[t];g.set(t.value,t)}g.size>1&&g.has("")&&g.delete("");const y=[...g.values()];return n.set(e,y),y}intersects(t,e){if(!(t instanceof i))throw new TypeError("a Range is required");return this.set.some((r=>g(r,e)&&t.set.some((t=>g(t,e)&&r.every((r=>t.every((t=>r.intersects(t,e)))))))))}test(t){if(!t)return!1;if("string"==typeof t)try{t=new h(t,this.options)}catch(t){return!1}for(let e=0;e"<0.0.0-0"===t.value,m=t=>""===t.value,g=(t,e)=>{let r=!0;const i=t.slice();let n=i.pop();for(;r&&i.length;)r=i.every((t=>n.intersects(t,e))),n=i.pop();return r},v=(t,e)=>(a("comp",t,e),t=M(t,e),a("caret",t),t=w(t,e),a("tildes",t),t=A(t,e),a("xrange",t),t=B(t,e),a("stars",t),t),y=t=>!t||"x"===t.toLowerCase()||"*"===t,w=(t,e)=>t.trim().split(/\s+/).map((t=>b(t,e))).join(" "),b=(t,e)=>{const r=e.loose?u[l.TILDELOOSE]:u[l.TILDE];return t.replace(r,((e,r,i,n,o)=>{let s;return a("tilde",t,e,r,i,n,o),y(r)?s="":y(i)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:y(n)?s=`>=${r}.${i}.0 <${r}.${+i+1}.0-0`:o?(a("replaceTilde pr",o),s=`>=${r}.${i}.${n}-${o} <${r}.${+i+1}.0-0`):s=`>=${r}.${i}.${n} <${r}.${+i+1}.0-0`,a("tilde return",s),s}))},M=(t,e)=>t.trim().split(/\s+/).map((t=>E(t,e))).join(" "),E=(t,e)=>{a("caret",t,e);const r=e.loose?u[l.CARETLOOSE]:u[l.CARET],i=e.includePrerelease?"-0":"";return t.replace(r,((e,r,n,o,s)=>{let h;return a("caret",t,e,r,n,o,s),y(r)?h="":y(n)?h=`>=${r}.0.0${i} <${+r+1}.0.0-0`:y(o)?h="0"===r?`>=${r}.${n}.0${i} <${r}.${+n+1}.0-0`:`>=${r}.${n}.0${i} <${+r+1}.0.0-0`:s?(a("replaceCaret pr",s),h="0"===r?"0"===n?`>=${r}.${n}.${o}-${s} <${r}.${n}.${+o+1}-0`:`>=${r}.${n}.${o}-${s} <${r}.${+n+1}.0-0`:`>=${r}.${n}.${o}-${s} <${+r+1}.0.0-0`):(a("no pr"),h="0"===r?"0"===n?`>=${r}.${n}.${o}${i} <${r}.${n}.${+o+1}-0`:`>=${r}.${n}.${o}${i} <${r}.${+n+1}.0-0`:`>=${r}.${n}.${o} <${+r+1}.0.0-0`),a("caret return",h),h}))},A=(t,e)=>(a("replaceXRanges",t,e),t.split(/\s+/).map((t=>C(t,e))).join(" ")),C=(t,e)=>{t=t.trim();const r=e.loose?u[l.XRANGELOOSE]:u[l.XRANGE];return t.replace(r,((r,i,n,o,s,h)=>{a("xRange",t,r,i,n,o,s,h);const u=y(n),l=u||y(o),c=l||y(s),f=c;return"="===i&&f&&(i=""),h=e.includePrerelease?"-0":"",u?r=">"===i||"<"===i?"<0.0.0-0":"*":i&&f?(l&&(o=0),s=0,">"===i?(i=">=",l?(n=+n+1,o=0,s=0):(o=+o+1,s=0)):"<="===i&&(i="<",l?n=+n+1:o=+o+1),"<"===i&&(h="-0"),r=`${i+n}.${o}.${s}${h}`):l?r=`>=${n}.0.0${h} <${+n+1}.0.0-0`:c&&(r=`>=${n}.${o}.0${h} <${n}.${+o+1}.0-0`),a("xRange return",r),r}))},B=(t,e)=>(a("replaceStars",t,e),t.trim().replace(u[l.STAR],"")),F=(t,e)=>(a("replaceGTE0",t,e),t.trim().replace(u[e.includePrerelease?l.GTE0PRE:l.GTE0],"")),_=t=>(e,r,i,n,o,s,a,h,u,l,c,f,d)=>`${r=y(i)?"":y(n)?`>=${i}.0.0${t?"-0":""}`:y(o)?`>=${i}.${n}.0${t?"-0":""}`:s?`>=${r}`:`>=${r}${t?"-0":""}`} ${h=y(u)?"":y(l)?`<${+u+1}.0.0-0`:y(c)?`<${u}.${+l+1}.0-0`:f?`<=${u}.${l}.${c}-${f}`:t?`<${u}.${l}.${+c+1}-0`:`<=${h}`}`.trim(),S=(t,e,r)=>{for(let r=0;r0){const i=t[r].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0}},(t,e,r)=>{"use strict";const i=r(87),n=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),h=Symbol("maxAge"),u=Symbol("dispose"),l=Symbol("noDisposeOnSet"),c=Symbol("lruList"),f=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=()=>1,m=(t,e,r)=>{const i=t[f].get(e);if(i){const e=i.value;if(g(t,e)){if(y(t,i),!t[a])return}else r&&(t[d]&&(i.value.now=Date.now()),t[c].unshiftNode(i));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[h])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[h]&&r>t[h]},v=t=>{if(t[o]>t[n])for(let e=t[c].tail;t[o]>t[n]&&null!==e;){const r=e.prev;y(t,e),e=r}},y=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[o]-=r.length,t[f].delete(r.key),t[c].removeNode(e)}};class w{constructor(t,e,r,i,n){this.key=t,this.value=e,this.length=r,this.now=i,this.maxAge=n||0}}const b=(t,e,r,i)=>{let n=r.value;g(t,n)&&(y(t,r),t[a]||(n=void 0)),n&&e.call(i,n.value,n.key,t)};t.exports=class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[n]=t.max||1/0;const e=t.length||p;if(this[s]="function"!=typeof e?p:e,this[a]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[h]=t.maxAge||0,this[u]=t.dispose,this[l]=t.noDisposeOnSet||!1,this[d]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[n]=t||1/0,v(this)}get max(){return this[n]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[h]=t,v(this)}get maxAge(){return this[h]}set lengthCalculator(t){"function"!=typeof t&&(t=p),t!==this[s]&&(this[s]=t,this[o]=0,this[c].forEach((t=>{t.length=this[s](t.value,t.key),this[o]+=t.length}))),v(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[c].length}rforEach(t,e){e=e||this;for(let r=this[c].tail;null!==r;){const i=r.prev;b(this,t,r,e),r=i}}forEach(t,e){e=e||this;for(let r=this[c].head;null!==r;){const i=r.next;b(this,t,r,e),r=i}}keys(){return this[c].toArray().map((t=>t.key))}values(){return this[c].toArray().map((t=>t.value))}reset(){this[u]&&this[c]&&this[c].length&&this[c].forEach((t=>this[u](t.key,t.value))),this[f]=new Map,this[c]=new i,this[o]=0}dump(){return this[c].map((t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[c]}set(t,e,r){if((r=r||this[h])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const i=r?Date.now():0,a=this[s](e,t);if(this[f].has(t)){if(a>this[n])return y(this,this[f].get(t)),!1;const s=this[f].get(t).value;return this[u]&&(this[l]||this[u](t,s.value)),s.now=i,s.maxAge=r,s.value=e,this[o]+=a-s.length,s.length=a,this.get(t),v(this),!0}const d=new w(t,e,a,i,r);return d.length>this[n]?(this[u]&&this[u](t,e),!1):(this[o]+=d.length,this[c].unshift(d),this[f].set(t,this[c].head),v(this),!0)}has(t){if(!this[f].has(t))return!1;const e=this[f].get(t).value;return!g(this,e)}get(t){return m(this,t,!0)}peek(t){return m(this,t,!1)}pop(){const t=this[c].tail;return t?(y(this,t),t.value):null}del(t){y(this,this[f].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const i=t[r],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const t=n-e;t>0&&this.set(i.k,i.v,t)}}}prune(){this[f].forEach(((t,e)=>m(this,e,!1)))}}},(t,e,r)=>{"use strict";function i(t){var e=this;if(e instanceof i||(e=new i),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=t(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(t,e){var r,i=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=t(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},i.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},i.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new i;if(ethis.length&&(e=this.length);for(var n=0,o=this.head;null!==o&&nthis.length&&(e=this.length);for(var n=this.length,o=this.tail;null!==o&&n>e;n--)o=o.prev;for(;null!==o&&n>t;n--,o=o.prev)r.push(o.value);return r},i.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var i=0,o=this.head;null!==o&&i{"use strict";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},(t,e,r)=>{const i=r(85);t.exports=(t,e,r)=>{try{e=new i(e,r)}catch(t){return!1}return e.test(t)}},(t,e,r)=>{const i=r(85);t.exports=(t,e)=>new i(t,e).set.map((t=>t.map((t=>t.value)).join(" ").trim().split(" ")))},(t,e,r)=>{const i=r(58),n=r(85);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new n(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new i(o,r)))})),o}},(t,e,r)=>{const i=r(58),n=r(85);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new n(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new i(o,r)))})),o}},(t,e,r)=>{const i=r(58),n=r(85),o=r(77);t.exports=(t,e)=>{t=new n(t,e);let r=new i("0.0.0");if(t.test(r))return r;if(r=new i("0.0.0-0"),t.test(r))return r;r=null;for(let e=0;e{const e=new i(t.semver.version);switch(t.operator){case">":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case"":case">=":s&&!o(e,s)||(s=e);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}})),!s||r&&!o(r,s)||(r=s)}return r&&t.test(r)?r:null}},(t,e,r)=>{const i=r(85);t.exports=(t,e)=>{try{return new i(t,e).range||"*"}catch(t){return null}}},(t,e,r)=>{const i=r(58),n=r(84),{ANY:o}=n,s=r(85),a=r(89),h=r(77),u=r(78),l=r(81),c=r(80);t.exports=(t,e,r,f)=>{let d,p,m,g,v;switch(t=new i(t,f),e=new s(e,f),r){case">":d=h,p=l,m=u,g=">",v=">=";break;case"<":d=u,p=c,m=h,g="<",v="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(a(t,e,f))return!1;for(let r=0;r{t.semver===o&&(t=new n(">=0.0.0")),s=s||t,a=a||t,d(t.semver,s.semver,f)?s=t:m(t.semver,a.semver,f)&&(a=t)})),s.operator===g||s.operator===v)return!1;if((!a.operator||a.operator===g)&&p(t,a.semver))return!1;if(a.operator===v&&m(t,a.semver))return!1}return!0}},(t,e,r)=>{const i=r(95);t.exports=(t,e,r)=>i(t,e,">",r)},(t,e,r)=>{const i=r(95);t.exports=(t,e,r)=>i(t,e,"<",r)},(t,e,r)=>{const i=r(85);t.exports=(t,e,r)=>(t=new i(t,r),e=new i(e,r),t.intersects(e))},(t,e,r)=>{const i=r(89),n=r(67);t.exports=(t,e,r)=>{const o=[];let s=null,a=null;const h=t.sort(((t,e)=>n(t,e,r)));for(const t of h)i(t,e,r)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null);s&&o.push([s,null]);const u=[];for(const[t,e]of o)t===e?u.push(t):e||t!==h[0]?e?t===h[0]?u.push(`<=${e}`):u.push(`${t} - ${e}`):u.push(`>=${t}`):u.push("*");const l=u.join(" || "),c="string"==typeof e.raw?e.raw:String(e);return l.length{const i=r(85),n=r(84),{ANY:o}=n,s=r(89),a=r(67),h=(t,e,r)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===o){if(1===e.length&&e[0].semver===o)return!0;t=r.includePrerelease?[new n(">=0.0.0-0")]:[new n(">=0.0.0")]}if(1===e.length&&e[0].semver===o){if(r.includePrerelease)return!0;e=[new n(">=0.0.0")]}const i=new Set;let h,c,f,d,p,m,g;for(const e of t)">"===e.operator||">="===e.operator?h=u(h,e,r):"<"===e.operator||"<="===e.operator?c=l(c,e,r):i.add(e.semver);if(i.size>1)return null;if(h&&c){if(f=a(h.semver,c.semver,r),f>0)return null;if(0===f&&(">="!==h.operator||"<="!==c.operator))return null}for(const t of i){if(h&&!s(t,String(h),r))return null;if(c&&!s(t,String(c),r))return null;for(const i of e)if(!s(t,String(i),r))return!1;return!0}let v=!(!c||r.includePrerelease||!c.semver.prerelease.length)&&c.semver,y=!(!h||r.includePrerelease||!h.semver.prerelease.length)&&h.semver;v&&1===v.prerelease.length&&"<"===c.operator&&0===v.prerelease[0]&&(v=!1);for(const t of e){if(g=g||">"===t.operator||">="===t.operator,m=m||"<"===t.operator||"<="===t.operator,h)if(y&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===y.major&&t.semver.minor===y.minor&&t.semver.patch===y.patch&&(y=!1),">"===t.operator||">="===t.operator){if(d=u(h,t,r),d===t&&d!==h)return!1}else if(">="===h.operator&&!s(h.semver,String(t),r))return!1;if(c)if(v&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===v.major&&t.semver.minor===v.minor&&t.semver.patch===v.patch&&(v=!1),"<"===t.operator||"<="===t.operator){if(p=l(c,t,r),p===t&&p!==c)return!1}else if("<="===c.operator&&!s(c.semver,String(t),r))return!1;if(!t.operator&&(c||h)&&0!==f)return!1}return!(h&&m&&!c&&0!==f||c&&g&&!h&&0!==f||y||v)},u=(t,e,r)=>{if(!t)return e;const i=a(t.semver,e.semver,r);return i>0?t:i<0||">"===e.operator&&">="===t.operator?e:t},l=(t,e,r)=>{if(!t)return e;const i=a(t.semver,e.semver,r);return i<0?t:i>0||"<"===e.operator&&"<="===t.operator?e:t};t.exports=(t,e,r={})=>{if(t===e)return!0;t=new i(t,r),e=new i(e,r);let n=!1;t:for(const i of t.set){for(const t of e.set){const e=h(i,t,r);if(n=n||null!==e,e)continue t}if(n)return!1}return!0}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{listen:()=>s,log:()=>o});let i=0;const n=[],o=(t,e,r)=>{const o={type:t,id:String(++i),date:new Date};e&&(o.message=e),r&&(o.data=r),function(t){for(let e=0;e(n.push(t),()=>{const e=n.indexOf(t);-1!==e&&(n[e]=n[n.length-1],n.pop())});"undefined"!=typeof window&&(window.__ledgerLogsListen=s)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{getFirstLedgerDevice:()=>a,getLedgerDevices:()=>s,isSupported:()=>h,requestLedgerDevice:()=>o});var i=r(53);const n=[{vendorId:i.ledgerUSBVendorId}];async function o(){return await navigator.usb.requestDevice({filters:n})}async function s(){return(await navigator.usb.getDevices()).filter((t=>t.vendorId===i.ledgerUSBVendorId))}async function a(){const t=await s();return t.length>0?t[0]:o()}const h=()=>Promise.resolve(!!navigator&&!!navigator.usb&&"function"==typeof navigator.usb.getDevices)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d});var i=r(49),n=r(52),o=r(53),s=r(101),a=r(51),h=r(9).Buffer;const u=[{vendorId:o.ledgerUSBVendorId}],l=()=>{const{hid:t}=navigator;if(!t)throw new a.TransportError("navigator.hid is not supported","HIDNotSupported");return t};async function c(){const t=await l().requestDevice({filters:u});return Array.isArray(t)?t:[t]}async function f(){return(await l().getDevices()).filter((t=>t.vendorId===o.ledgerUSBVendorId))}class d extends i.default{constructor(t){super(),this.device=void 0,this.deviceModel=void 0,this.channel=Math.floor(65535*Math.random()),this.packetSize=64,this.inputs=[],this.inputCallback=void 0,this.read=()=>this.inputs.length?Promise.resolve(this.inputs.shift()):new Promise((t=>{this.inputCallback=t})),this.onInputReport=t=>{const e=h.from(t.data.buffer);this.inputCallback?(this.inputCallback(e),this.inputCallback=null):this.inputs.push(e)},this._disconnectEmitted=!1,this._emitDisconnect=t=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",t))},this.exchange=t=>this.exchangeAtomicImpl((async()=>{const{channel:e,packetSize:r}=this;(0,s.log)("apdu","=> "+t.toString("hex"));const i=(0,n.default)(e,r),o=i.makeBlocks(t);for(let t=0;t{if(t&&t.message&&t.message.includes("write"))throw this._emitDisconnect(t),new a.DisconnectedDeviceDuringOperation(t.message);throw t})),this.device=t,this.deviceModel=(0,o.identifyUSBProductId)(t.productId),t.addEventListener("inputreport",this.onInputReport)}static async request(){const[t]=await c();return d.open(t)}static async openConnected(){const t=await f();return 0===t.length?null:d.open(t[0])}static async open(t){await t.open();const e=new d(t),r=i=>{t===i.device&&(l().removeEventListener("disconnect",r),e._emitDisconnect(new a.DisconnectedDevice))};return l().addEventListener("disconnect",r),e}async close(){await this.exchangeBusyPromise,this.device.removeEventListener("inputreport",this.onInputReport),await this.device.close()}setScrambleKey(){}}d.isSupported=()=>Promise.resolve(!(!r.g.navigator||!r.g.navigator.hid)),d.list=f,d.listen=t=>{let e=!1;return async function(){const t=await f();return t.length>0?t[0]:(await c())[0]}().then((r=>{if(r){if(!e){const e=(0,o.identifyUSBProductId)(r.productId);t.next({type:"add",descriptor:r,deviceModel:e}),t.complete()}}else t.error(new a.TransportOpenUserCancelled("Access denied to use Ledger device"))}),(e=>{t.error(new a.TransportOpenUserCancelled(e.message))})),{unsubscribe:function(){e=!0}}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>B});var i=r(49),n=r(51),o=r(53),s=r(105),a=r(209),h=r(101),u=r(107),l=r(197),c=r(189),f=r(181),d=r(211),p=r(212),m=r(214),g=r(164),v=r(218),y=r(210),w=r(9).Buffer;const b=()=>{const{bluetooth:t}=navigator;if(void 0===t)throw new Error("web bluetooth not supported");return t},M=()=>u.Observable.create((t=>{const e=b(),r=e=>{t.next(e.value)};e.addEventListener("availabilitychanged",r);let i=!1;return e.getAvailability().then((e=>{i||t.next(e)})),()=>{i=!0,e.removeEventListener("availabilitychanged",r)}})),E={},A=()=>({filters:(0,o.getBluetoothServiceUuids)().map((t=>({services:[t]})))});async function C(t,e){let r;if("string"==typeof t){if(E[t])return(0,h.log)("ble-verbose","Transport in cache, using that."),E[t];const e=b();r=await e.requestDevice(A())}else r=t;r.gatt.connected||((0,h.log)("ble-verbose","not connected. connecting..."),await r.gatt.connect());const[i,s]=await(async t=>{if(!t.gatt)throw new Error("bluetooth gatt not found");const[e]=await t.gatt.getPrimaryServices();if(!e)throw new Error("bluetooth service not found");const r=(0,o.getInfosForServiceUuid)(e.uuid);if(!r)throw new Error("bluetooth service infos not found");return[e,r]})(r),{deviceModel:a,writeUuid:u,notifyUuid:l}=s,[c,f]=await Promise.all([i.getCharacteristic(u),i.getCharacteristic(l)]),m=(0,y.monitorCharacteristic)(f).pipe((0,d.tap)((t=>{(0,h.log)("ble-frame","<= "+t.toString("hex"))})),(0,p.share)()),g=m.subscribe(),v=new B(r,c,m,a);if(!r.gatt.connected)throw new n.DisconnectedDevice;E[v.id]=v;const w=t=>{console.log("onDisconnect!",t),delete E[v.id],v.notYetDisconnected=!1,g.unsubscribe(),r.removeEventListener("gattserverdisconnected",w),(0,h.log)("ble-verbose",`BleTransport(${v.id}) disconnected`),v.emit("disconnect",t)};r.addEventListener("gattserverdisconnected",w);let M=Date.now();try{await v.inferMTU()}finally{Date.now()-M<1e3&&(e=!1),e&&(await r.gatt.disconnect(),await new Promise((t=>setTimeout(t,4e3))))}return e?C(r,!1):v}class B extends i.default{static listen(t){let e;return(0,h.log)("ble-verbose","listen..."),b().requestDevice(A()).then((async r=>{e||(t.next({type:"add",descriptor:r}),t.complete())}),(e=>{t.error(new n.TransportOpenUserCancelled(e.message))})),{unsubscribe:function(){e=!0}}}static async open(t){return C(t,!0)}constructor(t,e,r,i){super(),this.id=void 0,this.device=void 0,this.mtuSize=20,this.writeCharacteristic=void 0,this.notifyObservable=void 0,this.notYetDisconnected=!0,this.deviceModel=void 0,this.exchange=t=>this.exchangeAtomicImpl((async()=>{try{const e=t.toString("hex");(0,h.log)("apdu",`=> ${e}`);const r=await(0,l.merge)(this.notifyObservable.pipe(a.receiveAPDU),(0,s.sendAPDU)(this.write,t,this.mtuSize)).toPromise(),i=r.toString("hex");return(0,h.log)("apdu",`<= ${i}`),r}catch(t){throw(0,h.log)("ble-error","exchange got "+String(t)),this.notYetDisconnected&&this.device.gatt.disconnect(),t}})),this.write=async t=>{(0,h.log)("ble-frame","=> "+t.toString("hex")),await this.writeCharacteristic.writeValue(t)},this.id=t.id,this.device=t,this.writeCharacteristic=e,this.notifyObservable=r,this.deviceModel=i,(0,h.log)("ble-verbose",`BleTransport(${String(this.id)}) new instance`)}async inferMTU(){let t=23;if(await this.exchangeAtomicImpl((async()=>{try{t=await(0,l.merge)(this.notifyObservable.pipe((0,m.first)((t=>8===t.readUInt8(0))),(0,g.map)((t=>t.readUInt8(5)))),(0,c.defer)((()=>(0,f.from)(this.write(w.from([8,0,0,0,0]))))).pipe((0,v.ignoreElements)())).toPromise()+3}catch(t){throw(0,h.log)("ble-error","inferMTU got "+String(t)),this.device.gatt.disconnect(),t}})),t>23){const e=t-3;(0,h.log)("ble-verbose",`BleTransport(${String(this.id)}) mtu set to ${String(e)}`),this.mtuSize=e}return this.mtuSize}setScrambleKey(){}async close(){this.exchangeBusyPromise&&await this.exchangeBusyPromise}}B.isSupported=()=>Promise.resolve().then(b).then((()=>!0),(()=>!1)),B.observeAvailability=t=>M.subscribe(t),B.list=()=>Promise.resolve([]),B.disconnect=async t=>{(0,h.log)("ble-verbose",`user disconnect(${t})`);const e=E[t];e&&e.device.gatt.disconnect()}},(t,e,r)=>{"use strict";var i=r(9).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.sendAPDU=void 0;var n=r(106),o=r(101);e.sendAPDU=(t,e,r)=>{const s=function(t,e){const r=[];for(let i=0,n=e(0);ir-(0===t?5:3))).map(((t,r)=>{const n=i.alloc(0===r?5:3);return n.writeUInt8(5,0),n.writeUInt16BE(r,1),0===r&&n.writeUInt16BE(e.length,3),i.concat([n,t])}));return n.Observable.create((e=>{let r=!1;return async function(){for(const e of s){if(r)return;await t(e)}}().then((()=>{r=!0,e.complete()}),(t=>{r=!0,(0,o.log)("ble-error","sendAPDU failure "+String(t)),e.error(t)})),()=>{r||((0,o.log)("ble-verbose","sendAPDU interruption"),r=!0)}}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ArgumentOutOfRangeError:()=>C.ArgumentOutOfRangeError,AsyncSubject:()=>l.AsyncSubject,BehaviorSubject:()=>h.BehaviorSubject,ConnectableObservable:()=>n.ConnectableObservable,EMPTY:()=>N.EMPTY,EmptyError:()=>B.EmptyError,GroupedObservable:()=>o.GroupedObservable,NEVER:()=>K.NEVER,Notification:()=>w.Notification,NotificationKind:()=>w.NotificationKind,ObjectUnsubscribedError:()=>F.ObjectUnsubscribedError,Observable:()=>i.Observable,ReplaySubject:()=>u.ReplaySubject,Scheduler:()=>g.Scheduler,Subject:()=>a.Subject,Subscriber:()=>y.Subscriber,Subscription:()=>v.Subscription,TimeoutError:()=>S.TimeoutError,UnsubscriptionError:()=>_.UnsubscriptionError,VirtualAction:()=>m.VirtualAction,VirtualTimeScheduler:()=>m.VirtualTimeScheduler,animationFrame:()=>p.animationFrame,animationFrameScheduler:()=>p.animationFrameScheduler,asap:()=>c.asap,asapScheduler:()=>c.asapScheduler,async:()=>f.async,asyncScheduler:()=>f.asyncScheduler,bindCallback:()=>D.bindCallback,bindNodeCallback:()=>x.bindNodeCallback,combineLatest:()=>I.combineLatest,concat:()=>T.concat,config:()=>et.config,defer:()=>R.defer,empty:()=>N.empty,forkJoin:()=>O.forkJoin,from:()=>U.from,fromEvent:()=>k.fromEvent,fromEventPattern:()=>L.fromEventPattern,generate:()=>P.generate,identity:()=>E.identity,iif:()=>j.iif,interval:()=>$.interval,isObservable:()=>A.isObservable,merge:()=>q.merge,never:()=>K.never,noop:()=>M.noop,observable:()=>s.observable,of:()=>H.of,onErrorResumeNext:()=>G.onErrorResumeNext,pairs:()=>z.pairs,partition:()=>V.partition,pipe:()=>b.pipe,queue:()=>d.queue,queueScheduler:()=>d.queueScheduler,race:()=>W.race,range:()=>Z.range,scheduled:()=>tt.scheduled,throwError:()=>Y.throwError,timer:()=>X.timer,using:()=>J.using,zip:()=>Q.zip});var i=r(107),n=r(124),o=r(129),s=r(121),a=r(126),h=r(130),u=r(131),l=r(148),c=r(149),f=r(153),d=r(141),p=r(154),m=r(157),g=r(144),v=r(115),y=r(109),w=r(133),b=r(122),M=r(158),E=r(123),A=r(159),C=r(160),B=r(161),F=r(127),_=r(117),S=r(162),D=r(163),x=r(165),I=r(166),T=r(177),R=r(189),N=r(140),O=r(190),U=r(181),k=r(191),L=r(192),P=r(193),j=r(194),$=r(195),q=r(197),K=r(198),H=r(134),G=r(199),z=r(200),V=r(201),W=r(204),Z=r(205),Y=r(139),X=r(206),J=r(207),Q=r(208),tt=r(182),et=r(112)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Observable:()=>h});var i=r(120),n=r(108),o=r(121),s=r(122),a=r(112),h=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var i=this.operator,o=(0,n.toSubscriber)(t,e,r);if(i?o.add(i.call(o,this.source)):o.add(this.source||a.config.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),a.config.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){a.config.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),(0,i.canReportError)(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=u(e))((function(e,i){var n;n=r.subscribe((function(e){try{t(e)}catch(t){i(t),n&&n.unsubscribe()}}),i,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[o.observable]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{toSubscriber:()=>s});var i=r(109),n=r(114),o=r(111);function s(t,e,r){if(t){if(t instanceof i.Subscriber)return t;if(t[n.rxSubscriber])return t[n.rxSubscriber]()}return t||e||r?new i.Subscriber(t,e,r):new i.Subscriber(o.empty)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{SafeSubscriber:()=>c,Subscriber:()=>l});var i=r(110),n=r(116),o=r(111),s=r(115),a=r(114),h=r(112),u=r(113),l=function(t){function e(r,i,n){var s=t.call(this)||this;switch(s.syncErrorValue=null,s.syncErrorThrown=!1,s.syncErrorThrowable=!1,s.isStopped=!1,arguments.length){case 0:s.destination=o.empty;break;case 1:if(!r){s.destination=o.empty;break}if("object"==typeof r){r instanceof e?(s.syncErrorThrowable=r.syncErrorThrowable,s.destination=r,r.add(s)):(s.syncErrorThrowable=!0,s.destination=new c(s,r));break}default:s.syncErrorThrowable=!0,s.destination=new c(s,r,i,n)}return s}return i.__extends(e,t),e.prototype[a.rxSubscriber]=function(){return this},e.create=function(t,r,i){var n=new e(t,r,i);return n.syncErrorThrowable=!1,n},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(s.Subscription),c=function(t){function e(e,r,i,s){var a,h=t.call(this)||this;h._parentSubscriber=e;var u=h;return(0,n.isFunction)(r)?a=r:r&&(a=r.next,i=r.error,s=r.complete,r!==o.empty&&(u=Object.create(r),(0,n.isFunction)(u.unsubscribe)&&h.add(u.unsubscribe.bind(u)),u.unsubscribe=h.unsubscribe.bind(h))),h._context=u,h._next=a,h._error=i,h._complete=s,h}return i.__extends(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;h.config.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=h.config.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):(0,u.hostReportError)(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;(0,u.hostReportError)(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};h.config.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),h.config.useDeprecatedSynchronousErrorHandling)throw t;(0,u.hostReportError)(t)}},e.prototype.__tryOrSetError=function(t,e,r){if(!h.config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return h.config.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):((0,u.hostReportError)(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(l)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{__assign:()=>o,__asyncDelegator:()=>w,__asyncGenerator:()=>y,__asyncValues:()=>b,__await:()=>v,__awaiter:()=>l,__classPrivateFieldGet:()=>C,__classPrivateFieldSet:()=>B,__decorate:()=>a,__exportStar:()=>f,__extends:()=>n,__generator:()=>c,__importDefault:()=>A,__importStar:()=>E,__makeTemplateObject:()=>M,__metadata:()=>u,__param:()=>h,__read:()=>p,__rest:()=>s,__spread:()=>m,__spreadArrays:()=>g,__values:()=>d});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},i(t,e)};function n(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,i=arguments.length;r=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,r,s):n(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s}function h(t,e){return function(r,i){e(r,i,t)}}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function l(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{h(i.next(t))}catch(t){o(t)}}function a(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((i=i.apply(t,e||[])).next())}))}function c(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function m(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=n[t](e)).value instanceof v?Promise.resolve(r.value.v).then(h,u):l(o[0][2],r)}catch(t){l(o[0][3],t)}var r}function h(t){a("next",t)}function u(t){a("throw",t)}function l(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function w(t){var e,r;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,n){e[i]=t[i]?function(e){return(r=!r)?{value:v(t[i](e)),done:"return"===i}:n?n(e):e}:n}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=d(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(r){e[r]=t[r]&&function(e){return new Promise((function(i,n){!function(t,e,r,i){Promise.resolve(i).then((function(e){t({value:e,done:r})}),e)}(i,n,(e=t[r](e)).done,e.value)}))}}}function M(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function E(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function A(t){return t&&t.__esModule?t:{default:t}}function C(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function B(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{empty:()=>o});var i=r(112),n=r(113),o={closed:!0,next:function(t){},error:function(t){if(i.config.useDeprecatedSynchronousErrorHandling)throw t;(0,n.hostReportError)(t)},complete:function(){}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{config:()=>n});var i=!1,n={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,i=t},get useDeprecatedSynchronousErrorHandling(){return i}}},(t,e,r)=>{"use strict";function i(t){setTimeout((function(){throw t}),0)}r.r(e),r.d(e,{hostReportError:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{$$rxSubscriber:()=>n,rxSubscriber:()=>i});var i=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),n=i},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Subscription:()=>a});var i=r(118),n=r(119),o=r(116),s=r(117),a=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}var e;return t.prototype.unsubscribe=function(){var e;if(!this.closed){var r=this,a=r._parentOrParents,u=r._ctorUnsubscribe,l=r._unsubscribe,c=r._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof t)a.remove(this);else if(null!==a)for(var f=0;f{"use strict";function i(t){return"function"==typeof t}r.r(e),r.d(e,{isFunction:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{UnsubscriptionError:()=>i});var i=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isArray:()=>i});var i=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}()},(t,e,r)=>{"use strict";function i(t){return null!==t&&"object"==typeof t}r.r(e),r.d(e,{isObject:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{canReportError:()=>n});var i=r(109);function n(t){for(;t;){var e=t,r=e.closed,n=e.destination,o=e.isStopped;if(r||o)return!1;t=n&&n instanceof i.Subscriber?n:null}return!0}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{observable:()=>i});var i=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{pipe:()=>n,pipeFromArray:()=>o});var i=r(123);function n(){for(var t=[],e=0;e{"use strict";function i(t){return t}r.r(e),r.d(e,{identity:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ConnectableObservable:()=>u,connectableObservableDescriptor:()=>l});var i=r(110),n=r(126),o=r(107),s=r(109),a=r(115),h=r(125),u=function(t){function e(e,r){var i=t.call(this)||this;return i.source=e,i.subjectFactory=r,i._refCount=0,i._isComplete=!1,i}return i.__extends(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a.Subscription).add(this.source.subscribe(new c(this.getSubject(),this))),t.closed&&(this._connection=null,t=a.Subscription.EMPTY)),t},e.prototype.refCount=function(){return(0,h.refCount)()(this)},e}(o.Observable),l=function(){var t=u.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),c=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return i.__extends(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(n.SubjectSubscriber);s.Subscriber},(t,e,r)=>{"use strict";r.r(e),r.d(e,{refCount:()=>o});var i=r(110),n=r(109);function o(){return function(t){return t.lift(new s(t))}}var s=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var r=this.connectable;r._refCount++;var i=new a(t,r),n=e.subscribe(i);return i.closed||(i.connection=r.connect()),n},t}(),a=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return i.__extends(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var r=this.connection,i=t._connection;this.connection=null,!i||r&&i!==r||i.unsubscribe()}}else this.connection=null},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AnonymousSubject:()=>f,Subject:()=>c,SubjectSubscriber:()=>l});var i=r(110),n=r(107),o=r(109),s=r(115),a=r(127),h=r(128),u=r(114),l=function(t){function e(e){var r=t.call(this,e)||this;return r.destination=e,r}return i.__extends(e,t),e}(o.Subscriber),c=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return i.__extends(e,t),e.prototype[u.rxSubscriber]=function(){return new l(this)},e.prototype.lift=function(t){var e=new f(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new a.ObjectUnsubscribedError;if(!this.isStopped)for(var e=this.observers,r=e.length,i=e.slice(),n=0;n{"use strict";r.r(e),r.d(e,{ObjectUnsubscribedError:()=>i});var i=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{SubjectSubscription:()=>n});var i=r(110),n=function(t){function e(e,r){var i=t.call(this)||this;return i.subject=e,i.subscriber=r,i.closed=!1,i}return i.__extends(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},e}(r(115).Subscription)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{GroupedObservable:()=>f,groupBy:()=>h});var i=r(110),n=r(109),o=r(115),s=r(107),a=r(126);function h(t,e,r,i){return function(n){return n.lift(new u(t,e,r,i))}}var u=function(){function t(t,e,r,i){this.keySelector=t,this.elementSelector=e,this.durationSelector=r,this.subjectSelector=i}return t.prototype.call=function(t,e){return e.subscribe(new l(t,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},t}(),l=function(t){function e(e,r,i,n,o){var s=t.call(this,e)||this;return s.keySelector=r,s.elementSelector=i,s.durationSelector=n,s.subjectSelector=o,s.groups=null,s.attemptedToUnsubscribe=!1,s.count=0,s}return i.__extends(e,t),e.prototype._next=function(t){var e;try{e=this.keySelector(t)}catch(t){return void this.error(t)}this._group(t,e)},e.prototype._group=function(t,e){var r=this.groups;r||(r=this.groups=new Map);var i,n=r.get(e);if(this.elementSelector)try{i=this.elementSelector(t)}catch(t){this.error(t)}else i=t;if(!n){n=this.subjectSelector?this.subjectSelector():new a.Subject,r.set(e,n);var o=new f(e,n,this);if(this.destination.next(o),this.durationSelector){var s=void 0;try{s=this.durationSelector(new f(e,n))}catch(t){return void this.error(t)}this.add(s.subscribe(new c(e,n,this)))}}n.closed||n.next(i)},e.prototype._error=function(t){var e=this.groups;e&&(e.forEach((function(e,r){e.error(t)})),e.clear()),this.destination.error(t)},e.prototype._complete=function(){var t=this.groups;t&&(t.forEach((function(t,e){t.complete()})),t.clear()),this.destination.complete()},e.prototype.removeGroup=function(t){this.groups.delete(t)},e.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&t.prototype.unsubscribe.call(this))},e}(n.Subscriber),c=function(t){function e(e,r,i){var n=t.call(this,r)||this;return n.key=e,n.group=r,n.parent=i,n}return i.__extends(e,t),e.prototype._next=function(t){this.complete()},e.prototype._unsubscribe=function(){var t=this.parent,e=this.key;this.key=this.parent=null,t&&t.removeGroup(e)},e}(n.Subscriber),f=function(t){function e(e,r,i){var n=t.call(this)||this;return n.key=e,n.groupSubject=r,n.refCountSubscription=i,n}return i.__extends(e,t),e.prototype._subscribe=function(t){var e=new o.Subscription,r=this.refCountSubscription,i=this.groupSubject;return r&&!r.closed&&e.add(new d(r)),e.add(i.subscribe(t)),e},e}(s.Observable),d=function(t){function e(e){var r=t.call(this)||this;return r.parent=e,e.count++,r}return i.__extends(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(o.Subscription)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{BehaviorSubject:()=>s});var i=r(110),n=r(126),o=r(127),s=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return i.__extends(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new o.ObjectUnsubscribedError;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(n.Subject)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ReplaySubject:()=>l});var i=r(110),n=r(126),o=r(141),s=r(115),a=r(132),h=r(127),u=r(128),l=function(t){function e(e,r,i){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var n=t.call(this)||this;return n.scheduler=i,n._events=[],n._infiniteTimeWindow=!1,n._bufferSize=e<1?1:e,n._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(n._infiniteTimeWindow=!0,n.next=n.nextInfiniteTimeWindow):n.next=n.nextTimeWindow,n}return i.__extends(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var r=this._events;r.push(e),r.length>this._bufferSize&&r.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new c(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,r=this._infiniteTimeWindow,i=r?this._events:this._trimBufferThenGetEvents(),n=this.scheduler,o=i.length;if(this.closed)throw new h.ObjectUnsubscribedError;if(this.isStopped||this.hasError?e=s.Subscription.EMPTY:(this.observers.push(t),e=new u.SubjectSubscription(this,t)),n&&t.add(t=new a.ObserveOnSubscriber(t,n)),r)for(var l=0;le&&(o=Math.max(o,n-e)),o>0&&i.splice(0,o),i},e}(n.Subject),c=function(){return function(t,e){this.time=t,this.value=e}}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ObserveOnMessage:()=>u,ObserveOnOperator:()=>a,ObserveOnSubscriber:()=>h,observeOn:()=>s});var i=r(110),n=r(109),o=r(133);function s(t,e){return void 0===e&&(e=0),function(r){return r.lift(new a(t,e))}}var a=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.scheduler,this.delay))},t}(),h=function(t){function e(e,r,i){void 0===i&&(i=0);var n=t.call(this,e)||this;return n.scheduler=r,n.delay=i,n}return i.__extends(e,t),e.dispatch=function(t){var e=t.notification,r=t.destination;e.observe(r),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new u(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(o.Notification.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(o.Notification.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(o.Notification.createComplete()),this.unsubscribe()},e}(n.Subscriber),u=function(){return function(t,e){this.notification=t,this.destination=e}}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Notification:()=>a,NotificationKind:()=>i});var i,n=r(140),o=r(134),s=r(139);i||(i={});var a=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,r){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return r&&r()}},t.prototype.accept=function(t,e,r){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){switch(this.kind){case"N":return(0,o.of)(this.value);case"E":return(0,s.throwError)(this.error);case"C":return(0,n.empty)()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{of:()=>s});var i=r(135),n=r(137),o=r(136);function s(){for(var t=[],e=0;e{"use strict";function i(t){return t&&"function"==typeof t.schedule}r.r(e),r.d(e,{isScheduler:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduleArray:()=>o});var i=r(107),n=r(115);function o(t,e){return new i.Observable((function(r){var i=new n.Subscription,o=0;return i.add(e.schedule((function(){o!==t.length?(r.next(t[o++]),r.closed||i.add(this.schedule())):r.complete()}))),i}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{fromArray:()=>s});var i=r(107),n=r(138),o=r(136);function s(t,e){return e?(0,o.scheduleArray)(t,e):new i.Observable((0,n.subscribeToArray)(t))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToArray:()=>i});var i=function(t){return function(e){for(var r=0,i=t.length;r{"use strict";r.r(e),r.d(e,{throwError:()=>n});var i=r(107);function n(t,e){return e?new i.Observable((function(r){return e.schedule(o,0,{error:t,subscriber:r})})):new i.Observable((function(e){return e.error(t)}))}function o(t){var e=t.error;t.subscriber.error(e)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{EMPTY:()=>n,empty:()=>o});var i=r(107),n=new i.Observable((function(t){return t.complete()}));function o(t){return t?function(t){return new i.Observable((function(e){return t.schedule((function(){return e.complete()}))}))}(t):n}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{queue:()=>o,queueScheduler:()=>n});var i=r(145),n=new(r(142).QueueScheduler)(i.QueueAction),o=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{QueueScheduler:()=>n});var i=r(110),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e}(r(143).AsyncScheduler)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsyncScheduler:()=>o});var i=r(110),n=r(144),o=function(t){function e(r,i){void 0===i&&(i=n.Scheduler.now);var o=t.call(this,r,(function(){return e.delegate&&e.delegate!==o?e.delegate.now():i()}))||this;return o.actions=[],o.active=!1,o.scheduled=void 0,o}return i.__extends(e,t),e.prototype.schedule=function(r,i,n){return void 0===i&&(i=0),e.delegate&&e.delegate!==this?e.delegate.schedule(r,i,n):t.prototype.schedule.call(this,r,i,n)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var r;this.active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(n.Scheduler)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Scheduler:()=>i});var i=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t.now=function(){return Date.now()},t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{QueueAction:()=>n});var i=r(110),n=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return i.__extends(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,i):e.flush(this)},e}(r(146).AsyncAction)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsyncAction:()=>n});var i=r(110),n=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return i.__extends(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r=!1,i=void 0;try{this.work(t)}catch(t){r=!0,i=!!t&&t||new Error(t)}if(r)return this.unsubscribe(),i},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,i=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==i&&r.splice(i,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(r(147).Action)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Action:()=>n});var i=r(110),n=function(t){function e(e,r){return t.call(this)||this}return i.__extends(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(r(115).Subscription)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsyncSubject:()=>s});var i=r(110),n=r(126),o=r(115),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return i.__extends(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),o.Subscription.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),o.Subscription.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(n.Subject)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{asap:()=>o,asapScheduler:()=>n});var i=r(151),n=new(r(150).AsapScheduler)(i.AsapAction),o=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsapScheduler:()=>n});var i=r(110),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,i=-1,n=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++i{"use strict";r.r(e),r.d(e,{AsapAction:()=>o});var i=r(110),n=r(152),o=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return i.__extends(e,t),e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e.scheduled||(e.scheduled=n.Immediate.setImmediate(e.flush.bind(e,null))))},e.prototype.recycleAsyncId=function(e,r,i){if(void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);0===e.actions.length&&(n.Immediate.clearImmediate(r),e.scheduled=void 0)},e}(r(146).AsyncAction)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Immediate:()=>a,TestTools:()=>h});var i=1,n=function(){return Promise.resolve()}(),o={};function s(t){return t in o&&(delete o[t],!0)}var a={setImmediate:function(t){var e=i++;return o[e]=!0,n.then((function(){return s(e)&&t()})),e},clearImmediate:function(t){s(t)}},h={pending:function(){return Object.keys(o).length}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{async:()=>o,asyncScheduler:()=>n});var i=r(146),n=new(r(143).AsyncScheduler)(i.AsyncAction),o=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{animationFrame:()=>o,animationFrameScheduler:()=>n});var i=r(156),n=new(r(155).AnimationFrameScheduler)(i.AnimationFrameAction),o=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AnimationFrameScheduler:()=>n});var i=r(110),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,i=-1,n=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++i{"use strict";r.r(e),r.d(e,{AnimationFrameAction:()=>n});var i=r(110),n=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return i.__extends(e,t),e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,r,i){if(void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);0===e.actions.length&&(cancelAnimationFrame(r),e.scheduled=void 0)},e}(r(146).AsyncAction)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{VirtualAction:()=>s,VirtualTimeScheduler:()=>o});var i=r(110),n=r(146),o=function(t){function e(e,r){void 0===e&&(e=s),void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this,e,(function(){return i.frame}))||this;return i.maxFrames=r,i.frame=0,i.index=-1,i}return i.__extends(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,i=this.maxFrames;(e=r[0])&&e.delay<=i&&(r.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(r(143).AsyncScheduler),s=function(t){function e(e,r,i){void 0===i&&(i=e.index+=1);var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.index=i,n.active=!0,n.index=e.index=i,n}return i.__extends(e,t),e.prototype.schedule=function(r,i){if(void 0===i&&(i=0),!this.id)return t.prototype.schedule.call(this,r,i);this.active=!1;var n=new e(this.scheduler,this.work);return this.add(n),n.schedule(r,i)},e.prototype.requestAsyncId=function(t,r,i){void 0===i&&(i=0),this.delay=t.frame+i;var n=t.actions;return n.push(this),n.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,r){void 0===r&&(r=0)},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(n.AsyncAction)},(t,e,r)=>{"use strict";function i(){}r.r(e),r.d(e,{noop:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isObservable:()=>n});var i=r(107);function n(t){return!!t&&(t instanceof i.Observable||"function"==typeof t.lift&&"function"==typeof t.subscribe)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ArgumentOutOfRangeError:()=>i});var i=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{EmptyError:()=>i});var i=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{TimeoutError:()=>i});var i=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{bindCallback:()=>u});var i=r(107),n=r(148),o=r(164),s=r(120),a=r(118),h=r(135);function u(t,e,r){if(e){if(!(0,h.isScheduler)(e))return function(){for(var i=[],n=0;n{"use strict";r.r(e),r.d(e,{MapOperator:()=>s,map:()=>o});var i=r(110),n=r(109);function o(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new s(t,e))}}var s=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.project,this.thisArg))},t}(),a=function(t){function e(e,r,i){var n=t.call(this,e)||this;return n.project=r,n.count=0,n.thisArg=i||n,n}return i.__extends(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{bindNodeCallback:()=>u});var i=r(107),n=r(148),o=r(164),s=r(120),a=r(135),h=r(118);function u(t,e,r){if(e){if(!(0,a.isScheduler)(e))return function(){for(var i=[],n=0;n{"use strict";r.r(e),r.d(e,{CombineLatestOperator:()=>c,CombineLatestSubscriber:()=>f,combineLatest:()=>l});var i=r(110),n=r(135),o=r(118),s=r(176),a=r(167),h=r(137),u={};function l(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{subscribeToResult:()=>s});var i=r(168),n=r(169),o=r(107);function s(t,e,r,s,a){if(void 0===a&&(a=new i.InnerSubscriber(t,r,s)),!a.closed)return e instanceof o.Observable?e.subscribe(a):(0,n.subscribeTo)(e)(a)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{InnerSubscriber:()=>n});var i=r(110),n=function(t){function e(e,r,i){var n=t.call(this)||this;return n.parent=e,n.outerValue=r,n.outerIndex=i,n.index=0,n}return i.__extends(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(r(109).Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeTo:()=>f});var i=r(138),n=r(173),o=r(175),s=r(170),a=r(171),h=r(172),u=r(119),l=r(174),c=r(121),f=function(t){if(t&&"function"==typeof t[c.observable])return(0,s.subscribeToObservable)(t);if((0,a.isArrayLike)(t))return(0,i.subscribeToArray)(t);if((0,h.isPromise)(t))return(0,n.subscribeToPromise)(t);if(t&&"function"==typeof t[l.iterator])return(0,o.subscribeToIterable)(t);var e=(0,u.isObject)(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+e+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToObservable:()=>n});var i=r(121),n=function(t){return function(e){var r=t[i.observable]();if("function"!=typeof r.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return r.subscribe(e)}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isArrayLike:()=>i});var i=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},(t,e,r)=>{"use strict";function i(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}r.r(e),r.d(e,{isPromise:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToPromise:()=>n});var i=r(113),n=function(t){return function(e){return t.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,i.hostReportError),e}}},(t,e,r)=>{"use strict";function i(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}r.r(e),r.d(e,{$$iterator:()=>o,getSymbolIterator:()=>i,iterator:()=>n});var n=i(),o=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToIterable:()=>n});var i=r(174),n=function(t){return function(e){for(var r=t[i.iterator]();;){var n=void 0;try{n=r.next()}catch(t){return e.error(t),e}if(n.done){e.complete();break}if(e.next(n.value),e.closed)break}return"function"==typeof r.return&&e.add((function(){r.return&&r.return()})),e}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{OuterSubscriber:()=>n});var i=r(110),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.notifyNext=function(t,e,r,i,n){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(r(109).Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{concat:()=>o});var i=r(134),n=r(178);function o(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{concatAll:()=>n});var i=r(179);function n(){return(0,i.mergeAll)(1)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{mergeAll:()=>o});var i=r(180),n=r(123);function o(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),(0,i.mergeMap)(n.identity,t)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{MergeMapOperator:()=>h,MergeMapSubscriber:()=>u,flatMap:()=>l,mergeMap:()=>a});var i=r(110),n=r(164),o=r(181),s=r(188);function a(t,e,r){return void 0===r&&(r=Number.POSITIVE_INFINITY),"function"==typeof e?function(i){return i.pipe(a((function(r,i){return(0,o.from)(t(r,i)).pipe((0,n.map)((function(t,n){return e(r,t,i,n)})))}),r))}:("number"==typeof e&&(r=e),function(e){return e.lift(new h(t,r))})}var h=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.project,this.concurrent))},t}(),u=function(t){function e(e,r,i){void 0===i&&(i=Number.POSITIVE_INFINITY);var n=t.call(this,e)||this;return n.project=r,n.concurrent=i,n.hasCompleted=!1,n.buffer=[],n.active=0,n.index=0,n}return i.__extends(e,t),e.prototype._next=function(t){this.active0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(s.SimpleOuterSubscriber),l=a},(t,e,r)=>{"use strict";r.r(e),r.d(e,{from:()=>s});var i=r(107),n=r(169),o=r(182);function s(t,e){return e?(0,o.scheduled)(t,e):t instanceof i.Observable?t:new i.Observable((0,n.subscribeTo)(t))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduled:()=>c});var i=r(184),n=r(185),o=r(136),s=r(187),a=r(183),h=r(172),u=r(171),l=r(186);function c(t,e){if(null!=t){if((0,a.isInteropObservable)(t))return(0,i.scheduleObservable)(t,e);if((0,h.isPromise)(t))return(0,n.schedulePromise)(t,e);if((0,u.isArrayLike)(t))return(0,o.scheduleArray)(t,e);if((0,l.isIterable)(t)||"string"==typeof t)return(0,s.scheduleIterable)(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isInteropObservable:()=>n});var i=r(121);function n(t){return t&&"function"==typeof t[i.observable]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduleObservable:()=>s});var i=r(107),n=r(115),o=r(121);function s(t,e){return new i.Observable((function(r){var i=new n.Subscription;return i.add(e.schedule((function(){var n=t[o.observable]();i.add(n.subscribe({next:function(t){i.add(e.schedule((function(){return r.next(t)})))},error:function(t){i.add(e.schedule((function(){return r.error(t)})))},complete:function(){i.add(e.schedule((function(){return r.complete()})))}}))}))),i}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{schedulePromise:()=>o});var i=r(107),n=r(115);function o(t,e){return new i.Observable((function(r){var i=new n.Subscription;return i.add(e.schedule((function(){return t.then((function(t){i.add(e.schedule((function(){r.next(t),i.add(e.schedule((function(){return r.complete()})))})))}),(function(t){i.add(e.schedule((function(){return r.error(t)})))}))}))),i}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isIterable:()=>n});var i=r(174);function n(t){return t&&"function"==typeof t[i.iterator]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduleIterable:()=>s});var i=r(107),n=r(115),o=r(174);function s(t,e){if(!t)throw new Error("Iterable cannot be null");return new i.Observable((function(r){var i,s=new n.Subscription;return s.add((function(){i&&"function"==typeof i.return&&i.return()})),s.add(e.schedule((function(){i=t[o.iterator](),s.add(e.schedule((function(){if(!r.closed){var t,e;try{var n=i.next();t=n.value,e=n.done}catch(t){return void r.error(t)}e?r.complete():(r.next(t),this.schedule())}})))}))),s}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ComplexInnerSubscriber:()=>h,ComplexOuterSubscriber:()=>l,SimpleInnerSubscriber:()=>a,SimpleOuterSubscriber:()=>u,innerSubscribe:()=>c});var i=r(110),n=r(109),o=r(107),s=r(169),a=function(t){function e(e){var r=t.call(this)||this;return r.parent=e,r}return i.__extends(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(n.Subscriber),h=function(t){function e(e,r,i){var n=t.call(this)||this;return n.parent=e,n.outerValue=r,n.outerIndex=i,n}return i.__extends(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(n.Subscriber),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(n.Subscriber),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.notifyNext=function(t,e,r,i){this.destination.next(e)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(n.Subscriber);function c(t,e){if(!e.closed){if(t instanceof o.Observable)return t.subscribe(e);var r;try{r=(0,s.subscribeTo)(t)(e)}catch(t){e.error(t)}return r}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{defer:()=>s});var i=r(107),n=r(181),o=r(140);function s(t){return new i.Observable((function(e){var r;try{r=t()}catch(t){return void e.error(t)}return(r?(0,n.from)(r):(0,o.empty)()).subscribe(e)}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{forkJoin:()=>h});var i=r(107),n=r(118),o=r(164),s=r(119),a=r(181);function h(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{fromEvent:()=>a});var i=r(107),n=r(118),o=r(116),s=r(164);function a(t,e,r,u){return(0,o.isFunction)(r)&&(u=r,r=void 0),u?a(t,e,r).pipe((0,s.map)((function(t){return(0,n.isArray)(t)?u.apply(void 0,t):u(t)}))):new i.Observable((function(i){h(t,e,(function(t){arguments.length>1?i.next(Array.prototype.slice.call(arguments)):i.next(t)}),i,r)}))}function h(t,e,r,i,n){var o;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var s=t;t.addEventListener(e,r,n),o=function(){return s.removeEventListener(e,r,n)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,r),o=function(){return a.off(e,r)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var u=t;t.addListener(e,r),o=function(){return u.removeListener(e,r)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var l=0,c=t.length;l{"use strict";r.r(e),r.d(e,{fromEventPattern:()=>a});var i=r(107),n=r(118),o=r(116),s=r(164);function a(t,e,r){return r?a(t,e).pipe((0,s.map)((function(t){return(0,n.isArray)(t)?r.apply(void 0,t):r(t)}))):new i.Observable((function(r){var i,n=function(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{generate:()=>s});var i=r(107),n=r(123),o=r(135);function s(t,e,r,s,h){var u,l;if(1==arguments.length){var c=t;l=c.initialState,e=c.condition,r=c.iterate,u=c.resultSelector||n.identity,h=c.scheduler}else void 0===s||(0,o.isScheduler)(s)?(l=t,u=n.identity,h=s):(l=t,u=s);return new i.Observable((function(t){var i=l;if(h)return h.schedule(a,0,{subscriber:t,iterate:r,condition:e,resultSelector:u,state:i});for(;;){if(e){var n=void 0;try{n=e(i)}catch(e){return void t.error(e)}if(!n){t.complete();break}}var o=void 0;try{o=u(i)}catch(e){return void t.error(e)}if(t.next(o),t.closed)break;try{i=r(i)}catch(e){return void t.error(e)}}}))}function a(t){var e=t.subscriber,r=t.condition;if(!e.closed){if(t.needIterate)try{t.state=t.iterate(t.state)}catch(t){return void e.error(t)}else t.needIterate=!0;if(r){var i=void 0;try{i=r(t.state)}catch(t){return void e.error(t)}if(!i)return void e.complete();if(e.closed)return}var n;try{n=t.resultSelector(t.state)}catch(t){return void e.error(t)}if(!e.closed&&(e.next(n),!e.closed))return this.schedule(t)}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{iif:()=>o});var i=r(189),n=r(140);function o(t,e,r){return void 0===e&&(e=n.EMPTY),void 0===r&&(r=n.EMPTY),(0,i.defer)((function(){return t()?e:r}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{interval:()=>s});var i=r(107),n=r(153),o=r(196);function s(t,e){return void 0===t&&(t=0),void 0===e&&(e=n.async),(!(0,o.isNumeric)(t)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=n.async),new i.Observable((function(r){return r.add(e.schedule(a,t,{subscriber:r,counter:0,period:t})),r}))}function a(t){var e=t.subscriber,r=t.counter,i=t.period;e.next(r),this.schedule({subscriber:e,counter:r+1,period:i},i)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isNumeric:()=>n});var i=r(118);function n(t){return!(0,i.isArray)(t)&&t-parseFloat(t)+1>=0}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{merge:()=>a});var i=r(107),n=r(135),o=r(179),s=r(137);function a(){for(var t=[],e=0;e1&&"number"==typeof t[t.length-1]&&(r=t.pop())):"number"==typeof h&&(r=t.pop()),null===a&&1===t.length&&t[0]instanceof i.Observable?t[0]:(0,o.mergeAll)(r)((0,s.fromArray)(t,a))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{NEVER:()=>o,never:()=>s});var i=r(107),n=r(158),o=new i.Observable(n.noop);function s(){return o}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{onErrorResumeNext:()=>a});var i=r(107),n=r(181),o=r(118),s=r(140);function a(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{dispatch:()=>s,pairs:()=>o});var i=r(107),n=r(115);function o(t,e){return e?new i.Observable((function(r){var i=Object.keys(t),o=new n.Subscription;return o.add(e.schedule(s,0,{keys:i,index:0,subscriber:r,subscription:o,obj:t})),o})):new i.Observable((function(e){for(var r=Object.keys(t),i=0;i{"use strict";r.r(e),r.d(e,{partition:()=>a});var i=r(203),n=r(169),o=r(202),s=r(107);function a(t,e,r){return[(0,o.filter)(e,r)(new s.Observable((0,n.subscribeTo)(t))),(0,o.filter)((0,i.not)(e,r))(new s.Observable((0,n.subscribeTo)(t)))]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{filter:()=>o});var i=r(110),n=r(109);function o(t,e){return function(r){return r.lift(new s(t,e))}}var s=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.predicate,this.thisArg))},t}(),a=function(t){function e(e,r,i){var n=t.call(this,e)||this;return n.predicate=r,n.thisArg=i,n.count=0,n}return i.__extends(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(n.Subscriber)},(t,e,r)=>{"use strict";function i(t,e){function r(){return!r.pred.apply(r.thisArg,arguments)}return r.pred=t,r.thisArg=e,r}r.r(e),r.d(e,{not:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{RaceOperator:()=>u,RaceSubscriber:()=>l,race:()=>h});var i=r(110),n=r(118),o=r(137),s=r(176),a=r(167);function h(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{dispatch:()=>o,range:()=>n});var i=r(107);function n(t,e,r){return void 0===t&&(t=0),new i.Observable((function(i){void 0===e&&(e=t,t=0);var n=0,s=t;if(r)return r.schedule(o,0,{index:n,count:e,start:t,subscriber:i});for(;;){if(n++>=e){i.complete();break}if(i.next(s++),i.closed)break}}))}function o(t){var e=t.start,r=t.index,i=t.count,n=t.subscriber;r>=i?n.complete():(n.next(e),n.closed||(t.index=r+1,t.start=e+1,this.schedule(t)))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{timer:()=>a});var i=r(107),n=r(153),o=r(196),s=r(135);function a(t,e,r){void 0===t&&(t=0);var a=-1;return(0,o.isNumeric)(e)?a=Number(e)<1?1:Number(e):(0,s.isScheduler)(e)&&(r=e),(0,s.isScheduler)(r)||(r=n.async),new i.Observable((function(e){var i=(0,o.isNumeric)(t)?t:+t-r.now();return r.schedule(h,i,{index:0,period:a,subscriber:e})}))}function h(t){var e=t.index,r=t.period,i=t.subscriber;if(i.next(e),!i.closed){if(-1===r)return i.complete();t.index=e+1,this.schedule(t,r)}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{using:()=>s});var i=r(107),n=r(181),o=r(140);function s(t,e){return new i.Observable((function(r){var i,s;try{i=t()}catch(t){return void r.error(t)}try{s=e(i)}catch(t){return void r.error(t)}var a=(s?(0,n.from)(s):o.EMPTY).subscribe(r);return function(){a.unsubscribe(),i&&i.unsubscribe()}}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ZipOperator:()=>l,ZipSubscriber:()=>c,zip:()=>u});var i=r(110),n=r(137),o=r(118),s=r(109),a=r(174),h=r(188);function u(){for(var t=[],e=0;ethis.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),p=function(t){function e(e,r,i){var n=t.call(this,e)||this;return n.parent=r,n.observable=i,n.stillUnsubscribed=!0,n.buffer=[],n.isComplete=!1,n}return i.__extends(e,t),e.prototype[a.iterator]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return(0,h.innerSubscribe)(this.observable,new h.SimpleInnerSubscriber(this))},e}(h.SimpleOuterSubscriber)},(t,e,r)=>{"use strict";var i=r(9).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.receiveAPDU=void 0;var n=r(51),o=r(106),s=r(101);e.receiveAPDU=t=>o.Observable.create((e=>{let r=0,o=0,a=i.alloc(0);const h=t.subscribe({complete:()=>{e.error(new n.DisconnectedDevice),h.unsubscribe()},error:t=>{(0,s.log)("ble-error","in receiveAPDU "+String(t)),e.error(t),h.unsubscribe()},next:t=>{const s=t.readUInt8(0),u=t.readUInt16BE(1);let l=t.slice(3);5===s?r===u?(0===u&&(o=l.readUInt16BE(0),l=l.slice(2)),r++,a=i.concat([a,l]),a.length>o?e.error(new n.TransportError("BLE: received too much data. discontinued chunk. Received "+a.length+" but expected "+o,"BLETooMuchData")):a.length===o&&(e.next(a),e.complete(),h.unsubscribe())):e.error(new n.TransportError("BLE: Invalid sequence number. discontinued chunk. Received "+u+" but expected "+r,"InvalidSequence")):e.error(new n.TransportError("Invalid tag "+s.toString(16),"InvalidTag"))}});return()=>{h.unsubscribe()}}))},(t,e,r)=>{"use strict";r.r(e),r.d(e,{monitorCharacteristic:()=>s});var i=r(107),n=r(101),o=r(9).Buffer;const s=t=>i.Observable.create((e=>{function r(t){const r=t.target;r.value&&e.next(o.from(r.value.buffer))}return(0,n.log)("ble-verbose","start monitor "+t.uuid),t.startNotifications().then((()=>{t.addEventListener("characteristicvaluechanged",r)})),()=>{(0,n.log)("ble-verbose","end monitor "+t.uuid),t.stopNotifications()}}))},(t,e,r)=>{"use strict";r.r(e),r.d(e,{tap:()=>a});var i=r(110),n=r(109),o=r(158),s=r(116);function a(t,e,r){return function(i){return i.lift(new h(t,e,r))}}var h=function(){function t(t,e,r){this.nextOrObserver=t,this.error=e,this.complete=r}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.nextOrObserver,this.error,this.complete))},t}(),u=function(t){function e(e,r,i,n){var a=t.call(this,e)||this;return a._tapNext=o.noop,a._tapError=o.noop,a._tapComplete=o.noop,a._tapError=i||o.noop,a._tapComplete=n||o.noop,(0,s.isFunction)(r)?(a._context=a,a._tapNext=r):r&&(a._context=r,a._tapNext=r.next||o.noop,a._tapError=r.error||o.noop,a._tapComplete=r.complete||o.noop),a}return i.__extends(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{share:()=>a});var i=r(213),n=r(125),o=r(126);function s(){return new o.Subject}function a(){return function(t){return(0,n.refCount)()((0,i.multicast)(s)(t))}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{MulticastOperator:()=>o,multicast:()=>n});var i=r(124);function n(t,e){return function(r){var n;if(n="function"==typeof t?t:function(){return t},"function"==typeof e)return r.lift(new o(n,e));var s=Object.create(r,i.connectableObservableDescriptor);return s.source=r,s.subjectFactory=n,s}}var o=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var r=this.selector,i=this.subjectFactory(),n=r(i).subscribe(t);return n.add(e.subscribe(i)),n},t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{first:()=>u});var i=r(161),n=r(202),o=r(215),s=r(216),a=r(217),h=r(123);function u(t,e){var r=arguments.length>=2;return function(u){return u.pipe(t?(0,n.filter)((function(e,r){return t(e,r,u)})):h.identity,(0,o.take)(1),r?(0,s.defaultIfEmpty)(e):(0,a.throwIfEmpty)((function(){return new i.EmptyError})))}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{take:()=>a});var i=r(110),n=r(109),o=r(160),s=r(140);function a(t){return function(e){return 0===t?(0,s.empty)():e.lift(new h(t))}}var h=function(){function t(t){if(this.total=t,this.total<0)throw new o.ArgumentOutOfRangeError}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.total))},t}(),u=function(t){function e(e,r){var i=t.call(this,e)||this;return i.total=r,i.count=0,i}return i.__extends(e,t),e.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{defaultIfEmpty:()=>o});var i=r(110),n=r(109);function o(t){return void 0===t&&(t=null),function(e){return e.lift(new s(t))}}var s=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.defaultValue))},t}(),a=function(t){function e(e,r){var i=t.call(this,e)||this;return i.defaultValue=r,i.isEmpty=!0,i}return i.__extends(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{throwIfEmpty:()=>s});var i=r(110),n=r(161),o=r(109);function s(t){return void 0===t&&(t=u),function(e){return e.lift(new a(t))}}var a=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.errorFactory))},t}(),h=function(t){function e(e,r){var i=t.call(this,e)||this;return i.errorFactory=r,i.hasValue=!1,i}return i.__extends(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(o.Subscriber);function u(){return new n.EmptyError}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ignoreElements:()=>o});var i=r(110),n=r(109);function o(){return function(t){return t.lift(new s)}}var s=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new a(t))},t}(),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype._next=function(t){},e}(n.Subscriber)}],e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),r(0)})()})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.tonweb=e():t.TonWeb=e()}(self,(function(){return(()=>{var t=[(t,e,r)=>{const i=r(1),n=i.Address,s=r(21),o=r(25),a=r(27).default,{Contract:h}=r(26),u=r(30).default,l=r(38).default,c=r(42).default,f=r(45).default,d=r(50).default,{BlockSubscription:p,InMemoryBlockStorage:m}=r(53),{SubscriptionContract:g}=r(56),{Payments:y,PaymentChannel:w}=r(57),v=r(60).default,b=r(115).default,E=r(116).default,{Dns:A,DnsCollection:C,DnsItem:M}=r(231).default,B="0.0.66";class F{constructor(t){this.version=B,this.utils=i,this.Address=n,this.boc=s,this.Contract=h,this.BlockSubscription=p,this.InMemoryBlockStorage=m,this.provider=t||new a,this.dns=new A(this.provider),this.wallet=new u(this.provider),this.payments=new y(this.provider),this.lockupWallet=l}async getTransactions(t,e=20,r,i,n){return this.provider.getTransactions(t.toString(),e,r,i,n)}async getBalance(t){return this.provider.getBalance(t.toString())}async sendBoc(t){return this.provider.sendBoc(i.bytesToBase64(t))}async call(t,e,r=[]){return this.provider.call(t.toString(),e,r)}}F.version=B,F.utils=i,F.Address=n,F.boc=s,F.HttpProvider=a,F.Contract=h,F.Wallets=u,F.LockupWallets=l,F.SubscriptionContract=g,F.BlockSubscription=p,F.InMemoryBlockStorage=m,F.ledger={TransportWebUSB:v,TransportWebHID:b,BluetoothTransport:E,AppTon:o},F.token={nft:f,ft:d,jetton:d},F.HighloadWallets=c,F.dns=A,F.dns.DnsCollection=C,F.dns.DnsItem=M,F.payments=y,F.payments.PaymentChannel=w,t.exports=F},(t,e,r)=>{const{BN:i,nacl:n,sha256:s,fromNano:o,toNano:a,bytesToHex:h,hexToBytes:u,stringToBytes:l,crc32c:c,crc16:f,concatBytes:d,bytesToBase64:p,base64ToBytes:m,base64toString:g,stringToBase64:y,compareBytes:w,readNBytesUIntFromArray:v,keyPairFromSeed:b,newKeyPair:E,newSeed:A}=r(2),C=r(18).default,M=r(19).default,B=r(20).default;t.exports={Address:C,AdnlAddress:M,StorageBagId:B,BN:i,nacl:n,sha256:s,fromNano:o,toNano:a,bytesToHex:h,hexToBytes:u,stringToBytes:l,crc32c:c,crc16:f,concatBytes:d,bytesToBase64:p,base64ToBytes:m,base64toString:g,stringToBase64:y,compareBytes:w,readNBytesUIntFromArray:v,parseTransferUrl:function(t){const e="ton://transfer/";if(!t.startsWith(e))throw new Error("must starts with "+e);const r=t.substring(e.length).split("?");if(r.length>2)throw new Error('multiple "?"');const n=r[0];if(!C.isValid(n))throw new Error("invalid address format "+n);const s={address:n},o=r[1];if(o&&o.length){const t=o.split("&").map((t=>t.split("=")));for(const e of t){if(2!==e.length)throw new Error("invalid url pair");const t=e[0],r=e[1];if("amount"===t){if(s.amount)throw new Error("amount already set");if(new i(r).isNeg())throw new Error("negative amount");s.amount=r}else{if("text"!==t)throw new Error("unknown url var "+t);if(s.text)throw new Error("text already set");s.text=decodeURIComponent(r)}}}return s},formatTransferUrl:function(t,e,r){let i="ton://transfer/"+t;const n=[];return e&&n.push("amount="+e),r&&n.push("text="+encodeURIComponent(r)),0===n.length?i:i+"?"+n.join("&")},keyPairFromSeed:b,newKeyPair:E,newSeed:A}},(t,e,r)=>{var i=r(9).Buffer;const n=r(3),s=r(5),o=r(7),a="undefined"!=typeof self&&self.crypto&&self.crypto.subtle;let h=null;a||(h=r(16));const u=[],l={};for(let t=0;t<=255;t++){let e=t.toString(16);e.length<2&&(e="0"+e),u.push(e),l[e]=t}const c=(()=>{const t=[],e="A".charCodeAt(0),r="a".charCodeAt(0),i="0".charCodeAt(0);for(let r=0;r<26;++r)t.push(String.fromCharCode(e+r));for(let e=0;e<26;++e)t.push(String.fromCharCode(r+e));for(let e=0;e<10;++e)t.push(String.fromCharCode(i+e));return t.push("+"),t.push("/"),t})();function f(t){return"undefined"==typeof self?i.from(t,"base64").toString("binary"):atob(t)}t.exports={BN:n,nacl:s,sha256:function(t){return a?crypto.subtle.digest("SHA-256",t):h.subtle.digest({name:"SHA-256"},t)},fromNano:function(t){if(!n.isBN(t)&&"string"!=typeof t)throw new Error("Please pass numbers as strings or BN objects to avoid precision errors.");return o.fromWei(t,"gwei")},toNano:function(t){if(!n.isBN(t)&&"string"!=typeof t)throw new Error("Please pass numbers as strings or BN objects to avoid precision errors.");return o.toWei(t,"gwei")},bytesToHex:function(t){const e=[];for(let r=0;r>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1)?t>>>1^r:t>>>1;return 4294967295^t}(0,t),r=new ArrayBuffer(4);return new DataView(r).setUint32(0,e,!1),new Uint8Array(r).reverse()},crc16:function(t){let e=0;const r=new Uint8Array(t.length+2);r.set(t);for(let t of r){let r=128;for(;r>0;)e<<=1,t&r&&(e+=1),r>>=1,e>65535&&(e&=65535,e^=4129)}return new Uint8Array([Math.floor(e/256),e%256])},concatBytes:function(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r},bytesToBase64:function(t){let e,r="";const i=t.length;for(e=2;e>2],r+=c[(3&t[e-2])<<4|t[e-1]>>4],r+=c[(15&t[e-1])<<2|t[e]>>6],r+=c[63&t[e]];return e===i+1&&(r+=c[t[e-2]>>2],r+=c[(3&t[e-2])<<4],r+="=="),e===i&&(r+=c[t[e-2]>>2],r+=c[(3&t[e-2])<<4|t[e-1]>>4],r+=c[(15&t[e-1])<<2],r+="="),r},base64ToBytes:function(t){const e=f(t),r=e.length,i=new Uint8Array(r);for(let t=0;t=49&&u<=54?u-49+10:u>=17&&u<=22?u-17+10:u,o|=h}return i(!(240&o),"Invalid character in "+t),n}function h(t,e,r,n){for(var s=0,o=0,a=Math.min(t.length,r),h=e;h=49?u-49+10:u>=17?u-17+10:u,i(u>=0&&o"}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===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):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>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)n=a(t,r,r+6),this.words[i]|=n<>>26-s&4194303,(s+=24)>=26&&(s-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<>>26-s&4194303),this._strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?s.prototype[Symbol.for("nodejs.util.inspect.custom")]=l:s.prototype.inspect=l;var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(s=0|e.words[d])+c)/67108864|0,c=67108863&o}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o>>24-n&16777215)||o!==this.length-1?c[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=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 u=f[t],l=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(l).toString(t);r=(p=p.idivn(l)).isZero()?m+r:c[u-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,n),o},s.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,s=0;n>8&255),r>16&255),6===s?(r>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 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 i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,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,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o>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,m=d>>>13,g=0|o[2],y=8191&g,w=g>>>13,v=0|o[3],b=8191&v,E=v>>>13,A=0|o[4],C=8191&A,M=A>>>13,B=0|o[5],F=8191&B,S=B>>>13,_=0|o[6],D=8191&_,I=_>>>13,x=0|o[7],T=8191&x,N=x>>>13,U=0|o[8],R=8191&U,O=U>>>13,k=0|o[9],L=8191&k,P=k>>>13,j=0|a[0],$=8191&j,q=j>>>13,K=0|a[1],H=8191&K,G=K>>>13,V=0|a[2],W=8191&V,z=V>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,Q=0|a[4],J=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,$))|0)+((8191&(n=(n=Math.imul(c,q))+Math.imul(f,$)|0))<<13)|0;u=((s=Math.imul(f,q))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,q))+Math.imul(m,$)|0,s=Math.imul(m,q);var yt=(u+(i=i+Math.imul(c,H)|0)|0)+((8191&(n=(n=n+Math.imul(c,G)|0)+Math.imul(f,H)|0))<<13)|0;u=((s=s+Math.imul(f,G)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,$),n=(n=Math.imul(y,q))+Math.imul(w,$)|0,s=Math.imul(w,q),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,s=s+Math.imul(m,G)|0;var wt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,z)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,z)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,q))+Math.imul(E,$)|0,s=Math.imul(E,q),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,G)|0)+Math.imul(w,H)|0,s=s+Math.imul(w,G)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(c,Y)|0)|0)+((8191&(n=(n=n+Math.imul(c,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,X)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(C,$),n=(n=Math.imul(C,q))+Math.imul(M,$)|0,s=Math.imul(M,q),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(E,H)|0,s=s+Math.imul(E,G)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var bt=(u+(i=i+Math.imul(c,J)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,J)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(F,$),n=(n=Math.imul(F,q))+Math.imul(S,$)|0,s=Math.imul(S,q),i=i+Math.imul(C,H)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(M,H)|0,s=s+Math.imul(M,G)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,z)|0)+Math.imul(E,W)|0,s=s+Math.imul(E,z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(w,Y)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var Et=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,it)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,$),n=(n=Math.imul(D,q))+Math.imul(I,$)|0,s=Math.imul(I,q),i=i+Math.imul(F,H)|0,n=(n=n+Math.imul(F,G)|0)+Math.imul(S,H)|0,s=s+Math.imul(S,G)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,z)|0)+Math.imul(M,W)|0,s=s+Math.imul(M,z)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var At=(u+(i=i+Math.imul(c,st)|0)|0)+((8191&(n=(n=n+Math.imul(c,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,q))+Math.imul(N,$)|0,s=Math.imul(N,q),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(I,H)|0,s=s+Math.imul(I,G)|0,i=i+Math.imul(F,W)|0,n=(n=n+Math.imul(F,z)|0)+Math.imul(S,W)|0,s=s+Math.imul(S,z)|0,i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(E,J)|0,s=s+Math.imul(E,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var Ct=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(R,$),n=(n=Math.imul(R,q))+Math.imul(O,$)|0,s=Math.imul(O,q),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(N,H)|0,s=s+Math.imul(N,G)|0,i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,z)|0,i=i+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,X)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(C,J)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(M,J)|0,s=s+Math.imul(M,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Mt=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(L,$),n=(n=Math.imul(L,q))+Math.imul(P,$)|0,s=Math.imul(P,q),i=i+Math.imul(R,H)|0,n=(n=n+Math.imul(R,G)|0)+Math.imul(O,H)|0,s=s+Math.imul(O,G)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,z)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,z)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(F,J)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(M,rt)|0,s=s+Math.imul(M,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,ut)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,s=s+Math.imul(m,ft)|0;var Bt=(u+(i=i+Math.imul(c,pt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,G))+Math.imul(P,H)|0,s=Math.imul(P,G),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(C,st)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(w,ct)|0,s=s+Math.imul(w,ft)|0;var Ft=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(L,W),n=(n=Math.imul(L,z))+Math.imul(P,W)|0,s=Math.imul(P,z),i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,X)|0,i=i+Math.imul(T,J)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(F,st)|0,n=(n=n+Math.imul(F,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(E,ct)|0,s=s+Math.imul(E,ft)|0;var St=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(P,Y)|0,s=Math.imul(P,X),i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,J)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(D,st)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,ut)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ft)|0)+Math.imul(M,ct)|0,s=s+Math.imul(M,ft)|0;var _t=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(L,J),n=(n=Math.imul(L,tt))+Math.imul(P,J)|0,s=Math.imul(P,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ut)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(S,ct)|0,s=s+Math.imul(S,ft)|0;var Dt=(u+(i=i+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(P,rt)|0,s=Math.imul(P,it),i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ft)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ft)|0;var It=(u+(i=i+Math.imul(F,pt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(L,st),n=(n=Math.imul(L,ot))+Math.imul(P,st)|0,s=Math.imul(P,ot),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,ct)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,ft)|0;var xt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,ut))+Math.imul(P,ht)|0,s=Math.imul(P,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(O,ct)|0,s=s+Math.imul(O,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ft))+Math.imul(P,ct)|0,s=Math.imul(P,ft);var Nt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Ut=(u+(i=Math.imul(L,pt))|0)+((8191&(n=(n=Math.imul(L,mt))+Math.imul(P,pt)|0))<<13)|0;return u=((s=Math.imul(P,mt))+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=Et,h[6]=At,h[7]=Ct,h[8]=Mt,h[9]=Bt,h[10]=Ft,h[11]=St,h[12]=_t,h[13]=Dt,h[14]=It,h[15]=xt,h[16]=Tt,h[17]=Nt,h[18]=Ut,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}function w(t,e){this.x=t,this.y=e}Math.imul||(m=p),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):y(this,t,e)},w.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i>=1;return i},w.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),e?this.ineg():this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n&1}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=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!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-s|c>>>s,l=c&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var f=67108864*(0|i.words[n.length+c])+(0|i.words[n.length+c-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(n,f,c);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=f)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%t;return e?-n:n},s.prototype.modn=function(t){return this.modrn(t)},s.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/t|0,r=s%t}return this._strip(),e?this.ineg():this},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(l),o.isub(c)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(c)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var c=0,f=1;0==(r.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 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){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=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),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(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 B(t)},s.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={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 E(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function C(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function B(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function F(t){B.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(E,b),E.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},E.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]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new E;else if("p224"===t)e=new A;else if("p192"===t)e=new C;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return v[t]=e,e},B.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},B.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},B.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},B.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},B.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)},B.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},B.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)},B.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},B.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},B.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},B.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},B.prototype.isqr=function(t){return this.imul(t,t.clone())},B.prototype.sqr=function(t){return this.mul(t,t)},B.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==c||0!==o?(o<<=1,o|=c,(4==++a||0===i&&0===l)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},B.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},B.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new F(t)},n(F,B),F.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},F.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},F.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},F.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},F.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},()=>{},(t,e,r)=>{!function(t){"use strict";var e=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=i>>24&255,t[e+5]=i>>16&255,t[e+6]=i>>8&255,t[e+7]=255&i}function m(t,e,r,i,n){var s,o=0;for(s=0;s>>8)-1}function g(t,e,r,i){return m(t,e,r,i,16)}function y(t,e,r,i){return m(t,e,r,i,32)}function w(t,e,r,i){!function(t,e,r,i){for(var n,s=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,h=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,l=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,m=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,y=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,E=s,A=o,C=a,M=h,B=u,F=l,S=c,_=f,D=d,I=p,x=m,T=g,N=y,U=w,R=v,O=b,k=0;k<20;k+=2)E^=(n=(N^=(n=(D^=(n=(B^=(n=E+N|0)<<7|n>>>25)+E|0)<<9|n>>>23)+B|0)<<13|n>>>19)+D|0)<<18|n>>>14,F^=(n=(A^=(n=(U^=(n=(I^=(n=F+A|0)<<7|n>>>25)+F|0)<<9|n>>>23)+I|0)<<13|n>>>19)+U|0)<<18|n>>>14,x^=(n=(S^=(n=(C^=(n=(R^=(n=x+S|0)<<7|n>>>25)+x|0)<<9|n>>>23)+R|0)<<13|n>>>19)+C|0)<<18|n>>>14,O^=(n=(T^=(n=(_^=(n=(M^=(n=O+T|0)<<7|n>>>25)+O|0)<<9|n>>>23)+M|0)<<13|n>>>19)+_|0)<<18|n>>>14,E^=(n=(M^=(n=(C^=(n=(A^=(n=E+M|0)<<7|n>>>25)+E|0)<<9|n>>>23)+A|0)<<13|n>>>19)+C|0)<<18|n>>>14,F^=(n=(B^=(n=(_^=(n=(S^=(n=F+B|0)<<7|n>>>25)+F|0)<<9|n>>>23)+S|0)<<13|n>>>19)+_|0)<<18|n>>>14,x^=(n=(I^=(n=(D^=(n=(T^=(n=x+I|0)<<7|n>>>25)+x|0)<<9|n>>>23)+T|0)<<13|n>>>19)+D|0)<<18|n>>>14,O^=(n=(R^=(n=(U^=(n=(N^=(n=O+R|0)<<7|n>>>25)+O|0)<<9|n>>>23)+N|0)<<13|n>>>19)+U|0)<<18|n>>>14;E=E+s|0,A=A+o|0,C=C+a|0,M=M+h|0,B=B+u|0,F=F+l|0,S=S+c|0,_=_+f|0,D=D+d|0,I=I+p|0,x=x+m|0,T=T+g|0,N=N+y|0,U=U+w|0,R=R+v|0,O=O+b|0,t[0]=E>>>0&255,t[1]=E>>>8&255,t[2]=E>>>16&255,t[3]=E>>>24&255,t[4]=A>>>0&255,t[5]=A>>>8&255,t[6]=A>>>16&255,t[7]=A>>>24&255,t[8]=C>>>0&255,t[9]=C>>>8&255,t[10]=C>>>16&255,t[11]=C>>>24&255,t[12]=M>>>0&255,t[13]=M>>>8&255,t[14]=M>>>16&255,t[15]=M>>>24&255,t[16]=B>>>0&255,t[17]=B>>>8&255,t[18]=B>>>16&255,t[19]=B>>>24&255,t[20]=F>>>0&255,t[21]=F>>>8&255,t[22]=F>>>16&255,t[23]=F>>>24&255,t[24]=S>>>0&255,t[25]=S>>>8&255,t[26]=S>>>16&255,t[27]=S>>>24&255,t[28]=_>>>0&255,t[29]=_>>>8&255,t[30]=_>>>16&255,t[31]=_>>>24&255,t[32]=D>>>0&255,t[33]=D>>>8&255,t[34]=D>>>16&255,t[35]=D>>>24&255,t[36]=I>>>0&255,t[37]=I>>>8&255,t[38]=I>>>16&255,t[39]=I>>>24&255,t[40]=x>>>0&255,t[41]=x>>>8&255,t[42]=x>>>16&255,t[43]=x>>>24&255,t[44]=T>>>0&255,t[45]=T>>>8&255,t[46]=T>>>16&255,t[47]=T>>>24&255,t[48]=N>>>0&255,t[49]=N>>>8&255,t[50]=N>>>16&255,t[51]=N>>>24&255,t[52]=U>>>0&255,t[53]=U>>>8&255,t[54]=U>>>16&255,t[55]=U>>>24&255,t[56]=R>>>0&255,t[57]=R>>>8&255,t[58]=R>>>16&255,t[59]=R>>>24&255,t[60]=O>>>0&255,t[61]=O>>>8&255,t[62]=O>>>16&255,t[63]=O>>>24&255}(t,e,r,i)}function v(t,e,r,i){!function(t,e,r,i){for(var n,s=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,h=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,l=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,m=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,y=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,b=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,E=0;E<20;E+=2)s^=(n=(y^=(n=(d^=(n=(u^=(n=s+y|0)<<7|n>>>25)+s|0)<<9|n>>>23)+u|0)<<13|n>>>19)+d|0)<<18|n>>>14,l^=(n=(o^=(n=(w^=(n=(p^=(n=l+o|0)<<7|n>>>25)+l|0)<<9|n>>>23)+p|0)<<13|n>>>19)+w|0)<<18|n>>>14,m^=(n=(c^=(n=(a^=(n=(v^=(n=m+c|0)<<7|n>>>25)+m|0)<<9|n>>>23)+v|0)<<13|n>>>19)+a|0)<<18|n>>>14,b^=(n=(g^=(n=(f^=(n=(h^=(n=b+g|0)<<7|n>>>25)+b|0)<<9|n>>>23)+h|0)<<13|n>>>19)+f|0)<<18|n>>>14,s^=(n=(h^=(n=(a^=(n=(o^=(n=s+h|0)<<7|n>>>25)+s|0)<<9|n>>>23)+o|0)<<13|n>>>19)+a|0)<<18|n>>>14,l^=(n=(u^=(n=(f^=(n=(c^=(n=l+u|0)<<7|n>>>25)+l|0)<<9|n>>>23)+c|0)<<13|n>>>19)+f|0)<<18|n>>>14,m^=(n=(p^=(n=(d^=(n=(g^=(n=m+p|0)<<7|n>>>25)+m|0)<<9|n>>>23)+g|0)<<13|n>>>19)+d|0)<<18|n>>>14,b^=(n=(v^=(n=(w^=(n=(y^=(n=b+v|0)<<7|n>>>25)+b|0)<<9|n>>>23)+y|0)<<13|n>>>19)+w|0)<<18|n>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=l>>>0&255,t[5]=l>>>8&255,t[6]=l>>>16&255,t[7]=l>>>24&255,t[8]=m>>>0&255,t[9]=m>>>8&255,t[10]=m>>>16&255,t[11]=m>>>24&255,t[12]=b>>>0&255,t[13]=b>>>8&255,t[14]=b>>>16&255,t[15]=b>>>24&255,t[16]=c>>>0&255,t[17]=c>>>8&255,t[18]=c>>>16&255,t[19]=c>>>24&255,t[20]=f>>>0&255,t[21]=f>>>8&255,t[22]=f>>>16&255,t[23]=f>>>24&255,t[24]=d>>>0&255,t[25]=d>>>8&255,t[26]=d>>>16&255,t[27]=d>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,r,i)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function E(t,e,r,i,n,s,o){var a,h,u=new Uint8Array(16),l=new Uint8Array(64);for(h=0;h<16;h++)u[h]=0;for(h=0;h<8;h++)u[h]=s[h];for(;n>=64;){for(w(l,u,o,b),h=0;h<64;h++)t[e+h]=r[i+h]^l[h];for(a=1,h=8;h<16;h++)a=a+(255&u[h])|0,u[h]=255&a,a>>>=8;n-=64,e+=64,i+=64}if(n>0)for(w(l,u,o,b),h=0;h=64;){for(w(h,a,n,b),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;r-=64,e+=64}if(r>0)for(w(h,a,n,b),o=0;o>>13|r<<3),i=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|i<<6),n=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(i>>>7|n<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(n>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function F(t,e,r,i,n,s){var o=new B(s);return o.update(r,i,n),o.finish(t,e),0}function S(t,e,r,i,n,s){var o=new Uint8Array(16);return F(o,0,r,i,n,s),g(t,e,o,0)}function _(t,e,r,i,n){var s;if(r<32)return-1;for(M(t,0,e,0,r,i,n),F(t,16,t,32,r-32,t),s=0;s<16;s++)t[s]=0;return 0}function D(t,e,r,i,n){var s,o=new Uint8Array(32);if(r<32)return-1;if(C(o,0,32,i,n),0!==S(e,16,e,32,r-32,o))return-1;for(M(t,0,e,0,r,i,n),s=0;s<32;s++)t[s]=0;return 0}function I(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function x(t){var e,r,i=1;for(e=0;e<16;e++)r=t[e]+i+65535,i=Math.floor(r/65536),t[e]=r-65536*i;t[0]+=i-1+37*(i-1)}function T(t,e,r){for(var i,n=~(r-1),s=0;s<16;s++)i=n&(t[s]^e[s]),t[s]^=i,e[s]^=i}function N(t,r){var i,n,s,o=e(),a=e();for(i=0;i<16;i++)a[i]=r[i];for(x(a),x(a),x(a),n=0;n<2;n++){for(o[0]=a[0]-65517,i=1;i<15;i++)o[i]=a[i]-65535-(o[i-1]>>16&1),o[i-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,T(a,o,1-s)}for(i=0;i<16;i++)t[2*i]=255&a[i],t[2*i+1]=a[i]>>8}function U(t,e){var r=new Uint8Array(32),i=new Uint8Array(32);return N(r,t),N(i,e),y(r,0,i,0)}function R(t){var e=new Uint8Array(32);return N(e,t),1&e[0]}function O(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function k(t,e,r){for(var i=0;i<16;i++)t[i]=e[i]+r[i]}function L(t,e,r){for(var i=0;i<16;i++)t[i]=e[i]-r[i]}function P(t,e,r){var i,n,s=0,o=0,a=0,h=0,u=0,l=0,c=0,f=0,d=0,p=0,m=0,g=0,y=0,w=0,v=0,b=0,E=0,A=0,C=0,M=0,B=0,F=0,S=0,_=0,D=0,I=0,x=0,T=0,N=0,U=0,R=0,O=r[0],k=r[1],L=r[2],P=r[3],j=r[4],$=r[5],q=r[6],K=r[7],H=r[8],G=r[9],V=r[10],W=r[11],z=r[12],Z=r[13],Y=r[14],X=r[15];s+=(i=e[0])*O,o+=i*k,a+=i*L,h+=i*P,u+=i*j,l+=i*$,c+=i*q,f+=i*K,d+=i*H,p+=i*G,m+=i*V,g+=i*W,y+=i*z,w+=i*Z,v+=i*Y,b+=i*X,o+=(i=e[1])*O,a+=i*k,h+=i*L,u+=i*P,l+=i*j,c+=i*$,f+=i*q,d+=i*K,p+=i*H,m+=i*G,g+=i*V,y+=i*W,w+=i*z,v+=i*Z,b+=i*Y,E+=i*X,a+=(i=e[2])*O,h+=i*k,u+=i*L,l+=i*P,c+=i*j,f+=i*$,d+=i*q,p+=i*K,m+=i*H,g+=i*G,y+=i*V,w+=i*W,v+=i*z,b+=i*Z,E+=i*Y,A+=i*X,h+=(i=e[3])*O,u+=i*k,l+=i*L,c+=i*P,f+=i*j,d+=i*$,p+=i*q,m+=i*K,g+=i*H,y+=i*G,w+=i*V,v+=i*W,b+=i*z,E+=i*Z,A+=i*Y,C+=i*X,u+=(i=e[4])*O,l+=i*k,c+=i*L,f+=i*P,d+=i*j,p+=i*$,m+=i*q,g+=i*K,y+=i*H,w+=i*G,v+=i*V,b+=i*W,E+=i*z,A+=i*Z,C+=i*Y,M+=i*X,l+=(i=e[5])*O,c+=i*k,f+=i*L,d+=i*P,p+=i*j,m+=i*$,g+=i*q,y+=i*K,w+=i*H,v+=i*G,b+=i*V,E+=i*W,A+=i*z,C+=i*Z,M+=i*Y,B+=i*X,c+=(i=e[6])*O,f+=i*k,d+=i*L,p+=i*P,m+=i*j,g+=i*$,y+=i*q,w+=i*K,v+=i*H,b+=i*G,E+=i*V,A+=i*W,C+=i*z,M+=i*Z,B+=i*Y,F+=i*X,f+=(i=e[7])*O,d+=i*k,p+=i*L,m+=i*P,g+=i*j,y+=i*$,w+=i*q,v+=i*K,b+=i*H,E+=i*G,A+=i*V,C+=i*W,M+=i*z,B+=i*Z,F+=i*Y,S+=i*X,d+=(i=e[8])*O,p+=i*k,m+=i*L,g+=i*P,y+=i*j,w+=i*$,v+=i*q,b+=i*K,E+=i*H,A+=i*G,C+=i*V,M+=i*W,B+=i*z,F+=i*Z,S+=i*Y,_+=i*X,p+=(i=e[9])*O,m+=i*k,g+=i*L,y+=i*P,w+=i*j,v+=i*$,b+=i*q,E+=i*K,A+=i*H,C+=i*G,M+=i*V,B+=i*W,F+=i*z,S+=i*Z,_+=i*Y,D+=i*X,m+=(i=e[10])*O,g+=i*k,y+=i*L,w+=i*P,v+=i*j,b+=i*$,E+=i*q,A+=i*K,C+=i*H,M+=i*G,B+=i*V,F+=i*W,S+=i*z,_+=i*Z,D+=i*Y,I+=i*X,g+=(i=e[11])*O,y+=i*k,w+=i*L,v+=i*P,b+=i*j,E+=i*$,A+=i*q,C+=i*K,M+=i*H,B+=i*G,F+=i*V,S+=i*W,_+=i*z,D+=i*Z,I+=i*Y,x+=i*X,y+=(i=e[12])*O,w+=i*k,v+=i*L,b+=i*P,E+=i*j,A+=i*$,C+=i*q,M+=i*K,B+=i*H,F+=i*G,S+=i*V,_+=i*W,D+=i*z,I+=i*Z,x+=i*Y,T+=i*X,w+=(i=e[13])*O,v+=i*k,b+=i*L,E+=i*P,A+=i*j,C+=i*$,M+=i*q,B+=i*K,F+=i*H,S+=i*G,_+=i*V,D+=i*W,I+=i*z,x+=i*Z,T+=i*Y,N+=i*X,v+=(i=e[14])*O,b+=i*k,E+=i*L,A+=i*P,C+=i*j,M+=i*$,B+=i*q,F+=i*K,S+=i*H,_+=i*G,D+=i*V,I+=i*W,x+=i*z,T+=i*Z,N+=i*Y,U+=i*X,b+=(i=e[15])*O,o+=38*(A+=i*L),a+=38*(C+=i*P),h+=38*(M+=i*j),u+=38*(B+=i*$),l+=38*(F+=i*q),c+=38*(S+=i*K),f+=38*(_+=i*H),d+=38*(D+=i*G),p+=38*(I+=i*V),m+=38*(x+=i*W),g+=38*(T+=i*z),y+=38*(N+=i*Z),w+=38*(U+=i*Y),v+=38*(R+=i*X),s=(i=(s+=38*(E+=i*k))+(n=1)+65535)-65536*(n=Math.floor(i/65536)),o=(i=o+n+65535)-65536*(n=Math.floor(i/65536)),a=(i=a+n+65535)-65536*(n=Math.floor(i/65536)),h=(i=h+n+65535)-65536*(n=Math.floor(i/65536)),u=(i=u+n+65535)-65536*(n=Math.floor(i/65536)),l=(i=l+n+65535)-65536*(n=Math.floor(i/65536)),c=(i=c+n+65535)-65536*(n=Math.floor(i/65536)),f=(i=f+n+65535)-65536*(n=Math.floor(i/65536)),d=(i=d+n+65535)-65536*(n=Math.floor(i/65536)),p=(i=p+n+65535)-65536*(n=Math.floor(i/65536)),m=(i=m+n+65535)-65536*(n=Math.floor(i/65536)),g=(i=g+n+65535)-65536*(n=Math.floor(i/65536)),y=(i=y+n+65535)-65536*(n=Math.floor(i/65536)),w=(i=w+n+65535)-65536*(n=Math.floor(i/65536)),v=(i=v+n+65535)-65536*(n=Math.floor(i/65536)),b=(i=b+n+65535)-65536*(n=Math.floor(i/65536)),s=(i=(s+=n-1+37*(n-1))+(n=1)+65535)-65536*(n=Math.floor(i/65536)),o=(i=o+n+65535)-65536*(n=Math.floor(i/65536)),a=(i=a+n+65535)-65536*(n=Math.floor(i/65536)),h=(i=h+n+65535)-65536*(n=Math.floor(i/65536)),u=(i=u+n+65535)-65536*(n=Math.floor(i/65536)),l=(i=l+n+65535)-65536*(n=Math.floor(i/65536)),c=(i=c+n+65535)-65536*(n=Math.floor(i/65536)),f=(i=f+n+65535)-65536*(n=Math.floor(i/65536)),d=(i=d+n+65535)-65536*(n=Math.floor(i/65536)),p=(i=p+n+65535)-65536*(n=Math.floor(i/65536)),m=(i=m+n+65535)-65536*(n=Math.floor(i/65536)),g=(i=g+n+65535)-65536*(n=Math.floor(i/65536)),y=(i=y+n+65535)-65536*(n=Math.floor(i/65536)),w=(i=w+n+65535)-65536*(n=Math.floor(i/65536)),v=(i=v+n+65535)-65536*(n=Math.floor(i/65536)),b=(i=b+n+65535)-65536*(n=Math.floor(i/65536)),s+=n-1+37*(n-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=u,t[5]=l,t[6]=c,t[7]=f,t[8]=d,t[9]=p,t[10]=m,t[11]=g,t[12]=y,t[13]=w,t[14]=v,t[15]=b}function j(t,e){P(t,e,e)}function $(t,r){var i,n=e();for(i=0;i<16;i++)n[i]=r[i];for(i=253;i>=0;i--)j(n,n),2!==i&&4!==i&&P(n,n,r);for(i=0;i<16;i++)t[i]=n[i]}function q(t,r){var i,n=e();for(i=0;i<16;i++)n[i]=r[i];for(i=250;i>=0;i--)j(n,n),1!==i&&P(n,n,r);for(i=0;i<16;i++)t[i]=n[i]}function K(t,r,i){var n,s,o=new Uint8Array(32),a=new Float64Array(80),u=e(),l=e(),c=e(),f=e(),d=e(),p=e();for(s=0;s<31;s++)o[s]=r[s];for(o[31]=127&r[31]|64,o[0]&=248,O(a,i),s=0;s<16;s++)l[s]=a[s],f[s]=u[s]=c[s]=0;for(u[0]=f[0]=1,s=254;s>=0;--s)T(u,l,n=o[s>>>3]>>>(7&s)&1),T(c,f,n),k(d,u,c),L(u,u,c),k(c,l,f),L(l,l,f),j(f,d),j(p,u),P(u,c,u),P(c,l,d),k(d,u,c),L(u,u,c),j(l,u),L(c,f,p),P(u,c,h),k(u,u,f),P(c,c,u),P(u,f,p),P(f,l,a),j(l,d),T(u,l,n),T(c,f,n);for(s=0;s<16;s++)a[s+16]=u[s],a[s+32]=c[s],a[s+48]=l[s],a[s+64]=f[s];var m=a.subarray(32),g=a.subarray(16);return $(m,m),P(g,g,m),N(t,g),0}function H(t,e){return K(t,e,s)}function G(t,e){return i(e,32),H(t,e)}function V(t,e,r){var i=new Uint8Array(32);return K(i,r,e),v(t,n,i,b)}B.prototype.blocks=function(t,e,r){for(var i,n,s,o,a,h,u,l,c,f,d,p,m,g,y,w,v,b,E,A=this.fin?0:2048,C=this.h[0],M=this.h[1],B=this.h[2],F=this.h[3],S=this.h[4],_=this.h[5],D=this.h[6],I=this.h[7],x=this.h[8],T=this.h[9],N=this.r[0],U=this.r[1],R=this.r[2],O=this.r[3],k=this.r[4],L=this.r[5],P=this.r[6],j=this.r[7],$=this.r[8],q=this.r[9];r>=16;)f=c=0,f+=(C+=8191&(i=255&t[e+0]|(255&t[e+1])<<8))*N,f+=(M+=8191&(i>>>13|(n=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),f+=(B+=8191&(n>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*$),f+=(F+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*j),c=(f+=(S+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*P))>>>13,f&=8191,f+=(_+=a>>>1&8191)*(5*L),f+=(D+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*k),f+=(I+=8191&(h>>>11|(u=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*O),f+=(x+=8191&(u>>>8|(l=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*R),d=c+=(f+=(T+=l>>>5|A)*(5*U))>>>13,d+=C*U,d+=M*N,d+=B*(5*q),d+=F*(5*$),c=(d+=S*(5*j))>>>13,d&=8191,d+=_*(5*P),d+=D*(5*L),d+=I*(5*k),d+=x*(5*O),c+=(d+=T*(5*R))>>>13,d&=8191,p=c,p+=C*R,p+=M*U,p+=B*N,p+=F*(5*q),c=(p+=S*(5*$))>>>13,p&=8191,p+=_*(5*j),p+=D*(5*P),p+=I*(5*L),p+=x*(5*k),m=c+=(p+=T*(5*O))>>>13,m+=C*O,m+=M*R,m+=B*U,m+=F*N,c=(m+=S*(5*q))>>>13,m&=8191,m+=_*(5*$),m+=D*(5*j),m+=I*(5*P),m+=x*(5*L),g=c+=(m+=T*(5*k))>>>13,g+=C*k,g+=M*O,g+=B*R,g+=F*U,c=(g+=S*N)>>>13,g&=8191,g+=_*(5*q),g+=D*(5*$),g+=I*(5*j),g+=x*(5*P),y=c+=(g+=T*(5*L))>>>13,y+=C*L,y+=M*k,y+=B*O,y+=F*R,c=(y+=S*U)>>>13,y&=8191,y+=_*N,y+=D*(5*q),y+=I*(5*$),y+=x*(5*j),w=c+=(y+=T*(5*P))>>>13,w+=C*P,w+=M*L,w+=B*k,w+=F*O,c=(w+=S*R)>>>13,w&=8191,w+=_*U,w+=D*N,w+=I*(5*q),w+=x*(5*$),v=c+=(w+=T*(5*j))>>>13,v+=C*j,v+=M*P,v+=B*L,v+=F*k,c=(v+=S*O)>>>13,v&=8191,v+=_*R,v+=D*U,v+=I*N,v+=x*(5*q),b=c+=(v+=T*(5*$))>>>13,b+=C*$,b+=M*j,b+=B*P,b+=F*L,c=(b+=S*k)>>>13,b&=8191,b+=_*O,b+=D*R,b+=I*U,b+=x*N,E=c+=(b+=T*(5*q))>>>13,E+=C*q,E+=M*$,E+=B*j,E+=F*P,c=(E+=S*L)>>>13,E&=8191,E+=_*k,E+=D*O,E+=I*R,E+=x*U,C=f=8191&(c=(c=((c+=(E+=T*N)>>>13)<<2)+c|0)+(f&=8191)|0),M=d+=c>>>=13,B=p&=8191,F=m&=8191,S=g&=8191,_=y&=8191,D=w&=8191,I=v&=8191,x=b&=8191,T=E&=8191,e+=16,r-=16;this.h[0]=C,this.h[1]=M,this.h[2]=B,this.h[3]=F,this.h[4]=S,this.h[5]=_,this.h[6]=D,this.h[7]=I,this.h[8]=x,this.h[9]=T},B.prototype.finish=function(t,e){var r,i,n,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=r,r=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,o[0]=this.h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,i=(1^r)-1,s=0;s<10;s++)o[s]&=i;for(i=~i,s=0;s<10;s++)this.h[s]=this.h[s]&i|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),n=this.h[0]+this.pad[0],this.h[0]=65535&n,s=1;s<8;s++)n=(this.h[s]+this.pad[s]|0)+(n>>>16)|0,this.h[s]=65535&n;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},B.prototype.update=function(t,e,r){var i,n;if(this.leftover){for((n=16-this.leftover)>r&&(n=r),i=0;i=16&&(n=r-r%16,this.blocks(t,e,n),e+=n,r-=n),r){for(i=0;i=128;){for(A=0;A<16;A++)C=8*A+z,I[A]=r[C+0]<<24|r[C+1]<<16|r[C+2]<<8|r[C+3],x[A]=r[C+4]<<24|r[C+5]<<16|r[C+6]<<8|r[C+7];for(A=0;A<80;A++)if(n=T,s=N,o=U,a=R,h=O,u=k,l=L,f=j,d=$,p=q,m=K,g=H,y=G,w=V,F=65535&(B=W),S=B>>>16,_=65535&(M=P),D=M>>>16,F+=65535&(B=(H>>>14|O<<18)^(H>>>18|O<<14)^(O>>>9|H<<23)),S+=B>>>16,_+=65535&(M=(O>>>14|H<<18)^(O>>>18|H<<14)^(H>>>9|O<<23)),D+=M>>>16,F+=65535&(B=H&G^~H&V),S+=B>>>16,_+=65535&(M=O&k^~O&L),D+=M>>>16,F+=65535&(B=Z[2*A+1]),S+=B>>>16,_+=65535&(M=Z[2*A]),D+=M>>>16,M=I[A%16],S+=(B=x[A%16])>>>16,_+=65535&M,D+=M>>>16,_+=(S+=(F+=65535&B)>>>16)>>>16,F=65535&(B=E=65535&F|S<<16),S=B>>>16,_=65535&(M=b=65535&_|(D+=_>>>16)<<16),D=M>>>16,F+=65535&(B=(j>>>28|T<<4)^(T>>>2|j<<30)^(T>>>7|j<<25)),S+=B>>>16,_+=65535&(M=(T>>>28|j<<4)^(j>>>2|T<<30)^(j>>>7|T<<25)),D+=M>>>16,S+=(B=j&$^j&q^$&q)>>>16,_+=65535&(M=T&N^T&U^N&U),D+=M>>>16,c=65535&(_+=(S+=(F+=65535&B)>>>16)>>>16)|(D+=_>>>16)<<16,v=65535&F|S<<16,F=65535&(B=m),S=B>>>16,_=65535&(M=a),D=M>>>16,S+=(B=E)>>>16,_+=65535&(M=b),D+=M>>>16,N=n,U=s,R=o,O=a=65535&(_+=(S+=(F+=65535&B)>>>16)>>>16)|(D+=_>>>16)<<16,k=h,L=u,P=l,T=c,$=f,q=d,K=p,H=m=65535&F|S<<16,G=g,V=y,W=w,j=v,A%16==15)for(C=0;C<16;C++)M=I[C],F=65535&(B=x[C]),S=B>>>16,_=65535&M,D=M>>>16,M=I[(C+9)%16],F+=65535&(B=x[(C+9)%16]),S+=B>>>16,_+=65535&M,D+=M>>>16,b=I[(C+1)%16],F+=65535&(B=((E=x[(C+1)%16])>>>1|b<<31)^(E>>>8|b<<24)^(E>>>7|b<<25)),S+=B>>>16,_+=65535&(M=(b>>>1|E<<31)^(b>>>8|E<<24)^b>>>7),D+=M>>>16,b=I[(C+14)%16],S+=(B=((E=x[(C+14)%16])>>>19|b<<13)^(b>>>29|E<<3)^(E>>>6|b<<26))>>>16,_+=65535&(M=(b>>>19|E<<13)^(E>>>29|b<<3)^b>>>6),D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,I[C]=65535&_|D<<16,x[C]=65535&F|S<<16;F=65535&(B=j),S=B>>>16,_=65535&(M=T),D=M>>>16,M=t[0],S+=(B=e[0])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[0]=T=65535&_|D<<16,e[0]=j=65535&F|S<<16,F=65535&(B=$),S=B>>>16,_=65535&(M=N),D=M>>>16,M=t[1],S+=(B=e[1])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[1]=N=65535&_|D<<16,e[1]=$=65535&F|S<<16,F=65535&(B=q),S=B>>>16,_=65535&(M=U),D=M>>>16,M=t[2],S+=(B=e[2])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[2]=U=65535&_|D<<16,e[2]=q=65535&F|S<<16,F=65535&(B=K),S=B>>>16,_=65535&(M=R),D=M>>>16,M=t[3],S+=(B=e[3])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[3]=R=65535&_|D<<16,e[3]=K=65535&F|S<<16,F=65535&(B=H),S=B>>>16,_=65535&(M=O),D=M>>>16,M=t[4],S+=(B=e[4])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[4]=O=65535&_|D<<16,e[4]=H=65535&F|S<<16,F=65535&(B=G),S=B>>>16,_=65535&(M=k),D=M>>>16,M=t[5],S+=(B=e[5])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[5]=k=65535&_|D<<16,e[5]=G=65535&F|S<<16,F=65535&(B=V),S=B>>>16,_=65535&(M=L),D=M>>>16,M=t[6],S+=(B=e[6])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[6]=L=65535&_|D<<16,e[6]=V=65535&F|S<<16,F=65535&(B=W),S=B>>>16,_=65535&(M=P),D=M>>>16,M=t[7],S+=(B=e[7])>>>16,_+=65535&M,D+=M>>>16,D+=(_+=(S+=(F+=65535&B)>>>16)>>>16)>>>16,t[7]=P=65535&_|D<<16,e[7]=W=65535&F|S<<16,z+=128,i-=128}return i}function X(t,e,r){var i,n=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=r;for(n[0]=1779033703,n[1]=3144134277,n[2]=1013904242,n[3]=2773480762,n[4]=1359893119,n[5]=2600822924,n[6]=528734635,n[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,Y(n,s,e,r),r%=128,i=0;i=0;--n)J(t,e,i=r[n/8|0]>>(7&n)&1),Q(e,t),Q(t,t),J(t,e,i)}function rt(t,r){var i=[e(),e(),e(),e()];I(i[0],c),I(i[1],f),I(i[2],a),P(i[3],c,f),et(t,i,r)}function it(t,r,n){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(n||i(r,32),X(o,r,32),o[0]&=248,o[31]&=127,o[31]|=64,rt(a,o),tt(t,a),s=0;s<32;s++)r[s+32]=t[s];return 0}var nt=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]);function st(t,e){var r,i,n,s;for(i=63;i>=32;--i){for(r=0,n=i-32,s=i-12;n>4)*nt[n],r=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=r*nt[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,t[i]=255&e[i]}function ot(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,r)}function at(t,r,i,n){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),u=new Uint8Array(64),l=new Float64Array(64),c=[e(),e(),e(),e()];X(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=i+64;for(s=0;s>7&&L(t[0],o,t[0]),P(t[3],t[0],t[1]),0)}(f,n))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(lt),e=new Uint8Array(ct);return it(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(dt(t),t.length!==ct)throw new Error("bad secret key size");for(var e=new Uint8Array(lt),r=0;r{},(t,e,r)=>{"use strict";var i=r(8),n=r(12),s=new i(0),o=new i(-1),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};function h(t){var e=t?t.toLowerCase():"ether",r=a[e];if("string"!=typeof r)throw new Error("[ethjs-unit] the unit provided "+t+" doesn't exists, please use the one of the following units "+JSON.stringify(a,null,2));return new i(r,10)}function u(t){if("string"==typeof t){if(!t.match(/^-?[0-9.]+$/))throw new Error("while converting number to string, invalid number value '"+t+"', should be a number matching (^-?[0-9.]+).");return t}if("number"==typeof t)return String(t);if("object"==typeof t&&t.toString&&(t.toTwos||t.dividedToIntegerBy))return t.toPrecision?String(t.toPrecision()):t.toString(10);throw new Error("while converting number to string, invalid number value '"+t+"' type "+typeof t+".")}t.exports={unitMap:a,numberToString:u,getValueOfUnit:h,fromWei:function(t,e,r){var i=n(t),u=i.lt(s),l=h(e),c=a[e].length-1||1,f=r||{};u&&(i=i.mul(o));for(var d=i.mod(l).toString(10);d.length2)throw new Error("[ethjs-unit] while converting number "+t+" to wei, too many decimal points");var f=c[0],d=c[1];if(f||(f="0"),d||(d="0"),d.length>s)throw new Error("[ethjs-unit] while converting number "+t+" to wei, too many decimal places");for(;d.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===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):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>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)n=a(t,r,r+6),this.words[i]|=n<>>26-s&4194303,(s+=24)>=26&&(s-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,u=0,l=r;l1&&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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(s=0|e.words[d])+c)/67108864|0,c=67108863&o}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=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 f=l[t],d=c[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:u[f-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,h="le"===e,u=new t(s),l=this.clone();if(h){for(a=0;!l.isZero();a++)o=l.andln(255),l.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 i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,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,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o>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,m=d>>>13,g=0|o[2],y=8191&g,w=g>>>13,v=0|o[3],b=8191&v,E=v>>>13,A=0|o[4],C=8191&A,M=A>>>13,B=0|o[5],F=8191&B,S=B>>>13,_=0|o[6],D=8191&_,I=_>>>13,x=0|o[7],T=8191&x,N=x>>>13,U=0|o[8],R=8191&U,O=U>>>13,k=0|o[9],L=8191&k,P=k>>>13,j=0|a[0],$=8191&j,q=j>>>13,K=0|a[1],H=8191&K,G=K>>>13,V=0|a[2],W=8191&V,z=V>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,Q=0|a[4],J=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,$))|0)+((8191&(n=(n=Math.imul(c,q))+Math.imul(f,$)|0))<<13)|0;u=((s=Math.imul(f,q))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,q))+Math.imul(m,$)|0,s=Math.imul(m,q);var yt=(u+(i=i+Math.imul(c,H)|0)|0)+((8191&(n=(n=n+Math.imul(c,G)|0)+Math.imul(f,H)|0))<<13)|0;u=((s=s+Math.imul(f,G)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,$),n=(n=Math.imul(y,q))+Math.imul(w,$)|0,s=Math.imul(w,q),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,s=s+Math.imul(m,G)|0;var wt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,z)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,z)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,q))+Math.imul(E,$)|0,s=Math.imul(E,q),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,G)|0)+Math.imul(w,H)|0,s=s+Math.imul(w,G)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(c,Y)|0)|0)+((8191&(n=(n=n+Math.imul(c,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,X)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(C,$),n=(n=Math.imul(C,q))+Math.imul(M,$)|0,s=Math.imul(M,q),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(E,H)|0,s=s+Math.imul(E,G)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var bt=(u+(i=i+Math.imul(c,J)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,J)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(F,$),n=(n=Math.imul(F,q))+Math.imul(S,$)|0,s=Math.imul(S,q),i=i+Math.imul(C,H)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(M,H)|0,s=s+Math.imul(M,G)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,z)|0)+Math.imul(E,W)|0,s=s+Math.imul(E,z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(w,Y)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var Et=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,it)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,$),n=(n=Math.imul(D,q))+Math.imul(I,$)|0,s=Math.imul(I,q),i=i+Math.imul(F,H)|0,n=(n=n+Math.imul(F,G)|0)+Math.imul(S,H)|0,s=s+Math.imul(S,G)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,z)|0)+Math.imul(M,W)|0,s=s+Math.imul(M,z)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var At=(u+(i=i+Math.imul(c,st)|0)|0)+((8191&(n=(n=n+Math.imul(c,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,q))+Math.imul(N,$)|0,s=Math.imul(N,q),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(I,H)|0,s=s+Math.imul(I,G)|0,i=i+Math.imul(F,W)|0,n=(n=n+Math.imul(F,z)|0)+Math.imul(S,W)|0,s=s+Math.imul(S,z)|0,i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(E,J)|0,s=s+Math.imul(E,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var Ct=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(R,$),n=(n=Math.imul(R,q))+Math.imul(O,$)|0,s=Math.imul(O,q),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(N,H)|0,s=s+Math.imul(N,G)|0,i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,z)|0,i=i+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,X)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(C,J)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(M,J)|0,s=s+Math.imul(M,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Mt=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(L,$),n=(n=Math.imul(L,q))+Math.imul(P,$)|0,s=Math.imul(P,q),i=i+Math.imul(R,H)|0,n=(n=n+Math.imul(R,G)|0)+Math.imul(O,H)|0,s=s+Math.imul(O,G)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,z)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,z)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(F,J)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(M,rt)|0,s=s+Math.imul(M,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,ut)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,s=s+Math.imul(m,ft)|0;var Bt=(u+(i=i+Math.imul(c,pt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,G))+Math.imul(P,H)|0,s=Math.imul(P,G),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(C,st)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(w,ct)|0,s=s+Math.imul(w,ft)|0;var Ft=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(L,W),n=(n=Math.imul(L,z))+Math.imul(P,W)|0,s=Math.imul(P,z),i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,X)|0,i=i+Math.imul(T,J)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(F,st)|0,n=(n=n+Math.imul(F,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(E,ct)|0,s=s+Math.imul(E,ft)|0;var St=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(P,Y)|0,s=Math.imul(P,X),i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,J)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(D,st)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,ut)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ft)|0)+Math.imul(M,ct)|0,s=s+Math.imul(M,ft)|0;var _t=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(L,J),n=(n=Math.imul(L,tt))+Math.imul(P,J)|0,s=Math.imul(P,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ut)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(S,ct)|0,s=s+Math.imul(S,ft)|0;var Dt=(u+(i=i+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(P,rt)|0,s=Math.imul(P,it),i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ft)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ft)|0;var It=(u+(i=i+Math.imul(F,pt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(L,st),n=(n=Math.imul(L,ot))+Math.imul(P,st)|0,s=Math.imul(P,ot),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,ct)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,ft)|0;var xt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,ut))+Math.imul(P,ht)|0,s=Math.imul(P,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(O,ct)|0,s=s+Math.imul(O,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ft))+Math.imul(P,ct)|0,s=Math.imul(P,ft);var Nt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Ut=(u+(i=Math.imul(L,pt))|0)+((8191&(n=(n=Math.imul(L,mt))+Math.imul(P,pt)|0))<<13)|0;return u=((s=Math.imul(P,mt))+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=Et,h[6]=At,h[7]=Ct,h[8]=Mt,h[9]=Bt,h[10]=Ft,h[11]=St,h[12]=_t,h[13]=Dt,h[14]=It,h[15]=xt,h[16]=Tt,h[17]=Nt,h[18]=Ut,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=f),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,e+=n/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>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=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!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-s|c>>>s,l=c&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var f=67108864*(0|i.words[n.length+c])+(0|i.words[n.length+c-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(n,f,c);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=f)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(l),o.isub(c)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(c)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var c=0,f=1;0==(r.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 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){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=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),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(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 A(t)},s.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(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 w(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function C(t){A.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)}y.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(w,y),w.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},w.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]=n,e=i}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 w;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},A.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.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)},A.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},A.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)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==c||0!==o?(o<<=1,o|=c,(4==++a||0===i&&0===l)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new C(t)},n(C,A),C.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},C.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},C.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},C.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},C.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},(t,e,r)=>{"use strict";const i=r(10),n=r(11),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|m(t,e);let i=a(r);const n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,r);const n=function(t){if(h.isBuffer(t)){const e=0|p(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return l(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),r=a(e);for(let i=0;i=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function m(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(n)return i?-1:V(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return F(this,e,r);case"ascii":return _(this,e,r);case"latin1":case"binary":return D(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function y(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function w(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:v(t,e,r,i,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,i,n){let s,o=1,a=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){let i=-1;for(s=r;sa&&(r=a-h),s=r;s>=0;s--){let r=!0;for(let i=0;in&&(i=n):i=n;const s=e.length;let o;for(i>s/2&&(i=s/2),o=0;o>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function B(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function F(t,e,r){r=Math.min(t.length,r);const i=[];let n=e;for(;n239?4:e>223?3:e>191?2:1;if(n+o<=r){let r,i,a,h;switch(o){case 1:e<128&&(s=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(s=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:r=t[n+1],i=t[n+2],a=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&a)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&a,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),n+=o}return function(t){const e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);let r="",i=0;for(;ii.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},h.byteLength=m,h.prototype._isBuffer=!0,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,r,i,n){if(Z(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(e>>>=0);const a=Math.min(s,o),u=this.slice(i,n),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}const n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return A(this,t,e,r);case"base64":return C(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const S=4096;function _(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;ni)&&(r=i);let n="";for(let i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,i,n,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError("Index out of range")}function U(t,e,r,i,n){q(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,r}function R(t,e,r,i,n){q(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o>>=8,t[r+2]=o,o>>=8,t[r+1]=o,o>>=8,t[r]=o,r+8}function O(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,i,s){return e=+e,r>>>=0,s||O(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function L(t,e,r,i,s){return e=+e,r>>>=0,s||O(t,0,r,8),n.write(t,e,r,i,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);let i=this[t],n=1,s=0;for(;++s>>=0,e>>>=0,r||T(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<>>=0,e>>>=0,r||T(t,e,this.length);let i=this[t],n=1,s=0;for(;++s=n&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let i=e,n=1,s=this[t+--i];for(;i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||N(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,s=0;for(this[e]=255&t;++s>>=0,r>>>=0,i||N(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=Q((function(t,e=0){return R(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);N(this,t,e,r,i-1,-i)}let n=0,s=1,o=0;for(this[e]=255&t;++n>0)-o&255;return e+r},h.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*r-1);N(this,t,e,r,i-1,-i)}let n=r-1,s=1,o=0;for(this[e+n]=255&t;--n>=0&&(s*=256);)t<0&&0===o&&0!==this[e+n+1]&&(o=1),this[e+n]=(t/s>>0)-o&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=Q((function(t,e=0){return R(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(n=e;n=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function q(t,e,r,i,n,s){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${r}${i}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){K(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||H(e,t.length-(r+1))}(i,n,s)}function K(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new P.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=$(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=$(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const i=t.length;let n=null;const s=[];for(let o=0;o55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function W(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,i){let n;for(n=0;n=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function Q(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}},(t,e)=>{"use strict";e.byteLength=function(t){var e=h(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,s=h(t),o=s[0],a=s[1],u=new n(function(t,e,r){return 3*(e+r)/4-r}(0,o,a)),l=0,c=a>0?o-4:o;for(r=0;r>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,s=[],o=16383,a=0,h=i-n;ah?h:a+o));return 1===n?(e=t[i-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[i-2]<<8)+t[i-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),s.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=s.length;o0)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 u(t,e,i){for(var n,s,o=[],a=e;a>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},(t,e)=>{e.read=function(t,e,r,i,n){var s,o,a=8*n-i-1,h=(1<>1,l=-7,c=r?n-1:0,f=r?-1:1,d=t[e+c];for(c+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[e+c],c+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=i;l>0;o=256*o+t[e+c],c+=f,l-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),s-=u}return(d?-1:1)*o*Math.pow(2,s-i)},e.write=function(t,e,r,i,n,s){var o,a,h,u=8*s-n-1,l=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+c>=1?f/h:f*Math.pow(2,1-c))*h>=2&&(o++,h/=2),o+c>=l?(a=0,o=l):o+c>=1?(a=(e*h-1)*Math.pow(2,n),o+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;t[r+d]=255&a,d+=p,a/=256,n-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*m}},(t,e,r)=>{var i=r(13),n=r(14);t.exports=function(t){if("string"==typeof t||"number"==typeof t){var e=new i(1),r=String(t).toLowerCase().trim(),s="0x"===r.substr(0,2)||"-0x"===r.substr(0,3),o=n(r);if("-"===o.substr(0,1)&&(o=n(o.slice(1)),e=new i(-1,10)),!(o=""===o?"0":o).match(/^-?[0-9]+$/)&&o.match(/^[0-9A-Fa-f]+$/)||o.match(/^[a-fA-F]+$/)||!0===s&&o.match(/^[0-9A-Fa-f]+$/))return new i(o,16).mul(e);if((o.match(/^-?[0-9]+$/)||""===o)&&!1===s)return new i(o,10).mul(e)}else if("object"==typeof t&&t.toString&&!t.pop&&!t.push&&t.toString(10).match(/^-?[0-9]+$/)&&(t.mul||t.dividedToIntegerBy))return new i(t.toString(10),10);throw new Error("[number-to-bn] while converting number "+JSON.stringify(t)+" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.")}},function(t,e,r){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=r(9).Buffer}catch(t){}function a(t,e,r){for(var i=0,n=Math.min(t.length,r),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===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):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>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)n=a(t,r,r+6),this.words[i]|=n<>>26-s&4194303,(s+=24)>=26&&(s-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,u=0,l=r;l1&&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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(s=0|e.words[d])+c)/67108864|0,c=67108863&o}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=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 f=l[t],d=c[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:u[f-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,h="le"===e,u=new t(s),l=this.clone();if(h){for(a=0;!l.isZero();a++)o=l.andln(255),l.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 i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,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,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o>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,m=d>>>13,g=0|o[2],y=8191&g,w=g>>>13,v=0|o[3],b=8191&v,E=v>>>13,A=0|o[4],C=8191&A,M=A>>>13,B=0|o[5],F=8191&B,S=B>>>13,_=0|o[6],D=8191&_,I=_>>>13,x=0|o[7],T=8191&x,N=x>>>13,U=0|o[8],R=8191&U,O=U>>>13,k=0|o[9],L=8191&k,P=k>>>13,j=0|a[0],$=8191&j,q=j>>>13,K=0|a[1],H=8191&K,G=K>>>13,V=0|a[2],W=8191&V,z=V>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,Q=0|a[4],J=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,$))|0)+((8191&(n=(n=Math.imul(c,q))+Math.imul(f,$)|0))<<13)|0;u=((s=Math.imul(f,q))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,q))+Math.imul(m,$)|0,s=Math.imul(m,q);var yt=(u+(i=i+Math.imul(c,H)|0)|0)+((8191&(n=(n=n+Math.imul(c,G)|0)+Math.imul(f,H)|0))<<13)|0;u=((s=s+Math.imul(f,G)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,$),n=(n=Math.imul(y,q))+Math.imul(w,$)|0,s=Math.imul(w,q),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(m,H)|0,s=s+Math.imul(m,G)|0;var wt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,z)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,z)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,q))+Math.imul(E,$)|0,s=Math.imul(E,q),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,G)|0)+Math.imul(w,H)|0,s=s+Math.imul(w,G)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(c,Y)|0)|0)+((8191&(n=(n=n+Math.imul(c,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,X)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(C,$),n=(n=Math.imul(C,q))+Math.imul(M,$)|0,s=Math.imul(M,q),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(E,H)|0,s=s+Math.imul(E,G)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,z)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var bt=(u+(i=i+Math.imul(c,J)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,J)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(F,$),n=(n=Math.imul(F,q))+Math.imul(S,$)|0,s=Math.imul(S,q),i=i+Math.imul(C,H)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(M,H)|0,s=s+Math.imul(M,G)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,z)|0)+Math.imul(E,W)|0,s=s+Math.imul(E,z)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(w,Y)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var Et=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,it)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,$),n=(n=Math.imul(D,q))+Math.imul(I,$)|0,s=Math.imul(I,q),i=i+Math.imul(F,H)|0,n=(n=n+Math.imul(F,G)|0)+Math.imul(S,H)|0,s=s+Math.imul(S,G)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,z)|0)+Math.imul(M,W)|0,s=s+Math.imul(M,z)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var At=(u+(i=i+Math.imul(c,st)|0)|0)+((8191&(n=(n=n+Math.imul(c,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,q))+Math.imul(N,$)|0,s=Math.imul(N,q),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(I,H)|0,s=s+Math.imul(I,G)|0,i=i+Math.imul(F,W)|0,n=(n=n+Math.imul(F,z)|0)+Math.imul(S,W)|0,s=s+Math.imul(S,z)|0,i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(E,J)|0,s=s+Math.imul(E,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var Ct=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(R,$),n=(n=Math.imul(R,q))+Math.imul(O,$)|0,s=Math.imul(O,q),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(N,H)|0,s=s+Math.imul(N,G)|0,i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,z)|0,i=i+Math.imul(F,Y)|0,n=(n=n+Math.imul(F,X)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(C,J)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(M,J)|0,s=s+Math.imul(M,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Mt=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(L,$),n=(n=Math.imul(L,q))+Math.imul(P,$)|0,s=Math.imul(P,q),i=i+Math.imul(R,H)|0,n=(n=n+Math.imul(R,G)|0)+Math.imul(O,H)|0,s=s+Math.imul(O,G)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,z)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,z)|0,i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,X)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(F,J)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(M,rt)|0,s=s+Math.imul(M,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,ut)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,s=s+Math.imul(m,ft)|0;var Bt=(u+(i=i+Math.imul(c,pt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(L,H),n=(n=Math.imul(L,G))+Math.imul(P,H)|0,s=Math.imul(P,G),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,z)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(C,st)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(w,ct)|0,s=s+Math.imul(w,ft)|0;var Ft=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(L,W),n=(n=Math.imul(L,z))+Math.imul(P,W)|0,s=Math.imul(P,z),i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,X)|0,i=i+Math.imul(T,J)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(F,st)|0,n=(n=n+Math.imul(F,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(E,ct)|0,s=s+Math.imul(E,ft)|0;var St=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(P,Y)|0,s=Math.imul(P,X),i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(O,J)|0,s=s+Math.imul(O,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(D,st)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,ut)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ft)|0)+Math.imul(M,ct)|0,s=s+Math.imul(M,ft)|0;var _t=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(L,J),n=(n=Math.imul(L,tt))+Math.imul(P,J)|0,s=Math.imul(P,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ut)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(S,ct)|0,s=s+Math.imul(S,ft)|0;var Dt=(u+(i=i+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(P,rt)|0,s=Math.imul(P,it),i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ft)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ft)|0;var It=(u+(i=i+Math.imul(F,pt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(L,st),n=(n=Math.imul(L,ot))+Math.imul(P,st)|0,s=Math.imul(P,ot),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ut)|0,i=i+Math.imul(T,ct)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,ft)|0;var xt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,ut))+Math.imul(P,ht)|0,s=Math.imul(P,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(O,ct)|0,s=s+Math.imul(O,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ft))+Math.imul(P,ct)|0,s=Math.imul(P,ft);var Nt=(u+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Ut=(u+(i=Math.imul(L,pt))|0)+((8191&(n=(n=Math.imul(L,mt))+Math.imul(P,pt)|0))<<13)|0;return u=((s=Math.imul(P,mt))+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=Et,h[6]=At,h[7]=Ct,h[8]=Mt,h[9]=Bt,h[10]=Ft,h[11]=St,h[12]=_t,h[13]=Dt,h[14]=It,h[15]=xt,h[16]=Tt,h[17]=Nt,h[18]=Ut,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=f),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,e+=n/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>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=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!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-s|c>>>s,l=c&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var f=67108864*(0|i.words[n.length+c])+(0|i.words[n.length+c-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(n,f,c);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=f)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(l),o.isub(c)),n.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(c)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var c=0,f=1;0==(r.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 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){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=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),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(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 A(t)},s.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(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 w(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function C(t){A.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)}y.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(w,y),w.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},w.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]=n,e=i}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 w;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},A.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.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)},A.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},A.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)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==c||0!==o?(o<<=1,o|=c,(4==++a||0===i&&0===l)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new C(t)},n(C,A),C.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},C.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},C.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},C.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},C.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},(t,e,r)=>{var i=r(15);t.exports=function(t){return"string"!=typeof t?t:i(t)?t.slice(2):t}},t=>{t.exports=function(t){if("string"!=typeof t)throw new Error("[is-hex-prefixed] value must be type 'string', is currently type "+typeof t+", while checking isHexPrefixed.");return"0x"===t.slice(0,2)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i}),r(17);const i=window.crypto},(t,e,r)=>{"use strict";var i,n;r.r(e),r.d(e,{default:()=>s}),i="undefined"!=typeof self?self:void 0,n=function(t){if("function"!=typeof Promise)throw"Promise support required";var e=t.crypto||t.msCrypto;if(e){var r=e.subtle||e.webkitSubtle;if(r){var i=t.Crypto||e.constructor||Object,n=t.SubtleCrypto||r.constructor||Object,s=(t.CryptoKey||t.Key,t.navigator.userAgent.indexOf("Edge/")>-1),o=!!t.msCrypto&&!s,a=!e.subtle&&!!e.webkitSubtle;if(o||a){var h={KoZIhvcNAQEB:"1.2.840.113549.1.1.1"},u={"1.2.840.113549.1.1.1":"KoZIhvcNAQEB"};if(["generateKey","importKey","unwrapKey"].forEach((function(t){var i=r[t];r[t]=function(n,s,h){var u,l,c,p,b=[].slice.call(arguments);switch(t){case"generateKey":u=m(n),l=s,c=h;break;case"importKey":u=m(h),l=b[3],c=b[4],"jwk"===n&&((s=y(s)).alg||(s.alg=g(u)),s.key_ops||(s.key_ops="oct"!==s.kty?"d"in s?c.filter(B):c.filter(M):c.slice()),b[1]=w(s));break;case"unwrapKey":u=b[4],l=b[5],c=b[6],b[2]=h._key}if("generateKey"===t&&"HMAC"===u.name&&u.hash)return u.length=u.length||{"SHA-1":512,"SHA-256":512,"SHA-384":1024,"SHA-512":1024}[u.hash.name],r.importKey("raw",e.getRandomValues(new Uint8Array(u.length+7>>3)),u,l,c);if(a&&"generateKey"===t&&"RSASSA-PKCS1-v1_5"===u.name&&(!u.modulusLength||u.modulusLength>=2048))return(n=m(n)).name="RSAES-PKCS1-v1_5",delete n.hash,r.generateKey(n,!0,["encrypt","decrypt"]).then((function(t){return Promise.all([r.exportKey("jwk",t.publicKey),r.exportKey("jwk",t.privateKey)])})).then((function(t){return t[0].alg=t[1].alg=g(u),t[0].key_ops=c.filter(M),t[1].key_ops=c.filter(B),Promise.all([r.importKey("jwk",t[0],u,!0,t[0].key_ops),r.importKey("jwk",t[1],u,l,t[1].key_ops)])})).then((function(t){return{publicKey:t[0],privateKey:t[1]}}));if((a||o&&"SHA-1"===(u.hash||{}).name)&&"importKey"===t&&"jwk"===n&&"HMAC"===u.name&&"oct"===s.kty)return r.importKey("raw",d(f(s.k)),h,b[3],b[4]);if(a&&"importKey"===t&&("spki"===n||"pkcs8"===n))return r.importKey("jwk",v(s),h,b[3],b[4]);if(o&&"unwrapKey"===t)return r.decrypt(b[3],h,s).then((function(t){return r.importKey(n,t,b[4],b[5],b[6])}));try{p=i.apply(r,b)}catch(t){return Promise.reject(t)}return o&&(p=new Promise((function(t,e){p.onabort=p.onerror=function(t){e(t)},p.oncomplete=function(e){t(e.target.result)}}))),p=p.then((function(t){return"HMAC"===u.name&&(u.length||(u.length=8*t.algorithm.length)),0==u.name.search("RSA")&&(u.modulusLength||(u.modulusLength=(t.publicKey||t).algorithm.modulusLength),u.publicExponent||(u.publicExponent=(t.publicKey||t).algorithm.publicExponent)),t.publicKey&&t.privateKey?{publicKey:new C(t.publicKey,u,l,c.filter(M)),privateKey:new C(t.privateKey,u,l,c.filter(B))}:new C(t,u,l,c)}))}})),["exportKey","wrapKey"].forEach((function(t){var e=r[t];r[t]=function(i,n,s){var h,u=[].slice.call(arguments);switch(t){case"exportKey":u[1]=n._key;break;case"wrapKey":u[1]=n._key,u[2]=s._key}if((a||o&&"SHA-1"===(n.algorithm.hash||{}).name)&&"exportKey"===t&&"jwk"===i&&"HMAC"===n.algorithm.name&&(u[0]="raw"),!a||"exportKey"!==t||"spki"!==i&&"pkcs8"!==i||(u[0]="jwk"),o&&"wrapKey"===t)return r.exportKey(i,n).then((function(t){return"jwk"===i&&(t=d(unescape(encodeURIComponent(JSON.stringify(y(t)))))),r.encrypt(u[3],s,t)}));try{h=e.apply(r,u)}catch(t){return Promise.reject(t)}return o&&(h=new Promise((function(t,e){h.onabort=h.onerror=function(t){e(t)},h.oncomplete=function(e){t(e.target.result)}}))),"exportKey"===t&&"jwk"===i&&(h=h.then((function(t){return(a||o&&"SHA-1"===(n.algorithm.hash||{}).name)&&"HMAC"===n.algorithm.name?{kty:"oct",alg:g(n.algorithm),key_ops:n.usages.slice(),ext:!0,k:c(p(t))}:((t=y(t)).alg||(t.alg=g(n.algorithm)),t.key_ops||(t.key_ops="public"===n.type?n.usages.filter(M):"private"===n.type?n.usages.filter(B):n.usages.slice()),t)}))),!a||"exportKey"!==t||"spki"!==i&&"pkcs8"!==i||(h=h.then((function(t){return b(y(t))}))),h}})),["encrypt","decrypt","sign","verify"].forEach((function(t){var e=r[t];r[t]=function(i,n,s,a){if(o&&(!s.byteLength||a&&!a.byteLength))throw new Error("Empy input is not allowed");var h,u=[].slice.call(arguments),l=m(i);if(o&&"decrypt"===t&&"AES-GCM"===l.name){var c=i.tagLength>>3;u[2]=(s.buffer||s).slice(0,s.byteLength-c),i.tag=(s.buffer||s).slice(s.byteLength-c)}u[1]=n._key;try{h=e.apply(r,u)}catch(t){return Promise.reject(t)}return o&&(h=new Promise((function(e,r){h.onabort=h.onerror=function(t){r(t)},h.oncomplete=function(r){if(r=r.target.result,"encrypt"===t&&r instanceof AesGcmEncryptResult){var i=r.ciphertext,n=r.tag;(r=new Uint8Array(i.byteLength+n.byteLength)).set(new Uint8Array(i),0),r.set(new Uint8Array(n),i.byteLength),r=r.buffer}e(r)}}))),h}})),o){var l=r.digest;r.digest=function(t,e){if(!e.byteLength)throw new Error("Empy input is not allowed");var i;try{i=l.call(r,t,e)}catch(t){return Promise.reject(t)}return i=new Promise((function(t,e){i.onabort=i.onerror=function(t){e(t)},i.oncomplete=function(e){t(e.target.result)}}))},t.crypto=Object.create(e,{getRandomValues:{value:function(t){return e.getRandomValues(t)}},subtle:{value:r}}),t.CryptoKey=C}a&&(e.subtle=r,t.Crypto=i,t.SubtleCrypto=n,t.CryptoKey=C)}}}function c(t){return btoa(t).replace(/\=+$/,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(t){return t=(t+="===").slice(0,-t.length%4),atob(t.replace(/-/g,"+").replace(/_/g,"/"))}function d(t){for(var e=new Uint8Array(t.length),r=0;r2&&(r=!0,e.shift());var i={ext:!0};if("1.2.840.113549.1.1.1"!==e[0][0])throw new TypeError("Unsupported key type");var n=["n","e","d","p","q","dp","dq","qi"],s=E(e[1]);r&&s.shift();for(var o=0;o2&&(i=!0,s.unshift(new Uint8Array([0]))),r[0][0]="1.2.840.113549.1.1.1",e=s,r.push(new Uint8Array(A(e)).buffer),i?r.unshift(new Uint8Array([0])):r[1]={tag:3,value:r[1]},new Uint8Array(A(r)).buffer}function E(t,e){if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),e||(e={pos:0,end:t.length}),e.end-e.pos<2||e.end>t.length)throw new RangeError("Malformed DER");var r,i=t[e.pos++],n=t[e.pos++];if(n>=128){if(n&=127,e.end-e.pos=128){var a=i;for(i=4,e.splice(n,0,a>>24&255,a>>16&255,a>>8&255,255&a);i>1&&!(a>>24);)a<<=8,i--;i<4&&e.splice(n,4-i),i|=128}return e.splice(n-2,2,r,i),e}function C(t,e,r,i){Object.defineProperties(this,{_key:{value:t},type:{value:t.type,enumerable:!0},extractable:{value:void 0===r?t.extractable:r,enumerable:!0},algorithm:{value:void 0===e?t.algorithm:e,enumerable:!0},usages:{value:void 0===i?t.usages:i,enumerable:!0}})}function M(t){return"verify"===t||"encrypt"===t||"wrapKey"===t}function B(t){return"sign"===t||"decrypt"===t||"unwrapKey"===t}},"function"==typeof define&&define.amd?define([],(function(){return n(i)})):"object"==typeof module&&module.exports?module.exports=n(i):n(i);const s={}},(t,e,r)=>{const{crc16:i,hexToBytes:n,bytesToHex:s,stringToBytes:o,base64toString:a,stringToBase64:h}=r(2);class u{static isValid(t){try{return new u(t),!0}catch(t){return!1}}constructor(t){if(null==t)throw"Invalid address";if(t instanceof u)return this.wc=t.wc,this.hashPart=t.hashPart,this.isTestOnly=t.isTestOnly,this.isUserFriendly=t.isUserFriendly,this.isBounceable=t.isBounceable,void(this.isUrlSafe=t.isUrlSafe);if(this.isUrlSafe=!0,t.search(/\-/)>0||t.search(/_/)>0?t=t.replace(/\-/g,"+").replace(/_/g,"/"):this.isUrlSafe=!1,t.indexOf(":")>-1){const e=t.split(":");if(2!==e.length)throw new Error("Invalid address "+t);const r=parseInt(e[0]);if(0!==r&&-1!==r)throw new Error("Invalid address wc "+t);const i=e[1];if(64!==i.length)throw new Error("Invalid address hex "+t);this.isUserFriendly=!1,this.wc=r,this.hashPart=n(i),this.isTestOnly=!1,this.isBounceable=!1}else{this.isUserFriendly=!0;const e=function(t){if(48!==t.length)throw new Error("User-friendly address should contain strictly 48 characters");const e=o(a(t));if(36!==e.length)throw"Unknown address type: byte length is not equal to 36";const r=e.slice(0,34),n=e.slice(34,36),s=i(r);if(s[0]!==n[0]||s[1]!==n[1])throw"Wrong crc16 hashsum";let h=r[0],u=!1,l=!1;if(128&h&&(u=!0,h^=128),17!==h&&81!==h)throw"Unknown address tag";l=17===h;let c=null;if(c=255===r[1]?-1:r[1],0!==c&&-1!==c)throw new Error("Invalid address wc "+c);return{isTestOnly:u,isBounceable:l,workchain:c,hashPart:r.slice(2,34)}}(t);this.wc=e.workchain,this.hashPart=e.hashPart,this.isTestOnly=e.isTestOnly,this.isBounceable=e.isBounceable}}toString(t,e,r,n){if(void 0===t&&(t=this.isUserFriendly),void 0===e&&(e=this.isUrlSafe),void 0===r&&(r=this.isBounceable),void 0===n&&(n=this.isTestOnly),t){let t=r?17:81;n&&(t|=128);const s=new Int8Array(34);s[0]=t,s[1]=this.wc,s.set(this.hashPart,2);const o=new Uint8Array(36);o.set(s),o.set(i(s),34);let a=h(String.fromCharCode.apply(null,new Uint8Array(o)));return e&&(a=a.replace(/\+/g,"-").replace(/\//g,"_")),a}return this.wc+":"+s(this.hashPart)}}t.exports.default=u},(t,e,r)=>{const{hexToBytes:i,bytesToHex:n}=r(2);class s{static isValid(t){try{return new s(t),!0}catch(t){return!1}}constructor(t){if(null==t)throw"Invalid address";if(t instanceof s)this.bytes=t.bytes;else if(t instanceof Uint8Array){if(32!==t.length)throw new Error("invalid adnl bytes length");this.bytes=t}else{if("string"!=typeof t)throw new Error("unsupported type");if(64!==t.length)throw new Error("invalid adnl hex length");this.bytes=i(t)}}toHex(){let t=n(this.bytes);for(;t.length<64;)t="0"+t;return t}}t.exports.default=s},(t,e,r)=>{const{hexToBytes:i,bytesToHex:n}=r(2);class s{static isValid(t){try{return new s(t),!0}catch(t){return!1}}constructor(t){if(null==t)throw"Invalid address";if(t instanceof s)this.bytes=t.bytes;else if(t instanceof Uint8Array){if(32!==t.length)throw new Error("invalid bag id bytes length");this.bytes=t}else{if("string"!=typeof t)throw new Error("unsupported type");if(64!==t.length)throw new Error("invalid bag id hex length");this.bytes=i(t)}}toHex(){let t=n(this.bytes);for(;t.length<64;)t="0"+t;return t}}t.exports.default=s},(t,e,r)=>{const{BitString:i}=r(22),{Cell:n}=r(23),{Slice:s}=r(24);t.exports={BitString:i,Cell:n,Slice:s}},(t,e,r)=>{const{BN:i,bytesToHex:n}=r(1);class s{constructor(t){this.array=Uint8Array.from({length:Math.ceil(t/8)},(()=>0)),this.cursor=0,this.length=t}getFreeBits(){return this.length-this.cursor}getUsedBits(){return this.cursor}getUsedBytes(){return Math.ceil(this.cursor/8)}get(t){return(this.array[t/8|0]&1<<7-t%8)>0}checkRange(t){if(t>this.length)throw Error("BitString overflow")}on(t){this.checkRange(t),this.array[t/8|0]|=1<<7-t%8}off(t){this.checkRange(t),this.array[t/8|0]&=~(1<<7-t%8)}toggle(t){this.checkRange(t),this.array[t/8|0]^=1<<7-t%8}forEach(t){const e=this.cursor;for(let r=0;r0?this.on(this.cursor):this.off(this.cursor),this.cursor=this.cursor+1}writeBitArray(t){for(let e=0;ee){if(0==t)return;throw Error("bitLength is too small for number, got number="+t+",bitLength="+e)}const r=t.toString(2,e);for(let t=0;t{this.writeBit(t)}))}clone(){const t=new s(0);return t.array=this.array.slice(0),t.length=this.length,t.cursor=this.cursor,t}toString(){return this.toHex()}getTopUppedArray(){const t=this.clone();let e=8*Math.ceil(t.cursor/8)-t.cursor;if(e>0)for(e-=1,t.writeBit(!0);e>0;)e-=1,t.writeBit(!1);return t.array=t.array.slice(0,Math.ceil(t.cursor/8)),t.array}toHex(){if(this.cursor%4==0){const t=n(this.array.slice(0,Math.ceil(this.cursor/8))).toUpperCase();return this.cursor%8==0?t:t.substr(0,t.length-1)}{const t=this.clone();for(t.writeBit(1);t.cursor%4!=0;)t.writeBit(0);return t.toHex().toUpperCase()+"_"}}setTopUppedArray(t,e=!0){if(this.length=8*t.length,this.array=t,this.cursor=this.length,!e&&this.length){let r=!1;for(let t=0;t<7;t++)if(this.cursor-=1,this.get(this.cursor)){r=!0,this.off(this.cursor);break}if(!r)throw console.log(t,e),new Error("Incorrect TopUppedArray")}}}t.exports={BitString:s}},(t,e,r)=>{const{BitString:i}=r(22),{bytesToBase64:n,compareBytes:s,concatBytes:o,crc32c:a,hexToBytes:h,readNBytesUIntFromArray:u,sha256:l,bytesToHex:c}=r(1),{Slice:f}=r(24),d=h("B5EE9C72"),p=h("68ff65f3"),m=h("acc3a728");class g{constructor(){this.bits=new i(1023),this.refs=[],this.isExotic=!1}static fromBoc(t){return b(t)}static oneFromBoc(t){const e=b(t);if(1!==e.length)throw new Error("expected 1 root cell but have "+e.length);return e[0]}writeCell(t){this.bits.writeBitString(t.bits),this.refs=this.refs.concat(t.refs)}getMaxLevel(){let t=0;for(let e in this.refs){const r=this.refs[e];r.getMaxLevel()>t&&(t=r.getMaxLevel())}return t}isExplicitlyStoredHashes(){return 0}getMaxDepth(){let t=0;if(this.refs.length>0){for(let e=0;et&&(t=r)}t+=1}return t}getMaxDepthAsArray(){const t=this.getMaxDepth(),e=Uint8Array.from({length:2},(()=>0));return e[1]=t%256,e[0]=Math.floor(t/256),e}getRefsDescriptor(){const t=Uint8Array.from({length:1},(()=>0));return t[0]=this.refs.length+8*this.isExotic+32*this.getMaxLevel(),t}getBitsDescriptor(){const t=Uint8Array.from({length:1},(()=>0));return t[0]=Math.ceil(this.bits.cursor/8)+Math.floor(this.bits.cursor/8),t}getDataWithDescriptors(){const t=this.getRefsDescriptor(),e=this.getBitsDescriptor(),r=this.bits.getTopUppedArray();return o(o(t,e),r)}async getRepr(){const t=[];t.push(this.getDataWithDescriptors());for(let e in this.refs){const r=this.refs[e];t.push(r.getMaxDepthAsArray())}for(let e in this.refs){const r=this.refs[e];t.push(await r.hash())}let e=new Uint8Array;for(let r in t){const i=t[r];e=o(e,i)}return e}async hash(){return new Uint8Array(await l(await this.getRepr()))}beginParse(){const t=this.refs.map((t=>t.beginParse()));return new f(this.bits.array.slice(),this.bits.length,t)}print(t){let e=(t=t||"")+"x{"+this.bits.toHex()+"}\n";for(let r in this.refs)e+=this.refs[r].print(t+" ");return e}async toBoc(t=!0,e=!0,r=!1,n=0){const s=await this.treeWalk(),h=s[0],u=s[1],l=h.length,c=l.toString(2).length,f=Math.min(Math.ceil(c/8),1);let p=0,m=[];for(let t of h)m.push(p),p+=await t[1].bocSerializationSize(u,f);const g=p.toString(2).length,y=Math.max(Math.ceil(g/8),1),w=new i(1247*h.length);w.writeBytes(d),w.writeBitArray([t,e,r]),w.writeUint(n,2),w.writeUint(f,3),w.writeUint8(y),w.writeUint(l,8*f),w.writeUint(1,8*f),w.writeUint(0,8*f),w.writeUint(p,8*y),w.writeUint(0,8*f),t&&h.forEach(((t,e)=>w.writeUint(m[e],8*y)));for(let t of h){const e=await t[1].serializeForBoc(u,f);w.writeBytes(e)}let v=w.getTopUppedArray();return e&&(v=o(v,a(v))),v}async serializeForBoc(t,e){const r=[];if(r.push(this.getDataWithDescriptors()),this.isExplicitlyStoredHashes())throw new Error("Cell hashes explicit storing is not implemented");for(let e in this.refs){const i=this.refs[e];let n=t[await i.hash()].toString(16);n.length%2&&(n="0"+n);const s=h(n);r.push(s)}let i=new Uint8Array;for(let t in r){const e=r[t];i=o(i,e)}return i}async bocSerializationSize(t,e){return(await this.serializeForBoc(t,e)).length}async treeWalk(){return w(this,[],{})}}async function y(t,e,r){const i=t[r];for(let e in t)t[e]>i&&(t[e]=t[e]-1);t[r]=e.length-1;const n=e.splice(i,1)[0];e.push(n);for(let r of n[1].refs)await y(t,e,await r.hash())}async function w(t,e,r,i=null){const n=await t.hash();if(n in r)return i&&r[i]>r[n]&&await y(r,e,n),[e,r];r[n]=e.length,e.push([n,t]);for(let i of t.refs){const t=await w(i,e,r,n);e=t[0],r=t[1]}return[e,r]}function v(t,e){if(t.length<2)throw"Not enough bytes to encode cell descriptors";const r=t[0],i=t[1];t=t.slice(2),Math.floor(r/32);const n=8&r,s=r%8,o=Math.ceil(i/2),a=!(i%2);let h=new g;if(h.isExotic=n,t.length=0;t--){let e=i[t];for(let r=0;r{const{BN:i,Address:n,bytesToHex:s}=r(1),{BitString:o}=r(22);t.exports={Slice:class{constructor(t,e,r){this.array=t,this.length=e,this.readCursor=0,this.refs=r,this.refCursor=0}getFreeBits(){return this.length-this.readCursor}checkRange(t){if(t>this.length)throw Error("BitString overflow")}get(t){return this.checkRange(t),(this.array[t/8|0]&1<<7-t%8)>0}loadBit(){const t=this.get(this.readCursor);return this.readCursor++,t}loadBits(t){const e=new o(t);for(let r=0;r=4)throw new Error("refs overflow");const t=this.refs[this.refCursor];return this.refCursor++,t}}}},(t,e,r)=>{var i=r(9).Buffer;const{Cell:n}=r(21),{Address:s,BN:o,bytesToHex:a}=r(1),{Contract:h}=r(26);t.exports=class{constructor(t,e){this.transport=t,this.ton=e,this.ADDRESS_FORMAT_HEX=0,this.ADDRESS_FORMAT_USER_FRIENDLY=1,this.ADDRESS_FORMAT_URL_SAFE=2,this.ADDRESS_FORMAT_BOUNCEABLE=4,this.ADDRESS_FORMAT_TEST_ONLY=8}async getAppConfiguration(){const t=await this.transport.send(224,1,0,0);return{version:t[0]+"."+t[1]+"."+t[2]}}async getPublicKey(t,e){const r=i.alloc(4);r.writeInt32BE(t);const n=await this.transport.send(224,2,e?1:0,0,r),s=n[0];return{publicKey:new Uint8Array(n.slice(1,1+s))}}async getAddress(t,e,r){const n=i.alloc(4);n.writeInt32BE(t);const o=await this.transport.send(224,5,e?1:0,r,n),h=o[0],u=new Uint8Array(o.slice(1,1+h));return{address:new s("0:"+a(u))}}async sign(t,e){const r=i.alloc(4);r.writeInt32BE(t);const n=i.concat([r,i.from(e)]),s=await this.transport.send(224,3,0,0,n),o=s[0];return{signature:s.slice(1,1+o)}}async transfer(t,e,r,s,o,a){const u=await e.createTransferMessage(null,r,s,o,null,3,!0),l=i.alloc(4);l.writeInt32BE(t);const c=i.concat([l,i.from(await u.signingMessage.toBoc())]),f=await this.transport.send(224,4,a,0,c),d=f[0],p=f.slice(1,1+d),m=new Uint8Array(p),g=new n;g.bits.writeBytes(m),g.writeCell(u.signingMessage);let y=null,w=null,v=null;if(0===o){const t=await e.createStateInit();y=t.stateInit,w=t.code,v=t.data}const b=await e.getAddress(),E=h.createExternalMessageHeader(b),A=h.createCommonMsgInfo(E,y,g),C=new Promise((t=>{t({address:b,message:A,body:g,signature:m,signingMessage:u.signingMessage,stateInit:y,code:w,data:v})}));return h.createMethod(this.ton.provider,C)}}},(t,e,r)=>{const{Cell:i}=r(21),{Address:n,bytesToBase64:s,bytesToHex:o,BN:a}=r(1);class h{constructor(t,e){this.provider=t,this.options=e,this.address=e.address?new n(e.address):null,e.wc||(e.wc=this.address?this.address.wc:0),this.methods={}}async getAddress(){return this.address||(this.address=(await this.createStateInit()).address),this.address}createCodeCell(){if(!this.options.code)throw new Error("Contract: options.code is not defined");return this.options.code}createDataCell(){return new i}async createStateInit(){const t=this.createCodeCell(),e=this.createDataCell(),r=h.createStateInit(t,e),i=await r.hash();return{stateInit:r,address:new n(this.options.wc+":"+o(i)),code:t,data:e}}static createStateInit(t,e,r=null,n=null,s=null){if(r)throw"Library in state init is not implemented";if(n)throw"Split depth in state init is not implemented";if(s)throw"Ticktock in state init is not implemented";const o=new i;return o.bits.writeBitArray([Boolean(n),Boolean(s),Boolean(t),Boolean(e),Boolean(r)]),t&&o.refs.push(t),e&&o.refs.push(e),r&&o.refs.push(r),o}static createInternalMessageHeader(t,e=0,r=!0,s=null,o=!1,a=null,h=null,u=0,l=0,c=0,f=0){const d=new i;if(d.bits.writeBit(!1),d.bits.writeBit(r),null!==s?d.bits.writeBit(s):d.bits.writeBit(new n(t).isBounceable),d.bits.writeBit(o),d.bits.writeAddress(a?new n(a):null),d.bits.writeAddress(new n(t)),d.bits.writeGrams(e),h)throw"Currency collections are not implemented yet";return d.bits.writeBit(Boolean(h)),d.bits.writeGrams(u),d.bits.writeGrams(l),d.bits.writeUint(c,64),d.bits.writeUint(f,32),d}static createExternalMessageHeader(t,e=null,r=0){const s=new i;return s.bits.writeUint(2,2),s.bits.writeAddress(e?new n(e):null),s.bits.writeAddress(new n(t)),s.bits.writeGrams(r),s}static createOutMsg(t,e,r,s=null){let o=new i;r&&(r.refs?o=r:"string"==typeof r?r.length>0&&(o.bits.writeUint(0,32),o.bits.writeString(r)):o.bits.writeBytes(r));const u=h.createInternalMessageHeader(new n(t),new a(e));return h.createCommonMsgInfo(u,s,o)}static createCommonMsgInfo(t,e=null,r=null){const n=new i;return n.writeCell(t),e?(n.bits.writeBit(!0),n.bits.writeBit(!0),n.refs.push(e)):n.bits.writeBit(!1),r?n.bits.getFreeBits()>=r.bits.getUsedBits()&&n.refs.length+r.refs.length<=4?(n.bits.writeBit(!1),n.writeCell(r)):(n.bits.writeBit(!0),n.refs.push(r)):n.bits.writeBit(!1),n}static createMethod(t,e){return{getBody:async()=>(await e).body,getQuery:async()=>(await e).message,send:async()=>{const r=await e,i=s(await r.message.toBoc(!1));return t.sendBoc(i)},estimateFee:async()=>{const r=await e,i=r.code?{address:r.address.toString(!0,!0,!1),body:s(await r.body.toBoc(!1)),init_code:s(await r.code.toBoc(!1)),init_data:s(await r.data.toBoc(!1))}:{address:r.address.toString(!0,!0,!0),body:s(await r.body.toBoc(!1))};return t.getEstimateFee(i)}}}}t.exports={Contract:h}},(t,e,r)=>{const{Cell:i}=r(21),{base64ToBytes:n}=r(1),s=r(28).default;"undefined"==typeof fetch&&(fetch=r(29));const o="-9223372036854775808";class a{constructor(t,e){this.host=t||"https://toncenter.com/api/v2/jsonRPC",this.options=e||{}}sendImpl(t,e){const r={"Content-Type":"application/json"};return this.options.apiKey&&(r["X-API-Key"]=this.options.apiKey),fetch(t,{method:"POST",headers:r,body:JSON.stringify(e)}).then((t=>t.json())).then((({result:t,error:e})=>t||Promise.reject(e)))}send(t,e){return this.sendImpl(this.host,{id:1,jsonrpc:"2.0",method:t,params:e})}async getAddressInfo(t){return this.send("getAddressInformation",{address:t})}async getExtendedAddressInfo(t){return this.send("getExtendedAddressInformation",{address:t})}async getWalletInfo(t){return this.send("getWalletInformation",{address:t})}async getTransactions(t,e=20,r,i,n,s){return this.send("getTransactions",{address:t,limit:e,lt:r,hash:i,to_lt:n,archival:s})}async getBalance(t){return this.send("getAddressBalance",{address:t})}async sendBoc(t){return this.send("sendBoc",{boc:t})}async sendQuery(t){return this.send("sendQuerySimple",t)}async getEstimateFee(t){return this.send("estimateFee",t)}async call(t,e,r=[]){return this.send("runGetMethod",{address:t,method:e,stack:r})}async call2(t,e,r=[]){const i=await this.send("runGetMethod",{address:t,method:e,stack:r});return s.parseResponse(i)}async getConfigParam(t){const e=await this.send("getConfigParam",{config_id:t});if("configInfo"!==e["@type"])throw new Error("getConfigParam expected type configInfo");if(!e.config)throw new Error("getConfigParam expected config");if("tvm.cell"!==e.config["@type"])throw new Error("getConfigParam expected type tvm.cell");if(!e.config.bytes)throw new Error("getConfigParam expected bytes");return i.oneFromBoc(n(e.config.bytes))}async getMasterchainInfo(){return this.send("getMasterchainInfo",{})}async getBlockShards(t){return this.send("shards",{seqno:t})}async getBlockTransactions(t,e,r,i,n,s){return this.send("getBlockTransactions",{workchain:t,shard:e,seqno:r,count:i,after_lt:n,after_hash:s})}async getMasterchainBlockTransactions(t,e,r,i){return this.getBlockTransactions(-1,o,t,e,r,i)}async getBlockHeader(t,e,r){return this.send("getBlockHeader",{workchain:t,shard:e,seqno:r})}async getMasterchainBlockHeader(t){return this.getBlockHeader(-1,o,t)}}a.SHARD_ID_ALL=o,t.exports.default=a},(t,e,r)=>{const{BN:i,base64ToBytes:n}=r(1),{Cell:s}=r(21);class o{static parseObject(t){const e=t["@type"];switch(e){case"tvm.list":case"tvm.tuple":return t.elements.map(o.parseObject);case"tvm.cell":return s.oneFromBoc(n(t.bytes));case"tvm.stackEntryCell":return o.parseObject(t.cell);case"tvm.stackEntryTuple":return o.parseObject(t.tuple);case"tvm.stackEntryNumber":return o.parseObject(t.number);case"tvm.numberDecimal":return new i(t.number,10);default:throw new Error("unknown type "+e)}}static parseResponseStack(t){const e=t[0],r=t[1];switch(e){case"num":return new i(r.replace(/0x/,""),16);case"list":case"tuple":return o.parseObject(r);case"cell":const t=n(r.bytes);return s.oneFromBoc(t);default:throw new Error("unknown type "+e)}}static parseResponse(t){if(0!==t.exit_code){const e=new Error("http provider parse response error");throw e.result=t,e}const e=t.stack.map(o.parseResponseStack);return 1===e.length?e[0]:e}static makeArg(t){if(t instanceof i||t instanceof Number)return["num",t];throw new Error("unknown arg type "+t)}static makeArgs(t){return t.map(this.makeArg)}}t.exports.default=o},()=>{},(t,e,r)=>{const{Cell:i}=r(21),{Address:n,BN:s,toNano:o,bytesToHex:a,hexToBytes:h,nacl:u,stringToBytes:l,bytesToBase64:c}=r(1),{Contract:f}=r(26),{SimpleWalletContractR1:d,SimpleWalletContractR2:p,SimpleWalletContractR3:m}=r(31),{WalletV2ContractR1:g,WalletV2ContractR2:y}=r(33),{WalletV3ContractR1:w,WalletV3ContractR2:v}=r(34),{WalletV4ContractR1:b}=r(36),{WalletV4ContractR2:E}=r(37),A={simpleR1:d,simpleR2:p,simpleR3:m,v2R1:g,v2R2:y,v3R1:w,v3R2:v,v4R1:b,v4R2:E},C=[d,p,m,g,y,w,v,b,E];class M{constructor(t){this.provider=t,this.all=A,this.list=C,this.defaultVersion="v3R1",this.default=this.all[this.defaultVersion]}create(t){return new this.default(this.provider,t)}}M.all=A,M.list=C,t.exports.default=M},(t,e,r)=>{const{Cell:i}=r(21),{WalletContract:n}=r(32);t.exports={SimpleWalletContractR1:class extends n{constructor(t,e){e.code=i.oneFromBoc("B5EE9C72410101010044000084FF0020DDA4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED5441FDF089"),super(t,e)}getName(){return"simpleR1"}},SimpleWalletContractR2:class extends n{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100530000A2FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54D0E2786F"),super(t,e)}getName(){return"simpleR2"}},SimpleWalletContractR3:class extends n{constructor(t,e){e.code=i.oneFromBoc("B5EE9C7241010101005F0000BAFF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54B5B86E42"),super(t,e)}getName(){return"simpleR3"}}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{nacl:s,stringToBytes:o,Address:a,BN:h}=r(1);t.exports={WalletContract:class extends i{constructor(t,e){if(!e.publicKey&&!e.address)throw new Error("WalletContract required publicKey or address in options");super(t,e),this.methods={transfer:e=>i.createMethod(t,this.createTransferMessage(e.secretKey,e.toAddress,e.amount,e.seqno,e.payload,e.sendMode,!Boolean(e.secretKey),e.stateInit,e.expireAt)),transfers:e=>i.createMethod(t,this.createTransferMessages(e.secretKey,e.seqno,e.messages,!Boolean(e.secretKey),e.expireAt)),seqno:()=>({call:async()=>{const e=await this.getAddress();let r=null;try{r=(await t.call2(e.toString(),"seqno")).toNumber()}catch(t){}return r}})},this.deploy=e=>i.createMethod(t,this.createInitExternalMessage(e))}getName(){throw new Error("override me")}createDataCell(){const t=new n;return t.bits.writeUint(0,32),t.bits.writeBytes(this.options.publicKey),t}createSigningMessage(t){t=t||0;const e=new n;return e.bits.writeUint(t,32),e}async createInitExternalMessage(t){if(!this.options.publicKey){const e=s.sign.keyPair.fromSecretKey(t);this.options.publicKey=e.publicKey}const{stateInit:e,address:r,code:o,data:a}=await this.createStateInit(),h=this.createSigningMessage(),u=s.sign.detached(await h.hash(),t),l=new n;l.bits.writeBytes(u),l.writeCell(h);const c=i.createExternalMessageHeader(r);return{address:r,message:i.createCommonMsgInfo(c,e,l),body:l,signingMessage:h,stateInit:e,code:o,data:a}}async createExternalMessage(t,e,r,o=!1){const a=o?new Uint8Array(64):s.sign.detached(await t.hash(),e),h=new n;h.bits.writeBytes(a),h.writeCell(t);let u=null,l=null,c=null;if(0===r){if(!this.options.publicKey){const t=s.sign.keyPair.fromSecretKey(e);this.options.publicKey=t.publicKey}const t=await this.createStateInit();u=t.stateInit,l=t.code,c=t.data}const f=await this.getAddress(),d=i.createExternalMessageHeader(f);return{address:f,message:i.createCommonMsgInfo(d,u,h),body:h,signature:a,signingMessage:t,stateInit:u,code:l,data:c}}async createTransferMessage(t,e,r,n,s="",o=3,a=!1,h=null,u){if(null==n||n<0)throw new Error("seqno must be number >= 0");const l=this.createSigningMessage(n,u);return null==o&&(o=3),l.bits.writeUint8(o),l.refs.push(i.createOutMsg(e,r,s,h)),this.createExternalMessage(l,t,n,a)}async createTransferMessages(t,e,r,n=!1,s){if(null==e||e<0)throw new Error("seqno must be number >= 0");const o=this.createSigningMessage(e,s);if(r.length<1||r.length>4)throw new Error("put 1-4 messages");for(const t of r){let e=t.sendMode;null==e&&(e=3),o.bits.writeUint8(e),o.refs.push(i.createOutMsg(t.toAddress,t.amount,t.payload,t.stateInit))}return this.createExternalMessage(o,t,e,n)}}}},(t,e,r)=>{const{Cell:i}=r(21),{WalletContract:n}=r(32);class s extends n{createSigningMessage(t,e){t=t||0,e=e||Math.floor(Date.now()/1e3)+60;const r=new i;if(r.bits.writeUint(t,32),0===t)for(let t=0;t<32;t++)r.bits.writeBit(1);else r.bits.writeUint(e,32);return r}}t.exports={WalletV2ContractR1:class extends s{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100570000AAFF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31F01F823BBF263ED44D0D31FD3FFD15131BAF2A103F901541042F910F2A2F800029320D74A96D307D402FB00E8D1A4C8CB1FCBFFC9ED54A1370BB6"),super(t,e)}getName(){return"v2R1"}},WalletV2ContractR2:class extends s{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100630000C2FF0020DD2082014C97BA218201339CBAB19C71B0ED44D0D31FD70BFFE304E0A4F2608308D71820D31FD31F01F823BBF263ED44D0D31FD3FFD15131BAF2A103F901541042F910F2A2F800029320D74A96D307D402FB00E8D1A4C8CB1FCBFFC9ED54044CD7A1"),super(t,e)}getName(){return"v2R2"}}}},(t,e,r)=>{const{Cell:i}=r(21),{WalletContract:n}=r(32),{parseWalletV3TransferQuery:s,parseWalletV3TransferBody:o}=r(35);class a extends n{createSigningMessage(t,e){t=t||0,e=e||Math.floor(Date.now()/1e3)+60;const r=new i;if(r.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)r.bits.writeBit(1);else r.bits.writeUint(e,32);return r.bits.writeUint(t,32),r}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t}}class h extends a{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100620000C0FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED543FBE6EE0"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc)}getName(){return"v3R1"}}h.parseTransferQuery=s,h.parseTransferBody=o;class u extends a{constructor(t,e){e.code=i.oneFromBoc("B5EE9C724101010100710000DEFF0020DD2082014C97BA218201339CBAB19F71B0ED44D0D31FD31F31D70BFFE304E0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED5410BD6DAD"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc)}getName(){return"v3R2"}}u.parseTransferQuery=s,u.parseTransferBody=o,t.exports={WalletV3ContractR1:h,WalletV3ContractR2:u}},(t,e,r)=>{const{BN:i}=r(1);function n(t){if(t.loadBits(512),698983191!==t.loadUint(32).toNumber())throw new Error("invalid walletId");const e=t.loadUint(32).toNumber(),r=t.loadUint(32).toNumber();if(3!==t.loadUint(8).toNumber())throw new Error("invalid sendMode");let n=t.loadRef();if(n.loadBit())throw Error("invalid internal header");if(!n.loadBit())throw Error("invalid ihrDisabled");const s=n.loadBit();if(n.loadBit())throw Error("invalid bounced");if(null!==n.loadAddress())throw Error("invalid externalSourceAddress");const o=n.loadAddress(),a=n.loadCoins();if(n.loadBit())throw Error("invalid currencyCollection");if(!n.loadCoins().eq(new i(0)))throw new Error("invalid ihrFees");if(!n.loadCoins().eq(new i(0)))throw new Error("invalid fwdFees");if(!n.loadUint(64).eq(new i(0)))throw new Error("invalid createdLt");if(!n.loadUint(32).eq(new i(0)))throw new Error("invalid createdAt");n.loadBit()&&n.loadRef();let h=null;if(n.getFreeBits()>0&&(n.loadBit()&&(n=n.loadRef()),n.getFreeBits()>32)){const t=n.loadUint(32),e=n.loadBits(n.getFreeBits());h=t.eq(new i(0))?(new TextDecoder).decode(e):""}return{toAddress:o,value:a,bounce:s,seqno:r,expireAt:e,payload:h}}t.exports={parseWalletV3TransferQuery:function(t){const e=t.beginParse();if(2!==e.loadUint(2).toNumber())throw Error("invalid header");if(null!==e.loadAddress())throw Error("invalid externalSourceAddress");const r=e.loadAddress();if(!e.loadCoins().eq(new i(0)))throw new Error("invalid externalImportFee");return e.loadBit()&&e.loadBit()&&e.loadRef(),{fromAddress:r,...n(e.loadBit()?e.loadRef():e)}},parseWalletV3TransferBody:n}},(t,e,r)=>{const{Cell:i}=r(21),{Contract:n}=r(26),{Address:s,bytesToHex:o,BN:a}=r(1),{WalletContract:h}=r(32),{parseWalletV3TransferQuery:u,parseWalletV3TransferBody:l}=r(35);class c extends h{constructor(t,e){e.code=i.oneFromBoc("B5EE9C72410215010002F5000114FF00F4A413F4BCF2C80B010201200203020148040504F8F28308D71820D31FD31FD31F02F823BBF263ED44D0D31FD31FD3FFF404D15143BAF2A15151BAF2A205F901541064F910F2A3F80024A4C8CB1F5240CB1F5230CBFF5210F400C9ED54F80F01D30721C0009F6C519320D74A96D307D402FB00E830E021C001E30021C002E30001C0039130E30D03A4C8CB1F12CB1FCBFF1112131403EED001D0D3030171B0915BE021D749C120915BE001D31F218210706C7567BD228210626C6E63BDB022821064737472BDB0925F03E002FA403020FA4401C8CA07CBFFC9D0ED44D0810140D721F404305C810108F40A6FA131B3925F05E004D33FC8258210706C7567BA9131E30D248210626C6E63BAE30004060708020120090A005001FA00F404308210706C7567831EB17080185005CB0527CF165003FA02F40012CB69CB1F5210CB3F0052F8276F228210626C6E63831EB17080185005CB0527CF1624FA0214CB6A13CB1F5230CB3F01FA02F4000092821064737472BA8E3504810108F45930ED44D0810140D720C801CF16F400C9ED54821064737472831EB17080185004CB0558CF1622FA0212CB6ACB1FCB3F9410345F04E2C98040FB000201200B0C0059BD242B6F6A2684080A06B90FA0218470D4080847A4937D29910CE6903E9FF9837812801B7810148987159F31840201580D0E0011B8C97ED44D0D70B1F8003DB29DFB513420405035C87D010C00B23281F2FFF274006040423D029BE84C600201200F100019ADCE76A26840206B90EB85FFC00019AF1DF6A26840106B90EB858FC0006ED207FA00D4D422F90005C8CA0715CBFFC9D077748018C8CB05CB0222CF165005FA0214CB6B12CCCCC971FB00C84014810108F451F2A702006C810108D718C8542025810108F451F2A782106E6F746570748018C8CB05CB025004CF16821005F5E100FA0213CB6A12CB1FC971FB00020072810108D718305202810108F459F2A7F82582106473747270748018C8CB05CB025005CF16821005F5E100FA0214CB6A13CB1F12CB3FC973FB00000AF400C9ED5446A9F34F"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc),this.methods.getPublicKey=this.getPublicKey.bind(this)}getName(){return"v4R1"}createSigningMessage(t,e,r){t=t||0,e=e||Math.floor(Date.now()/1e3)+60;const n=new i;if(n.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)n.bits.writeBit(1);else n.bits.writeUint(e,32);return n.bits.writeUint(t,32),r||n.bits.writeUint(0,8),n}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t.bits.writeUint(0,1),t}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}}c.parseTransferQuery=u,c.parseTransferBody=l,t.exports={WalletV4ContractR1:c}},(t,e,r)=>{const{Cell:i}=r(21),{Contract:n}=r(26),{Address:s,bytesToHex:o,BN:a,toNano:h}=r(1),{WalletContract:u}=r(32),{parseWalletV3TransferQuery:l,parseWalletV3TransferBody:c}=r(35);class f extends u{constructor(t,e){e.code=i.oneFromBoc("B5EE9C72410214010002D4000114FF00F4A413F4BCF2C80B010201200203020148040504F8F28308D71820D31FD31FD31F02F823BBF264ED44D0D31FD31FD3FFF404D15143BAF2A15151BAF2A205F901541064F910F2A3F80024A4C8CB1F5240CB1F5230CBFF5210F400C9ED54F80F01D30721C0009F6C519320D74A96D307D402FB00E830E021C001E30021C002E30001C0039130E30D03A4C8CB1F12CB1FCBFF1011121302E6D001D0D3032171B0925F04E022D749C120925F04E002D31F218210706C7567BD22821064737472BDB0925F05E003FA403020FA4401C8CA07CBFFC9D0ED44D0810140D721F404305C810108F40A6FA131B3925F07E005D33FC8258210706C7567BA923830E30D03821064737472BA925F06E30D06070201200809007801FA00F40430F8276F2230500AA121BEF2E0508210706C7567831EB17080185004CB0526CF1658FA0219F400CB6917CB1F5260CB3F20C98040FB0006008A5004810108F45930ED44D0810140D720C801CF16F400C9ED540172B08E23821064737472831EB17080185005CB055003CF1623FA0213CB6ACB1FCB3FC98040FB00925F03E20201200A0B0059BD242B6F6A2684080A06B90FA0218470D4080847A4937D29910CE6903E9FF9837812801B7810148987159F31840201580C0D0011B8C97ED44D0D70B1F8003DB29DFB513420405035C87D010C00B23281F2FFF274006040423D029BE84C600201200E0F0019ADCE76A26840206B90EB85FFC00019AF1DF6A26840106B90EB858FC0006ED207FA00D4D422F90005C8CA0715CBFFC9D077748018C8CB05CB0222CF165005FA0214CB6B12CCCCC973FB00C84014810108F451F2A7020070810108D718FA00D33FC8542047810108F451F2A782106E6F746570748018C8CB05CB025006CF165004FA0214CB6A12CB1FCB3FC973FB0002006C810108D718FA00D33F305224810108F459F2A782106473747270748018C8CB05CB025005CF165003FA0213CB6ACB1F12CB3FC973FB00000AF400C9ED54696225E5"),super(t,e),this.options.walletId||(this.options.walletId=698983191+this.options.wc),this.methods.deployAndInstallPlugin=e=>n.createMethod(t,this.deployAndInstallPlugin(e)),this.methods.installPlugin=e=>n.createMethod(t,this.installPlugin(e)),this.methods.removePlugin=e=>n.createMethod(t,this.removePlugin(e)),this.methods.getPublicKey=this.getPublicKey.bind(this),this.methods.getWalletId=this.getWalletId.bind(this),this.methods.isPluginInstalled=this.isPluginInstalled.bind(this),this.methods.getPluginsList=this.getPluginsList.bind(this)}getName(){return"v4R2"}createSigningMessage(t,e,r){t=t||0,e=e||Math.floor(Date.now()/1e3)+60;const n=new i;if(n.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)n.bits.writeBit(1);else n.bits.writeUint(e,32);return n.bits.writeUint(t,32),r||n.bits.writeUint(0,8),n}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t.bits.writeUint(0,1),t}async deployAndInstallPlugin(t){const{secretKey:e,seqno:r,pluginWc:i,amount:n,stateInit:s,body:o,expireAt:a}=t,h=this.createSigningMessage(r,a,!0);return h.bits.writeUint(1,8),h.bits.writeInt(i,8),h.bits.writeGrams(n),h.refs.push(s),h.refs.push(o),this.createExternalMessage(h,e,r,!1)}async _setPlugin(t,e){const{secretKey:r,seqno:i,amount:n,queryId:o,expireAt:a}=t,u=new s(t.pluginAddress),l=this.createSigningMessage(i,a,!0);return l.bits.writeUint(e?2:3,8),l.bits.writeInt(u.wc,8),l.bits.writeBytes(u.hashPart),l.bits.writeGrams(n||h("0.1")),l.bits.writeUint(o||0,64),this.createExternalMessage(l,r,i,!1)}async installPlugin(t){return this._setPlugin(t,!0)}async removePlugin(t){return this._setPlugin(t,!1)}async getWalletId(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_subwallet_id")).toNumber()}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}async isPluginInstalled(t){t=new s(t);const e="0x"+o(t.hashPart),r=await this.getAddress();return!(await this.provider.call2(r.toString(),"is_plugin_installed",[["num",t.wc],["num",e]])).isZero()}async getPluginsList(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_plugin_list")).map((t=>t[0].toNumber()+":"+t[1].toString(16)))}}f.parseTransferQuery=l,f.parseTransferBody=c,t.exports={WalletV4ContractR2:f}},(t,e,r)=>{const{LockupWalletV1:i}=r(39),{VestingWalletV1:n}=r(40);t.exports.default={LockupWalletV1:i,VestingWalletV1:n,all:{"lockup-0.1":i,"vesting-1":n},list:[i,n]}},(t,e,r)=>{const{Cell:i}=r(21),{Address:n,BN:s,base64ToBytes:o}=r(1),{WalletContract:a}=r(32),h=698983191;class u extends a{constructor(t,e){e.code=i.oneFromBoc("B5EE9C7241021E01000261000114FF00F4A413F4BCF2C80B010201200203020148040501F2F28308D71820D31FD31FD31F802403F823BB13F2F2F003802251A9BA1AF2F4802351B7BA1BF2F4801F0BF9015410C5F9101AF2F4F8005057F823F0065098F823F0062071289320D74A8E8BD30731D4511BDB3C12B001E8309229A0DF72FB02069320D74A96D307D402FB00E8D103A4476814154330F004ED541D0202CD0607020120131402012008090201200F100201200A0B002D5ED44D0D31FD31FD3FFD3FFF404FA00F404FA00F404D1803F7007434C0C05C6C2497C0F83E900C0871C02497C0F80074C7C87040A497C1383C00D46D3C00608420BABE7114AC2F6C2497C338200A208420BABE7106EE86BCBD20084AE0840EE6B2802FBCBD01E0C235C62008087E4055040DBE4404BCBD34C7E00A60840DCEAA7D04EE84BCBD34C034C7CC0078C3C412040DD78CA00C0D0E00130875D27D2A1BE95B0C60000C1039480AF00500161037410AF0050810575056001010244300F004ED540201201112004548E1E228020F4966FA520933023BB9131E2209835FA00D113A14013926C21E2B3E6308003502323287C5F287C572FFC4F2FFFD00007E80BD00007E80BD00326000431448A814C4E0083D039BE865BE803444E800A44C38B21400FE809004E0083D10C06002012015160015BDE9F780188242F847800C02012017180201481B1C002DB5187E006D88868A82609E00C6207E00C63F04EDE20B30020158191A0017ADCE76A268699F98EB85FFC00017AC78F6A268698F98EB858FC00011B325FB513435C2C7E00017B1D1BE08E0804230FB50F620002801D0D3030178B0925B7FE0FA4031FA403001F001A80EDAA4"),super(t,e),this.options.walletId||(this.options.walletId=h+this.options.wc),this.methods.getPublicKey=this.getPublicKey.bind(this),this.methods.getWalletId=this.getWalletId.bind(this),this.methods.getLiquidBalance=this.getLiquidBalance.bind(this),this.methods.getNominalRestrictedBalance=this.getNominalRestrictedBalance.bind(this),this.methods.getNominalLockedBalance=this.getNominalLockedBalance.bind(this)}getName(){return"lockup-0.1"}createSigningMessage(t,e,r){t=t||0,e=e||Math.floor(Date.now()/1e3)+60;const n=new i;if(n.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)n.bits.writeBit(1);else n.bits.writeUint(e,32);return n.bits.writeUint(t,32),n}createDataCell(){const t=new i;return t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeBytes(this.options.publicKey),t.bits.writeBytes(o(this.options.config.config_public_key)),this.options.config.allowed_destinations?(t.bits.writeUint(1,1),t.refs.push(i.oneFromBoc(o(this.options.config.allowed_destinations)))):t.bits.writeUint(0,1),t.bits.writeGrams(0),t.bits.writeUint(0,1),t.bits.writeGrams(0),t.bits.writeUint(0,1),t}async getWalletId(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_subwallet_id")).toNumber()}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}async getLiquidBalance(){const t=await this.getBalances();return t[0]-t[1]-t[2]}async getNominalRestrictedBalance(){return await this.getBalances()[1]}async getNominalLockedBalance(){return await this.getBalances()[2]}async getBalances(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_balances")}}u.WALLET_ID_BASE=h,t.exports={LockupWalletV1:u}},(t,e,r)=>{const{Cell:i}=r(21),{Address:n,BN:s,bytesToHex:o}=r(1),{WalletContract:a}=r(32),{parseAddress:h}=r(41),{Contract:u}=r(26),l="b5ee9c7241021c010003fb000114ff00f4a413f4bcf2c80b01020120030203b8f28308d71820d31fd31fd31f02f823bbf264ed44d0d31fd31fd3ff305abaf2a15033baf2a202f9014033f910f2a3f800db3c20d74ac0018e99ed44ed45ed47915bed67ed65ed648e82db3ced41edf101f2ff9130e2f841a4f861db3c1b1413020148110402012008050201200706020db9846db3cdb3c81b1a0129ba462db3cf845f846f847f848f849f84af84bf84481b0201200e090201620d0a02016a0c0b012fa2c76cf3e9100723281f2fff2743e112040423d029be84c61b000fa25fb513435c2c7e014bad346d9e36fc22470d4080847a4937d29910ce6903e9ff9837812801b7810148987159f318401b02016e100f0019af1df6a26840106b90eb858fc00019adce76a26840206b90eb85ffc003acd06c2220d749c160915be001d0d3030171b0915be0fa4030db3c01d31fd33ff84b5240c705238210a7733acdbab08ea46c12db3c8210f7733acd01708018c8cb055004cf1623fa0213cb6acb1fcb3fc98040fb00e30e1b141201cef84a5240c7050382107258a69bba13b08ed18e2c01fa407fc8ca0002fa4401c8ca07cbffc9d0f8441023810108f441f86420d74ac200209501d430d001deb312e68210f258a69b32708018c8cb055004cf1623fa0213cb6acb1fcb3fc98040fb00db3c925f03e2130066f848f847f846f845c8cb3fcb1fcb1fcb1ff849fa02f84acf16f84bcf16c9f844f843f842f841c8cb1fcb1fcbfff400ccc9ed54025cd307d4d1f823db3c20c2008e9b22c003f2e06421d0d303fa4031fa40f84a5220c705b3925f04e30d9130e201fb001a1503fa21fa4401c8ca07cbffc9d0f844810108f40a6fa1318f5f330172b0c002f2e06501fa003171d721fa0031fa0031d33f31d31f31d30001c000f2e066d3000193d430d0de2171db3c8e2a31d31f302082104e73744bba21821047657424bab121821056744370bab1018210566f7465bab1f2e067e30e70925f03e220c200191716000e9372fb029130e202ea0170db3c8e6d20d749c2008e63d31f21c00022830bbab122811001bab122821047d54391bab1228210595f07bcbab122821069fb306cbab1228210566f7465bab122821056744370bab1f2e06701c00021d749c200b08e15d3073020c06421c077b121c044b101c057b1f2e0689130e29130e2e30d1918001ad31f308210566f7465baf2e067004401fa4401c3ff925b70e001f833206e925b70e0d020d7498307b9925b70e0d70bffba0060f845f846a05210bc923070e0f845f848a05210b99330f849e0f849f849f84513a1f847a904f846f847a9041023a984a1007eed44d0d31f01f861d31f01f862d3ff01f863f40401f864d401d0d33f01f865d31f01f866d31f01f867d31f01f868fa0001f869fa4001f86afa4001f86bd1d10a20c6a7";class c extends a{constructor(t,e){e.code=i.oneFromBoc(l),super(t,e),this.options.walletId||(this.options.walletId=268+this.options.wc),this.methods.getPublicKey=this.getPublicKey.bind(this),this.methods.getWalletId=this.getWalletId.bind(this),this.methods.getLockedAmount=this.getLockedAmount.bind(this),this.methods.getVestingData=this.getVestingData.bind(this),this.methods.getWhitelist=this.getWhitelist.bind(this)}getName(){return"vesting-1"}createSigningMessage(t,e,r){t=t||0,e=e||Math.floor(Date.now()/1e3)+60;const n=new i;if(n.bits.writeUint(this.options.walletId,32),0===t)for(let t=0;t<32;t++)n.bits.writeBit(1);else n.bits.writeUint(e,32);return n.bits.writeUint(t,32),n}createDataCell(){if(0!==this.options.walletId&&!this.options.walletId)throw new Error("no walletId");if(!this.options.publicKey)throw new Error("no publicKey");if(!(this.options.publicKey instanceof Uint8Array))throw new Error("publicKey not Uint8Array");if(0!==this.options.vestingStartTime&&!this.options.vestingStartTime)throw new Error("no vestingStartTime");if(this.options.vestingTotalDuration<=0)throw new Error("vestingTotalDuration cant be zero or negative");if(!this.options.vestingTotalDuration)throw new Error("no vestingTotalDuration");if(this.options.vestingTotalDuration>2**32-1)throw new Error("vestingTotalDuration > 2^32 - 1");if(this.options.unlockPeriod<=0)throw new Error("unlockPeriod cant be zero or negative");if(!this.options.unlockPeriod)throw new Error("no unlockPeriod");if(this.options.unlockPeriod>this.options.vestingTotalDuration)throw new Error("unlockPeriod > vestingTotalDuration");if(0!==this.options.cliffDuration&&!this.options.cliffDuration)throw new Error("no cliffDuration");if(this.options.cliffDuration<0)throw new Error("cliffDuration cant be negative");if(this.options.cliffDuration>=this.options.vestingTotalDuration)throw new Error("cliffDuration >= vestingTotalDuration");if(!new s(this.options.vestingTotalDuration).div(new s(this.options.unlockPeriod)).mul(new s(this.options.unlockPeriod)).eq(new s(this.options.vestingTotalDuration)))throw new Error("vestingTotalDuration mod unlockPeriod != 0");if(!new s(this.options.cliffDuration).div(new s(this.options.unlockPeriod)).mul(new s(this.options.unlockPeriod)).eq(new s(this.options.cliffDuration)))throw new Error("cliffDuration mod unlockPeriod != 0");if(!this.options.vestingTotalAmount)throw new Error("no vestingTotalAmount");if(!this.options.vestingTotalAmount.gt(new s(0)))throw new Error("vestingTotalAmount cant be zero");if(!this.options.vestingSenderAddress)throw new Error("no vestingSenderAddress");if(!(this.options.vestingSenderAddress instanceof n))throw new Error("vestingSenderAddress not Address");if(!this.options.ownerAddress)throw new Error("no ownerAddress");if(!(this.options.ownerAddress instanceof n))throw new Error("ownerAddress not Address");const t=new i;t.bits.writeUint(0,32),t.bits.writeUint(this.options.walletId,32),t.bits.writeUint(new s(o(this.options.publicKey),16),256),t.bits.writeBit(!1);const e=new i;return e.bits.writeUint(this.options.vestingStartTime,64),e.bits.writeUint(this.options.vestingTotalDuration,32),e.bits.writeUint(this.options.unlockPeriod,32),e.bits.writeUint(this.options.cliffDuration,32),e.bits.writeCoins(this.options.vestingTotalAmount),e.bits.writeAddress(new n(this.options.vestingSenderAddress)),e.bits.writeAddress(new n(this.options.ownerAddress)),t.refs[0]=e,t}createAddWhitelistBody(t){const{addresses:e,queryId:r}=t,n=new i;n.bits.writeUint(1918412443,32),n.bits.writeUint(r||0,64),n.bits.writeAddress(e[0]);let s=null;for(let t=e.length-1;t>=1;t--){const r=new i;r.bits.writeAddress(e[t]),s&&(r.refs[0]=s),s=r}return s&&(n.refs[0]=s),n}createInternalTransfer(t){const e=new i;return e.bits.writeUint(2809346765,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeUint8(t.sendMode||3),e.refs.push(u.createOutMsg(t.address,t.amount,t.payload)),e}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}async getWalletId(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_subwallet_id")}async getLockedAmount(t){const e=await this.getAddress();return this.provider.call2(e.toString(),"get_locked_amount",[["num",t]])}async getVestingData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_vesting_data");return{vestingStartTime:e[0].toNumber(),vestingTotalDuration:e[1].toNumber(),unlockPeriod:e[2].toNumber(),cliffDuration:e[3].toNumber(),vestingTotalAmount:e[4],vestingSenderAddress:h(e[5]),ownerAddress:h(e[6]),whitelistCell:e[7]}}async getWhitelist(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_whitelist"),r=[];for(const t of e){if(2!==t.length)throw new Error("invalid whitelist result");const e=t[0],i=t[1],s=new n(e.toString(10)+":"+i.toString(16).padStart(64,"0"));r.push(s)}return r}}c.WALLET_ID_BASE=268,c.codeHex=l,t.exports={VestingWalletV1:c}},(t,e,r)=>{const{Address:i}=r(1),{Cell:n}=r(21),s=t=>(new TextEncoder).encode(encodeURI(t)),o=t=>(new TextDecoder).decode(t),a=(t,e,r)=>{let i=BigInt(0);for(let n=0;n{let e=a(t.bits,3,8);e>BigInt(127)&&(e-=BigInt(256));const r=a(t.bits,11,256);if(e.toString(10)+":"+r.toString(16)=="0:0")return null;const n=e.toString(10)+":"+r.toString(16).padStart(64,"0");return new i(n)};t.exports={SNAKE_DATA_PREFIX:0,CHUNK_DATA_PREFIX:1,ONCHAIN_CONTENT_PREFIX:0,OFFCHAIN_CONTENT_PREFIX:1,parseAddress:h,serializeUri:s,parseUri:o,createOffchainUriCell:t=>{const e=new n;return e.bits.writeUint(1,8),e.bits.writeBytes(s(t)),e},parseOffchainUriCell:t=>{if(1!==t.bits.array[0])throw new Error("no OFFCHAIN_CONTENT_PREFIX");let e=0,r=t;for(;r;)e+=r.bits.array.length,r=r.refs[0];const i=new Uint8Array(e);for(e=0,r=t;r;)i.set(r.bits.array,e),e+=r.bits.array.length,r=r.refs[0];return o(i.slice(1))},getRoyaltyParams:async(t,e)=>{const r=await t.call2(e,"royalty_params"),i=r[0].toNumber(),n=r[1].toNumber();return{royalty:i/n,royaltyBase:n,royaltyFactor:i,royaltyAddress:h(r[2])}}}},(t,e,r)=>{const{HighloadWalletContractV3:i}=r(43),{HighloadQueryId:n}=r(44);t.exports.default={HighloadQueryId:n,HighloadWalletContractV3:i,all:{"highload-3":i},list:[i]}},(t,e,r)=>{const{Cell:i}=r(21),{Contract:n}=r(26),{Address:s,BN:o,nacl:a}=r(1),h="b5ee9c7241021001000228000114ff00f4a413f4bcf2c80b01020120020d02014803040078d020d74bc00101c060b0915be101d0d3030171b0915be0fa4030f828c705b39130e0d31f018210ae42e5a4ba9d8040d721d74cf82a01ed55fb04e030020120050a02027306070011adce76a2686b85ffc00201200809001aabb6ed44d0810122d721d70b3f0018aa3bed44d08307d721d70b1f0201200b0c001bb9a6eed44d0810162d721d70b15800e5b8bf2eda2edfb21ab09028409b0ed44d0810120d721f404f404d33fd315d1058e1bf82325a15210b99f326df82305aa0015a112b992306dde923033e2923033e25230800df40f6fa19ed021d721d70a00955f037fdb31e09130e259800df40f6fa19cd001d721d70a00937fdb31e0915be270801f6f2d48308d718d121f900ed44d0d3ffd31ff404f404d33fd315d1f82321a15220b98e12336df82324aa00a112b9926d32de58f82301de541675f910f2a106d0d31fd4d307d30cd309d33fd315d15168baf2a2515abaf2a6f8232aa15250bcf2a304f823bbf2a35304800df40f6fa199d024d721d70a00f2649130e20e01fe5309800df40f6fa18e13d05004d718d20001f264c858cf16cf8301cf168e1030c824cf40cf8384095005a1a514cf40e2f800c94039800df41704c8cbff13cb1ff40012f40012cb3f12cb15c9ed54f80f21d0d30001f265d3020171b0925f03e0fa4001d70b01c000f2a5fa4031fa0031f401fa0031fa00318060d721d300010f0020f265d2000193d431d19130e272b1fb00b585bf03",u=t=>{if(!t)throw new Error("invalid timeout");if(t<600)throw new Error("minimum timeout 10 minute");if(t>2592e3)throw new Error("maximum timeout 30 days")};class l extends n{constructor(t,e){if(e.wc)throw new Error("only basechain (wc = 0) supported");if(e.wc=0,!e.address){if(!e.publicKey)throw new Error("no publicKey");if(!(e.publicKey instanceof Uint8Array))throw new Error("publicKey not Uint8Array");u(e.timeout)}e.code=i.oneFromBoc(h),super(t,e),this.options.walletId||(this.options.walletId=4269),this.methods={transfer:e=>n.createMethod(t,this.createTransferMessage(e.secretKey,e.toAddress,e.amount,e.queryId,e.payload,e.sendMode,e.createdAt,e.needDeploy))},this.methods.getPublicKey=this.getPublicKey.bind(this),this.methods.getWalletId=this.getWalletId.bind(this),this.methods.getLastCleanTime=this.getLastCleanTime.bind(this),this.methods.getTimeout=this.getTimeout.bind(this),this.methods.isProcessed=this.isProcessed.bind(this)}getName(){return"highload-3"}createDataCell(){if(0!==this.options.walletId&&!this.options.walletId)throw new Error("no walletId");if(!this.options.publicKey)throw new Error("no publicKey");if(!(this.options.publicKey instanceof Uint8Array))throw new Error("publicKey not Uint8Array");u(this.options.timeout);const t=new i;return t.bits.writeBytes(this.options.publicKey),t.bits.writeUint(this.options.walletId,32),t.bits.writeUint(0,1),t.bits.writeUint(0,1),t.bits.writeUint(0,64),t.bits.writeUint(this.options.timeout,22),t}createSigningMessage(t,e,r,n){if(isNaN(r)||null==r)throw new Error("invalid sendMode");if(isNaN(e)||null==e)throw new Error("invalid createdAt");u(this.options.timeout);const s=new i;return s.bits.writeUint(this.options.walletId,32),s.refs.push(n),s.bits.writeUint(r,8),s.bits.writeUint(Number(t.getShift()),13),s.bits.writeUint(Number(t.getBitNumber()),10),s.bits.writeUint(e,64),s.bits.writeUint(this.options.timeout,22),s}async createTransferMessage(t,e,r,i,s="",o=3,a,h=!1){if(null==i)throw new Error("queryId must be number >= 0");if(null==a||a<0)throw new Error("createAt must be number >= 0");null==o&&(o=3);const u=n.createOutMsg(e,r,s),l=this.createSigningMessage(i,a,o,u);return this.createExternalMessage(l,t,h)}async createExternalMessage(t,e,r){const s=a.sign.detached(await t.hash(),e),o=new i;o.bits.writeBytes(s),o.refs.push(t);let h=null,u=null,l=null;if(r){if(!this.options.publicKey){const t=a.sign.keyPair.fromSecretKey(e);this.options.publicKey=t.publicKey}const t=await this.createStateInit();h=t.stateInit,u=t.code,l=t.data}const c=await this.getAddress(),f=n.createExternalMessageHeader(c);return{address:c,message:n.createCommonMsgInfo(f,h,o),body:o,signature:s,signingMessage:t,stateInit:h,code:u,data:l}}async getWalletId(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_subwallet_id")).toNumber()}async getPublicKey(){const t=await this.getAddress();return this.provider.call2(t.toString(),"get_public_key")}async getLastCleanTime(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_last_clean_time")).toNumber()}async getTimeout(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_timeout")).toNumber()}async isProcessed(t,e){const r=await this.getAddress();return!(await this.provider.call2(r.toString(),"processed?",[["num",t.getQueryId().toString()],["num",e?"-1":"0"]])).isZero()}}l.WALLET_ID_BASE=4269,l.codeHex=h,t.exports={HighloadWalletContractV3:l}},t=>{const e=10n,r=1022n,i=8191n;class n{constructor(){this.shift=0n,this.bitnumber=0n}static fromShiftAndBitNumber(t,e){const s=new n;if(s.shift=t,s.shift<0)throw new Error("invalid shift");if(s.shift>i)throw new Error("invalid shift");if(s.bitnumber=e,s.bitnumber<0)throw new Error("invalid bitnumber");if(s.bitnumber>r)throw new Error("invalid bitnumber");return s}getNext(){let t=this.bitnumber+1n,e=this.shift;if(e===i&&t>r-1n)throw new Error("Overload");if(t>r&&(t=0n,e+=1n,e>i))throw new Error("Overload");return n.fromShiftAndBitNumber(e,t)}hasNext(){return!(this.bitnumber>=r-1n&&this.shift===i)}getShift(){return this.shift}getBitNumber(){return this.bitnumber}getQueryId(){return(this.shift<>e,i=1023n&t;return this.fromShiftAndBitNumber(r,i)}static fromSeqno(t){const e=t/1023n,r=t%1023n;return this.fromShiftAndBitNumber(e,r)}toSeqno(){return this.bitnumber+1023n*this.shift}}t.exports={HighloadQueryId:n}},(t,e,r)=>{const{NftCollection:i}=r(46),{NftItem:n}=r(47),{NftMarketplace:s}=r(48),{NftSale:o}=r(49);t.exports.default={NftCollection:i,NftItem:n,NftMarketplace:s,NftSale:o}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{Address:s,bytesToBase64:o,BN:a}=r(1),{parseAddress:h}=r(41),{createOffchainUriCell:u,serializeUri:l,parseOffchainUriCell:c,getRoyaltyParams:f}=r(41);t.exports={NftCollection:class extends i{constructor(t,e){if(e.wc=0,e.code=e.code||n.oneFromBoc("B5EE9C724102140100021F000114FF00F4A413F4BCF2C80B0102016202030202CD04050201200E0F04E7D10638048ADF000E8698180B8D848ADF07D201800E98FE99FF6A2687D20699FEA6A6A184108349E9CA829405D47141BAF8280E8410854658056B84008646582A802E78B127D010A65B509E58FE59F80E78B64C0207D80701B28B9E382F970C892E000F18112E001718112E001F181181981E0024060708090201200A0B00603502D33F5313BBF2E1925313BA01FA00D43028103459F0068E1201A44343C85005CF1613CB3FCCCCCCC9ED54925F05E200A6357003D4308E378040F4966FA5208E2906A4208100FABE93F2C18FDE81019321A05325BBF2F402FA00D43022544B30F00623BA9302A402DE04926C21E2B3E6303250444313C85005CF1613CB3FCCCCCCC9ED54002C323401FA40304144C85005CF1613CB3FCCCCCCC9ED54003C8E15D4D43010344130C85005CF1613CB3FCCCCCCC9ED54E05F04840FF2F00201200C0D003D45AF0047021F005778018C8CB0558CF165004FA0213CB6B12CCCCC971FB008002D007232CFFE0A33C5B25C083232C044FD003D0032C03260001B3E401D3232C084B281F2FFF2742002012010110025BC82DF6A2687D20699FEA6A6A182DE86A182C40043B8B5D31ED44D0FA40D33FD4D4D43010245F04D0D431D430D071C8CB0701CF16CCC980201201213002FB5DAFDA89A1F481A67FA9A9A860D883A1A61FA61FF480610002DB4F47DA89A1F481A67FA9A9A86028BE09E008E003E00B01A500C6E"),e.royalty>1)throw new Error("royalty > 1");e.royaltyBase=1e3,e.royaltyFactor=Math.floor(e.royalty*e.royaltyBase),super(t,e),this.methods.getCollectionData=this.getCollectionData.bind(this),this.methods.getNftItemAddressByIndex=this.getNftItemAddressByIndex.bind(this),this.methods.getNftItemContent=this.getNftItemContent.bind(this),this.methods.getRoyaltyParams=this.getRoyaltyParams.bind(this)}createContentCell(t){const e=u(t.collectionContentUri),r=new n;r.bits.writeBytes(l(t.nftItemContentBaseUri));const i=new n;return i.refs[0]=e,i.refs[1]=r,i}createRoyaltyCell(t){const e=new n;return e.bits.writeUint(t.royaltyFactor,16),e.bits.writeUint(t.royaltyBase,16),e.bits.writeAddress(t.royaltyAddress),e}createDataCell(){const t=new n;return t.bits.writeAddress(this.options.ownerAddress),t.bits.writeUint(0,64),t.refs[0]=this.createContentCell(this.options),t.refs[1]=n.oneFromBoc(this.options.nftItemCodeHex),t.refs[2]=this.createRoyaltyCell(this.options),t}createMintBody(t){const e=new n;e.bits.writeUint(1,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeUint(t.itemIndex,64),e.bits.writeCoins(t.amount);const r=new n;r.bits.writeAddress(t.itemOwnerAddress);const i=new n;return i.bits.writeBytes(l(t.itemContentUri)),r.refs[0]=i,e.refs[0]=r,e}createGetRoyaltyParamsBody(t){const e=new n;return e.bits.writeUint(1765620048,32),e.bits.writeUint(t.queryId||0,64),e}createChangeOwnerBody(t){if(void 0===t.newOwnerAddress)throw new Error("Specify newOwnerAddress");const e=new n;return e.bits.writeUint(3,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.newOwnerAddress),e}createEditContentBody(t){if(t.royalty>1)throw new Error("royalty > 1");t.royaltyBase=1e3,t.royaltyFactor=Math.floor(t.royalty*t.royaltyBase);const e=new n;return e.bits.writeUint(4,32),e.bits.writeUint(t.queryId||0,64),e.refs[0]=this.createContentCell(t),e.refs[1]=this.createRoyaltyCell(t),e}async getCollectionData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_collection_data"),r=e[0];let i=NaN;try{i=r.toNumber()}catch(t){}const n=e[1];let s=null;try{s=c(n)}catch(t){}return{nextItemIndex:i,itemsCount:r,ownerAddress:h(e[2]),collectionContentCell:n,collectionContentUri:s}}async getNftItemContent(t){const e=await this.getAddress(),r=await t.getData();if(r.isInitialized){const t=await this.provider.call2(e.toString(),"get_nft_content",[["num",r.itemIndex.toString(10)],["tvm.Cell",o(await r.contentCell.toBoc(!1))]]);r.contentUri=null;try{r.contentUri=c(t)}catch(t){}}return r}async getNftItemAddressByIndex(t){t=new a(t);const e=await this.getAddress(),r=await this.provider.call2(e.toString(),"get_nft_address_by_index",[["num",t.toString(10)]]);return h(r)}async getRoyaltyParams(){const t=await this.getAddress();return f(this.provider,t.toString())}}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{Address:s,BN:o}=r(1),{parseAddress:a,getRoyaltyParams:h}=r(41),{parseOffchainUriCell:u}=r(41),l="B5EE9C7241020D010001D0000114FF00F4A413F4BCF2C80B0102016202030202CE04050009A11F9FE00502012006070201200B0C02D70C8871C02497C0F83434C0C05C6C2497C0F83E903E900C7E800C5C75C87E800C7E800C3C00812CE3850C1B088D148CB1C17CB865407E90350C0408FC00F801B4C7F4CFE08417F30F45148C2EA3A1CC840DD78C9004F80C0D0D0D4D60840BF2C9A884AEB8C097C12103FCBC20080900113E910C1C2EBCB8536001F65135C705F2E191FA4021F001FA40D20031FA00820AFAF0801BA121945315A0A1DE22D70B01C300209206A19136E220C2FFF2E192218E3E821005138D91C85009CF16500BCF16712449145446A0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00104794102A375BE20A00727082108B77173505C8CBFF5004CF1610248040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB000082028E3526F0018210D53276DB103744006D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093303234E25502F003003B3B513434CFFE900835D27080269FC07E90350C04090408F80C1C165B5B60001D00F232CFD633C58073C5B3327B5520BF75041B";class c extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc(l),super(t,e),this.methods.getData=this.getData.bind(this)}createDataCell(){const t=new n;return t.bits.writeUint(this.options.index,64),t.bits.writeAddress(this.options.collectionAddress),t}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_nft_data"),r=-1===e[0].toNumber(),i=e[1];let n=NaN;try{n=i.toNumber()}catch(t){}const s=a(e[2]),o=r?a(e[3]):null,h=e[4];let l=null;try{l=r&&null===s?u(h):null}catch(t){}return{isInitialized:r,index:n,itemIndex:i,collectionAddress:s,ownerAddress:o,contentCell:h,contentUri:l}}async createTransferBody(t){const e=new n;return e.bits.writeUint(1607220500,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.newOwnerAddress),e.bits.writeAddress(t.responseAddress),e.bits.writeBit(!1),e.bits.writeCoins(t.forwardAmount||new o(0)),t.forwardPayload?t.forwardPayload.refs?(e.bits.writeBit(!0),e.refs.push(t.forwardPayload)):(e.bits.writeBit(!1),e.bits.writeBytes(t.forwardPayload)):e.bits.writeBit(!1),e}createGetStaticDataBody(t){const e=new n;return e.bits.writeUint(801842850,32),e.bits.writeUint(t.queryId||0,64),e}async getRoyaltyParams(){const t=await this.getAddress();return h(this.provider,t.toString())}}c.codeHex=l,t.exports={NftItem:c}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{Address:s}=r(1),{parseAddress:o}=r(41);t.exports={NftMarketplace:class extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc("B5EE9C7241010401006D000114FF00F4A413F4BCF2C80B01020120020300AAD23221C700915BE0D0D3030171B0915BE0FA40ED44D0FA403012C705F2E19101D31F01C0018E2BFA003001D4D43021F90070C8CA07CBFFC9D077748018C8CB05CB0258CF165004FA0213CB6BCCCCC971FB00915BE20004F2308EF7CCE7"),super(t,e)}createDataCell(){const t=new n;return t.bits.writeAddress(this.options.ownerAddress),t}}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{parseAddress:s}=r(41),{BN:o}=r(1),a="B5EE9C7241020A010001B4000114FF00F4A413F4BCF2C80B01020120020302014804050004F2300202CD0607002FA03859DA89A1F481F481F481F401A861A1F401F481F4006101F7D00E8698180B8D8492F82707D201876A2687D207D207D207D006A18116BA4E10159C71D991B1B2990E382C92F837028916382F970FA01698FC1080289C6C8895D7970FAE99F98FD2018201A642802E78B2801E78B00E78B00FD016664F6AA701363804C9B081B2299823878027003698FE99F9810E000C92F857010C0801F5D41081DCD650029285029185F7970E101E87D007D207D0018384008646582A804E78B28B9D090D0A85AD08A500AFD010AE5B564B8FD80384008646582AC678B2803FD010B65B564B8FD80384008646582A802E78B00FD0109E5B564B8FD80381041082FE61E8A10C00C646582A802E78B117D010A65B509E58F8A40900C8C0029A3110471036454012F004E032363704C0038E4782103B9ACA0015BEF2E1C95312C70559C705B1F2E1CA702082105FCC3D14218010C8CB055006CF1622FA0215CB6A14CB1F14CB3F21CF1601CF16CA0021FA02CA00C98100A0FB00E05F06840FF2F0002ACB3F22CF1658CF16CA0021FA02CA00C98100A0FB00AECABAD1";class h extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc(a),super(t,e),this.methods.getData=this.getData.bind(this)}createDataCell(){const t=new n;t.bits.writeAddress(this.options.marketplaceAddress),t.bits.writeAddress(this.options.nftAddress),t.bits.writeAddress(null),t.bits.writeCoins(this.options.fullPrice);const e=new n;return e.bits.writeCoins(this.options.marketplaceFee),e.bits.writeAddress(this.options.royaltyAddress),e.bits.writeCoins(this.options.royaltyAmount),t.refs[0]=e,t}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_sale_data");return{marketplaceAddress:s(e[0]),nftAddress:s(e[1]),nftOwnerAddress:s(e[2]),fullPrice:e[3],marketplaceFee:e[4],royaltyAddress:s(e[5]),royaltyAmount:e[6]}}async createCancelBody(t){const e=new n;return e.bits.writeUint(3,32),e.bits.writeUint(t.queryId||0,64),e}}h.codeHex=a,t.exports={NftSale:h}},(t,e,r)=>{const{JettonMinter:i}=r(51),{JettonWallet:n}=r(52);t.exports.default={JettonMinter:i,JettonWallet:n}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{createOffchainUriCell:s,parseOffchainUriCell:o,parseAddress:a}=r(41),{Address:h,BN:u,bytesToBase64:l}=r(1);t.exports={JettonMinter:class extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc("B5EE9C7241020B010001ED000114FF00F4A413F4BCF2C80B0102016202030202CC040502037A60090A03EFD9910E38048ADF068698180B8D848ADF07D201800E98FE99FF6A2687D007D206A6A18400AA9385D47181A9AA8AAE382F9702480FD207D006A18106840306B90FD001812881A28217804502A906428027D012C678B666664F6AA7041083DEECBEF29385D71811A92E001F1811802600271812F82C207F97840607080093DFC142201B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064907C80383A6465816503E5FFE4E83BC00C646582AC678B28027D0109E5B589666664B8FD80400FE3603FA00FA40F82854120870542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D05008C705F2E04A12A1035024C85004FA0258CF16CCCCC9ED5401FA403020D70B01C3008E1F8210D53276DB708010C8CB055003CF1622FA0212CB6ACB1FCB3FC98042FB00915BE200303515C705F2E049FA403059C85004FA0258CF16CCCCC9ED54002E5143C705F2E049D43001C85004FA0258CF16CCCCC9ED54007DADBCF6A2687D007D206A6A183618FC1400B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064FC80383A6465816503E5FFE4E840001FAF16F6A2687D007D206A6A183FAA904051007F09"),super(t,e)}createDataCell(){const t=new n;return t.bits.writeCoins(0),t.bits.writeAddress(this.options.adminAddress),t.refs[0]=s(this.options.jettonContentUri),t.refs[1]=n.oneFromBoc(this.options.jettonWalletCodeHex),t}createMintBody(t){const e=new n;e.bits.writeUint(21,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.destination),e.bits.writeCoins(t.amount);const r=new n;return r.bits.writeUint(395134233,32),r.bits.writeUint(t.queryId||0,64),r.bits.writeCoins(t.jettonAmount),r.bits.writeAddress(null),r.bits.writeAddress(null),r.bits.writeCoins(new u(0)),r.bits.writeBit(!1),e.refs[0]=r,e}createChangeAdminBody(t){if(void 0===t.newAdminAddress)throw new Error("Specify newAdminAddress");const e=new n;return e.bits.writeUint(3,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.newAdminAddress),e}createEditContentBody(t){const e=new n;return e.bits.writeUint(4,32),e.bits.writeUint(t.queryId||0,64),e.refs[0]=s(t.jettonContentUri),e}async getJettonData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_jetton_data"),r=e[0],i=-1===e[1].toNumber(),n=a(e[2]),s=e[3];let h=null;try{h=o(s)}catch(t){}return{totalSupply:r,isMutable:i,adminAddress:n,jettonContentCell:s,jettonContentUri:h,jettonWalletCode:e[4]}}async getJettonWalletAddress(t){const e=await this.getAddress(),r=new n;r.bits.writeAddress(t);const i=await this.provider.call2(e.toString(),"get_wallet_address",[["tvm.Slice",l(await r.toBoc(!1))]]);return a(i)}}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{parseAddress:s}=r(41),{BN:o}=r(1),a="B5EE9C7241021201000328000114FF00F4A413F4BCF2C80B0102016202030202CC0405001BA0F605DA89A1F401F481F481A8610201D40607020148080900BB0831C02497C138007434C0C05C6C2544D7C0FC02F83E903E900C7E800C5C75C87E800C7E800C00B4C7E08403E29FA954882EA54C4D167C0238208405E3514654882EA58C511100FC02780D60841657C1EF2EA4D67C02B817C12103FCBC2000113E910C1C2EBCB853600201200A0B020120101101F500F4CFFE803E90087C007B51343E803E903E90350C144DA8548AB1C17CB8B04A30BFFCB8B0950D109C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C032483E401C1D3232C0B281F2FFF274013E903D010C7E801DE0063232C1540233C59C3E8085F2DAC4F3208405E351467232C7C6600C03F73B51343E803E903E90350C0234CFFE80145468017E903E9014D6F1C1551CDB5C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C0327E401C1D3232C0B281F2FFF274140371C1472C7CB8B0C2BE80146A2860822625A020822625A004AD822860822625A028062849F8C3C975C2C070C008E00D0E0F009ACB3F5007FA0222CF165006CF1625FA025003CF16C95005CC2391729171E25008A813A08208989680AA008208989680A0A014BCF2E2C504C98040FB001023C85004FA0258CF1601CF16CCC9ED5400705279A018A182107362D09CC8CB1F5230CB3F58FA025007CF165007CF16C9718018C8CB0524CF165006FA0215CB6A14CCC971FB0010241023000E10491038375F040076C200B08E218210D53276DB708010C8CB055008CF165004FA0216CB6A12CB1F12CB3FC972FB0093356C21E203C85004FA0258CF1601CF16CCC9ED5400DB3B51343E803E903E90350C01F4CFFE803E900C145468549271C17CB8B049F0BFFCB8B0A0822625A02A8005A805AF3CB8B0E0841EF765F7B232C7C572CFD400FE8088B3C58073C5B25C60063232C14933C59C3E80B2DAB33260103EC01004F214013E809633C58073C5B3327B55200083200835C87B51343E803E903E90350C0134C7E08405E3514654882EA0841EF765F784EE84AC7CB8B174CFCC7E800C04E81408F214013E809633C58073C5B3327B55205ECCF23D";class h extends i{constructor(t,e){e.wc=0,e.code=e.code||n.oneFromBoc(a),super(t,e)}async createTransferBody(t){const e=new n;return e.bits.writeUint(260734629,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeCoins(t.jettonAmount),e.bits.writeAddress(t.toAddress),e.bits.writeAddress(t.responseAddress),e.bits.writeBit(!1),e.bits.writeCoins(t.forwardAmount||new o(0)),t.forwardPayload?t.forwardPayload.refs?(e.bits.writeBit(!0),e.refs.push(t.forwardPayload)):(e.bits.writeBit(!1),e.bits.writeBytes(t.forwardPayload)):e.bits.writeBit(!1),e}async createBurnBody(t){const e=new n;return e.bits.writeUint(1499400124,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeCoins(t.jettonAmount),e.bits.writeAddress(t.responseAddress),e}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_wallet_data");return{balance:e[0],ownerAddress:s(e[1]),jettonMinterAddress:s(e[2]),jettonWalletCode:e[3]}}}h.codeHex=a,t.exports={JettonWallet:h}},(t,e,r)=>{const{BlockSubscription:i}=r(54),{InMemoryBlockStorage:n}=r(55);t.exports={BlockSubscription:i,InMemoryBlockStorage:n}},t=>{const e=t=>({workchain:t.workchain,shardId:t.shard,shardBlockNumber:t.seqno});t.exports={BlockSubscription:class{constructor(t,e,r,i){this.provider=t,this.storage=e,this.onBlock=r,this.startMcBlockNumber=i?i.startMcBlockNumber:void 0,this.mcInterval=(i?i.mcInterval:void 0)||1e4,this.shardsInterval=(i?i.shardsInterval:void 0)||1e3}async start(){if(this.stop(),!this.startMcBlockNumber&&(this.startMcBlockNumber=(await this.provider.getMasterchainInfo()).last.seqno,!this.startMcBlockNumber))throw new Error("Cannot get start mc block number from provider");const t=await this.provider.getMasterchainBlockHeader(this.startMcBlockNumber);if(this.startLT=t.end_lt,!this.startLT)throw new Error("Cannot get startLT from provider");let r=!1;const i=async()=>{if(!r){r=!0;try{const t=await this.storage.getLastMasterchainBlockNumber()||this.startMcBlockNumber;if(!t)throw new Error("no init masterchain block in storage");const r=(await this.provider.getMasterchainInfo()).last.seqno;if(!r)throw new Error("invalid last masterchain block from provider");for(let i=t+1;ii()),this.mcInterval),i();let n=!1;const s=async()=>{if(!n){n=!0;try{const t=await this.storage.getUnprocessedShardBlock();if(t){const{workchain:r,shardId:i,shardBlockNumber:n}=t,s=await this.provider.getBlockHeader(r,i,n);if(s.end_lts()),this.shardsInterval)}stop(){clearInterval(this.mcIntervalId),clearInterval(this.shardsIntervalId)}}}},t=>{t.exports={InMemoryBlockStorage:class{constructor(t){this.masterchainBlocks={},this.shardchainBlocks={},this.logFunction=t}async insertShardBlocks(t){for(const{workchain:e,shardId:r,shardBlockNumber:i}of t)void 0===this.shardchainBlocks[e+"_"+r+"_"+i]&&(this.logFunction&&this.logFunction("insert shard "+e+" "+r+" "+i),this.shardchainBlocks[e+"_"+r+"_"+i]=!1)}async insertBlocks(t,e){if(this.logFunction&&this.logFunction("mc processed "+t),void 0!==this.masterchainBlocks[t])throw new Error("mc already exists "+t);this.masterchainBlocks[t]=!0,await this.insertShardBlocks(e)}async getLastMasterchainBlockNumber(){return Object.keys(this.masterchainBlocks).map((t=>Number(t))).sort(((t,e)=>e-t))[0]}async setBlockProcessed(t,e,r,i){if(this.logFunction&&this.logFunction("shard processed "+t+" "+e+" "+r),void 0===this.shardchainBlocks[t+"_"+e+"_"+r])throw new Error("shard not exists "+t+"_"+e+"_"+r);this.shardchainBlocks[t+"_"+e+"_"+r]=!0,await this.insertShardBlocks(i)}async getUnprocessedShardBlock(){for(let t in this.shardchainBlocks)if(!1===this.shardchainBlocks[t]){const e=t.split("_");return{workchain:Number(e[0]),shardId:e[1],shardBlockNumber:Number(e[2])}}}}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{hexToBytes:s,BN:o,nacl:a,bytesToBase64:h}=r(1);t.exports={SubscriptionContract:class extends i{constructor(t,e){e.code=n.oneFromBoc("B5EE9C7241020F01000262000114FF00F4A413F4BCF2C80B0102012002030201480405036AF230DB3C5335A127A904F82327A128A90401BC5135A0F823B913B0F29EF800725210BE945387F0078E855386DB3CA4E2F82302DB3C0B0C0D0202CD06070121A0D0C9B67813F488DE0411F488DE0410130B048FD6D9E05E8698198FD201829846382C74E2F841999E98F9841083239BA395D497803F018B841083AB735BBED9E702984E382D9C74688462F863841083AB735BBED9E70156BA4E09040B0A0A080269F10FD22184093886D9E7C12C1083239BA39384008646582A803678B2801FD010A65B5658F89659FE4B9FD803FC1083239BA396D9E40E0A04F08E8D108C5F0C708210756E6B77DB3CE00AD31F308210706C7567831EB15210BA8F48305324A126A904F82326A127A904BEF27109FA4430A619F833D078D721D70B3F5260A11BBE8E923036F82370708210737562732759DB3C5077DE106910581047103645135042DB3CE0395F076C2232821064737472BA0A0A0D09011A8E897F821064737472DB3CE0300A006821B39982100400000072FB02DE70F8276F118010C8CB055005CF1621FA0214F40013CB6912CB1F830602948100A032DEC901FB000030ED44D0FA40FA40FA00D31FD31FD31FD31FD31FD307D31F30018021FA443020813A98DB3C01A619F833D078D721D70B3FA070F8258210706C7567228018C8CB055007CF165004FA0215CB6A12CB1F13CB3F01FA02CB00C973FB000E0040C8500ACF165008CF165006FA0214CB1F12CB1FCB1FCB1FCB1FCB07CB1FC9ED54005801A615F833D020D70B078100D1BA95810088D721DED307218100DDBA028100DEBA12B1F2E047D33F30A8AB0FE5855AB4"),super(t,e),this.methods.pay=()=>i.createMethod(t,this.createPayExternalMessage()),this.methods.getSubscriptionData=this.getSubscriptionData.bind(this)}createDataCell(){const t=new n;return t.bits.writeAddress(this.options.wallet),t.bits.writeAddress(this.options.beneficiary),t.bits.writeGrams(this.options.amount),t.bits.writeUint(this.options.period,32),t.bits.writeUint(this.options.startAt,32),t.bits.writeUint(this.options.timeout,32),t.bits.writeUint(0,32),t.bits.writeUint(0,32),t.bits.writeUint(0,8),t.bits.writeUint(this.options.subscriptionId,32),t}createBody(){const t=new n;return t.bits.writeUint(new o(1886156135).add(new o(2147483648)),32),t}createSelfDestructBody(){const t=new n;return t.bits.writeUint(1685288050,32),t}async getSubscriptionData(){const t=t=>t[0].toNumber()+":"+t[1].toString(16),e=await this.getAddress(),r=await this.provider.call2(e.toString(),"get_subscription_data");return{wallet:t(r[0]),beneficiary:t(r[1]),amount:r[2],period:r[3].toNumber(),startAt:r[4].toNumber(),timeout:r[5].toNumber(),lastPayment:r[6].toNumber(),lastRequest:r[7].toNumber(),failedAttempts:r[8].toNumber(),subscriptionId:r[9].toNumber()}}async createPayExternalMessage(){const t=await this.getAddress(),e=i.createExternalMessageHeader(t),r=i.createCommonMsgInfo(e,null,null),s=new n;return s.bits.writeUint(Math.floor(Date.now()/1e3),64),{address:t,message:r,body:s}}}}},(t,e,r)=>{const{PaymentChannel:i}=r(58);t.exports={Payments:class{constructor(t){this.provider=t}createChannel(t){return new i(this.provider,t)}},PaymentChannel:i}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{nacl:s,hexToBytes:o,BN:a}=r(1),{parseAddress:h}=r(41),{writePublicKey:u,writeSignature:l,createSignatureCell:c,tag_init:f,tag_cooperative_close:d,tag_cooperative_commit:p,tag_start_uncooperative_close:m,tag_challenge_state:g,tag_settle_conditionals:y,tag_state:w,op_top_up_balance:v,op_init_channel:b,op_cooperative_close:E,op_cooperative_commit:A,op_start_uncooperative_close:C,op_challenge_quarantined_state:M,op_settle_conditionals:B,op_finish_uncooperative_close:F,op_channel_closed:S,createTopUpBalance:_,createInitChannelBody:D,createCooperativeCloseChannelBody:I,createCooperativeCommitBody:x,createConditionalPayment:T,createSemiChannelBody:N,createSemiChannelState:U,createSignedSemiChannelState:R,createStartUncooperativeCloseBody:O,createChallengeQuarantinedStateBody:k,createSettleConditionalsBody:L,createFinishUncooperativeClose:P,createOneSignature:j,createTwoSignature:$}=r(59),q="B5EE9C72410230010007FB000114FF00F4A413F4BCF2C80B0102012002030201480405000AF26C21F0190202CB06070201202E2F020120080902012016170201200A0B0201200C0D0009D3610F80CC001D6B5007434C7FE8034C7CC1BC0FE19E0201580E0F0201201011002D3E11DBC4BE11DBC43232C7FE11DBC47E80B2C7F2407320008B083E1B7B51343480007E187E80007E18BE80007E18F4FFC07E1934FFC07E1974DFC07E19BC01887080A7F4C7C07E1A34C7C07E1A7D01007E1AB7807080E535007E1AF7BE1B2002012012130201201415008D3E13723E11BE117E113E10540132803E10BE80BE10FE8084F2FFC4B2FFF2DFFC02887080A7FE12BE127E121400F2C7C4B2C7FD0037807080E53E12C073253E1333C5B8B27B5520004D1C3C02FE106CFCB8193E803E800C3E1096283E18BE10C0683E18FE10BE10E8006EFCB819BC032000CF1D3C02FE106CFCB819348020C235C6083E4040E4BE1124BE117890CC3E443CB81974C7C060841A5B9A5D2EBCB81A3E118074DFD66EBCB81CBE803E800C3E1094882FBE10D4882FAC3CB819807E18BE18FE12F43E800C3E10BE10E80068006E7CB8199FFE187C0320004120843777222E9C20043232C15401B3C594013E808532DA84B2C7F2DFF2407EC02002012018190201D42B2C0201201A1B0201201E1F0201201C1D00E5473F00BD401D001D401D021F90102D31F01821043436D74BAF2E068F84601D37F59BAF2E072F844544355F910F8454330F910B0F2E065D33FD33F30F84822B9F84922B9B0F2E06C21F86820F869F84A6E915B8E19F84AD0D33FFA003171D721D33F305033BC02BCB1936DF86ADEE2F800F00C8006F3E12F43E800C7E903E900C3E09DBC41CBE10D62F24CC20C1B7BE10FE11963C03FE10BE11A04020BC03DC3E185C3E189C3E18DB7E1ABC032000B51D3C02F5007400750074087E4040B4C7C0608410DB1BDCEEBCB81A3E118074DFD66EBCB81CBE111510D57E443E1150CC3E442C3CB8197E80007E18BE80007E18F4CFF4CFCC3E1208AE7E1248AE6C3CB81B007E1A3E1A7E003C042001C1573F00BF84A6EF2E06AD2008308D71820F9012392F84492F845E24130F910F2E065D31F018210556E436CBAF2E068F84601D37F59BAF2E072D401D08308D71820F901F8444130F910F2E06501D430D08308D71820F901F8454130F910F2E06501820020120222301FED31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE2303205D31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE23032F8485280BEF8495250BEB0524BBE1AB0527ABE19210064B05215BE14B05248BE17B0F2E06970F82305C8CB3F5004FA0215F40015CB3F5004FA0212F400CB1F12CA00CA00C9F86AF00C01C31CFC02FE129BACFCB81AF48020C235C6083E4048E4BE1124BE1178904C3E443CB81974C7C0608410DA19D46EBCB81A3E118074DFD66EBCB81CB5007420C235C6083E407E11104C3E443CB81940750C3420C235C6083E407E11504C3E443CB81940602403F71CFC02FE129BACFCB81AF48020C235C6083E4048E4BE1124BE1178904C3E443CB81974C7C0608410DB10DBAEBCB81A3E118074DFD66EBCB81CBD010C3E12B434CFFE803D0134CFFE803D0134C7FE11DBC4148828083E08EE7CB81BBE11DBC4A83E08EF3CB81C34800C151D5A64D6D4C8F7A2B98E82A49B08B8C3816028292A01FCD31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE2303205D31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE230325339BE5381BEB0F8495250BEB0F8485290BEB02502FE5237BE16B05262BEB0F2E06927C20097F84918BEF2E0699137E222C20097F84813BEF2E0699132E2F84AD0D33FFA00F404D33FFA00F404D31FF8476F105220A0F823BCF2E06FD200D20030B3F2E073209C3537373A5274BC5263BC12B18E11323939395250BC5299BC18B14650134440E25319BAB3F2E06D9130E30D7F05C82627002496F8476F1114A098F8476F1117A00603E203003ECB3F5004FA0215F40012CB3F5004FA0213F400CB1F12CA00CA00C9F86AF00C00620A8020F4966FA5208E213050038020F4666FA1208E1001FA00ED1E15DA119450C3A00B9133E2923430E202926C21E2B31B000C3535075063140038C8CB3F5004FA0212F400CB3F5003FA0213F400CB1FCA00C9F86AF00C00D51D3C02FE129BACFCB81AFE12B434CFFE803D010C74CFFE803D010C74C7CC3E11DBC4283E11DBC4A83E08EE7CB81C7E003E10886808E87E18BE10D400E816287E18FE10F04026BE10BE10E83E189C3E18F7BE10B04026BE10FE10A83E18DC3E18F780693E1A293E1A7C042001F53B7EF4C7C8608419F1F4A06EA4CC7C037808608403818830AEA54C7C03B6CC780C882084155DD61FAEA54C3C0476CC780820841E6849BBEEA54C3C04B6CC7808208407C546B3EEA54C3C0576CC780820840223AA8CAEA54C3C05B6CC7808208419BDBC1A6EA54C3C05F6CC780C60840950CAA46EA53C0636CC78202D0008840FF2F00075BC7FE3A7805FC25E87D007D207D20184100D0CAF6A1EC7C217C21B7817C227C22B7817C237C23FC247C24B7817C2524C3B7818823881B22A021984008DBD0CABA7805FC20C8B870FC253748B8F07C256840206B90FD0018C020EB90FD0018B8EB90E98F987C23B7882908507C11DE491839707C23B788507C23B789507C11DE48B9F03A4331C4966";class K extends i{constructor(t,e){e.publicKeyA=e.isA?e.myKeyPair.publicKey:e.hisPublicKey,e.publicKeyB=e.isA?e.hisPublicKey:e.myKeyPair.publicKey,e.wc=e.wc||0,e.code=e.code||n.oneFromBoc(q),super(t,e)}createDataCell(){const t=new n;t.bits.writeBit(0),t.bits.writeCoins(0),t.bits.writeCoins(0),u(t,this.options.publicKeyA),u(t,this.options.publicKeyB),t.bits.writeUint(this.options.channelId,128);const e=new n;e.bits.writeUint(this.options.closingConfig?.quarantineDuration||0,32),e.bits.writeCoins(this.options.closingConfig?.misbehaviorFine||new a(0)),e.bits.writeUint(this.options.closingConfig?.conditionalCloseDuration||0,32),t.refs[0]=e,t.bits.writeUint(0,32),t.bits.writeUint(0,32),t.bits.writeBit(!1);const r=new n;return r.bits.writeCoins(this.options.excessFee||new a(0)),r.bits.writeAddress(this.options.addressA),r.bits.writeAddress(this.options.addressB),t.refs[1]=r,t}async createOneSignature(t,e){const r=s.sign.detached(await e.hash(),this.options.myKeyPair.secretKey);return{cell:j({op:t,isA:this.options.isA,signature:r,cell:e}),signature:r}}async createTwoSignature(t,e,r){const i=s.sign.detached(await r.hash(),this.options.myKeyPair.secretKey),n=this.options.isA?i:e,o=this.options.isA?e:i;return{cell:$({op:t,signatureA:n,signatureB:o,cell:r}),signature:i}}async createTopUpBalance(t){return _(t)}async createInitChannel(t){return this.createOneSignature(b,D({...t,channelId:this.options.channelId}))}async createCooperativeCloseChannel(t){return t.hisSignature||(t.hisSignature=new Uint8Array(64)),this.createTwoSignature(E,t.hisSignature,I({...t,channelId:this.options.channelId}))}async createCooperativeCommit(t){return t.hisSignature||(t.hisSignature=new Uint8Array(64)),this.createTwoSignature(A,t.hisSignature,x({...t,channelId:this.options.channelId}))}async createSignedSemiChannelState(t){const e=U({channelId:this.options.channelId,semiChannelBody:N({seqno:t.mySeqno,sentCoins:t.mySentCoins,conditionals:null}),counterpartySemiChannelBody:void 0===t.hisSeqno?null:N({seqno:t.hisSeqno,sentCoins:t.hisSentCoins,conditionals:null})}),r=s.sign.detached(await e.hash(),this.options.myKeyPair.secretKey);return{cell:R({signature:r,state:e}),signature:r}}async signState(t){const e=this.options.isA?t.seqnoA:t.seqnoB,r=this.options.isA?t.seqnoB:t.seqnoA,i=this.options.initBalanceA.gt(t.balanceA)?this.options.initBalanceA.sub(t.balanceA):new a(0),n=this.options.initBalanceB.gt(t.balanceB)?this.options.initBalanceB.sub(t.balanceB):new a(0),s=this.options.isA?i:n,o=this.options.isA?n:i,{cell:h,signature:u}=await this.createSignedSemiChannelState({mySeqno:e,mySentCoins:s,hisSeqno:r,hisSentCoins:o});return u}async verifyState(t,e){const r=this.options.isA?t.seqnoB:t.seqnoA,i=this.options.isA?t.seqnoA:t.seqnoB,n=this.options.initBalanceA.gt(t.balanceA)?this.options.initBalanceA.sub(t.balanceA):new a(0),o=this.options.initBalanceB.gt(t.balanceB)?this.options.initBalanceB.sub(t.balanceB):new a(0),h=this.options.isA?o:n,u=this.options.isA?n:o,l=U({channelId:this.options.channelId,semiChannelBody:N({seqno:r,sentCoins:h,conditionals:null}),counterpartySemiChannelBody:void 0===i?null:N({seqno:i,sentCoins:u,conditionals:null})}),c=await l.hash();return s.sign.detached.verify(c,e,this.options.isA?this.options.publicKeyB:this.options.publicKeyA)}async signClose(t){const{cell:e,signature:r}=await this.createCooperativeCloseChannel(t);return r}async verifyClose(t,e){const r=await I({...t,channelId:this.options.channelId}),i=await r.hash();return s.sign.detached.verify(i,e,this.options.isA?this.options.publicKeyB:this.options.publicKeyA)}async createStartUncooperativeClose(t){return this.createOneSignature(C,O({...t,channelId:this.options.channelId}))}async createChallengeQuarantinedState(t){return this.createOneSignature(M,k({...t,channelId:this.options.channelId}))}async createSettleConditionals(t){return this.createOneSignature(B,L({...t,channelId:this.options.channelId}))}async createFinishUncooperativeClose(){return P()}static STATE_UNINITED=0;static STATE_OPEN=1;static STATE_CLOSURE_STARTED=2;static STATE_SETTLING_CONDITIONALS=3;static STATE_AWAITING_FINALIZATION=4;async getChannelState(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_channel_state",[])).toNumber()}async getData(){const t=t=>{let e=t.toString(16);return e.length%2!=0&&(e="0"+e),o(e)},e=await this.getAddress(),r=await this.provider.call2(e.toString(),"get_channel_data",[]);return{state:r[0].toNumber(),balanceA:r[1][0],balanceB:r[1][1],publicKeyA:t(r[2][0]),publicKeyB:t(r[2][1]),channelId:r[3],quarantineDuration:r[4][0].toNumber(),misbehaviorFine:r[4][1],conditionalCloseDuration:r[4][2].toNumber(),seqnoA:r[5][0],seqnoB:r[5][1],quarantine:r[6],excessFee:r[7][0],addressA:h(r[7][1]),addressB:h(r[7][2])}}fromWallet(t){const{wallet:e,secretKey:r}=t,i=(t,i)=>{const n=async n=>{const s=i?(await this.createStateInit()).stateInit:null,o=await this.getAddress(),a=await e.methods.seqno().call()||0,h=await t;return e.methods.transfer({secretKey:r,toAddress:o.toString(!0,!0,!0),amount:n,seqno:a,payload:h,stateInit:s,sendMode:3})};return{send:t=>n(t).then((t=>t.send())),estimateFee:t=>n(t).then((t=>t.estimateFee()))}};return{deploy:()=>i(null,!0),init:t=>i(this.createInitChannel(t).then((t=>t.cell))),topUp:t=>i(this.createTopUpBalance(t)),close:t=>i(this.createCooperativeCloseChannel(t).then((t=>t.cell))),commit:t=>i(this.createCooperativeCommit(t).then((t=>t.cell))),startUncooperativeClose:t=>i(this.createStartUncooperativeClose(t).then((t=>t.cell))),challengeQuarantinedState:t=>i(this.createChallengeQuarantinedState(t).then((t=>t.cell))),settleConditionals:t=>i(this.createSettleConditionals(t).then((t=>t.cell))),finishUncooperativeClose:()=>i(this.createFinishUncooperativeClose())}}}K.codeHex=q,t.exports={PaymentChannel:K}},(t,e,r)=>{const{Cell:i}=r(21),n=(t,e)=>{if(64!==e.length)throw new Error("invalid signature length");t.bits.writeBytes(e)},s=t=>{const e=new i;return n(e,t),e},o=(t,e)=>{if(e){if(t.bits.writeBit(1),t.refs.length>=4)throw new Error("refs overflow");t.refs.push(e)}else t.bits.writeBit(0)},a=o,h=1768843636,u=1131179891,l=1128492404,c=1433289580,f=1130915665,d=1131168622,p=1130910580,m=1741148801,g=625158801;t.exports={writePublicKey:(t,e)=>{if(32!==e.length)throw new Error("invalid publicKey length");t.bits.writeBytes(e)},writeSignature:n,createSignatureCell:s,tag_init:h,tag_cooperative_close:u,tag_cooperative_commit:l,tag_start_uncooperative_close:c,tag_challenge_state:f,tag_settle_conditionals:d,tag_state:p,op_top_up_balance:m,op_init_channel:235282626,op_cooperative_close:1433884798,op_cooperative_commit:2040604399,op_start_uncooperative_close:521476815,op_challenge_quarantined_state:143567410,op_settle_conditionals:1727459433,op_finish_uncooperative_close:g,op_channel_closed:-572749638,createTopUpBalance:t=>{const e=new i;return e.bits.writeUint(m,32),e.bits.writeCoins(t.coinsA),e.bits.writeCoins(t.coinsB),e},createInitChannelBody:t=>{const e=new i;return e.bits.writeUint(h,32),e.bits.writeUint(t.channelId,128),e.bits.writeCoins(t.balanceA),e.bits.writeCoins(t.balanceB),e},createCooperativeCloseChannelBody:t=>{const e=new i;return e.bits.writeUint(u,32),e.bits.writeUint(t.channelId,128),e.bits.writeCoins(t.balanceA),e.bits.writeCoins(t.balanceB),e.bits.writeUint(t.seqnoA,64),e.bits.writeUint(t.seqnoB,64),e},createCooperativeCommitBody:t=>{const e=new i;return e.bits.writeUint(l,32),e.bits.writeUint(t.channelId,128),e.bits.writeUint(t.seqnoA,64),e.bits.writeUint(t.seqnoB,64),e},createConditionalPayment:t=>{const e=new i;return e.bits.writeCoins(t.amount),e.writeCell(t.condition),e},createSemiChannelBody:t=>{const e=new i;return e.bits.writeUint(t.seqno,64),e.bits.writeCoins(t.sentCoins),a(e,t.conditionals),e},createSemiChannelState:t=>{const e=new i;return e.bits.writeUint(p,32),e.bits.writeUint(t.channelId,128),e.writeCell(t.semiChannelBody),o(e,t.counterpartySemiChannelBody),e},createSignedSemiChannelState:t=>{const e=new i;return n(e,t.signature),e.writeCell(t.state),e},createStartUncooperativeCloseBody:t=>{const e=new i;return e.bits.writeUint(c,32),e.bits.writeUint(t.channelId,128),e.refs[0]=t.signedSemiChannelStateA,e.refs[1]=t.signedSemiChannelStateB,e},createChallengeQuarantinedStateBody:t=>{const e=new i;return e.bits.writeUint(f,32),e.bits.writeUint(t.channelId,128),e.refs[0]=t.signedSemiChannelStateA,e.refs[1]=t.signedSemiChannelStateB,e},createSettleConditionalsBody:t=>{const e=new i;return e.bits.writeUint(d,32),e.bits.writeUint(t.channelId,128),a(e,t.conditionalsToSettle),e},createFinishUncooperativeClose:()=>{const t=new i;return t.bits.writeUint(g,32),t},createOneSignature:t=>{const e=new i;return e.bits.writeUint(t.op,32),e.bits.writeBit(t.isA),n(e,t.signature),e.writeCell(t.cell),e},createTwoSignature:t=>{const e=new i;return e.bits.writeUint(t.op,32),e.refs[0]=s(t.signatureA),e.refs[1]=s(t.signatureB),e.writeCell(t.cell),e}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>l});var i=r(61),n=r(64),s=r(65),o=r(113),a=r(63),h=r(114),u=r(9).Buffer;class l extends i.default{constructor(t,e){super(),this.device=void 0,this.deviceModel=void 0,this.channel=Math.floor(65535*Math.random()),this.packetSize=64,this.interfaceNumber=void 0,this._disconnectEmitted=!1,this._emitDisconnect=t=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",t))},this.exchange=t=>this.exchangeAtomicImpl((async()=>{const{channel:e,packetSize:r}=this;(0,o.log)("apdu","=> "+t.toString("hex"));const i=(0,n.default)(e,r),s=i.makeBlocks(t);for(let t=0;t{if(t&&t.message&&t.message.includes("disconnected"))throw this._emitDisconnect(t),new a.DisconnectedDeviceDuringOperation(t.message);throw t})),this.device=t,this.interfaceNumber=e,this.deviceModel=(0,s.identifyUSBProductId)(t.productId)}static async request(){const t=await(0,h.requestLedgerDevice)();return l.open(t)}static async openConnected(){const t=await(0,h.getLedgerDevices)();return 0===t.length?null:l.open(t[0])}static async open(t){await t.open(),null===t.configuration&&await t.selectConfiguration(1),await c(t);const e=t.configurations[0].interfaces.find((({alternates:t})=>t.some((t=>255===t.interfaceClass))));if(!e)throw new a.TransportInterfaceNotAvailable("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.");const r=e.interfaceNumber;try{await t.claimInterface(r)}catch(e){throw await t.close(),new a.TransportInterfaceNotAvailable(e.message)}const i=new l(t,r),n=e=>{t===e.device&&(navigator.usb.removeEventListener("disconnect",n),i._emitDisconnect(new a.DisconnectedDevice))};return navigator.usb.addEventListener("disconnect",n),i}async close(){await this.exchangeBusyPromise,await this.device.releaseInterface(this.interfaceNumber),await c(this.device),await this.device.close()}setScrambleKey(){}}async function c(t){try{await t.reset()}catch(t){console.warn(t)}}l.isSupported=h.isSupported,l.list=h.getLedgerDevices,l.listen=t=>{let e=!1;return(0,h.getFirstLedgerDevice)().then((r=>{if(!e){const e=(0,s.identifyUSBProductId)(r.productId);t.next({type:"add",descriptor:r,deviceModel:e}),t.complete()}}),(e=>{window.DOMException&&e instanceof window.DOMException&&18===e.code?t.error(new a.TransportWebUSBGestureRequired(e.message)):t.error(new a.TransportOpenUserCancelled(e.message))})),{unsubscribe:function(){e=!0}}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{StatusCodes:()=>s.StatusCodes,TransportError:()=>s.TransportError,TransportStatusError:()=>s.TransportStatusError,default:()=>a,getAltStatusMessage:()=>s.getAltStatusMessage});var i=r(62),n=r.n(i),s=r(63),o=r(9).Buffer;class a{constructor(){this.exchangeTimeout=3e4,this.unresponsiveTimeout=15e3,this.deviceModel=null,this._events=new(n()),this.send=async(t,e,r,i,n=o.alloc(0),a=[s.StatusCodes.OK])=>{if(n.length>=256)throw new s.TransportError("data.length exceed 256 bytes limit. Got: "+n.length,"DataLengthTooBig");const h=await this.exchange(o.concat([o.from([t,e,r,i]),o.from([n.length]),n])),u=h.readUInt16BE(h.length-2);if(!a.some((t=>t===u)))throw new s.TransportStatusError(u);return h},this.exchangeBusyPromise=void 0,this.exchangeAtomicImpl=async t=>{if(this.exchangeBusyPromise)throw new s.TransportRaceCondition("An action was already pending on the Ledger device. Please deny or reconnect.");let e;const r=new Promise((t=>{e=t}));this.exchangeBusyPromise=r;let i=!1;const n=setTimeout((()=>{i=!0,this.emit("unresponsive")}),this.unresponsiveTimeout);try{const r=await t();return i&&this.emit("responsive"),r}finally{clearTimeout(n),e&&e(),this.exchangeBusyPromise=null}},this._appAPIlock=null}exchange(t){throw new Error("exchange not implemented")}setScrambleKey(t){}close(){return Promise.resolve()}on(t,e){this._events.on(t,e)}off(t,e){this._events.removeListener(t,e)}emit(t,...e){this._events.emit(t,...e)}setDebugMode(){console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.")}setExchangeTimeout(t){this.exchangeTimeout=t}setExchangeUnresponsiveTimeout(t){this.unresponsiveTimeout=t}static create(t=3e3,e){return new Promise(((r,i)=>{let n=!1;const o=this.listen({next:e=>{n=!0,o&&o.unsubscribe(),a&&clearTimeout(a),this.open(e.descriptor,t).then(r,i)},error:t=>{a&&clearTimeout(a),i(t)},complete:()=>{a&&clearTimeout(a),n||i(new s.TransportError(this.ErrorMessage_NoDeviceFound,"NoDeviceFound"))}}),a=e?setTimeout((()=>{o.unsubscribe(),i(new s.TransportError(this.ErrorMessage_ListenTimeout,"ListenTimeout"))}),e):null}))}decorateAppAPIMethods(t,e,r){for(let i of e)t[i]=this.decorateAppAPIMethod(i,t[i],t,r)}decorateAppAPIMethod(t,e,r,i){return async(...n)=>{const{_appAPIlock:o}=this;if(o)return Promise.reject(new s.TransportError("Ledger Device is busy (lock "+o+")","TransportLocked"));try{return this._appAPIlock=t,this.setScrambleKey(i),await e.apply(r,n)}finally{this._appAPIlock=null}}}}a.isSupported=void 0,a.list=void 0,a.listen=void 0,a.open=void 0,a.ErrorMessage_ListenTimeout="No Ledger device found (timeout)",a.ErrorMessage_NoDeviceFound="No Ledger device found"},t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,s),i(r)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",n),r([].slice.call(arguments))}m(t,e,s,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&m(t,"error",e,{once:!0})}(t,n)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(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?s.defaultMaxListeners:t._maxListeners}function u(t,e,r,i){var n,s,o,u;if(a(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]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=h(t))>0&&o.length>n&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=o.length,u=l,console&&console.warn&&console.warn(u)}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 c(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=l.bind(i);return n.listener=r,i.wrapFn=n,n}function f(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]: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 h=s[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var u=h.length,l=p(h,u);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AccountNameRequiredError:()=>l,AccountNotSupported:()=>c,AmountRequired:()=>f,BluetoothRequired:()=>d,BtcUnmatchedApp:()=>p,CantOpenDevice:()=>m,CantScanQRCode:()=>kt,CashAddrNotSupported:()=>g,CurrencyNotSupported:()=>y,DBNotReset:()=>Zt,DBWrongPassword:()=>zt,DeviceAppVerifyNotSupported:()=>w,DeviceGenuineSocketEarlyClose:()=>v,DeviceHalted:()=>M,DeviceInOSUExpected:()=>C,DeviceNameInvalid:()=>B,DeviceNotGenuineError:()=>b,DeviceOnDashboardExpected:()=>E,DeviceOnDashboardUnexpected:()=>A,DeviceShouldStayInApp:()=>xt,DeviceSocketFail:()=>F,DeviceSocketNoBulkStatus:()=>S,DisconnectedDevice:()=>_,DisconnectedDeviceDuringOperation:()=>D,ETHAddressNonEIP:()=>Ot,EnpointConfigError:()=>I,EthAppPleaseEnableContractData:()=>x,FeeEstimationFailed:()=>T,FeeNotLoaded:()=>Lt,FeeRequired:()=>Pt,FeeTooHigh:()=>jt,FirmwareNotRecognized:()=>N,FirmwareOrAppUpdateRequired:()=>Vt,GasLessThanEstimate:()=>at,GenuineCheckFailed:()=>Kt,HardResetFail:()=>U,InvalidAddress:()=>O,InvalidAddressBecauseDestinationIsAlsoSource:()=>k,InvalidXRPTag:()=>R,LatestMCUInstalledError:()=>L,LedgerAPI4xx:()=>Ht,LedgerAPI5xx:()=>Gt,LedgerAPIError:()=>j,LedgerAPIErrorWithMessage:()=>$,LedgerAPINotAvailable:()=>q,MCUNotGenuineToDashboard:()=>pt,ManagerAppAlreadyInstalledError:()=>K,ManagerAppDepInstallRequired:()=>G,ManagerAppDepUninstallRequired:()=>V,ManagerAppRelyOnBTCError:()=>H,ManagerDeviceLockedError:()=>W,ManagerFirmwareNotEnoughSpaceError:()=>z,ManagerNotEnoughSpaceError:()=>Z,ManagerUninstallBTCDep:()=>Y,NetworkDown:()=>X,NoAccessToCamera:()=>nt,NoAddressesFound:()=>Q,NoDBPathGiven:()=>Wt,NotEnoughBalance:()=>J,NotEnoughBalanceBecauseDestinationNotCreated:()=>it,NotEnoughBalanceInParentAccount:()=>et,NotEnoughBalanceToDelegate:()=>tt,NotEnoughGas:()=>st,NotEnoughSpendableBalance:()=>rt,NotSupportedLegacyAddress:()=>ot,PairingFailed:()=>qt,PasswordIncorrectError:()=>ut,PasswordsDontMatchError:()=>ht,RecipientRequired:()=>mt,RecommendSubAccountsToEmpty:()=>lt,RecommendUndelegation:()=>ct,StatusCodes:()=>Xt,SyncError:()=>$t,TimeoutTagged:()=>ft,TransportError:()=>Yt,TransportInterfaceNotAvailable:()=>_t,TransportOpenUserCancelled:()=>St,TransportRaceCondition:()=>Dt,TransportStatusError:()=>Jt,TransportWebUSBGestureRequired:()=>It,UnavailableTezosOriginatedAccountReceive:()=>gt,UnavailableTezosOriginatedAccountSend:()=>yt,UnexpectedBootloader:()=>dt,UnknownMCU:()=>P,UpdateFetchFileFail:()=>wt,UpdateIncorrectHash:()=>vt,UpdateIncorrectSig:()=>bt,UpdateYourApp:()=>Et,UserRefusedAddress:()=>Ct,UserRefusedAllowManager:()=>Bt,UserRefusedDeviceNameChange:()=>At,UserRefusedFirmwareUpdate:()=>Mt,UserRefusedOnDevice:()=>Ft,WebsocketConnectionError:()=>Tt,WebsocketConnectionFailed:()=>Nt,WrongAppForCurrency:()=>Rt,WrongDeviceForAccount:()=>Ut,addCustomErrorDeserializer:()=>s,createCustomErrorClass:()=>o,deserializeError:()=>a,getAltStatusMessage:()=>Qt,serializeError:()=>h});var i={},n={},s=function(t,e){n[t]=e},o=function(t){var e=function(e,r){Object.assign(this,r),this.name=t,this.message=e||t,this.stack=(new Error).stack};return e.prototype=new Error,i[t]=e,e},a=function(t){if("object"==typeof t&&t){try{var e=JSON.parse(t.message);e.message&&e.name&&(t=e)}catch(t){}var r=void 0;if("string"==typeof t.name){var s=t.name,h=n[s];if(h)r=h(t);else{var u="Error"===s?Error:i[s];u||(console.warn("deserializing an unknown class '"+s+"'"),u=o(s)),r=Object.create(u.prototype);try{for(var l in t)t.hasOwnProperty(l)&&(r[l]=t[l])}catch(t){}}}else r=new Error(t.message);return!r.stack&&Error.captureStackTrace&&Error.captureStackTrace(r,a),r}return new Error(String(t))},h=function(t){return t?"object"==typeof t?u(t,[]):"function"==typeof t?"[Function: "+(t.name||"anonymous")+"]":t:t};function u(t,e){var r={};e.push(t);for(var i=0,n=Object.keys(t);i{"use strict";var i=r(9).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(63);function s(t){const e=i.alloc(2);return e.writeUInt16BE(t,0),e}const o={data:i.alloc(0),dataLength:0,sequence:0};e.default=(t,e)=>({makeBlocks(r){let n=i.concat([s(r.length),r]);const o=e-5,a=Math.ceil(n.length/o);n=i.concat([n,i.alloc(a*o-n.length+1).fill(0)]);const h=[];for(let e=0;ea&&(s=s.slice(0,a)),{data:s,dataLength:a,sequence:h}},getReducedResult(t){if(t&&t.dataLength===t.data.length)return t.data}})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{IICCID:()=>h,IIGenericHID:()=>s,IIKeyboardHID:()=>o,IIU2F:()=>a,IIWebUSB:()=>u,getBluetoothServiceUuids:()=>v,getDeviceModel:()=>p,getInfosForServiceUuid:()=>b,identifyProductName:()=>g,identifyUSBProductId:()=>m,ledgerUSBVendorId:()=>d});var i=r(66),n=r.n(i);const s=1,o=2,a=4,h=8,u=16,l={blue:{id:"blue",productName:"Ledger Blue",productIdMM:0,legacyUsbProductId:0,usbOnly:!0,memorySize:491520,blockSize:4096,getBlockSize:t=>4096},nanoS:{id:"nanoS",productName:"Ledger Nano S",productIdMM:16,legacyUsbProductId:1,usbOnly:!0,memorySize:327680,blockSize:4096,getBlockSize:t=>n().lt(n().coerce(t),"2.0.0")?4096:2048},nanoX:{id:"nanoX",productName:"Ledger Nano X",productIdMM:64,legacyUsbProductId:4,usbOnly:!1,memorySize:2097152,blockSize:4096,getBlockSize:t=>4096,bluetoothSpec:[{serviceUuid:"d973f2e0-b19e-11e2-9e96-0800200c9a66",notifyUuid:"d973f2e1-b19e-11e2-9e96-0800200c9a66",writeUuid:"d973f2e2-b19e-11e2-9e96-0800200c9a66"},{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572"}]}},c={Blue:"blue","Nano S":"nanoS","Nano X":"nanoX"},f=Object.values(l),d=11415,p=t=>{const e=l[t];if(!e)throw new Error("device '"+t+"' does not exist");return e},m=t=>{const e=f.find((e=>e.legacyUsbProductId===t));if(e)return e;const r=t>>8;return f.find((t=>t.productIdMM===r))},g=t=>{const e=c[t];return f.find((t=>t.id===e))},y=[],w={};for(let t in l){const e=l[t],{bluetoothSpec:r}=e;if(r)for(let t=0;ty,b=t=>w[t.toLowerCase()]},(t,e,r)=>{const i=r(67);t.exports={re:i.re,src:i.src,tokens:i.t,SEMVER_SPEC_VERSION:r(68).SEMVER_SPEC_VERSION,SemVer:r(70),compareIdentifiers:r(72).compareIdentifiers,rcompareIdentifiers:r(72).rcompareIdentifiers,parse:r(73),valid:r(74),clean:r(75),inc:r(76),diff:r(77),major:r(80),minor:r(81),patch:r(82),prerelease:r(83),compare:r(79),rcompare:r(84),compareLoose:r(85),compareBuild:r(86),sort:r(87),rsort:r(88),gt:r(89),lt:r(90),eq:r(78),neq:r(91),gte:r(92),lte:r(93),cmp:r(94),coerce:r(95),Comparator:r(96),Range:r(97),satisfies:r(101),toComparators:r(102),maxSatisfying:r(103),minSatisfying:r(104),minVersion:r(105),validRange:r(106),outside:r(107),gtr:r(108),ltr:r(109),intersects:r(110),simplifyRange:r(111),subset:r(112)}},(t,e,r)=>{const{MAX_SAFE_COMPONENT_LENGTH:i}=r(68),n=r(69),s=(e=t.exports={}).re=[],o=e.src=[],a=e.t={};let h=0;const u=(t,e,r)=>{const i=h++;n(i,e),a[t]=i,o[i]=e,s[i]=new RegExp(e,r?"g":void 0)};u("NUMERICIDENTIFIER","0|[1-9]\\d*"),u("NUMERICIDENTIFIERLOOSE","[0-9]+"),u("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),u("MAINVERSION",`(${o[a.NUMERICIDENTIFIER]})\\.(${o[a.NUMERICIDENTIFIER]})\\.(${o[a.NUMERICIDENTIFIER]})`),u("MAINVERSIONLOOSE",`(${o[a.NUMERICIDENTIFIERLOOSE]})\\.(${o[a.NUMERICIDENTIFIERLOOSE]})\\.(${o[a.NUMERICIDENTIFIERLOOSE]})`),u("PRERELEASEIDENTIFIER",`(?:${o[a.NUMERICIDENTIFIER]}|${o[a.NONNUMERICIDENTIFIER]})`),u("PRERELEASEIDENTIFIERLOOSE",`(?:${o[a.NUMERICIDENTIFIERLOOSE]}|${o[a.NONNUMERICIDENTIFIER]})`),u("PRERELEASE",`(?:-(${o[a.PRERELEASEIDENTIFIER]}(?:\\.${o[a.PRERELEASEIDENTIFIER]})*))`),u("PRERELEASELOOSE",`(?:-?(${o[a.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[a.PRERELEASEIDENTIFIERLOOSE]})*))`),u("BUILDIDENTIFIER","[0-9A-Za-z-]+"),u("BUILD",`(?:\\+(${o[a.BUILDIDENTIFIER]}(?:\\.${o[a.BUILDIDENTIFIER]})*))`),u("FULLPLAIN",`v?${o[a.MAINVERSION]}${o[a.PRERELEASE]}?${o[a.BUILD]}?`),u("FULL",`^${o[a.FULLPLAIN]}$`),u("LOOSEPLAIN",`[v=\\s]*${o[a.MAINVERSIONLOOSE]}${o[a.PRERELEASELOOSE]}?${o[a.BUILD]}?`),u("LOOSE",`^${o[a.LOOSEPLAIN]}$`),u("GTLT","((?:<|>)?=?)"),u("XRANGEIDENTIFIERLOOSE",`${o[a.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),u("XRANGEIDENTIFIER",`${o[a.NUMERICIDENTIFIER]}|x|X|\\*`),u("XRANGEPLAIN",`[v=\\s]*(${o[a.XRANGEIDENTIFIER]})(?:\\.(${o[a.XRANGEIDENTIFIER]})(?:\\.(${o[a.XRANGEIDENTIFIER]})(?:${o[a.PRERELEASE]})?${o[a.BUILD]}?)?)?`),u("XRANGEPLAINLOOSE",`[v=\\s]*(${o[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[a.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[a.XRANGEIDENTIFIERLOOSE]})(?:${o[a.PRERELEASELOOSE]})?${o[a.BUILD]}?)?)?`),u("XRANGE",`^${o[a.GTLT]}\\s*${o[a.XRANGEPLAIN]}$`),u("XRANGELOOSE",`^${o[a.GTLT]}\\s*${o[a.XRANGEPLAINLOOSE]}$`),u("COERCE",`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?(?:$|[^\\d])`),u("COERCERTL",o[a.COERCE],!0),u("LONETILDE","(?:~>?)"),u("TILDETRIM",`(\\s*)${o[a.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",u("TILDE",`^${o[a.LONETILDE]}${o[a.XRANGEPLAIN]}$`),u("TILDELOOSE",`^${o[a.LONETILDE]}${o[a.XRANGEPLAINLOOSE]}$`),u("LONECARET","(?:\\^)"),u("CARETTRIM",`(\\s*)${o[a.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",u("CARET",`^${o[a.LONECARET]}${o[a.XRANGEPLAIN]}$`),u("CARETLOOSE",`^${o[a.LONECARET]}${o[a.XRANGEPLAINLOOSE]}$`),u("COMPARATORLOOSE",`^${o[a.GTLT]}\\s*(${o[a.LOOSEPLAIN]})$|^$`),u("COMPARATOR",`^${o[a.GTLT]}\\s*(${o[a.FULLPLAIN]})$|^$`),u("COMPARATORTRIM",`(\\s*)${o[a.GTLT]}\\s*(${o[a.LOOSEPLAIN]}|${o[a.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",u("HYPHENRANGE",`^\\s*(${o[a.XRANGEPLAIN]})\\s+-\\s+(${o[a.XRANGEPLAIN]})\\s*$`),u("HYPHENRANGELOOSE",`^\\s*(${o[a.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[a.XRANGEPLAINLOOSE]})\\s*$`),u("STAR","(<|>)?=?\\s*\\*"),u("GTE0","^\\s*>=\\s*0.0.0\\s*$"),u("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")},t=>{const e=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:e,MAX_SAFE_COMPONENT_LENGTH:16}},t=>{const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};t.exports=e},(t,e,r)=>{const i=r(69),{MAX_LENGTH:n,MAX_SAFE_INTEGER:s}=r(68),{re:o,t:a}=r(67),h=r(71),{compareIdentifiers:u}=r(72);class l{constructor(t,e){if(e=h(e),t instanceof l){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if("string"!=typeof t)throw new TypeError(`Invalid Version: ${t}`);if(t.length>n)throw new TypeError(`version is longer than ${n} characters`);i("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;const r=t.trim().match(e.loose?o[a.LOOSE]:o[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>s||this.major<0)throw new TypeError("Invalid major version");if(this.minor>s||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>s||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}}t.exports=l},t=>{const e=["includePrerelease","loose","rtl"];t.exports=t=>t?"object"!=typeof t?{loose:!0}:e.filter((e=>t[e])).reduce(((t,e)=>(t[e]=!0,t)),{}):{}},t=>{const e=/^[0-9]+$/,r=(t,r)=>{const i=e.test(t),n=e.test(r);return i&&n&&(t=+t,r=+r),t===r?0:i&&!n?-1:n&&!i?1:tr(e,t)}},(t,e,r)=>{const{MAX_LENGTH:i}=r(68),{re:n,t:s}=r(67),o=r(70),a=r(71);t.exports=(t,e)=>{if(e=a(e),t instanceof o)return t;if("string"!=typeof t)return null;if(t.length>i)return null;if(!(e.loose?n[s.LOOSE]:n[s.FULL]).test(t))return null;try{return new o(t,e)}catch(t){return null}}},(t,e,r)=>{const i=r(73);t.exports=(t,e)=>{const r=i(t,e);return r?r.version:null}},(t,e,r)=>{const i=r(73);t.exports=(t,e)=>{const r=i(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null}},(t,e,r)=>{const i=r(70);t.exports=(t,e,r,n)=>{"string"==typeof r&&(n=r,r=void 0);try{return new i(t,r).inc(e,n).version}catch(t){return null}}},(t,e,r)=>{const i=r(73),n=r(78);t.exports=(t,e)=>{if(n(t,e))return null;{const r=i(t),n=i(e),s=r.prerelease.length||n.prerelease.length,o=s?"pre":"",a=s?"prerelease":"";for(const t in r)if(("major"===t||"minor"===t||"patch"===t)&&r[t]!==n[t])return o+t;return a}}},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>0===i(t,e,r)},(t,e,r)=>{const i=r(70);t.exports=(t,e,r)=>new i(t,r).compare(new i(e,r))},(t,e,r)=>{const i=r(70);t.exports=(t,e)=>new i(t,e).major},(t,e,r)=>{const i=r(70);t.exports=(t,e)=>new i(t,e).minor},(t,e,r)=>{const i=r(70);t.exports=(t,e)=>new i(t,e).patch},(t,e,r)=>{const i=r(73);t.exports=(t,e)=>{const r=i(t,e);return r&&r.prerelease.length?r.prerelease:null}},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>i(e,t,r)},(t,e,r)=>{const i=r(79);t.exports=(t,e)=>i(t,e,!0)},(t,e,r)=>{const i=r(70);t.exports=(t,e,r)=>{const n=new i(t,r),s=new i(e,r);return n.compare(s)||n.compareBuild(s)}},(t,e,r)=>{const i=r(86);t.exports=(t,e)=>t.sort(((t,r)=>i(t,r,e)))},(t,e,r)=>{const i=r(86);t.exports=(t,e)=>t.sort(((t,r)=>i(r,t,e)))},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>i(t,e,r)>0},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>i(t,e,r)<0},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>0!==i(t,e,r)},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>i(t,e,r)>=0},(t,e,r)=>{const i=r(79);t.exports=(t,e,r)=>i(t,e,r)<=0},(t,e,r)=>{const i=r(78),n=r(91),s=r(89),o=r(92),a=r(90),h=r(93);t.exports=(t,e,r,u)=>{switch(e){case"===":return"object"==typeof t&&(t=t.version),"object"==typeof r&&(r=r.version),t===r;case"!==":return"object"==typeof t&&(t=t.version),"object"==typeof r&&(r=r.version),t!==r;case"":case"=":case"==":return i(t,r,u);case"!=":return n(t,r,u);case">":return s(t,r,u);case">=":return o(t,r,u);case"<":return a(t,r,u);case"<=":return h(t,r,u);default:throw new TypeError(`Invalid operator: ${e}`)}}},(t,e,r)=>{const i=r(70),n=r(73),{re:s,t:o}=r(67);t.exports=(t,e)=>{if(t instanceof i)return t;if("number"==typeof t&&(t=String(t)),"string"!=typeof t)return null;let r=null;if((e=e||{}).rtl){let e;for(;(e=s[o.COERCERTL].exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&e.index+e[0].length===r.index+r[0].length||(r=e),s[o.COERCERTL].lastIndex=e.index+e[1].length+e[2].length;s[o.COERCERTL].lastIndex=-1}else r=t.match(s[o.COERCE]);return null===r?null:n(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,e)}},(t,e,r)=>{const i=Symbol("SemVer ANY");class n{static get ANY(){return i}constructor(t,e){if(e=s(e),t instanceof n){if(t.loose===!!e.loose)return t;t=t.value}u("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===i?this.value="":this.value=this.operator+this.semver.version,u("comp",this)}parse(t){const e=this.options.loose?o[a.COMPARATORLOOSE]:o[a.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==r[1]?r[1]:"","="===this.operator&&(this.operator=""),r[2]?this.semver=new l(r[2],this.options.loose):this.semver=i}toString(){return this.value}test(t){if(u("Comparator.test",t,this.options.loose),this.semver===i||t===i)return!0;if("string"==typeof t)try{t=new l(t,this.options)}catch(t){return!1}return h(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof n))throw new TypeError("a Comparator is required");if(e&&"object"==typeof e||(e={loose:!!e,includePrerelease:!1}),""===this.operator)return""===this.value||new c(t.value,e).test(this.value);if(""===t.operator)return""===t.value||new c(this.value,e).test(t.semver);const r=!(">="!==this.operator&&">"!==this.operator||">="!==t.operator&&">"!==t.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==t.operator&&"<"!==t.operator),s=this.semver.version===t.semver.version,o=!(">="!==this.operator&&"<="!==this.operator||">="!==t.operator&&"<="!==t.operator),a=h(this.semver,"<",t.semver,e)&&(">="===this.operator||">"===this.operator)&&("<="===t.operator||"<"===t.operator),u=h(this.semver,">",t.semver,e)&&("<="===this.operator||"<"===this.operator)&&(">="===t.operator||">"===t.operator);return r||i||s&&o||a||u}}t.exports=n;const s=r(71),{re:o,t:a}=r(67),h=r(94),u=r(69),l=r(70),c=r(97)},(t,e,r)=>{class i{constructor(t,e){if(e=s(e),t instanceof i)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new i(t.raw,e);if(t instanceof o)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map((t=>this.parseRange(t.trim()))).filter((t=>t.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter((t=>!p(t[0]))),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&m(t[0])){this.set=[t];break}}this.format()}format(){return this.range=this.set.map((t=>t.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(t){t=t.trim();const e=`parseRange:${Object.keys(this.options).join(",")}:${t}`,r=n.get(e);if(r)return r;const i=this.options.loose,s=i?u[l.HYPHENRANGELOOSE]:u[l.HYPHENRANGE];t=t.replace(s,S(this.options.includePrerelease)),a("hyphen replace",t),t=t.replace(u[l.COMPARATORTRIM],c),a("comparator trim",t,u[l.COMPARATORTRIM]),t=(t=(t=t.replace(u[l.TILDETRIM],f)).replace(u[l.CARETTRIM],d)).split(/\s+/).join(" ");const h=i?u[l.COMPARATORLOOSE]:u[l.COMPARATOR],m=t.split(" ").map((t=>y(t,this.options))).join(" ").split(/\s+/).map((t=>F(t,this.options))).filter(this.options.loose?t=>!!t.match(h):()=>!0).map((t=>new o(t,this.options))),g=(m.length,new Map);for(const t of m){if(p(t))return[t];g.set(t.value,t)}g.size>1&&g.has("")&&g.delete("");const w=[...g.values()];return n.set(e,w),w}intersects(t,e){if(!(t instanceof i))throw new TypeError("a Range is required");return this.set.some((r=>g(r,e)&&t.set.some((t=>g(t,e)&&r.every((r=>t.every((t=>r.intersects(t,e)))))))))}test(t){if(!t)return!1;if("string"==typeof t)try{t=new h(t,this.options)}catch(t){return!1}for(let e=0;e"<0.0.0-0"===t.value,m=t=>""===t.value,g=(t,e)=>{let r=!0;const i=t.slice();let n=i.pop();for(;r&&i.length;)r=i.every((t=>n.intersects(t,e))),n=i.pop();return r},y=(t,e)=>(a("comp",t,e),t=E(t,e),a("caret",t),t=v(t,e),a("tildes",t),t=C(t,e),a("xrange",t),t=B(t,e),a("stars",t),t),w=t=>!t||"x"===t.toLowerCase()||"*"===t,v=(t,e)=>t.trim().split(/\s+/).map((t=>b(t,e))).join(" "),b=(t,e)=>{const r=e.loose?u[l.TILDELOOSE]:u[l.TILDE];return t.replace(r,((e,r,i,n,s)=>{let o;return a("tilde",t,e,r,i,n,s),w(r)?o="":w(i)?o=`>=${r}.0.0 <${+r+1}.0.0-0`:w(n)?o=`>=${r}.${i}.0 <${r}.${+i+1}.0-0`:s?(a("replaceTilde pr",s),o=`>=${r}.${i}.${n}-${s} <${r}.${+i+1}.0-0`):o=`>=${r}.${i}.${n} <${r}.${+i+1}.0-0`,a("tilde return",o),o}))},E=(t,e)=>t.trim().split(/\s+/).map((t=>A(t,e))).join(" "),A=(t,e)=>{a("caret",t,e);const r=e.loose?u[l.CARETLOOSE]:u[l.CARET],i=e.includePrerelease?"-0":"";return t.replace(r,((e,r,n,s,o)=>{let h;return a("caret",t,e,r,n,s,o),w(r)?h="":w(n)?h=`>=${r}.0.0${i} <${+r+1}.0.0-0`:w(s)?h="0"===r?`>=${r}.${n}.0${i} <${r}.${+n+1}.0-0`:`>=${r}.${n}.0${i} <${+r+1}.0.0-0`:o?(a("replaceCaret pr",o),h="0"===r?"0"===n?`>=${r}.${n}.${s}-${o} <${r}.${n}.${+s+1}-0`:`>=${r}.${n}.${s}-${o} <${r}.${+n+1}.0-0`:`>=${r}.${n}.${s}-${o} <${+r+1}.0.0-0`):(a("no pr"),h="0"===r?"0"===n?`>=${r}.${n}.${s}${i} <${r}.${n}.${+s+1}-0`:`>=${r}.${n}.${s}${i} <${r}.${+n+1}.0-0`:`>=${r}.${n}.${s} <${+r+1}.0.0-0`),a("caret return",h),h}))},C=(t,e)=>(a("replaceXRanges",t,e),t.split(/\s+/).map((t=>M(t,e))).join(" ")),M=(t,e)=>{t=t.trim();const r=e.loose?u[l.XRANGELOOSE]:u[l.XRANGE];return t.replace(r,((r,i,n,s,o,h)=>{a("xRange",t,r,i,n,s,o,h);const u=w(n),l=u||w(s),c=l||w(o),f=c;return"="===i&&f&&(i=""),h=e.includePrerelease?"-0":"",u?r=">"===i||"<"===i?"<0.0.0-0":"*":i&&f?(l&&(s=0),o=0,">"===i?(i=">=",l?(n=+n+1,s=0,o=0):(s=+s+1,o=0)):"<="===i&&(i="<",l?n=+n+1:s=+s+1),"<"===i&&(h="-0"),r=`${i+n}.${s}.${o}${h}`):l?r=`>=${n}.0.0${h} <${+n+1}.0.0-0`:c&&(r=`>=${n}.${s}.0${h} <${n}.${+s+1}.0-0`),a("xRange return",r),r}))},B=(t,e)=>(a("replaceStars",t,e),t.trim().replace(u[l.STAR],"")),F=(t,e)=>(a("replaceGTE0",t,e),t.trim().replace(u[e.includePrerelease?l.GTE0PRE:l.GTE0],"")),S=t=>(e,r,i,n,s,o,a,h,u,l,c,f,d)=>`${r=w(i)?"":w(n)?`>=${i}.0.0${t?"-0":""}`:w(s)?`>=${i}.${n}.0${t?"-0":""}`:o?`>=${r}`:`>=${r}${t?"-0":""}`} ${h=w(u)?"":w(l)?`<${+u+1}.0.0-0`:w(c)?`<${u}.${+l+1}.0-0`:f?`<=${u}.${l}.${c}-${f}`:t?`<${u}.${l}.${+c+1}-0`:`<=${h}`}`.trim(),_=(t,e,r)=>{for(let r=0;r0){const i=t[r].semver;if(i.major===e.major&&i.minor===e.minor&&i.patch===e.patch)return!0}return!1}return!0}},(t,e,r)=>{"use strict";const i=r(99),n=Symbol("max"),s=Symbol("length"),o=Symbol("lengthCalculator"),a=Symbol("allowStale"),h=Symbol("maxAge"),u=Symbol("dispose"),l=Symbol("noDisposeOnSet"),c=Symbol("lruList"),f=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=()=>1,m=(t,e,r)=>{const i=t[f].get(e);if(i){const e=i.value;if(g(t,e)){if(w(t,i),!t[a])return}else r&&(t[d]&&(i.value.now=Date.now()),t[c].unshiftNode(i));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[h])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[h]&&r>t[h]},y=t=>{if(t[s]>t[n])for(let e=t[c].tail;t[s]>t[n]&&null!==e;){const r=e.prev;w(t,e),e=r}},w=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[s]-=r.length,t[f].delete(r.key),t[c].removeNode(e)}};class v{constructor(t,e,r,i,n){this.key=t,this.value=e,this.length=r,this.now=i,this.maxAge=n||0}}const b=(t,e,r,i)=>{let n=r.value;g(t,n)&&(w(t,r),t[a]||(n=void 0)),n&&e.call(i,n.value,n.key,t)};t.exports=class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[n]=t.max||1/0;const e=t.length||p;if(this[o]="function"!=typeof e?p:e,this[a]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[h]=t.maxAge||0,this[u]=t.dispose,this[l]=t.noDisposeOnSet||!1,this[d]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[n]=t||1/0,y(this)}get max(){return this[n]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[h]=t,y(this)}get maxAge(){return this[h]}set lengthCalculator(t){"function"!=typeof t&&(t=p),t!==this[o]&&(this[o]=t,this[s]=0,this[c].forEach((t=>{t.length=this[o](t.value,t.key),this[s]+=t.length}))),y(this)}get lengthCalculator(){return this[o]}get length(){return this[s]}get itemCount(){return this[c].length}rforEach(t,e){e=e||this;for(let r=this[c].tail;null!==r;){const i=r.prev;b(this,t,r,e),r=i}}forEach(t,e){e=e||this;for(let r=this[c].head;null!==r;){const i=r.next;b(this,t,r,e),r=i}}keys(){return this[c].toArray().map((t=>t.key))}values(){return this[c].toArray().map((t=>t.value))}reset(){this[u]&&this[c]&&this[c].length&&this[c].forEach((t=>this[u](t.key,t.value))),this[f]=new Map,this[c]=new i,this[s]=0}dump(){return this[c].map((t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[c]}set(t,e,r){if((r=r||this[h])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const i=r?Date.now():0,a=this[o](e,t);if(this[f].has(t)){if(a>this[n])return w(this,this[f].get(t)),!1;const o=this[f].get(t).value;return this[u]&&(this[l]||this[u](t,o.value)),o.now=i,o.maxAge=r,o.value=e,this[s]+=a-o.length,o.length=a,this.get(t),y(this),!0}const d=new v(t,e,a,i,r);return d.length>this[n]?(this[u]&&this[u](t,e),!1):(this[s]+=d.length,this[c].unshift(d),this[f].set(t,this[c].head),y(this),!0)}has(t){if(!this[f].has(t))return!1;const e=this[f].get(t).value;return!g(this,e)}get(t){return m(this,t,!0)}peek(t){return m(this,t,!1)}pop(){const t=this[c].tail;return t?(w(this,t),t.value):null}del(t){w(this,this[f].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const i=t[r],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const t=n-e;t>0&&this.set(i.k,i.v,t)}}}prune(){this[f].forEach(((t,e)=>m(this,e,!1)))}}},(t,e,r)=>{"use strict";function i(t){var e=this;if(e instanceof i||(e=new i),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=t(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(t,e){var r,i=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=t(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},i.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},i.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new i;if(ethis.length&&(e=this.length);for(var n=0,s=this.head;null!==s&&nthis.length&&(e=this.length);for(var n=this.length,s=this.tail;null!==s&&n>e;n--)s=s.prev;for(;null!==s&&n>t;n--,s=s.prev)r.push(s.value);return r},i.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var i=0,s=this.head;null!==s&&i{"use strict";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},(t,e,r)=>{const i=r(97);t.exports=(t,e,r)=>{try{e=new i(e,r)}catch(t){return!1}return e.test(t)}},(t,e,r)=>{const i=r(97);t.exports=(t,e)=>new i(t,e).set.map((t=>t.map((t=>t.value)).join(" ").trim().split(" ")))},(t,e,r)=>{const i=r(70),n=r(97);t.exports=(t,e,r)=>{let s=null,o=null,a=null;try{a=new n(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(s&&-1!==o.compare(t)||(s=t,o=new i(s,r)))})),s}},(t,e,r)=>{const i=r(70),n=r(97);t.exports=(t,e,r)=>{let s=null,o=null,a=null;try{a=new n(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(s&&1!==o.compare(t)||(s=t,o=new i(s,r)))})),s}},(t,e,r)=>{const i=r(70),n=r(97),s=r(89);t.exports=(t,e)=>{t=new n(t,e);let r=new i("0.0.0");if(t.test(r))return r;if(r=new i("0.0.0-0"),t.test(r))return r;r=null;for(let e=0;e{const e=new i(t.semver.version);switch(t.operator){case">":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case"":case">=":o&&!s(e,o)||(o=e);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}})),!o||r&&!s(r,o)||(r=o)}return r&&t.test(r)?r:null}},(t,e,r)=>{const i=r(97);t.exports=(t,e)=>{try{return new i(t,e).range||"*"}catch(t){return null}}},(t,e,r)=>{const i=r(70),n=r(96),{ANY:s}=n,o=r(97),a=r(101),h=r(89),u=r(90),l=r(93),c=r(92);t.exports=(t,e,r,f)=>{let d,p,m,g,y;switch(t=new i(t,f),e=new o(e,f),r){case">":d=h,p=l,m=u,g=">",y=">=";break;case"<":d=u,p=c,m=h,g="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(a(t,e,f))return!1;for(let r=0;r{t.semver===s&&(t=new n(">=0.0.0")),o=o||t,a=a||t,d(t.semver,o.semver,f)?o=t:m(t.semver,a.semver,f)&&(a=t)})),o.operator===g||o.operator===y)return!1;if((!a.operator||a.operator===g)&&p(t,a.semver))return!1;if(a.operator===y&&m(t,a.semver))return!1}return!0}},(t,e,r)=>{const i=r(107);t.exports=(t,e,r)=>i(t,e,">",r)},(t,e,r)=>{const i=r(107);t.exports=(t,e,r)=>i(t,e,"<",r)},(t,e,r)=>{const i=r(97);t.exports=(t,e,r)=>(t=new i(t,r),e=new i(e,r),t.intersects(e))},(t,e,r)=>{const i=r(101),n=r(79);t.exports=(t,e,r)=>{const s=[];let o=null,a=null;const h=t.sort(((t,e)=>n(t,e,r)));for(const t of h)i(t,e,r)?(a=t,o||(o=t)):(a&&s.push([o,a]),a=null,o=null);o&&s.push([o,null]);const u=[];for(const[t,e]of s)t===e?u.push(t):e||t!==h[0]?e?t===h[0]?u.push(`<=${e}`):u.push(`${t} - ${e}`):u.push(`>=${t}`):u.push("*");const l=u.join(" || "),c="string"==typeof e.raw?e.raw:String(e);return l.length{const i=r(97),n=r(96),{ANY:s}=n,o=r(101),a=r(79),h=(t,e,r)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===s){if(1===e.length&&e[0].semver===s)return!0;t=r.includePrerelease?[new n(">=0.0.0-0")]:[new n(">=0.0.0")]}if(1===e.length&&e[0].semver===s){if(r.includePrerelease)return!0;e=[new n(">=0.0.0")]}const i=new Set;let h,c,f,d,p,m,g;for(const e of t)">"===e.operator||">="===e.operator?h=u(h,e,r):"<"===e.operator||"<="===e.operator?c=l(c,e,r):i.add(e.semver);if(i.size>1)return null;if(h&&c){if(f=a(h.semver,c.semver,r),f>0)return null;if(0===f&&(">="!==h.operator||"<="!==c.operator))return null}for(const t of i){if(h&&!o(t,String(h),r))return null;if(c&&!o(t,String(c),r))return null;for(const i of e)if(!o(t,String(i),r))return!1;return!0}let y=!(!c||r.includePrerelease||!c.semver.prerelease.length)&&c.semver,w=!(!h||r.includePrerelease||!h.semver.prerelease.length)&&h.semver;y&&1===y.prerelease.length&&"<"===c.operator&&0===y.prerelease[0]&&(y=!1);for(const t of e){if(g=g||">"===t.operator||">="===t.operator,m=m||"<"===t.operator||"<="===t.operator,h)if(w&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===w.major&&t.semver.minor===w.minor&&t.semver.patch===w.patch&&(w=!1),">"===t.operator||">="===t.operator){if(d=u(h,t,r),d===t&&d!==h)return!1}else if(">="===h.operator&&!o(h.semver,String(t),r))return!1;if(c)if(y&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===y.major&&t.semver.minor===y.minor&&t.semver.patch===y.patch&&(y=!1),"<"===t.operator||"<="===t.operator){if(p=l(c,t,r),p===t&&p!==c)return!1}else if("<="===c.operator&&!o(c.semver,String(t),r))return!1;if(!t.operator&&(c||h)&&0!==f)return!1}return!(h&&m&&!c&&0!==f||c&&g&&!h&&0!==f||w||y)},u=(t,e,r)=>{if(!t)return e;const i=a(t.semver,e.semver,r);return i>0?t:i<0||">"===e.operator&&">="===t.operator?e:t},l=(t,e,r)=>{if(!t)return e;const i=a(t.semver,e.semver,r);return i<0?t:i>0||"<"===e.operator&&"<="===t.operator?e:t};t.exports=(t,e,r={})=>{if(t===e)return!0;t=new i(t,r),e=new i(e,r);let n=!1;t:for(const i of t.set){for(const t of e.set){const e=h(i,t,r);if(n=n||null!==e,e)continue t}if(n)return!1}return!0}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{listen:()=>o,log:()=>s});let i=0;const n=[],s=(t,e,r)=>{const s={type:t,id:String(++i),date:new Date};e&&(s.message=e),r&&(s.data=r),function(t){for(let e=0;e(n.push(t),()=>{const e=n.indexOf(t);-1!==e&&(n[e]=n[n.length-1],n.pop())});"undefined"!=typeof window&&(window.__ledgerLogsListen=o)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{getFirstLedgerDevice:()=>a,getLedgerDevices:()=>o,isSupported:()=>h,requestLedgerDevice:()=>s});var i=r(65);const n=[{vendorId:i.ledgerUSBVendorId}];async function s(){return await navigator.usb.requestDevice({filters:n})}async function o(){return(await navigator.usb.getDevices()).filter((t=>t.vendorId===i.ledgerUSBVendorId))}async function a(){const t=await o();return t.length>0?t[0]:s()}const h=()=>Promise.resolve(!!navigator&&!!navigator.usb&&"function"==typeof navigator.usb.getDevices)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d});var i=r(61),n=r(64),s=r(65),o=r(113),a=r(63),h=r(9).Buffer;const u=[{vendorId:s.ledgerUSBVendorId}],l=()=>{const{hid:t}=navigator;if(!t)throw new a.TransportError("navigator.hid is not supported","HIDNotSupported");return t};async function c(){const t=await l().requestDevice({filters:u});return Array.isArray(t)?t:[t]}async function f(){return(await l().getDevices()).filter((t=>t.vendorId===s.ledgerUSBVendorId))}class d extends i.default{constructor(t){super(),this.device=void 0,this.deviceModel=void 0,this.channel=Math.floor(65535*Math.random()),this.packetSize=64,this.inputs=[],this.inputCallback=void 0,this.read=()=>this.inputs.length?Promise.resolve(this.inputs.shift()):new Promise((t=>{this.inputCallback=t})),this.onInputReport=t=>{const e=h.from(t.data.buffer);this.inputCallback?(this.inputCallback(e),this.inputCallback=null):this.inputs.push(e)},this._disconnectEmitted=!1,this._emitDisconnect=t=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",t))},this.exchange=t=>this.exchangeAtomicImpl((async()=>{const{channel:e,packetSize:r}=this;(0,o.log)("apdu","=> "+t.toString("hex"));const i=(0,n.default)(e,r),s=i.makeBlocks(t);for(let t=0;t{if(t&&t.message&&t.message.includes("write"))throw this._emitDisconnect(t),new a.DisconnectedDeviceDuringOperation(t.message);throw t})),this.device=t,this.deviceModel=(0,s.identifyUSBProductId)(t.productId),t.addEventListener("inputreport",this.onInputReport)}static async request(){const[t]=await c();return d.open(t)}static async openConnected(){const t=await f();return 0===t.length?null:d.open(t[0])}static async open(t){await t.open();const e=new d(t),r=i=>{t===i.device&&(l().removeEventListener("disconnect",r),e._emitDisconnect(new a.DisconnectedDevice))};return l().addEventListener("disconnect",r),e}async close(){await this.exchangeBusyPromise,this.device.removeEventListener("inputreport",this.onInputReport),await this.device.close()}setScrambleKey(){}}d.isSupported=()=>Promise.resolve(!(!r.g.navigator||!r.g.navigator.hid)),d.list=f,d.listen=t=>{let e=!1;return async function(){const t=await f();return t.length>0?t[0]:(await c())[0]}().then((r=>{if(r){if(!e){const e=(0,s.identifyUSBProductId)(r.productId);t.next({type:"add",descriptor:r,deviceModel:e}),t.complete()}}else t.error(new a.TransportOpenUserCancelled("Access denied to use Ledger device"))}),(e=>{t.error(new a.TransportOpenUserCancelled(e.message))})),{unsubscribe:function(){e=!0}}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>B});var i=r(61),n=r(63),s=r(65),o=r(117),a=r(221),h=r(113),u=r(119),l=r(209),c=r(201),f=r(193),d=r(223),p=r(224),m=r(226),g=r(176),y=r(230),w=r(222),v=r(9).Buffer;const b=()=>{const{bluetooth:t}=navigator;if(void 0===t)throw new Error("web bluetooth not supported");return t},E=()=>u.Observable.create((t=>{const e=b(),r=e=>{t.next(e.value)};e.addEventListener("availabilitychanged",r);let i=!1;return e.getAvailability().then((e=>{i||t.next(e)})),()=>{i=!0,e.removeEventListener("availabilitychanged",r)}})),A={},C=()=>({filters:(0,s.getBluetoothServiceUuids)().map((t=>({services:[t]})))});async function M(t,e){let r;if("string"==typeof t){if(A[t])return(0,h.log)("ble-verbose","Transport in cache, using that."),A[t];const e=b();r=await e.requestDevice(C())}else r=t;r.gatt.connected||((0,h.log)("ble-verbose","not connected. connecting..."),await r.gatt.connect());const[i,o]=await(async t=>{if(!t.gatt)throw new Error("bluetooth gatt not found");const[e]=await t.gatt.getPrimaryServices();if(!e)throw new Error("bluetooth service not found");const r=(0,s.getInfosForServiceUuid)(e.uuid);if(!r)throw new Error("bluetooth service infos not found");return[e,r]})(r),{deviceModel:a,writeUuid:u,notifyUuid:l}=o,[c,f]=await Promise.all([i.getCharacteristic(u),i.getCharacteristic(l)]),m=(0,w.monitorCharacteristic)(f).pipe((0,d.tap)((t=>{(0,h.log)("ble-frame","<= "+t.toString("hex"))})),(0,p.share)()),g=m.subscribe(),y=new B(r,c,m,a);if(!r.gatt.connected)throw new n.DisconnectedDevice;A[y.id]=y;const v=t=>{console.log("onDisconnect!",t),delete A[y.id],y.notYetDisconnected=!1,g.unsubscribe(),r.removeEventListener("gattserverdisconnected",v),(0,h.log)("ble-verbose",`BleTransport(${y.id}) disconnected`),y.emit("disconnect",t)};r.addEventListener("gattserverdisconnected",v);let E=Date.now();try{await y.inferMTU()}finally{Date.now()-E<1e3&&(e=!1),e&&(await r.gatt.disconnect(),await new Promise((t=>setTimeout(t,4e3))))}return e?M(r,!1):y}class B extends i.default{static listen(t){let e;return(0,h.log)("ble-verbose","listen..."),b().requestDevice(C()).then((async r=>{e||(t.next({type:"add",descriptor:r}),t.complete())}),(e=>{t.error(new n.TransportOpenUserCancelled(e.message))})),{unsubscribe:function(){e=!0}}}static async open(t){return M(t,!0)}constructor(t,e,r,i){super(),this.id=void 0,this.device=void 0,this.mtuSize=20,this.writeCharacteristic=void 0,this.notifyObservable=void 0,this.notYetDisconnected=!0,this.deviceModel=void 0,this.exchange=t=>this.exchangeAtomicImpl((async()=>{try{const e=t.toString("hex");(0,h.log)("apdu",`=> ${e}`);const r=await(0,l.merge)(this.notifyObservable.pipe(a.receiveAPDU),(0,o.sendAPDU)(this.write,t,this.mtuSize)).toPromise(),i=r.toString("hex");return(0,h.log)("apdu",`<= ${i}`),r}catch(t){throw(0,h.log)("ble-error","exchange got "+String(t)),this.notYetDisconnected&&this.device.gatt.disconnect(),t}})),this.write=async t=>{(0,h.log)("ble-frame","=> "+t.toString("hex")),await this.writeCharacteristic.writeValue(t)},this.id=t.id,this.device=t,this.writeCharacteristic=e,this.notifyObservable=r,this.deviceModel=i,(0,h.log)("ble-verbose",`BleTransport(${String(this.id)}) new instance`)}async inferMTU(){let t=23;if(await this.exchangeAtomicImpl((async()=>{try{t=await(0,l.merge)(this.notifyObservable.pipe((0,m.first)((t=>8===t.readUInt8(0))),(0,g.map)((t=>t.readUInt8(5)))),(0,c.defer)((()=>(0,f.from)(this.write(v.from([8,0,0,0,0]))))).pipe((0,y.ignoreElements)())).toPromise()+3}catch(t){throw(0,h.log)("ble-error","inferMTU got "+String(t)),this.device.gatt.disconnect(),t}})),t>23){const e=t-3;(0,h.log)("ble-verbose",`BleTransport(${String(this.id)}) mtu set to ${String(e)}`),this.mtuSize=e}return this.mtuSize}setScrambleKey(){}async close(){this.exchangeBusyPromise&&await this.exchangeBusyPromise}}B.isSupported=()=>Promise.resolve().then(b).then((()=>!0),(()=>!1)),B.observeAvailability=t=>E.subscribe(t),B.list=()=>Promise.resolve([]),B.disconnect=async t=>{(0,h.log)("ble-verbose",`user disconnect(${t})`);const e=A[t];e&&e.device.gatt.disconnect()}},(t,e,r)=>{"use strict";var i=r(9).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.sendAPDU=void 0;var n=r(118),s=r(113);e.sendAPDU=(t,e,r)=>{const o=function(t,e){const r=[];for(let i=0,n=e(0);ir-(0===t?5:3))).map(((t,r)=>{const n=i.alloc(0===r?5:3);return n.writeUInt8(5,0),n.writeUInt16BE(r,1),0===r&&n.writeUInt16BE(e.length,3),i.concat([n,t])}));return n.Observable.create((e=>{let r=!1;return async function(){for(const e of o){if(r)return;await t(e)}}().then((()=>{r=!0,e.complete()}),(t=>{r=!0,(0,s.log)("ble-error","sendAPDU failure "+String(t)),e.error(t)})),()=>{r||((0,s.log)("ble-verbose","sendAPDU interruption"),r=!0)}}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ArgumentOutOfRangeError:()=>M.ArgumentOutOfRangeError,AsyncSubject:()=>l.AsyncSubject,BehaviorSubject:()=>h.BehaviorSubject,ConnectableObservable:()=>n.ConnectableObservable,EMPTY:()=>U.EMPTY,EmptyError:()=>B.EmptyError,GroupedObservable:()=>s.GroupedObservable,NEVER:()=>K.NEVER,Notification:()=>v.Notification,NotificationKind:()=>v.NotificationKind,ObjectUnsubscribedError:()=>F.ObjectUnsubscribedError,Observable:()=>i.Observable,ReplaySubject:()=>u.ReplaySubject,Scheduler:()=>g.Scheduler,Subject:()=>a.Subject,Subscriber:()=>w.Subscriber,Subscription:()=>y.Subscription,TimeoutError:()=>_.TimeoutError,UnsubscriptionError:()=>S.UnsubscriptionError,VirtualAction:()=>m.VirtualAction,VirtualTimeScheduler:()=>m.VirtualTimeScheduler,animationFrame:()=>p.animationFrame,animationFrameScheduler:()=>p.animationFrameScheduler,asap:()=>c.asap,asapScheduler:()=>c.asapScheduler,async:()=>f.async,asyncScheduler:()=>f.asyncScheduler,bindCallback:()=>D.bindCallback,bindNodeCallback:()=>I.bindNodeCallback,combineLatest:()=>x.combineLatest,concat:()=>T.concat,config:()=>et.config,defer:()=>N.defer,empty:()=>U.empty,forkJoin:()=>R.forkJoin,from:()=>O.from,fromEvent:()=>k.fromEvent,fromEventPattern:()=>L.fromEventPattern,generate:()=>P.generate,identity:()=>A.identity,iif:()=>j.iif,interval:()=>$.interval,isObservable:()=>C.isObservable,merge:()=>q.merge,never:()=>K.never,noop:()=>E.noop,observable:()=>o.observable,of:()=>H.of,onErrorResumeNext:()=>G.onErrorResumeNext,pairs:()=>V.pairs,partition:()=>W.partition,pipe:()=>b.pipe,queue:()=>d.queue,queueScheduler:()=>d.queueScheduler,race:()=>z.race,range:()=>Z.range,scheduled:()=>tt.scheduled,throwError:()=>Y.throwError,timer:()=>X.timer,using:()=>Q.using,zip:()=>J.zip});var i=r(119),n=r(136),s=r(141),o=r(133),a=r(138),h=r(142),u=r(143),l=r(160),c=r(161),f=r(165),d=r(153),p=r(166),m=r(169),g=r(156),y=r(127),w=r(121),v=r(145),b=r(134),E=r(170),A=r(135),C=r(171),M=r(172),B=r(173),F=r(139),S=r(129),_=r(174),D=r(175),I=r(177),x=r(178),T=r(189),N=r(201),U=r(152),R=r(202),O=r(193),k=r(203),L=r(204),P=r(205),j=r(206),$=r(207),q=r(209),K=r(210),H=r(146),G=r(211),V=r(212),W=r(213),z=r(216),Z=r(217),Y=r(151),X=r(218),Q=r(219),J=r(220),tt=r(194),et=r(124)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Observable:()=>h});var i=r(132),n=r(120),s=r(133),o=r(134),a=r(124),h=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var i=this.operator,s=(0,n.toSubscriber)(t,e,r);if(i?s.add(i.call(s,this.source)):s.add(this.source||a.config.useDeprecatedSynchronousErrorHandling&&!s.syncErrorThrowable?this._subscribe(s):this._trySubscribe(s)),a.config.useDeprecatedSynchronousErrorHandling&&s.syncErrorThrowable&&(s.syncErrorThrowable=!1,s.syncErrorThrown))throw s.syncErrorValue;return s},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){a.config.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),(0,i.canReportError)(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=u(e))((function(e,i){var n;n=r.subscribe((function(e){try{t(e)}catch(t){i(t),n&&n.unsubscribe()}}),i,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[s.observable]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{toSubscriber:()=>o});var i=r(121),n=r(126),s=r(123);function o(t,e,r){if(t){if(t instanceof i.Subscriber)return t;if(t[n.rxSubscriber])return t[n.rxSubscriber]()}return t||e||r?new i.Subscriber(t,e,r):new i.Subscriber(s.empty)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{SafeSubscriber:()=>c,Subscriber:()=>l});var i=r(122),n=r(128),s=r(123),o=r(127),a=r(126),h=r(124),u=r(125),l=function(t){function e(r,i,n){var o=t.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=s.empty;break;case 1:if(!r){o.destination=s.empty;break}if("object"==typeof r){r instanceof e?(o.syncErrorThrowable=r.syncErrorThrowable,o.destination=r,r.add(o)):(o.syncErrorThrowable=!0,o.destination=new c(o,r));break}default:o.syncErrorThrowable=!0,o.destination=new c(o,r,i,n)}return o}return i.__extends(e,t),e.prototype[a.rxSubscriber]=function(){return this},e.create=function(t,r,i){var n=new e(t,r,i);return n.syncErrorThrowable=!1,n},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(o.Subscription),c=function(t){function e(e,r,i,o){var a,h=t.call(this)||this;h._parentSubscriber=e;var u=h;return(0,n.isFunction)(r)?a=r:r&&(a=r.next,i=r.error,o=r.complete,r!==s.empty&&(u=Object.create(r),(0,n.isFunction)(u.unsubscribe)&&h.add(u.unsubscribe.bind(u)),u.unsubscribe=h.unsubscribe.bind(h))),h._context=u,h._next=a,h._error=i,h._complete=o,h}return i.__extends(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;h.config.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=h.config.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):(0,u.hostReportError)(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;(0,u.hostReportError)(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};h.config.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),h.config.useDeprecatedSynchronousErrorHandling)throw t;(0,u.hostReportError)(t)}},e.prototype.__tryOrSetError=function(t,e,r){if(!h.config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return h.config.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):((0,u.hostReportError)(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(l)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{__assign:()=>s,__asyncDelegator:()=>v,__asyncGenerator:()=>w,__asyncValues:()=>b,__await:()=>y,__awaiter:()=>l,__classPrivateFieldGet:()=>M,__classPrivateFieldSet:()=>B,__decorate:()=>a,__exportStar:()=>f,__extends:()=>n,__generator:()=>c,__importDefault:()=>C,__importStar:()=>A,__makeTemplateObject:()=>E,__metadata:()=>u,__param:()=>h,__read:()=>p,__rest:()=>o,__spread:()=>m,__spreadArrays:()=>g,__values:()=>d});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},i(t,e)};function n(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,i=arguments.length;r=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function h(t,e){return function(r,i){e(r,i,t)}}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function l(t,e,r,i){return new(r||(r=Promise))((function(n,s){function o(t){try{h(i.next(t))}catch(t){s(t)}}function a(t){try{h(i.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}h((i=i.apply(t,e||[])).next())}))}function c(t,e){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function m(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=n[t](e)).value instanceof y?Promise.resolve(r.value.v).then(h,u):l(s[0][2],r)}catch(t){l(s[0][3],t)}var r}function h(t){a("next",t)}function u(t){a("throw",t)}function l(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function v(t){var e,r;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,n){e[i]=t[i]?function(e){return(r=!r)?{value:y(t[i](e)),done:"return"===i}:n?n(e):e}:n}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=d(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(r){e[r]=t[r]&&function(e){return new Promise((function(i,n){!function(t,e,r,i){Promise.resolve(i).then((function(e){t({value:e,done:r})}),e)}(i,n,(e=t[r](e)).done,e.value)}))}}}function E(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function A(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function C(t){return t&&t.__esModule?t:{default:t}}function M(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function B(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{empty:()=>s});var i=r(124),n=r(125),s={closed:!0,next:function(t){},error:function(t){if(i.config.useDeprecatedSynchronousErrorHandling)throw t;(0,n.hostReportError)(t)},complete:function(){}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{config:()=>n});var i=!1,n={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,i=t},get useDeprecatedSynchronousErrorHandling(){return i}}},(t,e,r)=>{"use strict";function i(t){setTimeout((function(){throw t}),0)}r.r(e),r.d(e,{hostReportError:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{$$rxSubscriber:()=>n,rxSubscriber:()=>i});var i=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),n=i},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Subscription:()=>a});var i=r(130),n=r(131),s=r(128),o=r(129),a=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}var e;return t.prototype.unsubscribe=function(){var e;if(!this.closed){var r=this,a=r._parentOrParents,u=r._ctorUnsubscribe,l=r._unsubscribe,c=r._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,a instanceof t)a.remove(this);else if(null!==a)for(var f=0;f{"use strict";function i(t){return"function"==typeof t}r.r(e),r.d(e,{isFunction:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{UnsubscriptionError:()=>i});var i=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isArray:()=>i});var i=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}()},(t,e,r)=>{"use strict";function i(t){return null!==t&&"object"==typeof t}r.r(e),r.d(e,{isObject:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{canReportError:()=>n});var i=r(121);function n(t){for(;t;){var e=t,r=e.closed,n=e.destination,s=e.isStopped;if(r||s)return!1;t=n&&n instanceof i.Subscriber?n:null}return!0}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{observable:()=>i});var i=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{pipe:()=>n,pipeFromArray:()=>s});var i=r(135);function n(){for(var t=[],e=0;e{"use strict";function i(t){return t}r.r(e),r.d(e,{identity:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ConnectableObservable:()=>u,connectableObservableDescriptor:()=>l});var i=r(122),n=r(138),s=r(119),o=r(121),a=r(127),h=r(137),u=function(t){function e(e,r){var i=t.call(this)||this;return i.source=e,i.subjectFactory=r,i._refCount=0,i._isComplete=!1,i}return i.__extends(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a.Subscription).add(this.source.subscribe(new c(this.getSubject(),this))),t.closed&&(this._connection=null,t=a.Subscription.EMPTY)),t},e.prototype.refCount=function(){return(0,h.refCount)()(this)},e}(s.Observable),l=function(){var t=u.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),c=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return i.__extends(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(n.SubjectSubscriber);o.Subscriber},(t,e,r)=>{"use strict";r.r(e),r.d(e,{refCount:()=>s});var i=r(122),n=r(121);function s(){return function(t){return t.lift(new o(t))}}var o=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var r=this.connectable;r._refCount++;var i=new a(t,r),n=e.subscribe(i);return i.closed||(i.connection=r.connect()),n},t}(),a=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return i.__extends(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var r=this.connection,i=t._connection;this.connection=null,!i||r&&i!==r||i.unsubscribe()}}else this.connection=null},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AnonymousSubject:()=>f,Subject:()=>c,SubjectSubscriber:()=>l});var i=r(122),n=r(119),s=r(121),o=r(127),a=r(139),h=r(140),u=r(126),l=function(t){function e(e){var r=t.call(this,e)||this;return r.destination=e,r}return i.__extends(e,t),e}(s.Subscriber),c=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return i.__extends(e,t),e.prototype[u.rxSubscriber]=function(){return new l(this)},e.prototype.lift=function(t){var e=new f(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new a.ObjectUnsubscribedError;if(!this.isStopped)for(var e=this.observers,r=e.length,i=e.slice(),n=0;n{"use strict";r.r(e),r.d(e,{ObjectUnsubscribedError:()=>i});var i=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{SubjectSubscription:()=>n});var i=r(122),n=function(t){function e(e,r){var i=t.call(this)||this;return i.subject=e,i.subscriber=r,i.closed=!1,i}return i.__extends(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},e}(r(127).Subscription)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{GroupedObservable:()=>f,groupBy:()=>h});var i=r(122),n=r(121),s=r(127),o=r(119),a=r(138);function h(t,e,r,i){return function(n){return n.lift(new u(t,e,r,i))}}var u=function(){function t(t,e,r,i){this.keySelector=t,this.elementSelector=e,this.durationSelector=r,this.subjectSelector=i}return t.prototype.call=function(t,e){return e.subscribe(new l(t,this.keySelector,this.elementSelector,this.durationSelector,this.subjectSelector))},t}(),l=function(t){function e(e,r,i,n,s){var o=t.call(this,e)||this;return o.keySelector=r,o.elementSelector=i,o.durationSelector=n,o.subjectSelector=s,o.groups=null,o.attemptedToUnsubscribe=!1,o.count=0,o}return i.__extends(e,t),e.prototype._next=function(t){var e;try{e=this.keySelector(t)}catch(t){return void this.error(t)}this._group(t,e)},e.prototype._group=function(t,e){var r=this.groups;r||(r=this.groups=new Map);var i,n=r.get(e);if(this.elementSelector)try{i=this.elementSelector(t)}catch(t){this.error(t)}else i=t;if(!n){n=this.subjectSelector?this.subjectSelector():new a.Subject,r.set(e,n);var s=new f(e,n,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new f(e,n))}catch(t){return void this.error(t)}this.add(o.subscribe(new c(e,n,this)))}}n.closed||n.next(i)},e.prototype._error=function(t){var e=this.groups;e&&(e.forEach((function(e,r){e.error(t)})),e.clear()),this.destination.error(t)},e.prototype._complete=function(){var t=this.groups;t&&(t.forEach((function(t,e){t.complete()})),t.clear()),this.destination.complete()},e.prototype.removeGroup=function(t){this.groups.delete(t)},e.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&t.prototype.unsubscribe.call(this))},e}(n.Subscriber),c=function(t){function e(e,r,i){var n=t.call(this,r)||this;return n.key=e,n.group=r,n.parent=i,n}return i.__extends(e,t),e.prototype._next=function(t){this.complete()},e.prototype._unsubscribe=function(){var t=this.parent,e=this.key;this.key=this.parent=null,t&&t.removeGroup(e)},e}(n.Subscriber),f=function(t){function e(e,r,i){var n=t.call(this)||this;return n.key=e,n.groupSubject=r,n.refCountSubscription=i,n}return i.__extends(e,t),e.prototype._subscribe=function(t){var e=new s.Subscription,r=this.refCountSubscription,i=this.groupSubject;return r&&!r.closed&&e.add(new d(r)),e.add(i.subscribe(t)),e},e}(o.Observable),d=function(t){function e(e){var r=t.call(this)||this;return r.parent=e,e.count++,r}return i.__extends(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(s.Subscription)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{BehaviorSubject:()=>o});var i=r(122),n=r(138),s=r(139),o=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return i.__extends(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new s.ObjectUnsubscribedError;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(n.Subject)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ReplaySubject:()=>l});var i=r(122),n=r(138),s=r(153),o=r(127),a=r(144),h=r(139),u=r(140),l=function(t){function e(e,r,i){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var n=t.call(this)||this;return n.scheduler=i,n._events=[],n._infiniteTimeWindow=!1,n._bufferSize=e<1?1:e,n._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(n._infiniteTimeWindow=!0,n.next=n.nextInfiniteTimeWindow):n.next=n.nextTimeWindow,n}return i.__extends(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var r=this._events;r.push(e),r.length>this._bufferSize&&r.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new c(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,r=this._infiniteTimeWindow,i=r?this._events:this._trimBufferThenGetEvents(),n=this.scheduler,s=i.length;if(this.closed)throw new h.ObjectUnsubscribedError;if(this.isStopped||this.hasError?e=o.Subscription.EMPTY:(this.observers.push(t),e=new u.SubjectSubscription(this,t)),n&&t.add(t=new a.ObserveOnSubscriber(t,n)),r)for(var l=0;le&&(s=Math.max(s,n-e)),s>0&&i.splice(0,s),i},e}(n.Subject),c=function(){return function(t,e){this.time=t,this.value=e}}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ObserveOnMessage:()=>u,ObserveOnOperator:()=>a,ObserveOnSubscriber:()=>h,observeOn:()=>o});var i=r(122),n=r(121),s=r(145);function o(t,e){return void 0===e&&(e=0),function(r){return r.lift(new a(t,e))}}var a=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.scheduler,this.delay))},t}(),h=function(t){function e(e,r,i){void 0===i&&(i=0);var n=t.call(this,e)||this;return n.scheduler=r,n.delay=i,n}return i.__extends(e,t),e.dispatch=function(t){var e=t.notification,r=t.destination;e.observe(r),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new u(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(s.Notification.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(s.Notification.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(s.Notification.createComplete()),this.unsubscribe()},e}(n.Subscriber),u=function(){return function(t,e){this.notification=t,this.destination=e}}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Notification:()=>a,NotificationKind:()=>i});var i,n=r(152),s=r(146),o=r(151);i||(i={});var a=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,r){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return r&&r()}},t.prototype.accept=function(t,e,r){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){switch(this.kind){case"N":return(0,s.of)(this.value);case"E":return(0,o.throwError)(this.error);case"C":return(0,n.empty)()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{of:()=>o});var i=r(147),n=r(149),s=r(148);function o(){for(var t=[],e=0;e{"use strict";function i(t){return t&&"function"==typeof t.schedule}r.r(e),r.d(e,{isScheduler:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduleArray:()=>s});var i=r(119),n=r(127);function s(t,e){return new i.Observable((function(r){var i=new n.Subscription,s=0;return i.add(e.schedule((function(){s!==t.length?(r.next(t[s++]),r.closed||i.add(this.schedule())):r.complete()}))),i}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{fromArray:()=>o});var i=r(119),n=r(150),s=r(148);function o(t,e){return e?(0,s.scheduleArray)(t,e):new i.Observable((0,n.subscribeToArray)(t))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToArray:()=>i});var i=function(t){return function(e){for(var r=0,i=t.length;r{"use strict";r.r(e),r.d(e,{throwError:()=>n});var i=r(119);function n(t,e){return e?new i.Observable((function(r){return e.schedule(s,0,{error:t,subscriber:r})})):new i.Observable((function(e){return e.error(t)}))}function s(t){var e=t.error;t.subscriber.error(e)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{EMPTY:()=>n,empty:()=>s});var i=r(119),n=new i.Observable((function(t){return t.complete()}));function s(t){return t?function(t){return new i.Observable((function(e){return t.schedule((function(){return e.complete()}))}))}(t):n}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{queue:()=>s,queueScheduler:()=>n});var i=r(157),n=new(r(154).QueueScheduler)(i.QueueAction),s=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{QueueScheduler:()=>n});var i=r(122),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e}(r(155).AsyncScheduler)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsyncScheduler:()=>s});var i=r(122),n=r(156),s=function(t){function e(r,i){void 0===i&&(i=n.Scheduler.now);var s=t.call(this,r,(function(){return e.delegate&&e.delegate!==s?e.delegate.now():i()}))||this;return s.actions=[],s.active=!1,s.scheduled=void 0,s}return i.__extends(e,t),e.prototype.schedule=function(r,i,n){return void 0===i&&(i=0),e.delegate&&e.delegate!==this?e.delegate.schedule(r,i,n):t.prototype.schedule.call(this,r,i,n)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var r;this.active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(n.Scheduler)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Scheduler:()=>i});var i=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t.now=function(){return Date.now()},t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{QueueAction:()=>n});var i=r(122),n=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return i.__extends(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,i):e.flush(this)},e}(r(158).AsyncAction)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsyncAction:()=>n});var i=r(122),n=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return i.__extends(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r=!1,i=void 0;try{this.work(t)}catch(t){r=!0,i=!!t&&t||new Error(t)}if(r)return this.unsubscribe(),i},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,i=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==i&&r.splice(i,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(r(159).Action)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Action:()=>n});var i=r(122),n=function(t){function e(e,r){return t.call(this)||this}return i.__extends(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(r(127).Subscription)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsyncSubject:()=>o});var i=r(122),n=r(138),s=r(127),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return i.__extends(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),s.Subscription.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),s.Subscription.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(n.Subject)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{asap:()=>s,asapScheduler:()=>n});var i=r(163),n=new(r(162).AsapScheduler)(i.AsapAction),s=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AsapScheduler:()=>n});var i=r(122),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,i=-1,n=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++i{"use strict";r.r(e),r.d(e,{AsapAction:()=>s});var i=r(122),n=r(164),s=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return i.__extends(e,t),e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e.scheduled||(e.scheduled=n.Immediate.setImmediate(e.flush.bind(e,null))))},e.prototype.recycleAsyncId=function(e,r,i){if(void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);0===e.actions.length&&(n.Immediate.clearImmediate(r),e.scheduled=void 0)},e}(r(158).AsyncAction)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{Immediate:()=>a,TestTools:()=>h});var i=1,n=function(){return Promise.resolve()}(),s={};function o(t){return t in s&&(delete s[t],!0)}var a={setImmediate:function(t){var e=i++;return s[e]=!0,n.then((function(){return o(e)&&t()})),e},clearImmediate:function(t){o(t)}},h={pending:function(){return Object.keys(s).length}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{async:()=>s,asyncScheduler:()=>n});var i=r(158),n=new(r(155).AsyncScheduler)(i.AsyncAction),s=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{animationFrame:()=>s,animationFrameScheduler:()=>n});var i=r(168),n=new(r(167).AnimationFrameScheduler)(i.AnimationFrameAction),s=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{AnimationFrameScheduler:()=>n});var i=r(122),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,i=-1,n=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++i{"use strict";r.r(e),r.d(e,{AnimationFrameAction:()=>n});var i=r(122),n=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return i.__extends(e,t),e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,r,i){if(void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);0===e.actions.length&&(cancelAnimationFrame(r),e.scheduled=void 0)},e}(r(158).AsyncAction)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{VirtualAction:()=>o,VirtualTimeScheduler:()=>s});var i=r(122),n=r(158),s=function(t){function e(e,r){void 0===e&&(e=o),void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this,e,(function(){return i.frame}))||this;return i.maxFrames=r,i.frame=0,i.index=-1,i}return i.__extends(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,i=this.maxFrames;(e=r[0])&&e.delay<=i&&(r.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(r(155).AsyncScheduler),o=function(t){function e(e,r,i){void 0===i&&(i=e.index+=1);var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.index=i,n.active=!0,n.index=e.index=i,n}return i.__extends(e,t),e.prototype.schedule=function(r,i){if(void 0===i&&(i=0),!this.id)return t.prototype.schedule.call(this,r,i);this.active=!1;var n=new e(this.scheduler,this.work);return this.add(n),n.schedule(r,i)},e.prototype.requestAsyncId=function(t,r,i){void 0===i&&(i=0),this.delay=t.frame+i;var n=t.actions;return n.push(this),n.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,r){void 0===r&&(r=0)},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(n.AsyncAction)},(t,e,r)=>{"use strict";function i(){}r.r(e),r.d(e,{noop:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isObservable:()=>n});var i=r(119);function n(t){return!!t&&(t instanceof i.Observable||"function"==typeof t.lift&&"function"==typeof t.subscribe)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ArgumentOutOfRangeError:()=>i});var i=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{EmptyError:()=>i});var i=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{TimeoutError:()=>i});var i=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{bindCallback:()=>u});var i=r(119),n=r(160),s=r(176),o=r(132),a=r(130),h=r(147);function u(t,e,r){if(e){if(!(0,h.isScheduler)(e))return function(){for(var i=[],n=0;n{"use strict";r.r(e),r.d(e,{MapOperator:()=>o,map:()=>s});var i=r(122),n=r(121);function s(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new o(t,e))}}var o=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.project,this.thisArg))},t}(),a=function(t){function e(e,r,i){var n=t.call(this,e)||this;return n.project=r,n.count=0,n.thisArg=i||n,n}return i.__extends(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{bindNodeCallback:()=>u});var i=r(119),n=r(160),s=r(176),o=r(132),a=r(147),h=r(130);function u(t,e,r){if(e){if(!(0,a.isScheduler)(e))return function(){for(var i=[],n=0;n{"use strict";r.r(e),r.d(e,{CombineLatestOperator:()=>c,CombineLatestSubscriber:()=>f,combineLatest:()=>l});var i=r(122),n=r(147),s=r(130),o=r(188),a=r(179),h=r(149),u={};function l(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{subscribeToResult:()=>o});var i=r(180),n=r(181),s=r(119);function o(t,e,r,o,a){if(void 0===a&&(a=new i.InnerSubscriber(t,r,o)),!a.closed)return e instanceof s.Observable?e.subscribe(a):(0,n.subscribeTo)(e)(a)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{InnerSubscriber:()=>n});var i=r(122),n=function(t){function e(e,r,i){var n=t.call(this)||this;return n.parent=e,n.outerValue=r,n.outerIndex=i,n.index=0,n}return i.__extends(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(r(121).Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeTo:()=>f});var i=r(150),n=r(185),s=r(187),o=r(182),a=r(183),h=r(184),u=r(131),l=r(186),c=r(133),f=function(t){if(t&&"function"==typeof t[c.observable])return(0,o.subscribeToObservable)(t);if((0,a.isArrayLike)(t))return(0,i.subscribeToArray)(t);if((0,h.isPromise)(t))return(0,n.subscribeToPromise)(t);if(t&&"function"==typeof t[l.iterator])return(0,s.subscribeToIterable)(t);var e=(0,u.isObject)(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+e+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToObservable:()=>n});var i=r(133),n=function(t){return function(e){var r=t[i.observable]();if("function"!=typeof r.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return r.subscribe(e)}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isArrayLike:()=>i});var i=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},(t,e,r)=>{"use strict";function i(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}r.r(e),r.d(e,{isPromise:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToPromise:()=>n});var i=r(125),n=function(t){return function(e){return t.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,i.hostReportError),e}}},(t,e,r)=>{"use strict";function i(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}r.r(e),r.d(e,{$$iterator:()=>s,getSymbolIterator:()=>i,iterator:()=>n});var n=i(),s=n},(t,e,r)=>{"use strict";r.r(e),r.d(e,{subscribeToIterable:()=>n});var i=r(186),n=function(t){return function(e){for(var r=t[i.iterator]();;){var n=void 0;try{n=r.next()}catch(t){return e.error(t),e}if(n.done){e.complete();break}if(e.next(n.value),e.closed)break}return"function"==typeof r.return&&e.add((function(){r.return&&r.return()})),e}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{OuterSubscriber:()=>n});var i=r(122),n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.notifyNext=function(t,e,r,i,n){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(r(121).Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{concat:()=>s});var i=r(146),n=r(190);function s(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{concatAll:()=>n});var i=r(191);function n(){return(0,i.mergeAll)(1)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{mergeAll:()=>s});var i=r(192),n=r(135);function s(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),(0,i.mergeMap)(n.identity,t)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{MergeMapOperator:()=>h,MergeMapSubscriber:()=>u,flatMap:()=>l,mergeMap:()=>a});var i=r(122),n=r(176),s=r(193),o=r(200);function a(t,e,r){return void 0===r&&(r=Number.POSITIVE_INFINITY),"function"==typeof e?function(i){return i.pipe(a((function(r,i){return(0,s.from)(t(r,i)).pipe((0,n.map)((function(t,n){return e(r,t,i,n)})))}),r))}:("number"==typeof e&&(r=e),function(e){return e.lift(new h(t,r))})}var h=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.project,this.concurrent))},t}(),u=function(t){function e(e,r,i){void 0===i&&(i=Number.POSITIVE_INFINITY);var n=t.call(this,e)||this;return n.project=r,n.concurrent=i,n.hasCompleted=!1,n.buffer=[],n.active=0,n.index=0,n}return i.__extends(e,t),e.prototype._next=function(t){this.active0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(o.SimpleOuterSubscriber),l=a},(t,e,r)=>{"use strict";r.r(e),r.d(e,{from:()=>o});var i=r(119),n=r(181),s=r(194);function o(t,e){return e?(0,s.scheduled)(t,e):t instanceof i.Observable?t:new i.Observable((0,n.subscribeTo)(t))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduled:()=>c});var i=r(196),n=r(197),s=r(148),o=r(199),a=r(195),h=r(184),u=r(183),l=r(198);function c(t,e){if(null!=t){if((0,a.isInteropObservable)(t))return(0,i.scheduleObservable)(t,e);if((0,h.isPromise)(t))return(0,n.schedulePromise)(t,e);if((0,u.isArrayLike)(t))return(0,s.scheduleArray)(t,e);if((0,l.isIterable)(t)||"string"==typeof t)return(0,o.scheduleIterable)(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isInteropObservable:()=>n});var i=r(133);function n(t){return t&&"function"==typeof t[i.observable]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduleObservable:()=>o});var i=r(119),n=r(127),s=r(133);function o(t,e){return new i.Observable((function(r){var i=new n.Subscription;return i.add(e.schedule((function(){var n=t[s.observable]();i.add(n.subscribe({next:function(t){i.add(e.schedule((function(){return r.next(t)})))},error:function(t){i.add(e.schedule((function(){return r.error(t)})))},complete:function(){i.add(e.schedule((function(){return r.complete()})))}}))}))),i}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{schedulePromise:()=>s});var i=r(119),n=r(127);function s(t,e){return new i.Observable((function(r){var i=new n.Subscription;return i.add(e.schedule((function(){return t.then((function(t){i.add(e.schedule((function(){r.next(t),i.add(e.schedule((function(){return r.complete()})))})))}),(function(t){i.add(e.schedule((function(){return r.error(t)})))}))}))),i}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isIterable:()=>n});var i=r(186);function n(t){return t&&"function"==typeof t[i.iterator]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{scheduleIterable:()=>o});var i=r(119),n=r(127),s=r(186);function o(t,e){if(!t)throw new Error("Iterable cannot be null");return new i.Observable((function(r){var i,o=new n.Subscription;return o.add((function(){i&&"function"==typeof i.return&&i.return()})),o.add(e.schedule((function(){i=t[s.iterator](),o.add(e.schedule((function(){if(!r.closed){var t,e;try{var n=i.next();t=n.value,e=n.done}catch(t){return void r.error(t)}e?r.complete():(r.next(t),this.schedule())}})))}))),o}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ComplexInnerSubscriber:()=>h,ComplexOuterSubscriber:()=>l,SimpleInnerSubscriber:()=>a,SimpleOuterSubscriber:()=>u,innerSubscribe:()=>c});var i=r(122),n=r(121),s=r(119),o=r(181),a=function(t){function e(e){var r=t.call(this)||this;return r.parent=e,r}return i.__extends(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(n.Subscriber),h=function(t){function e(e,r,i){var n=t.call(this)||this;return n.parent=e,n.outerValue=r,n.outerIndex=i,n}return i.__extends(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(n.Subscriber),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(n.Subscriber),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.notifyNext=function(t,e,r,i){this.destination.next(e)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(n.Subscriber);function c(t,e){if(!e.closed){if(t instanceof s.Observable)return t.subscribe(e);var r;try{r=(0,o.subscribeTo)(t)(e)}catch(t){e.error(t)}return r}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{defer:()=>o});var i=r(119),n=r(193),s=r(152);function o(t){return new i.Observable((function(e){var r;try{r=t()}catch(t){return void e.error(t)}return(r?(0,n.from)(r):(0,s.empty)()).subscribe(e)}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{forkJoin:()=>h});var i=r(119),n=r(130),s=r(176),o=r(131),a=r(193);function h(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{fromEvent:()=>a});var i=r(119),n=r(130),s=r(128),o=r(176);function a(t,e,r,u){return(0,s.isFunction)(r)&&(u=r,r=void 0),u?a(t,e,r).pipe((0,o.map)((function(t){return(0,n.isArray)(t)?u.apply(void 0,t):u(t)}))):new i.Observable((function(i){h(t,e,(function(t){arguments.length>1?i.next(Array.prototype.slice.call(arguments)):i.next(t)}),i,r)}))}function h(t,e,r,i,n){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,r,n),s=function(){return o.removeEventListener(e,r,n)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,r),s=function(){return a.off(e,r)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var u=t;t.addListener(e,r),s=function(){return u.removeListener(e,r)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var l=0,c=t.length;l{"use strict";r.r(e),r.d(e,{fromEventPattern:()=>a});var i=r(119),n=r(130),s=r(128),o=r(176);function a(t,e,r){return r?a(t,e).pipe((0,o.map)((function(t){return(0,n.isArray)(t)?r.apply(void 0,t):r(t)}))):new i.Observable((function(r){var i,n=function(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{generate:()=>o});var i=r(119),n=r(135),s=r(147);function o(t,e,r,o,h){var u,l;if(1==arguments.length){var c=t;l=c.initialState,e=c.condition,r=c.iterate,u=c.resultSelector||n.identity,h=c.scheduler}else void 0===o||(0,s.isScheduler)(o)?(l=t,u=n.identity,h=o):(l=t,u=o);return new i.Observable((function(t){var i=l;if(h)return h.schedule(a,0,{subscriber:t,iterate:r,condition:e,resultSelector:u,state:i});for(;;){if(e){var n=void 0;try{n=e(i)}catch(e){return void t.error(e)}if(!n){t.complete();break}}var s=void 0;try{s=u(i)}catch(e){return void t.error(e)}if(t.next(s),t.closed)break;try{i=r(i)}catch(e){return void t.error(e)}}}))}function a(t){var e=t.subscriber,r=t.condition;if(!e.closed){if(t.needIterate)try{t.state=t.iterate(t.state)}catch(t){return void e.error(t)}else t.needIterate=!0;if(r){var i=void 0;try{i=r(t.state)}catch(t){return void e.error(t)}if(!i)return void e.complete();if(e.closed)return}var n;try{n=t.resultSelector(t.state)}catch(t){return void e.error(t)}if(!e.closed&&(e.next(n),!e.closed))return this.schedule(t)}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{iif:()=>s});var i=r(201),n=r(152);function s(t,e,r){return void 0===e&&(e=n.EMPTY),void 0===r&&(r=n.EMPTY),(0,i.defer)((function(){return t()?e:r}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{interval:()=>o});var i=r(119),n=r(165),s=r(208);function o(t,e){return void 0===t&&(t=0),void 0===e&&(e=n.async),(!(0,s.isNumeric)(t)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=n.async),new i.Observable((function(r){return r.add(e.schedule(a,t,{subscriber:r,counter:0,period:t})),r}))}function a(t){var e=t.subscriber,r=t.counter,i=t.period;e.next(r),this.schedule({subscriber:e,counter:r+1,period:i},i)}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{isNumeric:()=>n});var i=r(130);function n(t){return!(0,i.isArray)(t)&&t-parseFloat(t)+1>=0}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{merge:()=>a});var i=r(119),n=r(147),s=r(191),o=r(149);function a(){for(var t=[],e=0;e1&&"number"==typeof t[t.length-1]&&(r=t.pop())):"number"==typeof h&&(r=t.pop()),null===a&&1===t.length&&t[0]instanceof i.Observable?t[0]:(0,s.mergeAll)(r)((0,o.fromArray)(t,a))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{NEVER:()=>s,never:()=>o});var i=r(119),n=r(170),s=new i.Observable(n.noop);function o(){return s}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{onErrorResumeNext:()=>a});var i=r(119),n=r(193),s=r(130),o=r(152);function a(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{dispatch:()=>o,pairs:()=>s});var i=r(119),n=r(127);function s(t,e){return e?new i.Observable((function(r){var i=Object.keys(t),s=new n.Subscription;return s.add(e.schedule(o,0,{keys:i,index:0,subscriber:r,subscription:s,obj:t})),s})):new i.Observable((function(e){for(var r=Object.keys(t),i=0;i{"use strict";r.r(e),r.d(e,{partition:()=>a});var i=r(215),n=r(181),s=r(214),o=r(119);function a(t,e,r){return[(0,s.filter)(e,r)(new o.Observable((0,n.subscribeTo)(t))),(0,s.filter)((0,i.not)(e,r))(new o.Observable((0,n.subscribeTo)(t)))]}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{filter:()=>s});var i=r(122),n=r(121);function s(t,e){return function(r){return r.lift(new o(t,e))}}var o=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.predicate,this.thisArg))},t}(),a=function(t){function e(e,r,i){var n=t.call(this,e)||this;return n.predicate=r,n.thisArg=i,n.count=0,n}return i.__extends(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(n.Subscriber)},(t,e,r)=>{"use strict";function i(t,e){function r(){return!r.pred.apply(r.thisArg,arguments)}return r.pred=t,r.thisArg=e,r}r.r(e),r.d(e,{not:()=>i})},(t,e,r)=>{"use strict";r.r(e),r.d(e,{RaceOperator:()=>u,RaceSubscriber:()=>l,race:()=>h});var i=r(122),n=r(130),s=r(149),o=r(188),a=r(179);function h(){for(var t=[],e=0;e{"use strict";r.r(e),r.d(e,{dispatch:()=>s,range:()=>n});var i=r(119);function n(t,e,r){return void 0===t&&(t=0),new i.Observable((function(i){void 0===e&&(e=t,t=0);var n=0,o=t;if(r)return r.schedule(s,0,{index:n,count:e,start:t,subscriber:i});for(;;){if(n++>=e){i.complete();break}if(i.next(o++),i.closed)break}}))}function s(t){var e=t.start,r=t.index,i=t.count,n=t.subscriber;r>=i?n.complete():(n.next(e),n.closed||(t.index=r+1,t.start=e+1,this.schedule(t)))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{timer:()=>a});var i=r(119),n=r(165),s=r(208),o=r(147);function a(t,e,r){void 0===t&&(t=0);var a=-1;return(0,s.isNumeric)(e)?a=Number(e)<1?1:Number(e):(0,o.isScheduler)(e)&&(r=e),(0,o.isScheduler)(r)||(r=n.async),new i.Observable((function(e){var i=(0,s.isNumeric)(t)?t:+t-r.now();return r.schedule(h,i,{index:0,period:a,subscriber:e})}))}function h(t){var e=t.index,r=t.period,i=t.subscriber;if(i.next(e),!i.closed){if(-1===r)return i.complete();t.index=e+1,this.schedule(t,r)}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{using:()=>o});var i=r(119),n=r(193),s=r(152);function o(t,e){return new i.Observable((function(r){var i,o;try{i=t()}catch(t){return void r.error(t)}try{o=e(i)}catch(t){return void r.error(t)}var a=(o?(0,n.from)(o):s.EMPTY).subscribe(r);return function(){a.unsubscribe(),i&&i.unsubscribe()}}))}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ZipOperator:()=>l,ZipSubscriber:()=>c,zip:()=>u});var i=r(122),n=r(149),s=r(130),o=r(121),a=r(186),h=r(200);function u(){for(var t=[],e=0;ethis.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),p=function(t){function e(e,r,i){var n=t.call(this,e)||this;return n.parent=r,n.observable=i,n.stillUnsubscribed=!0,n.buffer=[],n.isComplete=!1,n}return i.__extends(e,t),e.prototype[a.iterator]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return(0,h.innerSubscribe)(this.observable,new h.SimpleInnerSubscriber(this))},e}(h.SimpleOuterSubscriber)},(t,e,r)=>{"use strict";var i=r(9).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.receiveAPDU=void 0;var n=r(63),s=r(118),o=r(113);e.receiveAPDU=t=>s.Observable.create((e=>{let r=0,s=0,a=i.alloc(0);const h=t.subscribe({complete:()=>{e.error(new n.DisconnectedDevice),h.unsubscribe()},error:t=>{(0,o.log)("ble-error","in receiveAPDU "+String(t)),e.error(t),h.unsubscribe()},next:t=>{const o=t.readUInt8(0),u=t.readUInt16BE(1);let l=t.slice(3);5===o?r===u?(0===u&&(s=l.readUInt16BE(0),l=l.slice(2)),r++,a=i.concat([a,l]),a.length>s?e.error(new n.TransportError("BLE: received too much data. discontinued chunk. Received "+a.length+" but expected "+s,"BLETooMuchData")):a.length===s&&(e.next(a),e.complete(),h.unsubscribe())):e.error(new n.TransportError("BLE: Invalid sequence number. discontinued chunk. Received "+u+" but expected "+r,"InvalidSequence")):e.error(new n.TransportError("Invalid tag "+o.toString(16),"InvalidTag"))}});return()=>{h.unsubscribe()}}))},(t,e,r)=>{"use strict";r.r(e),r.d(e,{monitorCharacteristic:()=>o});var i=r(119),n=r(113),s=r(9).Buffer;const o=t=>i.Observable.create((e=>{function r(t){const r=t.target;r.value&&e.next(s.from(r.value.buffer))}return(0,n.log)("ble-verbose","start monitor "+t.uuid),t.startNotifications().then((()=>{t.addEventListener("characteristicvaluechanged",r)})),()=>{(0,n.log)("ble-verbose","end monitor "+t.uuid),t.stopNotifications()}}))},(t,e,r)=>{"use strict";r.r(e),r.d(e,{tap:()=>a});var i=r(122),n=r(121),s=r(170),o=r(128);function a(t,e,r){return function(i){return i.lift(new h(t,e,r))}}var h=function(){function t(t,e,r){this.nextOrObserver=t,this.error=e,this.complete=r}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.nextOrObserver,this.error,this.complete))},t}(),u=function(t){function e(e,r,i,n){var a=t.call(this,e)||this;return a._tapNext=s.noop,a._tapError=s.noop,a._tapComplete=s.noop,a._tapError=i||s.noop,a._tapComplete=n||s.noop,(0,o.isFunction)(r)?(a._context=a,a._tapNext=r):r&&(a._context=r,a._tapNext=r.next||s.noop,a._tapError=r.error||s.noop,a._tapComplete=r.complete||s.noop),a}return i.__extends(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{share:()=>a});var i=r(225),n=r(137),s=r(138);function o(){return new s.Subject}function a(){return function(t){return(0,n.refCount)()((0,i.multicast)(o)(t))}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{MulticastOperator:()=>s,multicast:()=>n});var i=r(136);function n(t,e){return function(r){var n;if(n="function"==typeof t?t:function(){return t},"function"==typeof e)return r.lift(new s(n,e));var o=Object.create(r,i.connectableObservableDescriptor);return o.source=r,o.subjectFactory=n,o}}var s=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var r=this.selector,i=this.subjectFactory(),n=r(i).subscribe(t);return n.add(e.subscribe(i)),n},t}()},(t,e,r)=>{"use strict";r.r(e),r.d(e,{first:()=>u});var i=r(173),n=r(214),s=r(227),o=r(228),a=r(229),h=r(135);function u(t,e){var r=arguments.length>=2;return function(u){return u.pipe(t?(0,n.filter)((function(e,r){return t(e,r,u)})):h.identity,(0,s.take)(1),r?(0,o.defaultIfEmpty)(e):(0,a.throwIfEmpty)((function(){return new i.EmptyError})))}}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{take:()=>a});var i=r(122),n=r(121),s=r(172),o=r(152);function a(t){return function(e){return 0===t?(0,o.empty)():e.lift(new h(t))}}var h=function(){function t(t){if(this.total=t,this.total<0)throw new s.ArgumentOutOfRangeError}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.total))},t}(),u=function(t){function e(e,r){var i=t.call(this,e)||this;return i.total=r,i.count=0,i}return i.__extends(e,t),e.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{defaultIfEmpty:()=>s});var i=r(122),n=r(121);function s(t){return void 0===t&&(t=null),function(e){return e.lift(new o(t))}}var o=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.defaultValue))},t}(),a=function(t){function e(e,r){var i=t.call(this,e)||this;return i.defaultValue=r,i.isEmpty=!0,i}return i.__extends(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(n.Subscriber)},(t,e,r)=>{"use strict";r.r(e),r.d(e,{throwIfEmpty:()=>o});var i=r(122),n=r(173),s=r(121);function o(t){return void 0===t&&(t=u),function(e){return e.lift(new a(t))}}var a=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new h(t,this.errorFactory))},t}(),h=function(t){function e(e,r){var i=t.call(this,e)||this;return i.errorFactory=r,i.hasValue=!1,i}return i.__extends(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(s.Subscriber);function u(){return new n.EmptyError}},(t,e,r)=>{"use strict";r.r(e),r.d(e,{ignoreElements:()=>s});var i=r(122),n=r(121);function s(){return function(t){return t.lift(new o)}}var o=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new a(t))},t}(),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype._next=function(t){},e}(n.Subscriber)},(t,e,r)=>{const i=r(232).default,{DnsCollection:n}=r(234),{DnsItem:s}=r(235);t.exports.default={Dns:i,DnsCollection:n,DnsItem:s}},(t,e,r)=>{const{Cell:i}=r(21),{Address:n,bytesToHex:s}=r(1),{DNS_CATEGORY_NEXT_RESOLVER:o,DNS_CATEGORY_SITE:a,DNS_CATEGORY_WALLET:h,DNS_CATEGORY_STORAGE:u,createSmartContractAddressRecord:l,createAdnlAddressRecord:c,createStorageBagIdRecord:f,createNextResolverRecord:d,parseSmartContractAddressRecord:p,parseAdnlAddressRecord:m,parseStorageBagIdRecord:g,parseSiteRecord:y,parseNextResolverRecord:w,dnsResolve:v}=r(233);class b{constructor(t){this.provider=t}async getRootDnsAddress(){const t=(await this.provider.getConfigParam(4)).bits.array;if(32!==t.length)throw new Error("Invalid ConfigParam 4 length "+t.length);const e=s(t);return new n("-1:"+e)}async resolve(t,e,r){const i=await this.getRootDnsAddress();return v(this.provider,i.toString(),t,e,r)}getWalletAddress(t){return this.resolve(t,h)}getSiteAddress(t){return this.resolve(t,a)}}b.resolve=v,b.createSmartContractAddressRecord=l,b.createAdnlAddressRecord=c,b.createStorageBagIdRecord=f,b.createNextResolverRecord=d,b.parseNextResolverRecord=w,b.parseAdnlAddressRecord=m,b.parseStorageBagIdRecord=g,b.parseSiteRecord=y,b.parseSmartContractAddressRecord=p,b.DNS_CATEGORY_NEXT_RESOLVER=o,b.DNS_CATEGORY_WALLET=h,b.DNS_CATEGORY_SITE=a,b.DNS_CATEGORY_STORAGE=u,t.exports.default=b},(t,e,r)=>{const{parseAddress:i}=r(41),{AdnlAddress:n,StorageBagId:s,BN:o,sha256:a,bytesToHex:h,bytesToBase64:u}=r(1),{Cell:l}=r(21),c="dns_next_resolver",f="wallet",d="site",p="storage",m=async t=>{if(!t)return new o(0);const e=(new TextEncoder).encode(t),r=new Uint8Array(await a(e));return new o(h(r),16)},g=(t,e,r)=>{if(t.bits.array[0]!==e||t.bits.array[1]!==r)throw new Error("Invalid dns record value prefix");return t.bits.array=t.bits.array.slice(2),i(t)},y=t=>g(t,159,211),w=t=>g(t,186,147),v=t=>{if(173!==t.bits.array[0]||1!==t.bits.array[1])throw new Error("Invalid dns record value prefix");const e=t.bits.array.slice(2,34);return new n(e)},b=t=>{if(116!==t.bits.array[0]||115!==t.bits.array[1])throw new Error("Invalid dns record value prefix");const e=t.bits.array.slice(2,34);return new s(e)},E=t=>t?173===t.bits.array[0]||1===t.bits.array[1]?v(t):b(t):null,A=async(t,e,r,i,n)=>{const s=8*r.length,o=new l;o.bits.writeBytes(r);const a=await m(i),h=await t.call2(e,"dnsresolve",[["tvm.Slice",u(await o.toBoc(!1))],["num",a.toString()]]);if(2!==h.length)throw new Error("Invalid dnsresolve response");const g=h[0].toNumber();let v=h[1];if(v instanceof Array&&0===v.length&&(v=null),v&&!v.bits)throw new Error("Invalid dnsresolve response");if(0===g)return null;if(g%8!=0)throw new Error("domain split not at a component boundary");if(g>s)throw new Error("invalid response "+g+"/"+s);if(g===s)return i===c?v?w(v):null:i===f?v?y(v):null:i===d?v?E(v):null:i===p?v?b(v):null:v;if(v){const e=w(v);return n?i===c?e:null:await A(t,e.toString(),r.slice(g/8),i,!1)}return null},C=t=>{if(!t||!t.length)throw new Error("empty domain");if("."===t)return new Uint8Array([0]);t=t.toLowerCase();for(let e=0;e{if(!t.length)throw new Error("domain name cannot have an empty component")}));let r=e.reverse().join("\0")+"\0";return r.length<126&&(r="\0"+r),(new TextEncoder).encode(r)};t.exports={DNS_CATEGORY_NEXT_RESOLVER:c,DNS_CATEGORY_SITE:d,DNS_CATEGORY_WALLET:f,DNS_CATEGORY_STORAGE:p,categoryToBN:m,domainToBytes:C,createSmartContractAddressRecord:t=>{const e=new l;return e.bits.writeUint(40915,16),e.bits.writeAddress(t),e.bits.writeUint(0,8),e},createAdnlAddressRecord:t=>{const e=new l;return e.bits.writeUint(44289,16),e.bits.writeBytes(t.bytes),e.bits.writeUint(0,8),e},createNextResolverRecord:t=>{const e=new l;return e.bits.writeUint(47763,16),e.bits.writeAddress(t),e},parseSmartContractAddressRecord:y,parseAdnlAddressRecord:v,parseStorageBagIdRecord:b,parseSiteRecord:E,parseNextResolverRecord:w,createStorageBagIdRecord:t=>{const e=new l;return e.bits.writeUint(29811,16),e.bits.writeBytes(t.bytes),e},dnsResolve:async(t,e,r,i,n)=>{const s=C(r);return A(t,e,s,i,n)}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{Address:s}=r(1),{parseAddress:o}=r(41),{dnsResolve:a}=r(233),{parseOffchainUriCell:h}=r(41);t.exports={DnsCollection:class extends i{constructor(t,e){if(e.wc=0,e.code=e.code,super(t,e),!e.collectionContent&&!e.address)throw new Error("required collectionContent cell");this.methods.getCollectionData=this.getCollectionData.bind(this),this.methods.getNftItemAddressByIndex=this.getNftItemAddressByIndex.bind(this),this.methods.getNftItemContent=this.getNftItemContent.bind(this),this.methods.resolve=this.resolve.bind(this)}createDataCell(){const t=new n;return t.refs[0]=this.options.collectionContent,t.refs[1]=n.oneFromBoc(this.options.dnsItemCodeHex),t}async getCollectionData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_collection_data"),r=e[0].toNumber(),i=e[1];return{collectionContentUri:h(i),collectionContent:i,ownerAddress:null,nextItemIndex:r}}async getNftItemContent(t){return await t.getData()}async getNftItemAddressByIndex(t){const e=await this.getAddress(),r=await this.provider.call2(e.toString(),"get_nft_address_by_index",[["num",t.toString()]]);return o(r)}async resolve(t,e,r){const i=await this.getAddress();return a(this.provider,i.toString(),t,e,r)}}}},(t,e,r)=>{const{Contract:i}=r(26),{Cell:n}=r(21),{Address:s,BN:o}=r(1),{parseAddress:a}=r(41),{dnsResolve:h,categoryToBN:u}=r(233);class l extends i{constructor(t,e){e.wc=0,e.code=e.code,super(t,e),this.methods.getData=this.getData.bind(this),this.methods.getDomain=this.getDomain.bind(this),this.methods.getAuctionInfo=this.getAuctionInfo.bind(this),this.methods.getLastFillUpTime=this.getLastFillUpTime.bind(this),this.methods.resolve=this.resolve.bind(this)}createDataCell(){const t=new n;return t.bits.writeUint(this.options.index,256),t.bits.writeAddress(this.options.collectionAddress),t}async getData(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_nft_data"),r=-1===e[0].toNumber();return{isInitialized:r,index:e[1],collectionAddress:a(e[2]),ownerAddress:r?a(e[3]):null,contentCell:e[4]}}async createTransferBody(t){const e=new n;return e.bits.writeUint(1607220500,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeAddress(t.newOwnerAddress),e.bits.writeAddress(t.responseAddress),e.bits.writeBit(!1),e.bits.writeCoins(t.forwardAmount||new o(0)),e.bits.writeBit(!1),t.forwardPayload&&e.bits.writeBytes(t.forwardPayload),e}createGetStaticDataBody(t){const e=new n;return e.bits.writeUint(801842850,32),e.bits.writeUint(t.queryId||0,64),e}async getDomain(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_domain");return(new TextDecoder).decode(e.bits.array.buffer)}async getAuctionInfo(){const t=await this.getAddress(),e=await this.provider.call2(t.toString(),"get_auction_info");return{maxBidAddress:a(e[0]),maxBidAmount:e[1],auctionEndTime:e[2].toNumber()}}async getLastFillUpTime(){const t=await this.getAddress();return(await this.provider.call2(t.toString(),"get_last_fill_up_time")).toNumber()}async resolve(t,e,r){const i=await this.getAddress();return h(this.provider,i.toString(),t,e,r)}}l.createChangeContentEntryBody=async t=>{const e=new n;return e.bits.writeUint(1320284409,32),e.bits.writeUint(t.queryId||0,64),e.bits.writeUint(await u(t.category),256),t.value&&(e.refs[0]=t.value),e},t.exports={DnsItem:l}}],e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.loaded=!0,s.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),r(0)})()})); \ No newline at end of file diff --git a/dist/types/contract/token/ft/jetton-wallet.d.ts b/dist/types/contract/token/ft/jetton-wallet.d.ts index d9869acb..00aab4bd 100644 --- a/dist/types/contract/token/ft/jetton-wallet.d.ts +++ b/dist/types/contract/token/ft/jetton-wallet.d.ts @@ -19,8 +19,8 @@ export interface TransferBodyParams { tokenAmount: BN; toAddress: Address; responseAddress: Address; - forwardAmount: BN; - forwardPayload: Uint8Array; + forwardAmount?: BN; + forwardPayload?: Uint8Array | Cell; } export interface BurnBodyParams { queryId?: number; diff --git a/dist/types/contract/token/nft/nft-item.d.ts b/dist/types/contract/token/nft/nft-item.d.ts index b2554405..3f34b52f 100644 --- a/dist/types/contract/token/nft/nft-item.d.ts +++ b/dist/types/contract/token/nft/nft-item.d.ts @@ -22,7 +22,7 @@ export interface CreateTransferBodyParams { responseAddress: Address; queryId?: number; forwardAmount?: BN; - forwardPayload?: Uint8Array; + forwardPayload?: Uint8Array | Cell; } export interface CreateGetStaticDataBodyParams { queryId?: number; diff --git a/dist/types/contract/wallet/v2/wallet-v2-contract-base.d.ts b/dist/types/contract/wallet/v2/wallet-v2-contract-base.d.ts index 3d570188..92851ce9 100644 --- a/dist/types/contract/wallet/v2/wallet-v2-contract-base.d.ts +++ b/dist/types/contract/wallet/v2/wallet-v2-contract-base.d.ts @@ -1,5 +1,5 @@ import { Cell } from '../../../boc/cell'; import { WalletContract } from '../wallet-contract'; export declare class WalletV2ContractBase extends WalletContract { - protected createSigningMessage(seqno?: number): Cell; + protected createSigningMessage(seqno?: number, expireAt?: number): Cell; } diff --git a/dist/types/contract/wallet/v3/wallet-v3-contract-base.d.ts b/dist/types/contract/wallet/v3/wallet-v3-contract-base.d.ts index 9406a12d..16ddf037 100644 --- a/dist/types/contract/wallet/v3/wallet-v3-contract-base.d.ts +++ b/dist/types/contract/wallet/v3/wallet-v3-contract-base.d.ts @@ -4,6 +4,6 @@ export interface WalletV3ContractOptions extends WalletContractOptions { walletId?: number; } export declare class WalletV3ContractBase extends WalletContract { - protected createSigningMessage(seqno?: number): Cell; + protected createSigningMessage(seqno?: number, expireAt?: number): Cell; protected createDataCell(): Cell; } diff --git a/dist/types/contract/wallet/v4/wallet-v4-contract-base.d.ts b/dist/types/contract/wallet/v4/wallet-v4-contract-base.d.ts index b4cebc3b..3bb2686d 100644 --- a/dist/types/contract/wallet/v4/wallet-v4-contract-base.d.ts +++ b/dist/types/contract/wallet/v4/wallet-v4-contract-base.d.ts @@ -9,6 +9,6 @@ export interface WalletV4ContractMethods extends WalletContractMethods { } export declare class WalletV4ContractBase extends WalletContract { getPublicKey(): Promise; - protected createSigningMessage(seqno?: number, withoutOp?: boolean): Cell; + protected createSigningMessage(seqno?: number, expireAt?: number, withoutOp?: boolean): Cell; protected createDataCell(): Cell; } diff --git a/dist/types/contract/wallet/v4/wallet-v4-contract-r2.d.ts b/dist/types/contract/wallet/v4/wallet-v4-contract-r2.d.ts index c6bcc20c..d7773ba7 100644 --- a/dist/types/contract/wallet/v4/wallet-v4-contract-r2.d.ts +++ b/dist/types/contract/wallet/v4/wallet-v4-contract-r2.d.ts @@ -20,6 +20,7 @@ export interface DeployAndInstallPluginParams { amount: BN; stateInit: Cell; body: Cell; + expireAt?: number; } export interface SetPluginParams { secretKey: Uint8Array; @@ -27,6 +28,7 @@ export interface SetPluginParams { pluginAddress: AddressType; amount?: BN; queryId?: number; + expireAt?: number; } export declare class WalletV4ContractR2 extends WalletV4ContractBase { constructor(provider: HttpProvider, options: WalletV4ContractOptions); diff --git a/dist/types/contract/wallet/wallet-contract.d.ts b/dist/types/contract/wallet/wallet-contract.d.ts index 3f5d293b..1e88b3c1 100644 --- a/dist/types/contract/wallet/wallet-contract.d.ts +++ b/dist/types/contract/wallet/wallet-contract.d.ts @@ -9,11 +9,12 @@ export interface WalletContractOptions extends ContractOptions { export interface TransferMethodParams { secretKey: Uint8Array; toAddress: AddressType; - amount: (BN | number); + amount: (BN | string); seqno: number; payload?: (string | Uint8Array | Cell); sendMode?: number; stateInit?: Cell; + expireAt?: number; } export interface WalletContractMethods extends ContractMethods { transfer: TransferMethod; @@ -54,7 +55,7 @@ export declare class WalletContract; + secretKey: Uint8Array, address: AddressType, nanocoins: (BN | string), seqno: number, payload?: (string | Uint8Array | Cell), sendMode?: number, dummySignature?: boolean, stateInit?: Cell, expireAt?: number): Promise; /** * Returns cell that contains wallet data. */ diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts index be6da5e3..b0d61b56 100644 --- a/dist/types/index.d.ts +++ b/dist/types/index.d.ts @@ -112,8 +112,8 @@ export default class TonWeb { formatTransferUrl: typeof formatTransferUrl; parseTransferUrl: typeof parseTransferUrl; sha256(bytes: Uint8Array): Promise; - toNano(amount: string | number | BN): BN; - fromNano(amount: string | number | BN): string; + toNano(amount: string | BN): BN; + fromNano(amount: string | BN): string; bytesToHex(buffer: Uint8Array): string; hexToBytes(hex: string): Uint8Array; stringToBytes(str: string, size?: number): Uint8Array; diff --git a/dist/types/providers/http-provider.d.ts b/dist/types/providers/http-provider.d.ts index dd836927..9d673040 100644 --- a/dist/types/providers/http-provider.d.ts +++ b/dist/types/providers/http-provider.d.ts @@ -74,7 +74,7 @@ export declare class HttpProvider { * * {@link https://toncenter.com/api/v2/#/accounts/get_transactions_getTransactions_get} */ - getTransactions(address: string, limit?: number, lt?: number, hash?: string, to_lt?: number, archival?: any): Promise; + getTransactions(address: string, limit?: number, lt?: number | string, hash?: string, to_lt?: number | string, archival?: any): Promise; /** * Use this method to get balance (in nanograms) * of a given address. @@ -157,7 +157,7 @@ export declare class HttpProvider { * * {@link https://toncenter.com/api/v2/#/blocks/get_block_transactions_getBlockTransactions_get} */ - getBlockTransactions(workchain: number, shardId: string, shardBlockNumber: number): Promise; + getBlockTransactions(workchain: number, shardId: string, shardBlockNumber: number, limit?: number, afterLt?: number | string, addressHash?: string): Promise; /** * Returns transactions hashes included * in this masterchain block. diff --git a/dist/types/utils/common.d.ts b/dist/types/utils/common.d.ts index 884a315f..c24a17e0 100644 --- a/dist/types/utils/common.d.ts +++ b/dist/types/utils/common.d.ts @@ -3,11 +3,11 @@ export declare function sha256(bytes: Uint8Array): Promise; /** * Converts the specified amount from coins to nanocoins. */ -export declare function toNano(amount: (number | BN | string)): BN; +export declare function toNano(amount: (BN | string)): BN; /** * Converts the specified amount from nanocoins to coins. */ -export declare function fromNano(amount: (number | BN | string)): string; +export declare function fromNano(amount: (BN | string)): string; /** * Converts the specified bytes array to hex string * using lookup table. diff --git a/package-lock.json b/package-lock.json index fbbeb2f1..c6cfed17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "tonweb", - "version": "0.0.35", + "version": "0.0.66", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tonweb", - "version": "0.0.35", - "license": "GPL-3.0", + "version": "0.0.60", + "license": "MIT", "dependencies": { "@ledgerhq/hw-transport-web-ble": "5.48.0", "@ledgerhq/hw-transport-webhid": "5.48.0", @@ -22,7 +22,7 @@ "@sinonjs/fake-timers": "^9.1.1", "buffer": "6.0.3", "webpack": "5.70.0", - "webpack-cli": "3.3.12" + "webpack-cli": "4.10.0" } }, "node_modules/@babel/code-frame": { @@ -2186,6 +2186,15 @@ "node": ">=0.1.95" } }, + "node_modules/@discoveryjs/json-ext": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", + "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/@expo/config": { "version": "6.0.6", "resolved": "https://registry.npmjs.org/@expo/config/-/config-6.0.6.tgz", @@ -4163,6 +4172,42 @@ "@xtuc/long": "4.2.2" } }, + "node_modules/@webpack-cli/configtest": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz", + "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==", + "dev": true, + "peerDependencies": { + "webpack": "4.x.x || 5.x.x", + "webpack-cli": "4.x.x" + } + }, + "node_modules/@webpack-cli/info": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz", + "integrity": "sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==", + "dev": true, + "dependencies": { + "envinfo": "^7.7.3" + }, + "peerDependencies": { + "webpack-cli": "4.x.x" + } + }, + "node_modules/@webpack-cli/serve": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz", + "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==", + "dev": true, + "peerDependencies": { + "webpack-cli": "4.x.x" + }, + "peerDependenciesMeta": { + "webpack-dev-server": { + "optional": true + } + } + }, "node_modules/@xmldom/xmldom": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.5.tgz", @@ -4288,7 +4333,8 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=6" } @@ -4297,7 +4343,8 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -4357,7 +4404,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4366,7 +4414,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4375,7 +4424,8 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4405,7 +4455,8 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4437,7 +4488,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4502,7 +4554,8 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "devOptional": true, + "optional": true, + "peer": true, "bin": { "atob": "bin/atob.js" }, @@ -4694,7 +4747,8 @@ "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -4717,7 +4771,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.0" }, @@ -4729,7 +4784,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -4741,7 +4797,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -4753,7 +4810,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -4793,15 +4851,6 @@ "node": ">=0.6" } }, - "node_modules/big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/blueimp-md5": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", @@ -4852,7 +4901,8 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -4873,7 +4923,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -4983,7 +5034,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -5053,7 +5105,8 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=6" } @@ -5085,7 +5138,8 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -5099,7 +5153,8 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -5130,7 +5185,8 @@ "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -5145,7 +5201,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -5179,17 +5236,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cliui": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", - "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", - "dev": true, - "dependencies": { - "string-width": "^3.1.0", - "strip-ansi": "^5.2.0", - "wrap-ansi": "^5.1.0" - } - }, "node_modules/clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", @@ -5204,8 +5250,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", - "optional": true, - "peer": true, + "devOptional": true, "dependencies": { "is-plain-object": "^2.0.4", "kind-of": "^6.0.2", @@ -5219,7 +5264,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -5232,7 +5278,8 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "color-name": "1.1.3" } @@ -5241,7 +5288,8 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/colorette": { "version": "1.4.0", @@ -5290,7 +5338,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/compressible": { "version": "2.0.18", @@ -5361,7 +5410,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -5403,7 +5453,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/cosmiconfig": { "version": "5.2.1", @@ -5425,7 +5476,8 @@ "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "nice-try": "^1.0.4", "path-key": "^2.0.1", @@ -5448,7 +5500,8 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "ms": "2.0.0" } @@ -5457,7 +5510,8 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -5466,7 +5520,8 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10" } @@ -5508,7 +5563,8 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -5521,7 +5577,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -5533,7 +5590,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -5545,7 +5603,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -5579,15 +5638,6 @@ "optional": true, "peer": true }, - "node_modules/detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -5601,21 +5651,6 @@ "integrity": "sha512-AOJ3cAE0TWxz4fQ9zkND5hWrQg16nsZKVz9INOot1oV//u4wWu5xrj9CQMmPTYskkZRunSRc9sAnr4EkexXokg==", "devOptional": true }, - "node_modules/emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "node_modules/emojis-list": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -5646,39 +5681,11 @@ "once": "^1.4.0" } }, - "node_modules/enhanced-resolve": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz", - "integrity": "sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "memory-fs": "^0.5.0", - "tapable": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/enhanced-resolve/node_modules/memory-fs": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", - "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", - "dev": true, - "dependencies": { - "errno": "^0.1.3", - "readable-stream": "^2.0.1" - }, - "engines": { - "node": ">=4.3.0 <5.0.0 || >=5.10" - } - }, "node_modules/envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", - "optional": true, - "peer": true, + "devOptional": true, "bin": { "envinfo": "dist/cli.js" }, @@ -5686,18 +5693,6 @@ "node": ">=4" } }, - "node_modules/errno": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", - "dev": true, - "dependencies": { - "prr": "~1.0.1" - }, - "bin": { - "errno": "cli.js" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -5758,7 +5753,8 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.8.0" } @@ -5906,7 +5902,8 @@ "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -5924,7 +5921,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -5936,7 +5934,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -5944,18 +5943,6 @@ "node": ">=0.10.0" } }, - "node_modules/expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "dependencies": { - "homedir-polyfill": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/expo": { "version": "44.0.5", "resolved": "https://registry.npmjs.org/expo/-/expo-44.0.5.tgz", @@ -6501,7 +6488,8 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -6514,7 +6502,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-plain-object": "^2.0.4" }, @@ -6526,7 +6515,8 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -6545,7 +6535,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.0" }, @@ -6557,7 +6548,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -6569,7 +6561,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -6581,7 +6574,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -6593,7 +6587,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -6701,6 +6696,15 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, + "node_modules/fastest-levenshtein": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", + "dev": true, + "engines": { + "node": ">= 4.9.1" + } + }, "node_modules/fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -6750,7 +6754,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -6765,7 +6770,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -6835,7 +6841,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "locate-path": "^3.0.0" }, @@ -6843,21 +6850,6 @@ "node": ">=6" } }, - "node_modules/findup-sync": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", - "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", - "dev": true, - "dependencies": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/flow-parser": { "version": "0.121.0", "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.121.0.tgz", @@ -6879,7 +6871,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -6888,7 +6881,8 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "map-cache": "^0.2.2" }, @@ -6933,8 +6927,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "optional": true, - "peer": true + "devOptional": true }, "node_modules/gensync": { "version": "1.0.0-beta.2", @@ -6950,7 +6943,8 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": "6.* || 8.* || >= 10.*" } @@ -6987,7 +6981,8 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -7029,48 +7024,6 @@ "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", "dev": true }, - "node_modules/global-modules": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz", - "integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==", - "dev": true, - "dependencies": { - "global-prefix": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/global-modules/node_modules/global-prefix": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", - "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", - "dev": true, - "dependencies": { - "ini": "^1.3.5", - "kind-of": "^6.0.2", - "which": "^1.3.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "dependencies": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -7091,8 +7044,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "optional": true, - "peer": true, + "devOptional": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -7104,7 +7056,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=4" } @@ -7126,7 +7079,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -7140,7 +7094,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -7153,7 +7108,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -7198,18 +7154,6 @@ "node": ">= 8" } }, - "node_modules/homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, - "dependencies": { - "parse-passwd": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", @@ -7288,19 +7232,80 @@ } }, "node_modules/import-local": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", - "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", "dev": true, "dependencies": { - "pkg-dir": "^3.0.0", - "resolve-cwd": "^2.0.0" + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" }, "bin": { "import-local-fixture": "fixtures/cli.js" }, "engines": { - "node": ">=6" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-local/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/import-local/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/import-local/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/import-local/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/import-local/node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, "node_modules/imurmurhash": { @@ -7328,22 +7333,13 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "devOptional": true - }, - "node_modules/ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "deprecated": "Please update to ini >=1.3.6 to avoid a prototype pollution issue", - "dev": true, - "engines": { - "node": "*" - } + "optional": true, + "peer": true }, "node_modules/interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", + "integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==", "dev": true, "engines": { "node": ">= 0.10" @@ -7369,7 +7365,8 @@ "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -7381,7 +7378,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -7400,7 +7398,8 @@ "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/is-ci": { "version": "2.0.0", @@ -7419,8 +7418,7 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "optional": true, - "peer": true, + "devOptional": true, "dependencies": { "has": "^1.0.3" }, @@ -7432,7 +7430,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -7444,7 +7443,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -7456,7 +7456,8 @@ "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -7470,7 +7471,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -7489,7 +7491,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -7498,7 +7501,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "devOptional": true, + "optional": true, "engines": { "node": ">=0.10.0" } @@ -7507,7 +7510,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=4" } @@ -7516,7 +7520,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "devOptional": true, + "optional": true, "dependencies": { "is-extglob": "^2.1.1" }, @@ -7537,7 +7541,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -7549,7 +7554,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -7583,7 +7589,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -7602,7 +7609,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/isexe": { "version": "2.0.0", @@ -8232,7 +8240,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "minimist": "^1.2.0" }, @@ -8326,25 +8335,12 @@ "node": ">=6.11.5" } }, - "node_modules/loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", - "dev": true, - "dependencies": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^1.0.1" - }, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "p-locate": "^3.0.0", "path-exists": "^3.0.0" @@ -8710,7 +8706,8 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -8719,7 +8716,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "object-visit": "^1.0.0" }, @@ -9694,7 +9692,8 @@ "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -9775,13 +9774,15 @@ "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -9794,7 +9795,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-plain-object": "^2.0.4" }, @@ -9819,7 +9821,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/msrcrypto": { "version": "1.5.8", @@ -9842,7 +9845,8 @@ "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -9880,7 +9884,8 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/nocache": { "version": "2.1.0", @@ -10020,7 +10025,8 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -10034,7 +10040,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -10046,7 +10053,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -10068,7 +10076,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "isobject": "^3.0.0" }, @@ -10099,7 +10108,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "isobject": "^3.0.1" }, @@ -10233,7 +10243,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "p-limit": "^2.0.0" }, @@ -10264,15 +10275,6 @@ "node": ">=4" } }, - "node_modules/parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -10287,7 +10289,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -10296,7 +10299,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=4" } @@ -10315,7 +10319,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=4" } @@ -10324,8 +10329,7 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "optional": true, - "peer": true + "devOptional": true }, "node_modules/picocolors": { "version": "1.0.0", @@ -10369,7 +10373,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "find-up": "^3.0.0" }, @@ -10418,7 +10423,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -10489,7 +10495,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/promise": { "version": "7.3.1", @@ -10534,12 +10541,6 @@ "optional": true, "peer": true }, - "node_modules/prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", - "dev": true - }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -10777,7 +10778,8 @@ "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -10828,6 +10830,18 @@ "optional": true, "peer": true }, + "node_modules/rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", + "dev": true, + "dependencies": { + "resolve": "^1.9.0" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -10869,7 +10883,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" @@ -10937,7 +10952,8 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -10946,7 +10962,8 @@ "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10" } @@ -10955,7 +10972,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -10974,7 +10992,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/requires-port": { "version": "1.0.0", @@ -10994,8 +11013,7 @@ "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "optional": true, - "peer": true, + "devOptional": true, "dependencies": { "is-core-module": "^2.8.1", "path-parse": "^1.0.7", @@ -11009,49 +11027,32 @@ } }, "node_modules/resolve-cwd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", - "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", - "dev": true, - "dependencies": { - "resolve-from": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, "dependencies": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" + "resolve-from": "^5.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, - "node_modules/resolve-dir/node_modules/global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "node_modules/resolve-cwd/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", "dev": true, - "dependencies": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - }, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, "node_modules/resolve-from": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=4" } @@ -11061,7 +11062,8 @@ "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "deprecated": "https://github.com/lydell/resolve-url#deprecated", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/restore-cursor": { "version": "2.0.0", @@ -11081,7 +11083,8 @@ "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.12" } @@ -11163,7 +11166,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "ret": "~0.1.10" } @@ -11240,7 +11244,8 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "devOptional": true, + "optional": true, + "peer": true, "bin": { "semver": "bin/semver" } @@ -11329,13 +11334,15 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -11350,7 +11357,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -11376,8 +11384,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", - "optional": true, - "peer": true, + "devOptional": true, "dependencies": { "kind-of": "^6.0.2" }, @@ -11389,7 +11396,8 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "shebang-regex": "^1.0.0" }, @@ -11401,7 +11409,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -11484,7 +11493,8 @@ "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "base": "^0.11.1", "debug": "^2.2.0", @@ -11503,7 +11513,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -11517,7 +11528,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.0" }, @@ -11529,7 +11541,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -11541,7 +11554,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -11553,7 +11567,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -11567,7 +11582,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^3.2.0" }, @@ -11579,7 +11595,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -11591,7 +11608,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -11603,7 +11621,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -11615,7 +11634,8 @@ "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -11624,7 +11644,8 @@ "version": "0.5.3", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "atob": "^2.1.2", "decode-uri-component": "^0.2.0", @@ -11656,13 +11677,15 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "extend-shallow": "^3.0.0" }, @@ -11701,7 +11724,8 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -11714,7 +11738,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -11751,30 +11776,18 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "safe-buffer": "~5.1.0" } }, - "node_modules/string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "dependencies": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "ansi-regex": "^4.1.0" }, @@ -11843,24 +11856,11 @@ "optional": true, "peer": true }, - "node_modules/supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "optional": true, - "peer": true, + "devOptional": true, "engines": { "node": ">= 0.4" }, @@ -11868,15 +11868,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/tapable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", - "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/temp": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", @@ -12071,7 +12062,8 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -12083,7 +12075,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -12095,7 +12088,8 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -12110,7 +12104,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" @@ -12280,7 +12275,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -12315,7 +12311,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -12328,7 +12325,8 @@ "version": "0.3.1", "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -12342,7 +12340,8 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "isarray": "1.0.0" }, @@ -12354,7 +12353,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -12373,7 +12373,8 @@ "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "deprecated": "Please see https://github.com/lydell/urix#deprecated", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/url-parse": { "version": "1.5.4", @@ -12390,7 +12391,8 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -12412,7 +12414,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/utils-merge": { "version": "1.0.1", @@ -12435,12 +12438,6 @@ "uuid": "bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -12566,68 +12563,174 @@ } }, "node_modules/webpack-cli": { - "version": "3.3.12", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.12.tgz", - "integrity": "sha512-NVWBaz9k839ZH/sinurM+HcDvJOTXwSjYp1ku+5XKeOC03z8v5QitnK/x+lAxGXFyhdayoIf/GOpv85z3/xPag==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz", + "integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==", "dev": true, "dependencies": { - "chalk": "^2.4.2", - "cross-spawn": "^6.0.5", - "enhanced-resolve": "^4.1.1", - "findup-sync": "^3.0.0", - "global-modules": "^2.0.0", - "import-local": "^2.0.0", - "interpret": "^1.4.0", - "loader-utils": "^1.4.0", - "supports-color": "^6.1.0", - "v8-compile-cache": "^2.1.1", - "yargs": "^13.3.2" + "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^1.2.0", + "@webpack-cli/info": "^1.5.0", + "@webpack-cli/serve": "^1.7.0", + "colorette": "^2.0.14", + "commander": "^7.0.0", + "cross-spawn": "^7.0.3", + "fastest-levenshtein": "^1.0.12", + "import-local": "^3.0.2", + "interpret": "^2.2.0", + "rechoir": "^0.7.0", + "webpack-merge": "^5.7.3" }, "bin": { "webpack-cli": "bin/cli.js" }, "engines": { - "node": ">=6.11.5" + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" }, "peerDependencies": { - "webpack": "4.x.x" + "webpack": "4.x.x || 5.x.x" + }, + "peerDependenciesMeta": { + "@webpack-cli/generators": { + "optional": true + }, + "@webpack-cli/migrate": { + "optional": true + }, + "webpack-bundle-analyzer": { + "optional": true + }, + "webpack-dev-server": { + "optional": true + } } }, - "node_modules/webpack-sources": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", - "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "node_modules/webpack-cli/node_modules/colorette": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", + "dev": true + }, + "node_modules/webpack-cli/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", "dev": true, "engines": { - "node": ">=10.13.0" + "node": ">= 10" } }, - "node_modules/webpack/node_modules/enhanced-resolve": { - "version": "5.9.2", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz", - "integrity": "sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA==", + "node_modules/webpack-cli/node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" }, "engines": { - "node": ">=10.13.0" + "node": ">= 8" } }, - "node_modules/webpack/node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "node_modules/webpack-cli/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, "engines": { - "node": ">=6" + "node": ">=8" } }, - "node_modules/whatwg-fetch": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", - "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==", + "node_modules/webpack-cli/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-cli/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-cli/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webpack-merge": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", + "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "dev": true, + "dependencies": { + "clone-deep": "^4.0.1", + "wildcard": "^2.0.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack/node_modules/enhanced-resolve": { + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz", + "integrity": "sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack/node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/whatwg-fetch": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", + "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==", "optional": true, "peer": true }, @@ -12644,7 +12747,8 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "isexe": "^2.0.0" }, @@ -12656,21 +12760,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "devOptional": true + "optional": true, + "peer": true }, - "node_modules/wrap-ansi": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", - "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" - }, - "engines": { - "node": ">=6" - } + "node_modules/wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", + "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", + "dev": true }, "node_modules/wrappy": { "version": "1.0.2", @@ -12783,35 +12880,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", - "devOptional": true - }, - "node_modules/yargs": { - "version": "13.3.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", - "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", - "dev": true, - "dependencies": { - "cliui": "^5.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^13.1.2" - } - }, - "node_modules/yargs-parser": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", - "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } + "optional": true, + "peer": true }, "node_modules/yocto-queue": { "version": "0.1.0", @@ -14362,6 +14432,12 @@ "minimist": "^1.2.0" } }, + "@discoveryjs/json-ext": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", + "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", + "dev": true + }, "@expo/config": { "version": "6.0.6", "resolved": "https://registry.npmjs.org/@expo/config/-/config-6.0.6.tgz", @@ -16022,6 +16098,29 @@ "@xtuc/long": "4.2.2" } }, + "@webpack-cli/configtest": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz", + "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==", + "dev": true, + "requires": {} + }, + "@webpack-cli/info": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz", + "integrity": "sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==", + "dev": true, + "requires": { + "envinfo": "^7.7.3" + } + }, + "@webpack-cli/serve": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz", + "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==", + "dev": true, + "requires": {} + }, "@xmldom/xmldom": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.5.tgz", @@ -16124,13 +16223,15 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "devOptional": true + "optional": true, + "peer": true }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "color-convert": "^1.9.0" } @@ -16186,19 +16287,22 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "devOptional": true + "optional": true, + "peer": true }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "devOptional": true + "optional": true, + "peer": true }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "devOptional": true + "optional": true, + "peer": true }, "array-filter": { "version": "0.0.1", @@ -16225,7 +16329,8 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "devOptional": true + "optional": true, + "peer": true }, "asap": { "version": "2.0.6", @@ -16251,7 +16356,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "devOptional": true + "optional": true, + "peer": true }, "ast-types": { "version": "0.14.2", @@ -16306,7 +16412,8 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "devOptional": true + "optional": true, + "peer": true }, "b64-lite": { "version": "1.4.0", @@ -16474,7 +16581,8 @@ "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -16489,7 +16597,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^1.0.0" } @@ -16498,7 +16607,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -16507,7 +16617,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -16516,7 +16627,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -16543,12 +16655,6 @@ "optional": true, "peer": true }, - "big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true - }, "blueimp-md5": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", @@ -16596,7 +16702,8 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -16614,7 +16721,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -16696,7 +16804,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -16751,7 +16860,8 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "devOptional": true + "optional": true, + "peer": true }, "caniuse-lite": { "version": "1.0.30001304", @@ -16773,7 +16883,8 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -16784,7 +16895,8 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "has-flag": "^3.0.0" } @@ -16811,7 +16923,8 @@ "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -16823,7 +16936,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -16847,17 +16961,6 @@ "optional": true, "peer": true }, - "cliui": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", - "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", - "dev": true, - "requires": { - "string-width": "^3.1.0", - "strip-ansi": "^5.2.0", - "wrap-ansi": "^5.1.0" - } - }, "clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", @@ -16869,8 +16972,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", - "optional": true, - "peer": true, + "devOptional": true, "requires": { "is-plain-object": "^2.0.4", "kind-of": "^6.0.2", @@ -16881,7 +16983,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -16891,7 +16994,8 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "color-name": "1.1.3" } @@ -16900,7 +17004,8 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "devOptional": true + "optional": true, + "peer": true }, "colorette": { "version": "1.4.0", @@ -16946,7 +17051,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "devOptional": true + "optional": true, + "peer": true }, "compressible": { "version": "2.0.18", @@ -17008,7 +17114,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "devOptional": true + "optional": true, + "peer": true }, "core-js": { "version": "1.2.7", @@ -17041,7 +17148,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "devOptional": true + "optional": true, + "peer": true }, "cosmiconfig": { "version": "5.2.1", @@ -17060,7 +17168,8 @@ "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "nice-try": "^1.0.4", "path-key": "^2.0.1", @@ -17080,7 +17189,8 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "ms": "2.0.0" } @@ -17089,13 +17199,15 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "devOptional": true + "optional": true, + "peer": true }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "devOptional": true + "optional": true, + "peer": true }, "deepmerge": { "version": "3.3.0", @@ -17128,7 +17240,8 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -17138,7 +17251,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -17147,7 +17261,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -17156,7 +17271,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -17186,12 +17302,6 @@ "optional": true, "peer": true }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true - }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -17205,18 +17315,6 @@ "integrity": "sha512-AOJ3cAE0TWxz4fQ9zkND5hWrQg16nsZKVz9INOot1oV//u4wWu5xrj9CQMmPTYskkZRunSRc9sAnr4EkexXokg==", "devOptional": true }, - "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "emojis-list": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "dev": true - }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -17244,44 +17342,11 @@ "once": "^1.4.0" } }, - "enhanced-resolve": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz", - "integrity": "sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "memory-fs": "^0.5.0", - "tapable": "^1.0.0" - }, - "dependencies": { - "memory-fs": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", - "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", - "dev": true, - "requires": { - "errno": "^0.1.3", - "readable-stream": "^2.0.1" - } - } - } - }, "envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", - "optional": true, - "peer": true - }, - "errno": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", - "dev": true, - "requires": { - "prr": "~1.0.1" - } + "devOptional": true }, "error-ex": { "version": "1.3.2", @@ -17337,7 +17402,8 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "devOptional": true + "optional": true, + "peer": true }, "eslint-scope": { "version": "5.1.1", @@ -17448,7 +17514,8 @@ "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -17463,7 +17530,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -17472,22 +17540,14 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } } } }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, "expo": { "version": "44.0.5", "resolved": "https://registry.npmjs.org/expo/-/expo-44.0.5.tgz", @@ -17896,7 +17956,8 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -17906,7 +17967,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-plain-object": "^2.0.4" } @@ -17917,7 +17979,8 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -17933,7 +17996,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^1.0.0" } @@ -17942,7 +18006,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -17951,7 +18016,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -17960,7 +18026,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -17969,7 +18036,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -18057,6 +18125,12 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, + "fastest-levenshtein": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", + "dev": true + }, "fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -18106,7 +18180,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -18118,7 +18193,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -18177,23 +18253,12 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "locate-path": "^3.0.0" } }, - "findup-sync": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", - "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - } - }, "flow-parser": { "version": "0.121.0", "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.121.0.tgz", @@ -18212,13 +18277,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "devOptional": true + "optional": true, + "peer": true }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "map-cache": "^0.2.2" } @@ -18254,8 +18321,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "optional": true, - "peer": true + "devOptional": true }, "gensync": { "version": "1.0.0-beta.2", @@ -18268,7 +18334,8 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "devOptional": true + "optional": true, + "peer": true }, "get-intrinsic": { "version": "1.1.1", @@ -18296,7 +18363,8 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "devOptional": true + "optional": true, + "peer": true }, "getenv": { "version": "1.0.0", @@ -18326,41 +18394,6 @@ "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", "dev": true }, - "global-modules": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz", - "integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==", - "dev": true, - "requires": { - "global-prefix": "^3.0.0" - }, - "dependencies": { - "global-prefix": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", - "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", - "dev": true, - "requires": { - "ini": "^1.3.5", - "kind-of": "^6.0.2", - "which": "^1.3.1" - } - } - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -18378,8 +18411,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "optional": true, - "peer": true, + "devOptional": true, "requires": { "function-bind": "^1.1.1" } @@ -18388,7 +18420,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "devOptional": true + "optional": true, + "peer": true }, "has-symbols": { "version": "1.0.2", @@ -18401,7 +18434,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -18412,7 +18446,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -18422,7 +18457,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -18462,15 +18498,6 @@ } } }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, - "requires": { - "parse-passwd": "^1.0.0" - } - }, "http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", @@ -18520,13 +18547,58 @@ } }, "import-local": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", - "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", "dev": true, "requires": { - "pkg-dir": "^3.0.0", - "resolve-cwd": "^2.0.0" + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + } } }, "imurmurhash": { @@ -18551,18 +18623,13 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "devOptional": true - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true + "optional": true, + "peer": true }, "interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", + "integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==", "dev": true }, "invariant": { @@ -18585,7 +18652,8 @@ "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -18594,7 +18662,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -18612,7 +18681,8 @@ "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "devOptional": true + "optional": true, + "peer": true }, "is-ci": { "version": "2.0.0", @@ -18628,8 +18698,7 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "optional": true, - "peer": true, + "devOptional": true, "requires": { "has": "^1.0.3" } @@ -18638,7 +18707,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -18647,7 +18717,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -18658,7 +18729,8 @@ "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -18669,7 +18741,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "devOptional": true + "optional": true, + "peer": true } } }, @@ -18684,25 +18757,27 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "devOptional": true + "optional": true, + "peer": true }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "devOptional": true + "optional": true }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "devOptional": true + "optional": true, + "peer": true }, "is-glob": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "devOptional": true, + "optional": true, "requires": { "is-extglob": "^2.1.1" } @@ -18716,7 +18791,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -18725,7 +18801,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -18752,7 +18829,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "devOptional": true + "optional": true, + "peer": true }, "is-wsl": { "version": "1.1.0", @@ -18765,7 +18843,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "devOptional": true + "optional": true, + "peer": true }, "isexe": { "version": "2.0.0", @@ -19263,7 +19342,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "minimist": "^1.2.0" } @@ -19336,22 +19416,12 @@ "integrity": "sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw==", "dev": true }, - "loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", - "dev": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^1.0.1" - } - }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "p-locate": "^3.0.0", "path-exists": "^3.0.0" @@ -19662,13 +19732,15 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "devOptional": true + "optional": true, + "peer": true }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "object-visit": "^1.0.0" } @@ -20517,7 +20589,8 @@ "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -20577,13 +20650,15 @@ "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "devOptional": true + "optional": true, + "peer": true }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -20593,7 +20668,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-plain-object": "^2.0.4" } @@ -20614,7 +20690,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "devOptional": true + "optional": true, + "peer": true }, "msrcrypto": { "version": "1.5.8", @@ -20637,7 +20714,8 @@ "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -20669,7 +20747,8 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "devOptional": true + "optional": true, + "peer": true }, "nocache": { "version": "2.1.0", @@ -20774,7 +20853,8 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -20785,7 +20865,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -20794,7 +20875,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -20812,7 +20894,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "isobject": "^3.0.0" } @@ -20834,7 +20917,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "isobject": "^3.0.1" } @@ -20935,7 +21019,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "p-limit": "^2.0.0" } @@ -20957,12 +21042,6 @@ "json-parse-better-errors": "^1.0.1" } }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -20974,13 +21053,15 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "devOptional": true + "optional": true, + "peer": true }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "devOptional": true + "optional": true, + "peer": true }, "path-is-absolute": { "version": "1.0.1", @@ -20993,14 +21074,14 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "devOptional": true + "optional": true, + "peer": true }, "path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "optional": true, - "peer": true + "devOptional": true }, "picocolors": { "version": "1.0.0", @@ -21032,7 +21113,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "find-up": "^3.0.0" } @@ -21071,7 +21153,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "devOptional": true + "optional": true, + "peer": true }, "pretty-format": { "version": "26.6.2", @@ -21126,7 +21209,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "devOptional": true + "optional": true, + "peer": true }, "promise": { "version": "7.3.1", @@ -21170,12 +21254,6 @@ } } }, - "prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", - "dev": true - }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -21364,7 +21442,8 @@ "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -21411,6 +21490,15 @@ } } }, + "rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", + "dev": true, + "requires": { + "resolve": "^1.9.0" + } + }, "regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -21449,7 +21537,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" @@ -21507,19 +21596,22 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "devOptional": true + "optional": true, + "peer": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "devOptional": true + "optional": true, + "peer": true }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "devOptional": true + "optional": true, + "peer": true }, "require-from-string": { "version": "2.0.2", @@ -21532,7 +21624,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "devOptional": true + "optional": true, + "peer": true }, "requires-port": { "version": "1.0.0", @@ -21552,8 +21645,7 @@ "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "optional": true, - "peer": true, + "devOptional": true, "requires": { "is-core-module": "^2.8.1", "path-parse": "^1.0.7", @@ -21561,34 +21653,19 @@ } }, "resolve-cwd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", - "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", - "dev": true, - "requires": { - "resolve-from": "^3.0.0" - } - }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" + "resolve-from": "^5.0.0" }, "dependencies": { - "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "dev": true, - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true } } }, @@ -21596,13 +21673,15 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", - "devOptional": true + "optional": true, + "peer": true }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "devOptional": true + "optional": true, + "peer": true }, "restore-cursor": { "version": "2.0.0", @@ -21619,7 +21698,8 @@ "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "devOptional": true + "optional": true, + "peer": true }, "reusify": { "version": "1.0.4", @@ -21671,7 +21751,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "ret": "~0.1.10" } @@ -21734,7 +21815,8 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "devOptional": true + "optional": true, + "peer": true }, "send": { "version": "0.17.2", @@ -21807,13 +21889,15 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "devOptional": true + "optional": true, + "peer": true }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -21825,7 +21909,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -21850,8 +21935,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", - "optional": true, - "peer": true, + "devOptional": true, "requires": { "kind-of": "^6.0.2" } @@ -21860,7 +21944,8 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "shebang-regex": "^1.0.0" } @@ -21869,7 +21954,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "devOptional": true + "optional": true, + "peer": true }, "shell-quote": { "version": "1.6.1", @@ -21940,7 +22026,8 @@ "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "base": "^0.11.1", "debug": "^2.2.0", @@ -21956,7 +22043,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -21965,7 +22053,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -21976,7 +22065,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -21987,7 +22077,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^1.0.0" } @@ -21996,7 +22087,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -22005,7 +22097,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -22014,7 +22107,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -22027,7 +22121,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^3.2.0" }, @@ -22036,7 +22131,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -22047,13 +22143,15 @@ "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "devOptional": true + "optional": true, + "peer": true }, "source-map-resolve": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "atob": "^2.1.2", "decode-uri-component": "^0.2.0", @@ -22084,13 +22182,15 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "devOptional": true + "optional": true, + "peer": true }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "extend-shallow": "^3.0.0" } @@ -22123,7 +22223,8 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -22133,7 +22234,8 @@ "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -22163,27 +22265,18 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "safe-buffer": "~5.1.0" } }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "ansi-regex": "^4.1.0" } @@ -22234,27 +22327,11 @@ "optional": true, "peer": true }, - "supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, "supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "optional": true, - "peer": true - }, - "tapable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", - "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", - "dev": true + "devOptional": true }, "temp": { "version": "0.8.3", @@ -22399,7 +22476,8 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -22408,7 +22486,8 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -22419,7 +22498,8 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -22431,7 +22511,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" @@ -22556,7 +22637,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -22582,7 +22664,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -22592,7 +22675,8 @@ "version": "0.3.1", "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -22603,7 +22687,8 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "isarray": "1.0.0" } @@ -22614,7 +22699,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "devOptional": true + "optional": true, + "peer": true } } }, @@ -22631,7 +22717,8 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "devOptional": true + "optional": true, + "peer": true }, "url-parse": { "version": "1.5.4", @@ -22648,7 +22735,8 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "devOptional": true + "optional": true, + "peer": true }, "use-subscription": { "version": "1.5.1", @@ -22664,7 +22752,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "devOptional": true + "optional": true, + "peer": true }, "utils-merge": { "version": "1.0.1", @@ -22680,12 +22769,6 @@ "optional": true, "peer": true }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -22810,22 +22893,88 @@ } }, "webpack-cli": { - "version": "3.3.12", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.12.tgz", - "integrity": "sha512-NVWBaz9k839ZH/sinurM+HcDvJOTXwSjYp1ku+5XKeOC03z8v5QitnK/x+lAxGXFyhdayoIf/GOpv85z3/xPag==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz", + "integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==", "dev": true, "requires": { - "chalk": "^2.4.2", - "cross-spawn": "^6.0.5", - "enhanced-resolve": "^4.1.1", - "findup-sync": "^3.0.0", - "global-modules": "^2.0.0", - "import-local": "^2.0.0", - "interpret": "^1.4.0", - "loader-utils": "^1.4.0", - "supports-color": "^6.1.0", - "v8-compile-cache": "^2.1.1", - "yargs": "^13.3.2" + "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^1.2.0", + "@webpack-cli/info": "^1.5.0", + "@webpack-cli/serve": "^1.7.0", + "colorette": "^2.0.14", + "commander": "^7.0.0", + "cross-spawn": "^7.0.3", + "fastest-levenshtein": "^1.0.12", + "import-local": "^3.0.2", + "interpret": "^2.2.0", + "rechoir": "^0.7.0", + "webpack-merge": "^5.7.3" + }, + "dependencies": { + "colorette": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", + "dev": true + }, + "commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "webpack-merge": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", + "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "dev": true, + "requires": { + "clone-deep": "^4.0.1", + "wildcard": "^2.0.0" } }, "webpack-sources": { @@ -22854,7 +23003,8 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "devOptional": true, + "optional": true, + "peer": true, "requires": { "isexe": "^2.0.0" } @@ -22863,18 +23013,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "devOptional": true + "optional": true, + "peer": true }, - "wrap-ansi": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", - "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" - } + "wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", + "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", + "dev": true }, "wrappy": { "version": "1.0.2", @@ -22973,35 +23119,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", - "devOptional": true - }, - "yargs": { - "version": "13.3.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", - "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", - "dev": true, - "requires": { - "cliui": "^5.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^13.1.2" - } - }, - "yargs-parser": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", - "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } + "optional": true, + "peer": true }, "yocto-queue": { "version": "0.1.0", diff --git a/package.json b/package.json index 20ae7e35..a9674169 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tonweb", - "version": "0.0.40", + "version": "0.0.66", "description": "TonWeb - JavaScript API for TON blockchain", "main": "src/index.js", "types": "dist/types/index.d.ts", @@ -15,13 +15,13 @@ ], "authors": [ { - "name": "rulon" + "name": "EmelyanenkoK" }, { "name": "tolya-yanot" } ], - "license": "GPL-3.0", + "license": "MIT", "bugs": { "url": "https://github.com/toncenter/tonweb/issues" }, @@ -41,7 +41,7 @@ "@sinonjs/fake-timers": "^9.1.1", "buffer": "6.0.3", "webpack": "5.70.0", - "webpack-cli": "3.3.12" + "webpack-cli": "4.10.0" }, "browser": { "node-fetch": false diff --git a/src/boc/BitString.js b/src/boc/BitString.js index 37ba7eb0..e6ff2899 100644 --- a/src/boc/BitString.js +++ b/src/boc/BitString.js @@ -115,6 +115,11 @@ class BitString { * @param bitLength {number} size of uint in bits */ writeUint(number, bitLength) { + if (isNaN(number)) throw new Error('writeUint: value is NaN'); + if (number === null) throw new Error('writeUint: value is null'); + if (number === undefined) throw new Error('writeUint: value is undefined'); + if (!bitLength) throw new Error('writeUint: no bitLength'); + number = new BN(number); if ( bitLength == 0 || @@ -135,6 +140,11 @@ class BitString { * @param bitLength {number} size of int in bits */ writeInt(number, bitLength) { + if (isNaN(number)) throw new Error('writeInt: value is NaN'); + if (number === null) throw new Error('writeInt: value is null'); + if (number === undefined) throw new Error('writeInt: value is undefined'); + if (!bitLength) throw new Error('writeInt: no bitLength'); + number = new BN(number); if (bitLength == 1) { if (number == -1) { diff --git a/src/boc/Cell.js b/src/boc/Cell.js index 31d46444..c4911ab2 100644 --- a/src/boc/Cell.js +++ b/src/boc/Cell.js @@ -9,6 +9,7 @@ const { sha256, bytesToHex } = require("../utils"); +const {Slice} = require("./Slice"); const reachBocMagicPrefix = hexToBytes('B5EE9C72'); const leanBocMagicPrefix = hexToBytes('68ff65f3'); @@ -77,10 +78,11 @@ class Cell { getMaxDepth() { let maxDepth = 0; if (this.refs.length > 0) { - for (let k in this.refs) { - const i = this.refs[k]; - if (i.getMaxDepth() > maxDepth) { - maxDepth = i.getMaxDepth(); + for (let k = 0; k < this.refs.length; k++) { + const child = this.refs[k]; + let childMaxDepth = child.getMaxDepth(); + if (childMaxDepth > maxDepth) { + maxDepth = childMaxDepth; } } maxDepth = maxDepth + 1; @@ -160,6 +162,11 @@ class Cell { ); } + beginParse() { + const refs = this.refs.map(ref => ref.beginParse()); + return new Slice(this.bits.array.slice(), this.bits.length, refs); + } + /** * Recursively prints cell's content like Fift * @return {string} diff --git a/src/boc/Slice.js b/src/boc/Slice.js new file mode 100644 index 00000000..816a6df5 --- /dev/null +++ b/src/boc/Slice.js @@ -0,0 +1,152 @@ +const {BN, Address, bytesToHex} = require("../utils"); +const {BitString} = require("./BitString"); + +/** + * A partial view of a TVM cell, used for parsing data from Cells. + */ +class Slice { + /** + * @param array {Uint8Array} + * @param length {number} length in bits + * @param refs {Slice[]} child cells + */ + constructor(array, length, refs) { + this.array = array; + this.length = length; + this.readCursor = 0; + + this.refs = refs; + this.refCursor = 0; + } + + /** + * @return {number} + */ + getFreeBits() { + return this.length - this.readCursor; + } + + /** + * @private + * @param n {number} + */ + checkRange(n) { + if (n > this.length) { + throw Error("BitString overflow"); + } + } + + /** + * @private + * @param n {number} + * @return {boolean} bit value at position `n` + */ + get(n) { + this.checkRange(n); + return (this.array[(n / 8) | 0] & (1 << (7 - (n % 8)))) > 0; + } + + /** + * @return {boolean} read bit + */ + loadBit() { + const result = this.get(this.readCursor); + this.readCursor++; + return result; + } + + /** + * @param bitLength {number} + * @return {Uint8Array} + */ + loadBits(bitLength) { + const result = new BitString(bitLength); + for (let i = 0; i < bitLength; i++) { + result.writeBit(this.loadBit()); + } + return result.array; + } + + /** + * Reads unsigned int + * + * @param {number} bitLength Size of uint in bits + * @returns {BN} number + */ + loadUint(bitLength) { + if (bitLength < 1) { + throw "Incorrect bitLength"; + } + let s = ''; + for (let i = 0; i < bitLength; i++) { + s += (this.loadBit() ? '1' : '0'); + } + return new BN(s, 2); + } + + /** + * Reads signed int + * + * @param {number} bitLength Size of uint in bits + * @returns {BN} number + */ + loadInt(bitLength) { + if (bitLength < 1) { + throw "Incorrect bitLength"; + } + const sign = this.loadBit(); + if (bitLength === 1) { + return sign ? new BN(-1) : new BN(0); + } + let number = this.loadUint(bitLength - 1); + if (sign) { + const b = new BN(2); + const nb = b.pow(new BN(bitLength - 1)); + number = number.sub(nb); + } + return number; + } + + /** + * @param bitLength {number} + * @return {BN} + */ + loadVarUint(bitLength) { + const len = this.loadUint((new BN(bitLength)).toString(2).length - 1); + if (len.toNumber() === 0) { + return new BN(0); + } else { + return this.loadUint(len * 8); + } + } + + /** + * @return {BN} + */ + loadCoins() { + return this.loadVarUint(16); + } + + loadAddress() { + const b = this.loadUint(2); + if (b.toNumber() === 0) return null; // null address + if (b.toNumber() !== 2) throw new Error('unsupported address type'); + if (this.loadBit()) throw new Error('unsupported address type'); + const wc = this.loadInt(8).toNumber(); + const hashPart = this.loadBits(256); + return new Address(wc + ':' + bytesToHex(hashPart)); + } + + /** + * @return {Slice} + */ + loadRef() { + if (this.refCursor >= 4) throw new Error('refs overflow'); + const result = this.refs[this.refCursor]; + this.refCursor++; + return result; + } + +} + +module.exports = {Slice}; \ No newline at end of file diff --git a/src/boc/index.js b/src/boc/index.js index 0d0bd2bd..40e2d3fc 100644 --- a/src/boc/index.js +++ b/src/boc/index.js @@ -1,4 +1,5 @@ const {BitString} = require("./BitString"); const {Cell} = require("./Cell"); +const {Slice} = require("./Slice"); -module.exports = {BitString, Cell}; \ No newline at end of file +module.exports = {BitString, Cell, Slice}; \ No newline at end of file diff --git a/src/contract/README.md b/src/contract/README.md index 1a5e33d3..d7858c41 100644 --- a/src/contract/README.md +++ b/src/contract/README.md @@ -11,8 +11,6 @@ tonweb.Contract is abstract class for all smart contract objects in TonWeb. ABI and json interface of contract not yet invented in TON, so you need extend tonweb.Contract and compose messages to contract yourself. ```js -import {Contract} from 'web3-eth-contract'; - export class MyContract extends Contract { constructor(provider, options) { options.code = hexToBytes('abcd..'); @@ -24,10 +22,6 @@ export class MyContract extends Contract { // @override createDataCell() { } - - // @override - createSigningMessage(options) { - } } ``` diff --git a/src/contract/dns/Dns.js b/src/contract/dns/Dns.js new file mode 100644 index 00000000..9d5e8aeb --- /dev/null +++ b/src/contract/dns/Dns.js @@ -0,0 +1,82 @@ +const {Cell} = require("../../boc"); +const {Address, bytesToHex} = require("../../utils"); +const { + DNS_CATEGORY_NEXT_RESOLVER, + DNS_CATEGORY_SITE, + DNS_CATEGORY_WALLET, + DNS_CATEGORY_STORAGE, + createSmartContractAddressRecord, + createAdnlAddressRecord, + createStorageBagIdRecord, + createNextResolverRecord, + parseSmartContractAddressRecord, + parseAdnlAddressRecord, + parseStorageBagIdRecord, + parseSiteRecord, + parseNextResolverRecord, + dnsResolve +} = require("./DnsUtils"); + +class Dns { + /** + * @param provider {HttpProvider} + */ + constructor(provider) { + this.provider = provider; + } + + /** + * @returns {Promise
} + */ + async getRootDnsAddress() { + const cell = await this.provider.getConfigParam(4); + const byteArray = cell.bits.array; + if (byteArray.length !== 256 / 8) throw new Error('Invalid ConfigParam 4 length ' + byteArray.length); + const hex = bytesToHex(byteArray); + return new Address('-1:' + hex); + } + + /** + * @param domain {string} e.g "sub.alice.ton" + * @param category {string | undefined} category of requested DNS record, null for all categories + * @param oneStep {boolean | undefined} non-recursive + * @returns {Promise} + */ + async resolve(domain, category, oneStep) { + const rootDnsAddress = await this.getRootDnsAddress(); + return dnsResolve(this.provider, rootDnsAddress.toString(), domain, category, oneStep) + } + + /** + * @param domain {string} e.g "sub.alice.ton" + * @returns {Promise
} + */ + getWalletAddress(domain) { + return this.resolve(domain, DNS_CATEGORY_WALLET); + } + + /** + * @param domain {string} e.g "sub.alice.ton" + * @returns {Promise} + */ + getSiteAddress(domain) { + return this.resolve(domain, DNS_CATEGORY_SITE); + } +} + +Dns.resolve = dnsResolve; +Dns.createSmartContractAddressRecord = createSmartContractAddressRecord; +Dns.createAdnlAddressRecord = createAdnlAddressRecord; +Dns.createStorageBagIdRecord = createStorageBagIdRecord; +Dns.createNextResolverRecord = createNextResolverRecord; +Dns.parseNextResolverRecord = parseNextResolverRecord; +Dns.parseAdnlAddressRecord = parseAdnlAddressRecord; +Dns.parseStorageBagIdRecord = parseStorageBagIdRecord; +Dns.parseSiteRecord = parseSiteRecord; +Dns.parseSmartContractAddressRecord = parseSmartContractAddressRecord; +Dns.DNS_CATEGORY_NEXT_RESOLVER = DNS_CATEGORY_NEXT_RESOLVER; +Dns.DNS_CATEGORY_WALLET = DNS_CATEGORY_WALLET; +Dns.DNS_CATEGORY_SITE = DNS_CATEGORY_SITE; +Dns.DNS_CATEGORY_STORAGE = DNS_CATEGORY_STORAGE; + +module.exports.default = Dns; \ No newline at end of file diff --git a/src/contract/dns/DnsCollection.js b/src/contract/dns/DnsCollection.js new file mode 100644 index 00000000..040c4df9 --- /dev/null +++ b/src/contract/dns/DnsCollection.js @@ -0,0 +1,84 @@ +const {Contract} = require("../../contract/index.js"); +const {Cell} = require("../../boc"); +const {Address} = require("../../utils"); +const {parseAddress} = require('../token/nft/NftUtils.js'); +const {dnsResolve} = require("./DnsUtils.js") +const {parseOffchainUriCell} = require("../token/nft/NftUtils"); + +class DnsCollection extends Contract { + /** + * @param provider + * @param options {{collectionContent: Cell, dnsItemCodeHex: string, address?: Address | string, code?: Cell}} + */ + constructor(provider, options) { + options.wc = 0; + options.code = options.code; + super(provider, options); + + if (!options.collectionContent && !options.address) throw new Error('required collectionContent cell'); + + this.methods.getCollectionData = this.getCollectionData.bind(this); + this.methods.getNftItemAddressByIndex = this.getNftItemAddressByIndex.bind(this); + this.methods.getNftItemContent = this.getNftItemContent.bind(this); + this.methods.resolve = this.resolve.bind(this); + } + + /** + * @override + * @private + * @return {Cell} cell contains dns collection data + */ + createDataCell() { + const cell = new Cell(); + cell.refs[0] = this.options.collectionContent; + cell.refs[1] = Cell.oneFromBoc(this.options.dnsItemCodeHex); + return cell; + } + + /** + * @return {Promise<{collectionContent: Cell}>} + */ + async getCollectionData() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_collection_data'); + + const nextItemIndex = result[0].toNumber(); + const collectionContent = result[1]; + const collectionContentUri = parseOffchainUriCell(collectionContent); + + return {collectionContentUri, collectionContent, ownerAddress: null, nextItemIndex}; + } + + /** + * @param nftItem {DnsItem} + * @return {Promise<{isInitialized: boolean, index: BN, collectionAddress: Address|null, ownerAddress: Address|null, contentCell: Cell}>} + */ + async getNftItemContent(nftItem) { + const nftData = await nftItem.getData(); + return nftData; + } + + /** + * @param index {BN} + * @return {Promise
} + */ + async getNftItemAddressByIndex(index) { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_nft_address_by_index', [['num', index.toString()]]); + + return parseAddress(result); + } + + /** + * @param domain {string} e.g "sub.alice.ton" + * @param category? {string} category of requested DNS record, null for all categories + * @param oneStep? {boolean} non-recursive + * @returns {Promise} + */ + async resolve(domain, category, oneStep) { + const myAddress = await this.getAddress(); + return dnsResolve(this.provider, myAddress.toString(), domain, category, oneStep); + } +} + +module.exports = {DnsCollection: DnsCollection}; diff --git a/src/contract/dns/DnsItem.js b/src/contract/dns/DnsItem.js new file mode 100644 index 00000000..5a4905e8 --- /dev/null +++ b/src/contract/dns/DnsItem.js @@ -0,0 +1,139 @@ +const {Contract} = require("../../contract/index.js"); +const {Cell} = require("../../boc"); +const {Address, BN} = require("../../utils"); +const {parseAddress} = require('./../token/nft/NftUtils.js'); +const {dnsResolve, categoryToBN} = require("./DnsUtils.js") + +class DnsItem extends Contract { + /** + * @param provider + * @param options {{index: BN, collectionAddress: Address, address?: Address | string, code?: Cell}} + */ + constructor(provider, options) { + options.wc = 0; + options.code = options.code; + super(provider, options); + + this.methods.getData = this.getData.bind(this); + this.methods.getDomain = this.getDomain.bind(this); + this.methods.getAuctionInfo = this.getAuctionInfo.bind(this); + this.methods.getLastFillUpTime = this.getLastFillUpTime.bind(this); + this.methods.resolve = this.resolve.bind(this); + } + + /** + * @override + * @private + * @return {Cell} cell contains nft data + */ + createDataCell() { + const cell = new Cell(); + cell.bits.writeUint(this.options.index, 256); + cell.bits.writeAddress(this.options.collectionAddress); + return cell; + } + + /** + * @return {Promise<{isInitialized: boolean, index: BN, collectionAddress: Address|null, ownerAddress: Address|null, contentCell: Cell}>} + */ + async getData() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_nft_data'); + + const isInitialized = result[0].toNumber() === -1; + const index = result[1]; + const collectionAddress = parseAddress(result[2]); + const ownerAddress = isInitialized ? parseAddress(result[3]) : null; + const contentCell = result[4]; + + return {isInitialized, index, collectionAddress, ownerAddress, contentCell}; + } + + /** + * @param params {{queryId?: number, newOwnerAddress: Address, forwardAmount?: BN, forwardPayload?: Uint8Array, responseAddress: Address}} + */ + async createTransferBody(params) { + const cell = new Cell(); + cell.bits.writeUint(0x5fcc3d14, 32); // transfer op + cell.bits.writeUint(params.queryId || 0, 64); + cell.bits.writeAddress(params.newOwnerAddress); + cell.bits.writeAddress(params.responseAddress); + cell.bits.writeBit(false); // null custom_payload + cell.bits.writeCoins(params.forwardAmount || new BN(0)); + cell.bits.writeBit(false); // forward_payload in this slice, not separate cell + + if (params.forwardPayload) { + cell.bits.writeBytes(params.forwardPayload); + } + return cell; + } + + /** + * params {{queryId?: number}} + * @return {Cell} + */ + createGetStaticDataBody(params) { + const body = new Cell(); + body.bits.writeUint(0x2fcb26a2, 32); // OP + body.bits.writeUint(params.queryId || 0, 64); // query_id + return body; + } + + /** + * @return {Promise} + */ + async getDomain() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_domain'); + return new TextDecoder().decode(result.bits.array.buffer); + } + + /** + * @return {Promise<{maxBidAddress: Address|null, maxBidAmount: BN, auctionEndTime: number}>} + */ + async getAuctionInfo() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_auction_info'); + const maxBidAddress = parseAddress(result[0]); + const maxBidAmount = result[1]; + const auctionEndTime = result[2].toNumber(); + return {maxBidAddress, maxBidAmount, auctionEndTime}; + } + + /** + * @return {Promise} + */ + async getLastFillUpTime() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_last_fill_up_time'); + return result.toNumber(); + } + + /** + * @param domain {string} e.g "sub.alice.ton" + * @param category? {string} category of requested DNS record, null for all categories + * @param oneStep? {boolean} non-recursive + * @returns {Promise} + */ + async resolve(domain, category, oneStep) { + const myAddress = await this.getAddress(); + return dnsResolve(this.provider, myAddress.toString(), domain, category, oneStep); + } +} + +/** + * params {{category: string, value: Cell|null, queryId?: number}} + * @return {Cell} + */ +DnsItem.createChangeContentEntryBody = async (params) => { + const body = new Cell(); + body.bits.writeUint(0x4eb1f0f9, 32); // OP + body.bits.writeUint(params.queryId || 0, 64); // query_id + body.bits.writeUint(await categoryToBN(params.category), 256); + if (params.value) { + body.refs[0] = params.value; + } + return body; +} + +module.exports = {DnsItem: DnsItem}; \ No newline at end of file diff --git a/src/contract/dns/DnsUtils.js b/src/contract/dns/DnsUtils.js new file mode 100644 index 00000000..0be3ed61 --- /dev/null +++ b/src/contract/dns/DnsUtils.js @@ -0,0 +1,279 @@ +const {parseAddress} = require("../token/nft/NftUtils"); +const {AdnlAddress, StorageBagId, BN, sha256, bytesToHex, bytesToBase64} = require("../../utils"); +const {Cell} = require("../../boc"); + +const DNS_CATEGORY_NEXT_RESOLVER = 'dns_next_resolver'; // Smart Contract address +const DNS_CATEGORY_WALLET = 'wallet'; // Smart Contract address +const DNS_CATEGORY_SITE = 'site'; // ADNL address or Bag ID +const DNS_CATEGORY_STORAGE = 'storage'; // Bag ID + +/** + * @param category {string | undefined} + * @return {BN} + */ +const categoryToBN = async (category) => { + if (!category) return new BN(0); // all categories + const categoryBytes = new TextEncoder().encode(category); + const categoryHash = new Uint8Array(await sha256(categoryBytes)); + return new BN(bytesToHex(categoryHash), 16); +} + +/** + * @param smartContractAddress {Address} + * @return {Cell} + */ +const createSmartContractAddressRecord = (smartContractAddress) => { + const cell = new Cell(); + cell.bits.writeUint(0x9fd3, 16); // https://github.com/ton-blockchain/ton/blob/7e3df93ca2ab336716a230fceb1726d81bac0a06/crypto/block/block.tlb#L827 + cell.bits.writeAddress(smartContractAddress); + cell.bits.writeUint(0, 8); // flags + return cell; +} + +/** + * @param adnlAddress {AdnlAddress} + * @return {Cell} + */ +const createAdnlAddressRecord = (adnlAddress) => { + const cell = new Cell(); + cell.bits.writeUint(0xad01, 16); // https://github.com/ton-blockchain/ton/blob/7e3df93ca2ab336716a230fceb1726d81bac0a06/crypto/block/block.tlb#L821 + cell.bits.writeBytes(adnlAddress.bytes); + cell.bits.writeUint(0, 8); // flags + return cell; +} + +/** + * @param storageBagId {StorageBagId} + * @return {Cell} + */ +const createStorageBagIdRecord = (storageBagId) => { + const cell = new Cell(); + cell.bits.writeUint(0x7473, 16); + cell.bits.writeBytes(storageBagId.bytes); + return cell; +} + +/** + * @param smartContractAddress {Address} + * @return {Cell} + */ +const createNextResolverRecord = (smartContractAddress) => { + const cell = new Cell(); + cell.bits.writeUint(0xba93, 16); // https://github.com/ton-blockchain/ton/blob/7e3df93ca2ab336716a230fceb1726d81bac0a06/crypto/block/block.tlb#L819 + cell.bits.writeAddress(smartContractAddress); + return cell; +} + +/** + * @private + * @param cell {Cell} + * @param prefix0 {number} + * @param prefix1 {number} + * @return {Address|null} + */ +const parseSmartContractAddressImpl = (cell, prefix0, prefix1) => { + if (cell.bits.array[0] !== prefix0 || cell.bits.array[1] !== prefix1) throw new Error('Invalid dns record value prefix'); + cell.bits.array = cell.bits.array.slice(2); // skip prefix - first 16 bits + return parseAddress(cell); +} + +/** + * @param cell {Cell} + * @return {Address|null} + */ +const parseSmartContractAddressRecord = (cell) => { + return parseSmartContractAddressImpl(cell, 0x9f, 0xd3); +} + +/** + * @param cell {Cell} + * @return {Address|null} + */ +const parseNextResolverRecord = (cell) => { + return parseSmartContractAddressImpl(cell, 0xba, 0x93); +} + +/** + * @param cell {Cell} + * @return {AdnlAddress} + */ +const parseAdnlAddressRecord = (cell) => { + if (cell.bits.array[0] !== 0xad || cell.bits.array[1] !== 0x01) throw new Error('Invalid dns record value prefix'); + const bytes = cell.bits.array.slice(2, 2 + 32); // skip prefix - first 16 bits + return new AdnlAddress(bytes); +} + +/** + * @param cell {Cell} + * @return {StorageBagId} + */ +const parseStorageBagIdRecord = (cell) => { + if (cell.bits.array[0] !== 0x74 || cell.bits.array[1] !== 0x73) throw new Error('Invalid dns record value prefix'); + const bytes = cell.bits.array.slice(2, 2 + 32); // skip prefix - first 16 bits + return new StorageBagId(bytes); +} + +/** + * @param cell {Cell} + * @return {AdnlAddress|StorageBagId|null} + */ +const parseSiteRecord = (cell) => { + if (!cell) return null; + if (cell.bits.array[0] === 0xad || cell.bits.array[1] === 0x01) { + return parseAdnlAddressRecord(cell); + } else { + return parseStorageBagIdRecord(cell); + } +} + +/** + * @private + * @param provider {HttpProvider} + * @param dnsAddress {string} address of dns smart contract + * @param rawDomainBytes {Uint8Array} + * @param category {string | undefined} category of requested DNS record + * @param oneStep {boolean | undefined} non-recursive + * @returns {Promise} + */ +const dnsResolveImpl = async (provider, dnsAddress, rawDomainBytes, category, oneStep) => { + const len = rawDomainBytes.length * 8; + + const domainCell = new Cell(); + domainCell.bits.writeBytes(rawDomainBytes); + + const categoryBN = await categoryToBN(category); + const result = await provider.call2(dnsAddress, 'dnsresolve', [['tvm.Slice', bytesToBase64(await domainCell.toBoc(false))], ['num', categoryBN.toString()]]); + if (result.length !== 2) { + throw new Error('Invalid dnsresolve response'); + } + const resultLen = result[0].toNumber(); + + let cell = result[1]; + if ((cell instanceof Array) && cell.length === 0) { + cell = null; + } + + if (cell && !cell.bits) { // not a Cell + throw new Error('Invalid dnsresolve response'); + } + + if (resultLen === 0) { + return null; // domain cannot be resolved + } + + if (resultLen % 8 !== 0) { + throw new Error('domain split not at a component boundary'); + } + // if (rawDomainBytes[resultLen] !== 0) { + // throw new Error('domain split not at a component boundary'); + // } + if (resultLen > len) { + throw new Error('invalid response ' + resultLen + '/' + len); + } else if (resultLen === len) { + if (category === DNS_CATEGORY_NEXT_RESOLVER) { + return cell ? parseNextResolverRecord(cell) : null; + } else if (category === DNS_CATEGORY_WALLET) { + return cell ? parseSmartContractAddressRecord(cell) : null; + } else if (category === DNS_CATEGORY_SITE) { + return cell ? parseSiteRecord(cell) : null; + } else if (category === DNS_CATEGORY_STORAGE) { + return cell ? parseStorageBagIdRecord(cell) : null; + } else { + return cell; + } + } else { + if (!cell) { + return null; // domain cannot be resolved + } else { + const nextAddress = parseNextResolverRecord(cell); + if (oneStep) { + if (category === DNS_CATEGORY_NEXT_RESOLVER) { + return nextAddress; + } else { + return null; + } + } else { + return await dnsResolveImpl(provider, nextAddress.toString(), rawDomainBytes.slice(resultLen / 8), category, false); + } + } + } +} + +/** + * Verify and convert domain + * @param domain {string} + * @return {Uint8Array} + */ +const domainToBytes = (domain) => { + if (!domain || !domain.length) { + throw new Error('empty domain'); + } + if (domain === '.') { + return new Uint8Array([0]); + } + + domain = domain.toLowerCase(); + + for (let i = 0; i < domain.length; i++) { + if (domain.charCodeAt(i) <= 32) { + throw new Error('bytes in range 0..32 are not allowed in domain names'); + } + } + + for (let i = 0; i < domain.length; i++) { + const s = domain.substring(i, i + 1); + for (let c = 127; c <= 159; c++) { // another control codes range + if (s === String.fromCharCode(c)) { + throw new Error('bytes in range 127..159 are not allowed in domain names'); + } + } + } + + const arr = domain.split('.'); + + arr.forEach(part => { + if (!part.length) { + throw new Error('domain name cannot have an empty component'); + } + }); + + let rawDomain = arr.reverse().join('\0') + '\0'; + if (rawDomain.length < 126) { + rawDomain = '\0' + rawDomain; + } + + return new TextEncoder().encode(rawDomain); +} + +/** + * @param provider {HttpProvider} + * @param rootDnsAddress {string} address of root DNS smart contract + * @param domain {string} e.g "sub.alice.ton" + * @param category {string | undefined} category of requested DNS record + * @param oneStep {boolean | undefined} non-recursive + * @returns {Promise} + */ +const dnsResolve = async (provider, rootDnsAddress, domain, category, oneStep) => { + const rawDomainBytes = domainToBytes(domain); + + return dnsResolveImpl(provider, rootDnsAddress, rawDomainBytes, category, oneStep); +} + +module.exports = { + DNS_CATEGORY_NEXT_RESOLVER, + DNS_CATEGORY_SITE, + DNS_CATEGORY_WALLET, + DNS_CATEGORY_STORAGE, + categoryToBN, + domainToBytes, + createSmartContractAddressRecord, + createAdnlAddressRecord, + createNextResolverRecord, + parseSmartContractAddressRecord, + parseAdnlAddressRecord, + parseStorageBagIdRecord, + parseSiteRecord, + parseNextResolverRecord, + createStorageBagIdRecord, + dnsResolve +}; \ No newline at end of file diff --git a/src/contract/dns/index.js b/src/contract/dns/index.js new file mode 100644 index 00000000..7f3598f5 --- /dev/null +++ b/src/contract/dns/index.js @@ -0,0 +1,7 @@ +const Dns = require("./Dns").default; +const {DnsCollection} = require("./DnsCollection"); +const {DnsItem} = require("./DnsItem"); + +module.exports.default = { + Dns, DnsCollection, DnsItem +}; \ No newline at end of file diff --git a/src/contract/highloadWallet/HighloadQueryId.js b/src/contract/highloadWallet/HighloadQueryId.js new file mode 100644 index 00000000..a48bfbba --- /dev/null +++ b/src/contract/highloadWallet/HighloadQueryId.js @@ -0,0 +1,109 @@ +const BIT_NUMBER_SIZE = 10n; // 10 bit +const SHIFT_SIZE = 13n; // 13 bit +const MAX_BIT_NUMBER = 1022n; +const MAX_SHIFT = 8191n; // 2^13 = 8192 + +class HighloadQueryId { + constructor() { + /** + * @private + * @type {bigint} [0 .. 8191] + */ + this.shift = 0n; + /** + * @private + * @type {bigint} [0 .. 1022] + */ + this.bitnumber = 0n; + } + + /** + * @param shift {bigint} + * @param bitnumber {bigint} + * @return {HighloadQueryId} + */ + static fromShiftAndBitNumber(shift, bitnumber) { + const q = new HighloadQueryId(); + q.shift = shift; + if (q.shift < 0) throw new Error('invalid shift'); + if (q.shift > MAX_SHIFT) throw new Error('invalid shift'); + q.bitnumber = bitnumber; + if (q.bitnumber < 0) throw new Error('invalid bitnumber'); + if (q.bitnumber > MAX_BIT_NUMBER) throw new Error('invalid bitnumber'); + return q; + } + + getNext() { + let newBitnumber = this.bitnumber + 1n; + let newShift = this.shift; + + if (newShift === MAX_SHIFT && newBitnumber > (MAX_BIT_NUMBER - 1n)) { + throw new Error('Overload'); // NOTE: we left one queryId for emergency withdraw + } + + if (newBitnumber > MAX_BIT_NUMBER) { + newBitnumber = 0n; + newShift += 1n; + if (newShift > MAX_SHIFT) { + throw new Error('Overload') + } + } + + return HighloadQueryId.fromShiftAndBitNumber(newShift, newBitnumber); + } + + hasNext() { + const isEnd = this.bitnumber >= (MAX_BIT_NUMBER - 1n) && this.shift === MAX_SHIFT; // NOTE: we left one queryId for emergency withdraw; + return !isEnd; + } + + /** + * @return {bigint} + */ + getShift() { + return this.shift; + } + + /** + * @return {bigint} + */ + getBitNumber() { + return this.bitnumber; + } + + /** + * @return {bigint} + */ + getQueryId() { + return (this.shift << BIT_NUMBER_SIZE) + this.bitnumber; + } + + /** + * @param queryId {bigint} + * @return {HighloadQueryId} + */ + static fromQueryId(queryId) { + const shift = queryId >> BIT_NUMBER_SIZE; + const bitnumber = queryId & 1023n; + return this.fromShiftAndBitNumber(shift, bitnumber); + } + + /** + * @param i {bigint} + * @return {HighloadQueryId} + */ + static fromSeqno(i) { + const shift = i / 1023n; + const bitnumber = i % 1023n; + return this.fromShiftAndBitNumber(shift, bitnumber); + } + + /** + * @return {bigint} [0 .. 8380415] + */ + toSeqno() { + return this.bitnumber + this.shift * 1023n; + } +} + +module.exports = {HighloadQueryId}; diff --git a/src/contract/highloadWallet/HighloadWalletContractV3.js b/src/contract/highloadWallet/HighloadWalletContractV3.js new file mode 100644 index 00000000..ff25b714 --- /dev/null +++ b/src/contract/highloadWallet/HighloadWalletContractV3.js @@ -0,0 +1,235 @@ +const {Cell} = require("../../boc"); +const {Contract} = require("../index.js"); +const {Address, BN, nacl} = require("../../utils"); + +// https://github.com/ton-blockchain/highload-wallet-contract-v3, tag 'v3.00' +const CODE_HEX = "b5ee9c7241021001000228000114ff00f4a413f4bcf2c80b01020120020d02014803040078d020d74bc00101c060b0915be101d0d3030171b0915be0fa4030f828c705b39130e0d31f018210ae42e5a4ba9d8040d721d74cf82a01ed55fb04e030020120050a02027306070011adce76a2686b85ffc00201200809001aabb6ed44d0810122d721d70b3f0018aa3bed44d08307d721d70b1f0201200b0c001bb9a6eed44d0810162d721d70b15800e5b8bf2eda2edfb21ab09028409b0ed44d0810120d721f404f404d33fd315d1058e1bf82325a15210b99f326df82305aa0015a112b992306dde923033e2923033e25230800df40f6fa19ed021d721d70a00955f037fdb31e09130e259800df40f6fa19cd001d721d70a00937fdb31e0915be270801f6f2d48308d718d121f900ed44d0d3ffd31ff404f404d33fd315d1f82321a15220b98e12336df82324aa00a112b9926d32de58f82301de541675f910f2a106d0d31fd4d307d30cd309d33fd315d15168baf2a2515abaf2a6f8232aa15250bcf2a304f823bbf2a35304800df40f6fa199d024d721d70a00f2649130e20e01fe5309800df40f6fa18e13d05004d718d20001f264c858cf16cf8301cf168e1030c824cf40cf8384095005a1a514cf40e2f800c94039800df41704c8cbff13cb1ff40012f40012cb3f12cb15c9ed54f80f21d0d30001f265d3020171b0925f03e0fa4001d70b01c000f2a5fa4031fa0031f401fa0031fa00318060d721d300010f0020f265d2000193d431d19130e272b1fb00b585bf03"; +const HIGHLOAD_WALLET_SUBWALLET_ID = 0x10ad; + +const checkTimeout = (seconds) => { + if (!seconds) throw new Error('invalid timeout'); + if (seconds < 60 * 10) throw new Error('minimum timeout 10 minute'); + if (seconds > 60 * 60 * 24 * 30) throw new Error('maximum timeout 30 days'); +} + +class HighloadWalletContractV3 extends Contract { + + /** + * @param provider {HttpProvider} + * @param options + * @param options.[publicKey] {Uint8Array} + * @param options.[timeout] {number} + * @param options.[walletId] {number} + * @param options.[address] {Address | string} + */ + constructor(provider, options) { + if (options.wc) throw new Error('only basechain (wc = 0) supported'); + options.wc = 0; + if (!options.address) { + if (!options.publicKey) throw new Error('no publicKey'); + if (!(options.publicKey instanceof Uint8Array)) throw new Error('publicKey not Uint8Array'); + checkTimeout(options.timeout); + } + options.code = Cell.oneFromBoc(CODE_HEX); + super(provider, options); + if (!this.options.walletId) this.options.walletId = HIGHLOAD_WALLET_SUBWALLET_ID; + + this.methods = { + /** + * @param params {{secretKey: Uint8Array, queryId: HighloadQueryId, createdAt: number, toAddress: Address | string, amount: BN, payload?: string | Uint8Array | Cell, sendMode?: number, needDeploy?: boolean }} + */ + transfer: (params) => Contract.createMethod(provider, this.createTransferMessage(params.secretKey, params.toAddress, params.amount, params.queryId, params.payload, params.sendMode, params.createdAt, params.needDeploy)), + } + + this.methods.getPublicKey = this.getPublicKey.bind(this); + this.methods.getWalletId = this.getWalletId.bind(this); + this.methods.getLastCleanTime = this.getLastCleanTime.bind(this); + this.methods.getTimeout = this.getTimeout.bind(this); + this.methods.isProcessed = this.isProcessed.bind(this); + } + + getName() { + return 'highload-3'; + } + + /** + * @override + * @return {Cell} cell contains wallet data + */ + createDataCell() { + if (this.options.walletId !== 0 && !this.options.walletId) throw new Error('no walletId'); + if (!this.options.publicKey) throw new Error('no publicKey'); + if (!(this.options.publicKey instanceof Uint8Array)) throw new Error('publicKey not Uint8Array'); + checkTimeout(this.options.timeout); + + const cell = new Cell(); + cell.bits.writeBytes(this.options.publicKey); + cell.bits.writeUint(this.options.walletId, 32); + cell.bits.writeUint(0, 1); // empty old_queries + cell.bits.writeUint(0, 1); // empty queries + cell.bits.writeUint(0, 64); // last_clean_time + cell.bits.writeUint(this.options.timeout, 22); + return cell; + } + + /** + * @private + * @param queryId {HighloadQueryId} + * @param createdAt {number} + * @param sendMode {number} + * @param messageToSend {Cell} + * @return {Cell} + */ + createSigningMessage(queryId, createdAt, sendMode, messageToSend) { + if (isNaN(sendMode) || sendMode === undefined || sendMode === null) throw new Error('invalid sendMode'); + if (isNaN(createdAt) || createdAt === undefined || createdAt === null) throw new Error('invalid createdAt'); + checkTimeout(this.options.timeout); + + const cell = new Cell(); + cell.bits.writeUint(this.options.walletId, 32); + cell.refs.push(messageToSend); + cell.bits.writeUint(sendMode, 8); + cell.bits.writeUint(Number(queryId.getShift()), 13); + cell.bits.writeUint(Number(queryId.getBitNumber()), 10); + cell.bits.writeUint(createdAt, 64); + cell.bits.writeUint(this.options.timeout, 22); + return cell; + } + + /** + * @param secretKey {Uint8Array} nacl.KeyPair.secretKey + * @param address {Address | string} + * @param amount {BN | number} in nanotons + * @param queryId {HighloadQueryId} + * @param [payload] {string | Uint8Array | Cell} + * @param [sendMode] {number} + * @param createAt {number} + * @param [needDeploy] {boolean} + * @return {Promise<{address: Address, signature: Uint8Array, message: Cell, cell: Cell, body: Cell, signingMessage: Cell}>} + */ + async createTransferMessage( + secretKey, + address, + amount, + queryId, + payload = "", + sendMode = 3, + createAt, + needDeploy = false + ) { + if (queryId === null || queryId === undefined) { + throw new Error('queryId must be number >= 0') + } + if (createAt === null || createAt === undefined || createAt < 0) { + throw new Error('createAt must be number >= 0') + } + if (sendMode === null || sendMode === undefined) { + sendMode = 3; + } + const messageToSend = Contract.createOutMsg(address, amount, payload); + const signingMessage = this.createSigningMessage(queryId, createAt, sendMode, messageToSend); + + return this.createExternalMessage(signingMessage, secretKey, needDeploy); + } + + /** + * @protected + * @param signingMessage {Cell} + * @param secretKey {Uint8Array} nacl.KeyPair.secretKey + * @param needDeploy {boolean} + * @return {Promise<{address: Address, signature: Uint8Array, message: Cell, cell: Cell, body: Cell, signingMessage: Cell}>} + */ + async createExternalMessage( + signingMessage, + secretKey, + needDeploy + ) { + const signature = nacl.sign.detached(await signingMessage.hash(), secretKey); + + const body = new Cell(); + body.bits.writeBytes(signature); + body.refs.push(signingMessage); + + let stateInit = null, code = null, data = null; + + if (needDeploy) { + if (!this.options.publicKey) { + const keyPair = nacl.sign.keyPair.fromSecretKey(secretKey) + this.options.publicKey = keyPair.publicKey; + } + const deploy = await this.createStateInit(); + stateInit = deploy.stateInit; + code = deploy.code; + data = deploy.data; + } + + const selfAddress = await this.getAddress(); + const header = Contract.createExternalMessageHeader(selfAddress); + const resultMessage = Contract.createCommonMsgInfo(header, stateInit, body); + + return { + address: selfAddress, + message: resultMessage, // old wallet_send_generate_external_message + + body: body, + signature: signature, + signingMessage: signingMessage, + + stateInit, + code, + data, + }; + } + + /** + * @return {Promise} + */ + async getWalletId() { + const myAddress = await this.getAddress(); + const id = await this.provider.call2(myAddress.toString(), 'get_subwallet_id'); + return id.toNumber(); + } + + /** + * @return {Promise} + */ + async getPublicKey() { + const myAddress = await this.getAddress(); + return this.provider.call2(myAddress.toString(), 'get_public_key'); + } + + /** + * @return {Promise} + */ + async getLastCleanTime() { + const myAddress = await this.getAddress(); + const id = await this.provider.call2(myAddress.toString(), 'get_last_clean_time'); + return id.toNumber(); + } + + /** + * @return {Promise} + */ + async getTimeout() { + const myAddress = await this.getAddress(); + const id = await this.provider.call2(myAddress.toString(), 'get_timeout'); + return id.toNumber(); + } + + /** + * @param queryId {HighloadQueryId} + * @param needClean {boolean} + * @return {Promise} + */ + async isProcessed(queryId, needClean) { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'processed?', [['num', queryId.getQueryId().toString()], ['num', needClean ? '-1' : '0']]); + return !result.isZero(); + } + +} + +HighloadWalletContractV3.WALLET_ID_BASE = HIGHLOAD_WALLET_SUBWALLET_ID; +HighloadWalletContractV3.codeHex = CODE_HEX; + +module.exports = {HighloadWalletContractV3}; diff --git a/src/contract/highloadWallet/index.js b/src/contract/highloadWallet/index.js new file mode 100644 index 00000000..91615375 --- /dev/null +++ b/src/contract/highloadWallet/index.js @@ -0,0 +1,11 @@ +const {HighloadWalletContractV3} = require("./HighloadWalletContractV3"); +const {HighloadQueryId} = require("./HighloadQueryId"); + +module.exports.default = { + HighloadQueryId, + HighloadWalletContractV3, + all: { + 'highload-3': HighloadWalletContractV3, + }, + list: [HighloadWalletContractV3] +}; diff --git a/src/contract/index.js b/src/contract/index.js index fd3a5e95..8882e4f7 100644 --- a/src/contract/index.js +++ b/src/contract/index.js @@ -1,5 +1,5 @@ const {Cell} = require("../boc"); -const {Address, bytesToBase64, bytesToHex} = require("../utils"); +const {Address, bytesToBase64, bytesToHex, BN} = require("../utils"); class Contract { /** @@ -171,6 +171,33 @@ class Contract { return message; } + /** + * @param address {Address | string} + * @param amount {BN} in nanotons + * @param payload {string | Uint8Array | Cell} + * @param stateInit? {Cell} + * @return {Cell} + */ + static createOutMsg(address, amount, payload, stateInit = null) { + let payloadCell = new Cell(); + if (payload) { + if (payload.refs) { // is Cell + payloadCell = payload; + } else if (typeof payload === 'string') { + if (payload.length > 0) { + payloadCell.bits.writeUint(0, 32); + payloadCell.bits.writeString(payload); + } + } else { + payloadCell.bits.writeBytes(payload) + } + } + + const orderHeader = Contract.createInternalMessageHeader(new Address(address), new BN(amount)); + const order = Contract.createCommonMsgInfo(orderHeader, stateInit, payloadCell); + return order; + } + //tblkch.pdf, page 57 /** * Create CommonMsgInfo contains header, stateInit, body @@ -187,7 +214,8 @@ class Contract { commonMsgInfo.bits.writeBit(true); //-1: need at least one bit for body // TODO we also should check for free refs here - if (commonMsgInfo.bits.getFreeBits() - 1 >= stateInit.bits.getUsedBits()) { + // TODO: temporary always push in ref because WalletQueryParser can parse only ref + if (false && (commonMsgInfo.bits.getFreeBits() - 1 >= stateInit.bits.getUsedBits())) { commonMsgInfo.bits.writeBit(false); commonMsgInfo.writeCell(stateInit); } else { @@ -199,7 +227,7 @@ class Contract { } // TODO we also should check for free refs here if (body) { - if (commonMsgInfo.bits.getFreeBits() >= body.bits.getUsedBits()) { + if ((commonMsgInfo.bits.getFreeBits() >= body.bits.getUsedBits()) && (commonMsgInfo.refs.length + body.refs.length <= 4)) { commonMsgInfo.bits.writeBit(false); commonMsgInfo.writeCell(body); } else { @@ -214,6 +242,16 @@ class Contract { static createMethod(provider, queryPromise) { return { + /** + * @return {Promise} + */ + getBody: async () => { + return (await queryPromise).body; + }, + + /** + * @return {Promise} + */ getQuery: async () => { return (await queryPromise).message; }, diff --git a/src/contract/lockup/LockupWalletV1.js b/src/contract/lockup/LockupWalletV1.js new file mode 100644 index 00000000..3e4c8f91 --- /dev/null +++ b/src/contract/lockup/LockupWalletV1.js @@ -0,0 +1,158 @@ +const {Cell} = require("../../boc"); +const { + Address, + BN, + base64ToBytes +} = require("../../utils"); +const {WalletContract} = require("../wallet/WalletContract"); + +const WALLET_ID_BASE = 698983191; + +class LockupWalletV1 extends WalletContract { + + /** + * @param provider {HttpProvider} + * @param options {{publicKey?: Uint8Array, address?: Address | string, wc?: number, config: any}} + * + * Config json is {config} + */ + constructor(provider, options) { + // options.config: + // { + // wallet_type: "lockup-0.1", + // config_pubkey: , + // allowed_destinations: [ "addr1", "addr2", ... ] + // } + + options.code = Cell.oneFromBoc("B5EE9C7241021E01000261000114FF00F4A413F4BCF2C80B010201200203020148040501F2F28308D71820D31FD31FD31F802403F823BB13F2F2F003802251A9BA1AF2F4802351B7BA1BF2F4801F0BF9015410C5F9101AF2F4F8005057F823F0065098F823F0062071289320D74A8E8BD30731D4511BDB3C12B001E8309229A0DF72FB02069320D74A96D307D402FB00E8D103A4476814154330F004ED541D0202CD0607020120131402012008090201200F100201200A0B002D5ED44D0D31FD31FD3FFD3FFF404FA00F404FA00F404D1803F7007434C0C05C6C2497C0F83E900C0871C02497C0F80074C7C87040A497C1383C00D46D3C00608420BABE7114AC2F6C2497C338200A208420BABE7106EE86BCBD20084AE0840EE6B2802FBCBD01E0C235C62008087E4055040DBE4404BCBD34C7E00A60840DCEAA7D04EE84BCBD34C034C7CC0078C3C412040DD78CA00C0D0E00130875D27D2A1BE95B0C60000C1039480AF00500161037410AF0050810575056001010244300F004ED540201201112004548E1E228020F4966FA520933023BB9131E2209835FA00D113A14013926C21E2B3E6308003502323287C5F287C572FFC4F2FFFD00007E80BD00007E80BD00326000431448A814C4E0083D039BE865BE803444E800A44C38B21400FE809004E0083D10C06002012015160015BDE9F780188242F847800C02012017180201481B1C002DB5187E006D88868A82609E00C6207E00C63F04EDE20B30020158191A0017ADCE76A268699F98EB85FFC00017AC78F6A268698F98EB858FC00011B325FB513435C2C7E00017B1D1BE08E0804230FB50F620002801D0D3030178B0925B7FE0FA4031FA403001F001A80EDAA4"); + super(provider, options); + if (!this.options.walletId) this.options.walletId = WALLET_ID_BASE + this.options.wc; + + this.methods.getPublicKey = this.getPublicKey.bind(this); + this.methods.getWalletId = this.getWalletId.bind(this); + this.methods.getLiquidBalance = this.getLiquidBalance.bind(this); + this.methods.getNominalRestrictedBalance = this.getNominalRestrictedBalance.bind(this); + this.methods.getNominalLockedBalance = this.getNominalLockedBalance.bind(this); + } + + getName() { + return 'lockup-0.1'; + } + + /** + * @override + * @private + * @param seqno? {number} + * @param expireAt?: {number} + * @param withoutOp? {boolean} + * @return {Cell} + */ + createSigningMessage(seqno, expireAt, withoutOp) { + seqno = seqno || 0; + expireAt = expireAt || (Math.floor(Date.now() / 1e3) + 60); + const message = new Cell(); + message.bits.writeUint(this.options.walletId, 32); + if (seqno === 0) { + // message.bits.writeInt(-1, 32);// todo: dont work + for (let i = 0; i < 32; i++) { + message.bits.writeBit(1); + } + } else { + message.bits.writeUint(expireAt, 32); + } + message.bits.writeUint(seqno, 32); + return message; + } + + /** + * @override + * @return {Cell} cell contains wallet data + */ + createDataCell() { + // from restricted.fc: + // .store_int(seqno, 32) + // .store_int(subwallet_id, 32) + // .store_uint(public_key, 256) + // .store_uint(config_public_key, 256) + // .store_dict(allowed_destinations) + // .store_grams(total_locked_value) + // .store_dict(locked) + // .store_grams(total_restricted_value) + // .store_dict(restricted).end_cell(); + + const cell = new Cell(); + cell.bits.writeUint(0, 32); // seqno + cell.bits.writeUint(this.options.walletId, 32); + cell.bits.writeBytes(this.options.publicKey); + + // TODO: write config.config_public_key (need to sort out encoding - the params come in base64), + // TODO: write the dict of allowed destinations (address is a key to an empty value). + cell.bits.writeBytes(base64ToBytes(this.options.config.config_public_key)); + if (this.options.config.allowed_destinations) { + cell.bits.writeUint(1, 1); + cell.refs.push(Cell.oneFromBoc(base64ToBytes(this.options.config.allowed_destinations))); + } else { + cell.bits.writeUint(0, 1); + } + + cell.bits.writeGrams(0); // .store_grams(total_locked_value) + cell.bits.writeUint(0, 1); // empty locked dict + cell.bits.writeGrams(0); // .store_grams(total_restricted_value) + cell.bits.writeUint(0, 1); // empty locked dict + return cell; + } + + /** + * @return {Promise} + */ + async getWalletId() { + const myAddress = await this.getAddress(); + const id = await this.provider.call2(myAddress.toString(), 'get_subwallet_id'); + return id.toNumber(); + } + + /** + * @return {Promise} + */ + async getPublicKey() { + const myAddress = await this.getAddress(); + return this.provider.call2(myAddress.toString(), 'get_public_key'); + } + + + /** + * @return {Promise} Amount of nanotoncoins that can be spent immediately. + */ + async getLiquidBalance() { + const balances = await this.getBalances(); + return balances[0] - balances[1] - balances[2]; + } + + /** + * @return {Promise} Amount of nanotoncoins that can be spent after the timelock OR to the whitelisted addresses. + */ + async getNominalRestrictedBalance() { + return await this.getBalances()[1]; + } + + /** + * @return {Promise} Amount of nanotoncoins that can be spent after the timelock only (whitelisted addresses not used). + */ + async getNominalLockedBalance() { + return await this.getBalances()[2]; + } + + /** + * @return {Promise<[BN,BN,BN]>} Total amount of nanotoncoins on the contract, + * nominal restricted value + * nominal locked value + */ + async getBalances() { + const myAddress = await this.getAddress(); + return this.provider.call2(myAddress.toString(), 'get_balances'); + } +} + +LockupWalletV1.WALLET_ID_BASE = WALLET_ID_BASE; + +module.exports = {LockupWalletV1}; diff --git a/src/contract/lockup/VestingWalletV1.js b/src/contract/lockup/VestingWalletV1.js new file mode 100644 index 00000000..a9f732cd --- /dev/null +++ b/src/contract/lockup/VestingWalletV1.js @@ -0,0 +1,226 @@ +const {Cell} = require("../../boc"); +const { + Address, + BN, bytesToHex, +} = require("../../utils"); +const {WalletContract} = require("../wallet/WalletContract"); +const {parseAddress} = require("../token/nft/NftUtils"); +const {Contract} = require("../index"); + +const WALLET_ID_BASE = 0x10C; // ATTENTION: need to be different with standard wallet id +const CODE_HEX = 'b5ee9c7241021c010003fb000114ff00f4a413f4bcf2c80b01020120030203b8f28308d71820d31fd31fd31f02f823bbf264ed44d0d31fd31fd3ff305abaf2a15033baf2a202f9014033f910f2a3f800db3c20d74ac0018e99ed44ed45ed47915bed67ed65ed648e82db3ced41edf101f2ff9130e2f841a4f861db3c1b1413020148110402012008050201200706020db9846db3cdb3c81b1a0129ba462db3cf845f846f847f848f849f84af84bf84481b0201200e090201620d0a02016a0c0b012fa2c76cf3e9100723281f2fff2743e112040423d029be84c61b000fa25fb513435c2c7e014bad346d9e36fc22470d4080847a4937d29910ce6903e9ff9837812801b7810148987159f318401b02016e100f0019af1df6a26840106b90eb858fc00019adce76a26840206b90eb85ffc003acd06c2220d749c160915be001d0d3030171b0915be0fa4030db3c01d31fd33ff84b5240c705238210a7733acdbab08ea46c12db3c8210f7733acd01708018c8cb055004cf1623fa0213cb6acb1fcb3fc98040fb00e30e1b141201cef84a5240c7050382107258a69bba13b08ed18e2c01fa407fc8ca0002fa4401c8ca07cbffc9d0f8441023810108f441f86420d74ac200209501d430d001deb312e68210f258a69b32708018c8cb055004cf1623fa0213cb6acb1fcb3fc98040fb00db3c925f03e2130066f848f847f846f845c8cb3fcb1fcb1fcb1ff849fa02f84acf16f84bcf16c9f844f843f842f841c8cb1fcb1fcbfff400ccc9ed54025cd307d4d1f823db3c20c2008e9b22c003f2e06421d0d303fa4031fa40f84a5220c705b3925f04e30d9130e201fb001a1503fa21fa4401c8ca07cbffc9d0f844810108f40a6fa1318f5f330172b0c002f2e06501fa003171d721fa0031fa0031d33f31d31f31d30001c000f2e066d3000193d430d0de2171db3c8e2a31d31f302082104e73744bba21821047657424bab121821056744370bab1018210566f7465bab1f2e067e30e70925f03e220c200191716000e9372fb029130e202ea0170db3c8e6d20d749c2008e63d31f21c00022830bbab122811001bab122821047d54391bab1228210595f07bcbab122821069fb306cbab1228210566f7465bab122821056744370bab1f2e06701c00021d749c200b08e15d3073020c06421c077b121c044b101c057b1f2e0689130e29130e2e30d1918001ad31f308210566f7465baf2e067004401fa4401c3ff925b70e001f833206e925b70e0d020d7498307b9925b70e0d70bffba0060f845f846a05210bc923070e0f845f848a05210b99330f849e0f849f849f84513a1f847a904f846f847a9041023a984a1007eed44d0d31f01f861d31f01f862d3ff01f863f40401f864d401d0d33f01f865d31f01f866d31f01f867d31f01f868fa0001f869fa4001f86afa4001f86bd1d10a20c6a7'; + +class VestingWalletV1 extends WalletContract { + + /** + * @param provider {HttpProvider} + * @param options {{walletId?: number, publicKey?: Uint8Array, vestingStartTime?: number, vestingTotalDuration?:number, unlockPeriod?:number, cliffDuration?: number, vestingTotalAmount?: BN, vestingSenderAddress?: Address, ownerAddress?:Address, address?: Address | string, wc?: number}} + */ + constructor(provider, options) { + options.code = Cell.oneFromBoc(CODE_HEX); + super(provider, options); + if (!this.options.walletId) this.options.walletId = WALLET_ID_BASE + this.options.wc; + + this.methods.getPublicKey = this.getPublicKey.bind(this); + this.methods.getWalletId = this.getWalletId.bind(this); + this.methods.getLockedAmount = this.getLockedAmount.bind(this); + this.methods.getVestingData = this.getVestingData.bind(this); + this.methods.getWhitelist = this.getWhitelist.bind(this); + } + + getName() { + return 'vesting-1'; + } + + /** + * @override + * @private + * @param seqno? {number} + * @param expireAt? {number} + * @param withoutOp? {boolean} + * @return {Cell} + */ + createSigningMessage(seqno, expireAt, withoutOp) { + seqno = seqno || 0; + expireAt = expireAt || (Math.floor(Date.now() / 1e3) + 60); + const message = new Cell(); + message.bits.writeUint(this.options.walletId, 32); + if (seqno === 0) { + // message.bits.writeInt(-1, 32);// todo: dont work + for (let i = 0; i < 32; i++) { + message.bits.writeBit(1); + } + } else { + message.bits.writeUint(expireAt, 32); + } + message.bits.writeUint(seqno, 32); + return message; + } + + /** + * @override + * @return {Cell} cell contains wallet data + */ + createDataCell() { + if (this.options.walletId !== 0 && !this.options.walletId) throw new Error('no walletId'); + if (!this.options.publicKey) throw new Error('no publicKey'); + if (!(this.options.publicKey instanceof Uint8Array)) throw new Error('publicKey not Uint8Array'); + if (this.options.vestingStartTime !== 0 && !this.options.vestingStartTime) throw new Error('no vestingStartTime'); + if (this.options.vestingTotalDuration <= 0) throw new Error('vestingTotalDuration cant be zero or negative'); + if (!this.options.vestingTotalDuration) throw new Error('no vestingTotalDuration'); + if (this.options.vestingTotalDuration > 2 ** 32 - 1) throw new Error('vestingTotalDuration > 2^32 - 1'); + if (this.options.unlockPeriod <= 0) throw new Error('unlockPeriod cant be zero or negative'); + if (!this.options.unlockPeriod) throw new Error('no unlockPeriod'); + if (this.options.unlockPeriod > this.options.vestingTotalDuration) throw new Error('unlockPeriod > vestingTotalDuration'); + if (this.options.cliffDuration !== 0 && (!this.options.cliffDuration)) throw new Error('no cliffDuration'); + if (this.options.cliffDuration < 0) throw new Error('cliffDuration cant be negative'); + if (this.options.cliffDuration >= this.options.vestingTotalDuration) throw new Error('cliffDuration >= vestingTotalDuration'); + const durationMod = new BN(this.options.vestingTotalDuration).div(new BN(this.options.unlockPeriod)).mul(new BN(this.options.unlockPeriod)); + if (!durationMod.eq(new BN(this.options.vestingTotalDuration))) throw new Error('vestingTotalDuration mod unlockPeriod != 0'); + const cliffMod = new BN(this.options.cliffDuration).div(new BN(this.options.unlockPeriod)).mul(new BN(this.options.unlockPeriod)); + if (!cliffMod.eq(new BN(this.options.cliffDuration))) throw new Error('cliffDuration mod unlockPeriod != 0'); + if (!this.options.vestingTotalAmount) throw new Error('no vestingTotalAmount'); + if (!this.options.vestingTotalAmount.gt(new BN(0))) throw new Error('vestingTotalAmount cant be zero'); + if (!this.options.vestingSenderAddress) throw new Error('no vestingSenderAddress'); + if (!(this.options.vestingSenderAddress instanceof Address)) throw new Error('vestingSenderAddress not Address'); + if (!this.options.ownerAddress) throw new Error('no ownerAddress'); + if (!(this.options.ownerAddress instanceof Address)) throw new Error('ownerAddress not Address'); + + const cell = new Cell(); + cell.bits.writeUint(0, 32); // seqno + cell.bits.writeUint(this.options.walletId, 32); // subwallet_id + cell.bits.writeUint(new BN(bytesToHex(this.options.publicKey), 16), 256); // public_key + cell.bits.writeBit(false); // empty whitelist + + const vestingCell = new Cell(); + vestingCell.bits.writeUint(this.options.vestingStartTime, 64); + vestingCell.bits.writeUint(this.options.vestingTotalDuration, 32); + vestingCell.bits.writeUint(this.options.unlockPeriod, 32); + vestingCell.bits.writeUint(this.options.cliffDuration, 32); + vestingCell.bits.writeCoins(this.options.vestingTotalAmount); + vestingCell.bits.writeAddress(new Address(this.options.vestingSenderAddress)); + vestingCell.bits.writeAddress(new Address(this.options.ownerAddress)); + + cell.refs[0] = vestingCell; + + return cell; + } + + /** + * @param params {{ addresses: Address[], queryId?: number }} + * @return {Cell} + */ + createAddWhitelistBody(params) { + const {addresses, queryId} = params; + const root = new Cell(); + root.bits.writeUint(0x7258a69b, 32) // op + root.bits.writeUint(queryId || 0, 64) // query_id; + root.bits.writeAddress(addresses[0]); + + let cell = null; + + for (let i = addresses.length - 1; i >= 1; i--) { + const newCell = new Cell(); + newCell.bits.writeAddress(addresses[i]); + + if (cell) { + newCell.refs[0] = cell; + } + + cell = newCell; + } + + if (cell) { + root.refs[0] = cell; + } + + return root; + } + + /** + * @param params {{address: Address | string, amount: BN, payload: string | Uint8Array | Cell, sendMode?: number, queryId?: number}} + * @return {Cell} + */ + createInternalTransfer(params) { + const message = new Cell(); + message.bits.writeUint(0xa7733acd, 32); + message.bits.writeUint(params.queryId || 0, 64) // query_id; + message.bits.writeUint8(params.sendMode || 3); // send_mode + message.refs.push(Contract.createOutMsg(params.address, params.amount, params.payload)); + return message; + } + + /** + * @return {Promise} + */ + async getPublicKey() { + const myAddress = await this.getAddress(); + return this.provider.call2(myAddress.toString(), 'get_public_key'); + } + + /** + * @return {Promise} + */ + async getWalletId() { + const myAddress = await this.getAddress(); + return this.provider.call2(myAddress.toString(), 'get_subwallet_id'); + } + + /** + * @param time {number} unixtime + * @return {Promise} + */ + async getLockedAmount(time) { + const myAddress = await this.getAddress(); + return this.provider.call2(myAddress.toString(), 'get_locked_amount', [['num', time]]); + } + + /** + * @return {Promise<{vestingStartTime: number, vestingTotalDuration: number, unlockPeriod: number, cliffDuration: number, vestingTotalAmount: BN, vestingSenderAddress: Address, ownerAddress: Address, whitelistCell: Cell}>} + */ + async getVestingData() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_vesting_data'); + const vestingStartTime = result[0].toNumber(); + const vestingTotalDuration = result[1].toNumber(); + const unlockPeriod = result[2].toNumber(); + const cliffDuration = result[3].toNumber(); + const vestingTotalAmount = result[4]; + const vestingSenderAddress = parseAddress(result[5]); + const ownerAddress = parseAddress(result[6]); + const whitelistCell = result[7]; + + return { + vestingStartTime, + vestingTotalDuration, + unlockPeriod, + cliffDuration, + vestingTotalAmount, + vestingSenderAddress, + ownerAddress, + whitelistCell, + }; + } + + /** + * @return {Promise} + */ + async getWhitelist() { + const myAddress = await this.getAddress(); + const list = await this.provider.call2(myAddress.toString(), 'get_whitelist'); + const addresses = []; + for (const tuple of list) { + if (tuple.length !== 2) throw new Error('invalid whitelist result'); + const wc = tuple[0]; + const hash = tuple[1]; + const address = new Address(wc.toString(10) + ':' + hash.toString(16).padStart(64, '0')); + addresses.push(address); + } + return addresses; + } +} + +VestingWalletV1.WALLET_ID_BASE = WALLET_ID_BASE; +VestingWalletV1.codeHex = CODE_HEX; + +module.exports = {VestingWalletV1: VestingWalletV1}; diff --git a/src/contract/lockup/index.js b/src/contract/lockup/index.js index b7f655a7..2784c1c0 100644 --- a/src/contract/lockup/index.js +++ b/src/contract/lockup/index.js @@ -1,157 +1,12 @@ -const {Cell} = require("../../boc"); -const {Address, BN, toNano, bytesToHex, hexToBytes, nacl, stringToBytes, bytesToBase64, base64ToBytes} = require("../../utils"); -const {Contract} = require("../index.js"); -const {WalletContract} = require("../wallet/WalletContract"); - -const WALLET_ID_BASE = 698983191; - -class LockupWalletV1 extends WalletContract { - - /** - * @param provider {HttpProvider} - * @param options {{publicKey?: Uint8Array, address?: Address | string, wc?: number, config: any}} - * - * Config json is {config} - */ - constructor(provider, options) { - // options.config: - // { - // wallet_type: "lockup-0.1", - // config_pubkey: , - // allowed_destinations: [ "addr1", "addr2", ... ] - // } - - options.code = Cell.oneFromBoc("B5EE9C7241021E01000261000114FF00F4A413F4BCF2C80B010201200203020148040501F2F28308D71820D31FD31FD31F802403F823BB13F2F2F003802251A9BA1AF2F4802351B7BA1BF2F4801F0BF9015410C5F9101AF2F4F8005057F823F0065098F823F0062071289320D74A8E8BD30731D4511BDB3C12B001E8309229A0DF72FB02069320D74A96D307D402FB00E8D103A4476814154330F004ED541D0202CD0607020120131402012008090201200F100201200A0B002D5ED44D0D31FD31FD3FFD3FFF404FA00F404FA00F404D1803F7007434C0C05C6C2497C0F83E900C0871C02497C0F80074C7C87040A497C1383C00D46D3C00608420BABE7114AC2F6C2497C338200A208420BABE7106EE86BCBD20084AE0840EE6B2802FBCBD01E0C235C62008087E4055040DBE4404BCBD34C7E00A60840DCEAA7D04EE84BCBD34C034C7CC0078C3C412040DD78CA00C0D0E00130875D27D2A1BE95B0C60000C1039480AF00500161037410AF0050810575056001010244300F004ED540201201112004548E1E228020F4966FA520933023BB9131E2209835FA00D113A14013926C21E2B3E6308003502323287C5F287C572FFC4F2FFFD00007E80BD00007E80BD00326000431448A814C4E0083D039BE865BE803444E800A44C38B21400FE809004E0083D10C06002012015160015BDE9F780188242F847800C02012017180201481B1C002DB5187E006D88868A82609E00C6207E00C63F04EDE20B30020158191A0017ADCE76A268699F98EB85FFC00017AC78F6A268698F98EB858FC00011B325FB513435C2C7E00017B1D1BE08E0804230FB50F620002801D0D3030178B0925B7FE0FA4031FA403001F001A80EDAA4"); - super(provider, options); - if (!this.options.walletId) this.options.walletId = WALLET_ID_BASE + this.options.wc; - - this.methods.getPublicKey = this.getPublicKey.bind(this); - this.methods.getWalletId = this.getWalletId.bind(this); - this.methods.getLiquidBalance = this.getLiquidBalance.bind(this); - this.methods.getNominalRestrictedBalance = this.getNominalRestrictedBalance.bind(this); - this.methods.getNominalLockedBalance = this.getNominalLockedBalance.bind(this); - } - - getName() { - return 'lockup-0.1'; - } - - /** - * @override - * @private - * @param seqno? {number} - * @param withoutOp? {boolean} - * @return {Cell} - */ - createSigningMessage(seqno, withoutOp) { - seqno = seqno || 0; - const message = new Cell(); - message.bits.writeUint(this.options.walletId, 32); - if (seqno === 0) { - // message.bits.writeInt(-1, 32);// todo: dont work - for (let i = 0; i < 32; i++) { - message.bits.writeBit(1); - } - } else { - const date = new Date(); - const timestamp = Math.floor(date.getTime() / 1e3); - message.bits.writeUint(timestamp + 60, 32); - } - message.bits.writeUint(seqno, 32); - return message; - } - - /** - * @override - * @return {Cell} cell contains wallet data - */ - createDataCell() { - // from restricted.fc: - // .store_int(seqno, 32) - // .store_int(subwallet_id, 32) - // .store_uint(public_key, 256) - // .store_uint(config_public_key, 256) - // .store_dict(allowed_destinations) - // .store_grams(total_locked_value) - // .store_dict(locked) - // .store_grams(total_restricted_value) - // .store_dict(restricted).end_cell(); - - const cell = new Cell(); - cell.bits.writeUint(0, 32); // seqno - cell.bits.writeUint(this.options.walletId, 32); - cell.bits.writeBytes(this.options.publicKey); - - // TODO: write config.config_public_key (need to sort out encoding - the params come in base64), - // TODO: write the dict of allowed destinations (address is a key to an empty value). - cell.bits.writeBytes(base64ToBytes(this.options.config.config_public_key)); - if (this.options.config.allowed_destinations) { - cell.bits.writeUint(1, 1); - cell.refs.push(Cell.oneFromBoc(base64ToBytes(this.options.config.allowed_destinations))); - } else { - cell.bits.writeUint(0, 1); - } - - cell.bits.writeGrams(0); // .store_grams(total_locked_value) - cell.bits.writeUint(0, 1); // empty locked dict - cell.bits.writeGrams(0); // .store_grams(total_restricted_value) - cell.bits.writeUint(0, 1); // empty locked dict - return cell; - } - - /** - * @return {Promise} - */ - async getWalletId() { - const myAddress = await this.getAddress(); - const id = await this.provider.call2(myAddress.toString(), 'get_subwallet_id'); - return id.toNumber(); - } - - /** - * @return {Promise} - */ - async getPublicKey() { - const myAddress = await this.getAddress(); - return this.provider.call2(myAddress.toString(), 'get_public_key'); - } - - - /** - * @return {Promise} Amount of nanotoncoins that can be spent immediately. - */ - async getLiquidBalance() { - const balances = await this.getBalances(); - return balances[0]-balances[1]-balances[2]; - } - /** - * @return {Promise} Amount of nanotoncoins that can be spent after the timelock OR to the whitelisted addresses. - */ - async getNominalRestrictedBalance() { - return await this.getBalances()[1]; - } - - /** - * @return {Promise} Amount of nanotoncoins that can be spent after the timelock only (whitelisted addresses not used). - */ - async getNominalLockedBalance() { - return await this.getBalances()[2]; - } - /** - * @return {Promise<[BN,BN,BN]>} Total amount of nanotoncoins on the contract, - * nominal restricted value - * nominal locked value - */ - async getBalances() { - const myAddress = await this.getAddress(); - return this.provider.call2(myAddress.toString(), 'get_balances'); - } -} +const {LockupWalletV1} = require("./LockupWalletV1"); +const {VestingWalletV1} = require("./VestingWalletV1"); module.exports.default = { LockupWalletV1, + VestingWalletV1, all: { 'lockup-0.1': LockupWalletV1, + 'vesting-1': VestingWalletV1, }, - list: [LockupWalletV1] + list: [LockupWalletV1, VestingWalletV1] }; diff --git a/src/contract/payments/PaymentChannel.js b/src/contract/payments/PaymentChannel.js new file mode 100644 index 00000000..96512178 --- /dev/null +++ b/src/contract/payments/PaymentChannel.js @@ -0,0 +1,488 @@ +const {Contract} = require("../index"); +const {Cell} = require("../../boc"); +const {nacl, hexToBytes, BN} = require("../../utils"); +const {parseAddress} = require("../token/nft/NftUtils"); +const { + writePublicKey, + writeSignature, + createSignatureCell, + tag_init, + tag_cooperative_close, + tag_cooperative_commit, + tag_start_uncooperative_close, + tag_challenge_state, + tag_settle_conditionals, + tag_state, + op_top_up_balance, + op_init_channel, + op_cooperative_close, + op_cooperative_commit, + op_start_uncooperative_close, + op_challenge_quarantined_state, + op_settle_conditionals, + op_finish_uncooperative_close, + op_channel_closed, + createTopUpBalance, + createInitChannelBody, + createCooperativeCloseChannelBody, + createCooperativeCommitBody, + createConditionalPayment, + createSemiChannelBody, + createSemiChannelState, + createSignedSemiChannelState, + createStartUncooperativeCloseBody, + createChallengeQuarantinedStateBody, + createSettleConditionalsBody, + createFinishUncooperativeClose, + createOneSignature, + createTwoSignature +} = require("./PaymentUtils"); + +const PAYMENT_CHANNEL_CODE_HEX = 'B5EE9C72410230010007FB000114FF00F4A413F4BCF2C80B0102012002030201480405000AF26C21F0190202CB06070201202E2F020120080902012016170201200A0B0201200C0D0009D3610F80CC001D6B5007434C7FE8034C7CC1BC0FE19E0201580E0F0201201011002D3E11DBC4BE11DBC43232C7FE11DBC47E80B2C7F2407320008B083E1B7B51343480007E187E80007E18BE80007E18F4FFC07E1934FFC07E1974DFC07E19BC01887080A7F4C7C07E1A34C7C07E1A7D01007E1AB7807080E535007E1AF7BE1B2002012012130201201415008D3E13723E11BE117E113E10540132803E10BE80BE10FE8084F2FFC4B2FFF2DFFC02887080A7FE12BE127E121400F2C7C4B2C7FD0037807080E53E12C073253E1333C5B8B27B5520004D1C3C02FE106CFCB8193E803E800C3E1096283E18BE10C0683E18FE10BE10E8006EFCB819BC032000CF1D3C02FE106CFCB819348020C235C6083E4040E4BE1124BE117890CC3E443CB81974C7C060841A5B9A5D2EBCB81A3E118074DFD66EBCB81CBE803E800C3E1094882FBE10D4882FAC3CB819807E18BE18FE12F43E800C3E10BE10E80068006E7CB8199FFE187C0320004120843777222E9C20043232C15401B3C594013E808532DA84B2C7F2DFF2407EC02002012018190201D42B2C0201201A1B0201201E1F0201201C1D00E5473F00BD401D001D401D021F90102D31F01821043436D74BAF2E068F84601D37F59BAF2E072F844544355F910F8454330F910B0F2E065D33FD33F30F84822B9F84922B9B0F2E06C21F86820F869F84A6E915B8E19F84AD0D33FFA003171D721D33F305033BC02BCB1936DF86ADEE2F800F00C8006F3E12F43E800C7E903E900C3E09DBC41CBE10D62F24CC20C1B7BE10FE11963C03FE10BE11A04020BC03DC3E185C3E189C3E18DB7E1ABC032000B51D3C02F5007400750074087E4040B4C7C0608410DB1BDCEEBCB81A3E118074DFD66EBCB81CBE111510D57E443E1150CC3E442C3CB8197E80007E18BE80007E18F4CFF4CFCC3E1208AE7E1248AE6C3CB81B007E1A3E1A7E003C042001C1573F00BF84A6EF2E06AD2008308D71820F9012392F84492F845E24130F910F2E065D31F018210556E436CBAF2E068F84601D37F59BAF2E072D401D08308D71820F901F8444130F910F2E06501D430D08308D71820F901F8454130F910F2E06501820020120222301FED31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE2303205D31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE23032F8485280BEF8495250BEB0524BBE1AB0527ABE19210064B05215BE14B05248BE17B0F2E06970F82305C8CB3F5004FA0215F40015CB3F5004FA0212F400CB1F12CA00CA00C9F86AF00C01C31CFC02FE129BACFCB81AF48020C235C6083E4048E4BE1124BE1178904C3E443CB81974C7C0608410DA19D46EBCB81A3E118074DFD66EBCB81CB5007420C235C6083E407E11104C3E443CB81940750C3420C235C6083E407E11504C3E443CB81940602403F71CFC02FE129BACFCB81AF48020C235C6083E4048E4BE1124BE1178904C3E443CB81974C7C0608410DB10DBAEBCB81A3E118074DFD66EBCB81CBD010C3E12B434CFFE803D0134CFFE803D0134C7FE11DBC4148828083E08EE7CB81BBE11DBC4A83E08EF3CB81C34800C151D5A64D6D4C8F7A2B98E82A49B08B8C3816028292A01FCD31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE2303205D31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE230325339BE5381BEB0F8495250BEB0F8485290BEB02502FE5237BE16B05262BEB0F2E06927C20097F84918BEF2E0699137E222C20097F84813BEF2E0699132E2F84AD0D33FFA00F404D33FFA00F404D31FF8476F105220A0F823BCF2E06FD200D20030B3F2E073209C3537373A5274BC5263BC12B18E11323939395250BC5299BC18B14650134440E25319BAB3F2E06D9130E30D7F05C82627002496F8476F1114A098F8476F1117A00603E203003ECB3F5004FA0215F40012CB3F5004FA0213F400CB1F12CA00CA00C9F86AF00C00620A8020F4966FA5208E213050038020F4666FA1208E1001FA00ED1E15DA119450C3A00B9133E2923430E202926C21E2B31B000C3535075063140038C8CB3F5004FA0212F400CB3F5003FA0213F400CB1FCA00C9F86AF00C00D51D3C02FE129BACFCB81AFE12B434CFFE803D010C74CFFE803D010C74C7CC3E11DBC4283E11DBC4A83E08EE7CB81C7E003E10886808E87E18BE10D400E816287E18FE10F04026BE10BE10E83E189C3E18F7BE10B04026BE10FE10A83E18DC3E18F780693E1A293E1A7C042001F53B7EF4C7C8608419F1F4A06EA4CC7C037808608403818830AEA54C7C03B6CC780C882084155DD61FAEA54C3C0476CC780820841E6849BBEEA54C3C04B6CC7808208407C546B3EEA54C3C0576CC780820840223AA8CAEA54C3C05B6CC7808208419BDBC1A6EA54C3C05F6CC780C60840950CAA46EA53C0636CC78202D0008840FF2F00075BC7FE3A7805FC25E87D007D207D20184100D0CAF6A1EC7C217C21B7817C227C22B7817C237C23FC247C24B7817C2524C3B7818823881B22A021984008DBD0CABA7805FC20C8B870FC253748B8F07C256840206B90FD0018C020EB90FD0018B8EB90E98F987C23B7882908507C11DE491839707C23B788507C23B789507C11DE48B9F03A4331C4966'; + +class PaymentChannel extends Contract { + + /** + * @param provider {HttpProvider} + * @param options {{isA: boolean, channelId: BN, myKeyPair: nacl.SignKeyPair, hisPublicKey: Uint8Array, initBalanceA: BN, initBalanceB: BN, addressA: Address, addressB: Address, closingConfig?: {quarantineDuration: number, misbehaviorFine: BN, conditionalCloseDuration: number}, excessFee?: BN}} + */ + constructor(provider, options) { + options.publicKeyA = options.isA ? options.myKeyPair.publicKey : options.hisPublicKey; + options.publicKeyB = !options.isA ? options.myKeyPair.publicKey : options.hisPublicKey; + + options.wc = options.wc || 0; + options.code = options.code || Cell.oneFromBoc(PAYMENT_CHANNEL_CODE_HEX); + super(provider, options); + } + + /** + * @override + * @private + * @return {Cell} cell contains payment channel data + */ + createDataCell() { + const cell = new Cell(); + cell.bits.writeBit(0); // inited + cell.bits.writeCoins(0); // balance_A + cell.bits.writeCoins(0); // balance_B + writePublicKey(cell, this.options.publicKeyA); // key_A + writePublicKey(cell, this.options.publicKeyB); // key_B + cell.bits.writeUint(this.options.channelId, 128); // channel_id + + const closingConfig = new Cell(); + closingConfig.bits.writeUint(this.options.closingConfig?.quarantineDuration || 0, 32); // quarantin_duration + closingConfig.bits.writeCoins(this.options.closingConfig?.misbehaviorFine || new BN(0)); // misbehavior_fine + closingConfig.bits.writeUint(this.options.closingConfig?.conditionalCloseDuration || 0, 32); // conditional_close_duration + cell.refs[0] = closingConfig; + + cell.bits.writeUint(0, 32); // commited_seqno_A + cell.bits.writeUint(0, 32); // commited_seqno_B + cell.bits.writeBit(false); // quarantin ref + + const paymentConfig = new Cell(); + paymentConfig.bits.writeCoins(this.options.excessFee || new BN(0)); // excess_fee + paymentConfig.bits.writeAddress(this.options.addressA); // addr_A + paymentConfig.bits.writeAddress(this.options.addressB); // addr_B + cell.refs[1] = paymentConfig; + + return cell; + } + + /** + * @private + * @param op {number} + * @param cellForSigning {Cell} + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createOneSignature(op, cellForSigning) { + const signature = nacl.sign.detached(await cellForSigning.hash(), this.options.myKeyPair.secretKey); + + const cell = createOneSignature({ + op, + isA: this.options.isA, + signature, + cell: cellForSigning + }); + + return {cell, signature}; + } + + /** + * @private + * @param op {number} + * @param hisSignature {Uint8Array} + * @param cellForSigning {Cell} + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createTwoSignature(op, hisSignature, cellForSigning) { + const signature = nacl.sign.detached(await cellForSigning.hash(), this.options.myKeyPair.secretKey); + + const signatureA = this.options.isA ? signature : hisSignature; + const signatureB = !this.options.isA ? signature : hisSignature; + + const cell = createTwoSignature({ + op, + signatureA, + signatureB, + cell: cellForSigning + }); + + return {cell, signature}; + } + + /** + * @param params {{coinsA: BN, coinsB: BN}} + * @returns {Promise} + */ + async createTopUpBalance(params) { + return createTopUpBalance(params); + } + + /** + * @param params {{balanceA: BN, balanceB: BN}} + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createInitChannel(params) { + return this.createOneSignature( + op_init_channel, + createInitChannelBody({...params, channelId: this.options.channelId}) + ); + } + + /** + * @param params {{hisSignature?: Uint8Array, balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createCooperativeCloseChannel(params) { + if (!params.hisSignature) { + params.hisSignature = new Uint8Array(512 / 8); + } + return this.createTwoSignature( + op_cooperative_close, + params.hisSignature, + createCooperativeCloseChannelBody({...params, channelId: this.options.channelId}) + ) + } + + /** + * @param params {{hisSignature?: Uint8Array, seqnoA: BN, seqnoB: BN}} + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createCooperativeCommit(params) { + if (!params.hisSignature) { + params.hisSignature = new Uint8Array(512 / 8); + } + return this.createTwoSignature( + op_cooperative_commit, + params.hisSignature, + createCooperativeCommitBody({...params, channelId: this.options.channelId}) + ) + } + + /** + * @private + * @param params {{mySeqno: BN, mySentCoins: BN, hisSeqno?: BN, hisSentCoins?: BN}} + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createSignedSemiChannelState(params) { + const state = createSemiChannelState({ + channelId: this.options.channelId, + semiChannelBody: createSemiChannelBody({ + seqno: params.mySeqno, + sentCoins: params.mySentCoins, + conditionals: null + }), + counterpartySemiChannelBody: params.hisSeqno === undefined ? null : createSemiChannelBody({ + seqno: params.hisSeqno, + sentCoins: params.hisSentCoins, + conditionals: null + }), + }); + const signature = nacl.sign.detached(await state.hash(), this.options.myKeyPair.secretKey); + const cell = createSignedSemiChannelState({signature, state}); + return {cell, signature}; + } + + /** + * @param params {{balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + * @returns {Promise} signature + */ + async signState(params) { + const mySeqno = this.options.isA ? params.seqnoA : params.seqnoB; + const hisSeqno = !this.options.isA ? params.seqnoA : params.seqnoB; + + const sentCoinsA = this.options.initBalanceA.gt(params.balanceA) ? this.options.initBalanceA.sub(params.balanceA) : new BN(0); + const sentCoinsB = this.options.initBalanceB.gt(params.balanceB) ? this.options.initBalanceB.sub(params.balanceB) : new BN(0); + + const mySentCoins = this.options.isA ? sentCoinsA : sentCoinsB; + const hisSentCoins = !this.options.isA ? sentCoinsA : sentCoinsB; + + const {cell, signature} = await this.createSignedSemiChannelState({ + mySeqno, + mySentCoins, + hisSeqno, + hisSentCoins + }); + + return signature; + } + + /** + * @param params {{balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + * @param hisSignature {Uint8Array} + * @returns {Promise} + */ + async verifyState(params, hisSignature) { + const mySeqno = !this.options.isA ? params.seqnoA : params.seqnoB; + const hisSeqno = this.options.isA ? params.seqnoA : params.seqnoB; + + const sentCoinsA = this.options.initBalanceA.gt(params.balanceA) ? this.options.initBalanceA.sub(params.balanceA) : new BN(0); + const sentCoinsB = this.options.initBalanceB.gt(params.balanceB) ? this.options.initBalanceB.sub(params.balanceB) : new BN(0); + + const mySentCoins = !this.options.isA ? sentCoinsA : sentCoinsB; + const hisSentCoins = this.options.isA ? sentCoinsA : sentCoinsB; + + const state = createSemiChannelState({ + channelId: this.options.channelId, + semiChannelBody: createSemiChannelBody({ + seqno: mySeqno, + sentCoins: mySentCoins, + conditionals: null + }), + counterpartySemiChannelBody: hisSeqno === undefined ? null : createSemiChannelBody({ + seqno: hisSeqno, + sentCoins: hisSentCoins, + conditionals: null + }), + }); + const hash = await state.hash(); + return nacl.sign.detached.verify(hash, hisSignature, this.options.isA ? this.options.publicKeyB : this.options.publicKeyA); + } + + /** + * @param params {{balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + * @return {Uint8Array} signature + */ + async signClose(params) { + const {cell, signature} = await this.createCooperativeCloseChannel(params); + return signature; + } + + /** + * @param params {{balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + * @param hisSignature {Uint8Array} + * @return {boolean} + */ + async verifyClose(params, hisSignature) { + const cell = await createCooperativeCloseChannelBody({...params, channelId: this.options.channelId}); + const hash = await cell.hash(); + return nacl.sign.detached.verify(hash, hisSignature, this.options.isA ? this.options.publicKeyB : this.options.publicKeyA); + } + + /** + * @param params {{signedSemiChannelStateA: Cell, signedSemiChannelStateB: Cell}} `signedSemiChannelState` created by `createSignedSemiChannelState` + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createStartUncooperativeClose(params) { + return this.createOneSignature( + op_start_uncooperative_close, + createStartUncooperativeCloseBody({...params, channelId: this.options.channelId}) + ); + } + + /** + * @param params {{signedSemiChannelStateA: Cell, signedSemiChannelStateB: Cell}} `signedSemiChannelState` created by `createSignedSemiChannelState` + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createChallengeQuarantinedState(params) { + return this.createOneSignature( + op_challenge_quarantined_state, + createChallengeQuarantinedStateBody({...params, channelId: this.options.channelId}) + ); + } + + /** + * @param params {{conditionalsToSettle: Cell | null}} dictionary with uint32 keys and values created by `createConditionalPayment` + * @returns {Promise<{cell: Cell, signature: Uint8Array}>} + */ + async createSettleConditionals(params) { + return this.createOneSignature( + op_settle_conditionals, + createSettleConditionalsBody({...params, channelId: this.options.channelId}) + ); + } + + /** + * @returns {Promise} + */ + async createFinishUncooperativeClose() { + return createFinishUncooperativeClose(); + } + + static STATE_UNINITED = 0; + static STATE_OPEN = 1; + static STATE_CLOSURE_STARTED = 2; + static STATE_SETTLING_CONDITIONALS = 3; + static STATE_AWAITING_FINALIZATION = 4; + + /** + * @returns {Promise} + */ + async getChannelState() { + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_channel_state', []); + return result.toNumber(); + } + + /** + * @returns {Promise<{state: number, balanceA: BN, balanceB: BN, publicKeyA: Uint8Array, publicKeyB: Uint8Array, channelId: BN, quarantineDuration: number, misbehaviorFine: BN, conditionalCloseDuration: number, seqnoA: BN, seqnoB: BN, quarantine: Cell, excessFee: BN, addressA: Address, addressB: Address}>} + */ + async getData() { + /** + * @param bn {BN} + * @return {Uint8Array} + */ + const bnToBytes = (bn) => { + let hex = bn.toString(16); + if (hex.length % 2 !== 0) hex = '0' + hex; + return hexToBytes(hex); + } + + const myAddress = await this.getAddress(); + const result = await this.provider.call2(myAddress.toString(), 'get_channel_data', []); + + const state = result[0].toNumber(); + const balanceA = result[1][0]; + const balanceB = result[1][1]; + const publicKeyA = bnToBytes(result[2][0]); + const publicKeyB = bnToBytes(result[2][1]); + const channelId = result[3]; + const quarantineDuration = result[4][0].toNumber(); + const misbehaviorFine = result[4][1]; + const conditionalCloseDuration = result[4][2].toNumber(); + const seqnoA = result[5][0]; + const seqnoB = result[5][1]; + const quarantine = result[6]; // Cell + const excessFee = result[7][0]; + const addressA = parseAddress(result[7][1]); + const addressB = parseAddress(result[7][2]); + return { + state, + balanceA, + balanceB, + publicKeyA, + publicKeyB, + channelId, + quarantineDuration, + misbehaviorFine, + conditionalCloseDuration, + seqnoA, + seqnoB, + quarantine, + excessFee, + addressA, + addressB + } + } + + /** + * @param params {{wallet: WalletContract, secretKey: Uint8Array}} + * @return {{deploy: Function, init: Function, topUp: Function, close: Function, commit: Function, startUncooperativeClose: Function, challengeQuarantinedState: Function, settleConditionals: Function, finishUncooperativeClose: Function}} + */ + fromWallet(params) { + const {wallet, secretKey} = params; + + const transfer = (payloadPromise, needStateInit) => { + + const createPromise = async (amount) => { + const stateInit = needStateInit ? (await this.createStateInit()).stateInit : null + const myAddress = await this.getAddress(); + const seqno = (await wallet.methods.seqno().call()) || 0; + const payload = await payloadPromise; + + return wallet.methods.transfer({ + secretKey: secretKey, + toAddress: myAddress.toString(true, true, true), + amount: amount, + seqno: seqno, + payload, // body + stateInit, + sendMode: 3 + }); + } + + return { + /** + * @param amount {BN} in Toncoins + */ + send: (amount) => { + return createPromise(amount).then(x => x.send()); + }, + /** + * @param amount {BN} in Toncoins + */ + estimateFee: (amount) => { + return createPromise(amount).then(x => x.estimateFee()); + } + } + } + + return { + deploy: () => { + return transfer(null, true); + }, + /** + * @param params {{balanceA: BN, balanceB: BN}} + */ + init: (params) => { + return transfer(this.createInitChannel(params).then(x => x.cell)); + }, + /** + * @param params {{coinsA: BN, coinsB: BN}} + */ + topUp: (params) => { + return transfer(this.createTopUpBalance(params)); + }, + /** + * @param params {{hisSignature: Uint8Array, balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + */ + close: (params) => { + return transfer(this.createCooperativeCloseChannel(params).then(x => x.cell)); + }, + /** + * @param params {{hisSignature: Uint8Array, seqnoA: BN, seqnoB: BN}} + */ + commit: (params) => { + return transfer(this.createCooperativeCommit(params).then(x => x.cell)); + }, + /** + * @param params {{signedSemiChannelStateA: Cell, signedSemiChannelStateB: Cell}} + */ + startUncooperativeClose: (params) => { + return transfer(this.createStartUncooperativeClose(params).then(x => x.cell)); + }, + /** + * @param params {{signedSemiChannelStateA: Cell, signedSemiChannelStateB: Cell}} + */ + challengeQuarantinedState: (params) => { + return transfer(this.createChallengeQuarantinedState(params).then(x => x.cell)); + }, + /** + * @param params {{conditionalsToSettle: Cell | null}} + */ + settleConditionals: (params) => { + return transfer(this.createSettleConditionals(params).then(x => x.cell)); + }, + /** + */ + finishUncooperativeClose: () => { + return transfer(this.createFinishUncooperativeClose()); + } + } + } + +} + +PaymentChannel.codeHex = PAYMENT_CHANNEL_CODE_HEX; + +module.exports = {PaymentChannel}; \ No newline at end of file diff --git a/src/contract/payments/PaymentUtils.js b/src/contract/payments/PaymentUtils.js new file mode 100644 index 00000000..ffbfb65b --- /dev/null +++ b/src/contract/payments/PaymentUtils.js @@ -0,0 +1,281 @@ +const {Cell} = require("../../boc"); + +/** + * @param cell {Cell} + * @param publicKey {Uint8Array} + */ +const writePublicKey = (cell, publicKey) => { + if (publicKey.length !== 256 / 8) { + throw new Error('invalid publicKey length'); + } + cell.bits.writeBytes(publicKey); +} + +/** + * @param cell {Cell} + * @param signature {Uint8Array} + */ +const writeSignature = (cell, signature) => { + if (signature.length !== 512 / 8) { + throw new Error('invalid signature length'); + } + cell.bits.writeBytes(signature); +} + +/** + * @param signature {Uint8Array} + * @returns {Cell} + */ +const createSignatureCell = (signature) => { + const cell = new Cell(); + writeSignature(cell, signature); + return cell; +} + +/** + * @param cell {Cell} + * @param ref {Cell} + */ +const writeMayBe = (cell, ref) => { + if (ref) { + cell.bits.writeBit(1); + if (cell.refs.length >= 4) { + throw new Error('refs overflow') + } + cell.refs.push(ref); + } else { + cell.bits.writeBit(0); + } +} + +/** + * @param cell {Cell} + * @param ref {Cell} + */ +const writeDict = writeMayBe; + +const tag_init = 0x696e6974; +const tag_cooperative_close = 0x436c6f73; +const tag_cooperative_commit = 0x43436d74; +const tag_start_uncooperative_close = 0x556e436c; +const tag_challenge_state = 0x43686751; +const tag_settle_conditionals = 0x436c436e; +const tag_state = 0x43685374; + +const op_top_up_balance = 1741148801; // crc32("top_up_balance add_A:Coins add_B:Coins = InternalMsgBody"); +const op_init_channel = 235282626; // crc32("init_channel is_A:Bool signature:bits512 tag:# = tag 1768843636 channel_id:uint128 balance_A:Coins balance_B:Coins = InternalMsgBody"); +const op_cooperative_close = 1433884798; // crc32("cooperative_close sig_A:^bits512 sig_B:^bits512 tag:# = tag 1131179891 channel_id:uint128 balance_A:Coins balance_B:Coins seqno_A:uint64 seqno_B:uint64 = InternalMsgBody"); +const op_cooperative_commit = 2040604399; // crc32("cooperative_commit sig_A:^bits512 sig_B:^bits512 tag:# = tag 1128492404 channel_id:uint128 seqno_A:uint64 seqno_B:uint64 = InternalMsgBody"); +const op_start_uncooperative_close = 521476815; // crc32("start_uncooperative_close signed_by_A:Bool signature:bits512 tag:# = tag 1433289580 channel_id:uint128 sch_A:^SignedSemiChannel sch_B:^SignedSemiChannel = InternalMsgBody"); +const op_challenge_quarantined_state = 143567410; // crc32("challenge_quarantined_state challenged_by_A:Bool signature:bits512 tag:# = tag 1130915665 channel_id:uint128 sch_A:^SignedSemiChannel sch_B:^SignedSemiChannel = InternalMsgBody"); +const op_settle_conditionals = 1727459433; // crc32("settle_conditionals from_A:Bool signature:bits512 tag:# = tag 1131168622 channel_id:uint128 conditionals_to_settle:HashmapE 32 Cell = InternalMsgBody"); +const op_finish_uncooperative_close = 625158801; // crc32("finish_uncooperative_close = InternalMsgBody"); +const op_channel_closed = -572749638; // crc32("channel_closed channel_id:uint128 = InternalMsgBody"); + +/** + * @param params {{coinsA: BN, coinsB: BN}} + * @returns {Cell} + */ +const createTopUpBalance = (params) => { + const cell = new Cell(); + cell.bits.writeUint(op_top_up_balance, 32); // OP + cell.bits.writeCoins(params.coinsA); + cell.bits.writeCoins(params.coinsB); + return cell; +} + +/** + * @param params {{channelId: BN, balanceA: BN, balanceB: BN}} + * @returns {Cell} + */ +const createInitChannelBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_init, 32); + cell.bits.writeUint(params.channelId, 128); + cell.bits.writeCoins(params.balanceA); + cell.bits.writeCoins(params.balanceB); + return cell; +} + +/** + * @param params {{channelId: BN, balanceA: BN, balanceB: BN, seqnoA: BN, seqnoB: BN}} + * @returns {Cell} + */ +const createCooperativeCloseChannelBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_cooperative_close, 32); + cell.bits.writeUint(params.channelId, 128); + cell.bits.writeCoins(params.balanceA); + cell.bits.writeCoins(params.balanceB); + cell.bits.writeUint(params.seqnoA, 64); + cell.bits.writeUint(params.seqnoB, 64); + return cell; +} + +/** + * @param params {{channelId: BN, seqnoA: BN, seqnoB: BN}} + * @returns {Cell} + */ +const createCooperativeCommitBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_cooperative_commit, 32); + cell.bits.writeUint(params.channelId, 128); + cell.bits.writeUint(params.seqnoA, 64); + cell.bits.writeUint(params.seqnoB, 64); + return cell; +} + +/** + * @param params {{amount: BN, condition: Cell}} condition is code + * @returns {Cell} + */ +const createConditionalPayment = (params) => { + const cell = new Cell(); + cell.bits.writeCoins(params.amount); + cell.writeCell(params.condition); + return cell; +} + +/** + * @param params {{seqno: BN, sentCoins: BN, conditionals: Cell | null}} conditionals - dictionary with uint32 keys and values created by `createConditionalPayment` + * @returns {Cell} + */ +const createSemiChannelBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(params.seqno, 64); // body start + cell.bits.writeCoins(params.sentCoins); + writeDict(cell, params.conditionals); // HashmapE 32 ConditionalPayment + return cell; +} + +/** + * @param params {{channelId: BN, semiChannelBody: Cell, counterpartySemiChannelBody?: Cell}} created by `createSemiChannelBody` + * @returns {Cell} + */ +const createSemiChannelState = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_state, 32); + cell.bits.writeUint(params.channelId, 128); + cell.writeCell(params.semiChannelBody); + writeMayBe(cell, params.counterpartySemiChannelBody) + return cell; +} + +/** + * @param params {{signature: Uint8Array, state: Cell}} `state` created by `createSemiChannelState` + */ +const createSignedSemiChannelState = (params) => { + const cell = new Cell(); + writeSignature(cell, params.signature); + cell.writeCell(params.state); + return cell; +} + +/** + * @param params {{channelId: BN, signedSemiChannelStateA: Cell, signedSemiChannelStateB: Cell}} `signedSemiChannelState` created by `createSignedSemiChannelState` + * @returns {Cell} + */ +const createStartUncooperativeCloseBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_start_uncooperative_close, 32); + cell.bits.writeUint(params.channelId, 128); + cell.refs[0] = params.signedSemiChannelStateA; + cell.refs[1] = params.signedSemiChannelStateB; + return cell; +} + +/** + * @param params {{channelId: BN, signedSemiChannelStateA: Cell, signedSemiChannelStateB: Cell}} `signedSemiChannelState` created by `createSignedSemiChannelState` + * @returns {Cell} + */ +const createChallengeQuarantinedStateBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_challenge_state, 32); + cell.bits.writeUint(params.channelId, 128); + cell.refs[0] = params.signedSemiChannelStateA; + cell.refs[1] = params.signedSemiChannelStateB; + return cell; +} + +/** + * @param params {{channelId: BN, conditionalsToSettle: Cell | null}} conditionalsToSettle - dictionary with uint32 keys and values created by `createConditionalPayment` + * @returns {Cell} + */ +const createSettleConditionalsBody = (params) => { + const cell = new Cell(); + cell.bits.writeUint(tag_settle_conditionals, 32); + cell.bits.writeUint(params.channelId, 128); + writeDict(cell, params.conditionalsToSettle); // HashmapE 32 Cell + return cell; +} + +/** + * @returns {Cell} + */ +const createFinishUncooperativeClose = () => { + const cell = new Cell(); + cell.bits.writeUint(op_finish_uncooperative_close, 32); // OP + return cell; +} + +/** + * @param params {{op: number, isA: boolean, signature: Uint8Array, cell: Cell}} + * @return {Cell} + */ +const createOneSignature = (params) => { + const cell = new Cell(); + cell.bits.writeUint(params.op, 32); // OP + cell.bits.writeBit(params.isA); + writeSignature(cell, params.signature); + cell.writeCell(params.cell); + return cell; +} + +/** + * @param params {{op: number, signatureA: Uint8Array, signatureB: Uint8Array, cell: Cell}} + * @return {Cell} + */ +const createTwoSignature = (params) => { + const cell = new Cell(); + cell.bits.writeUint(params.op, 32); // OP + cell.refs[0] = createSignatureCell(params.signatureA); + cell.refs[1] = createSignatureCell(params.signatureB); + cell.writeCell(params.cell); + return cell; +} + +module.exports = { + writePublicKey, + writeSignature, + createSignatureCell, + tag_init, + tag_cooperative_close, + tag_cooperative_commit, + tag_start_uncooperative_close, + tag_challenge_state, + tag_settle_conditionals, + tag_state, + op_top_up_balance, + op_init_channel, + op_cooperative_close, + op_cooperative_commit, + op_start_uncooperative_close, + op_challenge_quarantined_state, + op_settle_conditionals, + op_finish_uncooperative_close, + op_channel_closed, + createTopUpBalance, + createInitChannelBody, + createCooperativeCloseChannelBody, + createCooperativeCommitBody, + createConditionalPayment, + createSemiChannelBody, + createSemiChannelState, + createSignedSemiChannelState, + createStartUncooperativeCloseBody, + createChallengeQuarantinedStateBody, + createSettleConditionalsBody, + createFinishUncooperativeClose, + createOneSignature, + createTwoSignature +}; \ No newline at end of file diff --git a/src/contract/payments/index.js b/src/contract/payments/index.js new file mode 100644 index 00000000..55fcd44a --- /dev/null +++ b/src/contract/payments/index.js @@ -0,0 +1,16 @@ +const {PaymentChannel} = require("./PaymentChannel"); + +class Payments { + /** + * @param provider {HttpProvider} + */ + constructor(provider) { + this.provider = provider; + } + + createChannel(options) { + return new PaymentChannel(this.provider, options); + } +} + +module.exports = {Payments, PaymentChannel}; \ No newline at end of file diff --git a/src/contract/token/ft/JettonMinter.js b/src/contract/token/ft/JettonMinter.js index 4086b8c8..405f74ff 100644 --- a/src/contract/token/ft/JettonMinter.js +++ b/src/contract/token/ft/JettonMinter.js @@ -3,9 +3,6 @@ const {Cell} = require("../../../boc"); const {createOffchainUriCell, parseOffchainUriCell, parseAddress} = require("../nft/NftUtils"); const {Address, BN, bytesToBase64} = require("../../../utils"); -/** - * ATTENTION: this is DRAFT, there will be changes - */ class JettonMinter extends Contract { /** @@ -14,7 +11,7 @@ class JettonMinter extends Contract { */ constructor(provider, options) { options.wc = 0; - options.code = options.code || Cell.oneFromBoc('B5EE9C72410209010001AA000114FF00F4A413F4BCF2C80B0102016202030202CC040502037A60070801D5D9910E38048ADF068698180B8D848ADF07D201800E98FE99FF6A2687D007D206A6A18400AA9385D47181A9AA8AAE382F9702480FD207D006A18106840306B90FD001812881A28217804502A906428027D012C678B666664F6AA7041083DEECBEF0BDD71812F83C207F9784060093DFC142201B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064907C80383A6465816503E5FFE4E83BC00C646582AC678B28027D0109E5B589666664B8FD80400FC03FA00FA40F82854120870542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D05008C705F2E04A12A1035024C85004FA0258CF16CCCCC9ED5401FA403020D70B01C3008E1F8210D53276DB708010C8CB055003CF1622FA0212CB6ACB1FCB3FC98042FB00915BE2007DADBCF6A2687D007D206A6A183618FC1400B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064FC80383A6465816503E5FFE4E840001FAF16F6A2687D007D206A6A183FAA9040F6B06B3C'); + options.code = options.code || Cell.oneFromBoc('B5EE9C7241020B010001ED000114FF00F4A413F4BCF2C80B0102016202030202CC040502037A60090A03EFD9910E38048ADF068698180B8D848ADF07D201800E98FE99FF6A2687D007D206A6A18400AA9385D47181A9AA8AAE382F9702480FD207D006A18106840306B90FD001812881A28217804502A906428027D012C678B666664F6AA7041083DEECBEF29385D71811A92E001F1811802600271812F82C207F97840607080093DFC142201B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064907C80383A6465816503E5FFE4E83BC00C646582AC678B28027D0109E5B589666664B8FD80400FE3603FA00FA40F82854120870542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D05008C705F2E04A12A1035024C85004FA0258CF16CCCCC9ED5401FA403020D70B01C3008E1F8210D53276DB708010C8CB055003CF1622FA0212CB6ACB1FCB3FC98042FB00915BE200303515C705F2E049FA403059C85004FA0258CF16CCCCC9ED54002E5143C705F2E049D43001C85004FA0258CF16CCCCC9ED54007DADBCF6A2687D007D206A6A183618FC1400B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064FC80383A6465816503E5FFE4E840001FAF16F6A2687D007D206A6A183FAA904051007F09'); super(provider, options); } @@ -57,7 +54,33 @@ class JettonMinter extends Contract { } /** - * @return {Promise<{ totalSupply: BN, isMutable: boolean, adminAddress: Address|null, jettonContentUri: string, tokenWalletCode: Cell }>} + * params {{queryId?: number, newAdminAddress: Address}} + * @return {Cell} + */ + createChangeAdminBody(params) { + if (params.newAdminAddress === undefined) throw new Error('Specify newAdminAddress'); + + const body = new Cell(); + body.bits.writeUint(3, 32); // OP + body.bits.writeUint(params.queryId || 0, 64); // query_id + body.bits.writeAddress(params.newAdminAddress); + return body; + } + + /** + * params {{jettonContentUri: string, queryId?: number}} + * @return {Cell} + */ + createEditContentBody(params) { + const body = new Cell(); + body.bits.writeUint(4, 32); // OP + body.bits.writeUint(params.queryId || 0, 64); // query_id + body.refs[0] = createOffchainUriCell(params.jettonContentUri); + return body; + } + + /** + * @return {Promise<{ totalSupply: BN, isMutable: boolean, adminAddress: Address|null, jettonContentCell: Cell, jettonContentUri: string|null, jettonWalletCode: Cell }>} */ async getJettonData() { const myAddress = await this.getAddress(); @@ -66,10 +89,15 @@ class JettonMinter extends Contract { const totalSupply = result[0]; const isMutable = result[1].toNumber() === -1; const adminAddress = parseAddress(result[2]); - const jettonContentUri = parseOffchainUriCell(result[3]); - const tokenWalletCode = result[4]; + const jettonContentCell = result[3]; + let jettonContentUri = null; + try { + jettonContentUri = parseOffchainUriCell(jettonContentCell); + } catch (e) { + } + const jettonWalletCode = result[4]; - return {totalSupply, isMutable, adminAddress, jettonContentUri, tokenWalletCode}; + return {totalSupply, isMutable, adminAddress, jettonContentCell, jettonContentUri, jettonWalletCode}; } /** diff --git a/src/contract/token/ft/JettonWallet.js b/src/contract/token/ft/JettonWallet.js index 4eb5834b..a20b7e53 100644 --- a/src/contract/token/ft/JettonWallet.js +++ b/src/contract/token/ft/JettonWallet.js @@ -3,11 +3,8 @@ const {Cell} = require("../../../boc"); const {parseAddress} = require("../nft/NftUtils"); const {BN} = require("../../../utils"); -const JETTON_WALLET_CODE_HEX = 'B5EE9C7241021101000319000114FF00F4A413F4BCF2C80B0102016202030202CC0405001BA0F605DA89A1F401F481F481A8610201D40607020148080900BB0831C02497C138007434C0C05C6C2544D7C0FC02F83E903E900C7E800C5C75C87E800C7E800C00B4C7E08403E29FA954882EA54C4D167C0238208405E3514654882EA58C4CD00CFC02780D60841657C1EF2EA4D67C02B817C12103FCBC2000113E910C1C2EBCB853600201200A0B0201200F1001F500F4CFFE803E90087C007B51343E803E903E90350C144DA8548AB1C17CB8B04A30BFFCB8B0950D109C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C032483E401C1D3232C0B281F2FFF274013E903D010C7E801DE0063232C1540233C59C3E8085F2DAC4F3208405E351467232C7C6600C02F13B51343E803E903E90350C01F4CFFE80145468017E903E9014D6B1C1551CDB1C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C0327E401C1D3232C0B281F2FFF274140331C146EC7CB8B0C27E8020822625A020822625A02806A8486544124E17C138C34975C2C070C00930802C200D0E008ECB3F5007FA0222CF165006CF1625FA025003CF16C95005CC07AA0013A08208989680AA008208989680A0A014BCF2E2C504C98040FB001023C85004FA0258CF1601CF16CCC9ED54006C5219A018A182107362D09CC8CB1F5240CB3F5003FA0201CF165007CF16C9718018C8CB0525CF165007FA0216CB6A15CCC971FB00103400828E2A820898968072FB028210D53276DB708010C8CB055008CF165005FA0216CB6A13CB1F13CB3FC972FB0058926C33E25502C85004FA0258CF1601CF16CCC9ED5400DB3B51343E803E903E90350C01F4CFFE803E900C145468549271C17CB8B049F0BFFCB8B0A0822625A02A8005A805AF3CB8B0E0841EF765F7B232C7C572CFD400FE8088B3C58073C5B25C60043232C14933C59C3E80B2DAB33260103EC01004F214013E809633C58073C5B3327B55200083200835C87B51343E803E903E90350C0134C7E08405E3514654882EA0841EF765F784EE84AC7CB8B174CFCC7E800C04E81408F214013E809633C58073C5B3327B55204F664B79'; +const JETTON_WALLET_CODE_HEX = 'B5EE9C7241021201000328000114FF00F4A413F4BCF2C80B0102016202030202CC0405001BA0F605DA89A1F401F481F481A8610201D40607020148080900BB0831C02497C138007434C0C05C6C2544D7C0FC02F83E903E900C7E800C5C75C87E800C7E800C00B4C7E08403E29FA954882EA54C4D167C0238208405E3514654882EA58C511100FC02780D60841657C1EF2EA4D67C02B817C12103FCBC2000113E910C1C2EBCB853600201200A0B020120101101F500F4CFFE803E90087C007B51343E803E903E90350C144DA8548AB1C17CB8B04A30BFFCB8B0950D109C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C032483E401C1D3232C0B281F2FFF274013E903D010C7E801DE0063232C1540233C59C3E8085F2DAC4F3208405E351467232C7C6600C03F73B51343E803E903E90350C0234CFFE80145468017E903E9014D6F1C1551CDB5C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C0327E401C1D3232C0B281F2FFF274140371C1472C7CB8B0C2BE80146A2860822625A020822625A004AD822860822625A028062849F8C3C975C2C070C008E00D0E0F009ACB3F5007FA0222CF165006CF1625FA025003CF16C95005CC2391729171E25008A813A08208989680AA008208989680A0A014BCF2E2C504C98040FB001023C85004FA0258CF1601CF16CCC9ED5400705279A018A182107362D09CC8CB1F5230CB3F58FA025007CF165007CF16C9718018C8CB0524CF165006FA0215CB6A14CCC971FB0010241023000E10491038375F040076C200B08E218210D53276DB708010C8CB055008CF165004FA0216CB6A12CB1F12CB3FC972FB0093356C21E203C85004FA0258CF1601CF16CCC9ED5400DB3B51343E803E903E90350C01F4CFFE803E900C145468549271C17CB8B049F0BFFCB8B0A0822625A02A8005A805AF3CB8B0E0841EF765F7B232C7C572CFD400FE8088B3C58073C5B25C60063232C14933C59C3E80B2DAB33260103EC01004F214013E809633C58073C5B3327B55200083200835C87B51343E803E903E90350C0134C7E08405E3514654882EA0841EF765F784EE84AC7CB8B174CFCC7E800C04E81408F214013E809633C58073C5B3327B55205ECCF23D'; -/** - * ATTENTION: this is DRAFT, there will be changes - */ class JettonWallet extends Contract { /** * @param provider @@ -20,7 +17,7 @@ class JettonWallet extends Contract { } /** - * @param params {{queryId?: number, jettonAmount: BN, toAddress: Address, responseAddress: Address, forwardAmount: BN, forwardPayload: Uint8Array}} + * @param params {{queryId?: number, jettonAmount: BN, toAddress: Address, responseAddress: Address, forwardAmount?: BN, forwardPayload?: Uint8Array | Cell}} */ async createTransferBody(params) { const cell = new Cell(); @@ -31,9 +28,17 @@ class JettonWallet extends Contract { cell.bits.writeAddress(params.responseAddress); cell.bits.writeBit(false); // null custom_payload cell.bits.writeCoins(params.forwardAmount || new BN(0)); - cell.bits.writeBit(false); // forward_payload in this slice, not separate cell if (params.forwardPayload) { - cell.bits.writeBytes(params.forwardPayload); + if (params.forwardPayload.refs) { // is Cell + cell.bits.writeBit(true); // true Either - write forward_payload in separate cell + cell.refs.push(params.forwardPayload); + } else { // Uint8Array + cell.bits.writeBit(false); // false Either - write forward_payload in current slice + cell.bits.writeBytes(params.forwardPayload); + // todo: support write snake bytes + } + } else { + cell.bits.writeBit(false); // false Either for empty payload } return cell; } diff --git a/src/contract/token/nft/NftCollection.js b/src/contract/token/nft/NftCollection.js index bbffd84c..2fa9bc49 100644 --- a/src/contract/token/nft/NftCollection.js +++ b/src/contract/token/nft/NftCollection.js @@ -1,6 +1,6 @@ const {Contract} = require("../../index.js"); const {Cell} = require("../../../boc"); -const {Address, bytesToBase64} = require("../../../utils"); +const {Address, bytesToBase64, BN} = require("../../../utils"); const {parseAddress} = require('./NftUtils.js'); const {createOffchainUriCell, serializeUri, parseOffchainUriCell, getRoyaltyParams} = require("./NftUtils"); @@ -71,7 +71,7 @@ class NftCollection extends Contract { } /** - * params {{itemIndex: number, amount: BN, itemOwnerAddress: Address, itemContentUri: string, queryId?: number}} + * params {{itemIndex: BN|number, amount: BN, itemOwnerAddress: Address, itemContentUri: string, queryId?: number}} * @return {Cell} */ createMintBody(params) { @@ -108,6 +108,8 @@ class NftCollection extends Contract { * @return {Cell} */ createChangeOwnerBody(params) { + if (params.newOwnerAddress === undefined) throw new Error('Specify newOwnerAddress'); + const body = new Cell(); body.bits.writeUint(3, 32); // OP body.bits.writeUint(params.queryId || 0, 64); // query_id @@ -133,41 +135,55 @@ class NftCollection extends Contract { } /** - * @return {Promise<{nextItemIndex: number, ownerAddress: Address, collectionContentUri: string}>} + * @return {Promise<{nextItemIndex: number, itemsCount: BN, ownerAddress: Address, collectionContentCell: Cell, collectionContentUri: string|null}>} */ async getCollectionData() { const myAddress = await this.getAddress(); const result = await this.provider.call2(myAddress.toString(), 'get_collection_data'); - const nextItemIndex = result[0].toNumber(); - const collectionContentUri = parseOffchainUriCell(result[1]); + const itemsCount = result[0]; + let nextItemIndex = NaN; + try { + nextItemIndex = itemsCount.toNumber(); + } catch (e) { + } + const collectionContentCell = result[1]; + let collectionContentUri = null; + try { + collectionContentUri = parseOffchainUriCell(collectionContentCell); + } catch (e) { + } const ownerAddress = parseAddress(result[2]); - return {nextItemIndex, ownerAddress, collectionContentUri}; + return {nextItemIndex, itemsCount, ownerAddress, collectionContentCell, collectionContentUri}; } /** - * @param nftItem {NFTItem} - * @return {Promise<{isInitialized: boolean, index: number, collectionAddress: Address, ownerAddress: Address|null, contentUri: string}>} + * @param nftItem {NftItem} + * @return {Promise<{isInitialized: boolean, index: number, itemIndex: BN, collectionAddress: Address, ownerAddress: Address|null, contentCell: Cell, contentUri: string|null}>} */ async getNftItemContent(nftItem) { const myAddress = await this.getAddress(); const nftData = await nftItem.getData(); if (nftData.isInitialized) { - const result = await this.provider.call2(myAddress.toString(), 'get_nft_content', [['num', nftData.index], ['tvm.Cell', bytesToBase64(await nftData.contentCell.toBoc(false))]]); - nftData.contentUri = parseOffchainUriCell(result); - delete nftData.contentCell; + const result = await this.provider.call2(myAddress.toString(), 'get_nft_content', [['num', nftData.itemIndex.toString(10)], ['tvm.Cell', bytesToBase64(await nftData.contentCell.toBoc(false))]]); + nftData.contentUri = null; + try { + nftData.contentUri = parseOffchainUriCell(result); + } catch (e) { + } } return nftData; } /** - * @param index {number} + * @param index {BN|number} * @return {Promise
} */ async getNftItemAddressByIndex(index) { + index = new BN(index); const myAddress = await this.getAddress(); - const result = await this.provider.call2(myAddress.toString(), 'get_nft_address_by_index', [['num', index]]); + const result = await this.provider.call2(myAddress.toString(), 'get_nft_address_by_index', [['num', index.toString(10)]]); return parseAddress(result); } diff --git a/src/contract/token/nft/NftItem.js b/src/contract/token/nft/NftItem.js index 121f1896..a28ba57c 100644 --- a/src/contract/token/nft/NftItem.js +++ b/src/contract/token/nft/NftItem.js @@ -10,7 +10,7 @@ const NFT_ITEM_CODE_HEX = 'B5EE9C7241020D010001D0000114FF00F4A413F4BCF2C80B01020 class NftItem extends Contract { /** * @param provider - * @param options {{index: number, collectionAddress: Address, address?: Address | string, code?: Cell}} + * @param options {{index: number|BN, collectionAddress: Address, address?: Address | string, code?: Cell}} */ constructor(provider, options) { options.wc = 0; @@ -33,25 +33,34 @@ class NftItem extends Contract { } /** - * @return {Promise<{isInitialized: boolean, index: number, collectionAddress: Address|null, ownerAddress: Address|null, contentCell: Cell, contentUri: string|null}>} + * @return {Promise<{isInitialized: boolean, index: number, itemIndex: BN, collectionAddress: Address|null, ownerAddress: Address|null, contentCell: Cell, contentUri: string|null}>} */ async getData() { const myAddress = await this.getAddress(); const result = await this.provider.call2(myAddress.toString(), 'get_nft_data'); const isInitialized = result[0].toNumber() === -1; - const index = result[1].toNumber(); + const itemIndex = result[1]; + let index = NaN; + try { + index = itemIndex.toNumber(); + } catch (e) { + } const collectionAddress = parseAddress(result[2]); const ownerAddress = isInitialized ? parseAddress(result[3]) : null; const contentCell = result[4]; - const contentUri = (isInitialized && collectionAddress === null) ? parseOffchainUriCell(contentCell) : null; // single NFT without collection + let contentUri = null; + try { + contentUri = (isInitialized && collectionAddress === null) ? parseOffchainUriCell(contentCell) : null; // single NFT without collection + } catch (e) { + } - return {isInitialized, index, collectionAddress, ownerAddress, contentCell, contentUri}; + return {isInitialized, index, itemIndex, collectionAddress, ownerAddress, contentCell, contentUri}; } /** - * @param params {{queryId?: number, newOwnerAddress: Address, forwardAmount?: BN, forwardPayload?: Uint8Array, responseAddress: Address}} + * @param params {{queryId?: number, newOwnerAddress: Address, forwardAmount?: BN, forwardPayload?: Uint8Array | Cell, responseAddress: Address}} */ async createTransferBody(params) { const cell = new Cell(); @@ -61,10 +70,17 @@ class NftItem extends Contract { cell.bits.writeAddress(params.responseAddress); cell.bits.writeBit(false); // null custom_payload cell.bits.writeCoins(params.forwardAmount || new BN(0)); - cell.bits.writeBit(false); // forward_payload in this slice, not separate cell - if (params.forwardPayload) { - cell.bits.writeBytes(params.forwardPayload); + if (params.forwardPayload.refs) { // is Cell + cell.bits.writeBit(true); // true Either - write forward_payload in separate cell + cell.refs.push(params.forwardPayload); + } else { // Uint8Array + cell.bits.writeBit(false); // false Either - write forward_payload in current slice + cell.bits.writeBytes(params.forwardPayload); + // todo: support write snake bytes + } + } else { + cell.bits.writeBit(false); // false Either for empty payload } return cell; } diff --git a/src/contract/token/nft/NftUtils.js b/src/contract/token/nft/NftUtils.js index ecf7306e..30a43a0a 100644 --- a/src/contract/token/nft/NftUtils.js +++ b/src/contract/token/nft/NftUtils.js @@ -1,4 +1,4 @@ -const {base64ToBytes, Address} = require("../../../utils"); +const {Address} = require("../../../utils"); const {Cell} = require("../../../boc"); const SNAKE_DATA_PREFIX = 0x00; @@ -38,6 +38,10 @@ const createOffchainUriCell = (uri) => { * @returns {string} */ const parseOffchainUriCell = (cell) => { + if (cell.bits.array[0] !== OFFCHAIN_CONTENT_PREFIX) { + throw new Error('no OFFCHAIN_CONTENT_PREFIX'); + } + let length = 0; let c = cell; while (c) { diff --git a/src/contract/wallet/README.md b/src/contract/wallet/README.md index 64c41f36..b04d15e5 100644 --- a/src/contract/wallet/README.md +++ b/src/contract/wallet/README.md @@ -46,7 +46,7 @@ const deployQuery = await deploy.getQuery(); // get deploy query Cell const transfer = wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: 'EQDjVXa_oltdBP64Nc__p397xLCvGm2IcZ1ba7anSW0NAkeP', - amount: TonWeb.utils.toNano(0.01), // 0.01 TON + amount: TonWeb.utils.toNano('0.01'), // 0.01 TON seqno: seqno, payload: 'Hello', sendMode: 3, diff --git a/src/contract/wallet/WalletContract.js b/src/contract/wallet/WalletContract.js index 82b2fc33..ad4f0a2b 100644 --- a/src/contract/wallet/WalletContract.js +++ b/src/contract/wallet/WalletContract.js @@ -8,7 +8,7 @@ const {nacl, stringToBytes, Address, BN} = require("../../utils"); class WalletContract extends Contract { /** * @param provider {HttpProvider} - * @param options? {{code: Uint8Array, publicKey?: Uint8Array, address?: Address | string, wc?: number}} + * @param options? {{code: Cell, publicKey?: Uint8Array, address?: Address | string, wc?: number}} */ constructor(provider, options) { if (!options.publicKey && !options.address) throw new Error('WalletContract required publicKey or address in options') @@ -16,14 +16,19 @@ class WalletContract extends Contract { this.methods = { /** - * @param params {{secretKey: Uint8Array, toAddress: Address | string, amount: BN | number, seqno: number, payload: string | Uint8Array | Cell, sendMode: number, stateInit?: Cell}} + * @param params {{secretKey: Uint8Array, seqno: number, expireAt?: number, toAddress: Address | string, amount: BN, payload?: string | Uint8Array | Cell, sendMode?: number, stateInit?: Cell }} */ - transfer: (params) => Contract.createMethod(provider, this.createTransferMessage(params.secretKey, params.toAddress, params.amount, params.seqno, params.payload, params.sendMode, !Boolean(params.secretKey), params.stateInit)), + transfer: (params) => Contract.createMethod(provider, this.createTransferMessage(params.secretKey, params.toAddress, params.amount, params.seqno, params.payload, params.sendMode, !Boolean(params.secretKey), params.stateInit, params.expireAt)), + + /** + * @param params {{secretKey: Uint8Array, seqno: number, expireAt?: number, messages: [{toAddress: Address | string, amount: BN, payload?: string | Uint8Array | Cell, sendMode?: number, stateInit?: Cell }]}} + */ + transfers: (params) => Contract.createMethod(provider, this.createTransferMessages(params.secretKey, params.seqno, params.messages, !Boolean(params.secretKey), params.expireAt)), seqno: () => { return { /** - * @return {Promise} + * @return {Promise} */ call: async () => { const address = await this.getAddress(); @@ -161,12 +166,13 @@ class WalletContract extends Contract { /** * @param secretKey {Uint8Array} nacl.KeyPair.secretKey * @param address {Address | string} - * @param amount {BN | number} in nanograms + * @param amount {BN | number} in nanotons * @param seqno {number} * @param payload? {string | Uint8Array | Cell} * @param sendMode? {number} * @param dummySignature? {boolean} * @param stateInit? {Cell} + * @param expireAt? {number} * @return {Promise<{address: Address, signature: Uint8Array, message: Cell, cell: Cell, body: Cell, resultMessage: Cell}>} */ async createTransferMessage( @@ -177,28 +183,52 @@ class WalletContract extends Contract { payload = "", sendMode = 3, dummySignature = false, - stateInit = null + stateInit = null, + expireAt = undefined ) { - let payloadCell = new Cell(); - if (payload) { - if (payload.refs) { // is Cell - payloadCell = payload; - } else if (typeof payload === 'string') { - if (payload.length > 0) { - payloadCell.bits.writeUint(0, 32); - payloadCell.bits.writeString(payload); - } - } else { - payloadCell.bits.writeBytes(payload) - } + if (seqno === null || seqno === undefined || seqno < 0) { + throw new Error('seqno must be number >= 0') + } + const signingMessage = this.createSigningMessage(seqno, expireAt); + if (sendMode === null || sendMode === undefined) { + sendMode = 3; } - - const orderHeader = Contract.createInternalMessageHeader(new Address(address), new BN(amount)); - const order = Contract.createCommonMsgInfo(orderHeader, stateInit, payloadCell); - const signingMessage = this.createSigningMessage(seqno); signingMessage.bits.writeUint8(sendMode); - signingMessage.refs.push(order); + signingMessage.refs.push(Contract.createOutMsg(address, amount, payload, stateInit)); + + return this.createExternalMessage(signingMessage, secretKey, seqno, dummySignature); + } + /** + * @param secretKey {Uint8Array} nacl.KeyPair.secretKey + * @param seqno {number} + * @param messages {[{toAddress: Address | string, amount: BN, payload?: string | Uint8Array | Cell, sendMode?: number, stateInit?: Cell }]} up to 4 messages + * @param dummySignature? {boolean} + * @param expireAt? {number} + * @return {Promise<{address: Address, signature: Uint8Array, message: Cell, cell: Cell, body: Cell, resultMessage: Cell}>} + */ + async createTransferMessages( + secretKey, + seqno, + messages, + dummySignature = false, + expireAt = undefined, + ) { + if (seqno === null || seqno === undefined || seqno < 0) { + throw new Error('seqno must be number >= 0') + } + const signingMessage = this.createSigningMessage(seqno, expireAt); + if (messages.length < 1 || messages.length > 4) { + throw new Error('put 1-4 messages'); + } + for (const msg of messages) { + let sendMode = msg.sendMode; + if (sendMode === null || sendMode === undefined) { + sendMode = 3; + } + signingMessage.bits.writeUint8(sendMode); + signingMessage.refs.push(Contract.createOutMsg(msg.toAddress, msg.amount, msg.payload, msg.stateInit)); + } return this.createExternalMessage(signingMessage, secretKey, seqno, dummySignature); } } diff --git a/src/contract/wallet/WalletContractV2.js b/src/contract/wallet/WalletContractV2.js index 90e1e698..13abc702 100644 --- a/src/contract/wallet/WalletContractV2.js +++ b/src/contract/wallet/WalletContractV2.js @@ -6,10 +6,12 @@ class WalletV2ContractBase extends WalletContract { * @override * @private * @param seqno? {number} + * @param expireAt? {number} * @return {Cell} */ - createSigningMessage(seqno) { + createSigningMessage(seqno, expireAt) { seqno = seqno || 0; + expireAt = expireAt || (Math.floor(Date.now() / 1e3) + 60); const message = new Cell(); message.bits.writeUint(seqno, 32); if (seqno === 0) { @@ -18,9 +20,7 @@ class WalletV2ContractBase extends WalletContract { message.bits.writeBit(1); } } else { - const date = new Date(); - const timestamp = Math.floor(date.getTime() / 1e3); - message.bits.writeUint(timestamp + 60, 32); + message.bits.writeUint(expireAt, 32); } return message; } diff --git a/src/contract/wallet/WalletContractV3.js b/src/contract/wallet/WalletContractV3.js index b0e35544..b9c906b1 100644 --- a/src/contract/wallet/WalletContractV3.js +++ b/src/contract/wallet/WalletContractV3.js @@ -1,5 +1,6 @@ const {Cell} = require("../../boc"); const {WalletContract} = require("./WalletContract"); +const {parseWalletV3TransferQuery, parseWalletV3TransferBody} = require("./WalletQueryParser"); class WalletV3ContractBase extends WalletContract { @@ -7,10 +8,12 @@ class WalletV3ContractBase extends WalletContract { * @override * @private * @param seqno? {number} + * @param expireAt? {number} * @return {Cell} */ - createSigningMessage(seqno) { + createSigningMessage(seqno, expireAt) { seqno = seqno || 0; + expireAt = expireAt || (Math.floor(Date.now() / 1e3) + 60); const message = new Cell(); message.bits.writeUint(this.options.walletId, 32); if (seqno === 0) { @@ -19,9 +22,7 @@ class WalletV3ContractBase extends WalletContract { message.bits.writeBit(1); } } else { - const date = new Date(); - const timestamp = Math.floor(date.getTime() / 1e3); - message.bits.writeUint(timestamp + 60, 32); + message.bits.writeUint(expireAt, 32); } message.bits.writeUint(seqno, 32); return message; @@ -56,6 +57,9 @@ class WalletV3ContractR1 extends WalletV3ContractBase { } } +WalletV3ContractR1.parseTransferQuery = parseWalletV3TransferQuery; +WalletV3ContractR1.parseTransferBody = parseWalletV3TransferBody; + class WalletV3ContractR2 extends WalletV3ContractBase { /** * @param provider {HttpProvider} @@ -72,5 +76,8 @@ class WalletV3ContractR2 extends WalletV3ContractBase { } } +WalletV3ContractR2.parseTransferQuery = parseWalletV3TransferQuery; +WalletV3ContractR2.parseTransferBody = parseWalletV3TransferBody; + module.exports = {WalletV3ContractR1, WalletV3ContractR2}; diff --git a/src/contract/wallet/WalletContractV4.js b/src/contract/wallet/WalletContractV4.js index a3485f08..cd59c20c 100644 --- a/src/contract/wallet/WalletContractV4.js +++ b/src/contract/wallet/WalletContractV4.js @@ -2,6 +2,7 @@ const {Cell} = require("../../boc"); const {Contract} = require("../index.js"); const {Address, bytesToHex, BN} = require("../../utils"); const {WalletContract} = require("./WalletContract"); +const {parseWalletV3TransferQuery, parseWalletV3TransferBody} = require("./WalletQueryParser"); class WalletV4ContractR1 extends WalletContract { @@ -25,11 +26,13 @@ class WalletV4ContractR1 extends WalletContract { * @override * @private * @param seqno? {number} + * @param expireAt? {number} * @param withoutOp? {boolean} * @return {Cell} */ - createSigningMessage(seqno, withoutOp) { + createSigningMessage(seqno, expireAt, withoutOp) { seqno = seqno || 0; + expireAt = expireAt || (Math.floor(Date.now() / 1e3) + 60); const message = new Cell(); message.bits.writeUint(this.options.walletId, 32); if (seqno === 0) { @@ -38,9 +41,7 @@ class WalletV4ContractR1 extends WalletContract { message.bits.writeBit(1); } } else { - const date = new Date(); - const timestamp = Math.floor(date.getTime() / 1e3); - message.bits.writeUint(timestamp + 60, 32); + message.bits.writeUint(expireAt, 32); } message.bits.writeUint(seqno, 32); if (!withoutOp) { @@ -71,4 +72,7 @@ class WalletV4ContractR1 extends WalletContract { } } +WalletV4ContractR1.parseTransferQuery = parseWalletV3TransferQuery; +WalletV4ContractR1.parseTransferBody = parseWalletV3TransferBody; + module.exports = {WalletV4ContractR1}; diff --git a/src/contract/wallet/WalletContractV4R2.js b/src/contract/wallet/WalletContractV4R2.js index 846386a0..e2157db9 100644 --- a/src/contract/wallet/WalletContractV4R2.js +++ b/src/contract/wallet/WalletContractV4R2.js @@ -2,6 +2,7 @@ const {Cell} = require("../../boc"); const {Contract} = require("../index.js"); const {Address, bytesToHex, BN, toNano} = require("../../utils"); const {WalletContract} = require("./WalletContract"); +const {parseWalletV3TransferQuery, parseWalletV3TransferBody} = require("./WalletQueryParser"); class WalletV4ContractR2 extends WalletContract { @@ -31,11 +32,13 @@ class WalletV4ContractR2 extends WalletContract { * @override * @private * @param seqno? {number} + * @param expireAt? {number} * @param withoutOp? {boolean} * @return {Cell} */ - createSigningMessage(seqno, withoutOp) { + createSigningMessage(seqno, expireAt, withoutOp) { seqno = seqno || 0; + expireAt = expireAt || (Math.floor(Date.now() / 1e3) + 60); const message = new Cell(); message.bits.writeUint(this.options.walletId, 32); if (seqno === 0) { @@ -44,9 +47,7 @@ class WalletV4ContractR2 extends WalletContract { message.bits.writeBit(1); } } else { - const date = new Date(); - const timestamp = Math.floor(date.getTime() / 1e3); - message.bits.writeUint(timestamp + 60, 32); + message.bits.writeUint(expireAt, 32); } message.bits.writeUint(seqno, 32); if (!withoutOp) { @@ -69,12 +70,12 @@ class WalletV4ContractR2 extends WalletContract { } /** - * @param params {{secretKey: Uint8Array, seqno: number, pluginWc: number, amount: BN, stateInit: Cell, body: Cell}} + * @param params {{secretKey: Uint8Array, seqno: number, pluginWc: number, amount: BN, stateInit: Cell, body: Cell, expireAt?: number}} */ async deployAndInstallPlugin(params) { - const {secretKey, seqno, pluginWc, amount, stateInit, body} = params; + const {secretKey, seqno, pluginWc, amount, stateInit, body, expireAt} = params; - const signingMessage = this.createSigningMessage(seqno, true); + const signingMessage = this.createSigningMessage(seqno, expireAt, true); signingMessage.bits.writeUint(1, 8); // op signingMessage.bits.writeInt(pluginWc, 8); signingMessage.bits.writeGrams(amount); @@ -85,32 +86,32 @@ class WalletV4ContractR2 extends WalletContract { /** * @private - * @param params {{secretKey: Uint8Array, seqno: number, pluginAddress: string | Address, amount?: BN, queryId?: number}} + * @param params {{secretKey: Uint8Array, seqno: number, pluginAddress: string | Address, amount?: BN, queryId?: number, expireAt?: number}} * @param isInstall {boolean} install or uninstall */ async _setPlugin(params, isInstall) { - const {secretKey, seqno, amount, queryId} = params; + const {secretKey, seqno, amount, queryId, expireAt} = params; const pluginAddress = new Address(params.pluginAddress); - const signingMessage = this.createSigningMessage(seqno, true); + const signingMessage = this.createSigningMessage(seqno, expireAt, true); signingMessage.bits.writeUint(isInstall ? 2 : 3, 8); // op signingMessage.bits.writeInt(pluginAddress.wc, 8); signingMessage.bits.writeBytes(pluginAddress.hashPart); - signingMessage.bits.writeGrams(amount || toNano(0.1)); + signingMessage.bits.writeGrams(amount || toNano('0.1')); signingMessage.bits.writeUint(queryId || 0, 64); return this.createExternalMessage(signingMessage, secretKey, seqno, false); } /** - * @param params {{secretKey: Uint8Array, seqno: number, pluginAddress: string | Address, amount?: BN, queryId?: number}} + * @param params {{secretKey: Uint8Array, seqno: number, pluginAddress: string | Address, amount?: BN, queryId?: number, expireAt?: number}} */ async installPlugin(params) { return this._setPlugin(params, true); } /** - * @param params {{secretKey: Uint8Array, seqno: number, pluginAddress: string | Address, amount?: BN, queryId?: number}} + * @param params {{secretKey: Uint8Array, seqno: number, pluginAddress: string | Address, amount?: BN, queryId?: number, expireAt?: number}} */ async removePlugin(params) { return this._setPlugin(params, false); @@ -158,4 +159,7 @@ class WalletV4ContractR2 extends WalletContract { } } +WalletV4ContractR2.parseTransferQuery = parseWalletV3TransferQuery; +WalletV4ContractR2.parseTransferBody = parseWalletV3TransferBody; + module.exports = {WalletV4ContractR2}; diff --git a/src/contract/wallet/WalletQueryParser.js b/src/contract/wallet/WalletQueryParser.js new file mode 100644 index 00000000..85cd2c01 --- /dev/null +++ b/src/contract/wallet/WalletQueryParser.js @@ -0,0 +1,130 @@ +const {BN} = require("../../utils"); + +/** + * @param slice {Slice} + * @return {{seqno: number, bounce: boolean, payload: string, expireAt: number, toAddress: Address, value: BN}} + */ +function parseWalletV3TransferBody(slice) { + const signature = slice.loadBits(512); + + // signing message + + const walletId = slice.loadUint(32).toNumber(); + if (walletId !== 698983191) throw new Error('invalid walletId'); + + const expireAt = slice.loadUint(32).toNumber(); + + const seqno = slice.loadUint(32).toNumber(); + + const sendMode = slice.loadUint(8).toNumber(); + if (sendMode !== 3) throw new Error('invalid sendMode'); + + let order = slice.loadRef(); + + // order internal header + if (order.loadBit()) throw Error('invalid internal header'); + if (!order.loadBit()) throw Error('invalid ihrDisabled'); + const bounce = order.loadBit(); + if (order.loadBit()) throw Error('invalid bounced'); + const sourceAddress = order.loadAddress(); + if (sourceAddress !== null) throw Error('invalid externalSourceAddress'); + const destAddress = order.loadAddress(); + const value = order.loadCoins(); + + if (order.loadBit()) throw Error('invalid currencyCollection'); + const ihrFees = order.loadCoins(); + if (!ihrFees.eq(new BN(0))) throw new Error('invalid ihrFees'); + const fwdFees = order.loadCoins(); + if (!fwdFees.eq(new BN(0))) throw new Error('invalid fwdFees'); + const createdLt = order.loadUint(64); + if (!createdLt.eq(new BN(0))) throw new Error('invalid createdLt'); + const createdAt = order.loadUint(32); + if (!createdAt.eq(new BN(0))) throw new Error('invalid createdAt'); + + // order stateInit + if (order.loadBit()) { + order.loadRef(); // don't parse stateInit + } + + // order body + let payload = null; + + if (order.getFreeBits() > 0) { + if (order.loadBit()) { + order = order.loadRef(); + } + + if (order.getFreeBits() > 32) { + const op = order.loadUint(32); + const payloadBytes = order.loadBits(order.getFreeBits()); + payload = op.eq(new BN(0)) ? new TextDecoder().decode(payloadBytes) : ''; + } + } + + // console.log(bytesToHex(signature)); + // console.log(walletId); + // console.log(expireAt); + // console.log(seqno); + // console.log(sendMode); + // console.log(bounce); + // console.log(sourceAddress?.toString(true, true, true)); + // console.log(destAddress?.toString(true, true, true)); + // console.log(value.toNumber()); + // console.log(ihrFees); + // console.log(fwdFees); + // console.log(createdLt); + // console.log(createdAt); + // console.log(payload); + + return { + toAddress: destAddress, + value, + bounce, + seqno, + expireAt, + payload + }; +} + +/** + * @param cell {Cell} + * @return {{seqno: number, bounce: boolean, payload: string, fromAddress: Address|null, expireAt: number, toAddress: Address, value: BN}} + */ +function parseWalletV3TransferQuery(cell) { + const slice = cell.beginParse(); + + // header + + if (slice.loadUint(2).toNumber() !== 2) throw Error('invalid header'); + + const externalSourceAddress = slice.loadAddress(); + if (externalSourceAddress !== null) throw Error('invalid externalSourceAddress'); + + const externalDestAddress = slice.loadAddress(); + + const externalImportFee = slice.loadCoins(); + if (!externalImportFee.eq(new BN(0))) throw new Error('invalid externalImportFee'); + + // stateInit + + if (slice.loadBit()) { + if (slice.loadBit()) { + slice.loadRef(); // don't parse stateInit + } + } + + // body + + const bodySlice = slice.loadBit() ? slice.loadRef() : slice; + + // console.log(externalSourceAddress); + // console.log(externalDestAddress.toString(true, true, true)); + // console.log(externalImportFee); + + return { + fromAddress: externalDestAddress, + ...parseWalletV3TransferBody(bodySlice) + }; +} + +module.exports = {parseWalletV3TransferQuery, parseWalletV3TransferBody}; diff --git a/src/index.js b/src/index.js index 1f2ebd93..b2da2831 100644 --- a/src/index.js +++ b/src/index.js @@ -6,14 +6,17 @@ const HttpProvider = require("./providers").default; const {Contract} = require("./contract"); const Wallets = require("./contract/wallet").default; const LockupWallets = require("./contract/lockup").default; +const HighloadWallets = require("./contract/highloadWallet").default; const NFT = require("./contract/token/nft").default; const JETTON = require("./contract/token/ft").default; const {BlockSubscription, InMemoryBlockStorage} = require("./providers/blockSubscription"); const {SubscriptionContract} = require("./contract/subscription/index"); +const {Payments, PaymentChannel} = require("./contract/payments/index"); const TransportWebUSB = require("@ledgerhq/hw-transport-webusb").default; const TransportWebHID = require("@ledgerhq/hw-transport-webhid").default; const BluetoothTransport = require("@ledgerhq/hw-transport-web-ble").default; -const version = '0.0.40'; +const {Dns, DnsCollection, DnsItem} = require("./contract/dns").default; +const version = '0.0.66'; class TonWeb { constructor(provider) { @@ -26,7 +29,9 @@ class TonWeb { this.InMemoryBlockStorage = InMemoryBlockStorage; this.provider = provider || new HttpProvider(); + this.dns = new Dns(this.provider); this.wallet = new Wallets(this.provider); + this.payments = new Payments(this.provider); this.lockupWallet = LockupWallets; } @@ -92,5 +97,11 @@ TonWeb.token = { ft: JETTON, jetton: JETTON, } +TonWeb.HighloadWallets = HighloadWallets; +TonWeb.dns = Dns; +TonWeb.dns.DnsCollection = DnsCollection; +TonWeb.dns.DnsItem = DnsItem; +TonWeb.payments = Payments; +TonWeb.payments.PaymentChannel = PaymentChannel; module.exports = TonWeb; diff --git a/src/providers/HttpProviderUtils.js b/src/providers/HttpProviderUtils.js index ca11f46c..d9e1d55c 100644 --- a/src/providers/HttpProviderUtils.js +++ b/src/providers/HttpProviderUtils.js @@ -9,6 +9,10 @@ class HttpProviderUtils { case 'tvm.list': case 'tvm.tuple': return x.elements.map(HttpProviderUtils.parseObject); + case 'tvm.cell': + return Cell.oneFromBoc(base64ToBytes(x.bytes)); + case 'tvm.stackEntryCell': + return HttpProviderUtils.parseObject(x.cell); case 'tvm.stackEntryTuple': return HttpProviderUtils.parseObject(x.tuple); case 'tvm.stackEntryNumber': diff --git a/src/providers/index.js b/src/providers/index.js index 546dc4ea..d8a6c27a 100644 --- a/src/providers/index.js +++ b/src/providers/index.js @@ -1,3 +1,5 @@ +const {Cell} = require("../boc"); +const {base64ToBytes} = require("../utils"); const HttpProviderUtils = require('./HttpProviderUtils').default; if (typeof fetch === 'undefined') { @@ -79,9 +81,9 @@ class HttpProvider { * Use this method to get transaction history of a given address. * @param address {string} * @param limit? {number} - * @param lt? {number} + * @param lt? {number | string} * @param hash? {string} - * @param to_lt? {number} + * @param to_lt? {number | string} * @return array of transaction object */ async getTransactions(address, limit = 20, lt = undefined, hash = undefined, to_lt = undefined, archival = undefined) { @@ -152,6 +154,22 @@ class HttpProvider { return HttpProviderUtils.parseResponse(result); } + /** + * Returns network config param + * @param configParamId {number} + * @return {Cell} + */ + async getConfigParam(configParamId) { + const rawResult = await this.send('getConfigParam', { + config_id: configParamId + }); + if (rawResult['@type'] !== 'configInfo') throw new Error('getConfigParam expected type configInfo'); + if (!rawResult.config) throw new Error('getConfigParam expected config'); + if (rawResult.config['@type'] !== 'tvm.cell') throw new Error('getConfigParam expected type tvm.cell'); + if (!rawResult.config.bytes) throw new Error('getConfigParam expected bytes'); + return Cell.oneFromBoc(base64ToBytes(rawResult.config.bytes)); + } + /** * Returns ID's of last and init block of masterchain */ @@ -174,21 +192,30 @@ class HttpProvider { * @param workchain {number} * @param shardId {string} * @param shardBlockNumber {number} + * @param limit? {number} + * @param afterLt? {number} pivot transaction LT to start with + * @param addressHash? {string} take the account address where the pivot transaction took place, convert it to raw format and take the part of the address without the workchain (address hash) */ - async getBlockTransactions(workchain, shardId, shardBlockNumber) { + async getBlockTransactions(workchain, shardId, shardBlockNumber, limit, afterLt, addressHash) { return this.send('getBlockTransactions', { workchain: workchain, shard: shardId, - seqno: shardBlockNumber + seqno: shardBlockNumber, + count: limit, + after_lt: afterLt, + after_hash: addressHash }); } /** * Returns transactions hashes included in this masterhcain block * @param masterchainBlockNumber {number} + * @param limit? {number} + * @param afterLt? {number | string} pivot transaction LT to start with + * @param addressHash? {string} take the account address where the pivot transaction took place, convert it to raw format and take the part of the address without the workchain (address hash) */ - async getMasterchainBlockTransactions(masterchainBlockNumber) { - return this.getBlockTransactions(-1, SHARD_ID_ALL, masterchainBlockNumber); + async getMasterchainBlockTransactions(masterchainBlockNumber, limit, afterLt, addressHash) { + return this.getBlockTransactions(-1, SHARD_ID_ALL, masterchainBlockNumber, limit, afterLt, addressHash); } /** diff --git a/src/test-dns.js b/src/test-dns.js new file mode 100644 index 00000000..750461e7 --- /dev/null +++ b/src/test-dns.js @@ -0,0 +1,275 @@ +const TonWeb = require("./index"); +const {DnsCollection} = require("./contract/dns/DnsCollection"); +const {DnsItem} = require("./contract/dns/DnsItem"); +const {createOffchainUriCell} = require("./contract/token/nft/NftUtils"); +const {BN, sha256, bytesToHex} = require("./utils"); +const {Cell} = require("./boc"); +const {Contract} = require("./contract"); + +class DnsRoot extends Contract { + constructor(provider) { + const options = {}; + options.wc = -1; + options.code = options.code || Cell.oneFromBoc('B5EE9C7241020801000164000114FF00F4A413F4BCF2C80B0102016202030202CD040502FBA1C619DBF66041AE92F152118001E5C08C41AE140F800043AE92418010A4416128BE06F0DBC0432A05A60E6205BDDA89A1F481F481F48060E04191166E8DEDD19E2D960F166EEEEEF19E2D960F93A049847F1C484DAE3A7E038E0B1C326ABE070401752791961EB19E2D920322F122E1C54C7003B663C06122B7C4E1911306070005D2F81C00936483001258C2040FA201938083001658C20407D200CB8083001A58C204064200A38083001E58C20404B2007B8083002258C204032200538083002650C20191EB83002A4E00C9D781E9C60006746F6E00E6CF16CB07C9D023C21F8E2425D71D1F01C7058E193031328200BA93C8CB0F58CF16C90191789170E2A61801DB31E031923031E27020C88B26D658CF16CB078B1748CF16CB07C9D002C2278E2103D71D2701C7058E168200BA93C8CB0F58CF16C90191789170E2A62001DB31E05B925F04E2706DD3153191'); + super(provider, options); + } + + /** + * @override + * @private + * @return {Cell} + */ + createDataCell() { + const cell = new Cell(); + cell.bits.writeAddress(new TonWeb.Address('EQC3dNlesgVD8YbAazcauIrXBPfiVhMMr5YYk2in0Mtsz0Bz')); + cell.bits.writeAddress(new TonWeb.Address('EQCA14o1-VWhS2efqoh_9M1b_A9DtKTuoqfmkn83AbJzwnPi')); + cell.bits.writeAddress(new TonWeb.Address('EQB43-VCmf17O7YMd51fAvOjcMkCw46N_3JMCoegH_ZDo40e')); + return cell; + } +} + +async function init() { + const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC', {apiKey: ''})); + + const dnsResolve = async () => { + // const testnetRootDnsAddress = 'Ef_v5x0Thgr6pq6ur2NvkWhIf4DxAxsL-Nk5rknT6n99oPKX'; + // const mainnetRootDnsAddress = 'Ef-OJd0IF0yc0xkhgaAirq12WawqnUoSuE9RYO3S7McG6lDh'; + + const rootAddress = await tonweb.dns.getRootDnsAddress(); + console.log('rootAddress=', rootAddress.toString(true, true, true)); + + const s = 'apple.ton'; + + // const cell = await tonweb.dns.resolve(s, TonWeb.dns.DNS_CATEGORY_NEXT_RESOLVER, true); + // console.log(cell.toString(true, true, true)); + + const result = await tonweb.dns.getWalletAddress('foundation.ton'); + console.log(result?.toString(true, true, true)); + } + + const seed = TonWeb.utils.base64ToBytes('vt58J2v6FaSuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); +// const seed = TonWeb.utils.base64ToBytes('at58J2v6FaSuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); + const WALLET2_ADDRESS = 'EQB6-6po0yspb68p7RRetC-hONAz-JwxG9514IEOKw_llXd5'; + const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed); + const WalletClass = tonweb.wallet.all['v3R1']; + const wallet = new WalletClass(tonweb.provider, { + publicKey: keyPair.publicKey, + wc: 0 + }); + const walletAddress = await wallet.getAddress(); + console.log('wallet address=', walletAddress.toString(true, true, true)); + + const dnsRoot = new DnsRoot(tonweb.provider, {}); + const dnsRootAddress = await dnsRoot.getAddress(); + console.log('root address=', dnsRootAddress.toString(true, true, true)); + + const dnsItemCodeHex = 'B5EE9C7241022801000698000114FF00F4A413F4BCF2C80B0102016202030202CC04050201201E1F02012006070201481819020120080902015816170201200A0B000D470C8CB01C9D0801F73E09DBC400B434C0C05C6C2497C1383E903E900C7E800C5C75C87E800C7E800C3C0289ECE39397C15B088D148CB1C17CB865407E90350C1B5C3232C1FD00327E08E08418B9101A68608209E3402A4108308324CC200337A0404B20403C162A20032A41287E08C0683C00911DFC02440D7E08FC02F814D671C1462C200C00113E910C1C2EBCB8536003F88E34109B5F0BFA40307020F8256D8040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00E029C70091709509D31F50AAE221F008F82321BC24C0008E9E343A3A3B8E1636363737375135C705F2E196102510241023F823F00BE30EE0310DD33F256EB31FB0926C21E30D0D0E0F00FE302680698064A98452B0BEF2E19782103B9ACA0052A0A15270BC993682103B9ACA0019A193390805E220C2008E328210557CEA20F82510396D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00923036E2803C23F823A1A120C2009313A0029130E24474F0091024F823F00B00D2343653CDA182103B9ACA005210A15270BC993682103B9ACA0016A1923005E220C2008E378210370FEC516D72295134544743708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB001CA10B9130E26D5477655477632EF00B0204C882105FCC3D145220BA8E9531373B5372C705F2E191109A104910384706401504E082101A0B9D515220BA8E195B32353537375135C705F2E19A03D4304015045033F823F00BE02182104EB1F0F9BAE3023B20821044BEAE41BAE302382782104ED14B65BA1310111200885B363638385147C705F2E19B04D3FF20D74AC20007D0D30701C000F2E19CF404300798D43040168307F417983050058307F45B30E270C8CB07F400C910354014F823F00B01FE30363A246EF2E19D8050F833D0F4043052408307F40E6FA1F2E19FD30721C00022C001B1F2E1A021C0008E9124109B1068517A10571046105C43144CDD9630103A395F07E201C0018E32708210370FEC51586D8100A0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00915BE21301FE8E7A37F8235006A1810258BC066E16B0F2E19E23D0D749F823F0075290BEF2E1975178A182103B9ACA00A120C2008E32102782104ED14B6558076D72708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093303535E2F82381012CA0F0024477F0091045103412F823F00BE05F041501F03502FA4021F001FA40D20031FA0082103B9ACA001DA121945314A0A1DE22D70B01C300209205A19135E220C2FFF2E192218E3E821005138D91C8500BCF16500DCF1671244B145448C0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00106994102C395BE20114008A8E3528F0018210D53276DB103946096D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093383430E21045103412F823F00B009A32353582102FCB26A2BA8E3A7082108B77173504C8CBFF5005CF161443308040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00E05F04840FF2F00093083001258C2040FA201938083001658C20407D200CB8083001A58C204064200A38083001E58C20404B2007B8083002258C204032200538083002650C20191EB83002A4E00C9D781E9C600069006AC0BC018060840EE6B2802A0060840EE6B2802A00A08418B9101A68608209E3402A410830856456F81B04A5A9D6A0192A4139200201201A1B0201201C1D0021081BA50C1B5C0838343E903E8034CFCC200017321400F3C5807E80B2CFF26000513B513434FFFE900835D2708027DFC07E9035353D0134CFCC0415C415B80C1C1B5B5B5B490415C415A0002B01B232FFD40173C59400F3C5B3333D0032CFF27B5520020120202102012024250013BBB39F00A175F07F008802027422230010A874F00A10475F07000CA959F00A6C71000DB8FCFF00A5F03802012026270013B64A5E014204EBE0FA1000C7B461843AE9240F152118001E5C08DE014206EBE0FA1A60E038001E5C339E8086007AE140F8001E5C33B84111C466105E033E04883DCB11FB64DDC4964AD1BA06B879240DC23572F37CC5CAAAB143A2FFFBC4180012660F003C003060FE81EDF4260F00306EB1583C'; + + const dnsCollection = new DnsCollection(tonweb.provider, { + collectionContent: createOffchainUriCell('https://dns.ton.org/collection.json'), + dnsItemCodeHex: dnsItemCodeHex, + code: Cell.oneFromBoc('B5EE9C7241021D010002C7000114FF00F4A413F4BCF2C80B0102016202030202CC040502012017180201200607020120131402012008090201200D0E016D420C70094840FF2F0DE01D0D3030171B0925F03E0FA403001D31FED44D0D4D4303122C000E30210245F048210370FEC51BADC840FF2F080A0201200B0C00D032F82320821062E44069BCF2E0C701F00420D74920C218F2E0C8208103F0BBF2E0C92078A908C000F2E0CA21F005F2E0CB58F00714BEF2E0CC22F9018050F833206EB38E10D0F4043052108307F40E6FA131F2D0CD9130E2C85004CF16C9C85003CF1612CCC9F00C000D1C3232C072742000331C27C074C1C07000082CE500A98200B784B98C4830003CB432600201200F100201201112004F3223880875D244B5C61673C58875D2883000082CE6C070007CB83280B50C3400A44C78B98C727420007F1C0875D2638D572E882CE38B8C00B4C1C8700B48F0802C0929BE14902E6C08B08BC8F04EAC2C48B09800F05EC4EC04AC6CC82CE500A98200B784F7B99B04AEA00093083001258C2040FA201938083001658C20407D200CB8083001A58C204064200A38083001E58C20404B2007B8083002258C204032200538083002650C20191EB83002A4E00C9D781E9C600069006AC0BC018060840EE6B2802A0060840EE6B2802A00A08418B9101A68608209E3402A410830856456F81B04A5A9D6A0192A41392002015815160039D2CF8053810F805BBC00C646582AC678B387D0165B5E66664C0207D804002D007232FFFE0A33C5B25C083232C044FD003D0032C03260001B3E401D3232C084B281F2FFF27420020120191A0201201B1C0007B8B5D318001FBA7A3ED44D0D4D43031F00A7001F00B8001BB905BED44D0D4D430307FF002128009DBA30C3020D74978A908C000F2E04620D70A07C00021D749C0085210B0935B786DE0209501D3073101DE21F0035122D71830F9018200BA93C8CB0F01820167A3ED43D8CF16C90191789170E212A0018F83DF327') + }); + const dnsCollectionAddress = await dnsCollection.getAddress(); + console.log('collection address=', dnsCollectionAddress.toString(true, true, true)); + + const deployRootDns = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: dnsRootAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('0.1'), + seqno: seqno, + payload: null, // body + sendMode: 3, + stateInit: (await dnsRoot.createStateInit()).stateInit + }).send() + ); + } + + const deployDnsCollection = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + const payload = new Cell(); + payload.bits.writeUint(0x370fec51, 32); + payload.bits.writeUint(0, 64); + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: dnsCollectionAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('0.5'), + seqno: seqno, + payload: payload, // body + sendMode: 3, + stateInit: (await dnsCollection.createStateInit()).stateInit + }).send() + ); + } + + const getDnsCollectionInfo = async () => { + const data = await dnsCollection.getCollectionData(); + console.log(data); + + const cell = new Cell(); + cell.bits.writeString('alicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicea'); + const hash = await cell.hash(); + const bn = new BN(bytesToHex(hash), 16); + console.log(bn.toString(16)); + + console.log('addressByIndex=', (await dnsCollection.getNftItemAddressByIndex(new BN('6f0d5e27c981d01ba43aaf3d346a84beb1e8757b988465a325b3217ec3257af6', 16))).toString(true, true, true)); // "apple" + console.log('addressByIndex=', (await dnsCollection.getNftItemAddressByIndex(new BN('b413c774757e648677382bd685a02242640b846f9dc92455a2a044b9c3279d5a', 16))).toString(true, true, true)); // "alice-alice-alice" + console.log('addressByIndex=', (await dnsCollection.getNftItemAddressByIndex(new BN('8b98cad1bf9de7e1bd830ba3fba9608e6190825dddcf7edac7851ee16a692e81', 16))).toString(true, true, true)); // "alicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicea" + // console.log((await nftCollection.getNftItemAddressByIndex(new BN(1))).toString(true, true, true)); + console.log((await dnsCollection.resolve('alice-alice-alice', TonWeb.dns.DNS_CATEGORY_NEXT_RESOLVER, true))?.toString(true, true, true)); + console.log((await dnsCollection.resolve('alicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicealicea', TonWeb.dns.DNS_CATEGORY_NEXT_RESOLVER, true))?.toString(true, true, true)); + // console.log((await dnsCollection.resolve('apple'))); + } + + const dnsItemAddress = new TonWeb.utils.Address('EQDEwJoXDBqBFI-0pvYJOuI5MEuvYthhwkl56qi5oclHMyGC'); + console.log('dns item address=', dnsItemAddress.toString(true, true, true)); + const dnsItem = new DnsItem(tonweb.provider, {address: dnsItemAddress}); + + const getDnsItemInfo = async () => { + const data = await dnsCollection.methods.getNftItemContent(dnsItem); + data.collectionAddress = data.collectionAddress.toString(true, true, true); + data.ownerAddress = data.ownerAddress?.toString(true, true, true); + console.log(data); + + if (!data.ownerAddress) { + const auctionInfo = await dnsItem.methods.getAuctionInfo(); + auctionInfo.maxBidAddress = auctionInfo.maxBidAddress.toString(true, true, true); + auctionInfo.maxBidAmount = auctionInfo.maxBidAmount.toString(); + console.log(auctionInfo); + } + + const domain = await dnsItem.methods.getDomain(); + console.log({domain}); + + const lastFillUpTime = await dnsItem.methods.getLastFillUpTime(); + console.log({lastFillUpTime}); + + // console.log((await dnsItem.resolve('.'))); + // console.log((await dnsItem.resolve('.', TonWeb.dns.DNS_CATEGORY_NEXT_RESOLVER, true))?.toString(true, true, true)); + // console.log((await dnsItem.resolve('.', TonWeb.dns.DNS_CATEGORY_WALLET, true))?.toString(true, true, true)); + // console.log((await dnsItem.resolve('.', TonWeb.dns.DNS_CATEGORY_WALLET, true))?.toString(true, true, true)); + } + + + const setWalletRecord = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: dnsItemAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('0.1'), + seqno: seqno, + payload: await TonWeb.dns.DnsItem.createChangeContentEntryBody({category: TonWeb.dns.DNS_CATEGORY_WALLET, value: TonWeb.dns.createSmartContractAddressRecord(new TonWeb.Address('EQA0i8-CdGnF_DhUHHf92R1ONH6sIA9vLZ_WLcCIhfBBXwtG'))}), // body + sendMode: 3, + }).send() + ); + } + + const releaseDnsItem = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + const body = new Cell(); + body.bits.writeUint(0x4ed14b65, 32); + body.bits.writeUint(123, 64); + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: dnsItemAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('10'), + seqno: seqno, + payload: body, // body + sendMode: 3, + }).send() + ); + } + + const govDnsItem = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + const body = new Cell(); + body.bits.writeUint(0x44beae41, 32); + body.bits.writeUint(123, 64); + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: dnsItemAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('1'), + seqno: seqno, + payload: body, // body + sendMode: 3, + }).send() + ); + } + + const transferDnsItem = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + const amount = TonWeb.utils.toNano('0.05'); + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: await dnsItem.getAddress(), + amount: amount, + seqno: seqno, + payload: await dnsItem.createTransferBody({ + newOwnerAddress: new TonWeb.Address('EQBs7JfxnH2jNAlo0ytfKc77sSHQsUBzofngOkcLZyJlmm3j'), + forwardAmount: TonWeb.utils.toNano('0.02'), + forwardPayload: new TextEncoder().encode('gift'), + responseAddress: walletAddress + }), + sendMode: 3, + }).send() + ); + } + + + const getStaticData = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + const amount = TonWeb.utils.toNano('0.05'); + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: await dnsItem.getAddress(), + amount: amount, + seqno: seqno, + payload: await dnsItem.createGetStaticDataBody({ + queryId: 661 + }), + sendMode: 3, + }).send() + ); + } + + // await deployRootDns(); + // await dnsResolve(); + // await deployDnsCollection(); + // await getDnsCollectionInfo(); + // await getDnsItemInfo(); + // await setWalletRecord(); + // await transferDnsItem(); + // await releaseDnsItem(); + // await govDnsItem(); + // await getStaticData(); +} + +init(); \ No newline at end of file diff --git a/src/test-highload-query-id.js b/src/test-highload-query-id.js new file mode 100644 index 00000000..64b33aff --- /dev/null +++ b/src/test-highload-query-id.js @@ -0,0 +1,42 @@ +const TonWeb = require("./index"); +const HighloadQueryId = TonWeb.HighloadWallets.HighloadQueryId; + +if (HighloadQueryId.fromSeqno(0n).toSeqno() !== 0n) throw new Error(); + +const i = HighloadQueryId.fromSeqno(1022n); +if (i.toSeqno() !== 1022n) throw new Error(); +const i2 = HighloadQueryId.fromSeqno(1023n); +if (i2.toSeqno() !== 1023n) throw new Error(); +const i3 = HighloadQueryId.fromSeqno(1024n); +if (i3.toSeqno() !== 1024n) throw new Error(); +const i4 = HighloadQueryId.fromSeqno(8380415n); +if (i4.toSeqno() !== 8380415n) throw new Error(); + + +let queryId = new HighloadQueryId(); +console.log(queryId.getQueryId(), queryId.hasNext()); + +const MAX = (2n ** 13n) * 1023n - 2n; +for (let i = 0; i < MAX; i++) { + queryId = queryId.getNext(); + + const q = queryId.getQueryId(); + const q2 = HighloadQueryId.fromQueryId(q); + + if (queryId.getShift() !== q2.getShift()) throw new Error() + if (queryId.getBitNumber() !== q2.getBitNumber()) throw new Error() + if (q2.getQueryId() !== q) throw new Error(); + + const q3 = HighloadQueryId.fromShiftAndBitNumber(queryId.getShift(), queryId.getBitNumber()); + if (queryId.getShift() !== q3.getShift()) throw new Error() + if (queryId.getBitNumber() !== q3.getBitNumber()) throw new Error() + if (q3.getQueryId() !== q) throw new Error(); + + if (!queryId.hasNext()) { + console.log('END') + } +} +console.log(queryId.shift); +console.log(queryId.bitnumber); + +console.log(queryId.getQueryId(), queryId.hasNext()); \ No newline at end of file diff --git a/src/test-highload.js b/src/test-highload.js new file mode 100644 index 00000000..69744b06 --- /dev/null +++ b/src/test-highload.js @@ -0,0 +1,53 @@ +const TonWeb = require("./index"); +const {HighloadWalletContractV3, HighloadQueryId} = TonWeb.HighloadWallets; +const {Address, toNano} = TonWeb.utils; +const init = async () => { + + const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC', {apiKey: ''})); + + // Create v4 wallet + + const seed = TonWeb.utils.hexToBytes('607cdaf518cd38050b536005bea2667d008d5dda1027f9549479f4a42ac315c4'); + + const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed); + console.log('wallet public key =', TonWeb.utils.bytesToHex(keyPair.publicKey)); + + const highloadWallet = new HighloadWalletContractV3(tonweb.provider, { + publicKey: keyPair.publicKey, + timeout: 60 * 60, // 1 hour + }); + + const highloadAddress = await highloadWallet.getAddress(); + + console.log('Highload-wallet address is ' + highloadAddress.toString(true, true, true)); + + let queryId = new HighloadQueryId(); + queryId = queryId.getNext(); + + const createAt = Math.floor(Date.now() / 1000) - 60; + console.log(createAt); + + const transfer = highloadWallet.methods.transfer({ + secretKey: keyPair.secretKey, + queryId: queryId, + createdAt: createAt, + toAddress: new Address('UQCdqXGvONLwOr3zCNX5FjapflorB6ZsOdcdfLrjsDLt3AF4'), + amount: toNano('0.01'), // 0.01 TON + payload: 'Hello', + sendMode: 3, + needDeploy: queryId.getQueryId() === 0n + }); + + // console.log(await transfer.send()); + + console.log('isProcessed', await highloadWallet.isProcessed(queryId, false)); + console.log('isProcessed 0', await highloadWallet.isProcessed(HighloadQueryId.fromQueryId(0n), false)); + console.log('isProcessed 10', await highloadWallet.isProcessed(HighloadQueryId.fromQueryId(10n), false)); + console.log('getWalletId', await highloadWallet.getWalletId()); + console.log('getLastCleanTime', await highloadWallet.getLastCleanTime()); + console.log('getTimeout', await highloadWallet.getTimeout()); + console.log('getPublicKey', await highloadWallet.getPublicKey()); + +} + +init(); \ No newline at end of file diff --git a/src/test-jetton.js b/src/test-jetton.js index e3d13007..8500cf76 100644 --- a/src/test-jetton.js +++ b/src/test-jetton.js @@ -1,4 +1,6 @@ const TonWeb = require("./index"); +const {Cell} = require("./boc"); +const {BN} = require("./utils"); const {JettonMinter, JettonWallet} = TonWeb.token.jetton; const init = async () => { @@ -18,7 +20,7 @@ const init = async () => { const minter = new JettonMinter(tonweb.provider, { adminAddress: walletAddress, - jettonContentUri: 'http://localhost/nft-marketplace/my_collection.json', + jettonContentUri: 'https://ton.org/jetton.json', jettonWalletCodeHex: JettonWallet.codeHex }); const minterAddress = await minter.getAddress(); @@ -32,7 +34,7 @@ const init = async () => { await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: minterAddress.toString(true, true, true), - amount: TonWeb.utils.toNano(0.5), + amount: TonWeb.utils.toNano('0.05'), seqno: seqno, payload: null, // body sendMode: 3, @@ -62,7 +64,7 @@ const init = async () => { amount: TonWeb.utils.toNano('0.05'), seqno: seqno, payload: await minter.createMintBody({ - jettonAmount: TonWeb.utils.toNano(100500), + jettonAmount: TonWeb.utils.toNano('100500'), destination: walletAddress, amount: TonWeb.utils.toNano('0.04') }), @@ -71,8 +73,44 @@ const init = async () => { ); } - const JETTON_WALLET_ADDRESS = 'EQBREXwQn9ZCVae_b_jdked2c4Z14uAAD-1Vq0sZ0pCXWw0S'; - // const JETTON_WALLET_ADDRESS = 'EQAFeJKruIRXk25m_jfCGSYu2v7wJHvJx12N0r3D9dnp_1Gq'; + const editContent = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: minterAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('0.05'), + seqno: seqno, + payload: await minter.createEditContentBody({ + jettonContentUri: 'http://localhost/nft-marketplace/my_collection.123', + }), + sendMode: 3, + }).send() + ); + } + + const changeAdmin = async () => { + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}) + + console.log( + await wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: minterAddress.toString(true, true, true), + amount: TonWeb.utils.toNano('0.05'), + seqno: seqno, + payload: await minter.createChangeAdminBody({ + newAdminAddress: new TonWeb.Address(WALLET2_ADDRESS) + }), + sendMode: 3, + }).send() + ); + } + + const JETTON_WALLET_ADDRESS = 'EQBGpCSFJpAb1guZHVWIO8b_8g0e8yxp2ZfZWcTXvTjvvyFd'; + // const JETTON_WALLET_ADDRESS = 'EQAG6NvUCTxgQfcuUJVypQxN4rCm6krVH6T-mngXhSQwY0Ae'; console.log('jettonWalletAddress=', JETTON_WALLET_ADDRESS); const jettonWallet = new JettonWallet(tonweb.provider, { @@ -90,18 +128,19 @@ const init = async () => { const transfer = async () => { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - + // first four zero bytes are tag of text comment + const comment = new Uint8Array([... new Uint8Array(4), ... new TextEncoder().encode('gift')]); console.log( await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: JETTON_WALLET_ADDRESS, - amount: TonWeb.utils.toNano(0.4), + amount: TonWeb.utils.toNano('0.05'), seqno: seqno, payload: await jettonWallet.createTransferBody({ jettonAmount: TonWeb.utils.toNano('500'), toAddress: new TonWeb.utils.Address(WALLET2_ADDRESS), - forwardAmount: TonWeb.utils.toNano(0.1), - forwardPayload: new TextEncoder().encode('gift'), + forwardAmount: TonWeb.utils.toNano('0.01'), + forwardPayload: comment, responseAddress: walletAddress }), sendMode: 3, @@ -110,6 +149,8 @@ const init = async () => { } + + const burn = async () => { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) @@ -118,7 +159,7 @@ const init = async () => { await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: JETTON_WALLET_ADDRESS, - amount: TonWeb.utils.toNano(0.4), + amount: TonWeb.utils.toNano('0.05'), seqno: seqno, payload: await jettonWallet.createBurnBody({ jettonAmount: TonWeb.utils.toNano('400'), @@ -133,8 +174,10 @@ const init = async () => { // await getMinterInfo(); // await mint(); // await getJettonWalletInfo(); + // await editContent(); + // await changeAdmin(); // await transfer(); // await burn(); } -init(); \ No newline at end of file +init(); diff --git a/src/test-lockup.js b/src/test-lockup.js new file mode 100644 index 00000000..400c86d5 --- /dev/null +++ b/src/test-lockup.js @@ -0,0 +1,55 @@ +const TonWeb = require("./index"); + +async function init() { + const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC', {apiKey: undefined})); + + const walletSeed = TonWeb.utils.base64ToBytes('vt58J2v6FaBuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); + const walletKeyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(walletSeed); + + // Create private key + + const seed = TonWeb.utils.base64ToBytes('vt58J2v6FaBuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); + const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed); + + // Create v3 wallet + + console.log(JSON.stringify({ + publicKey: TonWeb.utils.bytesToBase64(keyPair.publicKey), + workchain: 0, + wallet_type: "lockup-0.1", + config_public_key: TonWeb.utils.bytesToBase64(walletKeyPair.publicKey), + allowed_destinations: 'te6cckEBBQEAegACA3TAAQIARaDgDSLz4J0acX8OFQcd/3ZHU40fqwgD28tn9YtwIiF8EFfQAgV/v7ADBABDv7MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzQABDv5VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQH26pHc=' + })); + + + const WalletClass = tonweb.lockupWallet.LockupWalletV1; + const wallet = new WalletClass(tonweb.provider, { + publicKey: keyPair.publicKey, + wc: 0, + config: { + config_public_key: TonWeb.utils.bytesToBase64(walletKeyPair.publicKey), + allowed_destinations: 'te6cckEBBQEAegACA3TAAQIARaDgDSLz4J0acX8OFQcd/3ZHU40fqwgD28tn9YtwIiF8EFfQAgV/v7ADBABDv7MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzQABDv5VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQH26pHc=' + } + }); + + const walletAddress = (await wallet.getAddress()).toString(true, true, true); + console.log('my address', walletAddress) + + // await wallet.deploy(keyPair.secretKey).send(); + + const seqno = (await wallet.methods.seqno().call()) || 0; + console.log({seqno}); + + const transfer = wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: 'EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N', + amount: TonWeb.utils.toNano('0.01'), // 0.01 TON + seqno: seqno, + payload: 'Transfer' + }); + + await transfer.send(); + +} + +init(); \ No newline at end of file diff --git a/src/test-nft.js b/src/test-nft.js index 02068253..641cff82 100644 --- a/src/test-nft.js +++ b/src/test-nft.js @@ -4,6 +4,8 @@ const {NftCollection} = require("./contract/token/nft/NftCollection"); const {NftMarketplace} = require("./contract/token/nft/NftMarketplace"); const {NftSale} = require("./contract/token/nft/NftSale"); +const BN = TonWeb.utils.BN; + async function init() { const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC')); @@ -38,7 +40,7 @@ async function init() { await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: nftCollectionAddress.toString(true, true, true), - amount: TonWeb.utils.toNano(1), + amount: TonWeb.utils.toNano('1'), seqno: seqno, payload: null, // body sendMode: 3, @@ -49,20 +51,21 @@ async function init() { const getNftCollectionInfo = async () => { const data = await nftCollection.getCollectionData(); - data.ownerAddress = data.ownerAddress.toString(true, true, true); + data.itemsCount = data.itemsCount.toString(); + data.ownerAddress = data.ownerAddress?.toString(true, true, true); console.log(data); const royaltyParams = await nftCollection.getRoyaltyParams(); royaltyParams.royaltyAddress = royaltyParams.royaltyAddress.toString(true, true, true); console.log(royaltyParams); console.log((await nftCollection.getNftItemAddressByIndex(0)).toString(true, true, true)); - console.log((await nftCollection.getNftItemAddressByIndex(1)).toString(true, true, true)); + console.log((await nftCollection.getNftItemAddressByIndex(new BN('1'))).toString(true, true, true)); } const deployNftItem = async () => { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); console.log( await wallet.methods.transfer({ @@ -85,7 +88,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); console.log( await wallet.methods.transfer({ @@ -105,7 +108,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); console.log( await wallet.methods.transfer({ @@ -128,7 +131,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); console.log( await wallet.methods.transfer({ @@ -150,6 +153,7 @@ async function init() { const getNftItemInfo = async () => { const data = await nftCollection.methods.getNftItemContent(nftItem); + data.itemIndex = data.itemIndex.toString(); data.collectionAddress = data.collectionAddress.toString(true, true, true); data.ownerAddress = data.ownerAddress?.toString(true, true, true); console.log(data); @@ -180,7 +184,7 @@ async function init() { await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: marketplaceAddress.toString(true, true, false), // non-bounceable - amount: TonWeb.utils.toNano(1), + amount: TonWeb.utils.toNano('1'), seqno: seqno, payload: null, // body sendMode: 3, @@ -204,7 +208,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); console.log( await wallet.methods.transfer({ @@ -214,7 +218,7 @@ async function init() { seqno: seqno, payload: await nftItem.createTransferBody({ newOwnerAddress: saleAddress, - forwardAmount: TonWeb.utils.toNano(0.02), + forwardAmount: TonWeb.utils.toNano('0.02'), forwardPayload: new TextEncoder().encode('gift'), responseAddress: walletAddress }), @@ -227,7 +231,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); console.log( await wallet.methods.transfer({ @@ -247,7 +251,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(0.05); + const amount = TonWeb.utils.toNano('0.05'); const body = new TonWeb.boc.Cell(); body.bits.writeUint(1, 32); // OP deploy new auction @@ -271,7 +275,7 @@ async function init() { const seqno = (await wallet.methods.seqno().call()) || 0; console.log({seqno}) - const amount = TonWeb.utils.toNano(1); + const amount = TonWeb.utils.toNano('1'); console.log( await wallet.methods.transfer({ diff --git a/src/test-payments.js b/src/test-payments.js new file mode 100644 index 00000000..4222afc3 --- /dev/null +++ b/src/test-payments.js @@ -0,0 +1,254 @@ +// TonWeb is JavaScript SDK (Web and NodeJS) for TON + +const TonWeb = require("./index"); + +// For calculations in the blockchain, we use BigNumber (BN.js). https://github.com/indutny/bn.js +// Don't use regular {Number} for coins, etc., it has not enough size and there will be loss of accuracy. + +const BN = TonWeb.utils.BN; + +// Blockchain does not operate with fractional numbers like `0.5`. +// `toNano` function converts TON to nanoton - smallest unit. +// 1 TON = 10^9 nanoton; 1 nanoton = 0.000000001 TON; +// So 0.5 TON is 500000000 nanoton + +const toNano = TonWeb.utils.toNano; + +const init = async () => { + const providerUrl = 'https://testnet.toncenter.com/api/v2/jsonRPC'; // TON HTTP API url. Use this url for testnet + const apiKey = ''; // Obtain your API key in https://t.me/tontestnetapibot + const tonweb = new TonWeb(new TonWeb.HttpProvider(providerUrl, {apiKey})); // Initialize TON SDK + + //---------------------------------------------------------------------- + // PARTIES + // The payment channel is established between two participants A and B. + // Each has own secret key, which he does not reveal to the other. + + // New secret key can be generated by `tonweb.utils.newSeed()` + tonweb.utils.newSeed(); // Uint8Array + + const seedA = TonWeb.utils.base64ToBytes('vt58J2v6FaSuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); // A's private (secret) key + const keyPairA = tonweb.utils.keyPairFromSeed(seedA); // Obtain key pair (public key and private key) + + const seedB = TonWeb.utils.base64ToBytes('at58J2v6FaSuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); // B's private (secret) key + const keyPairB = tonweb.utils.keyPairFromSeed(seedB); // Obtain key pair (public key and private key) + + // if you are new to cryptography then the public key is like a login, and the private key is like a password. + // Login can be shared with anyone, password cannot be shared with anyone. + + // With a key pair, you can create a wallet. + // Note that this is just an object, we are not deploying anything to the blockchain yet. + // Transfer some amount of test coins to this wallet address (from your wallet app). + // To check you can use blockchain explorer https://testnet.tonscan.org/address/ + + const walletA = tonweb.wallet.create({ + publicKey: keyPairA.publicKey + }); + const walletAddressA = await walletA.getAddress(); // address of this wallet in blockchain + console.log('walletAddressA = ', walletAddressA.toString(true, true, true)); + + const walletB = tonweb.wallet.create({ + publicKey: keyPairB.publicKey + }); + const walletAddressB = await walletB.getAddress(); // address of this wallet in blockchain + console.log('walletAddressB = ', walletAddressB.toString(true, true, true)); + + //---------------------------------------------------------------------- + // PREPARE PAYMENT CHANNEL + + // The parties agree on the configuration of the payment channel. + // They share information about the payment channel ID, their public keys, their wallet addresses for withdrawing coins, initial balances. + // They share this information off-chain, for example via a websocket. + + const channelInitState = { + balanceA: toNano('1'), // A's initial balance in Toncoins. Next A will need to make a top-up for this amount + balanceB: toNano('2'), // B's initial balance in Toncoins. Next B will need to make a top-up for this amount + seqnoA: new BN(0), // initially 0 + seqnoB: new BN(0) // initially 0 + }; + + const channelConfig = { + channelId: new BN(124), // Channel ID, for each new channel there must be a new ID + addressA: walletAddressA, // A's funds will be withdrawn to this wallet address after the channel is closed + addressB: walletAddressB, // B's funds will be withdrawn to this wallet address after the channel is closed + initBalanceA: channelInitState.balanceA, + initBalanceB: channelInitState.balanceB + } + + // Each on their side creates a payment channel object with this configuration + + const channelA = tonweb.payments.createChannel({ + ...channelConfig, + isA: true, + myKeyPair: keyPairA, + hisPublicKey: keyPairB.publicKey, + }); + const channelAddress = await channelA.getAddress(); // address of this payment channel smart-contract in blockchain + console.log('channelAddress=', channelAddress.toString(true, true, true)); + + const channelB = tonweb.payments.createChannel({ + ...channelConfig, + isA: false, + myKeyPair: keyPairB, + hisPublicKey: keyPairA.publicKey, + }); + + if ((await channelB.getAddress()).toString() !== channelAddress.toString()) { + throw new Error('Channels address not same'); + } + + // Interaction with the smart contract of the payment channel is carried out by sending messages from the wallet to it. + // So let's create helpers for such sends. + + const fromWalletA = channelA.fromWallet({ + wallet: walletA, + secretKey: keyPairA.secretKey + }); + + const fromWalletB = channelB.fromWallet({ + wallet: walletB, + secretKey: keyPairB.secretKey + }); + + //---------------------------------------------------------------------- + // DEPLOY PAYMENT CHANNEL FROM WALLET A + + // Wallet A must have a balance. + // 0.05 TON is the amount to execute this transaction on the blockchain. The unused portion will be returned. + // After this action, a smart contract of our payment channel will be created in the blockchain. + + await fromWalletA.deploy().send(toNano('0.05')); + + // To check you can use blockchain explorer https://testnet.tonscan.org/address/ + // We can also call get methods on the channel (it's free) to get its current data. + + console.log(await channelA.getChannelState()); + const data = await channelA.getData(); + console.log('balanceA = ', data.balanceA.toString()) + console.log('balanceB = ', data.balanceB.toString()) + + + // TOP UP + + // Now each parties must send their initial balance from the wallet to the channel contract. + + await fromWalletA + .topUp({coinsA: channelInitState.balanceA, coinsB: new BN(0)}) + .send(channelInitState.balanceA.add(toNano('0.05'))); // +0.05 TON to network fees + + await fromWalletB + .topUp({coinsA: new BN(0), coinsB: channelInitState.balanceB}) + .send(channelInitState.balanceB.add(toNano('0.05'))); // +0.05 TON to network fees + + // to check, call the get method - the balances should change + + // INIT + + // After everyone has done top-up, we can initialize the channel from any wallet + + await fromWalletA.init(channelInitState).send(toNano('0.05')); + + // to check, call the get method - `state` should change to `TonWeb.payments.PaymentChannel.STATE_OPEN` + + //---------------------------------------------------------------------- + // FIRST OFFCHAIN TRANSFER - A sends 0.1 TON to B + + // A creates new state - subtracts 0.1 from A's balance, adds 0.1 to B's balance, increases A's seqno by 1 + + const channelState1 = { + balanceA: toNano('0.9'), + balanceB: toNano('2.1'), + seqnoA: new BN(1), + seqnoB: new BN(0) + }; + + // A signs this state and send signed state to B (e.g. via websocket) + + const signatureA1 = await channelA.signState(channelState1); + + // B checks that the state is changed according to the rules, signs this state, send signed state to A (e.g. via websocket) + + if (!(await channelB.verifyState(channelState1, signatureA1))) { + throw new Error('Invalid A signature'); + } + const signatureB1 = await channelB.signState(channelState1); + + //---------------------------------------------------------------------- + // SECOND OFFCHAIN TRANSFER - A sends 0.2 TON to B + + // A creates new state - subtracts 0.2 from A's balance, adds 0.2 to B's balance, increases A's seqno by 1 + + const channelState2 = { + balanceA: toNano('0.7'), + balanceB: toNano('2.3'), + seqnoA: new BN(2), + seqnoB: new BN(0) + }; + + // A signs this state and send signed state to B (e.g. via websocket) + + const signatureA2 = await channelA.signState(channelState2); + + // B checks that the state is changed according to the rules, signs this state, send signed state to A (e.g. via websocket) + + if (!(await channelB.verifyState(channelState2, signatureA2))) { + throw new Error('Invalid A signature'); + } + const signatureB2 = await channelB.signState(channelState2); + + //---------------------------------------------------------------------- + // THIRD OFFCHAIN TRANSFER - B sends 1.1 TON TO A + + // B creates new state - subtracts 1.1 from B's balance, adds 1.1 to A's balance, increases B's seqno by 1 + + const channelState3 = { + balanceA: toNano('1.8'), + balanceB: toNano('1.2'), + seqnoA: new BN(2), + seqnoB: new BN(1) + }; + + // B signs this state and send signed state to A (e.g. via websocket) + + const signatureB3 = await channelB.signState(channelState3); + + // A checks that the state is changed according to the rules, signs this state, send signed state to B (e.g. via websocket) + + if (!(await channelA.verifyState(channelState3, signatureB3))) { + throw new Error('Invalid B signature'); + } + const signatureA3 = await channelA.signState(channelState3); + + //---------------------------------------------------------------------- + // So they can do this endlessly. + // Note that a party can make its transfers (from itself to another) asynchronously without waiting for the action of the other side. + // Party must increase its seqno by 1 for each of its transfers and indicate the last seqno and balance of the other party that it knows. + + //---------------------------------------------------------------------- + // CLOSE PAYMENT CHANNEL + + // The parties decide to end the transfer session. + // If one of the parties disagrees or is not available, then the payment channel can be emergency terminated using the last signed state. + // That is why the parties send signed states to each other off-chain. + // But in our case, they do it by mutual agreement. + + // First B signs closing message with last state, B sends it to A (e.g. via websocket) + + const signatureCloseB = await channelB.signClose(channelState3); + + // A verifies and signs this closing message and include B's signature + + // A sends closing message to blockchain, payments channel smart contract + // Payment channel smart contract will send funds to participants according to the balances of the sent state. + + if (!(await channelA.verifyClose(channelState3, signatureCloseB))) { + throw new Error('Invalid B signature'); + } + + await fromWalletA.close({ + ...channelState3, + hisSignature: signatureCloseB + }).send(toNano('0.05')); +} + +init(); \ No newline at end of file diff --git a/src/test-wallet.js b/src/test-wallet.js new file mode 100644 index 00000000..d55ede66 --- /dev/null +++ b/src/test-wallet.js @@ -0,0 +1,67 @@ +const TonWeb = require("./index"); + +async function init() { + const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC')); + + // Create private key + + const seed = TonWeb.utils.base64ToBytes('vt58J2v6FaBuXFGcyGtqT5elpVxcZ+I1zgu/GUfA5uY='); + const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(seed); + + // Create v3 wallet + + const WalletClass = tonweb.wallet.all['v3R2']; + const wallet = new WalletClass(tonweb.provider, { + publicKey: keyPair.publicKey, + wc: 0 + }); + + const walletAddress = (await wallet.getAddress()).toString(true, true, true); + console.log('my address', walletAddress) + + // Create transfer + + const transfer = wallet.methods.transfer({ + secretKey: keyPair.secretKey, + toAddress: 'EQA0i8-CdGnF_DhUHHf92R1ONH6sIA9vLZ_WLcCIhfBBXwtG', + amount: TonWeb.utils.toNano('0.01'), // 0.01 TON + seqno: 0, + payload: 'The aim of this text is to provide a brief', + expireAt: Math.floor(Date.now() / 1000) + 60 // now + 60 seconds + }); + + const query = await transfer.getQuery(); + const boc = TonWeb.utils.bytesToBase64(await query.toBoc(false)); // serialized query + // await tonweb.provider.sendBoc(boc); // send query to network + + // Parse query + + try { + const parsed = WalletClass.parseTransferQuery(TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(boc))); + + parsed.value = parsed.value.toString(); + parsed.fromAddress = parsed.fromAddress.toString(true, true, true); + parsed.toAddress = parsed.toAddress.toString(true, true, true); + console.log(parsed); + } catch (e) { + console.error(e); // not valid wallet transfer query + } + + // Get transaction and parse + + const transactions = await tonweb.provider.getTransactions(walletAddress.toString(true, true, true)); + + try { + const tx = transactions[0]; + const inMsgBody = TonWeb.utils.base64ToBytes(tx.in_msg.msg_data.body); + const parsed = WalletClass.parseTransferBody(TonWeb.boc.Cell.oneFromBoc(inMsgBody).beginParse()); + + parsed.value = parsed.value.toString(); + parsed.toAddress = parsed.toAddress.toString(true, true, true); + console.log(parsed); + } catch (e) { + console.error(e); // not valid wallet transfer tx + } +} + +init(); \ No newline at end of file diff --git a/src/test-wallet4.js b/src/test-wallet4.js index 67d2ae73..cf67b81a 100644 --- a/src/test-wallet4.js +++ b/src/test-wallet4.js @@ -40,7 +40,7 @@ async function init() { await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: BENEFICIARY, - amount: TonWeb.utils.toNano(0.01), // 0.01 TON + amount: TonWeb.utils.toNano('0.01'), // 0.01 TON seqno: seqno || 0, payload: 'Hello', sendMode: 3, @@ -54,7 +54,7 @@ async function init() { wc: 0, wallet: walletAddress, beneficiary: new TonWeb.utils.Address(BENEFICIARY), - amount: TonWeb.utils.toNano(1), // 1 ton + amount: TonWeb.utils.toNano('1'), // 1 ton startAt: 123, period: 2 * 60, // 2 min, timeout: 30, // 30 sec @@ -72,7 +72,7 @@ async function init() { secretKey: keyPair.secretKey, seqno: seqno, pluginWc: 0, - amount: TonWeb.utils.toNano(1), // 1 ton + amount: TonWeb.utils.toNano('1'), // 1 ton stateInit: (await subscription.createStateInit()).stateInit, body: subscription.createBody(), }).send() @@ -90,7 +90,7 @@ async function init() { secretKey: keyPair.secretKey, seqno: seqno, pluginAddress: PLUGIN_ADDRESS, - // amount: TonWeb.utils.toNano(0) + // amount: TonWeb.utils.toNano('0') }).send() ); } @@ -104,7 +104,7 @@ async function init() { secretKey: keyPair.secretKey, seqno: seqno, pluginAddress: PLUGIN_ADDRESS, - // amount: TonWeb.utils.toNano(0) + // amount: TonWeb.utils.toNano('0') }).send() ); } @@ -170,7 +170,7 @@ async function init() { await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: PLUGIN_ADDRESS, - amount: TonWeb.utils.toNano(0.2), + amount: TonWeb.utils.toNano('0.2'), seqno: seqno || 0, payload: body.array, sendMode: 3, @@ -194,14 +194,14 @@ async function init() { const body = new TonWeb.boc.Cell(); body.bits.writeUint(0x706c7567, 32); // op body.bits.writeUint(123, 64); // query id - body.bits.writeGrams(TonWeb.utils.toNano(2.22)); + body.bits.writeGrams(TonWeb.utils.toNano('2.22')); body.bits.writeUint(0, 1); // dict empty console.log( await wallet.methods.transfer({ secretKey: keyPair.secretKey, toAddress: WALLET_ADDRESS, - amount: TonWeb.utils.toNano(0.016), + amount: TonWeb.utils.toNano('0.016'), seqno: seqno || 0, payload: body, sendMode: 3, diff --git a/src/utils/Address.js b/src/utils/Address.js index 262cb788..31d33e86 100644 --- a/src/utils/Address.js +++ b/src/utils/Address.js @@ -78,8 +78,9 @@ class Address { return; } + this.isUrlSafe = true; + if (anyForm.search(/\-/) > 0 || anyForm.search(/_/) > 0) { - this.isUrlSafe = true; anyForm = anyForm.replace(/\-/g, '+').replace(/_/g, '\/'); } else { this.isUrlSafe = false; diff --git a/src/utils/AdnlAddress.js b/src/utils/AdnlAddress.js new file mode 100644 index 00000000..2ba0df95 --- /dev/null +++ b/src/utils/AdnlAddress.js @@ -0,0 +1,50 @@ +const {hexToBytes, bytesToHex} = require("./Utils"); + +class AdnlAddress { + /** + * @param anyForm {string | Uint8Array | AdnlAddress} + */ + static isValid(anyForm) { + try { + new AdnlAddress(anyForm); + return true; + } catch (e) { + return false; + } + } + + /** + * @param anyForm {string | Uint8Array | AdnlAddress} + */ + constructor(anyForm) { + if (anyForm == null) { + throw "Invalid address"; + } + + if (anyForm instanceof AdnlAddress) { + this.bytes = anyForm.bytes; + } else if (anyForm instanceof Uint8Array) { + if (anyForm.length !== 32) { + throw new Error('invalid adnl bytes length'); + } + this.bytes = anyForm; + } else if (typeof anyForm === 'string') { + if (anyForm.length !== 64) { + throw new Error('invalid adnl hex length'); + } + this.bytes = hexToBytes(anyForm); + } else { + throw new Error('unsupported type') + } + } + + toHex() { + let hex = bytesToHex(this.bytes); + while (hex.length < 64) { + hex = '0' + hex; + } + return hex; + } +} + +module.exports.default = AdnlAddress; diff --git a/src/utils/README.md b/src/utils/README.md index 8aeb6f19..f335b466 100644 --- a/src/utils/README.md +++ b/src/utils/README.md @@ -34,9 +34,9 @@ TonWeb.utils. * Address - Address class -* toNano(amount: number | BN | string): BN +* toNano(amount: BN | string): BN -* fromNano(amount: number | BN | string): string +* fromNano(amount: BN | string): string * bytesToHex(bytes: Uint8Array): string diff --git a/src/utils/StorageBagId.js b/src/utils/StorageBagId.js new file mode 100644 index 00000000..c40b7c2f --- /dev/null +++ b/src/utils/StorageBagId.js @@ -0,0 +1,50 @@ +const {hexToBytes, bytesToHex} = require("./Utils"); + +class StorageBagId { + /** + * @param anyForm {string | Uint8Array | StorageBagId} + */ + static isValid(anyForm) { + try { + new StorageBagId(anyForm); + return true; + } catch (e) { + return false; + } + } + + /** + * @param anyForm {string | Uint8Array | StorageBagId} + */ + constructor(anyForm) { + if (anyForm == null) { + throw "Invalid address"; + } + + if (anyForm instanceof StorageBagId) { + this.bytes = anyForm.bytes; + } else if (anyForm instanceof Uint8Array) { + if (anyForm.length !== 32) { + throw new Error('invalid bag id bytes length'); + } + this.bytes = anyForm; + } else if (typeof anyForm === 'string') { + if (anyForm.length !== 64) { + throw new Error('invalid bag id hex length'); + } + this.bytes = hexToBytes(anyForm); + } else { + throw new Error('unsupported type') + } + } + + toHex() { + let hex = bytesToHex(this.bytes); + while (hex.length < 64) { + hex = '0' + hex; + } + return hex; + } +} + +module.exports.default = StorageBagId; diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 53683062..315b7989 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -26,19 +26,27 @@ function sha256(bytes) { /** * from coins to nanocoins - * @param amount {number | BN | string} + * @param amount {BN | string} * @return {BN} */ function toNano(amount) { + if (!BN.isBN(amount) && !(typeof amount === 'string')) { + throw new Error('Please pass numbers as strings or BN objects to avoid precision errors.'); + } + return ethunit.toWei(amount, 'gwei'); } /** * from nanocoins to coins - * @param amount {number | BN | string} + * @param amount {BN | string} * @return {string} */ function fromNano(amount) { + if (!BN.isBN(amount) && !(typeof amount === 'string')) { + throw new Error('Please pass numbers as strings or BN objects to avoid precision errors.'); + } + return ethunit.fromWei(amount, 'gwei'); } @@ -296,6 +304,28 @@ function readNBytesUIntFromArray(n, ui8array) { return res; } +/** + * @param seed {Uint8Array} + * @returns {nacl.SignKeyPair} + */ +function keyPairFromSeed(seed) { + return nacl.sign.keyPair.fromSeed(seed); +} + +/** + * @returns {nacl.SignKeyPair} + */ +function newKeyPair() { + return nacl.sign.keyPair(); +} + +/** + * @returns {Uint8Array} + */ +function newSeed() { + return nacl.sign.keyPair().secretKey.slice(0, 32); +} + module.exports = { BN, nacl, @@ -313,5 +343,8 @@ module.exports = { base64toString, stringToBase64, compareBytes, - readNBytesUIntFromArray + readNBytesUIntFromArray, + keyPairFromSeed, + newKeyPair, + newSeed }; diff --git a/src/utils/index.js b/src/utils/index.js index 20195d75..50097d17 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -15,10 +15,15 @@ const { base64toString, stringToBase64, compareBytes, - readNBytesUIntFromArray + readNBytesUIntFromArray, + keyPairFromSeed, + newKeyPair, + newSeed } = require("./Utils"); const Address = require("./Address").default; +const AdnlAddress = require("./AdnlAddress").default; +const StorageBagId = require("./StorageBagId").default; // ton://transfer/EQA0i8-CdGnF_DhUHHf92R1ONH6sIA9vLZ_WLcCIhfBBXwtG // ton://transfer/EQA0i8-CdGnF_DhUHHf92R1ONH6sIA9vLZ_WLcCIhfBBXwtG?amount=1000000000 @@ -105,6 +110,8 @@ function formatTransferUrl(address, amount, text) { module.exports = { Address, + AdnlAddress, + StorageBagId, BN, nacl, sha256, @@ -123,5 +130,8 @@ module.exports = { compareBytes, readNBytesUIntFromArray, parseTransferUrl, - formatTransferUrl + formatTransferUrl, + keyPairFromSeed, + newKeyPair, + newSeed }; \ No newline at end of file