diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 2f285cb305c..00000000000 --- a/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -.git -.editorconfig -.gitignore -.next diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 3dce4145ff5..00000000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 38d404c2da5..00000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -updates: - - package-ecosystem: cargo - directory: "/" - schedule: - interval: daily - time: "04:00" - timezone: America/Los_Angeles - labels: - - "automerge" - open-pull-requests-limit: 3 - ignore: - - dependency-name: "cbindgen" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index c884585bac7..00000000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: Pull Request - -defaults: - run: - working-directory: ./rust - -on: - pull_request: - push: - branches: [master] - -jobs: - all_github_action_checks: - runs-on: ubuntu-latest - needs: - - rustfmt - - clippy - - cargo-build-test - steps: - - run: echo "Done" - working-directory: ./ - - rustfmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set env vars - run: | - source ci/rust-version.sh - echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_STABLE }} - override: true - profile: minimal - components: rustfmt - - - name: Run fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --manifest-path ./rust/Cargo.toml --all -- --check - - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set env vars - run: | - source ci/rust-version.sh - echo "RUST_NIGHTLY=$rust_nightly" >> $GITHUB_ENV - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_NIGHTLY }} - override: true - profile: minimal - components: clippy - - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: cargo-clippy-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - cargo-clippy- - - - name: Install dependencies - run: ./ci/install-build-deps.sh - - - name: Run clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --manifest-path ./rust/Cargo.toml -Zunstable-options --workspace --all-targets -- --deny=warnings - - cargo-build-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set env vars - run: | - source ci/rust-version.sh - echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV - source ci/solana-version.sh - echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_STABLE }} - override: true - profile: minimal - - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - # target # Removed due to build dependency caching conflicts - key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}} - - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/rustfilt - key: cargo-bpf-bins-${{ runner.os }} - - - uses: actions/cache@v2 - with: - path: | - ~/.cache - key: solana-${{ env.SOLANA_VERSION }} - - - name: Install dependencies - run: | - ./ci/install-build-deps.sh - ./ci/install-program-deps.sh - echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH - - - name: Build and test - run: ./ci/cargo-build-test.sh - - - name: Upload programs - uses: actions/upload-artifact@v2 - with: - name: programs - path: "rust/target/deploy/*.so" - if-no-files-found: error diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e075fe73447..00000000000 --- a/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -node_modules/ -build/ -dist/ -lib/ -deploy/ -docs/lockup-ui/ -.DS_Store -*~ -.idea -npm-debug.log* -yarn-debug.log* -yarn-error.log* -*.css -*.css.map -!js/packages/metaplex/src/fonts/fonts.css -!js/packages/metaplex/src/utils/globals.css -target -.env -.vscode -bin -config.json -node_modules -./package-lock.json -hfuzz_target -hfuzz_workspace -**/*.so -**/.DS_Store -.cache diff --git a/.mergify.yml b/.mergify.yml deleted file mode 100644 index 7b845b84c66..00000000000 --- a/.mergify.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Validate your changes with: -# -# $ curl -F 'data=@.mergify.yml' https://gh.mergify.io/validate/ -# -# https://doc.mergify.io/ -pull_request_rules: - - name: automatic merge (squash) on CI success - conditions: - - check-success=all_github_action_checks - - label=automerge - - author≠@dont-squash-my-commits - actions: - merge: - method: squash - # Join the dont-squash-my-commits group if you won't like your commits squashed - - name: automatic merge (rebase) on CI success - conditions: - - check-success=all_github_action_checks - - label=automerge - - author=@dont-squash-my-commits - actions: - merge: - method: rebase - - name: remove automerge label on CI failure - conditions: - - label=automerge - - "#status-failure!=0" - actions: - label: - remove: - - automerge - comment: - message: automerge label removed due to a CI failure - - name: remove outdated reviews - conditions: - - base=master - actions: - dismiss_reviews: - changes_requested: true diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/.travis/affects.sh b/.travis/affects.sh deleted file mode 100755 index 0d6bf3882d6..00000000000 --- a/.travis/affects.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -# -# Check if files in the commit range match one or more prefixes -# - -( - set -x - git diff --name-only "$TRAVIS_COMMIT_RANGE" -) - -for file in $(git diff --name-only "$TRAVIS_COMMIT_RANGE"); do - for prefix in "$@"; do - if [[ $file =~ ^"$prefix" ]]; then - exit 0 - fi - done -done - -echo "No modifications to $*" -exit 1 diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md deleted file mode 100644 index 172217c11af..00000000000 --- a/ARCHITECTURE.md +++ /dev/null @@ -1,981 +0,0 @@ -# Metaplex Developer Guide - -# Architecture - -## Overview - -Metaplex is actually not a single contract, but a contract ecosystem, consisting of four contracts that interact with one another. Only one of the contracts (Metaplex) actually knows about the other three, while the others represent primitives in the ecosystem and do not interact with each other at all. First, we'll go over what each contract does at a glance, and then we'll cover the full life cycle of a token becoming an NFT and getting auctioned to see the ecosystem in action. Following that will be modules for each contract. - -## The Contracts - -### Token Metadata - -This is the bedrock contract of the entire ecosystem. All that you need to interact with it is your own mint for which you have the mint authority. It is primarily a "mint decorator." It allows you to decorate your mint with a Metadata PDA that gives it a name, symbol, uri, list of creators with royalty splits, and whether or not it's been sold. You can do this with any mint with any supply. Phantom Wallet uses this Metadata account and it's URI field, which often links to a Manifest.json file of a certain format, to display NFTs in their Collections category on their UI. - -Furthermore, if your mint has one token in its supply, you can give it an additional decoration PDA, of type MasterEdition. This PDA denotes the mint as a special type of object that can mint other mints - which we call Editions (as opposed to MasterEditions because they can't print other mints themselves). This makes this mint like the "master records" that record studios used to use to make new copies of records back in the day. The MasterEdition PDA will take away minting and freezing authority from you in the process and will contain information about total supply, maximum possible supply, etc. - -The existence of Metadata and its sister PDA MasterEdition makes a very powerful combination for a mint that enables the entire rest of the Metaplex contract stack. Now you can create: - -- Normal mints that just have names (Metadata but no MasterEdition) -- One of a kind NFTs (Metadata + MasterEdition with `max_supply` of 0) -- NFTs that can print limited edition child NFTs (Metadata + MasterEdition with `max_supply` of say 10) -- NFTs that can print unlimited open edition NFTs (Metadata + MasterEdition with unlimited `max_supply`) - -You can also easily transfer ownership of these PDA records with the `updateAuthority` key on Metadata between parties, so you can sell printing rights to another party, or just give them the token itself while retaining the printing rights. - -### Token Vault - -Token Vault acts like a corporation or safe escrow for arbitrary token allotments. You can create a vault object, and insert any number of tokens from any number of mints into safety deposit boxes, and then activate the vault. It has a few different states, but the important ones are **Activated**, which is when it's locked and nobody can access its contents, and **Combined,** when the vault has essentially been opened and the vault authority can withdraw the contents. - -Going from **Activated** to **Combined** has only one restraint - that there are no outstanding fractional shares in circulation. You can in principle go straight from **Activated** to **Combined** immediately if you issue 0 fractional shares (which is what the Metaplex front-end contract does during Auction creation). - -Once the vault is **Activated**, you can then mint treasury shares that represent fractional ownership of the tokens inside the vault. The treasury shares are valued based on an external price indicator account that does not need to be owned by the vault and is considered the vault's price oracle, and these shares can then be sold on a dex or in an AMM or whatever you desire. This allows you, as the vault owner, to take your NFT(s) and turn them into a sort of corporation and sell partial ownership to other parties. If the external price oracle has its price driven by a proper third party such as a dex or other price discovery mechanism, then the entire system is balanced. - -When there are outstanding shares, you cannot, as the vault owner, **Combine** the vault, and retrieve your tokens, until you buy out the shares in circulation. You have to provide the number_of_shares_outstanding*price_from_oracle in the token_mint of the vault to the vault to unlock it. Then shareholders can return at their leisure to trade in shares for their winnings. - -### Auction - -The Auction Contract represents an auction primitive, and it knows nothing about NFTs, or Metadata, or anything else in the Metaplex ecosystem. All it cares about is that it has a resource address, it has auction mechanics, and it is using those auction mechanics to auction off that resource. It currently supports English Auctions and Open Edition Auctions (no winners but bids are tracked.) Its only purpose is to track who won what place in an auction and to collect money for those wins. When you place bids, or cancel them, you are interacting with this contract. However, when you redeem bids, you are not interacting with this contract, but Metaplex, because while it can provide proof that you did indeed win 4th place, it has no opinion on how the resource being auctioned off is divvied up between 1st, 2nd, 3rd, and 4th place winners, for example. - -This contract will be expanded in the future to include other auction types, and better guarantees between that the auctioneer claiming the bid actually has provided the prize by having the winner sign a PDA saying that they received the prize. Right now this primitive contract should *not* be used in isolation, but in companionship with another contract (like Metaplex in our case) that makes such guarantees that prizes are delivered if prizes are won. - -### Metaplex - -This is the granddaddy contract of them all. The primary product of the Metaplex contract are AuctionManagers, and they are the nexus of the other three contract's structs. The purpose of an AuctionManager is to understand that an Auction object is auctioning off the contents of a Vault, and that the contents of a Vault are different types of NFT arrangements, such as: - -- Limited Edition Prints (Printing a new child edition from limited supply) -- Open Edition Prints (Printing a new child edition from unlimited supply) -- Full Rights Transfers (Giving away token + metadata ownership) -- Single Token Transfers (Giving away a token but not metadata ownership) - -It orchestrates disbursements of those contents to winners of an auction. An AuctionManager requires both a Vault and an Auction to run, and it requires that the Auction's resource key be set to the Vault. - -Due to each type of NFT transfer above requiring slightly different nuanced handling and checking, Metaplex handles knowing about those things, and making the different CPI calls to the Token Metadata contract to make those things happen as required during the redemption phase. It also has full authority over all the objects like Vault and Auction, and handles all royalties payments by collecting funds from the auction into its own central escrow account and then disbursing to artists. - -## Basic Single Item Auction End To End - -Now that we've gone over the contracts, let's run through an example of how the contracts interact to create an NFT and sell it. I personally find these stories the most informative way to learn a new ecosystem. - -1. You allocate space for a mint account and a token account using Solana's system command and then you use spl-token JS SDK `createMint` and `createTokenAccount` commands to create a new mint and a new token account of that mint. You then use the `mintTo` command to mint a single token to that token account. -2. You now want to label this token account as a MasterEdition NFT that has a limited supply of 10 possible Limited Edition Prints. Cool! To begin with, you make a call to the Token Metadata's `create_metadata_account` endpoint, naming it the "Bob's Cool NFT" mint with symbol "BOB" and you pass in a link to a picture of your Uncle Bob for the URI. This command creates a Metadata account with a PDA seed of `['metadata', metadata_program_id, your_mint_id]` relative to the `metadata_program_id`. - - Note that the flow on the front end is a bit different - we put a dummy URI in place during this call, just to get the mint and metadata made, so that we can then push these values up to Arweave. Then we take the Arweave URL, and do a follow-up update_metadata_account call to update the Metadata with a proper URI that points to the metadata on the Arweave chain. It's a chicken-or-egg problem work-around because we need to have the Metadata existing to put it on Arweave, but we need the Arweave URI to place it in the Metadata. We simplify the case for this example. - -3. Next up, you need to turn this normal run of the mill NFT into a Master Edition. Right now you can still mint any number of tokens as you retain minting authority. The point of Metadata is to label mints - not just NFTs. So you call the create_master_edition endpoint on the Token Metadata contract which takes minting authority away from you, and creates a new Master Edition pda that contains information about how large a supply you want to have. - - When you want to mint Editions now, you'll need to present a token account containing the token from this Master Edition mint as proof of ownership and authority to do so. This is why we will later hand this token over to the Auction Manager, so that it can do the same to print off Editions for winners! - -4. Now that your token account has a bonafide NFT Master Edition in it, we can run an auction where we auction off Limited Edition prints! Let's say we want to auction off three such prints. -5. Next, we create a token vault using the `init_vault` endpoint of the token vault contract. We'll store our master edition token in it by adding it to the vault using the `add_token_to_inactive_vault` endpoint. This will create a safety deposit box in the vault that contains the the token. -6. Then we will call the `activate_vault` command which **Activates** the vault, locking everything inside. -7. We now **Combine** the vault using `combine_vault`, which is to say, we "open it," so the current authority could if they wanted withdraw the tokens inside it. The Auction Manager can only work with vaults in this state, which is why we have to go through the **Activation** phase to get here even though it seems a little nonsensical. See the in depth guide for more color on why these different states exist. -8. Next up, we create the auction, and we say its resource is this vault. The auction has not yet been started, but it has the right resource (the vault). We do this via the `create_auction` command on the Auction contract. -9. Now that we have an auction and a vault, we can go and call the `init_auction_manager` endpoint on the Metaplex contract with both of these accounts among a few others to create an AuctionManager, which ties them both together. Note that `init_auction_manager` takes a special struct called AuctionManagerSettings that allows one to specify how many winners there are and what winners get which items from which safety deposit box. At this point, we can't yet start the auction. The AuctionManager is in an invalidated state and we need to validate it by validating that the safety deposit boxes we provided to it in the vault are actually what we said are in them when we provided the AuctionManager with it's settings struct. -10. Before we begin validation, we call `set_authority` on both the vault and auction to change its authority to the auction manager, so that it has control over both of those structs. This is a requirement for the validation phase and the rest of the contract lifecycle. **Now you no longer have control over your items.** -11. We call the `validate_safety_deposit_box` endpoint on the Metaplex contract with the one safety deposit box in the vault, and the logic in this endpoint checks that there are exactly 3 printing tokens from the right mint in this box, matching the 3 printing tokens we promised it would have in our AuctionManagerSettings. Once we do this, and because this is the only safety deposit box in the vault, the AuctionManager is now validated. -12. We now call `start_auction` on the Metaplex contract, which, because the AuctionManager has authority over the Auction, calls `start_auction` on the Auction contract, and the auction begins! -13. Users can go and call `place_bid` on the Auction contract to place bids. When they do this, tokens of the `token_mint` type used by the auction are taken from the account they provide, tied to their main wallet, and stored in bidder pot accounts in the auction contract. -14. In order to update a bid, a user must first cancel the original bid, and then place a new bid. -15. Once the auction is over, a user can refund their bid if they did not win by calling `cancel_bid` again. Winners of the auction cannot cancel their bids. -16. The winner of a bid creates a mint with decimals 0, a token account with 1 token in it, and calls the `redeem_printing_v2_bid` endpoint on the Metaplex contract, all in a single transaction. This token is now *officially* a Limited Edition of the "Bob's Cool NFT" Master Edition NFT! -17. You, the auctioneer, visits /#/auction/id/billing and hit the settle button. This first iterates over all three bidders and for each wallet used, calls `claim_bid` on the Metaplex contract, which proxy-calls a `claim_bid` on the Auction contract, telling it to dump the winner's payment into an escrow account called `accept_payment` on the AuctionManager struct. It has the same token type as the auction. Once all payments have been collected, the front end then calls the `empty_payment_account` endpoint one time (since you are the only creator on the Metadata being sold) and the funds in this escrow are paid out to a token account provided of the same type owned by you. - - Note that our front end reference implementation uses SOL as the "token type." This has some special caveats, namely that SOL isn't really an "spl token." It instead has a work-around called the "Wrapped SOL mint." This is a special mint that is often used in a transient account. What this means is that when we place a bid, we actually make a one-off system account, transfer lamports to it of your bid amount + rent, then label it an spl-token account of the wrapped sol type, use it to place the bid, then close it all in one transaction. - - Special machinations in the spl token program then make this wrapped sol token account have a number of tokens with the proper decimals that map to the amount of SOL you transferred to it. We do a similar operation with cancelling, where we make a transient wrapped sol account, transfer cancelled bid funds to it, and then close the account, transferring funds out all in a single transaction. This is all done for ease of use. With settlements, when funds are disbursed to artists, we actually make a WSOL account for them and they have to close it by hand via a dropdown menu. - - The protocol operates off of generic spl tokens and has no opinions about WSOL specifically, but the front end reference implementation does. So take careful note! - -## Conclusion - -Now that you've been given this architectural overview, we'll follow up with specific in-depth break downs of each contract's state and mechanics. Hopefully you've got a better idea now of how they work together. If you have any further questions, you can always reach out to me, j_, on discord, or my twitter handle, @redacted_j. My partner in crime, b_, who helped build this protocol, can also be reached on twitter at @baalazamon. This was his brainchild and I couldn't have done it without him. He's been a good friend and an even better mentor. - -# Deep Dive - -Get ready and grab some aspirin. Here we go! - -## Token Metadata Contract - -### Overview - -The Token Metadata contract can be used for storing generic metadata about any given mint, whether NFT or not. Metadata allows storage of name, symbol, and URI to an external resource. Additionally, the Metadata allows for the tracking of creators, primary sales, and seller fees. Once the mint has been created, the mint authority can use the SPL Metadata program to create metadata as described in this document. - -Minting an NFT requires creating a new SPL Mint with the supply of one and decimals zero as described [https://spl.solana.com/token#example-create-a-non-fungible-token](https://spl.solana.com/token#example-create-a-non-fungible-token) - -Below is the Rust representation of the structs that are stored on-chain. - -```rust - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)] -pub struct Data { - /// The name of the asset - pub name: String, - /// The symbol for the asset - pub symbol: String, - /// URI pointing to JSON representing the asset - pub uri: String, - /// Royalty basis points that goes to creators in secondary sales (0-10000) - pub seller_fee_basis_points: u16, - /// Array of creators, optional - pub creators: Option>, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] -pub struct Metadata { - pub key: Key, - pub update_authority: Pubkey, - pub mint: Pubkey, - pub data: Data, - // Immutable, once flipped, all sales of this metadata are considered secondary. - pub primary_sale_happened: bool, - // Whether or not the data struct is mutable, default is not - pub is_mutable: bool, -} - -#[repr(C)] -#[derive(Clone, Debug, PartialEq, BorshSerialize, BorshDeserialize)] -pub struct MasterEdition { - pub key: Key, - - pub supply: u64, - - pub max_supply: Option, -} - -#[repr(C)] -#[derive(Clone, Debug, PartialEq, BorshSerialize, BorshDeserialize)] -/// All Editions should never have a supply greater than 1. -/// To enforce this, a transfer mint authority instruction will happen when -/// a normal token is turned into an Edition, and in order for a Metadata update authority -/// to do this transaction they will also need to sign the transaction as the Mint authority. -pub struct Edition { - pub key: Key, - - /// Points at MasterEdition struct - pub parent: Pubkey, - - /// Starting at 0 for master record, this is incremented for each edition minted. - pub edition: u64, -} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)] -pub struct Creator { - pub address: Pubkey, - pub verified: bool, - // In percentages, NOT basis points ;) Watch out! - pub share: u8, -} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)] -pub struct EditionMarker { - pub key: Key, - pub ledger: [u8; 31], -} - -``` - -The instruction set for the token metadata contract can be found here: [https://github.com/metaplex-foundation/metaplex/blob/master/rust/token-metadata/program/src/instruction.rs](https://github.com/metaplex-foundation/metaplex/blob/master/rust/token-vault/program/src/instruction.rs) - -### Types - -### Metadata - -This object can be used to provide basic info about SPL tokens on Solana, which include the name, symbol, URI and seller fees, as well as whether or not the sale of this metadata has happened yet. Anybody carrying a token from this mint can mark this primary sale as having happened via the `update_primary_sale_happened_via_token` command. There is obviously no incentive for a primary owner to do this as it precludes them from getting full royalties on the first sale, but a secondary owner must do this if they ever want to see fees from selling! - -Metadata accounts are simply PDA addresses with derived key of `['metaplex', metaplex_program_id, mint_id]`. - -### Master Edition - -In addition to simple metadata, a Master Edition object can be created. Master Editions act similar to a token mint and allows the holder to create new number editions while tracking provenance of the items. A Master Edition token, when minted, represents both a non-fungible token on Solana and metadata that allows creators to control the provenance of prints created from the master edition. A Master Edition object can only be created for mints with supply of one and decimals of zero. - -The creator can set the maximum supply of the master edition just like a regular mint on Solana, with the main difference being that each print is a numbered edition created from it. To mint a new limited edition, this master edition token must be presented, along with a new mint + token, to the `mint_new_edition_from_master_edition_via_token` endpoint. - -Master Edition accounts are PDA addresses of `['metaplex', metaplex_program_id, mint_id, 'edition']`. - -### Edition - -An edition represents a copy of an NFT, and is created from a Master Edition. Each print has an edition number associated with it. Normally, prints can be created during Open Edition or Limited Edition auction, but they could also be created by the creator manually. - -Editions are created by presenting the Master Edition token, along with a new mint that lacks a Metadata account and a token account containing one token from that mint to the `mint_new_edition_from_master_edition_via_token` endpoint. This endpoint will create both an immutable Metadata based on the parent Metadata and a special Edition struct based on the parent Master Edition struct. - -The Edition has the same PDA as a Master Edition to force collision and prevent a user from having a mint with both, `['metaplex', metaplex_program_id, mint_id, 'edition']`. - -## Concepts - -### Decoration as PDA Extensions - -The whole idea of the Token Metadata program is to be a decorator to a Token Mint. Each struct acts as further decoration. The Metadata struct gives a mint a name and a symbol and points to some external URI that can be anything. The Master Edition gives it printing capabilities. The Edition labels it as a child of something. - -This is important to internalize, because it means you as a Rust developer can take it a step further. There is nothing stopping you from building a new contract on top of ours that makes it's own PDAs and and extending this still further. Why not build a CookingRecipes PDA, that has seed `['your-app', your_program_id, mint_id, 'recipes']`? You can require that a Metadata PDA from our contract exists to make a PDA in your program, and then you can further decorate mints on top of our decorations. The idea is to compose mints with further information than they ever had before, and then build clients that can consume that information in new and interesting ways. - -### Co-Creators - -The SPL Metadata program supports storing up to five co-creators that share potential future profits from sales for the items as defined by `seller_fee_basis_points` . Each creator needs to be added as part of the minting process and is required to approve metadata that was used in his name using the `sign_metadata` endpoint. Unverified artwork cannot be sold with Metaplex. - -During the first sale, creators share in 100% of the proceeds, while in follow up sales, they share in proceeds as a percentage determined by `seller_fee_basis_points`. Whether or not a metadata is considered in second sale or not is determined by the `primary_sale_happened` boolean on the Metadata account. - -### URI JSON Schema - -The URI resource is compatible with [ERC-1155 JSON Schema](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md#erc-1155-metadata-uri-json-schema) in order to easily port NFTs across different chains using the wormhole bridge. You can see how we build this in our reference implementation here: [https://github.com/metaplex-foundation/metaplex/blob/master/js/packages/web/src/actions/nft.tsx#L66](https://github.com/metaplex-foundation/metaplex/blob/master/js/packages/web/src/actions/nft.tsx#L66) - -```jsx -{ - "title": "Token Metadata", - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Identifies the asset to which this token represents" - }, - "description": { - "type": "string", - "description": "Describes the asset to which this token represents" - }, - "image": { - "type": "string", - "description": "A URI pointing to a resource with mime type image/* representing the asset to which this token represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive." - }, - "external_url": { - "type": "string", - "description": "A URI pointing to an external resource that will take user outside of the platform." - }, - "seller_fee_basis_points": { - "type": "number", - - }, - "properties": { - "type": "object", - "description": "Arbitrary properties. Values may be strings, numbers, object or arrays.", - "properties": { - "creators": { - "type": "array", - "description": "Contains list of creators, each with Solana address and share of the nft" - }, - } - } - } -} -``` - -## Token Vault - -### Overview - -The Token Vault serves two purposes in the Metaplex ecosystem: Storing tokens for safe-keeping for the Auction Manager, and as a fractionalization service for NFTs. It has two primary concepts, that of the Vault and of the Safety Deposit Box. A Vault can have any number of Safety Deposit Boxes, one per unique mint being stored. A Vault goes through many phases in life-cycle, but the two important ones are when it's **Activated** and when it is **Combined**. When it is **Activated**, new fractional shares can be minted and distributed for partial ownership, and when it is **Combined**, fractional owners can burn their shares in exchange for remuneration and the vault authority can retrieve the stored tokens in the Vault. - -Below is the Rust state stored on chain: - -```rust -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq)] -pub enum Key { - Uninitialized, - SafetyDepositBoxV1, - ExternalAccountKeyV1, - VaultV1, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq)] -pub enum VaultState { - Inactive, - Active, - Combined, - Deactivated, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize)] -pub struct Vault { - pub key: Key, - /// Store token program used - pub token_program: Pubkey, - /// Mint that produces the fractional shares - pub fraction_mint: Pubkey, - /// Authority who can make changes to the vault - pub authority: Pubkey, - /// treasury where fractional shares are held for redemption by authority - pub fraction_treasury: Pubkey, - /// treasury where monies are held for fractional share holders to redeem(burn) shares once buyout is made - pub redeem_treasury: Pubkey, - /// Can authority mint more shares from fraction_mint after activation - pub allow_further_share_creation: bool, - - /// Must point at an ExternalPriceAccount, which gives permission and price for buyout. - pub pricing_lookup_address: Pubkey, - /// In inactive state, we use this to set the order key on Safety Deposit Boxes being added and - /// then we increment it and save so the next safety deposit box gets the next number. - /// In the Combined state during token redemption by authority, we use it as a decrementing counter each time - /// The authority of the vault withdrawals a Safety Deposit contents to count down how many - /// are left to be opened and closed down. Once this hits zero, and the fraction mint has zero shares, - /// then we can deactivate the vault. - pub token_type_count: u8, - pub state: VaultState, - - /// Once combination happens, we copy price per share to vault so that if something nefarious happens - /// to external price account, like price change, we still have the math 'saved' for use in our calcs - pub locked_price_per_share: u64, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize)] -pub struct SafetyDepositBox { - // Please note if you change this struct, be careful as we read directly off it - // in Metaplex to avoid serialization costs... - /// Each token type in a vault has it's own box that contains it's mint and a look-back - pub key: Key, - /// Key pointing to the parent vault - pub vault: Pubkey, - /// This particular token's mint - pub token_mint: Pubkey, - /// Account that stores the tokens under management - pub store: Pubkey, - /// the order in the array of registries - pub order: u8, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize)] -pub struct ExternalPriceAccount { - pub key: Key, - pub price_per_share: u64, - /// Mint of the currency we are pricing the shares against, should be same as redeem_treasury. - /// Most likely will be USDC mint most of the time. - pub price_mint: Pubkey, - /// Whether or not combination has been allowed for this vault. - pub allowed_to_combine: bool, -} - -``` - -The instruction set for the vault can be found here: [https://github.com/metaplex-foundation/metaplex/blob/master/rust/token-vault/program/src/instruction.rs](https://github.com/metaplex-foundation/metaplex/blob/master/rust/token-vault/program/src/instruction.rs) - -### Types - -### Vault - -The Big Kahuna and namesake of this contract, the Vault is really a container of many concepts. The Vault can be used without any fractional share emissions as a kind of escrow service for many different tokens of different mint types, and indeed, this is what Metaplex uses it for when performing Auctions. However it can also be used to provide partial ownership of NFTs to interested investors. Let's break down the keys in the Vault's state one by one. - -**Fractional shares:** It points at a `fractional_mint` and `fractional_treasury`, which allows the vault authority to mint new fractional shares to a treasury account before (or optionally after) **Activation** of the vault. Shares inside the treasury don't count towards the cost of **Combining** the vault. - -**Redeem treasury:** This account is used to hold in escrow the funds used to pay off fractional shareholders when the vault authority wishes to **Combine** the vault and regain possession of the stored assets inside. The vault authority has to pay shares_in_circulation*price_of_shares into this redeem treasury. The mint of the treasury is completely decidable by the vault authority, we make no opinions on that. - -**Pricing Lookup Address:** This is a pointer to an ExternalLookupAccount, which while its struct is defined by the Token Vault program, the account itself does not need to be owned by the vault program or anything within it. It is meant to be an external pricing oracle that is independent of the vault authority or vault that provides pricing data on the fractional share price so that the fractional share owners get a fair buyout by the vault authority. - -Token Vaults do not have PDA addresses. - -### Safety Deposit Box - -A safety deposit box keeps track of the token account containing the tokens, its vault, and what order in the vault it maintains. If it was inserted 3rd, it's order is 2 (0-based.) It's a pretty simple setup. And yes, you should be aware the safety deposit box doesn't *actually* store any tokens - it contains a `store` key that points to an spl-token account that contains the tokens. It's more of a foreign key join table between the vault and the store. - -Safety Deposit Boxes always have PDA addresses of type `['vault', vault_key, mint_key]`. - -### External Price Account - -The External Price Account is meant to be used as an external oracle. It is provided to a Vault on initialization and doesn't need to be owned or controlled by the vault authority (though it can be.) It can provide data on the `price_per_share` of fractional shares, whether or not the vault authority is currently allowed to **Combine** the vault and reclaim the contents, and what the `price_mint` of the vault is. - -ExternalPriceAccounts do not have PDA addresses. - -## Concepts - -### Vault State Machine - -A Vault begins its journey in the **Inactive** state. It is in this state that tokens can be added, and fractional shares can be minted into the fractional treasury. The idea is this phase is the "prep" where we are getting the Vault ready for use as an escrow or as a holding corporation for fractional ownership of NFTs. - -Once the vault is **Activated**, the Vault is closed, and the vault authority may *not* remove the tokens from the Vault. Furthermore, no new fractional shares may be minted unless during initialization the special `allow_further_share_creation` boolean was set. Some fractional share owners may not be too enthused about buying into a vault only to be diluted later, so we make this a one-time thing during initialization where the vault authority gets to choose what kind of vault it gets to be. The vault authority *can* however, remove shares from the treasury and give them to whomever they want, or start a dex with them, or an AMM, or what have you. These shares represent partial ownership of the vault now! - -Let's now say that the vault authority now wants to regain access to the Vault's contents. To do this, first, the ExternalPriceAccount tied to the vault needs to have `allowed_to_combine` set to true. If this is the case, the vault authority can then **Combine** the Vault, providing a token account with enough tokens to pay off all outstanding fractional share holders to the Vault. The Vault will drain this account to the `redeem_treasury` and the Vault will move to the **Combined** state. The Vault will use the `price_per_share` on the ExternalPriceAccount for this calculation. If no shares are outstanding, this **Combination** operation is free. During **Combination**, the vault authority also has the option to transmit vault authority to a new authority. Also note that all shares remaining in the fractional treasury are burned in this step. - -Once **Combined**, the Vault's contents can now be emptied by the vault authority, and fractional share owners can redeem (and burn) their fractional share tokens for tokens from the `redeem_treasury`. When all tokens in all safety deposit boxes have been removed, and all fractional tokens have been burned, the Vault will automatically move to the **Deactivated** state. - -## Auction - -### Overview - -The Auction contract is a primitive that is meant to be used in conjunction with another smart contract that understands the context of the resource for which the auction is being held. It contains mechanics for collecting payment from bidders, for keeping track of a winners list, and handling bid placement and cancellation, but it has no opinions on what the resource being bid on should be, or how it gets divided. - -While it currently has support for English Auctions and Open Edition Auctions, it will in the future support other types of auctions such as Vickrey and Dutch Auctions. The state for the contract is reproduced here: - -```rust -/// Structure with pricing floor data. -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub enum PriceFloor { - /// Due to borsh on the front end disallowing different arguments in enums, we have to make sure data is - /// same size across all three - /// No price floor, any bid is valid. - None([u8; 32]), - /// Explicit minimum price, any bid below this is rejected. - MinimumPrice([u64; 4]), - /// Hidden minimum price, revealed at the end of the auction. - BlindedPrice(Hash), -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub struct AuctionData { - /// Pubkey of the authority with permission to modify this auction. - pub authority: Pubkey, - /// Pubkey of the resource being bid on. - /// TODO try to bring this back some day. Had to remove this due to a stack access violation bug - /// interactin that happens in metaplex during redemptions due to some low level rust error - /// that happens when AuctionData has too many fields. This field was the least used. - ///pub resource: Pubkey, - /// Token mint for the SPL token being used to bid - pub token_mint: Pubkey, - /// The time the last bid was placed, used to keep track of auction timing. - pub last_bid: Option, - /// Slot time the auction was officially ended by. - pub ended_at: Option, - /// End time is the cut-off point that the auction is forced to end by. - pub end_auction_at: Option, - /// Gap time is the amount of time in slots after the previous bid at which the auction ends. - pub end_auction_gap: Option, - /// Minimum price for any bid to meet. - pub price_floor: PriceFloor, - /// The state the auction is in, whether it has started or ended. - pub state: AuctionState, - /// Auction Bids, each user may have one bid open at a time. - pub bid_state: BidState, -} - -// Further storage for more fields. Would like to store more on the main data but due -// to a borsh issue that causes more added fields to inflict "Access violation" errors -// during redemption in main Metaplex app for no reason, we had to add this nasty PDA. -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub struct AuctionDataExtended { - /// Total uncancelled bids - pub total_uncancelled_bids: u64, - // Unimplemented fields - /// Tick size - pub tick_size: Option, - /// gap_tick_size_percentage - two decimal points - pub gap_tick_size_percentage: Option, -} - -/// Define valid auction state transitions. -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub enum AuctionState { - Created, - Started, - Ended, -} - -/// Bids associate a bidding key with an amount bid. -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub struct Bid(pub Pubkey, pub u64); - -/// BidState tracks the running state of an auction, each variant represents a different kind of -/// auction being run. -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub enum BidState { - EnglishAuction { bids: Vec, max: usize }, - OpenEdition { bids: Vec, max: usize }, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub enum WinnerLimit { - Unlimited(usize), - Capped(usize), -} - -/// Models a set of metadata for a bidder, meant to be stored in a PDA. This allows looking up -/// information about a bidder regardless of if they have won, lost or cancelled. -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub struct BidderMetadata { - // Relationship with the bidder who's metadata this covers. - pub bidder_pubkey: Pubkey, - // Relationship with the auction this bid was placed on. - pub auction_pubkey: Pubkey, - // Amount that the user bid. - pub last_bid: u64, - // Tracks the last time this user bid. - pub last_bid_timestamp: UnixTimestamp, - // Whether the last bid the user made was cancelled. This should also be enough to know if the - // user is a winner, as if cancelled it implies previous bids were also cancelled. - pub cancelled: bool, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq)] -pub struct BidderPot { - /// Points at actual pot that is a token account - pub bidder_pot: Pubkey, - /// Originating bidder account - pub bidder_act: Pubkey, - /// Auction account - pub auction_act: Pubkey, - /// emptied or not - pub emptied: bool, -} - -``` - -The instruction set for auction can be found here: [https://github.com/metaplex-foundation/metaplex/blob/master/rust/auction/program/src/instruction.rs](https://github.com/metaplex-foundation/metaplex/blob/master/rust/token-vault/program/src/instruction.rs) - -### Types - -### AuctionData - -This is the core data representing an auction in this program. It contains (almost) all of the configuration representing an auction. You'll notice that it has a `token_mint` field which means any spl_token can be used as the base mint for an auction, so you can bid in any currency! It also keeps track of a few other goodies, so let's break them down one by one: - -`last_bid`: Every time someone bids, this is set. Useful for doing math with the gap time feature. - -`ended_at` : This is when the auction actually will end or has ended. It can be set at any time. - -`end_auction_at` : This is actually a duration and is a little confusing. If you're planning to start your auction at a later point in time, you can set this as a duration, and when you finally start your auction, ended_at will be set to now + this duration. Useful, right? Maybe poorly named. Our bad. - -`end_auction_gap` : Used in conjunction with `last_bid` - if this is set to 1 minute, then let's say someone makes a bid in the last 5 seconds of an auction. The auction is then extended by 55 seconds from it's original end time (+ 1 minute from the last bid.) If someone then makes another bid within that time period, it's another + 1 minute from that bid. And so on. - -`price_floor` : Various options for price floor, but essentially you can use this to set no price floor, a minimum price floor, or a blind price floor on the auction. See the enum for more. - -AuctionData accounts always have PDA addresses of `['auction', auction_program_id, resource_id]` where `resource_id` is the thing being auctioned off and `auction_program_id` is the id of the auction contract. - -### Bid State - -Bid State is technically not a top level struct, but an embedded one within AuctionData. I thought it was good to give it a section anyway because it's a complex little beast. It's actually an enum that holds a bid vector and a maximum size denoting how many of those bids are actually "valid winners" vs just placeholders. - -It's reversed, which is to say that the number one winner is always at the end of the vec. It's also always bigger generally than the number of winners so that if a bid is cancelled, we have some people who got bumped out of top spots that can be moved back into them without having to cancel and replace their bids. When a bid is placed, it is inserted in the proper position based on it's amount and then the lowest bidder is bumped off the 0th position of the vec if the vec is at max size, so the vec remains sorted at all times. - -In the case of open edition, the max is always zero, ie there are never any winners, and we are just accepting bids and creating BidderMetadata tickets and BidderPots to accept payment for (probably) fixed price Participation NFTs. - -We would prefer that OpenEdition enum have no bid vector and no max, but unfortunately borsh-js does not support enums with different internal data structures, so all data structures in an enum must be identical (even if unused.) Keep that in mind when designing your own end to end borsh implementations! - -### BidderMetadata - -This is created and/or updated during the `place_bid` and `cancel_bid` endpoints of the contract, and acts as proof to other contracts and this one that a bidder actually placed a bid, because there is no guarantee that this bidder will have an entry in the actual BidState as they could've gotten knocked off the array in high periods of bidder activity. - -BidderMetadata always has a PDA of `['auction', auction_program_id, auction_id, bidder_key, 'metadata']` where `auction_program_id` is the program id of the auction contract, `auction_id` is the key of the auction, and `bidder_key` is the wallet making the bid. - -### BidderPot - -This ended up being a bit of a redundant struct, but this serves as a join table between the actual token account containing the funds collected by the auction for a given bidder, the bidder's sol wallet, and an auction. In the future we may merge this struct into BidderMetadata. There is also an `emptied` boolean on it to track whether or not the bidder pot has been claimed by the auctioneer for easy lookup. - -BidderPot always has a PDA of `['auction', auction_program_id, auction_id, bidder_key]`where `auction_program_id` is the program id of the auction contract, `auction_id` is the key of the auction, and `bidder_key` is the wallet making the bid. - -### AuctionDataExtended - -If you've read this far, you now get to witness my personal shame. So as it turns out, if you build a complex enough program with enough structs flying around, there is some kind of weird interaction in the Metaplex contract that causes it to blow out with an access violation if you add more than a certain number of keys to one particular struct (AuctionData), and *only* during the redemption endpoint calls. We were unable to discern why this was across 3 days of debugging. We had a theory it was due to some issue with borsh but it is not 100% certain, as we're not experts with that library's internals. - -Instead, our work-around was to introduce AuctionDataExtended to add new fields that we needed to AuctionData without breaking this hidden bug that seems to exist. What is odd about the whole thing is adding fields to *other* structs doesn't cause any issues. In the future I'd love to have someone who knows way more than me about these subjects weigh in and tell me what I did wrong here to resolve this split-brain problem! We also don't have reverse lookup capability (Resource key on AuctionData) because of this bug - adding it would cause the blow out I mentioned. - -Another note here is `gap_tick_size_percentage` as of the time of this writing has not been implemented yet, it is just a dummy field. - -AuctionDataExtended accounts always have PDA addresses of `['auction', auction_program_id, resource_id, 'extended']` where `resource_id` is the thing being auctioned off and `auction_program_id` is the id of the auction contract. - -### Concepts - -### Incompleteness - -The contract currently has a deficiency in it's implementation where an auctioneer can claim the funds for a winning bid without the winner having signed off on having received some sort of prize for that bid - which is why we mention the "conjunction" above in the Overview. Metaplex guarantees through the interaction with the Metaplex contract that all users of Metaplex + Auction combination get a prize, but use of Auction by itself does not guarantee a winner gets a prize for a bid, because this functionality does not exist in this contract alone yet. A future version of this contract will require the winning bidders to create a PDA admitting they have received a prize before the auctioneer can withdraw funds, making this a complete primitive that can be used without any other contract making guarantees. - -The way Metaplex makes such a guarantee is that it controls the Vault resource being bid on, and if you present the Metaplex contract with a BidderMetadata account from the Auction that represents a winning bid, it will disburse the proper NFT to you from the Vault. You can do the same with your own custom implementation. - -### Cancelling before Placing a Bid - -Currently you cannot change or place a new bid until you cancel the old one. Just keep that in mind - it makes for easier logic all around. This may change in the future as we add support for bidders not being able to cancel once a bid is placed, or not being able to bid less than they previously bid. - -### Claiming bids - -Pulling money out of the auction contract as an auctioneer can only be done after an auction has ended and must be done for each winning bid, one after the other. You provide a destination token account and drain each bidder pot to it via the `claim_bid` endpoint. - -### Refunds - -Refunds work by cancelling bids. Currently, any bidder can cancel any time during an auction, but only non-winners of the auction can cancel after it ends. When users cancel, they receive full refunds. The "refund bid" button on the front end just cancels the bid. - -### Turning the Crank - -The `place_bid` will turn the state of the auction to **Ended** if someone places a bid after the auction's `ended_at` date passes. It will then return `Ok(())` in a kind of silent pass without actually placing a bid. Once the auction is in the **Ended** state, bid funds can be claimed by the auctioneer. This is actually how an auction is really ended - it does not end on it's own accord, someone has to turn the crank! In theory, an auction will remain open for all eternity, past its own end date, if nobody touches it, but nobody can do any invalid things to it. It's kind of like Schrodinger's Cat. However, even if an auction is not officially in **Ended** state but it is past its `ended_at`, winners will not be allowed to cancel bids. - -## Metaplex - -### Overview - -The Metaplex is the contract that knows how the others tie together and understands what an NFT truly is, how to auction it off and how to redeem it for others. It also understands the concept of royalties and how to pay them out. It's job is to act is the orchestrator between a Vault full of tokens, an Auction primitive, a bunch of winners, creators, and an auctioneer, and make sure everybody gets what is deserved, whether it be monies or tokens (though in the end they are all tokens). - -It's state is reproduced here: - -```rust -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug, Copy)] -pub enum Key { - Uninitialized, - OriginalAuthorityLookupV1, - BidRedemptionTicketV1, - StoreV1, - WhitelistedCreatorV1, - PayoutTicketV1, - SafetyDepositValidationTicketV1, - AuctionManagerV1, - PrizeTrackingTicketV1, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] -pub struct AuctionManager { - pub key: Key, - - pub store: Pubkey, - - pub authority: Pubkey, - - pub auction: Pubkey, - - pub vault: Pubkey, - - pub accept_payment: Pubkey, - - pub state: AuctionManagerState, - - pub settings: AuctionManagerSettings, - - /// True if this is only winning configs of one item each, used for optimization in saving. - pub straight_shot_optimization: bool, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] -pub struct AuctionManagerState { - pub status: AuctionManagerStatus, - /// When all configs are validated the auction is started and auction manager moves to Running - pub winning_config_items_validated: u8, - - pub winning_config_states: Vec, - - pub participation_state: Option, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] -pub struct AuctionManagerSettings { - /// The safety deposit box index in the vault containing the winning items, in order of place - /// The same index can appear multiple times if that index contains n tokens for n appearances (this will be checked) - pub winning_configs: Vec, - - /// The participation config is separated because it is structurally a bit different, - /// having different options and also because it has no real "winning place" in the array. - pub participation_config: Option, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub struct ParticipationState { - /// We have this variable below to keep track in the case of the participation NFTs, whose - /// income will trickle in over time, how much the artists have in the escrow account and - /// how much would/should be owed to them if they try to claim it relative to the winning bids. - /// It's abit tougher than a straightforward bid which has a price attached to it, because - /// there are many bids of differing amounts (in the case of GivenForBidPrice) and they dont all - /// come in at one time, so this little ledger here keeps track. - pub collected_to_accept_payment: u64, - - /// Record of primary sale or not at time of auction creation, set during validation step - pub primary_sale_happened: bool, - - pub validated: bool, - - /// An account for printing authorization tokens that are made with the one time use token - /// after the auction ends. Provided during validation step. - pub printing_authorization_token_account: Option, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub struct ParticipationConfig { - /// Setups: - /// 1. Winners get participation + not charged extra - /// 2. Winners dont get participation prize - pub winner_constraint: WinningConstraint, - - /// Setups: - /// 1. Non-winners get prize for free - /// 2. Non-winners get prize but pay fixed price - /// 3. Non-winners get prize but pay bid price - pub non_winning_constraint: NonWinningConstraint, - - /// The safety deposit box index in the vault containing the template for the participation prize - pub safety_deposit_box_index: u8, - /// Setting this field disconnects the participation prizes price from the bid. Any bid you submit, regardless - /// of amount, charges you the same fixed price. - pub fixed_price: Option, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub enum WinningConstraint { - NoParticipationPrize, - ParticipationPrizeGiven, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, PartialEq, Debug)] -pub enum NonWinningConstraint { - NoParticipationPrize, - GivenForFixedPrice, - GivenForBidPrice, -} - -#[repr(C)] -#[derive(Clone, PartialEq, BorshSerialize, BorshDeserialize, Copy, Debug)] -pub enum WinningConfigType { - /// You may be selling your one-of-a-kind NFT for the first time, but not it's accompanying Metadata, - /// of which you would like to retain ownership. You get 100% of the payment the first sale, then - /// royalties forever after. - /// - /// You may be re-selling something like a Limited/Open Edition print from another auction, - /// a master edition record token by itself (Without accompanying metadata/printing ownership), etc. - /// This means artists will get royalty fees according to the top level royalty % on the metadata - /// split according to their percentages of contribution. - /// - /// No metadata ownership is transferred in this instruction, which means while you may be transferring - /// the token for a limited/open edition away, you would still be (nominally) the owner of the limited edition - /// metadata, though it confers no rights or privileges of any kind. - TokenOnlyTransfer, - /// Means you are auctioning off the master edition record and it's metadata ownership as well as the - /// token itself. The other person will be able to mint authorization tokens and make changes to the - /// artwork. - FullRightsTransfer, - /// Means you are using authorization tokens to print off editions during the auction using - /// from a MasterEditionV1 - PrintingV1, - /// Means you are using the MasterEditionV2 to print off editions - PrintingV2, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] -pub struct WinningConfig { - // For now these are just array-of-array proxies but wanted to make them first class - // structs in case we want to attach other top level metadata someday. - pub items: Vec, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] -pub struct WinningConfigState { - pub items: Vec, - /// Ticked to true when money is pushed to accept_payment account from auction bidding pot - pub money_pushed_to_accept_payment: bool, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy, Debug)] -pub struct WinningConfigItem { - pub safety_deposit_box_index: u8, - pub amount: u8, - pub winning_config_type: WinningConfigType, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy, Debug)] -pub struct WinningConfigStateItem { - /// Record of primary sale or not at time of auction creation, set during validation step - pub primary_sale_happened: bool, - /// Ticked to true when a prize is claimed by person who won it - pub claimed: bool, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Debug, PartialEq)] -pub enum AuctionManagerStatus { - Initialized, - Validated, - Running, - Disbursing, - Finished, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy)] -pub struct OriginalAuthorityLookup { - pub key: Key, - pub original_authority: Pubkey, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy)] -pub struct BidRedemptionTicket { - pub key: Key, - pub participation_redeemed: bool, - pub items_redeemed: u8, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy)] -pub struct PayoutTicket { - pub key: Key, - pub recipient: Pubkey, - pub amount_paid: u64, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy)] -pub struct Store { - pub key: Key, - pub public: bool, - pub auction_program: Pubkey, - pub token_vault_program: Pubkey, - pub token_metadata_program: Pubkey, - pub token_program: Pubkey, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy)] -pub struct WhitelistedCreator { - pub key: Key, - pub address: Pubkey, - pub activated: bool, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy)] -pub struct SafetyDepositValidationTicket { - pub key: Key, - pub address: Pubkey, -} - -#[repr(C)] -#[derive(Clone, BorshSerialize, BorshDeserialize, Copy, Debug)] -pub struct PrizeTrackingTicket { - pub key: Key, - pub metadata: Pubkey, - pub supply_snapshot: u64, - pub expected_redemptions: u64, - pub redemptions: u64, -} -``` - -The instruction set for metaplex can be found here: [https://github.com/metaplex-foundation/metaplex/blob/master/rust/metaplex/program/src/instruction.rs](https://github.com/metaplex-foundation/metaplex/blob/master/rust/token-vault/program/src/instruction.rs) - -### Types - -### AuctionManager - -This is the top level struct of the entire contract and serves as a container for "all the things." When you make auctions on Metaplex, you are actually really making these ultimately. An AuctionManager has a single authority (you, the auctioneer), a store, which is the storefront struct, an Auction from the auction contract, and a Vault from the vault contract. It also has a token account called `accept_payment` that serves as a central clearing escrow for all tokens that it will collect in the future from the winning bidders and all payments for fixed price participation nfts from all non-winners in the auction. - -It contains embedded within it a separate `state` and `settings` struct. It is seeded with the `settings` on initialization by the caller, while the `state` is derived from `settings` on initialization. AuctionManager goes through several states: - -**Initialized:** This is the state it begins in. You provide a **Created** auction and a **Combined** vault. You can't start the auction yet though because you need to prove to this AuctionManager that the configurations you provided in your settings match the tokens in the vault. - -**Validated:** You have now proven that each winning configuration in your settings match the tokens in your vault, and you can start the auction via a proxy call. - -**Running:** The underlying Auction is now running. - -**Disbursing**: The underlying Auction is over and now the AuctionManager is in the business of disbursing royalties to the auctioneer and creators, prizes and participation NFTs to the winners, and possibly participation NFTs to the non-winners. - -**Finished:** All funds and prizes disbursed. - -This state is not currently in use as switching to it requires an iteration over prizes to review all items for claimed-ness and this costs CPU that is too precious during the redemption call OR adding new endpoint that is not guaranteed to be called. We will revisit it later to bring it back during a refactoring, for now it is considered a NOOP state. - -AuctionManagers always have PDAs of seed `['metaplex', metaplex_program_id, auction_id]` where metaplex_program_id is the id of the Metaplex contract and `auction_id` is the address of the Auction being passed to the AuctionManager. - -### AuctionManagerSettings - -AuctionManagerSettings is an embedded struct inside AuctionManager but is deserving of it's own section. This struct is actually provided by the user in the `init_auction_manager` call to parameterize the AuctionManager with who is winning what and whether or not there is a participation NFT. It is fairly straightforward - for each entry in the WinningConfig vec, it stands for a given winning place in the Auction. The 0th entry is the WinningConfig for the 1st place winner. A WinningConfig has many WinningConfigItems. For each WinningConfigItem in the 0th WinningConfig, it is a mapping to a Vault SafetyDepositBox that the 1st place winner gets items from. You can therefore configure quite arbitrary Auctions this way. - -This setup is actually quite redundant and will likely change in the future to a setup where a WinningConfigItem is the top level structure and it simply declares which winners will receive it, because if you wish for multiple winners to receive prints from the same Master Edition, the WinningConfigItem must right now be duplicated across each WinningConfig. - -The Participation Config is optional, but has enums describing how it will behave for winners and for non-winners, whether or not it has a price associated with it, and what safety deposit box contains its printing tokens. - -Notice that AuctionManagerSettings really doesn't contain settings about the auction. It really only breaks down how to divvy up the Vault. This is the separation of concerns in action - the Auction is parameterized with auction settings, while the AuctionManager understands how to divvy up rewards to winners and is parameterized that way. The Auction does not understand how to divvy up rewards, and the Metaplex contract does not understand how to do Auctions, only how to read winners off of it. - -### AuctionManagerState - -I consciously made the decision to keep AuctionManagerSettings identical to what you send up when you initialize AuctionManager. However, other things related to WinningConfigs, WinningConfigItems, etc change as the AuctionManager moves through its motions. These changes are recorded in AuctionManagerState, a kind of mirror object that is instantiated during the `init_auction_manager` action. - -Specifically, for each WinningConfigItem, we need to record at the time of creation whether the primary sale had happened for later royalties measurement (because this could be changed during auction) and we need to record whether or not this particular WinningConfigItem has been claimed by the winner yet. We do similar things for Participation prize in it's own config. - -### BidRedemptionTicket - -This is created once per bid and keeps track of whether a given bidder has redeemed their main bid and their participation NFT. This is how the Metaplex contract guarantees a given bidder gets something in exchange for their BidderMetadata PDA in the Auction contract. - -BidRedemptionTickets always have PDAs of `['metaplex', auction_id, bidder_metadata_key]` where the `auction_id` is the address of the Auction and the `bidder_metadata_key` is the address of the BidderMetadata PDA that the Auction contract produced. - -### PayoutTicket - -For each creator, for each metadata(WinningConfigItem), for each winning place(WinningConfig) in an Auction, a PayoutTicket is created to record the sliver of income generated for that creator. There is also one made for the Auctioneer for every such case. And yes, it really is that specific. This means that a given creator may have quite a few PayoutTickets for a single AuctionManager, but each one represents a slightly different royalty payout. - -For instance, 1st place may have three items with 3 unique metadata won while 2nd place may have 4 metadata from 4 items, every item with a single unique creator. The split of funds in the 1st place is going to be 3 ways, while in 2nd place would be 4 ways. Even if 1st and 2nd place bids are the same, we want two records to reflect the royalties paid from 1st and 2nd place, because they would be different numbers in this case, and we want to preserve history. - -PayoutTickets always have PDAs of `['metaplex', auction_manager_id, winning_config_index, winning_config_item_index, creator_index, safety_deposit_key, destination_owner]` where `auction_manager_id` is the address of the AuctionManager account, `winning_config_index` is the 0-based index of the WinningConfig in the AuctionManager settings you paid out in this ticket, `winning_config_item_index` is the 0-based index of the WinningConfigItem in that WinningConfig, `creator_index` is the 0-based creator index in that Metadata's creator array that you paid out for that WinningConfigItem (or 'auctioneer' if paying the auctioneer for this item), `safety_deposit_key` is the address to the safety deposit box for this item, and `destination_owner` is the owner of the destination account where the monies are being sent. Yeah, I know, painful. - -### Store - -Every person who forks the repository to make their own storefront should have a unique store struct that is seeded by their own administrative wallet. These are created and updated by the idempotent `set_store` endpoint. Each store can choose to use it's own token, token-metadata, token-vault and auction programs if it so chooses, though right now we've got a hard check that the token program is actually the global spl-token program. The store also can be either public or private, which determines whether or not AuctionManagers can sell items that have all non-whitelisted creators on them or not. We take a "bouncer-knows-your-friend-and-lets-you-in" approach to selling items in whitelist-only stores - if an item has at least one *verified* Whitelisted Creator, then it can be sold. - -Store PDAs are always a PDA seed of `['metaplex', metaplex_program_id, admin_wallet]` where `metaplex_program_id` is the address of the Metaplex contract and `admin_wallet` is the wallet that is administering this store. - -### WhitelistedCreator - -A cousin of the simple Creator struct from the Metadata program, this is a foreign key connector between a creator address and a store. It denotes whether or not this creator is currently active in the store and if they are, allows items from them to be sold in it. - -WhitelistedCreator PDAs are always a PDA seed of `['metaplex', metaplex_program_id, store_key, creator_key]` where `metaplex_program_id` is the address of the Metaplex contract, `store_key` is the address of the storefront, and `creator_key` is obviously the address of the creator's wallet you are whitelisting. - -### SafetyDepositValidationTicket - -This PDA solely exists to prevent validating a safety deposit box twice, which could present security vulnerabilities. It is created for each safety deposit box when it is presented for validation. - -SafetyDepositValidationTickets are always PDAs with seed of `['metaplex', metaplex_program_id, auction_manager_id, safety_deposit_key]`where `metaplex_program_id` is the address of the Metaplex contract, `auction_manager_id` is the address of the AuctionManager, and `safety_deposit_key` is the address of the SafetyDepositBox being validated. - -### OriginalAuthorityLookup - -These are created during FullRightsTransfers. When a FullRightsTransfer is happening, the Metadata `updateAuthority` is shifted from the Auctioneer to the AuctionManager so that it can grant it in turn to the winner, and this record is created to keep track of who the original `updateAuthority` was to return it later if the item is not sold. That functionality (returns) is not implemented as of this writing but will be in the near future. - -OriginalAuthorityLookups always have PDAs with seed of `['metaplex', auction_id, metadata_key]` where `auction_id` is the address of the Auction and `metadata_key` is the address of the actual Metadata struct. - -### PrizeTrackingTicket - -Created on a distinct WinningConfigItem basis (ie by WinningConfigType AND mint) across all WinningConfigs, one PrizeTrackingTicket is created to keep track of how many expected redemptions there will be across all winners for a given MasterEdition, and what the supply was when the first person hit redeem, to keep track of the relative edition offsets each person should get relative to winner #1, #2, etc. This is used for redeeming PrintingV2 bids, to ensure winner #1 gets edition #1, and so on. - -### Concepts - -### Types of Token Sales - -There are five major types of token sales supported by the Metaplex protocol. Four are covered in the WinningConfigType enum, but this is a bit limiting as it is really only considering sales to *winners*, and leaves out the all-important Participation NFT which is a different kind of sale we will consider separately. - -**TokenOnlyTransfer:** Probably the easiest to understand, this is a straight up spl_token_transfer command wrapped in a bunch of Metaplex magic. At the end of the day, the auctioneer still owns the Metadata struct and any other associated PDAs, but someone else now has the physical token in their wallets. These tokens will still show up and work just fine in Phantom and other supported wallet clients because those clients can still look up the Metadata. This is the difference between owning the Metadata and owning the token. For a token that is an Edition, the difference is nominal, as an Edition has zero printing rights and is immutable. However, for a token that is a MasterEdition, the difference is *substantial*, as the owner of the Metadata can rename it, change its symbol, it's URI, and creators array. - -Note that owning the token itself is the *only* requirement for using the `update_primary_sale_happened_via_token` endpoint on the token metadata program *and* for using the `mint_new_edition_from_master_edition_via_token`. - -**FullRightsTransfer:** This is a TokenOnlyTransfer, except in addition, the `updateAuthority` on the Metadata struct is set to the new owner as well, so they now have all the rights and privileges associated with the original owner, including the right to mint printing tokens. They can even change the name and URI of your token, so be careful! - -**PrintingV1:** This token type represents a deprecated logic flow that will be removed in future editions and can only be accessed if using a MasterEditionV1 type of NFT. In this case, the safety deposit box in question does not contain the actual token, but a token from the token's Master Edition's `printing_mint`. This printing token gives the bearer the authorization to label any mint they have that has a supply of one and decimals zero as a child Edition of that Master Edition one time. This is how Metaplex used to do a Printing sale. It doesn't grant the winning bidder a Limited Edition NFT. It grants them a printing token, they make their own mint/token account combo, and take the printing token to the token metadata contract and label it themselves. - -**PrintingV2:** The Auction holds the Master Edition in the safety deposit box and uses it via the special `mint_new_edition_from_master_edition_via_vault_proxy` call on Token Metadata to mint editions for auction winners. Once all bids have been redeemed, the auction releases the Master Edition from this escrow via the `withdraw_master_edition` call on Metaplex. This flow makes use of the PrizeTrackingTicket to keep track of the starting supply when the first redemption happens so that as each bidder comes in to redeem, everybody gets the correct offset for their edition relative to the #1 winner. - -**Participation NFTs:** Treated just like a PrintingV2, except these are first-come-first-serve as far as edition-numbering goes. This endpoint will also collect payment if the participation config has a fixed price setting or is using the "use last bid" setting to charge the user based on their last bid. Note that charging users for participation NFTs only can happen if they lose. Since the user previously cancelled their bid if they lost, they will net no change or net the difference between their last bid and the fixed price. - -### Royalties - -Metadata come locked and stocked with arrays of creators, each with their own `share` and all guaranteed to sum to 100. The Metadata itself has a `seller_fee_basis_points` field that represents the share creators get out of the proceeds in any secondary sale and a `primary_sale_happened` boolean that distinguishes to the world whether or not this particular Metadata has experienced it's first sale or not. With all of this, Metaplex is able to do complete Royalty calculations after an Auction is over. It was mentioned above that on initialization, the Metaplex contract snapshots for each Metadata being sold the `primary_sale_happened` just in case the boolean is flipped during the auction so that royalties are calculated as-of initiation - this is important to note. - -At the end of the auction, anybody (permissionless) can cycle through each winning bid in the contract and ask the Metaplex contract to use its authority to call the Auction contract and pump the winning bid monies into the `accept_payment` escrow account via `claim_bid`. Once all winning bids have been settled into here, royalties are eligible to be paid out. We'll cover payouts of fixed price Participation NFTs separately. - -Now, anybody (permissionless) can cycle through each creator PLUS the auctioneer on each item in each winning bid and call `empty_payment_account` with an Associated Token Account that is owned by that creator or auctioneer and that action will calculate, using the creator's share or auctioneer's share of that item's metadata, and the fractional percentage of that item of the overall winning basket, to payout the creator or auctioneer from the escrow. - -Our front end implementation immediately calls the `update_primary_sale_happened` endpoint on token metadata for any token once redeemed for users so that if they re-sell, the `primary_sale_happened` boolean is taken into account in the `empty_payment_account` logic and only the basis points given in `seller_fee_basis_points` goes to the creators instead of the whole pie. The remaining part of the pie goes to the auctioneer doing the reselling. - -We don't do weighted items in winning baskets right now - if a winning basket has 3 unique metadata in it right now, it is split three ways, even if one of the metadata is disbursing 3 tokens while the other is disbursing 2. This may come in a future version. Once this cycle is complete, the escrow account is usually empty. - -Things get a little complex when participation NFTs come into play. When a participation NFT has a fixed price, it is only paid in the case of non-winners. What they first do is cancel their bid, getting a refund, and then they redeem their participation bid with the `redeem_participation_bid` endpoint. This charges them the fixed price and dumps those funds into the `accept_payment` account. At intervals, someone must come and turn the crank to dump the proceeds to the creators of the Participation NFT from the latest redeemers of that NFT because they will only receive proceeds as people come and redeem and pay for them. - -Note because our front end implementation chooses to use SOL instead of a generic SPL token, we use a Wrapped SOL ATA account for creators. They are then forced to use a drop down menu to liquidate and close the Wrapped SOL ATA account when they next login, absorbing the Wrapped SOL back into their normal SOL wallets. If you choose not to use SOL in your implementation, you will not have this difficulty. - -### Validation - -Just because you provide a vault to an AuctionManager and an AuctionManagerSettings declaring this vault is filled with wonderful prizes *does not* believe that Metaplex will believe you. For every safety deposit box indexed in a WinningConfigItem, there must be a call to `validate_safety_deposit_box` after initiation where the safety deposit box is provided for inspection to the Metaplex contract so that it can verify that there are enough tokens, and of the right type, to pay off all winners in the auction. - -Given how irritating this process is, we may in the future merge token-vault with metaplex, or simply copy over the parts of it that are relevant, leaving token-vault out for those interested in experimenting with fractionalization. - -### Unwon Items - -Any Token Only Transfer item, or MasterEditionV1/MasterEditionV2 stored for a Full Rights Transfer unwon in an Auction can be returned to the Auction Manager by calling the `redeem_unused_winning_config_items_as_auctioneer` end point. It acts as a proxy, calling the `redeem_bid` or `redeem_full_rights_transfer_bid` depending on how it is parameterized, and passing in a winning_index that overrides the actual winning_index that would be detected for the bidder_info key being passed in (which is the auctioneer's in this case.) In this way the auctioneer acts not as a winning bidder but as a generic "non-bidder" who empties each prize that has no bidder using the same redemption flow. For MasterEditionV2s stored for PrintingV2 or Participation prizes, these can be withdrawn using `withdraw_edition`. diff --git a/DISCLAIMER.md b/DISCLAIMER.md deleted file mode 100644 index ee9f9220beb..00000000000 --- a/DISCLAIMER.md +++ /dev/null @@ -1,5 +0,0 @@ -# Disclaimer - -All claims, content, designs, algorithms, estimates, roadmaps, specifications, and performance measurements described in this project are done with the Metaplex Foundation’s ("MF") best efforts. It is up to the reader to check and validate their accuracy and truthfulness. Furthermore nothing in this project constitutes a solicitation for investment. -Any content produced by MF or developer resources that MF provides, are for educational and inspiration purposes only. MF does not encourage, induce or sanction the deployment, integration or use of any such applications in violation of applicable laws or regulations and hereby prohibits any such deployment, integration or use. This includes use of any such applications by the reader (a) in violation of export control or sanctions laws of the United States or any other applicable jurisdiction, (b) if the reader is located in or ordinarily resident in a country or territory subject to comprehensive sanctions administered by the U.S. Office of Foreign Assets Control (OFAC), or (c) if the reader is or is working on behalf of a Specially Designated National (SDN) or a person subject to similar blocking or denied party prohibitions. -The reader should be aware that U.S. export control and sanctions laws prohibit U.S. persons (and other persons that are subject to such laws) from transacting with persons in certain countries and territories or that are on the SDN list. It is possible that such sanctioned persons may nevertheless bypass prohibitions, obtain the code comprising the Metaplex protocol (or other project code or applications) and deploy, integrate, or otherwise use it. Accordingly, there is a risk to individuals that other persons using the Metaplex protocol may be sanctioned persons and that transactions with such persons would be a violation of U.S. export controls and sanctions law. This risk applies to individuals, organizations, and other ecosystem participants that deploy, integrate, or use the Metaplex protocol code directly (e.g., as a node operator) or indirectly. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4678c0e1daf..00000000000 --- a/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# Stage 1: Compile and Build the app - -# Node veersion -FROM node:14.17.3-alpine as build - -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -RUN apk add --no-cache libc6-compat git - -# Set the working directory -WORKDIR /app - -# Add the source code to app -COPY ./js /app - -# Install all the dependencies -RUN yarn install --frozen-lockfile -RUN yarn bootstrap - -# HERE ADD YOUR STORE WALLET ADDRESS -ENV REACT_APP_STORE_OWNER_ADDRESS_ADDRESS="" - -# Generate the build of the application -RUN yarn build - -# Stage 2: Serve app with nginx server - -# Production image, copy all the files and run next -FROM node:14.17.3-alpine AS runner -WORKDIR /app - -ENV NODE_ENV production - -RUN addgroup -g 1001 -S nodejs -RUN adduser -S nextjs -u 1001 - -# Copy the build output to replace the default nginx contents. -COPY --from=build /app/packages/web/next.config.js ./ -COPY --from=build /app/packages/web/public ./public -COPY --from=build --chown=nextjs:nodejs /app/packages/web/.next ./.next -COPY --from=build /app/node_modules ./node_modules -COPY --from=build /app/packages/web/package.json ./package.json - -USER nextjs - -EXPOSE 3000 - -CMD ["yarn", "start:prod"] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index b223be5019a..00000000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - limitations under the License. diff --git a/README.md b/README.md index e14383cf08f..07accfb4a08 100644 --- a/README.md +++ b/README.md @@ -1,127 +1,98 @@ -

- - Metaplex - -

+# Metaplex Foundation Project Directory +This repository is a directory of the projects that the Metaplex Foundation works on. -Metaplex is a protocol built on top of Solana that allows: +To learn more, visit our documentation at https://docs.metaplex.com. -- **Creating/Minting** non-fungible tokens; -- **Starting** a variety of auctions for primary/secondary sales; -- and **Visualizing** NFTs in a standard way across wallets and applications. - -Metaplex is comprised of two core components: an on-chain program, and a self-hosted front-end web3 application. - -## In Depth Developer's Guide - -If you want to deep dive on the Architecture, you can do so here: - -https://www.notion.so/Metaplex-Developer-Guide-afefbc19841744c28587ab948a08cfac - -## Installing - -Clone the repo, and run `yarn start` to deploy. +## Rust Programs +- **The Metaplex Program Library** - [GitHub](https://github.com/metaplex-foundation/metaplex-program-library) -```bash -$ git clone https://github.com/metaplex-foundation/metaplex.git -$ cd metaplex -$ cd js -$ yarn install -$ yarn bootstrap -$ yarn start -``` + A collection of all the Solana programs that the Metaplex Foundation actively maintains. Each program is published to https://crates.io. -## Rust Programs -The Rust programs will soon be added to this repo with JavaScript -bindings that allow interactivity. +## SDKs +These high level SDKs make it a breeze to interact with our programs. +- **JavaScript SDK** - [GitHub](https://github.com/metaplex-foundation/js) / [NPM](https://www.npmjs.com/package/@metaplex-foundation/js) + + Our JS SDK is a high level SDK for interacting with our programs and was built on top of our autogenerated libraries. It currently still in active development. -## Community -We have a few channels for contact: +- **iOS SDK** - [GitHub](https://github.com/metaplex-foundation/metaplex-ios) -- [Discord](https://discord.gg/metaplex) -- [@metaplex](https://twitter.com/metaplex) on Twitter -- [GitHub Issues](https://github.com/metaplex-foundation/metaplex/issues) + Our new iOS SDK is built from scratch in Swift to provide a smooth experience for interacting with NFTs. It uses a similar interface to our JS SDK. -# Protocol -## Non-fungible tokens +- **Android SDK** - [GitHub](https://github.com/metaplex-foundation/metaplex-android) -Metaplex's non-fungible-token standard is a part of the Solana Program Library (SPL), and can be characterized as a unique token with a fixed supply of 1 and 0 decimals. We extended the basic definition of an NFT on Solana to include additional metadata such as URI as defined in ERC-721 on Ethereum. + Our Android SDK was implemented from scratch in native Kotlin and is being developed in parallel with our iOS SDK. Like the iOS SDK, it also features a similar interface to our JS SDK. -Below are the types of NFTs that can be created using the Metaplex protocol. -### **Master Edition** +## Autogenerated Libraries +The following libraries were autogenerated by [Solita](#Solita). A link to each Rust crate on Crates.io is also provided for convenience. +- **MPL Token Metadata** - [GitHub](https://github.com/metaplex-foundation/metaplex-program-library/tree/master/token-metadata/js) / [NPM](https://www.npmjs.com/package/@metaplex-foundation/mpl-token-metadata) / [Crates.io](https://crates.io/crates/mpl-token-metadata) -A master edition token, when minted, represents both a non-fungible token on Solana and metadata that allows creators to control the provenance of prints created from the master edition. + The MPL Token Metadata program allows SPL tokens to add metadata to it and is one of the most important programs when dealing with NFTs on the Solana blockchain. -Rights to create prints are tokenized itself, and the owner of the master edition can distribute tokens that allow users to create prints from master editions. Additionally, the creator can set the max supply of the master edition just like a regular mint on Solana, with the main difference being that each print is a numbered edition created from it. -A notable and desirable effect of master editions is that as prints are sold, the artwork will still remain visible in the artist's wallet as a master edition, while the prints appear in the purchaser's wallets. +- **MPL Auction House** - [GitHub](https://github.com/metaplex-foundation/metaplex-program-library/tree/master/auction-house/js) / [NPM](https://www.npmjs.com/package/@metaplex-foundation/mpl-auction-house) / [Crates.io](https://crates.io/crates/mpl-auction-house) -### **Print** + The MPL Auction House program is a protocol for marketplaces to implement a decentralized sales contract. It additionally allows for escrowless sales where the NFT doesn't leave the seller's wallet until the sale is complete. -A **print** represents a copy of an NFT, and is created from a Master Edition. Each print has an edition number associated with it. -Usually, prints are created as a part of an auction that has happened on Metaplex, but they could also be created by the creator manually. +- **MPL Candy Machine** - [GitHub](https://github.com/metaplex-foundation/metaplex-program-library/tree/master/candy-machine/js) / [NPM](https://www.npmjs.com/package/@metaplex-foundation/mpl-candy-machine) / [Crates.io](https://crates.io/crates/mpl-candy-machine) -For limited auctions, each print number is awarded based on the bid placement. + The MPL Candy Machine program enables creators to easily and safely launch NFT collections without having to worry about the rent overhead from minting the NFTs themselves. -Prints can be created during [Open Edition](#open-edition) or [Limited Edition](#limited-edition) auction. -### Normal NFT -A normal NFT (like a Master Edition) when minted represents a non-fungible token on Solana and metadata, but lacks rights to print. +## Tools +- **Sugar, the Candy Machine CLI** - [GitHub](https://github.com/metaplex-foundation/sugar) -An example of a normal NFT would be an artwork that is a one-of-a-kind that, once sold, is no longer within the artist's own wallet, but is in the purchaser's wallet. + Sugar is our new Candy Machine CLI, built in rust. It is incredibly fast and easy to use. -## Types of Auctions -Metaplex currently supports four types of auctions that are all derived from English auctions. +- **Shank** - [GitHub](https://github.com/metaplex-foundation/shank) -Basic parameters include: + Shank is a tool that makes IDLs from native Solana programs. -- Auction start time -- Auction end time -- Reservation price +
-Additionally, Metaplex includes a novel concept of the participation NFT. Each bidding participant can be rewarded a unique NFT for participating in the auction. +- **Solita** - [GitHub](https://github.com/metaplex-foundation/solita) -The creator of an auction also has the ability to configure a minimal price that should be charged for redemption, with the option to set it as "free". + Solita (**SOL**ana **I**dl **T**o **A**pi) converts IDLs generated by *Shank* into JavaScript SDKs. -### Single Item -This type of auction can be used to sell normal NFTs and re-sell Prints, as well as the sale of Master Edition themselves (and the associated printing rights) if the artist so wishes. While this last behavior is not exposed in the current UI, it does exist in the protocol. +- **Amman** - [GitHub](https://github.com/metaplex-foundation/amman) -### Open Edition + Amman, and the [Amman Explorer](https://github.com/metaplex-foundation/amman-explorer) are a set of testing tools that make it easy to test Solana programs locally and see the changed deserialized states in real time on the explorer. -An open edition auction requires the offering of a Master Edition NFT that specifically has no set supply. The auction will only create Prints of this item for bidders: each bidder is guaranteed to get a print, as there are no true "winners" of this auction type. -An open edition auction can either have a set fixed price (equivalent to a Buy Now sale), can be set to the bid price (Pay what you want), or can be free (Make any bid to get it for free). +## UIs +- **Candy Machine UI** - [GitHub](https://github.com/metaplex-foundation/candy-machine-ui) -### Limited Edition + A reference minting UI for Candy Machine projects. -For a limited edition auction, a Master Edition NFT (of limited or unlimited supply) may be provided to the auction with a number of copies as the set amount of winning places. -For each prize place, a Print will be minted in order of prize place, and awarded to the winning bidder of that place. +- **Gumdrop** - [GitHub](https://github.com/metaplex-foundation/gumdrop) -For example, the first place winner will win Print #1; the second place winner Print #2; and so on. + The Gumdrop UI and CLI for managing inexpensive SPL token and NFT airdrops. -It is required for limited supply NFTs that there is at least as much supply remaining as there are desired winners in the auction. -### Tiered Auction +- **Token Entangler UI** - [GitHub](https://github.com/metaplex-foundation/token-entangler-ui) -A tiered auction can contain a mix of the other three auction types as winning placements. For instance, the first place winner could win a Print of Limited Edition NFT A, while the second-place winner could win Normal NFT, and so on. Additionally, all participants who did not win any place could get a Participation NFT Print from a Master Edition (if the Master Edition had no supply limit). + The Token Entangler UI that aims to help de-rug projects. -## Royalties -Metaplex can seamlessly create on-chain artist splits that remove the awkwardness out of collaboration. +## Deprecated +The following repositories are no longer maintained by the Metaplex Foundation. +- **Storefront** - [GitHub](https://github.com/metaplex-foundation/deprecated-storefront) -Tag each collaborator, set custom percentages, and you’re off to the races. Each NFT can also be minted with configurable royalty payments that are then sent automatically back to the original creators whenever an artwork is resold on a Metaplex marketplace in the future. + The deprecated Metaplex Storefront frontend for self-hosted NFT marketplaces. -## Storefronts -Metaplex's off-chain component allows creators to launch a custom storefront, similar to Shopify or WordPress. This open-source project provides a graphical interface to the on-chain Metaplex program, for creators, buyers, and curators of NFTs. The design and layout of storefronts can be customized to suit the needs of the entity creating it, either as a permanent storefront or an auction hub for a specific auction or collection. +- **Deprecated JavaScript CLIs** - [GitHub](https://github.com/metaplex-foundation/deprecated-clis) -All identification on the Storefront is based on wallet addresses. Creators and store admins sign through their wallets, and users place bids from connected wallets. Custom storefronts allow creators to create unique experiences per auction. Additionally, the Metaplex Foundation is working on multiple partnerships that will enable building immersive storefronts using VR/AR. + A collection of JS CLIs that are no longer maintained by the Metaplex Foundation. + +- **The Program Graveyard** - [GitHub](https://github.com/metaplex-foundation/the-graveyard) + + The Rust programs that are we no longer maintain. diff --git a/docs/create-store.md b/docs/create-store.md deleted file mode 100644 index 8b6c7cef952..00000000000 --- a/docs/create-store.md +++ /dev/null @@ -1,68 +0,0 @@ -# Create Store - -To create a storefront powered by Metaplex, you need to create a store on the Metaplex platform. This guide will outline -steps you need to take to create your store. After creating your store, this guide will show you how to manage your -store information, such as who to whitelist as creators. - -## Prerequisites -* You should have an understanding of `React` concepts such as hooks. Please refer to the React documentation - [here](https://reactjs.org/docs/getting-started.html). -* To create your store, you will need to have a wallet that contains token to perform your transactions. -* Knowing what the different `packages` are and what are their purposes would help but isn't required - -## Getting Started - -### Setting Up the Store ID - -To create a store, you must first derive the store ID given your public address. The Metaplex devs have already created -an environment variable for you to utilize - `REACT_APP_STORE_OWNER_ADDRESS_ADDRESS` - which you should set to be your -wallet public address. To do this, you can create a `.env` file in `packages/web`, and set -`REACT_APP_STORE_OWNER_ADDRESS_ADDRESS` to be your wallet public address in there. - -``` -REACT_APP_STORE_OWNER_ADDRESS_ADDRESS=YOUR_PUBLIC_WALLET_ADDRESS -``` - -### Create Your Store - -After creating your store ID, you may now create your store. The Metaplex platform has many helper methods to help you -to create your store. To create your store, you can use the `saveAdmin` method (`packages/web/src/actions/saveAdmin`) -The easiest way to do this would be to either create a script or render a button locally to click to call this method. -Please look at the function parameters of `saveAdmin` to see what parameters you would like to pass in: - -```js -saveAdmin(connection, wallet, false, []) -``` - -If you opted to create a button or something to click to call this method, here are some small snippets: - -```js -// These are hooks you should insert at the top of the component your rendering your button in -const { wallet } = useWallet(); -const connection = useConnection(); -``` - -```js -// The button to render somewhere for you to click - -``` - -You will be required to confirm your transactions if you decided to put a button or something to click. After clicking -the button, make sure you don't browse anywhere else or close the website. - -### Adding Your Information - -After creating your store, you must also insert your wallet public key and information in `userNames.json` at -`packages/web/src/config/userNames.json`. Make sure you follow the same format as the other objects in this file. - -### Accessing the Admin Panel - -After creating your store, you can now access `YOUR_URL/#/admin`. This is where you can edit your store and add -whitelisted creators. Add yourself if you need to or make it a public store, so anyone can create NFTs in your store. -Remember to click save after making your changes. diff --git a/docs/deploy.md b/docs/deploy.md deleted file mode 100644 index 2dd35906541..00000000000 --- a/docs/deploy.md +++ /dev/null @@ -1,63 +0,0 @@ -# Deploy - -## GitHub Pages - -Primarily you need to specify your repo in `js/packages/web/package.json` file - -Pay attention to these two lines: - -```json -"deploy:gh": "yarn export && gh-pages -d ../../build/web --repo https://github.com/metaplex-foundation/metaplex -t true", -"deploy": "cross-env ASSET_PREFIX=/metaplex/ yarn build && yarn deploy:gh", -``` - -There are 2 things to change: - -- specify your repo URL instead of `https://github.com/metaplex-foundation/metaplex` (for example, `https://github.com/my-name/my-metaplex`) -- set `ASSET_PREFIX` to repo name (for example, `ASSET_PREFIX=/my-metaplex/`) - -After that, the lines will look like this: - -```json -"deploy:gh": "yarn export && gh-pages -d ../../build/web --repo https://github.com/my-name/my-metaplex -t true", -"deploy": "cross-env ASSET_PREFIX=/my-metaplex/ yarn build && yarn deploy:gh", -``` - -And after that, you can publish the Metaplex app to GitHub Pages by the following commands: - -```bash -cd js/packages/web -yarn deploy -``` - -Note that if you have 2fa enabled, you'll need to use a personal access token as your password: - -https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token - -### GitHub Pages with a custom domain - -If you have a custom domain linked to the GitHub Pages in your repo, then the instructions are the same as above, but your need to remove `ASSET_PREFIX` from the deploy script: - -```json -"deploy:gh": "yarn export && gh-pages -d ../../build/web --repo https://github.com/my-name/my-metaplex -t true" -"deploy": "yarn build && yarn deploy:gh", -``` - -The publishing commands are the same: - -```bash -cd js/packages/web -yarn deploy -``` - -## Vercel - -To publish the Metaplex app to Vercel, you first need to visit [https://vercel.com/](https://vercel.com/) and create a new project linked to your github repo. - -After that, configure this project with the following settings: - -- Framework: `Next.js` -- Root directory: `js` -- Output directory: `packages/web/.next` - -One last thing: specify `REACT_APP_STORE_OWNER_ADDRESS_ADDRESS` in the Environment Variables section diff --git a/js/README.md b/js/README.md deleted file mode 100644 index 24cf24067c9..00000000000 --- a/js/README.md +++ /dev/null @@ -1,31 +0,0 @@ -## Setup - -Be sure to be running Node v12.16.2 and yarn version 1.22.10. - -`yarn bootstrap` - -Then run: - -`yarn start` - -You may have to rebuild your package more than one time to secure a -running environment. - -## Known Issues - -### Can't find CSS files in common - -Common currently uses a less library to compile down less files into css in both the src directory for the TS server -in vscode to pick up and in the dist folder for importers like lending and proposal projects to pick up. If you do not see these files appear when running the `npm start lending` or other commands, and you see missing CSS errors, -you likely did not install the packages for common correctly. Try running: - -`lerna exec npm install --scope @oyster/common` to specifically install packages for common. - -Then, test that css transpiling is working: - -`lerna exec npm watch-css-src --scope @oyster/common` and verify css files appear next to their less counterparts in src. - -## ⚠️ Warning - -Any content produced by Solana, or developer resources that Solana provides, are for educational and inspiration purposes only. Solana does not encourage, induce or sanction the deployment of any such applications in violation of applicable laws or regulations. - diff --git a/js/assets/wallets/ledger.svg b/js/assets/wallets/ledger.svg deleted file mode 100644 index feb68409409..00000000000 --- a/js/assets/wallets/ledger.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/js/assets/wallets/mathwallet.svg b/js/assets/wallets/mathwallet.svg deleted file mode 100644 index 588ace9cc4f..00000000000 --- a/js/assets/wallets/mathwallet.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - Logo_Icon_White - Created with Sketch. - - - - - - - - - \ No newline at end of file diff --git a/js/assets/wallets/metamask.svg b/js/assets/wallets/metamask.svg deleted file mode 100644 index a04dcfeeac5..00000000000 --- a/js/assets/wallets/metamask.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/js/assets/wallets/solflare.svg b/js/assets/wallets/solflare.svg deleted file mode 100644 index 73352b8e078..00000000000 --- a/js/assets/wallets/solflare.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/js/assets/wallets/sollet.svg b/js/assets/wallets/sollet.svg deleted file mode 100644 index 3440890257b..00000000000 --- a/js/assets/wallets/sollet.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - background - - - - Layer 1 - - - - - \ No newline at end of file diff --git a/js/assets/wallets/solong.png b/js/assets/wallets/solong.png deleted file mode 100644 index 4ad300895bb..00000000000 Binary files a/js/assets/wallets/solong.png and /dev/null differ diff --git a/js/assets/wallets/torus.svg b/js/assets/wallets/torus.svg deleted file mode 100644 index 1c0178e1a80..00000000000 --- a/js/assets/wallets/torus.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - -Created by potrace 1.16, written by Peter Selinger 2001-2019 - - - - - - diff --git a/js/assets/wallets/wormhole.svg b/js/assets/wallets/wormhole.svg deleted file mode 100644 index aecd9492ea5..00000000000 --- a/js/assets/wallets/wormhole.svg +++ /dev/null @@ -1,3857 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/js/deploy-web.bat b/js/deploy-web.bat deleted file mode 100644 index 03ea55291a6..00000000000 --- a/js/deploy-web.bat +++ /dev/null @@ -1,13 +0,0 @@ -ECHO "Starting to deploy 'web', bootstrapping..." -yarn bootstrap -ECHO "Preparing 'common'..." -CD packages\common -yarn prepare -yarn build-css -CD ..\web -ECHO "Prestarting 'web'..." -yarn prestart -ECHO "Building 'web'..." -# TODO: fix linting errors! -SET CI=false && yarn build -ECHO "#done" diff --git a/js/deploy-web.sh b/js/deploy-web.sh deleted file mode 100755 index 2ca32dab215..00000000000 --- a/js/deploy-web.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -echo "Starting to deploy 'web', bootstrapping..." -yarn bootstrap -echo "Preparing 'common'..." -cd packages/common || exit -yarn prepare -cd ../web || exit -echo "Prestarting 'web'..." -yarn prestart -echo "Building 'web'..." -# TODO: fix linting errors! -CI=false && yarn build -echo "#done" diff --git a/js/lerna.json b/js/lerna.json deleted file mode 100644 index ee6a86a820d..00000000000 --- a/js/lerna.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "lerna": "3.4.3", - "version": "independent", - "packages": ["packages/*"], - "npmClient": "yarn", - "useWorkspaces": true, - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org" - }, - "ignoreChanges": [ - "**/__tests__/**", - "**/*.md" - ], - "command": { - "publish": { - "conventionalCommits": true, - "allowBranch": ["master", "next"], - "message": "chore(release): Publish" - } - } -} diff --git a/js/package.json b/js/package.json deleted file mode 100644 index 216a2c7b45b..00000000000 --- a/js/package.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "private": true, - "workspaces": { - "packages": [ - "packages/*" - ] - }, - "keywords": [], - "license": "Apache-2.0", - "engines": { - "node": ">=6.0.0" - }, - "scripts": { - "bootstrap": "lerna link && lerna bootstrap", - "build": "lerna run build", - "start": "cross-env CI=true lerna run start --scope @oyster/common --stream --parallel --scope web", - "lint": "eslint 'packages/*/{src,test}/**/*.ts' && prettier -c 'packages/*/{src,test}/**/*.ts'", - "lint:fix": "eslint --fix 'packages/*/{src,test}/**/*.ts' && prettier --write 'packages/*/{src,test}/**/*.ts'", - "deploy": "run-s deploy:docs build deploy:apps && gh-pages -d docs", - "deploy:docs": "lerna run docs", - "deploy:apps": "lerna run deploy:app", - "test": "lerna run test --concurrency 1 --stream" - }, - "lint-staged": { - "packages/*/{src,test}/**/*.ts": [ - "prettier --write" - ] - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, - "prettier": { - "arrowParens": "avoid", - "semi": true, - "singleQuote": true, - "trailingComma": "all" - }, - "commitlint": { - "extends": [ - "@commitlint/config-conventional" - ] - }, - "dependencies": { - "cross-env": "^7.0.3", - "next": "^11.0.1", - "react": "17.0.2", - "react-dom": "17.0.2" - }, - "devDependencies": { - "@commitlint/cli": "^8.2.0", - "@commitlint/config-conventional": "^8.2.0", - "@types/animejs": "^3.1.3", - "@types/jest": "^24.0.0", - "@types/react": "^16.9.50", - "@types/react-dom": "^16.9.8", - "@typescript-eslint/eslint-plugin": "^4.6.0", - "@typescript-eslint/parser": "^4.6.0", - "eslint": "^6.6.0", - "eslint-config-prettier": "^6.15.0", - "gh-pages": "^3.1.0", - "husky": "^4.3.0", - "jest": "24.9.0", - "jest-config": "24.9.0", - "lerna": "3.22.1", - "lint-staged": "^10.5.0", - "npm-run-all": "^4.1.5", - "prettier": "^2.1.2", - "rimraf": "^3.0.2", - "ts-jest": "^24.0.0", - "ts-node": "^9.0.0", - "typescript": "^4.1.3" - }, - "resolutions": { - "react": "17.0.2", - "react-dom": "17.0.2" - } -} diff --git a/js/packages/common/package.json b/js/packages/common/package.json deleted file mode 100644 index abc84a13add..00000000000 --- a/js/packages/common/package.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "name": "@oyster/common", - "version": "0.0.1", - "description": "Oyster common utilities", - "main": "dist/lib/index.js", - "types": "dist/lib/index.d.ts", - "exports": { - ".": "./dist/lib", - "./dist/*": "./dist/*.js", - "./styles.css": "./dist/lib/styles.css" - }, - "license": "Apache-2.0", - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=10" - }, - "scripts": { - "build": "run-s build-ts build-css", - "build-ts": "tsc", - "build-css": "less-watch-compiler src/ dist/lib/ --run-once", - "start": "npm-run-all --parallel watch watch-css watch-css-src", - "watch-css": "less-watch-compiler src/ dist/lib/", - "watch-css-src": "less-watch-compiler src/ src/", - "watch": "tsc --watch", - "test": "jest test", - "clean": "rm -rf dist", - "prepare": "run-s clean build" - }, - "dependencies": { - "@project-serum/serum": "^0.13.52", - "@project-serum/sol-wallet-adapter": "^0.2.5", - "@solana/spl-token": "0.1.6", - "@solana/spl-token-registry": "0.2.202", - "@solana/wallet-base": "0.0.1", - "@solana/wallet-ledger": "0.0.1", - "@solana/web3.js": "^1.21.0", - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.5.0", - "@testing-library/user-event": "^7.2.1", - "@types/chart.js": "^2.9.29", - "@types/echarts": "^4.9.0", - "@types/react-router-dom": "^5.1.6", - "@welldone-software/why-did-you-render": "^6.0.5", - "antd": "^4.6.6", - "bignumber.js": "^9.0.1", - "bn.js": "^5.1.3", - "borsh": "^0.4.0", - "bs58": "^4.0.1", - "buffer-layout": "^1.2.0", - "crypto-hash": "^1.3.0", - "eventemitter3": "^4.0.7", - "identicon.js": "^2.3.3", - "jazzicon": "^1.5.0", - "lodash": "^4.17.20", - "react": "17.0.2", - "react-dom": "17.0.2", - "typescript": "^4.1.3" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/bs58": "^4.0.1", - "@types/identicon.js": "^2.3.0", - "@types/jest": "^24.9.1", - "@types/node": "^12.12.62", - "arweave-deploy": "^1.9.1", - "gh-pages": "^3.1.0", - "less": "^4.1.1", - "less-watch-compiler": "v1.14.6", - "prettier": "^2.1.2" - }, - "files": [ - "dist" - ], - "peerDependencies": { - "react": "*", - "react-dom": "*" - }, - "resolutions": { - "react": "17.0.2", - "react-dom": "17.0.2" - } -} diff --git a/js/packages/common/src/actions/account.ts b/js/packages/common/src/actions/account.ts deleted file mode 100644 index 4ce7069f98f..00000000000 --- a/js/packages/common/src/actions/account.ts +++ /dev/null @@ -1,334 +0,0 @@ -import { AccountLayout, MintLayout, Token } from '@solana/spl-token'; -import { - Keypair, - PublicKey, - SystemProgram, - SYSVAR_RENT_PUBKEY, - TransactionInstruction, -} from '@solana/web3.js'; -import { - SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, - TOKEN_PROGRAM_ID, - WRAPPED_SOL_MINT, -} from '../utils/ids'; -import { programIds } from '../utils/programIds'; -import { TokenAccount } from '../models/account'; -import { cache, TokenAccountParser } from '../contexts/accounts'; - -export function ensureSplAccount( - instructions: TransactionInstruction[], - cleanupInstructions: TransactionInstruction[], - toCheck: TokenAccount, - payer: PublicKey, - amount: number, - signers: Keypair[], -) { - if (!toCheck.info.isNative) { - return toCheck.pubkey; - } - - const account = createUninitializedAccount( - instructions, - payer, - amount, - signers, - ); - - instructions.push( - Token.createInitAccountInstruction( - TOKEN_PROGRAM_ID, - WRAPPED_SOL_MINT, - account, - payer, - ), - ); - - cleanupInstructions.push( - Token.createCloseAccountInstruction( - TOKEN_PROGRAM_ID, - account, - payer, - payer, - [], - ), - ); - - return account; -} - -export const DEFAULT_TEMP_MEM_SPACE = 65548; - -export function createTempMemoryAccount( - instructions: TransactionInstruction[], - payer: PublicKey, - signers: Keypair[], - owner: PublicKey, - space = DEFAULT_TEMP_MEM_SPACE, -) { - const account = Keypair.generate(); - instructions.push( - SystemProgram.createAccount({ - fromPubkey: payer, - newAccountPubkey: account.publicKey, - // 0 will evict/close account since it cannot pay rent - lamports: 0, - space: space, - programId: owner, - }), - ); - - signers.push(account); - - return account.publicKey; -} - -export function createUninitializedMint( - instructions: TransactionInstruction[], - payer: PublicKey, - amount: number, - signers: Keypair[], -) { - const account = Keypair.generate(); - instructions.push( - SystemProgram.createAccount({ - fromPubkey: payer, - newAccountPubkey: account.publicKey, - lamports: amount, - space: MintLayout.span, - programId: TOKEN_PROGRAM_ID, - }), - ); - - signers.push(account); - - return account.publicKey; -} - -export function createUninitializedAccount( - instructions: TransactionInstruction[], - payer: PublicKey, - amount: number, - signers: Keypair[], -) { - const account = Keypair.generate(); - instructions.push( - SystemProgram.createAccount({ - fromPubkey: payer, - newAccountPubkey: account.publicKey, - lamports: amount, - space: AccountLayout.span, - programId: TOKEN_PROGRAM_ID, - }), - ); - - signers.push(account); - - return account.publicKey; -} - -export function createAssociatedTokenAccountInstruction( - instructions: TransactionInstruction[], - associatedTokenAddress: PublicKey, - payer: PublicKey, - walletAddress: PublicKey, - splTokenMintAddress: PublicKey, -) { - const keys = [ - { - pubkey: payer, - isSigner: true, - isWritable: true, - }, - { - pubkey: associatedTokenAddress, - isSigner: false, - isWritable: true, - }, - { - pubkey: walletAddress, - isSigner: false, - isWritable: false, - }, - { - pubkey: splTokenMintAddress, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: TOKEN_PROGRAM_ID, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, - data: Buffer.from([]), - }), - ); -} - -export function createMint( - instructions: TransactionInstruction[], - payer: PublicKey, - mintRentExempt: number, - decimals: number, - owner: PublicKey, - freezeAuthority: PublicKey, - signers: Keypair[], -) { - const account = createUninitializedMint( - instructions, - payer, - mintRentExempt, - signers, - ); - - instructions.push( - Token.createInitMintInstruction( - TOKEN_PROGRAM_ID, - account, - decimals, - owner, - freezeAuthority, - ), - ); - - return account; -} - -export function createTokenAccount( - instructions: TransactionInstruction[], - payer: PublicKey, - accountRentExempt: number, - mint: PublicKey, - owner: PublicKey, - signers: Keypair[], -) { - const account = createUninitializedAccount( - instructions, - payer, - accountRentExempt, - signers, - ); - - instructions.push( - Token.createInitAccountInstruction(TOKEN_PROGRAM_ID, mint, account, owner), - ); - - return account; -} - -export function ensureWrappedAccount( - instructions: TransactionInstruction[], - cleanupInstructions: TransactionInstruction[], - toCheck: TokenAccount | undefined, - payer: PublicKey, - amount: number, - signers: Keypair[], -) { - if (toCheck && !toCheck.info.isNative) { - return toCheck.pubkey; - } - - const TOKEN_PROGRAM_ID = programIds().token; - const account = Keypair.generate(); - instructions.push( - SystemProgram.createAccount({ - fromPubkey: payer, - newAccountPubkey: account.publicKey, - lamports: amount, - space: AccountLayout.span, - programId: TOKEN_PROGRAM_ID, - }), - ); - - instructions.push( - Token.createInitAccountInstruction( - TOKEN_PROGRAM_ID, - WRAPPED_SOL_MINT, - account.publicKey, - payer, - ), - ); - - cleanupInstructions.push( - Token.createCloseAccountInstruction( - TOKEN_PROGRAM_ID, - account.publicKey, - payer, - payer, - [], - ), - ); - - signers.push(account); - - return account.publicKey.toBase58(); -} - -// TODO: check if one of to accounts needs to be native sol ... if yes unwrap it ... -export function findOrCreateAccountByMint( - payer: PublicKey, - owner: PublicKey, - instructions: TransactionInstruction[], - cleanupInstructions: TransactionInstruction[], - accountRentExempt: number, - mint: PublicKey, // use to identify same type - signers: Keypair[], - excluded?: Set, -): PublicKey { - const accountToFind = mint.toBase58(); - const ownerKey = owner.toBase58(); - const account = cache - .byParser(TokenAccountParser) - .map(id => cache.get(id)) - .find( - acc => - acc !== undefined && - acc.info.mint.toBase58() === accountToFind && - acc.info.owner.toBase58() === ownerKey && - (excluded === undefined || !excluded.has(acc.pubkey)), - ); - const isWrappedSol = accountToFind === WRAPPED_SOL_MINT.toBase58(); - - let toAccount: PublicKey; - if (account && !isWrappedSol) { - toAccount = new PublicKey(account.pubkey); - } else { - // creating depositor pool account - toAccount = createTokenAccount( - instructions, - payer, - accountRentExempt, - mint, - owner, - signers, - ); - - if (isWrappedSol) { - cleanupInstructions.push( - Token.createCloseAccountInstruction( - TOKEN_PROGRAM_ID, - toAccount, - payer, - payer, - [], - ), - ); - } - } - - return toAccount; -} diff --git a/js/packages/common/src/actions/auction.ts b/js/packages/common/src/actions/auction.ts deleted file mode 100644 index c01a12c8b84..00000000000 --- a/js/packages/common/src/actions/auction.ts +++ /dev/null @@ -1,1066 +0,0 @@ -import { - AccountInfo, - SystemProgram, - SYSVAR_CLOCK_PUBKEY, - SYSVAR_RENT_PUBKEY, - TransactionInstruction, -} from '@solana/web3.js'; -import { programIds } from '../utils/programIds'; -import { deserializeUnchecked, serialize } from 'borsh'; -import BN from 'bn.js'; -import { AccountParser } from '../contexts'; -import moment from 'moment'; -import { findProgramAddress, StringPublicKey, toPublicKey } from '../utils'; -export const AUCTION_PREFIX = 'auction'; -export const METADATA = 'metadata'; -export const EXTENDED = 'extended'; -export const MAX_AUCTION_DATA_EXTENDED_SIZE = 8 + 9 + 2 + 200; - -export enum AuctionState { - Created = 0, - Started, - Ended, -} - -export enum BidStateType { - EnglishAuction = 0, - OpenEdition = 1, -} - -export class Bid { - key: StringPublicKey; - amount: BN; - constructor(args: { key: StringPublicKey; amount: BN }) { - this.key = args.key; - this.amount = args.amount; - } -} - -export class BidState { - type: BidStateType; - bids: Bid[]; - max: BN; - - public getWinnerAt(winnerIndex: number): StringPublicKey | null { - const convertedIndex = this.bids.length - winnerIndex - 1; - - if (convertedIndex >= 0 && convertedIndex < this.bids.length) { - return this.bids[convertedIndex].key; - } else { - return null; - } - } - - public getAmountAt(winnerIndex: number): BN | null { - const convertedIndex = this.bids.length - winnerIndex - 1; - - if (convertedIndex >= 0 && convertedIndex < this.bids.length) { - return this.bids[convertedIndex].amount; - } else { - return null; - } - } - - public getWinnerIndex(bidder: StringPublicKey): number | null { - if (!this.bids) return null; - - const index = this.bids.findIndex(b => b.key === bidder); - // auction stores data in reverse order - if (index !== -1) { - const zeroBased = this.bids.length - index - 1; - return zeroBased < this.max.toNumber() ? zeroBased : null; - } else return null; - } - - constructor(args: { type: BidStateType; bids: Bid[]; max: BN }) { - this.type = args.type; - this.bids = args.bids; - this.max = args.max; - } -} - -export const AuctionParser: AccountParser = ( - pubkey: StringPublicKey, - account: AccountInfo, -) => ({ - pubkey, - account, - info: decodeAuction(account.data), -}); - -export const decodeAuction = (buffer: Buffer) => { - return deserializeUnchecked( - AUCTION_SCHEMA, - AuctionData, - buffer, - ) as AuctionData; -}; - -export const BidderPotParser: AccountParser = ( - pubkey: StringPublicKey, - account: AccountInfo, -) => ({ - pubkey, - account, - info: decodeBidderPot(account.data), -}); - -export const decodeBidderPot = (buffer: Buffer) => { - return deserializeUnchecked(AUCTION_SCHEMA, BidderPot, buffer) as BidderPot; -}; - -export const AuctionDataExtendedParser: AccountParser = ( - pubkey: StringPublicKey, - account: AccountInfo, -) => ({ - pubkey, - account, - info: decodeAuctionDataExtended(account.data), -}); - -export const decodeAuctionDataExtended = (buffer: Buffer) => { - return deserializeUnchecked( - AUCTION_SCHEMA, - AuctionDataExtended, - buffer, - ) as AuctionDataExtended; -}; - -export const BidderMetadataParser: AccountParser = ( - pubkey: StringPublicKey, - account: AccountInfo, -) => ({ - pubkey, - account, - info: decodeBidderMetadata(account.data), -}); - -export const decodeBidderMetadata = (buffer: Buffer) => { - return deserializeUnchecked( - AUCTION_SCHEMA, - BidderMetadata, - buffer, - ) as BidderMetadata; -}; - -export const BASE_AUCTION_DATA_SIZE = - 32 + 32 + 32 + 9 + 9 + 9 + 9 + 1 + 32 + 1 + 8 + 8; - -export enum PriceFloorType { - None = 0, - Minimum = 1, - BlindedPrice = 2, -} -export class PriceFloor { - type: PriceFloorType; - // It's an array of 32 u8s, when minimum, only first 8 are used (a u64), when blinded price, the entire - // thing is a hash and not actually a public key, and none is all zeroes - hash: Uint8Array; - - minPrice?: BN; - - constructor(args: { - type: PriceFloorType; - hash?: Uint8Array; - minPrice?: BN; - }) { - this.type = args.type; - this.hash = args.hash || new Uint8Array(32); - if (this.type === PriceFloorType.Minimum) { - if (args.minPrice) { - this.hash.set(args.minPrice.toArrayLike(Buffer, 'le', 8), 0); - } else { - this.minPrice = new BN( - (args.hash || new Uint8Array(0)).slice(0, 8), - 'le', - ); - } - } - } -} - -export class AuctionDataExtended { - /// Total uncancelled bids - totalUncancelledBids: BN; - tickSize: BN | null; - gapTickSizePercentage: number | null; - - constructor(args: { - totalUncancelledBids: BN; - tickSize: BN | null; - gapTickSizePercentage: number | null; - }) { - this.totalUncancelledBids = args.totalUncancelledBids; - this.tickSize = args.tickSize; - this.gapTickSizePercentage = args.gapTickSizePercentage; - } -} - -export interface CountdownState { - days: number; - hours: number; - minutes: number; - seconds: number; -} - -export class AuctionData { - /// Pubkey of the authority with permission to modify this auction. - authority: StringPublicKey; - /// Token mint for the SPL token being used to bid - tokenMint: StringPublicKey; - /// The time the last bid was placed, used to keep track of auction timing. - lastBid: BN | null; - /// Slot time the auction was officially ended by. - endedAt: BN | null; - /// End time is the cut-off point that the auction is forced to end by. - endAuctionAt: BN | null; - /// Gap time is the amount of time in slots after the previous bid at which the auction ends. - auctionGap: BN | null; - /// Minimum price for any bid to meet. - priceFloor: PriceFloor; - /// The state the auction is in, whether it has started or ended. - state: AuctionState; - /// Auction Bids, each user may have one bid open at a time. - bidState: BidState; - /// Used for precalculation on the front end, not a backend key - bidRedemptionKey?: StringPublicKey; - - public timeToEnd(): CountdownState { - const now = moment().unix(); - const ended = { days: 0, hours: 0, minutes: 0, seconds: 0 }; - let endAt = this.endedAt?.toNumber() || 0; - - if (this.auctionGap && this.lastBid) { - endAt = Math.max( - endAt, - this.auctionGap.toNumber() + this.lastBid.toNumber(), - ); - } - - let delta = endAt - now; - - if (!endAt || delta <= 0) return ended; - - const days = Math.floor(delta / 86400); - delta -= days * 86400; - - const hours = Math.floor(delta / 3600) % 24; - delta -= hours * 3600; - - const minutes = Math.floor(delta / 60) % 60; - delta -= minutes * 60; - - const seconds = Math.floor(delta % 60); - - return { days, hours, minutes, seconds }; - } - - public ended() { - const now = moment().unix(); - if (!this.endedAt) return false; - - if (this.endedAt.toNumber() > now) return false; - - if (this.endedAt.toNumber() < now) { - if (this.auctionGap && this.lastBid) { - const newEnding = this.auctionGap.toNumber() + this.lastBid.toNumber(); - return newEnding < now; - } else return true; - } - } - - constructor(args: { - authority: StringPublicKey; - tokenMint: StringPublicKey; - lastBid: BN | null; - endedAt: BN | null; - endAuctionAt: BN | null; - auctionGap: BN | null; - priceFloor: PriceFloor; - state: AuctionState; - bidState: BidState; - totalUncancelledBids: BN; - }) { - this.authority = args.authority; - this.tokenMint = args.tokenMint; - this.lastBid = args.lastBid; - this.endedAt = args.endedAt; - this.endAuctionAt = args.endAuctionAt; - this.auctionGap = args.auctionGap; - this.priceFloor = args.priceFloor; - this.state = args.state; - this.bidState = args.bidState; - } -} - -export const BIDDER_METADATA_LEN = 32 + 32 + 8 + 8 + 1; -export class BidderMetadata { - // Relationship with the bidder who's metadata this covers. - bidderPubkey: StringPublicKey; - // Relationship with the auction this bid was placed on. - auctionPubkey: StringPublicKey; - // Amount that the user bid. - lastBid: BN; - // Tracks the last time this user bid. - lastBidTimestamp: BN; - // Whether the last bid the user made was cancelled. This should also be enough to know if the - // user is a winner, as if cancelled it implies previous bids were also cancelled. - cancelled: boolean; - constructor(args: { - bidderPubkey: StringPublicKey; - auctionPubkey: StringPublicKey; - lastBid: BN; - lastBidTimestamp: BN; - cancelled: boolean; - }) { - this.bidderPubkey = args.bidderPubkey; - this.auctionPubkey = args.auctionPubkey; - this.lastBid = args.lastBid; - this.lastBidTimestamp = args.lastBidTimestamp; - this.cancelled = args.cancelled; - } -} - -export const BIDDER_POT_LEN = 32 + 32 + 32 + 1; -export class BidderPot { - /// Points at actual pot that is a token account - bidderPot: StringPublicKey; - bidderAct: StringPublicKey; - auctionAct: StringPublicKey; - emptied: boolean; - constructor(args: { - bidderPot: StringPublicKey; - bidderAct: StringPublicKey; - auctionAct: StringPublicKey; - emptied: boolean; - }) { - this.bidderPot = args.bidderPot; - this.bidderAct = args.bidderAct; - this.auctionAct = args.auctionAct; - this.emptied = args.emptied; - } -} - -export enum WinnerLimitType { - Unlimited = 0, - Capped = 1, -} - -export class WinnerLimit { - type: WinnerLimitType; - usize: BN; - constructor(args: { type: WinnerLimitType; usize: BN }) { - this.type = args.type; - this.usize = args.usize; - } -} - -export interface IPartialCreateAuctionArgs { - /// How many winners are allowed for this auction. See AuctionData. - winners: WinnerLimit; - /// End time is the cut-off point that the auction is forced to end by. See AuctionData. - endAuctionAt: BN | null; - /// Gap time is how much time after the previous bid where the auction ends. See AuctionData. - auctionGap: BN | null; - /// Token mint for the SPL token used for bidding. - tokenMint: StringPublicKey; - - priceFloor: PriceFloor; - - tickSize: BN | null; - - gapTickSizePercentage: number | null; -} - -export class CreateAuctionArgs implements IPartialCreateAuctionArgs { - instruction: number = 1; - /// How many winners are allowed for this auction. See AuctionData. - winners: WinnerLimit; - /// End time is the cut-off point that the auction is forced to end by. See AuctionData. - endAuctionAt: BN | null; - /// Gap time is how much time after the previous bid where the auction ends. See AuctionData. - auctionGap: BN | null; - /// Token mint for the SPL token used for bidding. - tokenMint: StringPublicKey; - /// Authority - authority: StringPublicKey; - /// The resource being auctioned. See AuctionData. - resource: StringPublicKey; - - priceFloor: PriceFloor; - - tickSize: BN | null; - - gapTickSizePercentage: number | null; - - constructor(args: { - winners: WinnerLimit; - endAuctionAt: BN | null; - auctionGap: BN | null; - tokenMint: StringPublicKey; - authority: StringPublicKey; - resource: StringPublicKey; - priceFloor: PriceFloor; - tickSize: BN | null; - gapTickSizePercentage: number | null; - }) { - this.winners = args.winners; - this.endAuctionAt = args.endAuctionAt; - this.auctionGap = args.auctionGap; - this.tokenMint = args.tokenMint; - this.authority = args.authority; - this.resource = args.resource; - this.priceFloor = args.priceFloor; - this.tickSize = args.tickSize; - this.gapTickSizePercentage = args.gapTickSizePercentage; - } -} - -class StartAuctionArgs { - instruction: number = 4; - resource: StringPublicKey; - - constructor(args: { resource: StringPublicKey }) { - this.resource = args.resource; - } -} - -class PlaceBidArgs { - instruction: number = 6; - resource: StringPublicKey; - amount: BN; - - constructor(args: { resource: StringPublicKey; amount: BN }) { - this.resource = args.resource; - this.amount = args.amount; - } -} - -class CancelBidArgs { - instruction: number = 0; - resource: StringPublicKey; - - constructor(args: { resource: StringPublicKey }) { - this.resource = args.resource; - } -} - -class SetAuthorityArgs { - instruction: number = 5; -} - -export const AUCTION_SCHEMA = new Map([ - [ - CreateAuctionArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['winners', WinnerLimit], - ['endAuctionAt', { kind: 'option', type: 'u64' }], - ['auctionGap', { kind: 'option', type: 'u64' }], - ['tokenMint', 'pubkeyAsString'], - ['authority', 'pubkeyAsString'], - ['resource', 'pubkeyAsString'], - ['priceFloor', PriceFloor], - ['tickSize', { kind: 'option', type: 'u64' }], - ['gapTickSizePercentage', { kind: 'option', type: 'u8' }], - ], - }, - ], - [ - WinnerLimit, - { - kind: 'struct', - fields: [ - ['type', 'u8'], - ['usize', 'u64'], - ], - }, - ], - [ - StartAuctionArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['resource', 'pubkeyAsString'], - ], - }, - ], - [ - PlaceBidArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['amount', 'u64'], - ['resource', 'pubkeyAsString'], - ], - }, - ], - [ - CancelBidArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['resource', 'pubkeyAsString'], - ], - }, - ], - - [ - SetAuthorityArgs, - { - kind: 'struct', - fields: [['instruction', 'u8']], - }, - ], - [ - AuctionData, - { - kind: 'struct', - fields: [ - ['authority', 'pubkeyAsString'], - ['tokenMint', 'pubkeyAsString'], - ['lastBid', { kind: 'option', type: 'u64' }], - ['endedAt', { kind: 'option', type: 'u64' }], - ['endAuctionAt', { kind: 'option', type: 'u64' }], - ['auctionGap', { kind: 'option', type: 'u64' }], - ['priceFloor', PriceFloor], - ['state', 'u8'], - ['bidState', BidState], - ], - }, - ], - [ - AuctionDataExtended, - { - kind: 'struct', - fields: [ - ['totalUncancelledBids', 'u64'], - ['tickSize', { kind: 'option', type: 'u64' }], - ['gapTickSizePercentage', { kind: 'option', type: 'u8' }], - ], - }, - ], - [ - PriceFloor, - { - kind: 'struct', - fields: [ - ['type', 'u8'], - ['hash', [32]], - ], - }, - ], - [ - BidState, - { - kind: 'struct', - fields: [ - ['type', 'u8'], - ['bids', [Bid]], - ['max', 'u64'], - ], - }, - ], - [ - Bid, - { - kind: 'struct', - fields: [ - ['key', 'pubkeyAsString'], - ['amount', 'u64'], - ], - }, - ], - [ - BidderMetadata, - { - kind: 'struct', - fields: [ - ['bidderPubkey', 'pubkeyAsString'], - ['auctionPubkey', 'pubkeyAsString'], - ['lastBid', 'u64'], - ['lastBidTimestamp', 'u64'], - ['cancelled', 'u8'], - ], - }, - ], - [ - BidderPot, - { - kind: 'struct', - fields: [ - ['bidderPot', 'pubkeyAsString'], - ['bidderAct', 'pubkeyAsString'], - ['auctionAct', 'pubkeyAsString'], - ['emptied', 'u8'], - ], - }, - ], -]); - -export const decodeAuctionData = (buffer: Buffer) => { - return deserializeUnchecked( - AUCTION_SCHEMA, - AuctionData, - buffer, - ) as AuctionData; -}; - -export async function createAuction( - settings: CreateAuctionArgs, - creator: StringPublicKey, - instructions: TransactionInstruction[], -) { - const auctionProgramId = programIds().auction; - - const data = Buffer.from(serialize(AUCTION_SCHEMA, settings)); - - const auctionKey: StringPublicKey = ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(settings.resource).toBuffer(), - ], - toPublicKey(auctionProgramId), - ) - )[0]; - - const keys = [ - { - pubkey: toPublicKey(creator), - isSigner: true, - isWritable: true, - }, - { - pubkey: toPublicKey(auctionKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey( - await getAuctionExtended({ - auctionProgramId, - resource: settings.resource, - }), - ), - isSigner: false, - isWritable: true, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(auctionProgramId), - data: data, - }), - ); -} - -export async function startAuction( - resource: StringPublicKey, - creator: StringPublicKey, - instructions: TransactionInstruction[], -) { - const auctionProgramId = programIds().auction; - - const data = Buffer.from( - serialize( - AUCTION_SCHEMA, - new StartAuctionArgs({ - resource, - }), - ), - ); - - const auctionKey: StringPublicKey = ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(resource).toBuffer(), - ], - toPublicKey(auctionProgramId), - ) - )[0]; - - const keys = [ - { - pubkey: toPublicKey(creator), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(auctionKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: SYSVAR_CLOCK_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(auctionProgramId), - data: data, - }), - ); -} - -export async function setAuctionAuthority( - auction: StringPublicKey, - currentAuthority: StringPublicKey, - newAuthority: StringPublicKey, - instructions: TransactionInstruction[], -) { - const auctionProgramId = programIds().auction; - - const data = Buffer.from(serialize(AUCTION_SCHEMA, new SetAuthorityArgs())); - - const keys = [ - { - pubkey: toPublicKey(auction), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(currentAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(newAuthority), - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(auctionProgramId), - data: data, - }), - ); -} - -export async function placeBid( - bidderPubkey: StringPublicKey, - bidderTokenPubkey: StringPublicKey, - bidderPotTokenPubkey: StringPublicKey, - tokenMintPubkey: StringPublicKey, - transferAuthority: StringPublicKey, - payer: StringPublicKey, - resource: StringPublicKey, - amount: BN, - instructions: TransactionInstruction[], -) { - const auctionProgramId = programIds().auction; - - const data = Buffer.from( - serialize( - AUCTION_SCHEMA, - new PlaceBidArgs({ - resource, - amount, - }), - ), - ); - - const auctionKey: StringPublicKey = ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(resource).toBuffer(), - ], - toPublicKey(auctionProgramId), - ) - )[0]; - - const bidderPotKey = await getBidderPotKey({ - auctionProgramId, - auctionKey, - bidderPubkey, - }); - - const bidderMetaKey: StringPublicKey = ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(auctionKey).toBuffer(), - toPublicKey(bidderPubkey).toBuffer(), - Buffer.from('metadata'), - ], - toPublicKey(auctionProgramId), - ) - )[0]; - - const keys = [ - { - pubkey: toPublicKey(bidderPubkey), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(bidderTokenPubkey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(bidderPotKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(bidderPotTokenPubkey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(bidderMetaKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(auctionKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey( - await getAuctionExtended({ auctionProgramId, resource }), - ), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(tokenMintPubkey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(transferAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: SYSVAR_CLOCK_PUBKEY, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(auctionProgramId), - data: data, - }), - ); - - return { - amount, - }; -} - -export async function getBidderPotKey({ - auctionProgramId, - auctionKey, - bidderPubkey, -}: { - auctionProgramId: StringPublicKey; - auctionKey: StringPublicKey; - bidderPubkey: StringPublicKey; -}): Promise { - return ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(auctionKey).toBuffer(), - toPublicKey(bidderPubkey).toBuffer(), - ], - toPublicKey(auctionProgramId), - ) - )[0]; -} - -export async function getAuctionExtended({ - auctionProgramId, - resource, -}: { - auctionProgramId: StringPublicKey; - resource: StringPublicKey; -}): Promise { - return ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(resource).toBuffer(), - Buffer.from(EXTENDED), - ], - toPublicKey(auctionProgramId), - ) - )[0]; -} - -export async function cancelBid( - bidderPubkey: StringPublicKey, - bidderTokenPubkey: StringPublicKey, - bidderPotTokenPubkey: StringPublicKey, - tokenMintPubkey: StringPublicKey, - resource: StringPublicKey, - instructions: TransactionInstruction[], -) { - const auctionProgramId = programIds().auction; - - const data = Buffer.from( - serialize( - AUCTION_SCHEMA, - new CancelBidArgs({ - resource, - }), - ), - ); - - const auctionKey = ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(resource).toBuffer(), - ], - toPublicKey(auctionProgramId), - ) - )[0]; - - const bidderPotKey = await getBidderPotKey({ - auctionProgramId, - auctionKey, - bidderPubkey, - }); - - const bidderMetaKey = ( - await findProgramAddress( - [ - Buffer.from(AUCTION_PREFIX), - toPublicKey(auctionProgramId).toBuffer(), - toPublicKey(auctionKey).toBuffer(), - toPublicKey(bidderPubkey).toBuffer(), - Buffer.from('metadata'), - ], - toPublicKey(auctionProgramId), - ) - )[0]; - - const keys = [ - { - pubkey: toPublicKey(bidderPubkey), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(bidderTokenPubkey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(bidderPotKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(bidderPotTokenPubkey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(bidderMetaKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(auctionKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey( - await getAuctionExtended({ auctionProgramId, resource }), - ), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(tokenMintPubkey), - isSigner: false, - isWritable: true, - }, - { - pubkey: SYSVAR_CLOCK_PUBKEY, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(auctionProgramId), - data: data, - }), - ); -} diff --git a/js/packages/common/src/actions/index.ts b/js/packages/common/src/actions/index.ts deleted file mode 100644 index f11ceca206b..00000000000 --- a/js/packages/common/src/actions/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './account'; -export * from './metadata'; -export * from './vault'; -export * from './auction'; diff --git a/js/packages/common/src/actions/metadata.ts b/js/packages/common/src/actions/metadata.ts deleted file mode 100644 index fad713c1694..00000000000 --- a/js/packages/common/src/actions/metadata.ts +++ /dev/null @@ -1,1212 +0,0 @@ -import { - SystemProgram, - SYSVAR_RENT_PUBKEY, - TransactionInstruction, -} from '@solana/web3.js'; -import { programIds } from '../utils/programIds'; -import { deserializeUnchecked, serialize } from 'borsh'; -import BN from 'bn.js'; -import { findProgramAddress, StringPublicKey, toPublicKey } from '../utils'; -export const METADATA_PREFIX = 'metadata'; -export const EDITION = 'edition'; -export const RESERVATION = 'reservation'; - -export const MAX_NAME_LENGTH = 32; - -export const MAX_SYMBOL_LENGTH = 10; - -export const MAX_URI_LENGTH = 200; - -export const MAX_CREATOR_LIMIT = 5; - -export const MAX_CREATOR_LEN = 32 + 1 + 1; -export const MAX_METADATA_LEN = - 1 + - 32 + - 32 + - MAX_NAME_LENGTH + - MAX_SYMBOL_LENGTH + - MAX_URI_LENGTH + - MAX_CREATOR_LIMIT * MAX_CREATOR_LEN + - 2 + - 1 + - 1 + - 198; - -export const MAX_EDITION_LEN = 1 + 32 + 8 + 200; - -export const EDITION_MARKER_BIT_SIZE = 248; - -export enum MetadataKey { - Uninitialized = 0, - MetadataV1 = 4, - EditionV1 = 1, - MasterEditionV1 = 2, - MasterEditionV2 = 6, - EditionMarker = 7, -} - -export enum MetadataCategory { - Audio = 'audio', - Video = 'video', - Image = 'image', - VR = 'vr', -} - -export type MetadataFile = { - uri: string; - type: string; -}; - -export type FileOrString = MetadataFile | string; - -export interface IMetadataExtension { - name: string; - symbol: string; - - creators: Creator[] | null; - description: string; - // preview image absolute URI - image: string; - animation_url?: string; - - // stores link to item on meta - external_url: string; - - seller_fee_basis_points: number; - - properties: { - files?: FileOrString[]; - category: MetadataCategory; - maxSupply?: number; - creators?: { - address: string; - shares: number; - }[]; - }; -} - -export class MasterEditionV1 { - key: MetadataKey; - supply: BN; - maxSupply?: BN; - /// Can be used to mint tokens that give one-time permission to mint a single limited edition. - printingMint: StringPublicKey; - /// If you don't know how many printing tokens you are going to need, but you do know - /// you are going to need some amount in the future, you can use a token from this mint. - /// Coming back to token metadata with one of these tokens allows you to mint (one time) - /// any number of printing tokens you want. This is used for instance by Auction Manager - /// with participation NFTs, where we dont know how many people will bid and need participation - /// printing tokens to redeem, so we give it ONE of these tokens to use after the auction is over, - /// because when the auction begins we just dont know how many printing tokens we will need, - /// but at the end we will. At the end it then burns this token with token-metadata to - /// get the printing tokens it needs to give to bidders. Each bidder then redeems a printing token - /// to get their limited editions. - oneTimePrintingAuthorizationMint: StringPublicKey; - - constructor(args: { - key: MetadataKey; - supply: BN; - maxSupply?: BN; - printingMint: StringPublicKey; - oneTimePrintingAuthorizationMint: StringPublicKey; - }) { - this.key = MetadataKey.MasterEditionV1; - this.supply = args.supply; - this.maxSupply = args.maxSupply; - this.printingMint = args.printingMint; - this.oneTimePrintingAuthorizationMint = - args.oneTimePrintingAuthorizationMint; - } -} - -export class MasterEditionV2 { - key: MetadataKey; - supply: BN; - maxSupply?: BN; - - constructor(args: { key: MetadataKey; supply: BN; maxSupply?: BN }) { - this.key = MetadataKey.MasterEditionV2; - this.supply = args.supply; - this.maxSupply = args.maxSupply; - } -} - -export class EditionMarker { - key: MetadataKey; - ledger: number[]; - - constructor(args: { key: MetadataKey; ledger: number[] }) { - this.key = MetadataKey.EditionMarker; - this.ledger = args.ledger; - } - - editionTaken(edition: number) { - const editionOffset = edition % EDITION_MARKER_BIT_SIZE; - const indexOffset = Math.floor(editionOffset / 8); - - if (indexOffset > 30) { - throw Error('bad index for edition'); - } - - const positionInBitsetFromRight = 7 - (editionOffset % 8); - - const mask = Math.pow(2, positionInBitsetFromRight); - - const appliedMask = this.ledger[indexOffset] & mask; - - return appliedMask != 0; - } -} - -export class Edition { - key: MetadataKey; - /// Points at MasterEdition struct - parent: StringPublicKey; - /// Starting at 0 for master record, this is incremented for each edition minted. - edition: BN; - - constructor(args: { - key: MetadataKey; - parent: StringPublicKey; - edition: BN; - }) { - this.key = MetadataKey.EditionV1; - this.parent = args.parent; - this.edition = args.edition; - } -} -export class Creator { - address: StringPublicKey; - verified: boolean; - share: number; - - constructor(args: { - address: StringPublicKey; - verified: boolean; - share: number; - }) { - this.address = args.address; - this.verified = args.verified; - this.share = args.share; - } -} - -export class Data { - name: string; - symbol: string; - uri: string; - sellerFeeBasisPoints: number; - creators: Creator[] | null; - constructor(args: { - name: string; - symbol: string; - uri: string; - sellerFeeBasisPoints: number; - creators: Creator[] | null; - }) { - this.name = args.name; - this.symbol = args.symbol; - this.uri = args.uri; - this.sellerFeeBasisPoints = args.sellerFeeBasisPoints; - this.creators = args.creators; - } -} - -export class Metadata { - key: MetadataKey; - updateAuthority: StringPublicKey; - mint: StringPublicKey; - data: Data; - primarySaleHappened: boolean; - isMutable: boolean; - editionNonce: number | null; - - // set lazy - masterEdition?: StringPublicKey; - edition?: StringPublicKey; - - constructor(args: { - updateAuthority: StringPublicKey; - mint: StringPublicKey; - data: Data; - primarySaleHappened: boolean; - isMutable: boolean; - editionNonce: number | null; - }) { - this.key = MetadataKey.MetadataV1; - this.updateAuthority = args.updateAuthority; - this.mint = args.mint; - this.data = args.data; - this.primarySaleHappened = args.primarySaleHappened; - this.isMutable = args.isMutable; - this.editionNonce = args.editionNonce; - } - - public async init() { - const edition = await getEdition(this.mint); - this.edition = edition; - this.masterEdition = edition; - } -} - -class CreateMetadataArgs { - instruction: number = 0; - data: Data; - isMutable: boolean; - - constructor(args: { data: Data; isMutable: boolean }) { - this.data = args.data; - this.isMutable = args.isMutable; - } -} -class UpdateMetadataArgs { - instruction: number = 1; - data: Data | null; - // Not used by this app, just required for instruction - updateAuthority: StringPublicKey | null; - primarySaleHappened: boolean | null; - constructor(args: { - data?: Data; - updateAuthority?: string; - primarySaleHappened: boolean | null; - }) { - this.data = args.data ? args.data : null; - this.updateAuthority = args.updateAuthority ? args.updateAuthority : null; - this.primarySaleHappened = args.primarySaleHappened; - } -} - -class CreateMasterEditionArgs { - instruction: number = 10; - maxSupply: BN | null; - constructor(args: { maxSupply: BN | null }) { - this.maxSupply = args.maxSupply; - } -} - -class MintPrintingTokensArgs { - instruction: number = 9; - supply: BN; - - constructor(args: { supply: BN }) { - this.supply = args.supply; - } -} - -export const METADATA_SCHEMA = new Map([ - [ - CreateMetadataArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['data', Data], - ['isMutable', 'u8'], // bool - ], - }, - ], - [ - UpdateMetadataArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['data', { kind: 'option', type: Data }], - ['updateAuthority', { kind: 'option', type: 'pubkeyAsString' }], - ['primarySaleHappened', { kind: 'option', type: 'u8' }], - ], - }, - ], - - [ - CreateMasterEditionArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['maxSupply', { kind: 'option', type: 'u64' }], - ], - }, - ], - [ - MintPrintingTokensArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['supply', 'u64'], - ], - }, - ], - [ - MasterEditionV1, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['supply', 'u64'], - ['maxSupply', { kind: 'option', type: 'u64' }], - ['printingMint', 'pubkeyAsString'], - ['oneTimePrintingAuthorizationMint', 'pubkeyAsString'], - ], - }, - ], - [ - MasterEditionV2, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['supply', 'u64'], - ['maxSupply', { kind: 'option', type: 'u64' }], - ], - }, - ], - [ - Edition, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['parent', 'pubkeyAsString'], - ['edition', 'u64'], - ], - }, - ], - [ - Data, - { - kind: 'struct', - fields: [ - ['name', 'string'], - ['symbol', 'string'], - ['uri', 'string'], - ['sellerFeeBasisPoints', 'u16'], - ['creators', { kind: 'option', type: [Creator] }], - ], - }, - ], - [ - Creator, - { - kind: 'struct', - fields: [ - ['address', 'pubkeyAsString'], - ['verified', 'u8'], - ['share', 'u8'], - ], - }, - ], - [ - Metadata, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['updateAuthority', 'pubkeyAsString'], - ['mint', 'pubkeyAsString'], - ['data', Data], - ['primarySaleHappened', 'u8'], // bool - ['isMutable', 'u8'], // bool - ], - }, - ], - [ - EditionMarker, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['ledger', [31]], - ], - }, - ], -]); - -const METADATA_REPLACE = new RegExp('\u0000', 'g'); - -export const decodeMetadata = (buffer: Buffer): Metadata => { - const metadata = deserializeUnchecked( - METADATA_SCHEMA, - Metadata, - buffer, - ) as Metadata; - metadata.data.name = metadata.data.name.replace(METADATA_REPLACE, ''); - metadata.data.uri = metadata.data.uri.replace(METADATA_REPLACE, ''); - metadata.data.symbol = metadata.data.symbol.replace(METADATA_REPLACE, ''); - return metadata; -}; - -export const decodeEditionMarker = (buffer: Buffer): EditionMarker => { - const editionMarker = deserializeUnchecked( - METADATA_SCHEMA, - EditionMarker, - buffer, - ) as EditionMarker; - return editionMarker; -}; - -export const decodeEdition = (buffer: Buffer) => { - return deserializeUnchecked(METADATA_SCHEMA, Edition, buffer) as Edition; -}; - -export const decodeMasterEdition = ( - buffer: Buffer, -): MasterEditionV1 | MasterEditionV2 => { - if (buffer[0] == MetadataKey.MasterEditionV1) { - return deserializeUnchecked( - METADATA_SCHEMA, - MasterEditionV1, - buffer, - ) as MasterEditionV1; - } else { - return deserializeUnchecked( - METADATA_SCHEMA, - MasterEditionV2, - buffer, - ) as MasterEditionV2; - } -}; - -export async function updateMetadata( - data: Data | undefined, - newUpdateAuthority: string | undefined, - primarySaleHappened: boolean | null | undefined, - mintKey: StringPublicKey, - updateAuthority: StringPublicKey, - instructions: TransactionInstruction[], - metadataAccount?: StringPublicKey, -) { - const metadataProgramId = programIds().metadata; - - metadataAccount = - metadataAccount || - ( - await findProgramAddress( - [ - Buffer.from('metadata'), - toPublicKey(metadataProgramId).toBuffer(), - toPublicKey(mintKey).toBuffer(), - ], - toPublicKey(metadataProgramId), - ) - )[0]; - - const value = new UpdateMetadataArgs({ - data, - updateAuthority: !newUpdateAuthority ? undefined : newUpdateAuthority, - primarySaleHappened: - primarySaleHappened === null || primarySaleHappened === undefined - ? null - : primarySaleHappened, - }); - const txnData = Buffer.from(serialize(METADATA_SCHEMA, value)); - const keys = [ - { - pubkey: toPublicKey(metadataAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(updateAuthority), - isSigner: true, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data: txnData, - }), - ); - - return metadataAccount; -} - -export async function createMetadata( - data: Data, - updateAuthority: StringPublicKey, - mintKey: StringPublicKey, - mintAuthorityKey: StringPublicKey, - instructions: TransactionInstruction[], - payer: StringPublicKey, -) { - const metadataProgramId = programIds().metadata; - - const metadataAccount = ( - await findProgramAddress( - [ - Buffer.from('metadata'), - toPublicKey(metadataProgramId).toBuffer(), - toPublicKey(mintKey).toBuffer(), - ], - toPublicKey(metadataProgramId), - ) - )[0]; - console.log('Data', data); - const value = new CreateMetadataArgs({ data, isMutable: true }); - const txnData = Buffer.from(serialize(METADATA_SCHEMA, value)); - - const keys = [ - { - pubkey: toPublicKey(metadataAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(mintKey), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(mintAuthorityKey), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(updateAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data: txnData, - }), - ); - - return metadataAccount; -} - -export async function createMasterEdition( - maxSupply: BN | undefined, - mintKey: StringPublicKey, - updateAuthorityKey: StringPublicKey, - mintAuthorityKey: StringPublicKey, - payer: StringPublicKey, - instructions: TransactionInstruction[], -) { - const metadataProgramId = programIds().metadata; - - const metadataAccount = ( - await findProgramAddress( - [ - Buffer.from(METADATA_PREFIX), - toPublicKey(metadataProgramId).toBuffer(), - toPublicKey(mintKey).toBuffer(), - ], - toPublicKey(metadataProgramId), - ) - )[0]; - - const editionAccount = ( - await findProgramAddress( - [ - Buffer.from(METADATA_PREFIX), - toPublicKey(metadataProgramId).toBuffer(), - toPublicKey(mintKey).toBuffer(), - Buffer.from(EDITION), - ], - toPublicKey(metadataProgramId), - ) - )[0]; - - const value = new CreateMasterEditionArgs({ maxSupply: maxSupply || null }); - const data = Buffer.from(serialize(METADATA_SCHEMA, value)); - - const keys = [ - { - pubkey: toPublicKey(editionAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(mintKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(updateAuthorityKey), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(mintAuthorityKey), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(metadataAccount), - isSigner: false, - isWritable: false, - }, - - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function deprecatedMintNewEditionFromMasterEditionViaPrintingToken( - newMint: StringPublicKey, - tokenMint: StringPublicKey, - newMintAuthority: StringPublicKey, - printingMint: StringPublicKey, - authorizationTokenHoldingAccount: StringPublicKey, - burnAuthority: StringPublicKey, - updateAuthorityOfMaster: StringPublicKey, - reservationList: StringPublicKey | undefined, - instructions: TransactionInstruction[], - payer: StringPublicKey, -) { - const metadataProgramId = programIds().metadata; - - const newMetadataKey = await getMetadata(newMint); - const masterMetadataKey = await getMetadata(tokenMint); - const newEdition = await getEdition(newMint); - const masterEdition = await getEdition(tokenMint); - - const data = Buffer.from([3]); - - const keys = [ - { - pubkey: toPublicKey(newMetadataKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newEdition), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(masterEdition), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newMintAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(printingMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(authorizationTokenHoldingAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(burnAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(updateAuthorityOfMaster), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(masterMetadataKey), - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - - if (reservationList) { - keys.push({ - pubkey: toPublicKey(reservationList), - isSigner: false, - isWritable: true, - }); - } - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function mintNewEditionFromMasterEditionViaToken( - newMint: StringPublicKey, - tokenMint: StringPublicKey, - newMintAuthority: StringPublicKey, - newUpdateAuthority: StringPublicKey, - tokenOwner: StringPublicKey, - tokenAccount: StringPublicKey, - instructions: TransactionInstruction[], - payer: StringPublicKey, - edition: BN, -) { - const metadataProgramId = programIds().metadata; - - const newMetadataKey = await getMetadata(newMint); - const masterMetadataKey = await getMetadata(tokenMint); - const newEdition = await getEdition(newMint); - const masterEdition = await getEdition(tokenMint); - const editionMarkPda = await getEditionMarkPda(tokenMint, edition); - - const data = Buffer.from([11, ...edition.toArray('le', 8)]); - - const keys = [ - { - pubkey: toPublicKey(newMetadataKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newEdition), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(masterEdition), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(editionMarkPda), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newMintAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(tokenOwner), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(tokenAccount), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(newUpdateAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(masterMetadataKey), - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function updatePrimarySaleHappenedViaToken( - metadata: StringPublicKey, - owner: StringPublicKey, - tokenAccount: StringPublicKey, - instructions: TransactionInstruction[], -) { - const metadataProgramId = programIds().metadata; - - const data = Buffer.from([4]); - - const keys = [ - { - pubkey: toPublicKey(metadata), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(owner), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(tokenAccount), - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function deprecatedCreateReservationList( - metadata: StringPublicKey, - masterEdition: StringPublicKey, - resource: StringPublicKey, - updateAuthority: StringPublicKey, - payer: StringPublicKey, - instructions: TransactionInstruction[], -) { - const metadataProgramId = programIds().metadata; - - const reservationList = await deprecatedGetReservationList( - masterEdition, - resource, - ); - const data = Buffer.from([6]); - - const keys = [ - { - pubkey: toPublicKey(reservationList), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(updateAuthority), - isSigner: true, - isWritable: false, - }, - - { - pubkey: toPublicKey(masterEdition), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(resource), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(metadata), - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function signMetadata( - metadata: StringPublicKey, - creator: StringPublicKey, - instructions: TransactionInstruction[], -) { - const metadataProgramId = programIds().metadata; - - const data = Buffer.from([7]); - - const keys = [ - { - pubkey: toPublicKey(metadata), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(creator), - isSigner: true, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function deprecatedMintPrintingTokens( - destination: StringPublicKey, - printingMint: StringPublicKey, - updateAuthority: StringPublicKey, - metadata: StringPublicKey, - masterEdition: StringPublicKey, - supply: BN, - instructions: TransactionInstruction[], -) { - const PROGRAM_IDS = programIds(); - const metadataProgramId = PROGRAM_IDS.metadata; - - const value = new MintPrintingTokensArgs({ supply }); - const data = Buffer.from(serialize(METADATA_SCHEMA, value)); - - const keys = [ - { - pubkey: toPublicKey(destination), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(printingMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(updateAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(metadata), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(masterEdition), - isSigner: false, - isWritable: false, - }, - { - pubkey: PROGRAM_IDS.token, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function convertMasterEditionV1ToV2( - masterEdition: StringPublicKey, - oneTimeAuthMint: StringPublicKey, - printingMint: StringPublicKey, - instructions: TransactionInstruction[], -) { - const metadataProgramId = programIds().metadata; - - const data = Buffer.from([12]); - - const keys = [ - { - pubkey: toPublicKey(masterEdition), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(oneTimeAuthMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(printingMint), - isSigner: false, - isWritable: true, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(metadataProgramId), - data, - }), - ); -} - -export async function getEdition( - tokenMint: StringPublicKey, -): Promise { - const PROGRAM_IDS = programIds(); - - return ( - await findProgramAddress( - [ - Buffer.from(METADATA_PREFIX), - toPublicKey(PROGRAM_IDS.metadata).toBuffer(), - toPublicKey(tokenMint).toBuffer(), - Buffer.from(EDITION), - ], - toPublicKey(PROGRAM_IDS.metadata), - ) - )[0]; -} - -export async function getMetadata( - tokenMint: StringPublicKey, -): Promise { - const PROGRAM_IDS = programIds(); - - return ( - await findProgramAddress( - [ - Buffer.from(METADATA_PREFIX), - toPublicKey(PROGRAM_IDS.metadata).toBuffer(), - toPublicKey(tokenMint).toBuffer(), - ], - toPublicKey(PROGRAM_IDS.metadata), - ) - )[0]; -} - -export async function deprecatedGetReservationList( - masterEdition: StringPublicKey, - resource: StringPublicKey, -): Promise { - const PROGRAM_IDS = programIds(); - - return ( - await findProgramAddress( - [ - Buffer.from(METADATA_PREFIX), - toPublicKey(PROGRAM_IDS.metadata).toBuffer(), - toPublicKey(masterEdition).toBuffer(), - Buffer.from(RESERVATION), - toPublicKey(resource).toBuffer(), - ], - toPublicKey(PROGRAM_IDS.metadata), - ) - )[0]; -} - -export async function getEditionMarkPda( - mint: StringPublicKey, - edition: BN, -): Promise { - const PROGRAM_IDS = programIds(); - const editionNumber = Math.floor(edition.toNumber() / 248); - - return ( - await findProgramAddress( - [ - Buffer.from(METADATA_PREFIX), - toPublicKey(PROGRAM_IDS.metadata).toBuffer(), - toPublicKey(mint).toBuffer(), - Buffer.from(EDITION), - Buffer.from(editionNumber.toString()), - ], - toPublicKey(PROGRAM_IDS.metadata), - ) - )[0]; -} diff --git a/js/packages/common/src/actions/vault.ts b/js/packages/common/src/actions/vault.ts deleted file mode 100644 index 8e1a58abccf..00000000000 --- a/js/packages/common/src/actions/vault.ts +++ /dev/null @@ -1,769 +0,0 @@ -import { - SystemProgram, - SYSVAR_RENT_PUBKEY, - TransactionInstruction, -} from '@solana/web3.js'; -import { programIds } from '../utils/programIds'; -import { deserializeUnchecked, serialize } from 'borsh'; -import BN from 'bn.js'; -import { findProgramAddress, StringPublicKey, toPublicKey } from '../utils'; - -export const VAULT_PREFIX = 'vault'; -export enum VaultKey { - Uninitialized = 0, - VaultV1 = 3, - SafetyDepositBoxV1 = 1, - ExternalPriceAccountV1 = 2, -} - -export enum VaultState { - Inactive = 0, - Active = 1, - Combined = 2, - Deactivated = 3, -} - -export const MAX_VAULT_SIZE = - 1 + 32 + 32 + 32 + 32 + 1 + 32 + 1 + 32 + 1 + 1 + 8; - -export const MAX_EXTERNAL_ACCOUNT_SIZE = 1 + 8 + 32 + 1; -export class Vault { - key: VaultKey; - /// Store token program used - tokenProgram: StringPublicKey; - /// Mint that produces the fractional shares - fractionMint: StringPublicKey; - /// Authority who can make changes to the vault - authority: StringPublicKey; - /// treasury where fractional shares are held for redemption by authority - fractionTreasury: StringPublicKey; - /// treasury where monies are held for fractional share holders to redeem(burn) shares once buyout is made - redeemTreasury: StringPublicKey; - /// Can authority mint more shares from fraction_mint after activation - allowFurtherShareCreation: boolean; - - /// Must point at an ExternalPriceAccount, which gives permission and price for buyout. - pricingLookupAddress: StringPublicKey; - /// In inactive state, we use this to set the order key on Safety Deposit Boxes being added and - /// then we increment it and save so the next safety deposit box gets the next number. - /// In the Combined state during token redemption by authority, we use it as a decrementing counter each time - /// The authority of the vault withdrawals a Safety Deposit contents to count down how many - /// are left to be opened and closed down. Once this hits zero, and the fraction mint has zero shares, - /// then we can deactivate the vault. - tokenTypeCount: number; - state: VaultState; - - /// Once combination happens, we copy price per share to vault so that if something nefarious happens - /// to external price account, like price change, we still have the math 'saved' for use in our calcs - lockedPricePerShare: BN; - - constructor(args: { - tokenProgram: StringPublicKey; - fractionMint: StringPublicKey; - authority: StringPublicKey; - fractionTreasury: StringPublicKey; - redeemTreasury: StringPublicKey; - allowFurtherShareCreation: boolean; - pricingLookupAddress: StringPublicKey; - tokenTypeCount: number; - state: VaultState; - lockedPricePerShare: BN; - }) { - this.key = VaultKey.VaultV1; - this.tokenProgram = args.tokenProgram; - this.fractionMint = args.fractionMint; - this.authority = args.authority; - this.fractionTreasury = args.fractionTreasury; - this.redeemTreasury = args.redeemTreasury; - this.allowFurtherShareCreation = args.allowFurtherShareCreation; - this.pricingLookupAddress = args.pricingLookupAddress; - this.tokenTypeCount = args.tokenTypeCount; - this.state = args.state; - this.lockedPricePerShare = args.lockedPricePerShare; - } -} -export class SafetyDepositBox { - /// Each token type in a vault has it's own box that contains it's mint and a look-back - key: VaultKey; - /// VaultKey pointing to the parent vault - vault: StringPublicKey; - /// This particular token's mint - tokenMint: StringPublicKey; - /// Account that stores the tokens under management - store: StringPublicKey; - /// the order in the array of registries - order: number; - - constructor(args: { - vault: StringPublicKey; - tokenMint: StringPublicKey; - store: StringPublicKey; - order: number; - }) { - this.key = VaultKey.SafetyDepositBoxV1; - this.vault = args.vault; - this.tokenMint = args.tokenMint; - this.store = args.store; - this.order = args.order; - } -} - -export class ExternalPriceAccount { - key: VaultKey; - pricePerShare: BN; - /// Mint of the currency we are pricing the shares against, should be same as redeem_treasury. - /// Most likely will be USDC mint most of the time. - priceMint: StringPublicKey; - /// Whether or not combination has been allowed for this vault. - allowedToCombine: boolean; - - constructor(args: { - pricePerShare: BN; - priceMint: StringPublicKey; - allowedToCombine: boolean; - }) { - this.key = VaultKey.ExternalPriceAccountV1; - this.pricePerShare = args.pricePerShare; - this.priceMint = args.priceMint; - this.allowedToCombine = args.allowedToCombine; - } -} - -class InitVaultArgs { - instruction: number = 0; - allowFurtherShareCreation: boolean = false; - - constructor(args: { allowFurtherShareCreation: boolean }) { - this.allowFurtherShareCreation = args.allowFurtherShareCreation; - } -} - -class AmountArgs { - instruction: number; - amount: BN; - - constructor(args: { instruction: number; amount: BN }) { - this.instruction = args.instruction; - this.amount = args.amount; - } -} - -class NumberOfShareArgs { - instruction: number; - numberOfShares: BN; - - constructor(args: { instruction: number; numberOfShares: BN }) { - this.instruction = args.instruction; - this.numberOfShares = args.numberOfShares; - } -} - -class UpdateExternalPriceAccountArgs { - instruction: number = 9; - externalPriceAccount: ExternalPriceAccount; - - constructor(args: { externalPriceAccount: ExternalPriceAccount }) { - this.externalPriceAccount = args.externalPriceAccount; - } -} - -export const VAULT_SCHEMA = new Map([ - [ - InitVaultArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['allowFurtherShareCreation', 'u8'], - ], - }, - ], - [ - AmountArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['amount', 'u64'], - ], - }, - ], - [ - NumberOfShareArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['numberOfShares', 'u64'], - ], - }, - ], - [ - UpdateExternalPriceAccountArgs, - { - kind: 'struct', - fields: [ - ['instruction', 'u8'], - ['externalPriceAccount', ExternalPriceAccount], - ], - }, - ], - [ - Vault, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['tokenProgram', 'pubkeyAsString'], - ['fractionMint', 'pubkeyAsString'], - ['authority', 'pubkeyAsString'], - ['fractionTreasury', 'pubkeyAsString'], - ['redeemTreasury', 'pubkeyAsString'], - ['allowFurtherShareCreation', 'u8'], - ['pricingLookupAddress', 'pubkeyAsString'], - ['tokenTypeCount', 'u8'], - ['state', 'u8'], - ['lockedPricePerShare', 'u64'], - ], - }, - ], - [ - SafetyDepositBox, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['vault', 'pubkeyAsString'], - ['tokenMint', 'pubkeyAsString'], - ['store', 'pubkeyAsString'], - ['order', 'u8'], - ], - }, - ], - [ - ExternalPriceAccount, - { - kind: 'struct', - fields: [ - ['key', 'u8'], - ['pricePerShare', 'u64'], - ['priceMint', 'pubkeyAsString'], - ['allowedToCombine', 'u8'], - ], - }, - ], -]); - -export const decodeVault = (buffer: Buffer) => { - return deserializeUnchecked(VAULT_SCHEMA, Vault, buffer) as Vault; -}; - -export const decodeExternalPriceAccount = (buffer: Buffer) => { - return deserializeUnchecked( - VAULT_SCHEMA, - ExternalPriceAccount, - buffer, - ) as ExternalPriceAccount; -}; - -export const decodeSafetyDeposit = (buffer: Buffer) => { - return deserializeUnchecked( - VAULT_SCHEMA, - SafetyDepositBox, - buffer, - ) as SafetyDepositBox; -}; - -export async function setVaultAuthority( - vault: StringPublicKey, - currentAuthority: StringPublicKey, - newAuthority: StringPublicKey, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const data = Buffer.from([10]); - - const keys = [ - { - pubkey: toPublicKey(vault), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(currentAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(newAuthority), - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data: data, - }), - ); -} - -export async function initVault( - allowFurtherShareCreation: boolean, - fractionalMint: StringPublicKey, - redeemTreasury: StringPublicKey, - fractionalTreasury: StringPublicKey, - vault: StringPublicKey, - vaultAuthority: StringPublicKey, - pricingLookupAddress: StringPublicKey, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const data = Buffer.from( - serialize(VAULT_SCHEMA, new InitVaultArgs({ allowFurtherShareCreation })), - ); - - const keys = [ - { - pubkey: toPublicKey(fractionalMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(redeemTreasury), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionalTreasury), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(vault), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(vaultAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(pricingLookupAddress), - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data: data, - }), - ); -} - -export async function getSafetyDepositBox( - vault: StringPublicKey, - tokenMint: StringPublicKey, -): Promise { - const vaultProgramId = programIds().vault; - - return ( - await findProgramAddress( - [ - Buffer.from(VAULT_PREFIX), - toPublicKey(vault).toBuffer(), - toPublicKey(tokenMint).toBuffer(), - ], - toPublicKey(vaultProgramId), - ) - )[0]; -} - -export async function addTokenToInactiveVault( - amount: BN, - tokenMint: StringPublicKey, - tokenAccount: StringPublicKey, - tokenStoreAccount: StringPublicKey, - vault: StringPublicKey, - vaultAuthority: StringPublicKey, - payer: StringPublicKey, - transferAuthority: StringPublicKey, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const safetyDepositBox = await getSafetyDepositBox(vault, tokenMint); - - const value = new AmountArgs({ - instruction: 1, - amount, - }); - - const data = Buffer.from(serialize(VAULT_SCHEMA, value)); - const keys = [ - { - pubkey: toPublicKey(safetyDepositBox), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(tokenAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(tokenStoreAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(vault), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(vaultAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(payer), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(transferAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data, - }), - ); -} - -export async function activateVault( - numberOfShares: BN, - vault: StringPublicKey, - fractionMint: StringPublicKey, - fractionTreasury: StringPublicKey, - vaultAuthority: StringPublicKey, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const fractionMintAuthority = ( - await findProgramAddress( - [ - Buffer.from(VAULT_PREFIX), - toPublicKey(vaultProgramId).toBuffer(), - toPublicKey(vault).toBuffer(), - ], - toPublicKey(vaultProgramId), - ) - )[0]; - - const value = new NumberOfShareArgs({ instruction: 2, numberOfShares }); - const data = Buffer.from(serialize(VAULT_SCHEMA, value)); - - const keys = [ - { - pubkey: toPublicKey(vault), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionTreasury), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionMintAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(vaultAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data, - }), - ); -} - -export async function combineVault( - vault: StringPublicKey, - outstandingShareTokenAccount: StringPublicKey, - payingTokenAccount: StringPublicKey, - fractionMint: StringPublicKey, - fractionTreasury: StringPublicKey, - redeemTreasury: StringPublicKey, - newVaultAuthority: StringPublicKey | undefined, - vaultAuthority: StringPublicKey, - transferAuthority: StringPublicKey, - externalPriceAccount: StringPublicKey, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const burnAuthority = ( - await findProgramAddress( - [ - Buffer.from(VAULT_PREFIX), - toPublicKey(vaultProgramId).toBuffer(), - toPublicKey(vault).toBuffer(), - ], - toPublicKey(vaultProgramId), - ) - )[0]; - - const data = Buffer.from([3]); - - const keys = [ - { - pubkey: toPublicKey(vault), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(outstandingShareTokenAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(payingTokenAccount), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionTreasury), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(redeemTreasury), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(newVaultAuthority || vaultAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(vaultAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(transferAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(burnAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: toPublicKey(externalPriceAccount), - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data, - }), - ); -} - -export async function withdrawTokenFromSafetyDepositBox( - amount: BN, - destination: StringPublicKey, - safetyDepositBox: StringPublicKey, - storeKey: StringPublicKey, - vault: StringPublicKey, - fractionMint: StringPublicKey, - vaultAuthority: StringPublicKey, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const transferAuthority = ( - await findProgramAddress( - [ - Buffer.from(VAULT_PREFIX), - toPublicKey(vaultProgramId).toBuffer(), - toPublicKey(vault).toBuffer(), - ], - toPublicKey(vaultProgramId), - ) - )[0]; - - const value = new AmountArgs({ instruction: 5, amount }); - const data = Buffer.from(serialize(VAULT_SCHEMA, value)); - - const keys = [ - { - pubkey: toPublicKey(destination), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(safetyDepositBox), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(storeKey), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(vault), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(fractionMint), - isSigner: false, - isWritable: true, - }, - { - pubkey: toPublicKey(vaultAuthority), - isSigner: true, - isWritable: false, - }, - { - pubkey: toPublicKey(transferAuthority), - isSigner: false, - isWritable: false, - }, - { - pubkey: programIds().token, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data, - }), - ); -} - -export async function updateExternalPriceAccount( - externalPriceAccountKey: StringPublicKey, - externalPriceAccount: ExternalPriceAccount, - instructions: TransactionInstruction[], -) { - const vaultProgramId = programIds().vault; - - const value = new UpdateExternalPriceAccountArgs({ externalPriceAccount }); - const data = Buffer.from(serialize(VAULT_SCHEMA, value)); - console.log('Data', data); - - const keys = [ - { - pubkey: toPublicKey(externalPriceAccountKey), - isSigner: false, - isWritable: true, - }, - ]; - instructions.push( - new TransactionInstruction({ - keys, - programId: toPublicKey(vaultProgramId), - data, - }), - ); -} - -export async function getSafetyDepositBoxAddress( - vault: StringPublicKey, - tokenMint: StringPublicKey, -): Promise { - const PROGRAM_IDS = programIds(); - return ( - await findProgramAddress( - [ - Buffer.from(VAULT_PREFIX), - toPublicKey(vault).toBuffer(), - toPublicKey(tokenMint).toBuffer(), - ], - toPublicKey(PROGRAM_IDS.vault), - ) - )[0]; -} diff --git a/js/packages/common/src/components/ActionConfirmation/index.tsx b/js/packages/common/src/components/ActionConfirmation/index.tsx deleted file mode 100644 index 9eb0ec7c4d6..00000000000 --- a/js/packages/common/src/components/ActionConfirmation/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { Button } from 'antd'; -import { LABELS } from '../../constants'; -import { Link } from 'react-router-dom'; - -export const ActionConfirmation = (props: { - className?: string; - onClose: () => void; -}) => { - return ( -
-

Congratulations!

-
Your action has been successfully executed
-
- - - - -
- ); -}; diff --git a/js/packages/common/src/components/ActionConfirmation/style.less b/js/packages/common/src/components/ActionConfirmation/style.less deleted file mode 100644 index 64d27b288fa..00000000000 --- a/js/packages/common/src/components/ActionConfirmation/style.less +++ /dev/null @@ -1,5 +0,0 @@ -.success-icon { - background-image: url('data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjNzBjMDQxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iTGF5ZXIgMSIgdmlld0JveD0iMCAwIDY0IDY0IiB4PSIwcHgiIHk9IjBweCI+PHRpdGxlPmJ1c2luZXNzIGZpbmFuY2UgdXAgcmlzZSBhcnJvdyBkZW1hbmQ8L3RpdGxlPjxwYXRoIGQ9Ik01LDE0YTEsMSwwLDEsMC0xLTFINEExLDEsMCwwLDAsNSwxNFoiPjwvcGF0aD48cGF0aCBkPSJNNyw1Mkg1NWExLDEsMCwwLDAsMC0ySDUwVjI3YTEsMSwwLDAsMC0yLDBWNTBINDRWMzRhMSwxLDAsMCwwLTIsMFY1MEgzOFYzOWExLDEsMCwwLDAtMiwwVjUwSDMyVjQzYTEsMSwwLDAsMC0yLDB2N0gyNlY0NmExLDEsMCwwLDAtMiwwdjRIMjBWNDdhMSwxLDAsMCwwLTIsMHYzSDE0VjQ4YTEsMSwwLDAsMC0yLDB2Mkg3YTEsMSwwLDAsMS0xLTFWMTdhMSwxLDAsMCwwLTIsMFY0OUEzLDMsMCwwLDAsNyw1MloiPjwvcGF0aD48cGF0aCBkPSJNNTksNTBhMSwxLDAsMCwwLTEsMWgwYTEsMSwwLDEsMCwxLTFaIj48L3BhdGg+PHBhdGggZD0iTTExLDQ0aC4wN2E0OS4wNyw0OS4wNywwLDAsMCwyNS41Mi05LjE5QTQ4LjkxLDQ4LjkxLDAsMCwwLDQ5LjcsMjAuNTlMNTIuMzgsMjIsNTIsMTRsLTYuNzEsNC4zMSwyLjYzLDEuMzZBNDYuODEsNDYuODEsMCwwLDEsMzUuNDEsMzMuMTksNDYuOTQsNDYuOTQsMCwwLDEsMTAuOTMsNDIsMSwxLDAsMCwwLDExLDQ0WiI+PC9wYXRoPjwvc3ZnPg=='); - width: 280px; - height: 280px; -} diff --git a/js/packages/common/src/components/AppBar/index.tsx b/js/packages/common/src/components/AppBar/index.tsx deleted file mode 100644 index 1e44d00b2d8..00000000000 --- a/js/packages/common/src/components/AppBar/index.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import { Button, Popover } from 'antd'; -import { CurrentUserBadge } from '../CurrentUserBadge'; -import { SettingOutlined } from '@ant-design/icons'; -import { Settings } from '../Settings'; -import { LABELS } from '../../constants/labels'; -import { ConnectButton } from '..'; -import { useWallet } from '../../contexts/wallet'; -export const AppBar = (props: { - left?: JSX.Element; - right?: JSX.Element; - useWalletBadge?: boolean; - additionalSettings?: JSX.Element; -}) => { - const { connected } = useWallet(); - - const TopBar = ( -
- {props.left} - {connected ? ( - - ) : ( - - )} - } - trigger="click" - > -
- ); - - return TopBar; -}; diff --git a/js/packages/common/src/components/AppBar/style.less b/js/packages/common/src/components/AppBar/style.less deleted file mode 100644 index 0c8bfcaf44b..00000000000 --- a/js/packages/common/src/components/AppBar/style.less +++ /dev/null @@ -1,57 +0,0 @@ -.App-Bar { - -webkit-box-pack: justify; - justify-content: space-between !important; - -webkit-box-align: center; - align-items: center; - flex-direction: row; - display: flex; - width: 100%; - top: 0px; - position: relative; - padding: 1rem; - z-index: 2; - - .ant-menu-horizontal { - border-bottom-color: transparent; - background-color: transparent; - line-height: inherit; - font-size: 16px; - margin: 0 10px; - - .ant-menu-item { - margin: 0 10px; - color: lightgrey; - height: 35px; - line-height: 35px; - border-width: 0px !important; - } - - .ant-menu-item:hover { - color: white; - border-width: 0px !important; - } - - .ant-menu-item-selected { - font-weight: bold; - } - } -} - -.App-Bar-left { - box-sizing: border-box; - margin: 0px; - min-width: 0px; - display: flex; - padding: 0px; - -webkit-box-align: center; - align-items: center; - width: fit-content; -} - -.App-Bar-right { - display: flex; - flex-direction: row; - -webkit-box-align: center; - align-items: center; - justify-self: flex-end; -} diff --git a/js/packages/common/src/components/BackButton/index.tsx b/js/packages/common/src/components/BackButton/index.tsx deleted file mode 100644 index 82ce8863e6e..00000000000 --- a/js/packages/common/src/components/BackButton/index.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { Button } from 'antd'; -import { LABELS } from '../../constants'; -import { useHistory } from 'react-router-dom'; - -export const BackButton = () => { - const history = useHistory(); - return ( - - ); -}; diff --git a/js/packages/common/src/components/ConnectButton/index.tsx b/js/packages/common/src/components/ConnectButton/index.tsx deleted file mode 100644 index aac77f876b3..00000000000 --- a/js/packages/common/src/components/ConnectButton/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { Button, Dropdown, Menu } from "antd"; -import { ButtonProps } from "antd/lib/button"; -import React from "react"; -import { useWallet } from './../../contexts/wallet'; - -export interface ConnectButtonProps extends ButtonProps, React.RefAttributes { - allowWalletChange?: boolean; -} - -export const ConnectButton = ( - props: ConnectButtonProps -) => { - const { connected, connect, select, provider } = useWallet(); - const { onClick, children, disabled, allowWalletChange, ...rest } = props; - - // only show if wallet selected or user connected - - const menu = ( - - Change Wallet - - ); - - if(!provider || !allowWalletChange) { - return ; - } - - return ( - - Connect - - ); -}; diff --git a/js/packages/common/src/components/CurrentUserBadge/index.tsx b/js/packages/common/src/components/CurrentUserBadge/index.tsx deleted file mode 100644 index 8524f34915b..00000000000 --- a/js/packages/common/src/components/CurrentUserBadge/index.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import React from 'react'; - -import { Identicon } from '../Identicon'; -import { LAMPORTS_PER_SOL } from '@solana/web3.js'; -import { useWallet } from '../../contexts/wallet'; -import { useNativeAccount } from '../../contexts/accounts'; -import { formatNumber, shortenAddress } from '../../utils'; -import { Popover } from 'antd'; -import { Settings } from '../Settings'; - -export const CurrentUserBadge = (props: { - showBalance?: boolean; - showAddress?: boolean; - iconSize?: number; -}) => { - const { wallet } = useWallet(); - const { account } = useNativeAccount(); - - if (!wallet || !wallet.publicKey) { - return null; - } - - const iconStyle: React.CSSProperties = props.showAddress - ? { - marginLeft: '0.5rem', - display: 'flex', - width: props.iconSize, - borderRadius: 50, - } - : { - display: 'flex', - width: props.iconSize, - paddingLeft: 0, - borderRadius: 50, - }; - - const baseWalletKey: React.CSSProperties = { - height: props.iconSize, - cursor: 'pointer', - userSelect: 'none', - }; - const walletKeyStyle: React.CSSProperties = props.showAddress - ? baseWalletKey - : { ...baseWalletKey, paddingLeft: 0 }; - - let name = props.showAddress ? shortenAddress(`${wallet.publicKey}`) : ''; - const unknownWallet = wallet as any; - if (unknownWallet.name) { - name = unknownWallet.name; - } - - let image = ( - - ); - - if (unknownWallet.image) { - image = ; - } - - return ( -
- {props.showBalance && ( - - {formatNumber.format((account?.lamports || 0) / LAMPORTS_PER_SOL)} SOL - - )} - - } - trigger="click" - > -
- {name && {name}} - {image} -
-
-
- ); -}; diff --git a/js/packages/common/src/components/CurrentUserBadge/styles.less b/js/packages/common/src/components/CurrentUserBadge/styles.less deleted file mode 100644 index 5940a94bf7a..00000000000 --- a/js/packages/common/src/components/CurrentUserBadge/styles.less +++ /dev/null @@ -1,15 +0,0 @@ -.wallet-wrapper { - padding-left: 0.7rem; - border-radius: 0.5rem; - display: flex; - align-items: center; - white-space: nowrap; -} - -.wallet-key { - padding: 0.1rem 0.5rem 0.1rem 0.7rem; - margin-left: 0.3rem; - border-radius: 0.5rem; - display: flex; - align-items: center; -} diff --git a/js/packages/common/src/components/EtherscanLink/index.tsx b/js/packages/common/src/components/EtherscanLink/index.tsx deleted file mode 100644 index 321febb81d7..00000000000 --- a/js/packages/common/src/components/EtherscanLink/index.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -import { Typography } from 'antd'; -import { shortenAddress } from '../../utils/utils'; - -export const EtherscanLink = (props: { - address: string ; - type: string; - code?: boolean; - style?: React.CSSProperties; - length?: number; -}) => { - const { type, code } = props; - - const address = props.address; - - if (!address) { - return null; - } - - const length = props.length ?? 9; - - return ( - - {code ? ( - - {shortenAddress(address, length)} - - ) : ( - shortenAddress(address, length) - )} - - ); -}; diff --git a/js/packages/common/src/components/ExplorerLink/index.tsx b/js/packages/common/src/components/ExplorerLink/index.tsx deleted file mode 100644 index 32fcc069da1..00000000000 --- a/js/packages/common/src/components/ExplorerLink/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import { Typography } from 'antd'; -import { shortenAddress } from '../../utils/utils'; -import { PublicKey } from '@solana/web3.js'; - -export const ExplorerLink = (props: { - address: string | PublicKey; - type: string; - code?: boolean; - style?: React.CSSProperties; - length?: number; -}) => { - const { type, code } = props; - - const address = - typeof props.address === 'string' - ? props.address - : props.address?.toBase58(); - - if (!address) { - return null; - } - - const length = props.length ?? 9; - - return ( - - {code ? ( - - {shortenAddress(address, length)} - - ) : ( - shortenAddress(address, length) - )} - - ); -}; diff --git a/js/packages/common/src/components/Icons/info.tsx b/js/packages/common/src/components/Icons/info.tsx deleted file mode 100644 index 4bb0e3a090c..00000000000 --- a/js/packages/common/src/components/Icons/info.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Button, Popover } from "antd"; -import React from "react"; - -import { InfoCircleOutlined } from "@ant-design/icons"; - -export const Info = (props: { - text: React.ReactElement; - style?: React.CSSProperties; -}) => { - return ( - {props.text}
} - > - - - ); -}; diff --git a/js/packages/common/src/components/Identicon/index.tsx b/js/packages/common/src/components/Identicon/index.tsx deleted file mode 100644 index bb9d7e8dc52..00000000000 --- a/js/packages/common/src/components/Identicon/index.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React, { useEffect, useRef } from 'react'; - -import Jazzicon from 'jazzicon'; -import bs58 from 'bs58'; -import { PublicKey } from '@solana/web3.js'; - -export const Identicon = (props: { - address?: string | PublicKey; - style?: React.CSSProperties; - className?: string; - alt?: string; -}) => { - const { style, className, alt } = props; - const address = - typeof props.address === 'string' - ? props.address - : props.address?.toBase58(); - const ref = useRef(); - - useEffect(() => { - if (address && ref.current) { - try { - ref.current.innerHTML = ''; - ref.current.className = className || ''; - ref.current.appendChild( - Jazzicon( - style?.width || 16, - parseInt(bs58.decode(address).toString('hex').slice(5, 15), 16), - ), - ); - } catch (err) { - // TODO - } - } - }, [address, style, className]); - - return ( -
- ); -}; diff --git a/js/packages/common/src/components/Identicon/style.less b/js/packages/common/src/components/Identicon/style.less deleted file mode 100644 index 4b04246474c..00000000000 --- a/js/packages/common/src/components/Identicon/style.less +++ /dev/null @@ -1,8 +0,0 @@ -.identicon-wrapper { - display: flex; - height: 1rem; - width: 1rem; - border-radius: 1.125rem; - margin: 0.2rem 0.2rem 0.2rem 0.1rem; - /* background-color: ${({ theme }) => theme.bg4}; */ -} diff --git a/js/packages/common/src/components/Input/numeric.tsx b/js/packages/common/src/components/Input/numeric.tsx deleted file mode 100644 index c307e3e9ed6..00000000000 --- a/js/packages/common/src/components/Input/numeric.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from "react"; -import { Input } from "antd"; - -export class NumericInput extends React.Component { - onChange = (e: any) => { - const { value } = e.target; - const reg = /^-?\d*(\.\d*)?$/; - if (reg.test(value) || value === "" || value === "-") { - this.props.onChange(value); - } - }; - - // '.' at the end or only '-' in the input box. - onBlur = () => { - const { value, onBlur, onChange } = this.props; - let valueTemp = value; - if (value === undefined || value === null) return; - if ( - value.charAt && - (value.charAt(value.length - 1) === "." || value === "-") - ) { - valueTemp = value.slice(0, -1); - } - if (value.startsWith && (value.startsWith(".") || value.startsWith("-."))) { - valueTemp = valueTemp.replace(".", "0."); - } - if (valueTemp.replace) onChange?.(valueTemp.replace(/0*(\d+)/, "$1")); - if (onBlur) { - onBlur(); - } - }; - - render() { - return ( - - ); - } -} diff --git a/js/packages/common/src/components/MetaplexModal/index.less b/js/packages/common/src/components/MetaplexModal/index.less deleted file mode 100644 index 13f8a9034be..00000000000 --- a/js/packages/common/src/components/MetaplexModal/index.less +++ /dev/null @@ -1,9 +0,0 @@ -.ant-scrolling-effect { - #root>.ant-layout { - filter: blur(10px) brightness(0.5); - } -} - -.ant-modal-content { - border-radius: 16px; -} diff --git a/js/packages/common/src/components/MetaplexModal/index.tsx b/js/packages/common/src/components/MetaplexModal/index.tsx deleted file mode 100644 index 05b7be3ae13..00000000000 --- a/js/packages/common/src/components/MetaplexModal/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import { Modal } from 'antd'; - -export const MetaplexModal = (props: any) => { - const { children, bodyStyle, ...rest } = props; - - return ( - - {children} - - ); -}; diff --git a/js/packages/common/src/components/MetaplexOverlay/index.tsx b/js/packages/common/src/components/MetaplexOverlay/index.tsx deleted file mode 100644 index 2c9d787cf45..00000000000 --- a/js/packages/common/src/components/MetaplexOverlay/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { Modal } from 'antd'; - -export const MetaplexOverlay = (props: any) => { - - const { children, ...rest } = props - - const content =
- {children} -
- - return ( - content} - width={'100vw'} - mask={false} - {...rest} - > - ); -}; diff --git a/js/packages/common/src/components/Settings/index.tsx b/js/packages/common/src/components/Settings/index.tsx deleted file mode 100644 index 0ca0c7400fd..00000000000 --- a/js/packages/common/src/components/Settings/index.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react'; -import { Button, Select } from 'antd'; -import { useWallet } from '../../contexts/wallet'; -import { ENDPOINTS, useConnectionConfig } from '../../contexts/connection'; -import { shortenAddress } from '../../utils'; -import { CopyOutlined } from '@ant-design/icons'; - -export const Settings = ({ - additionalSettings, -}: { - additionalSettings?: JSX.Element; -}) => { - const { connected, disconnect, select, wallet } = useWallet(); - const { endpoint, setEndpoint } = useConnectionConfig(); - - return ( - <> -
- Network:{' '} - - {connected && ( - <> - Wallet: - {wallet?.publicKey && ( - - )} - - - - - )} - {additionalSettings} -
- - ); -}; diff --git a/js/packages/common/src/components/TokenDisplay/index.tsx b/js/packages/common/src/components/TokenDisplay/index.tsx deleted file mode 100644 index 223dd81a17c..00000000000 --- a/js/packages/common/src/components/TokenDisplay/index.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react'; -import { useMint } from '../../contexts/accounts'; -import { useAccountByMint } from '../../hooks'; -import { TokenIcon } from '../TokenIcon'; - -export const TokenDisplay = (props: { - name: string; - mintAddress: string; - icon?: JSX.Element; - showBalance?: boolean; -}) => { - const { showBalance, mintAddress, name, icon } = props; - const tokenMint = useMint(mintAddress); - const tokenAccount = useAccountByMint(mintAddress); - - let balance: number = 0; - let hasBalance: boolean = false; - if (showBalance) { - if (tokenAccount && tokenMint) { - balance = - tokenAccount.info.amount.toNumber() / Math.pow(10, tokenMint.decimals); - hasBalance = balance > 0; - } - } - - return ( - <> -
-
- {icon || } - {name} -
- {showBalance ? ( - -  {' '} - {hasBalance - ? balance < 0.001 - ? '<0.001' - : balance.toFixed(3) - : '-'} - - ) : null} -
- - ); -}; diff --git a/js/packages/common/src/components/TokenIcon/index.tsx b/js/packages/common/src/components/TokenIcon/index.tsx deleted file mode 100644 index 21da7ecd3db..00000000000 --- a/js/packages/common/src/components/TokenIcon/index.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React from 'react'; -import { PublicKey } from '@solana/web3.js'; -import {getTokenIcon, KnownTokenMap} from '../../utils'; -import { useConnectionConfig } from '../../contexts/connection'; -import { Identicon } from '../Identicon'; - -export const TokenIcon = (props: { - mintAddress?: string | PublicKey; - style?: React.CSSProperties; - size?: number; - className?: string; - tokenMap?: KnownTokenMap, -}) => { - let icon: string | undefined = ''; - if (props.tokenMap) { - icon = getTokenIcon(props.tokenMap, props.mintAddress); - } else { - const { tokenMap } = useConnectionConfig(); - icon = getTokenIcon(tokenMap, props.mintAddress); - } - - const size = props.size || 20; - - if (icon) { - return ( - Token icon - ); - } - return ( - - ); -}; - -export const PoolIcon = (props: { - mintA: string; - mintB: string; - style?: React.CSSProperties; - className?: string; -}) => { - return ( -
- - -
- ); -}; diff --git a/js/packages/common/src/components/index.tsx b/js/packages/common/src/components/index.tsx deleted file mode 100644 index bf58f3ed652..00000000000 --- a/js/packages/common/src/components/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -export { ExplorerLink } from './ExplorerLink/index'; -export { ConnectButton } from './ConnectButton/index'; -export { CurrentUserBadge } from './CurrentUserBadge/index'; -export { Identicon } from './Identicon/index'; -export { Info } from './Icons/info'; -export { NumericInput } from './Input/numeric'; -export { AppBar } from './AppBar/index'; -export { Settings } from './Settings/index'; -export { ActionConfirmation } from './ActionConfirmation/index'; -export { BackButton } from './BackButton/index'; -export { TokenIcon } from './TokenIcon'; -export { TokenDisplay } from './TokenDisplay'; -export { EtherscanLink } from './EtherscanLink'; -export { MetaplexModal } from './MetaplexModal'; -export { MetaplexOverlay } from './MetaplexOverlay'; diff --git a/js/packages/common/src/constants/index.ts b/js/packages/common/src/constants/index.ts deleted file mode 100644 index 7d6bf06cafb..00000000000 --- a/js/packages/common/src/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './math'; -export * from './labels'; diff --git a/js/packages/common/src/constants/labels.ts b/js/packages/common/src/constants/labels.ts deleted file mode 100644 index be5c639705d..00000000000 --- a/js/packages/common/src/constants/labels.ts +++ /dev/null @@ -1,15 +0,0 @@ -export const LABELS = { - CONNECT_LABEL: 'Connect Wallet', - AUDIT_WARNING: - 'Oyster is an unaudited software project used for internal purposes at the Solana Foundation. This app is not for public use.', - FOOTER: - 'This page was produced by the Solana Foundation ("SF") for internal educational and inspiration purposes only. SF does not encourage, induce or sanction the deployment, integration or use of Oyster or any similar application (including its code) in violation of applicable laws or regulations and hereby prohibits any such deployment, integration or use. Anyone using this code or a derivation thereof must comply with applicable laws and regulations when releasing related software.', - MENU_HOME: 'Home', - MENU_DASHBOARD: 'Dashboard', - CONNECT_BUTTON: 'Connect', - WALLET_TOOLTIP: 'Wallet public key', - WALLET_BALANCE: 'Wallet balance', - SETTINGS_TOOLTIP: 'Settings', - DASHBOARD_ACTION: 'Go to dashboard', - GO_BACK_ACTION: 'Go back', -}; diff --git a/js/packages/common/src/constants/math.ts b/js/packages/common/src/constants/math.ts deleted file mode 100644 index 6e062935d0a..00000000000 --- a/js/packages/common/src/constants/math.ts +++ /dev/null @@ -1,7 +0,0 @@ -import BN from 'bn.js'; - -export const TEN = new BN(10); -export const HALF_WAD = TEN.pow(new BN(18)); -export const WAD = TEN.pow(new BN(18)); -export const RAY = TEN.pow(new BN(27)); -export const ZERO = new BN(0); diff --git a/js/packages/common/src/contexts/accounts.tsx b/js/packages/common/src/contexts/accounts.tsx deleted file mode 100644 index e2b5bc0f7e2..00000000000 --- a/js/packages/common/src/contexts/accounts.tsx +++ /dev/null @@ -1,668 +0,0 @@ -import React, { - useCallback, - useContext, - useEffect, - useMemo, - useState, -} from 'react'; -import { useConnection } from '../contexts/connection'; -import { useWallet } from '../contexts/wallet'; -import { AccountInfo, Connection, PublicKey } from '@solana/web3.js'; -import { AccountLayout, MintInfo, MintLayout, u64 } from '@solana/spl-token'; -import { TokenAccount } from '../models'; -import { chunks } from '../utils/utils'; -import { EventEmitter } from '../utils/eventEmitter'; -import { StringPublicKey, WRAPPED_SOL_MINT } from '../utils/ids'; -import { programIds } from '../utils/programIds'; - -const AccountsContext = React.createContext(null); - -const pendingCalls = new Map>(); -const genericCache = new Map(); -const pendingMintCalls = new Map>(); -const mintCache = new Map(); - -export interface ParsedAccountBase { - pubkey: StringPublicKey; - account: AccountInfo; - info: any; // TODO: change to unknown -} - -export type AccountParser = ( - pubkey: StringPublicKey, - data: AccountInfo, -) => ParsedAccountBase | undefined; - -export interface ParsedAccount extends ParsedAccountBase { - info: T; -} - -const getMintInfo = async (connection: Connection, pubKey: PublicKey) => { - const info = await connection.getAccountInfo(pubKey); - if (info === null) { - throw new Error('Failed to find mint account'); - } - - const data = Buffer.from(info.data); - - return deserializeMint(data); -}; - -export const MintParser = (pubKey: string, info: AccountInfo) => { - const buffer = Buffer.from(info.data); - - const data = deserializeMint(buffer); - - const details = { - pubkey: pubKey, - account: { - ...info, - }, - info: data, - } as ParsedAccountBase; - - return details; -}; - -export const TokenAccountParser = ( - pubKey: string, - info: AccountInfo, -) => { - // Sometimes a wrapped sol account gets closed, goes to 0 length, - // triggers an update over wss which triggers this guy to get called - // since your UI already logged that pubkey as a token account. Check for length. - if (info.data.length > 0) { - const buffer = Buffer.from(info.data); - const data = deserializeAccount(buffer); - - const details = { - pubkey: pubKey, - account: { - ...info, - }, - info: data, - } as TokenAccount; - - return details; - } -}; - -export const GenericAccountParser = ( - pubKey: string, - info: AccountInfo, -) => { - const buffer = Buffer.from(info.data); - - const details = { - pubkey: pubKey, - account: { - ...info, - }, - info: buffer, - } as ParsedAccountBase; - - return details; -}; - -export const keyToAccountParser = new Map(); - -export const cache = { - emitter: new EventEmitter(), - query: async ( - connection: Connection, - pubKey: string | PublicKey, - parser?: AccountParser, - ) => { - let id: PublicKey; - if (typeof pubKey === 'string') { - id = new PublicKey(pubKey); - } else { - id = pubKey; - } - - const address = id.toBase58(); - - let account = genericCache.get(address); - if (account) { - return account; - } - - let query = pendingCalls.get(address); - if (query) { - return query; - } - - // TODO: refactor to use multiple accounts query with flush like behavior - query = connection.getAccountInfo(id).then(data => { - if (!data) { - throw new Error('Account not found'); - } - - return cache.add(id, data, parser); - }) as Promise; - pendingCalls.set(address, query as any); - - return query; - }, - add: ( - id: PublicKey | string, - obj: AccountInfo, - parser?: AccountParser, - isActive?: boolean | undefined | ((parsed: any) => boolean), - ) => { - const address = typeof id === 'string' ? id : id?.toBase58(); - const deserialize = parser ? parser : keyToAccountParser.get(address); - if (!deserialize) { - throw new Error( - 'Deserializer needs to be registered or passed as a parameter', - ); - } - - cache.registerParser(id, deserialize); - pendingCalls.delete(address); - const account = deserialize(address, obj); - if (!account) { - return; - } - - if (isActive === undefined) isActive = true; - else if (isActive instanceof Function) isActive = isActive(account); - - const isNew = !genericCache.has(address); - - genericCache.set(address, account); - cache.emitter.raiseCacheUpdated(address, isNew, deserialize, isActive); - return account; - }, - get: (pubKey: string | PublicKey) => { - let key: string; - if (typeof pubKey !== 'string') { - key = pubKey.toBase58(); - } else { - key = pubKey; - } - - return genericCache.get(key); - }, - delete: (pubKey: string | PublicKey) => { - let key: string; - if (typeof pubKey !== 'string') { - key = pubKey.toBase58(); - } else { - key = pubKey; - } - - if (genericCache.get(key)) { - genericCache.delete(key); - cache.emitter.raiseCacheDeleted(key); - return true; - } - return false; - }, - - byParser: (parser: AccountParser) => { - const result: string[] = []; - for (const id of keyToAccountParser.keys()) { - if (keyToAccountParser.get(id) === parser) { - result.push(id); - } - } - - return result; - }, - registerParser: (pubkey: PublicKey | string, parser: AccountParser) => { - if (pubkey) { - const address = typeof pubkey === 'string' ? pubkey : pubkey?.toBase58(); - keyToAccountParser.set(address, parser); - } - - return pubkey; - }, - queryMint: async (connection: Connection, pubKey: string | PublicKey) => { - let id: PublicKey; - if (typeof pubKey === 'string') { - id = new PublicKey(pubKey); - } else { - id = pubKey; - } - - const address = id.toBase58(); - let mint = mintCache.get(address); - if (mint) { - return mint; - } - - let query = pendingMintCalls.get(address); - if (query) { - return query; - } - - query = getMintInfo(connection, id).then(data => { - pendingMintCalls.delete(address); - - mintCache.set(address, data); - return data; - }) as Promise; - pendingMintCalls.set(address, query as any); - - return query; - }, - getMint: (pubKey: string | PublicKey) => { - let key: string; - if (typeof pubKey !== 'string') { - key = pubKey.toBase58(); - } else { - key = pubKey; - } - - return mintCache.get(key); - }, - addMint: (pubKey: PublicKey, obj: AccountInfo) => { - const mint = deserializeMint(obj.data); - const id = pubKey.toBase58(); - mintCache.set(id, mint); - return mint; - }, -}; - -export const useAccountsContext = () => { - const context = useContext(AccountsContext); - - return context; -}; - -function wrapNativeAccount( - pubkey: string, - account?: AccountInfo, -): TokenAccount | undefined { - if (!account) { - return undefined; - } - - const key = new PublicKey(pubkey); - - return { - pubkey: pubkey, - account, - info: { - address: key, - mint: WRAPPED_SOL_MINT, - owner: key, - amount: new u64(account.lamports), - delegate: null, - delegatedAmount: new u64(0), - isInitialized: true, - isFrozen: false, - isNative: true, - rentExemptReserve: null, - closeAuthority: null, - }, - }; -} - -export const getCachedAccount = ( - predicate: (account: TokenAccount) => boolean, -) => { - for (const account of genericCache.values()) { - if (predicate(account)) { - return account as TokenAccount; - } - } -}; - -const UseNativeAccount = () => { - const connection = useConnection(); - const { wallet } = useWallet(); - - const [nativeAccount, setNativeAccount] = useState>(); - - const updateCache = useCallback( - account => { - if (wallet && wallet.publicKey) { - const wrapped = wrapNativeAccount( - wallet.publicKey?.toBase58(), - account, - ); - if (wrapped !== undefined && wallet) { - const id = wallet.publicKey?.toBase58(); - cache.registerParser(id, TokenAccountParser); - genericCache.set(id, wrapped as TokenAccount); - cache.emitter.raiseCacheUpdated(id, false, TokenAccountParser, true); - } - } - }, - [wallet], - ); - - useEffect(() => { - let subId = 0; - const updateAccount = (account: AccountInfo | null) => { - if (account) { - updateCache(account); - setNativeAccount(account); - } - }; - - (async () => { - if (!connection || !wallet?.publicKey) { - return; - } - - const account = await connection.getAccountInfo(wallet.publicKey); - updateAccount(account); - - subId = connection.onAccountChange(wallet.publicKey, updateAccount); - })(); - - return () => { - if (subId) { - connection.removeAccountChangeListener(subId); - } - }; - }, [setNativeAccount, wallet, wallet?.publicKey, connection, updateCache]); - - return { nativeAccount }; -}; - -const PRECACHED_OWNERS = new Set(); -const precacheUserTokenAccounts = async ( - connection: Connection, - owner?: PublicKey, -) => { - if (!owner) { - return; - } - - // used for filtering account updates over websocket - PRECACHED_OWNERS.add(owner.toBase58()); - - // user accounts are updated via ws subscription - const accounts = await connection.getTokenAccountsByOwner(owner, { - programId: programIds().token, - }); - - accounts.value.forEach(info => { - cache.add(info.pubkey.toBase58(), info.account, TokenAccountParser); - }); -}; - -export function AccountsProvider({ children = null as any }) { - const connection = useConnection(); - const { wallet, connected } = useWallet(); - const [tokenAccounts, setTokenAccounts] = useState([]); - const [userAccounts, setUserAccounts] = useState([]); - const { nativeAccount } = UseNativeAccount(); - const walletKey = wallet?.publicKey?.toBase58(); - - const selectUserAccounts = useCallback(() => { - return cache - .byParser(TokenAccountParser) - .map(id => cache.get(id)) - .filter(a => a && a.info.owner.toBase58() === walletKey) - .map(a => a as TokenAccount); - }, [walletKey]); - - useEffect(() => { - const accounts = selectUserAccounts().filter( - a => a !== undefined, - ) as TokenAccount[]; - setUserAccounts(accounts); - }, [nativeAccount, wallet, tokenAccounts, selectUserAccounts]); - - useEffect(() => { - const subs: number[] = []; - cache.emitter.onCache(args => { - if (args.isNew && args.isActive) { - let id = args.id; - let deserialize = args.parser; - connection.onAccountChange(new PublicKey(id), info => { - cache.add(id, info, deserialize); - }); - } - }); - - return () => { - subs.forEach(id => connection.removeAccountChangeListener(id)); - }; - }, [connection]); - - const publicKey = wallet?.publicKey; - useEffect(() => { - if (!connection || !publicKey) { - setTokenAccounts([]); - } else { - precacheUserTokenAccounts(connection, publicKey).then(() => { - setTokenAccounts(selectUserAccounts()); - }); - - // This can return different types of accounts: token-account, mint, multisig - // TODO: web3.js expose ability to filter. - // this should use only filter syntax to only get accounts that are owned by user - const tokenSubID = connection.onProgramAccountChange( - programIds().token, - info => { - // TODO: fix type in web3.js - const id = info.accountId as unknown as string; - // TODO: do we need a better way to identify layout (maybe a enum identifing type?) - if (info.accountInfo.data.length === AccountLayout.span) { - const data = deserializeAccount(info.accountInfo.data); - - if (PRECACHED_OWNERS.has(data.owner.toBase58())) { - cache.add(id, info.accountInfo, TokenAccountParser); - setTokenAccounts(selectUserAccounts()); - } - } - }, - 'singleGossip', - ); - - return () => { - connection.removeProgramAccountChangeListener(tokenSubID); - }; - } - }, [connection, connected, publicKey, selectUserAccounts]); - - return ( - - {children} - - ); -} - -export function useNativeAccount() { - const context = useContext(AccountsContext); - return { - account: context.nativeAccount as AccountInfo, - }; -} - -export const getMultipleAccounts = async ( - connection: any, - keys: string[], - commitment: string, -) => { - const result = await Promise.all( - chunks(keys, 99).map(chunk => - getMultipleAccountsCore(connection, chunk, commitment), - ), - ); - - const array = result - .map( - a => - a.array.map(acc => { - if (!acc) { - return undefined; - } - - const { data, ...rest } = acc; - const obj = { - ...rest, - data: Buffer.from(data[0], 'base64'), - } as AccountInfo; - return obj; - }) as AccountInfo[], - ) - .flat(); - return { keys, array }; -}; - -const getMultipleAccountsCore = async ( - connection: any, - keys: string[], - commitment: string, -) => { - const args = connection._buildArgs([keys], commitment, 'base64'); - - const unsafeRes = await connection._rpcRequest('getMultipleAccounts', args); - if (unsafeRes.error) { - throw new Error( - 'failed to get info about account ' + unsafeRes.error.message, - ); - } - - if (unsafeRes.result.value) { - const array = unsafeRes.result.value as AccountInfo[]; - return { keys, array }; - } - - // TODO: fix - throw new Error(); -}; - -export function useMint(key?: string | PublicKey) { - const connection = useConnection(); - const [mint, setMint] = useState(); - - const id = typeof key === 'string' ? key : key?.toBase58(); - - useEffect(() => { - if (!id) { - return; - } - - cache - .query(connection, id, MintParser) - .then(acc => setMint(acc.info as any)) - .catch(err => console.log(err)); - - const dispose = cache.emitter.onCache(e => { - const event = e; - if (event.id === id) { - cache - .query(connection, id, MintParser) - .then(mint => setMint(mint.info as any)); - } - }); - return () => { - dispose(); - }; - }, [connection, id]); - - return mint; -} - -export function useAccount(pubKey?: PublicKey) { - const connection = useConnection(); - const [account, setAccount] = useState(); - - const key = pubKey?.toBase58(); - useEffect(() => { - const query = async () => { - try { - if (!key) { - return; - } - - const acc = await cache - .query(connection, key, TokenAccountParser) - .catch(err => console.log(err)); - if (acc) { - setAccount(acc); - } - } catch (err) { - console.error(err); - } - }; - - query(); - - const dispose = cache.emitter.onCache(e => { - const event = e; - if (event.id === key) { - query(); - } - }); - return () => { - dispose(); - }; - }, [connection, key]); - - return account; -} - -// TODO: expose in spl package -export const deserializeAccount = (data: Buffer) => { - const accountInfo = AccountLayout.decode(data); - accountInfo.mint = new PublicKey(accountInfo.mint); - accountInfo.owner = new PublicKey(accountInfo.owner); - accountInfo.amount = u64.fromBuffer(accountInfo.amount); - - if (accountInfo.delegateOption === 0) { - accountInfo.delegate = null; - accountInfo.delegatedAmount = new u64(0); - } else { - accountInfo.delegate = new PublicKey(accountInfo.delegate); - accountInfo.delegatedAmount = u64.fromBuffer(accountInfo.delegatedAmount); - } - - accountInfo.isInitialized = accountInfo.state !== 0; - accountInfo.isFrozen = accountInfo.state === 2; - - if (accountInfo.isNativeOption === 1) { - accountInfo.rentExemptReserve = u64.fromBuffer(accountInfo.isNative); - accountInfo.isNative = true; - } else { - accountInfo.rentExemptReserve = null; - accountInfo.isNative = false; - } - - if (accountInfo.closeAuthorityOption === 0) { - accountInfo.closeAuthority = null; - } else { - accountInfo.closeAuthority = new PublicKey(accountInfo.closeAuthority); - } - - return accountInfo; -}; - -// TODO: expose in spl package -export const deserializeMint = (data: Buffer) => { - if (data.length !== MintLayout.span) { - throw new Error('Not a valid Mint'); - } - - const mintInfo = MintLayout.decode(data); - - if (mintInfo.mintAuthorityOption === 0) { - mintInfo.mintAuthority = null; - } else { - mintInfo.mintAuthority = new PublicKey(mintInfo.mintAuthority); - } - - mintInfo.supply = u64.fromBuffer(mintInfo.supply); - mintInfo.isInitialized = mintInfo.isInitialized !== 0; - - if (mintInfo.freezeAuthorityOption === 0) { - mintInfo.freezeAuthority = null; - } else { - mintInfo.freezeAuthority = new PublicKey(mintInfo.freezeAuthority); - } - - return mintInfo as MintInfo; -}; diff --git a/js/packages/common/src/contexts/connection.tsx b/js/packages/common/src/contexts/connection.tsx deleted file mode 100644 index 652f458fc94..00000000000 --- a/js/packages/common/src/contexts/connection.tsx +++ /dev/null @@ -1,684 +0,0 @@ -import { sleep, useLocalStorageState } from '../utils/utils'; -import { - Keypair, - BlockhashAndFeeCalculator, - clusterApiUrl, - Commitment, - Connection, - RpcResponseAndContext, - SignatureStatus, - SimulatedTransactionResponse, - Transaction, - TransactionInstruction, - TransactionSignature, -} from '@solana/web3.js'; -import React, { useContext, useEffect, useMemo, useState } from 'react'; -import { notify } from '../utils/notifications'; -import { ExplorerLink } from '../components/ExplorerLink'; -import { - TokenInfo, - TokenListProvider, - ENV as ChainId, -} from '@solana/spl-token-registry'; - -export type ENV = - | 'mainnet-beta' - | 'mainnet-beta (Solana)' - | 'mainnet-beta (Serum)' - | 'testnet' - | 'devnet' - | 'localnet' - | 'lending'; - -export const ENDPOINTS = [ - { - name: 'mainnet-beta' as ENV, - endpoint: 'https://api.metaplex.solana.com/', - ChainId: ChainId.MainnetBeta, - }, - { - name: 'mainnet-beta (Solana)' as ENV, - endpoint: 'https://api.mainnet-beta.solana.com', - ChainId: ChainId.MainnetBeta, - }, - { - name: 'mainnet-beta (Serum)' as ENV, - endpoint: 'https://solana-api.projectserum.com/', - ChainId: ChainId.MainnetBeta, - }, - { - name: 'testnet' as ENV, - endpoint: clusterApiUrl('testnet'), - ChainId: ChainId.Testnet, - }, - { - name: 'devnet' as ENV, - endpoint: clusterApiUrl('devnet'), - ChainId: ChainId.Devnet, - }, -]; - -const DEFAULT = ENDPOINTS[0].endpoint; - -interface ConnectionConfig { - connection: Connection; - endpoint: string; - env: ENV; - setEndpoint: (val: string) => void; - tokens: TokenInfo[]; - tokenMap: Map; -} - -const ConnectionContext = React.createContext({ - endpoint: DEFAULT, - setEndpoint: () => {}, - connection: new Connection(DEFAULT, 'recent'), - env: ENDPOINTS[0].name, - tokens: [], - tokenMap: new Map(), -}); - -export function ConnectionProvider({ children = undefined as any }) { - const [endpoint, setEndpoint] = useLocalStorageState( - 'connectionEndpoint', - ENDPOINTS[0].endpoint, - ); - - const connection = useMemo( - () => new Connection(endpoint, 'recent'), - [endpoint], - ); - - const env = - ENDPOINTS.find(end => end.endpoint === endpoint)?.name || ENDPOINTS[0].name; - - const [tokens, setTokens] = useState([]); - const [tokenMap, setTokenMap] = useState>(new Map()); - useEffect(() => { - // fetch token files - new TokenListProvider().resolve().then(container => { - const list = container - .excludeByTag('nft') - .filterByChainId( - ENDPOINTS.find(end => end.endpoint === endpoint)?.ChainId || - ChainId.MainnetBeta, - ) - .getList(); - - const knownMints = [...list].reduce((map, item) => { - map.set(item.address, item); - return map; - }, new Map()); - - setTokenMap(knownMints); - setTokens(list); - }); - }, [env]); - - // The websocket library solana/web3.js uses closes its websocket connection when the subscription list - // is empty after opening its first time, preventing subsequent subscriptions from receiving responses. - // This is a hack to prevent the list from every getting empty - useEffect(() => { - const id = connection.onAccountChange( - Keypair.generate().publicKey, - () => {}, - ); - return () => { - connection.removeAccountChangeListener(id); - }; - }, [connection]); - - useEffect(() => { - const id = connection.onSlotChange(() => null); - return () => { - connection.removeSlotChangeListener(id); - }; - }, [connection]); - - return ( - - {children} - - ); -} - -export function useConnection() { - return useContext(ConnectionContext).connection as Connection; -} - -export function useConnectionConfig() { - const context = useContext(ConnectionContext); - return { - endpoint: context.endpoint, - setEndpoint: context.setEndpoint, - env: context.env, - tokens: context.tokens, - tokenMap: context.tokenMap, - }; -} - -export const getErrorForTransaction = async ( - connection: Connection, - txid: string, -) => { - // wait for all confirmation before geting transaction - await connection.confirmTransaction(txid, 'max'); - - const tx = await connection.getParsedConfirmedTransaction(txid); - - const errors: string[] = []; - if (tx?.meta && tx.meta.logMessages) { - tx.meta.logMessages.forEach(log => { - const regex = /Error: (.*)/gm; - let m; - while ((m = regex.exec(log)) !== null) { - // This is necessary to avoid infinite loops with zero-width matches - if (m.index === regex.lastIndex) { - regex.lastIndex++; - } - - if (m.length > 1) { - errors.push(m[1]); - } - } - }); - } - - return errors; -}; - -export enum SequenceType { - Sequential, - Parallel, - StopOnFailure, -} - -export async function sendTransactionsWithManualRetry( - connection: Connection, - wallet: any, - instructions: TransactionInstruction[][], - signers: Keypair[][], -) { - let stopPoint = 0; - let tries = 0; - let lastInstructionsLength = null; - let toRemoveSigners: Record = {}; - instructions = instructions.filter((instr, i) => { - if (instr.length > 0) { - return true; - } else { - toRemoveSigners[i] = true; - return false; - } - }); - let filteredSigners = signers.filter((_, i) => !toRemoveSigners[i]); - - while (stopPoint < instructions.length && tries < 3) { - instructions = instructions.slice(stopPoint, instructions.length); - filteredSigners = filteredSigners.slice(stopPoint, filteredSigners.length); - - if (instructions.length === lastInstructionsLength) tries = tries + 1; - else tries = 0; - - try { - if (instructions.length === 1) { - await sendTransactionWithRetry( - connection, - wallet, - instructions[0], - filteredSigners[0], - 'single', - ); - stopPoint = 1; - } else { - stopPoint = await sendTransactions( - connection, - wallet, - instructions, - filteredSigners, - SequenceType.StopOnFailure, - 'single', - ); - } - } catch (e) { - console.error(e); - } - console.log( - 'Died on ', - stopPoint, - 'retrying from instruction', - instructions[stopPoint], - 'instructions length is', - instructions.length, - ); - lastInstructionsLength = instructions.length; - } -} - -export const sendTransactions = async ( - connection: Connection, - wallet: any, - instructionSet: TransactionInstruction[][], - signersSet: Keypair[][], - sequenceType: SequenceType = SequenceType.Parallel, - commitment: Commitment = 'singleGossip', - successCallback: (txid: string, ind: number) => void = (txid, ind) => {}, - failCallback: (reason: string, ind: number) => boolean = (txid, ind) => false, - block?: BlockhashAndFeeCalculator, -): Promise => { - const unsignedTxns: Transaction[] = []; - - if (!block) { - block = await connection.getRecentBlockhash(commitment); - } - - for (let i = 0; i < instructionSet.length; i++) { - const instructions = instructionSet[i]; - const signers = signersSet[i]; - - if (instructions.length === 0) { - continue; - } - - let transaction = new Transaction(); - instructions.forEach(instruction => transaction.add(instruction)); - transaction.recentBlockhash = block.blockhash; - transaction.setSigners( - // fee payed by the wallet owner - wallet.publicKey, - ...signers.map(s => s.publicKey), - ); - - if (signers.length > 0) { - transaction.partialSign(...signers); - } - - unsignedTxns.push(transaction); - } - - const signedTxns = await wallet.signAllTransactions(unsignedTxns); - - const pendingTxns: Promise<{ txid: string; slot: number }>[] = []; - - let breakEarlyObject = { breakEarly: false, i: 0 }; - console.log( - 'Signed txns length', - signedTxns.length, - 'vs handed in length', - instructionSet.length, - ); - for (let i = 0; i < signedTxns.length; i++) { - const signedTxnPromise = sendSignedTransaction({ - connection, - signedTransaction: signedTxns[i], - }); - - signedTxnPromise - .then(({ txid, slot }) => { - successCallback(txid, i); - }) - .catch(reason => { - failCallback(signedTxns[i], i); - if (sequenceType === SequenceType.StopOnFailure) { - breakEarlyObject.breakEarly = true; - breakEarlyObject.i = i; - } - }); - - if (sequenceType !== SequenceType.Parallel) { - try { - await signedTxnPromise; - } catch (e) { - console.log('Caught failure', e); - if (breakEarlyObject.breakEarly) { - console.log('Died on ', breakEarlyObject.i); - return breakEarlyObject.i; // Return the txn we failed on by index - } - } - } else { - pendingTxns.push(signedTxnPromise); - } - } - - if (sequenceType !== SequenceType.Parallel) { - await Promise.all(pendingTxns); - } - - return signedTxns.length; -}; - -export const sendTransaction = async ( - connection: Connection, - wallet: any, - instructions: TransactionInstruction[], - signers: Keypair[], - awaitConfirmation = true, - commitment: Commitment = 'singleGossip', - includesFeePayer: boolean = false, - block?: BlockhashAndFeeCalculator, -) => { - let transaction = new Transaction(); - instructions.forEach(instruction => transaction.add(instruction)); - transaction.recentBlockhash = ( - block || (await connection.getRecentBlockhash(commitment)) - ).blockhash; - - if (includesFeePayer) { - transaction.setSigners(...signers.map(s => s.publicKey)); - } else { - transaction.setSigners( - // fee payed by the wallet owner - wallet.publicKey, - ...signers.map(s => s.publicKey), - ); - } - - if (signers.length > 0) { - transaction.partialSign(...signers); - } - if (!includesFeePayer) { - transaction = await wallet.signTransaction(transaction); - } - - const rawTransaction = transaction.serialize(); - let options = { - skipPreflight: true, - commitment, - }; - - const txid = await connection.sendRawTransaction(rawTransaction, options); - let slot = 0; - - if (awaitConfirmation) { - const confirmation = await awaitTransactionSignatureConfirmation( - txid, - DEFAULT_TIMEOUT, - connection, - commitment, - ); - - if (!confirmation) - throw new Error('Timed out awaiting confirmation on transaction'); - slot = confirmation?.slot || 0; - - if (confirmation?.err) { - const errors = await getErrorForTransaction(connection, txid); - notify({ - message: 'Transaction failed...', - description: ( - <> - {errors.map(err => ( -
{err}
- ))} - - - ), - type: 'error', - }); - - throw new Error( - `Raw transaction ${txid} failed (${JSON.stringify(status)})`, - ); - } - } - - return { txid, slot }; -}; - -export const sendTransactionWithRetry = async ( - connection: Connection, - wallet: any, - instructions: TransactionInstruction[], - signers: Keypair[], - commitment: Commitment = 'singleGossip', - includesFeePayer: boolean = false, - block?: BlockhashAndFeeCalculator, - beforeSend?: () => void, -) => { - let transaction = new Transaction(); - instructions.forEach(instruction => transaction.add(instruction)); - transaction.recentBlockhash = ( - block || (await connection.getRecentBlockhash(commitment)) - ).blockhash; - - if (includesFeePayer) { - transaction.setSigners(...signers.map(s => s.publicKey)); - } else { - transaction.setSigners( - // fee payed by the wallet owner - wallet.publicKey, - ...signers.map(s => s.publicKey), - ); - } - - if (signers.length > 0) { - transaction.partialSign(...signers); - } - if (!includesFeePayer) { - transaction = await wallet.signTransaction(transaction); - } - - if (beforeSend) { - beforeSend(); - } - - const { txid, slot } = await sendSignedTransaction({ - connection, - signedTransaction: transaction, - }); - - return { txid, slot }; -}; - -export const getUnixTs = () => { - return new Date().getTime() / 1000; -}; - -const DEFAULT_TIMEOUT = 15000; - -export async function sendSignedTransaction({ - signedTransaction, - connection, - timeout = DEFAULT_TIMEOUT, -}: { - signedTransaction: Transaction; - connection: Connection; - sendingMessage?: string; - sentMessage?: string; - successMessage?: string; - timeout?: number; -}): Promise<{ txid: string; slot: number }> { - const rawTransaction = signedTransaction.serialize(); - const startTime = getUnixTs(); - let slot = 0; - const txid: TransactionSignature = await connection.sendRawTransaction( - rawTransaction, - { - skipPreflight: true, - }, - ); - - console.log('Started awaiting confirmation for', txid); - - let done = false; - (async () => { - while (!done && getUnixTs() - startTime < timeout) { - connection.sendRawTransaction(rawTransaction, { - skipPreflight: true, - }); - await sleep(500); - } - })(); - try { - const confirmation = await awaitTransactionSignatureConfirmation( - txid, - timeout, - connection, - 'recent', - true, - ); - - if (!confirmation) - throw new Error('Timed out awaiting confirmation on transaction'); - - if (confirmation.err) { - console.error(confirmation.err); - throw new Error('Transaction failed: Custom instruction error'); - } - - slot = confirmation?.slot || 0; - } catch (err) { - console.error('Timeout Error caught', err); - if (err.timeout) { - throw new Error('Timed out awaiting confirmation on transaction'); - } - let simulateResult: SimulatedTransactionResponse | null = null; - try { - simulateResult = ( - await simulateTransaction(connection, signedTransaction, 'single') - ).value; - } catch (e) {} - if (simulateResult && simulateResult.err) { - if (simulateResult.logs) { - for (let i = simulateResult.logs.length - 1; i >= 0; --i) { - const line = simulateResult.logs[i]; - if (line.startsWith('Program log: ')) { - throw new Error( - 'Transaction failed: ' + line.slice('Program log: '.length), - ); - } - } - } - throw new Error(JSON.stringify(simulateResult.err)); - } - // throw new Error('Transaction failed'); - } finally { - done = true; - } - - console.log('Latency', txid, getUnixTs() - startTime); - return { txid, slot }; -} - -async function simulateTransaction( - connection: Connection, - transaction: Transaction, - commitment: Commitment, -): Promise> { - // @ts-ignore - transaction.recentBlockhash = await connection._recentBlockhash( - // @ts-ignore - connection._disableBlockhashCaching, - ); - - const signData = transaction.serializeMessage(); - // @ts-ignore - const wireTransaction = transaction._serialize(signData); - const encodedTransaction = wireTransaction.toString('base64'); - const config: any = { encoding: 'base64', commitment }; - const args = [encodedTransaction, config]; - - // @ts-ignore - const res = await connection._rpcRequest('simulateTransaction', args); - if (res.error) { - throw new Error('failed to simulate transaction: ' + res.error.message); - } - return res.result; -} - -async function awaitTransactionSignatureConfirmation( - txid: TransactionSignature, - timeout: number, - connection: Connection, - commitment: Commitment = 'recent', - queryStatus = false, -): Promise { - let done = false; - let status: SignatureStatus | null | void = { - slot: 0, - confirmations: 0, - err: null, - }; - let subId = 0; - status = await new Promise(async (resolve, reject) => { - setTimeout(() => { - if (done) { - return; - } - done = true; - console.log('Rejecting for timeout...'); - reject({ timeout: true }); - }, timeout); - try { - subId = connection.onSignature( - txid, - (result, context) => { - done = true; - status = { - err: result.err, - slot: context.slot, - confirmations: 0, - }; - if (result.err) { - console.log('Rejected via websocket', result.err); - reject(status); - } else { - console.log('Resolved via websocket', result); - resolve(status); - } - }, - commitment, - ); - } catch (e) { - done = true; - console.error('WS error in setup', txid, e); - } - while (!done && queryStatus) { - // eslint-disable-next-line no-loop-func - (async () => { - try { - const signatureStatuses = await connection.getSignatureStatuses([ - txid, - ]); - status = signatureStatuses && signatureStatuses.value[0]; - if (!done) { - if (!status) { - console.log('REST null result for', txid, status); - } else if (status.err) { - console.log('REST error for', txid, status); - done = true; - reject(status.err); - } else if (!status.confirmations) { - console.log('REST no confirmations for', txid, status); - } else { - console.log('REST confirmation for', txid, status); - done = true; - resolve(status); - } - } - } catch (e) { - if (!done) { - console.log('REST connection error: txid', txid, e); - } - } - })(); - await sleep(2000); - } - }); - - //@ts-ignore - if (connection._signatureSubscriptions[subId]) - connection.removeSignatureListener(subId); - done = true; - console.log('Returning status', status); - return status; -} diff --git a/js/packages/common/src/contexts/index.tsx b/js/packages/common/src/contexts/index.tsx deleted file mode 100644 index b3561315517..00000000000 --- a/js/packages/common/src/contexts/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -export * as Accounts from './accounts'; -export * as Connection from './connection'; -export * as Wallet from './wallet'; -export { ParsedAccount, ParsedAccountBase } from './accounts'; - -export * from './accounts'; -export * from './wallet'; -export * from './connection'; -export * from './store'; diff --git a/js/packages/common/src/contexts/store.tsx b/js/packages/common/src/contexts/store.tsx deleted file mode 100644 index 2649120b8a0..00000000000 --- a/js/packages/common/src/contexts/store.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React, { - createContext, - FC, - useState, - useContext, - useEffect, - useMemo, -} from 'react'; -import { getStoreID, setProgramIds, StringPublicKey } from '../utils'; -import { useQuerySearch } from '../hooks'; - -interface StoreConfig { - // Store Address - storeAddress?: StringPublicKey; - // Store was configured via ENV or query params - isConfigured: boolean; - // Initial calculating of store address completed (successfully or not) - isReady: boolean; - // recalculate store address for specified owner address - setStoreForOwner: (ownerAddress?: string) => Promise; -} - -export const StoreContext = createContext(null!); - -export const StoreProvider: FC<{ - ownerAddress?: string; - storeAddress?: string; -}> = ({ children, ownerAddress, storeAddress }) => { - const searchParams = useQuerySearch(); - const ownerAddressFromQuery = searchParams.get('store'); - - const initOwnerAddress = ownerAddressFromQuery || ownerAddress; - const initStoreAddress = !ownerAddressFromQuery ? storeAddress : undefined; - const isConfigured = Boolean(initStoreAddress || initOwnerAddress); - - const [store, setStore] = useState< - Pick - >({ - storeAddress: initStoreAddress, - isReady: Boolean(!initOwnerAddress || initStoreAddress), - }); - - const setStoreForOwner = useMemo( - () => async (ownerAddress?: string) => { - const storeAddress = await getStoreID(ownerAddress); - setProgramIds(storeAddress); // fallback - setStore({ storeAddress, isReady: true }); - console.log(`CUSTOM STORE: ${storeAddress}`); - return storeAddress; - }, - [], - ); - - useEffect(() => { - console.log(`STORE_OWNER_ADDRESS: ${initOwnerAddress}`); - if (initOwnerAddress && !initStoreAddress) { - setStoreForOwner(initOwnerAddress); - } else { - setProgramIds(initStoreAddress); // fallback - console.log(`CUSTOM STORE FROM ENV: ${initStoreAddress}`); - } - }, [initOwnerAddress]); - - return ( - - {children} - - ); -}; - -export const useStore = () => { - return useContext(StoreContext); -}; diff --git a/js/packages/common/src/contexts/wallet.less b/js/packages/common/src/contexts/wallet.less deleted file mode 100644 index cd085414d24..00000000000 --- a/js/packages/common/src/contexts/wallet.less +++ /dev/null @@ -1,6 +0,0 @@ -p { - color: #6d6d6d; - font-family: Inter, sans-serif; - font-style: normal; - font-size: 0.9rem; -} diff --git a/js/packages/common/src/contexts/wallet.tsx b/js/packages/common/src/contexts/wallet.tsx deleted file mode 100644 index 9282f46dfd1..00000000000 --- a/js/packages/common/src/contexts/wallet.tsx +++ /dev/null @@ -1,277 +0,0 @@ -import { WalletAdapter } from '@solana/wallet-base'; - -import Wallet from '@project-serum/sol-wallet-adapter'; -import { Button } from 'antd'; -import React, { - useCallback, - useContext, - useEffect, - useMemo, - useState, -} from 'react'; -import { notify } from './../utils/notifications'; -import { useConnectionConfig } from './connection'; -import { useLocalStorageState } from '../utils/utils'; -import { PhantomWalletAdapter } from '../wallet-adapters/phantom'; -import { useLocation } from 'react-router'; -import { MetaplexModal } from '../components/MetaplexModal'; -import { TorusWalletAdapter } from '../wallet-adapters/torus'; -import { SolflareWalletAdapter } from '../wallet-adapters/solflare'; - -const ASSETS_URL = - 'https://raw.githubusercontent.com/solana-labs/oyster/main/assets/wallets/'; -export const WALLET_PROVIDERS = [ - { - name: 'Phantom', - url: 'https://www.phantom.app', - icon: `https://www.phantom.app/img/logo.png`, - adapter: PhantomWalletAdapter, - }, - { - name: 'Solflare', - url: 'https://solflare.com', - icon: `${ASSETS_URL}solflare.svg`, - adapter: SolflareWalletAdapter, - }, - { - name: 'Sollet', - url: 'https://www.sollet.io', - icon: `${ASSETS_URL}sollet.svg`, - }, - { - name: 'MathWallet', - url: 'https://mathwallet.org', - icon: `${ASSETS_URL}mathwallet.svg`, - }, - { - name: 'Torus', - url: 'https://tor.us', - icon: `${ASSETS_URL}torus.svg`, - adapter: TorusWalletAdapter, - }, -]; - -const WalletContext = React.createContext<{ - wallet: WalletAdapter | undefined; - connected: boolean; - select: () => void; - provider: typeof WALLET_PROVIDERS[number] | undefined; -}>({ - wallet: undefined, - connected: false, - select() {}, - provider: undefined, -}); - -export function WalletProvider({ children = null as any }) { - const { endpoint } = useConnectionConfig(); - const location = useLocation(); - const [autoConnect, setAutoConnect] = useState( - location.pathname.indexOf('result=') >= 0 || false, - ); - const [providerUrl, setProviderUrl] = useLocalStorageState('walletProvider'); - - const provider = useMemo( - () => WALLET_PROVIDERS.find(({ url }) => url === providerUrl), - [providerUrl], - ); - - const wallet = useMemo( - function () { - if (provider) { - return new (provider.adapter || Wallet)( - providerUrl, - endpoint, - ) as WalletAdapter; - } - }, - [provider, providerUrl, endpoint], - ); - - const [connected, setConnected] = useState(false); - - useEffect(() => { - if (wallet?.publicKey && connected) { - const walletPublicKey = wallet.publicKey.toBase58(); - const keyToDisplay = - walletPublicKey.length > 20 - ? `${walletPublicKey.substring(0, 7)}.....${walletPublicKey.substring( - walletPublicKey.length - 7, - walletPublicKey.length, - )}` - : walletPublicKey; - notify({ - message: 'Wallet update', - description: 'Connected to wallet ' + keyToDisplay, - }); - } - }, [connected]); - - useEffect(() => { - if (wallet) { - wallet.on('connect', () => { - if (wallet.publicKey) { - setConnected(true); - } - }); - - wallet.on('disconnect', () => { - setConnected(false); - notify({ - message: 'Wallet update', - description: 'Disconnected from wallet', - }); - }); - } - - return () => { - setConnected(false); - if (wallet) { - wallet.disconnect(); - } - }; - }, [wallet]); - - useEffect(() => { - if (wallet && autoConnect) { - wallet.connect(); - setAutoConnect(false); - } - - return () => {}; - }, [wallet, autoConnect]); - - const [isModalVisible, setIsModalVisible] = useState(false); - const [showProviders, setShowProviders] = useState(false); - - const select = useCallback(() => setIsModalVisible(true), []); - const close = useCallback(() => { - setIsModalVisible(false); - setShowProviders(false); - }, []); - - const pp = WALLET_PROVIDERS.find(wp => wp.name === 'Phantom'); - - return ( - - {children} - -
- M -
- -

{provider ? 'Change provider' : 'Welcome to Metaplex'}

-

- {provider - ? 'Feel free to switch wallet provider' - : 'You must be signed in to place a bid'} -

- -
- - {provider || showProviders ? ( - <> - {WALLET_PROVIDERS.map((provider, idx) => { - if (providerUrl === provider.url) return null; - - const onClick = function () { - setProviderUrl(provider.url); - setAutoConnect(true); - close(); - }; - return ( - - ); - })} - - ) : ( - <> - -

setShowProviders(true)} - style={{ cursor: 'pointer', marginTop: 10 }} - > - Select a different Solana wallet -

- - )} -
-
- ); -} - -export const useWallet = () => { - const { wallet, connected, provider, select } = useContext(WalletContext); - return { - wallet, - connected, - provider, - select, - connect() { - wallet ? wallet.connect() : select(); - }, - disconnect() { - wallet?.disconnect(); - }, - }; -}; diff --git a/js/packages/common/src/contracts/token.ts b/js/packages/common/src/contracts/token.ts deleted file mode 100644 index 9755a54099a..00000000000 --- a/js/packages/common/src/contracts/token.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { - MintLayout, - AccountLayout, - Token, - AuthorityType, -} from '@solana/spl-token'; -import { - Connection, - PublicKey, - Transaction, - Account, - SystemProgram, -} from '@solana/web3.js'; - -export const mintNFT = async ( - connection: Connection, - wallet: { - publicKey: PublicKey; - signTransaction: (tx: Transaction) => Transaction; - }, - // SOL account - owner: PublicKey, -) => { - const TOKEN_PROGRAM_ID = new PublicKey( - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - ); - const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - ); - const mintAccount = new Account(); - const tokenAccount = new Account(); - - // Allocate memory for the account - const mintRent = await connection.getMinimumBalanceForRentExemption( - MintLayout.span, - ); - - const accountRent = await connection.getMinimumBalanceForRentExemption( - AccountLayout.span, - ); - - let transaction = new Transaction(); - const signers = [mintAccount, tokenAccount]; - transaction.recentBlockhash = ( - await connection.getRecentBlockhash('max') - ).blockhash; - - transaction.add( - SystemProgram.createAccount({ - fromPubkey: wallet.publicKey, - newAccountPubkey: mintAccount.publicKey, - lamports: mintRent, - space: MintLayout.span, - programId: TOKEN_PROGRAM_ID, - }), - ); - - transaction.add( - SystemProgram.createAccount({ - fromPubkey: wallet.publicKey, - newAccountPubkey: tokenAccount.publicKey, - lamports: accountRent, - space: AccountLayout.span, - programId: TOKEN_PROGRAM_ID, - }), - ); - - transaction.add( - Token.createInitMintInstruction( - TOKEN_PROGRAM_ID, - mintAccount.publicKey, - 0, - wallet.publicKey, - wallet.publicKey, - ), - ); - transaction.add( - Token.createInitAccountInstruction( - TOKEN_PROGRAM_ID, - mintAccount.publicKey, - tokenAccount.publicKey, - owner, - ), - ); - transaction.add( - Token.createMintToInstruction( - TOKEN_PROGRAM_ID, - mintAccount.publicKey, - tokenAccount.publicKey, - wallet.publicKey, - [], - 1, - ), - ); - transaction.add( - Token.createSetAuthorityInstruction( - TOKEN_PROGRAM_ID, - mintAccount.publicKey, - null, - 'MintTokens', - wallet.publicKey, - [], - ), - ); - - transaction.setSigners(wallet.publicKey, ...signers.map(s => s.publicKey)); - if (signers.length > 0) { - transaction.partialSign(...signers); - } - transaction = await wallet.signTransaction(transaction); - const rawTransaction = transaction.serialize(); - let options = { - skipPreflight: true, - commitment: 'singleGossip', - }; - - const txid = await connection.sendRawTransaction(rawTransaction, options); - - return { txid, mint: mintAccount.publicKey, account: tokenAccount.publicKey }; -}; diff --git a/js/packages/common/src/hooks/index.ts b/js/packages/common/src/hooks/index.ts deleted file mode 100644 index 9cdf818d648..00000000000 --- a/js/packages/common/src/hooks/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './useUserAccounts'; -export * from './useAccountByMint'; -export * from './useTokenName'; -export * from './useThatState'; -export * from './useQuerySearch'; diff --git a/js/packages/common/src/hooks/useAccountByMint.ts b/js/packages/common/src/hooks/useAccountByMint.ts deleted file mode 100644 index 0271d9439a5..00000000000 --- a/js/packages/common/src/hooks/useAccountByMint.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { PublicKey } from '@solana/web3.js'; -import { useUserAccounts } from '../hooks/useUserAccounts'; - -export const useAccountByMint = (mint?: string | PublicKey) => { - const { userAccounts } = useUserAccounts(); - const mintAddress = typeof mint === 'string' ? mint : mint?.toBase58(); - - const index = userAccounts.findIndex( - acc => acc.info.mint.toBase58() === mintAddress, - ); - - if (index !== -1) { - return userAccounts[index]; - } - - return; -}; diff --git a/js/packages/common/src/hooks/useQuerySearch.ts b/js/packages/common/src/hooks/useQuerySearch.ts deleted file mode 100644 index 7fa6f85e170..00000000000 --- a/js/packages/common/src/hooks/useQuerySearch.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { useLocation } from 'react-router-dom'; - -export function useQuerySearch() { - return new URLSearchParams(useLocation().search); -} diff --git a/js/packages/common/src/hooks/useThatState.ts b/js/packages/common/src/hooks/useThatState.ts deleted file mode 100644 index 86ecf10df29..00000000000 --- a/js/packages/common/src/hooks/useThatState.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useState } from 'react'; - -// Extends useState() hook with async getThatState getter which can be used to get state value in contexts (ex. async callbacks) where up to date state is not available -export function useThatState(initialState: T) { - const [state, setState] = useState(initialState); - const getThatState = () => - new Promise(resolve => { - // Use NOP setState call to retrieve current state value - setState(s => { - resolve(s); - return s; - }); - }); - - return [state, setState, getThatState] as const; -} diff --git a/js/packages/common/src/hooks/useTokenName.ts b/js/packages/common/src/hooks/useTokenName.ts deleted file mode 100644 index b4a6b60a1de..00000000000 --- a/js/packages/common/src/hooks/useTokenName.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PublicKey } from '@solana/web3.js'; -import { useConnectionConfig } from '../contexts/connection'; -import { getTokenName } from '../utils/utils'; - -export function useTokenName(mintAddress?: string | PublicKey) { - const { tokenMap } = useConnectionConfig(); - const address = - typeof mintAddress === 'string' ? mintAddress : mintAddress?.toBase58(); - return getTokenName(tokenMap, address); -} diff --git a/js/packages/common/src/hooks/useUserAccounts.ts b/js/packages/common/src/hooks/useUserAccounts.ts deleted file mode 100644 index 43bacbf54a3..00000000000 --- a/js/packages/common/src/hooks/useUserAccounts.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { TokenAccount } from '../models'; -import { useAccountsContext } from '../contexts/accounts'; - -export function useUserAccounts(): { - userAccounts: TokenAccount[]; - accountByMint: Map; -} { - const context = useAccountsContext(); - - const accountByMint = context.userAccounts.reduce( - (prev: Map, acc: TokenAccount) => { - prev.set(acc.info.mint.toBase58(), acc); - return prev; - }, - new Map(), - ); - return { - userAccounts: context.userAccounts as TokenAccount[], - accountByMint, - }; -} diff --git a/js/packages/common/src/index.tsx b/js/packages/common/src/index.tsx deleted file mode 100644 index d0985cef696..00000000000 --- a/js/packages/common/src/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -export * as actions from './actions'; -export * from './actions'; -export * as components from './components'; -export * from './components'; // Allow direct exports too -export * as constants from './constants'; -export * as hooks from './hooks'; -export * from './hooks'; -export * as contexts from './contexts'; -export * from './contexts'; -export * as models from './models'; -export * as utils from './utils'; -export * from './utils'; -export * as walletAdapters from './wallet-adapters'; - -export { TokenAccount } from './models'; -export { ParsedAccount, ParsedAccountBase } from './contexts'; -export { KnownTokenMap, EventEmitter, Layout } from './utils'; diff --git a/js/packages/common/src/models/account.ts b/js/packages/common/src/models/account.ts deleted file mode 100644 index 8e39274d013..00000000000 --- a/js/packages/common/src/models/account.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { - AccountInfo, - Keypair, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; - -import { AccountInfo as TokenAccountInfo, Token } from '@solana/spl-token'; -import { TOKEN_PROGRAM_ID } from '../utils/ids'; -import BufferLayout from 'buffer-layout'; - -export interface TokenAccount { - pubkey: string; - account: AccountInfo; - info: TokenAccountInfo; -} - -export interface ParsedDataAccount { - amount: number; - rawAmount: string; - parsedAssetAddress: string; - parsedAccount: any; - assetDecimals: number; - assetIcon: any; - name: string; - symbol: string; - sourceAddress: string; - targetAddress: string; -} - -export const ParsedDataLayout = BufferLayout.struct([ - BufferLayout.blob(32, 'amount'), - BufferLayout.u8('toChain'), - BufferLayout.blob(32, 'sourceAddress'), - BufferLayout.blob(32, 'targetAddress'), - BufferLayout.blob(32, 'assetAddress'), - BufferLayout.u8('assetChain'), - BufferLayout.u8('assetDecimals'), - BufferLayout.seq(BufferLayout.u8(), 1), // 4 byte alignment because a u32 is following - BufferLayout.u32('nonce'), - BufferLayout.blob(1001, 'vaa'), - BufferLayout.seq(BufferLayout.u8(), 3), // 4 byte alignment because a u32 is following - BufferLayout.u32('vaaTime'), - BufferLayout.u32('lockupTime'), - BufferLayout.u8('pokeCounter'), - BufferLayout.blob(32, 'signatureAccount'), - BufferLayout.u8('initialized'), -]); - -export function approve( - instructions: TransactionInstruction[], - cleanupInstructions: TransactionInstruction[], - account: PublicKey, - owner: PublicKey, - amount: number, - autoRevoke = true, - - // if delegate is not passed ephemeral transfer authority is used - delegate?: PublicKey, - existingTransferAuthority?: Keypair, -): Keypair { - const tokenProgram = TOKEN_PROGRAM_ID; - - const transferAuthority = existingTransferAuthority || Keypair.generate(); - const delegateKey = delegate ?? transferAuthority.publicKey; - - instructions.push( - Token.createApproveInstruction( - tokenProgram, - account, - delegate ?? transferAuthority.publicKey, - owner, - [], - amount, - ), - ); - - if (autoRevoke) { - cleanupInstructions.push( - Token.createRevokeInstruction(tokenProgram, account, owner, []), - ); - } - - return transferAuthority; -} diff --git a/js/packages/common/src/models/index.ts b/js/packages/common/src/models/index.ts deleted file mode 100644 index 362a768e537..00000000000 --- a/js/packages/common/src/models/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './account'; diff --git a/js/packages/common/src/styles.less b/js/packages/common/src/styles.less deleted file mode 100644 index d0e235ef7e9..00000000000 --- a/js/packages/common/src/styles.less +++ /dev/null @@ -1,6 +0,0 @@ -@import './contexts/wallet.less'; -@import './components/AppBar/style.less'; -@import './components/ActionConfirmation/style.less'; -@import './components/Identicon/style.less'; -@import './components/MetaplexModal/index.less'; -@import './components/CurrentUserBadge/styles.less'; diff --git a/js/packages/common/src/types/buffer-layout.d.ts b/js/packages/common/src/types/buffer-layout.d.ts deleted file mode 100644 index 32e44d0edee..00000000000 --- a/js/packages/common/src/types/buffer-layout.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module 'buffer-layout' { - const bl: any; - export = bl; -} - -declare module 'jazzicon' { - const jazzicon: any; - export = jazzicon; -} diff --git a/js/packages/common/src/types/sol-wallet-adapter.d.ts b/js/packages/common/src/types/sol-wallet-adapter.d.ts deleted file mode 100644 index 41acf5df4f8..00000000000 --- a/js/packages/common/src/types/sol-wallet-adapter.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '@project-serum/sol-wallet-adapter' { - const adapter: any; - export = adapter; -} diff --git a/js/packages/common/src/types/u64.d.ts b/js/packages/common/src/types/u64.d.ts deleted file mode 100644 index 6c349cfa95c..00000000000 --- a/js/packages/common/src/types/u64.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import BN from 'bn.js'; - -export class u64 extends BN { - toBuffer(): Buffer; - static fromBuffer(buffer: Buffer): u64; -} diff --git a/js/packages/common/src/utils/borsh.ts b/js/packages/common/src/utils/borsh.ts deleted file mode 100644 index 2e540ccb309..00000000000 --- a/js/packages/common/src/utils/borsh.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PublicKey } from '@solana/web3.js'; -import { BinaryReader, BinaryWriter } from 'borsh'; -import base58 from 'bs58'; -import { StringPublicKey } from './ids'; - -export const extendBorsh = () => { - (BinaryReader.prototype as any).readPubkey = function () { - const reader = this as unknown as BinaryReader; - const array = reader.readFixedArray(32); - return new PublicKey(array); - }; - - (BinaryWriter.prototype as any).writePubkey = function (value: PublicKey) { - const writer = this as unknown as BinaryWriter; - writer.writeFixedArray(value.toBuffer()); - }; - - (BinaryReader.prototype as any).readPubkeyAsString = function () { - const reader = this as unknown as BinaryReader; - const array = reader.readFixedArray(32); - return base58.encode(array) as StringPublicKey; - }; - - (BinaryWriter.prototype as any).writePubkeyAsString = function ( - value: StringPublicKey, - ) { - const writer = this as unknown as BinaryWriter; - writer.writeFixedArray(base58.decode(value)); - }; -}; - -extendBorsh(); diff --git a/js/packages/common/src/utils/eventEmitter.ts b/js/packages/common/src/utils/eventEmitter.ts deleted file mode 100644 index 6d111ce8fc9..00000000000 --- a/js/packages/common/src/utils/eventEmitter.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { EventEmitter as Emitter } from 'eventemitter3'; - -export class CacheUpdateEvent { - static type = 'CacheUpdate'; - id: string; - parser: any; - isNew: boolean; - isActive: boolean; - constructor(id: string, isNew: boolean, parser: any, isActive: boolean) { - this.id = id; - this.parser = parser; - this.isNew = isNew; - this.isActive = isActive; - } -} - -export class CacheDeleteEvent { - static type = 'CacheUpdate'; - id: string; - constructor(id: string) { - this.id = id; - } -} - -export class MarketUpdateEvent { - static type = 'MarketUpdate'; - ids: Set; - constructor(ids: Set) { - this.ids = ids; - } -} - -export class EventEmitter { - private emitter = new Emitter(); - - onMarket(callback: (args: MarketUpdateEvent) => void) { - this.emitter.on(MarketUpdateEvent.type, callback); - - return () => this.emitter.removeListener(MarketUpdateEvent.type, callback); - } - - onCache(callback: (args: CacheUpdateEvent) => void) { - this.emitter.on(CacheUpdateEvent.type, callback); - - return () => this.emitter.removeListener(CacheUpdateEvent.type, callback); - } - - raiseMarketUpdated(ids: Set) { - this.emitter.emit(MarketUpdateEvent.type, new MarketUpdateEvent(ids)); - } - - raiseCacheUpdated( - id: string, - isNew: boolean, - parser: any, - isActive: boolean, - ) { - this.emitter.emit( - CacheUpdateEvent.type, - new CacheUpdateEvent(id, isNew, parser, isActive), - ); - } - - raiseCacheDeleted(id: string) { - this.emitter.emit(CacheDeleteEvent.type, new CacheDeleteEvent(id)); - } -} diff --git a/js/packages/common/src/utils/ids.ts b/js/packages/common/src/utils/ids.ts deleted file mode 100644 index 8b365166ae2..00000000000 --- a/js/packages/common/src/utils/ids.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { PublicKey, AccountInfo, Account } from '@solana/web3.js'; - -export type StringPublicKey = string; - -export class LazyAccountInfoProxy { - executable: boolean = false; - owner: StringPublicKey = ''; - lamports: number = 0; - - get data() { - // - return undefined as unknown as T; - } -} - -export interface LazyAccountInfo { - executable: boolean; - owner: StringPublicKey; - lamports: number; - data: [string, string]; -} - -const PubKeysInternedMap = new Map(); - -export const toPublicKey = (key: string | PublicKey) => { - if (typeof key !== 'string') { - return key; - } - - let result = PubKeysInternedMap.get(key); - if (!result) { - result = new PublicKey(key); - PubKeysInternedMap.set(key, result); - } - - return result; -}; - -export interface PublicKeyStringAndAccount { - pubkey: string; - account: AccountInfo; -} - -export const WRAPPED_SOL_MINT = new PublicKey( - 'So11111111111111111111111111111111111111112', -); - -export const TOKEN_PROGRAM_ID = new PublicKey( - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', -); - -export const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', -); - -export const BPF_UPGRADE_LOADER_ID = new PublicKey( - 'BPFLoaderUpgradeab1e11111111111111111111111', -); - -export const MEMO_ID = new PublicKey( - 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr', -); - -export const METADATA_PROGRAM_ID = - 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' as StringPublicKey; - -export const VAULT_ID = - 'vau1zxA2LbssAUEF7Gpw91zMM1LvXrvpzJtmZ58rPsn' as StringPublicKey; - -export const AUCTION_ID = - 'auctxRXPeJoc4817jDhf4HbjnhEcr1cCXenosMhK5R8' as StringPublicKey; - -export const METAPLEX_ID = - 'p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98' as StringPublicKey; - -export const SYSTEM = new PublicKey('11111111111111111111111111111111'); diff --git a/js/packages/common/src/utils/index.tsx b/js/packages/common/src/utils/index.tsx deleted file mode 100644 index 82a9c93d390..00000000000 --- a/js/packages/common/src/utils/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -export * from './eventEmitter'; -export * from './ids'; -export * from './programIds'; -export * as Layout from './layout'; -export * from './notifications'; -export * from './utils'; -export * from './strings'; -export * as shortvec from './shortvec'; -export * from './borsh'; diff --git a/js/packages/common/src/utils/layout.ts b/js/packages/common/src/utils/layout.ts deleted file mode 100644 index 38931a471b1..00000000000 --- a/js/packages/common/src/utils/layout.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { PublicKey } from '@solana/web3.js'; -import BN from 'bn.js'; -import * as BufferLayout from 'buffer-layout'; - -/** - * Layout for a public key - */ -export const publicKey = (property = 'publicKey'): unknown => { - const publicKeyLayout = BufferLayout.blob(32, property); - - const _decode = publicKeyLayout.decode.bind(publicKeyLayout); - const _encode = publicKeyLayout.encode.bind(publicKeyLayout); - - publicKeyLayout.decode = (buffer: Buffer, offset: number) => { - const data = _decode(buffer, offset); - return new PublicKey(data); - }; - - publicKeyLayout.encode = (key: PublicKey, buffer: Buffer, offset: number) => { - return _encode(key.toBuffer(), buffer, offset); - }; - - return publicKeyLayout; -}; - -/** - * Layout for a 64bit unsigned value - */ -export const uint64 = (property = 'uint64'): unknown => { - const layout = BufferLayout.blob(8, property); - - const _decode = layout.decode.bind(layout); - const _encode = layout.encode.bind(layout); - - layout.decode = (buffer: Buffer, offset: number) => { - const data = _decode(buffer, offset); - return new BN( - [...data] - .reverse() - .map(i => `00${i.toString(16)}`.slice(-2)) - .join(''), - 16, - ); - }; - - layout.encode = (num: BN, buffer: Buffer, offset: number) => { - const a = num.toArray().reverse(); - let b = Buffer.from(a); - if (b.length !== 8) { - const zeroPad = Buffer.alloc(8); - b.copy(zeroPad); - b = zeroPad; - } - return _encode(b, buffer, offset); - }; - - return layout; -}; - -// TODO: wrap in BN (what about decimals?) -export const uint128 = (property = 'uint128'): unknown => { - const layout = BufferLayout.blob(16, property); - - const _decode = layout.decode.bind(layout); - const _encode = layout.encode.bind(layout); - - layout.decode = (buffer: Buffer, offset: number) => { - const data = _decode(buffer, offset); - return new BN( - [...data] - .reverse() - .map(i => `00${i.toString(16)}`.slice(-2)) - .join(''), - 16, - ); - }; - - layout.encode = (num: BN, buffer: Buffer, offset: number) => { - const a = num.toArray().reverse(); - let b = Buffer.from(a); - if (b.length !== 16) { - const zeroPad = Buffer.alloc(16); - b.copy(zeroPad); - b = zeroPad; - } - - return _encode(b, buffer, offset); - }; - - return layout; -}; - -/** - * Layout for a Rust String type - */ -export const rustString = (property = 'string'): unknown => { - const rsl = BufferLayout.struct( - [ - BufferLayout.u32('length'), - BufferLayout.u32('lengthPadding'), - BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars'), - ], - property, - ); - const _decode = rsl.decode.bind(rsl); - const _encode = rsl.encode.bind(rsl); - - rsl.decode = (buffer: Buffer, offset: number) => { - const data = _decode(buffer, offset); - return data.chars.toString('utf8'); - }; - - rsl.encode = (str: string, buffer: Buffer, offset: number) => { - const data = { - chars: Buffer.from(str, 'utf8'), - }; - return _encode(data, buffer, offset); - }; - - return rsl; -}; diff --git a/js/packages/common/src/utils/notifications.tsx b/js/packages/common/src/utils/notifications.tsx deleted file mode 100644 index ae1dc1586ec..00000000000 --- a/js/packages/common/src/utils/notifications.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from "react"; -import { notification } from "antd"; -// import Link from '../components/Link'; - -export function notify({ - message = "", - description = undefined as any, - txid = "", - type = "info", - placement = "bottomLeft", -}) { - if (txid) { - // - // View transaction {txid.slice(0, 8)}...{txid.slice(txid.length - 8)} - // - - description = <>; - } - (notification as any)[type]({ - message: {message}, - description: ( - {description} - ), - placement, - style: { - backgroundColor: "white", - }, - }); -} diff --git a/js/packages/common/src/utils/programIds.ts b/js/packages/common/src/utils/programIds.ts deleted file mode 100644 index 81b8f0637e7..00000000000 --- a/js/packages/common/src/utils/programIds.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { PublicKey } from '@solana/web3.js'; -import { findProgramAddress } from '../utils'; - -import { - METADATA_PROGRAM_ID, - TOKEN_PROGRAM_ID, - SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, - METAPLEX_ID, - BPF_UPGRADE_LOADER_ID, - SYSTEM, - MEMO_ID, - VAULT_ID, - AUCTION_ID, - toPublicKey, -} from './ids'; - -export const getStoreID = async (storeOwnerAddress?: string) => { - if (!storeOwnerAddress) { - return undefined; - } - - const programs = await findProgramAddress( - [ - Buffer.from('metaplex'), - toPublicKey(METAPLEX_ID).toBuffer(), - toPublicKey(storeOwnerAddress).toBuffer(), - ], - toPublicKey(METAPLEX_ID), - ); - const storeAddress = programs[0]; - - return storeAddress; -}; - -export const setProgramIds = async (store?: string) => { - STORE = store ? toPublicKey(store) : undefined; -}; - -let STORE: PublicKey | undefined; - -export const programIds = () => { - return { - token: TOKEN_PROGRAM_ID, - associatedToken: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, - bpf_upgrade_loader: BPF_UPGRADE_LOADER_ID, - system: SYSTEM, - metadata: METADATA_PROGRAM_ID, - memo: MEMO_ID, - vault: VAULT_ID, - auction: AUCTION_ID, - metaplex: METAPLEX_ID, - store: STORE, - }; -}; diff --git a/js/packages/common/src/utils/shortvec.ts b/js/packages/common/src/utils/shortvec.ts deleted file mode 100644 index 0acc0fc8421..00000000000 --- a/js/packages/common/src/utils/shortvec.ts +++ /dev/null @@ -1,30 +0,0 @@ -export function decodeLength(bytes: Array): number { - let len = 0; - let size = 0; - for (;;) { - let elem = bytes.shift(); - //@ts-ignore - len |= (elem & 0x7f) << (size * 7); - size += 1; - //@ts-ignore - if ((elem & 0x80) === 0) { - break; - } - } - return len; -} - -export function encodeLength(bytes: Array, len: number) { - let rem_len = len; - for (;;) { - let elem = rem_len & 0x7f; - rem_len >>= 7; - if (rem_len === 0) { - bytes.push(elem); - break; - } else { - elem |= 0x80; - bytes.push(elem); - } - } -} diff --git a/js/packages/common/src/utils/strings.ts b/js/packages/common/src/utils/strings.ts deleted file mode 100644 index 28a73568335..00000000000 --- a/js/packages/common/src/utils/strings.ts +++ /dev/null @@ -1,74 +0,0 @@ -// credit https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array -export function toUTF8Array(str: string) { - let utf8 = []; - for (let i = 0; i < str.length; i++) { - let charcode = str.charCodeAt(i); - if (charcode < 0x80) utf8.push(charcode); - else if (charcode < 0x800) { - utf8.push(0xc0 | (charcode >> 6), 0x80 | (charcode & 0x3f)); - } else if (charcode < 0xd800 || charcode >= 0xe000) { - utf8.push( - 0xe0 | (charcode >> 12), - 0x80 | ((charcode >> 6) & 0x3f), - 0x80 | (charcode & 0x3f), - ); - } - // surrogate pair - else { - i++; - // UTF-16 encodes 0x10000-0x10FFFF by - // subtracting 0x10000 and splitting the - // 20 bits of 0x0-0xFFFFF into two halves - charcode = - 0x10000 + (((charcode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff)); - utf8.push( - 0xf0 | (charcode >> 18), - 0x80 | ((charcode >> 12) & 0x3f), - 0x80 | ((charcode >> 6) & 0x3f), - 0x80 | (charcode & 0x3f), - ); - } - } - return utf8; -} - -//courtesy https://gist.github.com/joni/3760795 -export function fromUTF8Array(data: number[]) { - // array of bytes - let str = '', - i; - - for (i = 0; i < data.length; i++) { - const value = data[i]; - - if (value < 0x80) { - str += String.fromCharCode(value); - } else if (value > 0xbf && value < 0xe0) { - str += String.fromCharCode(((value & 0x1f) << 6) | (data[i + 1] & 0x3f)); - i += 1; - } else if (value > 0xdf && value < 0xf0) { - str += String.fromCharCode( - ((value & 0x0f) << 12) | - ((data[i + 1] & 0x3f) << 6) | - (data[i + 2] & 0x3f), - ); - i += 2; - } else { - // surrogate pair - const charCode = - (((value & 0x07) << 18) | - ((data[i + 1] & 0x3f) << 12) | - ((data[i + 2] & 0x3f) << 6) | - (data[i + 3] & 0x3f)) - - 0x010000; - - str += String.fromCharCode( - (charCode >> 10) | 0xd800, - (charCode & 0x03ff) | 0xdc00, - ); - i += 3; - } - } - - return str; -} diff --git a/js/packages/common/src/utils/utils.ts b/js/packages/common/src/utils/utils.ts deleted file mode 100644 index 2a4e308eb23..00000000000 --- a/js/packages/common/src/utils/utils.ts +++ /dev/null @@ -1,297 +0,0 @@ -import { useCallback, useState } from 'react'; -import { MintInfo } from '@solana/spl-token'; - -import { TokenAccount } from './../models'; -import { PublicKey } from '@solana/web3.js'; -import BN from 'bn.js'; -import { WAD, ZERO } from '../constants'; -import { TokenInfo } from '@solana/spl-token-registry'; - -export type KnownTokenMap = Map; - -export const formatPriceNumber = new Intl.NumberFormat('en-US', { - style: 'decimal', - minimumFractionDigits: 2, - maximumFractionDigits: 8, -}); - -export function useLocalStorageState(key: string, defaultState?: string) { - const [state, setState] = useState(() => { - // NOTE: Not sure if this is ok - const storedState = localStorage.getItem(key); - if (storedState) { - return JSON.parse(storedState); - } - return defaultState; - }); - - const setLocalStorageState = useCallback( - newState => { - const changed = state !== newState; - if (!changed) { - return; - } - setState(newState); - if (newState === null) { - localStorage.removeItem(key); - } else { - try { - localStorage.setItem(key, JSON.stringify(newState)); - } catch { - // ignore - } - } - }, - [state, key], - ); - - return [state, setLocalStorageState]; -} - -export const findProgramAddress = async ( - seeds: (Buffer | Uint8Array)[], - programId: PublicKey, -) => { - const key = - 'pda-' + - seeds.reduce((agg, item) => agg + item.toString('hex'), '') + - programId.toString(); - let cached = localStorage.getItem(key); - if (cached) { - const value = JSON.parse(cached); - - return [value.key, parseInt(value.nonce)] as [string, number]; - } - - const result = await PublicKey.findProgramAddress(seeds, programId); - - try { - localStorage.setItem( - key, - JSON.stringify({ - key: result[0].toBase58(), - nonce: result[1], - }), - ); - } catch { - // ignore - } - - return [result[0].toBase58(), result[1]] as [string, number]; -}; - -// shorten the checksummed version of the input address to have 4 characters at start and end -export function shortenAddress(address: string, chars = 4): string { - return `${address.slice(0, chars)}...${address.slice(-chars)}`; -} - -export function getTokenName( - map: KnownTokenMap, - mint?: string | PublicKey, - shorten = true, -): string { - const mintAddress = typeof mint === 'string' ? mint : mint?.toBase58(); - - if (!mintAddress) { - return 'N/A'; - } - - const knownSymbol = map.get(mintAddress)?.symbol; - if (knownSymbol) { - return knownSymbol; - } - - return shorten ? `${mintAddress.substring(0, 5)}...` : mintAddress; -} -export function getVerboseTokenName( - map: KnownTokenMap, - mint?: string | PublicKey, - shorten = true, -): string { - const mintAddress = typeof mint === 'string' ? mint : mint?.toBase58(); - - if (!mintAddress) { - return 'N/A'; - } - - const knownName = map.get(mintAddress)?.name; - if (knownName) { - return knownName; - } - - return shorten ? `${mintAddress.substring(0, 5)}...` : mintAddress; -} - -export function getTokenByName(tokenMap: KnownTokenMap, name: string) { - let token: TokenInfo | null = null; - for (const val of tokenMap.values()) { - if (val.symbol === name) { - token = val; - break; - } - } - return token; -} - -export function getTokenIcon( - map: KnownTokenMap, - mintAddress?: string | PublicKey, -): string | undefined { - const address = - typeof mintAddress === 'string' ? mintAddress : mintAddress?.toBase58(); - if (!address) { - return; - } - - return map.get(address)?.logoURI; -} - -export function isKnownMint(map: KnownTokenMap, mintAddress: string) { - return !!map.get(mintAddress); -} - -export const STABLE_COINS = new Set(['USDC', 'wUSDC', 'USDT']); - -export function chunks(array: T[], size: number): T[][] { - return Array.apply( - 0, - new Array(Math.ceil(array.length / size)), - ).map((_, index) => array.slice(index * size, (index + 1) * size)); -} - -export function toLamports( - account?: TokenAccount | number, - mint?: MintInfo, -): number { - if (!account) { - return 0; - } - - const amount = - typeof account === 'number' ? account : account.info.amount?.toNumber(); - - const precision = Math.pow(10, mint?.decimals || 0); - return Math.floor(amount * precision); -} - -export function wadToLamports(amount?: BN): BN { - return amount?.div(WAD) || ZERO; -} - -export function fromLamports( - account?: TokenAccount | number | BN, - mint?: MintInfo, - rate: number = 1.0, -): number { - if (!account) { - return 0; - } - - const amount = Math.floor( - typeof account === 'number' - ? account - : BN.isBN(account) - ? account.toNumber() - : account.info.amount.toNumber(), - ); - - const precision = Math.pow(10, mint?.decimals || 9); - return (amount / precision) * rate; -} - -export const tryParseKey = (key: string): PublicKey | null => { - try { - return new PublicKey(key); - } catch (error) { - return null; - } -}; - -var SI_SYMBOL = ['', 'k', 'M', 'G', 'T', 'P', 'E']; - -const abbreviateNumber = (number: number, precision: number) => { - let tier = (Math.log10(number) / 3) | 0; - let scaled = number; - let suffix = SI_SYMBOL[tier]; - if (tier !== 0) { - let scale = Math.pow(10, tier * 3); - scaled = number / scale; - } - - return scaled.toFixed(precision) + suffix; -}; - -export const formatAmount = ( - val: number, - precision: number = 2, - abbr: boolean = true, -) => (abbr ? abbreviateNumber(val, precision) : val.toFixed(precision)); - -export function formatTokenAmount( - account?: TokenAccount | number | BN, - mint?: MintInfo, - rate: number = 1.0, - prefix = '', - suffix = '', - precision = 2, - abbr = false, -): string { - if (!account) { - return ''; - } - - return `${[prefix]}${formatAmount( - fromLamports(account, mint, rate), - precision, - abbr, - )}${suffix}`; -} - -export const formatUSD = new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'USD', -}); - -const numberFormater = new Intl.NumberFormat('en-US', { - style: 'decimal', - minimumFractionDigits: 2, - maximumFractionDigits: 2, -}); - -export const formatNumber = { - format: (val?: number) => { - if (!val) { - return '--'; - } - - return numberFormater.format(val); - }, -}; - -export const formatPct = new Intl.NumberFormat('en-US', { - style: 'percent', - minimumFractionDigits: 2, - maximumFractionDigits: 2, -}); - -export function convert( - account?: TokenAccount | number, - mint?: MintInfo, - rate: number = 1.0, -): number { - if (!account) { - return 0; - } - - const amount = - typeof account === 'number' ? account : account.info.amount?.toNumber(); - - const precision = Math.pow(10, mint?.decimals || 0); - let result = (amount / precision) * rate; - - return result; -} - -export function sleep(ms: number): Promise { - return new Promise(resolve => setTimeout(resolve, ms)); -} diff --git a/js/packages/common/src/wallet-adapters/index.tsx b/js/packages/common/src/wallet-adapters/index.tsx deleted file mode 100644 index b1952ae7c39..00000000000 --- a/js/packages/common/src/wallet-adapters/index.tsx +++ /dev/null @@ -1,4 +0,0 @@ -export * from './solong'; -export * from './phantom'; -export * from './torus'; -export * as solong_adapter from './solong_adapter'; diff --git a/js/packages/common/src/wallet-adapters/phantom/index.tsx b/js/packages/common/src/wallet-adapters/phantom/index.tsx deleted file mode 100644 index 6618192f0a0..00000000000 --- a/js/packages/common/src/wallet-adapters/phantom/index.tsx +++ /dev/null @@ -1,108 +0,0 @@ -import EventEmitter from 'eventemitter3'; -import { PublicKey, Transaction } from '@solana/web3.js'; -import { notify } from '../../utils/notifications'; -import { WalletAdapter } from '@solana/wallet-base'; - -type PhantomEvent = 'disconnect' | 'connect'; -type PhantomRequestMethod = - | 'connect' - | 'disconnect' - | 'signTransaction' - | 'signAllTransactions'; - -interface PhantomProvider { - publicKey?: PublicKey; - isConnected?: boolean; - autoApprove?: boolean; - signTransaction: (transaction: Transaction) => Promise; - signAllTransactions: (transactions: Transaction[]) => Promise; - connect: () => Promise; - disconnect: () => Promise; - on: (event: PhantomEvent, handler: (args: any) => void) => void; - request: (method: PhantomRequestMethod, params: any) => Promise; -} - -export class PhantomWalletAdapter - extends EventEmitter - implements WalletAdapter { - _provider: PhantomProvider | undefined; - _cachedCorrectKey?: PublicKey; - constructor() { - super(); - this.connect = this.connect.bind(this); - } - - get connected() { - return this._provider?.isConnected || false; - } - - get autoApprove() { - return this._provider?.autoApprove || false; - } - - async signAllTransactions( - transactions: Transaction[], - ): Promise { - if (!this._provider) { - return transactions; - } - - return this._provider.signAllTransactions(transactions); - } - - get publicKey() { - // Due to weird phantom bug where their public key isnt quite like ours - if (!this._cachedCorrectKey && this._provider?.publicKey) - this._cachedCorrectKey = new PublicKey( - this._provider.publicKey.toBase58(), - ); - - return this._cachedCorrectKey || null; - } - - async signTransaction(transaction: Transaction) { - if (!this._provider) { - return transaction; - } - - return this._provider.signTransaction(transaction); - } - - connect = async () => { - if (this._provider) { - return; - } - - let provider: PhantomProvider; - if ((window as any)?.solana?.isPhantom) { - provider = (window as any).solana; - } else { - window.open('https://phantom.app/', '_blank'); - notify({ - message: 'Phantom Error', - description: 'Please install Phantom wallet from Chrome ', - }); - return; - } - - provider.on('connect', () => { - this._provider = provider; - this.emit('connect'); - }); - - if (!provider.isConnected) { - await provider.connect(); - } - - this._provider = provider; - this.emit('connect'); - }; - - disconnect() { - if (this._provider) { - this._provider.disconnect(); - this._provider = undefined; - this.emit('disconnect'); - } - } -} diff --git a/js/packages/common/src/wallet-adapters/solflare/index.tsx b/js/packages/common/src/wallet-adapters/solflare/index.tsx deleted file mode 100644 index 018bfabb958..00000000000 --- a/js/packages/common/src/wallet-adapters/solflare/index.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import EventEmitter from 'eventemitter3'; -import { PublicKey, Transaction } from '@solana/web3.js'; -import { notify } from '../../utils/notifications'; -import { WalletAdapter } from '@solana/wallet-base'; - -interface SolflareWalletEvents { - connect: (...args: unknown[]) => unknown; - disconnect: (...args: unknown[]) => unknown; -} - -interface SolflareWallet extends EventEmitter { - isSolflare?: boolean; - publicKey?: { toBuffer(): Buffer }; - isConnected: boolean; - autoApprove: boolean; - signTransaction: (transaction: Transaction) => Promise; - signAllTransactions: (transactions: Transaction[]) => Promise; - connect: () => Promise; - disconnect: () => Promise; -} - -interface SolflareWindow extends Window { - solflare?: SolflareWallet; -} - -declare const window: SolflareWindow; - -export class SolflareWalletAdapter - extends EventEmitter - implements WalletAdapter { - - _wallet: SolflareWallet | undefined; - _publicKey: PublicKey | undefined; - - constructor() { - super(); - this.connect = this.connect.bind(this); - } - - get connected() { - return !!this._wallet?.isConnected; - } - - get autoApprove() { - return !!this._wallet?.autoApprove; - } - - async signAllTransactions( - transactions: Transaction[], - ): Promise { - if (!this._wallet) { - return transactions; - } - - return this._wallet.signAllTransactions(transactions); - } - - get publicKey() { - if (!this._publicKey && this._wallet?.publicKey) - this._publicKey = new PublicKey( - this._wallet.publicKey.toBuffer(), - ); - - return this._publicKey || null; - } - - async signTransaction(transaction: Transaction) { - if (!this._wallet) { - return transaction; - } - - return this._wallet.signTransaction(transaction); - } - - connect = async () => { - if (this._wallet) { - return; - } - - let wallet: SolflareWallet; - if (window.solflare?.isSolflare) { - wallet = window.solflare; - } else { - window.open('https://solflare.com', '_blank'); - notify({ - message: 'Solflare Error', - description: 'Please install Solflare wallet', - }); - return; - } - - wallet.on('connect', () => { - this._wallet = wallet; - this.emit('connect'); - }); - - if (!wallet.isConnected) { - await wallet.connect(); - } - - this._wallet = wallet; - this.emit('connect'); - }; - - disconnect() { - if (this._wallet) { - this._wallet.disconnect(); - this._wallet = undefined; - this.emit('disconnect'); - } - } -} diff --git a/js/packages/common/src/wallet-adapters/solong/index.tsx b/js/packages/common/src/wallet-adapters/solong/index.tsx deleted file mode 100644 index 4f2bcc66a02..00000000000 --- a/js/packages/common/src/wallet-adapters/solong/index.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import EventEmitter from "eventemitter3"; -import {PublicKey, Transaction} from "@solana/web3.js"; -import { WalletAdapter } from "@solana/wallet-base"; -import { notify } from "../../utils/notifications"; - -export class SolongWalletAdapter extends EventEmitter implements WalletAdapter { - _publicKey: PublicKey | null; - _onProcess: boolean; - constructor() { - super(); - this._publicKey = null; - this._onProcess = false; - this.connect = this.connect.bind(this); - } - - get publicKey() { - return this._publicKey; - } - - async signTransaction(transaction: Transaction) { - return (window as any).solong.signTransaction(transaction); - } - - async signAllTransactions(transactions: Transaction[]) { - return transactions; - } - - connect() { - if (this._onProcess) { - return; - } - - if ((window as any).solong === undefined) { - notify({ - message: "Solong Error", - description: "Please install solong wallet from Chrome ", - }); - return; - } - - this._onProcess = true; - (window as any).solong - .selectAccount() - .then((account: any) => { - this._publicKey = new PublicKey(account); - this.emit("connect", this._publicKey); - }) - .catch(() => { - this.disconnect(); - }) - .finally(() => { - this._onProcess = false; - }); - } - - disconnect() { - if (this._publicKey) { - this._publicKey = null; - this.emit("disconnect"); - } - } -} diff --git a/js/packages/common/src/wallet-adapters/solong_adapter.tsx b/js/packages/common/src/wallet-adapters/solong_adapter.tsx deleted file mode 100644 index aef7dd640d7..00000000000 --- a/js/packages/common/src/wallet-adapters/solong_adapter.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import EventEmitter from "eventemitter3"; -import { PublicKey } from "@solana/web3.js"; -import { notify } from "../utils/notifications"; - -export class SolongAdapter extends EventEmitter { - _publicKey: any; - _onProcess: boolean; - constructor(providerUrl: string, network: string) { - super(); - this._publicKey = null; - this._onProcess = false; - this.connect = this.connect.bind(this); - } - - get publicKey() { - return this._publicKey; - } - - async signTransaction(transaction: any) { - return (window as any).solong.signTransaction(transaction); - } - - connect() { - if (this._onProcess) { - return; - } - - if ((window as any).solong === undefined) { - notify({ - message: "Solong Error", - description: "Please install solong wallet from Chrome ", - }); - return; - } - - this._onProcess = true; - (window as any).solong - .selectAccount() - .then((account: any) => { - this._publicKey = new PublicKey(account); - this.emit("connect", this._publicKey); - }) - .catch(() => { - this.disconnect(); - }) - .finally(() => { - this._onProcess = false; - }); - } - - disconnect() { - if (this._publicKey) { - this._publicKey = null; - this.emit("disconnect"); - } - } -} diff --git a/js/packages/common/src/wallet-adapters/torus/index.tsx b/js/packages/common/src/wallet-adapters/torus/index.tsx deleted file mode 100644 index e2b8347abc3..00000000000 --- a/js/packages/common/src/wallet-adapters/torus/index.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import EventEmitter from "eventemitter3" -import { Keypair, PublicKey, Transaction } from "@solana/web3.js" -import { WalletAdapter } from "@solana/wallet-base" -import OpenLogin from "@toruslabs/openlogin" -import { getED25519Key } from "@toruslabs/openlogin-ed25519" - -const getSolanaPrivateKey = (openloginKey: string)=>{ - const { sk } = getED25519Key(openloginKey) - return sk -} - -export class TorusWalletAdapter extends EventEmitter implements WalletAdapter { - _provider: OpenLogin | undefined; - endpoint: string; - providerUrl: string; - account: Keypair | undefined; - image: string = ''; - name: string = ''; - - constructor(providerUrl: string, endpoint: string) { - super() - this.connect = this.connect.bind(this) - this.endpoint = endpoint; - this.providerUrl = providerUrl; - } - - async signAllTransactions(transactions: Transaction[]): Promise { - if(this.account) { - let account = this.account; - transactions.forEach(t => t.partialSign(account)); - } - - return transactions - } - - get publicKey() { - return this.account?.publicKey || null; - } - - async signTransaction(transaction: Transaction) { - if(this.account) { - transaction.partialSign(this.account) - } - - return transaction - } - - connect = async () => { - this._provider = new OpenLogin({ - clientId: process.env.NEXT_PUBLIC_CLIENT_ID || 'BKBTX-SmaEFGddZQrwqd65YFoImRQLca_Tj2IdmKyD2UbDpzrtN2WQ-NYLuej6gP0DfF3jSpEkI13wPt1uPedm0', - network: "mainnet", // mainnet, testnet, development - uxMode: 'popup' - }); - - try { - await this._provider.init(); - } catch (ex) { - console.error('init failed', ex) - } - - console.error(this._provider?.state.store); - - if (this._provider.privKey) { - const privateKey = this._provider.privKey; - console.log(privateKey); - const secretKey = getSolanaPrivateKey(privateKey); - console.log(secretKey); - this.account = Keypair.fromSecretKey(secretKey); - } else { - try { - const { privKey } = await this._provider.login(); - console.log(privKey); - const secretKey = getSolanaPrivateKey(privKey); - console.log(secretKey); - this.account = Keypair.fromSecretKey(secretKey); - } catch(ex) { - console.error('login failed', ex); - } - } - - console.log(this.account?.publicKey.toBase58()); - this.name = this._provider?.state.store.get('name');; - this.image = this._provider?.state.store.get('profileImage');; - - this.emit("connect"); - } - - disconnect = async () => { - console.log("Disconnecting...") - if (this._provider) { - await this._provider.logout(); - await this._provider._cleanup(); - this._provider = undefined; - this.emit("disconnect"); - } - } -} diff --git a/js/packages/common/tsconfig.json b/js/packages/common/tsconfig.json deleted file mode 100644 index 4d65d0b5fa0..00000000000 --- a/js/packages/common/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es2019", - - "outDir": "./dist/lib", - "rootDir": "./src", - - "composite": true, - "declaration": true, - "declarationMap": true, - "sourceMap": true, - "jsx": "react", - "strict": true, - "esModuleInterop": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "typeRoots": ["types", "../../types", "../../node_modules/@types"] - }, - "include": ["src/**/*"], - "exclude": ["src/**/*.test.ts", "**/node_modules"] -} diff --git a/js/packages/web/.env b/js/packages/web/.env deleted file mode 100644 index f01fb3a6810..00000000000 --- a/js/packages/web/.env +++ /dev/null @@ -1,3 +0,0 @@ -REACT_APP_STORE_OWNER_ADDRESS_ADDRESS= -REACT_APP_STORE_ADDRESS= -REACT_APP_BIG_STORE=FALSE diff --git a/js/packages/web/.env.production b/js/packages/web/.env.production deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/js/packages/web/.gitignore b/js/packages/web/.gitignore deleted file mode 100644 index c13e26c1b13..00000000000 --- a/js/packages/web/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -.next -.env.local diff --git a/js/packages/web/next-env.d.ts b/js/packages/web/next-env.d.ts deleted file mode 100644 index c6643fda12f..00000000000 --- a/js/packages/web/next-env.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -/// -/// diff --git a/js/packages/web/next.config.js b/js/packages/web/next.config.js deleted file mode 100644 index 933f34c0146..00000000000 --- a/js/packages/web/next.config.js +++ /dev/null @@ -1,46 +0,0 @@ -const withPlugins = require('next-compose-plugins'); -const withLess = require('next-with-less'); - -const assetPrefix = process.env.ASSET_PREFIX || ''; - -const plugins = [ - [ - withLess, - { - lessLoaderOptions: { - lessOptions: { - modifyVars: { - '@primary-color': '#768BF9', - '@text-color': 'rgba(255, 255, 255)', - '@assetPrefix': assetPrefix || "''", - }, - javascriptEnabled: true, - }, - }, - }, - ], -]; - -module.exports = withPlugins(plugins, { - assetPrefix, - reactStrictMode: true, - eslint: { - ignoreDuringBuilds: true, - }, - env: { - NEXT_PUBLIC_STORE_OWNER_ADDRESS: - process.env.STORE_OWNER_ADDRESS || - process.env.REACT_APP_STORE_OWNER_ADDRESS_ADDRESS, - NEXT_PUBLIC_STORE_ADDRESS: process.env.STORE_ADDRESS, - NEXT_PUBLIC_BIG_STORE: process.env.REACT_APP_BIG_STORE, - NEXT_PUBLIC_CLIENT_ID: process.env.REACT_APP_CLIENT_ID, - }, - async rewrites() { - return [ - { - source: '/:any*', - destination: '/', - }, - ]; - }, -}); diff --git a/js/packages/web/package.json b/js/packages/web/package.json deleted file mode 100644 index 3a37eef1f4f..00000000000 --- a/js/packages/web/package.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "name": "web", - "version": "0.1.0", - "dependencies": { - "@ant-design/icons": "^4.4.0", - "@babel/preset-typescript": "^7.12.13", - "@cloudflare/stream-react": "^1.1.0", - "@oyster/common": "0.0.1", - "@project-serum/serum": "^0.13.52", - "@project-serum/sol-wallet-adapter": "^0.2.5", - "@solana/spl-name-service": "0.1.3", - "@solana/spl-token": "0.1.6", - "@solana/spl-token-registry": "^0.2.202", - "@solana/wallet-base": "0.0.1", - "@solana/wallet-ledger": "0.0.1", - "@solana/web3.js": "^1.21.0", - "@toruslabs/openlogin": "0.9.0", - "@toruslabs/openlogin-ed25519": "0.9.0", - "@toruslabs/openlogin-utils": "0.9.0", - "@welldone-software/why-did-you-render": "^6.0.5", - "bn.js": "^5.1.3", - "borsh": "^0.4.0", - "bs58": "^4.0.1", - "buffer-layout": "^1.2.0", - "canvas-confetti": "^1.4.0", - "chart.js": "^3.5.0", - "eventemitter3": "^4.0.7", - "less": "^4.1.1", - "less-loader": "^10.0.1", - "lodash": "^4.17.20", - "next": "^11.0.1", - "next-compose-plugins": "^2.2.1", - "next-with-less": "^1.0.0", - "react": "16.13.1", - "react-chartjs-2": "^3.0.4", - "react-content-loader": "^6.0.3", - "react-dom": "16.13.1", - "react-intersection-observer": "^8.32.0", - "react-masonry-css": "^1.0.16", - "react-router-dom": "^5.2.0", - "react-virtualized": "^9.22.3", - "three": "^0.128.0", - "use-wallet": "^0.8.1" - }, - "scripts": { - "prestart": "npm-link-shared ../common/node_modules/ . react", - "start": "next dev", - "build": "next build", - "export": "next export -o ../../build/web", - "start:prod": "next start", - "test": "jest", - "deploy:ar": "yarn export && arweave deploy-dir ../../build/web --key-file ", - "deploy:gh": "yarn export && gh-pages -d ../../build/web --repo https://github.com/metaplex-foundation/metaplex -t true", - "deploy": "cross-env ASSET_PREFIX=/metaplex/ yarn build && yarn deploy:gh", - "format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\"" - }, - "eslintConfig": { - "extends": "react-app" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - }, - "repository": { - "type": "git", - "url": "https://github.com/metaplex-foundation/metaplex" - }, - "homepage": ".", - "devDependencies": { - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.5.0", - "@testing-library/user-event": "^7.2.1", - "@typechain/ethers-v4": "^1.0.0", - "@types/bn.js": "^5.1.0", - "@types/bs58": "^4.0.1", - "@types/canvas-confetti": "^1.4.0", - "@types/jest": "^24.9.1", - "@types/node": "^12.12.62", - "@types/react-router-dom": "^5.1.6", - "@types/testing-library__react": "^10.2.0", - "@types/three": "^0.128.0", - "arweave-deploy": "^1.9.1", - "cross-env": "^7.0.3", - "gh-pages": "^3.1.0", - "npm-link-shared": "0.5.6", - "prettier": "^2.1.2", - "typescript": "^4.1.3", - "webpack-dev-server": "3.11.0" - }, - "peerDependencies": { - "next": "*", - "react": "*", - "react-dom": "*" - }, - "resolutions": { - "next": "11.0.1", - "react": "17.0.2", - "react-dom": "17.0.2" - }, - "license": "MIT" -} diff --git a/js/packages/web/public/.nojekyll b/js/packages/web/public/.nojekyll deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/js/packages/web/public/favicon-16x16.png b/js/packages/web/public/favicon-16x16.png deleted file mode 100644 index f90c68647eb..00000000000 Binary files a/js/packages/web/public/favicon-16x16.png and /dev/null differ diff --git a/js/packages/web/public/favicon-32x32.png b/js/packages/web/public/favicon-32x32.png deleted file mode 100644 index 0b6246b2623..00000000000 Binary files a/js/packages/web/public/favicon-32x32.png and /dev/null differ diff --git a/js/packages/web/public/favicon-96x96.png b/js/packages/web/public/favicon-96x96.png deleted file mode 100644 index 7c767b10a64..00000000000 Binary files a/js/packages/web/public/favicon-96x96.png and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Black-Web.woff b/js/packages/web/public/font/Graphik-Black-Web.woff deleted file mode 100644 index fb07a529525..00000000000 Binary files a/js/packages/web/public/font/Graphik-Black-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Black-Web.woff2 b/js/packages/web/public/font/Graphik-Black-Web.woff2 deleted file mode 100644 index 30b8ab34aa5..00000000000 Binary files a/js/packages/web/public/font/Graphik-Black-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-BlackItalic-Web.woff b/js/packages/web/public/font/Graphik-BlackItalic-Web.woff deleted file mode 100644 index 6ffba9141dd..00000000000 Binary files a/js/packages/web/public/font/Graphik-BlackItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-BlackItalic-Web.woff2 b/js/packages/web/public/font/Graphik-BlackItalic-Web.woff2 deleted file mode 100644 index d08e63587f1..00000000000 Binary files a/js/packages/web/public/font/Graphik-BlackItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Bold-Web.woff b/js/packages/web/public/font/Graphik-Bold-Web.woff deleted file mode 100644 index 95f3a55656f..00000000000 Binary files a/js/packages/web/public/font/Graphik-Bold-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Bold-Web.woff2 b/js/packages/web/public/font/Graphik-Bold-Web.woff2 deleted file mode 100644 index d5d1d5856a1..00000000000 Binary files a/js/packages/web/public/font/Graphik-Bold-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-BoldItalic-Web.woff b/js/packages/web/public/font/Graphik-BoldItalic-Web.woff deleted file mode 100644 index b282dfdd1d8..00000000000 Binary files a/js/packages/web/public/font/Graphik-BoldItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-BoldItalic-Web.woff2 b/js/packages/web/public/font/Graphik-BoldItalic-Web.woff2 deleted file mode 100644 index eeea3608663..00000000000 Binary files a/js/packages/web/public/font/Graphik-BoldItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Extralight-Web.woff b/js/packages/web/public/font/Graphik-Extralight-Web.woff deleted file mode 100644 index 65b37ea1fce..00000000000 Binary files a/js/packages/web/public/font/Graphik-Extralight-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Extralight-Web.woff2 b/js/packages/web/public/font/Graphik-Extralight-Web.woff2 deleted file mode 100644 index c88cd9055be..00000000000 Binary files a/js/packages/web/public/font/Graphik-Extralight-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-ExtralightItalic-Web.woff b/js/packages/web/public/font/Graphik-ExtralightItalic-Web.woff deleted file mode 100644 index c9e4b540beb..00000000000 Binary files a/js/packages/web/public/font/Graphik-ExtralightItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-ExtralightItalic-Web.woff2 b/js/packages/web/public/font/Graphik-ExtralightItalic-Web.woff2 deleted file mode 100644 index 0cf9303093c..00000000000 Binary files a/js/packages/web/public/font/Graphik-ExtralightItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Light-Web.woff b/js/packages/web/public/font/Graphik-Light-Web.woff deleted file mode 100644 index 90469e3b808..00000000000 Binary files a/js/packages/web/public/font/Graphik-Light-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Light-Web.woff2 b/js/packages/web/public/font/Graphik-Light-Web.woff2 deleted file mode 100644 index 445fd6f497c..00000000000 Binary files a/js/packages/web/public/font/Graphik-Light-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-LightItalic-Web.woff b/js/packages/web/public/font/Graphik-LightItalic-Web.woff deleted file mode 100644 index 4761ef0f6e0..00000000000 Binary files a/js/packages/web/public/font/Graphik-LightItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-LightItalic-Web.woff2 b/js/packages/web/public/font/Graphik-LightItalic-Web.woff2 deleted file mode 100644 index e4e3404132b..00000000000 Binary files a/js/packages/web/public/font/Graphik-LightItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Medium-Web.woff b/js/packages/web/public/font/Graphik-Medium-Web.woff deleted file mode 100644 index 5d149434f66..00000000000 Binary files a/js/packages/web/public/font/Graphik-Medium-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Medium-Web.woff2 b/js/packages/web/public/font/Graphik-Medium-Web.woff2 deleted file mode 100644 index b829dfc3fb3..00000000000 Binary files a/js/packages/web/public/font/Graphik-Medium-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-MediumItalic-Web.woff b/js/packages/web/public/font/Graphik-MediumItalic-Web.woff deleted file mode 100644 index cb9e9a9fe99..00000000000 Binary files a/js/packages/web/public/font/Graphik-MediumItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-MediumItalic-Web.woff2 b/js/packages/web/public/font/Graphik-MediumItalic-Web.woff2 deleted file mode 100644 index 1cb8a9a34f3..00000000000 Binary files a/js/packages/web/public/font/Graphik-MediumItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Regular-Web.woff b/js/packages/web/public/font/Graphik-Regular-Web.woff deleted file mode 100644 index 63a3e0d31e8..00000000000 Binary files a/js/packages/web/public/font/Graphik-Regular-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Regular-Web.woff2 b/js/packages/web/public/font/Graphik-Regular-Web.woff2 deleted file mode 100644 index 11dabfcbac9..00000000000 Binary files a/js/packages/web/public/font/Graphik-Regular-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-RegularItalic-Web.woff b/js/packages/web/public/font/Graphik-RegularItalic-Web.woff deleted file mode 100644 index 4ceb4dee408..00000000000 Binary files a/js/packages/web/public/font/Graphik-RegularItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-RegularItalic-Web.woff2 b/js/packages/web/public/font/Graphik-RegularItalic-Web.woff2 deleted file mode 100644 index 66b79aefced..00000000000 Binary files a/js/packages/web/public/font/Graphik-RegularItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Semibold-Web.woff b/js/packages/web/public/font/Graphik-Semibold-Web.woff deleted file mode 100644 index c1107b52f3d..00000000000 Binary files a/js/packages/web/public/font/Graphik-Semibold-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Semibold-Web.woff2 b/js/packages/web/public/font/Graphik-Semibold-Web.woff2 deleted file mode 100644 index 438fefc74f9..00000000000 Binary files a/js/packages/web/public/font/Graphik-Semibold-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-SemiboldItalic-Web.woff b/js/packages/web/public/font/Graphik-SemiboldItalic-Web.woff deleted file mode 100644 index d7d8ba1f028..00000000000 Binary files a/js/packages/web/public/font/Graphik-SemiboldItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-SemiboldItalic-Web.woff2 b/js/packages/web/public/font/Graphik-SemiboldItalic-Web.woff2 deleted file mode 100644 index ae3f510b882..00000000000 Binary files a/js/packages/web/public/font/Graphik-SemiboldItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Super-Web.woff b/js/packages/web/public/font/Graphik-Super-Web.woff deleted file mode 100644 index 93ddcbdf1d2..00000000000 Binary files a/js/packages/web/public/font/Graphik-Super-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Super-Web.woff2 b/js/packages/web/public/font/Graphik-Super-Web.woff2 deleted file mode 100644 index 5b3c07583f9..00000000000 Binary files a/js/packages/web/public/font/Graphik-Super-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-SuperItalic-Web.woff b/js/packages/web/public/font/Graphik-SuperItalic-Web.woff deleted file mode 100644 index cb510c874f2..00000000000 Binary files a/js/packages/web/public/font/Graphik-SuperItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-SuperItalic-Web.woff2 b/js/packages/web/public/font/Graphik-SuperItalic-Web.woff2 deleted file mode 100644 index d490b0ef52b..00000000000 Binary files a/js/packages/web/public/font/Graphik-SuperItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Thin-Web.woff b/js/packages/web/public/font/Graphik-Thin-Web.woff deleted file mode 100644 index e166e713143..00000000000 Binary files a/js/packages/web/public/font/Graphik-Thin-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-Thin-Web.woff2 b/js/packages/web/public/font/Graphik-Thin-Web.woff2 deleted file mode 100644 index d51ee82d86a..00000000000 Binary files a/js/packages/web/public/font/Graphik-Thin-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-ThinItalic-Web.woff b/js/packages/web/public/font/Graphik-ThinItalic-Web.woff deleted file mode 100644 index 1ae13a43804..00000000000 Binary files a/js/packages/web/public/font/Graphik-ThinItalic-Web.woff and /dev/null differ diff --git a/js/packages/web/public/font/Graphik-ThinItalic-Web.woff2 b/js/packages/web/public/font/Graphik-ThinItalic-Web.woff2 deleted file mode 100644 index 678ff33b035..00000000000 Binary files a/js/packages/web/public/font/Graphik-ThinItalic-Web.woff2 and /dev/null differ diff --git a/js/packages/web/public/ftxpay.png b/js/packages/web/public/ftxpay.png deleted file mode 100644 index d204cae91cf..00000000000 Binary files a/js/packages/web/public/ftxpay.png and /dev/null differ diff --git a/js/packages/web/public/img/artist1.jpeg b/js/packages/web/public/img/artist1.jpeg deleted file mode 100644 index c884b07c5a9..00000000000 Binary files a/js/packages/web/public/img/artist1.jpeg and /dev/null differ diff --git a/js/packages/web/public/img/artist2.jpeg b/js/packages/web/public/img/artist2.jpeg deleted file mode 100644 index bbe3a5f9da5..00000000000 Binary files a/js/packages/web/public/img/artist2.jpeg and /dev/null differ diff --git a/js/packages/web/public/img/artist3.jpeg b/js/packages/web/public/img/artist3.jpeg deleted file mode 100644 index c8c8d21d970..00000000000 Binary files a/js/packages/web/public/img/artist3.jpeg and /dev/null differ diff --git a/js/packages/web/public/img/artist4.jpeg b/js/packages/web/public/img/artist4.jpeg deleted file mode 100644 index c13843c19b3..00000000000 Binary files a/js/packages/web/public/img/artist4.jpeg and /dev/null differ diff --git a/js/packages/web/public/img/banner1.jpeg b/js/packages/web/public/img/banner1.jpeg deleted file mode 100644 index cdedc7797f4..00000000000 Binary files a/js/packages/web/public/img/banner1.jpeg and /dev/null differ diff --git a/js/packages/web/public/js/libs/draco/README.md b/js/packages/web/public/js/libs/draco/README.md deleted file mode 100644 index 6dfa1d3a9b6..00000000000 --- a/js/packages/web/public/js/libs/draco/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Draco 3D Data Compression - -Draco is an open-source library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics. - -[Website](https://google.github.io/draco/) | [GitHub](https://github.com/google/draco) - -## Contents - -This folder contains three utilities: - -* `draco_decoder.js` — Emscripten-compiled decoder, compatible with any modern browser. -* `draco_decoder.wasm` — WebAssembly decoder, compatible with newer browsers and devices. -* `draco_wasm_wrapper.js` — JavaScript wrapper for the WASM decoder. - -Each file is provided in two variations: - -* **Default:** Latest stable builds, tracking the project's [master branch](https://github.com/google/draco). -* **glTF:** Builds targeted by the [glTF mesh compression extension](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression), tracking the [corresponding Draco branch](https://github.com/google/draco/tree/gltf_2.0_draco_extension). - -Either variation may be used with `THREE.DRACOLoader`: - -```js -var dracoLoader = new THREE.DRACOLoader(); -dracoLoader.setDecoderPath('path/to/decoders/'); -dracoLoader.setDecoderConfig({type: 'js'}); // (Optional) Override detection of WASM support. -``` - -Further [documentation on GitHub](https://github.com/google/draco/tree/master/javascript/example#static-loading-javascript-decoder). - -## License - -[Apache License 2.0](https://github.com/google/draco/blob/master/LICENSE) diff --git a/js/packages/web/public/js/libs/draco/draco_decoder.js b/js/packages/web/public/js/libs/draco/draco_decoder.js deleted file mode 100644 index 1aa9ed1970c..00000000000 --- a/js/packages/web/public/js/libs/draco/draco_decoder.js +++ /dev/null @@ -1,52 +0,0 @@ - -var DracoDecoderModule = (function() { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(DracoDecoderModule) { - DracoDecoderModule = DracoDecoderModule || {}; - -var Module=typeof DracoDecoderModule!=="undefined"?DracoDecoderModule:{};var isRuntimeInitialized=false;var isModuleParsed=false;Module["onRuntimeInitialized"]=function(){isRuntimeInitialized=true;if(isModuleParsed){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};Module["onModuleParsed"]=function(){isModuleParsed=true;if(isRuntimeInitialized){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}};function isVersionSupported(versionString){if(typeof versionString!=="string")return false;const version=versionString.split(".");if(version.length<2||version.length>3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";read_=function shell_read(filename,binary){var ret=tryParseAsDataURI(filename);if(ret){return binary?ret:ret.toString()}if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}readBinary=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var STACK_ALIGN=16;function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;if(end>_emscripten_get_heap_size()){abort()}HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}function convertJsFunctionToWasm(func,sig){return func}function addFunctionWasm(func,sig){var table=wasmTable;var ret=table.length;try{table.grow(1)}catch(err){if(!err instanceof RangeError){throw err}throw"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}try{table.set(ret,func)}catch(err){if(!err instanceof TypeError){throw err}assert(typeof sig!=="undefined","Missing signature argument to addFunction");var wrapped=convertJsFunctionToWasm(func,sig);table.set(ret,wrapped)}return ret}function removeFunctionWasm(index){}var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];var WebAssembly={Memory:function(opts){return{buffer:new ArrayBuffer(opts["initial"]*65536),grow:function(amount){var ret=__growWasmMemory(amount);return ret}}},Table:function(opts){var ret=new Array(opts["initial"]);ret.grow=function(by){if(ret.length>=381+0){abort("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH.")}ret.push(null)};ret.set=function(i,func){ret[i]=func};ret.get=function(i){return ret[i]};return ret},Module:function(binary){return{}},Instance:function(module,info){var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i>2]=0;q[c>>2]=0;q[c+4>>2]=0;d=dm(b);if(d>>>0<4294967280){a:{b:{if(d>>>0>=11){f=d+16&-16;e=Mm(f);q[c+8>>2]=f|-2147483648;q[c>>2]=e;q[c+4>>2]=d;break b}o[c+11|0]=d;e=c;if(!d){break a}}Cn(e,b,d)}o[d+e|0]=0;a=ga(a,c);if(o[c+11|0]<=-1){An(q[c>>2])}T=c+16|0;return(a|0)!=0}Pm();F()}function ga(a,b){var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=q[a+4>>2];if(a){h=r[b+11|0];i=h<<24>>24<0;h=i?q[b+4>>2]:h;l=i?q[b>>2]:b;while(1){b=a+16|0;g=r[a+27|0];i=g<<24>>24<0;j=i?q[a+20>>2]:g;m=j>>>0>>0;a:{b:{c:{d:{e:{f:{g=m?j:h;if(g){k=i?q[b>>2]:b;n=cm(l,k,g);if(n){break f}}if(h>>>0>>0){break a}if(!g){break d}k=i?q[b>>2]:b;break e}if((n|0)<=-1){break a}}b=cm(k,l,g);if(b){break c}}if(m){break b}return 1}if((b|0)<=-1){break b}return 1}a=a+4|0}a=q[a>>2];if(a){continue}break}}return 0}function ha(a,b){var p=0,r=0,s=0,t=0;p=T-16|0;T=p;q[p+12>>2]=0;q[p+8>>2]=0;q[p>>2]=0;q[p+4>>2]=0;r=dm(b);if(r>>>0<4294967280){a:{b:{if(r>>>0>=11){t=r+16&-16;s=Mm(t);q[p+8>>2]=t|-2147483648;q[p>>2]=s;q[p+4>>2]=r;break b}o[p+11|0]=r;s=p;if(!r){break a}}Cn(s,b,r)}o[r+s|0]=0;Vk(a,p,p+12|0);a=q[p+12>>2];if(o[p+11|0]<=-1){An(q[p>>2])}T=p+16|0;return a}Pm();F()}function ia(a,b,u){var v=0,w=0,x=0,y=0;v=T-32|0;T=v;q[v+24>>2]=0;q[v+16>>2]=0;q[v+20>>2]=0;w=dm(b);if(w>>>0<4294967280){a:{b:{if(w>>>0>=11){y=w+16&-16;x=Mm(y);q[v+24>>2]=y|-2147483648;q[v+16>>2]=x;q[v+20>>2]=w;break b}o[v+27|0]=w;x=v+16|0;if(!w){break a}}Cn(x,b,w)}o[w+x|0]=0;q[v+8>>2]=0;q[v>>2]=0;q[v+4>>2]=0;Wk(a,v+16|0,v);a=q[u>>2];if(a){q[u+4>>2]=a;An(a);q[u+8>>2]=0;q[u>>2]=0;q[u+4>>2]=0}q[u>>2]=q[v>>2];q[u+4>>2]=q[v+4>>2];q[u+8>>2]=q[v+8>>2];if(o[v+27|0]<=-1){An(q[v+16>>2])}T=v+32|0;return}Pm();F()}function ja(a,b){var u=0,z=0,A=0,B=0,C=0;u=T-32|0;T=u;q[u+24>>2]=0;q[u+28>>2]=0;q[u+16>>2]=0;q[u+8>>2]=0;q[u+12>>2]=0;z=dm(b);if(z>>>0<4294967280){a:{b:{if(z>>>0>=11){B=z+16&-16;A=Mm(B);q[u+16>>2]=B|-2147483648;q[u+8>>2]=A;q[u+12>>2]=z;break b}o[u+19|0]=z;A=u+8|0;if(!z){break a}}Cn(A,b,z)}o[z+A|0]=0;Xk(a,u+8|0,u+24|0);C=v[u+24>>3];if(o[u+19|0]<=-1){An(q[u+8>>2])}T=u+32|0;return C}Pm();F()}function ka(a,b,D){var E=0,G=0,H=0,I=0;E=T-16|0;T=E;q[E+8>>2]=0;q[E>>2]=0;q[E+4>>2]=0;G=dm(D);if(G>>>0<4294967280){a:{b:{if(G>>>0>=11){I=G+16&-16;H=Mm(I);q[E+8>>2]=I|-2147483648;q[E>>2]=H;q[E+4>>2]=G;break b}o[E+11|0]=G;H=E;if(!G){break a}}Cn(H,D,G)}o[G+H|0]=0;a=a+16|0;D=0;c:{if(!Yk(b,E,a)){break c}D=q[a>>2];if(o[a+11|0]<=-1){break c}D=a}if(o[E+11|0]<=-1){An(q[E>>2])}T=E+16|0;return D}Pm();F()}function la(a,b,D){var F=0,J=0,K=0,L=0;a:{if(q[a+12>>2]==(b|0)){break a}F=q[a>>2];K=a+4|0;J=q[K>>2];if((F|0)!=(J|0)){while(1){L=J+ -12|0;if(o[J+ -1|0]<=-1){An(q[L>>2])}J=L;if((J|0)!=(F|0)){continue}break}}q[a+12>>2]=b;q[K>>2]=F;J=q[b>>2];K=b+4|0;if((J|0)==(K|0)){break a}L=a+8|0;while(1){b=J+16|0;b:{if(q[L>>2]!=(F|0)){Rm(F,b);b=a+4|0;q[b>>2]=q[b>>2]+12;break b}ma(a,b)}F=q[J+4>>2];c:{if(!F){b=q[J+8>>2];if(q[b>>2]==(J|0)){break c}J=J+8|0;while(1){F=q[J>>2];J=F+8|0;b=q[F+8>>2];if((F|0)!=q[b>>2]){continue}break}break c}while(1){b=F;F=q[F>>2];if(F){continue}break}}if((b|0)==(K|0)){break a}F=q[a+4>>2];J=b;continue}}F=0;d:{if((D|0)<0){break d}b=q[a+4>>2];a=q[a>>2];if((b-a|0)/12>>>0<=D>>>0){break d}F=a+w(D,12)|0;if(o[F+11|0]>-1){break d}F=q[F>>2]}return F}function ma(a,b){var D=0,M=0,N=0,O=0,P=0;a:{b:{c:{N=q[a>>2];P=(q[a+4>>2]-N|0)/12|0;D=P+1|0;if(D>>>0<357913942){N=(q[a+8>>2]-N|0)/12|0;O=N<<1;D=N>>>0<178956970?O>>>0>>0?D:O:357913941;M=0;d:{if(!D){break d}if(D>>>0>=357913942){break c}M=Mm(w(D,12))}N=M+w(D,12)|0;b=Rm(M+w(P,12)|0,b);P=b+12|0;D=q[a+4>>2];M=q[a>>2];if((D|0)==(M|0)){break b}while(1){D=D+ -12|0;O=q[D+4>>2];b=b+ -12|0;q[b>>2]=q[D>>2];q[b+4>>2]=O;O=D+8|0;q[b+8>>2]=q[O>>2];q[D>>2]=0;q[D+4>>2]=0;q[O>>2]=0;if((D|0)!=(M|0)){continue}break}M=q[a+4>>2];D=q[a>>2];break a}bn();F()}ab(1040);F()}D=M}q[a>>2]=b;q[a+8>>2]=N;q[a+4>>2]=P;if((D|0)!=(M|0)){while(1){a=M+ -12|0;if(o[M+ -1|0]<=-1){An(q[a>>2])}M=a;if((a|0)!=(D|0)){continue}break}}if(D){An(D)}}function na(a){var b=0;ck(a);b=a+16|0;q[b>>2]=0;q[b+4>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;q[a+12>>2]=b;q[a+32>>2]=0;q[a+36>>2]=0;return a}function oa(a){var Q=0;Q=T-32|0;T=Q;hh(Q+8|0,a);a=q[Q+24>>2];if(o[Q+23|0]<=-1){An(q[Q+12>>2])}T=Q+32|0;return a}function pa(a,R,S){var U=0;U=T-16|0;T=U;ih(U,a,R,S);q[a+24>>2]=q[U>>2];Tm(a+28|0,U|4);a=a+24|0;if(o[U+15|0]<=-1){An(q[U+4>>2])}T=U+16|0;return a}function qa(a,R,S){var V=0;V=T-16|0;T=V;jh(V,a,R,S);q[a+24>>2]=q[V>>2];Tm(a+28|0,V|4);a=a+24|0;if(o[V+15|0]<=-1){An(q[V+4>>2])}T=V+16|0;return a}function ra(a,R){var S=0,W=0,X=0,Y=0;S=T-32|0;T=S;q[S+24>>2]=0;q[S+16>>2]=0;q[S+20>>2]=0;W=dm(R);if(W>>>0<4294967280){a:{b:{if(W>>>0>=11){Y=W+16&-16;X=Mm(Y);q[S+24>>2]=Y|-2147483648;q[S+16>>2]=X;q[S+20>>2]=W;break b}o[S+27|0]=W;X=S+16|0;if(!W){break a}}Cn(X,R,W)}o[W+X|0]=0;q[S+8>>2]=67108864;q[S>>2]=0;q[S+4>>2]=0;o[S+4|0]=0;q[S>>2]=1701667182;W=q[a+4>>2];R=-1;c:{if(!W){break c}W=Pk(W,S,S+16|0);R=-1;if(!W){break c}R=el(a,q[W+24>>2])}if(o[S+11|0]<=-1){An(q[S>>2])}if(o[S+27|0]<=-1){An(q[S+16>>2])}T=S+32|0;return R}Pm();F()}function sa(a,R,Z){var _=0,$=0,aa=0,ba=0;_=T-32|0;T=_;q[_+24>>2]=0;q[_+16>>2]=0;q[_+20>>2]=0;a:{ba=dm(R);if(ba>>>0<4294967280){b:{c:{if(ba>>>0>=11){$=ba+16&-16;aa=Mm($);q[_+24>>2]=$|-2147483648;q[_+16>>2]=aa;q[_+20>>2]=ba;break c}o[_+27|0]=ba;aa=_+16|0;if(!ba){break b}}Cn(aa,R,ba)}o[aa+ba|0]=0;q[_+8>>2]=0;q[_>>2]=0;q[_+4>>2]=0;$=dm(Z);if($>>>0>=4294967280){break a}d:{e:{if($>>>0>=11){R=$+16&-16;aa=Mm(R);q[_+8>>2]=R|-2147483648;q[_>>2]=aa;q[_+4>>2]=$;break e}o[_+11|0]=$;aa=_;if(!$){break d}}Cn(aa,Z,$)}o[$+aa|0]=0;Z=q[a+4>>2];R=-1;f:{if(!Z){break f}Z=Pk(Z,_+16|0,_);R=-1;if(!Z){break f}R=el(a,q[Z+24>>2])}a=R;if(o[_+11|0]<=-1){An(q[_>>2])}if(o[_+27|0]<=-1){An(q[_+16>>2])}T=_+32|0;return a}Pm();F()}Pm();F()}function ta(a,o,R){var Z=0,ca=0,da=0;Z=T-16|0;T=Z;ca=q[a+96>>2];q[Z+8>>2]=0;q[Z>>2]=0;q[Z+4>>2]=0;a=Mm(12);q[Z>>2]=a;q[Z+4>>2]=a;da=a+12|0;q[Z+8>>2]=da;ca=Cn(a,ca+w(o,12)|0,12)+12|0;q[Z+4>>2]=ca;o=q[R>>2];if(o){q[R+4>>2]=o;An(o);q[R+8>>2]=0;q[R>>2]=0;q[R+4>>2]=0}q[R>>2]=a;q[R+8>>2]=da;q[R+4>>2]=ca;T=Z+16|0;return 1}function ua(a,o){var R=0,ea=0;R=T-96|0;T=R;Dn(R+16|0,0,76);q[R+92>>2]=-1;q[R+8>>2]=0;q[R>>2]=0;q[R+4>>2]=0;a:{if(va(R+16|0,a,R)){a=q[o>>2];if(a){q[o+4>>2]=a;An(a);q[o+8>>2]=0;q[o>>2]=0;q[o+4>>2]=0}q[o>>2]=q[R>>2];q[o+4>>2]=q[R+4>>2];q[o+8>>2]=q[R+8>>2];q[R+8>>2]=0;q[R>>2]=0;q[R+4>>2]=0;ea=q[R+84>>2];break a}a=q[R>>2];if(!a){break a}q[R+4>>2]=a;An(a)}a=q[R+72>>2];if(a){An(a)}a=q[R+48>>2];if(a){q[R+52>>2]=a;An(a)}a=q[R+36>>2];if(a){q[R+40>>2]=a;An(a)}a=q[R+24>>2];if(a){q[R+28>>2]=a;An(a)}a=q[R+20>>2];q[R+20>>2]=0;if(a){wa(R+16|4,a)}T=R+96|0;return ea}function va(a,o,fa){var ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0;ja=T-16|0;T=ja;a:{if(!xa(a,o)){break a}ia=1;ha=q[o+96>>2];oa=o+100|0;ga=q[oa>>2];if((ha|0)==(ga|0)){break a}pa=a+12|0;qa=a+24|0;ra=a+36|0;na=fa+8|0;la=fa+4|0;while(1){if(!(q[q[a+56>>2]+(ma>>>3&536870908)>>2]>>>(ma&31)&1)){ia=w(ma,3);Jk(a,0,ia);sa=q[pa>>2];ka=q[a+8>>2];Jk(a,1,ia+1|0);ha=q[qa>>2];ga=q[a+20>>2];Jk(a,2,ia+2|0);ia=ha-ga>>2;ha=sa-ka|0;ga=ha>>2;ka=ia>>>0>ga>>>0;ka=q[ra>>2]-q[a+32>>2]>>2>>>0>(ka?ia:ga)>>>0?2:ka?1:ha?0:-1;b:{if(q[a+68>>2]<1){break b}ga=q[a+76>>2];q[ja+12>>2]=ga;ha=q[la>>2];c:{if(ha>>>0>2]){q[ha>>2]=ga;q[la>>2]=ha+4;break c}ya(fa,ja+12|0)}ga=ja;ia=q[((ka<<2)+a|0)+44>>2];ha=-1;d:{if((ia|0)<0){break d}ha=(ia>>>0)/3|0;ha=q[(q[q[a>>2]+96>>2]+w(ha,12)|0)+(ia-w(ha,3)<<2)>>2]}q[ga+8>>2]=ha;ga=q[la>>2];e:{if(ga>>>0>2]){q[ga>>2]=ha;q[la>>2]=ga+4;break e}ya(fa,ja+8|0)}ga=q[a+72>>2]+2|0;q[a+72>>2]=ga;if(!(ga&1)){break b}q[ja+4>>2]=ha;ga=q[la>>2];f:{if(ga>>>0>2]){q[ga>>2]=ha;q[la>>2]=ga+4;break f}ya(fa,ja+4|0)}q[a+72>>2]=q[a+72>>2]+1}za(a,ka,fa);ha=q[o+96>>2];ga=q[oa>>2]}ia=1;ma=ma+1|0;if(ma>>>0<(ga-ha|0)/12>>>0){continue}break}}T=ja+16|0;return ia}function wa(a,o){if(o){a=q[o+76>>2];if(a){q[o+80>>2]=a;An(a)}a=q[o- -64>>2];if(a){q[o+68>>2]=a;An(a)}a=q[o+48>>2];if(a){q[o+52>>2]=a;An(a)}a=q[o+24>>2];if(a){q[o+28>>2]=a;An(a)}a=q[o+12>>2];if(a){q[o+16>>2]=a;An(a)}a=q[o>>2];if(a){q[o+4>>2]=a;An(a)}An(o)}}function xa(a,fa){var ta=0,ua=0,va=0;ta=T-16|0;T=ta;q[a+68>>2]=0;q[a+72>>2]=0;q[a>>2]=fa;Ik(ta+8|0,fa);ua=q[ta+8>>2];q[ta+8>>2]=0;va=q[a+4>>2];q[a+4>>2]=ua;a:{if(!va){q[ta+8>>2]=0;break a}ua=a+4|0;wa(ua,va);va=q[ta+8>>2];q[ta+8>>2]=0;if(va){wa(ta+8|0,va)}ua=q[ua>>2]}if(ua){ua=q[fa+100>>2];fa=q[fa+96>>2];o[ta+7|0]=0;bb(a+56|0,(ua-fa|0)/12|0,ta+7|0);a=1}else{a=0}T=ta+16|0;return a}function ya(a,o){var T=0,fa=0,wa=0,xa=0,ya=0,za=0;a:{wa=q[a>>2];ya=q[a+4>>2]-wa|0;T=ya>>2;fa=T+1|0;if(fa>>>0<1073741824){za=T<<2;T=q[a+8>>2]-wa|0;xa=T>>1;fa=T>>2>>>0<536870911?xa>>>0>>0?fa:xa:1073741823;T=0;b:{if(!fa){break b}if(fa>>>0>=1073741824){break a}T=Mm(fa<<2)}xa=za+T|0;q[xa>>2]=q[o>>2];o=T+(fa<<2)|0;fa=xa+4|0;if((ya|0)>=1){Cn(T,wa,ya)}q[a>>2]=T;q[a+8>>2]=o;q[a+4>>2]=fa;if(wa){An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Da+12|0);break b}Ba=(o|0)<0?-1:q[(q[q[a>>2]+96>>2]+w(Fa,12)|0)+((o>>>0)%3<<2)>>2];q[a+76>>2]=Ba;q[Da+12>>2]=Ba;Ca=q[Ea>>2];g:{if(Ca>>>0>2]){q[Ca>>2]=Ba;q[Ea>>2]=Ca+4;break g}ya(Aa,Da+12|0)}if(Ha&1){Ba=-1;if((o|0)==-1){break a}if(o-w(Fa,3)){o=o+ -1|0;break b}o=o+2|0;break b}Ba=-1;if((o|0)==-1){break a}Ba=o+1|0;o=(Ba>>>0)%3|0?Ba:o+ -2|0}Ba=-1;if((o|0)==-1){break a}Ba=q[q[q[a+4>>2]+12>>2]+(o<<2)>>2]}Ha=Ha+1|0;if((Ha|0)<(Ia|0)){continue}break}}T=Da+16|0}function Aa(a,o,Aa){var Ja=0,Ka=0,La=0;a:{if(t[a+80>>2]>65535){break a}Ka=q[a+96>>2];a=q[a+100>>2]-Ka|0;La=(a|0)/12|0;if((w(La,6)|0)!=(o|0)){break a}if(!a){return 1}a=0;while(1){o=w(a,6)+Aa|0;Ja=w(a,12)+Ka|0;p[o>>1]=q[Ja>>2];p[o+2>>1]=q[Ja+4>>2];p[o+4>>1]=q[Ja+8>>2];Ja=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ja}function Ba(a,o,Aa){var Ma=0,Na=0,Oa=0;Na=q[a+96>>2];a=q[a+100>>2]-Na|0;Oa=(a|0)/12|0;if((a|0)==(o|0)){if(!o){return 1}a=0;while(1){Ma=w(a,12);o=Ma+Aa|0;Ma=Ma+Na|0;q[o>>2]=q[Ma>>2];q[o+4>>2]=q[Ma+4>>2];q[o+8>>2]=q[Ma+8>>2];Ma=1;a=a+1|0;if(a>>>0>>0){continue}break}}return Ma}function Ca(a,Aa,Pa){var Qa=0,Ra=0,Sa=0,Ta=0;Qa=T-32|0;T=Qa;Ra=o[a+24|0];Ta=q[259];q[Qa+24>>2]=q[258];q[Qa+28>>2]=Ta;Ta=q[257];q[Qa+16>>2]=q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aa=Aa+1|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 1:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(p[Aa>>1]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa/x(32767)):Xa;Aa=Aa+2|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 2:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(s[Aa>>1]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa/x(65535)):Xa;Aa=Aa+2|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 3:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(q[Aa>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(4.656612873077393e-10)):Xa;Aa=Aa+4|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 4:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(t[Aa>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(2.3283064365386963e-10)):Xa;Aa=Aa+4|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 5:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(+t[Aa>>2]+4294967296*+q[Aa+4>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(1.0842021724855044e-19)):Xa;Aa=Aa+8|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 6:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;Ya=r[a+32|0];while(1){Xa=x(+t[Aa>>2]+4294967296*+t[Aa+4>>2]);u[(Wa<<2)+Ua>>2]=Ya?x(Xa*x(5.421010862427522e-20)):Xa;Aa=Aa+8|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 7:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;while(1){q[(Wa<<2)+Ua>>2]=q[Aa>>2];Aa=Aa+4|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 8:Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;while(1){u[(Wa<<2)+Ua>>2]=v[Aa>>3];Aa=Aa+8|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}break a;case 9:break c}}Za=1;Va=o[a+24|0];if(((Va|0)>(Pa|0)?Pa:Va)<<24>>24>=1){Va=q[q[a>>2]>>2];Aa=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],Aa,0)|0;Aa=Va+Aa|0;while(1){u[(Wa<<2)+Ua>>2]=r[Aa|0]?x(1):x(0);Aa=Aa+1|0;Wa=Wa+1|0;Va=o[a+24|0];if((Wa|0)<((Va|0)>(Pa|0)?Pa:Va)<<24>>24){continue}break}}if((Va|0)>=(Pa|0)){break b}Dn((Va<<2)+Ua|0,0,Pa-Va<<2)}return Za}Dn((Va<<2)+Ua|0,0,Pa-Va<<2);return 1}function Ea(a,Aa,Pa){var Ua=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0;Ua=T-16|0;T=Ua;bb=q[a+80>>2];cb=o[Aa+24|0];a=q[259];q[Ua+8>>2]=q[258];q[Ua+12>>2]=a;a=q[257];q[Ua>>2]=q[256];q[Ua+4>>2]=a;a=w(bb,cb);$a=q[Pa>>2];_a=q[Pa+4>>2]-$a>>2;a:{if(a>>>0>_a>>>0){Fa(Pa,a-_a|0);break a}if(a>>>0>=_a>>>0){break a}q[Pa+4>>2]=$a+(a<<2)}b:{if(!bb){a=1;break b}$a=0;db=Aa+68|0;eb=(cb|0)<1;while(1){a=ab;_a=Aa;if(!r[_a+84|0]){a=q[q[db>>2]+(ab<<2)>>2]}if(!Da(_a,a,o[Aa+24|0],Ua)){a=0;break b}if(!eb){_a=q[Pa>>2];a=0;while(1){q[_a+($a<<2)>>2]=q[(a<<2)+Ua>>2];$a=$a+1|0;a=a+1|0;if((cb|0)!=(a|0)){continue}break}}a=1;ab=ab+1|0;if((bb|0)!=(ab|0)){continue}break}}T=Ua+16|0;return a}function Fa(a,o){var Aa=0,Pa=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0;Pa=q[a+8>>2];fb=a+4|0;Aa=q[fb>>2];if(Pa-Aa>>2>>>0>=o>>>0){a=o<<2;kb=fb,lb=Dn(Aa,0,a)+a|0,q[kb>>2]=lb;return}a:{fb=q[a>>2];hb=Aa-fb|0;Aa=hb>>2;gb=Aa+o|0;if(gb>>>0<1073741824){jb=Aa<<2;Pa=Pa-fb|0;Aa=Pa>>1;Pa=Pa>>2>>>0<536870911?Aa>>>0>>0?gb:Aa:1073741823;Aa=0;b:{if(!Pa){break b}if(Pa>>>0>=1073741824){break a}ib=Mm(Pa<<2);Aa=ib}Dn(jb+Aa|0,0,o<<2);o=Aa+(gb<<2)|0;gb=Aa+(Pa<<2)|0;if((hb|0)>=1){Cn(ib,fb,hb)}q[a>>2]=Aa;q[a+8>>2]=gb;q[a+4>>2]=o;if(fb){An(fb)}return}bn();F()}ab(1040);F()}function Ga(a,mb,nb){var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0;pb=T-16|0;T=pb;sb=q[a+80>>2];rb=o[mb+24|0];qb=w(sb,rb);a:{a=q[mb+28>>2];b:{if(!(!r[mb+84|0]|((a|0)!=2?(a|0)!=1:0))){rb=q[mb+48>>2];mb=q[q[mb>>2]>>2];q[pb+8>>2]=0;q[pb>>2]=0;q[pb+4>>2]=0;a=0;if(qb){if((qb|0)<=-1){break a}a=Mm(qb);q[pb>>2]=a;ob=a+qb|0;q[pb+8>>2]=ob;Cn(a,mb+rb|0,qb);q[pb+4>>2]=ob}mb=q[nb>>2];if(mb){q[nb+4>>2]=mb;An(mb);q[nb+8>>2]=0;q[nb>>2]=0;q[nb+4>>2]=0}q[nb>>2]=a;q[nb+8>>2]=ob;q[nb+4>>2]=ob;ob=1;break b}q[pb+8>>2]=0;q[pb>>2]=0;q[pb+4>>2]=0;if(rb){if((rb|0)<=-1){break a}ob=Mm(rb);q[pb>>2]=ob;q[pb+4>>2]=ob;q[pb+8>>2]=ob+rb;a=rb;while(1){o[ob|0]=0;ob=q[pb+4>>2]+1|0;q[pb+4>>2]=ob;a=a+ -1|0;if(a){continue}break}}ob=q[nb>>2];a=q[nb+4>>2]-ob|0;c:{if(qb>>>0>a>>>0){Ha(nb,qb-a|0);break c}if(qb>>>0>=a>>>0){break c}q[nb+4>>2]=ob+qb}d:{if(!sb){ob=1;break d}a=0;tb=mb+68|0;ub=(rb|0)<1;qb=0;while(1){ob=qb;vb=mb;if(!r[mb+84|0]){ob=q[q[tb>>2]+(qb<<2)>>2]}if(!Ia(vb,ob,o[mb+24|0],q[pb>>2])){ob=0;break d}ob=0;if(!ub){while(1){o[q[nb>>2]+a|0]=r[q[pb>>2]+ob|0];a=a+1|0;ob=ob+1|0;if((rb|0)!=(ob|0)){continue}break}}ob=1;qb=qb+1|0;if((sb|0)!=(qb|0)){continue}break}}a=q[pb>>2];if(!a){break b}q[pb+4>>2]=a;An(a)}T=pb+16|0;return ob}bn();F()}function Ha(a,mb){var nb=0,wb=0,xb=0,yb=0,zb=0,Ab=0;a:{wb=q[a+8>>2];xb=a+4|0;nb=q[xb>>2];b:{if(wb-nb>>>0>=mb>>>0){while(1){o[nb|0]=0;nb=q[xb>>2]+1|0;q[xb>>2]=nb;mb=mb+ -1|0;if(mb){continue}break b}}yb=q[a>>2];zb=nb-yb|0;nb=zb+mb|0;if((nb|0)<=-1){break a}xb=0;wb=wb-yb|0;Ab=wb<<1;wb=wb>>>0<1073741823?Ab>>>0>>0?nb:Ab:2147483647;if(wb){xb=Mm(wb)}nb=xb+zb|0;Dn(nb,0,mb);wb=wb+xb|0;while(1){nb=nb+1|0;mb=mb+ -1|0;if(mb){continue}break}if((zb|0)>=1){Cn(xb,yb,zb)}q[a>>2]=xb;q[a+8>>2]=wb;q[a+4>>2]=nb;if(!yb){break b}An(yb)}return}bn();F()}function Ia(a,mb,Bb,Cb){var Db=0,Eb=0,Fb=0,Gb=0,Hb=x(0),Ib=0;a:{b:{if(!Cb){break b}Db=q[a+28>>2]+ -1|0;if(Db>>>0>10){break b}c:{d:{e:{switch(Db-1|0){default:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+1|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 0:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+1|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 1:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+2|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 2:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+2|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 3:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+4|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 4:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+4|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 5:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+8|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 6:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=q[mb>>2];mb=mb+8|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}}if((Db|0)>=(Bb|0)){break b}break a;case 7:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24<1){break c}Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){Db=Cb+Eb|0;Hb=u[mb>>2];f:{if(x(y(Hb))(Bb|0)?Bb:Db)<<24>>24){continue}break}break c;case 8:Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24<1){break d}Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){Db=Cb+Eb|0;Ib=v[mb>>3];g:{if(y(Ib)<2147483648){Gb=~~Ib;break g}Gb=-2147483648}o[Db|0]=Gb;mb=mb+8|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?Bb:Db)<<24>>24){continue}break}break d;case 9:break e}}Fb=1;Db=o[a+24|0];if(((Db|0)>(Bb|0)?Bb:Db)<<24>>24>=1){Db=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Db+mb|0;while(1){o[Cb+Eb|0]=r[mb|0];mb=mb+1|0;Eb=Eb+1|0;Db=o[a+24|0];if((Eb|0)<((Db|0)>(Bb|0)?B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0]){Cb=q[q[Nb>>2]+(Kb<<2)>>2]}if(!Ka(Pb,Cb,o[mb+24|0],q[Jb>>2])){Cb=0;break d}Cb=0;if(!Ob){while(1){o[q[Bb>>2]+a|0]=r[q[Jb>>2]+Cb|0];a=a+1|0;Cb=Cb+1|0;if((Lb|0)!=(Cb|0)){continue}break}}Cb=1;Kb=Kb+1|0;if((Mb|0)!=(Kb|0)){continue}break}}a=q[Jb>>2];if(!a){break b}q[Jb+4>>2]=a;An(a)}T=Jb+16|0;return Cb}bn();F()}function Ka(a,mb,Bb,Qb){var Rb=0,Sb=0,Tb=0,Ub=0,Vb=x(0),Wb=0;a:{b:{if(!Qb){break b}Rb=q[a+28>>2]+ -1|0;if(Rb>>>0>10){break b}c:{d:{e:{switch(Rb-1|0){default:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+1|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 0:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+1|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 1:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+2|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 2:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=r[mb|0];mb=mb+2|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 3:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+4|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 4:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+4|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 5:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+8|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 6:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24>=1){Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){o[Qb+Sb|0]=q[mb>>2];mb=mb+8|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}}if((Rb|0)>=(Bb|0)){break b}break a;case 7:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24<1){break c}Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){Rb=Qb+Sb|0;Vb=u[mb>>2];f:{if(Vb=x(0)){Ub=~~Vb>>>0;break f}Ub=0}o[Rb|0]=Ub;mb=mb+4|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}break c;case 8:Tb=1;Rb=o[a+24|0];if(((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24<1){break d}Rb=q[q[a>>2]>>2];mb=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],mb,0)|0;mb=Rb+mb|0;while(1){Rb=Qb+Sb|0;Wb=v[mb>>3];g:{if(Wb<4294967296&Wb>=0){Ub=~~Wb>>>0;break g}Ub=0}o[Rb|0]=Ub;mb=mb+8|0;Sb=Sb+1|0;Rb=o[a+24|0];if((Sb|0)<((Rb|0)>(Bb|0)?Bb:Rb)<<24>>24){continue}break}break d;case 9:break e}}Tb=1;Rb=o[a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Bb+4>>2]-Yb>>1;c:{if(a>>>0>Xb>>>0){Ma(Bb,a-Xb|0);break c}if(a>>>0>=Xb>>>0){break c}q[Bb+4>>2]=Yb+(a<<1)}d:{if(!ac){a=1;break d}Yb=0;Zb=mb+68|0;bc=(_b|0)<1;while(1){a=$b;Xb=mb;if(!r[mb+84|0]){a=q[q[Zb>>2]+($b<<2)>>2]}if(!Na(Xb,a,o[mb+24|0],q[Qb>>2])){a=0;break d}if(!bc){Xb=q[Bb>>2];a=0;cc=q[Qb>>2];while(1){p[Xb+(Yb<<1)>>1]=s[cc+(a<<1)>>1];Yb=Yb+1|0;a=a+1|0;if((_b|0)!=(a|0)){continue}break}}a=1;$b=$b+1|0;if((ac|0)!=($b|0)){continue}break}}mb=q[Qb>>2];if(!mb){break b}q[Qb+4>>2]=mb;An(mb)}T=Qb+16|0;return a}bn();F()}function Ma(a,o){var mb=0,Bb=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0,jc=0;Bb=q[a+8>>2];dc=a+4|0;mb=q[dc>>2];if(Bb-mb>>1>>>0>=o>>>0){a=o<<1;ic=dc,jc=Dn(mb,0,a)+a|0,q[ic>>2]=jc;return}a:{dc=q[a>>2];fc=mb-dc|0;mb=fc>>1;ec=mb+o|0;if((ec|0)>-1){hc=mb<<1;Bb=Bb-dc|0;Bb=Bb>>1>>>0<1073741823?Bb>>>0>>0?ec:Bb:2147483647;mb=0;b:{if(!Bb){break b}if((Bb|0)<=-1){break a}gc=Mm(Bb<<1);mb=gc}Dn(hc+mb|0,0,o<<1);o=mb+(ec<<1)|0;ec=mb+(Bb<<1)|0;if((fc|0)>=1){Cn(gc,dc,fc)}q[a>>2]=mb;q[a+8>>2]=ec;q[a+4>>2]=o;if(dc){An(dc)}return}bn();F()}ab(1040);F()}function Na(a,kc,lc,mc){var nc=0,oc=0,pc=0,qc=0,rc=x(0),sc=0;a:{b:{if(!mc){break b}nc=q[a+28>>2]+ -1|0;if(nc>>>0>10){break b}c:{d:{e:{switch(nc-1|0){default:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=o[kc|0];kc=kc+1|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 0:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=r[kc|0];kc=kc+1|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 1:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=s[kc>>1];kc=kc+2|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 2:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=s[kc>>1];kc=kc+2|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 3:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+4|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 4:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+4|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 5:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+8|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 6:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=q[kc>>2];kc=kc+8|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}break a;case 7:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24<1){break c}nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){nc=(oc<<1)+mc|0;rc=u[kc>>2];f:{if(x(y(rc))>1]=qc;kc=kc+4|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}break c;case 8:pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24<1){break d}nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){nc=(oc<<1)+mc|0;sc=v[kc>>3];g:{if(y(sc)<2147483648){qc=~~sc;break g}qc=-2147483648}p[nc>>1]=qc;kc=kc+8|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}break d;case 9:break e}}pc=1;nc=o[a+24|0];if(((nc|0)>(lc|0)?lc:nc)<<24>>24>=1){nc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=nc+kc|0;while(1){p[(oc<<1)+mc>>1]=r[kc|0];kc=kc+1|0;oc=oc+1|0;nc=o[a+24|0];if((oc|0)<((nc|0)>(lc|0)?lc:nc)<<24>>24){continue}break}}if((nc|0)>=(lc|0)){break b}Dn((nc<<1)+mc|0,0,lc-nc<<1);break b}if((nc|0)>=(lc|0)){break b}break a}if((nc|0)>=(lc|0)){break b}break a}return pc}Dn((nc<<1)+mc|0,0,lc-nc<<1);return 1}function Oa(a,kc,lc){var mc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0;mc=T-16|0;T=mc;yc=q[a+80>>2];wc=o[kc+24|0];a=w(yc,wc);a:{tc=q[kc+28>>2];b:{if(!(!r[kc+84|0]|((tc|0)!=4?(tc|0)!=3:0))){xc=q[kc+48>>2];tc=q[q[kc>>2]>>2];q[mc+8>>2]=0;q[mc>>2]=0;q[mc+4>>2]=0;kc=0;a=a<<1;if(a){if((a|0)<=-1){break a}uc=Mm(a);q[mc>>2]=uc;vc=(a>>1<<1)+uc|0;q[mc+8>>2]=vc;kc=Cn(uc,tc+xc|0,a)+a|0;q[mc+4>>2]=kc}a=q[lc>>2];if(a){q[lc+4>>2]=a;An(a);q[lc+8>>2]=0;q[lc>>2]=0;q[lc+4>>2]=0}q[lc>>2]=uc;q[lc+8>>2]=vc;q[lc+4>>2]=kc;a=1;break b}q[mc+8>>2]=0;q[mc>>2]=0;q[mc+4>>2]=0;if(wc){if((wc|0)<=-1){break a}tc=wc<<1;uc=Mm(tc);q[mc>>2]=uc;vc=tc+uc|0;q[mc+8>>2]=vc;Dn(uc,0,tc);q[mc+4>>2]=vc}uc=q[lc>>2];tc=q[lc+4>>2]-uc>>1;c:{if(a>>>0>tc>>>0){Ma(lc,a-tc|0);break c}if(a>>>0>=tc>>>0){break c}q[lc+4>>2]=uc+(a<<1)}d:{if(!yc){a=1;break d}uc=0;vc=kc+68|0;zc=(wc|0)<1;while(1){a=xc;tc=kc;if(!r[kc+84|0]){a=q[q[vc>>2]+(xc<<2)>>2]}if(!Pa(tc,a,o[kc+24|0],q[mc>>2])){a=0;break d}if(!zc){tc=q[lc>>2];a=0;Ac=q[mc>>2];while(1){p[tc+(uc<<1)>>1]=s[Ac+(a<<1)>>1];uc=uc+1|0;a=a+1|0;if((wc|0)!=(a|0)){continue}break}}a=1;xc=xc+1|0;if((yc|0)!=(xc|0)){continue}break}}kc=q[mc>>2];if(!kc){break b}q[mc+4>>2]=kc;An(kc)}T=mc+16|0;return a}bn();F()}function Pa(a,kc,lc,Bc){var Cc=0,Dc=0,Ec=0,Fc=0,Gc=x(0),Hc=0;a:{b:{if(!Bc){break b}Cc=q[a+28>>2]+ -1|0;if(Cc>>>0>10){break b}c:{d:{e:{switch(Cc-1|0){default:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=o[kc|0];kc=kc+1|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 0:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=r[kc|0];kc=kc+1|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 1:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=s[kc>>1];kc=kc+2|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 2:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=s[kc>>1];kc=kc+2|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 3:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+4|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 4:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+4|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 5:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+8|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 6:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=q[kc>>2];kc=kc+8|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}break a;case 7:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24<1){break c}Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){Cc=(Dc<<1)+Bc|0;Gc=u[kc>>2];f:{if(Gc=x(0)){Fc=~~Gc>>>0;break f}Fc=0}p[Cc>>1]=Fc;kc=kc+4|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}break c;case 8:Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24<1){break d}Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){Cc=(Dc<<1)+Bc|0;Hc=v[kc>>3];g:{if(Hc<4294967296&Hc>=0){Fc=~~Hc>>>0;break g}Fc=0}p[Cc>>1]=Fc;kc=kc+8|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}break d;case 9:break e}}Ec=1;Cc=o[a+24|0];if(((Cc|0)>(lc|0)?lc:Cc)<<24>>24>=1){Cc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Cc+kc|0;while(1){p[(Dc<<1)+Bc>>1]=r[kc|0];kc=kc+1|0;Dc=Dc+1|0;Cc=o[a+24|0];if((Dc|0)<((Cc|0)>(lc|0)?lc:Cc)<<24>>24){continue}break}}if((Cc|0)>=(lc|0)){break b}Dn((Cc<<1)+Bc|0,0,lc-Cc<<1);break b}if((Cc|0)>=(lc|0)){break b}break a}if((Cc|0)>=(lc|0)){break b}break a}return Ec}Dn((Cc<<1)+Bc|0,0,lc-Cc<<1);return 1}function Qa(a,kc,lc){var Bc=0,Ic=0,Jc=0,Kc=0,Lc=0,Mc=0,Nc=0,Oc=0,Pc=0;Bc=T-16|0;T=Bc;Nc=q[a+80>>2];Kc=o[kc+24|0];Jc=w(N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}q[Bc+4>>2]=kc;An(kc)}T=Bc+16|0;return a}bn();F()}function Ra(a,kc,lc,Qc){var Rc=0,Sc=0,Tc=0,Uc=0,Vc=x(0),Wc=0;a:{b:{if(!Qc){break b}Rc=q[a+28>>2]+ -1|0;if(Rc>>>0>10){break b}c:{d:{e:{switch(Rc-1|0){default:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=o[kc|0];kc=kc+1|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 0:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=r[kc|0];kc=kc+1|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 1:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=p[kc>>1];kc=kc+2|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 2:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=s[kc>>1];kc=kc+2|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 3:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+4|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 4:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+4|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 5:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+8|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 6:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=q[kc>>2];kc=kc+8|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}break a;case 7:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24<1){break c}Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){Rc=(Sc<<2)+Qc|0;Vc=u[kc>>2];f:{if(x(y(Vc))>2]=Uc;kc=kc+4|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}break c;case 8:Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24<1){break d}Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){Rc=(Sc<<2)+Qc|0;Wc=v[kc>>3];g:{if(y(Wc)<2147483648){Uc=~~Wc;break g}Uc=-2147483648}q[Rc>>2]=Uc;kc=kc+8|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}break d;case 9:break e}}Tc=1;Rc=o[a+24|0];if(((Rc|0)>(lc|0)?lc:Rc)<<24>>24>=1){Rc=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=Rc+kc|0;while(1){q[(Sc<<2)+Qc>>2]=r[kc|0];kc=kc+1|0;Sc=Sc+1|0;Rc=o[a+24|0];if((Sc|0)<((Rc|0)>(lc|0)?lc:Rc)<<24>>24){continue}break}}if((Rc|0)>=(lc|0)){break b}Dn((Rc<<2)+Q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c+24|0],q[Qc>>2])){a=0;break e}if(!bd){Yc=q[lc>>2];a=0;cd=q[Qc>>2];while(1){q[Yc+(Xc<<2)>>2]=q[cd+(a<<2)>>2];Xc=Xc+1|0;a=a+1|0;if((Zc|0)!=(a|0)){continue}break}}a=1;$c=$c+1|0;if((ad|0)!=($c|0)){continue}break}}kc=q[Qc>>2];if(!kc){break b}q[Qc+4>>2]=kc;An(kc)}T=Qc+16|0;return a}bn();F()}function Ta(a,kc,lc,dd){var ed=0,fd=0,gd=0,hd=0,id=x(0),jd=0;a:{b:{if(!dd){break b}ed=q[a+28>>2]+ -1|0;if(ed>>>0>10){break b}c:{d:{e:{switch(ed-1|0){default:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=o[kc|0];kc=kc+1|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 0:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=r[kc|0];kc=kc+1|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 1:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=p[kc>>1];kc=kc+2|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 2:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=s[kc>>1];kc=kc+2|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 3:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+4|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 4:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+4|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 5:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+8|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 6:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=q[kc>>2];kc=kc+8|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}break a;case 7:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24<1){break c}ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){ed=(fd<<2)+dd|0;id=u[kc>>2];f:{if(id=x(0)){hd=~~id>>>0;break f}hd=0}q[ed>>2]=hd;kc=kc+4|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}break c;case 8:gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24<1){break d}ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){ed=(fd<<2)+dd|0;jd=v[kc>>3];g:{if(jd<4294967296&jd>=0){hd=~~jd>>>0;break g}hd=0}q[ed>>2]=hd;kc=kc+8|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}break d;case 9:break e}}gd=1;ed=o[a+24|0];if(((ed|0)>(lc|0)?lc:ed)<<24>>24>=1){ed=q[q[a>>2]>>2];kc=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],kc,0)|0;kc=ed+kc|0;while(1){q[(fd<<2)+dd>>2]=r[kc|0];kc=kc+1|0;fd=fd+1|0;ed=o[a+24|0];if((fd|0)<((ed|0)>(lc|0)?lc:ed)<<24>>24){continue}break}}if((ed|0)>=(lc|0)){break b}Dn((ed<<2)+dd|0,0,lc-ed<<2);break b}if((ed|0)>=(lc|0)){break b}break a}if((ed|0)>=(lc|0)){break b}break a}return gd}Dn((ed<<2)+dd|0,0,lc-ed<<2);return 1}function Ua(a,kc,lc,dd,kd){var ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0;md=T-16|0;T=md;lc=lc+ -1|0;a:{if(lc>>>0>8){break a}b:{switch(lc-1|0){default:ld=Va(a,kc,dd,kd);break a;case 1:ld=Wa(a,kc,dd,kd);break a;case 3:ld=Xa(a,kc,dd,kd);break a;case 0:ld=Ya(a,kc,dd,kd);break a;case 2:ld=Za(a,kc,dd,kd);break a;case 4:ld=_a(a,kc,dd,kd);break a;case 5:case 6:break a;case 7:break b}}nd=q[a+80>>2];od=o[kc+24|0];pd=od<<2;if((w(nd,pd)|0)!=(dd|0)){break a}a=0;lc=q[259];q[md+8>>2]=q[258];q[md+12>>2]=lc;lc=q[257];q[md>>2]=q[256];q[md+4>>2]=lc;if(!nd){ld=1;break a}qd=kc+68|0;rd=(od|0)<1;lc=0;while(1){dd=lc;ld=kc;if(!r[kc+84|0]){dd=q[q[qd>>2]+(lc<<2)>>2]}if(!Da(ld,dd,o[kc+24|0],md)){ld=0;break a}if(!rd){Cn((a<<2)+kd|0,md,pd);a=a+od|0}ld=1;lc=lc+1|0;if((nd|0)!=(lc|0)){continue}break}}T=md+16|0;return ld}function Va(a,kc,lc,dd){var kd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0;sd=T-16|0;T=sd;a:{vd=q[a+80>>2];td=o[kc+24|0];b:{if((w(vd,td)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=1)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);kd=1;break b}q[sd+8>>2]=0;q[sd>>2]=0;q[sd+4>>2]=0;if(td){if((td|0)<=-1){break a}kd=Mm(td);q[sd>>2]=kd;q[sd+4>>2]=kd;q[sd+8>>2]=kd+td;lc=td;while(1){o[kd|0]=0;kd=q[sd+4>>2]+1|0;q[sd+4>>2]=kd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!vd){kd=1;break c}lc=0;wd=kc+68|0;xd=(td|0)<1;while(1){a=ud;kd=kc;if(!r[kd+84|0]){a=q[q[wd>>2]+(ud<<2)>>2]}if(!Ia(kd,a,o[kc+24|0],q[sd>>2])){kd=0;break c}if(!xd){kd=0;a=q[sd>>2];while(1){o[lc+dd|0]=r[a+kd|0];lc=lc+1|0;kd=kd+1|0;if((td|0)!=(kd|0)){continue}break}}kd=1;ud=ud+1|0;if((vd|0)!=(ud|0)){continue}break}}a=q[sd>>2];if(!a){break b}q[sd+4>>2]=a;An(a)}T=sd+16|0;return kd}bn();F()}function Wa(a,kc,lc,dd){var yd=0,zd=0,Ad=0,Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0;yd=T-16|0;T=yd;a:{Cd=q[a+80>>2];Ad=o[kc+24|0];a=Ad<<1;b:{if((w(Cd,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=3)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);zd=1;break b}lc=0;q[yd+8>>2]=0;q[yd>>2]=0;q[yd+4>>2]=0;if(Ad){if((Ad|0)<=-1){break a}lc=Mm(a);q[yd>>2]=lc;q[yd+8>>2]=(Ad<<1)+lc;Fd=yd,Gd=Dn(lc,0,a)+a|0,q[Fd+4>>2]=Gd}c:{if(!Cd){zd=1;break c}lc=0;Dd=kc+68|0;Ed=(Ad|0)<1;while(1){a=Bd;zd=kc;if(!r[kc+84|0]){a=q[q[Dd>>2]+(Bd<<2)>>2]}d:{if(!Na(zd,a,o[kc+24|0],q[yd>>2])){zd=0;break d}if(!Ed){zd=0;a=q[yd>>2];while(1){p[(lc<<1)+dd>>1]=s[a+(zd<<1)>>1];lc=lc+1|0;zd=zd+1|0;if((Ad|0)!=(zd|0)){continue}break}}zd=1;Bd=Bd+1|0;if((Cd|0)!=(Bd|0)){continue}}break}lc=q[yd>>2]}if(!lc){break b}q[yd+4>>2]=lc;An(lc)}T=yd+16|0;return zd}bn();F()}function Xa(a,kc,lc,dd){var Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0,Od=0,Pd=0;Hd=T-16|0;T=Hd;a:{Ld=q[a+80>>2];Jd=o[kc+24|0];a=Jd<<2;b:{if((w(Ld,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=5)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);Id=1;break b}lc=0;q[Hd+8>>2]=0;q[Hd>>2]=0;q[Hd+4>>2]=0;if(Jd){if((Jd|0)<=-1){break a}lc=Mm(a);q[Hd>>2]=lc;q[Hd+8>>2]=(Jd<<2)+lc;Od=Hd,Pd=Dn(lc,0,a)+a|0,q[Od+4>>2]=Pd}c:{if(!Ld){Id=1;break c}lc=0;Md=kc+68|0;Nd=(Jd|0)<1;while(1){a=Kd;Id=kc;if(!r[kc+84|0]){a=q[q[Md>>2]+(Kd<<2)>>2]}d:{if(!Ra(Id,a,o[kc+24|0],q[Hd>>2])){Id=0;break d}if(!Nd){Id=0;a=q[Hd>>2];while(1){q[(lc<<2)+dd>>2]=q[a+(Id<<2)>>2];lc=lc+1|0;Id=Id+1|0;if((Jd|0)!=(Id|0)){continue}break}}Id=1;Kd=Kd+1|0;if((Ld|0)!=(Kd|0)){continue}}break}lc=q[Hd>>2]}if(!lc){break b}q[Hd+4>>2]=lc;An(lc)}T=Hd+16|0;return Id}bn();F()}function Ya(a,kc,lc,dd){var Qd=0,Rd=0,Sd=0,Td=0,Ud=0,Vd=0,Wd=0;Rd=T-16|0;T=Rd;a:{Ud=q[a+80>>2];Sd=o[kc+24|0];b:{if((w(Ud,Sd)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=2)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);Qd=1;break b}q[Rd+8>>2]=0;q[Rd>>2]=0;q[Rd+4>>2]=0;if(Sd){if((Sd|0)<=-1){break a}Qd=Mm(Sd);q[Rd>>2]=Qd;q[Rd+4>>2]=Qd;q[Rd+8>>2]=Qd+Sd;lc=Sd;while(1){o[Qd|0]=0;Qd=q[Rd+4>>2]+1|0;q[Rd+4>>2]=Qd;lc=lc+ -1|0;if(lc){continue}break}}c:{if(!Ud){Qd=1;break c}lc=0;Vd=kc+68|0;Wd=(Sd|0)<1;while(1){a=Td;Qd=kc;if(!r[Qd+84|0]){a=q[q[Vd>>2]+(Td<<2)>>2]}if(!Ka(Qd,a,o[kc+24|0],q[Rd>>2])){Qd=0;break c}if(!Wd){Qd=0;a=q[Rd>>2];while(1){o[lc+dd|0]=r[a+Qd|0];lc=lc+1|0;Qd=Qd+1|0;if((Sd|0)!=(Qd|0)){continue}break}}Qd=1;Td=Td+1|0;if((Ud|0)!=(Td|0)){continue}break}}a=q[Rd>>2];if(!a){break b}q[Rd+4>>2]=a;An(a)}T=Rd+16|0;return Qd}bn();F()}function Za(a,kc,lc,dd){var Xd=0,Yd=0,Zd=0,_d=0,$d=0,ae=0,be=0,ce=0,de=0;Xd=T-16|0;T=Xd;a:{$d=q[a+80>>2];Zd=o[kc+24|0];a=Zd<<1;b:{if((w($d,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=4)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);Yd=1;break b}lc=0;q[Xd+8>>2]=0;q[Xd>>2]=0;q[Xd+4>>2]=0;if(Zd){if((Zd|0)<=-1){break a}lc=Mm(a);q[Xd>>2]=lc;q[Xd+8>>2]=(Zd<<1)+lc;ce=Xd,de=Dn(lc,0,a)+a|0,q[ce+4>>2]=de}c:{if(!$d){Yd=1;break c}lc=0;ae=kc+68|0;be=(Zd|0)<1;while(1){a=_d;Yd=kc;if(!r[kc+84|0]){a=q[q[ae>>2]+(_d<<2)>>2]}d:{if(!Pa(Yd,a,o[kc+24|0],q[Xd>>2])){Yd=0;break d}if(!be){Yd=0;a=q[Xd>>2];while(1){p[(lc<<1)+dd>>1]=s[a+(Yd<<1)>>1];lc=lc+1|0;Yd=Yd+1|0;if((Zd|0)!=(Yd|0)){continue}break}}Yd=1;_d=_d+1|0;if(($d|0)!=(_d|0)){continue}}break}lc=q[Xd>>2]}if(!lc){break b}q[Xd+4>>2]=lc;An(lc)}T=Xd+16|0;return Yd}bn();F()}function _a(a,kc,lc,dd){var ee=0,fe=0,ge=0,he=0,ie=0,je=0,ke=0,le=0,me=0;ee=T-16|0;T=ee;a:{ie=q[a+80>>2];ge=o[kc+24|0];a=ge<<2;b:{if((w(ie,a)|0)!=(lc|0)){break b}if(!(!r[kc+84|0]|q[kc+28>>2]!=6)){Cn(dd,q[q[kc>>2]>>2]+q[kc+48>>2]|0,lc);fe=1;break b}lc=0;q[ee+8>>2]=0;q[ee>>2]=0;q[ee+4>>2]=0;if(ge){if((ge|0)<=-1){break a}lc=Mm(a);q[ee>>2]=lc;q[ee+8>>2]=(ge<<2)+lc;le=ee,me=Dn(lc,0,a)+a|0,q[le+4>>2]=me}c:{if(!ie){fe=1;break c}lc=0;je=kc+68|0;ke=(ge|0)<1;while(1){a=he;fe=kc;if(!r[kc+84|0]){a=q[q[je>>2]+(he<<2)>>2]}d:{if(!Ta(fe,a,o[kc+24|0],q[ee>>2])){fe=0;break d}if(!ke){fe=0;a=q[ee>>2];while(1){q[(lc<<2)+dd>>2]=q[a+(fe<<2)>>2];lc=lc+1|0;fe=fe+1|0;if((ge|0)!=(fe|0)){continue}break}}fe=1;he=he+1|0;if((ie|0)!=(he|0)){continue}}break}lc=q[ee>>2]}if(!lc){break b}q[ee+4>>2]=lc;An(lc)}T=ee+16|0;return fe}bn();F()}function $a(a,o){var kc=0,lc=0;kc=q[a+4>>2];if(!kc){return 0}o=q[q[q[a+8>>2]+(o<<2)>>2]+60>>2];if((o|0)<0){return 0}a=q[kc+24>>2];kc=q[kc+28>>2];if((a|0)==(kc|0)){return 0}a:{while(1){lc=q[a>>2];if((o|0)==q[lc+24>>2]){break a}a=a+4|0;if((kc|0)!=(a|0)){continue}break}return 0}return lc}function ab(a){var o=0;o=I(8)|0;q[o>>2]=15856;q[o>>2]=15900;Nm(o+4|0,a);q[o>>2]=15948;J(o|0,15980,1);F()}function bb(a,dd,ne){var oe=0,pe=0,qe=0,re=0,se=0;pe=T-16|0;T=pe;q[a+4>>2]=0;a:{b:{if(!dd){break b}qe=q[a+8>>2];oe=qe<<5;c:{if(oe>>>0>=dd>>>0){q[a+4>>2]=dd;break c}q[pe+8>>2]=0;q[pe>>2]=0;q[pe+4>>2]=0;if((dd|0)<=-1){break a}se=pe;if(oe>>>0<=1073741822){re=dd+31&-32;oe=qe<<6;re=oe>>>0>>0?re:oe}else{re=2147483647}cb(se,re);re=q[a>>2];q[a>>2]=q[pe>>2];q[pe>>2]=re;qe=q[a+4>>2];q[a+4>>2]=dd;q[pe+4>>2]=qe;oe=a+8|0;qe=q[oe>>2];q[oe>>2]=q[pe+8>>2];q[pe+8>>2]=qe;if(!re){break c}An(re)}oe=dd>>>5;qe=oe<<2;a=q[a>>2];if(r[ne|0]){a=Dn(a,255,qe);dd=dd&31;if(!dd){break b}a=a+(oe<<2)|0;q[a>>2]=q[a>>2]|-1>>>32-dd;break b}a=Dn(a,0,qe);dd=dd&31;if(!dd){break b}a=a+(oe<<2)|0;q[a>>2]=q[a>>2]&(-1>>>32-dd^-1)}T=pe+16|0;return}bn();F()}function cb(a,dd){var ne=0,te=0;ne=T-32|0;T=ne;a:{b:{if(q[a+8>>2]<<5>>>0>=dd>>>0){break b}q[ne+24>>2]=0;q[ne+16>>2]=0;q[ne+20>>2]=0;if((dd|0)<=-1){break a}dd=(dd+ -1>>>5)+1|0;te=Mm(dd<<2);q[ne+24>>2]=dd;q[ne+20>>2]=0;q[ne+16>>2]=te;dd=q[a>>2];q[ne+12>>2]=0;q[ne+8>>2]=dd;te=q[a+4>>2];q[ne+4>>2]=te&31;q[ne>>2]=dd+(te>>>3&536870908);db(ne+16|0,ne+8|0,ne);dd=q[a>>2];q[a>>2]=q[ne+16>>2];q[ne+16>>2]=dd;te=q[a+4>>2];q[a+4>>2]=q[ne+20>>2];q[ne+20>>2]=te;a=a+8|0;te=q[a>>2];q[a>>2]=q[ne+24>>2];q[ne+24>>2]=te;if(!dd){break b}An(dd)}T=ne+32|0;return}bn();F()}function db(a,dd,ue){var ve=0,we=0,xe=0,ye=0,ze=0,Ae=0;xe=T-32|0;T=xe;ze=q[ue+4>>2];ve=q[dd+4>>2];Ae=q[ue>>2];ye=q[dd>>2];dd=(ze-ve|0)+(Ae-ye<<3)|0;ue=q[a+4>>2];we=dd+ue|0;q[a+4>>2]=we;a:{if(!(!ue|(we+ -1^ue+ -1)>>>0>31)){a=q[a>>2];break a}a=q[a>>2];if(we>>>0<=32){q[a>>2]=0;break a}q[(we+ -1>>>3&536870908)+a>>2]=0}a=(ue>>>3&536870908)+a|0;ue=ue&31;b:{if((ue|0)==(ve|0)){c:{if((dd|0)<1){break c}d:{if(!ve){ue=0;break d}we=32-ve|0;ue=(dd|0)<(we|0)?dd:we;we=-1<>>we-ue;q[a>>2]=q[a>>2]&(we^-1)|we&q[ye>>2];dd=dd-ue|0;ve=ue+ve|0;ue=ve&31;a=(ve>>>3&536870908)+a|0;ye=ye+4|0}ve=(dd|0)/32|0;we=ve<<2;a=En(a,ye,we)+we|0;ve=dd-(ve<<5)|0;if((ve|0)<1){ve=ue;break c}dd=-1>>>32-ve;q[a>>2]=q[a>>2]&(dd^-1)|dd&q[we+ye>>2]}q[xe+4>>2]=ve;q[xe>>2]=a;break b}q[xe+28>>2]=ve;q[xe+24>>2]=ye;q[xe+20>>2]=ze;q[xe+16>>2]=Ae;q[xe+12>>2]=ue;q[xe+8>>2]=a;eb(xe,xe+24|0,xe+16|0,xe+8|0)}T=xe+32|0}function eb(a,dd,ue,Be){var Ce=0,De=0,Ee=0,Fe=0,Ge=0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a){a=a|0;var dd=0;dd=a+4|0;if(o[a+15|0]<=-1){dd=q[dd>>2]}return dd|0}function ib(a){a=a|0;if(a){if(o[a+15|0]<=-1){An(q[a+4>>2])}An(a)}}function jb(){var a=0;a=Mm(12);q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;return a|0}function kb(ue,Be){ue=ue|0;Be=Be|0;return s[q[ue>>2]+(Be<<1)>>1]}function lb(ue){ue=ue|0;return q[ue+4>>2]-q[ue>>2]>>1}function mb(ue){ue=ue|0;var Be=0;if(ue){Be=q[ue>>2];if(Be){q[ue+4>>2]=Be;An(Be)}An(ue)}}function nb(){return al(Mm(84))|0}function ob(ue){ue=ue|0;return q[ue+12>>2]-q[ue+8>>2]>>2}function pb(ue){ue=ue|0;return q[ue+80>>2]}function qb(ue){ue=ue|0;if(ue){n[q[q[ue>>2]+4>>2]](ue)}}function rb(ue,Ke){ue=ue|0;Ke=Ke|0;return r[q[ue>>2]+Ke|0]}function sb(ue){ue=ue|0;return q[ue+4>>2]-q[ue>>2]|0}function tb(ue,Ke){ue=ue|0;Ke=Ke|0;return q[q[ue>>2]+(Ke<<2)>>2]}function ub(ue){ue=ue|0;return q[ue+4>>2]-q[ue>>2]>>2}function vb(){var ue=0;ue=Mm(8);q[ue+4>>2]=-1;q[ue>>2]=1116;return ue|0}function wb(Ke,Le){Ke=Ke|0;Le=Le|0;return n[q[q[Ke>>2]+12>>2]](Ke,Le)|0}function xb(Ke){Ke=Ke|0;return q[Ke+4>>2]}function yb(){return rd(Mm(96))|0}function zb(Ke){Ke=Ke|0;return q[Ke+88>>2]}function Ab(Ke){Ke=Ke|0;return q[Ke+56>>2]}function Bb(Ke){Ke=Ke|0;return q[Ke+28>>2]}function Cb(q){q=q|0;return o[q+24|0]}function Db(q){q=q|0;return r[q+32|0]}function Eb(Ke){Ke=Ke|0;return q[Ke+40>>2]}function Fb(Ke){Ke=Ke|0;return q[Ke+48>>2]}function Gb(Ke){Ke=Ke|0;return q[Ke+60>>2]}function Hb(Ke){Ke=Ke|0;var Le=0,Me=0;if(Ke){Le=Ke+88|0;Me=q[Le>>2];q[Le>>2]=0;if(Me){Le=q[Me+8>>2];if(Le){q[Me+12>>2]=Le;An(Le)}An(Me)}Me=q[Ke+68>>2];if(Me){q[Ke+72>>2]=Me;An(Me)}Le=Ke- -64|0;Me=q[Le>>2];q[Le>>2]=0;if(Me){Le=q[Me>>2];if(Le){q[Me+4>>2]=Le;An(Le)}An(Me)}An(Ke)}}function Ib(){var Ke=0;Ke=Mm(40);q[Ke>>2]=-1;Uj(Ke+8|0);return Ke|0}function Jb(Ne){Ne=Ne|0;var Oe=0;if(Ne){Oe=q[Ne+8>>2];if(Oe){q[Ne+12>>2]=Oe;An(Oe)}An(Ne)}}function Kb(){var Ne=0;Ne=Mm(24);q[Ne+4>>2]=-1;q[Ne>>2]=1232;q[Ne+8>>2]=0;q[Ne+12>>2]=0;q[Ne+16>>2]=0;q[Ne+20>>2]=0;return Ne|0}function Lb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return x(u[q[Pe+8>>2]+(Qe<<2)>>2])}function Mb(q){q=q|0;return x(u[q+20>>2])}function Nb(Pe,Qe){Pe=Pe|0;Qe=Qe|0;return o[q[Pe>>2]+Qe|0]}function Ob(){var Pe=0;Pe=Mm(28);q[Pe>>2]=0;q[Pe+4>>2]=0;q[Pe+24>>2]=0;q[Pe+16>>2]=0;q[Pe+20>>2]=0;q[Pe+8>>2]=0;q[Pe+12>>2]=0;return Pe|0}function Pb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return fa(Qe,Re)|0}function Qb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return ha(Qe,Re)|0}function Rb(q,Qe,Re,Se){q=q|0;Qe=Qe|0;Re=Re|0;Se=Se|0;ia(Qe,Re,Se)}function Sb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return+ja(Qe,Re)}function Tb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return ka(q,Qe,Re)|0}function Ub(Qe,Re){Qe=Qe|0;Re=Re|0;return q[Re+8>>2]}function Vb(q,Qe,Re){q=q|0;Qe=Qe|0;Re=Re|0;return la(q,Qe,Re)|0}function Wb(Qe){Qe=Qe|0;var Re=0,Se=0,Te=0,Ue=0,Ve=0;if(Qe){if(o[Qe+27|0]<=-1){An(q[Qe+16>>2])}Se=q[Qe>>2];if(Se){Re=Se;Ve=Qe+4|0;Te=q[Ve>>2];Ue=Re;a:{if((Te|0)==(Re|0)){break a}while(1){Re=Te+ -12|0;if(o[Te+ -1|0]<=-1){An(q[Re>>2])}Te=Re;if((Re|0)!=(Se|0)){continue}break}Ue=q[Qe>>2]}Re=Ue;q[Ve>>2]=Se;An(Re)}An(Qe)}}function Xb(Qe,We){Qe=Qe|0;We=We|0;return p[q[Qe>>2]+(We<<1)>>1]}function Yb(Qe,We){Qe=Qe|0;We=We|0;return x(u[q[Qe>>2]+(We<<2)>>2])}function Zb(){return nd(Mm(64))|0}function _b(q){q=q|0;if(q){An(q)}}function $b(){return Yj(Mm(40))|0}function ac(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;q[Qe+16>>2]=0;q[Qe+20>>2]=0;q[Qe>>2]=We;q[Qe+8>>2]=Xe;q[Qe+12>>2]=0}function bc(){return na(Mm(40))|0}function cc(q,Qe){q=q|0;Qe=Qe|0;return oa(Qe)|0}function dc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return pa(q,Qe,We)|0}function ec(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return qa(q,Qe,We)|0}function fc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return bl(Qe,We)|0}function gc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return ra(Qe,We)|0}function hc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return sa(Qe,We,Xe)|0}function ic(Qe,We,Xe){Qe=Qe|0;We=We|0;Xe=Xe|0;return q[q[We+8>>2]+(Xe<<2)>>2]}function jc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return dl(Qe,We)|0}function kc(Qe,We){Qe=Qe|0;We=We|0;return q[We+4>>2]}function lc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return $a(Qe,We)|0}function mc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return ta(Qe,We,Xe)|0}function nc(q,Qe,We){q=q|0;Qe=Qe|0;We=We|0;return ua(Qe,We)|0}function oc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Aa(Qe,We,Xe)|0}function pc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ba(Qe,We,Xe)|0}function qc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ca(Qe,We,Xe)|0}function rc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ea(Qe,We,Xe)|0}function sc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Qa(Qe,We,Xe)|0}function tc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ga(Qe,We,Xe)|0}function uc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Ja(Qe,We,Xe)|0}function vc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return La(Qe,We,Xe)|0}function wc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Oa(Qe,We,Xe)|0}function xc(q,Qe,We,Xe){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;return Sa(Qe,We,Xe)|0}function yc(q,Qe,We,Xe,Ye,Ze){q=q|0;Qe=Qe|0;We=We|0;Xe=Xe|0;Ye=Ye|0;Ze=Ze|0;return Ua(Qe,We,Xe,Ye,Ze)|0}function zc(q,Qe){q=q|0;Qe=Qe|0;kh(q,Qe)}function Ac(Qe){Qe=Qe|0;if(Qe){if(o[Qe+39|0]<=-1){An(q[Qe+28>>2])}Bc(Qe+12|0,q[Qe+16>>2]);Cc(Qe,q[Qe+4>>2]);An(Qe)}}function Bc(Qe,We){if(We){Bc(Qe,q[We>>2]);Bc(Qe,q[We+4>>2]);Cc(We+20|0,q[We+24>>2]);An(We)}}function Cc(Qe,We){if(We){Cc(Qe,q[We>>2]);Cc(Qe,q[We+4>>2]);if(o[We+39|0]<=-1){An(q[We+28>>2])}if(o[We+27|0]<=-1){An(q[We+16>>2])}An(We)}}function Dc(){return vk(Mm(108))|0}function Ec(Qe){Qe=Qe|0;return(q[Qe+100>>2]-q[Qe+96>>2]|0)/12|0}function Fc(){var Qe=0,We=0,Xe=0;We=Mm(24);Xe=We+4|0;Qe=Xe;q[Qe>>2]=0;q[Qe+4>>2]=0;Qe=We+16|0;q[Qe>>2]=0;q[Qe+4>>2]=0;q[We>>2]=Xe;q[We+12>>2]=Qe;return We|0}function Gc(Ye){Ye=Ye|0;if(Ye){Hc(Ye+12|0,q[Ye+16>>2]);Ic(Ye,q[Ye+4>>2]);An(Ye)}}function Hc(Ye,Ze){var _e=0;if(Ze){Hc(Ye,q[Ze>>2]);Hc(Ye,q[Ze+4>>2]);_e=Ze+28|0;Ye=q[_e>>2];q[_e>>2]=0;if(Ye){Hc(Ye+12|0,q[Ye+16>>2]);Ic(Ye,q[Ye+4>>2]);An(Ye)}if(o[Ze+27|0]<=-1){An(q[Ze+16>>2])}An(Ze)}}function Ic(Ye,Ze){if(Ze){Ic(Ye,q[Ze>>2]);Ic(Ye,q[Ze+4>>2]);Ye=q[Ze+28>>2];if(Ye){q[Ze+32>>2]=Ye;An(Ye)}if(o[Ze+27|0]<=-1){An(q[Ze+16>>2])}An(Ze)}}function Jc(){return 0}function Kc(){return-1}function Lc(){return-2}function Mc(){return-3}function Nc(){return-4}function Oc(){return-5}function Pc(){return 1}function Qc(){return 2}function Rc(){return 3}function Sc(){return 4}function Tc(){return 5}function Uc(){return 6}function Vc(){return 7}function Wc(){return 8}function Xc(){return 9}function Yc(){return 10}function Zc(){return 11}function _c(){return 12}function $c(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var $e=0;Ze=q[Ze+88>>2];if(!(!Ze|q[Ze>>2]!=2)){$e=Ye;Ye=q[Ze+8>>2];q[$e+4>>2]=r[Ye|0]|r[Ye+1|0]<<8|(r[Ye+2|0]<<16|r[Ye+3|0]<<24);$e=1}return $e|0}function ad(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var af=0,bf=0;q[Ze>>2]=2;af=q[Ze+8>>2];bf=q[Ze+12>>2]-af|0;if(bf>>>0<=4294967291){Ze=Ze+8|0;Xj(Ze,bf+4|0);af=q[Ze>>2]}Ze=af+bf|0;Ye=r[Ye+4|0]|r[Ye+5|0]<<8|(r[Ye+6|0]<<16|r[Ye+7|0]<<24);o[Ze|0]=Ye;o[Ze+1|0]=Ye>>>8;o[Ze+2|0]=Ye>>>16;o[Ze+3|0]=Ye>>>24}function bd(q){q=q|0;return q|0}function cd(q){q=q|0;An(q)}function dd(q){q=q|0;return 2}function ed(Ye,Ze){Ye=Ye|0;Ze=Ze|0;var cf=0,df=0,ef=0,ff=0,gf=0,hf=0;ef=q[Ze+88>>2];if(!(!ef|q[ef>>2]!=1)){ff=ef+8|0;ef=q[ff>>2];cf=ef;q[Ye+4>>2]=r[cf|0]|r[cf+1|0]<<8|(r[cf+2|0]<<16|r[cf+3|0]<<24);gf=Ye+8|0;hf=q[Ye+8>>2];df=q[Ye+12>>2]-hf>>2;cf=o[Ze+24|0];a:{if(df>>>0>>0){Fa(gf,cf-df|0);ef=q[ff>>2];cf=r[Ze+24|0];break a}if(df>>>0<=cf>>>0){break a}q[Ye+12>>2]=hf+(cf<<2)}ff=1;Ze=ef;df=r[Ze+4|0]|r[Ze+5|0]<<8|(r[Ze+6|0]<<16|r[Ze+7|0]<<24);if(cf<<24>>24>=1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+4>>2]=Ze;hd(Ye+8|0,pf,(qf<<2)+pf|0);u[Ye+20>>2]=rf}function hd(Ye,Ze,pf){var qf=0,rf=0,sf=0,tf=0,uf=0,vf=0,wf=0;a:{tf=pf-Ze|0;sf=tf>>2;qf=q[Ye+8>>2];rf=q[Ye>>2];b:{if(sf>>>0<=qf-rf>>2>>>0){qf=q[Ye+4>>2]-rf|0;tf=qf>>2;qf=sf>>>0>tf>>>0?Ze+qf|0:pf;uf=qf-Ze|0;if(uf){En(rf,Ze,uf)}if(sf>>>0>tf>>>0){Ze=pf-qf|0;if((Ze|0)<1){break b}Ye=Ye+4|0;Cn(q[Ye>>2],qf,Ze);q[Ye>>2]=Ze+q[Ye>>2];return}q[Ye+4>>2]=rf+(uf>>2<<2);return}if(rf){q[Ye+4>>2]=rf;An(rf);q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;qf=0}if(sf>>>0>=1073741824){break a}pf=qf>>1;pf=qf>>2>>>0<536870911?pf>>>0>>0?sf:pf:1073741823;if(pf>>>0>=1073741824){break a}rf=pf<<2;pf=Mm(rf);q[Ye>>2]=pf;sf=Ye+4|0;q[sf>>2]=pf;q[Ye+8>>2]=pf+rf;if((tf|0)<1){break b}vf=sf,wf=Cn(pf,Ze,tf)+tf|0,q[vf>>2]=wf}return}bn();F()}function id(Ye){Ye=Ye|0;var Ze=0;q[Ye>>2]=1232;Ze=q[Ye+8>>2];if(Ze){q[Ye+12>>2]=Ze;An(Ze)}return Ye|0}function jd(Ye){Ye=Ye|0;var pf=0;q[Ye>>2]=1232;pf=q[Ye+8>>2];if(pf){q[Ye+12>>2]=pf;An(pf)}An(Ye)}function kd(q){q=q|0;return 1}function ld(Ye,xf){var yf=0;yf=Mm(40);q[yf>>2]=-1;Uj(yf+8|0);n[q[q[Ye>>2]+16>>2]](Ye,yf);Ye=q[xf+88>>2];q[xf+88>>2]=yf;if(Ye){xf=q[Ye+8>>2];if(xf){q[Ye+12>>2]=xf;An(xf)}An(Ye)}return 1}function md(Ye,xf,zf){var Af=0,Bf=0,Cf=0,Df=0,Ef=0,Ff=0;Cf=q[Ye+8>>2];Af=q[Ye+4>>2];if(Cf-Af>>2>>>0>=xf>>>0){while(1){q[Af>>2]=q[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}q[Ye+4>>2]=Af;return}a:{Df=q[Ye>>2];Ef=Af-Df|0;Ff=Ef>>2;Af=Ff+xf|0;if(Af>>>0<1073741824){Cf=Cf-Df|0;Bf=Cf>>1;Af=Cf>>2>>>0<536870911?Bf>>>0>>0?Af:Bf:1073741823;Bf=0;b:{if(!Af){break b}if(Af>>>0>=1073741824){break a}Bf=Mm(Af<<2)}Cf=Bf+(Af<<2)|0;Af=Bf+(Ff<<2)|0;while(1){q[Af>>2]=q[zf>>2];Af=Af+4|0;xf=xf+ -1|0;if(xf){continue}break}if((Ef|0)>=1){Cn(Bf,Df,Ef)}q[Ye>>2]=Bf;q[Ye+8>>2]=Cf;q[Ye+4>>2]=Af;if(Df){An(Df)}return}bn();F()}ab(1308);F()}function nd(Ye){q[Ye+8>>2]=0;q[Ye+12>>2]=0;q[Ye>>2]=0;q[Ye+40>>2]=0;q[Ye+44>>2]=0;q[Ye+28>>2]=9;o[Ye+24|0]=1;q[Ye+56>>2]=-1;q[Ye+60>>2]=0;q[Ye+16>>2]=0;q[Ye+20>>2]=0;q[Ye+48>>2]=0;q[Ye+52>>2]=0;return Ye}function od(Ye,xf,zf,Gf,Hf,If,Jf){q[Ye>>2]=0;q[Ye+56>>2]=xf;q[Ye+48>>2]=0;q[Ye+52>>2]=0;q[Ye+40>>2]=If;q[Ye+44>>2]=Jf;o[Ye+32|0]=Hf;q[Ye+28>>2]=Gf;o[Ye+24|0]=zf}function pd(Ye,xf){var zf=0,Gf=0,Hf=0;Gf=q[Ye>>2];a:{if(!Gf){break a}zf=q[xf>>2];if(!zf){break a}Hf=Gf;Gf=q[zf>>2];Vj(Hf,Gf,q[zf+4>>2]-Gf|0,0);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;while(1){gg=q[xf+8>>2];dg=q[xf+16>>2];bg=q[xf+12>>2];$f=bg;Tf=q[xf+20>>2];if(($f|0)<(Tf|0)?1:($f|0)<=(Tf|0)?gg>>>0>dg>>>0?0:1:0){ag=0;break a}ig=q[xf>>2];og=r[ig+dg|0];$f=Tf;fg=dg+1|0;if(fg>>>0<1){$f=$f+1|0}ag=xf;q[xf+16>>2]=fg;q[xf+20>>2]=$f;if((bg|0)<($f|0)?1:(bg|0)<=($f|0)?gg>>>0>fg>>>0?0:1:0){ag=0;break a}fg=r[fg+ig|0];$f=Tf;hg=dg+2|0;if(hg>>>0<2){$f=$f+1|0}q[xf+16>>2]=hg;q[ag+20>>2]=$f;if((bg|0)<($f|0)?1:(bg|0)<=($f|0)?gg>>>0>hg>>>0?0:1:0){ag=0;break a}hg=r[hg+ig|0];$f=Tf;jg=dg+3|0;if(jg>>>0<3){$f=$f+1|0}q[xf+16>>2]=jg;q[ag+20>>2]=$f;if((bg|0)<($f|0)?1:(bg|0)<=($f|0)?gg>>>0>jg>>>0?0:1:0){ag=0;break a}bg=r[jg+ig|0];$f=Tf;Tf=dg+4|0;if(Tf>>>0<4){$f=$f+1|0}q[xf+16>>2]=Tf;q[ag+20>>2]=$f;if(og>>>0>4){ag=0;break a}if((fg+ -1&255)>>>0>10){ag=0;break a}dg=nd(cg+24|0);Tf=w(bk(fg),hg);od(dg,og,hg<<24>>24,fg,(bg|0)!=0,Tf,Tf>>31);d:{Tf=s[q[Ye+28>>2]+36>>1];e:{if((Tf<<24|Tf<<8&16711680)>>>16>>>0<=258){ag=q[xf+12>>2];$f=q[xf+20>>2];bg=q[xf+16>>2];Tf=bg+2|0;if(Tf>>>0<2){$f=$f+1|0}gg=Tf;Tf=$f;if((ag|0)<(Tf|0)?1:(ag|0)<=(Tf|0)?t[xf+8>>2]>=gg>>>0?0:1:0){break d}$f=bg+q[xf>>2]|0;$f=r[$f|0]|r[$f+1|0]<<8;q[xf+16>>2]=gg;q[xf+20>>2]=Tf;q[cg+20>>2]=$f;break e}zd(1,cg+20|0,xf);$f=q[cg+20>>2]}q[cg+84>>2]=$f;Tf=Mm(96);sd(Tf,dg);q[cg+16>>2]=Tf;Tf=fl(mg,cg+16|0);ag=q[cg+16>>2];q[cg+16>>2]=0;if(ag){Hb(ag)}bg=Tf<<2;q[q[bg+q[mg+8>>2]>>2]+60>>2]=$f;q[q[Ye+4>>2]+(kg<<2)>>2]=Tf;$f=q[Ye+16>>2];ag=q[ng>>2]-$f>>2;f:{if((Tf|0)<(ag|0)){break f}q[cg+12>>2]=-1;Tf=Tf+1|0;if(Tf>>>0>ag>>>0){Ad(lg,Tf-ag|0,cg+12|0);$f=q[lg>>2];break f}if(Tf>>>0>=ag>>>0){break f}q[ng>>2]=(Tf<<2)+$f}q[$f+bg>>2]=kg;ag=1;kg=kg+1|0;if((kg|0)!=(eg|0)){continue}break a}break}ag=0}T=cg+96|0;return ag|0}function zd(Ye,xf,pg){var qg=0,rg=0,sg=0,tg=0;a:{if(Ye>>>0>5){break a}sg=q[pg+16>>2];qg=q[pg+12>>2];rg=q[pg+20>>2];if((qg|0)<(rg|0)?1:(qg|0)<=(rg|0)?t[pg+8>>2]>sg>>>0?0:1:0){break a}qg=r[sg+q[pg>>2]|0];sg=sg+1|0;if(sg>>>0<1){rg=rg+1|0}q[pg+16>>2]=sg;q[pg+20>>2]=rg;rg=xf;if(qg&128){if(!zd(Ye+1|0,xf,pg)){break a}Ye=q[xf>>2]<<7;q[xf>>2]=Ye;qg=Ye|qg&127}q[rg>>2]=qg;tg=1}return tg}function Ad(Ye,xf,pg){var ug=0,vg=0,wg=0,xg=0,yg=0,zg=0;wg=q[Ye+8>>2];ug=q[Ye+4>>2];if(wg-ug>>2>>>0>=xf>>>0){while(1){q[ug>>2]=q[pg>>2];ug=ug+4|0;xf=xf+ -1|0;if(xf){continue}break}q[Ye+4>>2]=ug;return}a:{xg=q[Ye>>2];yg=ug-xg|0;zg=yg>>2;ug=zg+xf|0;if(ug>>>0<1073741824){wg=wg-xg|0;vg=wg>>1;ug=wg>>2>>>0<536870911?vg>>>0>>0?ug:vg:1073741823;vg=0;b:{if(!ug){break b}if(ug>>>0>=1073741824){break a}vg=Mm(ug<<2)}wg=vg+(ug<<2)|0;ug=vg+(zg<<2)|0;while(1){q[ug>>2]=q[pg>>2];ug=ug+4|0;xf=xf+ -1|0;if(xf){continue}break}if((yg|0)>=1){Cn(vg,xg,yg)}q[Ye>>2]=vg;q[Ye+8>>2]=wg;q[Ye+4>>2]=ug;if(xg){An(xg)}return}bn();F()}ab(1520);F()}function Bd(Ye){Ye=Ye|0;var xf=0;q[Ye>>2]=1384;xf=q[Ye+16>>2];if(xf){q[Ye+20>>2]=xf;An(xf)}xf=q[Ye+4>>2];if(xf){q[Ye+8>>2]=xf;An(xf)}return Ye|0}function Cd(q){q=q|0;F()}function Dd(Ye,pg){Ye=Ye|0;pg=pg|0;var Ag=0;a:{if(!n[q[q[Ye>>2]+36>>2]](Ye,pg)){break a}if(!n[q[q[Ye>>2]+40>>2]](Ye,pg)){break a}Ag=n[q[q[Ye>>2]+44>>2]](Ye)|0}return Ag|0}function Ed(Ye,pg){Ye=Ye|0;pg=pg|0;return q[q[Ye+4>>2]+(pg<<2)>>2]}function Fd(Ye){Ye=Ye|0;return q[Ye+8>>2]-q[Ye+4>>2]>>2}function Gd(q,Ye){q=q|0;Ye=Ye|0;return 0}function Hd(q,Ye){q=q|0;Ye=Ye|0;return 1}function Id(Ye){wd(Ye);q[Ye+36>>2]=0;q[Ye+40>>2]=0;q[Ye>>2]=1596;q[Ye+44>>2]=0;q[Ye+48>>2]=0;q[Ye+52>>2]=0;q[Ye+56>>2]=0;q[Ye+60>>2]=0;q[Ye+64>>2]=0;q[Ye+68>>2]=0}function Jd(Ye,pg){Ye=Ye|0;pg=pg|0;var Bg=0,Cg=0,Dg=0,Eg=0,Fg=0,Gg=0,Hg=0,Ig=0,Jg=0,Kg=0,Lg=0,Mg=0,Ng=0,Og=0,Pg=0,Qg=0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g=q[pg+4>>2]-Yg|0;if((pg|0)>0){break b}}q[Ye+28>>2]=0;q[Ye+12>>2]=0;return Ye}Yg=Cn(Wg,Yg,pg);q[Ye+28>>2]=0;_g=Xg;Xg=w((pg>>>0)/20|0,20);Wg=Xg+Yg|0;q[_g>>2]=Wg;pg=0;_g=Ye;if(Xg){Wg=(Wg-Yg|0)/20|0;Xg=0;while(1){Zg=w(Xg,20)+Yg|0;Zg=w(q[Zg+16>>2],q[Zg+12>>2]);pg=pg>>>0>>0?Zg:pg;Xg=Xg+1|0;if(Xg>>>0>>0){continue}break}if(!pg){q[Ye+12>>2]=0;return Ye}Ha(Ye,pg);pg=q[Ye>>2]}else{pg=0}q[_g+12>>2]=pg;return Ye}bn();F()}function Md(Ye,pg,ah){var bh=0,ch=0,dh=0,eh=0,fh=0,gh=0;ch=q[pg+12>>2];a:{dh=q[pg+20>>2];eh=q[pg+16>>2];bh=eh+4|0;if(bh>>>0<4){dh=dh+1|0}if((ch|0)<(dh|0)?1:(ch|0)<=(dh|0)?t[pg+8>>2]>=bh>>>0?0:1:0){break a}bh=eh+q[pg>>2]|0;bh=r[bh|0]|r[bh+1|0]<<8|(r[bh+2|0]<<16|r[bh+3|0]<<24);q[Ye>>2]=bh;ch=q[pg+20>>2];eh=ch;fh=q[pg+16>>2];dh=fh+4|0;if(dh>>>0<4){ch=ch+1|0}q[pg+16>>2]=dh;q[pg+20>>2]=ch;if(bh>>>0>32){break a}ch=q[pg+12>>2];bh=fh+8|0;if(bh>>>0<8){eh=eh+1|0}if((ch|0)<(eh|0)?1:(ch|0)<=(eh|0)?t[pg+8>>2]>=bh>>>0?0:1:0){break a}bh=dh+q[pg>>2]|0;ch=r[bh|0]|r[bh+1|0]<<8|(r[bh+2|0]<<16|r[bh+3|0]<<24);q[Ye+4>>2]=ch;dh=q[pg+20>>2];eh=q[pg+16>>2]+4|0;if(eh>>>0<4){dh=dh+1|0}q[pg+16>>2]=eh;q[pg+20>>2]=dh;if(!ch){gh=1;break a}q[Ye+8>>2]=0;if(!$g(Ye+16|0,pg)){break a}if(!$g(Ye+36|0,pg)){break a}if(!$g(Ye+56|0,pg)){break a}if(!$g(Ye+76|0,pg)){break a}return Zd(Ye,q[Ye+4>>2],ah)}return gh}function Nd(Ye){var pg=0,$g=0,ah=0,hh=0,ih=0;ah=q[Ye+132>>2];if(ah){ih=Ye+136|0;pg=q[ih>>2];$g=ah;a:{if((ah|0)==(pg|0)){break a}while(1){$g=pg+ -12|0;hh=q[$g>>2];if(hh){q[pg+ -8>>2]=hh;An(hh)}pg=$g;if((pg|0)!=(ah|0)){continue}break}$g=q[Ye+132>>2]}q[ih>>2]=ah;An($g)}ah=q[Ye+120>>2];if(ah){ih=Ye+124|0;pg=q[ih>>2];$g=ah;b:{if((ah|0)==(pg|0)){break b}while(1){$g=pg+ -12|0;hh=q[$g>>2];if(hh){q[pg+ -8>>2]=hh;An(hh)}pg=$g;if((pg|0)!=(ah|0)){continue}break}$g=q[Ye+120>>2]}q[ih>>2]=ah;An($g)}pg=q[Ye+108>>2];if(pg){q[Ye+112>>2]=pg;An(pg)}pg=q[Ye+96>>2];if(pg){q[Ye+100>>2]=pg;An(pg)}_g(Ye+76|0);_g(Ye+56|0);_g(Ye+36|0);_g(Ye+16|0)}function Od(Ye,jh){var kh=0,lh=0,mh=0,nh=0;mh=T-16|0;T=mh;q[Ye+12>>2]=jh;q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;Zg(Ye+16|0);Zg(Ye+36|0);Zg(Ye+56|0);Zg(Ye+76|0);q[Ye+104>>2]=0;q[Ye+96>>2]=0;q[Ye+100>>2]=0;a:{b:{c:{if(jh){if(jh>>>0>=1073741824){break c}kh=jh<<2;lh=Mm(kh);q[Ye+96>>2]=lh;q[Ye+100>>2]=lh;q[Ye+104>>2]=lh+kh;Dn(lh,0,kh);kh=jh;while(1){lh=lh+4|0;kh=kh+ -1|0;if(kh){continue}break}q[Ye+100>>2]=lh}q[Ye+108>>2]=0;q[Ye+112>>2]=0;q[Ye+116>>2]=0;if(jh){if(jh>>>0>=1073741824){break b}kh=jh<<2;lh=Mm(kh);q[Ye+108>>2]=lh;q[Ye+112>>2]=lh;q[Ye+116>>2]=lh+kh;Dn(lh,0,kh);kh=jh;while(1){lh=lh+4|0;kh=kh+ -1|0;if(kh){continue}break}q[Ye+112>>2]=lh}q[mh+8>>2]=0;q[mh>>2]=0;q[mh+4>>2]=0;if(jh){if(jh>>>0>=1073741824){break a}kh=jh<<2;lh=Mm(kh);q[mh>>2]=lh;q[mh+4>>2]=lh;q[mh+8>>2]=lh+kh;Dn(lh,0,kh);kh=jh;while(1){lh=lh+4|0;kh=kh+ -1|0;if(kh){continue}break}q[mh+4>>2]=lh}nh=jh<<5|1;_d(Ye+120|0,nh,mh);kh=q[mh>>2];if(kh){q[mh+4>>2]=kh;An(kh)}q[mh+8>>2]=0;q[mh>>2]=0;q[mh+4>>2]=0;if(jh){if(jh>>>0>=1073741824){break a}kh=jh<<2;lh=Mm(kh);q[mh>>2]=lh;q[mh+4>>2]=lh;q[mh+8>>2]=lh+kh;Dn(lh,0,kh);while(1){lh=lh+4|0;jh=jh+ -1|0;if(jh){continue}break}q[mh+4>>2]=lh}_d(Ye+132|0,nh,mh);jh=q[mh>>2];if(jh){q[mh+4>>2]=jh;An(jh)}T=mh+16|0;return Ye}bn();F()}bn();F()}bn();F()}function Pd(Ye,jh,oh){var ph=0,qh=0,rh=0,sh=0,th=0,uh=0;qh=q[jh+12>>2];a:{rh=q[jh+20>>2];sh=q[jh+16>>2];ph=sh+4|0;if(ph>>>0<4){rh=rh+1|0}if((qh|0)<(rh|0)?1:(qh|0)<=(rh|0)?t[jh+8>>2]>=ph>>>0?0:1:0){break a}ph=sh+q[jh>>2]|0;ph=r[ph|0]|r[ph+1|0]<<8|(r[ph+2|0]<<16|r[ph+3|0]<<24);q[Ye>>2]=ph;qh=q[jh+20>>2];sh=qh;th=q[jh+16>>2];rh=th+4|0;if(rh>>>0<4){qh=qh+1|0}q[jh+16>>2]=rh;q[jh+20>>2]=qh;if(ph>>>0>32){break a}qh=q[jh+12>>2];ph=th+8|0;if(ph>>>0<8){sh=sh+1|0}if((qh|0)<(sh|0)?1:(qh|0)<=(sh|0)?t[jh+8>>2]>=ph>>>0?0:1:0){break a}ph=rh+q[jh>>2]|0;qh=r[ph|0]|r[ph+1|0]<<8|(r[ph+2|0]<<16|r[ph+3|0]<<24);q[Ye+4>>2]=qh;rh=q[jh+20>>2];sh=q[jh+16>>2]+4|0;if(sh>>>0<4){rh=rh+1|0}q[jh+16>>2]=sh;q[jh+20>>2]=rh;if(!qh){uh=1;break a}q[Ye+8>>2]=0;if(!$g(Ye+16|0,jh)){break a}if(!$g(Ye+36|0,jh)){break a}if(!$g(Ye+56|0,jh)){break a}if(!$g(Ye+76|0,jh)){break a}return $d(Ye,q[Ye+4>>2],oh)}return uh}function Qd(Ye,jh,oh){var vh=0,wh=0,xh=0,yh=0,zh=0,Ah=0;wh=q[jh+12>>2];a:{xh=q[jh+20>>2];yh=q[jh+16>>2];vh=yh+4|0;if(vh>>>0<4){xh=xh+1|0}if((wh|0)<(xh|0)?1:(wh|0)<=(xh|0)?t[jh+8>>2]>=vh>>>0?0:1:0){break a}vh=yh+q[jh>>2]|0;vh=r[vh|0]|r[vh+1|0]<<8|(r[vh+2|0]<<16|r[vh+3|0]<<24);q[Ye>>2]=vh;wh=q[jh+20>>2];yh=wh;zh=q[jh+16>>2];xh=zh+4|0;if(xh>>>0<4){wh=wh+1|0}q[jh+16>>2]=xh;q[jh+20>>2]=wh;if(vh>>>0>32){break a}wh=q[jh+12>>2];vh=zh+8|0;if(vh>>>0<8){yh=yh+1|0}if((wh|0)<(yh|0)?1:(wh|0)<=(yh|0)?t[jh+8>>2]>=vh>>>0?0:1:0){break a}vh=xh+q[jh>>2]|0;wh=r[vh|0]|r[vh+1|0]<<8|(r[vh+2|0]<<16|r[vh+3|0]<<24);q[Ye+4>>2]=wh;xh=q[jh+20>>2];yh=q[jh+16>>2]+4|0;if(yh>>>0<4){xh=xh+1|0}q[jh+16>>2]=yh;q[jh+20>>2]=xh;if(!wh){Ah=1;break a}q[Ye+8>>2]=0;if(!bh(Ye+16|0,jh)){break a}if(!$g(Ye+32|0,jh)){break a}if(!$g(Ye+52|0,jh)){break a}if(!$g(Ye+72|0,jh)){break a}return ae(Ye,q[Ye+4>>2],oh)}return Ah}function Rd(Ye){var jh=0,oh=0,Bh=0,Ch=0,Dh=0;Bh=q[Ye+128>>2];if(Bh){Dh=Ye+132|0;jh=q[Dh>>2];oh=Bh;a:{if((Bh|0)==(jh|0)){break a}while(1){oh=jh+ -12|0;Ch=q[oh>>2];if(Ch){q[jh+ -8>>2]=Ch;An(Ch)}jh=oh;if((jh|0)!=(Bh|0)){continue}break}oh=q[Ye+128>>2]}q[Dh>>2]=Bh;An(oh)}Bh=q[Ye+116>>2];if(Bh){Dh=Ye+120|0;jh=q[Dh>>2];oh=Bh;b:{if((Bh|0)==(jh|0)){break b}while(1){oh=jh+ -12|0;Ch=q[oh>>2];if(Ch){q[jh+ -8>>2]=Ch;An(Ch)}jh=oh;if((jh|0)!=(Bh|0)){continue}break}oh=q[Ye+116>>2]}q[Dh>>2]=Bh;An(oh)}jh=q[Ye+104>>2];if(jh){q[Ye+108>>2]=jh;An(jh)}jh=q[Ye+92>>2];if(jh){q[Ye+96>>2]=jh;An(jh)}_g(Ye+72|0);_g(Ye+52|0);_g(Ye+32|0)}function Sd(Ye,Eh){var Fh=0,Gh=0,Hh=0,Ih=0;Hh=T-16|0;T=Hh;q[Ye+12>>2]=Eh;q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;ah(Ye+16|0);Zg(Ye+32|0);Zg(Ye+52|0);Zg(Ye+72|0);q[Ye+100>>2]=0;q[Ye+92>>2]=0;q[Ye+96>>2]=0;a:{b:{c:{if(Eh){if(Eh>>>0>=1073741824){break c}Fh=Eh<<2;Gh=Mm(Fh);q[Ye+92>>2]=Gh;q[Ye+96>>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-8>>2]=Xh;An(Xh)}Eh=Jh;if((Eh|0)!=(Wh|0)){continue}break}Jh=q[Ye+628>>2]}q[Yh>>2]=Wh;An(Jh)}Eh=q[Ye+616>>2];if(Eh){q[Ye+620>>2]=Eh;An(Eh)}Eh=q[Ye+604>>2];if(Eh){q[Ye+608>>2]=Eh;An(Eh)}_g(Ye+584|0);_g(Ye+564|0);_g(Ye+544|0)}function Wd(Ye,Zh){var _h=0,$h=0,ai=0,bi=0;ai=T-16|0;T=ai;q[Ye+12>>2]=Zh;q[Ye+8>>2]=0;q[Ye>>2]=0;q[Ye+4>>2]=0;de(Ye+16|0);ah(Ye+528|0);Zg(Ye+544|0);Zg(Ye+564|0);Zg(Ye+584|0);q[Ye+612>>2]=0;q[Ye+604>>2]=0;q[Ye+608>>2]=0;a:{b:{c:{if(Zh){if(Zh>>>0>=1073741824){break c}_h=Zh<<2;$h=Mm(_h);q[Ye+604>>2]=$h;q[Ye+608>>2]=$h;q[Ye+612>>2]=$h+_h;Dn($h,0,_h);_h=Zh;while(1){$h=$h+4|0;_h=_h+ -1|0;if(_h){continue}break}q[Ye+608>>2]=$h}q[Ye+616>>2]=0;q[Ye+620>>2]=0;q[Ye+624>>2]=0;if(Zh){if(Zh>>>0>=1073741824){break b}_h=Zh<<2;$h=Mm(_h);q[Ye+616>>2]=$h;q[Ye+620>>2]=$h;q[Ye+624>>2]=$h+_h;Dn($h,0,_h);_h=Zh;while(1){$h=$h+4|0;_h=_h+ -1|0;if(_h){continue}break}q[Ye+620>>2]=$h}q[ai+8>>2]=0;q[ai>>2]=0;q[ai+4>>2]=0;if(Zh){if(Zh>>>0>=1073741824){break a}_h=Zh<<2;$h=Mm(_h);q[ai>>2]=$h;q[ai+4>>2]=$h;q[ai+8>>2]=$h+_h;Dn($h,0,_h);_h=Zh;while(1){$h=$h+4|0;_h=_h+ -1|0;if(_h){continue}break}q[ai+4>>2]=$h}bi=Zh<<5|1;_d(Ye+628|0,bi,ai);_h=q[ai>>2];if(_h){q[ai+4>>2]=_h;An(_h)}q[ai+8>>2]=0;q[ai>>2]=0;q[ai+4>>2]=0;if(Zh){if(Zh>>>0>=1073741824){break a}_h=Zh<<2;$h=Mm(_h);q[ai>>2]=$h;q[ai+4>>2]=$h;q[ai+8>>2]=$h+_h;Dn($h,0,_h);while(1){$h=$h+4|0;Zh=Zh+ -1|0;if(Zh){continue}break}q[ai+4>>2]=$h}_d(Ye+640|0,bi,ai);Zh=q[ai>>2];if(Zh){q[ai+4>>2]=Zh;An(Zh)}T=ai+16|0;return Ye}bn();F()}bn();F()}bn();F()}function Xd(Ye,Zh,ci){var di=0,ei=0,fi=0,gi=0,hi=0,ii=0;ei=q[Zh+12>>2];a:{fi=q[Zh+20>>2];gi=q[Zh+16>>2];di=gi+4|0;if(di>>>0<4){fi=fi+1|0}if((ei|0)<(fi|0)?1:(ei|0)<=(fi|0)?t[Zh+8>>2]>=di>>>0?0:1:0){break a}di=gi+q[Zh>>2]|0;di=r[di|0]|r[di+1|0]<<8|(r[di+2|0]<<16|r[di+3|0]<<24);q[Ye>>2]=di;ei=q[Zh+20>>2];gi=ei;hi=q[Zh+16>>2];fi=hi+4|0;if(fi>>>0<4){ei=ei+1|0}q[Zh+16>>2]=fi;q[Zh+20>>2]=ei;if(di>>>0>32){break a}ei=q[Zh+12>>2];di=hi+8|0;if(di>>>0<8){gi=gi+1|0}if((ei|0)<(gi|0)?1:(ei|0)<=(gi|0)?t[Zh+8>>2]>=di>>>0?0:1:0){break a}di=fi+q[Zh>>2]|0;ei=r[di|0]|r[di+1|0]<<8|(r[di+2|0]<<16|r[di+3|0]<<24);q[Ye+4>>2]=ei;fi=q[Zh+20>>2];gi=q[Zh+16>>2]+4|0;if(gi>>>0<4){fi=fi+1|0}q[Zh+16>>2]=gi;q[Zh+20>>2]=fi;if(!ei){ii=1;break a}q[Ye+8>>2]=0;di=0;while(1){if(!bh(((di<<4)+Ye|0)+16|0,Zh)){break a}di=di+1|0;if((di|0)!=32){continue}break}if(!bh(Ye+528|0,Zh)){break a}if(!$g(Ye+544|0,Zh)){break a}if(!$g(Ye+564|0,Zh)){break a}if(!$g(Ye+584|0,Zh)){break a}return ee(Ye,q[Ye+4>>2],ci)}return ii}function Yd(Ye,Zh,ci){var ji=0,ki=0,li=0,mi=0,ni=0,oi=0;ki=q[Zh+12>>2];a:{li=q[Zh+20>>2];mi=q[Zh+16>>2];ji=mi+4|0;if(ji>>>0<4){li=li+1|0}if((ki|0)<(li|0)?1:(ki|0)<=(li|0)?t[Zh+8>>2]>=ji>>>0?0:1:0){break a}ji=mi+q[Zh>>2]|0;ji=r[ji|0]|r[ji+1|0]<<8|(r[ji+2|0]<<16|r[ji+3|0]<<24);q[Ye>>2]=ji;ki=q[Zh+20>>2];mi=ki;ni=q[Zh+16>>2];li=ni+4|0;if(li>>>0<4){ki=ki+1|0}q[Zh+16>>2]=li;q[Zh+20>>2]=ki;if(ji>>>0>32){break a}ki=q[Zh+12>>2];ji=ni+8|0;if(ji>>>0<8){mi=mi+1|0}if((ki|0)<(mi|0)?1:(ki|0)<=(mi|0)?t[Zh+8>>2]>=ji>>>0?0:1:0){break a}ji=li+q[Zh>>2]|0;ki=r[ji|0]|r[ji+1|0]<<8|(r[ji+2|0]<<16|r[ji+3|0]<<24);q[Ye+4>>2]=ki;li=q[Zh+20>>2];mi=q[Zh+16>>2]+4|0;if(mi>>>0<4){li=li+1|0}q[Zh+16>>2]=mi;q[Zh+20>>2]=li;if(!ki){oi=1;break a}q[Ye+8>>2]=0;ji=0;while(1){if(!bh(((ji<<4)+Ye|0)+16|0,Zh)){break a}ji=ji+1|0;if((ji|0)!=32){continue}break}if(!bh(Ye+528|0,Zh)){break a}if(!$g(Ye+544|0,Zh)){break a}if(!$g(Ye+564|0,Zh)){break a}if(!$g(Ye+584|0,Zh)){break a}return fe(Ye,q[Ye+4>>2],ci)}return oi}function Zd(Ye,Zh,ci){var pi=0,qi=0,ri=0,si=0,ti=0,ui=0,vi=0,wi=0,xi=0,yi=0,zi=0,Ai=0,Bi=0,Ci=0,Di=0,Ei=0,Fi=0,Gi=0,Hi=0,Ii=0,Ji=0,Ki=0,Li=0,Mi=0,Ni=0,Oi=0;si=T-32|0;T=si;qi=q[Ye+12>>2];q[si+16>>2]=0;q[si+8>>2]=0;q[si+12>>2]=0;a:{if(qi){if(qi>>>0>=1073741824){break a}pi=qi<<2;ri=Mm(pi);q[si+8>>2]=ri;q[si+12>>2]=ri;q[si+16>>2]=pi+ri;ui=Dn(ri,0,pi);pi=qi;while(1){ui=ui+4|0;pi=pi+ -1|0;if(pi){continue}break}q[si+12>>2]=ui}ti=q[Ye+120>>2];pi=q[ti>>2];if(pi){q[ti+4>>2]=pi;An(pi);q[ti+8>>2]=0;q[ti>>2]=0;q[ti+4>>2]=0;qi=q[Ye+12>>2];ui=q[si+12>>2];ri=q[si+8>>2]}q[ti>>2]=ri;q[ti+4>>2]=ui;q[ti+8>>2]=q[si+16>>2];ui=0;q[si+16>>2]=0;q[si+8>>2]=0;q[si+12>>2]=0;pi=0;b:{if(qi){if(qi>>>0>=1073741824){break b}ri=qi<<2;pi=Mm(ri);q[si+8>>2]=pi;q[si+12>>2]=pi;q[si+16>>2]=pi+ri;ui=Dn(pi,0,ri);while(1){ui=ui+4|0;qi=qi+ -1|0;if(qi){continue}break}q[si+12>>2]=ui}ti=q[Ye+132>>2];ri=q[ti>>2];if(ri){q[ti+4>>2]=ri;An(ri);q[ti+8>>2]=0;q[ti>>2]=0;q[ti+4>>2]=0;ui=q[si+12>>2];pi=q[si+8>>2]}q[ti>>2]=pi;q[ti+4>>2]=ui;q[ti+8>>2]=q[si+16>>2];qi=si+24|0;q[qi>>2]=0;q[qi+4>>2]=0;ri=si+16|0;q[ri>>2]=0;q[ri+4>>2]=0;q[si+8>>2]=0;q[si+12>>2]=0;re(si+8|0);ti=q[si+12>>2];pi=0;c:{if((ti|0)==q[ri>>2]){break c}ri=q[qi>>2]+q[si+28>>2]|0;pi=(ri>>>0)/341|0;pi=q[ti+(pi<<2)>>2]+w(ri-w(pi,341)|0,12)|0}q[pi+4>>2]=0;q[pi+8>>2]=0;q[pi>>2]=Zh;pi=1;ri=q[si+28>>2];qi=ri+1|0;q[si+28>>2]=qi;d:{if(qi>>>0>>0){break d}Li=Ye+132|0;Ki=Ye+120|0;Gi=ci+20|0;Mi=Ye+108|0;Ni=Ye+96|0;Hi=Ye+48|0;Ii=Ye+28|0;Oi=Ye+80|0;while(1){pi=q[si+12>>2];vi=q[si+24>>2];wi=qi+ -1|0;ti=vi+wi|0;ri=(ti>>>0)/341|0;ri=q[pi+(ri<<2)>>2]+w(ti-w(ri,341)|0,12)|0;Ai=q[ri+8>>2];ti=q[ri+4>>2];zi=q[ri>>2];q[si+28>>2]=wi;ri=q[si+16>>2];pi=ri-pi|0;if(((pi?w(pi>>2,341)+ -1|0:0)-(qi+vi|0)|0)+1>>>0>=682){An(q[ri+ -4>>2]);q[si+16>>2]=q[si+16>>2]+ -4}pi=0;if(zi>>>0>Zh>>>0){break d}ri=q[Ki>>2];Bi=w(Ai,12);Ei=Bi+q[Li>>2]|0;ui=ml(Ye,Ei,ti);if(ui>>>0>=t[Ye+12>>2]){break d}Fi=ri+Bi|0;e:{f:{Ci=ui<<2;ti=q[Ye>>2]-q[Ci+q[Ei>>2]>>2]|0;if(!ti){if(!zi){break f}xi=0;while(1){ti=0;qi=q[ci+16>>2];g:{if((qi|0)==q[Gi>>2]){break g}while(1){qi=w(ti,20)+qi|0;ri=q[Fi>>2]+(q[qi+4>>2]<<2)|0;yi=q[qi>>2];ui=q[qi+12>>2];h:{if(ui>>>0>3){break h}pi=q[ci+12>>2];vi=qi+16|0;if(!q[vi>>2]){ri=pi;break h}wi=qi+12|0;qi=0;while(1){pi=Cn(pi,(qi<<2)+ri|0,ui);ui=q[wi>>2];pi=pi+ui|0;qi=qi+1|0;if(qi>>>0>2]){continue}break}ri=q[ci+12>>2]}qi=q[ci+28>>2];qi=r[yi+84|0]?qi:q[q[yi+68>>2]+(qi<<2)>>2];if(qi>>>0>=t[yi+80>>2]){break g}pi=q[yi+40>>2];Cn(q[q[yi>>2]>>2]+w(pi,qi)|0,ri,pi);ti=ti+1|0;qi=q[ci+16>>2];if(ti>>>0<(q[Gi>>2]-qi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;xi=xi+1|0;if((zi|0)!=(xi|0)){continue}break}break f}i:{j:{k:{l:{if(zi>>>0<=2){ri=q[Mi>>2];q[ri>>2]=ui;pi=1;qi=q[Ye+12>>2];if(qi>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}pi=q[Ki>>2];xi=Ai+1|0;yi=w(xi,12);ri=pi+yi|0;if((ri|0)!=(Fi|0)){hd(ri,q[Fi>>2],q[Fi+4>>2]);pi=q[Ki>>2]}pi=Ci+q[pi+yi>>2]|0;q[pi>>2]=q[pi>>2]+(1<>2];ti=32-wi|0;m:{if((vi|0)<=(ti|0)){ti=q[Ii>>2];if((ti|0)==q[Ye+20>>2]){pi=0;break m}pi=q[ti>>2];ri=vi+wi|0;q[Ye+32>>2]=ri;pi=pi<>>32-vi;if((ri|0)!=32){break m}q[Ye+32>>2]=0;q[Ii>>2]=ti+4;break m}qi=q[Ii>>2];pi=qi+4|0;if((pi|0)==q[Ye+20>>2]){pi=0;break m}ri=q[qi>>2];q[Ii>>2]=pi;pi=vi-ti|0;q[Ye+32>>2]=pi;pi=q[qi+4>>2]>>>32-pi|ri<>>32-vi}ri=(zi>>>1)-pi|0;pi=zi-ri|0;n:{if((pi|0)==(ri|0)){pi=ri;break n}vi=q[Ye+88>>2];if((vi|0)==q[Oi>>2]){break k}wi=q[vi>>2];qi=q[Ye+92>>2];ti=qi+1|0;q[Ye+92>>2]=ti;qi=wi&-2147483648>>>qi;o:{if((ti|0)==32){q[Ye+92>>2]=0;q[Ye+88>>2]=vi+4;if(qi){break o}break k}if(!qi){break k}}}ti=pi;pi=ri;break j}while(1){ui=(qi+ -1|0)==(ui|0)?0:ui+1|0;q[ri+(pi<<2)>>2]=ui;pi=pi+1|0;qi=q[Ye+12>>2];if(pi>>>0>>0){continue}break}break i}ti=ri}vi=q[Li>>2];wi=vi+Bi|0;qi=q[wi>>2];ri=qi+Ci|0;q[ri>>2]=q[ri>>2]+1;hd(vi+yi|0,qi,q[wi+4>>2]);if(pi){ri=q[si+28>>2]+q[si+24>>2]|0;vi=q[si+16>>2];qi=q[si+12>>2];wi=vi-qi|0;if((ri|0)==((wi?w(wi>>2,341)+ -1|0:0)|0)){re(si+8|0);qi=q[si+12>>2];vi=q[si+16>>2];ri=q[si+24>>2]+q[si+28>>2]|0}if((qi|0)==(vi|0)){ri=0}else{Ei=qi;qi=(ri>>>0)/341|0;ri=q[Ei+(qi<<2)>>2]+w(ri-w(qi,341)|0,12)|0}q[ri+8>>2]=Ai;q[ri+4>>2]=ui;q[ri>>2]=pi;q[si+28>>2]=q[si+28>>2]+1}if(!ti){break f}pi=q[si+28>>2]+q[si+24>>2]|0;ri=q[si+16>>2];qi=q[si+12>>2];wi=ri-qi|0;if((pi|0)==((wi?w(wi>>2,341)+ -1|0:0)|0)){re(si+8|0);ri=q[si+16>>2];qi=q[si+12>>2];pi=q[si+24>>2]+q[si+28>>2]|0}if((qi|0)==(ri|0)){pi=0}else{ri=(pi>>>0)/341|0;pi=q[(ri<<2)+qi>>2]+w(pi-w(ri,341)|0,12)|0}q[pi+8>>2]=xi;q[pi+4>>2]=ui;q[pi>>2]=ti;qi=q[si+28>>2]+1|0;q[si+28>>2]=qi;break e}if(!zi){break f}Ai=0;while(1){if(qi){ui=q[Ni>>2];xi=q[Mi>>2];vi=q[Fi>>2];wi=q[Ei>>2];qi=0;while(1){Bi=xi+(qi<<2)|0;q[ui+(q[Bi>>2]<<2)>>2]=0;pi=q[Bi>>2]<<2;Di=q[Ye>>2]-q[pi+wi>>2]|0;p:{if(!Di){break p}Ji=pi+ui|0;Ci=q[Ye+52>>2];ti=32-Ci|0;if((Di|0)<=(ti|0)){ri=q[Hi>>2];if((ri|0)==q[Ye+40>>2]){q[Ji>>2]=0;break p}q[Ji>>2]=q[ri>>2]<>>32-Di;pi=Di+q[Ye+52>>2]|0;q[Ye+52>>2]=pi;if((pi|0)!=32){break p}q[Ye+52>>2]=0;q[Hi>>2]=ri+4;break p}yi=q[Hi>>2];pi=yi+4|0;if((pi|0)==q[Ye+40>>2]){q[Ji>>2]=0;break p}ri=q[yi>>2];q[Hi>>2]=pi;pi=Di-ti|0;q[Ye+52>>2]=pi;q[Ji>>2]=q[yi+4>>2]>>>32-pi|ri<>>32-Di}ri=q[Bi>>2]<<2;pi=ri+ui|0;q[pi>>2]=q[pi>>2]|q[ri+vi>>2];qi=qi+1|0;if(qi>>>0>2]){continue}break}}ti=0;qi=q[ci+16>>2];q:{if((qi|0)==q[Gi>>2]){break q}while(1){qi=w(ti,20)+qi|0;ri=q[Ni>>2]+(q[qi+4>>2]<<2)|0;xi=q[qi>>2];ui=q[qi+12>>2];r:{if(ui>>>0>3){break r}pi=q[ci+12>>2];vi=qi+16|0;if(!q[vi>>2]){ri=pi;break r}wi=qi+12|0;qi=0;while(1){pi=Cn(pi,(qi<<2)+ri|0,ui);ui=q[wi>>2];pi=pi+ui|0;qi=qi+1|0;if(qi>>>0>2]){continue}break}ri=q[ci+12>>2]}qi=q[ci+28>>2];qi=r[xi+84|0]?qi:q[q[xi+68>>2]+(qi<<2)>>2];if(qi>>>0>=t[xi+80>>2]){break q}pi=q[xi+40>>2];Cn(q[q[xi>>2]>>2]+w(pi,qi)|0,ri,pi);ti=ti+1|0;qi=q[ci+16>>2];if(ti>>>0<(q[Gi>>2]-qi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Ai=Ai+1|0;if((Ai|0)==(zi|0)){break f}qi=q[Ye+12>>2];continue}}qi=q[si+28>>2]}if(qi){continue}break}pi=1}se(si+8|0);qi=q[si+12>>2];Ye=q[si+16>>2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2]+(Yi<<2)>>2];if(Yi>>>0>=t[bj+80>>2]){break g}Xi=q[bj+40>>2];Cn(q[q[bj>>2]>>2]+w(Xi,Yi)|0,Zi,Xi);ej=ej+1|0;Yi=q[ci+16>>2];if(ej>>>0<(q[jj>>2]-Yi|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;cj=cj+1|0;if((aj|0)!=(cj|0)){continue}break}break f}i:{j:{k:{l:{if(aj>>>0<=2){Zi=q[pj>>2];q[Zi>>2]=$i;Xi=1;Yi=q[Ye+12>>2];if(Yi>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}Zi=Xi;Xi=Yi+12|0;hd(Zi+Xi|0,q[fj>>2],q[fj+4>>2]);Xi=bj+q[Xi+q[nj>>2]>>2]|0;q[Xi>>2]=q[Xi>>2]+(1<>2];cj=32-Zi|0;m:{if((Xi|0)<=(cj|0)){fj=q[lj>>2];if((fj|0)==q[Ye+20>>2]){Zi=0;break m}cj=q[fj>>2];dj=Xi+Zi|0;q[Ye+32>>2]=dj;Zi=cj<>>32-Xi;if((dj|0)!=32){break m}q[Ye+32>>2]=0;q[lj>>2]=fj+4;break m}fj=q[lj>>2];dj=fj+4|0;if((dj|0)==q[Ye+20>>2]){Zi=0;break m}gj=q[fj>>2];q[lj>>2]=dj;cj=Xi-cj|0;q[Ye+32>>2]=cj;Zi=q[fj+4>>2]>>>32-cj|gj<>>32-Xi}fj=ej+1|0;Xi=(aj>>>1)-Zi|0;Zi=aj-Xi|0;n:{if((Zi|0)==(Xi|0)){Zi=Xi;break n}aj=q[Ye+88>>2];if((aj|0)==q[sj>>2]){break k}cj=q[aj>>2];dj=q[Ye+92>>2];gj=dj+1|0;q[Ye+92>>2]=gj;cj=cj&-2147483648>>>dj;o:{if((gj|0)==32){q[Ye+92>>2]=0;q[Ye+88>>2]=aj+4;if(cj){break o}break k}if(!cj){break k}}}aj=Zi;Zi=Xi;break j}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>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;cj=cj+1|0;if((cj|0)==(aj|0)){break f}Yi=q[Ye+12>>2];continue}}Yi=q[_i+28>>2]}if(Yi){continue}break}Zi=1}se(_i+8|0);Yi=q[_i+12>>2];Ye=q[_i+16>>2];s:{if((Yi|0)==(Ye|0)){break s}while(1){An(q[Yi>>2]);Yi=Yi+4|0;if((Ye|0)!=(Yi|0)){continue}break}Ye=q[_i+16>>2];Zh=q[_i+12>>2];if((Ye|0)==(Zh|0)){break s}q[_i+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[_i+8>>2];if(Ye){An(Ye)}T=_i+32|0;return Zi}bn();F()}bn();F()}function ae(Ye,Zh,ci){var vj=0,wj=0,xj=0,yj=0,zj=0,Aj=0,Bj=0,Cj=0,Dj=0,Ej=0,Fj=0,Gj=0,Hj=0,Ij=0,Jj=0,Kj=0,Lj=0,Mj=0,Nj=0,Oj=0,Pj=0,Qj=0,Rj=0,Sj=0,Tj=0,Uj=0,Vj=0;yj=T-32|0;T=yj;vj=q[Ye+12>>2];q[yj+16>>2]=0;q[yj+8>>2]=0;q[yj+12>>2]=0;a:{if(vj){if(vj>>>0>=1073741824){break a}wj=vj<<2;xj=Mm(wj);q[yj+8>>2]=xj;q[yj+12>>2]=xj;q[yj+16>>2]=wj+xj;Aj=Dn(xj,0,wj);wj=vj;while(1){Aj=Aj+4|0;wj=wj+ -1|0;if(wj){continue}break}q[yj+12>>2]=Aj}zj=q[Ye+116>>2];wj=q[zj>>2];if(wj){q[zj+4>>2]=wj;An(wj);q[zj+8>>2]=0;q[zj>>2]=0;q[zj+4>>2]=0;vj=q[Ye+12>>2];Aj=q[yj+12>>2];xj=q[yj+8>>2]}q[zj>>2]=xj;q[zj+4>>2]=Aj;q[zj+8>>2]=q[yj+16>>2];Aj=0;q[yj+16>>2]=0;q[yj+8>>2]=0;q[yj+12>>2]=0;wj=0;b:{if(vj){if(vj>>>0>=1073741824){break b}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h>>>0){break d}xj=q[Oj>>2];Hj=w(Gj,12);Pj=Hj+q[Qj>>2]|0;Aj=ml(Ye,Pj,zj);if(Aj>>>0>=t[Ye+12>>2]){break d}Kj=xj+Hj|0;e:{Ij=Aj<<2;zj=q[Ye>>2]-q[Ij+q[Pj>>2]>>2]|0;if(!zj){if(!Fj){break e}Dj=0;while(1){zj=0;vj=q[ci+16>>2];f:{if((vj|0)==q[Lj>>2]){break f}while(1){vj=w(zj,20)+vj|0;xj=q[Kj>>2]+(q[vj+4>>2]<<2)|0;Ej=q[vj>>2];Aj=q[vj+12>>2];g:{if(Aj>>>0>3){break g}wj=q[ci+12>>2];Bj=vj+16|0;if(!q[Bj>>2]){xj=wj;break g}Cj=vj+12|0;vj=0;while(1){wj=Cn(wj,(vj<<2)+xj|0,Aj);Aj=q[Cj>>2];wj=wj+Aj|0;vj=vj+1|0;if(vj>>>0>2]){continue}break}xj=q[ci+12>>2]}vj=q[ci+28>>2];vj=r[Ej+84|0]?vj:q[q[Ej+68>>2]+(vj<<2)>>2];if(vj>>>0>=t[Ej+80>>2]){break f}wj=q[Ej+40>>2];Cn(q[q[Ej>>2]>>2]+w(wj,vj)|0,xj,wj);zj=zj+1|0;vj=q[ci+16>>2];if(zj>>>0<(q[Lj>>2]-vj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Dj=Dj+1|0;if((Fj|0)!=(Dj|0)){continue}break}break e}h:{i:{j:{k:{if(Fj>>>0<=2){xj=q[Rj>>2];q[xj>>2]=Aj;wj=1;vj=q[Ye+12>>2];if(vj>>>0>1){break k}break h}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}wj=q[Oj>>2];Dj=Gj+1|0;Ej=w(Dj,12);xj=wj+Ej|0;if((xj|0)!=(Kj|0)){hd(xj,q[Kj>>2],q[Kj+4>>2]);wj=q[Oj>>2]}wj=Ij+q[wj+Ej>>2]|0;q[wj>>2]=q[wj>>2]+(1<>2]=0;eh(Uj,z(Fj)^31,yj+4|0);xj=(Fj>>>1)-q[yj+4>>2]|0;wj=Fj-xj|0;l:{if((wj|0)==(xj|0)){wj=xj;break l}Bj=q[Ye+84>>2];if((Bj|0)==q[Vj>>2]){break j}Cj=q[Bj>>2];vj=q[Ye+88>>2];zj=vj+1|0;q[Ye+88>>2]=zj;vj=Cj&-2147483648>>>vj;m:{if((zj|0)==32){q[Ye+88>>2]=0;q[Ye+84>>2]=Bj+4;if(vj){break m}break j}if(!vj){break j}}}zj=wj;wj=xj;break i}while(1){Aj=(vj+ -1|0)==(Aj|0)?0:Aj+1|0;q[xj+(wj<<2)>>2]=Aj;wj=wj+1|0;vj=q[Ye+12>>2];if(wj>>>0>>0){continue}break}break h}zj=xj}Bj=q[Qj>>2];Cj=Bj+Hj|0;vj=q[Cj>>2];xj=vj+Ij|0;q[xj>>2]=q[xj>>2]+1;hd(Bj+Ej|0,vj,q[Cj+4>>2]);if(wj){xj=q[yj+28>>2]+q[yj+24>>2]|0;Bj=q[yj+16>>2];vj=q[yj+12>>2];Cj=Bj-vj|0;if((xj|0)==((Cj?w(Cj>>2,341)+ -1|0:0)|0)){re(yj+8|0);vj=q[yj+12>>2];Bj=q[yj+16>>2];xj=q[yj+24>>2]+q[yj+28>>2]|0}if((vj|0)==(Bj|0)){xj=0}else{Bj=vj;vj=(xj>>>0)/341|0;xj=q[Bj+(vj<<2)>>2]+w(xj-w(vj,341)|0,12)|0}q[xj+8>>2]=Gj;q[xj+4>>2]=Aj;q[xj>>2]=wj;q[yj+28>>2]=q[yj+28>>2]+1}if(!zj){break e}wj=q[yj+28>>2]+q[yj+24>>2]|0;xj=q[yj+16>>2];vj=q[yj+12>>2];Cj=xj-vj|0;if((wj|0)==((Cj?w(Cj>>2,341)+ -1|0:0)|0)){re(yj+8|0);xj=q[yj+16>>2];vj=q[yj+12>>2];wj=q[yj+24>>2]+q[yj+28>>2]|0}if((vj|0)==(xj|0)){wj=0}else{xj=(wj>>>0)/341|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}break}xj=q[ci+12>>2]}vj=q[ci+28>>2];vj=r[Dj+84|0]?vj:q[q[Dj+68>>2]+(vj<<2)>>2];if(vj>>>0>=t[Dj+80>>2]){break o}wj=q[Dj+40>>2];Cn(q[q[Dj>>2]>>2]+w(wj,vj)|0,xj,wj);zj=zj+1|0;vj=q[ci+16>>2];if(zj>>>0<(q[Lj>>2]-vj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Gj=Gj+1|0;if((Gj|0)==(Fj|0)){break e}vj=q[Ye+12>>2];continue}}vj=q[yj+28>>2];if(vj){continue}break}wj=1}se(yj+8|0);vj=q[yj+12>>2];Ye=q[yj+16>>2];q:{if((vj|0)==(Ye|0)){break q}while(1){An(q[vj>>2]);vj=vj+4|0;if((Ye|0)!=(vj|0)){continue}break}Zh=q[yj+16>>2];Ye=q[yj+12>>2];if((Zh|0)==(Ye|0)){break q}q[yj+16>>2]=Zh+(((Zh-Ye|0)+ -4>>>2^-1)<<2)}Ye=q[yj+8>>2];if(Ye){An(Ye)}T=yj+32|0;return wj}bn();F()}bn();F()}function be(Ye,Zh,ci){var Wj=0,Xj=0,Yj=0,Zj=0,_j=0,$j=0,ak=0,bk=0,ck=0,dk=0,ek=0,fk=0,gk=0,hk=0,ik=0,jk=0,kk=0,lk=0,mk=0,nk=0,ok=0,pk=0,qk=0,rk=0,sk=0,tk=0,uk=0;Zj=T-32|0;T=Zj;Xj=q[Ye+12>>2];q[Zj+16>>2]=0;q[Zj+8>>2]=0;q[Zj+12>>2]=0;a:{if(Xj){if(Xj>>>0>=1073741824){break a}Wj=Xj<<2;Yj=Mm(Wj);q[Zj+8>>2]=Yj;q[Zj+12>>2]=Yj;q[Zj+16>>2]=Wj+Yj;_j=Dn(Yj,0,Wj);Wj=Xj;while(1){_j=_j+4|0;Wj=Wj+ -1|0;if(Wj){continue}break}q[Zj+12>>2]=_j}Wj=q[Ye+116>>2];$j=q[Wj>>2];if($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+_j|0;q[Yj>>2]=q[Yj>>2]|q[Wj+sk>>2];Xj=Xj+1|0;if(Xj>>>0>2]){continue}break}}ck=0;Xj=q[ci+16>>2];o:{if((Xj|0)==q[hk>>2]){break o}while(1){Xj=w(ck,20)+Xj|0;Yj=q[nk>>2]+(q[Xj+4>>2]<<2)|0;ak=q[Xj>>2];_j=q[Xj+12>>2];p:{if(_j>>>0>3){break p}Wj=q[ci+12>>2];dk=Xj+16|0;if(!q[dk>>2]){Yj=Wj;break p}jk=Xj+12|0;Xj=0;while(1){Wj=Cn(Wj,(Xj<<2)+Yj|0,_j);_j=q[jk>>2];Wj=Wj+_j|0;Xj=Xj+1|0;if(Xj>>>0>2]){continue}break}Yj=q[ci+12>>2]}Xj=q[ci+28>>2];Xj=r[ak+84|0]?Xj:q[q[ak+68>>2]+(Xj<<2)>>2];if(Xj>>>0>=t[ak+80>>2]){break o}Wj=q[ak+40>>2];Cn(q[q[ak>>2]>>2]+w(Wj,Xj)|0,Yj,Wj);ck=ck+1|0;Xj=q[ci+16>>2];if(ck>>>0<(q[hk>>2]-Xj|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;bk=bk+1|0;if((bk|0)==($j|0)){break e}Xj=q[Ye+12>>2];continue}}Xj=q[Zj+28>>2];if(Xj){continue}break}Yj=1}se(Zj+8|0);Xj=q[Zj+12>>2];Ye=q[Zj+16>>2];q:{if((Xj|0)==(Ye|0)){break q}while(1){An(q[Xj>>2]);Xj=Xj+4|0;if((Ye|0)!=(Xj|0)){continue}break}Ye=q[Zj+16>>2];Zh=q[Zj+12>>2];if((Ye|0)==(Zh|0)){break q}q[Zj+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[Zj+8>>2];if(Ye){An(Ye)}T=Zj+32|0;return Yj}bn();F()}bn();F()}function ce(Ye,Zh,ci){var vk=0,wk=0,xk=0,yk=0,zk=0,Ak=0,Bk=0,Ck=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2];wk=wk+Ak|0;vk=vk+1|0;if(vk>>>0>2]){continue}break}xk=q[ci+12>>2]}vk=q[ci+28>>2];vk=r[Bk+84|0]?vk:q[q[Bk+68>>2]+(vk<<2)>>2];if(vk>>>0>=t[Bk+80>>2]){break g}wk=vk;vk=q[Bk+40>>2];Cn(q[q[Bk>>2]>>2]+w(wk,vk)|0,xk,vk);Ck=Ck+1|0;vk=q[ci+16>>2];if(Ck>>>0<(q[Jk>>2]-vk|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Gk=Gk+1|0;if((zk|0)!=(Gk|0)){continue}break}break f}i:{j:{k:{l:{if(zk>>>0<=2){xk=q[Nk>>2];q[xk>>2]=Ak;wk=1;vk=q[Ye+12>>2];if(vk>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}xk=q[Lk>>2];Ek=Ck+1|0;Gk=w(Ek,12);wk=xk+Gk|0;if((wk|0)!=(Dk|0)){hd(wk,q[Dk>>2],q[Dk+4>>2]);xk=q[Lk>>2]}xk=Fk+q[xk+Gk>>2]|0;q[xk>>2]=q[xk>>2]+(1<>>1)-wk|0;vk=zk-wk|0;m:{if((vk|0)==(wk|0)){vk=wk;break m}xk=q[Ye+596>>2];if((xk|0)==q[Rk>>2]){break k}zk=q[xk>>2];Dk=q[Ye+600>>2];Hk=Dk+1|0;q[Ye+600>>2]=Hk;zk=zk&-2147483648>>>Dk;n:{if((Hk|0)==32){q[Ye+600>>2]=0;q[Ye+596>>2]=xk+4;if(zk){break n}break k}if(!zk){break k}}}xk=vk;vk=wk;break j}while(1){Ak=(vk+ -1|0)==(Ak|0)?0:Ak+1|0;q[xk+(wk<<2)>>2]=Ak;wk=wk+1|0;vk=q[Ye+12>>2];if(wk>>>0>>0){continue}break}break i}xk=wk}wk=q[Mk>>2];zk=wk+Bk|0;Dk=q[zk>>2];Bk=Dk+Fk|0;q[Bk>>2]=q[Bk>>2]+1;hd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q[Ye+560>>2]=xk;if((xk|0)!=32){break p}q[Ye+560>>2]=0;q[Kk>>2]=Ek+4;break p}Ek=q[Kk>>2];Qk=Ek+4|0;if((Qk|0)==q[Pk>>2]){q[wk>>2]=0;break p}Uk=q[Ek>>2];q[Kk>>2]=Qk;Ik=xk-Ik|0;q[Ye+560>>2]=Ik;q[wk>>2]=q[Ek+4>>2]>>>32-Ik|Uk<>>32-xk}xk=q[Ck>>2]<<2;wk=xk+Ak|0;q[wk>>2]=q[wk>>2]|q[xk+Sk>>2];vk=vk+1|0;if(vk>>>0>2]){continue}break}}Ck=0;vk=q[ci+16>>2];q:{if((vk|0)==q[Jk>>2]){break q}while(1){vk=w(Ck,20)+vk|0;xk=q[Ok>>2]+(q[vk+4>>2]<<2)|0;Bk=q[vk>>2];Ak=q[vk+12>>2];r:{if(Ak>>>0>3){break r}wk=q[ci+12>>2];Ek=vk+16|0;if(!q[Ek>>2]){xk=wk;break r}Hk=vk+12|0;vk=0;while(1){wk=Cn(wk,(vk<<2)+xk|0,Ak);Ak=q[Hk>>2];wk=wk+Ak|0;vk=vk+1|0;if(vk>>>0>2]){continue}break}xk=q[ci+12>>2]}vk=q[ci+28>>2];vk=r[Bk+84|0]?vk:q[q[Bk+68>>2]+(vk<<2)>>2];if(vk>>>0>=t[Bk+80>>2]){break q}wk=vk;vk=q[Bk+40>>2];Cn(q[q[Bk>>2]>>2]+w(wk,vk)|0,xk,vk);Ck=Ck+1|0;vk=q[ci+16>>2];if(Ck>>>0<(q[Jk>>2]-vk|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Fk=Fk+1|0;if((Fk|0)==(zk|0)){break f}vk=q[Ye+12>>2];continue}}vk=q[yk+28>>2]}if(vk){continue}break}wk=1}se(yk+8|0);vk=q[yk+12>>2];Ye=q[yk+16>>2];s:{if((vk|0)==(Ye|0)){break s}while(1){An(q[vk>>2]);vk=vk+4|0;if((Ye|0)!=(vk|0)){continue}break}Ye=q[yk+16>>2];Zh=q[yk+12>>2];if((Ye|0)==(Zh|0)){break s}q[yk+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[yk+8>>2];if(Ye){An(Ye)}T=yk+32|0;return wk}bn();F()}bn();F()}function de(q){ah(q);ah(q+16|0);ah(q+32|0);ah(q+48|0);ah(q- -64|0);ah(q+80|0);ah(q+96|0);ah(q+112|0);ah(q+128|0);ah(q+144|0);ah(q+160|0);ah(q+176|0);ah(q+192|0);ah(q+208|0);ah(q+224|0);ah(q+240|0);ah(q+256|0);ah(q+272|0);ah(q+288|0);ah(q+304|0);ah(q+320|0);ah(q+336|0);ah(q+352|0);ah(q+368|0);ah(q+384|0);ah(q+400|0);ah(q+416|0);ah(q+432|0);ah(q+448|0);ah(q+464|0);ah(q+480|0);ah(q+496|0)}function ee(Ye,Zh,ci){var Vk=0,Wk=0,Xk=0,Yk=0,Zk=0,_k=0,$k=0,al=0,bl=0,cl=0,dl=0,el=0,fl=0,gl=0,hl=0,il=0,jl=0,kl=0,ll=0,ml=0,nl=0,ol=0,pl=0,ql=0,rl=0,sl=0;Yk=T-32|0;T=Yk;Vk=q[Ye+12>>2];q[Yk+16>>2]=0;q[Yk+8>>2]=0;q[Yk+12>>2]=0;a:{if(Vk){if(Vk>>>0>=1073741824){break a}Wk=Vk<<2;Xk=Mm(Wk);q[Yk+8>>2]=Xk;q[Yk+12>>2]=Xk;q[Yk+16>>2]=Wk+Xk;Zk=Dn(Xk,0,Wk);Wk=Vk;while(1){Zk=Zk+4|0;Wk=Wk+ -1|0;if(Wk){continue}break}q[Yk+12>>2]=Zk}Wk=q[Ye+628>>2];_k=q[Wk>>2];if(_k){q[Wk+4>>2]=_k;An(_k);q[Wk+8>>2]=0;q[Wk>>2]=0;q[Wk+4>>2]=0;Vk=q[Ye+12>>2];Zk=q[Yk+12>>2];Xk=q[Yk+8>>2]}q[Wk>>2]=Xk;q[Wk+4>>2]=Zk;q[W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];Zk=q[Vk+12>>2];r:{if(Zk>>>0>3){break r}Wk=q[ci+12>>2];cl=Vk+16|0;if(!q[cl>>2]){Xk=Wk;break r}il=Vk+12|0;Vk=0;while(1){Wk=Cn(Wk,(Vk<<2)+Xk|0,Zk);Zk=q[il>>2];Wk=Wk+Zk|0;Vk=Vk+1|0;if(Vk>>>0>2]){continue}break}Xk=q[ci+12>>2]}Vk=q[ci+28>>2];Vk=r[al+84|0]?Vk:q[q[al+68>>2]+(Vk<<2)>>2];if(Vk>>>0>=t[al+80>>2]){break q}Wk=Vk;Vk=q[al+40>>2];Cn(q[q[al>>2]>>2]+w(Wk,Vk)|0,Xk,Vk);$k=$k+1|0;Vk=q[ci+16>>2];if($k>>>0<(q[gl>>2]-Vk|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;bl=bl+1|0;if((bl|0)==(_k|0)){break f}Vk=q[Ye+12>>2];continue}}Vk=q[Yk+28>>2]}if(Vk){continue}break}Xk=1}se(Yk+8|0);Vk=q[Yk+12>>2];Ye=q[Yk+16>>2];s:{if((Vk|0)==(Ye|0)){break s}while(1){An(q[Vk>>2]);Vk=Vk+4|0;if((Ye|0)!=(Vk|0)){continue}break}Ye=q[Yk+16>>2];Zh=q[Yk+12>>2];if((Ye|0)==(Zh|0)){break s}q[Yk+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[Yk+8>>2];if(Ye){An(Ye)}T=Yk+32|0;return Xk}bn();F()}bn();F()}function fe(Ye,Zh,ci){var tl=0,ul=0,vl=0,wl=0,xl=0,yl=0,zl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0,Ml=0,Nl=0,Ol=0,Pl=0,Ql=0,Rl=0,Sl=0;wl=T-32|0;T=wl;tl=q[Ye+12>>2];q[wl+16>>2]=0;q[wl+8>>2]=0;q[wl+12>>2]=0;a:{if(tl){if(tl>>>0>=1073741824){break a}ul=tl<<2;vl=Mm(ul);q[wl+8>>2]=vl;q[wl+12>>2]=vl;q[wl+16>>2]=ul+vl;yl=Dn(vl,0,ul);ul=tl;while(1){yl=yl+4|0;ul=ul+ -1|0;if(ul){continue}break}q[wl+12>>2]=yl}ul=q[Ye+628>>2];xl=q[ul>>2];if(xl){q[ul+4>>2]=xl;An(xl);q[ul+8>>2]=0;q[ul>>2]=0;q[ul+4>>2]=0;tl=q[Ye+12>>2];yl=q[wl+12>>2];vl=q[wl+8>>2]}q[ul>>2]=vl;q[ul+4>>2]=yl;q[ul+8>>2]=q[wl+16>>2];yl=0;q[wl+16>>2]=0;q[wl+8>>2]=0;q[wl+12>>2]=0;ul=0;b:{if(tl){if(tl>>>0>=1073741824){break b}vl=tl<<2;ul=Mm(vl);q[wl+8>>2]=ul;q[wl+12>>2]=ul;q[wl+16>>2]=ul+vl;yl=Dn(ul,0,vl);while(1){yl=yl+4|0;tl=tl+ -1|0;if(tl){continue}break}q[wl+12>>2]=yl}vl=q[Ye+640>>2];tl=q[vl>>2];if(tl){q[vl+4>>2]=tl;An(tl);q[vl+8>>2]=0;q[vl>>2]=0;q[vl+4>>2]=0;yl=q[wl+12>>2];ul=q[wl+8>>2]}q[vl>>2]=ul;q[vl+4>>2]=yl;q[vl+8>>2]=q[wl+16>>2];tl=wl+24|0;q[tl>>2]=0;q[tl+4>>2]=0;ul=wl+16|0;q[ul>>2]=0;q[ul+4>>2]=0;q[wl+8>>2]=0;q[wl+12>>2]=0;re(wl+8|0);xl=q[ul>>2];ul=q[wl+12>>2];vl=0;c:{if((xl|0)==(ul|0)){break c}vl=q[tl>>2]+q[wl+28>>2]|0;tl=(vl>>>0)/341|0;vl=q[ul+(tl<<2)>>2]+w(vl-w(tl,341)|0,12)|0}q[vl+4>>2]=0;q[vl+8>>2]=0;q[vl>>2]=Zh;ul=1;vl=q[wl+28>>2];tl=vl+1|0;q[wl+28>>2]=tl;d:{if(tl>>>0>>0){break d}Kl=Ye+640|0;Jl=Ye+628|0;Hl=ci+20|0;Ll=Ye+616|0;Ml=Ye+604|0;Il=Ye+556|0;Nl=Ye+548|0;Pl=Ye+588|0;while(1){Bl=q[wl+12>>2];ul=q[wl+24>>2];yl=tl+ -1|0;vl=ul+yl|0;xl=(vl>>>0)/341|0;vl=q[Bl+(xl<<2)>>2]+w(vl-w(xl,341)|0,12)|0;Al=q[vl+8>>2];xl=q[vl>>2];q[wl+28>>2]=yl;vl=q[wl+16>>2];yl=vl-Bl|0;if(((yl?w(yl>>2,341)+ -1|0:0)-(tl+ul|0)|0)+1>>>0>=682){An(q[vl+ -4>>2]);q[wl+16>>2]=q[wl+16>>2]+ -4}ul=0;if(xl>>>0>Zh>>>0){break d}vl=q[Jl>>2];zl=w(Al,12);Dl=zl+q[Kl>>2]|0;yl=nl(Ye,xl,Dl);if(yl>>>0>=t[Ye+12>>2]){break d}Bl=vl+zl|0;e:{f:{El=yl<<2;tl=q[Ye>>2]-q[El+q[Dl>>2]>>2]|0;if(!tl){if(!xl){break f}Dl=0;while(1){Al=0;tl=q[ci+16>>2];g:{if((tl|0)==q[Hl>>2]){break g}while(1){tl=w(Al,20)+tl|0;vl=q[Bl>>2]+(q[tl+4>>2]<<2)|0;zl=q[tl>>2];yl=q[tl+12>>2];h:{if(yl>>>0>3){break h}ul=q[ci+12>>2];El=tl+16|0;if(!q[El>>2]){vl=ul;break h}Cl=tl+12|0;tl=0;while(1){ul=Cn(ul,(tl<<2)+vl|0,yl);yl=q[Cl>>2];ul=ul+yl|0;tl=tl+1|0;if(tl>>>0>2]){continue}break}vl=q[ci+12>>2]}tl=q[ci+28>>2];tl=r[zl+84|0]?tl:q[q[zl+68>>2]+(tl<<2)>>2];if(tl>>>0>=t[zl+80>>2]){break g}ul=tl;tl=q[zl+40>>2];Cn(q[q[zl>>2]>>2]+w(ul,tl)|0,vl,tl);Al=Al+1|0;tl=q[ci+16>>2];if(Al>>>0<(q[Hl>>2]-tl|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;Dl=Dl+1|0;if((xl|0)!=(Dl|0)){continue}break}break f}i:{j:{k:{l:{if(xl>>>0<=2){vl=q[Ll>>2];q[vl>>2]=yl;ul=1;tl=q[Ye+12>>2];if(tl>>>0>1){break l}break i}if(t[Ye+8>>2]>t[Ye+4>>2]){break d}vl=q[Jl>>2];Cl=Al+1|0;Dl=w(Cl,12);ul=vl+Dl|0;if((ul|0)!=(Bl|0)){hd(ul,q[Bl>>2],q[Bl+4>>2]);vl=q[Jl>>2]}vl=El+q[vl+Dl>>2]|0;q[vl>>2]=q[vl>>2]+(1<>>1)-ul|0;tl=xl-ul|0;m:{if((tl|0)==(ul|0)){tl=ul;break m}vl=q[Ye+596>>2];if((vl|0)==q[Pl>>2]){break k}xl=q[vl>>2];Bl=q[Ye+600>>2];Fl=Bl+1|0;q[Ye+600>>2]=Fl;xl=xl&-2147483648>>>Bl;n:{if((Fl|0)==32){q[Ye+600>>2]=0;q[Ye+596>>2]=vl+4;if(xl){break n}break k}if(!xl){break k}}}vl=tl;tl=ul;break j}while(1){yl=(tl+ -1|0)==(yl|0)?0:yl+1|0;q[vl+(ul<<2)>>2]=yl;ul=ul+1|0;tl=q[Ye+12>>2];if(ul>>>0>>0){continue}break}break i}vl=ul}ul=q[Kl>>2];xl=ul+zl|0;Bl=q[xl>>2];zl=Bl+El|0;q[zl>>2]=q[zl>>2]+1;hd(ul+Dl|0,Bl,q[xl+4>>2]);if(tl){Bl=q[wl+28>>2]+q[wl+24>>2]|0;zl=q[wl+16>>2];ul=q[wl+12>>2];xl=zl-ul|0;if((Bl|0)==((xl?w(xl>>2,341)+ -1|0:0)|0)){re(wl+8|0);Bl=q[wl+24>>2]+q[wl+28>>2]|0;zl=q[wl+16>>2];ul=q[wl+12>>2]}xl=0;o:{if((ul|0)==(zl|0)){break o}xl=ul;ul=(Bl>>>0)/341|0;xl=q[xl+(ul<<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;if(tl>>>0>2]){continue}break}}Al=0;tl=q[ci+16>>2];q:{if((tl|0)==q[Hl>>2]){break q}while(1){tl=w(Al,20)+tl|0;vl=q[Ml>>2]+(q[tl+4>>2]<<2)|0;zl=q[tl>>2];yl=q[tl+12>>2];r:{if(yl>>>0>3){break r}ul=q[ci+12>>2];Cl=tl+16|0;if(!q[Cl>>2]){vl=ul;break r}Fl=tl+12|0;tl=0;while(1){ul=Cn(ul,(tl<<2)+vl|0,yl);yl=q[Fl>>2];ul=ul+yl|0;tl=tl+1|0;if(tl>>>0>2]){continue}break}vl=q[ci+12>>2]}tl=q[ci+28>>2];tl=r[zl+84|0]?tl:q[q[zl+68>>2]+(tl<<2)>>2];if(tl>>>0>=t[zl+80>>2]){break q}ul=tl;tl=q[zl+40>>2];Cn(q[q[zl>>2]>>2]+w(ul,tl)|0,vl,tl);Al=Al+1|0;tl=q[ci+16>>2];if(Al>>>0<(q[Hl>>2]-tl|0)/20>>>0){continue}break}}q[ci+28>>2]=q[ci+28>>2]+1;q[Ye+8>>2]=q[Ye+8>>2]+1;El=El+1|0;if((El|0)==(xl|0)){break f}tl=q[Ye+12>>2];continue}}tl=q[wl+28>>2]}if(tl){continue}break}ul=1}se(wl+8|0);tl=q[wl+12>>2];Ye=q[wl+16>>2];s:{if((tl|0)==(Ye|0)){break s}while(1){An(q[tl>>2]);tl=tl+4|0;if((Ye|0)!=(tl|0)){continue}break}Ye=q[wl+16>>2];Zh=q[wl+12>>2];if((Ye|0)==(Zh|0)){break s}q[wl+16>>2]=Ye+(((Ye-Zh|0)+ -4>>>2^-1)<<2)}Ye=q[wl+8>>2];if(Ye){An(Ye)}T=wl+32|0;return ul}bn();F()}bn();F()}function ge(Ye,Zh){Ye=Ye|0;Zh=Zh|0;var ci=0,Tl=0,Ul=0,Vl=0,Wl=0,Xl=0,Zl=0,_l=0,$l=0,am=0,bm=0,cm=0,dm=0,em=0,fm=0,gm=0,hm=0,im=0,jm=0;Ul=T-720|0;T=Ul;a:{b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;q[Tl+72>>2]=q[Tl+68>>2];ci=ci+1|0;if((am|0)!=(ci|0)){continue}break}}Wl=1;Ye=Ld(Ul+672|0,Ul+704|0);k:{if(Zl>>>0>6){break k}l:{m:{switch(Zl-1|0){default:ci=Od(Ul+16|0,Xl);Zh=Md(ci,Zh,Ye);Nd(ci);if(Zh){break l}break k;case 0:ci=Od(Ul+16|0,Xl);Zh=Pd(ci,Zh,Ye);Nd(ci);if(Zh){break l}break k;case 1:ci=Sd(Ul+16|0,Xl);Zh=Qd(ci,Zh,Ye);Rd(ci);if(Zh){break l}break k;case 2:ci=Sd(Ul+16|0,Xl);Zh=Td(ci,Zh,Ye);Rd(ci);if(Zh){break l}break k;case 3:ci=Wd(Ul+16|0,Xl);Zh=Ud(ci,Zh,Ye);Vd(ci);if(Zh){break l}break k;case 4:ci=Wd(Ul+16|0,Xl);Zh=Xd(ci,Zh,Ye);Vd(ci);if(Zh){break l}break k;case 5:break m}}ci=Wd(Ul+16|0,Xl);Zh=Yd(ci,Zh,Ye);Vd(ci);if(!Zh){break k}}Wl=0}Zh=q[Ye+16>>2];if(Zh){q[Ye+20>>2]=Zh;An(Zh)}Zh=q[Ye>>2];if(Zh){q[Ye+4>>2]=Zh;An(Zh)}if(Wl){break h}}gm=1}Ye=q[Ul+704>>2];if(!Ye){break a}q[Ul+708>>2]=Ye;An(Ye);break a}bn();F()}bn();F()}Ye=q[Ul+672>>2];if(!Ye){break a}q[Ul+676>>2]=Ye;An(Ye)}T=Ul+720|0;return gm|0}function he(Ye,Zh,Yl){var km=0,lm=0,mm=0,nm=0;a:{if(Ye>>>0>5){break a}mm=q[Yl+16>>2];km=q[Yl+12>>2];lm=q[Yl+20>>2];if((km|0)<(lm|0)?1:(km|0)<=(lm|0)?t[Yl+8>>2]>mm>>>0?0:1:0){break a}km=r[mm+q[Yl>>2]|0];mm=mm+1|0;if(mm>>>0<1){lm=lm+1|0}q[Yl+16>>2]=mm;q[Yl+20>>2]=lm;lm=Zh;if(km&128){if(!he(Ye+1|0,Zh,Yl)){break a}Ye=q[Zh>>2]<<7;q[Zh>>2]=Ye;km=Ye|km&127}q[lm>>2]=km;nm=1}return nm}function ie(Ye,Zh){var Yl=0,om=0,pm=0,qm=0,rm=0,sm=0,tm=0;a:{b:{c:{om=q[Ye>>2];rm=(q[Ye+4>>2]-om|0)/24|0;Yl=rm+1|0;if(Yl>>>0<178956971){om=(q[Ye+8>>2]-om|0)/24|0;sm=om<<1;om=om>>>0<89478485?sm>>>0>>0?Yl:sm:178956970;pm=0;d:{if(!om){break d}if(om>>>0>=178956971){break c}pm=Mm(w(om,24))}Yl=pm+w(rm,24)|0;ve(Yl,Zh);rm=pm+w(om,24)|0;sm=Yl+24|0;Zh=q[Ye+4>>2];pm=q[Ye>>2];if((Zh|0)==(pm|0)){break b}while(1){Yl=Yl+ -24|0;q[Yl>>2]=1232;om=q[Zh+ -20>>2];qm=Yl+16|0;q[qm>>2]=0;q[Yl+8>>2]=0;q[Yl+12>>2]=0;q[Yl+4>>2]=om;om=Zh+ -16|0;q[Yl+8>>2]=q[om>>2];q[Yl+12>>2]=q[Zh+ -12>>2];tm=qm;qm=Zh+ -8|0;q[tm>>2]=q[qm>>2];q[qm>>2]=0;q[om>>2]=0;q[om+4>>2]=0;q[Yl+20>>2]=q[Zh+ -4>>2];Zh=Zh+ -24|0;if((pm|0)!=(Zh|0)){continue}break}pm=q[Ye+4>>2];Zh=q[Ye>>2];break a}bn();F()}ab(1780);F()}Zh=pm}q[Ye>>2]=Yl;q[Ye+8>>2]=rm;q[Ye+4>>2]=sm;if((Zh|0)!=(pm|0)){while(1){pm=pm+ -24|0;n[q[q[pm>>2]>>2]](pm)|0;if((Zh|0)!=(pm|0)){continue}break}}if(Zh){An(Zh)}}function je(Ye,Zh,um){var vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0,Cm=0,Dm=0,Em=0;wm=T-32|0;T=wm;q[wm+24>>2]=0;q[wm+16>>2]=0;q[wm+20>>2]=0;zm=q[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i}j:{switch(Zh-1|0){case 3:Zh=1;if(me(Ye,Qm,Wm)){break i}break h;case 1:Zh=1;if(ne(Ye,Qm,Wm)){break i}break h;case 0:case 2:break i;default:break j}}Zh=1;if(!oe(Ye,Qm,Wm)){break h}}Wm=o[Fm|0]+Wm|0;Zh=0}Fm=q[Om>>2];if(Fm){q[Om+4>>2]=Fm;An(Fm)}Fm=q[Om+16>>2];if(Fm){q[Om+20>>2]=Fm;An(Fm)}if(!Zh){break f}break d;case 0:case 2:case 4:case 5:case 6:break f;case 7:break g}}Sm=q[q[Zm>>2]+(Rm<<2)>>2];Vm=q[_m>>2];Zh=n[q[q[Ye>>2]+28>>2]](Ye)|0;Pm=q[Qm+56>>2];Tm=q[Zh+40>>2];Zh=Mm(32);q[Om+16>>2]=Zh;q[Om+20>>2]=24;q[Om+24>>2]=-2147483616;o[Zh+24|0]=0;Fm=r[1726]|r[1727]<<8|(r[1728]<<16|r[1729]<<24);um=r[1722]|r[1723]<<8|(r[1724]<<16|r[1725]<<24);o[Zh+16|0]=um;o[Zh+17|0]=um>>>8;o[Zh+18|0]=um>>>16;o[Zh+19|0]=um>>>24;o[Zh+20|0]=Fm;o[Zh+21|0]=Fm>>>8;o[Zh+22|0]=Fm>>>16;o[Zh+23|0]=Fm>>>24;Fm=r[1718]|r[1719]<<8|(r[1720]<<16|r[1721]<<24);um=r[1714]|r[1715]<<8|(r[1716]<<16|r[1717]<<24);o[Zh+8|0]=um;o[Zh+9|0]=um>>>8;o[Zh+10|0]=um>>>16;o[Zh+11|0]=um>>>24;o[Zh+12|0]=Fm;o[Zh+13|0]=Fm>>>8;o[Zh+14|0]=Fm>>>16;o[Zh+15|0]=Fm>>>24;Fm=r[1710]|r[1711]<<8|(r[1712]<<16|r[1713]<<24);um=r[1706]|r[1707]<<8|(r[1708]<<16|r[1709]<<24);o[Zh|0]=um;o[Zh+1|0]=um>>>8;o[Zh+2|0]=um>>>16;o[Zh+3|0]=um>>>24;o[Zh+4|0]=Fm;o[Zh+5|0]=Fm>>>8;o[Zh+6|0]=Fm>>>16;o[Zh+7|0]=Fm>>>24;k:{l:{Fm=Tm+16|0;um=Fm;Zh=q[um>>2];if(!Zh){break l}while(1){Um=q[Zh+16>>2]<(Pm|0);um=Um?um:Zh;Zh=q[(Um<<2)+Zh>>2];if(Zh){continue}break}if((um|0)==(Fm|0)|(Pm|0)>2]){break l}Zh=um+20|0;if(!ga(Zh,Om+16|0)){break l}Zh=gk(Zh,Om+16|0);break k}Zh=gk(Tm,Om+16|0)}if(o[Om+27|0]<=-1){An(q[Om+16>>2])}Fm=Rm+1|0;m:{if(Zh){ud(Qm,Sm);break m}Zh=Vm+w(Rm,24)|0;um=q[Zh+4>>2];Rm=o[Qm+24|0];Vm=Rm<<2;Pm=Mm((Rm|0)!=(Rm&1073741823)?-1:Vm);if(!ik(hk(Om+16|0),u[Zh+20>>2],-1<>2]){$m=q[q[Sm>>2]>>2]+q[Sm+48>>2]|0;an=Zh+8|0;Um=0;Tm=0;um=0;while(1){if((Rm|0)>=1){cn=q[an>>2];Zh=0;dn=u[Om+16>>2];while(1){Ym=Zh<<2;u[Ym+Pm>>2]=x(dn*x(q[$m+(um<<2)>>2]))+u[cn+Ym>>2];um=um+1|0;Zh=Zh+1|0;if((Rm|0)!=(Zh|0)){continue}break}}Cn(q[q[Qm- -64>>2]>>2]+Tm|0,Pm,Vm);Tm=Tm+Vm|0;Um=Um+1|0;if(Um>>>0>2]){continue}break}}An(Pm)}Rm=Fm}Zh=1;Xm=Xm+1|0;if((Xm|0)<(n[q[q[Ye>>2]+24>>2]](Ye)|0)){continue}break c}break}An(Pm)}Zh=0}T=Om+32|0;return Zh|0}bn();F()}bn();F()}function me(Ye,en,fn){var gn=0,hn=0,jn=0,kn=0,ln=0,mn=0,nn=0,on=0,pn=0,qn=0,rn=0,sn=0,tn=0,un=0,vn=0;hn=T-16|0;T=hn;gn=o[en+24|0];q[hn+8>>2]=0;q[hn>>2]=0;q[hn+4>>2]=0;a:{b:{if(gn){if((gn|0)<=-1){break b}jn=gn<<2;kn=Mm(jn);q[hn>>2]=kn;ln=jn+kn|0;q[hn+8>>2]=ln;Dn(kn,0,jn);q[hn+4>>2]=ln;pn=Mm(jn);jn=Dn(pn,0,jn)}else{jn=0}if(!q[en+80>>2]){break a}sn=en+40|0;un=en+48|0;vn=Ye+48|0;while(1){tn=q[en>>2];mn=q[tn>>2];qn=q[un>>2];Ye=q[sn>>2];ln=$n(Ye,q[sn+4>>2],rn,nn);on=mn;mn=ln+qn|0;ln=Cn(kn,on+mn|0,Ye);if(gn<<24>>24>=1){mn=gn&255;qn=q[vn>>2];gn=0;while(1){on=gn<<2;q[on+jn>>2]=q[(fn+gn<<2)+qn>>2]+q[ln+on>>2];gn=gn+1|0;if(gn>>>0>>0){continue}break}}Cn(q[tn>>2]+w(Ye,rn)|0,pn,Ye);Ye=rn+1|0;if(Ye>>>0<1){nn=nn+1|0}rn=Ye;if(!nn&Ye>>>0>=t[en+80>>2]|nn>>>0>0){break a}gn=r[en+24|0];continue}}bn();F()}if(jn){An(pn)}if(kn){q[hn+4>>2]=kn;An(kn)}T=hn+16|0;return 1}function ne(Ye,en,fn){var wn=0,xn=0,yn=0,zn=0,Bn=0,En=0,Fn=0,Gn=0,Hn=0,In=0,Jn=0,Kn=0,Ln=0,Mn=0,Nn=0;xn=T-16|0;T=xn;wn=o[en+24|0];q[xn+8>>2]=0;q[xn>>2]=0;q[xn+4>>2]=0;a:{b:{if(wn){if((wn|0)<=-1){break b}yn=wn<<1;zn=Mm(yn);q[xn>>2]=zn;Bn=yn+zn|0;q[xn+8>>2]=Bn;Dn(zn,0,yn);q[xn+4>>2]=Bn;Hn=Mm(yn);yn=Dn(Hn,0,yn)}else{yn=0}if(!q[en+80>>2]){break a}Kn=en+40|0;Mn=en+48|0;Nn=Ye+48|0;while(1){Ln=q[en>>2];En=q[Ln>>2];In=q[Mn>>2];Ye=q[Kn>>2];Bn=$n(Ye,q[Kn+4>>2],Jn,Fn);Gn=En;En=Bn+In|0;Bn=Cn(zn,Gn+En|0,Ye);if(wn<<24>>24>=1){En=wn&255;In=q[Nn>>2];wn=0;while(1){Gn=wn<<1;p[Gn+yn>>1]=s[Bn+Gn>>1]+s[(fn+wn<<2)+In>>1];wn=wn+1|0;if(wn>>>0>>0){continue}break}}Cn(q[Ln>>2]+w(Ye,Jn)|0,Hn,Ye);Ye=Jn+1|0;if(Ye>>>0<1){Fn=Fn+1|0}Jn=Ye;if(!Fn&Ye>>>0>=t[en+80>>2]|Fn>>>0>0){break a}wn=r[en+24|0];continue}}bn();F()}if(yn){An(Hn)}if(zn){q[xn+4>>2]=zn;An(zn)}T=xn+16|0;return 1}function oe(Ye,en,fn){var Dn=0,On=0,Pn=0,Qn=0,Rn=0,Sn=0,Tn=0,Un=0,Vn=0,Wn=0;On=T-32|0;T=On;Dn=o[en+24|0];q[On+24>>2]=0;q[On+16>>2]=0;q[On+20>>2]=0;a:{b:{c:{if(Dn){if((Dn|0)<=-1){break c}Pn=Mm(Dn);q[On+16>>2]=Pn;q[On+20>>2]=Pn;q[On+24>>2]=Dn+Pn;while(1){o[Pn|0]=0;Pn=q[On+20>>2]+1|0;q[On+20>>2]=Pn;Dn=Dn+ -1|0;if(Dn){continue}break}Pn=r[en+24|0]}q[On+8>>2]=0;q[On>>2]=0;q[On+4>>2]=0;if(Pn&255){if(Pn<<24>>24<=-1){break b}Pn=Pn<<24>>24;Dn=Mm(Pn);q[On>>2]=Dn;q[On+4>>2]=Dn;q[On+8>>2]=Dn+Pn;while(1){o[Dn|0]=0;Dn=q[On+4>>2]+1|0;q[On+4>>2]=Dn;Pn=Pn+ -1|0;if(Pn){continue}break}}if(!q[en+80>>2]){Dn=q[On>>2];break a}Pn=en+40|0;Un=en+48|0;Tn=en+24|0;while(1){Vn=q[On+16>>2];Wn=q[q[en>>2]>>2];Dn=q[Pn>>2];Qn=q[Un>>2]+$n(Dn,q[Pn+4>>2],Rn,Sn)|0;Dn=Cn(Vn,Wn+Qn|0,Dn);d:{if(o[Tn|0]<1){break d}Qn=Ye+48|0;o[q[On>>2]]=r[Dn|0]+r[q[Qn>>2]+(fn<<2)|0];Dn=1;if(o[Tn|0]<2){break d}while(1){o[q[On>>2]+Dn|0]=r[q[On+16>>2]+Dn|0]+r[q[Qn>>2]+(fn+Dn<<2)|0];Dn=Dn+1|0;if((Dn|0)>2];Dn=q[On>>2];Cn(q[q[en>>2]>>2]+w(Qn,Rn)|0,Dn,Qn);Rn=Rn+1|0;if(Rn>>>0<1){Sn=Sn+1|0}Qn=Rn;if(!Sn&Qn>>>0>2]|Sn>>>0<0){continue}break}break a}bn();F()}bn();F()}if(Dn){q[On+4>>2]=Dn;An(Dn)}Ye=q[On+16>>2];if(Ye){q[On+20>>2]=Ye;An(Ye)}T=On+32|0;return 1}function pe(Ye){Ye=Ye|0;var bn=0,en=0,fn=0,Cn=0;q[Ye>>2]=1596;bn=q[Ye+60>>2];if(bn){Cn=Ye- -64|0;en=q[Cn>>2];fn=bn;a:{if((bn|0)==(en|0)){break a}while(1){en=en+ -4|0;fn=q[en>>2];q[en>>2]=0;if(fn){Hb(fn)}if((bn|0)!=(en|0)){continue}break}fn=q[Ye+60>>2]}q[Cn>>2]=bn;An(fn)}bn=q[Ye+48>>2];if(bn){q[Ye+52>>2]=bn;An(bn)}bn=q[Ye+36>>2];if(bn){Cn=Ye+40|0;en=q[Cn>>2];fn=bn;b:{if((bn|0)==(en|0)){break b}while(1){en=en+ -24|0;n[q[q[en>>2]>>2]](en)|0;if((bn|0)!=(en|0)){continue}break}fn=q[Ye+36>>2]}q[Cn>>2]=bn;An(fn)}q[Ye>>2]=1384;bn=q[Ye+16>>2];if(bn){q[Ye+20>>2]=bn;An(bn)}bn=q[Ye+4>>2];if(bn){q[Ye+8>>2]=bn;An(bn)}return Ye|0}function qe(q){q=q|0;An(pe(q))}function re(Ye){var Xn=0,Yn=0,Zn=0,_n=0,$n=0,ao=0,bo=0,co=0,eo=0,fo=0,go=0,ho=0;ao=T-32|0;T=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>2]=_n;if((Xn|0)!=(Yn|0)){q[ao+16>>2]=Xn+(((Xn-$n|0)+ -4>>>2^-1)<<2)}if(!Zn){break a}An(Zn);break a}else{Yn=Yn+ -4|0;ue(ao+8|0,Yn);continue}}}ab(1780);F()}ab(1780);F()}ab(1780);F()}T=ao+32|0}function se(Ye){var io=0,jo=0,ko=0,lo=0,mo=0,no=0,oo=0;jo=q[Ye+16>>2];io=(jo>>>0)/341|0;ko=q[Ye+4>>2];no=q[Ye+8>>2];a:{if((ko|0)==(no|0)){mo=Ye+20|0;break a}lo=(io<<2)+ko|0;io=q[lo>>2]+w(jo-w(io,341)|0,12)|0;mo=Ye+20|0;jo=jo+q[mo>>2]|0;oo=(jo>>>0)/341|0;jo=q[(oo<<2)+ko>>2]+w(jo-w(oo,341)|0,12)|0;if((io|0)==(jo|0)){break a}while(1){io=io+12|0;if((io-q[lo>>2]|0)==4092){io=q[lo+4>>2];lo=lo+4|0}if((io|0)!=(jo|0)){continue}break}}q[mo>>2]=0;io=no-ko>>2;if(io>>>0>2){while(1){An(q[ko>>2]);ko=q[Ye+4>>2]+4|0;q[Ye+4>>2]=ko;io=q[Ye+8>>2]-ko>>2;if(io>>>0>2){continue}break}}io=io+ -1|0;if(io>>>0<=1){q[Ye+16>>2]=io-1|0?170:341}}function te(Ye,po){var qo=0,ro=0,so=0,to=0,uo=0,vo=0,wo=0;a:{so=q[Ye+8>>2];qo=q[Ye+12>>2];b:{if((so|0)!=(qo|0)){qo=so;break b}ro=q[Ye+4>>2];to=q[Ye>>2];if(ro>>>0>to>>>0){so=so-ro|0;vo=so>>2;to=((ro-to>>2)+1|0)/-2<<2;uo=to+ro|0;qo=Ye;if(so){En(uo,ro,so);ro=q[Ye+4>>2]}q[qo+4>>2]=ro+to;qo=uo+(vo<<2)|0;q[Ye+8>>2]=qo;break b}qo=qo-to|0;qo=qo?qo>>1:1;if(qo>>>0>=1073741824){break a}uo=qo<<2;vo=Mm(uo);wo=uo+vo|0;uo=vo+(qo&-4)|0;qo=uo;if((ro|0)!=(so|0)){qo=uo;while(1){q[qo>>2]=q[ro>>2];qo=qo+4|0;ro=ro+4|0;if((so|0)!=(ro|0)){continue}break}to=q[Ye>>2]}q[Ye+8>>2]=qo;q[Ye+4>>2]=uo;q[Ye>>2]=vo;q[Ye+12>>2]=wo;if(!to){break b}An(to);qo=q[Ye+8>>2]}q[qo>>2]=q[po>>2];q[Ye+8>>2]=q[Ye+8>>2]+4;return}ab(1780);F()}function ue(Ye,po){var xo=0,yo=0,zo=0,Ao=0,Bo=0,Co=0;a:{zo=q[Ye+4>>2];yo=q[Ye>>2];b:{if((zo|0)!=(yo|0)){xo=zo;break b}Ao=q[Ye+8>>2];xo=q[Ye+12>>2];if(Ao>>>0>>0){Bo=((xo-Ao>>2)+1|0)/2<<2;xo=Bo+Ao|0;yo=Ao-zo|0;if(yo){xo=xo-yo|0;En(xo,zo,yo);Ao=q[Ye+8>>2]}q[Ye+4>>2]=xo;q[Ye+8>>2]=Ao+Bo;break b}xo=xo-yo|0;xo=xo?xo>>1:1;if(xo>>>0>=1073741824){break a}yo=xo<<2;Bo=Mm(yo);Co=yo+Bo|0;xo=Bo+(xo+3&-4)|0;c:{if((zo|0)==(Ao|0)){yo=xo;break c}yo=xo;while(1){q[yo>>2]=q[zo>>2];yo=yo+4|0;zo=zo+4|0;if((Ao|0)!=(zo|0)){continue}break}zo=q[Ye>>2]}q[Ye+8>>2]=yo;q[Ye+4>>2]=xo;q[Ye>>2]=Bo;q[Ye+12>>2]=Co;if(!zo){break b}An(zo);xo=q[Ye+4>>2]}q[xo+ -4>>2]=q[po>>2];q[Ye+4>>2]=q[Ye+4>>2]+ -4;return}ab(1780);F()}function ve(Ye,An){var po=0,Do=0,Eo=0,Fo=0,Go=0,Ho=0;q[Ye>>2]=1232;po=q[An+4>>2];q[Ye+16>>2]=0;q[Ye+8>>2]=0;q[Ye+12>>2]=0;q[Ye+4>>2]=po;a:{po=q[An+12>>2]-q[An+8>>2]|0;b:{if(!po){break b}Do=po>>2;if(Do>>>0>=1073741824){break a}po=Mm(po);q[Ye+8>>2]=po;Eo=Ye+12|0;q[Eo>>2]=po;q[Ye+16>>2]=po+(Do<<2);Fo=q[An+8>>2];Do=q[An+12>>2]-Fo|0;if((Do|0)<1){break b}Go=Eo,Ho=Cn(po,Fo,Do)+Do|0,q[Go>>2]=Ho}q[Ye+20>>2]=q[An+20>>2];return}bn();F()}function we(Ye){q[Ye+12>>2]=-1;q[Ye+16>>2]=0;q[Ye+4>>2]=0;q[Ye+8>>2]=0;q[Ye>>2]=1908}function xe(Ye,An,Io){Ye=Ye|0;An=An|0;Io=Io|0;q[Ye+4>>2]=An;An=q[q[q[An+4>>2]+8>>2]+(Io<<2)>>2];q[Ye+12>>2]=Io;q[Ye+8>>2]=An;return 1}function ye(Ye,An){Ye=Ye|0;An=An|0;q[Ye+12>>2]=-1;q[Ye+8>>2]=An;return 1}function ze(Ye,An,Io){Ye=Ye|0;An=An|0;Io=Io|0;var Jo=0,Ko=0;Jo=q[Ye+8>>2];a:{if(o[Jo+24|0]<1){break a}if(!td(Jo,q[An+4>>2]-q[An>>2]>>2)){break a}Ko=n[q[q[Ye>>2]+32>>2]](Ye,An,Io)|0}return Ko|0}function Ae(q,Ye,An){q=q|0;Ye=Ye|0;An=An|0;return 1}function Be(Ye){var An=0,Io=0,Lo=0,Mo=0,No=0,Oo=0,Po=0,Qo=0;a:{Lo=q[Ye+8>>2];if(r[Lo+84|0]){break a}An=q[Ye+16>>2];if(!An|!r[An+84|0]){break a}Io=q[Lo+72>>2];Mo=q[Lo+68>>2];o[An+84|0]=0;Io=Io-Mo>>2;No=q[An+68>>2];Mo=q[An+72>>2]-No>>2;b:{if(Io>>>0>Mo>>>0){md(An+68|0,Io-Mo|0,1992);Lo=q[Ye+8>>2];break b}if(Io>>>0>=Mo>>>0){break b}q[An+72>>2]=No+(Io<<2)}An=0;Mo=r[Lo+84|0];Oo=Lo+72|0;Po=Ye+16|0;Qo=Lo+68|0;while(1){if(An>>>0>=(Mo?0:q[Oo>>2]-q[Lo+68>>2]>>2)>>>0){break a}Io=An;No=q[q[Po>>2]+68>>2]+(An<<2)|0;if(!Mo){Io=q[q[Qo>>2]+(An<<2)>>2]}q[No>>2]=Io;An=An+1|0;continue}}return q[Ye+16>>2]}function Ce(Ye,Ro){Ye=Ye|0;Ro=Ro|0;var So=0,To=0,Uo=0;if((n[q[q[Ro>>2]+20>>2]](Ro)|0)>=1){while(1){So=bl(q[q[Ye+4>>2]+4>>2],n[q[q[Ro>>2]+24>>2]](Ro,To)|0);if((So|0)==-1){return 0}a:{Uo=q[Ye+4>>2];if(r[Uo+36|0]<=1){if(n[q[q[Ro>>2]+28>>2]](Ro,q[q[q[Uo+4>>2]+8>>2]+(So<<2)>>2])){break a}return 0}So=Pj(Uo,So);if(!So){return 0}if(n[q[q[Ro>>2]+28>>2]](Ro,So)){break a}return 0}To=To+1|0;if((To|0)<(n[q[q[Ro>>2]+20>>2]](Ro)|0)){continue}break}}return 1}function De(Ye,Ro,Vo){Ye=Ye|0;Ro=Ro|0;Vo=Vo|0;var Wo=0,Xo=0,Yo=0,Zo=0,_o=0,$o=0,ap=0,bp=0,cp=0,dp=0,ep=0;Wo=q[Ro+4>>2];Xo=q[Ro>>2];Ro=q[q[Ye+8>>2]+40>>2];Yo=Ro;Zo=Mm((Ro|0)>-1?Ro:-1);Wo=Wo-Xo|0;if((Wo|0)>=1){dp=Wo>>2;while(1){$o=q[Vo+12>>2];Wo=ep+q[Vo+20>>2]|0;ap=q[Vo+16>>2];_o=Ro+ap|0;if(_o>>>0>>0){Wo=Wo+1|0}Xo=Wo;if(($o|0)<(Wo|0)?1:($o|0)<=(Wo|0)?t[Vo+8>>2]>=_o>>>0?0:1:0){An(Zo);return 0}Wo=Cn(Zo,ap+q[Vo>>2]|0,Yo);q[Vo+16>>2]=_o;q[Vo+20>>2]=Xo;Cn(q[q[q[Ye+8>>2]- -64>>2]>>2]+bp|0,Wo,Yo);bp=Yo+bp|0;cp=cp+1|0;if((cp|0)<(dp|0)){continue}break}}An(Zo);return 1}function Ee(Ye){Ye=Ye|0;var Ro=0;q[Ye>>2]=1908;Ro=q[Ye+16>>2];q[Ye+16>>2]=0;if(Ro){Hb(Ro)}return Ye|0}function Fe(Ye){Ye=Ye|0;var Vo=0;q[Ye>>2]=1908;Vo=q[Ye+16>>2];q[Ye+16>>2]=0;if(Vo){Hb(Vo)}An(Ye)}function Ge(Ye,fp){var gp=0;wd(Ye);q[Ye+36>>2]=0;q[Ye+40>>2]=0;q[Ye>>2]=2004;q[Ye+44>>2]=0;q[Ye+48>>2]=0;q[Ye+52>>2]=0;q[Ye+56>>2]=0;gp=q[fp>>2];q[fp>>2]=0;q[Ye+60>>2]=gp}function He(Ye,fp){Ye=Ye|0;fp=fp|0;var hp=0,ip=0,jp=0,kp=0,lp=0,mp=0,np=0,op=0,pp=0,qp=0,rp=0,sp=0,tp=0;lp=T-16|0;T=lp;a:{if(!yd(Ye,fp)){break a}pp=Ye+36|0;mp=n[q[q[Ye>>2]+24>>2]](Ye)|0;jp=q[Ye+40>>2];ip=q[Ye+36>>2];hp=jp-ip>>2;b:{if(mp>>>0>hp>>>0){Ie(pp,mp-hp|0);break b}if(mp>>>0>=hp>>>0){break b}ip=ip+(mp<<2)|0;if((ip|0)!=(jp|0)){while(1){jp=jp+ -4|0;hp=q[jp>>2];q[jp>>2]=0;if(hp){n[q[q[hp>>2]+4>>2]](hp)}if((jp|0)!=(ip|0)){continue}break}}q[Ye+40>>2]=ip}op=1;if((mp|0)<1){break a}op=0;jp=0;while(1){kp=q[fp+16>>2];ip=q[fp+12>>2];hp=q[fp+20>>2];if((ip|0)<(hp|0)?1:(ip|0)<=(hp|0)?t[fp+8>>2]>kp>>>0?0:1:0){break a}np=r[kp+q[fp>>2]|0];kp=kp+1|0;if(kp>>>0<1){hp=hp+1|0}ip=fp;q[ip+16>>2]=kp;q[ip+20>>2]=hp;n[q[q[Ye>>2]+48>>2]](lp+8|0,Ye,np);hp=q[Ye+36>>2];ip=q[lp+8>>2];q[lp+8>>2]=0;kp=jp<<2;np=hp+kp|0;hp=q[np>>2];q[np>>2]=ip;if(hp){n[q[q[hp>>2]+4>>2]](hp)}hp=q[lp+8>>2];q[lp+8>>2]=0;if(hp){n[q[q[hp>>2]+4>>2]](hp)}hp=q[q[pp>>2]+kp>>2];if(!hp){break a}if(!(rp=hp,sp=n[q[q[Ye>>2]+28>>2]](Ye)|0,tp=n[q[q[Ye>>2]+20>>2]](Ye,jp)|0,qp=q[q[hp>>2]+8>>2],n[qp](rp|0,sp|0,tp|0)|0)){break a}jp=jp+1|0;if((mp|0)!=(jp|0)){continue}break}op=1}T=lp+16|0;return op|0}function Ie(Ye,fp){var up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0,Cp=0;vp=q[Ye+8>>2];wp=Ye+4|0;up=q[wp>>2];if(vp-up>>2>>>0>=fp>>>0){Ye=fp<<2;Bp=wp,Cp=Dn(up,0,Ye)+Ye|0,q[Bp>>2]=Cp;return}a:{wp=q[Ye>>2];xp=up-wp>>2;yp=xp+fp|0;if(yp>>>0<1073741824){xp=xp<<2;vp=vp-wp|0;Ap=vp>>1;vp=vp>>2>>>0<536870911?Ap>>>0>>0?yp:Ap:1073741823;if(vp){if(vp>>>0>=1073741824){break a}zp=Mm(vp<<2)}xp=xp+zp|0;Dn(xp,0,fp<<2);fp=(yp<<2)+zp|0;yp=(vp<<2)+zp|0;if((up|0)!=(wp|0)){while(1){up=up+ -4|0;vp=q[up>>2];q[up>>2]=0;xp=xp+ -4|0;q[xp>>2]=vp;if((up|0)!=(wp|0)){continue}break}wp=q[Ye>>2];up=q[Ye+4>>2]}q[Ye>>2]=xp;q[Ye+8>>2]=yp;q[Ye+4>>2]=fp;if((up|0)!=(wp|0)){while(1){up=up+ -4|0;Ye=q[up>>2];q[up>>2]=0;if(Ye){n[q[q[Ye>>2]+4>>2]](Ye)}if((up|0)!=(wp|0)){continue}break}}if(wp){An(wp)}return}bn();F()}ab(2144);F()}function Je(Ye,fp){Ye=Ye|0;fp=fp|0;var Dp=0,Ep=0,Fp=0,Gp=0,Hp=0,Ip=0,Jp=0;Dp=q[Ye+60>>2];a:{if(!Dp){break a}q[Dp+4>>2]=Ye+48;if(!n[q[q[Dp>>2]+12>>2]](Dp)){break a}b:{Ep=n[q[q[Ye>>2]+24>>2]](Ye)|0;if((Ep|0)<1){break b}Gp=Ye+60|0;Dp=0;while(1){c:{Hp=q[(n[q[q[Ye>>2]+28>>2]](Ye)|0)+4>>2];Ip=n[q[q[Ye>>2]+20>>2]](Ye,Dp)|0;Fp=q[Gp>>2];if(!n[q[q[Fp>>2]+8>>2]](Fp,q[q[Hp+8>>2]+(Ip<<2)>>2])){break c}Dp=Dp+1|0;if((Ep|0)!=(Dp|0)){continue}break b}break}return 0}if(!n[q[q[Ye>>2]+36>>2]](Ye,fp)){break a}if(!n[q[q[Ye>>2]+40>>2]](Ye,fp)){break a}Jp=n[q[q[Ye>>2]+44>>2]](Ye)|0}return Jp|0}function Ke(Ye,fp){Ye=Ye|0;fp=fp|0;var Kp=0,Lp=0,Mp=0,Np=0,Op=0;Kp=1;Lp=n[q[q[Ye>>2]+24>>2]](Ye)|0;a:{if((Lp|0)<1){break a}Np=Ye+48|0;Kp=0;Op=Ye+36|0;Ye=0;while(1){Mp=q[q[Op>>2]+(Ye<<2)>>2];if(!n[q[q[Mp>>2]+16>>2]](Mp,Np,fp)){break a}Ye=Ye+1|0;if((Lp|0)!=(Ye|0)){continue}break}Kp=1}return Kp|0}function Le(Ye,fp){Ye=Ye|0;fp=fp|0;var Pp=0,Qp=0,Rp=0,Sp=0,Tp=0;Pp=1;Qp=n[q[q[Ye>>2]+24>>2]](Ye)|0;a:{if((Qp|0)<1){break a}Sp=Ye+48|0;Pp=0;Tp=Ye+36|0;Ye=0;while(1){Rp=q[q[Tp>>2]+(Ye<<2)>>2];if(!n[q[q[Rp>>2]+20>>2]](Rp,Sp,fp)){break a}Ye=Ye+1|0;if((Qp|0)!=(Ye|0)){continue}break}Pp=1}return Pp|0}function Me(Ye){Ye=Ye|0;var fp=0,Up=0,Vp=0,Wp=0,Xp=0,Yp=0,Zp=0,_p=0,$p=0,aq=0,bq=0,cq=0,dq=0;Wp=T-16|0;T=Wp;fp=1;Zp=n[q[q[Ye>>2]+24>>2]](Ye)|0;a:{if((Zp|0)<1){break a}dq=Ye+48|0;Yp=Ye+36|0;while(1){b:{c:{if(!q[(n[q[q[Ye>>2]+28>>2]](Ye)|0)+40>>2]){break c}_p=Xp<<2;fp=q[_p+q[Yp>>2]>>2];Up=q[fp+8>>2];$p=Be(fp);if(!$p){break c}fp=n[q[q[Ye>>2]+28>>2]](Ye)|0;aq=q[Up+56>>2];bq=q[fp+40>>2];fp=Mm(32);q[Wp>>2]=fp;q[Wp+4>>2]=24;q[Wp+8>>2]=-2147483616;o[fp+24|0]=0;Up=r[2076]|r[2077]<<8|(r[2078]<<16|r[2079]<<24);Vp=r[2072]|r[2073]<<8|(r[2074]<<16|r[2075]<<24);o[fp+16|0]=Vp;o[fp+17|0]=Vp>>>8;o[fp+18|0]=Vp>>>16;o[fp+19|0]=Vp>>>24;o[fp+20|0]=Up;o[fp+21|0]=Up>>>8;o[fp+22|0]=Up>>>16;o[fp+23|0]=Up>>>24;Up=r[2068]|r[2069]<<8|(r[2070]<<16|r[2071]<<24);Vp=r[2064]|r[2065]<<8|(r[2066]<<16|r[2067]<<24);o[fp+8|0]=Vp;o[fp+9|0]=Vp>>>8;o[fp+10|0]=Vp>>>16;o[fp+11|0]=Vp>>>24;o[fp+12|0]=Up;o[fp+13|0]=Up>>>8;o[fp+14|0]=Up>>>16;o[fp+15|0]=Up>>>24;Up=r[2060]|r[2061]<<8|(r[2062]<<16|r[2063]<<24);Vp=r[2056]|r[2057]<<8|(r[2058]<<16|r[2059]<<24);o[fp|0]=Vp;o[fp+1|0]=Vp>>>8;o[fp+2|0]=Vp>>>16;o[fp+3|0]=Vp>>>24;o[fp+4|0]=Up;o[fp+5|0]=Up>>>8;o[fp+6|0]=Up>>>16;o[fp+7|0]=Up>>>24;d:{e:{Vp=bq+16|0;Up=Vp;fp=q[Up>>2];if(!fp){break e}while(1){cq=q[fp+16>>2]<(aq|0);Up=cq?Up:fp;fp=q[(cq<<2)+fp>>2];if(fp){continue}break}if((Up|0)==(Vp|0)|(aq|0)>2]){break e}fp=Up+20|0;if(!ga(fp,Wp)){break e}fp=gk(fp,Wp);break d}fp=gk(bq,Wp)}if(o[Wp+11|0]<=-1){An(q[Wp>>2])}if(!fp){break c}ud(q[q[q[Yp>>2]+_p>>2]+8>>2],$p);break b}fp=q[q[Yp>>2]+(Xp<<2)>>2];if(n[q[q[fp>>2]+24>>2]](fp,dq)){break b}fp=0;break a}fp=1;Xp=Xp+1|0;if((Zp|0)!=(Xp|0)){continue}break}}T=Wp+16|0;return fp|0}function Ne(Ye,eq,fq){Ye=Ye|0;eq=eq|0;fq=fq|0;if(fq>>>0>3){q[Ye>>2]=0;return}a:{b:{switch(fq-1|0){default:eq=Mm(20);we(eq);break a;case 0:eq=Mm(24);Re(eq);break a;case 1:eq=Mm(36);Re(eq);q[eq+32>>2]=0;q[eq+24>>2]=-1;q[eq+28>>2]=0;q[eq>>2]=10764;break a;case 2:break b}}eq=Mm(28);Re(eq);q[eq+24>>2]=-1;q[eq>>2]=6744;q[Ye>>2]=eq;return}q[Ye>>2]=eq}function Oe(Ye){Ye=Ye|0;var eq=0,fq=0,gq=0,hq=0,iq=0;q[Ye>>2]=2004;eq=Ye+60|0;fq=q[eq>>2];q[eq>>2]=0;if(fq){n[q[q[fq>>2]+4>>2]](fq)}eq=q[Ye+48>>2];if(eq){q[Ye+52>>2]=eq;An(eq)}fq=q[Ye+36>>2];if(fq){eq=fq;iq=Ye+40|0;gq=q[iq>>2];hq=eq;a:{if((eq|0)==(gq|0)){break a}while(1){gq=gq+ -4|0;eq=q[gq>>2];q[gq>>2]=0;if(eq){n[q[q[eq>>2]+4>>2]](eq)}if((fq|0)!=(gq|0)){continue}break}hq=q[Ye+36>>2]}eq=hq;q[iq>>2]=fq;An(eq)}q[Ye>>2]=1384;eq=q[Ye+16>>2];if(eq){q[Ye+20>>2]=eq;An(eq)}eq=q[Ye+4>>2];if(eq){q[Ye+8>>2]=eq;An(eq)}return Ye|0}function Pe(Ye){Ye=Ye|0;var jq=0,kq=0,lq=0,mq=0,nq=0;q[Ye>>2]=2004;jq=Ye+60|0;kq=q[jq>>2];q[jq>>2]=0;if(kq){n[q[q[kq>>2]+4>>2]](kq)}jq=q[Ye+48>>2];if(jq){q[Ye+52>>2]=jq;An(jq)}kq=q[Ye+36>>2];if(kq){jq=kq;nq=Ye+40|0;lq=q[nq>>2];mq=jq;a:{if((jq|0)==(lq|0)){break a}while(1){lq=lq+ -4|0;jq=q[lq>>2];q[lq>>2]=0;if(jq){n[q[q[jq>>2]+4>>2]](jq)}if((kq|0)!=(lq|0)){continue}break}mq=q[Ye+36>>2]}jq=mq;q[nq>>2]=kq;An(jq)}q[Ye>>2]=1384;jq=q[Ye+16>>2];if(jq){q[Ye+20>>2]=jq;An(jq)}jq=q[Ye+4>>2];if(jq){q[Ye+8>>2]=jq;An(jq)}An(Ye)}function Qe(Ye,oq){Ye=Ye|0;oq=oq|0;var pq=0,qq=0;qq=q[Ye+16>>2];pq=0;a:{if(q[Ye+20>>2]-qq>>2<=(oq|0)){break a}oq=q[(oq<<2)+qq>>2];pq=0;if((oq|0)<0){break a}pq=Be(q[q[Ye+36>>2]+(oq<<2)>>2])}return pq|0}function Re(Ye){we(Ye);q[Ye+20>>2]=0;q[Ye>>2]=2220}function Se(q,Ye,oq){q=q|0;Ye=Ye|0;oq=oq|0;return xe(q,Ye,oq)|0}function Te(Ye,oq){Ye=Ye|0;oq=oq|0;var rq=0,sq=0;sq=q[Ye+4>>2];a:{if(sq){rq=1;if(r[sq+36|0]<2){break a}}rq=n[q[q[Ye>>2]+48>>2]](Ye,q[oq+4>>2]-q[oq>>2]>>2)|0}return rq|0}function Ue(Ye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-1|0){case 0:$q=o[Zq+24|0];ar=Mm(($q|0)>-1?$q:-1);tq=q[Ye+16>>2];Zq=0;c:{if(!q[tq+80>>2]){break c}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=($q|0)<1;dr=Ye+8|0;tq=0;while(1){Ye=0;if(!br){while(1){o[Ye+ar|0]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if(($q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[dr>>2]- -64>>2]>>2]+cr|0,ar,$q);cr=$q+cr|0;_q=_q+1|0;if((_q|0)!=(oq|0)){continue}break}break a;default:$q=o[Zq+24|0];ar=Mm(($q|0)>-1?$q:-1);tq=q[Ye+16>>2];Zq=0;d:{if(!q[tq+80>>2]){break d}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=($q|0)<1;dr=Ye+8|0;tq=0;while(1){Ye=0;if(!br){while(1){o[Ye+ar|0]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if(($q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[dr>>2]- -64>>2]>>2]+cr|0,ar,$q);cr=$q+cr|0;_q=_q+1|0;if((_q|0)!=(oq|0)){continue}break}break a;case 2:_q=o[Zq+24|0];Zq=_q+_q|0;ar=Mm(Zq>>>0<_q>>>0?-1:Zq);tq=q[Ye+16>>2];Zq=0;e:{if(!q[tq+80>>2]){break e}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=_q<<1;dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){p[(Ye<<1)+ar>>1]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}break a;case 1:_q=o[Zq+24|0];Zq=_q+_q|0;ar=Mm(Zq>>>0<_q>>>0?-1:Zq);tq=q[Ye+16>>2];Zq=0;f:{if(!q[tq+80>>2]){break f}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}br=_q<<1;dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){p[(Ye<<1)+ar>>1]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}break a;case 4:_q=o[Zq+24|0];br=_q<<2;ar=Mm((_q|0)!=(_q&1073741823)?-1:br);tq=q[Ye+16>>2];Zq=0;g:{if(!q[tq+80>>2]){break g}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){q[(Ye<<2)+ar>>2]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}break a;case 3:break b}}_q=o[Zq+24|0];br=_q<<2;ar=Mm((_q|0)!=(_q&1073741823)?-1:br);tq=q[Ye+16>>2];Zq=0;h:{if(!q[tq+80>>2]){break h}Zq=q[q[tq>>2]>>2]+q[tq+48>>2]|0}if(!oq){break a}dr=(_q|0)<1;er=Ye+8|0;tq=0;while(1){Ye=0;if(!dr){while(1){q[(Ye<<2)+ar>>2]=q[Zq+(tq<<2)>>2];tq=tq+1|0;Ye=Ye+1|0;if((_q|0)!=(Ye|0)){continue}break}}Cn(q[q[q[er>>2]- -64>>2]>>2]+cr|0,ar,br);cr=cr+br|0;$q=$q+1|0;if(($q|0)!=(oq|0)){continue}break}}An(ar);return 1}function _e(Ye){Ye=Ye|0;var oq=0,fr=0;q[Ye>>2]=2220;fr=Ye+20|0;oq=q[fr>>2];q[fr>>2]=0;if(oq){n[q[q[oq>>2]+4>>2]](oq)}q[Ye>>2]=1908;fr=Ye+16|0;oq=q[fr>>2];q[fr>>2]=0;if(oq){Hb(oq)}return Ye|0}function $e(Ye){Ye=Ye|0;var gr=0,hr=0;q[Ye>>2]=2220;hr=Ye+20|0;gr=q[hr>>2];q[hr>>2]=0;if(gr){n[q[q[gr>>2]+4>>2]](gr)}q[Ye>>2]=1908;hr=Ye+16|0;gr=q[hr>>2];q[hr>>2]=0;if(gr){Hb(gr)}An(Ye)}function af(Ye){Ye=Ye|0;return o[q[Ye+8>>2]+24|0]}function bf(Ye,ir,jr,kr,lr,mr){var nr=0,or=0,pr=0,qr=0;nr=T-32|0;T=nr;pr=q[q[q[ir+4>>2]+8>>2]+(kr<<2)>>2];a:{b:{if((n[q[q[ir>>2]+8>>2]](ir)|0)!=1|jr+ -1>>>0>5){break b}qr=n[q[q[ir>>2]+36>>2]](ir)|0;or=n[q[q[ir>>2]+44>>2]](ir,kr)|0;if(!(or?qr:0)){q[Ye>>2]=0;break a}kr=n[q[q[ir>>2]+40>>2]](ir,kr)|0;if(kr){ir=q[ir+44>>2];q[nr+12>>2]=kr;q[nr+8>>2]=ir;q[nr+20>>2]=or;q[nr+16>>2]=or+12;df(Ye,jr,pr,lr,nr+8|0,mr);if(q[Ye>>2]){break a}q[Ye>>2]=0;break b}ir=q[ir+44>>2];q[nr+12>>2]=qr;q[nr+8>>2]=ir;q[nr+20>>2]=or;q[nr+16>>2]=or+12;ef(Ye,jr,pr,lr,nr+8|0,mr);if(q[Ye>>2]){break a}q[Ye>>2]=0}q[Ye>>2]=0}T=nr+32|0}function cf(Ye,ir,jr){var kr=0,lr=0,mr=0,rr=0,sr=0,tr=0,ur=0,vr=0;q[Ye>>2]=3044;q[Ye+4>>2]=ir;ir=q[jr+8>>2];kr=q[jr+12>>2];lr=q[jr+16>>2];rr=q[jr+20>>2];sr=q[jr>>2];tr=q[jr+4>>2];q[Ye+40>>2]=0;mr=Ye+32|0;q[mr>>2]=0;q[mr+4>>2]=0;q[Ye+24>>2]=lr;q[Ye+28>>2]=rr;q[Ye+16>>2]=ir;q[Ye+20>>2]=kr;q[Ye+8>>2]=sr;q[Ye+12>>2]=tr;a:{ir=q[jr+28>>2]-q[jr+24>>2]|0;b:{if(!ir){break b}kr=ir>>2;if(kr>>>0>=1073741824){break a}ir=Mm(ir);q[Ye+32>>2]=ir;lr=Ye+36|0;q[lr>>2]=ir;q[Ye+40>>2]=ir+(kr<<2);kr=q[jr+24>>2];jr=q[jr+28>>2]-kr|0;if((jr|0)<1){break b}ur=lr,vr=Cn(ir,kr,jr)+jr|0,q[ur>>2]=vr}q[Ye>>2]=6584;return}bn();F()}function df(Ye,ir,jr,wr,xr,yr){ir=ir+ -1|0;if(ir>>>0>5){q[Ye>>2]=0;return}a:{b:{switch(ir-1|0){default:ir=Mm(60);ff(ir,jr,wr,xr);q[ir>>2]=2336;break a;case 0:ir=Mm(60);ff(ir,jr,wr,xr);q[ir>>2]=3100;break a;case 2:ir=Mm(112);ff(ir,jr,wr,xr);q[ir>>2]=3336;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;q[ir+88>>2]=0;q[ir+92>>2]=0;q[ir+96>>2]=0;q[ir+100>>2]=0;q[ir+104>>2]=0;q[ir+108>>2]=0;break a;case 1:ir=Mm(92);ff(ir,jr,wr,xr);q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=3584;q[ir+88>>2]=yr;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;break a;case 3:ir=Mm(104);ff(ir,jr,wr,xr);q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=3812;q[ir+84>>2]=0;jr=q[xr+4>>2];q[ir+88>>2]=q[xr>>2];q[ir+92>>2]=jr;jr=q[xr+12>>2];q[ir+96>>2]=q[xr+8>>2];q[ir+100>>2]=jr;break a;case 4:break b}}ir=Mm(124);ff(ir,jr,wr,xr);q[ir>>2]=4048;jr=ir- -64|0;q[jr>>2]=0;q[jr+4>>2]=0;jr=q[xr+4>>2];q[ir+72>>2]=q[xr>>2];q[ir+76>>2]=jr;jr=q[xr+12>>2];q[ir+80>>2]=q[xr+8>>2];q[ir+84>>2]=jr;q[ir+92>>2]=-1;q[ir+96>>2]=-1;q[ir+88>>2]=1;q[ir+60>>2]=4284;q[ir+100>>2]=-1;q[ir+104>>2]=-1;ah(ir+108|0);q[Ye>>2]=ir;return}q[Ye>>2]=ir}function ef(Ye,ir,jr,wr,xr,yr){ir=ir+ -1|0;if(ir>>>0>5){q[Ye>>2]=0;return}a:{b:{switch(ir-1|0){default:ir=Mm(60);Vf(ir,jr,wr,xr);q[ir>>2]=4676;break a;case 0:ir=Mm(60);Vf(ir,jr,wr,xr);q[ir>>2]=5100;break a;case 2:ir=Mm(112);Vf(ir,jr,wr,xr);q[ir>>2]=5324;q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;q[ir+88>>2]=0;q[ir+92>>2]=0;q[ir+96>>2]=0;q[ir+100>>2]=0;q[ir+104>>2]=0;q[ir+108>>2]=0;break a;case 1:ir=Mm(92);Vf(ir,jr,wr,xr);q[ir+60>>2]=0;q[ir+64>>2]=0;q[ir>>2]=5560;q[ir+88>>2]=yr;q[ir+68>>2]=0;q[ir+72>>2]=0;q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+84>>2]=0;break a;case 3:ir=Mm(104);Vf(ir,jr,wr,xr);q[ir+76>>2]=0;q[ir+80>>2]=0;q[ir+60>>2]=0;q[ir+64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q[Ye+32>>2];if(wr){q[Ye+36>>2]=wr;An(wr)}return Ye|0}function of(Ye,Pr,Qr,Rr,Sr,hs){Ye=Ye|0;Pr=Pr|0;Qr=Qr|0;Rr=Rr|0;Sr=Sr|0;hs=hs|0;var is=0,js=0,ks=0,ls=0,ms=0,ns=0,os=0,ps=0,qs=0,rs=0,ss=0,ts=0,us=0,vs=0,ws=0,xs=0,ys=0,zs=0,As=0,Bs=0,Cs=0,Ds=0;q[Ye+8>>2]=Sr;hs=Ye+32|0;is=q[hs>>2];Rr=q[Ye+36>>2]-is>>2;a:{if(Rr>>>0>>0){Fa(hs,Sr-Rr|0);break a}if(Rr>>>0<=Sr>>>0){break a}q[Ye+36>>2]=is+(Sr<<2)}hs=0;Rr=(Sr&1073741823)!=(Sr|0)?-1:Sr<<2;rs=Dn(Mm(Rr),0,Rr);ws=Dn(Mm(Rr),0,Rr);os=Ye+8|0;is=q[os>>2];b:{if((is|0)<1){break b}ps=Ye+16|0;Rr=Ye+32|0;qs=Ye+12|0;while(1){is=hs<<2;ls=q[is+rs>>2];ns=q[ps>>2];c:{if((ls|0)>(ns|0)){ks=q[Rr>>2];q[is+ks>>2]=ns;break c}ks=q[Rr>>2];is=is+ks|0;ns=q[qs>>2];if((ls|0)<(ns|0)){q[is>>2]=ns;break c}q[is>>2]=ls}hs=hs+1|0;is=q[os>>2];if((hs|0)<(is|0)){continue}break}if((is|0)<1){break b}Rr=0;os=Ye+16|0;ls=Ye+20|0;ps=Ye+8|0;qs=Ye+12|0;while(1){is=Rr<<2;hs=is+Qr|0;is=q[Pr+is>>2]+q[is+ks>>2]|0;q[hs>>2]=is;d:{if((is|0)>q[os>>2]){is=is-q[ls>>2]|0}else{if((is|0)>=q[qs>>2]){break d}is=is+q[ls>>2]|0}q[hs>>2]=is}Rr=Rr+1|0;is=q[ps>>2];if((Rr|0)<(is|0)){continue}break}}Rr=q[Ye+56>>2];xs=q[Rr>>2];Rr=q[Rr+4>>2]-xs|0;if((Rr|0)>=5){ys=Rr>>2;As=Sr<<2;Bs=q[Ye+52>>2];os=Ye+16|0;ps=Ye+32|0;qs=Ye+8|0;ns=Ye+20|0;us=Ye+12|0;ss=q[Ye+48>>2];Cs=ss+28|0;ls=1;while(1){e:{f:{g:{if(ys>>>0>ls>>>0){Ye=q[(ls<<2)+xs>>2];zs=(Sr|0)<1;if(!zs){Dn(rs,0,As)}if((Ye|0)==-1){Ye=w(Sr,ls);break f}Ds=q[ss>>2];ks=0;Rr=Ye;while(1){h:{if(q[Ds+(Rr>>>3&536870908)>>2]>>>(Rr&31)&1){break h}hs=q[q[q[ss+64>>2]+12>>2]+(Rr<<2)>>2];if((hs|0)==-1){break h}ms=q[Bs>>2];js=q[Cs>>2];vs=q[ms+(q[js+(hs<<2)>>2]<<2)>>2];if((vs|0)>=(ls|0)){break h}ts=hs+1|0;ts=q[ms+(q[js+(((ts>>>0)%3|0?ts:hs+ -2|0)<<2)>>2]<<2)>>2];if((ts|0)>=(ls|0)){break h}hs=q[ms+(q[js+(hs+((hs>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2];if((hs|0)>=(ls|0)){break h}i:{if(zs){break i}js=w(Sr,hs);ms=w(Sr,ts);vs=w(Sr,vs);hs=0;while(1){q[ws+(hs<<2)>>2]=(q[(hs+js<<2)+Qr>>2]+q[(hs+ms<<2)+Qr>>2]|0)-q[(hs+vs<<2)+Qr>>2];hs=hs+1|0;if((hs|0)!=(Sr|0)){continue}break}hs=0;if((Sr|0)<=0){break i}while(1){js=hs<<2;ms=js+rs|0;q[ms>>2]=q[ms>>2]+q[js+ws>>2];hs=hs+1|0;if((hs|0)!=(Sr|0)){continue}break}}ks=ks+1|0}hs=-1;Rr=((Rr>>>0)%3|0?-1:2)+Rr|0;j:{if((Rr|0)==-1|q[q[ss>>2]+(Rr>>>3&536870908)>>2]>>>(Rr&31)&1){break j}Rr=q[q[q[ss+64>>2]+12>>2]+(Rr<<2)>>2];if((Rr|0)==-1){break j}if((Rr>>>0)%3){hs=Rr+ -1|0;break j}hs=Rr+2|0}Rr=(Ye|0)==(hs|0)?-1:hs;if((Rr|0)!=-1){continue}break}Ye=w(Sr,ls);if(!ks){break f}hs=0;if((Sr|0)<=0){break g}while(1){Rr=(hs<<2)+rs|0;q[Rr>>2]=q[Rr>>2]/(ks|0);hs=hs+1|0;if((hs|0)!=(Sr|0)){continue}break}break g}cn();F()}if((is|0)<1){break e}hs=0;while(1){Rr=hs<<2;is=q[Rr+rs>>2];js=q[os>>2];k:{if((is|0)>(js|0)){ks=q[ps>>2];q[Rr+ks>>2]=js;break k}ks=q[ps>>2];Rr=Rr+ks|0;js=q[us>>2];if((is|0)<(js|0)){q[Rr>>2]=js;break k}q[Rr>>2]=is}hs=hs+1|0;is=q[qs>>2];if((hs|0)<(is|0)){continue}break}Rr=0;if((is|0)<1){break e}Ye=Ye<<2;js=Ye+Qr|0;ms=Ye+Pr|0;while(1){hs=Rr<<2;Ye=hs+js|0;hs=q[hs+ms>>2]+q[hs+ks>>2]|0;q[Ye>>2]=hs;l:{if((hs|0)>q[os>>2]){hs=hs-q[ns>>2]|0}else{if((hs|0)>=q[us>>2]){break l}hs=hs+q[ns>>2]|0}q[Ye>>2]=hs}Rr=Rr+1|0;is=q[qs>>2];if((Rr|0)<(is|0)){continue}break}break e}if((is|0)<1){break e}js=(w(ls+ -1|0,Sr)<<2)+Qr|0;hs=0;while(1){Rr=hs<<2;is=q[Rr+js>>2];ms=q[os>>2];m:{if((is|0)>(ms|0)){ks=q[ps>>2];q[Rr+ks>>2]=ms;break m}ks=q[ps>>2];Rr=Rr+ks|0;ms=q[us>>2];if((is|0)<(ms|0)){q[Rr>>2]=ms;break m}q[Rr>>2]=is}hs=hs+1|0;is=q[qs>>2];if((hs|0)<(is|0)){continue}break}Rr=0;if((is|0)<1){break e}Ye=Ye<<2;js=Ye+Qr|0;ms=Ye+Pr|0;while(1){hs=Rr<<2;Ye=hs+js|0;hs=q[hs+ms>>2]+q[hs+ks>>2]|0;q[Ye>>2]=hs;n:{if((hs|0)>q[os>>2]){hs=hs-q[ns>>2]|0}else{if((hs|0)>=q[us>>2]){break n}hs=hs+q[ns>>2]|0}q[Ye>>2]=hs}Rr=Rr+1|0;is=q[qs>>2];if((Rr|0)<(is|0)){continue}break}}ls=ls+1|0;if((ls|0)<(ys|0)){continue}break}}An(ws);An(rs);return 1}function pf(Ye){Ye=Ye|0;var Pr=0;q[Ye>>2]=3336;Pr=q[Ye+96>>2];if(Pr){An(Pr)}Pr=q[Ye+84>>2];if(Pr){An(Pr)}Pr=q[Ye+72>>2];if(Pr){An(Pr)}Pr=q[Ye+60>>2];if(Pr){An(Pr)}q[Ye>>2]=3044;Pr=q[Ye+32>>2];if(Pr){q[Ye+36>>2]=Pr;An(Pr)}return Ye|0}function qf(Ye){Ye=Ye|0;var Qr=0;q[Ye>>2]=3336;Qr=q[Ye+96>>2];if(Qr){An(Qr)}Qr=q[Ye+84>>2];if(Qr){An(Qr)}Qr=q[Ye+72>>2];if(Qr){An(Qr)}Qr=q[Ye+60>>2];if(Qr){An(Qr)}q[Ye>>2]=3044;Qr=q[Ye+32>>2];if(Qr){q[Ye+36>>2]=Qr;An(Qr)}An(Ye)}function rf(q){q=q|0;return 4}function sf(Ye,Rr){Ye=Ye|0;Rr=Rr|0;var Sr=0,hs=0,Es=0,Fs=0,Gs=0,Hs=0,Is=0,Js=0,Ks=0,Ls=0,Ms=0;Js=T-32|0;T=Js;a:{if(s[Rr+38>>1]<=513){Es=q[Rr+16>>2];hs=q[Rr+12>>2];Sr=q[Rr+20>>2];if((hs|0)<(Sr|0)?1:(hs|0)<=(Sr|0)?t[Rr+8>>2]>Es>>>0?0:1:0){break a}Fs=r[Es+q[Rr>>2]|0];Es=Es+1|0;if(Es>>>0<1){Sr=Sr+1|0}q[Rr+16>>2]=Es;q[Rr+20>>2]=Sr;if(Fs){break a}}b:{while(1){if(!tf(1,Js+28|0,Rr)){break b}Sr=q[Js+28>>2];if(Sr){Fs=(w(Gs,12)+Ye|0)+60|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ad(bt+16|0,Zs,bt);at=q[bt+28>>2];Ys=q[_s>>2]}q[bt>>2]=0;Ys=Ys-at>>2;b:{if(Ys>>>0>=Zs>>>0){if(Ys>>>0<=Zs>>>0){break b}q[bt+32>>2]=(Zs<<2)+at;break b}Ad(bt+16|12,Zs-Ys|0,bt)}q[bt>>2]=0;_s=q[bt+40>>2];Ys=q[bt+44>>2]-_s>>2;c:{if(Ys>>>0>=Zs>>>0){if(Ys>>>0<=Zs>>>0){break c}q[bt+44>>2]=_s+(Zs<<2);break c}Ad(bt+40|0,Zs-Ys|0,bt)}q[bt>>2]=0;_s=q[bt+52>>2];Ys=q[bt+56>>2]-_s>>2;d:{if(Ys>>>0>=Zs>>>0){if(Ys>>>0<=Zs>>>0){break d}q[bt+56>>2]=_s+(Zs<<2);break d}Ad(bt+52|0,Zs-Ys|0,bt)}et=Ye+8|0;e:{if(q[et>>2]<=0){break e}ft=q[bt+16>>2];at=0;ht=Ye+16|0;Ys=Ye+32|0;dt=Ye+12|0;while(1){_s=at<<2;$s=q[_s+ft>>2];it=q[ht>>2];f:{if(($s|0)>(it|0)){ct=q[Ys>>2];q[_s+ct>>2]=it;break f}ct=q[Ys>>2];_s=_s+ct|0;it=q[dt>>2];if(($s|0)<(it|0)){q[_s>>2]=it;break f}q[_s>>2]=$s}at=at+1|0;_s=q[et>>2];if((at|0)<(_s|0)){continue}break}if((_s|0)<1){break e}Ys=0;et=Ye+16|0;at=Ye+20|0;ft=Ye+8|0;ht=Ye+12|0;while(1){$s=Ys<<2;_s=$s+Xs|0;$s=q[Rr+$s>>2]+q[$s+ct>>2]|0;q[_s>>2]=$s;g:{if(($s|0)>q[et>>2]){$s=$s-q[at>>2]|0}else{if(($s|0)>=q[ht>>2]){break g}$s=$s+q[at>>2]|0}q[_s>>2]=$s}Ys=Ys+1|0;if((Ys|0)>2]){continue}break}}wt=q[Ye+52>>2];ft=q[Ye+48>>2];qt=Mm(16);Ys=qt;q[Ys>>2]=0;q[Ys+4>>2]=0;q[Ys+8>>2]=0;q[Ys+12>>2]=0;q[bt+8>>2]=0;q[bt>>2]=0;q[bt+4>>2]=0;h:{if(Zs){if(Zs>>>0>=1073741824){break h}Ys=Zs<<2;mt=Mm(Ys);q[bt>>2]=mt;_s=Ys+mt|0;q[bt+8>>2]=_s;Dn(mt,0,Ys);q[bt+4>>2]=_s}Ys=1;_s=q[Ye+56>>2];ut=q[_s>>2];_s=q[_s+4>>2]-ut|0;i:{if((_s|0)<5){break i}vt=_s>>2;xt=Zs<<2;ht=Ye+8|0;it=Ye+16|0;nt=Ye+32|0;ot=Ye+20|0;pt=Ye+12|0;yt=ft+28|0;et=1;while(1){j:{k:{l:{if(vt>>>0>et>>>0){m:{n:{ct=q[(et<<2)+ut>>2];if((ct|0)==-1){break n}gt=ct+((ct>>>0)%3|0?-1:2)|0;rt=gt>>>5;dt=1;st=1<<(gt&31);tt=q[ft>>2];_s=0;Ys=ct;o:{while(1){p:{if(q[tt+(Ys>>>3&536870908)>>2]>>>(Ys&31)&1){break p}$s=q[q[q[ft+64>>2]+12>>2]+(Ys<<2)>>2];if(($s|0)==-1){break p}kt=q[wt>>2];at=q[yt>>2];lt=q[kt+(q[at+($s<<2)>>2]<<2)>>2];if((lt|0)>=(et|0)){break p}jt=$s+1|0;jt=q[kt+(q[at+(((jt>>>0)%3|0?jt:$s+ -2|0)<<2)>>2]<<2)>>2];if((jt|0)>=(et|0)){break p}$s=q[kt+(q[at+($s+(($s>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2];if(($s|0)>=(et|0)){break p}if((Zs|0)>=1){kt=q[(bt+16|0)+w(_s,12)>>2];$s=w(Zs,$s);jt=w(Zs,jt);lt=w(Zs,lt);at=0;while(1){q[kt+(at<<2)>>2]=(q[($s+at<<2)+Xs>>2]+q[(at+jt<<2)+Xs>>2]|0)-q[(at+lt<<2)+Xs>>2];at=at+1|0;if((at|0)!=(Zs|0)){continue}break}}$s=4;_s=_s+1|0;if((_s|0)==4){break o}}q:{if(dt&1){at=-1;$s=Ys+1|0;Ys=($s>>>0)%3|0?$s:Ys+ -2|0;if((Ys|0)==-1|q[q[ft>>2]+(Ys>>>3&536870908)>>2]>>>(Ys&31)&1){break q}Ys=q[q[q[ft+64>>2]+12>>2]+(Ys<<2)>>2];if((Ys|0)==-1){break q}$s=Ys+1|0;at=($s>>>0)%3|0?$s:Ys+ -2|0;break q}at=-1;Ys=((Ys>>>0)%3|0?-1:2)+Ys|0;if((Ys|0)==-1|q[q[ft>>2]+(Ys>>>3&536870908)>>2]>>>(Ys&31)&1){break q}Ys=q[q[q[ft+64>>2]+12>>2]+(Ys<<2)>>2];if((Ys|0)==-1){break q}if((Ys>>>0)%3){at=Ys+ -1|0;break q}at=Ys+2|0}r:{if((at|0)==(ct|0)){break r}Ys=at;$s=(at|0)!=-1;at=($s|dt^-1)&1;Ys=at?Ys:-1;dt=$s&dt;if(!((gt|0)==-1|at)){if(q[q[ft>>2]+(rt<<2)>>2]&st){break r}$s=q[q[q[ft+64>>2]+12>>2]+(gt<<2)>>2];if(($s|0)==-1){break r}dt=0;if(($s>>>0)%3){Ys=$s+ -1|0}else{Ys=$s+2|0}}if((Ys|0)!=-1){continue}}break}$s=_s;if(($s|0)<1){break n}}gt=(Zs|0)<1;if(!gt){Dn(mt,0,xt)}Ys=$s+ -1|0;dt=(Ys<<2)+qt|0;Ys=w(Ys,12)+Ye|0;kt=Ys+60|0;rt=q[Ys- -64>>2];Ys=0;st=q[bt>>2];ct=0;_s=0;while(1){at=q[dt>>2];q[dt>>2]=at+1;if(rt>>>0<=at>>>0){break i}s:{if(q[q[kt>>2]+(at>>>3&536870908)>>2]>>>(at&31)&1){break s}_s=_s+1|0;if(gt){break s}tt=q[(bt+16|0)+w(ct,12)>>2];at=0;while(1){lt=at<<2;jt=lt+st|0;q[jt>>2]=q[jt>>2]+q[lt+tt>>2];at=at+1|0;if((at|0)!=(Zs|0)){continue}break}}ct=ct+1|0;if(($s|0)!=(ct|0)){continue}break}dt=w(Zs,et);$s=dt;if(!_s){break m}at=0;if((Zs|0)>0){break l}break k}$s=w(Zs,et)}if(q[ht>>2]<1){break j}dt=(w(et+ -1|0,Zs)<<2)+Xs|0;at=0;while(1){Ys=at<<2;_s=q[Ys+dt>>2];gt=q[it>>2];t:{if((_s|0)>(gt|0)){ct=q[nt>>2];q[Ys+ct>>2]=gt;break t}ct=q[nt>>2];Ys=Ys+ct|0;gt=q[pt>>2];if((_s|0)<(gt|0)){q[Ys>>2]=gt;break t}q[Ys>>2]=_s}at=at+1|0;_s=q[ht>>2];if((at|0)<(_s|0)){continue}break}Ys=0;if((_s|0)<1){break j}_s=$s<<2;at=_s+Xs|0;dt=Rr+_s|0;while(1){$s=Ys<<2;_s=$s+at|0;$s=q[$s+dt>>2]+q[$s+ct>>2]|0;q[_s>>2]=$s;u:{if(($s|0)>q[it>>2]){$s=$s-q[ot>>2]|0}else{if(($s|0)>=q[pt>>2]){break u}$s=$s+q[ot>>2]|0}q[_s>>2]=$s}Ys=Ys+1|0;if((Ys|0)>2]){continue}break}break j}cn();F()}while(1){Ys=(at<<2)+mt|0;q[Ys>>2]=q[Ys>>2]/(_s|0);at=at+1|0;if((at|0)!=(Zs|0)){continue}break}}if(q[ht>>2]<1){break j}at=0;while(1){Ys=at<<2;_s=q[Ys+mt>>2];$s=q[it>>2];v:{if((_s|0)>($s|0)){ct=q[nt>>2];q[Ys+ct>>2]=$s;break v}ct=q[nt>>2];Ys=Ys+ct|0;$s=q[pt>>2];if((_s|0)<($s|0)){q[Ys>>2]=$s;break v}q[Ys>>2]=_s}at=at+1|0;_s=q[ht>>2];if((at|0)<(_s|0)){continue}break}Ys=0;if((_s|0)<1){break j}_s=dt<<2;at=_s+Xs|0;dt=Rr+_s|0;while(1){$s=Ys<<2;_s=$s+at|0;$s=q[$s+dt>>2]+q[$s+ct>>2]|0;q[_s>>2]=$s;w:{if(($s|0)>q[it>>2]){$s=$s-q[ot>>2]|0}else{if(($s|0)>=q[pt>>2]){break w}$s=$s+q[ot>>2]|0}q[_s>>2]=$s}Ys=Ys+1|0;if((Ys|0)>2]){continue}break}}Ys=1;et=et+1|0;if((et|0)<(vt|0)){continue}break}}Ye=q[bt>>2];if(Ye){q[bt+4>>2]=Ye;An(Ye)}An(qt);Ye=q[bt+52>>2];if(Ye){q[bt+56>>2]=Ye;An(Ye)}Ye=q[bt+40>>2];if(Ye){q[bt+44>>2]=Ye;An(Ye)}Ye=q[bt+28>>2];if(Ye){q[bt+32>>2]=Ye;An(Ye)}Ye=q[bt+16>>2];if(Ye){q[bt+20>>2]=Ye;An(Ye)}T=bt- -64|0;return Ys|0}bn();F()}function wf(Ye){Ye=Ye|0;var Rr=0,Xs=0;q[Ye>>2]=3584;Rr=q[Ye+76>>2];if(Rr){An(Rr)}Xs=Ye+68|0;Rr=q[Xs>>2];q[Xs>>2]=0;if(Rr){An(Rr)}q[Ye>>2]=3044;Rr=q[Ye+32>>2];if(Rr){q[Ye+36>>2]=Rr;An(Rr)}return Ye|0}function xf(Ye){Ye=Ye|0;var Ys=0,Zs=0;q[Ye>>2]=3584;Ys=q[Ye+76>>2];if(Ys){An(Ys)}Zs=Ye+68|0;Ys=q[Zs>>2];q[Zs>>2]=0;if(Ys){An(Ys)}q[Ye>>2]=3044;Ys=q[Ye+32>>2];if(Ys){q[Ye+36>>2]=Ys;An(Ys)}An(Ye)}function yf(q){q=q|0;return 3}function zf(Ye){Ye=Ye|0;if(!(!q[Ye+60>>2]|!q[Ye+44>>2]|(!q[Ye+48>>2]|!q[Ye+52>>2]))){return q[Ye+56>>2]!=0|0}return 0}function Af(Ye,_s){Ye=Ye|0;_s=_s|0;var zt=0;if(!(q[_s+56>>2]|!_s|r[_s+24|0]!=3)){q[Ye+60>>2]=_s;zt=1}return zt|0}function Bf(Ye,_s){Ye=Ye|0;_s=_s|0;var At=0,Bt=0,Ct=0,Dt=0,Et=0,Ft=0,Gt=0,Ht=0,It=0,Jt=0,Kt=0;Gt=T-32|0;T=Gt;q[Gt+28>>2]=0;a:{b:{if(s[_s+38>>1]<=513){Et=q[_s+12>>2];At=q[_s+20>>2];Ct=q[_s+16>>2];Bt=Ct+4|0;if(Bt>>>0<4){At=At+1|0}Dt=Bt;Bt=At;if((Et|0)<(At|0)?1:(Et|0)<=(At|0)?t[_s+8>>2]>=Dt>>>0?0:1:0){break a}At=Ct+q[_s>>2]|0;At=r[At|0]|r[At+1|0]<<8|(r[At+2|0]<<16|r[At+3|0]<<24);q[Gt+28>>2]=At;q[_s+16>>2]=Dt;q[_s+20>>2]=Bt;break b}if(!tf(1,Gt+28|0,_s)){break a}At=q[Gt+28>>2]}if(!At){break a}Dt=Ye+76|0;uf(Dt,At);It=ah(Gt+8|0);c:{if(!bh(It,_s)){break c}Et=1;while(1){Ct=1<<(Ht&31);Ft=dh(It);Bt=q[Dt>>2]+(Ht>>>3&536870908)|0;Et=Et^Ft;Ft=q[Bt>>2]|Ct;d:{if(!(Et&1)){break d}Ft=q[Bt>>2]&(Ct^-1)}Ct=Ft;Et=Et^1;q[Bt>>2]=Ct;Ht=Ht+1|0;if((At|0)!=(Ht|0)){continue}break}Ht=0;Bt=q[_s+12>>2];Et=Bt;At=q[_s+20>>2];Ct=At;It=q[_s+16>>2];Dt=It+4|0;if(Dt>>>0<4){At=At+1|0}Jt=q[_s+8>>2];Ft=Dt;Dt=At;if((Bt|0)<(At|0)?1:(Bt|0)<=(At|0)?Jt>>>0>=Ft>>>0?0:1:0){break c}Kt=q[_s>>2];At=Kt+It|0;Bt=r[At|0]|r[At+1|0]<<8|(r[At+2|0]<<16|r[At+3|0]<<24);q[_s+16>>2]=Ft;q[_s+20>>2]=Dt;At=Ct;Ct=It+8|0;if(Ct>>>0<8){At=At+1|0}Dt=Ct;Ct=At;if((Et|0)<(At|0)?1:(Et|0)<=(At|0)?Jt>>>0>=Dt>>>0?0:1:0){break c}At=Ft+Kt|0;At=r[At|0]|r[At+1|0]<<8|(r[At+2|0]<<16|r[At+3|0]<<24);q[_s+16>>2]=Dt;q[_s+20>>2]=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=Qt;break d}St=q[Wt>>2];Mt=Mt+St|0;Qt=q[Yt>>2];if((Pt|0)<(Qt|0)){q[Mt>>2]=Qt;break d}q[Mt>>2]=Pt}Ot=Ot+1|0;Pt=q[Tt>>2];if((Ot|0)<(Pt|0)){continue}break}Mt=0;if((Pt|0)<1){break c}Ot=w(Nt,Rt)<<2;Ut=Ot+Lt|0;Qt=_s+Ot|0;while(1){Pt=Mt<<2;Ot=Pt+Ut|0;Pt=q[Pt+Qt>>2]+q[Pt+St>>2]|0;q[Ot>>2]=Pt;e:{if((Pt|0)>q[Vt>>2]){Pt=Pt-q[Xt>>2]|0}else{if((Pt|0)>=q[Yt>>2]){break e}Pt=Pt+q[Xt>>2]|0}q[Ot>>2]=Pt}Mt=Mt+1|0;if((Mt|0)>2]){continue}break}}Rt=Rt+1|0;if((Rt|0)>=(Zt|0)){break b}Mt=q[_t>>2];Ot=q[Mt>>2];if(q[Mt+4>>2]-Ot>>2>>>0>Rt>>>0){continue}break}}cn();F()}return 1}function Df(Ye,_s,Lt,Mt){var Nt=0,Ot=0,$t=0,au=x(0),bu=x(0),cu=x(0),du=0,eu=x(0),fu=x(0),gu=x(0),hu=x(0),iu=x(0),ju=0,ku=0,lu=x(0),mu=x(0),nu=x(0),ou=x(0),pu=x(0),qu=x(0),ru=x(0),su=x(0),tu=0;Nt=T-48|0;T=Nt;du=-1;Ot=-1;a:{if((_s|0)==-1){break a}Ot=_s+1|0;du=(Ot>>>0)%3|0?Ot:_s+ -2|0;Ot=_s+ -1|0;if((_s>>>0)%3){break a}Ot=_s+2|0}$t=q[Ye+52>>2];_s=q[$t>>2];b:{$t=q[$t+4>>2]-_s>>2;ju=q[q[Ye+48>>2]+28>>2];du=q[ju+(du<<2)>>2];if($t>>>0<=du>>>0){break b}tu=$t;$t=q[(Ot<<2)+ju>>2];if(tu>>>0<=$t>>>0){break b}c:{d:{Ot=q[_s+(du<<2)>>2];ju=(Ot|0)>=(Mt|0);if(ju){break d}du=q[_s+($t<<2)>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fu*au));cu=x(eu-x(cu*au));hu=x(E(x(x(x(gu*gu)+x(x(fu*fu)+x(x(cu*cu)+x(0))))/pu)))}eu=hu;Lt=Ye+80|0;_s=q[Lt>>2]+ -1|0;Mt=q[q[Ye+76>>2]+(_s>>>3&536870908)>>2];q[Lt>>2]=_s;cu=x(bu-iu);hu=x(x(cu*au)+iu);iu=x(lu-ou);bu=x(iu*eu);_s=Mt>>>(_s&31)&1;bu=x(hu+(_s?bu:x(-bu)));hu=x(x(iu*au)+ou);au=x(cu*eu);au=x(hu+(_s?x(-au):au));f:{if(((k(au),e(0))&2147483647)>>>0>=2139095041){_s=q[Ye+68>>2];q[_s>>2]=-2147483648;break f}_s=q[Ye+68>>2];Ye=_s;ku=C(+au+.5);g:{if(y(ku)<2147483648){Lt=~~ku;break g}Lt=-2147483648}q[Ye>>2]=Lt}Lt=((k(bu),e(0))&2147483647)>>>0>2139095040;ku=C(+bu+.5);h:{if(y(ku)<2147483648){Ye=~~ku;break h}Ye=-2147483648}q[_s+4>>2]=Lt?-2147483648:Ye;break c}i:{if(!ju){_s=q[Ye+72>>2];Mt=w(Ot,_s);break i}if((Mt|0)<=0){if(q[Ye+72>>2]<1){break c}Lt=q[Ye+68>>2];_s=0;while(1){q[Lt+(_s<<2)>>2]=0;_s=_s+1|0;if((_s|0)>2]){continue}break}break c}_s=q[Ye+72>>2];Mt=w(_s,Mt+ -1|0)}if((_s|0)<1){break c}Ot=q[Ye+68>>2];_s=0;while(1){q[Ot+(_s<<2)>>2]=q[(_s+Mt<<2)+Lt>>2];_s=_s+1|0;if((_s|0)>2]){continue}break}}T=Nt+48|0;return}cn();F()}function Ef(Ye){Ye=Ye|0;var _s=0;q[Ye>>2]=3812;_s=q[Ye+76>>2];if(_s){An(_s)}q[Ye>>2]=3044;_s=q[Ye+32>>2];if(_s){q[Ye+36>>2]=_s;An(_s)}return Ye|0}function Ff(Ye){Ye=Ye|0;var Lt=0;q[Ye>>2]=3812;Lt=q[Ye+76>>2];if(L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n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=r[b|0];q[e+4>>2]=0;b=b+1|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 1:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;h=p[b>>1];q[e>>2]=h;q[e+4>>2]=h>>31;b=b+2|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 2:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=s[b>>1];q[e+4>>2]=0;b=b+2|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 3:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;h=q[b>>2];q[e>>2]=h;q[e+4>>2]=h>>31;b=b+4|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 4:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=q[b>>2];q[e+4>>2]=0;b=b+4|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 5:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){h=q[b+4>>2];e=(f<<3)+d|0;q[e>>2]=q[b>>2];q[e+4>>2]=h;b=b+8|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 6:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){h=q[b+4>>2];e=(f<<3)+d|0;q[e>>2]=q[b>>2];q[e+4>>2]=h;b=b+8|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}break a;case 7:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24<1){break c}g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;g=e;i=u[b>>2];f:{if(x(y(i))=x(1)?i>x(0)?~~x(A(x(C(x(i/x(4294967296)))),x(4294967296)))>>>0:~~x(D(x(x(i-x(~~i>>>0>>>0))/x(4294967296))))>>>0:0;k=~~i>>>0;break f}h=-2147483648;k=0}q[g>>2]=k;q[e+4>>2]=h;b=b+4|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}break c;case 8:e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24<1){break d}g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;g=e;j=v[b>>3];g:{if(y(j)<0x8000000000000000){h=y(j)>=1?j>0?~~A(C(j/4294967296),4294967295)>>>0:~~D((j- +(~~j>>>0>>>0))/4294967296)>>>0:0;k=~~j>>>0;break g}h=-2147483648;k=0}q[g>>2]=k;q[e+4>>2]=h;b=b+8|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}break d;case 9:break e}}e=o[a+24|0];if(((e|0)>(c|0)?c:e)<<24>>24>=1){g=q[q[a>>2]>>2];e=q[a+48>>2]+$n(q[a+40>>2],q[a+44>>2],b,0)|0;b=g+e|0;while(1){e=(f<<3)+d|0;q[e>>2]=r[b|0];q[e+4>>2]=0;b=b+1|0;f=f+1|0;e=o[a+24|0];if((f|0)<((e|0)>(c|0)?c:e)<<24>>24){continue}break}}if((e|0)>=(c|0)){break b}Dn((e<<3)+d|0,0,c-e<<3);break b}if((e|0)>=(c|0)){break b}break a}if((e|0)>=(c|0)){break b}Dn((e<<3)+d|0,0,c-e<<3)}return}Dn((e<<3)+d|0,0,c-e<<3)}function Lf(a){a=a|0;var b=0;q[a>>2]=4048;q[a>>2]=3044;b=q[a+32>>2];if(b){q[a+36>>2]=b;An(b)}return a|0}function Mf(a){a=a|0;var c=0;q[a>>2]=4048;q[a>>2]=3044;c=q[a+32>>2];if(c){q[a+36>>2]=c;An(c)}An(a)}function Nf(a){a=a|0;return 6}function Of(a){a=a|0;var d=0;a:{if(!q[a- -64>>2]|!q[a+68>>2]|(!q[a+44>>2]|!q[a+48>>2])){break a}if(!q[a+52>>2]|!q[a+56>>2]){break a}d=q[a+92>>2]!=-1}return d|0}function Pf(a,l){a=a|0;l=l|0;var m=0;if(!(q[l+56>>2]|r[l+24|0]!=3)){q[a- -64>>2]=l;m=1}return m|0}function Qf(a,l){a=a|0;l=l|0;var n=0,o=0,p=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;w=q[l+12>>2];p=w;o=q[l+20>>2];u=o;x=q[l+16>>2];n=x+4|0;if(n>>>0<4){o=o+1|0}y=q[l+8>>2];t=n;n=o;a:{if((p|0)<(n|0)?1:(p|0)<=(n|0)?y>>>0>=t>>>0?0:1:0){break a}z=q[l>>2];o=x+z|0;p=r[o|0]|r[o+1|0]<<8|(r[o+2|0]<<16|r[o+3|0]<<24);q[l+16>>2]=t;q[l+20>>2]=n;n=w;o=u;v=x+8|0;if(v>>>0<8){o=o+1|0}if((n|0)<(o|0)?1:(n|0)<=(o|0)?y>>>0>=v>>>0?0:1:0){break a}n=t+z|0;n=r[n|0]|r[n+1|0]<<8|(r[n+2|0]<<16|r[n+3|0]<<24);q[l+16>>2]=v;q[l+20>>2]=o;if((p|0)>(n|0)){break a}q[a+16>>2]=n;q[a+12>>2]=p;t=p;p=(n>>31)-((p>>31)+(n>>>0

>>0)|0)|0;n=n-t|0;if(!p&n>>>0>2147483646|p>>>0>0){break a}p=n+1|0;q[a+20>>2]=p;t=a+24|0;n=(p|0)/2|0;q[t>>2]=n;q[a+28>>2]=0-n;if(!(p&1)){q[t>>2]=n+ -1}if(s[l+38>>1]<=513){if((w|0)<(o|0)?1:(w|0)<=(o|0)?y>>>0>v>>>0?0:1:0){break a}n=r[v+z|0];o=u;u=x+9|0;if(u>>>0<9){o=o+1|0}p=l;q[p+16>>2]=u;q[p+20>>2]=o;if(n>>>0>1){break a}q[a+88>>2]=n-1|0?0:1}A=bh(a+108|0,l)}return A|0}function Rf(a,l,r,s,B,C){a=a|0;l=l|0;r=r|0;s=s|0;B=B|0;C=C|0;var D=0,E=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;E=T-32|0;T=E;q[a+68>>2]=C;s=q[a+56>>2];B=q[s>>2];C=s+4|0;D=q[C>>2];q[E+24>>2]=0;q[E+16>>2]=0;q[E+20>>2]=0;a:{B=D-B|0;if((B|0)<1){break a}s=q[s>>2];if((s|0)!=q[C>>2]){P=B>>2;Q=a+60|0;R=a+108|0;K=a+8|0;L=a+16|0;M=a+32|0;N=a+20|0;O=a+12|0;S=a+56|0;while(1){Sf(Q,q[(I<<2)+s>>2],E+16|0);B=q[E+20>>2];D=B>>31;C=q[E+16>>2];G=C>>31;J=q[E+24>>2];H=J>>31;s=0;H=H^H+J;D=H+((D^B+D)+(G^C+G)|0)|0;if(D>>>0>>0){s=1}b:{if(!(s|D)){q[E+16>>2]=q[a+104>>2];break b}G=q[a+104>>2];H=G>>31;B=ao($n(G,H,B,B>>31),V,D,s);q[E+20>>2]=B;s=ao($n(G,H,C,C>>31),V,D,s);q[E+16>>2]=s;C=s;s=s>>31;s=(G-(C+s^s)|0)+((B|0)<0?B:0-B|0)|0;if((J|0)>=0){q[E+24>>2]=s;break b}q[E+24>>2]=0-s}s=dh(R);C=q[E+16>>2];c:{if(!s){B=q[E+20>>2];break c}q[E+24>>2]=0-q[E+24>>2];B=0-q[E+20>>2]|0;q[E+20>>2]=B;C=0-C|0;q[E+16>>2]=C}d:{if((C|0)>=0){s=q[a+104>>2];C=s+q[E+24>>2]|0;s=s+B|0;break d}e:{if((B|0)<=-1){C=q[E+24>>2];s=C>>31;s=s^s+C;break e}C=q[E+24>>2];s=C>>31;s=q[a+100>>2]-(s^s+C)|0}if((C|0)<=-1){C=B;B=B>>31;C=C+B^B;break d}C=B;B=B>>31;C=q[a+100>>2]-(C+B^B)|0}B=q[a+100>>2];f:{if(!(s|C)){C=B;s=B;break f}if(!((B|0)!=(C|0)|s)){s=C;break f}if(!((s|0)!=(B|0)|C)){C=s;break f}g:{if(s){break g}D=q[a+104>>2];if((D|0)>=(C|0)){break g}C=(D<<1)-C|0;s=0;break f}h:{if((s|0)!=(B|0)){break h}D=q[a+104>>2];if((D|0)<=(C|0)){break h}C=(D<<1)-C|0;break f}i:{if((B|0)!=(C|0)){break i}B=q[a+104>>2];if((B|0)<=(s|0)){break i}s=(B<<1)-s|0;break f}if(C){break f}C=0;B=q[a+104>>2];if((B|0)>=(s|0)){break f}s=(B<<1)-s|0}q[E+12>>2]=C;q[E+8>>2]=s;j:{if(q[K>>2]<1){break j}C=0;while(1){D=q[L>>2];k:{if((s|0)>(D|0)){B=q[M>>2];q[B+(C<<2)>>2]=D;break k}B=q[M>>2];D=B+(C<<2)|0;G=q[O>>2];if((s|0)<(G|0)){q[D>>2]=G;break k}q[D>>2]=s}C=C+1|0;D=q[K>>2];if((C|0)<(D|0)){s=q[(E+8|0)+(C<<2)>>2];continue}break}s=0;if((D|0)<1){break j}C=I<<3;G=C+r|0;J=l+C|0;while(1){D=s<<2;C=D+G|0;D=q[D+J>>2]+q[B+D>>2]|0;q[C>>2]=D;l:{if((D|0)>q[L>>2]){H=D-q[N>>2]|0}else{if((D|0)>=q[O>>2]){break l}H=D+q[N>>2]|0}q[C>>2]=H}s=s+1|0;if((s|0)>2]){continue}break}}I=I+1|0;if((I|0)>=(P|0)){break a}B=q[S>>2];s=q[B>>2];if(q[B+4>>2]-s>>2>>>0>I>>>0){continue}break}}cn();F()}T=E+32|0;return 1}function Sf(a,l,s){a=a|0;l=l|0;s=s|0;var B=0,C=0,U=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0;C=T-96|0;T=C;B=q[a+16>>2];o[C+92|0]=1;q[C+88>>2]=l;q[C+84>>2]=l;q[C+80>>2]=B;W=q[a+20>>2];U=q[W>>2];a:{b:{c:{d:{B=q[q[B+28>>2]+(l<<2)>>2];if(q[W+4>>2]-U>>2>>>0>B>>>0){B=q[q[a+8>>2]+(q[U+(B<<2)>>2]<<2)>>2];U=q[a+4>>2];if(!r[U+84|0]){B=q[q[U+68>>2]+(B<<2)>>2]}q[C+72>>2]=0;q[C+76>>2]=0;W=C- -64|0;q[W>>2]=0;q[W+4>>2]=0;q[C+56>>2]=0;q[C+60>>2]=0;Kf(U,B,o[U+24|0],C+56|0);if((l|0)==-1){break a}B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>>0>>0)+ga|0)|0;B=$n(ja,_,ia,ga);Y=B+ka|0;l=V+$|0;l=Y>>>0>>0?l+1|0:l;$=l;B=Z;ba=fa;qa=U;Z=q[C+48>>2];l=q[C+72>>2];U=Z-l|0;fa=q[C+76>>2];ka=q[C+52>>2]-(fa+(Z>>>0>>0)|0)|0;ba=$n(ba,qa,U,ka);Z=B+ba|0;B=V+ca|0;B=Z>>>0>>0?B+1|0:B;ca=Z;Z=q[X>>2];ba=Z-l|0;l=q[X+4>>2]-((Z>>>0>>0)+fa|0)|0;X=$n(ba,l,ia,ga);Z=ca-X|0;ca=B-(V+(ca>>>0>>0)|0)|0;B=$n(ja,_,U,ka);U=aa-B|0;da=da-(V+(aa>>>0>>0)|0)|0;B=$n(ba,l,pa,ha);aa=B+U|0;l=V+da|0;l=aa>>>0>>0?l+1|0:l;da=l;Uf(C+80|0);_=q[la>>2];X=!_;l=q[C+88>>2];if((l|0)!=-1){continue}break}l=ca;B=l>>31;a=l>>31;l=a+l|0;W=B+Z|0;if(W>>>0>>0){l=l+1|0}B=B^W;X=a^l;l=da;a=l>>31;l=l>>31;W=a;ea=da+a|0;U=l+aa|0;if(U>>>0>>0){ea=ea+1|0}a=l^U;U=W^ea;f:{if(($|0)<-1?1:($|0)<=-1?Y>>>0>4294967295?0:1:0){l=Y;W=a+(B-l|0)|0;l=U+(X-((B>>>0>>0)+$|0)|0)|0;B=W;a=B>>>0>>0?l+1|0:l;if(!_){break f}break b}l=X+$|0;W=B;B=Y;W=W+B|0;if(W>>>0>>0){l=l+1|0}B=a;W=B+W|0;a=l+U|0;a=W>>>0>>0?a+1|0:a;B=W;if(_){break b}}if((B|0)<536870913){break a}a=((a&536870911)<<3|B>>>29)&7;l=0;Y=ao(Y,$,a,l);Z=ao(Z,ca,a,l);aa=ao(aa,da,a,l);break a}cn();F()}cn();F()}cn();F()}if((a|0)<0?1:(a|0)<=0?B>>>0>=536870913?0:1:0){break a}l=a>>>29;a=(a&536870911)<<3|B>>>29;Y=ao(Y,$,a,l);Z=ao(Z,ca,a,l);aa=ao(aa,da,a,l)}q[s+8>>2]=Y;q[s+4>>2]=Z;q[s>>2]=aa;T=C+96|0}function Tf(a,l){a=a|0;l=l|0;if(l>>>0<=1){q[a+28>>2]=l;a=1}else{a=0}return a|0}function Uf(a){var l=0,s=0,F=0;l=q[a+8>>2];F=q[a>>2];a:{if(r[a+12|0]){b:{c:{d:{e:{if((l|0)==-1){break e}s=l+1|0;l=(s>>>0)%3|0?s:l+ -2|0;if((l|0)==-1|q[q[F>>2]+(l>>>3&536870908)>>2]>>>(l&31)&1){break e}l=q[q[q[F+64>>2]+12>>2]+(l<<2)>>2];if((l|0)!=-1){break d}}q[a+8>>2]=-1;break c}s=l+1|0;l=(s>>>0)%3|0?s:l+ -2|0;q[a+8>>2]=l;if((l|0)!=-1){break b}}l=-1;s=q[a+4>>2];f:{if((s|0)==-1){break f}s=s+((s>>>0)%3|0?-1:2)|0;if((s|0)==-1|q[q[F>>2]+(s>>>3&536870908)>>2]>>>(s&31)&1){break f}F=q[q[q[F+64>>2]+12>>2]+(s<<2)>>2];if((F|0)==-1){break f}if((F>>>0)%3){l=F+ -1|0;break f}l=F+2|0}o[a+12|0]=0;q[a+8>>2]=l;return}if((l|0)!=q[a+4>>2]){break a}q[a+8>>2]=-1;return}s=-1;g:{if((l|0)==-1){break g}l=l+((l>>>0)%3|0?-1:2)|0;if((l|0)==-1|q[q[F>>2]+(l>>>3&536870908)>>2]>>>(l&31)&1){break g}l=q[q[q[F+64>>2]+12>>2]+(l<<2)>>2];if((l|0)==-1){break g}if((l>>>0)%3){s=l+ -1|0;break g}s=l+2|0}q[a+8>>2]=s}}function Vf(a,r,T,V){var ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0;q[a>>2]=3044;q[a+4>>2]=r;r=q[T+8>>2];ra=q[T+12>>2];sa=q[T+16>>2];ua=q[T+20>>2];va=q[T>>2];wa=q[T+4>>2];q[a+40>>2]=0;ta=a+32|0;q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Ga>>2];if((V|0)<(Aa|0)){continue}break}if((Aa|0)<1){break b}Ca=0;Ga=a+16|0;Ba=a+20|0;Ia=a+8|0;Ja=a+12|0;while(1){Aa=Ca<<2;V=Aa+T|0;Aa=q[r+Aa>>2]+q[Aa+Ha>>2]|0;q[V>>2]=Aa;d:{if((Aa|0)>q[Ga>>2]){Aa=Aa-q[Ba>>2]|0}else{if((Aa|0)>=q[Ja>>2]){break d}Aa=Aa+q[Ba>>2]|0}q[V>>2]=Aa}Ca=Ca+1|0;Aa=q[Ia>>2];if((Ca|0)<(Aa|0)){continue}break}}V=q[a+56>>2];Pa=q[V>>2];V=q[V+4>>2]-Pa|0;if((V|0)>=5){Qa=V>>2;Ha=a+16|0;Ga=a+32|0;Ia=a+8|0;Ja=a+20|0;Ea=a+12|0;Ca=1;while(1){e:{f:{if(Qa>>>0>Ca>>>0){Ma=w(za,Ca);a=q[(Ca<<2)+Pa>>2];if((a|0)==-1){break f}a=q[q[Oa+12>>2]+(a<<2)>>2];if((a|0)==-1){break f}V=-1;Da=q[Ra>>2];Ba=q[Oa>>2];Ka=q[Da+(q[Ba+(a<<2)>>2]<<2)>>2];La=a+1|0;La=(La>>>0)%3|0?La:a+ -2|0;if((La|0)!=-1){La=q[Ba+(La<<2)>>2]}else{La=-1}a=a+((a>>>0)%3|0?-1:2)|0;if((a|0)!=-1){V=q[Ba+(a<<2)>>2]}if((Ka|0)>=(Ca|0)){break f}a=q[(La<<2)+Da>>2];if((a|0)>=(Ca|0)){break f}V=q[Da+(V<<2)>>2];if((V|0)>=(Ca|0)){break f}if((za|0)>=1){Ba=w(V,za);a=w(a,za);Da=w(za,Ka);V=0;while(1){q[(V<<2)+Na>>2]=(q[(V+Ba<<2)+T>>2]+q[(a+V<<2)+T>>2]|0)-q[(V+Da<<2)+T>>2];V=V+1|0;if((za|0)!=(V|0)){continue}break}}if((Aa|0)<1){break e}V=0;while(1){a=V<<2;Aa=q[a+Na>>2];Da=q[Ha>>2];g:{if((Aa|0)>(Da|0)){Ba=q[Ga>>2];q[a+Ba>>2]=Da;break g}Ba=q[Ga>>2];a=a+Ba|0;Da=q[Ea>>2];if((Aa|0)<(Da|0)){q[a>>2]=Da;break g}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}V=0;if((Aa|0)<1){break e}a=Ma<<2;Ma=a+T|0;Da=a+r|0;while(1){Aa=V<<2;a=Aa+Ma|0;Aa=q[Aa+Da>>2]+q[Aa+Ba>>2]|0;q[a>>2]=Aa;h:{if((Aa|0)>q[Ha>>2]){Aa=Aa-q[Ja>>2]|0}else{if((Aa|0)>=q[Ea>>2]){break h}Aa=Aa+q[Ja>>2]|0}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}break e}cn();F()}if((Aa|0)<1){break e}Da=(w(Ca+ -1|0,za)<<2)+T|0;V=0;while(1){a=V<<2;Aa=q[a+Da>>2];Ka=q[Ha>>2];i:{if((Aa|0)>(Ka|0)){Ba=q[Ga>>2];q[a+Ba>>2]=Ka;break i}Ba=q[Ga>>2];a=a+Ba|0;Ka=q[Ea>>2];if((Aa|0)<(Ka|0)){q[a>>2]=Ka;break i}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}V=0;if((Aa|0)<1){break e}a=Ma<<2;Ma=a+T|0;Da=a+r|0;while(1){Aa=V<<2;a=Aa+Ma|0;Aa=q[Aa+Da>>2]+q[Aa+Ba>>2]|0;q[a>>2]=Aa;j:{if((Aa|0)>q[Ha>>2]){Aa=Aa-q[Ja>>2]|0}else{if((Aa|0)>=q[Ea>>2]){break j}Aa=Aa+q[Ja>>2]|0}q[a>>2]=Aa}V=V+1|0;Aa=q[Ia>>2];if((V|0)<(Aa|0)){continue}break}}Ca=Ca+1|0;if((Ca|0)<(Qa|0)){continue}break}}An(Na);return 1}function Xf(a,r,T,V,za,Aa){a=a|0;r=r|0;T=T|0;V=V|0;za=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f:{g:{if(fb>>>0>Va>>>0){Aa=q[(Va<<2)+eb>>2];hb=(za|0)<1;if(!hb){Dn($a,0,kb)}if((Aa|0)==-1){a=w(za,Va);break f}ib=q[gb+12>>2];Ya=0;V=Aa;while(1){a=q[ib+(V<<2)>>2];h:{if((a|0)==-1){break h}Ua=-1;ab=q[lb>>2];Sa=q[gb>>2];jb=q[ab+(q[Sa+(a<<2)>>2]<<2)>>2];Xa=a+1|0;Xa=(Xa>>>0)%3|0?Xa:a+ -2|0;if((Xa|0)!=-1){Xa=q[Sa+(Xa<<2)>>2]}else{Xa=-1}a=a+((a>>>0)%3|0?-1:2)|0;if((a|0)!=-1){Ua=q[Sa+(a<<2)>>2]}if((jb|0)>=(Va|0)){break h}a=q[(Xa<<2)+ab>>2];if((a|0)>=(Va|0)){break h}Sa=q[ab+(Ua<<2)>>2];if((Sa|0)>=(Va|0)){break h}i:{if(hb){break i}Ua=w(za,Sa);a=w(a,za);ab=w(za,jb);Sa=0;while(1){q[db+(Sa<<2)>>2]=(q[(Sa+Ua<<2)+T>>2]+q[(a+Sa<<2)+T>>2]|0)-q[(Sa+ab<<2)+T>>2];Sa=Sa+1|0;if((Sa|0)!=(za|0)){continue}break}Sa=0;if((za|0)<=0){break i}while(1){a=Sa<<2;Ua=a+$a|0;q[Ua>>2]=q[Ua>>2]+q[a+db>>2];Sa=Sa+1|0;if((Sa|0)!=(za|0)){continue}break}}Ya=Ya+1|0}V=((V>>>0)%3|0?-1:2)+V|0;a=-1;j:{if((V|0)==-1){break j}V=q[ib+(V<<2)>>2];a=-1;if((V|0)==-1){break j}a=V+ -1|0;if((V>>>0)%3){break j}a=V+2|0}V=(a|0)==(Aa|0)?-1:a;if((V|0)!=-1){continue}break}a=w(za,Va);if(!Ya){break f}Sa=0;if((za|0)<=0){break g}while(1){V=(Sa<<2)+$a|0;q[V>>2]=q[V>>2]/(Ya|0);Sa=Sa+1|0;if((Sa|0)!=(za|0)){continue}break}break g}cn();F()}if((Ta|0)<1){break e}Sa=0;while(1){V=Sa<<2;Aa=q[V+$a>>2];Ta=q[Za>>2];k:{if((Aa|0)>(Ta|0)){Ua=q[_a>>2];q[V+Ua>>2]=Ta;break k}Ua=q[_a>>2];V=V+Ua|0;Ta=q[cb>>2];if((Aa|0)<(Ta|0)){q[V>>2]=Ta;break k}q[V>>2]=Aa}Sa=Sa+1|0;Ta=q[Wa>>2];if((Sa|0)<(Ta|0)){continue}break}Aa=0;if((Ta|0)<1){break e}a=a<<2;Sa=a+T|0;Ya=a+r|0;while(1){V=Aa<<2;a=V+Sa|0;V=q[V+Ya>>2]+q[V+Ua>>2]|0;q[a>>2]=V;l:{if((V|0)>q[Za>>2]){V=V-q[bb>>2]|0}else{if((V|0)>=q[cb>>2]){break l}V=V+q[bb>>2]|0}q[a>>2]=V}Aa=Aa+1|0;Ta=q[Wa>>2];if((Aa|0)<(Ta|0)){continue}break}break e}if((Ta|0)<1){break e}Ya=(w(Va+ -1|0,za)<<2)+T|0;Sa=0;while(1){V=Sa<<2;Aa=q[V+Ya>>2];Ta=q[Za>>2];m:{if((Aa|0)>(Ta|0)){Ua=q[_a>>2];q[V+Ua>>2]=Ta;break m}Ua=q[_a>>2];V=V+Ua|0;Ta=q[cb>>2];if((Aa|0)<(Ta|0)){q[V>>2]=Ta;break m}q[V>>2]=Aa}Sa=Sa+1|0;Ta=q[Wa>>2];if((Sa|0)<(Ta|0)){continue}break}Aa=0;if((Ta|0)<1){break e}a=a<<2;Sa=a+T|0;Ya=a+r|0;while(1){V=Aa<<2;a=V+Sa|0;V=q[V+Ya>>2]+q[V+Ua>>2]|0;q[a>>2]=V;n:{if((V|0)>q[Za>>2]){V=V-q[bb>>2]|0}else{if((V|0)>=q[cb>>2]){break n}V=V+q[bb>>2]|0}q[a>>2]=V}Aa=Aa+1|0;Ta=q[Wa>>2];if((Aa|0)<(Ta|0)){continue}break}}Va=Va+1|0;if((Va|0)<(fb|0)){continue}break}}An(db);An($a);return 1}function Yf(a){a=a|0;var r=0;q[a>>2]=5324;r=q[a+96>>2];if(r){An(r)}r=q[a+84>>2];if(r){An(r)}r=q[a+72>>2];if(r){An(r)}r=q[a+60>>2];if(r){An(r)}q[a>>2]=3044;r=q[a+32>>2];if(r){q[a+36>>2]=r;An(r)}return a|0}function Zf(a){a=a|0;var T=0;q[a>>2]=5324;T=q[a+96>>2];if(T){An(T)}T=q[a+84>>2];if(T){An(T)}T=q[a+72>>2];if(T){An(T)}T=q[a+60>>2];if(T){An(T)}q[a>>2]=3044;T=q[a+32>>2];if(T){q[a+36>>2]=T;An(T)}An(a)}function _f(a,V,za,Aa,mb,nb){a=a|0;V=V|0;za=za|0;Aa=Aa|0;mb=mb|0;nb=nb|0;var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0,Fb=0,Gb=0,Hb=0,Ib=0,Jb=0,Kb=0,Lb=0,Mb=0;qb=T+ -64|0;T=qb;q[a+8>>2]=mb;nb=a+32|0;rb=q[nb>>2];Aa=q[a+36>>2]-rb>>2;a:{if(Aa>>>0>>0){Fa(nb,mb-Aa|0);break a}if(Aa>>>0<=mb>>>0){break a}q[a+36>>2]=rb+(mb<<2)}q[qb+56>>2]=0;q[qb+60>>2]=0;q[qb+48>>2]=0;q[qb+52>>2]=0;q[qb+40>>2]=0;q[qb+44>>2]=0;Aa=qb+32|0;q[Aa>>2]=0;q[Aa+4>>2]=0;q[qb+24>>2]=0;q[qb+28>>2]=0;q[qb+16>>2]=0;q[qb+20>>2]=0;q[qb>>2]=0;nb=0;if(mb){Ad(qb+16|0,mb,qb);pb=q[qb+28>>2];nb=q[Aa>>2]}q[qb>>2]=0;Aa=nb-pb>>2;b:{if(Aa>>>0>=mb>>>0){if(Aa>>>0<=mb>>>0){break b}q[qb+32>>2]=(mb<<2)+pb;break b}Ad(qb+16|12,mb-Aa|0,qb)}q[qb>>2]=0;nb=q[qb+40>>2];Aa=q[qb+44>>2]-nb>>2;c:{if(Aa>>>0>=mb>>>0){if(Aa>>>0<=mb>>>0){break c}q[qb+44>>2]=nb+(mb<<2);break c}Ad(qb+40|0,mb-Aa|0,qb)}q[qb>>2]=0;nb=q[qb+52>>2];Aa=q[qb+56>>2]-nb>>2;d:{if(Aa>>>0>=mb>>>0){if(Aa>>>0<=mb>>>0){break d}q[qb+56>>2]=nb+(mb<<2);break d}Ad(qb+52|0,mb-Aa|0,qb)}tb=a+8|0;e:{if(q[tb>>2]<=0){break e}vb=q[qb+16>>2];pb=0;sb=a+16|0;Aa=a+32|0;Ab=a+12|0;while(1){nb=pb<<2;ob=q[nb+vb>>2];wb=q[sb>>2];f:{if((ob|0)>(wb|0)){rb=q[Aa>>2];q[nb+rb>>2]=wb;break f}rb=q[Aa>>2];nb=nb+rb|0;wb=q[Ab>>2];if((ob|0)<(wb|0)){q[nb>>2]=wb;break f}q[nb>>2]=ob}pb=pb+1|0;nb=q[tb>>2];if((pb|0)<(nb|0)){continue}break}if((nb|0)<1){break e}nb=0;tb=a+16|0;pb=a+20|0;vb=a+8|0;sb=a+12|0;while(1){ob=nb<<2;Aa=ob+za|0;ob=q[V+ob>>2]+q[ob+rb>>2]|0;q[Aa>>2]=ob;g:{if((ob|0)>q[tb>>2]){ob=ob-q[pb>>2]|0}else{if((ob|0)>=q[sb>>2]){break g}ob=ob+q[pb>>2]|0}q[Aa>>2]=ob}nb=nb+1|0;if((nb|0)>2]){continue}break}}Lb=q[a+52>>2];Ib=q[a+48>>2];Hb=Mm(16);Aa=Hb;q[Aa>>2]=0;q[Aa+4>>2]=0;q[Aa+8>>2]=0;q[Aa+12>>2]=0;q[qb+8>>2]=0;q[qb>>2]=0;q[qb+4>>2]=0;h:{if(mb){if(mb>>>0>=1073741824){break h}Aa=mb<<2;Bb=Mm(Aa);q[qb>>2]=Bb;nb=Aa+Bb|0;q[qb+8>>2]=nb;Dn(Bb,0,Aa);q[qb+4>>2]=nb}rb=1;Aa=q[a+56>>2];Jb=q[Aa>>2];Aa=q[Aa+4>>2]-Jb|0;i:{if((Aa|0)<5){break i}Kb=Aa>>2;Mb=mb<<2;vb=a+8|0;Ab=a+16|0;wb=a+32|0;Eb=a+20|0;Fb=a+12|0;tb=1;while(1){j:{k:{l:{if(Kb>>>0>tb>>>0){m:{n:{rb=q[(tb<<2)+Jb>>2];if((rb|0)==-1){break n}ub=q[Ib+12>>2];Db=rb+((rb>>>0)%3|0?-1:2)|0;Gb=ub+(Db<<2)|0;sb=1;nb=0;Aa=rb;o:{while(1){ob=q[ub+(Aa<<2)>>2];p:{if((ob|0)==-1){break p}pb=-1;zb=q[Lb>>2];xb=q[Ib>>2];Cb=q[zb+(q[xb+(ob<<2)>>2]<<2)>>2];yb=ob+1|0;yb=(yb>>>0)%3|0?yb:ob+ -2|0;if((yb|0)!=-1){yb=q[xb+(yb<<2)>>2]}else{yb=-1}ob=ob+((ob>>>0)%3|0?-1:2)|0;if((ob|0)!=-1){pb=q[xb+(ob<<2)>>2]}if((Cb|0)>=(tb|0)){break p}ob=q[(yb<<2)+zb>>2];if((ob|0)>=(tb|0)){break p}pb=q[zb+(pb<<2)>>2];if((pb|0)>=(tb|0)){break p}xb=q[(qb+16|0)+w(nb,12)>>2];if((mb|0)>=1){zb=w(mb,pb);ob=w(mb,ob);Cb=w(mb,Cb);pb=0;while(1){q[xb+(pb<<2)>>2]=(q[(pb+zb<<2)+za>>2]+q[(ob+pb<<2)+za>>2]|0)-q[(pb+Cb<<2)+za>>2];pb=pb+1|0;if((pb|0)!=(mb|0)){continue}break}}ob=4;nb=nb+1|0;if((nb|0)==4){break o}}q:{if(sb&1){xb=Aa+1|0;Aa=(xb>>>0)%3|0?xb:Aa+ -2|0;ob=-1;if((Aa|0)==-1){break q}Aa=q[ub+(Aa<<2)>>2];ob=-1;if((Aa|0)==-1){break q}ob=Aa+1|0;ob=(ob>>>0)%3|0?ob:Aa+ -2|0;break q}Aa=((Aa>>>0)%3|0?-1:2)+Aa|0;ob=-1;if((Aa|0)==-1){break q}Aa=q[ub+(Aa<<2)>>2];ob=-1;if((Aa|0)==-1){break q}ob=Aa+ -1|0;if((Aa>>>0)%3){break q}ob=Aa+2|0}r:{if((ob|0)==(rb|0)){break r}Aa=ob;ob=(ob|0)!=-1;pb=(ob|sb^-1)&1;Aa=pb?Aa:-1;sb=ob&sb;if(!((Db|0)==-1|pb)){ob=q[Gb>>2];if((ob|0)==-1){break r}sb=0;if((ob>>>0)%3){Aa=ob+ -1|0}else{Aa=ob+2|0}}if((Aa|0)!=-1){continue}}break}ob=nb;if((ob|0)<1){break n}}ub=(mb|0)<1;if(!ub){Dn(Bb,0,Mb)}Aa=ob+ -1|0;sb=(Aa<<2)+Hb|0;Aa=w(Aa,12)+a|0;xb=Aa+60|0;zb=q[Aa- -64>>2];rb=0;Cb=q[qb>>2];Aa=0;nb=0;while(1){pb=q[sb>>2];q[sb>>2]=pb+1;if(zb>>>0<=pb>>>0){break i}s:{if(q[q[xb>>2]+(pb>>>3&536870908)>>2]>>>(pb&31)&1){break s}nb=nb+1|0;if(ub){break s}yb=q[(qb+16|0)+w(Aa,12)>>2];pb=0;while(1){Db=pb<<2;Gb=Db+Cb|0;q[Gb>>2]=q[Gb>>2]+q[yb+Db>>2];pb=pb+1|0;if((pb|0)!=(mb|0)){continue}break}}Aa=Aa+1|0;if((ob|0)!=(Aa|0)){continue}break}ob=w(mb,tb);Aa=ob;if(!nb){break m}pb=0;if((mb|0)>0){break l}break k}Aa=w(mb,tb)}if(q[vb>>2]<1){break j}sb=(w(tb+ -1|0,mb)<<2)+za|0;pb=0;while(1){nb=pb<<2;ob=q[nb+sb>>2];ub=q[Ab>>2];t:{if((ob|0)>(ub|0)){rb=q[wb>>2];q[nb+rb>>2]=ub;break t}rb=q[wb>>2];nb=nb+rb|0;ub=q[Fb>>2];if((ob|0)<(ub|0)){q[nb>>2]=ub;break t}q[nb>>2]=ob}pb=pb+1|0;ob=q[vb>>2];if((pb|0)<(ob|0)){continue}break}nb=0;if((ob|0)<1){break j}Aa=Aa<<2;pb=Aa+za|0;sb=V+Aa|0;while(1){ob=nb<<2;Aa=ob+pb|0;ob=q[ob+sb>>2]+q[ob+rb>>2]|0;q[Aa>>2]=ob;u:{if((ob|0)>q[Ab>>2]){ob=ob-q[Eb>>2]|0}else{if((ob|0)>=q[Fb>>2]){break u}ob=ob+q[Eb>>2]|0}q[Aa>>2]=ob}nb=nb+1|0;if((nb|0)>2]){continue}break}break j}cn();F()}while(1){Aa=(pb<<2)+Bb|0;q[Aa>>2]=q[Aa>>2]/(nb|0);pb=pb+1|0;if((pb|0)!=(mb|0)){continue}break}}if(q[vb>>2]<1){break j}pb=0;while(1){Aa=pb<<2;nb=q[Aa+Bb>>2];sb=q[Ab>>2];v:{if((nb|0)>(sb|0)){rb=q[wb>>2];q[Aa+rb>>2]=sb;break v}rb=q[wb>>2];Aa=Aa+rb|0;sb=q[Fb>>2];if((nb|0)<(sb|0)){q[Aa>>2]=sb;break v}q[Aa>>2]=nb}pb=pb+1|0;Aa=q[vb>>2];if((pb|0)<(Aa|0)){continue}break}nb=0;if((Aa|0)<1){break j}Aa=ob<<2;pb=Aa+za|0;sb=V+Aa|0;while(1){ob=nb<<2;Aa=ob+pb|0;ob=q[ob+sb>>2]+q[ob+rb>>2]|0;q[Aa>>2]=ob;w:{if((ob|0)>q[Ab>>2]){ob=ob-q[Eb>>2]|0}else{if((ob|0)>=q[Fb>>2]){break w}ob=ob+q[Eb>>2]|0}q[Aa>>2]=ob}nb=nb+1|0;if((nb|0)>2]){continue}break}}rb=1;tb=tb+1|0;if((tb|0)<(Kb|0)){continue}break}}a=q[qb>>2];if(a){q[qb+4>>2]=a;An(a)}An(Hb);a=q[qb+52>>2];if(a){q[qb+56>>2]=a;An(a)}a=q[qb+40>>2];if(a){q[qb+44>>2]=a;An(a)}a=q[qb+28>>2];if(a){q[qb+32>>2]=a;An(a)}a=q[qb+16>>2];if(a){q[qb+20>>2]=a;An(a)}T=qb- -64|0;return rb|0}bn();F()}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c));ic=x(E(x(x(x(hc*hc)+x(x(gc*gc)+x(x(ec*ec)+x(0))))/qc)))}fc=ic;nb=a+80|0;mb=q[nb>>2]+ -1|0;Nb=q[q[a+76>>2]+(mb>>>3&536870908)>>2];q[nb>>2]=mb;ec=x(dc-jc);ic=x(x(ec*bc)+jc);jc=x(mc-pc);dc=x(jc*fc);mb=Nb>>>(mb&31)&1;dc=x(ic+(mb?dc:x(-dc)));ic=x(x(jc*bc)+pc);bc=x(ec*fc);bc=x(ic+(mb?x(-bc):bc));e:{if(((k(bc),e(0))&2147483647)>>>0>=2139095041){mb=q[a+68>>2];q[mb>>2]=-2147483648;break e}mb=q[a+68>>2];a=mb;lc=C(+bc+.5);f:{if(y(lc)<2147483648){nb=~~lc;break f}nb=-2147483648}q[a>>2]=nb}nb=((k(dc),e(0))&2147483647)>>>0>2139095040;lc=C(+dc+.5);g:{if(y(lc)<2147483648){a=~~lc;break g}a=-2147483648}q[mb+4>>2]=nb?-2147483648:a;break b}h:{if(!kc){mb=q[a+72>>2];Nb=w(Pb,mb);break h}if((Nb|0)<=0){if(q[a+72>>2]<1){break b}nb=q[a+68>>2];mb=0;while(1){q[nb+(mb<<2)>>2]=0;mb=mb+1|0;if((mb|0)>2]){continue}break}break b}mb=q[a+72>>2];Nb=w(mb,Nb+ -1|0)}if((mb|0)<1){break b}Pb=q[a+68>>2];mb=0;while(1){q[Pb+(mb<<2)>>2]=q[(mb+Nb<<2)+nb>>2];mb=mb+1|0;if((mb|0)>2]){continue}break}}T=Ob+48|0;return}cn();F()}function dg(a){a=a|0;var mb=0;q[a>>2]=5776;mb=q[a+76>>2];if(mb){An(mb)}q[a>>2]=3044;mb=q[a+32>>2];if(mb){q[a+36>>2]=mb;An(mb)}return a|0}function eg(a){a=a|0;var nb=0;q[a>>2]=5776;nb=q[a+76>>2];if(nb){An(nb)}q[a>>2]=3044;nb=q[a+32>>2];if(nb){q[a+36>>2]=nb;An(nb)}An(a)}function fg(a,Nb,vc,wc,xc,yc){a=a|0;Nb=Nb|0;vc=vc|0;wc=wc|0;xc=xc|0;yc=yc|0;var zc=0,Ac=0,Bc=0,Cc=0,Dc=0,Ec=0,Fc=0,Gc=0,Hc=0,Ic=0,Jc=0,Kc=0;wc=0;a:{if((xc|0)!=2){break a}q[a+8>>2]=2;q[a- -64>>2]=yc;wc=a+32|0;xc=q[wc>>2];yc=q[a+36>>2]-xc|0;zc=yc>>2;b:{if(zc>>>0<=1){Fa(wc,2-zc|0);break b}if((yc|0)==8){break b}q[a+36>>2]=xc+8}wc=1;xc=q[a+56>>2];yc=q[xc+4>>2];xc=q[xc>>2];zc=yc-xc|0;if((zc|0)<1){break a}if((xc|0)!=(yc|0)){Hc=a+60|0;Ic=zc>>2;zc=a+8|0;Dc=a+16|0;Ec=a+32|0;Fc=a+20|0;Gc=a+12|0;Jc=a+56|0;while(1){if(!gg(Hc,q[(Bc<<2)+xc>>2],vc,Bc)){wc=0;break a}c:{if(q[zc>>2]<1){break c}xc=0;while(1){wc=xc<<2;yc=q[(wc+a|0)+68>>2];Ac=q[Dc>>2];d:{if((yc|0)>(Ac|0)){Cc=q[Ec>>2];q[wc+Cc>>2]=Ac;break d}Cc=q[Ec>>2];wc=wc+Cc|0;Ac=q[Gc>>2];if((yc|0)<(Ac|0)){q[wc>>2]=Ac;break d}q[wc>>2]=yc}xc=xc+1|0;wc=q[zc>>2];if((xc|0)<(wc|0)){continue}break}yc=0;if((wc|0)<1){break c}wc=Bc<<3;Ac=wc+vc|0;Kc=Nb+wc|0;while(1){xc=yc<<2;wc=xc+Ac|0;xc=q[xc+Kc>>2]+q[xc+Cc>>2]|0;q[wc>>2]=xc;e:{if((xc|0)>q[Dc>>2]){xc=xc-q[Fc>>2]|0}else{if((xc|0)>=q[Gc>>2]){break e}xc=xc+q[Fc>>2]|0}q[wc>>2]=xc}yc=yc+1|0;if((yc|0)>2]){continue}break}}wc=1;Bc=Bc+1|0;if((Bc|0)>=(Ic|0)){break a}wc=q[Jc>>2];xc=q[wc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vc=q[a+32>>2];if(vc){q[a+36>>2]=vc;An(vc)}An(a)}function jg(a,wc,gd,hd,id,jd){a=a|0;wc=wc|0;gd=gd|0;hd=hd|0;id=id|0;jd=jd|0;var kd=0,ld=0,md=0,nd=0,od=0,pd=0,qd=0,rd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0,yd=0;ld=T-32|0;T=ld;q[a+68>>2]=jd;hd=q[a+56>>2];id=q[hd>>2];jd=hd+4|0;kd=q[jd>>2];q[ld+24>>2]=0;q[ld+16>>2]=0;q[ld+20>>2]=0;a:{id=kd-id|0;if((id|0)<1){break a}hd=q[hd>>2];if((hd|0)!=q[jd>>2]){vd=id>>2;wd=a+60|0;xd=a+108|0;qd=a+8|0;rd=a+16|0;sd=a+32|0;td=a+20|0;ud=a+12|0;yd=a+56|0;while(1){kg(wd,q[(od<<2)+hd>>2],ld+16|0);id=q[ld+20>>2];kd=id>>31;jd=q[ld+16>>2];md=jd>>31;pd=q[ld+24>>2];nd=pd>>31;hd=0;nd=nd^nd+pd;kd=nd+((kd^id+kd)+(md^jd+md)|0)|0;if(kd>>>0>>0){hd=1}b:{if(!(hd|kd)){q[ld+16>>2]=q[a+104>>2];break b}md=q[a+104>>2];nd=md>>31;id=ao($n(md,nd,id,id>>31),V,kd,hd);q[ld+20>>2]=id;hd=ao($n(md,nd,jd,jd>>31),V,kd,hd);q[ld+16>>2]=hd;jd=hd;hd=hd>>31;hd=(md-(jd+hd^hd)|0)+((id|0)<0?id:0-id|0)|0;if((pd|0)>=0){q[ld+24>>2]=hd;break b}q[ld+24>>2]=0-hd}hd=dh(xd);jd=q[ld+16>>2];c:{if(!hd){id=q[ld+20>>2];break c}q[ld+24>>2]=0-q[ld+24>>2];id=0-q[ld+20>>2]|0;q[ld+20>>2]=id;jd=0-jd|0;q[ld+16>>2]=jd}d:{if((jd|0)>=0){hd=q[a+104>>2];jd=hd+q[ld+24>>2]|0;hd=hd+id|0;break d}e:{if((id|0)<=-1){jd=q[ld+24>>2];hd=jd>>31;hd=hd^hd+jd;break e}jd=q[ld+24>>2];hd=jd>>31;hd=q[a+100>>2]-(hd^hd+jd)|0}if((jd|0)<=-1){jd=id;id=id>>31;jd=jd+id^id;break d}jd=id;id=id>>31;jd=q[a+100>>2]-(jd+id^id)|0}id=q[a+100>>2];f:{if(!(hd|jd)){jd=id;hd=id;break f}if(!((id|0)!=(jd|0)|hd)){hd=jd;break f}if(!((hd|0)!=(id|0)|jd)){jd=hd;break f}g:{if(hd){break g}kd=q[a+104>>2];if((kd|0)>=(jd|0)){break g}jd=(kd<<1)-jd|0;hd=0;break f}h:{if((hd|0)!=(id|0)){break h}kd=q[a+104>>2];if((kd|0)<=(jd|0)){break h}jd=(kd<<1)-jd|0;break f}i:{if((id|0)!=(jd|0)){break i}id=q[a+104>>2];if((id|0)<=(hd|0)){break i}hd=(id<<1)-hd|0;break f}if(jd){break f}jd=0;id=q[a+104>>2];if((id|0)>=(hd|0)){break f}hd=(id<<1)-hd|0}q[ld+12>>2]=jd;q[ld+8>>2]=hd;j:{if(q[qd>>2]<1){break j}jd=0;while(1){kd=q[rd>>2];k:{if((hd|0)>(kd|0)){id=q[sd>>2];q[id+(jd<<2)>>2]=kd;break k}id=q[sd>>2];kd=id+(jd<<2)|0;md=q[ud>>2];if((hd|0)<(md|0)){q[kd>>2]=md;break k}q[kd>>2]=hd}jd=jd+1|0;kd=q[qd>>2];if((jd|0)<(kd|0)){hd=q[(ld+8|0)+(jd<<2)>>2];continue}break}hd=0;if((kd|0)<1){break j}jd=od<<3;md=jd+gd|0;pd=wc+jd|0;while(1){kd=hd<<2;jd=kd+md|0;kd=q[kd+pd>>2]+q[id+kd>>2]|0;q[jd>>2]=kd;l:{if((kd|0)>q[rd>>2]){nd=kd-q[td>>2]|0}else{if((kd|0)>=q[ud>>2]){break l}nd=kd+q[td>>2]|0}q[jd>>2]=nd}hd=hd+1|0;if((hd|0)>2]){continue}break}}od=od+1|0;if((od|0)>=(vd|0)){break a}id=q[yd>>2];h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hd>>>29;Bd=ao(Bd,Ed,a,wc);Cd=ao(Cd,Hd,a,wc);Fd=ao(Fd,Id,a,wc)}q[gd+8>>2]=Bd;q[gd+4>>2]=Cd;q[gd>>2]=Fd;T=jd+96|0}function lg(a){var wc=0,gd=0,Wd=0;wc=q[a+8>>2];Wd=q[a>>2];a:{if(r[a+12|0]){b:{c:{d:{e:{if((wc|0)==-1){break e}gd=wc+1|0;wc=(gd>>>0)%3|0?gd:wc+ -2|0;if((wc|0)==-1){break e}wc=q[q[Wd+12>>2]+(wc<<2)>>2];if((wc|0)!=-1){break d}}q[a+8>>2]=-1;break c}gd=wc+1|0;wc=(gd>>>0)%3|0?gd:wc+ -2|0;q[a+8>>2]=wc;if((wc|0)!=-1){break b}}gd=q[a+4>>2];wc=-1;f:{if((gd|0)==-1){break f}gd=gd+((gd>>>0)%3|0?-1:2)|0;wc=-1;if((gd|0)==-1){break f}gd=q[q[Wd+12>>2]+(gd<<2)>>2];wc=-1;if((gd|0)==-1){break f}wc=gd+ -1|0;if((gd>>>0)%3){break f}wc=gd+2|0}o[a+12|0]=0;q[a+8>>2]=wc;return}if((wc|0)!=q[a+4>>2]){break a}q[a+8>>2]=-1;return}gd=-1;g:{if((wc|0)==-1){break g}wc=wc+((wc>>>0)%3|0?-1:2)|0;gd=-1;if((wc|0)==-1){break g}wc=q[q[Wd+12>>2]+(wc<<2)>>2];gd=-1;if((wc|0)==-1){break g}gd=wc+ -1|0;if((wc>>>0)%3){break g}gd=wc+2|0}q[a+8>>2]=gd}}function mg(a,Xd,Yd,Zd,_d,$d){a=a|0;Xd=Xd|0;Yd=Yd|0;Zd=Zd|0;_d=_d|0;$d=$d|0;var ae=0,be=0,ce=0,de=0,ee=0,fe=0,ge=0,he=0,ie=0,je=0,ke=0,le=0,me=0,ne=0;q[a+8>>2]=_d;be=a+32|0;ae=q[be>>2];$d=q[a+36>>2]-ae>>2;a:{if($d>>>0<_d>>>0){Fa(be,_d-$d|0);break a}if($d>>>0<=_d>>>0){break a}q[a+36>>2]=ae+(_d<<2)}be=0;$d=(_d&1073741823)!=(_d|0)?-1:_d<<2;ke=Dn(Mm($d),0,$d);ee=a+8|0;ae=q[ee>>2];b:{if((ae|0)<1){break b}ge=a+16|0;$d=a+32|0;he=a+12|0;while(1){ae=be<<2;de=q[ae+ke>>2];ce=q[ge>>2];c:{if((de|0)>(ce|0)){fe=q[$d>>2];q[ae+fe>>2]=ce;break c}fe=q[$d>>2];ae=ae+fe|0;ce=q[he>>2];if((de|0)<(ce|0)){q[ae>>2]=ce;break c}q[ae>>2]=de}be=be+1|0;ae=q[ee>>2];if((be|0)<(ae|0)){continue}break}if((ae|0)<1){break b}be=0;ee=a+16|0;de=a+20|0;ge=a+8|0;he=a+12|0;while(1){ae=be<<2;$d=ae+Yd|0;ae=q[Xd+ae>>2]+q[ae+fe>>2]|0;q[$d>>2]=ae;d:{if((ae|0)>q[ee>>2]){ae=ae-q[de>>2]|0}else{if((ae|0)>=q[he>>2]){break d}ae=ae+q[de>>2]|0}q[$d>>2]=ae}be=be+1|0;ae=q[ge>>2];if((be|0)<(ae|0)){continue}break}}if((_d|0)<(Zd|0)){me=0-_d<<2;de=a+16|0;fe=a+32|0;ee=a+8|0;ge=a+20|0;he=a+12|0;$d=_d;while(1){e:{if((ae|0)<1){break e}je=$d<<2;le=je+Yd|0;ne=le+me|0;be=0;while(1){a=be<<2;ae=q[a+ne>>2];ie=q[de>>2];f:{if((ae|0)>(ie|0)){ce=q[fe>>2];q[a+ce>>2]=ie;break f}ce=q[fe>>2];a=a+ce|0;ie=q[he>>2];if((ae|0)<(ie|0)){q[a>>2]=ie;break f}q[a>>2]=ae}be=be+1|0;ae=q[ee>>2];if((be|0)<(ae|0)){continue}break}be=0;if((ae|0)<1){break e}je=Xd+je|0;while(1){ae=be<<2;a=ae+le|0;ae=q[ae+je>>2]+q[ae+ce>>2]|0;q[a>>2]=ae;g:{if((ae|0)>q[de>>2]){ae=ae-q[ge>>2]|0}else{if((ae|0)>=q[he>>2]){break g}ae=ae+q[ge>>2]|0}q[a>>2]=ae}be=be+1|0;ae=q[ee>>2];if((be|0)<(ae|0)){continue}break}}$d=_d+$d|0;if(($d|0)<(Zd|0)){continue}break}}An(ke);return 1}function ng(a,Xd,Yd){a=a|0;Xd=Xd|0;Yd=Yd|0;var Zd=0;a:{if(!Se(a,Xd,Yd)){break a}a=q[a+8>>2];if(r[a+24|0]!=3){break a}Zd=q[a+28>>2]==9}return Zd|0}function og(a,Xd,Yd){a=a|0;Xd=Xd|0;Yd=Yd|0;var _d=0,$d=0,oe=0,pe=0,qe=0;a:{if(r[q[a+4>>2]+36|0]<=1){_d=q[Yd+16>>2];$d=q[Yd+12>>2];oe=q[Yd+20>>2];qe=oe;pe=0;if(($d|0)<(qe|0)?1:($d|0)<=(qe|0)?t[Yd+8>>2]>_d>>>0?0:1:0){break a}$d=r[_d+q[Yd>>2]|0];_d=_d+1|0;if(_d>>>0<1){oe=oe+1|0}q[Yd+16>>2]=_d;q[Yd+20>>2]=oe;q[a+24>>2]=$d}pe=Xe(a,Xd,Yd)}return pe|0}function pg(a,Xd,Yd){a=a|0;Xd=Xd|0;Yd=Yd|0;var re=0,se=0,te=0,ue=0,ve=0;re=T-16|0;T=re;a:{b:{if(r[q[a+4>>2]+36|0]<=1){Xd=q[a+24>>2];break b}ue=q[Yd+16>>2];se=q[Yd+12>>2];te=q[Yd+20>>2];Xd=te;ve=0;if((se|0)<(Xd|0)?1:(se|0)<=(Xd|0)?t[Yd+8>>2]>ue>>>0?0:1:0){break a}Xd=r[ue+q[Yd>>2]|0];se=ue+1|0;if(se>>>0<1){te=te+1|0}q[Yd+16>>2]=se;q[Yd+20>>2]=te;q[a+24>>2]=Xd}q[re+12>>2]=-1;q[re+8>>2]=1116;q[(re+8|0)+4>>2]=Xd;ve=ld(re+8|0,q[a+16>>2])}a=ve;T=re+16|0;return a|0}function qg(a,Xd){a=a|0;Xd=Xd|0;var Yd=0,we=0,xe=0,ye=0,ze=0,Ae=x(0),Be=0,Ce=0;we=T-32|0;T=we;ye=o[q[a+8>>2]+24|0];Yd=q[a+16>>2];if(q[Yd+80>>2]){ze=q[q[Yd>>2]>>2]+q[Yd+48>>2]|0}q[we+8>>2]=-1;q[we+12>>2]=-1;q[we>>2]=-1;q[we+4>>2]=-1;a:{Yd=q[a+24>>2];if(Yd+ -2>>>0>28){break a}q[we>>2]=Yd;Yd=-1<>2]=xe;q[we+4>>2]=Yd^-1;q[we+12>>2]=(xe|0)/2;if(!Xd){xe=1;break a}ye=ye<<2;Yd=0;Ce=a+8|0;a=0;while(1){Ae=x(x(1)/x(xe|0));xe=Yd<<2;rg(x(Ae*x(q[xe+ze>>2])),x(Ae*x(q[(xe|4)+ze>>2])),we+20|0);Cn(q[q[q[Ce>>2]- -64>>2]>>2]+a|0,we+20|0,ye);xe=1;Be=Be+1|0;if((Be|0)==(Xd|0)){break a}Yd=Yd+2|0;a=a+ye|0;xe=q[we+8>>2];continue}}T=we+32|0;return xe|0}function rg(a,Xd,De){var Ee=0,Fe=0,Ge=x(0),He=x(0),Ie=x(0),Je=0,Ke=0;Ge=x(a+Xd);a:{b:{Ie=x(a-Xd);if(Ie<=x(.5)^1|Ie>=x(-.5)^1|Ge>=x(.5)^1){break b}Fe=1;if(!(Ge<=x(1.5))){break b}He=Xd;break a}c:{if(!!(Ge<=x(.5))){He=x(x(.5)-a);a=x(x(.5)-Xd);break c}if(!!(Ge>=x(1.5))){He=x(x(1.5)-a);a=x(x(1.5)-Xd);break c}if(!!(Ie<=x(-.5))){He=x(a+x(.5));a=x(Xd+x(-.5));break c}He=x(a+x(-.5));a=x(Xd+x(.5))}Ie=x(a-He);Ge=x(He+a);Fe=-1}Ee=+He;Xd=x(Ee+Ee+ -1);Ee=+a;a=x(Ee+Ee+ -1);Ke=Fe;Fe=+Ie;Fe=Fe+Fe;Ee=1-Fe;Fe=Fe+1;Fe=Ee>2]=0;Ge=x(0);a=x(0);break d}Ie=x(x(1)/x(E(Ge)));u[De>>2]=Ie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[Xd+60>>2]=Le;q[Xd+56>>2]=We;q[Xd+52>>2]=Ve;q[Xd+44>>2]=0;q[Xd+48>>2]=0;q[Xd>>2]=9748;q[Xd+72>>2]=-1;q[Xd+76>>2]=-1;q[Xd+68>>2]=1;q[Xd+40>>2]=10168;break a}q[a>>2]=0}q[a>>2]=0;return}q[Xd+80>>2]=-1;q[Xd+84>>2]=-1;ah(Xd+88|0);q[a>>2]=Xd}function vg(a){a=a|0;q[a>>2]=6860;return a|0}function wg(a){a=a|0;q[a>>2]=6860;An(a)}function xg(a){a=a|0;var Xd=0;a:{if(!q[a+44>>2]|!q[a+48>>2]|(!q[a+24>>2]|!q[a+28>>2])){break a}if(!q[a+32>>2]|!q[a+36>>2]){break a}Xd=q[a+72>>2]!=-1}return Xd|0}function yg(a,De){a=a|0;De=De|0;var Le=0;if(!(q[De+56>>2]|r[De+24|0]!=3)){q[a+44>>2]=De;Le=1}return Le|0}function zg(a,De){a=a|0;De=De|0;var Pe=0,Qe=0,Ze=0,_e=0,$e=0,af=0,bf=0,cf=0,df=0,ef=0,ff=0;$e=q[De+12>>2];Pe=$e;Qe=q[De+20>>2];Ze=Qe;af=q[De+16>>2];_e=af+4|0;if(_e>>>0<4){Qe=Qe+1|0}bf=q[De+8>>2];a:{if((Pe|0)<(Qe|0)?1:(Pe|0)<=(Qe|0)?bf>>>0>=_e>>>0?0:1:0){break a}cf=q[De>>2];Pe=af+cf|0;df=r[Pe|0]|r[Pe+1|0]<<8|(r[Pe+2|0]<<16|r[Pe+3|0]<<24);q[De+16>>2]=_e;q[De+20>>2]=Qe;ef=s[De+38>>1];if(ef>>>0<=513){Pe=$e;Qe=Ze;Ze=af+8|0;if(Ze>>>0<8){Qe=Qe+1|0}_e=Ze;if((Pe|0)<(Qe|0)?1:(Pe|0)<=(Qe|0)?bf>>>0>=_e>>>0?0:1:0){break a}q[De+16>>2]=_e;q[De+20>>2]=Qe}if(!(df&1)){break a}Pe=z(df)^31;if(Pe+ -1>>>0>28){break a}q[a+8>>2]=Pe+1;Pe=-2<>2]=Ze;q[a+12>>2]=Pe^-1;q[a+20>>2]=(Ze|0)/2;if(ef>>>0<=513){if(($e|0)<(Qe|0)?1:($e|0)<=(Qe|0)?bf>>>0>_e>>>0?0:1:0){break a}Pe=r[_e+cf|0];Ze=_e+1|0;if(Ze>>>0<1){Qe=Qe+1|0}q[De+16>>2]=Ze;q[De+20>>2]=Qe;if(Pe>>>0>1){break a}q[a+68>>2]=Pe-1|0?0:1}ff=bh(a+88|0,De)}return ff|0}function Ag(a,De,gf,hf,jf,kf){a=a|0;De=De|0;gf=gf|0;hf=hf|0;jf=jf|0;kf=kf|0;var lf=0,mf=0,nf=0,of=0,pf=0,qf=0,rf=0,sf=0,tf=0,uf=0,vf=0;lf=T-48|0;T=lf;rf=a+8|0;hf=q[rf>>2];if(hf+ -2>>>0<=28){q[a+72>>2]=hf;hf=-1<>2]=jf;q[a+76>>2]=hf^-1;q[a+84>>2]=(jf|0)/2}q[a+48>>2]=kf;hf=q[a+36>>2];jf=q[hf>>2];kf=hf+4|0;mf=q[kf>>2];q[lf+16>>2]=0;q[lf+8>>2]=0;q[lf+12>>2]=0;a:{jf=mf-jf|0;if((jf|0)<1){break a}hf=q[hf>>2];if((hf|0)!=q[kf>>2]){sf=jf>>2;tf=a+40|0;uf=a+88|0;vf=a+36|0;while(1){Sf(tf,q[(pf<<2)+hf>>2],lf+8|0);jf=q[lf+12>>2];mf=jf>>31;kf=q[lf+8>>2];of=kf>>31;qf=q[lf+16>>2];nf=qf>>31;hf=0;nf=nf^nf+qf;mf=nf+((mf^jf+mf)+(of^kf+of)|0)|0;if(mf>>>0>>0){hf=1}b:{if(!(hf|mf)){q[lf+8>>2]=q[a+84>>2];break b}of=q[a+84>>2];nf=of;nf=nf>>31;jf=ao($n(of,nf,jf,jf>>31),V,mf,hf);q[lf+12>>2]=jf;hf=ao($n(of,nf,kf,kf>>31),V,mf,hf);q[lf+8>>2]=hf;kf=hf;hf=hf>>31;hf=(of-(kf+hf^hf)|0)+((jf|0)<0?jf:0-jf|0)|0;if((qf|0)>=0){q[lf+16>>2]=hf;break b}q[lf+16>>2]=0-hf}hf=dh(uf);kf=q[lf+8>>2];c:{if(!hf){jf=q[lf+12>>2];break c}q[lf+16>>2]=0-q[lf+16>>2];jf=0-q[lf+12>>2]|0;q[lf+12>>2]=jf;kf=0-kf|0;q[lf+8>>2]=kf}d:{if((kf|0)>=0){kf=q[a+84>>2];hf=kf+q[lf+16>>2]|0;kf=jf+kf|0;break d}e:{if((jf|0)<=-1){hf=q[lf+16>>2];kf=hf>>31;kf=kf^hf+kf;break e}hf=q[lf+16>>2];kf=hf>>31;kf=q[a+80>>2]-(kf^hf+kf)|0}if((hf|0)<=-1){hf=jf>>31;hf=hf+jf^hf;break d}hf=jf>>31;hf=q[a+80>>2]-(hf+jf^hf)|0}jf=q[a+80>>2];f:{if(!(hf|kf)){hf=jf;kf=hf;break f}if(!((hf|0)!=(jf|0)|kf)){kf=hf;break f}if(!((jf|0)!=(kf|0)|hf)){hf=kf;break f}g:{if(kf){break g}mf=q[a+84>>2];if((mf|0)>=(hf|0)){break g}hf=(mf<<1)-hf|0;kf=0;break f}h:{if((jf|0)!=(kf|0)){break h}mf=q[a+84>>2];if((mf|0)<=(hf|0)){break h}hf=(mf<<1)-hf|0;break f}i:{if((hf|0)!=(jf|0)){break i}jf=q[a+84>>2];if((jf|0)<=(kf|0)){break i}kf=(jf<<1)-kf|0;break f}if(hf){break f}hf=0;jf=q[a+84>>2];if((jf|0)>=(kf|0)){break f}kf=(jf<<1)-kf|0}jf=pf<<3;mf=jf+De|0;of=q[mf+4>>2];q[lf+40>>2]=q[mf>>2];q[lf+44>>2]=of;q[lf+28>>2]=hf;q[lf+24>>2]=kf;Bg(lf+32|0,rf,lf+24|0,lf+40|0);hf=gf+jf|0;q[hf>>2]=q[lf+32>>2];q[hf+4>>2]=q[lf+36>>2];pf=pf+1|0;if((pf|0)>=(sf|0)){break a}jf=q[vf>>2];hf=q[jf>>2];if(q[jf+4>>2]-hf>>2>>>0>pf>>>0){continue}break}}cn();F()}T=lf+48|0;return 1}function Bg(a,De,gf,hf){var jf=0,kf=0,wf=0,xf=0,yf=0,zf=0,Af=0,Bf=0;xf=De+12|0;Af=q[xf>>2];kf=q[gf+4>>2]-Af|0;jf=q[gf>>2]-Af|0;q[gf>>2]=jf;q[gf+4>>2]=kf;wf=kf>>31;yf=wf+kf^wf;wf=jf>>31;xf=q[xf>>2];Bf=(yf+(wf+jf^wf)|0)<=(xf|0);if(!Bf){a:{b:{if((jf|0)>=0){zf=1;yf=1;if((kf|0)>-1){break a}wf=1;zf=-1;yf=-1;if((jf|0)>=1){break b}break a}wf=-1;zf=-1;yf=-1;if((kf|0)<1){break a}}zf=(kf|0)<1?-1:1;yf=wf}wf=kf<<1;kf=w(xf,zf);wf=wf-kf|0;q[gf+4>>2]=wf;xf=w(xf,yf);jf=(jf<<1)-xf|0;q[gf>>2]=jf;c:{if((w(yf,zf)|0)>=0){wf=0-wf|0;q[gf>>2]=wf;jf=0-jf|0;break c}q[gf>>2]=wf}kf=(jf+kf|0)/2|0;q[gf+4>>2]=kf;jf=(xf+wf|0)/2|0;q[gf>>2]=jf;xf=q[De+12>>2]}jf=q[hf>>2]+jf|0;q[a>>2]=jf;gf=q[hf+4>>2]+kf|0;q[a+4>>2]=gf;d:{if((xf|0)<(jf|0)){jf=jf-q[De+4>>2]|0;break d}if((jf|0)>=(0-xf|0)){break d}jf=q[De+4>>2]+jf|0}q[a>>2]=jf;e:{if((xf|0)<(gf|0)){gf=gf-q[De+4>>2]|0;break e}if((gf|0)>=(0-xf|0)){break e}gf=q[De+4>>2]+gf|0}q[a+4>>2]=gf;if(!Bf){f:{g:{if((jf|0)>=0){De=1;hf=1;if((gf|0)>-1){break f}kf=1;De=-1;hf=-1;if((jf|0)>=1){break g}break f}kf=-1;De=-1;hf=-1;if((gf|0)<1){break f}}De=(gf|0)<1?-1:1;hf=kf}wf=w(De,xf);kf=(gf<<1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og+sg)|0)|0;if(qg>>>0>>0){mg=1}b:{if(!(mg|qg)){q[pg+8>>2]=q[a+84>>2];break b}sg=q[a+84>>2];rg=sg;rg=rg>>31;ng=ao($n(sg,rg,ng,ng>>31),V,qg,mg);q[pg+12>>2]=ng;mg=ao($n(sg,rg,og,og>>31),V,qg,mg);q[pg+8>>2]=mg;og=mg;mg=mg>>31;mg=(sg-(og+mg^mg)|0)+((ng|0)<0?ng:0-ng|0)|0;if((ug|0)>=0){q[pg+16>>2]=mg;break b}q[pg+16>>2]=0-mg}mg=dh(yg);og=q[pg+8>>2];c:{if(!mg){ng=q[pg+12>>2];break c}q[pg+16>>2]=0-q[pg+16>>2];ng=0-q[pg+12>>2]|0;q[pg+12>>2]=ng;og=0-og|0;q[pg+8>>2]=og}d:{if((og|0)>=0){og=q[a+84>>2];mg=og+q[pg+16>>2]|0;og=ng+og|0;break d}e:{if((ng|0)<=-1){mg=q[pg+16>>2];og=mg>>31;og=og^mg+og;break e}mg=q[pg+16>>2];og=mg>>31;og=q[a+80>>2]-(og^mg+og)|0}if((mg|0)<=-1){mg=ng>>31;mg=mg+ng^mg;break d}mg=ng>>31;mg=q[a+80>>2]-(mg+ng^mg)|0}ng=q[a+80>>2];f:{if(!(mg|og)){mg=ng;og=mg;break f}if(!((mg|0)!=(ng|0)|og)){og=mg;break f}if(!((ng|0)!=(og|0)|mg)){mg=og;break f}g:{if(og){break g}qg=q[a+84>>2];if((qg|0)>=(mg|0)){break g}mg=(qg<<1)-mg|0;og=0;break f}h:{if((ng|0)!=(og|0)){break h}qg=q[a+84>>2];if((qg|0)<=(mg|0)){break h}mg=(qg<<1)-mg|0;break f}i:{if((mg|0)!=(ng|0)){break i}ng=q[a+84>>2];if((ng|0)<=(og|0)){break i}og=(ng<<1)-og|0;break f}if(mg){break f}mg=0;ng=q[a+84>>2];if((ng|0)>=(og|0)){break f}og=(ng<<1)-og|0}ng=tg<<3;qg=ng+De|0;sg=q[qg+4>>2];qg=q[qg>>2];q[pg+36>>2]=mg;q[pg+32>>2]=og;q[pg+24>>2]=qg;q[pg+28>>2]=sg;Lg(pg+40|0,vg,pg+32|0,pg+24|0);mg=lg+ng|0;q[mg>>2]=q[pg+40>>2];q[mg+4>>2]=q[pg+44>>2];tg=tg+1|0;if((tg|0)>=(wg|0)){break a}ng=q[zg>>2];mg=q[ng>>2];if(q[ng+4>>2]-mg>>2>>>0>tg>>>0){continue}break}}cn();F()}T=pg+48|0;return 1}function Lg(a,De,lg,mg){var ng=0,og=0,Ag=0,Bg=0,Cg=0,Dg=0,Eg=0,Fg=0;Bg=De+12|0;Eg=q[Bg>>2];og=q[lg+4>>2]-Eg|0;ng=q[lg>>2]-Eg|0;q[lg>>2]=ng;q[lg+4>>2]=og;Ag=og>>31;Cg=Ag+og^Ag;Ag=ng>>31;Bg=q[Bg>>2];Fg=(Cg+(Ag+ng^Ag)|0)<=(Bg|0);if(!Fg){a:{b:{if((ng|0)>=0){Ag=1;Dg=1;if((og|0)>-1){break a}Cg=1;Ag=-1;Dg=-1;if((ng|0)>=1){break b}break a}Cg=-1;Ag=-1;Dg=-1;if((og|0)<1){break a}}Ag=(og|0)<1?-1:1;Dg=Cg}Cg=og<<1;og=w(Ag,Bg);Cg=Cg-og|0;q[lg+4>>2]=Cg;Bg=w(Bg,Dg);ng=(ng<<1)-Bg|0;q[lg>>2]=ng;c:{if((w(Ag,Dg)|0)>=0){Cg=0-Cg|0;q[lg>>2]=Cg;ng=0-ng|0;break c}q[lg>>2]=Cg}og=(ng+og|0)/2|0;q[lg+4>>2]=og;ng=(Bg+Cg|0)/2|0;q[lg>>2]=ng}d:{e:{f:{g:{h:{i:{j:{k:{if(!ng){if(og){break j}Bg=1;Dg=0;break k}Bg=1;Ag=(ng|0)<0&(og|0)<1;if((ng|0)>=1){Dg=(og|0)>-1?2:1;if(Ag){break k}break i}Dg=(og|0)>0?3:0;if(!Ag){break i}}Ag=og;Cg=ng;break d}if((og|0)>=1){break f}break h}Ag=Dg+ -1|0;if(Ag>>>0>2){Ag=og;og=ng;Dg=0;break e}switch(Ag-1|0){case 0:break g;case 1:break f;default:break h}}Ag=0-ng|0;Dg=1;break e}Ag=0-og|0;og=0-ng|0;Dg=2;break e}Ag=ng;og=0-og|0;Dg=3}ng=lg;Cg=og;q[ng>>2]=og;q[ng+4>>2]=Ag;Bg=0}og=q[mg>>2]+Cg|0;q[a>>2]=og;ng=q[mg+4>>2]+Ag|0;q[a+4>>2]=ng;Ag=q[De+12>>2];l:{if((Ag|0)<(og|0)){og=og-q[De+4>>2]|0;break l}if((og|0)>=(0-Ag|0)){break l}og=q[De+4>>2]+og|0}q[a>>2]=og;m:{if((Ag|0)<(ng|0)){ng=ng-q[De+4>>2]|0;break m}if((ng|0)>=(0-Ag|0)){break m}ng=q[De+4>>2]+ng|0}q[a+4>>2]=ng;n:{if(Bg){lg=ng;ng=og;break n}De=(4-Dg&3)+ -1|0;o:{if(De>>>0>2){lg=ng;ng=og;break o}p:{switch(De-1|0){default:lg=0-og|0;break o;case 0:lg=0-ng|0;ng=0-og|0;break o;case 1:break p}}ng=0-ng|0;lg=og}q[a>>2]=ng;q[a+4>>2]=lg}if(!Fg){q:{r:{if((ng|0)>=0){De=1;Bg=1;if((lg|0)>-1){break q}og=1;De=-1;Bg=-1;if((ng|0)>=1){break r}break q}og=-1;De=-1;Bg=-1;if((lg|0)<1){break q}}De=(lg|0)<1?-1:1;Bg=og}mg=lg<<1;lg=w(De,Ag);og=mg-lg|0;q[a+4>>2]=og;mg=w(Ag,Bg);ng=(ng<<1)-mg|0;q[a>>2]=ng;s:{if((w(De,Bg)|0)>=0){og=0-og|0;q[a>>2]=og;ng=0-ng|0;break s}q[a>>2]=og}lg=(lg+ng|0)/2|0;q[a+4>>2]=lg;ng=(mg+og|0)/2|0;q[a>>2]=ng}q[a>>2]=ng+Eg;q[a+4>>2]=lg+Eg}function Mg(a,De){a=a|0;De=De|0;var lg=0,mg=0,Gg=0,Hg=0,Ig=0,Jg=0,Kg=0,Lg=0,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q[dh>>2];dh=q[dh+4>>2];ah=Ng+ah|0;fh=ah+eh|0;hh=q[fh+4>>2];q[Qg+16>>2]=q[fh>>2];q[Qg+20>>2]=hh;q[Qg+8>>2]=gh;q[Qg+12>>2]=dh;Lg(Qg+24|0,ch,Qg+16|0,Qg+8|0);q[ah>>2]=q[Qg+24>>2];q[ah+4>>2]=q[Qg+28>>2];a=a+Pg|0;if((a|0)<(Og|0)){continue}break}}An(bh);T=Qg+32|0;return 1}function Rg(a,De,Ng){a=a|0;De=De|0;Ng=Ng|0;if(Se(a,De,Ng)){a=q[q[q[q[De+4>>2]+8>>2]+(Ng<<2)>>2]+28>>2]==9}else{a=0}return a|0}function Sg(a,De,Ng){a=a|0;De=De|0;Ng=Ng|0;var Og=0;a:{if(r[q[a+4>>2]+36|0]<=1){Og=0;if(!n[q[q[a>>2]+52>>2]](a)){break a}}Og=Xe(a,De,Ng)}return Og|0}function Tg(a,De,Ng){a=a|0;De=De|0;Ng=Ng|0;De=T-32|0;T=De;a:{if(r[q[a+4>>2]+36|0]>=2){Ng=0;if(!n[q[q[a>>2]+52>>2]](a)){break a}}q[De+24>>2]=0;q[De+28>>2]=0;q[De+16>>2]=0;q[De+20>>2]=0;q[De+12>>2]=-1;q[De+8>>2]=1232;gd(De+8|0,q[a+24>>2],q[a+28>>2],o[q[a+8>>2]+24|0],u[a+32>>2]);Ng=ld(De+8|0,q[a+16>>2]);q[De+8>>2]=1232;a=q[De+16>>2];if(!a){break a}q[De+20>>2]=a;An(a)}T=De+32|0;return Ng|0}function Ug(a,De){a=a|0;De=De|0;return n[q[q[a>>2]+56>>2]](a,De)|0}function Vg(a){a=a|0;var De=0,Ng=0,Pg=0,Qg=0,ih=0,jh=0,kh=0,lh=0,mh=0,nh=0;De=o[q[a+8>>2]+24|0];Pg=De<<2;De=Mm((De|0)!=(De&1073741823)?-1:Pg);Ng=q[a+28>>2];q[a+28>>2]=De;if(Ng){An(Ng)}lh=a+4|0;Ng=q[q[lh>>2]+32>>2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>2]+24|0];th=rh<<2;uh=Mm((rh&1073741823)!=(rh|0)?-1:th);vh=hk(sh+8|0);a:{if(!ik(vh,u[a+32>>2],-1<>2];qh=0;b:{if(!q[ph+80>>2]){break b}qh=q[q[ph>>2]>>2]+q[ph+48>>2]|0}if(!oh){ph=1;break a}zh=(rh|0)<1;Ah=a+28|0;Bh=a+8|0;a=0;while(1){if(!zh){Ch=q[Ah>>2];Dh=u[vh>>2];ph=0;while(1){wh=ph<<2;u[wh+uh>>2]=x(Dh*x(q[(a<<2)+qh>>2]))+u[Ch+wh>>2];a=a+1|0;ph=ph+1|0;if((rh|0)!=(ph|0)){continue}break}}Cn(q[q[q[Bh>>2]- -64>>2]>>2]+xh|0,uh,th);xh=th+xh|0;ph=1;yh=yh+1|0;if((yh|0)!=(oh|0)){continue}break}}An(uh);T=sh+16|0;return ph|0}function Xg(a){a=a|0;var oh=0,Eh=0;q[a>>2]=10764;Eh=a+28|0;oh=q[Eh>>2];q[Eh>>2]=0;if(oh){An(oh)}q[a>>2]=2220;Eh=a+20|0;oh=q[Eh>>2];q[Eh>>2]=0;if(oh){n[q[q[oh>>2]+4>>2]](oh)}q[a>>2]=1908;Eh=a+16|0;oh=q[Eh>>2];q[Eh>>2]=0;if(oh){Hb(oh)}return a|0}function Yg(a){a=a|0;var Fh=0,Gh=0;q[a>>2]=10764;Gh=a+28|0;Fh=q[Gh>>2];q[Gh>>2]=0;if(Fh){An(Fh)}q[a>>2]=2220;Gh=a+20|0;Fh=q[Gh>>2];q[Gh>>2]=0;if(Fh){n[q[q[Fh>>2]+4>>2]](Fh)}q[a>>2]=1908;Gh=a+16|0;Fh=q[Gh>>2];q[Gh>>2]=0;if(Fh){Hb(Fh)}An(a)}function Zg(a){q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}function _g(a){var Hh=0,Ih=0;q[a+16>>2]=0;Ih=a+4|0;Hh=q[a>>2];q[Ih>>2]=Hh;q[a+12>>2]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+4>>2]=Vh+ -2;a=(Vh+Wh|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c;case 1:break d}}if((Vh|0)<3){break a}q[a+4>>2]=Vh+ -3;a=(Vh+Wh|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0]}a=a+4096|0;q[ai+8>>2]=a;if(a>>>0>1048575){break a}a=Uh+Xh|0;if(a>>>0>>0){Th=Th+1|0}q[Jh+16>>2]=a;q[Jh+20>>2]=Th;bi=1}T=_h+16|0;return bi}function ch(a,Jh,ci){var di=0,ei=0,fi=0,gi=0;a:{if(a>>>0>5){break a}fi=q[ci+16>>2];di=q[ci+12>>2];ei=q[ci+20>>2];if((di|0)<(ei|0)?1:(di|0)<=(ei|0)?t[ci+8>>2]>fi>>>0?0:1:0){break a}di=r[fi+q[ci>>2]|0];fi=fi+1|0;if(fi>>>0<1){ei=ei+1|0}q[ci+16>>2]=fi;q[ci+20>>2]=ei;ei=Jh;if(di&128){if(!ch(a+1|0,Jh,ci)){break a}a=q[Jh>>2]<<7;q[Jh>>2]=a;di=a|di&127}q[ei>>2]=di;gi=1}return gi}function dh(a){var Jh=0,ci=0,hi=0,ii=0,ji=0;hi=0-r[a+12|0]|0;ci=q[a+8>>2];a:{if(ci>>>0>4095){break a}Jh=q[a+4>>2];if((Jh|0)<1){break a}Jh=Jh+ -1|0;q[a+4>>2]=Jh;ci=r[Jh+q[a>>2]|0]|ci<<8;q[a+8>>2]=ci}hi=hi&255;Jh=w(hi,ci>>>8);ii=ci&255;ji=ii>>>0>>0;q[a+8>>2]=ji?Jh+ii|0:(ci-hi|0)-Jh|0;return ji}function eh(a,ki,li){var mi=0,ni=0,oi=0,pi=0,qi=0,ri=0;if(!ki){q[li>>2]=0;return}pi=0-r[a+12|0]&255;ni=q[a+8>>2];while(1){qi=mi<<1;a:{if(ni>>>0>4095){break a}mi=q[a+4>>2];if((mi|0)<1){break a}mi=mi+ -1|0;q[a+4>>2]=mi;ni=r[mi+q[a>>2]|0]|ni<<8;q[a+8>>2]=ni}oi=ni&255;mi=oi>>>0>>0;ri=oi;oi=w(ni>>>8,pi);ni=mi?ri+oi|0:(ni-pi|0)-oi|0;q[a+8>>2]=ni;mi=mi|qi;ki=ki+ -1|0;if(ki){continue}break}q[li>>2]=mi}function fh(a,ki){var li=0,si=0,ti=0;ti=T-32|0;T=ti;a:{if(ki>>>0<=1){if(ki-1){li=Mm(44);ki=li;q[ki>>2]=0;q[ki+4>>2]=0;q[ki+40>>2]=0;q[ki+32>>2]=0;q[ki+36>>2]=0;q[ki+24>>2]=0;q[ki+28>>2]=0;q[ki+16>>2]=0;q[ki+20>>2]=0;q[ki+8>>2]=0;q[ki+12>>2]=0;Ij(ki);q[ki>>2]=13760;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}li=Mm(44);ki=li;q[ki>>2]=0;q[ki+4>>2]=0;q[ki+40>>2]=0;q[ki+32>>2]=0;q[ki+36>>2]=0;q[ki+24>>2]=0;q[ki+28>>2]=0;q[ki+16>>2]=0;q[ki+20>>2]=0;q[ki+8>>2]=0;q[ki+12>>2]=0;Ij(ki);q[ki>>2]=13668;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}ki=Mm(32);q[ti>>2]=ki;q[ti+4>>2]=28;q[ti+8>>2]=-2147483616;o[ki+28|0]=0;li=r[10912]|r[10913]<<8|(r[10914]<<16|r[10915]<<24);o[ki+24|0]=li;o[ki+25|0]=li>>>8;o[ki+26|0]=li>>>16;o[ki+27|0]=li>>>24;li=r[10908]|r[10909]<<8|(r[10910]<<16|r[10911]<<24);si=r[10904]|r[10905]<<8|(r[10906]<<16|r[10907]<<24);o[ki+16|0]=si;o[ki+17|0]=si>>>8;o[ki+18|0]=si>>>16;o[ki+19|0]=si>>>24;o[ki+20|0]=li;o[ki+21|0]=li>>>8;o[ki+22|0]=li>>>16;o[ki+23|0]=li>>>24;li=r[10900]|r[10901]<<8|(r[10902]<<16|r[10903]<<24);si=r[10896]|r[10897]<<8|(r[10898]<<16|r[10899]<<24);o[ki+8|0]=si;o[ki+9|0]=si>>>8;o[ki+10|0]=si>>>16;o[ki+11|0]=si>>>24;o[ki+12|0]=li;o[ki+13|0]=li>>>8;o[ki+14|0]=li>>>16;o[ki+15|0]=li>>>24;li=r[10892]|r[10893]<<8|(r[10894]<<16|r[10895]<<24);si=r[10888]|r[10889]<<8|(r[10890]<<16|r[10891]<<24);o[ki|0]=si;o[ki+1|0]=si>>>8;o[ki+2|0]=si>>>16;o[ki+3|0]=si>>>24;o[ki+4|0]=li;o[ki+5|0]=li>>>8;o[ki+6|0]=li>>>16;o[ki+7|0]=li>>>24;q[ti+16>>2]=-1;ki=Rm(ti+16|4,ti);q[a>>2]=q[ti+16>>2];Rm(a+4|0,ki);q[a+16>>2]=0;if(o[ki+11|0]<=-1){An(q[ki>>2])}if(o[ti+11|0]>-1){break a}An(q[ti>>2])}T=ti+32|0}function gh(a,ki){var ui=0,vi=0,wi=0;wi=T-32|0;T=wi;a:{if(ki>>>0<=1){if(ki-1){ki=Mm(48);Rh(ki);q[ki>>2]=13064;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}ki=Mm(52);Rh(ki);q[ki+48>>2]=0;q[ki>>2]=11164;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;break a}ki=Mm(32);q[wi>>2]=ki;q[wi+4>>2]=28;q[wi+8>>2]=-2147483616;o[ki+28|0]=0;ui=r[10912]|r[10913]<<8|(r[10914]<<16|r[10915]<<24);o[ki+24|0]=ui;o[ki+25|0]=ui>>>8;o[ki+26|0]=ui>>>16;o[ki+27|0]=ui>>>24;ui=r[10908]|r[10909]<<8|(r[10910]<<16|r[10911]<<24);vi=r[10904]|r[10905]<<8|(r[10906]<<16|r[10907]<<24);o[ki+16|0]=vi;o[ki+17|0]=vi>>>8;o[ki+18|0]=vi>>>16;o[ki+19|0]=vi>>>24;o[ki+20|0]=ui;o[ki+21|0]=ui>>>8;o[ki+22|0]=ui>>>16;o[ki+23|0]=ui>>>24;ui=r[10900]|r[10901]<<8|(r[10902]<<16|r[10903]<<24);vi=r[10896]|r[10897]<<8|(r[10898]<<16|r[10899]<<24);o[ki+8|0]=vi;o[ki+9|0]=vi>>>8;o[ki+10|0]=vi>>>16;o[ki+11|0]=vi>>>24;o[ki+12|0]=ui;o[ki+13|0]=ui>>>8;o[ki+14|0]=ui>>>16;o[ki+15|0]=ui>>>24;ui=r[10892]|r[10893]<<8|(r[10894]<<16|r[10895]<<24);vi=r[10888]|r[10889]<<8|(r[10890]<<16|r[10891]<<24);o[ki|0]=vi;o[ki+1|0]=vi>>>8;o[ki+2|0]=vi>>>16;o[ki+3|0]=vi>>>24;o[ki+4|0]=ui;o[ki+5|0]=ui>>>8;o[ki+6|0]=ui>>>16;o[ki+7|0]=ui>>>24;q[wi+16>>2]=-1;ki=Rm(wi+16|4,wi);q[a>>2]=q[wi+16>>2];Rm(a+4|0,ki);q[a+16>>2]=0;if(o[ki+11|0]<=-1){An(q[ki>>2])}if(o[wi+11|0]>-1){break a}An(q[wi>>2])}T=wi+32|0}function hh(a,ki){var xi=0,yi=0,zi=0;xi=T-80|0;T=xi;yi=q[ki+36>>2];q[xi+72>>2]=q[ki+32>>2];q[xi+76>>2]=yi;zi=q[ki+28>>2];yi=xi- -64|0;q[yi>>2]=q[ki+24>>2];q[yi+4>>2]=zi;yi=q[ki+20>>2];q[xi+56>>2]=q[ki+16>>2];q[xi+60>>2]=yi;yi=q[ki+12>>2];q[xi+48>>2]=q[ki+8>>2];q[xi+52>>2]=yi;yi=q[ki+4>>2];q[xi+40>>2]=q[ki>>2];q[xi+44>>2]=yi;Jj(xi+8|0,xi+40|0,xi+24|0);ki=q[xi+8>>2];a:{if(ki){q[a>>2]=ki;Rm(a+4|0,xi+8|4);if(o[xi+23|0]>=0){break a}An(q[xi+12>>2]);break a}if(o[xi+23|0]<=-1){An(q[xi+12>>2])}ki=r[xi+31|0];q[a>>2]=0;q[a+4>>2]=0;q[a+16>>2]=ki;q[a+8>>2]=0;q[a+12>>2]=0}T=xi+80|0}function ih(a,ki,Ai,Bi){var Ci=0,Di=0,Ei=0;Ci=T-80|0;T=Ci;Di=q[Ai+36>>2];q[Ci+72>>2]=q[Ai+32>>2];q[Ci+76>>2]=Di;Ei=q[Ai+28>>2];Di=Ci- -64|0;q[Di>>2]=q[Ai+24>>2];q[Di+4>>2]=Ei;Di=q[Ai+20>>2];q[Ci+56>>2]=q[Ai+16>>2];q[Ci+60>>2]=Di;Di=q[Ai+12>>2];q[Ci+48>>2]=q[Ai+8>>2];q[Ci+52>>2]=Di;Di=q[Ai+4>>2];q[Ci+40>>2]=q[Ai>>2];q[Ci+44>>2]=Di;Jj(a,Ci+40|0,Ci+24|0);a:{if(q[a>>2]){break a}Ei=a+4|0;if(o[a+15|0]<=-1){An(q[Ei>>2])}if(r[Ci+31|0]){q[Ci+8>>2]=0;q[Ci>>2]=0;q[Ci+4>>2]=0;ki=Mm(32);q[Ci>>2]=ki;q[Ci+4>>2]=27;q[Ci+8>>2]=-2147483616;o[ki+27|0]=0;Ai=r[10940]|r[10941]<<8|(r[10942]<<16|r[10943]<<24);o[ki+23|0]=Ai;o[ki+24|0]=Ai>>>8;o[ki+25|0]=Ai>>>16;o[ki+26|0]=Ai>>>24;Ai=r[10937]|r[10938]<<8|(r[10939]<<16|r[10940]<<24);Bi=r[10933]|r[10934]<<8|(r[10935]<<16|r[10936]<<24);o[ki+16|0]=Bi;o[ki+17|0]=Bi>>>8;o[ki+18|0]=Bi>>>16;o[ki+19|0]=Bi>>>24;o[ki+20|0]=Ai;o[ki+21|0]=Ai>>>8;o[ki+22|0]=Ai>>>16;o[ki+23|0]=Ai>>>24;Ai=r[10929]|r[10930]<<8|(r[10931]<<16|r[10932]<<24);Bi=r[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])}q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}if(!Hi){break b}n[q[q[Hi>>2]+4>>2]](Hi)}a=q[Fi+16>>2];q[Fi+16>>2]=0;if(a){n[q[q[a>>2]+4>>2]](a)}if(o[Fi+15|0]>-1){break a}An(q[Fi+4>>2])}T=Fi+80|0}function kh(a,ki){var Ai=0,Bi=0,Ii=0;Ii=T-16|0;T=Ii;q[Ii+12>>2]=ki;ki=Mm(32);q[Ii>>2]=ki;q[Ii+4>>2]=24;q[Ii+8>>2]=-2147483616;o[ki+24|0]=0;Ai=r[10986]|r[10987]<<8|(r[10988]<<16|r[10989]<<24);Bi=r[10982]|r[10983]<<8|(r[10984]<<16|r[10985]<<24);o[ki+16|0]=Bi;o[ki+17|0]=Bi>>>8;o[ki+18|0]=Bi>>>16;o[ki+19|0]=Bi>>>24;o[ki+20|0]=Ai;o[ki+21|0]=Ai>>>8;o[ki+22|0]=Ai>>>16;o[ki+23|0]=Ai>>>24;Ai=r[10978]|r[10979]<<8|(r[10980]<<16|r[10981]<<24);Bi=r[10974]|r[10975]<<8|(r[10976]<<16|r[10977]<<24);o[ki+8|0]=Bi;o[ki+9|0]=Bi>>>8;o[ki+10|0]=Bi>>>16;o[ki+11|0]=Bi>>>24;o[ki+12|0]=Ai;o[ki+13|0]=Ai>>>8;o[ki+14|0]=Ai>>>16;o[ki+15|0]=Ai>>>24;Ai=r[10970]|r[10971]<<8|(r[10972]<<16|r[10973]<<24);Bi=r[10966]|r[10967]<<8|(r[10968]<<16|r[10969]<<24);o[ki|0]=Bi;o[ki+1|0]=Bi>>>8;o[ki+2|0]=Bi>>>16;o[ki+3|0]=Bi>>>24;o[ki+4|0]=Ai;o[ki+5|0]=Ai>>>8;o[ki+6|0]=Ai>>>16;o[ki+7|0]=Ai>>>24;ek(lh(a,Ii+12|0),Ii);if(o[Ii+11|0]<=-1){An(q[Ii>>2])}T=Ii+16|0}function lh(a,ki){var Ji=0,Ki=0,Li=0,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){break e}}_i=q[ki>>2];h:{i:{if(q[a>>2]==(ki|0)){Yi=ki;break i}j:{if(!_i){Wi=ki;while(1){Yi=q[Wi+8>>2];$i=q[Yi>>2]==(Wi|0);Wi=Yi;if($i){continue}break}break j}Wi=_i;while(1){Yi=Wi;Wi=q[Yi+4>>2];if(Wi){continue}break}}Zi=r[Xi+11|0];Wi=Zi<<24>>24<0;aj=r[Yi+27|0];$i=aj<<24>>24<0;k:{Zi=Wi?q[Xi+4>>2]:Zi;aj=$i?q[Yi+20>>2]:aj;bj=Zi>>>0>>0?Zi:aj;if(bj){cj=Yi+16|0;Wi=cm($i?q[cj>>2]:cj,Wi?q[Xi>>2]:Xi,bj);if(Wi){break k}}if(aj>>>0>>0){break i}break h}if((Wi|0)>-1){break h}}if(!_i){q[Vi>>2]=ki;return ki}q[Vi>>2]=Yi;return Yi+4|0}return ph(a,Vi,Xi)}Yi=cm(Zi,bj,_i);if(Yi){break c}}if(dj){break b}break a}if((Yi|0)>-1){break a}}bj=ki+4|0;_i=q[bj>>2];l:{if(_i){Yi=_i;while(1){Wi=Yi;Yi=q[Yi>>2];if(Yi){continue}break}break l}Wi=q[ki+8>>2];if(q[Wi>>2]==(ki|0)){break l}Yi=ki+8|0;while(1){Zi=q[Yi>>2];Yi=Zi+8|0;Wi=q[Zi+8>>2];if((Zi|0)!=q[Wi>>2]){continue}break}}m:{n:{if((Wi|0)==(ej|0)){break n}Zi=r[Wi+27|0];Yi=Zi<<24>>24<0;o:{Zi=Yi?q[Wi+20>>2]:Zi;cj=Zi>>>0<$i>>>0?Zi:$i;if(cj){dj=(aj|0)<0?q[Xi>>2]:Xi;aj=Wi+16|0;Yi=cm(dj,Yi?q[aj>>2]:aj,cj);if(Yi){break o}}if($i>>>0>>0){break n}break m}if((Yi|0)>-1){break m}}if(!_i){q[Vi>>2]=ki;return bj}q[Vi>>2]=Wi;return Wi}return ph(a,Vi,Xi)}q[Vi>>2]=ki;q[Wi>>2]=ki;return Wi}function ph(a,ki,Vi){var Wi=0,Xi=0,hj=0,ij=0,jj=0,kj=0,lj=0,mj=0,nj=0;a:{Wi=a+4|0;a=q[Wi>>2];if(a){hj=r[Vi+11|0];ij=hj<<24>>24<0;hj=ij?q[Vi+4>>2]:hj;lj=ij?q[Vi>>2]:Vi;while(1){Vi=a+16|0;Xi=r[a+27|0];ij=Xi<<24>>24<0;jj=ij?q[a+20>>2]:Xi;mj=jj>>>0>>0;b:{c:{d:{e:{f:{g:{h:{Xi=mj?jj:hj;if(Xi){kj=ij?q[Vi>>2]:Vi;nj=cm(lj,kj,Xi);if(nj){break h}}if(hj>>>0>>0){break g}if(!Xi){break e}kj=ij?q[Vi>>2]:Vi;break f}if((nj|0)>-1){break f}}Vi=q[a>>2];if(Vi){break b}q[ki>>2]=a;return a}Vi=cm(kj,lj,Xi);if(Vi){break d}}if(mj){break c}break a}if((Vi|0)>-1){break a}}Wi=a+4|0;Vi=q[a+4>>2];if(!Vi){break a}a=Wi}Wi=a;a=Vi;continue}}q[ki>>2]=Wi;return Wi}q[ki>>2]=a;return Wi}function qh(a,ki,Vi,oj){var pj=0,qj=0,rj=0,sj=0,tj=0;if(!a){return 1}pj=q[Vi+16>>2];sj=q[Vi+12>>2];rj=q[Vi+20>>2];qj=rj;a:{if((sj|0)<(qj|0)?1:(sj|0)<=(qj|0)?t[Vi+8>>2]>pj>>>0?0:1:0){break a}qj=r[pj+q[Vi>>2]|0];pj=pj+1|0;if(pj>>>0<1){rj=rj+1|0}q[Vi+16>>2]=pj;q[Vi+20>>2]=rj;if(qj>>>0>1){break a}if(qj-1){return rh(a,ki,Vi,oj)}tj=sh(a,Vi,oj)}return tj}function rh(a,ki,Vi,oj){var uj=0,vj=0,wj=0,xj=0,yj=0,zj=0,Aj=0,Bj=0,Cj=0,Dj=0,Ej=0,Fj=0,Gj=0,Hj=0,Ij=0,Jj=0;uj=T+ -64|0;T=uj;q[uj+56>>2]=0;q[uj+48>>2]=0;q[uj+52>>2]=0;q[uj+40>>2]=0;q[uj+44>>2]=0;q[uj+32>>2]=0;q[uj+36>>2]=0;q[uj+24>>2]=0;q[uj+28>>2]=0;q[uj+16>>2]=0;q[uj+20>>2]=0;q[uj+8>>2]=0;q[uj+12>>2]=0;a:{if(!th(uj+8|0,Vi)){break a}if(!uh(uj+8|0,Vi)|(q[uj+20>>2]?0:a)){break a}_j(Vi,0,0);if(a){xj=q[uj+56>>2];Fj=q[uj+36>>2];Gj=q[uj+48>>2];Hj=q[uj+24>>2];while(1){b:{if(xj>>>0>16383){break b}vj=q[uj+52>>2];while(1){if((vj|0)<1){break b}vj=vj+ -1|0;q[uj+52>>2]=vj;xj=r[vj+Gj|0]|xj<<8;q[uj+56>>2]=xj;if(xj>>>0<16384){continue}break}}wj=xj&4095;Dj=q[(wj<<2)+Hj>>2];yj=(Dj<<3)+Fj|0;xj=(w(q[yj>>2],xj>>>12)+wj|0)-q[yj+4>>2]|0;q[uj+56>>2]=xj;if((ki|0)>=1){if(!r[Vi+36|0]){wj=0;break a}yj=ki+zj|0;while(1){c:{if((Dj|0)<1){Bj=0;break c}wj=q[Vi+32>>2];Ij=q[Vi+28>>2];Jj=q[Vi+24>>2];vj=0;Bj=0;while(1){Aj=(wj>>>3)+Jj|0;d:{if(Aj>>>0>=Ij>>>0){Cj=0;break d}Cj=r[Aj|0];Aj=wj+1|0;q[Vi+32>>2]=Aj;Cj=Cj>>>(wj&7)&1;wj=Aj}Bj=Cj<>2]=Bj;zj=zj+1|0;if((yj|0)!=(zj|0)){continue}break}zj=yj}Ej=ki+Ej|0;if(Ej>>>0>>0){continue}break}}ak(Vi);wj=1}a=q[uj+36>>2];if(a){q[uj+40>>2]=a;An(a)}a=q[uj+24>>2];if(a){q[uj+28>>2]=a;An(a)}a=q[uj+8>>2];if(a){q[uj+12>>2]=a;An(a)}T=uj- -64|0;return wj}function sh(a,ki,Vi){var oj=0,Kj=0,Lj=0,Mj=0;a:{b:{Kj=q[ki+16>>2];Lj=q[ki+12>>2];oj=q[ki+20>>2];c:{if((Lj|0)<(oj|0)?1:(Lj|0)<=(oj|0)?t[ki+8>>2]>Kj>>>0?0:1:0){break c}Lj=r[Kj+q[ki>>2]|0];Kj=Kj+1|0;if(Kj>>>0<1){oj=oj+1|0}q[ki+16>>2]=Kj;q[ki+20>>2]=oj;oj=Lj+ -1|0;if(oj>>>0>17){break c}d:{e:{switch(oj-1|0){case 7:return wh(a,ki,Vi);case 8:return xh(a,ki,Vi);case 9:return yh(a,ki,Vi);case 10:return zh(a,ki,Vi);case 12:case 13:case 14:case 15:break a;case 16:break d;case 11:break e;default:break b}}return Ah(a,ki,Vi)}Mj=Bh(a,ki,Vi)}return Mj}return vh(a,ki,Vi)}return Bh(a,ki,Vi)}function th(a,ki){var Vi=0,Nj=0,Oj=0,Pj=0,Qj=0,Rj=0,Sj=0,Tj=0,Uj=0,Vj=0,Wj=0,Xj=0,Yj=0;a:{Vi=s[ki+38>>1];if(!Vi){break a}Sj=a+12|0;b:{if(Vi>>>0<=511){Nj=q[ki+12>>2];Vi=q[ki+20>>2];Oj=q[ki+16>>2];Qj=Oj+4|0;if(Qj>>>0<4){Vi=Vi+1|0}if((Nj|0)<(Vi|0)?1:(Nj|0)<=(Vi|0)?t[ki+8>>2]>=Qj>>>0?0:1:0){break a}Vi=Oj+q[ki>>2]|0;Oj=r[Vi|0]|r[Vi+1|0]<<8|(r[Vi+2|0]<<16|r[Vi+3|0]<<24);q[Sj>>2]=Oj;Nj=q[ki+20>>2];Qj=q[ki+16>>2]+4|0;if(Qj>>>0<4){Nj=Nj+1|0}Vi=ki;q[Vi+16>>2]=Qj;q[Vi+20>>2]=Nj;break b}if(!Ch(1,Sj,ki)){break a}Oj=q[Sj>>2]}Nj=q[a>>2];Vi=q[a+4>>2]-Nj>>2;c:{if(Oj>>>0>Vi>>>0){Fa(a,Oj-Vi|0);Oj=q[a+12>>2];break c}if(Oj>>>0>=Vi>>>0){break c}q[a+4>>2]=Nj+(Oj<<2)}if(!Oj){Yj=1;break a}Wj=q[ki+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]=Qj;a=q[a>>2]+Nj|0;if(a>>>0>4096){break a}if(Nj>>>0>>0){Qj=q[Rj>>2];while(1){q[Qj+(Nj<<2)>>2]=ki;Nj=Nj+1|0;if((a|0)!=(Nj|0)){continue}break}}Nj=a;ki=ki+1|0;if((Oj|0)!=(ki|0)){continue}break}return(a|0)==4096}return Yj}function uh(a,ki){var Zj=0,_j=0,$j=0,ak=0,bk=0,ck=0,dk=0,ek=0,fk=0;bk=T-16|0;T=bk;a:{b:{if(s[ki+38>>1]<=511){_j=q[ki+12>>2];ek=_j;Zj=q[ki+20>>2];$j=q[ki+16>>2];ak=$j+8|0;if(ak>>>0<8){Zj=Zj+1|0}ck=q[ki+8>>2];if((_j|0)<(Zj|0)?1:(_j|0)<=(Zj|0)?ck>>>0>=ak>>>0?0:1:0){break a}_j=$j+q[ki>>2]|0;$j=r[_j+4|0]|r[_j+5|0]<<8|(r[_j+6|0]<<16|r[_j+7|0]<<24);_j=r[_j|0]|r[_j+1|0]<<8|(r[_j+2|0]<<16|r[_j+3|0]<<24);q[bk+8>>2]=_j;q[bk+12>>2]=$j;q[ki+16>>2]=ak;q[ki+20>>2]=Zj;break b}if(!Eh(1,bk+8|0,ki)){break a}ak=q[ki+16>>2];Zj=q[ki+20>>2];ck=q[ki+8>>2];ek=q[ki+12>>2];_j=q[bk+8>>2];$j=q[bk+12>>2]}dk=ck-ak|0;ck=ek-(Zj+(ck>>>0>>0)|0)|0;if((ck|0)==($j|0)&_j>>>0>dk>>>0|$j>>>0>ck>>>0){break a}$j=Zj+$j|0;Zj=ak;dk=Zj+_j|0;if(dk>>>0>>0){$j=$j+1|0}q[ki+16>>2]=dk;q[ki+20>>2]=$j;Zj=_j;if((Zj|0)<1){break a}ak=ak+q[ki>>2]|0;q[a+40>>2]=ak;ki=a;c:{d:{e:{f:{g:{_j=Zj+ -1|0;$j=ak+_j|0;switch((r[$j|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=_j;a=r[$j|0]&63;break c}if((Zj|0)<2){break a}q[a+44>>2]=Zj+ -2;a=(Zj+ak|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Zj|0)<3){break a}q[a+44>>2]=Zj+ -3;a=(Zj+ak|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Zj+ -4;a=(Zj+ak|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+16384|0;q[ki+48>>2]=a;fk=a>>>0<4194304}T=bk+16|0;return fk}function vh(a,ki,gk){var hk=0,ik=0,jk=0,kk=0,lk=0,mk=0,nk=0,ok=0;hk=T+ -64|0;T=hk;q[hk+56>>2]=0;q[hk+48>>2]=0;q[hk+52>>2]=0;q[hk+40>>2]=0;q[hk+44>>2]=0;q[hk+32>>2]=0;q[hk+36>>2]=0;q[hk+24>>2]=0;q[hk+28>>2]=0;q[hk+16>>2]=0;q[hk+20>>2]=0;q[hk+8>>2]=0;q[hk+12>>2]=0;a:{if(!th(hk+8|0,ki)|(q[hk+20>>2]?0:a)){break a}ik=uh(hk+8|0,ki);if(!a|!ik){break a}ki=q[hk+56>>2];mk=q[hk+36>>2];nk=q[hk+48>>2];ok=q[hk+24>>2];while(1){b:{if(ki>>>0>16383){break b}ik=q[hk+52>>2];while(1){if((ik|0)<1){break b}ik=ik+ -1|0;q[hk+52>>2]=ik;ki=r[ik+nk|0]|ki<<8;q[hk+56>>2]=ki;if(ki>>>0<16384){continue}break}}ik=ki&4095;kk=q[(ik<<2)+ok>>2];lk=(kk<<3)+mk|0;ki=(w(q[lk>>2],ki>>>12)+ik|0)-q[lk+4>>2]|0;q[hk+56>>2]=ki;q[(jk<<2)+gk>>2]=kk;ik=1;jk=jk+1|0;if((jk|0)!=(a|0)){continue}break}}a=q[hk+36>>2];if(a){q[hk+40>>2]=a;An(a)}a=q[hk+24>>2];if(a){q[hk+28>>2]=a;An(a)}a=q[hk+8>>2];if(a){q[hk+12>>2]=a;An(a)}T=hk- -64|0;return ik}function wh(a,ki,gk){var pk=0,qk=0,rk=0,sk=0,tk=0,uk=0,vk=0,wk=0;pk=T+ -64|0;T=pk;q[pk+56>>2]=0;q[pk+48>>2]=0;q[pk+52>>2]=0;q[pk+40>>2]=0;q[pk+44>>2]=0;q[pk+32>>2]=0;q[pk+36>>2]=0;q[pk+24>>2]=0;q[pk+28>>2]=0;q[pk+16>>2]=0;q[pk+20>>2]=0;q[pk+8>>2]=0;q[pk+12>>2]=0;a:{if(!Fh(pk+8|0,ki)|(q[pk+20>>2]?0:a)){break a}qk=Gh(pk+8|0,ki);if(!a|!qk){break a}ki=q[pk+56>>2];uk=q[pk+36>>2];vk=q[pk+48>>2];wk=q[pk+24>>2];while(1){b:{if(ki>>>0>32767){break b}qk=q[pk+52>>2];while(1){if((qk|0)<1){break b}qk=qk+ -1|0;q[pk+52>>2]=qk;ki=r[qk+vk|0]|ki<<8;q[pk+56>>2]=ki;if(ki>>>0<32768){continue}break}}qk=ki&8191;sk=q[(qk<<2)+wk>>2];tk=(sk<<3)+uk|0;ki=(w(q[tk>>2],ki>>>13)+qk|0)-q[tk+4>>2]|0;q[pk+56>>2]=ki;q[(rk<<2)+gk>>2]=sk;qk=1;rk=rk+1|0;if((rk|0)!=(a|0)){continue}break}}a=q[pk+36>>2];if(a){q[pk+40>>2]=a;An(a)}a=q[pk+24>>2];if(a){q[pk+28>>2]=a;An(a)}a=q[pk+8>>2];if(a){q[pk+12>>2]=a;An(a)}T=pk- -64|0;return qk}function xh(a,ki,gk){var xk=0,yk=0,zk=0,Ak=0,Bk=0,Ck=0,Dk=0,Ek=0;xk=T+ -64|0;T=xk;q[xk+56>>2]=0;q[xk+48>>2]=0;q[xk+52>>2]=0;q[xk+40>>2]=0;q[xk+44>>2]=0;q[xk+32>>2]=0;q[xk+36>>2]=0;q[xk+24>>2]=0;q[xk+28>>2]=0;q[xk+16>>2]=0;q[xk+20>>2]=0;q[xk+8>>2]=0;q[xk+12>>2]=0;a:{if(!Hh(xk+8|0,ki)|(q[xk+20>>2]?0:a)){break a}yk=Ih(xk+8|0,ki);if(!a|!yk){break a}ki=q[xk+56>>2];Ck=q[xk+36>>2];Dk=q[xk+48>>2];Ek=q[xk+24>>2];while(1){b:{if(ki>>>0>131071){break b}yk=q[xk+52>>2];while(1){if((yk|0)<1){break b}yk=yk+ -1|0;q[xk+52>>2]=yk;ki=r[yk+Dk|0]|ki<<8;q[xk+56>>2]=ki;if(ki>>>0<131072){continue}break}}yk=ki&32767;Ak=q[(yk<<2)+Ek>>2];Bk=(Ak<<3)+Ck|0;ki=(w(q[Bk>>2],ki>>>15)+yk|0)-q[Bk+4>>2]|0;q[xk+56>>2]=ki;q[(zk<<2)+gk>>2]=Ak;yk=1;zk=zk+1|0;if((zk|0)!=(a|0)){continue}break}}a=q[xk+36>>2];if(a){q[xk+40>>2]=a;An(a)}a=q[xk+24>>2];if(a){q[xk+28>>2]=a;An(a)}a=q[xk+8>>2];if(a){q[xk+12>>2]=a;An(a)}T=xk- -64|0;return yk}function yh(a,ki,gk){var Fk=0,Gk=0,Hk=0,Ik=0,Jk=0,Kk=0,Lk=0,Mk=0;Fk=T+ -64|0;T=Fk;q[Fk+56>>2]=0;q[Fk+48>>2]=0;q[Fk+52>>2]=0;q[Fk+40>>2]=0;q[Fk+44>>2]=0;q[Fk+32>>2]=0;q[Fk+36>>2]=0;q[Fk+24>>2]=0;q[Fk+28>>2]=0;q[Fk+16>>2]=0;q[Fk+20>>2]=0;q[Fk+8>>2]=0;q[Fk+12>>2]=0;a:{if(!Jh(Fk+8|0,ki)|(q[Fk+20>>2]?0:a)){break a}Gk=Kh(Fk+8|0,ki);if(!a|!Gk){break a}ki=q[Fk+56>>2];Kk=q[Fk+36>>2];Lk=q[Fk+48>>2];Mk=q[Fk+24>>2];while(1){b:{if(ki>>>0>262143){break b}Gk=q[Fk+52>>2];while(1){if((Gk|0)<1){break b}Gk=Gk+ -1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<2)+gk>>2]=Qk;Ok=1;Pk=Pk+1|0;if((Pk|0)!=(a|0)){continue}break}}a=q[Nk+36>>2];if(a){q[Nk+40>>2]=a;An(a)}a=q[Nk+24>>2];if(a){q[Nk+28>>2]=a;An(a)}a=q[Nk+8>>2];if(a){q[Nk+12>>2]=a;An(a)}T=Nk- -64|0;return Ok}function Ah(a,ki,gk){var Vk=0,Wk=0,Xk=0,Yk=0,Zk=0,_k=0,$k=0,al=0;Vk=T+ -64|0;T=Vk;q[Vk+56>>2]=0;q[Vk+48>>2]=0;q[Vk+52>>2]=0;q[Vk+40>>2]=0;q[Vk+44>>2]=0;q[Vk+32>>2]=0;q[Vk+36>>2]=0;q[Vk+24>>2]=0;q[Vk+28>>2]=0;q[Vk+16>>2]=0;q[Vk+20>>2]=0;q[Vk+8>>2]=0;q[Vk+12>>2]=0;a:{if(!Nh(Vk+8|0,ki)|(q[Vk+20>>2]?0:a)){break a}Wk=Oh(Vk+8|0,ki);if(!a|!Wk){break a}ki=q[Vk+56>>2];_k=q[Vk+36>>2];$k=q[Vk+48>>2];al=q[Vk+24>>2];while(1){b:{if(ki>>>0>2097151){break b}Wk=q[Vk+52>>2];while(1){if((Wk|0)<1){break b}Wk=Wk+ -1|0;q[Vk+52>>2]=Wk;ki=r[Wk+$k|0]|ki<<8;q[Vk+56>>2]=ki;if(ki>>>0<2097152){continue}break}}Wk=ki&524287;Yk=q[(Wk<<2)+al>>2];Zk=(Yk<<3)+_k|0;ki=(w(q[Zk>>2],ki>>>19)+Wk|0)-q[Zk+4>>2]|0;q[Vk+56>>2]=ki;q[(Xk<<2)+gk>>2]=Yk;Wk=1;Xk=Xk+1|0;if((Xk|0)!=(a|0)){continue}break}}a=q[Vk+36>>2];if(a){q[Vk+40>>2]=a;An(a)}a=q[Vk+24>>2];if(a){q[Vk+28>>2]=a;An(a)}a=q[Vk+8>>2];if(a){q[Vk+12>>2]=a;An(a)}T=Vk- -64|0;return Wk}function Bh(a,ki,gk){var bl=0,cl=0,dl=0,el=0,fl=0,gl=0,hl=0,il=0;bl=T+ -64|0;T=bl;q[bl+56>>2]=0;q[bl+48>>2]=0;q[bl+52>>2]=0;q[bl+40>>2]=0;q[bl+44>>2]=0;q[bl+32>>2]=0;q[bl+36>>2]=0;q[bl+24>>2]=0;q[bl+28>>2]=0;q[bl+16>>2]=0;q[bl+20>>2]=0;q[bl+8>>2]=0;q[bl+12>>2]=0;a:{if(!Ph(bl+8|0,ki)|(q[bl+20>>2]?0:a)){break a}cl=Qh(bl+8|0,ki);if(!a|!cl){break a}ki=q[bl+56>>2];gl=q[bl+36>>2];hl=q[bl+48>>2];il=q[bl+24>>2];while(1){b:{if(ki>>>0>4194303){break b}cl=q[bl+52>>2];while(1){if((cl|0)<1){break b}cl=cl+ -1|0;q[bl+52>>2]=cl;ki=r[cl+hl|0]|ki<<8;q[bl+56>>2]=ki;if(ki>>>0<4194304){continue}break}}cl=ki&1048575;el=q[(cl<<2)+il>>2];fl=(el<<3)+gl|0;ki=(w(q[fl>>2],ki>>>20)+cl|0)-q[fl+4>>2]|0;q[bl+56>>2]=ki;q[(dl<<2)+gk>>2]=el;cl=1;dl=dl+1|0;if((dl|0)!=(a|0)){continue}break}}a=q[bl+36>>2];if(a){q[bl+40>>2]=a;An(a)}a=q[bl+24>>2];if(a){q[bl+28>>2]=a;An(a)}a=q[bl+8>>2];if(a){q[bl+12>>2]=a;An(a)}T=bl- -64|0;return cl}function Ch(a,ki,gk){var jl=0,kl=0,ll=0,ml=0;a:{if(a>>>0>5){break a}ll=q[gk+16>>2];jl=q[gk+12>>2];kl=q[gk+20>>2];if((jl|0)<(kl|0)?1:(jl|0)<=(kl|0)?t[gk+8>>2]>ll>>>0?0:1:0){break a}jl=r[ll+q[gk>>2]|0];ll=ll+1|0;if(ll>>>0<1){kl=kl+1|0}q[gk+16>>2]=ll;q[gk+20>>2]=kl;kl=ki;if(jl&128){if(!Ch(a+1|0,ki,gk)){break a}a=q[ki>>2]<<7;q[ki>>2]=a;jl=a|jl&127}q[kl>>2]=jl;ml=1}return ml}function Dh(a,ki){var gk=0,nl=0,ol=0,pl=0,ql=0,rl=0,sl=0;a:{b:{ol=q[a+8>>2];gk=a+4|0;nl=q[gk>>2];c:{if(ol-nl>>3>>>0>=ki>>>0){while(1){q[nl>>2]=0;q[nl+4>>2]=0;nl=q[gk>>2]+8|0;q[gk>>2]=nl;ki=ki+ -1|0;if(ki){continue}break c}}pl=q[a>>2];ql=nl-pl|0;gk=ql>>3;nl=gk+ki|0;if(nl>>>0>=536870912){break b}sl=gk<<3;ol=ol-pl|0;gk=ol>>2;ol=ol>>3>>>0<268435455?gk>>>0>>0?nl:gk:536870911;gk=0;d:{if(!ol){break d}if(ol>>>0>=536870912){break a}rl=Mm(ol<<3);gk=rl}nl=sl+gk|0;Dn(nl,0,ki<<3);ol=gk+(ol<<3)|0;while(1){nl=nl+8|0;ki=ki+ -1|0;if(ki){continue}break}if((ql|0)>=1){Cn(rl,pl,ql)}q[a>>2]=gk;q[a+8>>2]=ol;q[a+4>>2]=nl;if(!pl){break c}An(pl)}return}bn();F()}ab(10991);F()}function Eh(a,ki,tl){var ul=0,vl=0,wl=0,xl=0,yl=0,zl=0;a:{if(a>>>0>10){break a}wl=q[tl+16>>2];ul=q[tl+12>>2];vl=q[tl+20>>2];xl=vl;if((ul|0)<(xl|0)?1:(ul|0)<=(xl|0)?t[tl+8>>2]>wl>>>0?0:1:0){break a}yl=o[wl+q[tl>>2]|0];ul=wl+1|0;if(ul>>>0<1){vl=vl+1|0}q[tl+16>>2]=ul;q[tl+20>>2]=vl;xl=ki;wl=ki;ul=yl;b:{if((ul|0)<=-1){if(!Eh(a+1|0,ki,tl)){break a}a=ki;tl=q[ki+4>>2];ki=q[ki>>2];vl=tl<<7|ki>>>25;ki=ki<<7;q[a>>2]=ki;q[a+4>>2]=vl;a=ul&127|ki;break b}vl=0;a=ul&255}q[wl>>2]=a;q[xl+4>>2]=vl;zl=1}return zl}function Fh(a,ki){var tl=0,Al=0,Bl=0,Cl=0,Dl=0,El=0,Fl=0,Gl=0,Hl=0,Il=0,Jl=0,Kl=0,Ll=0;a:{tl=s[ki+38>>1];if(!tl){break a}Fl=a+12|0;b:{if(tl>>>0<=511){Al=q[ki+12>>2];tl=q[ki+20>>2];Bl=q[ki+16>>2];Dl=Bl+4|0;if(Dl>>>0<4){tl=tl+1|0}if((Al|0)<(tl|0)?1:(Al|0)<=(tl|0)?t[ki+8>>2]>=Dl>>>0?0:1:0){break a}tl=Bl+q[ki>>2]|0;Bl=r[tl|0]|r[tl+1|0]<<8|(r[tl+2|0]<<16|r[tl+3|0]<<24);q[Fl>>2]=Bl;Al=q[ki+20>>2];Dl=q[ki+16>>2]+4|0;if(Dl>>>0<4){Al=Al+1|0}tl=ki;q[tl+16>>2]=Dl;q[tl+20>>2]=Al;break b}if(!Ch(1,Fl,ki)){break a}Bl=q[Fl>>2]}Al=q[a>>2];tl=q[a+4>>2]-Al>>2;c:{if(Bl>>>0>tl>>>0){Fa(a,Bl-tl|0);Bl=q[a+12>>2];break c}if(Bl>>>0>=tl>>>0){break c}q[a+4>>2]=Al+(Bl<<2)}if(!Bl){Ll=1;break a}Jl=q[ki+8>>2];Dl=q[ki+12>>2];while(1){Cl=q[ki+16>>2];tl=q[ki+20>>2];if((Dl|0)<(tl|0)?1:(Dl|0)<=(tl|0)?Jl>>>0>Cl>>>0?0:1:0){break a}Kl=q[ki>>2];Gl=r[Kl+Cl|0];Cl=Cl+1|0;if(Cl>>>0<1){tl=tl+1|0}q[ki+16>>2]=Cl;q[ki+20>>2]=tl;Hl=Gl>>>2;d:{e:{f:{Il=Gl&3;if(Il>>>0>3){Al=0;break f}Al=0;g:{switch(Il-1|0){case 0:case 1:break f;case 2:break g;default:break e}}tl=El+Hl|0;if(tl>>>0>=Bl>>>0){return 0}Dn(q[a>>2]+(El<<2)|0,0,(Gl&252)+4|0);El=tl;break d}while(1){if((Dl|0)<(tl|0)?1:(Dl|0)<=(tl|0)?Jl>>>0>Cl>>>0?0:1:0){return 0}Gl=r[Cl+Kl|0];Cl=Cl+1|0;if(Cl>>>0<1){tl=tl+1|0}q[ki+16>>2]=Cl;q[ki+20>>2]=tl;Hl=Gl<<(Al<<3|6)|Hl;Al=Al+1|0;if((Il|0)!=(Al|0)){continue}break}}q[q[a>>2]+(El<<2)>>2]=Hl}El=El+1|0;Bl=q[Fl>>2];if(El>>>0>>0){continue}break}El=a+16|0;Fl=q[a>>2];ki=q[a+16>>2];tl=q[a+20>>2]-ki|0;Al=tl>>2;h:{if(Al>>>0<=8191){Fa(El,8192-Al|0);break h}if((tl|0)==32768){break h}q[a+20>>2]=ki+32768}i:{ki=a+28|0;tl=q[ki>>2];Al=q[a+32>>2]-tl>>3;if(Bl>>>0>Al>>>0){Dh(ki,Bl-Al|0);tl=q[ki>>2];break i}if(Bl>>>0>>0){q[a+32>>2]=(Bl<<3)+tl}if(Bl){break i}return 0}ki=0;Al=0;while(1){a=Fl+(ki<<2)|0;Dl=q[a>>2];Cl=(ki<<3)+tl|0;q[Cl+4>>2]=Al;q[Cl>>2]=Dl;a=q[a>>2]+Al|0;if(a>>>0>8192){break a}if(Al>>>0>>0){Dl=q[El>>2];while(1){q[Dl+(Al<<2)>>2]=ki;Al=Al+1|0;if((a|0)!=(Al|0)){continue}break}}Al=a;ki=ki+1|0;if((Bl|0)!=(ki|0)){continue}break}return(a|0)==8192}return Ll}function Gh(a,ki){var Ml=0,Nl=0,Ol=0,Pl=0,Ql=0,Rl=0,Sl=0,Tl=0,Ul=0;Ql=T-16|0;T=Ql;a:{b:{if(s[ki+38>>1]<=511){Nl=q[ki+12>>2];Tl=Nl;Ml=q[ki+20>>2];Ol=q[ki+16>>2];Pl=Ol+8|0;if(Pl>>>0<8){Ml=Ml+1|0}Rl=q[ki+8>>2];if((Nl|0)<(Ml|0)?1:(Nl|0)<=(Ml|0)?Rl>>>0>=Pl>>>0?0:1:0){break a}Nl=Ol+q[ki>>2]|0;Ol=r[Nl+4|0]|r[Nl+5|0]<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>>0<1){Vl=Vl+1|0}q[ki+16>>2]=Yl;q[ki+20>>2]=Vl;bm=am<<(Wl<<3|6)|bm;Wl=Wl+1|0;if((cm|0)!=(Wl|0)){continue}break}}q[q[a>>2]+(_l<<2)>>2]=bm}_l=_l+1|0;Xl=q[$l>>2];if(_l>>>0>>0){continue}break}_l=a+16|0;$l=q[a>>2];ki=q[a+16>>2];Vl=q[a+20>>2]-ki|0;Wl=Vl>>2;h:{if(Wl>>>0<=32767){Fa(_l,32768-Wl|0);break h}if((Vl|0)==131072){break h}q[a+20>>2]=ki+131072}i:{ki=a+28|0;Vl=q[ki>>2];Wl=q[a+32>>2]-Vl>>3;if(Xl>>>0>Wl>>>0){Dh(ki,Xl-Wl|0);Vl=q[ki>>2];break i}if(Xl>>>0>>0){q[a+32>>2]=(Xl<<3)+Vl}if(Xl){break i}return 0}ki=0;Wl=0;while(1){a=$l+(ki<<2)|0;Zl=q[a>>2];Yl=(ki<<3)+Vl|0;q[Yl+4>>2]=Wl;q[Yl>>2]=Zl;a=q[a>>2]+Wl|0;if(a>>>0>32768){break a}if(Wl>>>0>>0){Zl=q[_l>>2];while(1){q[Zl+(Wl<<2)>>2]=ki;Wl=Wl+1|0;if((a|0)!=(Wl|0)){continue}break}}Wl=a;ki=ki+1|0;if((Xl|0)!=(ki|0)){continue}break}return(a|0)==32768}return fm}function Ih(a,ki){var gm=0,hm=0,im=0,jm=0,km=0,lm=0,mm=0,nm=0,om=0;km=T-16|0;T=km;a:{b:{if(s[ki+38>>1]<=511){hm=q[ki+12>>2];nm=hm;gm=q[ki+20>>2];im=q[ki+16>>2];jm=im+8|0;if(jm>>>0<8){gm=gm+1|0}lm=q[ki+8>>2];if((hm|0)<(gm|0)?1:(hm|0)<=(gm|0)?lm>>>0>=jm>>>0?0:1:0){break a}hm=im+q[ki>>2]|0;im=r[hm+4|0]|r[hm+5|0]<<8|(r[hm+6|0]<<16|r[hm+7|0]<<24);hm=r[hm|0]|r[hm+1|0]<<8|(r[hm+2|0]<<16|r[hm+3|0]<<24);q[km+8>>2]=hm;q[km+12>>2]=im;q[ki+16>>2]=jm;q[ki+20>>2]=gm;break b}if(!Eh(1,km+8|0,ki)){break a}jm=q[ki+16>>2];gm=q[ki+20>>2];lm=q[ki+8>>2];nm=q[ki+12>>2];hm=q[km+8>>2];im=q[km+12>>2]}mm=lm-jm|0;lm=nm-(gm+(lm>>>0>>0)|0)|0;if((lm|0)==(im|0)&hm>>>0>mm>>>0|im>>>0>lm>>>0){break a}im=gm+im|0;gm=jm;mm=gm+hm|0;if(mm>>>0>>0){im=im+1|0}q[ki+16>>2]=mm;q[ki+20>>2]=im;gm=hm;if((gm|0)<1){break a}jm=jm+q[ki>>2]|0;q[a+40>>2]=jm;ki=a;c:{d:{e:{f:{g:{hm=gm+ -1|0;im=jm+hm|0;switch((r[im|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=hm;a=r[im|0]&63;break c}if((gm|0)<2){break a}q[a+44>>2]=gm+ -2;a=(gm+jm|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((gm|0)<3){break a}q[a+44>>2]=gm+ -3;a=(gm+jm|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=gm+ -4;a=(gm+jm|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+131072|0;q[ki+48>>2]=a;om=a>>>0<33554432}T=km+16|0;return om}function Jh(a,ki){var pm=0,qm=0,rm=0,sm=0,tm=0,um=0,vm=0,wm=0,xm=0,ym=0,zm=0,Am=0,Bm=0;a:{pm=s[ki+38>>1];if(!pm){break a}vm=a+12|0;b:{if(pm>>>0<=511){qm=q[ki+12>>2];pm=q[ki+20>>2];rm=q[ki+16>>2];tm=rm+4|0;if(tm>>>0<4){pm=pm+1|0}if((qm|0)<(pm|0)?1:(qm|0)<=(pm|0)?t[ki+8>>2]>=tm>>>0?0:1:0){break a}pm=rm+q[ki>>2]|0;rm=r[pm|0]|r[pm+1|0]<<8|(r[pm+2|0]<<16|r[pm+3|0]<<24);q[vm>>2]=rm;qm=q[ki+20>>2];tm=q[ki+16>>2]+4|0;if(tm>>>0<4){qm=qm+1|0}pm=ki;q[pm+16>>2]=tm;q[pm+20>>2]=qm;break b}if(!Ch(1,vm,ki)){break a}rm=q[vm>>2]}qm=q[a>>2];pm=q[a+4>>2]-qm>>2;c:{if(rm>>>0>pm>>>0){Fa(a,rm-pm|0);rm=q[a+12>>2];break c}if(rm>>>0>=pm>>>0){break c}q[a+4>>2]=qm+(rm<<2)}if(!rm){Bm=1;break a}zm=q[ki+8>>2];tm=q[ki+12>>2];while(1){sm=q[ki+16>>2];pm=q[ki+20>>2];if((tm|0)<(pm|0)?1:(tm|0)<=(pm|0)?zm>>>0>sm>>>0?0:1:0){break a}Am=q[ki>>2];wm=r[Am+sm|0];sm=sm+1|0;if(sm>>>0<1){pm=pm+1|0}q[ki+16>>2]=sm;q[ki+20>>2]=pm;xm=wm>>>2;d:{e:{f:{ym=wm&3;if(ym>>>0>3){qm=0;break f}qm=0;g:{switch(ym-1|0){case 0:case 1:break f;case 2:break g;default:break e}}pm=um+xm|0;if(pm>>>0>=rm>>>0){return 0}Dn(q[a>>2]+(um<<2)|0,0,(wm&252)+4|0);um=pm;break d}while(1){if((tm|0)<(pm|0)?1:(tm|0)<=(pm|0)?zm>>>0>sm>>>0?0:1:0){return 0}wm=r[sm+Am|0];sm=sm+1|0;if(sm>>>0<1){pm=pm+1|0}q[ki+16>>2]=sm;q[ki+20>>2]=pm;xm=wm<<(qm<<3|6)|xm;qm=qm+1|0;if((ym|0)!=(qm|0)){continue}break}}q[q[a>>2]+(um<<2)>>2]=xm}um=um+1|0;rm=q[vm>>2];if(um>>>0>>0){continue}break}um=a+16|0;vm=q[a>>2];ki=q[a+16>>2];pm=q[a+20>>2]-ki|0;qm=pm>>2;h:{if(qm>>>0<=65535){Fa(um,65536-qm|0);break h}if((pm|0)==262144){break h}q[a+20>>2]=ki+262144}i:{ki=a+28|0;pm=q[ki>>2];qm=q[a+32>>2]-pm>>3;if(rm>>>0>qm>>>0){Dh(ki,rm-qm|0);pm=q[ki>>2];break i}if(rm>>>0>>0){q[a+32>>2]=(rm<<3)+pm}if(rm){break i}return 0}ki=0;qm=0;while(1){a=vm+(ki<<2)|0;tm=q[a>>2];sm=(ki<<3)+pm|0;q[sm+4>>2]=qm;q[sm>>2]=tm;a=q[a>>2]+qm|0;if(a>>>0>65536){break a}if(qm>>>0>>0){tm=q[um>>2];while(1){q[tm+(qm<<2)>>2]=ki;qm=qm+1|0;if((a|0)!=(qm|0)){continue}break}}qm=a;ki=ki+1|0;if((rm|0)!=(ki|0)){continue}break}return(a|0)==65536}return Bm}function Kh(a,ki){var Cm=0,Dm=0,Em=0,Fm=0,Gm=0,Hm=0,Im=0,Jm=0,Km=0;Gm=T-16|0;T=Gm;a:{b:{if(s[ki+38>>1]<=511){Dm=q[ki+12>>2];Jm=Dm;Cm=q[ki+20>>2];Em=q[ki+16>>2];Fm=Em+8|0;if(Fm>>>0<8){Cm=Cm+1|0}Hm=q[ki+8>>2];if((Dm|0)<(Cm|0)?1:(Dm|0)<=(Cm|0)?Hm>>>0>=Fm>>>0?0:1:0){break a}Dm=Em+q[ki>>2]|0;Em=r[Dm+4|0]|r[Dm+5|0]<<8|(r[Dm+6|0]<<16|r[Dm+7|0]<<24);Dm=r[Dm|0]|r[Dm+1|0]<<8|(r[Dm+2|0]<<16|r[Dm+3|0]<<24);q[Gm+8>>2]=Dm;q[Gm+12>>2]=Em;q[ki+16>>2]=Fm;q[ki+20>>2]=Cm;break b}if(!Eh(1,Gm+8|0,ki)){break a}Fm=q[ki+16>>2];Cm=q[ki+20>>2];Hm=q[ki+8>>2];Jm=q[ki+12>>2];Dm=q[Gm+8>>2];Em=q[Gm+12>>2]}Im=Hm-Fm|0;Hm=Jm-(Cm+(Hm>>>0>>0)|0)|0;if((Hm|0)==(Em|0)&Dm>>>0>Im>>>0|Em>>>0>Hm>>>0){break a}Em=Cm+Em|0;Cm=Fm;Im=Cm+Dm|0;if(Im>>>0>>0){Em=Em+1|0}q[ki+16>>2]=Im;q[ki+20>>2]=Em;Cm=Dm;if((Cm|0)<1){break a}Fm=Fm+q[ki>>2]|0;q[a+40>>2]=Fm;ki=a;c:{d:{e:{f:{g:{Dm=Cm+ -1|0;Em=Fm+Dm|0;switch((r[Em|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=Dm;a=r[Em|0]&63;break c}if((Cm|0)<2){break a}q[a+44>>2]=Cm+ -2;a=(Cm+Fm|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Cm|0)<3){break a}q[a+44>>2]=Cm+ -3;a=(Cm+Fm|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Cm+ -4;a=(Cm+Fm|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+262144|0;q[ki+48>>2]=a;Km=a>>>0<67108864}T=Gm+16|0;return Km}function Lh(a,ki){var Lm=0,Mm=0,Nm=0,Om=0,Pm=0,Qm=0,Rm=0,Sm=0,Tm=0,Um=0,Vm=0,Wm=0,Xm=0;a:{Lm=s[ki+38>>1];if(!Lm){break a}Rm=a+12|0;b:{if(Lm>>>0<=511){Mm=q[ki+12>>2];Lm=q[ki+20>>2];Nm=q[ki+16>>2];Pm=Nm+4|0;if(Pm>>>0<4){Lm=Lm+1|0}if((Mm|0)<(Lm|0)?1:(Mm|0)<=(Lm|0)?t[ki+8>>2]>=Pm>>>0?0:1:0){break a}Lm=Nm+q[ki>>2]|0;Nm=r[Lm|0]|r[Lm+1|0]<<8|(r[Lm+2|0]<<16|r[Lm+3|0]<<24);q[Rm>>2]=Nm;Mm=q[ki+20>>2];Pm=q[ki+16>>2]+4|0;if(Pm>>>0<4){Mm=Mm+1|0}Lm=ki;q[Lm+16>>2]=Pm;q[Lm+20>>2]=Mm;break b}if(!Ch(1,Rm,ki)){break a}Nm=q[Rm>>2]}Mm=q[a>>2];Lm=q[a+4>>2]-Mm>>2;c:{if(Nm>>>0>Lm>>>0){Fa(a,Nm-Lm|0);Nm=q[a+12>>2];break c}if(Nm>>>0>=Lm>>>0){break c}q[a+4>>2]=Mm+(Nm<<2)}if(!Nm){Xm=1;break a}Vm=q[ki+8>>2];Pm=q[ki+12>>2];while(1){Om=q[ki+16>>2];Lm=q[ki+20>>2];if((Pm|0)<(Lm|0)?1:(Pm|0)<=(Lm|0)?Vm>>>0>Om>>>0?0:1:0){break a}Wm=q[ki>>2];Sm=r[Wm+Om|0];Om=Om+1|0;if(Om>>>0<1){Lm=Lm+1|0}q[ki+16>>2]=Om;q[ki+20>>2]=Lm;Tm=Sm>>>2;d:{e:{f:{Um=Sm&3;if(Um>>>0>3){Mm=0;break f}Mm=0;g:{switch(Um-1|0){case 0:case 1:break f;case 2:break g;default:break e}}Lm=Qm+Tm|0;if(Lm>>>0>=Nm>>>0){return 0}Dn(q[a>>2]+(Qm<<2)|0,0,(Sm&252)+4|0);Qm=Lm;break d}while(1){if((Pm|0)<(Lm|0)?1:(Pm|0)<=(Lm|0)?Vm>>>0>Om>>>0?0:1:0){return 0}Sm=r[Om+Wm|0];Om=Om+1|0;if(Om>>>0<1){Lm=Lm+1|0}q[ki+16>>2]=Om;q[ki+20>>2]=Lm;Tm=Sm<<(Mm<<3|6)|Tm;Mm=Mm+1|0;if((Um|0)!=(Mm|0)){continue}break}}q[q[a>>2]+(Qm<<2)>>2]=Tm}Qm=Qm+1|0;Nm=q[Rm>>2];if(Qm>>>0>>0){continue}break}Qm=a+16|0;Rm=q[a>>2];ki=q[a+16>>2];Lm=q[a+20>>2]-ki|0;Mm=Lm>>2;h:{if(Mm>>>0<=262143){Fa(Qm,262144-Mm|0);break h}if((Lm|0)==1048576){break h}q[a+20>>2]=ki- -1048576}i:{ki=a+28|0;Lm=q[ki>>2];Mm=q[a+32>>2]-Lm>>3;if(Nm>>>0>Mm>>>0){Dh(ki,Nm-Mm|0);Lm=q[ki>>2];break i}if(Nm>>>0>>0){q[a+32>>2]=(Nm<<3)+Lm}if(Nm){break i}return 0}ki=0;Mm=0;while(1){a=Rm+(ki<<2)|0;Pm=q[a>>2];Om=(ki<<3)+Lm|0;q[Om+4>>2]=Mm;q[Om>>2]=Pm;a=q[a>>2]+Mm|0;if(a>>>0>262144){break a}if(Mm>>>0>>0){Pm=q[Qm>>2];while(1){q[Pm+(Mm<<2)>>2]=ki;Mm=Mm+1|0;if((a|0)!=(Mm|0)){continue}break}}Mm=a;ki=ki+1|0;if((Nm|0)!=(ki|0)){continue}break}return(a|0)==262144}return Xm}function Mh(a,ki){var Ym=0,Zm=0,_m=0,$m=0,an=0,bn=0,cn=0,dn=0,en=0;an=T-16|0;T=an;a:{b:{if(s[ki+38>>1]<=511){Zm=q[ki+12>>2];dn=Zm;Ym=q[ki+20>>2];_m=q[ki+16>>2];$m=_m+8|0;if($m>>>0<8){Ym=Ym+1|0}bn=q[ki+8>>2];if((Zm|0)<(Ym|0)?1:(Zm|0)<=(Ym|0)?bn>>>0>=$m>>>0?0:1:0){break a}Zm=_m+q[ki>>2]|0;_m=r[Zm+4|0]|r[Zm+5|0]<<8|(r[Zm+6|0]<<16|r[Zm+7|0]<<24);Zm=r[Zm|0]|r[Zm+1|0]<<8|(r[Zm+2|0]<<16|r[Zm+3|0]<<24);q[an+8>>2]=Zm;q[an+12>>2]=_m;q[ki+16>>2]=$m;q[ki+20>>2]=Ym;break b}if(!Eh(1,an+8|0,ki)){break a}$m=q[ki+16>>2];Ym=q[ki+20>>2];bn=q[ki+8>>2];dn=q[ki+12>>2];Zm=q[an+8>>2];_m=q[an+12>>2]}cn=bn-$m|0;bn=dn-(Ym+(bn>>>0<$m>>>0)|0)|0;if((bn|0)==(_m|0)&Zm>>>0>cn>>>0|_m>>>0>bn>>>0){break a}_m=Ym+_m|0;Ym=$m;cn=Ym+Zm|0;if(cn>>>0>>0){_m=_m+1|0}q[ki+16>>2]=cn;q[ki+20>>2]=_m;Ym=Zm;if((Ym|0)<1){break a}$m=$m+q[ki>>2]|0;q[a+40>>2]=$m;ki=a;c:{d:{e:{f:{g:{Zm=Ym+ -1|0;_m=$m+Zm|0;switch((r[_m|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=Zm;a=r[_m|0]&63;break c}if((Ym|0)<2){break a}q[a+44>>2]=Ym+ -2;a=(Ym+$m|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((Ym|0)<3){break a}q[a+44>>2]=Ym+ -3;a=(Ym+$m|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Ym+ -4;a=(Ym+$m|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a- -1048576|0;q[ki+48>>2]=a;en=a>>>0<268435456}T=an+16|0;return en}function Nh(a,ki){var fn=0,gn=0,hn=0,jn=0,kn=0,ln=0,mn=0,nn=0,on=0,pn=0,qn=0,rn=0,sn=0;a:{fn=s[ki+38>>1];if(!fn){break a}mn=a+12|0;b:{if(fn>>>0<=511){gn=q[ki+12>>2];fn=q[ki+20>>2];hn=q[ki+16>>2];kn=hn+4|0;if(kn>>>0<4){fn=fn+1|0}if((gn|0)<(fn|0)?1:(gn|0)<=(fn|0)?t[ki+8>>2]>=kn>>>0?0:1:0){break a}fn=hn+q[ki>>2]|0;hn=r[fn|0]|r[fn+1|0]<<8|(r[fn+2|0]<<16|r[fn+3|0]<<24);q[mn>>2]=hn;gn=q[ki+20>>2];kn=q[ki+16>>2]+4|0;if(kn>>>0<4){gn=gn+1|0}fn=ki;q[fn+16>>2]=kn;q[fn+20>>2]=gn;break b}if(!Ch(1,mn,ki)){break a}hn=q[mn>>2]}gn=q[a>>2];fn=q[a+4>>2]-gn>>2;c:{if(hn>>>0>fn>>>0){Fa(a,hn-fn|0);hn=q[a+12>>2];break c}if(hn>>>0>=fn>>>0){break c}q[a+4>>2]=gn+(hn<<2)}if(!hn){sn=1;break a}qn=q[ki+8>>2];kn=q[ki+12>>2];while(1){jn=q[ki+16>>2];fn=q[ki+20>>2];if((kn|0)<(fn|0)?1:(kn|0)<=(fn|0)?qn>>>0>jn>>>0?0:1:0){break a}rn=q[ki>>2];nn=r[rn+jn|0];jn=jn+1|0;if(jn>>>0<1){fn=fn+1|0}q[ki+16>>2]=jn;q[ki+20>>2]=fn;on=nn>>>2;d:{e:{f:{pn=nn&3;if(pn>>>0>3){gn=0;break f}gn=0;g:{switch(pn-1|0){case 0:case 1:break f;case 2:break g;default:break e}}fn=ln+on|0;if(fn>>>0>=hn>>>0){return 0}Dn(q[a>>2]+(ln<<2)|0,0,(nn&252)+4|0);ln=fn;break d}while(1){if((kn|0)<(fn|0)?1:(kn|0)<=(fn|0)?qn>>>0>jn>>>0?0:1:0){return 0}nn=r[jn+rn|0];jn=jn+1|0;if(jn>>>0<1){fn=fn+1|0}q[ki+16>>2]=jn;q[ki+20>>2]=fn;on=nn<<(gn<<3|6)|on;gn=gn+1|0;if((pn|0)!=(gn|0)){continue}break}}q[q[a>>2]+(ln<<2)>>2]=on}ln=ln+1|0;hn=q[mn>>2];if(ln>>>0>>0){continue}break}ln=a+16|0;mn=q[a>>2];ki=q[a+16>>2];fn=q[a+20>>2]-ki|0;gn=fn>>2;h:{if(gn>>>0<=524287){Fa(ln,524288-gn|0);break h}if((fn|0)==2097152){break h}q[a+20>>2]=ki+2097152}i:{ki=a+28|0;fn=q[ki>>2];gn=q[a+32>>2]-fn>>3;if(hn>>>0>gn>>>0){Dh(ki,hn-gn|0);fn=q[ki>>2];break i}if(hn>>>0>>0){q[a+32>>2]=(hn<<3)+fn}if(hn){break i}return 0}ki=0;gn=0;while(1){a=mn+(ki<<2)|0;kn=q[a>>2];jn=(ki<<3)+fn|0;q[jn+4>>2]=gn;q[jn>>2]=kn;a=q[a>>2]+gn|0;if(a>>>0>524288){break a}if(gn>>>0>>0){kn=q[ln>>2];while(1){q[kn+(gn<<2)>>2]=ki;gn=gn+1|0;if((a|0)!=(gn|0)){continue}break}}gn=a;ki=ki+1|0;if((hn|0)!=(ki|0)){continue}break}return(a|0)==524288}return sn}function Oh(a,ki){var tn=0,un=0,vn=0,wn=0,xn=0,yn=0,zn=0,An=0,Bn=0;xn=T-16|0;T=xn;a:{b:{if(s[ki+38>>1]<=511){un=q[ki+12>>2];An=un;tn=q[ki+20>>2];vn=q[ki+16>>2];wn=vn+8|0;if(wn>>>0<8){tn=tn+1|0}yn=q[ki+8>>2];if((un|0)<(tn|0)?1:(un|0)<=(tn|0)?yn>>>0>=wn>>>0?0:1:0){break a}un=vn+q[ki>>2]|0;vn=r[un+4|0]|r[un+5|0]<<8|(r[un+6|0]<<16|r[un+7|0]<<24);un=r[un|0]|r[un+1|0]<<8|(r[un+2|0]<<16|r[un+3|0]<<24);q[xn+8>>2]=un;q[xn+12>>2]=vn;q[ki+16>>2]=wn;q[ki+20>>2]=tn;break b}if(!Eh(1,xn+8|0,ki)){break a}wn=q[ki+16>>2];tn=q[ki+20>>2];yn=q[ki+8>>2];An=q[ki+12>>2];un=q[xn+8>>2];vn=q[xn+12>>2]}zn=yn-wn|0;yn=An-(tn+(yn>>>0>>0)|0)|0;if((yn|0)==(vn|0)&un>>>0>zn>>>0|vn>>>0>yn>>>0){break a}vn=tn+vn|0;tn=wn;zn=tn+un|0;if(zn>>>0>>0){vn=vn+1|0}q[ki+16>>2]=zn;q[ki+20>>2]=vn;tn=un;if((tn|0)<1){break a}wn=wn+q[ki>>2]|0;q[a+40>>2]=wn;ki=a;c:{d:{e:{f:{g:{un=tn+ -1|0;vn=wn+un|0;switch((r[vn|0]>>>6)-1|0){case 2:break d;case 1:break e;case 0:break f;default:break g}}q[a+44>>2]=un;a=r[vn|0]&63;break c}if((tn|0)<2){break a}q[a+44>>2]=tn+ -2;a=(tn+wn|0)+ -2|0;a=r[a+1|0]<<8&16128|r[a|0];break c}if((tn|0)<3){break a}q[a+44>>2]=tn+ -3;a=(tn+wn|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=tn+ -4;a=(tn+wn|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+2097152|0;q[ki+48>>2]=a;Bn=a>>>0<536870912}T=xn+16|0;return Bn}function Ph(a,ki){var Cn=0,En=0,Fn=0,Gn=0,Hn=0,In=0,Jn=0,Kn=0,Ln=0,Mn=0,Nn=0,On=0,Pn=0;a:{Cn=s[ki+38>>1];if(!Cn){break a}Jn=a+12|0;b:{if(Cn>>>0<=511){En=q[ki+12>>2];Cn=q[ki+20>>2];Fn=q[ki+16>>2];Hn=Fn+4|0;if(Hn>>>0<4){Cn=Cn+1|0}if((En|0)<(Cn|0)?1:(En|0)<=(Cn|0)?t[ki+8>>2]>=Hn>>>0?0:1:0){break a}Cn=Fn+q[ki>>2]|0;Fn=r[Cn|0]|r[Cn+1|0]<<8|(r[Cn+2|0]<<16|r[Cn+3|0]<<24);q[Jn>>2]=Fn;En=q[ki+20>>2];Hn=q[ki+16>>2]+4|0;if(Hn>>>0<4){En=En+1|0}Cn=ki;q[Cn+16>>2]=Hn;q[Cn+20>>2]=En;break b}if(!Ch(1,Jn,ki)){break a}Fn=q[Jn>>2]}En=q[a>>2];Cn=q[a+4>>2]-En>>2;c:{if(Fn>>>0>Cn>>>0){Fa(a,Fn-Cn|0);Fn=q[a+12>>2];break c}if(Fn>>>0>=Cn>>>0){break c}q[a+4>>2]=En+(Fn<<2)}if(!Fn){Pn=1;break a}Nn=q[ki+8>>2];Hn=q[ki+12>>2];while(1){Gn=q[ki+16>>2];Cn=q[ki+20>>2];if((Hn|0)<(Cn|0)?1:(Hn|0)<=(Cn|0)?Nn>>>0>Gn>>>0?0:1:0){break a}On=q[ki>>2];Kn=r[On+Gn|0];Gn=Gn+1|0;if(Gn>>>0<1){Cn=Cn+1|0}q[ki+16>>2]=Gn;q[ki+20>>2]=Cn;Ln=Kn>>>2;d:{e:{f:{Mn=Kn&3;if(Mn>>>0>3){En=0;break f}En=0;g:{switch(Mn-1|0){case 0:case 1:break f;case 2:break g;default:break e}}Cn=In+Ln|0;if(Cn>>>0>=Fn>>>0){return 0}Dn(q[a>>2]+(In<<2)|0,0,(Kn&252)+4|0);In=Cn;break d}while(1){if((Hn|0)<(Cn|0)?1:(Hn|0)<=(Cn|0)?Nn>>>0>Gn>>>0?0:1:0){return 0}Kn=r[Gn+On|0];Gn=Gn+1|0;if(Gn>>>0<1){Cn=Cn+1|0}q[ki+16>>2]=Gn;q[ki+20>>2]=Cn;Ln=Kn<<(En<<3|6)|Ln;En=En+1|0;if((Mn|0)!=(En|0)){continue}break}}q[q[a>>2]+(In<<2)>>2]=Ln}In=In+1|0;Fn=q[Jn>>2];if(In>>>0>>0){continue}break}In=a+16|0;Jn=q[a>>2];ki=q[a+16>>2];Cn=q[a+20>>2]-ki|0;En=Cn>>2;h:{if(En>>>0<=1048575){Fa(In,1048576-En|0);break h}if((Cn|0)==4194304){break h}q[a+20>>2]=ki+4194304}i:{ki=a+28|0;Cn=q[ki>>2];En=q[a+32>>2]-Cn>>3;if(Fn>>>0>En>>>0){Dh(ki,Fn-En|0);Cn=q[ki>>2];break i}if(Fn>>>0>>0){q[a+32>>2]=(Fn<<3)+Cn}if(Fn){break i}return 0}ki=0;En=0;while(1){a=Jn+(ki<<2)|0;Hn=q[a>>2];Gn=(ki<<3)+Cn|0;q[Gn+4>>2]=En;q[Gn>>2]=Hn;a=q[a>>2]+En|0;if(a>>>0>1048576){break a}if(En>>>0>>0){Hn=q[In>>2];while(1){q[Hn+(En<<2)>>2]=ki;En=En+1|0;if((a|0)!=(En|0)){continue}break}}En=a;ki=ki+1|0;if((Fn|0)!=(ki|0)){continue}break}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];break c}if((Dn|0)<3){break a}q[a+44>>2]=Dn+ -3;a=(Dn+Sn|0)+ -3|0;a=r[a+1|0]<<8|r[a+2|0]<<16&4128768|r[a|0];break c}q[a+44>>2]=Dn+ -4;a=(Dn+Sn|0)+ -4|0;a=r[a+2|0]<<16|r[a+3|0]<<24&1056964608|r[a+1|0]<<8|r[a|0]}a=a+4194304|0;q[ki+48>>2]=a;Xn=a>>>0<1073741824}T=Tn+16|0;return Xn}function Rh(a){Ij(a);q[a+44>>2]=0;q[a>>2]=11068}function Sh(a){a=a|0;if(q[a+44>>2]){return n[q[q[a>>2]+48>>2]](a)|0}return 0}function Th(a){a=a|0;var ki=0,Yn=0,Zn=0,_n=0,$n=0;q[a>>2]=13300;ki=q[a+20>>2];if(ki){q[a+24>>2]=ki;An(ki)}Zn=q[a+8>>2];if(Zn){ki=Zn;$n=a+12|0;Yn=q[$n>>2];_n=ki;a:{if((ki|0)==(Yn|0)){break a}while(1){Yn=Yn+ -4|0;ki=q[Yn>>2];q[Yn>>2]=0;if(ki){n[q[q[ki>>2]+4>>2]](ki)}if((Yn|0)!=(Zn|0)){continue}break}_n=q[a+8>>2]}ki=_n;q[$n>>2]=Zn;An(ki)}return a|0}function Uh(a,ao){a=a|0;ao=ao|0;a=q[a+48>>2];return n[q[q[a>>2]+20>>2]](a,ao)|0}function Vh(a){a=a|0;var ao=0,bo=0,co=0,eo=0;ao=q[a+32>>2];co=q[ao+16>>2];eo=q[ao+12>>2];bo=q[ao+20>>2];if((eo|0)>(bo|0)?1:(eo|0)>=(bo|0)?t[ao+8>>2]<=co>>>0?0:1:0){eo=r[co+q[ao>>2]|0];co=co+1|0;if(co>>>0<1){bo=bo+1|0}q[ao+16>>2]=co;q[ao+20>>2]=bo;ao=q[a+48>>2];q[a+48>>2]=0;if(ao){n[q[q[ao>>2]+4>>2]](ao)}a:{b:{if(eo>>>0>2){break b}c:{switch(eo-1|0){default:bo=Mm(384);bi(bo);ao=q[a+48>>2];q[a+48>>2]=bo;if(!ao){break a}n[q[q[ao>>2]+4>>2]](ao);break b;case 0:bo=Mm(424);Ei(bo);ao=q[a+48>>2];q[a+48>>2]=bo;if(!ao){break a}n[q[q[ao>>2]+4>>2]](ao);break b;case 1:break c}}bo=Mm(440);Ji(bo);ao=q[a+48>>2];q[a+48>>2]=bo;if(!ao){break a}n[q[q[ao>>2]+4>>2]](ao)}bo=q[a+48>>2];if(bo){break a}return 0}a=n[q[q[bo>>2]+8>>2]](bo,a)|0}else{a=0}return a|0}function Wh(a){a=a|0;a=q[a+48>>2];return n[q[q[a>>2]+24>>2]](a)|0}function Xh(a){a=a|0;a=q[a+48>>2];return n[q[q[a>>2]+28>>2]](a)|0}function Yh(a){a=a|0;var fo=0,go=0,ho=0,io=0,jo=0;q[a>>2]=11164;fo=a+48|0;go=q[fo>>2];q[fo>>2]=0;if(go){n[q[q[go>>2]+4>>2]](go)}q[a>>2]=13300;fo=q[a+20>>2];if(fo){q[a+24>>2]=fo;An(fo)}go=q[a+8>>2];if(go){fo=go;jo=a+12|0;ho=q[jo>>2];io=fo;a:{if((fo|0)==(ho|0)){break a}while(1){ho=ho+ -4|0;fo=q[ho>>2];q[ho>>2]=0;if(fo){n[q[q[fo>>2]+4>>2]](fo)}if((go|0)!=(ho|0)){continue}break}io=q[a+8>>2]}fo=io;q[jo>>2]=go;An(fo)}return a|0}function Zh(a){a=a|0;var ko=0,lo=0,mo=0,no=0,oo=0;q[a>>2]=11164;ko=a+48|0;lo=q[ko>>2];q[ko>>2]=0;if(lo){n[q[q[lo>>2]+4>>2]](lo)}q[a>>2]=13300;ko=q[a+20>>2];if(ko){q[a+24>>2]=ko;An(ko)}lo=q[a+8>>2];if(lo){ko=lo;oo=a+12|0;mo=q[oo>>2];no=ko;a:{if((ko|0)==(mo|0)){break a}while(1){mo=mo+ -4|0;ko=q[mo>>2];q[mo>>2]=0;if(ko){n[q[q[ko>>2]+4>>2]](ko)}if((lo|0)!=(mo|0)){continue}break}no=q[a+8>>2]}ko=no;q[oo>>2]=lo;An(ko)}An(a)}function _h(a){a=a|0;a=q[a+48>>2];return n[q[q[a>>2]+36>>2]](a)|0}function $h(a,po){a=a|0;po=po|0;a=q[a+48>>2];return n[q[q[a>>2]+12>>2]](a,po)|0}function ai(a,po){a=a|0;po=po|0;a=q[a+48>>2];return n[q[q[a>>2]+16>>2]](a,po)|0}function bi(a){q[a>>2]=11272;Dn(a+4|0,0,80);q[a+96>>2]=0;q[a+100>>2]=0;q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+104>>2]=0;q[a+108>>2]=0;q[a+112>>2]=0;q[a+116>>2]=0;q[a+120>>2]=0;q[a+124>>2]=0;q[a+128>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0;q[a+144>>2]=0;q[a+148>>2]=0;q[a+156>>2]=0;q[a+160>>2]=0;q[a+152>>2]=1065353216;q[a+164>>2]=0;q[a+168>>2]=0;q[a+172>>2]=0;q[a+176>>2]=0;q[a+180>>2]=0;q[a+184>>2]=0;q[a+188>>2]=0;q[a+192>>2]=0;q[a+196>>2]=0;q[a+200>>2]=0;q[a+204>>2]=0;q[a+208>>2]=0;q[a+212>>2]=-1;q[a+216>>2]=0;q[a+220>>2]=0;q[a+224>>2]=0;ci(a+232|0)}function ci(a){Yj(a);Yj(a+40|0);ah(a+80|0);Yj(a+96|0);q[a+144>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0}function di(a,po){a=a|0;po=po|0;q[a+4>>2]=po;return 1}function ei(a,po){a=a|0;po=po|0;var qo=0,ro=0,so=0,to=0,uo=0;qo=q[a+216>>2];to=a+220|0;if((qo|0)!=q[to>>2]){while(1){a:{qo=q[w(so,144)+qo>>2];if((qo|0)<0){break a}uo=q[a+4>>2];ro=q[uo+8>>2];if((qo|0)>=q[uo+12>>2]-ro>>2){break a}qo=q[ro+(qo<<2)>>2];if((n[q[q[qo>>2]+24>>2]](qo)|0)<1){break a}ro=0;while(1){if((n[q[q[qo>>2]+20>>2]](qo,ro)|0)!=(po|0)){ro=ro+1|0;if((ro|0)<(n[q[q[qo>>2]+24>>2]](qo)|0)){continue}break a}break}a=q[a+216>>2]+w(so,144)|0;return(r[a+100|0]?a+4|0:0)|0}so=so+1|0;qo=q[a+216>>2];if(so>>>0<(q[to>>2]-qo|0)/144>>>0){continue}break}}return 0}function fi(a,po){a=a|0;po=po|0;var vo=0,wo=0,xo=0,yo=0,zo=0;vo=q[a+216>>2];yo=a+220|0;if((vo|0)!=q[yo>>2]){while(1){a:{vo=q[w(xo,144)+vo>>2];if((vo|0)<0){break a}zo=q[a+4>>2];wo=q[zo+8>>2];if((vo|0)>=q[zo+12>>2]-wo>>2){break a}vo=q[wo+(vo<<2)>>2];if((n[q[q[vo>>2]+24>>2]](vo)|0)<1){break a}wo=0;while(1){if((n[q[q[vo>>2]+20>>2]](vo,wo)|0)!=(po|0)){wo=wo+1|0;if((wo|0)<(n[q[q[vo>>2]+24>>2]](vo)|0)){continue}break a}break}return(q[a+216>>2]+w(xo,144)|0)+104|0}xo=xo+1|0;vo=q[a+216>>2];if(xo>>>0<(q[yo>>2]-vo|0)/144>>>0){continue}break}}return a+184|0}function gi(a,po){a=a|0;po=po|0;var Ao=0,Bo=0,Co=0,Do=0,Eo=0,Fo=0,Go=0,Ho=0,Io=0,Jo=0,Ko=0,Lo=0,Mo=0,No=0,Oo=0;Do=T-80|0;T=Do;a:{b:{Mo=q[a+4>>2];Ao=q[Mo+32>>2];Io=q[Ao+8>>2];Ho=q[Ao+16>>2];Ko=q[Ao+12>>2];Bo=Ko;Fo=q[Ao+20>>2];Eo=Fo;c:{if((Bo|0)<(Eo|0)?1:(Bo|0)<=(Eo|0)?Io>>>0>Ho>>>0?0:1:0){break c}No=q[Ao>>2];Jo=r[No+Ho|0];Bo=Fo;Go=Ho+1|0;if(Go>>>0<1){Bo=Bo+1|0}Eo=Ao;q[Ao+16>>2]=Go;q[Ao+20>>2]=Bo;if((Ko|0)<(Bo|0)?1:(Ko|0)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=q[Ho>>2];break i}Bo=q[Ho>>2];if(Bo){An(Bo);q[Ao+52>>2]=0;q[Ao+44>>2]=0;q[Ao+48>>2]=0;Co=q[Do+56>>2]}if((Co|0)<=-1){break a}Bo=Co+ -1>>>5;Eo=Bo+1|0;Co=Mm(Eo<<2);q[Ao+52>>2]=Eo;q[Ao+48>>2]=0;q[Ao+44>>2]=Co}En(Co,q[Do+52>>2],(Bo<<2)+4|0);Bo=q[Do+56>>2]}else{Bo=0}q[Fo+48>>2]=Bo;vd(Mo,q[Do+64>>2],q[Do+68>>2]);q[Do+16>>2]=11760;Fo=q[Do+64>>2];if(Fo){q[Do+68>>2]=Fo;An(Fo)}q[Do+16>>2]=12012;Fo=q[Do+52>>2];if(Fo){An(Fo)}Fo=q[Do+40>>2];if(!Fo){break e}An(Fo);break e}ii(Do+16|0,a,Ao)}Ao=q[Do+16>>2];if(!Ao){break c}}Fo=Mm(64);q[Do+8>>2]=Ao;Ge(Fo,Do+8|0);Ao=q[Do+8>>2];q[Do+8>>2]=0;if(Ao){n[q[q[Ao>>2]+4>>2]](Ao)}if((po|0)>=0){a=q[a+4>>2];Co=a+8|0;Ao=q[a+12>>2];Jo=q[a+8>>2];Bo=Ao-Jo>>2;j:{if((Bo|0)>(po|0)){break j}Eo=po+1|0;if(Bo>>>0<=po>>>0){ji(Co,Eo-Bo|0);break j}if(Eo>>>0>=Bo>>>0){break j}Eo=Jo+(Eo<<2)|0;if((Eo|0)!=(Ao|0)){while(1){Ao=Ao+ -4|0;Bo=q[Ao>>2];q[Ao>>2]=0;if(Bo){n[q[q[Bo>>2]+4>>2]](Bo)}if((Ao|0)!=(Eo|0)){continue}break}}q[a+12>>2]=Eo}po=q[Co>>2]+(po<<2)|0;a=q[po>>2];q[po>>2]=Fo;Co=1;if(!a){break c}n[q[q[a>>2]+4>>2]](a);break c}n[q[q[Fo>>2]+4>>2]](Fo);Co=0}T=Do+80|0;return Co|0}bn();F()}bn();F()}function hi(a,po,Po){var Qo=0,Ro=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a:{b:{Po=Ro;po=q[Qo+28>>2];if(po){So=Ro+32|0;c:{if(po>>>0<=q[Ro+40>>2]<<5>>>0){To=po+ -1>>>5;po=q[So>>2];break c}So=q[So>>2];if(So){An(So);q[Ro+40>>2]=0;q[Ro+32>>2]=0;q[Ro+36>>2]=0;po=q[Qo+28>>2]}if((po|0)<=-1){break b}To=po+ -1>>>5;So=To+1|0;po=Mm(So<<2);q[Ro+40>>2]=So;q[Ro+36>>2]=0;q[Ro+32>>2]=po}En(po,q[Qo+24>>2],(To<<2)+4|0);po=q[Qo+28>>2]}else{po=0}q[Po+36>>2]=po;Xo=Ro;po=q[Wo>>2];if(po){d:{if(po>>>0<=q[Ro+52>>2]<<5>>>0){Po=po+ -1>>>5;po=q[Uo>>2];break d}Po=q[Uo>>2];if(Po){An(Po);q[Ro+52>>2]=0;q[Ro+44>>2]=0;q[Ro+48>>2]=0;po=q[Qo+40>>2]}if((po|0)<=-1){break a}Po=po+ -1>>>5;To=Po+1|0;po=Mm(To<<2);q[Ro+52>>2]=To;q[Ro+48>>2]=0;q[Ro+44>>2]=po}En(po,q[Qo+36>>2],(Po<<2)+4|0);po=q[Qo+40>>2]}else{po=0}q[Xo+48>>2]=po;vd(_o,q[Qo+48>>2],q[Qo+52>>2]);q[a>>2]=Ro;q[Qo>>2]=12756;a=q[Qo+48>>2];if(a){q[Qo+52>>2]=a;An(a)}q[Qo>>2]=12572;a=q[Qo+36>>2];if(a){An(a)}a=q[Qo+24>>2];if(a){An(a)}T=Qo- -64|0;return}bn();F()}bn();F()}function ii(a,po,Po){var ap=0,bp=0,cp=0,dp=0,ep=0,fp=0,gp=0;ap=T-112|0;T=ap;gp=q[q[po+4>>2]+44>>2];bp=Mm(120);q[bp>>2]=12124;q[bp+116>>2]=0;q[bp+112>>2]=Po;q[bp+108>>2]=gp;q[bp+12>>2]=0;q[bp+16>>2]=0;q[bp+4>>2]=0;q[bp+20>>2]=0;q[bp+24>>2]=0;q[bp+28>>2]=0;q[bp+32>>2]=0;q[bp+36>>2]=0;q[bp+40>>2]=0;q[bp+44>>2]=0;q[bp+48>>2]=0;q[bp+52>>2]=0;q[bp+56>>2]=0;q[bp+60>>2]=0;q[bp+8>>2]=12336;ep=bp- -64|0;q[ep>>2]=0;q[ep+4>>2]=0;q[bp+72>>2]=0;q[bp+76>>2]=0;q[bp+80>>2]=0;q[bp+84>>2]=0;q[bp+88>>2]=0;q[bp+104>>2]=0;q[bp+96>>2]=0;q[bp+100>>2]=0;po=q[po+8>>2];q[ap+48>>2]=0;q[ap+52>>2]=0;q[ap+40>>2]=0;q[ap+44>>2]=0;ep=ap+24|0;cp=ep;q[cp>>2]=0;q[cp+4>>2]=0;cp=ap- -64|0;q[cp>>2]=0;q[cp+4>>2]=0;q[ap+72>>2]=0;q[ap+76>>2]=0;cp=ap+80|0;q[cp>>2]=0;q[cp+4>>2]=0;q[ap+88>>2]=0;q[ap+104>>2]=0;q[ap+32>>2]=0;q[ap+36>>2]=0;q[ap+16>>2]=0;q[ap+20>>2]=0;q[ap+56>>2]=0;q[ap+60>>2]=0;q[ap+8>>2]=12336;q[ap+96>>2]=0;q[ap+100>>2]=0;q[ap+12>>2]=po;dp=q[po>>2];fp=q[po+4>>2];o[ap+111|0]=0;bb(ap+32|0,(fp-dp>>2>>>0)/3|0,ap+111|0);dp=q[ap+12>>2];fp=q[dp+28>>2];dp=q[dp+24>>2];o[ap+111|0]=0;bb(ap+44|0,fp-dp>>2,ap+111|0);q[ap+28>>2]=bp;q[ep>>2]=gp;q[ap+20>>2]=Po;q[ap+16>>2]=po;ki(bp,ap+8|0);q[a>>2]=bp;q[ap+8>>2]=12336;a=q[ap+96>>2];if(a){q[ap+100>>2]=a;An(a)}a=q[cp>>2];if(a){q[ap+84>>2]=a;An(a)}a=q[ap+68>>2];if(a){q[ap+72>>2]=a;An(a)}a=q[ap+56>>2];if(a){q[ap+60>>2]=a;An(a)}q[ap+8>>2]=12572;a=q[ap+44>>2];if(a){An(a)}a=q[ap+32>>2];if(a){An(a)}T=ap+112|0}function ji(a,po){var Po=0,hp=0,ip=0,jp=0,kp=0,lp=0,mp=0,np=0,op=0;hp=q[a+8>>2];ip=a+4|0;Po=q[ip>>2];if(hp-Po>>2>>>0>=po>>>0){a=po<<2;np=ip,op=Dn(Po,0,a)+a|0,q[np>>2]=op;return}a:{ip=q[a>>2];jp=Po-ip>>2;kp=jp+po|0;if(kp>>>0<1073741824){jp=jp<<2;hp=hp-ip|0;mp=hp>>1;hp=hp>>2>>>0<536870911?mp>>>0>>0?kp:mp:1073741823;if(hp){if(hp>>>0>=1073741824){break a}lp=Mm(hp<<2)}jp=jp+lp|0;Dn(jp,0,po<<2);po=(kp<<2)+lp|0;kp=(hp<<2)+lp|0;if((Po|0)!=(ip|0)){while(1){Po=Po+ -4|0;hp=q[Po>>2];q[Po>>2]=0;jp=jp+ -4|0;q[jp>>2]=hp;if((Po|0)!=(ip|0)){continue}break}ip=q[a>>2];Po=q[a+4>>2]}q[a>>2]=jp;q[a+8>>2]=kp;q[a+4>>2]=po;if((Po|0)!=(ip|0)){while(1){Po=Po+ -4|0;a=q[Po>>2];q[Po>>2]=0;if(a){n[q[q[a>>2]+4>>2]](a)}if((Po|0)!=(ip|0)){continue}break}}if(ip){An(ip)}return}bn();F()}ab(12024);F()}function ki(a,po){var pp=0;pp=q[po+8>>2];q[a+12>>2]=q[po+4>>2];q[a+16>>2]=pp;q[a+28>>2]=q[po+20>>2];pp=q[po+16>>2];q[a+20>>2]=q[po+12>>2];q[a+24>>2]=pp;$i(a+32|0,po+24|0);$i(a+44|0,po+36|0);if((a+8|0)==(po|0)){q[a+92>>2]=q[po+84>>2];return}vd(a+56|0,q[po+48>>2],q[po+52>>2]);vd(a+68|0,q[po+60>>2],q[po- -64>>2]);vd(a+80|0,q[po+72>>2],q[po+76>>2]);q[a+92>>2]=q[po+84>>2];hd(a+96|0,q[po+88>>2],q[po+92>>2])}function li(a,po,qp){a=a|0;po=po|0;qp=qp|0;var rp=0,sp=0;rp=T-16|0;T=rp;q[a+4>>2]=po;po=q[po+64>>2];sp=q[po+4>>2];po=q[po>>2];o[rp+15|0]=0;bb(a+24|0,(sp-po>>2>>>0)/3|0,rp+15|0);po=q[a+4>>2];sp=q[po+56>>2];po=q[po+52>>2];o[rp+14|0]=0;bb(a+36|0,sp-po>>2,rp+14|0);po=q[qp+12>>2];q[a+16>>2]=q[qp+8>>2];q[a+20>>2]=po;po=q[qp+4>>2];q[a+8>>2]=q[qp>>2];q[a+12>>2]=po;T=rp+16|0}function mi(a){a=a|0;var po=0;q[a>>2]=11760;po=q[a+48>>2];if(po){q[a+52>>2]=po;An(po)}q[a>>2]=12012;po=q[a+36>>2];if(po){An(po)}po=q[a+24>>2];if(po){An(po)}return a|0}function ni(a){a=a|0;var qp=0,tp=0,up=0,vp=0,wp=0,xp=0,yp=0,zp=0,Ap=0,Bp=0,Cp=0,Dp=0,Ep=0,Fp=0,Gp=0;zp=T+ -64|0;T=zp;q[a+132>>2]=0;if(q[a+148>>2]){up=a+144|0;tp=q[up>>2];if(tp){while(1){qp=q[tp>>2];An(tp);tp=qp;if(qp){continue}break}}q[up>>2]=0;qp=q[a+140>>2];if(qp){up=a+136|0;tp=0;while(1){q[q[up>>2]+(tp<<2)>>2]=0;tp=tp+1|0;if((qp|0)!=(tp|0)){continue}break}}q[a+148>>2]=0}a:{b:{c:{d:{e:{f:{tp=q[a+4>>2];up=r[tp+36|0];qp=up<<8|r[tp+37|0];g:{if(qp>>>0>513){break g}xp=q[tp+32>>2];if(qp>>>0<=511){wp=q[xp+12>>2];qp=q[xp+20>>2];yp=q[xp+16>>2];vp=yp+4|0;if(vp>>>0<4){qp=qp+1|0}Ap=vp;vp=qp;if((wp|0)<(qp|0)?1:(wp|0)<=(qp|0)?t[xp+8>>2]>=Ap>>>0?0:1:0){break f}qp=yp+q[xp>>2]|0;qp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp>>2]=qp;q[xp+16>>2]=Ap;q[xp+20>>2]=vp;q[a+132>>2]=qp;break g}if(!oi(1,zp,xp)){break f}tp=q[a+4>>2];up=r[tp+36|0];q[a+132>>2]=q[zp>>2]}tp=q[tp+32>>2];h:{i:{j:{if((up&255)>>>0<=1){up=0;xp=q[tp+12>>2];qp=q[tp+20>>2];wp=q[tp+16>>2];vp=wp+4|0;if(vp>>>0<4){qp=qp+1|0}yp=vp;vp=qp;if((xp|0)<(qp|0)?1:(xp|0)<=(qp|0)?t[tp+8>>2]>=yp>>>0?0:1:0){break a}qp=wp+q[tp>>2]|0;qp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+60>>2]=qp;q[tp+16>>2]=yp;q[tp+20>>2]=vp;q[a+156>>2]=qp;Dp=a+156|0;break j}up=0;if(!oi(1,zp+60|0,tp)){break a}qp=q[a+4>>2];tp=q[qp+32>>2];qp=r[qp+36|0];q[a+156>>2]=q[zp+60>>2];Dp=a+156|0;if(qp>>>0>1){break i}}xp=q[tp+12>>2];qp=q[tp+20>>2];wp=q[tp+16>>2];vp=wp+4|0;if(vp>>>0<4){qp=qp+1|0}Ap=vp;vp=qp;if((xp|0)<(qp|0)?1:(xp|0)<=(qp|0)?t[tp+8>>2]>=Ap>>>0?0:1:0){break a}qp=wp+q[tp>>2]|0;yp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+56>>2]=yp;q[tp+16>>2]=Ap;q[tp+20>>2]=vp;break h}if(!oi(1,zp+56|0,tp)){break a}yp=q[zp+56>>2]}if(yp>>>0>1431655765|t[Dp>>2]>w(yp,3)>>>0){break a}Bp=q[a+4>>2];vp=q[Bp+32>>2];Fp=q[vp+8>>2];Cp=q[vp+16>>2];xp=q[vp+12>>2];qp=xp;tp=q[vp+20>>2];if((qp|0)<(tp|0)?1:(qp|0)<=(tp|0)?Fp>>>0>Cp>>>0?0:1:0){break a}Gp=q[vp>>2];Ap=r[Gp+Cp|0];qp=tp;Ep=Cp+1|0;if(Ep>>>0<1){qp=qp+1|0}q[vp+16>>2]=Ep;q[vp+20>>2]=qp;k:{if(r[Bp+36|0]<=1){qp=tp;tp=Cp+5|0;if(tp>>>0<5){qp=qp+1|0}wp=tp;tp=qp;if((xp|0)<(qp|0)?1:(xp|0)<=(qp|0)?Fp>>>0>=wp>>>0?0:1:0){break a}qp=Ep+Gp|0;xp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+52>>2]=xp;q[vp+16>>2]=wp;q[vp+20>>2]=tp;break k}if(!oi(1,zp+52|0,vp)){break a}xp=q[zp+52>>2]}if(yp>>>0>>0|yp>>>0>((xp>>>0)/3|0)+xp>>>0){break a}qp=q[a+4>>2];vp=q[qp+32>>2];l:{if(r[qp+36|0]<=1){wp=q[vp+12>>2];qp=q[vp+20>>2];Cp=q[vp+16>>2];tp=Cp+4|0;if(tp>>>0<4){qp=qp+1|0}Bp=tp;tp=qp;if((wp|0)<(qp|0)?1:(wp|0)<=(qp|0)?t[vp+8>>2]>=Bp>>>0?0:1:0){break a}qp=Cp+q[vp>>2]|0;wp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+48>>2]=wp;q[vp+16>>2]=Bp;q[vp+20>>2]=tp;break l}if(!oi(1,zp+48|0,vp)){break a}wp=q[zp+48>>2]}if(wp>>>0>xp>>>0){break a}q[a+28>>2]=q[a+24>>2];tp=Mm(88);jk(tp);qp=q[a+8>>2];q[a+8>>2]=tp;vp=a+8|0;if(qp){wa(vp,qp);if(!q[vp>>2]){break a}}qp=q[a+160>>2];q[a+164>>2]=qp;m:{if(q[a+168>>2]-qp>>2>>>0>=yp>>>0){break m}if(yp>>>0>=1073741824){break e}up=yp<<2;tp=Mm(up);q[a+164>>2]=tp;q[a+160>>2]=tp;q[a+168>>2]=tp+up;if(!qp){break m}An(qp)}qp=q[a+172>>2];q[a+176>>2]=qp;n:{if(q[a+180>>2]-qp>>2>>>0>=yp>>>0){break n}if(yp>>>0>=1073741824){break d}up=yp<<2;tp=Mm(up);q[a+176>>2]=tp;q[a+172>>2]=tp;q[a+180>>2]=tp+up;if(!qp){break n}An(qp)}q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+40>>2]=q[a+36>>2];q[a- -64>>2]=0;q[a+52>>2]=q[a+48>>2];q[a+76>>2]=q[a+72>>2];Cp=a+216|0;tp=q[a+220>>2];up=q[a+216>>2];if((tp|0)==(up|0)){break c}while(1){qp=q[tp+ -12>>2];if(qp){q[tp+ -8>>2]=qp;An(qp)}qp=q[tp+ -28>>2];if(qp){q[tp+ -24>>2]=qp;An(qp)}qp=tp+ -144|0;Bp=q[tp+ -40>>2];if(Bp){q[tp+ -36>>2]=Bp;An(Bp)}pi(tp+ -140|0);tp=qp;if((up|0)!=(qp|0)){continue}break}qp=q[Cp>>2];break b}up=0;break a}ab(12024);F()}ab(12024);F()}qp=up}q[a+220>>2]=up;tp=(up-qp|0)/144|0;o:{if(tp>>>0>>0){qi(Cp,Ap-tp|0);break o}if(tp>>>0<=Ap>>>0){break o}tp=qp+w(Ap,144)|0;if((tp|0)!=(up|0)){while(1){qp=q[up+ -12>>2];if(qp){q[up+ -8>>2]=qp;An(qp)}qp=q[up+ -28>>2];if(qp){q[up+ -24>>2]=qp;An(qp)}qp=up+ -144|0;Bp=q[up+ -40>>2];if(Bp){q[up+ -36>>2]=Bp;An(Bp)}pi(up+ -140|0);up=qp;if((qp|0)!=(tp|0)){continue}break}}q[a+220>>2]=tp}up=0;if(!tk(q[vp>>2],yp,q[Dp>>2]+wp|0)){break a}qp=q[a+156>>2];o[zp|0]=1;bb(a+120|0,qp+wp|0,zp);tp=q[a+4>>2];qp=s[tp+36>>1];qp=(qp<<24|qp<<8&16711680)>>>16;p:{if(qp>>>0<=513){wp=q[tp+32>>2];q:{if(qp>>>0<=511){yp=q[wp+12>>2];qp=q[wp+20>>2];Dp=q[wp+16>>2];tp=Dp+4|0;if(tp>>>0<4){qp=qp+1|0}Bp=tp;tp=qp;if((yp|0)<(qp|0)?1:(yp|0)<=(qp|0)?t[wp+8>>2]>=Bp>>>0?0:1:0){break a}qp=Dp+q[wp>>2]|0;yp=r[qp|0]|r[qp+1|0]<<8|(r[qp+2|0]<<16|r[qp+3|0]<<24);q[zp+44>>2]=yp;q[wp+16>>2]=Bp;q[wp+20>>2]=tp;break q}if(!oi(1,zp+44|0,wp)){break a}yp=q[zp+44>>2]}if(!yp){break a}qp=q[q[a+4>>2]+32>>2];tp=q[qp+8>>2];wp=q[qp+16>>2];qp=q[qp+12>>2]-(q[qp+20>>2]+(tp>>>0>>0)|0)|0;if((qp|0)<0?1:(qp|0)<=0?tp-wp>>>0>=yp>>>0?0:1:0){break a}wp=Yj(zp);tp=q[q[a+4>>2]+32>>2];qp=q[tp+16>>2];Dp=q[tp+8>>2];Zj(wp,(qp+q[tp>>2]|0)+yp|0,(Dp-qp|0)-yp|0,s[tp+38>>1]);tp=ri(a,wp);if((tp|0)==-1){break a}qp=tp;wp=qp>>31;break p}qp=-1;wp=-1;if((ri(a,q[tp+32>>2])|0)==-1){break a}}q[a+376>>2]=a;Dp=a+232|0;tp=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];Bp=q[tp>>2]+q[tp+16>>2]|0;yp=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];tp=q[yp+8>>2];up=q[yp+16>>2];Zj(Dp,Bp,tp-up|0,s[q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);q[a+372>>2]=Ap;up=0;tp=Yj(zp);r:{if(!si(Dp,tp)){break r}yp=ti(a,xp);if((yp|0)==-1){break r}xp=q[q[a+4>>2]+32>>2];up=q[tp+16>>2];Ap=up+q[tp>>2]|0;tp=q[tp+8>>2];Zj(xp,Ap,tp-up|0,s[xp+38>>1]);tp=q[a+4>>2];up=s[tp+36>>1];xp=(up<<24|up<<8&16711680)>>>16;if(xp>>>0<=513){up=q[tp+32>>2];Ap=up;Bp=up;tp=wp+q[up+20>>2]|0;up=qp+q[up+16>>2]|0;if(up>>>0>>0){tp=tp+1|0}q[Bp+16>>2]=up;q[Ap+20>>2]=tp}s:{if(q[a+220>>2]==q[a+216>>2]){break s}tp=q[vp>>2];qp=q[tp+4>>2];tp=q[tp>>2];t:{if(xp>>>0>=513){if((qp|0)==(tp|0)){break s}tp=0;break t}if((qp|0)==(tp|0)){break s}tp=0;while(1){if(ui(a,tp)){tp=tp+3|0;qp=q[vp>>2];if(tp>>>0>2]-q[qp>>2]>>2>>>0){continue}break s}break}up=0;break r}while(1){if(vi(a,tp)){tp=tp+3|0;qp=q[vp>>2];if(tp>>>0>2]-q[qp>>2]>>2>>>0){continue}break s}break}up=0;break r}if(r[a+308|0]){ak(a+272|0)}if(s[a+270>>1]<=513){ak(a+328|0)}tp=q[a+216>>2];wp=a+220|0;if((tp|0)!=q[wp>>2]){xp=0;while(1){qp=w(xp,144);Ek((qp+tp|0)+4|0,q[vp>>2]);up=q[Cp>>2];Ap=qp+up|0;tp=q[Ap+132>>2];Ap=q[Ap+136>>2];if((tp|0)!=(Ap|0)){while(1){Gk((qp+up|0)+4|0,q[tp>>2]);up=q[Cp>>2];tp=tp+4|0;if((Ap|0)!=(tp|0)){continue}break}}Fk((qp+up|0)+4|0);xp=xp+1|0;tp=q[a+216>>2];if(xp>>>0<(q[wp>>2]-tp|0)/144>>>0){continue}break}}qp=q[a+8>>2];wi(a+184|0,q[qp+28>>2]-q[qp+24>>2]>>2);up=q[a+216>>2];if((up|0)!=q[wp>>2]){tp=0;xp=a+220|0;while(1){qp=w(tp,144)+up|0;up=q[qp+60>>2]-q[qp+56>>2]>>2;Ap=qp+104|0;qp=q[vp>>2];qp=q[qp+28>>2]-q[qp+24>>2]>>2;wi(Ap,(up|0)<(qp|0)?qp:up);tp=tp+1|0;up=q[a+216>>2];if(tp>>>0<(q[xp>>2]-up|0)/144>>>0){continue}break}}up=xi(a,yp)}}T=z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ip|0;if(Np>>>0>=29826162){break b}q[Op+24>>2]=a+8;Qp=0;q[Op+20>>2]=0;Pp=(Pp-Rp|0)/144|0;Rp=Pp<<1;Pp=Pp>>>0<14913080?Rp>>>0>>0?Np:Rp:29826161;if(Pp){if(Pp>>>0>=29826162){break a}Qp=Mm(w(Pp,144))}q[Op+8>>2]=Qp;Np=w(Sp,144)+Qp|0;q[Op+16>>2]=Np;q[Op+20>>2]=w(Pp,144)+Qp;q[Op+12>>2]=Np;while(1){q[Np>>2]=-1;Dk(Np+4|0);q[Np+104>>2]=0;q[Np+108>>2]=0;o[Np+100|0]=1;q[Np+112>>2]=0;q[Np+116>>2]=0;q[Np+120>>2]=0;q[Np+124>>2]=0;q[Np+128>>2]=0;q[Np+132>>2]=0;q[Np+136>>2]=0;q[Np+140>>2]=0;Np=q[Op+16>>2]+144|0;q[Op+16>>2]=Np;Ip=Ip+ -1|0;if(Ip){continue}break}Ip=q[a+4>>2];Pp=q[a>>2];d:{if((Ip|0)==(Pp|0)){Qp=q[Op+12>>2];break d}Qp=q[Op+12>>2];while(1){Ip=Ip+ -144|0;Qp=vj(Qp+ -144|0,Ip);if((Ip|0)!=(Pp|0)){continue}break}q[Op+12>>2]=Qp;Ip=q[a+4>>2];Pp=q[a>>2]}q[a>>2]=Qp;q[Op+12>>2]=Pp;q[a+4>>2]=Np;q[Op+16>>2]=Ip;a=a+8|0;Ip=q[a>>2];q[a>>2]=q[Op+20>>2];q[Op+8>>2]=Pp;q[Op+20>>2]=Ip;wj(Op+8|0)}T=Op+32|0;return}bn();F()}ab(12024);F()}function ri(a,Ip){var Tp=0,Up=0,Vp=0,Wp=0,Xp=0,Yp=0,Zp=0,_p=0,$p=0,aq=0,bq=0,cq=0,dq=0,eq=0,fq=0,gq=0;Vp=T-32|0;T=Vp;a:{b:{if(r[q[a+4>>2]+36|0]<=1){Zp=-1;Xp=q[Ip+12>>2];Tp=q[Ip+20>>2];Wp=q[Ip+16>>2];Up=Wp+4|0;if(Up>>>0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0)==(iq|0)&hq>>>0<=lq>>>0|oq>>>0>>0){break b}}hq=0;break a}kq=mq+oq|0;jq=hq+jq|0;if(jq>>>0>>0){kq=kq+1|0}q[a+16>>2]=jq;q[a+20>>2]=kq;c:{if(s[a+38>>1]<=513){hq=q[a+4>>2];q[a+96>>2]=q[a>>2];q[a+100>>2]=hq;jq=a+32|0;hq=jq;iq=q[hq+4>>2];q[a+128>>2]=q[hq>>2];q[a+132>>2]=iq;iq=a+24|0;hq=iq;kq=q[hq+4>>2];q[a+120>>2]=q[hq>>2];q[a+124>>2]=kq;kq=a+16|0;hq=kq;lq=q[hq+4>>2];q[a+112>>2]=q[hq>>2];q[a+116>>2]=lq;lq=a+8|0;hq=lq;mq=q[hq+4>>2];q[a+104>>2]=q[hq>>2];q[a+108>>2]=mq;d:{hq=a+96|0;if(_j(hq,1,nq+8|0)){mq=q[hq+4>>2];q[a>>2]=q[hq>>2];q[a+4>>2]=mq;mq=q[hq+36>>2];q[jq>>2]=q[hq+32>>2];q[jq+4>>2]=mq;jq=q[hq+28>>2];q[iq>>2]=q[hq+24>>2];q[iq+4>>2]=jq;iq=q[hq+20>>2];mq=iq;jq=q[hq+16>>2];q[kq>>2]=jq;q[kq+4>>2]=iq;iq=q[hq+12>>2];kq=iq;hq=q[hq+8>>2];q[lq>>2]=hq;q[lq+4>>2]=iq;iq=jq;lq=hq-iq|0;oq=q[nq+12>>2];iq=kq-((hq>>>0>>0)+mq|0)|0;hq=q[nq+8>>2];if((oq|0)==(iq|0)&hq>>>0<=lq>>>0|oq>>>0>>0){break d}}hq=0;break a}kq=mq+oq|0;jq=hq+jq|0;if(jq>>>0>>0){kq=kq+1|0}q[a+16>>2]=jq;q[a+20>>2]=kq;break c}hq=0;if(!bh(a+80|0,a)){break a}}hq=0;if(!Ai(a)){break a}hq=q[a+4>>2];q[Ip>>2]=q[a>>2];q[Ip+4>>2]=hq;hq=q[a+36>>2];q[Ip+32>>2]=q[a+32>>2];q[Ip+36>>2]=hq;hq=q[a+28>>2];q[Ip+24>>2]=q[a+24>>2];q[Ip+28>>2]=hq;hq=q[a+20>>2];q[Ip+16>>2]=q[a+16>>2];q[Ip+20>>2]=hq;hq=q[a+12>>2];q[Ip+8>>2]=q[a+8>>2];q[Ip+12>>2]=hq;hq=1}T=nq+16|0;return hq}function ti(a,Ip){var pq=0,qq=0,rq=0,sq=0,tq=0,uq=0,vq=0,wq=0,xq=0,yq=0,zq=0,Aq=0,Bq=0,Cq=0,Dq=0,Eq=0,Fq=0,Gq=0,Hq=0,Iq=0,Jq=0,Kq=0,Lq=0;sq=T-96|0;T=sq;q[sq+72>>2]=0;q[sq+64>>2]=0;q[sq+68>>2]=0;q[sq+48>>2]=0;q[sq+52>>2]=0;q[sq+40>>2]=0;q[sq+44>>2]=0;q[sq+56>>2]=1065353216;q[sq+32>>2]=0;q[sq+24>>2]=0;q[sq+28>>2]=0;Jq=q[a+124>>2];a:{b:{c:{d:{if((Ip|0)>=1){Iq=a+8|0;Fq=q[a+216>>2]!=q[a+220>>2];Gq=a+40|0;while(1){e:{f:{g:{h:{i:{j:{k:{if(!r[a+308|0]){break k}l:{m:{wq=q[a+296>>2];yq=q[a+304>>2];pq=wq+(yq>>>3)|0;uq=q[a+300>>2];if(pq>>>0>=uq>>>0){break m}pq=r[pq|0];qq=yq+1|0;q[a+304>>2]=qq;if(!(pq>>>(yq&7)&1)){break m}pq=qq>>>3;rq=wq+pq|0;n:{if(rq>>>0>=uq>>>0){rq=qq;qq=0;break n}vq=r[rq|0];rq=yq+2|0;q[a+304>>2]=rq;pq=rq>>>3;qq=vq>>>(qq&7)&1}pq=pq+wq|0;if(pq>>>0>>0){pq=r[pq|0];q[a+304>>2]=rq+1;pq=pq>>>(rq&7)<<1&2}else{pq=0}pq=(qq|pq)<<1|1;switch(pq+ -2|0){case 0:case 2:case 4:break h;case 5:break j;case 1:case 3:break l;default:break k}}qq=q[sq+68>>2];if((qq|0)==q[sq+64>>2]){break d}wq=-1;Aq=q[Iq>>2];u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11312);Aq=q[rq>>2]}rq=-1;qq=q[Iq>>2];yq=q[qq+24>>2];if(q[qq+28>>2]-yq>>2>(Jq|0)){break c}rq=zq+2|0;Bq=q[qq>>2];xq=Bq+pq|0;qq=Aq-q[vq>>2]|0;pq=(qq>>2)+ -1|0;q[xq>>2]=pq;if(qq){q[yq+(pq<<2)>>2]=uq}rq=wq?zq:rq;qq=Bq+(wq+zq<<2)|0;t:{u:{v:{if((Cq|0)!=-1){pq=Cq+((Cq>>>0)%3|0?-1:2)|0;if((pq|0)==-1){break v}pq=q[Bq+(pq<<2)>>2];q[Bq+(rq<<2)>>2]=pq;if((pq|0)==-1){break u}q[yq+(pq<<2)>>2]=rq;break u}q[Bq+(rq<<2)>>2]=-1;rq=-1;break t}q[Bq+(rq<<2)>>2]=-1}pq=Cq+1|0;pq=(pq>>>0)%3|0?pq:Cq+ -2|0;rq=-1;if((pq|0)==-1){break t}rq=q[Bq+(pq<<2)>>2]}q[qq>>2]=rq;q[q[sq+68>>2]+ -4>>2]=zq;break i}rq=-1;pq=q[sq+68>>2];Aq=q[sq+64>>2];if((pq|0)==(Aq|0)){break c}qq=pq+ -4|0;Eq=q[qq>>2];q[sq+68>>2]=qq;zq=q[sq+44>>2];w:{if(!zq){pq=qq;break w}uq=q[sq+40>>2];yq=co(zq)>>>0>1;vq=zq+2147483647&tq;x:{if(!yq){break x}vq=tq;if(tq>>>0>>0){break x}vq=(tq>>>0)%(zq>>>0)|0}uq=q[uq+(vq<<2)>>2];if(!uq){pq=qq;break w}xq=q[uq>>2];if(!xq){pq=qq;break w}uq=zq+ -1|0;y:{while(1){wq=q[xq+4>>2];z:{if((wq|0)!=(tq|0)){A:{if(!yq){wq=wq&uq;break A}if(wq>>>0>>0){break A}wq=(wq>>>0)%(zq>>>0)|0}if((wq|0)==(vq|0)){break z}pq=qq;break w}if(q[xq+8>>2]==(tq|0)){break y}}xq=q[xq>>2];if(xq){continue}break}pq=qq;break w}vq=xq+12|0;if((qq|0)!=q[sq+72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>>2];qq=uq+28|0;vq=q[qq>>2];D:{if((vq|0)!=q[uq+32>>2]){q[vq>>2]=-1;wq=vq+4|0;q[qq>>2]=wq;break D}zi(uq+24|0,11312);wq=q[qq>>2]}q[q[uq>>2]+(pq<<2)>>2]=(wq-q[uq+24>>2]>>2)+ -1;pq=q[Iq>>2];qq=q[pq+24>>2];if(q[pq+28>>2]-qq>>2>(Jq|0)){break d}pq=q[sq>>2];E:{F:{if(!yq){wq=1;q[qq+(zq<<2)>>2]=pq+1;break F}q[qq+(rq<<2)>>2]=pq;wq=0;if((yq|0)==-4){break F}q[qq+(zq<<2)>>2]=q[sq>>2]+1;wq=zq+1|0;if((wq|0)==-1){break E}}q[qq+(wq<<2)>>2]=q[sq>>2]+2}pq=q[sq+68>>2];if((pq|0)!=q[sq+72>>2]){q[pq>>2]=q[sq>>2];q[sq+68>>2]=pq+4;break i}zi(sq- -64|0,sq)}xq=q[Gq>>2];if((xq|0)==q[a+36>>2]){break e}uq=(tq^-1)+Ip|0;while(1){rq=-1;pq=q[xq+ -8>>2];if(pq>>>0>uq>>>0){break c}if((pq|0)!=(uq|0)){break e}qq=r[xq+ -4|0];pq=xq+ -12|0;vq=q[pq>>2];q[Gq>>2]=pq;if((vq|0)<0){break c}rq=q[q[sq+68>>2]+ -4>>2];q[sq+20>>2]=(vq^-1)+Ip;q[sq+88>>2]=sq+20;Bi(sq,sq+40|0,sq+20|0,sq+88|0);vq=q[sq>>2];G:{if(qq&1){pq=-1;if((rq|0)==-1){break G}pq=rq+1|0;pq=(pq>>>0)%3|0?pq:rq+ -2|0;break G}pq=-1;if((rq|0)==-1){break G}pq=rq+ -1|0;if((rq>>>0)%3){break G}pq=rq+2|0}q[vq+12>>2]=pq;xq=q[Gq>>2];if((xq|0)!=q[a+36>>2]){continue}break}break e}F()}wq=-1;vq=q[Hq>>2];q[vq+(Cq<<2)>>2]=-1}q[uq+vq>>2]=rq;H:{I:{J:{if(!yq){qq=Eq+((Eq>>>0)%3|0?-1:2)|0;if((qq|0)==-1){break J}qq=q[(qq<<2)+vq>>2];q[vq+Bq>>2]=qq;if((qq|0)==-1){break I}q[q[Hq+24>>2]+(qq<<2)>>2]=Aq;break I}q[vq+Bq>>2]=-1;xq=-1;rq=-1;break H}q[vq+Bq>>2]=-1}xq=-1;qq=Eq+1|0;qq=(qq>>>0)%3|0?qq:Eq+ -2|0;rq=-1;if((qq|0)==-1){break H}xq=q[(qq<<2)+vq>>2];rq=qq}q[sq>>2]=xq;uq=q[Hq+24>>2];if((wq|0)!=-1){q[uq+(wq<<2)>>2]=q[uq+(xq<<2)>>2]}K:{if((rq|0)==-1){break K}vq=q[Hq>>2];while(1){q[vq+(rq<<2)>>2]=wq;qq=rq+1|0;qq=(qq>>>0)%3|0?qq:rq+ -2|0;if((qq|0)==-1){break K}rq=q[q[zq>>2]+(qq<<2)>>2];if((rq|0)==-1){break K}qq=rq+1|0;rq=(qq>>>0)%3|0?qq:rq+ -2|0;if((rq|0)!=-1){continue}break}}q[uq+(q[sq>>2]<<2)>>2]=-1;L:{if(Fq){break L}qq=q[sq+28>>2];if((qq|0)!=q[sq+32>>2]){q[qq>>2]=q[sq>>2];q[sq+28>>2]=qq+4;break L}zi(sq+24|0,sq);pq=q[sq+68>>2]}q[pq+ -4>>2]=Cq}tq=tq+1|0;if((tq|0)!=(Ip|0)){continue}break}wq=Ip}rq=-1;xq=q[a+8>>2];if(q[xq+28>>2]-q[xq+24>>2]>>2>(Jq|0)){break c}tq=q[sq+68>>2];if((tq|0)!=q[sq+64>>2]){Dq=a+72|0;qq=a+60|0;Aq=a+312|0;Fq=a+8|0;Cq=a+68|0;Jq=a+80|0;Hq=a+76|0;while(1){pq=tq+ -4|0;Ip=q[pq>>2];q[sq+68>>2]=pq;q[sq>>2]=Ip;M:{N:{O:{P:{if(s[a+270>>1]<=513){if(!r[a+364|0]){break O}pq=q[a+360>>2];Ip=q[a+352>>2]+(pq>>>3)|0;if(Ip>>>0>=t[a+356>>2]){break N}Ip=r[Ip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2];Kq=vq,Lq=eo(tq)&pq,q[Kq>>2]=Lq;Ip=(Gq|0)!=-1?q[zq>>2]:Ip;vq=Bq+(Ip>>>3&536870908)|0;pq=q[vq>>2];Kq=vq,Lq=eo(Ip)&pq,q[Kq>>2]=Lq;tq=-1;tq=(yq|0)!=-1?q[uq>>2]:tq;pq=Bq+(tq>>>3&536870908)|0;Ip=q[pq>>2];Kq=pq,Lq=eo(tq)&Ip,q[Kq>>2]=Lq;tq=q[a+64>>2];pq=q[Cq>>2];if((tq|0)==pq<<5){if((tq+1|0)<=-1){break a}Ip=qq;if(tq>>>0<=1073741822){vq=tq+32&-32;pq=pq<<6;pq=pq>>>0>>0?vq:pq}else{pq=2147483647}cb(Ip,pq);tq=q[a+64>>2]}wq=wq+1|0;q[a+64>>2]=tq+1;Ip=q[a+60>>2]+(tq>>>3&536870908)|0;q[Ip>>2]=q[Ip>>2]|1<<(tq&31);Ip=q[Hq>>2];if((Ip|0)!=q[Jq>>2]){q[Ip>>2]=q[sq+88>>2];q[Hq>>2]=Ip+4;break M}zi(Dq,sq+88|0);break M}tq=q[a+64>>2];pq=q[Cq>>2];if((tq|0)==pq<<5){if((tq+1|0)<=-1){break a}Ip=qq;if(tq>>>0<=1073741822){vq=tq+32&-32;pq=pq<<6;pq=pq>>>0>>0?vq:pq}else{pq=2147483647}cb(Ip,pq);tq=q[a+64>>2]}q[a+64>>2]=tq+1;pq=q[a+60>>2]+(tq>>>3&536870908)|0;Ip=q[pq>>2];Kq=pq,Lq=eo(tq)&Ip,q[Kq>>2]=Lq;Ip=q[Hq>>2];if((Ip|0)!=q[Jq>>2]){q[Ip>>2]=q[sq>>2];q[Hq>>2]=Ip+4;break M}zi(Dq,sq)}tq=q[sq+68>>2];if((tq|0)!=q[sq+64>>2]){continue}break}xq=q[a+8>>2]}if(((q[xq+4>>2]-q[xq>>2]>>2>>>0)/3|0)!=(wq|0)){break c}rq=q[xq+28>>2]-q[xq+24>>2]>>2;Fq=q[sq+24>>2];uq=q[sq+28>>2];if((Fq|0)==(uq|0)){break b}vq=a+8|0;while(1){zq=q[Fq>>2];wq=q[xq+24>>2];tq=rq+ -1|0;T:{if(q[wq+(tq<<2)>>2]!=-1){pq=rq;break T}wq=q[xq+24>>2];while(1){tq=rq+ -2|0;pq=rq+ -1|0;rq=pq;if(q[(tq<<2)+wq>>2]==-1){continue}break}}if(!(tq>>>0>>0)){q[sq>>2]=xq;Ip=tq<<2;rq=q[Ip+wq>>2];o[sq+12|0]=1;q[sq+8>>2]=rq;q[sq+4>>2]=rq;if((rq|0)!=-1){while(1){q[q[xq>>2]+(rq<<2)>>2]=zq;lg(sq);xq=q[vq>>2];rq=q[sq+8>>2];if((rq|0)!=-1){continue}break}}qq=Ip;Ip=q[xq+24>>2];qq=qq+Ip|0;if((zq|0)!=-1){q[Ip+(zq<<2)>>2]=q[qq>>2]}q[qq>>2]=-1;yq=1<<(zq&31);Ip=q[a+120>>2];rq=Ip+(zq>>>3&536870908)|0;qq=rq;wq=Ip+(tq>>>3&536870908)|0;Ip=1<<(tq&31);tq=yq|q[rq>>2];U:{if(q[wq>>2]&Ip){break U}tq=q[rq>>2]&(yq^-1)}q[qq>>2]=tq;q[wq>>2]=q[wq>>2]&(Ip^-1);pq=pq+ -1|0}rq=pq;Fq=Fq+4|0;if((uq|0)!=(Fq|0)){continue}break}break c}rq=-1}Fq=q[sq+24>>2]}if(Fq){q[sq+28>>2]=Fq;An(Fq)}tq=q[sq+48>>2];if(tq){while(1){a=q[tq>>2];An(tq);tq=a;if(tq){continue}break}}a=q[sq+40>>2];q[sq+40>>2]=0;if(a){An(a)}a=q[sq+64>>2];if(a){q[sq+68>>2]=a;An(a)}T=sq+96|0;return rq}bn();F()}function ui(a,Ip){var Mq=0,Nq=0,Oq=0,Pq=0,Qq=0,Rq=0,Sq=0,Tq=0,Uq=0,Vq=0,Wq=0;Nq=T-32|0;T=Nq;q[Nq+16>>2]=Ip;Mq=-1;a:{if((Ip|0)==-1){q[Nq+20>>2]=-1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Xq=Ip+2|0}q[Yq+24>>2]=Xq;er=(Ip|0)==-1?-1:(Ip>>>0)/3|0;ar=a+220|0;fr=a+8|0;gr=a+368|0;while(1){b:{c:{if((Ip|0)!=-1){Xq=q[q[q[fr>>2]+12>>2]+(Ip<<2)>>2];if((Xq|0)!=-1){break c}}Xq=0;Zq=q[a+216>>2];_q=q[ar>>2];if((Zq|0)==(_q|0)){break b}while(1){q[Yq+12>>2]=Ip;$q=w(Xq,144)+Zq|0;dr=$q+136|0;br=q[dr>>2];d:{if(br>>>0>2]){q[br>>2]=Ip;q[dr>>2]=br+4;break d}ya($q+132|0,Yq+12|0);_q=q[ar>>2];Zq=q[a+216>>2]}Xq=Xq+1|0;if(Xq>>>0<(_q-Zq|0)/144>>>0){continue}break}break b}if((Xq>>>0)/3>>>0>>0){break b}Xq=0;if(q[ar>>2]==q[a+216>>2]){break b}while(1){e:{if(!dh(q[gr>>2]+(Xq<<4)|0)){break e}Zq=q[a+216>>2];q[Yq+12>>2]=Ip;Zq=Zq+w(Xq,144)|0;$q=Zq+136|0;_q=q[$q>>2];if(_q>>>0>2]){q[_q>>2]=Ip;q[$q>>2]=_q+4;break e}ya(Zq+132|0,Yq+12|0)}Xq=Xq+1|0;if(Xq>>>0<(q[ar>>2]-q[a+216>>2]|0)/144>>>0){continue}break}}cr=cr+1|0;if((cr|0)!=3){Ip=q[(Yq+16|0)+(cr<<2)>>2];continue}break}T=Yq+32|0;return 1}function wi(a,Ip){var hr=0,ir=0,jr=0,kr=0,lr=0;ir=q[a+12>>2];hr=q[a+16>>2]-ir>>2;a:{if(hr>>>0>>0){Fa(a+12|0,Ip-hr|0);break a}if(hr>>>0<=Ip>>>0){break a}q[a+16>>2]=ir+(Ip<<2)}b:{hr=q[a>>2];c:{if(q[a+8>>2]-hr>>2>>>0>=Ip>>>0){break c}if(Ip>>>0>=1073741824){break b}kr=a+4|0;ir=q[kr>>2];jr=Ip<<2;Ip=Mm(jr);jr=Ip+jr|0;ir=ir-hr|0;lr=ir+Ip|0;if((ir|0)>=1){Cn(Ip,hr,ir)}q[a>>2]=Ip;q[a+8>>2]=jr;q[kr>>2]=lr;if(!hr){break c}An(hr)}return}ab(12024);F()}function xi(a,Ip){var mr=0,nr=0,or=0,pr=0,qr=0,rr=0,sr=0,tr=0,ur=0,vr=0,wr=0,xr=0,yr=0,zr=0,Ar=0,Br=0;nr=T-48|0;T=nr;mr=q[a+8>>2];or=q[mr>>2];qr=q[mr+4>>2];mr=q[q[a+4>>2]+44>>2];q[nr+40>>2]=0;q[nr+32>>2]=0;q[nr+36>>2]=0;or=(qr-or>>2>>>0)/3|0;pr=q[mr+96>>2];qr=(q[mr+100>>2]-pr|0)/12|0;a:{if(or>>>0>qr>>>0){Ci(mr+96|0,or-qr|0,nr+32|0);break a}if(or>>>0>=qr>>>0){break a}q[mr+100>>2]=pr+w(or,12)}b:{if(q[a+216>>2]==q[a+220>>2]){ur=q[a+4>>2];mr=q[ur+44>>2];or=q[mr+100>>2];sr=q[mr+96>>2];if((or|0)!=(sr|0)){vr=(or-sr|0)/12|0;wr=nr+40|0;mr=0;while(1){q[wr>>2]=0;q[nr+32>>2]=0;q[nr+36>>2]=0;qr=nr;c:{d:{e:{pr=w(mr,3);if((pr|0)==-1){or=-1;q[nr+32>>2]=-1;rr=0;break e}or=q[q[q[a+8>>2]>>2]+(pr<<2)>>2];q[nr+32>>2]=or;rr=pr+1|0;if((rr|0)!=-1){break e}q[nr+36>>2]=-1;pr=0;break d}q[nr+36>>2]=q[q[q[a+8>>2]>>2]+(rr<<2)>>2];pr=pr+2|0;xr=-1;if((pr|0)==-1){break c}}xr=q[q[q[a+8>>2]>>2]+(pr<<2)>>2]}q[qr+40>>2]=xr;qr=sr+w(mr,12)|0;q[qr>>2]=or;q[qr+4>>2]=q[nr+36>>2];q[qr+8>>2]=q[nr+40>>2];mr=mr+1|0;if(mr>>>0>>0){continue}break}}q[q[ur+4>>2]+80>>2]=Ip;mr=1;break b}q[nr+40>>2]=0;q[nr+32>>2]=0;q[nr+36>>2]=0;pr=q[a+8>>2];Ip=q[pr>>2];mr=q[pr+4>>2];q[nr+24>>2]=0;q[nr+16>>2]=0;q[nr+20>>2]=0;f:{g:{h:{Ip=mr-Ip|0;if(Ip){or=Ip>>2;if(or>>>0>=1073741824){break h}mr=Mm(Ip);q[nr+16>>2]=mr;q[nr+24>>2]=mr+(or<<2);Ar=nr,Br=Dn(mr,0,Ip)+Ip|0,q[Ar+20>>2]=Br}if((q[pr+28>>2]-q[pr+24>>2]|0)<1){break g}ur=a+220|0;vr=a+8|0;while(1){or=q[q[pr+24>>2]+(sr<<2)>>2];i:{if((or|0)==-1){break i}j:{if(q[q[a+120>>2]+(sr>>>3&536870908)>>2]>>>(sr&31)&1){break j}Ip=q[ur>>2];wr=q[a+216>>2];if((Ip|0)==(wr|0)){break j}xr=(Ip-wr|0)/144|0;yr=((or>>>0)%3|0?-1:2)+or|0;rr=0;while(1){zr=or<<2;tr=wr+w(rr,144)|0;Ip=q[zr+q[q[tr+68>>2]>>2]>>2];k:{if(!(q[q[tr+16>>2]+(Ip>>>3&536870908)>>2]>>>(Ip&31)&1)){break k}Ip=or;mr=-1;l:{if((yr|0)==-1){break l}qr=q[q[pr+12>>2]+(yr<<2)>>2];mr=-1;if((qr|0)==-1){break l}mr=qr+ -1|0;if((qr>>>0)%3){break l}mr=qr+2|0}if((Ip|0)==(mr|0)){break k}tr=q[tr+32>>2];zr=q[tr+zr>>2];while(1){Ip=0;if((mr|0)==-1){break f}if((zr|0)!=q[tr+(mr<<2)>>2]){or=mr;break j}qr=or;mr=((mr>>>0)%3|0?-1:2)+mr|0;Ip=-1;m:{if((mr|0)==-1){break m}mr=q[q[pr+12>>2]+(mr<<2)>>2];Ip=-1;if((mr|0)==-1){break m}Ip=mr+ -1|0;if((mr>>>0)%3){break m}Ip=mr+2|0}mr=Ip;if((qr|0)!=(mr|0)){continue}break}}rr=rr+1|0;if(rr>>>0>>0){continue}break}}Ip=q[nr+36>>2];q[q[nr+16>>2]+(or<<2)>>2]=Ip-q[nr+32>>2]>>2;q[nr>>2]=or;n:{if(t[nr+40>>2]>Ip>>>0){q[Ip>>2]=or;q[nr+36>>2]=Ip+4;break n}ya(nr+32|0,nr);pr=q[vr>>2]}if((or|0)==-1){break i}Ip=((or>>>0)%3|0?-1:2)+or|0;if((Ip|0)==-1){break i}Ip=q[q[pr+12>>2]+(Ip<<2)>>2];if((Ip|0)==-1){break i}mr=Ip+((Ip>>>0)%3|0?-1:2)|0;if((mr|0)==-1){break i}qr=or;if((mr|0)==(or|0)){break i}while(1){Ip=mr;o:{p:{mr=q[ur>>2];rr=q[a+216>>2];if((mr|0)==(rr|0)){break p}wr=(mr-rr|0)/144|0;mr=0;while(1){yr=q[(rr+w(mr,144)|0)+32>>2];tr=Ip<<2;if(q[yr+tr>>2]==q[yr+(qr<<2)>>2]){mr=mr+1|0;if(mr>>>0>>0){continue}break p}break}mr=q[nr+36>>2];q[tr+q[nr+16>>2]>>2]=mr-q[nr+32>>2]>>2;q[nr>>2]=Ip;if(t[nr+40>>2]>mr>>>0){q[mr>>2]=Ip;q[nr+36>>2]=mr+4;break o}ya(nr+32|0,nr);pr=q[vr>>2];break o}mr=q[nr+16>>2];q[mr+(Ip<<2)>>2]=q[mr+(qr<<2)>>2]}if((Ip|0)==-1){break i}mr=Ip+((Ip>>>0)%3|0?-1:2)|0;if((mr|0)==-1){break i}mr=q[q[pr+12>>2]+(mr<<2)>>2];if((mr|0)==-1){break i}mr=mr+((mr>>>0)%3|0?-1:2)|0;if((mr|0)==-1){break i}qr=Ip;if((mr|0)!=(or|0)){continue}break}}sr=sr+1|0;if((sr|0)>2]-q[pr+24>>2]>>2){continue}break}break g}bn();F()}or=q[a+4>>2];a=q[or+44>>2];Ip=q[a+100>>2];a=q[a+96>>2];if((Ip|0)!=(a|0)){qr=(Ip-a|0)/12|0;mr=0;pr=q[nr+16>>2];while(1){sr=nr+8|0;rr=w(mr,12);Ip=rr+pr|0;q[sr>>2]=q[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>0>=1073741824){break a}Ir=Mm(Jr<<2)}Lr=Nr+Ir|0;q[Lr>>2]=q[Ip>>2];Ip=Ir+(Jr<<2)|0;Jr=Lr+4|0;if((Mr|0)>=1){Cn(Ir,Kr,Mr)}q[a>>2]=Ir;q[a+8>>2]=Ip;q[a+4>>2]=Jr;if(Kr){An(Kr)}return}bn();F()}ab(12024);F()}function Ai(a){var Ip=0,Or=0,Pr=0,Qr=0;Or=1;Pr=q[a+140>>2];a:{if((Pr|0)<1){break a}Ip=Pr<<4;Or=Mm((Pr|0)!=(Pr&268435455)?-1:Ip|4);q[Or>>2]=Pr;Or=Or+4|0;Pr=Or+Ip|0;Ip=Or;while(1){Ip=ah(Ip)+16|0;if((Pr|0)!=(Ip|0)){continue}break}Qr=q[a+136>>2];q[a+136>>2]=Or;if(Qr){Pr=Qr+ -4|0;Or=q[Pr>>2];if(Or){Ip=Qr+(Or<<4)|0;while(1){Ip=Ip+ -16|0;if((Qr|0)!=(Ip|0)){continue}break}}An(Pr)}Or=1;if(q[a+140>>2]<1){break a}Or=0;Ip=0;while(1){if(!bh(q[a+136>>2]+(Ip<<4)|0,a)){break a}Ip=Ip+1|0;if((Ip|0)>2]){continue}break}Or=1}return Or}function Bi(a,Rr,Sr,Tr){var Ur=0,Vr=0,Wr=0,Xr=0,Yr=0,Zr=x(0),_r=0,$r=x(0),as=0;Ur=q[Sr>>2];as=a;a:{b:{Vr=q[Rr+4>>2];if(!Vr){break b}_r=q[Rr>>2];Xr=co(Vr);Sr=Vr+ -1&Ur;c:{if(Xr>>>0<=1){break c}Sr=Ur;if(Ur>>>0>>0){break c}Sr=(Ur>>>0)%(Vr>>>0)|0}Wr=Sr;Sr=q[(Sr<<2)+_r>>2];if(!Sr){break b}_r=Vr+ -1|0;Xr=Xr>>>0>1;while(1){Sr=q[Sr>>2];if(!Sr){break b}Yr=q[Sr+4>>2];if((Yr|0)!=(Ur|0)){d:{if(!Xr){Yr=Yr&_r;break d}if(Yr>>>0>>0){break d}Yr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r){continue}break c}}cs=q[a>>2];es=(Tr-cs|0)/12|0;bs=es+Rr|0;if(bs>>>0>=357913942){break b}ds=(ds-cs|0)/12|0;cs=ds<<1;bs=ds>>>0<178956970?cs>>>0>>0?bs:cs:357913941;Tr=0;d:{if(!bs){break d}if(bs>>>0>=357913942){break a}Tr=Mm(w(bs,12))}ds=Tr+w(bs,12)|0;bs=Tr+w(es,12)|0;Tr=bs;while(1){cs=q[Sr+4>>2];q[Tr>>2]=q[Sr>>2];q[Tr+4>>2]=cs;q[Tr+8>>2]=q[Sr+8>>2];Tr=Tr+12|0;Rr=Rr+ -1|0;if(Rr){continue}break}cs=a+4|0;Rr=q[a>>2];Sr=q[cs>>2]-Rr|0;bs=bs+w((Sr|0)/-12|0,12)|0;if((Sr|0)>=1){Cn(bs,Rr,Sr)}q[a>>2]=bs;q[a+8>>2]=ds;q[cs>>2]=Tr;if(!Rr){break c}An(Rr)}return}bn();F()}ab(12024);F()}function Di(a){a=a|0;return q[a+8>>2]}function Ei(a){q[a>>2]=11324;Dn(a+4|0,0,80);q[a+96>>2]=0;q[a+100>>2]=0;q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+104>>2]=0;q[a+108>>2]=0;q[a+112>>2]=0;q[a+116>>2]=0;q[a+120>>2]=0;q[a+124>>2]=0;q[a+128>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0;q[a+144>>2]=0;q[a+148>>2]=0;q[a+156>>2]=0;q[a+160>>2]=0;q[a+152>>2]=1065353216;q[a+164>>2]=0;q[a+168>>2]=0;q[a+172>>2]=0;q[a+176>>2]=0;q[a+180>>2]=0;q[a+184>>2]=0;q[a+188>>2]=0;q[a+192>>2]=0;q[a+196>>2]=0;q[a+200>>2]=0;q[a+204>>2]=0;q[a+208>>2]=0;q[a+212>>2]=-1;q[a+216>>2]=0;q[a+220>>2]=0;q[a+224>>2]=0;ci(a+232|0);q[a+396>>2]=0;q[a+388>>2]=0;q[a+392>>2]=0;q[a+380>>2]=0;q[a+384>>2]=0;ah(a+400|0);q[a+416>>2]=-1;q[a+420>>2]=-1}function Fi(a){a=a|0;var Rr=0,Sr=0,fs=0,gs=0,hs=0,is=0,js=0,ks=0,ls=0,ms=0,ns=0,os=0,ps=0,qs=0,rs=0,ss=0,ts=0;ks=T+ -64|0;T=ks;q[a+132>>2]=0;if(q[a+148>>2]){fs=a+144|0;Sr=q[fs>>2];if(Sr){while(1){Rr=q[Sr>>2];An(Sr);Sr=Rr;if(Rr){continue}break}}q[fs>>2]=0;Rr=q[a+140>>2];if(Rr){fs=a+136|0;Sr=0;while(1){q[q[fs>>2]+(Sr<<2)>>2]=0;Sr=Sr+1|0;if((Rr|0)!=(Sr|0)){continue}break}}q[a+148>>2]=0}a:{b:{c:{d:{e:{f:{Sr=q[a+4>>2];fs=r[Sr+36|0];Rr=fs<<8|r[Sr+37|0];g:{if(Rr>>>0>513){break g}is=q[Sr+32>>2];if(Rr>>>0<=511){gs=q[is+12>>2];Rr=q[is+20>>2];js=q[is+16>>2];hs=js+4|0;if(hs>>>0<4){Rr=Rr+1|0}ls=hs;hs=Rr;if((gs|0)<(Rr|0)?1:(gs|0)<=(Rr|0)?t[is+8>>2]>=ls>>>0?0:1:0){break f}Rr=js+q[is>>2]|0;Rr=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks>>2]=Rr;q[is+16>>2]=ls;q[is+20>>2]=hs;q[a+132>>2]=Rr;break g}if(!oi(1,ks,is)){break f}Sr=q[a+4>>2];fs=r[Sr+36|0];q[a+132>>2]=q[ks>>2]}Sr=q[Sr+32>>2];h:{i:{j:{if((fs&255)>>>0<=1){fs=0;is=q[Sr+12>>2];Rr=q[Sr+20>>2];gs=q[Sr+16>>2];hs=gs+4|0;if(hs>>>0<4){Rr=Rr+1|0}js=hs;hs=Rr;if((is|0)<(Rr|0)?1:(is|0)<=(Rr|0)?t[Sr+8>>2]>=js>>>0?0:1:0){break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+3|0]<<24);q[ks+52>>2]=is;q[hs+16>>2]=gs;q[hs+20>>2]=Sr;break k}if(!oi(1,ks+52|0,hs)){break a}is=q[ks+52>>2]}if(js>>>0>>0|js>>>0>((is>>>0)/3|0)+is>>>0){break a}Rr=q[a+4>>2];hs=q[Rr+32>>2];l:{if(r[Rr+36|0]<=1){gs=q[hs+12>>2];Rr=q[hs+20>>2];ms=q[hs+16>>2];Sr=ms+4|0;if(Sr>>>0<4){Rr=Rr+1|0}os=Sr;Sr=Rr;if((gs|0)<(Rr|0)?1:(gs|0)<=(Rr|0)?t[hs+8>>2]>=os>>>0?0:1:0){break a}Rr=ms+q[hs>>2]|0;ms=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks+48>>2]=ms;q[hs+16>>2]=os;q[hs+20>>2]=Sr;break l}if(!oi(1,ks+48|0,hs)){break a}ms=q[ks+48>>2]}if(ms>>>0>is>>>0){break a}q[a+28>>2]=q[a+24>>2];Sr=Mm(88);jk(Sr);Rr=q[a+8>>2];q[a+8>>2]=Sr;hs=a+8|0;if(Rr){wa(hs,Rr);if(!q[hs>>2]){break a}}Rr=q[a+160>>2];q[a+164>>2]=Rr;m:{if(q[a+168>>2]-Rr>>2>>>0>=js>>>0){break m}if(js>>>0>=1073741824){break e}fs=js<<2;Sr=Mm(fs);q[a+164>>2]=Sr;q[a+160>>2]=Sr;q[a+168>>2]=Sr+fs;if(!Rr){break m}An(Rr)}Rr=q[a+172>>2];q[a+176>>2]=Rr;n:{if(q[a+180>>2]-Rr>>2>>>0>=js>>>0){break n}if(js>>>0>=1073741824){break d}fs=js<<2;Sr=Mm(fs);q[a+176>>2]=Sr;q[a+172>>2]=Sr;q[a+180>>2]=Sr+fs;if(!Rr){break n}An(Rr)}q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+40>>2]=q[a+36>>2];q[a- -64>>2]=0;q[a+52>>2]=q[a+48>>2];q[a+76>>2]=q[a+72>>2];os=a+216|0;Sr=q[a+220>>2];fs=q[a+216>>2];if((Sr|0)==(fs|0)){break c}while(1){Rr=q[Sr+ -12>>2];if(Rr){q[Sr+ -8>>2]=Rr;An(Rr)}Rr=q[Sr+ -28>>2];if(Rr){q[Sr+ -24>>2]=Rr;An(Rr)}Rr=Sr+ -144|0;gs=q[Sr+ -40>>2];if(gs){q[Sr+ -36>>2]=gs;An(gs)}pi(Sr+ -140|0);Sr=Rr;if((fs|0)!=(Rr|0)){continue}break}Rr=q[os>>2];break b}fs=0;break a}ab(12024);F()}ab(12024);F()}Rr=fs}q[a+220>>2]=fs;Sr=(fs-Rr|0)/144|0;o:{if(Sr>>>0>>0){qi(os,ls-Sr|0);break o}if(Sr>>>0<=ls>>>0){break o}Sr=Rr+w(ls,144)|0;if((Sr|0)!=(fs|0)){while(1){Rr=q[fs+ -12>>2];if(Rr){q[fs+ -8>>2]=Rr;An(Rr)}Rr=q[fs+ -28>>2];if(Rr){q[fs+ -24>>2]=Rr;An(Rr)}Rr=fs+ -144|0;gs=q[fs+ -40>>2];if(gs){q[fs+ -36>>2]=gs;An(gs)}pi(fs+ -140|0);fs=Rr;if((Rr|0)!=(Sr|0)){continue}break}}q[a+220>>2]=Sr}fs=0;if(!tk(q[hs>>2],js,q[ns>>2]+ms|0)){break a}Rr=q[a+156>>2];o[ks|0]=1;bb(a+120|0,Rr+ms|0,ks);Sr=q[a+4>>2];Rr=s[Sr+36>>1];Rr=(Rr<<24|Rr<<8&16711680)>>>16;p:{if(Rr>>>0<=513){gs=q[Sr+32>>2];q:{if(Rr>>>0<=511){js=q[gs+12>>2];Rr=q[gs+20>>2];ns=q[gs+16>>2];Sr=ns+4|0;if(Sr>>>0<4){Rr=Rr+1|0}ps=Sr;Sr=Rr;if((js|0)<(Rr|0)?1:(js|0)<=(Rr|0)?t[gs+8>>2]>=ps>>>0?0:1:0){break a}Rr=ns+q[gs>>2]|0;js=r[Rr|0]|r[Rr+1|0]<<8|(r[Rr+2|0]<<16|r[Rr+3|0]<<24);q[ks+44>>2]=js;q[gs+16>>2]=ps;q[gs+20>>2]=Sr;break q}if(!oi(1,ks+44|0,gs)){break a}js=q[ks+44>>2]}if(!js){break a}Rr=q[q[a+4>>2]+32>>2];Sr=q[Rr+8>>2];gs=q[Rr+16>>2];Rr=q[Rr+12>>2]-(q[Rr+20>>2]+(Sr>>>0>>0)|0)|0;if((Rr|0)<0?1:(Rr|0)<=0?Sr-gs>>>0>=js>>>0?0:1:0){break a}gs=Yj(ks);Sr=q[q[a+4>>2]+32>>2];Rr=q[Sr+16>>2];ns=q[Sr+8>>2];Zj(gs,(Rr+q[Sr>>2]|0)+js|0,(ns-Rr|0)-js|0,s[Sr+38>>1]);Sr=ri(a,gs);if((Sr|0)==-1){break a}Rr=Sr;gs=Rr>>31;break p}Rr=-1;gs=-1;if((ri(a,q[Sr+32>>2])|0)==-1){break a}}q[a+376>>2]=a;ns=a+232|0;Sr=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];ps=q[Sr>>2]+q[Sr+16>>2]|0;js=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];Sr=q[js+8>>2];fs=q[js+16>>2];Zj(ns,ps,Sr-fs|0,s[q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);ss=a,ts=n[q[q[a>>2]+36>>2]](a)|0,q[ss+380>>2]=ts;q[a+372>>2]=ls;q[a+384>>2]=q[a+156>>2]+ms;fs=0;Sr=Yj(ks);r:{if(!Gi(ns,Sr)){break r}js=Hi(a,is);if((js|0)==-1){break r}is=q[q[a+4>>2]+32>>2];fs=q[Sr+16>>2];ls=fs+q[Sr>>2]|0;Sr=q[Sr+8>>2];Zj(is,ls,Sr-fs|0,s[is+38>>1]);Sr=q[a+4>>2];fs=s[Sr+36>>1];is=(fs<<24|fs<<8&16711680)>>>16;if(is>>>0<=513){fs=q[Sr+32>>2];ls=fs;ps=fs;Sr=gs+q[fs+20>>2]|0;fs=Rr+q[fs+16>>2]|0;if(fs>>>0>>0){Sr=Sr+1|0}q[ps+16>>2]=fs;q[ls+20>>2]=Sr}s:{if(q[a+220>>2]==q[a+216>>2]){break s}Sr=q[hs>>2];Rr=q[Sr+4>>2];Sr=q[Sr>>2];t:{if(is>>>0>=513){if((Rr|0)==(Sr|0)){break s}Sr=0;break t}if((Rr|0)==(Sr|0)){break s}Sr=0;while(1){if(ui(a,Sr)){Sr=Sr+3|0;Rr=q[hs>>2];if(Sr>>>0>2]-q[Rr>>2]>>2>>>0){continue}break s}break}fs=0;break r}while(1){if(vi(a,Sr)){Sr=Sr+3|0;Rr=q[hs>>2];if(Sr>>>0>2]-q[Rr>>2]>>2>>>0){continue}break s}break}fs=0;break r}if(r[a+308|0]){ak(a+272|0)}if(s[a+270>>1]<=513){ak(a+328|0)}Sr=q[a+216>>2];gs=a+220|0;if((Sr|0)!=q[gs>>2]){is=0;while(1){Rr=w(is,144);Ek((Rr+Sr|0)+4|0,q[hs>>2]);fs=q[os>>2];ls=Rr+fs|0;Sr=q[ls+132>>2];ls=q[ls+136>>2];if((Sr|0)!=(ls|0)){while(1){Gk((Rr+fs|0)+4|0,q[Sr>>2]);fs=q[os>>2];Sr=Sr+4|0;if((ls|0)!=(Sr|0)){continue}break}}Fk((Rr+fs|0)+4|0);is=is+1|0;Sr=q[a+216>>2];if(is>>>0<(q[gs>>2]-Sr|0)/144>>>0){continue}break}}Rr=q[a+8>>2];wi(a+184|0,q[Rr+28>>2]-q[Rr+24>>2]>>2);fs=q[a+216>>2];if((fs|0)!=q[gs>>2]){Sr=0;is=a+220|0;while(1){Rr=w(Sr,144)+fs|0;fs=q[Rr+60>>2]-q[Rr+56>>2]>>2;ls=Rr+104|0;Rr=q[hs>>2];Rr=q[Rr+28>>2]-q[Rr+24>>2]>>2;wi(ls,(fs|0)<(Rr|0)?Rr:fs);Sr=Sr+1|0;fs=q[a+216>>2];if(Sr>>>0<(q[is>>2]-fs|0)/144>>>0){continue}break}}fs=xi(a,js)}}T=ks- -64|0;return fs|0}function Gi(a,us){var vs=0,ws=0,xs=0,ys=0,zs=0,As=0,Bs=0;ys=T-16|0;T=ys;a:{if(!si(a,us)){break a}zs=q[us+12>>2];vs=q[us+20>>2];As=q[us+16>>2];xs=As+4|0;if(xs>>>0<4){vs=vs+1|0}ws=xs;xs=vs;if((zs|0)<(vs|0)?1:(zs|0)<=(vs|0)?t[us+8>>2]>=ws>>>0?0:1:0){break a}vs=As+q[us>>2]|0;vs=r[vs|0]|r[vs+1|0]<<8|(r[vs+2|0]<<16|r[vs+3|0]<<24);q[us+16>>2]=ws;q[us+20>>2]=xs;if((vs|0)<0){break a}ws=q[a+152>>2];if((vs|0)>=(ws|0)){break a}q[ys+12>>2]=0;xs=q[a+156>>2];vs=q[a+160>>2]-xs>>2;b:{if(ws>>>0>vs>>>0){Ad(a+156|0,ws-vs|0,ys+12|0);break b}if(ws>>>0>=vs>>>0){break b}q[a+160>>2]=xs+(ws<<2)}Bs=bh(a+168|0,us)}T=ys+16|0;return Bs}function Hi(a,us){var Cs=0,Ds=0,Es=0,Fs=0,Gs=0,Hs=0,Is=0,Js=0,Ks=0,Ls=0,Ms=0,Ns=0,Os=0,Ps=0,Qs=0,Rs=0,Ss=0,Ts=0,Us=0,Vs=0,Ws=0,Xs=0,Ys=0,Zs=0,_s=0,$s=0,at=0;Gs=T-96|0;T=Gs;q[Gs+72>>2]=0;q[Gs+64>>2]=0;q[Gs+68>>2]=0;q[Gs+48>>2]=0;q[Gs+52>>2]=0;q[Gs+40>>2]=0;q[Gs+44>>2]=0;q[Gs+56>>2]=1065353216;q[Gs+32>>2]=0;q[Gs+24>>2]=0;q[Gs+28>>2]=0;Ss=q[a+124>>2];a:{b:{c:{if((us|0)>=1){Ts=a+400|0;Us=a+232|0;Zs=a+296|0;Vs=a+8|0;_s=a+388|0;Ys=q[a+216>>2]!=q[a+220>>2];Ws=a+40|0;while(1){d:{e:{f:{g:{h:{if(q[a+420>>2]!=-1){if(dh(Ts)){break h}}Cs=a;Js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break I}Es=q[q[Is>>2]+(Cs<<2)>>2];if((Es|0)==-1){break I}Cs=Es+1|0;Es=(Cs>>>0)%3|0?Cs:Es+ -2|0;if((Es|0)!=-1){continue}break}}q[Hs+(q[Gs>>2]<<2)>>2]=-1;J:{if(Ys){break J}Cs=q[Gs+28>>2];if((Cs|0)!=q[Gs+32>>2]){q[Cs>>2]=q[Gs>>2];q[Gs+28>>2]=Cs+4;break J}zi(Gs+24|0,Gs);Ds=q[Gs+68>>2]}q[Ds+ -4>>2]=Ps;Cs=0}Ii(Us,q[Ds+ -4>>2]);K:{if(!Cs){break K}Ds=q[Ws>>2];if((Ds|0)==q[a+36>>2]){break K}Hs=(Ls^-1)+us|0;while(1){Es=-1;Cs=q[Ds+ -8>>2];if(Cs>>>0>Hs>>>0){break c}if((Cs|0)!=(Hs|0)){break K}Cs=r[Ds+ -4|0];Ds=Ds+ -12|0;Fs=q[Ds>>2];q[Ws>>2]=Ds;if((Fs|0)<0){break c}Es=q[q[Gs+68>>2]+ -4>>2];q[Gs+20>>2]=(Fs^-1)+us;q[Gs+88>>2]=Gs+20;Bi(Gs,Gs+40|0,Gs+20|0,Gs+88|0);Fs=q[Gs>>2];L:{if(Cs&1){Cs=-1;if((Es|0)==-1){break L}Ds=Es+1|0;Cs=(Ds>>>0)%3|0?Ds:Es+ -2|0;break L}Cs=-1;if((Es|0)==-1){break L}Cs=Es+ -1|0;if((Es>>>0)%3){break L}Cs=Es+2|0}q[Fs+12>>2]=Cs;Ds=q[Ws>>2];if((Ds|0)!=q[a+36>>2]){continue}break}}Ls=Ls+1|0;if((Ls|0)!=(us|0)){continue}break}Hs=us}Es=-1;Js=q[a+8>>2];if(q[Js+28>>2]-q[Js+24>>2]>>2>(Ss|0)){break c}Ds=q[Gs+68>>2];if((Ds|0)!=q[Gs+64>>2]){Ps=a+72|0;us=a+60|0;Zs=a+312|0;_s=a+352|0;Ys=a+8|0;Os=a+68|0;Qs=a+80|0;Ws=a+76|0;while(1){Cs=Ds+ -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870908)|0;Cs=q[Ls>>2];$s=Ls,at=eo(Ds)&Cs,q[$s>>2]=at;Ds=q[Ws>>2];if((Ds|0)!=q[Qs>>2]){q[Ds>>2]=q[Gs>>2];q[Ws>>2]=Ds+4;break M}zi(Ps,Gs)}Ds=q[Gs+68>>2];if((Ds|0)!=q[Gs+64>>2]){continue}break}Js=q[a+8>>2]}if(((q[Js+4>>2]-q[Js>>2]>>2>>>0)/3|0)!=(Hs|0)){break c}Es=q[Js+28>>2]-q[Js+24>>2]>>2;us=q[Gs+24>>2];Ks=q[Gs+28>>2];if((us|0)==(Ks|0)){break b}Fs=a+8|0;while(1){Is=q[us>>2];Hs=q[Js+24>>2];Ds=Es+ -1|0;T:{if(q[Hs+(Ds<<2)>>2]!=-1){Ls=Es;break T}Hs=q[Js+24>>2];while(1){Ds=Es+ -2|0;Ls=Es+ -1|0;Es=Ls;if(q[(Ds<<2)+Hs>>2]==-1){continue}break}}if(!(Ds>>>0>>0)){q[Gs>>2]=Js;Cs=Ds<<2;Es=q[Cs+Hs>>2];o[Gs+12|0]=1;q[Gs+8>>2]=Es;q[Gs+4>>2]=Es;if((Es|0)!=-1){while(1){q[q[Js>>2]+(Es<<2)>>2]=Is;lg(Gs);Js=q[Fs>>2];Es=q[Gs+8>>2];if((Es|0)!=-1){continue}break}}Es=Cs;Cs=q[Js+24>>2];Es=Es+Cs|0;if((Is|0)!=-1){q[Cs+(Is<<2)>>2]=q[Es>>2]}q[Es>>2]=-1;Ys=1<<(Is&31);Es=q[a+120>>2];Is=Es+(Is>>>3&536870908)|0;Cs=Is;Hs=Es+(Ds>>>3&536870908)|0;Ds=1<<(Ds&31);Es=Ys|q[Is>>2];U:{if(q[Hs>>2]&Ds){break U}Es=q[Is>>2]&(Ys^-1)}q[Cs>>2]=Es;q[Hs>>2]=q[Hs>>2]&(Ds^-1);Ls=Ls+ -1|0}Es=Ls;us=us+4|0;if((Ks|0)!=(us|0)){continue}break}}us=q[Gs+24>>2]}if(us){q[Gs+28>>2]=us;An(us)}Ds=q[Gs+48>>2];if(Ds){while(1){a=q[Ds>>2];An(Ds);Ds=a;if(Ds){continue}break}}a=q[Gs+40>>2];q[Gs+40>>2]=0;if(a){An(a)}a=q[Gs+64>>2];if(a){q[Gs+68>>2]=a;An(a)}T=Gs+96|0;return Es}bn();F()}function Ii(a,us){var bt=0,ct=0,dt=0,et=0,ft=0;ct=-1;ft=-1;a:{if((us|0)==-1){break a}bt=us+1|0;ct=(bt>>>0)%3|0?bt:us+ -2|0;ft=us+ -1|0;if((us>>>0)%3){break a}ft=us+2|0}bt=q[a+184>>2];b:{if(bt>>>0>7){break b}c:{d:{switch(bt-2|0){default:dt=q[a+148>>2];bt=-1;bt=(ct|0)!=-1?q[q[dt>>2]+(ct<<2)>>2]:bt;ct=1;et=bt<<2;bt=q[a+156>>2];et=et+bt|0;q[et>>2]=q[et>>2]+1;bt=(((ft|0)!=-1?q[q[dt>>2]+(ft<<2)>>2]:-1)<<2)+bt|0;break c;case 3:et=q[a+148>>2];bt=q[a+156>>2];dt=bt+(((us|0)!=-1?q[q[et>>2]+(us<<2)>>2]:-1)<<2)|0;q[dt>>2]=q[dt>>2]+1;dt=(((ct|0)!=-1?q[q[et>>2]+(ct<<2)>>2]:-1)<<2)+bt|0;q[dt>>2]=q[dt>>2]+1;ct=2;bt=(((ft|0)!=-1?q[q[et>>2]+(ft<<2)>>2]:-1)<<2)+bt|0;break c;case 1:et=q[a+148>>2];bt=q[a+156>>2];dt=bt+(((us|0)!=-1?q[q[et>>2]+(us<<2)>>2]:-1)<<2)|0;q[dt>>2]=q[dt>>2]+1;dt=(((ct|0)!=-1?q[q[et>>2]+(ct<<2)>>2]:-1)<<2)+bt|0;q[dt>>2]=q[dt>>2]+2;ct=1;bt=(((ft|0)!=-1?q[q[et>>2]+(ft<<2)>>2]:-1)<<2)+bt|0;break c;case 0:case 2:case 4:break b;case 5:break d}}et=q[a+148>>2];bt=q[a+156>>2];dt=bt+(((us|0)!=-1?q[q[et>>2]+(us<<2)>>2]:-1)<<2)|0;q[dt>>2]=q[dt>>2]+2;dt=(((ct|0)!=-1?q[q[et>>2]+(ct<<2)>>2]:-1)<<2)+bt|0;q[dt>>2]=q[dt>>2]+2;ct=2;bt=(((ft|0)!=-1?q[q[et>>2]+(ft<<2)>>2]:-1)<<2)+bt|0}q[bt>>2]=q[bt>>2]+ct;bt=q[a+184>>2]}e:{if(bt>>>0>5){break e}f:{switch(bt-1|0){case 0:case 1:case 2:case 3:break e;default:break f}}bt=a;ft=bt;bt=q[bt+156>>2];ct=-1;g:{if((us|0)==-1){break g}ct=us+1|0;us=(ct>>>0)%3|0?ct:us+ -2|0;ct=-1;if((us|0)==-1){break g}ct=q[q[q[a+148>>2]>>2]+(us<<2)>>2]}q[ft+188>>2]=q[bt+(ct<<2)>>2]>5?0:5;return}q[a+188>>2]=-1}function Ji(a){q[a>>2]=11372;Dn(a+4|0,0,80);q[a+96>>2]=0;q[a+100>>2]=0;q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+104>>2]=0;q[a+108>>2]=0;q[a+112>>2]=0;q[a+116>>2]=0;q[a+120>>2]=0;q[a+124>>2]=0;q[a+128>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+140>>2]=0;q[a+144>>2]=0;q[a+148>>2]=0;q[a+156>>2]=0;q[a+160>>2]=0;q[a+152>>2]=1065353216;q[a+164>>2]=0;q[a+168>>2]=0;q[a+172>>2]=0;q[a+176>>2]=0;q[a+180>>2]=0;q[a+184>>2]=0;q[a+188>>2]=0;q[a+192>>2]=0;q[a+196>>2]=0;q[a+200>>2]=0;q[a+204>>2]=0;q[a+208>>2]=0;q[a+212>>2]=-1;q[a+216>>2]=0;q[a+220>>2]=0;q[a+224>>2]=0;ci(a+232|0);q[a+388>>2]=0;q[a+392>>2]=0;q[a+380>>2]=0;q[a+384>>2]=0;q[a+416>>2]=0;q[a+420>>2]=0;q[a+412>>2]=7;q[a+404>>2]=-1;q[a+408>>2]=2;q[a+396>>2]=0;q[a+400>>2]=-1;q[a+424>>2]=0;q[a+428>>2]=0;q[a+432>>2]=0;q[a+436>>2]=0}function Ki(a){a=a|0;var us=0,gt=0,ht=0,it=0,jt=0,kt=0,lt=0,mt=0,nt=0,ot=0,pt=0,qt=0,rt=0,st=0,tt=0,ut=0,vt=0;mt=T+ -64|0;T=mt;q[a+132>>2]=0;if(q[a+148>>2]){ht=a+144|0;gt=q[ht>>2];if(gt){while(1){us=q[gt>>2];An(gt);gt=us;if(us){continue}break}}q[ht>>2]=0;us=q[a+140>>2];if(us){ht=a+136|0;gt=0;while(1){q[q[ht>>2]+(gt<<2)>>2]=0;gt=gt+1|0;if((us|0)!=(gt|0)){continue}break}}q[a+148>>2]=0}a:{b:{c:{d:{e:{f:{gt=q[a+4>>2];ht=r[gt+36|0];us=ht<<8|r[gt+37|0];g:{if(us>>>0>513){break g}kt=q[gt+32>>2];if(us>>>0<=511){it=q[kt+12>>2];us=q[kt+20>>2];lt=q[kt+16>>2];jt=lt+4|0;if(jt>>>0<4){us=us+1|0}nt=jt;jt=us;if((it|0)<(us|0)?1:(it|0)<=(us|0)?t[kt+8>>2]>=nt>>>0?0:1:0){break f}us=lt+q[kt>>2]|0;us=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt>>2]=us;q[kt+16>>2]=nt;q[kt+20>>2]=jt;q[a+132>>2]=us;break g}if(!oi(1,mt,kt)){break f}gt=q[a+4>>2];ht=r[gt+36|0];q[a+132>>2]=q[mt>>2]}gt=q[gt+32>>2];h:{i:{j:{if((ht&255)>>>0<=1){ht=0;kt=q[gt+12>>2];us=q[gt+20>>2];it=q[gt+16>>2];jt=it+4|0;if(jt>>>0<4){us=us+1|0}lt=jt;jt=us;if((kt|0)<(us|0)?1:(kt|0)<=(us|0)?t[gt+8>>2]>=lt>>>0?0:1:0){break a}us=it+q[gt>>2]|0;us=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+60>>2]=us;q[gt+16>>2]=lt;q[gt+20>>2]=jt;q[a+156>>2]=us;pt=a+156|0;break j}ht=0;if(!oi(1,mt+60|0,gt)){break a}us=q[a+4>>2];gt=q[us+32>>2];us=r[us+36|0];q[a+156>>2]=q[mt+60>>2];pt=a+156|0;if(us>>>0>1){break i}}kt=q[gt+12>>2];us=q[gt+20>>2];it=q[gt+16>>2];jt=it+4|0;if(jt>>>0<4){us=us+1|0}nt=jt;jt=us;if((kt|0)<(us|0)?1:(kt|0)<=(us|0)?t[gt+8>>2]>=nt>>>0?0:1:0){break a}us=it+q[gt>>2]|0;lt=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+56>>2]=lt;q[gt+16>>2]=nt;q[gt+20>>2]=jt;break h}if(!oi(1,mt+56|0,gt)){break a}lt=q[mt+56>>2]}if(lt>>>0>1431655765|t[pt>>2]>w(lt,3)>>>0){break a}qt=q[a+4>>2];jt=q[qt+32>>2];rt=q[jt+8>>2];ot=q[jt+16>>2];kt=q[jt+12>>2];us=kt;gt=q[jt+20>>2];if((us|0)<(gt|0)?1:(us|0)<=(gt|0)?rt>>>0>ot>>>0?0:1:0){break a}tt=q[jt>>2];nt=r[tt+ot|0];us=gt;st=ot+1|0;if(st>>>0<1){us=us+1|0}q[jt+16>>2]=st;q[jt+20>>2]=us;k:{if(r[qt+36|0]<=1){us=gt;gt=ot+5|0;if(gt>>>0<5){us=us+1|0}it=gt;gt=us;if((kt|0)<(us|0)?1:(kt|0)<=(us|0)?rt>>>0>=it>>>0?0:1:0){break a}us=st+tt|0;kt=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+52>>2]=kt;q[jt+16>>2]=it;q[jt+20>>2]=gt;break k}if(!oi(1,mt+52|0,jt)){break a}kt=q[mt+52>>2]}if(lt>>>0>>0|lt>>>0>((kt>>>0)/3|0)+kt>>>0){break a}us=q[a+4>>2];jt=q[us+32>>2];l:{if(r[us+36|0]<=1){it=q[jt+12>>2];us=q[jt+20>>2];ot=q[jt+16>>2];gt=ot+4|0;if(gt>>>0<4){us=us+1|0}qt=gt;gt=us;if((it|0)<(us|0)?1:(it|0)<=(us|0)?t[jt+8>>2]>=qt>>>0?0:1:0){break a}us=ot+q[jt>>2]|0;ot=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+48>>2]=ot;q[jt+16>>2]=qt;q[jt+20>>2]=gt;break l}if(!oi(1,mt+48|0,jt)){break a}ot=q[mt+48>>2]}if(ot>>>0>kt>>>0){break a}q[a+28>>2]=q[a+24>>2];gt=Mm(88);jk(gt);us=q[a+8>>2];q[a+8>>2]=gt;jt=a+8|0;if(us){wa(jt,us);if(!q[jt>>2]){break a}}us=q[a+160>>2];q[a+164>>2]=us;m:{if(q[a+168>>2]-us>>2>>>0>=lt>>>0){break m}if(lt>>>0>=1073741824){break e}ht=lt<<2;gt=Mm(ht);q[a+164>>2]=gt;q[a+160>>2]=gt;q[a+168>>2]=gt+ht;if(!us){break m}An(us)}us=q[a+172>>2];q[a+176>>2]=us;n:{if(q[a+180>>2]-us>>2>>>0>=lt>>>0){break n}if(lt>>>0>=1073741824){break d}ht=lt<<2;gt=Mm(ht);q[a+176>>2]=gt;q[a+172>>2]=gt;q[a+180>>2]=gt+ht;if(!us){break n}An(us)}q[a+92>>2]=-1;q[a+84>>2]=-1;q[a+88>>2]=-1;q[a+40>>2]=q[a+36>>2];q[a- -64>>2]=0;q[a+52>>2]=q[a+48>>2];q[a+76>>2]=q[a+72>>2];qt=a+216|0;gt=q[a+220>>2];ht=q[a+216>>2];if((gt|0)==(ht|0)){break c}while(1){us=q[gt+ -12>>2];if(us){q[gt+ -8>>2]=us;An(us)}us=q[gt+ -28>>2];if(us){q[gt+ -24>>2]=us;An(us)}us=gt+ -144|0;it=q[gt+ -40>>2];if(it){q[gt+ -36>>2]=it;An(it)}pi(gt+ -140|0);gt=us;if((ht|0)!=(us|0)){continue}break}us=q[qt>>2];break b}ht=0;break a}ab(12024);F()}ab(12024);F()}us=ht}q[a+220>>2]=ht;gt=(ht-us|0)/144|0;o:{if(gt>>>0>>0){qi(qt,nt-gt|0);break o}if(gt>>>0<=nt>>>0){break o}gt=us+w(nt,144)|0;if((gt|0)!=(ht|0)){while(1){us=q[ht+ -12>>2];if(us){q[ht+ -8>>2]=us;An(us)}us=q[ht+ -28>>2];if(us){q[ht+ -24>>2]=us;An(us)}us=ht+ -144|0;it=q[ht+ -40>>2];if(it){q[ht+ -36>>2]=it;An(it)}pi(ht+ -140|0);ht=us;if((us|0)!=(gt|0)){continue}break}}q[a+220>>2]=gt}ht=0;if(!tk(q[jt>>2],lt,q[pt>>2]+ot|0)){break a}us=q[a+156>>2];o[mt|0]=1;bb(a+120|0,us+ot|0,mt);gt=q[a+4>>2];us=s[gt+36>>1];us=(us<<24|us<<8&16711680)>>>16;p:{if(us>>>0<=513){it=q[gt+32>>2];q:{if(us>>>0<=511){lt=q[it+12>>2];us=q[it+20>>2];pt=q[it+16>>2];gt=pt+4|0;if(gt>>>0<4){us=us+1|0}rt=gt;gt=us;if((lt|0)<(us|0)?1:(lt|0)<=(us|0)?t[it+8>>2]>=rt>>>0?0:1:0){break a}us=pt+q[it>>2]|0;lt=r[us|0]|r[us+1|0]<<8|(r[us+2|0]<<16|r[us+3|0]<<24);q[mt+44>>2]=lt;q[it+16>>2]=rt;q[it+20>>2]=gt;break q}if(!oi(1,mt+44|0,it)){break a}lt=q[mt+44>>2]}if(!lt){break a}us=q[q[a+4>>2]+32>>2];gt=q[us+8>>2];it=q[us+16>>2];us=q[us+12>>2]-(q[us+20>>2]+(gt>>>0>>0)|0)|0;if((us|0)<0?1:(us|0)<=0?gt-it>>>0>=lt>>>0?0:1:0){break a}it=Yj(mt);gt=q[q[a+4>>2]+32>>2];us=q[gt+16>>2];pt=q[gt+8>>2];Zj(it,(us+q[gt>>2]|0)+lt|0,(pt-us|0)-lt|0,s[gt+38>>1]);gt=ri(a,it);if((gt|0)==-1){break a}us=gt;it=us>>31;break p}us=-1;it=-1;if((ri(a,q[gt+32>>2])|0)==-1){break a}}q[a+376>>2]=a;pt=a+232|0;gt=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];rt=q[gt>>2]+q[gt+16>>2]|0;lt=q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2];gt=q[lt+8>>2];ht=q[lt+16>>2];Zj(pt,rt,gt-ht|0,s[q[(n[q[q[a>>2]+32>>2]](a)|0)+32>>2]+38>>1]);ut=a,vt=n[q[q[a>>2]+36>>2]](a)|0,q[ut+380>>2]=vt;q[a+372>>2]=nt;q[a+384>>2]=q[a+156>>2]+ot;ht=0;gt=Yj(mt);r:{if(!Li(pt,gt)){break r}lt=Mi(a,kt);if((lt|0)==-1){break r}kt=q[q[a+4>>2]+32>>2];ht=q[gt+16>>2];nt=ht+q[gt>>2]|0;gt=q[gt+8>>2];Zj(kt,nt,gt-ht|0,s[kt+38>>1]);gt=q[a+4>>2];ht=s[gt+36>>1];kt=(ht<<24|ht<<8&16711680)>>>16;if(kt>>>0<=513){ht=q[gt+32>>2];nt=ht;rt=ht;gt=it+q[ht+20>>2]|0;ht=us+q[ht+16>>2]|0;if(ht>>>0>>0){gt=gt+1|0}q[rt+16>>2]=ht;q[nt+20>>2]=gt}s:{if(q[a+220>>2]==q[a+216>>2]){break s}gt=q[jt>>2];us=q[gt+4>>2];gt=q[gt>>2];t:{if(kt>>>0>=513){if((us|0)==(gt|0)){break s}gt=0;break t}if((us|0)==(gt|0)){break s}gt=0;while(1){if(ui(a,gt)){gt=gt+3|0;us=q[jt>>2];if(gt>>>0>2]-q[us>>2]>>2>>>0){continue}break s}break}ht=0;break r}while(1){if(vi(a,gt)){gt=gt+3|0;us=q[jt>>2];if(gt>>>0>2]-q[us>>2]>>2>>>0){continue}break s}break}ht=0;break r}if(r[a+308|0]){ak(a+272|0)}if(s[a+270>>1]<=513){ak(a+328|0)}gt=q[a+216>>2];it=a+220|0;if((gt|0)!=q[it>>2]){kt=0;while(1){us=w(kt,144);Ek((us+gt|0)+4|0,q[jt>>2]);ht=q[qt>>2];nt=us+ht|0;gt=q[nt+132>>2];nt=q[nt+136>>2];if((gt|0)!=(nt|0)){while(1){Gk((us+ht|0)+4|0,q[gt>>2]);ht=q[qt>>2];gt=gt+4|0;if((nt|0)!=(gt|0)){continue}break}}Fk((us+ht|0)+4|0);kt=kt+1|0;gt=q[a+216>>2];if(kt>>>0<(q[it>>2]-gt|0)/144>>>0){continue}break}}us=q[a+8>>2];wi(a+184|0,q[us+28>>2]-q[us+24>>2]>>2);ht=q[a+216>>2];if((ht|0)!=q[it>>2]){gt=0;kt=a+220|0;while(1){us=w(gt,144)+ht|0;ht=q[us+60>>2]-q[us+56>>2]>>2;nt=us+104|0;us=q[jt>>2];us=q[us+28>>2]-q[us+24>>2]>>2;wi(nt,(ht|0)<(us|0)?us:ht);gt=gt+1|0;ht=q[a+216>>2];if(gt>>>0<(q[kt>>2]-ht|0)/144>>>0){continue}break}}ht=xi(a,lt)}}T=mt- -64|0;return ht|0}function Li(a,wt){var xt=0,yt=0,zt=0,At=0,Bt=0,Ct=0,Dt=0,Et=0,Ft=0,Gt=0,Ht=0,It=0;Et=T-16|0;T=Et;xt=q[a+144>>2];xt=s[(n[q[q[xt>>2]+32>>2]](xt)|0)+36>>1];a:{if((xt<<24|xt<<8&16711680)>>>16>>>0<=513){xt=q[a+4>>2];q[a+40>>2]=q[a>>2];q[a+44>>2]=xt;zt=a+32|0;xt=zt;yt=q[xt+4>>2];q[a+72>>2]=q[xt>>2];q[a+76>>2]=yt;yt=q[a+28>>2];xt=a- -64|0;q[xt>>2]=q[a+24>>2];q[xt+4>>2]=yt;xt=q[a+20>>2];q[a+56>>2]=q[a+16>>2];q[a+60>>2]=xt;xt=q[a+12>>2];q[a+48>>2]=q[a+8>>2];q[a+52>>2]=xt;b:{xt=a+40|0;if(_j(xt,1,Et+8|0)){yt=q[xt+4>>2];q[a>>2]=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-((xt>>>0>>0)+Ct|0)|0;xt=q[Et+8>>2];if((Dt|0)==(yt|0)&xt>>>0<=Bt>>>0|Dt>>>0>>0){break d}}At=0;break a}At=Ct+Dt|0;zt=xt+zt|0;if(zt>>>0>>0){At=At+1|0}q[a+16>>2]=zt;q[a+20>>2]=At;break c}At=0;if(!bh(a+80|0,a)){break a}}At=0;if(!Ai(a)){break a}xt=q[a+4>>2];q[wt>>2]=q[a>>2];q[wt+4>>2]=xt;xt=q[a+36>>2];q[wt+32>>2]=q[a+32>>2];q[wt+36>>2]=xt;xt=q[a+28>>2];q[wt+24>>2]=q[a+24>>2];q[wt+28>>2]=xt;xt=q[a+20>>2];q[wt+16>>2]=q[a+16>>2];q[wt+20>>2]=xt;xt=q[a+12>>2];q[wt+8>>2]=q[a+8>>2];q[wt+12>>2]=xt;xt=q[a+144>>2];xt=s[(n[q[q[xt>>2]+32>>2]](xt)|0)+36>>1];e:{if((xt<<24|xt<<8&16711680)>>>16>>>0<=513){xt=q[a+144>>2];f:{if(r[(n[q[q[xt>>2]+32>>2]](xt)|0)+36|0]<=1){yt=q[wt+12>>2];xt=q[wt+20>>2];Bt=q[wt+16>>2];zt=Bt+4|0;if(zt>>>0<4){xt=xt+1|0}Ct=zt;zt=xt;if((yt|0)<(xt|0)?1:(yt|0)<=(xt|0)?t[wt+8>>2]>=Ct>>>0?0:1:0){break a}xt=Bt+q[wt>>2]|0;yt=r[xt|0]|r[xt+1|0]<<8|(r[xt+2|0]<<16|r[xt+3|0]<<24);q[Et+8>>2]=yt;q[wt+16>>2]=Ct;q[wt+20>>2]=zt;break f}if(!oi(1,Et+8|0,wt)){break a}yt=q[Et+8>>2]}xt=q[a+152>>2];if(yt>>>0>=xt>>>0){break a}Bt=q[wt+16>>2];yt=q[wt+12>>2];zt=q[wt+20>>2];if((yt|0)<(zt|0)?1:(yt|0)<=(zt|0)?t[wt+8>>2]>Bt>>>0?0:1:0){break a}Ct=r[Bt+q[wt>>2]|0];Bt=Bt+1|0;if(Bt>>>0<1){zt=zt+1|0}yt=wt;q[yt+16>>2]=Bt;q[yt+20>>2]=zt;if(Ct){break a}q[a+176>>2]=2;q[a+180>>2]=7;break e}q[a+176>>2]=2;q[a+180>>2]=7;xt=q[a+152>>2]}if((xt|0)<0){break a}q[Et+8>>2]=0;At=2;Bt=q[a+156>>2];yt=q[a+160>>2]-Bt>>2;g:{if(xt>>>0>yt>>>0){Ad(a+156|0,xt-yt|0,Et+8|0);At=q[a+176>>2];zt=q[a+180>>2];break g}zt=7;if(xt>>>0>=yt>>>0){break g}q[a+160>>2]=Bt+(xt<<2)}Bt=a+184|0;zt=(zt-At|0)+1|0;At=a+188|0;xt=q[At>>2];Ct=q[a+184>>2];yt=(xt-Ct|0)/12|0;h:{if(zt>>>0>yt>>>0){Ni(Bt,zt-yt|0);zt=q[At>>2];break h}if(zt>>>0>=yt>>>0){zt=xt;break h}zt=Ct+w(zt,12)|0;if((zt|0)!=(xt|0)){while(1){yt=xt+ -12|0;At=q[yt>>2];if(At){q[xt+ -8>>2]=At;An(At)}xt=yt;if((xt|0)!=(zt|0)){continue}break}}q[a+188>>2]=zt}Ct=a+196|0;xt=q[a+184>>2];yt=(zt-xt|0)/12|0;Dt=q[a+196>>2];At=q[a+200>>2]-Dt>>2;i:{if(yt>>>0>At>>>0){Fa(Ct,yt-At|0);zt=q[a+188>>2];xt=q[a+184>>2];break i}if(yt>>>0>=At>>>0){break i}q[a+200>>2]=Dt+(yt<<2)}At=1;if((xt|0)==(zt|0)){break a}xt=0;It=a+188|0;while(1){oi(1,Et+8|0,wt);zt=q[Et+8>>2];if(zt){yt=q[Bt>>2];Ft=w(xt,12);At=yt+Ft|0;Gt=At+4|0;Ht=q[At>>2];Dt=q[Gt>>2]-Ht>>2;j:{if(zt>>>0>Dt>>>0){Fa(At,zt-Dt|0);yt=q[Bt>>2];break j}if(zt>>>0>=Dt>>>0){break j}q[Gt>>2]=(zt<<2)+Ht}qh(zt,1,wt,q[yt+Ft>>2]);q[q[Ct>>2]+(xt<<2)>>2]=zt}At=1;xt=xt+1|0;if(xt>>>0<(q[It>>2]-q[a+184>>2]|0)/12>>>0){continue}break}}T=Et+16|0;return At} - - - -function Mi(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,p=0,u=0,v=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,G=0,H=0,I=0;g=T-96|0;T=g;q[g+72>>2]=0;q[g+64>>2]=0;q[g+68>>2]=0;q[g+48>>2]=0;q[g+52>>2]=0;q[g+40>>2]=0;q[g+44>>2]=0;q[g+56>>2]=1065353216;q[g+32>>2]=0;q[g+24>>2]=0;q[g+28>>2]=0;C=q[a+124>>2];a:{b:{c:{if((b|0)>=1){A=a+232|0;B=a+8|0;D=a+40|0;G=a+388|0;E=q[a+216>>2]!=q[a+220>>2];while(1){h=Oi(A);d:{if(!h){d=q[g+68>>2];if((d|0)==q[g+64>>2]){e=-1;break c}n=-1;u=q[B>>2];i=q[u+24>>2];f=i;h=d+ -4|0;v=q[h>>2];c=-1;e:{if((v|0)==-1){break e}e=v+1|0;e=(e>>>0)%3|0?e:v+ -2|0;c=-1;if((e|0)==-1){break e}c=q[q[u>>2]+(e<<2)>>2]}f=q[f+(c<<2)>>2];if((f|0)!=-1){e=f+1|0;n=(e>>>0)%3|0?e:f+ -2|0}f=q[u+12>>2];x=w(j,3);e=x+1|0;q[f+(v<<2)>>2]=e;e=e<<2;q[e+f>>2]=v;y=x+2|0;q[f+(n<<2)>>2]=y;k=y<<2;q[k+f>>2]=n;p=q[u>>2];q[p+(x<<2)>>2]=c;m=e+p|0;f=-1;f:{if((n|0)==-1){break f}e=n+1|0;e=(e>>>0)%3|0?e:n+ -2|0;f=-1;if((e|0)==-1){break f}f=q[p+(e<<2)>>2]}q[m>>2]=f;g:{h:{if((v|0)!=-1){e=v+((v>>>0)%3|0?-1:2)|0;if((e|0)!=-1){break h}}q[k+p>>2]=-1;break g}e=q[p+(e<<2)>>2];q[k+p>>2]=e;if((e|0)==-1){break g}q[i+(e<<2)>>2]=y}f=q[a+120>>2]+(c>>>3&536870908)|0;e=q[f>>2];H=f,I=eo(c)&e,q[H>>2]=I;q[h>>2]=x;c=0;break d}e=-1;d=h+ -1|0;if(d>>>0>6){break c}i:{j:{k:{l:{switch(d-1|0){case 1:case 3:f=q[g+68>>2];if((f|0)==q[g+64>>2]){break c}e=q[B>>2];c=q[e+12>>2];y=w(j,3);i=(h|0)==5;h=y+(i?2:1)|0;d=h<<2;p=q[f+ -4>>2];q[c+d>>2]=p;q[c+(p<<2)>>2]=h;f=e+24|0;m=q[e+32>>2];e=e+28|0;c=q[e>>2];m:{if((m|0)!=(c|0)){q[c>>2]=-1;u=c+4|0;q[e>>2]=u;break m}zi(f,11312);u=q[e>>2]}e=-1;c=q[B>>2];k=q[c+24>>2];if(q[c+28>>2]-k>>2>(C|0)){break c}e=y+2|0;x=q[c>>2];m=x+d|0;c=u-q[f>>2]|0;d=(c>>2)+ -1|0;q[m>>2]=d;if(c){q[k+(d<<2)>>2]=h}e=i?y:e;f=x+(i+y<<2)|0;n:{o:{p:{if((p|0)!=-1){d=p+((p>>>0)%3|0?-1:2)|0;if((d|0)==-1){break p}d=q[x+(d<<2)>>2];q[x+(e<<2)>>2]=d;if((d|0)==-1){break o}q[k+(d<<2)>>2]=e;break o}q[x+(e<<2)>>2]=-1;c=-1;break n}q[x+(e<<2)>>2]=-1}d=p+1|0;d=(d>>>0)%3|0?d:p+ -2|0;c=-1;if((d|0)==-1){break n}c=q[x+(d<<2)>>2]}q[f>>2]=c;d=q[g+68>>2];q[d+ -4>>2]=y;break k;default:d=q[g+68>>2];u=q[g+64>>2];if((d|0)==(u|0)){break c}c=d+ -4|0;z=q[c>>2];q[g+68>>2]=c;k=q[g+44>>2];q:{if(!k){d=c;break q}i=co(k)>>>0>1;r:{if(!i){f=k+2147483647&j;break r}f=j;if(f>>>0>>0){break r}f=(j>>>0)%(k>>>0)|0}h=q[q[g+40>>2]+(f<<2)>>2];if(!h){d=c;break q}l=q[h>>2];if(!l){d=c;break q}h=k+ -1|0;s:{while(1){n=q[l+4>>2];t:{if((j|0)!=(n|0)){u:{if(!i){n=h&n;break u}if(n>>>0>>0){break u}n=(n>>>0)%(k>>>0)|0}if((f|0)==(n|0)){break t}d=c;break q}if(q[l+8>>2]==(j|0)){break s}}l=q[l>>2];if(l){continue}break}d=c;break q}f=l+12|0;if((c|0)!=q[g+72>>2]){q[c>>2]=q[f>>2];q[g+68>>2]=d;break q}zi(g- -64|0,f);d=q[g+68>>2];u=q[g+64>>2]}if((d|0)==(u|0)){break c}p=q[d+ -4>>2];f=(p|0)==-1;v=q[B>>2];if(q[q[v+12>>2]+(p<<2)>>2]!=-1?!f:0){break c}i=(z|0)==-1;k=v+12|0;h=q[k>>2];if(q[h+(z<<2)>>2]!=-1?!i:0){break c}x=w(j,3);y=x+2|0;q[h+(p<<2)>>2]=y;u=y<<2;q[u+h>>2]=p;c=x+1|0;q[h+(z<<2)>>2]=c;m=h;h=c<<2;q[m+h>>2]=z;if(f){break j}n=-1;m=q[v>>2];f=m+(x<<2)|0;c=p+((p>>>0)%3|0?-1:2)|0;if((c|0)!=-1){n=q[(c<<2)+m>>2]}q[f>>2]=n;c=p+1|0;c=(c>>>0)%3|0?c:p+ -2|0;if((c|0)==-1){break i}e=q[(c<<2)+m>>2];break i;case 5:break l;case 0:case 2:case 4:break c}}q[g>>2]=w(j,3);d=q[B>>2];f=d+24|0;i=q[d+32>>2];c=d+28|0;d=q[c>>2];v:{if((i|0)!=(d|0)){q[d>>2]=-1;m=d+4|0;q[c>>2]=m;break v}zi(f,11312);m=q[c>>2]}u=q[B>>2];n=q[u>>2];d=q[g>>2];k=m-q[f>>2]|0;y=k>>2;c=y+ -1|0;q[n+(d<<2)>>2]=c;d=d+1|0;i=u+24|0;h=u+28|0;f=q[h>>2];w:{if((f|0)!=q[u+32>>2]){q[f>>2]=-1;m=f+4|0;q[h>>2]=m;break w}zi(i,11312);m=q[h>>2];n=q[u>>2]}q[(d<<2)+n>>2]=(m-q[i>>2]>>2)+ -1;d=q[g>>2]+2|0;i=q[B>>2];f=i+28|0;h=q[f>>2];x:{if((h|0)!=q[i+32>>2]){q[h>>2]=-1;n=h+4|0;q[f>>2]=n;break x}zi(i+24|0,11312);n=q[f>>2]}q[q[i>>2]+(d<<2)>>2]=(n-q[i+24>>2]>>2)+ -1;d=q[B>>2];f=q[d+24>>2];if(q[d+28>>2]-f>>2>(C|0)){break c}d=q[g>>2];y:{z:{if(!k){e=1;q[f+(y<<2)>>2]=d+1;break z}q[f+(c<<2)>>2]=d;e=0;if((k|0)==-4){break z}q[f+(y<<2)>>2]=q[g>>2]+1;e=y+1|0;if((e|0)==-1){break y}}q[f+(e<<2)>>2]=q[g>>2]+2}d=q[g+68>>2];if((d|0)!=q[g+72>>2]){q[d>>2]=q[g>>2];d=d+4|0;q[g+68>>2]=d;break k}zi(g- -64|0,g);d=q[g+68>>2]}c=1;break d}n=-1;m=q[v>>2];q[m+(x<<2)>>2]=-1}q[h+m>>2]=e;A:{B:{C:{if(!i){c=z+((z>>>0)%3|0?-1:2)|0;if((c|0)==-1){break C}c=q[(c<<2)+m>>2];q[u+m>>2]=c;if((c|0)==-1){break B}q[q[v+24>>2]+(c<<2)>>2]=y;break B}q[u+m>>2]=-1;l=-1;e=-1;break A}q[u+m>>2]=-1}l=-1;c=z+1|0;c=(c>>>0)%3|0?c:z+ -2|0;e=-1;if((c|0)==-1){break A}l=q[(c<<2)+m>>2];e=c}q[g>>2]=l;h=q[G>>2];f=n<<2;c=h+f|0;q[c>>2]=q[c>>2]+q[h+(l<<2)>>2];h=q[v+24>>2];if((n|0)!=-1){q[f+h>>2]=q[h+(q[g>>2]<<2)>>2]}D:{if((e|0)==-1){break D}f=q[v>>2];while(1){q[f+(e<<2)>>2]=n;c=e+1|0;c=(c>>>0)%3|0?c:e+ -2|0;if((c|0)==-1){break D}e=q[q[k>>2]+(c<<2)>>2];if((e|0)==-1){break D}c=e+1|0;e=(c>>>0)%3|0?c:e+ -2|0;if((e|0)!=-1){continue}break}}q[h+(q[g>>2]<<2)>>2]=-1;E:{if(E){break E}c=q[g+28>>2];if((c|0)!=q[g+32>>2]){q[c>>2]=q[g>>2];q[g+28>>2]=c+4;break E}zi(g+24|0,g);d=q[g+68>>2]}q[d+ -4>>2]=x;c=0}Pi(A,q[d+ -4>>2]);F:{if(!c){break F}d=q[D>>2];if((d|0)==q[a+36>>2]){break F}h=(j^-1)+b|0;while(1){e=-1;c=q[d+ -8>>2];if(c>>>0>h>>>0){break c}if((c|0)!=(h|0)){break F}c=r[d+ -4|0];d=d+ -12|0;f=q[d>>2];q[D>>2]=d;if((f|0)<0){break c}e=q[q[g+68>>2]+ -4>>2];q[g+20>>2]=(f^-1)+b;q[g+88>>2]=g+20;Bi(g,g+40|0,g+20|0,g+88|0);f=q[g>>2];G:{if(c&1){c=-1;if((e|0)==-1){break G}d=e+1|0;c=(d>>>0)%3|0?d:e+ -2|0;break G}c=-1;if((e|0)==-1){break G}c=e+ -1|0;if((e>>>0)%3){break G}c=e+2|0}q[f+12>>2]=c;d=q[D>>2];if((d|0)!=q[a+36>>2]){continue}break}}j=j+1|0;if((j|0)!=(b|0)){continue}break}h=b}e=-1;l=q[a+8>>2];if(q[l+28>>2]-q[l+24>>2]>>2>(C|0)){break c}d=q[g+68>>2];if((d|0)!=q[g+64>>2]){C=a+72|0;b=a+60|0;y=a+312|0;G=a+352|0;E=a+8|0;D=a+68|0;x=a+80|0;v=a+76|0;while(1){c=d+ -4|0;d=q[c>>2];q[g+68>>2]=c;q[g>>2]=d;H:{I:{J:{K:{if(s[a+270>>1]<=513){if(!r[a+364|0]){break J}c=q[a+360>>2];d=q[G>>2]+(c>>>3)|0;if(d>>>0>=t[a+356>>2]){break I}d=r[d|0];q[a+360>>2]=c+1;c=d>>>(c&7)&1;break K}c=dh(y)}if(!c){break I}}k=q[E>>2];z=q[k>>2];if((h|0)>=((q[k+4>>2]-z>>2>>>0)/3|0)){break c}j=-1;l=-1;i=q[k+24>>2];f=i;A=q[g>>2];d=-1;L:{if((A|0)==-1){break L}c=A+1|0;c=(c>>>0)%3|0?c:A+ -2|0;d=-1;if((c|0)==-1){break L}d=q[z+(c<<2)>>2]}f=q[f+(d<<2)>>2];M:{if((f|0)==-1){break M}c=f+1|0;c=(c>>>0)%3|0?c:f+ -2|0;if((c|0)==-1){break M}j=c+1|0;j=(j>>>0)%3|0?j:c+ -2|0;if((j|0)!=-1){l=q[z+(j<<2)>>2]}j=c}p=-1;m=-1;i=q[i+(l<<2)>>2];f=-1;N:{if((i|0)==-1){break N}c=i+1|0;c=(c>>>0)%3|0?c:i+ -2|0;f=-1;if((c|0)==-1){break N}f=c+1|0;f=(f>>>0)%3|0?f:c+ -2|0;if((f|0)!=-1){m=q[z+(f<<2)>>2]}f=c}c=w(h,3);q[g+88>>2]=c;i=q[k+12>>2];q[i+(c<<2)>>2]=A;q[i+(A<<2)>>2]=c;c=q[g+88>>2]+1|0;q[i+(c<<2)>>2]=j;q[i+(j<<2)>>2]=c;c=q[g+88>>2]+2|0;q[i+(c<<2)>>2]=f;q[i+(f<<2)>>2]=c;c=q[g+88>>2];q[z+(c<<2)>>2]=l;u=c+1|0;k=z+(u<<2)|0;q[k>>2]=m;i=c+2|0;f=z+(i<<2)|0;q[f>>2]=d;A=q[a+120>>2];j=u>>>0>>0?-1:l;c=A+(j>>>3&536870908)|0;d=q[c>>2];H=c,I=eo(j)&d,q[H>>2]=I;p=(u|0)!=-1?q[k>>2]:p;c=A+(p>>>3&536870908)|0;d=q[c>>2];H=c,I=eo(p)&d,q[H>>2]=I;d=-1;d=(i|0)!=-1?q[f>>2]:d;j=A+(d>>>3&536870908)|0;c=q[j>>2];H=j,I=eo(d)&c,q[H>>2]=I;d=q[a+64>>2];f=q[D>>2];if((d|0)==f<<5){if((d+1|0)<=-1){break a}c=b;if(d>>>0<=1073741822){j=d+32&-32;d=f<<6;d=d>>>0>>0?j:d}else{d=2147483647}cb(c,d);d=q[a+64>>2]}h=h+1|0;q[a+64>>2]=d+1;c=q[a+60>>2]+(d>>>3&536870908)|0;q[c>>2]=q[c>>2]|1<<(d&31);d=q[v>>2];if((d|0)!=q[x>>2]){q[d>>2]=q[g+88>>2];q[v>>2]=d+4;break H}zi(C,g+88|0);break H}d=q[a+64>>2];f=q[D>>2];if((d|0)==f<<5){if((d+1|0)<=-1){break a}c=b;if(d>>>0<=1073741822){j=d+32&-32;d=f<<6;d=d>>>0>>0?j:d}else{d=2147483647}cb(c,d);d=q[a+64>>2]}q[a+64>>2]=d+1;j=q[a+60>>2]+(d>>>3&536870908)|0;c=q[j>>2];H=j,I=eo(d)&c,q[H>>2]=I;d=q[v>>2];if((d|0)!=q[x>>2]){q[d>>2]=q[g>>2];q[v>>2]=d+4;break H}zi(C,g)}d=q[g+68>>2];if((d|0)!=q[g+64>>2]){continue}break}l=q[a+8>>2]}if(((q[l+4>>2]-q[l>>2]>>2>>>0)/3|0)!=(h|0)){break c}e=q[l+28>>2]-q[l+24>>2]>>2;b=q[g+24>>2];i=q[g+28>>2];if((b|0)==(i|0)){break b}f=a+8|0;while(1){k=q[b>>2];h=q[l+24>>2];d=e+ -1|0;O:{if(q[h+(d<<2)>>2]!=-1){j=e;break O}h=q[l+24>>2];while(1){d=e+ -2|0;j=e+ -1|0;e=j;if(q[(d<<2)+h>>2]==-1){continue}break}}if(d>>>0>=k>>>0){q[g>>2]=l;c=d<<2;e=q[c+h>>2];o[g+12|0]=1;q[g+8>>2]=e;q[g+4>>2]=e;if((e|0)!=-1){while(1){q[q[l>>2]+(e<<2)>>2]=k;lg(g);l=q[f>>2];e=q[g+8>>2];if((e|0)!=-1){continue}break}}e=c;c=q[l+24>>2];e=e+c|0;if((k|0)!=-1){q[c+(k<<2)>>2]=q[e>>2]}q[e>>2]=-1;E=1<<(k&31);e=q[a+120>>2];k=e+(k>>>3&536870908)|0;c=k;h=e+(d>>>3&536870908)|0;d=1<<(d&31);e=E|q[k>>2];P:{if(q[h>>2]&d){break P}e=q[k>>2]&(E^-1)}q[c>>2]=e;q[h>>2]=q[h>>2]&(d^-1);j=j+ -1|0}e=j;b=b+4|0;if((i|0)!=(b|0)){continue}break}}b=q[g+24>>2]}if(b){q[g+28>>2]=b;An(b)}d=q[g+48>>2];if(d){while(1){a=q[d>>2];An(d);d=a;if(d){continue}break}}a=q[g+40>>2];q[g+40>>2]=0;if(a){An(a)}a=q[g+64>>2];if(a){q[g+68>>2]=a;An(a)}T=g+96|0;return e}bn();F()}function Ni(a,b){var o=0,r=0,s=0,t=0,J=0,K=0,L=0,M=0,N=0;s=q[a+8>>2];t=a+4|0;o=q[t>>2];if((s-o|0)/12>>>0>=b>>>0){a=w(b,12);M=t,N=Dn(o,0,a)+a|0,q[M>>2]=N;return}a:{t=q[a>>2];r=(o-t|0)/12|0;J=r+b|0;if(J>>>0<357913942){L=w(r,12);s=(s-t|0)/12|0;r=s<<1;r=s>>>0<178956970?r>>>0>>0?J:r:357913941;if(r){if(r>>>0>=357913942){break a}K=Mm(w(r,12))}s=K+L|0;Dn(s,0,w(b,12));b=w(J,12)+K|0;J=w(r,12)+K|0;if((o|0)!=(t|0)){while(1){s=s+ -12|0;q[s>>2]=0;q[s+4>>2]=0;r=s+8|0;q[r>>2]=0;o=o+ -12|0;q[s>>2]=q[o>>2];q[s+4>>2]=q[o+4>>2];K=r;r=o+8|0;q[K>>2]=q[r>>2];q[r>>2]=0;q[o>>2]=0;q[o+4>>2]=0;if((o|0)!=(t|0)){continue}break}t=q[a>>2];o=q[a+4>>2]}q[a>>2]=s;q[a+8>>2]=J;q[a+4>>2]=b;if((o|0)!=(t|0)){while(1){a=o+ -12|0;b=q[a>>2];if(b){q[o+ -8>>2]=b;An(b)}o=a;if((o|0)!=(t|0)){continue}break}}if(t){An(t)}return}bn();F()}ab(12024);F()}function Oi(a){var b=0,F=0,O=0,P=0,Q=0,R=0,S=0;b=q[a+172>>2];if((b|0)!=-1){F=q[a+196>>2]+(b<<2)|0;O=q[F>>2];b=O+ -1|0;q[F>>2]=b;if((O|0)<1){return 9}F=a;a=q[(q[q[q[a+184>>2]+w(q[a+172>>2],12)>>2]+(b<<2)>>2]<<2)+12096>>2];q[F+168>>2]=a;return a}b=7;F=q[a+144>>2];F=s[(n[q[q[F>>2]+32>>2]](F)|0)+36>>1];a:{if((F<<24|F<<8&16711680)>>>16>>>0>513){break a}if(!r[a+76|0]){q[a+168>>2]=1;return 1}b=0;Q=q[a- -64>>2];O=q[a+72>>2];F=Q+(O>>>3)|0;R=q[a+68>>2];if(F>>>0>=R>>>0){break a}P=r[F|0];F=O+1|0;q[a+72>>2]=F;if(!(P>>>(O&7)&1)){break a}P=F>>>3;b=Q+P|0;b:{if(b>>>0>=R>>>0){b=F;F=0;break b}S=r[b|0];b=O+2|0;q[a+72>>2]=b;P=b>>>3;F=S>>>(F&7)&1}O=P+Q|0;if(O>>>0>>0){O=r[O|0];q[a+72>>2]=b+1;b=O>>>(b&7)<<1&2}else{b=0}b=(F|b)<<1|1}q[a+168>>2]=b;return b}function Pi(a,w){var T=0,U=0,V=0,W=0,X=0;W=-1;U=-1;a:{if((w|0)==-1){break a}U=w+1|0;W=(U>>>0)%3|0?U:w+ -2|0;U=w+ -1|0;if((w>>>0)%3){break a}U=w+2|0}T=q[a+168>>2];b:{if(T>>>0>7){break b}c:{d:{switch(T-2|0){default:T=q[a+148>>2];V=1;w=q[a+156>>2];X=w+(((W|0)!=-1?q[q[T>>2]+(W<<2)>>2]:-1)<<2)|0;q[X>>2]=q[X>>2]+1;w=(((U|0)!=-1?q[q[T>>2]+(U<<2)>>2]:-1)<<2)+w|0;break c;case 3:V=q[a+148>>2];T=-1;T=((w|0)!=-1?q[q[V>>2]+(w<<2)>>2]:T)<<2;w=q[a+156>>2];T=T+w|0;q[T>>2]=q[T>>2]+1;T=(((W|0)!=-1?q[q[V>>2]+(W<<2)>>2]:-1)<<2)+w|0;q[T>>2]=q[T>>2]+1;T=-1;T=(U|0)!=-1?q[q[V>>2]+(U<<2)>>2]:T;V=2;w=w+(T<<2)|0;break c;case 1:V=q[a+148>>2];T=-1;T=((w|0)!=-1?q[q[V>>2]+(w<<2)>>2]:T)<<2;w=q[a+156>>2];T=T+w|0;q[T>>2]=q[T>>2]+1;T=(((W|0)!=-1?q[q[V>>2]+(W<<2)>>2]:-1)<<2)+w|0;q[T>>2]=q[T>>2]+2;w=(((U|0)!=-1?q[q[V>>2]+(U<<2)>>2]:-1)<<2)+w|0;V=1;break c;case 0:case 2:case 4:break b;case 5:break d}}V=q[a+148>>2];T=-1;T=((w|0)!=-1?q[q[V>>2]+(w<<2)>>2]:T)<<2;w=q[a+156>>2];T=T+w|0;q[T>>2]=q[T>>2]+2;T=(((W|0)!=-1?q[q[V>>2]+(W<<2)>>2]:-1)<<2)+w|0;q[T>>2]=q[T>>2]+2;T=-1;T=(U|0)!=-1?q[q[V>>2]+(U<<2)>>2]:T;V=2;w=w+(T<<2)|0}q[w>>2]=q[w>>2]+V}T=-1;T=(W|0)!=-1?q[q[q[a+148>>2]>>2]+(W<<2)>>2]:T;W=q[a+176>>2];w=W;U=a;T=q[q[a+156>>2]+(T<<2)>>2];if((T|0)>=(w|0)){a=q[a+180>>2];w=(T|0)>(a|0)?a:T}q[U+172>>2]=w-W}function Qi(a){a=a|0;var w=0,Y=0,Z=0,_=0,$=0;q[a>>2]=11272;w=a+368|0;Z=q[w>>2];q[w>>2]=0;if(Z){Y=Z+ -4|0;w=q[Y>>2];if(w){w=Z+(w<<4)|0;while(1){w=w+ -16|0;if((Z|0)!=(w|0)){continue}break}}An(Y)}Z=q[a+216>>2];if(Z){$=a+220|0;w=q[$>>2];Y=Z;a:{if((Z|0)==(w|0)){break a}while(1){Y=q[w+ -12>>2];if(Y){q[w+ -8>>2]=Y;An(Y)}Y=q[w+ -28>>2];if(Y){q[w+ -24>>2]=Y;An(Y)}Y=w+ -144|0;_=q[w+ -40>>2];if(_){q[w+ -36>>2]=_;An(_)}pi(w+ -140|0);w=Y;if((Z|0)!=(w|0)){continue}break}Y=q[a+216>>2]}q[$>>2]=Z;An(Y)}w=q[a+196>>2];if(w){q[a+200>>2]=w;An(w)}w=q[a+184>>2];if(w){q[a+188>>2]=w;An(w)}w=q[a+172>>2];if(w){q[a+176>>2]=w;An(w)}w=q[a+160>>2];if(w){q[a+164>>2]=w;An(w)}w=q[a+144>>2];if(w){while(1){Z=q[w>>2];An(w);w=Z;if(w){continue}break}}Z=a+136|0;w=q[Z>>2];q[Z>>2]=0;if(w){An(w)}w=q[a+120>>2];if(w){An(w)}w=q[a+108>>2];if(w){An(w)}w=q[a+96>>2];if(w){An(w)}w=q[a+72>>2];if(w){q[a+76>>2]=w;An(w)}w=q[a+60>>2];if(w){An(w)}w=q[a+48>>2];if(w){q[a+52>>2]=w;An(w)}w=q[a+36>>2];if(w){q[a+40>>2]=w;An(w)}w=q[a+24>>2];if(w){q[a+28>>2]=w;An(w)}w=q[a+12>>2];if(w){q[a+16>>2]=w;An(w)}w=q[a+8>>2];q[a+8>>2]=0;if(w){wa(a+8|0,w)}return a|0}function Ri(a){a=a|0;An(Qi(a))}function Si(a){a=a|0;var aa=0,ba=0,ca=0,da=0,ea=0;q[a>>2]=11324;aa=q[a+388>>2];if(aa){q[a+392>>2]=aa;An(aa)}aa=a+368|0;ca=q[aa>>2];q[aa>>2]=0;if(ca){ba=ca+ -4|0;aa=q[ba>>2];if(aa){aa=ca+(aa<<4)|0;while(1){aa=aa+ -16|0;if((ca|0)!=(aa|0)){continue}break}}An(ba)}ca=q[a+216>>2];if(ca){ea=a+220|0;aa=q[ea>>2];ba=ca;a:{if((ca|0)==(aa|0)){break a}while(1){ba=q[aa+ -12>>2];if(ba){q[aa+ -8>>2]=ba;An(ba)}ba=q[aa+ -28>>2];if(ba){q[aa+ -24>>2]=ba;An(ba)}ba=aa+ -144|0;da=q[aa+ -40>>2];if(da){q[aa+ -36>>2]=da;An(da)}pi(aa+ -140|0);aa=ba;if((ca|0)!=(aa|0)){continue}break}ba=q[a+216>>2]}q[ea>>2]=ca;An(ba)}aa=q[a+196>>2];if(aa){q[a+200>>2]=aa;An(aa)}aa=q[a+184>>2];if(aa){q[a+188>>2]=aa;An(aa)}aa=q[a+172>>2];if(aa){q[a+176>>2]=aa;An(aa)}aa=q[a+160>>2];if(aa){q[a+164>>2]=aa;An(aa)}aa=q[a+144>>2];if(aa){while(1){ca=q[aa>>2];An(aa);aa=ca;if(aa){continue}break}}ca=a+136|0;aa=q[ca>>2];q[ca>>2]=0;if(aa){An(aa)}aa=q[a+120>>2];if(aa){An(aa)}aa=q[a+108>>2];if(aa){An(aa)}aa=q[a+96>>2];if(aa){An(aa)}aa=q[a+72>>2];if(aa){q[a+76>>2]=aa;An(aa)}aa=q[a+60>>2];if(aa){An(aa)}aa=q[a+48>>2];if(aa){q[a+52>>2]=aa;An(aa)}aa=q[a+36>>2];if(aa){q[a+40>>2]=aa;An(aa)}aa=q[a+24>>2];if(aa){q[a+28>>2]=aa;An(aa)}aa=q[a+12>>2];if(aa){q[a+16>>2]=aa;An(aa)}aa=q[a+8>>2];q[a+8>>2]=0;if(aa){wa(a+8|0,aa)}return a|0}function Ti(a){a=a|0;An(Si(a))}function Ui(a){a=a|0;var fa=0,ga=0,ha=0,ia=0,ja=0;q[a>>2]=11372;Vi(a+232|0);ia=q[a+216>>2];if(ia){ga=ia;ja=a+220|0;fa=q[ja>>2];ha=ga;a:{if((ga|0)==(fa|0)){break a}while(1){ga=q[fa+ -12>>2];if(ga){q[fa+ -8>>2]=ga;An(ga)}ga=q[fa+ -28>>2];if(ga){q[fa+ -24>>2]=ga;An(ga)}ga=fa+ -144|0;ha=q[fa+ -40>>2];if(ha){q[fa+ -36>>2]=ha;An(ha)}pi(fa+ -140|0);fa=ga;if((ia|0)!=(fa|0)){continue}break}ha=q[a+216>>2]}ga=ha;q[ja>>2]=ia;An(ga)}fa=q[a+196>>2];if(fa){q[a+200>>2]=fa;An(fa)}fa=q[a+184>>2];if(fa){q[a+188>>2]=fa;An(fa)}fa=q[a+172>>2];if(fa){q[a+176>>2]=fa;An(fa)}fa=q[a+160>>2];if(fa){q[a+164>>2]=fa;An(fa)}fa=q[a+144>>2];if(fa){while(1){ga=q[fa>>2];An(fa);fa=ga;if(fa){continue}break}}fa=a+136|0;ga=q[fa>>2];q[fa>>2]=0;if(ga){An(ga)}fa=q[a+120>>2];if(fa){An(fa)}fa=q[a+108>>2];if(fa){An(fa)}fa=q[a+96>>2];if(fa){An(fa)}fa=q[a+72>>2];if(fa){q[a+76>>2]=fa;An(fa)}fa=q[a+60>>2];if(fa){An(fa)}fa=q[a+48>>2];if(fa){q[a+52>>2]=fa;An(fa)}fa=q[a+36>>2];if(fa){q[a+40>>2]=fa;An(fa)}fa=q[a+24>>2];if(fa){q[a+28>>2]=fa;An(fa)}fa=q[a+12>>2];if(fa){q[a+16>>2]=fa;An(fa)}fa=q[a+8>>2];q[a+8>>2]=0;if(fa){wa(a+8|0,fa)}return a|0}function Vi(a){var ka=0,la=0,ma=0,na=0,oa=0;ka=q[a+196>>2];if(ka){q[a+200>>2]=ka;An(ka)}ka=q[a+184>>2];if(ka){oa=a+188|0;la=q[oa>>2];ma=ka;a:{if((ka|0)==(la|0)){break a}while(1){ma=la+ -12|0;na=q[ma>>2];if(na){q[la+ -8>>2]=na;An(na)}la=ma;if((la|0)!=(ka|0)){continue}break}ma=q[a+184>>2]}q[oa>>2]=ka;An(ma)}ka=q[a+156>>2];if(ka){q[a+160>>2]=ka;An(ka)}ka=a+136|0;a=q[ka>>2];q[ka>>2]=0;if(a){la=a+ -4|0;ka=q[la>>2];if(ka){ka=a+(ka<<4)|0;while(1){ka=ka+ -16|0;if((a|0)!=(ka|0)){continue}break}}An(la)}}function Wi(a){a=a|0;An(Ui(a))}function Xi(a){a=a|0;var pa=0;q[a>>2]=11760;pa=q[a+48>>2];if(pa){q[a+52>>2]=pa;An(pa)}q[a>>2]=12012;pa=q[a+36>>2];if(pa){An(pa)}pa=q[a+24>>2];if(pa){An(pa)}An(a)}function Yi(a){a=a|0;var qa=0;q[a>>2]=12012;qa=q[a+36>>2];if(qa){An(qa)}qa=q[a+24>>2];if(qa){An(qa)}return a|0}function Zi(a){a=a|0;var ra=0;q[a>>2]=12012;ra=q[a+36>>2];if(ra){An(ra)}ra=q[a+24>>2];if(ra){An(ra)}An(a)}function _i(a,sa,ta){a=a|0;sa=sa|0;ta=ta|0;var ua=0,va=0;ua=T-16|0;T=ua;q[a+4>>2]=sa;va=q[sa+4>>2];sa=q[sa>>2];o[ua+15|0]=0;bb(a+24|0,(va-sa>>2>>>0)/3|0,ua+15|0);sa=q[a+4>>2];va=q[sa+28>>2];sa=q[sa+24>>2];o[ua+14|0]=0;bb(a+36|0,va-sa>>2,ua+14|0);sa=q[ta+12>>2];q[a+16>>2]=q[ta+8>>2];q[a+20>>2]=sa;sa=q[ta+4>>2];q[a+8>>2]=q[ta>>2];q[a+12>>2]=sa;T=ua+16|0}function $i(a,sa){var ta=0,wa=0,xa=0;a:{if((a|0)!=(sa|0)){xa=a;ta=q[sa+4>>2];wa=0;b:{if(!ta){break b}c:{if(ta>>>0<=q[a+8>>2]<<5>>>0){wa=q[a>>2];break c}wa=q[a>>2];if(wa){An(wa);q[a+8>>2]=0;q[a>>2]=0;q[a+4>>2]=0;ta=q[sa+4>>2]}if((ta|0)<=-1){break a}ta=(ta+ -1>>>5)+1|0;wa=Mm(ta<<2);q[a+8>>2]=ta;q[a+4>>2]=0;q[a>>2]=wa;ta=q[sa+4>>2]}En(wa,q[sa>>2],(ta+ -1>>>3&536870908)+4|0);wa=q[sa+4>>2]}q[xa+4>>2]=wa}return}bn();F()}function aj(a){a=a|0;var sa=0;q[a>>2]=12336;sa=q[a+88>>2];if(sa){q[a+92>>2]=sa;An(sa)}sa=q[a+72>>2];if(sa){q[a+76>>2]=sa;An(sa)}sa=q[a+60>>2];if(sa){q[a- -64>>2]=sa;An(sa)}sa=q[a+48>>2];if(sa){q[a+52>>2]=sa;An(sa)}q[a>>2]=12572;sa=q[a+36>>2];if(sa){An(sa)}sa=q[a+24>>2];if(sa){An(sa)}return a|0}function bj(a){a=a|0;var ya=0;q[a>>2]=12124;q[a+8>>2]=12336;ya=q[a+96>>2];if(ya){q[a+100>>2]=ya;An(ya)}ya=q[a+80>>2];if(ya){q[a+84>>2]=ya;An(ya)}ya=q[a+68>>2];if(ya){q[a+72>>2]=ya;An(ya)}ya=q[a+56>>2];if(ya){q[a+60>>2]=ya;An(ya)}q[a+8>>2]=12572;ya=q[a+44>>2];if(ya){An(ya)}ya=q[a+32>>2];if(ya){An(ya)}return a|0}function cj(a){a=a|0;var za=0;q[a>>2]=12124;q[a+8>>2]=12336;za=q[a+96>>2];if(za){q[a+100>>2]=za;An(za)}za=q[a+80>>2];if(za){q[a+84>>2]=za;An(za)}za=q[a+68>>2];if(za){q[a+72>>2]=za;An(za)}za=q[a+56>>2];if(za){q[a+60>>2]=za;An(za)}q[a+8>>2]=12572;za=q[a+44>>2];if(za){An(za)}za=q[a+32>>2];if(za){An(za)}An(a)}function dj(a,Aa){a=a|0;Aa=Aa|0;var Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0;Ja=q[a+12>>2];Ba=q[a+108>>2];Ca=q[Ba+80>>2];o[Aa+84|0]=0;Fa=q[Aa+68>>2];Da=q[Aa+72>>2]-Fa>>2;a:{if(Ca>>>0>Da>>>0){md(Aa+68|0,Ca-Da|0,12324);Ba=q[a+108>>2];Ca=q[Ba+80>>2];break a}if(Ca>>>0>=Da>>>0){break a}q[Aa+72>>2]=Fa+(Ca<<2)}Ia=q[Ba+96>>2];Ba=q[Ba+100>>2]-Ia|0;Ka=(Ba|0)/12|0;if(!Ba){return 1}La=Aa+68|0;Aa=0;b:{while(1){c:{if((Aa|0)==1431655765){break c}Ba=q[Ja>>2]+(w(Aa,3)<<2)|0;Fa=q[Ba>>2];if((Fa|0)==-1){break c}Da=w(Aa,12)+Ia|0;Ga=q[Da>>2];if(Ga>>>0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c}q[a+100>>2]=Oa+(Aa<<2)}Oa=a+8|0;d:{e:{Aa=q[a+116>>2];if(Aa){Na=q[Aa>>2];Ma=1;if((Na|0)==q[Aa+4>>2]){break d}Aa=0;while(1){if(!fj(Oa,q[(Aa<<2)+Na>>2])){break e}Ma=q[a+116>>2];Na=q[Ma>>2];Aa=Aa+1|0;if(Aa>>>0>2]-Na>>2>>>0){continue}break}Ma=1;break d}Aa=0;a=q[a+12>>2];a=(q[a+4>>2]-q[a>>2]>>2>>>0)/3|0;Ma=1;if((a|0)<=0){break d}while(1){if(!fj(Oa,w(Aa,3))){break e}Aa=Aa+1|0;if(Aa>>>0>>0){continue}break}Ma=1;break d}Ma=0}T=Pa+16|0;return Ma|0}ab(12024);F()}function fj(a,Ua){var Va=0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0;Ya=T-32|0;T=Ya;q[Ya+8>>2]=Ua;a:{if(q[a+92>>2]==q[a+88>>2]){break a}Xa=a+52|0;Va=q[Xa>>2];b:{if((Va|0)!=q[a+56>>2]){q[Va>>2]=Ua;q[Xa>>2]=Va+4;break b}zi(a+48|0,Ya+8|0)}q[a+84>>2]=0;Ua=-1;Xa=-1;Va=q[Ya+8>>2];c:{if((Va|0)==-1){break c}Wa=q[a+4>>2];Za=Va+1|0;Za=(Za>>>0)%3|0?Za:Va+ -2|0;if((Za|0)!=-1){Ua=q[q[Wa>>2]+(Za<<2)>>2]}Va=Va+((Va>>>0)%3|0?-1:2)|0;if((Va|0)==-1){break c}Xa=q[q[Wa>>2]+(Va<<2)>>2]}Va=q[a+36>>2];Wa=Va+(Ua>>>3&536870908)|0;Za=q[Wa>>2];$a=1<<(Ua&31);if(!(Za&$a)){q[Wa>>2]=Za|$a;Va=-1;Wa=q[Ya+8>>2];if((Wa|0)!=-1){Va=Wa+1|0;Va=(Va>>>0)%3|0?Va:Wa+ -2|0}q[Ya+16>>2]=Va;Wa=q[a+20>>2];Za=(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+(_a>>>3&536870908)>>2]>>>(_a&31)&1)){_a=q[cb>>2]+(_a<<2)|0;Wa=q[_a>>2];q[_a>>2]=Wa+1;Wa=(Wa|0)<1?2:1}if((Wa|0)<=q[a+84>>2]?ab:0){break r}q[Ya+24>>2]=Ua;bb=w(Wa,12)+a|0;ab=bb+52|0;_a=q[ab>>2];u:{if((_a|0)!=q[bb+56>>2]){q[_a>>2]=Ua;q[ab>>2]=_a+4;break u}zi(bb+48|0,Ya+24|0)}if(q[a+84>>2]<=(Wa|0)){break t}q[a+84>>2]=Wa}if(Xa){break m}}Ua=-1;Xa=0;Ua=(Va|0)!=-1?q[q[q[db>>2]>>2]+(Va<<2)>>2]:Ua;if(!(q[q[$a>>2]+(Ua>>>3&536870908)>>2]>>>(Ua&31)&1)){Xa=q[cb>>2]+(Ua<<2)|0;Ua=q[Xa>>2];q[Xa>>2]=Ua+1;Xa=(Ua|0)<1?2:1}if((Xa|0)>q[a+84>>2]){break q}Ua=Va}q[Ya+8>>2]=Ua;Xa=q[Za>>2];continue}break}q[Ya+24>>2]=Va;Wa=w(Xa,12)+a|0;_a=Wa+52|0;Ua=q[_a>>2];v:{if((Ua|0)!=q[Wa+56>>2]){q[Ua>>2]=Va;q[_a>>2]=Ua+4;break v}zi(Wa+48|0,Ya+24|0)}Va=q[a+84>>2];if((Va|0)<=(Xa|0)){break l}q[a+84>>2]=Xa;Va=Xa;break l}Va=q[a+84>>2]}if((Va|0)<3){continue}break}}q[Ya+8>>2]=-1}T=Ya+32|0;return 1}function gj(a){a=a|0;var Ua=0;q[a>>2]=12336;Ua=q[a+88>>2];if(Ua){q[a+92>>2]=Ua;An(Ua)}Ua=q[a+72>>2];if(Ua){q[a+76>>2]=Ua;An(Ua)}Ua=q[a+60>>2];if(Ua){q[a- -64>>2]=Ua;An(Ua)}Ua=q[a+48>>2];if(Ua){q[a+52>>2]=Ua;An(Ua)}q[a>>2]=12572;Ua=q[a+36>>2];if(Ua){An(Ua)}Ua=q[a+24>>2];if(Ua){An(Ua)}An(a)}function hj(a){a=a|0;var gb=0;q[a>>2]=12572;gb=q[a+36>>2];if(gb){An(gb)}gb=q[a+24>>2];if(gb){An(gb)}return a|0}function ij(a){a=a|0;var hb=0;q[a>>2]=12572;hb=q[a+36>>2];if(hb){An(hb)}hb=q[a+24>>2];if(hb){An(hb)}An(a)}function jj(a){a=a|0;var ib=0;q[a>>2]=12756;ib=q[a+48>>2];if(ib){q[a+52>>2]=ib;An(ib)}q[a>>2]=12572;ib=q[a+36>>2];if(ib){An(ib)}ib=q[a+24>>2];if(ib){An(ib)}return a|0}function kj(a){a=a|0;var jb=0,kb=0;q[a>>2]=12592;kb=a+8|0;q[kb>>2]=12756;jb=q[a+56>>2];if(jb){q[a+60>>2]=jb;An(jb)}q[kb>>2]=12572;jb=q[a+44>>2];if(jb){An(jb)}jb=q[a+32>>2];if(jb){An(jb)}return a|0}function lj(a){a=a|0;var lb=0,mb=0;q[a>>2]=12592;mb=a+8|0;q[mb>>2]=12756;lb=q[a+56>>2];if(lb){q[a+60>>2]=lb;An(lb)}q[mb>>2]=12572;lb=q[a+44>>2];if(lb){An(lb)}lb=q[a+32>>2];if(lb){An(lb)}An(a)}function mj(a,nb){a=a|0;nb=nb|0;var ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0;wb=q[a+12>>2];ob=q[a+68>>2];pb=q[ob+80>>2];o[nb+84|0]=0;sb=q[nb+68>>2];qb=q[nb+72>>2]-sb>>2;a:{if(pb>>>0>qb>>>0){md(nb+68|0,pb-qb|0,12324);ob=q[a+68>>2];pb=q[ob+80>>2];break a}if(pb>>>0>=qb>>>0){break a}q[nb+72>>2]=sb+(pb<<2)}vb=q[ob+96>>2];ob=q[ob+100>>2]-vb|0;xb=(ob|0)/12|0;if(!ob){return 1}yb=nb+68|0;nb=0;b:{while(1){c:{if((nb|0)==1431655765){break c}ob=q[wb>>2]+(w(nb,3)<<2)|0;sb=q[ob>>2];if((sb|0)==-1){break c}qb=w(nb,12)+vb|0;tb=q[qb>>2];if(tb>>>0>=pb>>>0){break c}rb=sb<<2;sb=q[q[a+72>>2]+12>>2];rb=q[rb+sb>>2];if(rb>>>0>=pb>>>0){break c}ub=tb<<2;tb=q[yb>>2];q[ub+tb>>2]=rb;rb=q[ob+4>>2];if((rb|0)==-1){break c}ub=q[qb+4>>2];if(ub>>>0>=pb>>>0){break c}rb=q[sb+(rb<<2)>>2];if(rb>>>0>=pb>>>0){break c}q[tb+(ub<<2)>>2]=rb;ob=q[ob+8>>2];if((ob|0)==-1){break c}qb=q[qb+8>>2];if(qb>>>0>=pb>>>0){break c}ob=q[sb+(ob<<2)>>2];if(ob>>>0>=pb>>>0){break c}q[tb+(qb<<2)>>2]=ob;ob=1;nb=nb+1|0;if(nb>>>0>>0){continue}break b}break}ob=0}return ob|0}function nj(a){a=a|0;var nb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0;Bb=q[a+4>>2];nb=q[Bb>>2];a:{zb=q[a+12>>2];Ab=q[zb+28>>2]-q[zb+24>>2]|0;zb=Ab>>2;b:{if(q[Bb+8>>2]-nb>>2>>>0>=zb>>>0){break b}if(zb>>>0>=1073741824){break a}Eb=Bb+4|0;Cb=q[Eb>>2];Db=zb<<2;zb=Mm(Ab);Db=Db+zb|0;Ab=Cb-nb|0;Cb=Ab+zb|0;if((Ab|0)>=1){Cn(zb,nb,Ab)}q[Bb>>2]=zb;q[Bb+8>>2]=Db;q[Eb>>2]=Cb;if(!nb){break b}An(nb)}zb=a+8|0;c:{d:{nb=q[a+76>>2];if(nb){Bb=q[nb>>2];Ab=1;if((Bb|0)==q[nb+4>>2]){break c}nb=0;while(1){if(!oj(zb,q[(nb<<2)+Bb>>2])){break d}Ab=q[a+76>>2];Bb=q[Ab>>2];nb=nb+1|0;if(nb>>>0>2]-Bb>>2>>>0){continue}break}return 1}nb=0;a=q[a+12>>2];a=(q[a+4>>2]-q[a>>2]>>2>>>0)/3|0;if((a|0)<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Nb>>2];if((Fb|0)!=q[a+48>>2]){continue}break}}T=Kb+32|0;return Jb}function pj(a){a=a|0;var Fb=0;q[a>>2]=12756;Fb=q[a+48>>2];if(Fb){q[a+52>>2]=Fb;An(Fb)}q[a>>2]=12572;Fb=q[a+36>>2];if(Fb){An(Fb)}Fb=q[a+24>>2];if(Fb){An(Fb)}An(a)}function qj(a){a=a|0;var Vb=0,Wb=0;q[a>>2]=12884;Wb=a+8|0;q[Wb>>2]=11760;Vb=q[a+56>>2];if(Vb){q[a+60>>2]=Vb;An(Vb)}q[Wb>>2]=12012;Vb=q[a+44>>2];if(Vb){An(Vb)}Vb=q[a+32>>2];if(Vb){An(Vb)}return a|0}function rj(a){a=a|0;var Xb=0,Yb=0;q[a>>2]=12884;Yb=a+8|0;q[Yb>>2]=11760;Xb=q[a+56>>2];if(Xb){q[a+60>>2]=Xb;An(Xb)}q[Yb>>2]=12012;Xb=q[a+44>>2];if(Xb){An(Xb)}Xb=q[a+32>>2];if(Xb){An(Xb)}An(a)}function sj(a,Zb){a=a|0;Zb=Zb|0;var _b=0,$b=0,ac=0,bc=0,cc=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0;dc=q[a+12>>2];_b=q[a+68>>2];$b=q[_b+80>>2];o[Zb+84|0]=0;cc=q[Zb+68>>2];ac=q[Zb+72>>2]-cc>>2;a:{if($b>>>0>ac>>>0){md(Zb+68|0,$b-ac|0,12324);_b=q[a+68>>2];$b=q[_b+80>>2];break a}if($b>>>0>=ac>>>0){break a}q[Zb+72>>2]=cc+($b<<2)}fc=q[_b+96>>2];_b=q[_b+100>>2]-fc|0;gc=(_b|0)/12|0;if(!_b){return 1}hc=q[dc+28>>2];ic=Zb+68|0;Zb=0;b:{while(1){c:{_b=(w(Zb,3)<<2)+hc|0;dc=q[_b>>2];if((dc|0)==-1){break c}ac=w(Zb,12)+fc|0;cc=q[ac>>2];if(cc>>>0>=$b>>>0){break c}bc=dc<<2;dc=q[q[a+72>>2]+12>>2];bc=q[bc+dc>>2];if(bc>>>0>=$b>>>0){break c}ec=cc<<2;cc=q[ic>>2];q[ec+cc>>2]=bc;bc=q[_b+4>>2];if((bc|0)==-1){break c}ec=q[ac+4>>2];if(ec>>>0>=$b>>>0){break c}bc=q[dc+(bc<<2)>>2];if(bc>>>0>=$b>>>0){break c}q[cc+(ec<<2)>>2]=bc;_b=q[_b+8>>2];if((_b|0)==-1){break c}ac=q[ac+8>>2];if(ac>>>0>=$b>>>0){break c}_b=q[dc+(_b<<2)>>2];if(_b>>>0>=$b>>>0){break c}q[cc+(ac<<2)>>2]=_b;_b=1;Zb=Zb+1|0;if(Zb>>>0>>0){continue}break b}break}_b=0}return _b|0}function tj(a){a=a|0;var Zb=0,jc=0,kc=0,lc=0,mc=0,nc=0,oc=0;lc=q[a+4>>2];Zb=q[lc>>2];a:{jc=q[a+12>>2];kc=q[jc+56>>2]-q[jc+52>>2]|0;jc=kc>>2;b:{if(q[lc+8>>2]-Zb>>2>>>0>=jc>>>0){break b}if(jc>>>0>=1073741824){break a}oc=lc+4|0;mc=q[oc>>2];nc=jc<<2;jc=Mm(kc);nc=nc+jc|0;kc=mc-Zb|0;mc=kc+jc|0;if((kc|0)>=1){Cn(jc,Zb,kc)}q[lc>>2]=jc;q[lc+8>>2]=nc;q[oc>>2]=mc;if(!Zb){break b}An(Zb)}jc=a+8|0;c:{d:{Zb=q[a+76>>2];if(Zb){lc=q[Zb>>2];kc=1;if((lc|0)==q[Zb+4>>2]){break c}Zb=0;while(1){if(!uj(jc,q[(Zb<<2)+lc>>2])){break d}kc=q[a+76>>2];lc=q[kc>>2];Zb=Zb+1|0;if(Zb>>>0>2]-lc>>2>>>0){continue}break}return 1}Zb=0;a=q[q[a+12>>2]+64>>2];a=(q[a+4>>2]-q[a>>2]>>2>>>0)/3|0;if((a|0)<=0){return 1}while(1){if(!uj(jc,w(Zb,3))){break d}Zb=Zb+1|0;if(Zb>>>0>>0){continue}break}return 1}kc=0}return kc|0}ab(12024);F()}function uj(a,pc){var qc=0,rc=0,sc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0,Ac=0,Bc=0,Cc=0,Dc=0,Ec=0;uc=T-32|0;T=uc;q[uc+8>>2]=pc;a:{if((pc|0)==-1){qc=1;break a}qc=1;tc=(pc>>>0)/3|0;if(q[q[a+24>>2]+(tc>>>3&268435452)>>2]>>>(tc&31)&1){break a}tc=a+52|0;qc=q[a+48>>2];q[tc>>2]=qc;zc=a+48|0;b:{if((qc|0)!=q[a+56>>2]){q[qc>>2]=pc;q[tc>>2]=qc+4;break b}zi(zc,uc+8|0)}rc=-1;qc=q[a+4>>2];pc=q[uc+8>>2];c:{if((pc|0)==-1){tc=q[qc+28>>2];qc=q[tc+ -4>>2];break c}tc=q[qc+28>>2];qc=pc+1|0;qc=q[tc+(((qc>>>0)%3|0?qc:pc+ -2|0)<<2)>>2];if((pc>>>0)%3){rc=pc+ -1|0;break c}rc=pc+2|0}if((qc|0)==-1){qc=0;break a}tc=q[(rc<<2)+tc>>2];if((tc|0)==-1){qc=0;break a}pc=q[a+36>>2];sc=pc+(qc>>>3&536870908)|0;rc=q[sc>>2];vc=1<<(qc&31);if(!(rc&vc)){q[sc>>2]=rc|vc;rc=-1;pc=q[uc+8>>2];if((pc|0)!=-1){sc=pc+1|0;rc=(sc>>>0)%3|0?sc:pc+ -2|0}q[uc+16>>2]=rc;pc=q[a+20>>2];sc=(rc>>>0)/3|0;rc=q[(q[q[a+16>>2]+96>>2]+w(sc,12)|0)+(rc-w(sc,3)<<2)>>2];q[uc+24>>2]=rc;sc=q[pc+4>>2];vc=sc+4|0;pc=q[vc>>2];d:{if((pc|0)!=q[sc+8>>2]){q[pc>>2]=rc;q[vc>>2]=pc+4;break d}zi(sc,uc+24|0)}sc=a+12|0;rc=q[sc>>2];vc=rc+4|0;pc=q[vc>>2];e:{if((pc|0)!=q[rc+8>>2]){q[pc>>2]=q[uc+16>>2];q[vc>>2]=pc+4;break e}zi(rc,uc+16|0);rc=q[sc>>2]}q[q[rc+12>>2]+(qc<<2)>>2]=q[rc+24>>2];q[rc+24>>2]=q[rc+24>>2]+1;pc=q[a+36>>2]}pc=(tc>>>3&536870908)+pc|0;qc=q[pc>>2];sc=1<<(tc&31);if(!(qc&sc)){q[pc>>2]=qc|sc;pc=uc;rc=pc;sc=q[pc+8>>2];qc=-1;f:{if((sc|0)==-1){break f}qc=sc+ -1|0;if((sc>>>0)%3){break f}qc=sc+2|0}q[rc+16>>2]=qc;pc=q[a+20>>2];sc=(qc>>>0)/3|0;sc=q[(q[q[a+16>>2]+96>>2]+w(sc,12)|0)+(qc-w(sc,3)<<2)>>2];q[uc+24>>2]=sc;qc=q[pc+4>>2];rc=qc+4|0;pc=q[rc>>2];g:{if((pc|0)!=q[qc+8>>2]){q[pc>>2]=sc;q[rc>>2]=pc+4;break g}zi(qc,uc+24|0)}sc=a+12|0;qc=q[sc>>2];rc=qc+4|0;pc=q[rc>>2];h:{if((pc|0)!=q[qc+8>>2]){q[pc>>2]=q[uc+16>>2];q[rc>>2]=pc+4;break h}zi(qc,uc+16|0);qc=q[sc>>2]}q[q[qc+12>>2]+(tc<<2)>>2]=q[qc+24>>2];q[qc+24>>2]=q[qc+24>>2]+1}vc=a+52|0;pc=q[vc>>2];if((pc|0)==q[a+48>>2]){qc=1;break a}xc=a+24|0;yc=a+4|0;Bc=a+36|0;Cc=a+16|0;Dc=a+20|0;Ec=a+56|0;while(1){tc=pc+ -4|0;pc=q[tc>>2];q[uc+8>>2]=pc;qc=(pc>>>0)/3|0;i:{j:{k:{if((pc|0)==-1){break k}pc=q[xc>>2]+(qc>>>3&268435452)|0;sc=q[pc>>2];qc=1<<(qc&31);if(sc&qc){break k}q[pc>>2]=qc|sc;rc=q[yc>>2];pc=q[uc+8>>2];qc=q[q[rc+28>>2]+(pc<<2)>>2];if((qc|0)!=-1){break j}qc=0;break a}q[vc>>2]=tc;break i}l:{m:{n:{while(1){o:{p:{tc=q[Bc>>2]+(qc>>>3&536870908)|0;sc=q[tc>>2];wc=1<<(qc&31);if(sc&wc){break p}Ac=qc<<2;qc=q[Ac+q[rc+40>>2]>>2];pc=1;q:{if((qc|0)==-1){break q}pc=qc+1|0;pc=(pc>>>0)%3|0?pc:qc+ -2|0;r:{if((pc|0)==-1|q[q[rc>>2]+(pc>>>3&536870908)>>2]>>>(pc&31)&1){break r}qc=q[q[q[rc+64>>2]+12>>2]+(pc<<2)>>2];if((qc|0)==-1){break r}rc=qc+1|0;pc=0;if((((rc>>>0)%3|0?rc:qc+ -2|0)|0)!=-1){break q}}pc=1}qc=pc;q[tc>>2]=sc|wc;pc=q[uc+8>>2];q[uc+16>>2]=pc;tc=q[Dc>>2];sc=(pc>>>0)/3|0;sc=q[(q[q[Cc>>2]+96>>2]+w(sc,12)|0)+(pc-w(sc,3)<<2)>>2];q[uc+24>>2]=sc;tc=q[tc+4>>2];rc=tc+4|0;pc=q[rc>>2];s:{if((pc|0)!=q[tc+8>>2]){q[pc>>2]=sc;q[rc>>2]=pc+4;break s}zi(tc,uc+24|0)}sc=a+12|0;pc=q[sc>>2];rc=pc+4|0;tc=q[rc>>2];t:{if((tc|0)!=q[pc+8>>2]){q[tc>>2]=q[uc+16>>2];q[rc>>2]=tc+4;break t}zi(pc,uc+16|0);pc=q[sc>>2]}q[q[pc+12>>2]+Ac>>2]=q[pc+24>>2];q[pc+24>>2]=q[pc+24>>2]+1;rc=q[yc>>2];pc=q[uc+8>>2];if(qc){break p}qc=-1;u:{if((pc|0)==-1){break u}tc=pc+1|0;pc=(tc>>>0)%3|0?tc:pc+ -2|0;if((pc|0)==-1|q[q[rc>>2]+(pc>>>3&536870908)>>2]>>>(pc&31)&1){break u}qc=q[q[q[rc+64>>2]+12>>2]+(pc<<2)>>2]}q[uc+8>>2]=qc;pc=(qc>>>0)/3|0;break o}if((pc|0)==-1){break m}tc=-1;sc=uc;wc=pc+1|0;wc=(wc>>>0)%3|0?wc:pc+ -2|0;qc=-1;v:{if((wc|0)==-1){break v}qc=-1;if(q[q[rc>>2]+(wc>>>3&536870908)>>2]>>>(wc&31)&1){break v}qc=q[q[q[rc+64>>2]+12>>2]+(wc<<2)>>2]}q[sc+24>>2]=qc;pc=((pc>>>0)%3|0?-1:2)+pc|0;if(!((pc|0)==-1|q[q[rc>>2]+(pc>>>3&536870908)>>2]>>>(pc&31)&1)){tc=q[q[q[rc+64>>2]+12>>2]+(pc<<2)>>2]}sc=(tc>>>0)/3|0;pc=(qc>>>0)/3|0;rc=(qc|0)==-1;w:{if(rc){pc=-1;rc=1;break w}rc=rc?-1:pc;rc=q[q[xc>>2]+(rc>>>3&536870908)>>2]>>>(rc&31)&1}x:{if((tc|0)!=-1){wc=(tc|0)==-1?-1:sc;wc=q[q[xc>>2]+(wc>>>3&536870908)>>2]&1<<(wc&31);if(rc){qc=tc;pc=sc;if(!wc){break x}break l}if(wc){break x}pc=q[vc>>2];q[pc+ -4>>2]=tc;if((pc|0)==q[Ec>>2]){break n}q[pc>>2]=q[uc+24>>2];q[vc>>2]=pc+4;break i}if(rc){break l}}q[uc+8>>2]=qc}qc=q[xc>>2]+(pc>>>3&536870908)|0;q[qc>>2]=q[qc>>2]|1<<(pc&31);rc=q[yc>>2];pc=q[uc+8>>2];qc=q[q[rc+28>>2]+(pc<<2)>>2];if((qc|0)!=-1){continue}break}qc=0;break a}zi(zc,uc+24|0);break i}q[uc+24>>2]=-1}q[vc>>2]=q[vc>>2]+ -4}qc=1;pc=q[vc>>2];if((pc|0)!=q[a+48>>2]){continue}break}}T=uc+32|0;return qc}function vj(a,pc){var Fc=0,Gc=0,Hc=0;q[a>>2]=q[pc>>2];q[a+4>>2]=q[pc+4>>2];q[a+8>>2]=q[pc+8>>2];Fc=pc+12|0;q[a+12>>2]=q[Fc>>2];q[Fc>>2]=0;q[pc+4>>2]=0;q[pc+8>>2]=0;Fc=pc+16|0;q[a+16>>2]=q[Fc>>2];q[a+20>>2]=q[pc+20>>2];Gc=pc+24|0;q[a+24>>2]=q[Gc>>2];q[Gc>>2]=0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fc>>2]=0;q[Fc+4>>2]=0;Fc=r[pc+100|0];Gc=a+112|0;q[Gc>>2]=0;q[a+104>>2]=0;q[a+108>>2]=0;o[a+100|0]=Fc;q[a+104>>2]=q[pc+104>>2];q[a+108>>2]=q[pc+108>>2];Fc=pc+112|0;q[Gc>>2]=q[Fc>>2];q[Fc>>2]=0;q[pc+104>>2]=0;q[pc+108>>2]=0;Gc=a+124|0;q[Gc>>2]=0;Fc=a+116|0;q[Fc>>2]=0;q[Fc+4>>2]=0;Hc=Fc;Fc=pc+116|0;q[Hc>>2]=q[Fc>>2];q[a+120>>2]=q[pc+120>>2];Hc=Gc;Gc=pc+124|0;q[Hc>>2]=q[Gc>>2];q[Gc>>2]=0;q[Fc>>2]=0;q[Fc+4>>2]=0;Fc=q[pc+128>>2];Gc=a+140|0;q[Gc>>2]=0;q[a+132>>2]=0;q[a+136>>2]=0;q[a+128>>2]=Fc;q[a+132>>2]=q[pc+132>>2];q[a+136>>2]=q[pc+136>>2];Fc=pc+140|0;q[Gc>>2]=q[Fc>>2];q[Fc>>2]=0;q[pc+132>>2]=0;q[pc+136>>2]=0;return a}function wj(a){var pc=0,Ic=0,Jc=0;Ic=q[a+8>>2];Jc=q[a+4>>2];if((Ic|0)!=(Jc|0)){while(1){pc=Ic+ -144|0;q[a+8>>2]=pc;pc=q[pc+132>>2];if(pc){q[Ic+ -8>>2]=pc;An(pc)}pc=q[Ic+ -28>>2];if(pc){q[Ic+ -24>>2]=pc;An(pc)}pc=q[Ic+ -40>>2];if(pc){q[Ic+ -36>>2]=pc;An(pc)}pi(Ic+ -140|0);Ic=q[a+8>>2];if((Jc|0)!=(Ic|0)){continue}break}}a=q[a>>2];if(a){An(a)}}function xj(a,Kc){var Lc=0,Mc=0,Nc=x(0);Lc=2;a:{if((Kc|0)==1){break a}Lc=Kc;if(!(Kc+ -1&Kc)){break a}Lc=jm(Kc)}Mc=q[a+4>>2];if(Lc>>>0>Mc>>>0){yj(a,Lc);return}b:{if(Lc>>>0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q[cd>>2];q[Yc>>2]=q[Yc>>2]+12}gd=gd+1|0;if((hd|0)==(gd|0)){break c}Yc=q[ld>>2];Kc=Yc;bd=q[Kc+16>>2];Xc=q[Kc+20>>2];q[cd>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;$c=q[Kc+12>>2];ad=$c;ed=q[Kc+8>>2];fd=ed;Kc=Xc;_c=bd+2|0;if(_c>>>0<2){Kc=Kc+1|0}dd=_c;_c=Kc;if(($c|0)>(Kc|0)?1:($c|0)>=(Kc|0)?fd>>>0

>>0?0:1:0){continue}break}break d}g:{if(t[q[a+44>>2]+80>>2]>2097151){break g}_c=s[a+36>>1];if((_c<<24|_c<<8&16711680)>>>16>>>0<514){break g}if(!hd){break c}_c=Zc+16|0;q[_c>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;if(!Aj(1,Zc+4|0,Yc)){break d}Kc=a+32|0;$c=a+44|0;while(1){q[Zc+8>>2]=q[Zc+4>>2];if(!Aj(1,Zc+4|0,q[Kc>>2])){break d}q[Zc+12>>2]=q[Zc+4>>2];if(!Aj(1,Zc+4|0,q[Kc>>2])){break d}q[Zc+16>>2]=q[Zc+4>>2];Yc=q[$c>>2];ad=Yc+100|0;Xc=q[ad>>2];h:{if((Xc|0)==q[Yc+104>>2]){Cj(Yc+96|0,Zc+8|0);break h}Yc=q[Zc+12>>2];q[Xc>>2]=q[Zc+8>>2];q[Xc+4>>2]=Yc;q[Xc+8>>2]=q[_c>>2];q[ad>>2]=q[ad>>2]+12}cd=cd+1|0;if((cd|0)==(hd|0)){break c}Xc=q[Kc>>2];q[_c>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;if(Aj(1,Zc+4|0,Xc)){continue}break}break d}if(!hd){break c}gd=Zc+16|0;q[gd>>2]=0;q[Zc+8>>2]=0;q[Zc+12>>2]=0;ad=q[Yc+12>>2];cd=ad;_c=$c+5|0;if(_c>>>0<5){Kc=Kc+1|0}ed=q[Yc+8>>2];dd=_c;_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0;if(_c>>>0<4){Kc=Kc+1|0}dd=_c;_c=Kc;if(($c|0)>(Kc|0)?1:($c|0)>=(Kc|0)?fd>>>0
>>0?0:1:0){continue}break}}dd=0;break a}q[q[a+4>>2]+80>>2]=id;dd=1}T=Zc+32|0;return dd|0}function Aj(a,md,nd){var od=0,pd=0,qd=0,rd=0;a:{if(a>>>0>5){break a}qd=q[nd+16>>2];od=q[nd+12>>2];pd=q[nd+20>>2];if((od|0)<(pd|0)?1:(od|0)<=(pd|0)?t[nd+8>>2]>qd>>>0?0:1:0){break a}od=r[qd+q[nd>>2]|0];qd=qd+1|0;if(qd>>>0<1){pd=pd+1|0}q[nd+16>>2]=qd;q[nd+20>>2]=pd;pd=md;if(od&128){if(!Aj(a+1|0,md,nd)){break a}a=q[md>>2]<<7;q[md>>2]=a;od=a|od&127}q[pd>>2]=od;rd=1}return rd}function Bj(a,md){var nd=0,sd=0,td=0,ud=0,vd=0,wd=0,xd=0,yd=0,zd=0,Ad=0;nd=T-32|0;T=nd;q[nd+24>>2]=0;q[nd+16>>2]=0;q[nd+20>>2]=0;a:{ud=w(md,3);if(ud){if(ud>>>0>=1073741824){break a}sd=w(md,12);vd=Mm(sd);q[nd+16>>2]=vd;q[nd+24>>2]=(ud<<2)+vd;zd=nd,Ad=Dn(vd,0,sd)+sd|0,q[zd+20>>2]=Ad}b:{if(!qh(ud,1,q[a+32>>2],vd)){break b}td=1;if(!md){break b}yd=a+44|0;vd=0;while(1){ud=nd+8|0;q[ud>>2]=0;q[nd>>2]=0;q[nd+4>>2]=0;a=q[nd+16>>2]+(vd<<2)|0;sd=q[a>>2];td=sd>>>1;sd=(sd&1?0-td|0:td)+wd|0;q[nd>>2]=sd;td=q[a+4>>2];wd=td>>>1;sd=sd+(td&1?0-wd|0:wd)|0;q[nd+4>>2]=sd;a=q[a+8>>2];td=a>>>1;wd=sd+(a&1?0-td|0:td)|0;q[ud>>2]=wd;sd=q[yd>>2];td=sd+100|0;a=q[td>>2];c:{if((a|0)!=q[sd+104>>2]){sd=q[nd+4>>2];q[a>>2]=q[nd>>2];q[a+4>>2]=sd;q[a+8>>2]=q[ud>>2];q[td>>2]=q[td>>2]+12;break c}Cj(sd+96|0,nd)}vd=vd+3|0;td=1;xd=xd+1|0;if((xd|0)!=(md|0)){continue}break}}a=q[nd+16>>2];if(a){q[nd+20>>2]=a;An(a)}T=nd+32|0;return td}bn();F()}function Cj(a,md){var Bd=0,Cd=0,Dd=0,Ed=0,Fd=0,Gd=0;a:{Ed=q[a>>2];Fd=q[a+4>>2]-Ed|0;Bd=(Fd|0)/12|0;Cd=Bd+1|0;if(Cd>>>0<357913942){Gd=w(Bd,12);Dd=(q[a+8>>2]-Ed|0)/12|0;Bd=Dd<<1;Dd=Dd>>>0<178956970?Bd>>>0>>0?Cd:Bd:357913941;Bd=0;b:{if(!Dd){break b}if(Dd>>>0>=357913942){break a}Bd=Mm(w(Dd,12))}Cd=Gd+Bd|0;Gd=q[md+4>>2];q[Cd>>2]=q[md>>2];q[Cd+4>>2]=Gd;q[Cd+8>>2]=q[md+8>>2];md=Cd+w((Fd|0)/-12|0,12)|0;Bd=Bd+w(Dd,12)|0;Cd=Cd+12|0;if((Fd|0)>=1){Cn(md,Ed,Fd)}q[a>>2]=md;q[a+8>>2]=Bd;q[a+4>>2]=Cd;if(Ed){An(Ed)}return}bn();F()}ab(13160);F()}function Dj(a,md){a=a|0;md=md|0;var Hd=0,Id=0,Jd=0,Kd=0,Ld=0,Md=0,Nd=0;Kd=T-16|0;T=Kd;Ld=Mm(64);Hd=Mm(12);q[Hd+8>>2]=q[q[a+4>>2]+80>>2];q[Hd>>2]=13236;q[Hd+4>>2]=0;q[Kd+8>>2]=Hd;Ge(Ld,Kd+8|0);a:{if((md|0)>=0){Hd=q[a+12>>2];Md=a+8|0;Nd=q[Md>>2];Id=Hd-Nd>>2;b:{if((Id|0)>(md|0)){break b}Jd=md+1|0;if(Id>>>0<=md>>>0){ji(Md,Jd-Id|0);break b}if(Jd>>>0>=Id>>>0){break b}Jd=Nd+(Jd<<2)|0;if((Jd|0)!=(Hd|0)){while(1){Hd=Hd+ -4|0;Id=q[Hd>>2];q[Hd>>2]=0;if(Id){n[q[q[Id>>2]+4>>2]](Id)}if((Hd|0)!=(Jd|0)){continue}break}}q[a+12>>2]=Jd}md=q[Md>>2]+(md<<2)|0;a=q[md>>2];q[md>>2]=Ld;Id=1;if(!a){break a}n[q[q[a>>2]+4>>2]](a);break a}n[q[q[Ld>>2]+4>>2]](Ld)}a=q[Kd+8>>2];q[Kd+8>>2]=0;if(a){n[q[q[a>>2]+4>>2]](a)}T=Kd+16|0;return Id|0}function Ej(a){a=a|0;var md=0,Od=0,Pd=0,Qd=0,Rd=0;q[a>>2]=13300;md=q[a+20>>2];if(md){q[a+24>>2]=md;An(md)}Pd=q[a+8>>2];if(Pd){md=Pd;Rd=a+12|0;Od=q[Rd>>2];Qd=md;a:{if((md|0)==(Od|0)){break a}while(1){Od=Od+ -4|0;md=q[Od>>2];q[Od>>2]=0;if(md){n[q[q[md>>2]+4>>2]](md)}if((Od|0)!=(Pd|0)){continue}break}Qd=q[a+8>>2]}md=Qd;q[Rd>>2]=Pd;An(md)}An(a)}function Fj(a,Sd){a=a|0;Sd=Sd|0;o[Sd+84|0]=1;q[Sd+72>>2]=q[Sd+68>>2];return 1}function Gj(a){a=a|0;var Sd=0,Td=0,Ud=0,Vd=0;a:{Sd=q[a+8>>2];b:{if((Sd|0)<0){break b}Td=q[a+4>>2];Vd=q[Td>>2];Ud=q[Td+4>>2]-Vd>>2;c:{if(Sd>>>0>Ud>>>0){Hj(Td,Sd-Ud|0);Sd=q[a+8>>2];break c}if(Sd>>>0>=Ud>>>0){break c}q[Td+4>>2]=Vd+(Sd<<2)}Vd=1;if((Sd|0)<1){break b}a=q[a+4>>2];Td=q[a>>2];Ud=q[a+4>>2]-Td>>2;a=0;while(1){if((a|0)==(Ud|0)){break a}q[Td+(a<<2)>>2]=a;a=a+1|0;if((a|0)<(Sd|0)){continue}break}}return Vd|0}cn();F()}function Hj(a,Wd){var Xd=0,Yd=0,Zd=0,_d=0,$d=0,ae=0,be=0,ce=0,de=0;Yd=q[a+8>>2];Zd=a+4|0;Xd=q[Zd>>2];if(Yd-Xd>>2>>>0>=Wd>>>0){a=Wd<<2;ce=Zd,de=Dn(Xd,0,a)+a|0,q[ce>>2]=de;return}a:{Zd=q[a>>2];$d=Xd-Zd|0;Xd=$d>>2;_d=Xd+Wd|0;if(_d>>>0<1073741824){be=Xd<<2;Yd=Yd-Zd|0;Xd=Yd>>1;Yd=Yd>>2>>>0<536870911?Xd>>>0<_d>>>0?_d:Xd:1073741823;Xd=0;b:{if(!Yd){break b}if(Yd>>>0>=1073741824){break a}ae=Mm(Yd<<2);Xd=ae}Dn(be+Xd|0,0,Wd<<2);Wd=Xd+(_d<<2)|0;_d=Xd+(Yd<<2)|0;if(($d|0)>=1){Cn(ae,Zd,$d)}q[a>>2]=Xd;q[a+8>>2]=_d;q[a+4>>2]=Wd;if(Zd){An(Zd)}return}bn();F()}ab(13160);F()}function Ij(a){q[a+40>>2]=0;q[a>>2]=13300;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;q[a+32>>2]=0;p[a+36>>1]=0}function Jj(a,Wd,ee){var fe=0,ge=0,he=0,ie=0,je=0,ke=0;ge=T-16|0;T=ge;ie=q[Wd+12>>2];fe=q[Wd+20>>2];he=q[Wd+16>>2];je=he+5|0;if(je>>>0<5){fe=fe+1|0}a:{if((ie|0)<(fe|0)?1:(ie|0)<=(fe|0)?t[Wd+8>>2]>=je>>>0?0:1:0){Wd=Mm(32);q[ge>>2]=Wd;q[ge+4>>2]=29;q[ge+8>>2]=-2147483616;o[Wd+29|0]=0;ee=r[13369]|r[13370]<<8|(r[13371]<<16|r[13372]<<24);fe=r[13365]|r[13366]<<8|(r[13367]<<16|r[13368]<<24);o[Wd+21|0]=fe;o[Wd+22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390]<<16|r[13391]<<24);o[Wd+8|0]=fe;o[Wd+9|0]=fe>>>8;o[Wd+10|0]=fe>>>16;o[Wd+11|0]=fe>>>24;o[Wd+12|0]=ee;o[Wd+13|0]=ee>>>8;o[Wd+14|0]=ee>>>16;o[Wd+15|0]=ee>>>24;ee=r[13384]|r[13385]<<8|(r[13386]<<16|r[13387]<<24);fe=r[13380]|r[13381]<<8|(r[13382]<<16|r[13383]<<24);o[Wd|0]=fe;o[Wd+1|0]=fe>>>8;o[Wd+2|0]=fe>>>16;o[Wd+3|0]=fe>>>24;o[Wd+4|0]=ee;o[Wd+5|0]=ee>>>8;o[Wd+6|0]=ee>>>16;o[Wd+7|0]=ee>>>24;q[a>>2]=-1;Rm(a+4|0,ge);if(o[ge+11|0]>-1){break a}An(q[ge>>2]);break a}fe=q[Wd+12>>2];if((fe|0)<(he|0)?1:(fe|0)<=(he|0)?t[Wd+8>>2]>je>>>0?0:1:0){Wd=Mm(32);q[ge>>2]=Wd;q[ge+4>>2]=29;q[ge+8>>2]=-2147483616;o[Wd+29|0]=0;ee=r[13369]|r[13370]<<8|(r[13371]<<16|r[13372]<<24);fe=r[13365]|r[13366]<<8|(r[13367]<<16|r[13368]<<24);o[Wd+21|0]=fe;o[Wd+22|0]=fe>>>8;o[Wd+23|0]=fe>>>16;o[Wd+24|0]=fe>>>24;o[Wd+25|0]=ee;o[Wd+26|0]=ee>>>8;o[Wd+27|0]=ee>>>16;o[Wd+28|0]=ee>>>24;ee=q[3341];fe=q[3340];o[Wd+16|0]=fe;o[Wd+17|0]=fe>>>8;o[Wd+18|0]=fe>>>16;o[Wd+19|0]=fe>>>24;o[Wd+20|0]=ee;o[Wd+21|0]=ee>>>8;o[Wd+22|0]=ee>>>16;o[Wd+23|0]=ee>>>24;ee=q[3339];fe=q[3338];o[Wd+8|0]=fe;o[Wd+9|0]=fe>>>8;o[Wd+10|0]=fe>>>16;o[Wd+11|0]=fe>>>24;o[Wd+12|0]=ee;o[Wd+13|0]=ee>>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Rm(a+4|0,ge);if(o[ge+11|0]>-1){break a}An(q[ge>>2]);break a}he=ee;ee=je+q[Wd>>2]|0;p[he+10>>1]=r[ee|0]|r[ee+1|0]<<8;ee=Wd;he=Wd;fe=q[Wd+20>>2];Wd=q[Wd+16>>2]+2|0;if(Wd>>>0<2){fe=fe+1|0}q[he+16>>2]=Wd;q[ee+20>>2]=fe;q[a+8>>2]=0;q[a+12>>2]=0;q[a>>2]=0;q[a+4>>2]=0}T=ge+16|0}function Kj(a,Wd){var ee=0,le=0,me=0,ne=0;le=T-48|0;T=le;ee=Mm(36);me=ee+4|0;q[me>>2]=0;q[me+4>>2]=0;ne=ee+16|0;q[ne>>2]=0;q[ne+4>>2]=0;q[ee>>2]=me;q[ee+32>>2]=0;q[ee+24>>2]=0;q[ee+28>>2]=0;q[ee+12>>2]=ne;q[le+40>>2]=ee;ee=le+32|0;q[ee>>2]=0;a:{if(!Ok(ee,q[Wd+32>>2],q[le+40>>2])){q[le+24>>2]=0;q[le+16>>2]=0;q[le+20>>2]=0;Wd=Mm(32);q[le+16>>2]=Wd;q[le+20>>2]=26;q[le+24>>2]=-2147483616;o[Wd+26|0]=0;ee=r[13422]|r[13423]<<8;o[Wd+24|0]=ee;o[Wd+25|0]=ee>>>8;ee=r[13418]|r[13419]<<8|(r[13420]<<16|r[13421]<<24);me=r[13414]|r[13415]<<8|(r[13416]<<16|r[13417]<<24);o[Wd+16|0]=me;o[Wd+17|0]=me>>>8;o[Wd+18|0]=me>>>16;o[Wd+19|0]=me>>>24;o[Wd+20|0]=ee;o[Wd+21|0]=ee>>>8;o[Wd+22|0]=ee>>>16;o[Wd+23|0]=ee>>>24;ee=r[13410]|r[13411]<<8|(r[13412]<<16|r[13413]<<24);me=r[13406]|r[13407]<<8|(r[13408]<<16|r[13409]<<24);o[Wd+8|0]=me;o[Wd+9|0]=me>>>8;o[Wd+10|0]=me>>>16;o[Wd+11|0]=me>>>24;o[Wd+12|0]=ee;o[Wd+13|0]=ee>>>8;o[Wd+14|0]=ee>>>16;o[Wd+15|0]=ee>>>24;ee=r[13402]|r[13403]<<8|(r[13404]<<16|r[13405]<<24);me=r[13398]|r[13399]<<8|(r[13400]<<16|r[13401]<<24);o[Wd|0]=me;o[Wd+1|0]=me>>>8;o[Wd+2|0]=me>>>16;o[Wd+3|0]=me>>>24;o[Wd+4|0]=ee;o[Wd+5|0]=ee>>>8;o[Wd+6|0]=ee>>>16;o[Wd+7|0]=ee>>>24;q[a>>2]=-1;Rm(a+4|0,le+16|0);if(o[le+27|0]>-1){break a}An(q[le+16>>2]);break a}Wd=q[Wd+4>>2];q[le+8>>2]=0;me=q[le+40>>2];q[le+40>>2]=0;ee=q[Wd+4>>2];q[Wd+4>>2]=me;b:{if(!ee){q[le+8>>2]=0;break b}Lj(ee);Wd=q[le+8>>2];q[le+8>>2]=0;if(!Wd){break b}Lj(Wd)}q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}a=q[le+40>>2];q[le+40>>2]=0;if(a){Lj(a)}T=le+48|0}function Lj(a){var Wd=0,oe=0,pe=0,qe=0,re=0;if(a){pe=q[a+24>>2];if(pe){Wd=pe;re=a+28|0;oe=q[re>>2];qe=Wd;a:{if((oe|0)==(Wd|0)){break a}while(1){oe=oe+ -4|0;Wd=q[oe>>2];q[oe>>2]=0;if(Wd){Hc(Wd+12|0,q[Wd+16>>2]);Ic(Wd,q[Wd+4>>2]);An(Wd)}if((oe|0)!=(pe|0)){continue}break}qe=q[a+24>>2]}Wd=qe;q[re>>2]=pe;An(Wd)}Hc(a+12|0,q[a+16>>2]);Ic(a,q[a+4>>2]);An(a)}}function Mj(a,se,te,ue,ve){var we=0,xe=0;we=T-32|0;T=we;q[se+32>>2]=ue;q[se+40>>2]=te;q[se+4>>2]=ve;Jj(a,ue,we+16|0);a:{if(q[a>>2]){break a}te=a+4|0;if(o[a+15|0]<=-1){An(q[te>>2])}ve=r[we+23|0];if((n[q[q[se>>2]+8>>2]](se)|0)!=(ve|0)){se=Mm(64);q[we>>2]=se;q[we+4>>2]=50;q[we+8>>2]=-2147483584;o[se+50|0]=0;ue=r[13473]|r[13474]<<8;o[se+48|0]=ue;o[se+49|0]=ue>>>8;ue=r[13469]|r[13470]<<8|(r[13471]<<16|r[13472]<<24);ve=r[13465]|r[13466]<<8|(r[13467]<<16|r[13468]<<24);o[se+40|0]=ve;o[se+41|0]=ve>>>8;o[se+42|0]=ve>>>16;o[se+43|0]=ve>>>24;o[se+44|0]=ue;o[se+45|0]=ue>>>8;o[se+46|0]=ue>>>16;o[se+47|0]=ue>>>24;ue=r[13461]|r[13462]<<8|(r[13463]<<16|r[13464]<<24);ve=r[13457]|r[13458]<<8|(r[13459]<<16|r[13460]<<24);o[se+32|0]=ve;o[se+33|0]=ve>>>8;o[se+34|0]=ve>>>16;o[se+35|0]=ve>>>24;o[se+36|0]=ue;o[se+37|0]=ue>>>8;o[se+38|0]=ue>>>16;o[se+39|0]=ue>>>24;ue=r[13453]|r[13454]<<8|(r[13455]<<16|r[13456]<<24);ve=r[13449]|r[13450]<<8|(r[13451]<<16|r[13452]<<24);o[se+24|0]=ve;o[se+25|0]=ve>>>8;o[se+26|0]=ve>>>16;o[se+27|0]=ve>>>24;o[se+28|0]=ue;o[se+29|0]=ue>>>8;o[se+30|0]=ue>>>16;o[se+31|0]=ue>>>24;ue=r[13445]|r[13446]<<8|(r[13447]<<16|r[13448]<<24);ve=r[13441]|r[13442]<<8|(r[13443]<<16|r[13444]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13437]|r[13438]<<8|(r[13439]<<16|r[13440]<<24);ve=r[13433]|r[13434]<<8|(r[13435]<<16|r[13436]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13429]|r[13430]<<8|(r[13431]<<16|r[13432]<<24);ve=r[13425]|r[13426]<<8|(r[13427]<<16|r[13428]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}ue=r[we+21|0];o[se+36|0]=ue;xe=r[we+22|0];o[se+37|0]=xe;if((ue+ -1&255)>>>0>=2){se=Mm(32);q[we>>2]=se;q[we+4>>2]=22;q[we+8>>2]=-2147483616;o[se+22|0]=0;ue=r[13494]|r[13495]<<8|(r[13496]<<16|r[13497]<<24);ve=r[13490]|r[13491]<<8|(r[13492]<<16|r[13493]<<24);o[se+14|0]=ve;o[se+15|0]=ve>>>8;o[se+16|0]=ve>>>16;o[se+17|0]=ve>>>24;o[se+18|0]=ue;o[se+19|0]=ue>>>8;o[se+20|0]=ue>>>16;o[se+21|0]=ue>>>24;ue=r[13488]|r[13489]<<8|(r[13490]<<16|r[13491]<<24);ve=r[13484]|r[13485]<<8|(r[13486]<<16|r[13487]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13480]|r[13481]<<8|(r[13482]<<16|r[13483]<<24);ve=r[13476]|r[13477]<<8|(r[13478]<<16|r[13479]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-5;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}if(!((ue|0)!=2|(ve?2:3)>>>0>=xe>>>0)){se=Mm(32);q[we>>2]=se;q[we+4>>2]=22;q[we+8>>2]=-2147483616;o[se+22|0]=0;ue=r[13517]|r[13518]<<8|(r[13519]<<16|r[13520]<<24);ve=r[13513]|r[13514]<<8|(r[13515]<<16|r[13516]<<24);o[se+14|0]=ve;o[se+15|0]=ve>>>8;o[se+16|0]=ve>>>16;o[se+17|0]=ve>>>24;o[se+18|0]=ue;o[se+19|0]=ue>>>8;o[se+20|0]=ue>>>16;o[se+21|0]=ue>>>24;ue=r[13511]|r[13512]<<8|(r[13513]<<16|r[13514]<<24);ve=r[13507]|r[13508]<<8|(r[13509]<<16|r[13510]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13503]|r[13504]<<8|(r[13505]<<16|r[13506]<<24);ve=r[13499]|r[13500]<<8|(r[13501]<<16|r[13502]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-5;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}ue=ue<<8|xe;p[q[se+32>>2]+38>>1]=ue;b:{if((ue&65535)>>>0<259|p[we+26>>1]>-1){break b}Kj(a,se);if(q[a>>2]){break a}if(o[te+11|0]>-1){break b}An(q[te>>2])}if(!n[q[q[se>>2]+12>>2]](se)){se=Mm(48);q[we>>2]=se;q[we+4>>2]=33;q[we+8>>2]=-2147483600;o[se+33|0]=0;o[se+32|0]=r[13554];ue=r[13550]|r[13551]<<8|(r[13552]<<16|r[13553]<<24);ve=r[13546]|r[13547]<<8|(r[13548]<<16|r[13549]<<24);o[se+24|0]=ve;o[se+25|0]=ve>>>8;o[se+26|0]=ve>>>16;o[se+27|0]=ve>>>24;o[se+28|0]=ue;o[se+29|0]=ue>>>8;o[se+30|0]=ue>>>16;o[se+31|0]=ue>>>24;ue=r[13542]|r[13543]<<8|(r[13544]<<16|r[13545]<<24);ve=r[13538]|r[13539]<<8|(r[13540]<<16|r[13541]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13534]|r[13535]<<8|(r[13536]<<16|r[13537]<<24);ve=r[13530]|r[13531]<<8|(r[13532]<<16|r[13533]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13526]|r[13527]<<8|(r[13528]<<16|r[13529]<<24);ve=r[13522]|r[13523]<<8|(r[13524]<<16|r[13525]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}if(!n[q[q[se>>2]+20>>2]](se)){se=Mm(32);q[we>>2]=se;q[we+4>>2]=31;q[we+8>>2]=-2147483616;o[se+31|0]=0;ue=r[13583]|r[13584]<<8|(r[13585]<<16|r[13586]<<24);ve=r[13579]|r[13580]<<8|(r[13581]<<16|r[13582]<<24);o[se+23|0]=ve;o[se+24|0]=ve>>>8;o[se+25|0]=ve>>>16;o[se+26|0]=ve>>>24;o[se+27|0]=ue;o[se+28|0]=ue>>>8;o[se+29|0]=ue>>>16;o[se+30|0]=ue>>>24;ue=r[13576]|r[13577]<<8|(r[13578]<<16|r[13579]<<24);ve=r[13572]|r[13573]<<8|(r[13574]<<16|r[13575]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13568]|r[13569]<<8|(r[13570]<<16|r[13571]<<24);ve=r[13564]|r[13565]<<8|(r[13566]<<16|r[13567]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13560]|r[13561]<<8|(r[13562]<<16|r[13563]<<24);ve=r[13556]|r[13557]<<8|(r[13558]<<16|r[13559]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}if(!n[q[q[se>>2]+24>>2]](se)){se=Mm(48);q[we>>2]=se;q[we+4>>2]=34;q[we+8>>2]=-2147483600;o[se+34|0]=0;ue=r[13620]|r[13621]<<8;o[se+32|0]=ue;o[se+33|0]=ue>>>8;ue=r[13616]|r[13617]<<8|(r[13618]<<16|r[13619]<<24);ve=r[13612]|r[13613]<<8|(r[13614]<<16|r[13615]<<24);o[se+24|0]=ve;o[se+25|0]=ve>>>8;o[se+26|0]=ve>>>16;o[se+27|0]=ve>>>24;o[se+28|0]=ue;o[se+29|0]=ue>>>8;o[se+30|0]=ue>>>16;o[se+31|0]=ue>>>24;ue=r[13608]|r[13609]<<8|(r[13610]<<16|r[13611]<<24);ve=r[13604]|r[13605]<<8|(r[13606]<<16|r[13607]<<24);o[se+16|0]=ve;o[se+17|0]=ve>>>8;o[se+18|0]=ve>>>16;o[se+19|0]=ve>>>24;o[se+20|0]=ue;o[se+21|0]=ue>>>8;o[se+22|0]=ue>>>16;o[se+23|0]=ue>>>24;ue=r[13600]|r[13601]<<8|(r[13602]<<16|r[13603]<<24);ve=r[13596]|r[13597]<<8|(r[13598]<<16|r[13599]<<24);o[se+8|0]=ve;o[se+9|0]=ve>>>8;o[se+10|0]=ve>>>16;o[se+11|0]=ve>>>24;o[se+12|0]=ue;o[se+13|0]=ue>>>8;o[se+14|0]=ue>>>16;o[se+15|0]=ue>>>24;ue=r[13592]|r[13593]<<8|(r[13594]<<16|r[13595]<<24);ve=r[13588]|r[13589]<<8|(r[13590]<<16|r[13591]<<24);o[se|0]=ve;o[se+1|0]=ve>>>8;o[se+2|0]=ve>>>16;o[se+3|0]=ve>>>24;o[se+4|0]=ue;o[se+5|0]=ue>>>8;o[se+6|0]=ue>>>16;o[se+7|0]=ue>>>24;q[a>>2]=-1;Rm(te,we);if(o[we+11|0]>-1){break a}An(q[we>>2]);break a}q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0}T=we+32|0}function Nj(a){a=a|0;var se=0,te=0,ue=0,ve=0,ye=0,ze=0,Ae=0,Be=0,Ce=0,De=0,Ee=0,Fe=0;a:{se=q[a+32>>2];ve=q[se+16>>2];ze=q[se+12>>2];ue=q[se+20>>2];b:{if((ze|0)<(ue|0)?1:(ze|0)<=(ue|0)?t[se+8>>2]>ve>>>0?0:1:0){break b}ye=r[ve+q[se>>2]|0];Ae=ve+1|0;if(Ae>>>0<1){ue=ue+1|0}q[se+16>>2]=Ae;q[se+20>>2]=ue;c:{if(!ye){break c}while(1){if(n[q[q[a>>2]+16>>2]](a,te)){te=te+1|0;if((ye|0)!=(te|0)){continue}break c}break}return 0}te=q[a+8>>2];ue=q[a+12>>2];if((te|0)!=(ue|0)){while(1){se=q[te>>2];if(!n[q[q[se>>2]+8>>2]](se,a,q[a+4>>2])){break b}te=te+4|0;if((ue|0)!=(te|0)){continue}break}}d:{if(!ye){break d}te=0;ue=a+8|0;while(1){se=q[q[ue>>2]+(te<<2)>>2];if(!n[q[q[se>>2]+12>>2]](se,q[a+32>>2])){break a}te=te+1|0;if((ye|0)!=(te|0)){continue}break}if(!ye){break d}ve=a+20|0;Be=a+8|0;ze=a+24|0;while(1){te=0;Ae=Ce<<2;se=q[Ae+q[Be>>2]>>2];ue=n[q[q[se>>2]+24>>2]](se)|0;if((ue|0)>0){while(1){se=q[q[Be>>2]+Ae>>2];se=n[q[q[se>>2]+20>>2]](se,te)|0;De=q[a+20>>2];Ee=q[ze>>2]-De>>2;e:{if(se>>>0>>0){break e}Fe=se+1|0;if(Fe>>>0>Ee>>>0){Fa(ve,Fe-Ee|0);De=q[ve>>2];break e}if(Fe>>>0>=Ee>>>0){break e}q[ze>>2]=(Fe<<2)+De}q[(se<<2)+De>>2]=Ce;te=te+1|0;if((ue|0)!=(te|0)){continue}break}}Ce=Ce+1|0;if((Ce|0)!=(ye|0)){continue}break}}Be=0;if(!n[q[q[a>>2]+28>>2]](a)){break b}Be=n[q[q[a>>2]+32>>2]](a)|0}return Be|0}return 0}function Oj(a){a=a|0;var Ge=0,He=0,Ie=0,Je=0;He=1;Ge=q[a+8>>2];Ie=q[a+12>>2];a:{if((Ge|0)==(Ie|0)){break a}while(1){Je=q[Ge>>2];if(n[q[q[Je>>2]+16>>2]](Je,q[a+32>>2])){Ge=Ge+4|0;if((Ie|0)!=(Ge|0)){continue}break a}break}He=0}return He|0}function Pj(a,Ke){var Le=0,Me=0;a:{if((Ke|0)<0){break a}Le=q[a+4>>2];if(q[Le+12>>2]-q[Le+8>>2]>>2<=(Ke|0)){break a}a=q[q[a+8>>2]+(q[q[a+20>>2]+(Ke<<2)>>2]<<2)>>2];Me=n[q[q[a>>2]+32>>2]](a,Ke)|0}return Me}function Qj(a){a=a|0;var Ke=0,Ne=0,Oe=0,Pe=0,Qe=0,Re=0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cf|0)>(Ue|0)?1:(cf|0)>=(Ue|0)?ef>>>0>>0?0:1:0){Ue=bf+q[af>>2]|0;Ue=r[Ue|0]|r[Ue+1|0]<<8|(r[Ue+2|0]<<16|r[Ue+3|0]<<24);q[af+16>>2]=df;q[af+20>>2]=$e;q[q[a+4>>2]+80>>2]=Ue;a=1}else{a=0}return a|0}function Tj(a,ff,gf){var hf=0,jf=0,kf=0;if((ff|0)>0){while(1){jf=hf<<2;kf=q[jf+a>>2];q[gf+jf>>2]=0-(kf&1)^kf>>>1;hf=hf+1|0;if((hf|0)!=(ff|0)){continue}break}}}function Uj(a){q[a+16>>2]=0;q[a+20>>2]=0;q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0}function Vj(a,q,ff,gf){return Wj(a,q,ff,gf)}function Wj(a,ff,gf,lf){var mf=0,nf=0,of=0;a:{if(!ff){ff=gf;lf=ff>>>0<0?lf+1|0:lf;if((lf|0)<0?1:(lf|0)<=0?ff>>>0>=0?0:1:0){return 0}lf=q[a>>2];gf=q[a+4>>2]-lf|0;if(gf>>>0>>0){Ha(a,ff-gf|0);break a}if(gf>>>0<=ff>>>0){break a}q[a+4>>2]=ff+lf;break a}if((lf|0)<0?1:(lf|0)<=0?gf>>>0>=0?0:1:0){return 0}nf=gf;if(gf>>>0<0){lf=lf+1|0}of=q[a>>2];mf=q[a+4>>2]-of|0;b:{if((lf|0)<0?1:(lf|0)<=0?nf>>>0>mf>>>0?0:1:0){break b}lf=nf;if(mf>>>0>>0){Ha(a,lf-mf|0);break b}if(mf>>>0<=lf>>>0){break b}q[a+4>>2]=lf+of}if(!gf){break a}En(q[a>>2],ff,gf)}ff=a+24|0;gf=ff;lf=ff;a=q[ff+4>>2];ff=q[ff>>2]+1|0;if(ff>>>0<1){a=a+1|0}q[lf>>2]=ff;q[gf+4>>2]=a;return 1}function Xj(a,ff){var gf=0,lf=0;lf=q[a>>2];gf=q[a+4>>2]-lf|0;a:{if(gf>>>0>>0){Ha(a,ff-gf|0);break a}if(gf>>>0<=ff>>>0){break a}q[a+4>>2]=ff+lf}ff=a+24|0;gf=ff;lf=ff;a=q[ff+4>>2];ff=q[ff>>2]+1|0;if(ff>>>0<1){a=a+1|0}q[lf>>2]=ff;q[gf+4>>2]=a}function Yj(a){p[a+38>>1]=0;q[a>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a+24>>2]=0;q[a+28>>2]=0;o[a+29|0]=0;o[a+30|0]=0;o[a+31|0]=0;o[a+32|0]=0;o[a+33|0]=0;o[a+34|0]=0;o[a+35|0]=0;o[a+36|0]=0;return a}function Zj(a,ff,pf,qf){p[a+38>>1]=qf;q[a>>2]=ff;q[a+16>>2]=0;q[a+20>>2]=0;q[a+8>>2]=pf;q[a+12>>2]=0}function _j(a,ff,pf){var qf=0,rf=0,sf=0,tf=0;a:{b:{if(!ff){break b}if(s[a+38>>1]<=513){rf=q[a+12>>2];ff=q[a+20>>2];sf=q[a+16>>2];tf=sf+8|0;if(tf>>>0<8){ff=ff+1|0}if((rf|0)<(ff|0)?1:(rf|0)<=(ff|0)?t[a+8>>2]>=tf>>>0?0:1:0){break a}ff=sf+q[a>>2]|0;qf=r[ff+4|0]|r[ff+5|0]<<8|(r[ff+6|0]<<16|r[ff+7|0]<<24);q[pf>>2]=r[ff|0]|r[ff+1|0]<<8|(r[ff+2|0]<<16|r[ff+3|0]<<24);q[pf+4>>2]=qf;pf=q[a+20>>2];qf=q[a+16>>2]+8|0;if(qf>>>0<8){pf=pf+1|0}q[a+16>>2]=qf;q[a+20>>2]=pf;break b}if(!$j(1,pf,a)){break a}}o[a+36|0]=1;q[a+32>>2]=0;ff=q[a+16>>2];pf=ff+q[a>>2]|0;q[a+24>>2]=pf;qf=a;a=q[a+8>>2];q[qf+28>>2]=pf+(a-ff|0);qf=1}return qf}function $j(a,ff,pf){var uf=0,vf=0,wf=0,xf=0,yf=0,zf=0;a:{if(a>>>0>10){break a}wf=q[pf+16>>2];uf=q[pf+12>>2];vf=q[pf+20>>2];xf=vf;if((uf|0)<(xf|0)?1:(uf|0)<=(xf|0)?t[pf+8>>2]>wf>>>0?0:1:0){break a}yf=o[wf+q[pf>>2]|0];uf=wf+1|0;if(uf>>>0<1){vf=vf+1|0}q[pf+16>>2]=uf;q[pf+20>>2]=vf;xf=ff;wf=ff;uf=yf;b:{if((uf|0)<=-1){if(!$j(a+1|0,ff,pf)){break a}a=ff;pf=q[ff+4>>2];ff=q[ff>>2];vf=pf<<7|ff>>>25;ff=ff<<7;q[a>>2]=ff;q[a+4>>2]=vf;a=uf&127|ff;break b}vf=0;a=uf&255}q[wf>>2]=a;q[xf+4>>2]=vf;zf=1}return zf}function ak(a){var ff=0,pf=0,Af=0,Bf=0,Cf=0,Df=0;o[a+36|0]=0;Af=q[a+20>>2];Bf=a;Cf=a;Df=q[a+16>>2];a=q[a+32>>2]+7|0;if(a>>>0<7){ff=1}pf=ff>>>3;a=ff<<29|a>>>3;ff=Df+a|0;pf=pf+Af|0;q[Cf+16>>2]=ff;q[Bf+20>>2]=ff>>>0>>0?pf+1|0:pf}function bk(a){a=a+ -1|0;if(a>>>0<=10){return q[(a<<2)+13848>>2]}return-1}function ck(a){var Ef=0;Ef=a+4|0;q[Ef>>2]=0;q[Ef+4>>2]=0;q[a>>2]=Ef;return a}function dk(a,Ff,Gf,Hf){var If=0,Jf=0,Kf=0,Lf=0;If=T-16|0;T=If;Lf=a;Jf=ph(Ff,If+12|0,Gf);Gf=q[Jf>>2];if(Gf){Ff=0}else{Gf=Mm(40);Rm(Gf+16|0,q[Hf>>2]);q[Gf+36>>2]=0;q[Gf+28>>2]=0;q[Gf+32>>2]=0;q[Gf+8>>2]=q[If+12>>2];q[Gf>>2]=0;q[Gf+4>>2]=0;q[Jf>>2]=Gf;Hf=Gf;Kf=q[q[Ff>>2]>>2];if(Kf){q[Ff>>2]=Kf;Hf=q[Jf>>2]}nh(q[Ff+4>>2],Hf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]=Uf;if(fg){An(fg)}return}bn();F()}ab(13904);F()}function nk(a,Uf){var mg=0,ng=0,og=0,pg=0,qg=0,rg=0,sg=0,tg=0,ug=0,vg=0,wg=0,xg=0,yg=0,zg=0,Ag=0,Bg=0,Cg=0,Dg=0,Eg=0,Fg=0,Gg=0;og=T-48|0;T=og;if(Uf){Dg=a+12|0;ng=a+4|0;tg=q[ng>>2];ug=q[a>>2];rg=tg-ug|0;pg=rg>>2;mg=q[a+12>>2];qg=q[a+16>>2]-mg>>2;a:{if(pg>>>0>qg>>>0){qk(Dg,pg-qg|0);tg=q[ng>>2];ug=q[a>>2];rg=tg-ug|0;pg=rg>>2;break a}if(pg>>>0>=qg>>>0){break a}q[a+16>>2]=mg+(pg<<2)}ng=0;q[og+40>>2]=0;q[og+32>>2]=0;q[og+36>>2]=0;b:{c:{d:{if(!pg){mg=0;qg=0;break d}if(pg>>>0>=1073741824){break c}mg=Mm(rg);q[og+36>>2]=mg;q[og+32>>2]=mg;q[og+40>>2]=(pg<<2)+mg;qg=mg}e:{if(!rg){break e}sg=a+4|0;ng=qg;wg=ng;rg=0;while(1){vg=q[(rg<<2)+ug>>2];wg=wg-ng>>2;if(vg>>>0>=wg>>>0){q[og+16>>2]=0;mg=vg+1|0;f:{if(mg>>>0>wg>>>0){Ad(og+32|0,mg-wg|0,og+16|0);tg=q[sg>>2];ug=q[a>>2];break f}if(mg>>>0>=wg>>>0){break f}q[og+36>>2]=(mg<<2)+ng}mg=q[og+32>>2];qg=mg}ng=(vg<<2)+mg|0;q[ng>>2]=q[ng>>2]+1;rg=rg+1|0;ng=tg-ug|0;pg=ng>>2;if(rg>>>0>=pg>>>0){break e}wg=q[og+36>>2];ng=mg;continue}}q[og+24>>2]=0;q[og+16>>2]=0;q[og+20>>2]=0;rg=0;g:{if(ng){if(pg>>>0>=536870912){break g}rg=Mm(ng<<1);q[og+16>>2]=rg;q[og+20>>2]=rg;ng=pg<<3;q[og+24>>2]=ng+rg;ng=Dn(rg,255,ng);while(1){ng=ng+8|0;pg=pg+ -1|0;if(pg){continue}break}q[og+20>>2]=ng}q[og+8>>2]=0;q[og>>2]=0;q[og+4>>2]=0;ng=q[og+36>>2]-qg|0;Ag=ng>>2;h:{if(ng){if(Ag>>>0>=1073741824){break h}xg=Mm(ng);q[og>>2]=xg;q[og+8>>2]=(Ag<<2)+xg;pg=0;sg=Dn(xg,0,ng);q[og+4>>2]=sg+ng;ng=0;while(1){qg=ng<<2;q[qg+sg>>2]=pg;pg=q[mg+qg>>2]+pg|0;ng=ng+1|0;if(ng>>>0>>0){continue}break}}if((tg|0)==(ug|0)){break b}Gg=tg-ug>>2;sg=0;Eg=q[og+32>>2];while(1){Bg=sg<<2;wg=q[Bg+ug>>2];tg=-1;ng=sg+1|0;mg=(ng>>>0)%3|0?ng:sg+ -2|0;if((mg|0)!=-1){tg=q[(mg<<2)+ug>>2]}yg=-1;qg=(sg>>>0)%3|0;mg=(qg?-1:2)+sg|0;if((mg|0)!=-1){yg=q[(mg<<2)+ug>>2]}i:{j:{if(qg){break j}k:{if((tg|0)==(yg|0)){break k}mg=q[ug+Bg>>2];if((mg|0)==(tg|0)){break k}if((mg|0)!=(yg|0)){break j}}q[a+40>>2]=q[a+40>>2]+1;ng=sg+3|0;break i}mg=yg<<2;Cg=q[mg+Eg>>2];l:{m:{if((Cg|0)<1){break m}mg=q[mg+xg>>2];pg=0;while(1){vg=(mg<<3)+rg|0;qg=q[vg>>2];if((qg|0)==-1){break m}n:{if((qg|0)!=(tg|0)){break n}zg=q[vg+4>>2];if((zg|0)!=-1){qg=q[(zg<<2)+ug>>2]}else{qg=-1}if((qg|0)==(wg|0)){break n}while(1){qg=mg;pg=pg+1|0;o:{if((pg|0)>=(Cg|0)){break o}Fg=(qg<<3)+rg|0;mg=qg+1|0;wg=(mg<<3)+rg|0;vg=q[wg>>2];q[Fg>>2]=vg;q[Fg+4>>2]=q[wg+4>>2];if((vg|0)!=-1){continue}}break}q[(qg<<3)+rg>>2]=-1;if((zg|0)==-1){break m}mg=q[Dg>>2];q[mg+Bg>>2]=zg;q[mg+(zg<<2)>>2]=sg;break l}mg=mg+1|0;pg=pg+1|0;if((Cg|0)!=(pg|0)){continue}break}}mg=tg<<2;qg=q[mg+Eg>>2];if((qg|0)<1){break l}mg=q[mg+xg>>2];pg=0;while(1){vg=(mg<<3)+rg|0;if(q[vg>>2]==-1){q[vg>>2]=yg;q[vg+4>>2]=sg;break l}mg=mg+1|0;pg=pg+1|0;if((qg|0)!=(pg|0)){continue}break}}}sg=ng;if(sg>>>0>>0){continue}break}break b}bn();F()}bn();F()}ab(13904);F()}q[Uf>>2]=Ag;if(xg){q[og+4>>2]=xg;An(xg)}a=q[og+16>>2];if(a){q[og+20>>2]=a;An(a)}a=q[og+32>>2];if(a){q[og+36>>2]=a;An(a)}a=1}else{a=0}T=og+48|0;return a}function ok(a){var Uf=0,Hg=0,Ig=0,Jg=0,Kg=0,Lg=0,Mg=0,Ng=0,Og=0,Pg=0,Qg=0,Rg=0,Sg=0,Tg=0,Ug=0;Ig=T-48|0;T=Ig;Qg=a+4|0;Uf=q[Qg>>2];Og=q[a>>2];o[Ig+16|0]=0;Rg=rk(Ig+32|0,Uf-Og>>2,Ig+16|0);q[Ig+24>>2]=0;q[Ig+16>>2]=0;q[Ig+20>>2]=0;Uf=q[Qg>>2];Mg=q[a>>2];Ng=a+12|0;while(1){Sg=0;Lg=0;a:{if((Uf|0)==(Mg|0)){break a}while(1){Jg=q[Rg>>2];b:{if(q[Jg+(Lg>>>3&536870908)>>2]>>>(Lg&31)&1){break b}Kg=q[Ig+16>>2];q[Ig+20>>2]=Kg;Uf=Lg;while(1){Hg=Uf+1|0;Og=Uf;Uf=(Hg>>>0)%3|0?Hg:Uf+ -2|0;c:{if((Uf|0)==-1){break c}Uf=q[q[Ng>>2]+(Uf<<2)>>2];if((Uf|0)==-1){break c}Hg=Uf+1|0;Uf=(Hg>>>0)%3|0?Hg:Uf+ -2|0;if((Lg|0)==(Uf|0)|(Uf|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Yg>>2]=q[Yg>>2]|1<<(Wg&31);if(Zg){q[q[a>>2]+(Wg<<2)>>2]=q[$g+8>>2]}Wg=((Wg>>>0)%3|0?-1:2)+Wg|0;if((Wg|0)==-1){break e}Wg=q[q[hh>>2]+(Wg<<2)>>2];if((Wg|0)==-1){break e}Wg=Wg+((Wg>>>0)%3|0?-1:2)|0;if((Wg|0)!=-1){continue}break}}eh=eh+1|0;if((eh|0)!=3){continue}break}}ih=ih+1|0;Wg=q[a>>2];if(ih>>>0<(q[gh>>2]-Wg>>2>>>0)/3>>>0){continue}break b}break}bn();F()}q[a+44>>2]=0;Vg=q[ah>>2];Wg=q[ah+4>>2];Yg=Wg>>>5;Zg=Wg&31;if(Yg|Zg){Yg=(Yg<<2)+Vg|0;Xg=Vg;Wg=0;while(1){if(!(q[Xg>>2]>>>Wg&1)){lh=lh+1|0;q[a+44>>2]=lh}_g=(Wg|0)==31;Wg=_g?0:Wg+1|0;Xg=_g?Xg+4|0:Xg;if((Yg|0)!=(Xg|0)|(Wg|0)!=(Zg|0)){continue}break}}a=q[ch>>2];if(a){An(a);Vg=q[ah>>2]}if(Vg){An(Vg)}T=$g+48|0}function qk(a,Vg){var rh=0,sh=0,th=0,uh=0,vh=0,wh=0;th=q[a+8>>2];rh=q[a+4>>2];if(th-rh>>2>>>0>=Vg>>>0){while(1){q[rh>>2]=q[3475];rh=rh+4|0;Vg=Vg+ -1|0;if(Vg){continue}break}q[a+4>>2]=rh;return}a:{uh=q[a>>2];vh=rh-uh|0;wh=vh>>2;rh=wh+Vg|0;if(rh>>>0<1073741824){th=th-uh|0;sh=th>>1;rh=th>>2>>>0<536870911?sh>>>0>>0?rh:sh:1073741823;sh=0;b:{if(!rh){break b}if(rh>>>0>=1073741824){break a}sh=Mm(rh<<2)}th=sh+(rh<<2)|0;rh=sh+(wh<<2)|0;while(1){q[rh>>2]=q[3475];rh=rh+4|0;Vg=Vg+ -1|0;if(Vg){continue}break}if((vh|0)>=1){Cn(sh,uh,vh)}q[a>>2]=sh;q[a+8>>2]=th;q[a+4>>2]=rh;if(uh){An(uh)}return}bn();F()}ab(13904);F()}function rk(a,Vg,xh){var yh=0,zh=0,Ah=0;q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;a:{b:{if(!Vg){break b}if((Vg|0)<=-1){break a}zh=Vg+ -1>>>5;Ah=zh+1|0;yh=Mm(Ah<<2);q[a+8>>2]=Ah;q[a>>2]=yh;Ah=r[xh|0];q[a+4>>2]=Vg;q[(Vg>>>0<33?yh:yh+(zh<<2)|0)>>2]=0;xh=Vg>>>5;zh=xh<<2;if(Ah){yh=Dn(yh,255,zh);Vg=Vg&31;if(!Vg){break b}xh=yh+(xh<<2)|0;q[xh>>2]=q[xh>>2]|-1>>>32-Vg;return a}yh=Dn(yh,0,zh);Vg=Vg&31;if(!Vg){break b}xh=yh+(xh<<2)|0;q[xh>>2]=q[xh>>2]&(-1>>>32-Vg^-1)}return a}bn();F()}function sk(a,Vg){var xh=0,Bh=0,Ch=0,Dh=0,Eh=0,Fh=0;a:{Ch=q[a>>2];Fh=q[a+4>>2]-Ch|0;xh=Fh>>3;Bh=xh+1|0;if(Bh>>>0<536870912){Dh=xh<<3;Eh=q[a+8>>2]-Ch|0;xh=Eh>>2;Bh=Eh>>3>>>0<268435455?xh>>>0>>0?Bh:xh:536870911;xh=0;b:{if(!Bh){break b}if(Bh>>>0>=536870912){break a}xh=Mm(Bh<<3)}Dh=Dh+xh|0;Eh=q[Vg+4>>2];q[Dh>>2]=q[Vg>>2];q[Dh+4>>2]=Eh;Vg=xh+(Bh<<3)|0;Bh=Dh+8|0;if((Fh|0)>=1){Cn(xh,Ch,Fh)}q[a>>2]=xh;q[a+8>>2]=Vg;q[a+4>>2]=Bh;if(Ch){An(Ch)}return}bn();F()}ab(13904);F()}function tk(a,Vg,Gh){var Hh=0,Ih=0,Jh=0,Kh=0;a:{b:{if((Vg|Gh)<0|Vg>>>0>1431655765){break b}Vg=w(Vg,3);uk(a,Vg,13896);u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Lh=Lh+4|0;Vg=Vg+ -1|0;if(Vg){continue}break}q[a+4>>2]=Lh;return}bn();F()}function vk(a){al(a);q[a+84>>2]=0;q[a+88>>2]=0;q[a>>2]=13980;q[a+92>>2]=0;q[a+96>>2]=0;q[a+100>>2]=0;q[a+104>>2]=0;return a}function wk(a){a=a|0;var Vg=0,Gh=0,Qh=0,Rh=0,Sh=0;q[a>>2]=14380;Vg=q[a+68>>2];if(Vg){q[a+72>>2]=Vg;An(Vg)}Vg=q[a+56>>2];if(Vg){q[a+60>>2]=Vg;An(Vg)}Vg=q[a+44>>2];if(Vg){q[a+48>>2]=Vg;An(Vg)}Vg=q[a+32>>2];if(Vg){q[a+36>>2]=Vg;An(Vg)}Vg=q[a+20>>2];if(Vg){q[a+24>>2]=Vg;An(Vg)}Qh=q[a+8>>2];if(Qh){Vg=Qh;Sh=a+12|0;Gh=q[Sh>>2];Rh=Vg;a:{if((Vg|0)==(Gh|0)){break a}while(1){Gh=Gh+ -4|0;Vg=q[Gh>>2];q[Gh>>2]=0;if(Vg){Hb(Vg)}if((Gh|0)!=(Qh|0)){continue}break}Rh=q[a+8>>2]}Vg=Rh;q[Sh>>2]=Qh;An(Vg)}Vg=q[a+4>>2];q[a+4>>2]=0;if(Vg){Lj(Vg)}return a|0}function xk(a){a=a|0;var Th=0;q[a>>2]=13980;Th=q[a+96>>2];if(Th){q[a+100>>2]=Th;An(Th)}Th=q[a+84>>2];if(Th){q[a+88>>2]=Th;An(Th)}wk(a);return a|0}function yk(a){a=a|0;var Uh=0;q[a>>2]=13980;Uh=q[a+96>>2];if(Uh){q[a+100>>2]=Uh;An(Uh)}Uh=q[a+84>>2];if(Uh){q[a+88>>2]=Uh;An(Uh)}wk(a);An(a)}function zk(a,Vh,Wh){a=a|0;Vh=Vh|0;Wh=Wh|0;var Xh=0,Yh=0;Xh=T-16|0;T=Xh;Yh=q[Wh>>2];q[Wh>>2]=0;q[Xh+8>>2]=Yh;gl(a,Vh,Xh+8|0);Wh=q[Xh+8>>2];q[Xh+8>>2]=0;if(Wh){Hb(Wh)}Yh=q[a+84>>2];Wh=q[a+88>>2]-Yh>>2;a:{if((Wh|0)>(Vh|0)){break a}Vh=Vh+1|0;if(Vh>>>0>Wh>>>0){Ak(a+84|0,Vh-Wh|0);break a}if(Vh>>>0>=Wh>>>0){break a}q[a+88>>2]=Yh+(Vh<<2)}T=Xh+16|0}function Ak(a,Vh){var Wh=0,Zh=0,_h=0,$h=0,ai=0,bi=0;_h=q[a+8>>2];Wh=q[a+4>>2];if(_h-Wh>>2>>>0>=Vh>>>0){while(1){q[Wh>>2]=1;Wh=Wh+4|0;Vh=Vh+ -1|0;if(Vh){continue}break}q[a+4>>2]=Wh;return}a:{$h=q[a>>2];ai=Wh-$h|0;bi=ai>>2;Wh=bi+Vh|0;if(Wh>>>0<1073741824){_h=_h-$h|0;Zh=_h>>1;Wh=_h>>2>>>0<536870911?Zh>>>0>>0?Wh:Zh:1073741823;Zh=0;b:{if(!Wh){break b}if(Wh>>>0>=1073741824){break a}Zh=Mm(Wh<<2)}_h=Zh+(Wh<<2)|0;Wh=Zh+(bi<<2)|0;while(1){q[Wh>>2]=1;Wh=Wh+4|0;Vh=Vh+ -1|0;if(Vh){continue}break}if((ai|0)>=1){Cn(Zh,$h,ai)}q[a>>2]=Zh;q[a+8>>2]=_h;q[a+4>>2]=Wh;if($h){An($h)}return}bn();F()}ab(14024);F()}function Bk(a,Vh){a=a|0;Vh=Vh|0;var ci=0,di=0,ei=0;jl(a,Vh);a:{if((Vh|0)<0){break a}ci=q[a+88>>2];di=q[a+84>>2];if(ci-di>>2<=(Vh|0)){break a}Vh=di+(Vh<<2)|0;di=Vh+4|0;ci=ci-di|0;ei=ci>>2;if(ci){En(Vh,di,ci)}q[a+88>>2]=Vh+(ei<<2)}}function Ck(a,Vh){var fi=0,gi=0,hi=0,ii=0,ji=0,ki=0;a:{hi=q[a>>2];ji=q[a+4>>2]-hi|0;fi=ji>>2;gi=fi+1|0;if(gi>>>0<1073741824){ki=fi<<2;fi=q[a+8>>2]-hi|0;ii=fi>>1;gi=fi>>2>>>0<536870911?ii>>>0>>0?gi:ii:1073741823;fi=0;b:{if(!gi){break b}if(gi>>>0>=1073741824){break a}fi=Mm(gi<<2)}ii=ki+fi|0;q[ii>>2]=q[Vh>>2];Vh=fi+(gi<<2)|0;gi=ii+4|0;if((ji|0)>=1){Cn(fi,hi,ji)}q[a>>2]=fi;q[a+8>>2]=Vh;q[a+4>>2]=gi;if(hi){An(hi)}return}bn();F()}ab(14092);F()}function Dk(a){q[a>>2]=0;q[a+4>>2]=0;o[a+24|0]=1;q[a+16>>2]=0;q[a+20>>2]=0;q[a+8>>2]=0;q[a+12>>2]=0;q[a+28>>2]=0;q[a+32>>2]=0;q[a+36>>2]=0;q[a+40>>2]=0;q[a+44>>2]=0;q[a+48>>2]=0;q[a+52>>2]=0;q[a+56>>2]=0;q[a+60>>2]=0;q[a+64>>2]=0;q[a+72>>2]=0;q[a+76>>2]=0;q[a+80>>2]=0;q[a+84>>2]=0;q[a+88>>2]=0;q[a+92>>2]=0;q[a+68>>2]=a}function Ek(a,Vh){var li=0,mi=0,ni=0,oi=0,pi=0,qi=0,ri=0,si=0;qi=T-16|0;T=qi;a:{b:{if(Vh){q[a+88>>2]=0;q[a+92>>2]=0;li=a+84|0;mi=q[li>>2];q[li>>2]=0;if(mi){An(mi)}q[a+76>>2]=0;q[a+80>>2]=0;li=a+72|0;mi=q[li>>2];q[li>>2]=0;if(mi){An(mi)}mi=Vh+4|0;li=q[mi>>2];ni=q[Vh>>2];o[qi+15|0]=0;bb(a,li-ni>>2,qi+15|0);ni=Vh+28|0;li=q[ni>>2];oi=q[Vh+24>>2];o[qi+14|0]=0;bb(a+12|0,li-oi>>2,qi+14|0);uk(a+28|0,q[mi>>2]-q[Vh>>2]>>2,14160);mi=q[a+52>>2];oi=q[ni>>2]-q[Vh+24>>2]|0;li=oi>>2;c:{if(q[a+60>>2]-mi>>2>>>0>=li>>>0){break c}if(li>>>0>=1073741824){break b}ri=a+56|0;pi=q[ri>>2];si=li<<2;li=Mm(oi);si=si+li|0;oi=pi-mi|0;pi=oi+li|0;if((oi|0)>=1){Cn(li,mi,oi)}q[a+52>>2]=li;q[a+60>>2]=si;q[ri>>2]=pi;if(!mi){break c}An(mi)}mi=q[a+40>>2];ni=q[ni>>2]-q[Vh+24>>2]|0;li=ni>>2;d:{if(q[a+48>>2]-mi>>2>>>0>=li>>>0){break d}if(li>>>0>=1073741824){break a}oi=a+44|0;ri=q[oi>>2];pi=li<<2;li=Mm(ni);pi=pi+li|0;ni=ri-mi|0;ri=ni+li|0;if((ni|0)>=1){Cn(li,mi,ni)}q[a+40>>2]=li;q[a+48>>2]=pi;q[oi>>2]=ri;if(!mi){break d}An(mi)}o[a+24|0]=1;q[a+64>>2]=Vh}T=qi+16|0;return}ab(14164);F()}ab(14164);F()}function Fk(a){var Vh=0,ti=0,ui=0,vi=0,wi=0,xi=0,yi=0,Ai=0,Bi=0,Ci=0,Di=0,Ei=0,Fi=0;ui=T-32|0;T=ui;xi=a+56|0;q[xi>>2]=q[a+52>>2];yi=a+44|0;q[yi>>2]=q[a+40>>2];Vh=q[a+64>>2];if(q[Vh+28>>2]!=q[Vh+24>>2]){Bi=a+40|0;Ci=a+52|0;Di=a+60|0;Ei=a+48|0;while(1){ti=q[q[Vh+24>>2]+(Ai<<2)>>2];a:{if((ti|0)==-1){break a}q[ui+24>>2]=wi;Vh=q[xi>>2];b:{if((Vh|0)!=q[Di>>2]){q[Vh>>2]=wi;q[xi>>2]=Vh+4;break b}Hk(Ci,ui+24|0)}q[ui+16>>2]=ti;q[ui+8>>2]=0;c:{if(!(q[q[a+12>>2]+(Ai>>>3&536870908)>>2]>>>(Ai&31)&1)){break c}d:{Vh=ti+1|0;Vh=(Vh>>>0)%3|0?Vh:ti+ -2|0;if(!((Vh|0)==-1|q[q[a>>2]+(Vh>>>3&536870908)>>2]>>>(Vh&31)&1)){Vh=q[q[q[a+64>>2]+12>>2]+(Vh<<2)>>2];if((Vh|0)!=-1){break d}}q[ui+8>>2]=-1;break c}vi=Vh+1|0;Vh=(vi>>>0)%3|0?vi:Vh+ -2|0;q[ui+8>>2]=Vh;if((Vh|0)==-1){break c}while(1){q[ui+16>>2]=Vh;e:{vi=Vh+1|0;ti=Vh;Vh=(vi>>>0)%3|0?vi:Vh+ -2|0;if(!((Vh|0)==-1|q[q[a>>2]+(Vh>>>3&536870908)>>2]>>>(Vh&31)&1)){Vh=q[q[q[a+64>>2]+12>>2]+(Vh<<2)>>2];if((Vh|0)!=-1){break e}}q[ui+8>>2]=-1;break c}vi=Vh+1|0;Vh=(vi>>>0)%3|0?vi:Vh+ -2|0;q[ui+8>>2]=Vh;if((Vh|0)!=-1){continue}break}}Fi=a+28|0;q[q[Fi>>2]+(ti<<2)>>2]=q[ui+24>>2];Vh=q[yi>>2];f:{if((Vh|0)!=q[Ei>>2]){q[Vh>>2]=q[ui+16>>2];q[yi>>2]=Vh+4;break f}zi(Bi,ui+16|0)}wi=wi+1|0;Vh=q[a+64>>2];g:{vi=q[ui+16>>2];if((vi|0)==-1){break g}ti=vi+((vi>>>0)%3|0?-1:2)|0;if((ti|0)==-1){break g}ti=q[q[Vh+12>>2]+(ti<<2)>>2];if((ti|0)==-1){break g}ti=ti+((ti>>>0)%3|0?-1:2)|0;q[ui+8>>2]=ti;if((ti|0)==-1|(ti|0)==(vi|0)){break a}while(1){Vh=ti+1|0;Vh=(Vh>>>0)%3|0?Vh:ti+ -2|0;h:{if(!(q[q[a>>2]+(Vh>>>3&536870908)>>2]>>>(Vh&31)&1)){break h}q[ui+24>>2]=wi;Vh=q[xi>>2];i:{if((Vh|0)!=q[Di>>2]){q[Vh>>2]=wi;q[xi>>2]=Vh+4;break i}Hk(Ci,ui+24|0)}wi=wi+1|0;Vh=q[yi>>2];if((Vh|0)!=q[Ei>>2]){q[Vh>>2]=q[ui+8>>2];q[yi>>2]=Vh+4;break h}zi(Bi,ui+8|0)}q[q[Fi>>2]+(q[ui+8>>2]<<2)>>2]=q[ui+24>>2];Vh=q[a+64>>2];ti=q[ui+8>>2];if((ti|0)==-1){break g}ti=ti+((ti>>>0)%3|0?-1:2)|0;if((ti|0)==-1){break g}ti=q[q[Vh+12>>2]+(ti<<2)>>2];if((ti|0)==-1){break g}ti=ti+((ti>>>0)%3|0?-1:2)|0;q[ui+8>>2]=ti;if((ti|0)==-1){break a}if(q[ui+16>>2]!=(ti|0)){continue}break}break a}q[ui+8>>2]=-1}Ai=Ai+1|0;if(Ai>>>0>2]-q[Vh+24>>2]>>2>>>0){continue}break}}T=ui+32|0}function Gk(a,zi){var Gi=0,Hi=0,Ii=0,Ji=0,Ki=0,Li=0;Ii=q[a>>2];Gi=Ii+(zi>>>3&536870908)|0;q[Gi>>2]=q[Gi>>2]|1<<(zi&31);Ki=q[a+64>>2];Ji=(zi|0)==-1;Gi=-1;a:{if(Ji){break a}Hi=zi+1|0;Hi=(Hi>>>0)%3|0?Hi:zi+ -2|0;Gi=-1;if((Hi|0)==-1){break a}Gi=q[q[Ki>>2]+(Hi<<2)>>2]}Hi=q[a+12>>2];Li=(Gi>>>3&536870908)+Hi|0;q[Li>>2]=q[Li>>2]|1<<(Gi&31);b:{c:{if(!Ji){Gi=-1;Ji=((zi>>>0)%3|0?-1:2)+zi|0;if((Ji|0)!=-1){Gi=q[q[Ki>>2]+(Ji<<2)>>2]}Ji=Hi+(Gi>>>3&536870908)|0;q[Ji>>2]=q[Ji>>2]|1<<(Gi&31);zi=q[q[Ki+12>>2]+(zi<<2)>>2];if((zi|0)==-1){break b}o[a+24|0]=0;a=(zi>>>3&536870908)+Ii|0;q[a>>2]=q[a>>2]|1<<(zi&31);a=-1;Gi=-1;Ii=zi+1|0;Ii=(Ii>>>0)%3|0?Ii:zi+ -2|0;if((Ii|0)!=-1){Gi=q[q[Ki>>2]+(Ii<<2)>>2]}Ii=Hi+(Gi>>>3&536870908)|0;q[Ii>>2]=q[Ii>>2]|1<<(Gi&31);zi=zi+((zi>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zi|0;Ui=q[Si>>2];c:{if($i){Vi=Si+8|0;Si=Si+4|0;break c}Xi=q[aj>>2];Vi=Xi+(q[Si+8>>2]<<2)|0;Ui=q[Xi+(Ui<<2)>>2];Si=Xi+(q[Si+4>>2]<<2)|0}Xi=q[Si>>2];Si=Wi+_i|0;q[Si+8>>2]=q[Vi>>2];q[Si+4>>2]=Xi;q[Si>>2]=Ui;zi=zi+1|0;if(zi>>>0>>0){continue}break}}kk(a,Ti);a=q[Ti>>2];if(!a){break a}q[Ti+4>>2]=a;An(a);break a}bn();F()}T=Ti+16|0}function Jk(a,zi,bj){var cj=0,dj=0,ej=0,fj=0,gj=0,hj=0,ij=0,jj=0,kj=0,lj=0,mj=0,nj=0,oj=0,pj=0,qj=0,rj=0;hj=T-16|0;T=hj;gj=w(zi,12)+a|0;ij=gj+12|0;nj=gj+8|0;q[ij>>2]=q[nj>>2];q[hj+8>>2]=(bj|0)==-1?-1:(bj>>>0)/3|0;oj=gj+16|0;pj=a+4|0;ej=bj;while(1){gj=dj;jj=(dj|0)==1;a:{b:{if(!jj){dj=q[hj+8>>2];break b}if((ej|0)==-1){ej=-1;Kk(a,-1);break a}if((ej|0)==-1|(Kk(a,((ej>>>0)%3|0?-1:2)+ej|0)|0)==-1){break a}bj=ej+1|0;cj=(bj>>>0)%3|0?bj:ej+ -2|0;if((cj|0)==-1){break a}bj=cj+1|0;bj=(bj>>>0)%3|0?bj:cj+ -2|0;if((bj|0)==-1){break a}cj=q[q[q[pj>>2]+12>>2]+(bj<<2)>>2];if((cj|0)==-1){break a}bj=cj+1|0;bj=(bj>>>0)%3|0?bj:cj+ -2|0;if((bj|0)==-1){break a}dj=(bj>>>0)/3|0;q[hj+8>>2]=dj}kj=1<<(dj&31);lj=q[a+56>>2]+(dj>>>3&536870908)|0;mj=q[lj>>2];c:{if(kj&mj){break c}fj=0;while(1){q[lj>>2]=kj|mj;cj=q[ij>>2];d:{if((cj|0)!=q[oj>>2]){q[cj>>2]=dj;q[ij>>2]=cj+4;break d}Ck(nj,hj+8|0)}cj=fj+1|0;e:{if(!fj){break e}if(cj&1){if((bj|0)==-1){bj=-1;break e}fj=bj+1|0;bj=(fj>>>0)%3|0?fj:bj+ -2|0;break e}ej=jj?bj:ej;if((bj|0)==-1){bj=-1;break e}if((bj>>>0)%3){bj=bj+ -1|0;break e}bj=bj+2|0}bj=Kk(a,bj);if((bj|0)!=-1){dj=(bj>>>0)/3|0;q[hj+8>>2]=dj;fj=cj;kj=1<<(dj&31);lj=q[a+56>>2]+(dj>>>3&268435452)|0;mj=q[lj>>2];if(!(kj&mj)){continue}}break}if(!(cj&1)|(gj|0)!=1){break c}jj=q[ij>>2]+ -4|0;dj=q[jj>>2];fj=q[a+56>>2]+(dj>>>3&536870908)|0;cj=q[fj>>2];qj=fj,rj=eo(dj)&cj,q[qj>>2]=rj;q[ij>>2]=jj}dj=1;if(!gj){continue}}break}q[((zi<<2)+a|0)+44>>2]=ej;zi=q[ij>>2];ej=q[nj>>2];if((zi|0)!=(ej|0)){fj=zi-ej>>2;cj=q[a+56>>2];bj=0;while(1){gj=q[ej+(bj<<2)>>2];zi=cj+(gj>>>3&536870908)|0;a=q[zi>>2];qj=zi,rj=eo(gj)&a,q[qj>>2]=rj;bj=bj+1|0;if(bj>>>0>>0){continue}break}}T=hj+16|0}function Kk(a,zi){var bj=0,sj=0,tj=0,uj=0,vj=0;sj=-1;uj=-1;tj=-1;a:{b:{if((zi|0)==-1){break b}vj=1;uj=q[q[q[a+4>>2]+12>>2]+(zi<<2)>>2];bj=zi+1|0;bj=(bj>>>0)%3|0?bj:zi+ -2|0;if((bj|0)>=0){tj=(bj>>>0)/3|0;tj=q[(q[q[a>>2]+96>>2]+w(tj,12)|0)+(bj-w(tj,3)<<2)>>2]}c:{if((uj|0)==-1){break c}vj=0;bj=((uj>>>0)%3|0?-1:2)+uj|0;if((bj|0)<0){break c}sj=(bj>>>0)/3|0;sj=q[(q[q[a>>2]+96>>2]+w(sj,12)|0)+(bj-w(s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>>2]>=wj>>>0?0:1:0){break e}Cn(Fj,Ej+q[zj>>2]|0,yj);wj=zj;zj=wj;Aj=q[wj+20>>2];yj=zi+q[wj+16>>2]|0;if(yj>>>0>>0){Aj=Aj+1|0}q[zj+16>>2]=yj;q[wj+20>>2]=Aj}Bj=Mm(24);wj=Bj+4|0;q[wj>>2]=0;q[wj+4>>2]=0;zi=Bj+16|0;q[zi>>2]=0;q[zi+4>>2]=0;q[Bj>>2]=wj;q[Bj+12>>2]=zi;q[xj+8>>2]=Bj;_k(Gj,xj+16|0,xj+8|0);zi=q[xj+8>>2];Dj=0;q[xj+8>>2]=0;if(!zi){break e}Hc(zi+12|0,q[zi+16>>2]);Ic(zi,q[zi+4>>2]);An(zi)}if(o[xj+27|0]<=-1){An(q[xj+16>>2])}if(Dj){break b}}if(!Bj){break b}q[xj+16>>2]=0;if(!Mk(1,xj+16|0,q[a>>2])){break b}zi=0;wj=q[xj+16>>2];if(wj){while(1){if(!Nk(a,Bj)){break b}zi=zi+1|0;if(zi>>>0>>0){continue}break}}q[xj+4>>2]=0;if(!Mk(1,xj+4|0,q[a>>2])){break b}Aj=q[xj+4>>2];if(Aj){Dj=0;while(1){zi=q[xj+36>>2];wj=q[xj+40>>2];f:{if(zi>>>0>>0){q[zi+4>>2]=0;q[zi>>2]=Bj;q[xj+36>>2]=q[xj+36>>2]+8;break f}Cj=q[xj+32>>2];Fj=zi-Cj|0;zi=Fj>>3;Ej=zi+1|0;if(Ej>>>0>=536870912){break d}zj=zi<<3;yj=wj-Cj|0;wj=yj>>2;yj=yj>>3>>>0<268435455?wj>>>0>>0?Ej:wj:536870911;zi=0;g:{if(!yj){break g}if(yj>>>0>=536870912){break c}zi=Mm(yj<<3)}wj=zj+zi|0;q[wj+4>>2]=0;q[wj>>2]=Bj;yj=zi+(yj<<3)|0;wj=wj+8|0;if((Fj|0)>=1){Cn(zi,Cj,Fj)}q[xj+40>>2]=yj;q[xj+36>>2]=wj;q[xj+32>>2]=zi;if(!Cj){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if(!Mk(1,Xj+12|0,zi)){break a}c:{_j=q[Xj+12>>2];if(_j){zi=0;while(1){if(!Mk(1,Xj+8|0,q[a>>2])){break b}Wj=Mm(28);Yj=Wj+4|0;q[Yj>>2]=0;q[Yj+4>>2]=0;Zj=Wj+16|0;q[Zj>>2]=0;q[Zj+4>>2]=0;q[Wj>>2]=Yj;Yj=Wj+12|0;q[Yj>>2]=Zj;q[Wj+24>>2]=q[Xj+8>>2];if(!Lk(a,Wj)){break c}q[Xj>>2]=Wj;Qk(Vj,Xj);Wj=q[Xj>>2];q[Xj>>2]=0;if(Wj){Hc(Wj+12|0,q[Wj+16>>2]);Ic(Wj,q[Wj+4>>2]);An(Wj)}zi=zi+1|0;if(zi>>>0<_j>>>0){continue}break}}Wj=Lk(a,Vj);break a}Hc(Yj,q[Wj+16>>2]);Ic(Wj,q[Wj+4>>2]);An(Wj)}Wj=0}T=Xj+16|0;return Wj}function Pk(a,zi,Vj){var $j=0,ak=0,bk=0,ck=0,dk=0,ek=0,fk=0,gk=0,hk=0,ik=0,jk=0,kk=0;$j=T-16|0;T=$j;ck=q[a+24>>2];hk=q[a+28>>2];a:{if((ck|0)!=(hk|0)){jk=$j+8|0;kk=Vj+4|0;while(1){q[jk>>2]=0;q[$j>>2]=0;q[$j+4>>2]=0;a=Yk(q[ck>>2],zi,$j);dk=r[$j+11|0];gk=dk<<24>>24;b:{c:{d:{if(!a){a=3;break d}a=0;ak=r[Vj+11|0];bk=ak<<24>>24;fk=(gk|0)<0?q[$j+4>>2]:dk;if((fk|0)!=(((bk|0)<0?q[kk>>2]:ak)|0)){break d}ek=(bk|0)<0?q[Vj>>2]:Vj;bk=q[$j>>2];ak=(gk|0)<0;e:{if(!ak){if(!fk){break e}ak=$j;if(r[ek|0]!=(bk&255)){break d}while(1){dk=dk+ -1|0;if(!dk){break e}bk=r[ek+1|0];ek=ek+1|0;ak=ak+1|0;if((bk|0)==r[ak|0]){continue}break}break d}if(!fk){break e}if(cm(ak?bk:$j,ek,fk)){break c}}ik=q[ck>>2];a=1}if((gk|0)>-1){break b}}An(q[$j>>2])}if(a>>>0>3){break a}f:{switch(a-1|0){case 0:case 1:break a;default:break f}}ck=ck+4|0;if((hk|0)!=(ck|0)){continue}break}}ik=0}T=$j+16|0;return ik}function Qk(a,zi){var Vj=0,lk=0,mk=0;lk=q[zi>>2];if(!lk){return}Vj=a+28|0;mk=q[Vj>>2];if(mk>>>0>2]){q[zi>>2]=0;q[mk>>2]=lk;q[Vj>>2]=q[Vj>>2]+4;return}Rk(a+24|0,zi)}function Rk(a,zi){var nk=0,ok=0,pk=0,qk=0,rk=0;a:{b:{c:{pk=q[a>>2];qk=q[a+4>>2]-pk>>2;nk=qk+1|0;if(nk>>>0<1073741824){pk=q[a+8>>2]-pk|0;rk=pk>>1;nk=pk>>2>>>0<536870911?rk>>>0>>0?nk:rk:1073741823;if(nk){if(nk>>>0>=1073741824){break c}ok=Mm(nk<<2)}pk=q[zi>>2];q[zi>>2]=0;zi=(qk<<2)+ok|0;q[zi>>2]=pk;pk=(nk<<2)+ok|0;qk=zi+4|0;nk=q[a+4>>2];ok=q[a>>2];if((nk|0)==(ok|0)){break b}while(1){nk=nk+ -4|0;rk=q[nk>>2];q[nk>>2]=0;zi=zi+ -4|0;q[zi>>2]=rk;if((nk|0)!=(ok|0)){continue}break}ok=q[a+4>>2];nk=q[a>>2];break a}bn();F()}ab(14300);F()}nk=ok}q[a>>2]=zi;q[a+8>>2]=pk;q[a+4>>2]=qk;if((nk|0)!=(ok|0)){while(1){ok=ok+ -4|0;a=q[ok>>2];q[ok>>2]=0;if(a){Hc(a+12|0,q[a+16>>2]);Ic(a,q[a+4>>2]);An(a)}if((nk|0)!=(ok|0)){continue}break}}if(nk){An(nk)}}function Sk(a,zi,sk,tk){var uk=0,vk=0,wk=0,xk=0;uk=T-16|0;T=uk;xk=a;vk=ph(zi,uk+12|0,sk);sk=q[vk>>2];if(sk){zi=0}else{sk=Mm(32);Rm(sk+16|0,q[tk>>2]);q[sk+28>>2]=0;q[sk+8>>2]=q[uk+12>>2];q[sk>>2]=0;q[sk+4>>2]=0;q[vk>>2]=sk;tk=sk;wk=q[q[zi>>2]>>2];if(wk){q[zi>>2]=wk;tk=q[vk>>2]}nh(q[zi+4>>2],tk);zi=zi+8|0;q[zi>>2]=q[zi>>2]+1;zi=1}o[xk+4|0]=zi;q[a>>2]=sk;T=uk+16|0}function Tk(a,zi){var sk=0,tk=0,yk=0;sk=q[zi+4>>2];a:{if(!sk){tk=q[zi+8>>2];if(q[tk>>2]==(zi|0)){break a}yk=zi+8|0;while(1){sk=q[yk>>2];yk=sk+8|0;tk=q[sk+8>>2];if((sk|0)!=q[tk>>2]){continue}break}break a}while(1){tk=sk;sk=q[sk>>2];if(sk){continue}break}}if(q[a>>2]==(zi|0)){q[a>>2]=tk}tk=a+8|0;q[tk>>2]=q[tk>>2]+ -1;$k(q[a+4>>2],zi);a=q[zi+28>>2];if(a){q[zi+32>>2]=a;An(a)}if(o[zi+27|0]<=-1){An(q[zi+16>>2])}An(zi)}function Uk(a,zi,zk){var Ak=0,Bk=0,Ck=0,Dk=0,Ek=0;Ak=Mm(40);o[a+8|0]=0;q[a+4>>2]=zi+4;q[a>>2]=Ak;zi=zk+8|0;q[Ak+24>>2]=q[zi>>2];Bk=q[zk+4>>2];q[Ak+16>>2]=q[zk>>2];q[Ak+20>>2]=Bk;q[zk>>2]=0;q[zk+4>>2]=0;q[zi>>2]=0;q[Ak+36>>2]=0;q[Ak+28>>2]=0;q[Ak+32>>2]=0;Ck=zk+16|0;Bk=q[Ck>>2];zi=q[zk+12>>2];Dk=Bk-zi|0;if(Dk){zi=Ak+28|0;Ha(zi,Dk);Bk=q[Ck>>2];Ek=q[zi>>2];zi=q[zk+12>>2]}Cn(Ek,zi,Bk-zi|0);o[a+8|0]=1}function Vk(a,zi,zk){var Fk=0;Fk=a+4|0;a=fk(a,zi);a:{if((Fk|0)==(a|0)){break a}zi=q[a+32>>2];a=q[a+28>>2];if((zi-a|0)!=4){break a}q[zk>>2]=r[a|0]|r[a+1|0]<<8|(r[a+2|0]<<16|r[a+3|0]<<24)}}function Wk(a,zi,zk){var Gk=0,Hk=0,Ik=0,Jk=0;a:{zi=fk(a,zi);b:{if((zi|0)==(a+4|0)){break b}a=q[zi+28>>2];Gk=q[zi+32>>2];if((a|0)==(Gk|0)){break b}a=Gk-a|0;if(a&3){break b}Gk=a>>>2;Jk=zk+4|0;Hk=q[Jk>>2];a=q[zk>>2];Ik=Hk-a>>2;c:{if(Gk>>>0>Ik>>>0){Fa(zk,Gk-Ik|0);Hk=q[Jk>>2];a=q[zk>>2];break c}if(Gk>>>0>=Ik>>>0){break c}Hk=(Gk<<2)+a|0;q[zk+4>>2]=Hk}if((a|0)==(Hk|0)){break a}zk=a;a=q[zi+28>>2];Cn(zk,a,q[zi+32>>2]-a|0)}return}cn();F()}function Xk(a,zi,zk){var Kk=0;Kk=a+4|0;a=fk(a,zi);a:{if((Kk|0)==(a|0)){break a}zi=q[a+32>>2];a=q[a+28>>2];if((zi-a|0)!=8){break a}zi=r[a+4|0]|r[a+5|0]<<8|(r[a+6|0]<<16|r[a+7|0]<<24);q[zk>>2]=r[a|0]|r[a+1|0]<<8|(r[a+2|0]<<16|r[a+3|0]<<24);q[zk+4>>2]=zi}}function Yk(a,zi,zk){var Lk=0,Mk=0,Nk=0;Lk=a+4|0;a=fk(a,zi);a:{if((Lk|0)==(a|0)){break a}zi=a+32|0;Lk=q[zi>>2];Mk=q[a+28>>2];if((Lk|0)==(Mk|0)){break a}Wm(zk,Lk-Mk|0);zk=_m(zk);a=q[a+28>>2];Cn(zk,a,q[zi>>2]-a|0);Nk=1}return Nk}function Zk(a,zi,zk){var Ok=0,Pk=0,Qk=0,Rk=0;Ok=T+ -64|0;T=Ok;Pk=fk(a,zi);if((Pk|0)!=(a+4|0)){Tk(a,Pk)}Pk=0;q[Ok+16>>2]=0;q[Ok+8>>2]=0;q[Ok+12>>2]=0;Rk=q[zk>>2];Qk=q[zk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;if(a){q[a+8>>2]=zk}q[zi+8>>2]=q[zk+8>>2];a=q[zk+8>>2];q[((zk|0)==q[a>>2]?a:a+4|0)>>2]=zi;q[zi>>2]=zk;q[zk+8>>2]=zi}function al(a){q[a>>2]=14380;Dn(a+4|0,0,80);return a}function bl(a,zi){var Zk=0;Zk=-1;a:{if((zi|0)==-1|(zi|0)>4){break a}zi=w(zi,12)+a|0;a=q[zi+20>>2];if((q[zi+24>>2]-a|0)<1){break a}Zk=q[a>>2]}return Zk}function cl(a){var zi=0,_k=0;zi=q[a+20>>2];a:{if((q[a+24>>2]-zi|0)<1){break a}zi=q[zi>>2];if((zi|0)==-1){break a}_k=q[q[a+8>>2]+(zi<<2)>>2]}return _k}function dl(a,$k){var al=0,bl=0,cl=0;al=q[a+8>>2];a=q[a+12>>2];a:{if((al|0)==(a|0)){break a}cl=a-al>>2;a=0;while(1){bl=q[(a<<2)+al>>2];if(q[bl+60>>2]==($k|0)){break a}a=a+1|0;if(a>>>0>>0){continue}break}bl=0}return bl}function el(a,$k){var dl=0,el=0;dl=q[a+8>>2];a=q[a+12>>2];if((dl|0)!=(a|0)){el=a-dl>>2;a=0;while(1){if(q[q[(a<<2)+dl>>2]+60>>2]==($k|0)){return a}a=a+1|0;if(a>>>0>>0){continue}break}}return-1}function fl(a,$k){var fl=0,gl=0,hl=0,il=0,jl=0;fl=T-16|0;T=fl;gl=a+12|0;hl=q[gl>>2];il=q[a+8>>2];jl=q[$k>>2];q[$k>>2]=0;q[fl+8>>2]=jl;n[q[q[a>>2]+8>>2]](a,hl-il>>2,fl+8|0);$k=q[fl+8>>2];q[fl+8>>2]=0;if($k){Hb($k)}T=fl+16|0;return(q[gl>>2]-q[a+8>>2]>>2)+ -1|0}function gl(a,$k,kl){a=a|0;$k=$k|0;kl=kl|0;var ll=0,ml=0,nl=0,ol=0,pl=0,ql=0;ol=T-16|0;T=ol;q[ol+12>>2]=$k;pl=a+8|0;ll=q[a+12>>2];ql=q[a+8>>2];ml=ll-ql>>2;a:{if((ml|0)>($k|0)){break a}nl=$k+1|0;if(nl>>>0>ml>>>0){hl(pl,nl-ml|0);break a}if(nl>>>0>=ml>>>0){break a}ml=ql+(nl<<2)|0;if((ml|0)!=(ll|0)){while(1){ll=ll+ -4|0;nl=q[ll>>2];q[ll>>2]=0;if(nl){Hb(nl)}if((ll|0)!=(ml|0)){continue}break}}q[a+12>>2]=ml}ll=q[q[kl>>2]+56>>2];b:{if((ll|0)>4){break b}ll=w(ll,12)+a|0;ml=ll+24|0;a=q[ml>>2];if((a|0)!=q[ll+28>>2]){q[a>>2]=$k;q[ml>>2]=a+4;break b}il(ll+20|0,ol+12|0)}$k=q[kl>>2];a=q[ol+12>>2];q[$k+60>>2]=a;ll=q[pl>>2];q[kl>>2]=0;kl=ll+(a<<2)|0;a=q[kl>>2];q[kl>>2]=$k;if(a){Hb(a)}T=ol+16|0}function hl(a,$k){var kl=0,rl=0,sl=0,tl=0,ul=0,vl=0,wl=0,xl=0,yl=0;rl=q[a+8>>2];sl=a+4|0;kl=q[sl>>2];if(rl-kl>>2>>>0>=$k>>>0){a=$k<<2;xl=sl,yl=Dn(kl,0,a)+a|0,q[xl>>2]=yl;return}a:{sl=q[a>>2];tl=kl-sl>>2;ul=tl+$k|0;if(ul>>>0<1073741824){tl=tl<<2;rl=rl-sl|0;wl=rl>>1;rl=rl>>2>>>0<536870911?wl>>>0