@lightprotocol/stateless.js 0.17.2-alpha.0 → 0.17.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser/constants.d.ts +2 -0
- package/dist/cjs/browser/idl.d.ts +1015 -0
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/index.d.ts +1 -0
- package/dist/cjs/browser/rpc-interface.d.ts +110 -117
- package/dist/cjs/browser/rpc.d.ts +2 -57
- package/dist/cjs/browser/state/types.d.ts +5 -0
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +2 -3
- package/dist/cjs/browser/utils/test-utils.d.ts +8 -0
- package/dist/cjs/node/constants.d.ts +2 -0
- package/dist/cjs/node/idl.d.ts +1015 -0
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/index.d.ts +1 -0
- package/dist/cjs/node/rpc-interface.d.ts +110 -117
- package/dist/cjs/node/rpc.d.ts +2 -57
- package/dist/cjs/node/state/types.d.ts +5 -0
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +2 -3
- package/dist/cjs/node/utils/test-utils.d.ts +8 -0
- package/dist/types/index.d.ts +1036 -193
- package/package.json +9 -8
- package/dist/cjs/browser/connection-interface.d.ts +0 -125
- package/dist/cjs/node/connection-interface.d.ts +0 -125
- package/dist/es/browser/actions/common.d.ts +0 -3
- package/dist/es/browser/actions/compress.d.ts +0 -16
- package/dist/es/browser/actions/create-account.d.ts +0 -41
- package/dist/es/browser/actions/decompress.d.ts +0 -16
- package/dist/es/browser/actions/index.d.ts +0 -5
- package/dist/es/browser/actions/transfer.d.ts +0 -20
- package/dist/es/browser/connection-interface.d.ts +0 -125
- package/dist/es/browser/constants.d.ts +0 -63
- package/dist/es/browser/errors.d.ts +0 -74
- package/dist/es/browser/index.d.ts +0 -10
- package/dist/es/browser/index.js +0 -2
- package/dist/es/browser/index.js.map +0 -1
- package/dist/es/browser/instruction/index.d.ts +0 -1
- package/dist/es/browser/instruction/pack-compressed-accounts.d.ts +0 -35
- package/dist/es/browser/programs/index.d.ts +0 -2
- package/dist/es/browser/programs/layout.d.ts +0 -25
- package/dist/es/browser/programs/system.d.ts +0 -199
- package/dist/es/browser/rpc-interface.d.ts +0 -1179
- package/dist/es/browser/rpc.d.ts +0 -330
- package/dist/es/browser/state/BN254.d.ts +0 -14
- package/dist/es/browser/state/compressed-account.d.ts +0 -31
- package/dist/es/browser/state/index.d.ts +0 -3
- package/dist/es/browser/state/types.d.ts +0 -91
- package/dist/es/browser/test-helpers/index.d.ts +0 -2
- package/dist/es/browser/test-helpers/merkle-tree/index.d.ts +0 -2
- package/dist/es/browser/test-helpers/merkle-tree/indexed-array.d.ts +0 -85
- package/dist/es/browser/test-helpers/merkle-tree/merkle-tree.d.ts +0 -92
- package/dist/es/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +0 -7
- package/dist/es/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +0 -40
- package/dist/es/browser/test-helpers/test-rpc/get-parsed-events.d.ts +0 -13
- package/dist/es/browser/test-helpers/test-rpc/index.d.ts +0 -3
- package/dist/es/browser/test-helpers/test-rpc/test-rpc.d.ts +0 -250
- package/dist/es/browser/utils/address.d.ts +0 -63
- package/dist/es/browser/utils/airdrop.d.ts +0 -7
- package/dist/es/browser/utils/calculate-compute-unit-price.d.ts +0 -7
- package/dist/es/browser/utils/conversion.d.ts +0 -31
- package/dist/es/browser/utils/index.d.ts +0 -10
- package/dist/es/browser/utils/parse-validity-proof.d.ts +0 -20
- package/dist/es/browser/utils/pipe.d.ts +0 -2
- package/dist/es/browser/utils/send-and-confirm.d.ts +0 -52
- package/dist/es/browser/utils/sleep.d.ts +0 -1
- package/dist/es/browser/utils/test-utils.d.ts +0 -23
- package/dist/es/browser/utils/validation.d.ts +0 -4
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import BN from 'bn.js';
|
|
2
|
-
import { ConfirmOptions, PublicKey } from '@solana/web3.js';
|
|
3
|
-
export declare const FIELD_SIZE: BN;
|
|
4
|
-
export declare const HIGHEST_ADDRESS_PLUS_ONE: BN;
|
|
5
|
-
export declare const noopProgram = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV";
|
|
6
|
-
export declare const lightProgram = "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7";
|
|
7
|
-
export declare const accountCompressionProgram = "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq";
|
|
8
|
-
export declare const getRegisteredProgramPda: () => PublicKey;
|
|
9
|
-
export declare const getAccountCompressionAuthority: () => PublicKey;
|
|
10
|
-
export declare const defaultStaticAccounts: () => PublicKey[];
|
|
11
|
-
export declare const defaultStaticAccountsStruct: () => {
|
|
12
|
-
registeredProgramPda: PublicKey;
|
|
13
|
-
noopProgram: PublicKey;
|
|
14
|
-
accountCompressionProgram: PublicKey;
|
|
15
|
-
accountCompressionAuthority: PublicKey;
|
|
16
|
-
cpiSignatureAccount: null;
|
|
17
|
-
};
|
|
18
|
-
export declare const defaultTestStateTreeAccounts: () => {
|
|
19
|
-
nullifierQueue: PublicKey;
|
|
20
|
-
merkleTree: PublicKey;
|
|
21
|
-
merkleTreeHeight: number;
|
|
22
|
-
addressTree: PublicKey;
|
|
23
|
-
addressQueue: PublicKey;
|
|
24
|
-
};
|
|
25
|
-
export declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
|
|
26
|
-
export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
|
|
27
|
-
export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
|
|
28
|
-
export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
|
|
29
|
-
export declare const confirmConfig: ConfirmOptions;
|
|
30
|
-
export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
|
|
31
|
-
export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
|
|
32
|
-
/** Threshold (per asset) at which new in-UTXOs get merged, in order to reduce UTXO pool size */
|
|
33
|
-
export declare const UTXO_MERGE_THRESHOLD = 20;
|
|
34
|
-
export declare const UTXO_MERGE_MAXIMUM = 10;
|
|
35
|
-
/**
|
|
36
|
-
* Treshold after which the currently used transaction Merkle tree is switched
|
|
37
|
-
* to the next one
|
|
38
|
-
*/
|
|
39
|
-
export declare const TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD: BN;
|
|
40
|
-
/**
|
|
41
|
-
* Fee to provide continous funding for the state Merkle tree.
|
|
42
|
-
* Once the state Merkle tree is at 95% capacity the accumulated fees
|
|
43
|
-
* will be used to fund the next state Merkle tree with the same parameters.
|
|
44
|
-
*
|
|
45
|
-
* Is charged per output compressed account.
|
|
46
|
-
*/
|
|
47
|
-
export declare const STATE_MERKLE_TREE_ROLLOVER_FEE: BN;
|
|
48
|
-
/**
|
|
49
|
-
* Fee to provide continous funding for the address queue and address Merkle tree.
|
|
50
|
-
* Once the address Merkle tree is at 95% capacity the accumulated fees
|
|
51
|
-
* will be used to fund the next address queue and address tree with the same parameters.
|
|
52
|
-
*
|
|
53
|
-
* Is charged per newly created address.
|
|
54
|
-
*/
|
|
55
|
-
export declare const ADDRESS_QUEUE_ROLLOVER_FEE: BN;
|
|
56
|
-
/**
|
|
57
|
-
* Is charged if the transaction nullifies at least one compressed account.
|
|
58
|
-
*/
|
|
59
|
-
export declare const STATE_MERKLE_TREE_NETWORK_FEE: BN;
|
|
60
|
-
/**
|
|
61
|
-
* Is charged if the transaction creates at least one address.
|
|
62
|
-
*/
|
|
63
|
-
export declare const ADDRESS_TREE_NETWORK_FEE: BN;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export declare enum UtxoErrorCode {
|
|
2
|
-
NEGATIVE_LAMPORTS = "NEGATIVE_LAMPORTS",
|
|
3
|
-
NOT_U64 = "NOT_U64",
|
|
4
|
-
BLINDING_EXCEEDS_FIELD_SIZE = "BLINDING_EXCEEDS_FIELD_SIZE"
|
|
5
|
-
}
|
|
6
|
-
export declare enum SelectInUtxosErrorCode {
|
|
7
|
-
FAILED_TO_FIND_UTXO_COMBINATION = "FAILED_TO_FIND_UTXO_COMBINATION",
|
|
8
|
-
INVALID_NUMBER_OF_IN_UTXOS = "INVALID_NUMBER_OF_IN_UTXOS"
|
|
9
|
-
}
|
|
10
|
-
export declare enum CreateUtxoErrorCode {
|
|
11
|
-
OWNER_UNDEFINED = "OWNER_UNDEFINED",
|
|
12
|
-
INVALID_OUTPUT_UTXO_LENGTH = "INVALID_OUTPUT_UTXO_LENGTH",
|
|
13
|
-
UTXO_DATA_UNDEFINED = "UTXO_DATA_UNDEFINED"
|
|
14
|
-
}
|
|
15
|
-
export declare enum RpcErrorCode {
|
|
16
|
-
CONNECTION_UNDEFINED = "CONNECTION_UNDEFINED",
|
|
17
|
-
RPC_PUBKEY_UNDEFINED = "RPC_PUBKEY_UNDEFINED",
|
|
18
|
-
RPC_METHOD_NOT_IMPLEMENTED = "RPC_METHOD_NOT_IMPLEMENTED",
|
|
19
|
-
RPC_INVALID = "RPC_INVALID"
|
|
20
|
-
}
|
|
21
|
-
export declare enum LookupTableErrorCode {
|
|
22
|
-
LOOK_UP_TABLE_UNDEFINED = "LOOK_UP_TABLE_UNDEFINED",
|
|
23
|
-
LOOK_UP_TABLE_NOT_INITIALIZED = "LOOK_UP_TABLE_NOT_INITIALIZED"
|
|
24
|
-
}
|
|
25
|
-
export declare enum HashErrorCode {
|
|
26
|
-
NO_POSEIDON_HASHER_PROVIDED = "NO_POSEIDON_HASHER_PROVIDED"
|
|
27
|
-
}
|
|
28
|
-
export declare enum ProofErrorCode {
|
|
29
|
-
INVALID_PROOF = "INVALID_PROOF",
|
|
30
|
-
PROOF_INPUT_UNDEFINED = "PROOF_INPUT_UNDEFINED",
|
|
31
|
-
PROOF_GENERATION_FAILED = "PROOF_GENERATION_FAILED"
|
|
32
|
-
}
|
|
33
|
-
export declare enum MerkleTreeErrorCode {
|
|
34
|
-
MERKLE_TREE_NOT_INITIALIZED = "MERKLE_TREE_NOT_INITIALIZED",
|
|
35
|
-
SOL_MERKLE_TREE_UNDEFINED = "SOL_MERKLE_TREE_UNDEFINED",
|
|
36
|
-
MERKLE_TREE_UNDEFINED = "MERKLE_TREE_UNDEFINED",
|
|
37
|
-
INPUT_UTXO_NOT_INSERTED_IN_MERKLE_TREE = "INPUT_UTXO_NOT_INSERTED_IN_MERKLE_TREE",
|
|
38
|
-
MERKLE_TREE_INDEX_UNDEFINED = "MERKLE_TREE_INDEX_UNDEFINED",
|
|
39
|
-
MERKLE_TREE_SET_SPACE_UNDEFINED = "MERKLE_TREE_SET_SPACE_UNDEFINED"
|
|
40
|
-
}
|
|
41
|
-
export declare enum UtilsErrorCode {
|
|
42
|
-
ACCOUNT_NAME_UNDEFINED_IN_IDL = "ACCOUNT_NAME_UNDEFINED_IN_IDL",
|
|
43
|
-
PROPERTY_UNDEFINED = "PROPERTY_UNDEFINED",
|
|
44
|
-
LOOK_UP_TABLE_CREATION_FAILED = "LOOK_UP_TABLE_CREATION_FAILED",
|
|
45
|
-
UNSUPPORTED_ARCHITECTURE = "UNSUPPORTED_ARCHITECTURE",
|
|
46
|
-
UNSUPPORTED_PLATFORM = "UNSUPPORTED_PLATFORM",
|
|
47
|
-
ACCOUNTS_UNDEFINED = "ACCOUNTS_UNDEFINED",
|
|
48
|
-
INVALID_NUMBER = "INVALID_NUMBER"
|
|
49
|
-
}
|
|
50
|
-
declare class MetaError extends Error {
|
|
51
|
-
code: string;
|
|
52
|
-
functionName: string;
|
|
53
|
-
codeMessage?: string;
|
|
54
|
-
constructor(code: string, functionName: string, codeMessage?: string);
|
|
55
|
-
}
|
|
56
|
-
export declare class UtxoError extends MetaError {
|
|
57
|
-
}
|
|
58
|
-
export declare class SelectInUtxosError extends MetaError {
|
|
59
|
-
}
|
|
60
|
-
export declare class CreateUtxoError extends MetaError {
|
|
61
|
-
}
|
|
62
|
-
export declare class RpcError extends MetaError {
|
|
63
|
-
}
|
|
64
|
-
export declare class LookupTableError extends MetaError {
|
|
65
|
-
}
|
|
66
|
-
export declare class HashError extends MetaError {
|
|
67
|
-
}
|
|
68
|
-
export declare class ProofError extends MetaError {
|
|
69
|
-
}
|
|
70
|
-
export declare class MerkleTreeError extends MetaError {
|
|
71
|
-
}
|
|
72
|
-
export declare class UtilsError extends MetaError {
|
|
73
|
-
}
|
|
74
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './actions';
|
|
2
|
-
export * from './instruction';
|
|
3
|
-
export * from './programs';
|
|
4
|
-
export * from './state';
|
|
5
|
-
export * from './utils';
|
|
6
|
-
export * from './constants';
|
|
7
|
-
export * from './errors';
|
|
8
|
-
export * from './rpc-interface';
|
|
9
|
-
export * from './rpc';
|
|
10
|
-
export * from './test-helpers';
|
package/dist/es/browser/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import t,{PublicKey as e,Keypair as r,TransactionMessage as n,VersionedTransaction as o,Connection as s,SystemProgram as i,TransactionInstruction as a,ComputeBudgetProgram as u,SolanaJSONRPCError as l}from"@solana/web3.js";import{Buffer as h}from"buffer";import c from"buffer-layout";import{coerce as d,instance as m,string as f,number as p,unknown as g,type as w,nullable as y,array as v,any as M,union as b,literal as A,create as E}from"superstruct";var I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function k(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T={exports:{}};!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof T?T.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function i(t,e){var n=t.charCodeAt(e);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(0,"Invalid character in "+t)}function a(t,e,r){var n=i(t,r);return r-1>=e&&(n|=i(t,r-1)<<4),n}function u(t,e,n,o){for(var s=0,i=0,a=Math.min(t.length,n),u=e;u<a;u++){var l=t.charCodeAt(u)-48;s*=o,i=l>=49?l-49+10:l>=17?l-17+10:l,r(l>=0&&i<o,"Invalid character"),s+=i}return s}function l(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o?1:null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var o=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<t.length&&(16===e?this._parseHex(t,o,n):(this._parseBase(t,e,o),"le"===n&&this._initArray(this.toArray(),e,n)))},o.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var s,i,a=0;if("be"===n)for(o=t.length-1,s=0;o>=0;o-=3)i=t[o]|t[o-1]<<8|t[o-2]<<16,this.words[s]|=i<<a&67108863,this.words[s+1]=i>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(o=0,s=0;o<t.length;o+=3)i=t[o]|t[o+1]<<8|t[o+2]<<16,this.words[s]|=i<<a&67108863,this.words[s+1]=i>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,s=0,i=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)o=a(t,e,n)<<s,this.words[i]|=67108863&o,s>=18?(s-=18,i+=1,this.words[i]|=o>>>26):s+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)o=a(t,e,n)<<s,this.words[i]|=67108863&o,s>=18?(s-=18,i+=1,this.words[i]|=o>>>26):s+=8;this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,o=1;o<=67108863;o*=e)n++;n--,o=o/e|0;for(var s=t.length-r,i=s%n,a=Math.min(s,s-i)+r,l=0,h=r;h<a;h+=n)l=u(t,h,h+n,e),this.imuln(o),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l);if(0!==i){var c=1;for(l=u(t,h,t.length,e),h=0;h<i;h++)c*=e;this.imuln(c),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){l(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(t){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var o=0|t.words[0],s=0|e.words[0],i=o*s,a=67108863&i,u=i/67108864|0;r.words[0]=a;for(var l=1;l<n;l++){for(var h=u>>>26,c=67108863&u,d=Math.min(l,e.length-1),m=Math.max(0,l-t.length+1);m<=d;m++){var f=l-m|0;h+=(i=(o=0|t.words[f])*(s=0|e.words[m])+c)/67108864|0,c=67108863&i}r.words[l]=0|c,u=0|h}return 0!==u?r.words[l]=0|u:r.length--,r._strip()}o.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var o=0,s=0,i=0;i<this.length;i++){var a=this.words[i],u=(16777215&(a<<o|s)).toString(16);s=a>>>24-o&16777215,(o+=2)>=26&&(o-=26,i--),n=0!==s||i!==this.length-1?c[6-u.length]+u+n:u+n}for(0!==s&&(n=s.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var l=d[t],h=m[t];n="";var f=this.clone();for(f.negative=0;!f.isZero();){var p=f.modrn(h).toString(t);n=(f=f.idivn(h)).isZero()?p+n:c[l-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(0,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(0,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,n){this._strip();var o=this.byteLength(),s=n||Math.max(1,o);r(o<=s,"byte array longer than desired length"),r(s>0,"Requested array length <= 0");var i=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](i,o),i},o.prototype._toArrayLikeLE=function(t){for(var e=0,r=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|r;t[e++]=255&s,e<t.length&&(t[e++]=s>>8&255),e<t.length&&(t[e++]=s>>16&255),6===o?(e<t.length&&(t[e++]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(e<t.length)for(t[e++]=r;e<t.length;)t[e++]=0},o.prototype._toArrayLikeBE=function(t){for(var e=t.length-1,r=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|r;t[e--]=255&s,e>=0&&(t[e--]=s>>8&255),e>=0&&(t[e--]=s>>16&255),6===o?(e>=0&&(t[e--]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(e>=0)for(t[e--]=r;e>=0;)t[e--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},o.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},o.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},o.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var o=0;o<e;o++)this.words[o]=67108863&~this.words[o];return n>0&&(this.words[o]=~this.words[o]&67108863>>26-n),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,o=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<o:this.words[n]&~(1<<o),this._strip()},o.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)e=(0|r.words[s])+(0|n.words[s])+o,this.words[s]=67108863&e,o=e>>>26;for(;0!==o&&s<r.length;s++)e=(0|r.words[s])+o,this.words[s]=67108863&e,o=e>>>26;if(this.length=r.length,0!==o)this.words[this.length]=o,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,o=this.cmp(t);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(r=this,n=t):(r=t,n=this);for(var s=0,i=0;i<n.length;i++)s=(e=(0|r.words[i])-(0|n.words[i])+s)>>26,this.words[i]=67108863&e;for(;0!==s&&i<r.length;i++)s=(e=(0|r.words[i])+s)>>26,this.words[i]=67108863&e;if(0===s&&i<r.length&&r!==this)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=Math.max(this.length,i),r!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var n,o,s,i=t.words,a=e.words,u=r.words,l=0,h=0|i[0],c=8191&h,d=h>>>13,m=0|i[1],f=8191&m,p=m>>>13,g=0|i[2],w=8191&g,y=g>>>13,v=0|i[3],M=8191&v,b=v>>>13,A=0|i[4],E=8191&A,I=A>>>13,k=0|i[5],T=8191&k,x=k>>>13,_=0|i[6],S=8191&_,N=_>>>13,P=0|i[7],B=8191&P,C=P>>>13,O=0|i[8],L=8191&O,U=O>>>13,D=0|i[9],R=8191&D,q=D>>>13,F=0|a[0],V=8191&F,H=F>>>13,Q=0|a[1],K=8191&Q,z=Q>>>13,W=0|a[2],j=8191&W,$=W>>>13,Z=0|a[3],X=8191&Z,G=Z>>>13,J=0|a[4],Y=8191&J,tt=J>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,ot=0|a[6],st=8191&ot,it=ot>>>13,at=0|a[7],ut=8191&at,lt=at>>>13,ht=0|a[8],ct=8191&ht,dt=ht>>>13,mt=0|a[9],ft=8191&mt,pt=mt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(n=Math.imul(c,V))|0)+((8191&(o=(o=Math.imul(c,H))+Math.imul(d,V)|0))<<13)|0;l=((s=Math.imul(d,H))+(o>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(f,V),o=(o=Math.imul(f,H))+Math.imul(p,V)|0,s=Math.imul(p,H);var wt=(l+(n=n+Math.imul(c,K)|0)|0)+((8191&(o=(o=o+Math.imul(c,z)|0)+Math.imul(d,K)|0))<<13)|0;l=((s=s+Math.imul(d,z)|0)+(o>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(w,V),o=(o=Math.imul(w,H))+Math.imul(y,V)|0,s=Math.imul(y,H),n=n+Math.imul(f,K)|0,o=(o=o+Math.imul(f,z)|0)+Math.imul(p,K)|0,s=s+Math.imul(p,z)|0;var yt=(l+(n=n+Math.imul(c,j)|0)|0)+((8191&(o=(o=o+Math.imul(c,$)|0)+Math.imul(d,j)|0))<<13)|0;l=((s=s+Math.imul(d,$)|0)+(o>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(M,V),o=(o=Math.imul(M,H))+Math.imul(b,V)|0,s=Math.imul(b,H),n=n+Math.imul(w,K)|0,o=(o=o+Math.imul(w,z)|0)+Math.imul(y,K)|0,s=s+Math.imul(y,z)|0,n=n+Math.imul(f,j)|0,o=(o=o+Math.imul(f,$)|0)+Math.imul(p,j)|0,s=s+Math.imul(p,$)|0;var vt=(l+(n=n+Math.imul(c,X)|0)|0)+((8191&(o=(o=o+Math.imul(c,G)|0)+Math.imul(d,X)|0))<<13)|0;l=((s=s+Math.imul(d,G)|0)+(o>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(E,V),o=(o=Math.imul(E,H))+Math.imul(I,V)|0,s=Math.imul(I,H),n=n+Math.imul(M,K)|0,o=(o=o+Math.imul(M,z)|0)+Math.imul(b,K)|0,s=s+Math.imul(b,z)|0,n=n+Math.imul(w,j)|0,o=(o=o+Math.imul(w,$)|0)+Math.imul(y,j)|0,s=s+Math.imul(y,$)|0,n=n+Math.imul(f,X)|0,o=(o=o+Math.imul(f,G)|0)+Math.imul(p,X)|0,s=s+Math.imul(p,G)|0;var Mt=(l+(n=n+Math.imul(c,Y)|0)|0)+((8191&(o=(o=o+Math.imul(c,tt)|0)+Math.imul(d,Y)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(o>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(T,V),o=(o=Math.imul(T,H))+Math.imul(x,V)|0,s=Math.imul(x,H),n=n+Math.imul(E,K)|0,o=(o=o+Math.imul(E,z)|0)+Math.imul(I,K)|0,s=s+Math.imul(I,z)|0,n=n+Math.imul(M,j)|0,o=(o=o+Math.imul(M,$)|0)+Math.imul(b,j)|0,s=s+Math.imul(b,$)|0,n=n+Math.imul(w,X)|0,o=(o=o+Math.imul(w,G)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,G)|0,n=n+Math.imul(f,Y)|0,o=(o=o+Math.imul(f,tt)|0)+Math.imul(p,Y)|0,s=s+Math.imul(p,tt)|0;var bt=(l+(n=n+Math.imul(c,rt)|0)|0)+((8191&(o=(o=o+Math.imul(c,nt)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,nt)|0)+(o>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,V),o=(o=Math.imul(S,H))+Math.imul(N,V)|0,s=Math.imul(N,H),n=n+Math.imul(T,K)|0,o=(o=o+Math.imul(T,z)|0)+Math.imul(x,K)|0,s=s+Math.imul(x,z)|0,n=n+Math.imul(E,j)|0,o=(o=o+Math.imul(E,$)|0)+Math.imul(I,j)|0,s=s+Math.imul(I,$)|0,n=n+Math.imul(M,X)|0,o=(o=o+Math.imul(M,G)|0)+Math.imul(b,X)|0,s=s+Math.imul(b,G)|0,n=n+Math.imul(w,Y)|0,o=(o=o+Math.imul(w,tt)|0)+Math.imul(y,Y)|0,s=s+Math.imul(y,tt)|0,n=n+Math.imul(f,rt)|0,o=(o=o+Math.imul(f,nt)|0)+Math.imul(p,rt)|0,s=s+Math.imul(p,nt)|0;var At=(l+(n=n+Math.imul(c,st)|0)|0)+((8191&(o=(o=o+Math.imul(c,it)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(o>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(B,V),o=(o=Math.imul(B,H))+Math.imul(C,V)|0,s=Math.imul(C,H),n=n+Math.imul(S,K)|0,o=(o=o+Math.imul(S,z)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,z)|0,n=n+Math.imul(T,j)|0,o=(o=o+Math.imul(T,$)|0)+Math.imul(x,j)|0,s=s+Math.imul(x,$)|0,n=n+Math.imul(E,X)|0,o=(o=o+Math.imul(E,G)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,G)|0,n=n+Math.imul(M,Y)|0,o=(o=o+Math.imul(M,tt)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,tt)|0,n=n+Math.imul(w,rt)|0,o=(o=o+Math.imul(w,nt)|0)+Math.imul(y,rt)|0,s=s+Math.imul(y,nt)|0,n=n+Math.imul(f,st)|0,o=(o=o+Math.imul(f,it)|0)+Math.imul(p,st)|0,s=s+Math.imul(p,it)|0;var Et=(l+(n=n+Math.imul(c,ut)|0)|0)+((8191&(o=(o=o+Math.imul(c,lt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(o>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(L,V),o=(o=Math.imul(L,H))+Math.imul(U,V)|0,s=Math.imul(U,H),n=n+Math.imul(B,K)|0,o=(o=o+Math.imul(B,z)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,z)|0,n=n+Math.imul(S,j)|0,o=(o=o+Math.imul(S,$)|0)+Math.imul(N,j)|0,s=s+Math.imul(N,$)|0,n=n+Math.imul(T,X)|0,o=(o=o+Math.imul(T,G)|0)+Math.imul(x,X)|0,s=s+Math.imul(x,G)|0,n=n+Math.imul(E,Y)|0,o=(o=o+Math.imul(E,tt)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,tt)|0,n=n+Math.imul(M,rt)|0,o=(o=o+Math.imul(M,nt)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,nt)|0,n=n+Math.imul(w,st)|0,o=(o=o+Math.imul(w,it)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,it)|0,n=n+Math.imul(f,ut)|0,o=(o=o+Math.imul(f,lt)|0)+Math.imul(p,ut)|0,s=s+Math.imul(p,lt)|0;var It=(l+(n=n+Math.imul(c,ct)|0)|0)+((8191&(o=(o=o+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(o>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(R,V),o=(o=Math.imul(R,H))+Math.imul(q,V)|0,s=Math.imul(q,H),n=n+Math.imul(L,K)|0,o=(o=o+Math.imul(L,z)|0)+Math.imul(U,K)|0,s=s+Math.imul(U,z)|0,n=n+Math.imul(B,j)|0,o=(o=o+Math.imul(B,$)|0)+Math.imul(C,j)|0,s=s+Math.imul(C,$)|0,n=n+Math.imul(S,X)|0,o=(o=o+Math.imul(S,G)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,G)|0,n=n+Math.imul(T,Y)|0,o=(o=o+Math.imul(T,tt)|0)+Math.imul(x,Y)|0,s=s+Math.imul(x,tt)|0,n=n+Math.imul(E,rt)|0,o=(o=o+Math.imul(E,nt)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,nt)|0,n=n+Math.imul(M,st)|0,o=(o=o+Math.imul(M,it)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,it)|0,n=n+Math.imul(w,ut)|0,o=(o=o+Math.imul(w,lt)|0)+Math.imul(y,ut)|0,s=s+Math.imul(y,lt)|0,n=n+Math.imul(f,ct)|0,o=(o=o+Math.imul(f,dt)|0)+Math.imul(p,ct)|0,s=s+Math.imul(p,dt)|0;var kt=(l+(n=n+Math.imul(c,ft)|0)|0)+((8191&(o=(o=o+Math.imul(c,pt)|0)+Math.imul(d,ft)|0))<<13)|0;l=((s=s+Math.imul(d,pt)|0)+(o>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(R,K),o=(o=Math.imul(R,z))+Math.imul(q,K)|0,s=Math.imul(q,z),n=n+Math.imul(L,j)|0,o=(o=o+Math.imul(L,$)|0)+Math.imul(U,j)|0,s=s+Math.imul(U,$)|0,n=n+Math.imul(B,X)|0,o=(o=o+Math.imul(B,G)|0)+Math.imul(C,X)|0,s=s+Math.imul(C,G)|0,n=n+Math.imul(S,Y)|0,o=(o=o+Math.imul(S,tt)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,tt)|0,n=n+Math.imul(T,rt)|0,o=(o=o+Math.imul(T,nt)|0)+Math.imul(x,rt)|0,s=s+Math.imul(x,nt)|0,n=n+Math.imul(E,st)|0,o=(o=o+Math.imul(E,it)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,it)|0,n=n+Math.imul(M,ut)|0,o=(o=o+Math.imul(M,lt)|0)+Math.imul(b,ut)|0,s=s+Math.imul(b,lt)|0,n=n+Math.imul(w,ct)|0,o=(o=o+Math.imul(w,dt)|0)+Math.imul(y,ct)|0,s=s+Math.imul(y,dt)|0;var Tt=(l+(n=n+Math.imul(f,ft)|0)|0)+((8191&(o=(o=o+Math.imul(f,pt)|0)+Math.imul(p,ft)|0))<<13)|0;l=((s=s+Math.imul(p,pt)|0)+(o>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(R,j),o=(o=Math.imul(R,$))+Math.imul(q,j)|0,s=Math.imul(q,$),n=n+Math.imul(L,X)|0,o=(o=o+Math.imul(L,G)|0)+Math.imul(U,X)|0,s=s+Math.imul(U,G)|0,n=n+Math.imul(B,Y)|0,o=(o=o+Math.imul(B,tt)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,tt)|0,n=n+Math.imul(S,rt)|0,o=(o=o+Math.imul(S,nt)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,nt)|0,n=n+Math.imul(T,st)|0,o=(o=o+Math.imul(T,it)|0)+Math.imul(x,st)|0,s=s+Math.imul(x,it)|0,n=n+Math.imul(E,ut)|0,o=(o=o+Math.imul(E,lt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,lt)|0,n=n+Math.imul(M,ct)|0,o=(o=o+Math.imul(M,dt)|0)+Math.imul(b,ct)|0,s=s+Math.imul(b,dt)|0;var xt=(l+(n=n+Math.imul(w,ft)|0)|0)+((8191&(o=(o=o+Math.imul(w,pt)|0)+Math.imul(y,ft)|0))<<13)|0;l=((s=s+Math.imul(y,pt)|0)+(o>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(R,X),o=(o=Math.imul(R,G))+Math.imul(q,X)|0,s=Math.imul(q,G),n=n+Math.imul(L,Y)|0,o=(o=o+Math.imul(L,tt)|0)+Math.imul(U,Y)|0,s=s+Math.imul(U,tt)|0,n=n+Math.imul(B,rt)|0,o=(o=o+Math.imul(B,nt)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,nt)|0,n=n+Math.imul(S,st)|0,o=(o=o+Math.imul(S,it)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,it)|0,n=n+Math.imul(T,ut)|0,o=(o=o+Math.imul(T,lt)|0)+Math.imul(x,ut)|0,s=s+Math.imul(x,lt)|0,n=n+Math.imul(E,ct)|0,o=(o=o+Math.imul(E,dt)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,dt)|0;var _t=(l+(n=n+Math.imul(M,ft)|0)|0)+((8191&(o=(o=o+Math.imul(M,pt)|0)+Math.imul(b,ft)|0))<<13)|0;l=((s=s+Math.imul(b,pt)|0)+(o>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,Y),o=(o=Math.imul(R,tt))+Math.imul(q,Y)|0,s=Math.imul(q,tt),n=n+Math.imul(L,rt)|0,o=(o=o+Math.imul(L,nt)|0)+Math.imul(U,rt)|0,s=s+Math.imul(U,nt)|0,n=n+Math.imul(B,st)|0,o=(o=o+Math.imul(B,it)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,it)|0,n=n+Math.imul(S,ut)|0,o=(o=o+Math.imul(S,lt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,lt)|0,n=n+Math.imul(T,ct)|0,o=(o=o+Math.imul(T,dt)|0)+Math.imul(x,ct)|0,s=s+Math.imul(x,dt)|0;var St=(l+(n=n+Math.imul(E,ft)|0)|0)+((8191&(o=(o=o+Math.imul(E,pt)|0)+Math.imul(I,ft)|0))<<13)|0;l=((s=s+Math.imul(I,pt)|0)+(o>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(R,rt),o=(o=Math.imul(R,nt))+Math.imul(q,rt)|0,s=Math.imul(q,nt),n=n+Math.imul(L,st)|0,o=(o=o+Math.imul(L,it)|0)+Math.imul(U,st)|0,s=s+Math.imul(U,it)|0,n=n+Math.imul(B,ut)|0,o=(o=o+Math.imul(B,lt)|0)+Math.imul(C,ut)|0,s=s+Math.imul(C,lt)|0,n=n+Math.imul(S,ct)|0,o=(o=o+Math.imul(S,dt)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(n=n+Math.imul(T,ft)|0)|0)+((8191&(o=(o=o+Math.imul(T,pt)|0)+Math.imul(x,ft)|0))<<13)|0;l=((s=s+Math.imul(x,pt)|0)+(o>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(R,st),o=(o=Math.imul(R,it))+Math.imul(q,st)|0,s=Math.imul(q,it),n=n+Math.imul(L,ut)|0,o=(o=o+Math.imul(L,lt)|0)+Math.imul(U,ut)|0,s=s+Math.imul(U,lt)|0,n=n+Math.imul(B,ct)|0,o=(o=o+Math.imul(B,dt)|0)+Math.imul(C,ct)|0,s=s+Math.imul(C,dt)|0;var Pt=(l+(n=n+Math.imul(S,ft)|0)|0)+((8191&(o=(o=o+Math.imul(S,pt)|0)+Math.imul(N,ft)|0))<<13)|0;l=((s=s+Math.imul(N,pt)|0)+(o>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(R,ut),o=(o=Math.imul(R,lt))+Math.imul(q,ut)|0,s=Math.imul(q,lt),n=n+Math.imul(L,ct)|0,o=(o=o+Math.imul(L,dt)|0)+Math.imul(U,ct)|0,s=s+Math.imul(U,dt)|0;var Bt=(l+(n=n+Math.imul(B,ft)|0)|0)+((8191&(o=(o=o+Math.imul(B,pt)|0)+Math.imul(C,ft)|0))<<13)|0;l=((s=s+Math.imul(C,pt)|0)+(o>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(R,ct),o=(o=Math.imul(R,dt))+Math.imul(q,ct)|0,s=Math.imul(q,dt);var Ct=(l+(n=n+Math.imul(L,ft)|0)|0)+((8191&(o=(o=o+Math.imul(L,pt)|0)+Math.imul(U,ft)|0))<<13)|0;l=((s=s+Math.imul(U,pt)|0)+(o>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(l+(n=Math.imul(R,ft))|0)+((8191&(o=(o=Math.imul(R,pt))+Math.imul(q,ft)|0))<<13)|0;return l=((s=Math.imul(q,pt))+(o>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=gt,u[1]=wt,u[2]=yt,u[3]=vt,u[4]=Mt,u[5]=bt,u[6]=At,u[7]=Et,u[8]=It,u[9]=kt,u[10]=Tt,u[11]=xt,u[12]=_t,u[13]=St,u[14]=Nt,u[15]=Pt,u[16]=Bt,u[17]=Ct,u[18]=Ot,0!==l&&(u[19]=l,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,o=0,s=0;s<r.length-1;s++){var i=o;o=0;for(var a=67108863&n,u=Math.min(s,e.length-1),l=Math.max(0,s-t.length+1);l<=u;l++){var h=s-l,c=(0|t.words[h])*(0|e.words[l]),d=67108863&c;a=67108863&(d=d+a|0),o+=(i=(i=i+(c/67108864|0)|0)+(d>>>26)|0)>>>26,i&=67108863}r.words[s]=a,n=i,i=o}return 0!==n?r.words[s]=n:r.length--,r._strip()}function w(t,e,r){return g(t,e,r)}Math.imul||(p=f),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?f(this,t,e):r<1024?g(this,t,e):w(this,t,e)},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),w(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,o=0;o<this.length;o++){var s=(0|this.words[o])*t,i=(67108863&s)+(67108863&n);n>>=26,n+=s/67108864|0,n+=i>>>26,this.words[o]=67108863&i}return 0!==n&&(this.words[o]=n,this.length++),e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,o=r%26;e[r]=t.words[n]>>>o&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var s=r.sqr();n<e.length;n++,s=s.sqr())0!==e[n]&&(r=r.mul(s));return r},o.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,o=(t-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var i=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,u=(0|this.words[e])-a<<n;this.words[e]=u|i,i=a>>>26-n}i&&(this.words[e]=i,this.length++)}if(0!==o){for(e=this.length-1;e>=0;e--)this.words[e+o]=this.words[e];for(e=0;e<o;e++)this.words[e]=0;this.length+=o}return this._strip()},o.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,n){var o;r("number"==typeof t&&t>=0),o=e?(e-e%26)/26:0;var s=t%26,i=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,u=n;if(o-=i,o=Math.max(0,o),u){for(var l=0;l<i;l++)u.words[l]=this.words[l];u.length=i}if(0===i);else if(this.length>i)for(this.length-=i,l=0;l<this.length;l++)this.words[l]=this.words[l+i];else this.words[0]=0,this.length=1;var h=0;for(l=this.length-1;l>=0&&(0!==h||l>=o);l--){var c=0|this.words[l];this.words[l]=h<<26-s|c>>>s,h=c&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,o=1<<e;return this.length<=n?0:!!(this.words[n]&o)},o.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var o=67108863^67108863>>>e<<e;this.words[this.length-1]&=o}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,n){var o,s,i=t.length+n;this._expand(i);var a=0;for(o=0;o<t.length;o++){s=(0|this.words[o+n])+a;var u=(0|t.words[o])*e;a=((s-=67108863&u)>>26)-(u/67108864|0),this.words[o+n]=67108863&s}for(;o<this.length-n;o++)a=(s=(0|this.words[o+n])+a)>>26,this.words[o+n]=67108863&s;if(0===a)return this._strip();for(r(-1===a),a=0,o=0;o<this.length;o++)a=(s=-(0|this.words[o])+a)>>26,this.words[o]=67108863&s;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),s=t,i=0|s.words[s.length-1];0!=(r=26-this._countBits(i))&&(s=s.ushln(r),n.iushln(r),i=0|s.words[s.length-1]);var a,u=n.length-s.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var l=0;l<a.length;l++)a.words[l]=0}var h=n.clone()._ishlnsubmul(s,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var c=u-1;c>=0;c--){var d=67108864*(0|n.words[s.length+c])+(0|n.words[s.length+c-1]);for(d=Math.min(d/i|0,67108863),n._ishlnsubmul(s,d,c);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,c),n.isZero()||(n.negative^=1);a&&(a.words[c]=d)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(s=a.div.neg()),"div"!==e&&(i=a.mod.neg(),n&&0!==i.negative&&i.iadd(t)),{div:s,mod:i}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(s=a.div.neg()),{div:s,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(i=a.mod.neg(),n&&0!==i.negative&&i.isub(t)),{div:a.div,mod:i}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var s,i,a},o.prototype.div=function(t){return this.divmod(t,"div",0).div},o.prototype.mod=function(t){return this.divmod(t,"mod",0).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",1).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),o=t.andln(1),s=r.cmp(n);return s<0||1===o&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,o=0,s=this.length-1;s>=0;s--)o=(n*o+(0|this.words[s]))%t;return e?-o:o},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,o=this.length-1;o>=0;o--){var s=(0|this.words[o])+67108864*n;this.words[o]=s/t|0,n=s%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new o(1),i=new o(0),a=new o(0),u=new o(1),l=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++l;for(var h=n.clone(),c=e.clone();!e.isZero();){for(var d=0,m=1;0==(e.words[0]&m)&&d<26;++d,m<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||i.isOdd())&&(s.iadd(h),i.isub(c)),s.iushrn(1),i.iushrn(1);for(var f=0,p=1;0==(n.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(n.iushrn(f);f-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(c)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a),i.isub(u)):(n.isub(e),a.isub(s),u.isub(i))}return{a:a,b:u,gcd:n.iushln(l)}},o.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s,i=new o(1),a=new o(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var l=0,h=1;0==(e.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(e.iushrn(l);l-- >0;)i.isOdd()&&i.iadd(u),i.iushrn(1);for(var c=0,d=1;0==(n.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(n.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a)):(n.isub(e),a.isub(i))}return(s=0===e.cmpn(1)?i:a).cmpn(0)<0&&s.iadd(t),s},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var o=e.cmp(r);if(o<0){var s=e;e=r,r=s}else if(0===o||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,o=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=o,this;for(var s=o,i=n;0!==s&&i<this.length;i++){var a=0|this.words[i];s=(a+=s)>>>26,a&=67108863,this.words[i]=a}return 0!==s&&(this.words[i]=s,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var o=0|this.words[0];e=o===t?0:o<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],o=0|t.words[r];if(n!==o){n<o?e=-1:n>o&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new I(t)},o.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function I(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){I.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(M,v),M.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),o=0;o<n;o++)e.words[o]=t.words[o];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,o=10;o<t.length;o++){var i=0|t.words[o];t.words[o-10]=(i&r)<<4|s>>>22,s=i}s>>>=22,t.words[o-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},M.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(b,v),n(A,v),n(E,v),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,o=67108863&n;n>>>=26,t.words[r]=o,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new M;else if("p224"===t)e=new b;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return y[t]=e,e},I.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},I.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},I.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},I.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},I.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},I.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},I.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},I.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},I.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},I.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},I.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},I.prototype.isqr=function(t){return this.imul(t,t.clone())},I.prototype.sqr=function(t){return this.mul(t,t)},I.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var s=this.m.subn(1),i=0;!s.isZero()&&0===s.andln(1);)i++,s.iushrn(1);r(!s.isZero());var a=new o(1).toRed(this),u=a.redNeg(),l=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,l).cmp(u);)h.redIAdd(u);for(var c=this.pow(h,s),d=this.pow(t,s.addn(1).iushrn(1)),m=this.pow(t,s),f=i;0!==m.cmp(a);){for(var p=m,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<f);var w=this.pow(c,new o(1).iushln(f-g-1));d=d.redMul(w),c=w.redSqr(),m=m.redMul(c),f=g}return d},I.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},I.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var s=r[0],i=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var l=e.words[n],h=u-1;h>=0;h--){var c=l>>h&1;s!==r[0]&&(s=this.sqr(s)),0!==c||0!==i?(i<<=1,i|=c,(4==++a||0===n&&0===h)&&(s=this.mul(s,r[i]),a=0,i=0)):a=0}u=26}return s},I.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},I.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new k(t)},n(k,I),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(n).iushrn(this.shift),i=s;return s.cmp(this.m)>=0?i=s.isub(this.m):s.cmpn(0)<0&&(i=s.iadd(this.m)),i._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,I);var x=T.exports,_=k(x);const S=new _("21888242871839275222246405745257275088548364400416034343698204186575808495617"),N=new _("452312848583266388373324160190187140051835877600158453279131187530910662655"),P="noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",B="SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7",C="compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq",O=()=>new e("35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh"),L=()=>e.findProgramAddressSync([h.from("cpi_authority")],new e(B))[0],U=()=>[new e(O()),new e(P),new e(C),new e(L())],D=()=>({registeredProgramPda:new e(O()),noopProgram:new e(P),accountCompressionProgram:new e(C),accountCompressionAuthority:new e(L()),cpiSignatureAccount:null}),R=()=>({nullifierQueue:new e(q),merkleTree:new e(F),merkleTreeHeight:K,addressTree:new e(V),addressQueue:new e(H)}),q="nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148",F="smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT",V="amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2",H="aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F",Q={commitment:"confirmed",preflightCommitment:"confirmed"},K=26,z=2800,W=20,j=10,$=new _(Math.floor(2**K*.95)),Z=new _(300),X=new _(392),G=new _(5e3),J=new _(5e3);var Y=function(t){const e=new Uint8Array(256);for(let t=0;t<e.length;t++)e[t]=255;for(let r=0;r<58;r++){const n=t.charAt(r),o=n.charCodeAt(0);if(255!==e[o])throw new TypeError(n+" is ambiguous");e[o]=r}const r=t.charAt(0),n=Math.log(58)/Math.log(256),o=Math.log(256)/Math.log(58);function s(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;let o=0,s=0,i=0;for(;t[o]===r;)s++,o++;const a=(t.length-o)*n+1>>>0,u=new Uint8Array(a);for(;t[o];){let r=e[t.charCodeAt(o)];if(255===r)return;let n=0;for(let t=a-1;(0!==r||n<i)&&-1!==t;t--,n++)r+=58*u[t]>>>0,u[t]=r%256>>>0,r=r/256>>>0;if(0!==r)throw new Error("Non-zero carry");i=n,o++}let l=a-i;for(;l!==a&&0===u[l];)l++;const h=new Uint8Array(s+(a-l));let c=s;for(;l!==a;)h[c++]=u[l++];return h}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";let n=0,s=0,i=0;const a=e.length;for(;i!==a&&0===e[i];)i++,n++;const u=(a-i)*o+1>>>0,l=new Uint8Array(u);for(;i!==a;){let t=e[i],r=0;for(let e=u-1;(0!==t||r<s)&&-1!==e;e--,r++)t+=256*l[e]>>>0,l[e]=t%58>>>0,t=t/58>>>0;if(0!==t)throw new Error("Non-zero carry");s=r,i++}let h=u-s;for(;h!==u&&0===l[h];)h++;let c=r.repeat(n);for(;h<u;++h)c+=t.charAt(l[h]);return c},decodeUnsafe:s,decode:function(t){const e=s(t);if(e)return e;throw new Error("Non-base58 character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");const tt=(t,e,r)=>new _(t,e,r),et=(t,e)=>{if("base58"===e){if("string"!=typeof t)throw new Error("Must be a base58 string");return et(Y.decode(t))}return function(t){if(t.gte(S))throw new Error("Value is too large. Max <254 bits");return t}(new _(t,e))};function rt(t){const e=et(t).toArrayLike(h,void 0,32);return Y.encode(e)}const nt=(t,e,r,n)=>({owner:t,lamports:e??tt(0),address:n??null,data:r??null}),ot=(t,e,r,n,o)=>({...nt(e,r,n,o),...t,readOnly:0}),st=(t,e,r,n)=>({merkleTree:t,nullifierQueue:e,hash:r,leafIndex:n});function it(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function at(t,...e){if(!((r=t)instanceof Uint8Array||null!=r&&"object"==typeof r&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function ut(t,e=1){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}const lt=BigInt(2**32-1),ht=BigInt(32);function ct(t,e=0){return e?{h:Number(t<),l:Number(t>>ht<)}:{h:0|Number(t>>ht<),l:0|Number(t<)}}function dt(t,e=0){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:s,l:i}=ct(t[o],e);[r[o],n[o]]=[s,i]}return[r,n]}const mt=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function ft(t){for(let r=0;r<t.length;r++)t[r]=(e=t[r])<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var e}function pt(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),at(t),t}class gt{clone(){return this._cloneInto()}}const wt=[],yt=[],vt=[],Mt=BigInt(0),bt=BigInt(1),At=BigInt(2),Et=BigInt(7),It=BigInt(256),kt=BigInt(113);for(let t=0,e=bt,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],wt.push(2*(5*n+r)),yt.push((t+1)*(t+2)/2%64);let o=Mt;for(let t=0;t<7;t++)e=(e<<bt^(e>>Et)*kt)%It,e&At&&(o^=bt<<(bt<<BigInt(t))-bt);vt.push(o)}const[Tt,xt]=dt(vt,1),_t=(t,e,r)=>r>32?((t,e,r)=>e<<r-32|t>>>64-r)(t,e,r):((t,e,r)=>t<<r|e>>>32-r)(t,e,r),St=(t,e,r)=>r>32?((t,e,r)=>t<<r-32|e>>>64-r)(t,e,r):((t,e,r)=>e<<r|t>>>32-r)(t,e,r);class Nt extends gt{constructor(t,e,r,n=0,o=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=o,this.pos=0,this.posOut=0,this.finished=0,this.destroyed=0,it(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){mt||ft(this.state32),function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,o=(e+2)%10,s=r[o],i=r[o+1],a=_t(s,i,1)^r[n],u=St(s,i,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=u}let e=t[2],o=t[3];for(let r=0;r<24;r++){const n=yt[r],s=_t(e,o,n),i=St(e,o,n),a=wt[r];e=t[a],o=t[a+1],t[a]=s,t[a+1]=i}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=Tt[n],t[1]^=xt[n]}r.fill(0)}(this.state32,this.rounds),mt||ft(this.state32),this.posOut=0,this.pos=0}update(t){ut(this);const{blockLen:e,state:r}=this,n=(t=pt(t)).length;for(let o=0;o<n;){const s=Math.min(e-this.pos,n-o);for(let e=0;e<s;e++)r[this.pos++]^=t[o++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=1;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,0!=(128&e)&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){ut(this,0),at(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,o=t.length;n<o;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,o-n);t.set(e.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return it(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(function(t,e){at(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=1,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:o,enableXOF:s}=this;return t||(t=new Nt(e,r,n,s,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=n,t.enableXOF=s,t.destroyed=this.destroyed,t}}const Pt=(()=>function(t){const e=e=>t().update(pt(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}((()=>new Nt(136,1,32))))();function Bt(t){return r.fromSecretKey(Uint8Array.from(t))}function Ct(t){return"0x"+t.toString("hex")}const Ot=t=>Array.isArray(t)?t:[t],Lt=t=>et(t).toString();function Ut(t){return tt(t,void 0,"be").lt(S)}function Dt(t){let e=255;for(;e>=0;){const r=h.concat([t,h.from([e])]),n=Pt(r);if(32!==n.length)throw new Error("Invalid hash length");if(n[0]=0,Ut(h.from(n)))return[h.from(n),e];e-=1}return null}function Rt(t){const e=Pt.create();for(const r of t)e.update(r);const r=e.digest();return r[0]=0,r}function qt(t,e){t.forEach((t=>{e.includes(t)||e.push(t)}))}function Ft(t){return Array.isArray(t)?t.map((t=>Ft(t))):null!==t&&t.constructor===Object?Object.keys(t).reduce(((e,r)=>(e[r.replace(/([-_][a-z])/gi,(t=>t.toUpperCase().replace("-","").replace("_","")))]=Ft(t[r]),e)),{}):t}if(import.meta.vitest){const{it:t,expect:e,describe:r}=import.meta.vitest;r("toArray function",(()=>{t("should convert a single item to an array",(()=>{e(Ot(1)).toEqual([1])})),t("should leave an array unchanged",(()=>{e(Ot([1,2,3])).toEqual([1,2,3])}))})),r("isSmallerThanBn254FieldSizeBe function",(()=>{t("should return true for a small number",(()=>{const t=h.from("0000000000000000000000000000000000000000000000000000000000000000","hex");e(Ut(t)).toBe(1)})),t("should return false for a large number",(()=>{const t=h.from("0000000000000000000000000000000000000000000000000000000000000065","hex").reverse();e(Ut(t)).toBe(0)}))})),r("hashToBn254FieldSizeBe function",(()=>{const r=[131,219,249,246,221,196,33,3,114,23,121,235,18,229,71,152,39,87,169,208,143,101,43,128,245,59,22,134,182,231,116,33],n=[0,146,15,187,171,163,183,93,237,121,37,231,55,162,208,188,244,77,185,157,93,9,101,193,220,247,109,94,48,212,98,149];t("should return a valid value for initial buffer",(async()=>{const t=await Dt(h.from(r));e(Array.from(t[0])).toEqual(n)})),t("should return a valid value for initial buffer",(async()=>{const t=h.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),r=await Dt(t);e(r).not.toBeNull(),r&&(e(r[0]).toBeInstanceOf(h),e(r[1]).toBe(255))})),t("should return a valid value for a buffer that can be hashed to a smaller value",(async()=>{const t=h.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe","hex"),r=await Dt(t);e(r).not.toBeNull(),r&&(e(r[1]).toBeLessThanOrEqual(255),e(r[0]).toBeInstanceOf(h),e(Ut(r[0])).toBe(1))})),t("should correctly hash the input buffer",(async()=>{const t=h.from("deadbeef","hex"),r=await Dt(t);e(r).not.toBeNull(),r&&(e(r[0].length).toBe(32),e(r[1]).toBeLessThanOrEqual(255),e(Ut(r[0])).toBe(1))}))})),r("pushUniqueItems function",(()=>{t("should add unique items",(()=>{const t=[1,2,3];qt([3,4,5],t),e(t).toEqual([1,2,3,4,5])})),t("should ignore duplicates",(()=>{const t=[1,2,3];qt([1,2,3],t),e(t).toEqual([1,2,3])})),t("should handle empty arrays",(()=>{const t=[];qt([],t),e(t).toEqual([])}))})),r("bufToDecStr",(()=>{t("should convert buffer [0] to '0'",(()=>{e(Lt(h.from([0]))).toEqual("0")})),t("should convert buffer [1] to '1'",(()=>{e(Lt(h.from([1]))).toEqual("1")})),t("should convert buffer [1, 0] to '256'",(()=>{e(Lt(h.from([1,0]))).toEqual("256")})),t("should convert buffer [1, 1] to '257'",(()=>{e(Lt(h.from([1,1]))).toEqual("257")})),t("should convert buffer [7, 91, 205, 21] to '123456789'",(()=>{e(Lt(h.from([7,91,205,21]))).toEqual("123456789")}))})),r("toCamelCase",(()=>{t("should convert object keys to camelCase",(()=>{e(Ft({test_key:1,"another-testKey":2})).toEqual({testKey:1,anotherTestKey:2})})),t("should handle arrays of objects",(()=>{e(Ft([{array_key:3},{"another_array-key":4}])).toEqual([{arrayKey:3},{anotherArrayKey:4}])})),t("should return the input if it is neither an object nor an array",(()=>{const t="testString";e(Ft(t)).toBe(t)}))}))}function Vt(t,e){const r=t.findIndex((t=>t.equals(e)));return-1===r?(t.push(e),t.length-1):r}function Ht(t,e,r){if(e<=0)return[];if(void 0===t)return 0===r.length?new Array(e).fill(R().merkleTree):new Array(e).fill(r[0].merkleTree);{const r=Ot(t);return r.length>=e?r.slice(0,e):r.concat(new Array(e-r.length).fill(r[0]))}}function Qt(t){return t.map((t=>({pubkey:t,isWritable:1,isSigner:0})))}function Kt(t,e,r,n,o=[]){const s=o.slice(),i=[],a=[];t.forEach(((t,r)=>{const n=Vt(s,t.merkleTree),o=Vt(s,t.nullifierQueue);i.push({compressedAccount:{owner:t.owner,lamports:t.lamports,address:t.address,data:t.data},merkleContext:{merkleTreePubkeyIndex:n,nullifierQueuePubkeyIndex:o,leafIndex:t.leafIndex,queueIndex:null},rootIndex:e[r],readOnly:0})}));const u=Ht(n,r.length,t);return r.forEach(((t,e)=>{const r=Vt(s,u[e]);a.push({compressedAccount:{owner:t.owner,lamports:t.lamports,address:t.address,data:t.data},merkleTreeIndex:r})})),{packedInputCompressedAccounts:i,packedOutputCompressedAccounts:a,remainingAccounts:s}}const zt=t=>{if(t.lt(tt(0)))throw new Error("Not enough balance for transfer")},Wt=t=>{if(0===t.length)throw new Error("No accounts provided for validation");const e=t[0].owner;if(!t.every((t=>t.owner.equals(e))))throw new Error("All input accounts must have the same owner")};function jt(t,e){return Rt([e.toBytes(),...t])}function $t(t,r=R().addressTree){if(32!=t.length)throw new Error("Seed length is not 32 bytes.");const n=r.toBytes(),o=Dt(Buffer.from([...n,...t]));if(null===o)throw new Error("DeriveAddressError");const s=o[0];return new e(s)}function Zt(t,e){const r=e.slice(),n=t.map((t=>({seed:Array.from(t.seed),addressMerkleTreeRootIndex:t.addressMerkleTreeRootIndex,addressMerkleTreeAccountIndex:0,addressQueueAccountIndex:0})));return t.forEach(((t,e)=>{n[e].addressMerkleTreeAccountIndex=Vt(r,t.addressMerkleTreePubkey)})),t.forEach(((t,e)=>{n[e].addressQueueAccountIndex=Vt(r,t.addressQueuePubkey)})),{newAddressParamsPacked:n,remainingAccounts:r}}if(import.meta.vitest){const{it:t,expect:r,describe:n}=import.meta.vitest,o=new e("7yucc7fL3JGbyMwg4neUaenNSdySS39hbAk89Ao3t1Hz");n("derive address seed",(()=>{t("should derive a valid address seed",(()=>{const t=[(new TextEncoder).encode("foo"),(new TextEncoder).encode("bar")];r(jt(t,o)).toStrictEqual(new Uint8Array([0,246,150,3,192,95,53,123,56,139,206,179,253,133,115,103,120,155,251,72,250,47,117,217,118,59,174,207,49,101,201,110]))})),t("should derive a valid address seed",(()=>{const t=[(new TextEncoder).encode("ayy"),(new TextEncoder).encode("lmao")];r(jt(t,o)).toStrictEqual(new Uint8Array([0,202,44,25,221,74,144,92,69,168,38,19,206,208,29,162,53,27,120,214,152,116,15,107,212,168,33,121,187,10,76,233]))}))})),n("deriveAddress function",(()=>{t("should derive a valid address from a seed and a merkle tree public key",(async()=>{const t=$t(jt([(new TextEncoder).encode("foo"),(new TextEncoder).encode("bar")],o),new e("11111111111111111111111111111111"));r(t).toBeInstanceOf(e),r(t).toStrictEqual(new e("139uhyyBtEh4e1CBDJ68ooK5nCeWoncZf9HPyAfRrukA"))})),t("should derive a valid address from a seed and a merkle tree public key",(async()=>{const t=$t(jt([(new TextEncoder).encode("ayy"),(new TextEncoder).encode("lmao")],o),new e("11111111111111111111111111111111"));r(t).toBeInstanceOf(e),r(t).toStrictEqual(new e("12bhHm6PQjbNmEn3Yu1Gq9k7XwVn2rZpzYokmLwbFazN"))}))})),n("packNewAddressParams function",(()=>{t("should pack new address params correctly",(()=>{const t=Zt([{seed:new Uint8Array([1,2,3,4]),addressMerkleTreeRootIndex:0,addressMerkleTreePubkey:new e("11111111111111111111111111111111"),addressQueuePubkey:new e("11111111111111111111111111111112")}],[new e("11111111111111111111111111111112"),new e("11111111111111111111111111111111")]);r(t.newAddressParamsPacked[0].addressMerkleTreeAccountIndex).toBe(1),r(t.newAddressParamsPacked[0].addressQueueAccountIndex).toBe(0)}))}))}async function Xt({connection:t,lamports:e,recipientPublicKey:r}){const n=await t.requestAirdrop(r,e);return await Gt(t,n),n}async function Gt(t,e,r="confirmed"){const n=await t.getLatestBlockhash(r),o={signature:e.toString(),lastValidBlockHeight:n.lastValidBlockHeight,blockhash:n.blockhash};return await t.confirmTransaction(o,r)}const Jt=()=>({a:Array.from({length:32},((t,e)=>e+1)),b:Array.from({length:64},((t,e)=>e+1)),c:Array.from({length:32},((t,e)=>e+1))}),Yt=t=>{if(32!==t.a.length||64!==t.b.length||32!==t.c.length)throw new Error("ValidityProof has invalid shape")};function te(t){const e=re(t.ar[0]),r=re(t.ar[1]),n=new Uint8Array([...e,...r]),o=re(t.bs[0][0]),s=re(t.bs[0][1]),i=re(t.bs[1][0]),a=re(t.bs[1][1]),u=new Uint8Array([...o,...s,...i,...a]),l=re(t.krs[0]),h=re(t.krs[1]);return{a:n,b:u,c:new Uint8Array([...l,...h])}}function ee(t){const e=t.a,r=t.b,n=t.c,o=e.slice(0,32),s=ne(new _(e.slice(32,64),32,"be"))?0:1;o[0]=oe(o[0],s);const i=r.slice(0,64),a=r.slice(64,128),u=function(t,e){const r=S.div(new _(2));return t.lt(r)?1:t.gt(r)?0:e.lt(r)}(new _(a.slice(0,32),32,"be"),new _(a.slice(32,64),32,"be"));i[0]=oe(i[0],u);const l=n.slice(0,32),h=n.slice(32,64),c=ne(new _(h,32,"be"));return l[0]=oe(l[0],c),{a:Array.from(o),b:Array.from(i),c:Array.from(l)}}function re(t){const e=new _(t.startsWith("0x")?t.substring(2):t,"hex");return new Uint8Array(e.toArray("be",32))}function ne(t){return t.lte(S.sub(t))}function oe(t,e){return e?t:128|t}if(import.meta.vitest){const{it:t,expect:e,describe:r}=import.meta.vitest;r("addBitmaskToByte",(()=>{t("should add a bitmask to the byte if yIsPositive is false",(()=>{const t=oe(0,0);e(t).toBe(128)})),t("should not modify the byte if yIsPositive is true",(()=>{const t=oe(0,1);e(t).toBe(0)}))})),r("test prover server",(()=>{const r={ar:["0x22bdaa3187d8fe294925a66fa0165a11bc9e07678fa2fc72402ebfd33d521c69","0x2d18ff780b69898b4cdd8d7b6ac72d077799399f0f45e52665426456f3903584"],bs:[["0x138cc0962e49f76a701d2871d2799892c9782940095eb0429e979f336d2e162d","0x2fe1bfbb15cbfb83d7e00ace23e45f890604003783eaf34affa35e0d6f4822bc"],["0x1a89264f82cc6e8ef1c696bea0b5803c28c0ba6ab61366bcb71e73a4135cae8d","0xf778d857b3df01a4100265c9d014ce02d47425f0114685356165fa5ee3f3a26"]],krs:["0x176b6ae9001f66832951e2d43a98a972667447bb1781f534b70cb010270dcdd3","0xb748d5fac1686db28d94c02250af7eb4f28dfdabc8983305c45bcbc6e163eeb"]},n=[34,189,170,49,135,216,254,41,73,37,166,111,160,22,90,17,188,158,7,103,143,162,252,114,64,46,191,211,61,82,28,105],o=[147,140,192,150,46,73,247,106,112,29,40,113,210,121,152,146,201,120,41,64,9,94,176,66,158,151,159,51,109,46,22,45,47,225,191,187,21,203,251,131,215,224,10,206,35,228,95,137,6,4,0,55,131,234,243,74,255,163,94,13,111,72,34,188],s=[23,107,106,233,0,31,102,131,41,81,226,212,58,152,169,114,102,116,71,187,23,129,245,52,183,12,176,16,39,13,205,211];t("should execute a compressed token mint",(async()=>{const t=ee(te(r));e(t.a).toEqual(n),e(t.b).toEqual(o),e(t.c).toEqual(s)}))})),r("Validity Proof Functions",(()=>{r("placeholderValidityProof",(()=>{t("should create a validity proof with correct shape",(()=>{const t=Jt();e(t.a.length).toBe(32),e(t.b.length).toBe(64),e(t.c.length).toBe(32)}))})),r("checkValidityProofShape",(()=>{t("should not throw an error for valid proof shape",(()=>{const t={a:Array.from(new Uint8Array(32)),b:Array.from(new Uint8Array(64)),c:Array.from(new Uint8Array(32))};e((()=>Yt(t))).not.toThrow()})),t("should throw an error for an invalid proof",(()=>{const t={a:Array.from(new Uint8Array(31)),b:Array.from(new Uint8Array(64)),c:Array.from(new Uint8Array(32))};e((()=>Yt(t))).toThrow("ValidityProof has invalid shape")}))}))}))}function se(t,...e){return r=>e.reduce(((t,e)=>e(t)),t(r))}if(import.meta.vitest){const{it:t,expect:e,describe:r}=import.meta.vitest;r("pipe",(()=>{t("should return the result of applying all fns to the initial value",(()=>{const t=se((t=>t+1),(t=>2*t),(t=>t-3));e(t(5)).toBe(9)}))}))}function ie(t,e,r,s){const i=new n({payerKey:e,recentBlockhash:r,instructions:t}).compileToV0Message(s);return new o(i)}async function ae(t,e,r,n){const o=await t.sendTransaction(e,r);n||(n=await t.getLatestBlockhash());const s={signature:o,blockhash:n.blockhash,lastValidBlockHeight:n.lastValidBlockHeight},i=(await t.confirmTransaction(s,r?.commitment||t.commitment||"confirmed")).context.slot;return await t.confirmTransactionIndexed(i),o}async function ue(t,e,r,n){n||(n=await t.getLatestBlockhash());const o={signature:e,blockhash:n.blockhash,lastValidBlockHeight:n.lastValidBlockHeight},s=await t.confirmTransaction(o,r?.commitment||t.commitment||"confirmed"),i=s.context.slot;return await t.confirmTransactionIndexed(i),s}function le(t,e,r,n=[],o){if(n.includes(e))throw new Error("payer must not be in additionalSigners");const s=[e,...n],i=ie(t,e.publicKey,r,o);return i.sign(s),i}function he(t){return new Promise((e=>setTimeout(e,t)))}let ce=1;const de=ye(255),me=ye(254),fe=ye(253),pe=ye(252);async function ge(t,e=1e9,r){(void 0===r||r>255)&&(r=256);const n=ye(r),o=await t.requestAirdrop(n.publicKey,e);return await ue(t,o),n}function we(){return new s("http://127.0.0.1:8899","confirmed")}function ye(t){if(t||(t=ce,ce++),t>255)return r.generate();const e=new Uint8Array(32);return e[31]=t,r.fromSeed(e)}if(import.meta.vitest){const{describe:t,it:e,expect:n}=import.meta.vitest;t("getTestKeypair",(()=>{e("should generate a keypair with a specific counter",(()=>{const t=ye(10),e=ye(10);n(t).toEqual(e),n(t).toBeInstanceOf(r),n(t.publicKey).toBeDefined(),n(t.secretKey).toBeDefined()})),e("should generate random keypair if counter is greater than 255",(()=>{const t=()=>ye(256),e=t(),r=t();n(e).not.toEqual(r)})),e("should increment the global counter if no counter is provided",(()=>{const t=ye(),e=ye(),r=ye(),o=ye(3);n(t).not.toEqual(e),n(e).not.toEqual(r),n(r).toEqual(o)}))}))}function ve(t,e){return Math.ceil(1e6*t/e)}var Me={};!function(e){var r=I&&I.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:1}),e.map=e.array=e.rustEnum=e.str=e.vecU8=e.tagged=e.vec=e.bool=e.option=e.publicKey=e.i256=e.u256=e.i128=e.u128=e.i64=e.u64=e.struct=e.f64=e.f32=e.i32=e.u32=e.i16=e.u16=e.i8=e.u8=void 0;const n=c,o=t,s=r(x);var i=c;Object.defineProperty(e,"u8",{enumerable:1,get:function(){return i.u8}}),Object.defineProperty(e,"i8",{enumerable:1,get:function(){return i.s8}}),Object.defineProperty(e,"u16",{enumerable:1,get:function(){return i.u16}}),Object.defineProperty(e,"i16",{enumerable:1,get:function(){return i.s16}}),Object.defineProperty(e,"u32",{enumerable:1,get:function(){return i.u32}}),Object.defineProperty(e,"i32",{enumerable:1,get:function(){return i.s32}}),Object.defineProperty(e,"f32",{enumerable:1,get:function(){return i.f32}}),Object.defineProperty(e,"f64",{enumerable:1,get:function(){return i.f64}}),Object.defineProperty(e,"struct",{enumerable:1,get:function(){return i.struct}});class a extends n.Layout{constructor(t,e,r){super(t,r),this.blob=(0,n.blob)(t),this.signed=e}decode(t,e=0){const r=new s.default(this.blob.decode(t,e),10,"le");return this.signed?r.fromTwos(8*this.span).clone():r}encode(t,e,r=0){return this.signed&&(t=t.toTwos(8*this.span)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),e,r)}}function u(t){return new a(8,0,t)}e.u64=u,e.i64=function(t){return new a(8,1,t)},e.u128=function(t){return new a(16,0,t)},e.i128=function(t){return new a(16,1,t)},e.u256=function(t){return new a(32,0,t)},e.i256=function(t){return new a(32,1,t)};class l extends n.Layout{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}e.publicKey=function(t){return new l((0,n.blob)(32),(t=>new o.PublicKey(t)),(t=>t.toBuffer()),t)};class h extends n.Layout{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=(0,n.u8)()}encode(t,e,r=0){return null==t?this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+1)+1)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+1);throw new Error("Invalid option "+this.property)}getSpan(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return 1;if(1===r)return this.layout.getSpan(t,e+1)+1;throw new Error("Invalid option "+this.property)}}function d(t){if(0===t)return 0;if(1===t)return 1;throw new Error("Invalid bool: "+t)}function m(t){return t?1:0}function f(t){const e=(0,n.u32)("length"),r=(0,n.struct)([e,(0,n.blob)((0,n.offset)(e,-e.span),"data")]);return new l(r,(({data:t})=>t),(t=>({data:t})),t)}e.option=function(t,e){return new h(t,e)},e.bool=function(t){return new l((0,n.u8)(),d,m,t)},e.vec=function(t,e){const r=(0,n.u32)("length"),o=(0,n.struct)([r,(0,n.seq)(t,(0,n.offset)(r,-r.span),"values")]);return new l(o,(({values:t})=>t),(t=>({values:t})),e)},e.tagged=function(t,e,r){const o=(0,n.struct)([u("tag"),e.replicate("data")]);return new l(o,(function({tag:e,data:r}){if(!e.eq(t))throw new Error("Invalid tag, expected: "+t.toString("hex")+", got: "+e.toString("hex"));return r}),(e=>({tag:t,data:e})),r)},e.vecU8=f,e.str=function(t){return new l(f(),(t=>t.toString("utf-8")),(t=>Buffer.from(t,"utf-8")),t)},e.rustEnum=function(t,e,r){const o=(0,n.union)(null!=r?r:(0,n.u8)(),e);return t.forEach(((t,e)=>o.addVariant(e,t,t.property))),o},e.array=function(t,e,r){const o=(0,n.struct)([(0,n.seq)(t,e,"values")]);return new l(o,(({values:t})=>t),(t=>({values:t})),r)};class p extends n.Layout{constructor(t,e,r){super(t.span+e.span,r),this.keyLayout=t,this.valueLayout=e}decode(t,e){return e=e||0,[this.keyLayout.decode(t,e),this.valueLayout.decode(t,e+this.keyLayout.getSpan(t,e))]}encode(t,e,r){r=r||0;const n=this.keyLayout.encode(t[0],e,r);return n+this.valueLayout.encode(t[1],e,r+n)}getSpan(t,e){return this.keyLayout.getSpan(t,e)+this.valueLayout.getSpan(t,e)}}e.map=function(t,e,r){const o=(0,n.u32)("length"),s=(0,n.struct)([o,(0,n.seq)(new p(t,e),(0,n.offset)(o,-o.span),"values")]);return new l(s,(({values:t})=>new Map(t)),(t=>({values:Array.from(t.entries())})),r)}}(Me);const be=Me.struct([Me.publicKey("owner"),Me.u64("lamports"),Me.option(Me.array(Me.u8(),32),"address"),Me.option(Me.struct([Me.array(Me.u8(),8,"discriminator"),Me.vecU8("data"),Me.array(Me.u8(),32,"dataHash")]),"data")],"compressedAccount"),Ae=Me.struct([Me.u8("merkleTreePubkeyIndex"),Me.u8("nullifierQueuePubkeyIndex"),Me.u32("leafIndex"),Me.option(Me.struct([Me.u8("queueId"),Me.u16("index")]),"queueIndex")],"merkleContext"),Ee=Me.struct([Me.array(Me.u8(),32,"seed"),Me.u8("addressQueueAccountIndex"),Me.u8("addressMerkleTreeAccountIndex"),Me.u16("addressMerkleTreeRootIndex")],"newAddressParams"),Ie=Me.struct([Me.option(Me.struct([Me.array(Me.u8(),32,"a"),Me.array(Me.u8(),64,"b"),Me.array(Me.u8(),32,"c")]),"proof"),Me.vec(Me.struct([be,Ae,Me.u16("rootIndex"),Me.bool("readOnly")]),"inputCompressedAccountsWithMerkleContext"),Me.vec(Me.struct([be,Me.u8("merkleTreeIndex")]),"outputCompressedAccounts"),Me.option(Me.u64(),"relayFee"),Me.vec(Ee,"newAddressParams"),Me.option(Me.u64(),"compressOrDecompressLamports"),Me.bool("isCompress")]);function ke(t){const e=h.alloc(1e3),r=Ie.encode(t,e),n=h.from(e.slice(0,r)),o=h.alloc(4);return o.writeUInt32LE(r,0),h.concat([h.from([26,16,169,7,21,202,242,25]),o,n])}function Te(t){return Ie.decode(t)}const xe=t=>{const e=Ce.programId,{feePayer:r,authority:n,registeredProgramPda:o,noopProgram:s,accountCompressionAuthority:i,accountCompressionProgram:a,solPoolPda:u,decompressionRecipient:l,systemProgram:h}=t;return[{pubkey:r,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u??e,isSigner:0,isWritable:null!==u},{pubkey:l??e,isSigner:0,isWritable:1},{pubkey:h,isSigner:0,isWritable:0}]},_e=Me.struct([Me.vec(Me.array(Me.u8(),32),"inputCompressedAccountHashes"),Me.vec(Me.array(Me.u8(),32),"outputCompressedAccountHashes"),Me.vec(Me.struct([Me.struct([Me.publicKey("owner"),Me.u64("lamports"),Me.option(Me.array(Me.u8(),32),"address"),Me.option(Me.struct([Me.array(Me.u8(),8,"discriminator"),Me.vecU8("data"),Me.array(Me.u8(),32,"dataHash")]),"data")],"compressedAccount"),Me.u8("merkleTreeIndex")]),"outputCompressedAccounts"),Me.vec(Me.u32(),"outputLeafIndices"),Me.vec(Me.struct([Me.publicKey("pubkey"),Me.u64("seq")]),"sequenceNumbers"),Me.option(Me.u64(),"relayFee"),Me.bool("isCompress"),Me.option(Me.u64(),"compressOrDecompressLamports"),Me.vec(Me.publicKey(),"pubkeyArray"),Me.option(Me.vecU8(),"message")]);function Se(t){const e=h.alloc(1e3),r=_e.encode(t,e);return e.slice(0,r)}function Ne(t){return _e.decode(t)}const Pe=t=>t.reduce(((t,e)=>t.add(tt(e.lamports))),tt(0)),Be=h.from("sol_pool_pda");class Ce{constructor(){}static programId=new e("SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7");static deriveCompressedSolPda(){const t=[Be],[r,n]=e.findProgramAddressSync(t,this.programId);return r}static createTransferOutputState(t,e,r){r=tt(r);const n=Pe(t).sub(r);return zt(n),n.eq(tt(0))?[nt(e,r)]:(Wt(t),[nt(t[0].owner,n),nt(e,r)])}static createDecompressOutputState(t,e){e=tt(e);const r=Pe(t).sub(e);return zt(r),r.eq(tt(0))?[]:(Wt(t),[nt(t[0].owner,r)])}static createNewAddressOutputState(t,e,r,n){r=tt(r??0);const o=Pe(n??[]).sub(r);return zt(o),o.eq(tt(0))||!n?[nt(e,r,void 0,t)]:(Wt(n),[nt(n[0].owner,o),nt(e,r,void 0,t)])}static async createAccount({payer:t,newAddressParams:e,newAddress:r,recentValidityProof:n,outputStateTree:o,inputCompressedAccounts:s,inputStateRootIndices:u,lamports:l}){const h=this.createNewAddressOutputState(r,t,l,s),{packedInputCompressedAccounts:c,packedOutputCompressedAccounts:d,remainingAccounts:m}=Kt(s??[],u??[],h,o),{newAddressParamsPacked:f,remainingAccounts:p}=Zt([e],m),g=ke({proof:n,inputCompressedAccountsWithMerkleContext:c,outputCompressedAccounts:d,relayFee:null,newAddressParams:f,compressOrDecompressLamports:null,isCompress:0}),w=[...xe({...D(),feePayer:t,authority:t,solPoolPda:null,decompressionRecipient:null,systemProgram:i.programId}),...Qt(p)];return new a({programId:this.programId,keys:w,data:g})}static async transfer({payer:t,inputCompressedAccounts:e,toAddress:r,lamports:n,recentInputStateRootIndices:o,recentValidityProof:s,outputStateTrees:u}){const l=this.createTransferOutputState(e,r,n),{packedInputCompressedAccounts:h,packedOutputCompressedAccounts:c,remainingAccounts:d}=Kt(e,o,l,u),m=ke({proof:s,inputCompressedAccountsWithMerkleContext:h,outputCompressedAccounts:c,relayFee:null,newAddressParams:[],compressOrDecompressLamports:null,isCompress:0}),f=[...xe({...D(),feePayer:t,authority:t,solPoolPda:null,decompressionRecipient:null,systemProgram:i.programId}),...Qt(d)];return new a({programId:this.programId,keys:f,data:m})}static async compress({payer:t,toAddress:e,lamports:r,outputStateTree:n}){r=tt(r);const o=nt(e,r),{packedInputCompressedAccounts:s,packedOutputCompressedAccounts:u,remainingAccounts:l}=Kt([],[],[o],n),h=ke({proof:null,inputCompressedAccountsWithMerkleContext:s,outputCompressedAccounts:u,relayFee:null,newAddressParams:[],compressOrDecompressLamports:r,isCompress:1}),c=[...xe({...D(),feePayer:t,authority:t,solPoolPda:this.deriveCompressedSolPda(),decompressionRecipient:null,systemProgram:i.programId}),...Qt(l)];return new a({programId:this.programId,keys:c,data:h})}static async decompress({payer:t,inputCompressedAccounts:e,toAddress:r,lamports:n,recentInputStateRootIndices:o,recentValidityProof:s,outputStateTree:u}){n=tt(n);const l=this.createDecompressOutputState(e,n),{packedInputCompressedAccounts:h,packedOutputCompressedAccounts:c,remainingAccounts:d}=Kt(e,o,l,u),m=ke({proof:s,inputCompressedAccountsWithMerkleContext:h,outputCompressedAccounts:c,relayFee:null,newAddressParams:[],compressOrDecompressLamports:n,isCompress:0}),f=[...xe({...D(),feePayer:t,authority:t,solPoolPda:this.deriveCompressedSolPda(),decompressionRecipient:r,systemProgram:i.programId}),...Qt(d)];return new a({programId:this.programId,keys:f,data:m})}}function Oe(t,e){let r=tt(0);e=tt(e);const n=[];t.sort(((t,e)=>e.lamports.cmp(t.lamports)));for(const o of t){if(r.gte(tt(e)))break;r=r.add(o.lamports),n.push(o)}if(r.lt(tt(e)))throw new Error(`Not enough balance for transfer. Required: ${e.toString()}, available: ${r.toString()}`);return[n,r]}async function Le(t,e,r,n,o,s){const{blockhash:i}=await t.getLatestBlockhash(),a=await Ce.compress({payer:e.publicKey,toAddress:n,lamports:r,outputStateTree:o}),l=le([u.setComputeUnitLimit({units:1e6}),a],e,i,[]);return await ae(t,l,s)}async function Ue(t,e,r,n,o,s,i,a){const{blockhash:l}=await t.getLatestBlockhash();o=o??R().addressTree,s=s??R().addressQueue;const h=jt(r,n),c=$t(h,o),d=await t.getValidityProofV0(void 0,[{address:tt(c.toBytes()),tree:o,queue:s}]),m={seed:h,addressMerkleTreeRootIndex:d.rootIndices[0],addressMerkleTreePubkey:d.merkleTrees[0],addressQueuePubkey:d.nullifierQueues[0]},f=await Ce.createAccount({payer:e.publicKey,newAddressParams:m,newAddress:Array.from(c.toBytes()),recentValidityProof:d.compressedProof,programId:n,outputStateTree:i}),p=le([u.setComputeUnitLimit({units:1e6}),f],e,l,[]);return await ae(t,p,a)}async function De(t,e,r,n,o,s,i,a,l){n=tt(n);const h=await t.getCompressedAccountsByOwner(e.publicKey),[c]=Oe(h.items,n),{blockhash:d}=await t.getLatestBlockhash();s=s??R().addressTree,i=i??R().addressQueue;const m=jt(r,o),f=$t(m,s),p=await t.getValidityProof(c.map((t=>tt(t.hash))),[tt(f.toBytes())]),g={seed:m,addressMerkleTreeRootIndex:p.rootIndices[p.rootIndices.length-1],addressMerkleTreePubkey:p.merkleTrees[p.merkleTrees.length-1],addressQueuePubkey:p.nullifierQueues[p.nullifierQueues.length-1]},w=await Ce.createAccount({payer:e.publicKey,newAddressParams:g,newAddress:Array.from(f.toBytes()),recentValidityProof:p.compressedProof,inputCompressedAccounts:c,inputStateRootIndices:p.rootIndices,programId:o,outputStateTree:a}),y=le([u.setComputeUnitLimit({units:1e6}),w],e,d,[]);return await ae(t,y,l)}async function Re(t,e,r,n,o,s){const i=(await t.getCompressedAccountsByOwner(e.publicKey)).items;r=tt(r);const a=Pe(i);if(r.gt(a))throw new Error(`Not enough compressed lamports. Expected ${r}, got ${a}`);const l=await t.getValidityProof(i.map((t=>tt(t.hash)))),{blockhash:h}=await t.getLatestBlockhash(),c=await Ce.decompress({payer:e.publicKey,toAddress:n,outputStateTree:o,inputCompressedAccounts:i,recentValidityProof:l.compressedProof,recentInputStateRootIndices:l.rootIndices,lamports:r}),d=le([u.setComputeUnitLimit({units:1e6}),c],e,h,[]);return await ae(t,d,s)}function qe(t,e){return e.includes(t)?e.filter((e=>e.publicKey.toString()!==t.publicKey.toString())):e}async function Fe(t,e,r,n,o,s,i){let a=tt(0);const l=[];let h;for(r=tt(r);a.lt(r);){const e={filters:void 0,dataSlice:void 0,cursor:h,limit:new _(1e3)},o=await t.getCompressedAccountsByOwner(n.publicKey,e);for(const t of o.items)t.lamports.gt(new _(0))&&(l.push(t),a=a.add(t.lamports));if(h=o.cursor??void 0,o.items.length<1e3||a.gte(r))break}if(a.lt(r))throw new Error(`Not enough balance for transfer. Required: ${r.toString()}, available: ${a.toString()}`);const[c]=Oe(l,r),d=await t.getValidityProof(c.map((t=>tt(t.hash)))),m=await Ce.transfer({payer:e.publicKey,inputCompressedAccounts:c,toAddress:o,lamports:r,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,outputStateTrees:s}),{blockhash:f}=await t.getLatestBlockhash(),p=le([u.setComputeUnitLimit({units:1e6}),m],e,f);return await ae(t,p,i)}var Ve,He,Qe,Ke,ze,We,je,$e,Ze;!function(t){t.NEGATIVE_LAMPORTS="NEGATIVE_LAMPORTS",t.NOT_U64="NOT_U64",t.BLINDING_EXCEEDS_FIELD_SIZE="BLINDING_EXCEEDS_FIELD_SIZE"}(Ve||(Ve={})),function(t){t.FAILED_TO_FIND_UTXO_COMBINATION="FAILED_TO_FIND_UTXO_COMBINATION",t.INVALID_NUMBER_OF_IN_UTXOS="INVALID_NUMBER_OF_IN_UTXOS"}(He||(He={})),function(t){t.OWNER_UNDEFINED="OWNER_UNDEFINED",t.INVALID_OUTPUT_UTXO_LENGTH="INVALID_OUTPUT_UTXO_LENGTH",t.UTXO_DATA_UNDEFINED="UTXO_DATA_UNDEFINED"}(Qe||(Qe={})),function(t){t.CONNECTION_UNDEFINED="CONNECTION_UNDEFINED",t.RPC_PUBKEY_UNDEFINED="RPC_PUBKEY_UNDEFINED",t.RPC_METHOD_NOT_IMPLEMENTED="RPC_METHOD_NOT_IMPLEMENTED",t.RPC_INVALID="RPC_INVALID"}(Ke||(Ke={})),function(t){t.LOOK_UP_TABLE_UNDEFINED="LOOK_UP_TABLE_UNDEFINED",t.LOOK_UP_TABLE_NOT_INITIALIZED="LOOK_UP_TABLE_NOT_INITIALIZED"}(ze||(ze={})),function(t){t.NO_POSEIDON_HASHER_PROVIDED="NO_POSEIDON_HASHER_PROVIDED"}(We||(We={})),function(t){t.INVALID_PROOF="INVALID_PROOF",t.PROOF_INPUT_UNDEFINED="PROOF_INPUT_UNDEFINED",t.PROOF_GENERATION_FAILED="PROOF_GENERATION_FAILED"}(je||(je={})),function(t){t.MERKLE_TREE_NOT_INITIALIZED="MERKLE_TREE_NOT_INITIALIZED",t.SOL_MERKLE_TREE_UNDEFINED="SOL_MERKLE_TREE_UNDEFINED",t.MERKLE_TREE_UNDEFINED="MERKLE_TREE_UNDEFINED",t.INPUT_UTXO_NOT_INSERTED_IN_MERKLE_TREE="INPUT_UTXO_NOT_INSERTED_IN_MERKLE_TREE",t.MERKLE_TREE_INDEX_UNDEFINED="MERKLE_TREE_INDEX_UNDEFINED",t.MERKLE_TREE_SET_SPACE_UNDEFINED="MERKLE_TREE_SET_SPACE_UNDEFINED"}($e||($e={})),function(t){t.ACCOUNT_NAME_UNDEFINED_IN_IDL="ACCOUNT_NAME_UNDEFINED_IN_IDL",t.PROPERTY_UNDEFINED="PROPERTY_UNDEFINED",t.LOOK_UP_TABLE_CREATION_FAILED="LOOK_UP_TABLE_CREATION_FAILED",t.UNSUPPORTED_ARCHITECTURE="UNSUPPORTED_ARCHITECTURE",t.UNSUPPORTED_PLATFORM="UNSUPPORTED_PLATFORM",t.ACCOUNTS_UNDEFINED="ACCOUNTS_UNDEFINED",t.INVALID_NUMBER="INVALID_NUMBER"}(Ze||(Ze={}));class Xe extends Error{code;functionName;codeMessage;constructor(t,e,r){super(`${t}: ${r}`),this.code=t,this.functionName=e,this.codeMessage=r}}class Ge extends Xe{}class Je extends Xe{}class Ye extends Xe{}class tr extends Xe{}class er extends Xe{}class rr extends Xe{}class nr extends Xe{}class or extends Xe{}class sr extends Xe{}class ir{async getCancellationPromise(){throw new Error("getCancellationPromise not supported in rpc. it is a stub that is marked as private in web3.js Connection")}async getTransactionConfirmationPromise(){throw new Error("getTransactionConfirmationPromise not supported in rpc. it is a stub that is marked as private in web3.js Connection")}async confirmTransactionUsingBlockHeightExceedanceStrategy(){throw new Error("confirmTransactionUsingBlockHeightExceedanceStrategy not supported in rpc. it is a stub that is marked as private in web3.js Connection")}async confirmTransactionUsingDurableNonceStrategy(){throw new Error("confirmTransactionUsingDurableNonceStrategy not supported in rpc. it is a stub that is marked as private in web3.js Connection")}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){throw new Error("confirmTransactionUsingLegacyTimeoutStrategy not supported in rpc. it is a stub that is marked as private in web3.js Connection")}}const ar=d(m(e),f(),(t=>new e(t))),ur=d(m(Array),f(),(t=>Array.from(new e(t).toBytes()))),lr=d(m(_),f(),(t=>et(t,"base58"))),hr=d(m(_),p(),(t=>Number.isSafeInteger(t)?tt(t):tt(t.toString(),10))),cr=d(f(),f(),(t=>""===t?null:t));function dr(t){return b([w({jsonrpc:A("2.0"),id:f(),result:t}),w({jsonrpc:A("2.0"),id:f(),error:w({code:g(),message:f(),data:y(M())})})])}const mr=dr(g());function fr(t){return d(dr(t),mr,(e=>"error"in e?e:{...e,result:E(e.result,t)}))}function pr(t){return fr(w({context:w({slot:p()}),value:t}))}const gr=w({address:y(ur),hash:lr,data:y(w({data:cr,dataHash:lr,discriminator:hr})),lamports:hr,owner:ar,leafIndex:p(),tree:ar,seq:y(hr),slotCreated:hr}),wr=w({mint:ar,owner:ar,amount:hr,delegate:y(ar),state:f()}),yr=w({tokenData:wr,account:gr}),vr=w({items:v(gr)}),Mr=w({items:v(gr),cursor:y(f())}),br=w({items:v(yr),cursor:y(f())}),Ar=p(),Er=f(),Ir=w({items:v(w({signature:f(),slot:p(),blockTime:p(),error:y(f())}))}),kr=w({items:v(w({signature:f(),slot:p(),blockTime:p()})),cursor:y(f())}),Tr=w({hash:lr,leafIndex:p(),merkleTree:ar,proof:v(lr),rootSeq:p(),root:lr}),xr=w({address:lr,nextIndex:p(),merkleTree:ar,proof:v(lr),rootSeq:p(),root:lr,lowerRangeAddress:lr,higherRangeAddress:lr,lowElementLeafIndex:p()}),_r=w({a:v(p()),b:v(p()),c:v(p())}),Sr=w({compressedProof:_r,leafIndices:v(p()),leaves:v(lr),rootIndices:v(p()),roots:v(lr),merkleTrees:v(ar)}),Nr=v(Tr),Pr=w({amount:hr}),Br=hr,Cr=w({balance:hr,mint:ar}),Or=w({tokenBalances:v(Cr),cursor:y(f())}),Lr=w({items:v(Cr),cursor:y(f())}),Ur=w({cursor:y(f()),items:v(w({balance:hr,owner:ar}))}),Dr=w({hash:v(p()),root:v(p()),proof:v(v(p()))}),Rr=t=>new Date(t).getTime(),qr=w({items:v(w({blockTime:p(),signature:f(),slot:p()}))}),Fr=w({items:v(w({blockTime:p(),signature:f(),slot:p()})),cursor:y(f())}),Vr=w({compressionInfo:w({closedAccounts:v(w({account:gr,optionalTokenData:y(wr)})),openedAccounts:v(w({account:gr,optionalTokenData:y(wr)}))}),transaction:M()});function Hr({discriminator:t,data:e,dataHash:r}){return{discriminator:t.toArray("le",8),data:h.from(e,"base64"),dataHash:r.toArray("le",32)}}async function Qr(t,e,r,n=0){const o=n?"getCompressedTokenAccountsByDelegate":"getCompressedTokenAccountsByOwner",s=n?"delegate":"owner",i=await Wr(t.compressionApiEndpoint,o,{[s]:e.toBase58(),mint:r.mint?.toBase58(),limit:r.limit?.toNumber(),cursor:r.cursor}),a=E(i,pr(br));if("error"in a)throw new l(a.error,`failed to get info for compressed accounts by ${s} ${e.toBase58()}`);if(null===a.result.value)throw new Error("not implemented: NULL result");const u=[];return a.result.value.items.map((t=>{const r=t.account,n=t.tokenData,o=ot(st(r.tree,Jr,r.hash.toArray("be",32),r.leafIndex),r.owner,tt(r.lamports),r.data?Hr(r.data):void 0,r.address||void 0),i={mint:n.mint,owner:n.owner,amount:n.amount,delegate:n.delegate,state:["uninitialized","initialized","frozen"].indexOf(n.state),tlv:null};if(i[s]?.toBase58()!==e.toBase58())throw new Error(`RPC returned token account with ${s} different from requested ${s}`);u.push({compressedAccount:o,parsed:i})})),{items:u.sort(((t,e)=>e.compressedAccount.leafIndex-t.compressedAccount.leafIndex)),cursor:a.result.value.cursor}}function Kr(t){const e=t.account,r=t.optionalTokenData,n=ot(st(e.merkleTree,Jr,e.hash.toArray("be",32),e.leafIndex),e.owner,tt(e.lamports),e.data?Hr(e.data):void 0,e.address||void 0);return null===r?{account:n,maybeTokenData:null}:{account:n,maybeTokenData:{mint:r.mint,owner:r.owner,amount:r.amount,delegate:r.delegate,state:["uninitialized","initialized","frozen"].indexOf(r.state),tlv:null}}}function zr(t="http://127.0.0.1:8899",e="http://127.0.0.1:8784",r="http://127.0.0.1:3001",n){const o="string"==typeof t?t:t.rpcEndpoint;return new tn(o,e,r,n)}const Wr=async(t,e,r=[],n=1)=>{const o=JSON.stringify({jsonrpc:"2.0",id:"test-account",method:e,params:r}),s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:o});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return n?Ft(await s.json()):await s.json()},jr=async(t,e,r=[])=>{let n;"inclusion"===e?n=JSON.stringify({circuitType:"inclusion",stateTreeHeight:26,inputCompressedAccounts:r}):"new-address"===e?n=JSON.stringify({circuitType:"non-inclusion",addressTreeHeight:26,newAddresses:r}):"combined"===e&&(n=JSON.stringify({circuitType:"combined",stateTreeHeight:26,addressTreeHeight:26,inputCompressedAccounts:r[0],newAddresses:r[1]}));const o=await fetch(`${t}/prove`,{method:"POST",headers:{"Content-Type":"application/json"},body:n});if(!o.ok)throw new Error(`Error fetching proof: ${o.statusText}`);return ee(te(await o.json()))};function $r(t){const e=[];for(let r=0;r<t.length;r++){const n={root:Ct(t[r].root),pathIndex:t[r].leafIndex,pathElements:t[r].merkleProof.map((t=>Ct(t))),leaf:Ct(tt(t[r].hash))};e.push(n)}return e}function Zr(t){const e=[];for(let r=0;r<t.length;r++){const n={root:Ct(t[r].root),value:Ct(t[r].value),pathIndex:t[r].indexHashedIndexedElementLeaf.toNumber(),pathElements:t[r].merkleProofHashedIndexedElementLeaf.map((t=>Ct(t))),nextIndex:t[r].nextIndex.toNumber(),leafLowerRangeValue:Ct(t[r].leafLowerRangeValue),leafHigherRangeValue:Ct(t[r].leafHigherRangeValue)};e.push(n)}return e}function Xr(t,e,r){if(t.length!==e.length)throw new Error("Input lengths must match.");if(0===t.length)return new _(0);let n=r.poseidonHashBN([t[0].toString(),e[0].toString()]);for(let o=1;o<t.length;o++)n=r.poseidonHashBN([n.toString(),t[o].toString(),e[o].toString()]);return n}function Gr(t,e,r,n){const o=Xr(t.map((t=>t.root)),e,n),s=r.map((t=>t.value)),i=Xr(r.map((t=>t.root)),s,n);return i.isZero()?o.isZero()?Xr([o],[i],n):o:i}const Jr=R().nullifierQueue,Yr=R().addressQueue;class tn extends s{connection;compressionApiEndpoint;proverEndpoint;constructor(t,e,r,n){super(t,n||"confirmed"),this.connection=new s(t,n||"confirmed"),this.compressionApiEndpoint=e,this.proverEndpoint=r}get commitment(){return this.connection.commitment}get rpcEndpoint(){return this.connection.rpcEndpoint}async getBalanceAndContext(t,e){return this.connection.getBalanceAndContext(t,e)}async getBalance(t,e){return this.connection.getBalance(t,e)}async getBlockTime(t){return this.connection.getBlockTime(t)}async getMinimumLedgerSlot(){return this.connection.getMinimumLedgerSlot()}async getFirstAvailableBlock(){return this.connection.getFirstAvailableBlock()}async getSupply(t){return this.connection.getSupply(t)}async getTokenSupply(t,e){return this.connection.getTokenSupply(t,e)}async getTokenAccountBalance(t,e){return this.connection.getTokenAccountBalance(t,e)}async getTokenAccountsByOwner(t,e,r){return this.connection.getTokenAccountsByOwner(t,e,r)}async getParsedTokenAccountsByOwner(t,e,r){return this.connection.getParsedTokenAccountsByOwner(t,e,r)}async getLargestAccounts(t){return this.connection.getLargestAccounts(t)}async getTokenLargestAccounts(t,e){return this.connection.getTokenLargestAccounts(t,e)}async getAccountInfoAndContext(t,e){return this.connection.getAccountInfoAndContext(t,e)}async getParsedAccountInfo(t,e){return this.connection.getParsedAccountInfo(t,e)}async getAccountInfo(t,e){return this.connection.getAccountInfo(t,e)}async getMultipleParsedAccounts(t,e){return this.connection.getMultipleParsedAccounts(t,e)}async getMultipleAccountsInfoAndContext(t,e){return this.connection.getMultipleAccountsInfoAndContext(t,e)}async getMultipleAccountsInfo(t,e){return this.connection.getMultipleAccountsInfo(t,e)}async getStakeActivation(t,e,r){return this.connection.getStakeActivation(t,e,r)}async getProgramAccounts(t,e){return this.connection.getProgramAccounts(t,e)}async getParsedProgramAccounts(t,e){return this.connection.getParsedProgramAccounts(t,e)}async getParsedBlock(t,e){return this.connection.getParsedBlock(t,e)}async getConfirmedTransaction(t,e){return this.connection.getConfirmedTransaction(t,e)}async getParsedConfirmedTransaction(t,e){return this.connection.getParsedConfirmedTransaction(t,e)}async getParsedConfirmedTransactions(t,e){return this.connection.getParsedConfirmedTransactions(t,e)}async getConfirmedSignaturesForAddress(t,e,r){return this.connection.getConfirmedSignaturesForAddress(t,e,r)}async getConfirmedSignaturesForAddress2(t,e,r){return this.connection.getConfirmedSignaturesForAddress2(t,e,r)}async getSignaturesForAddress(t,e,r){return this.connection.getSignaturesForAddress(t,e,r)}async getRecentPrioritizationFees(t){return this.connection.getRecentPrioritizationFees(t)}async getLatestBlockhash(t){return this.connection.getLatestBlockhash(t)}async getLatestBlockhashAndContext(t){return this.connection.getLatestBlockhashAndContext(t)}async isBlockhashValid(t,e){return this.connection.isBlockhashValid(t,e)}async getVersion(){return this.connection.getVersion()}async getAddressLookupTable(t,e){return this.connection.getAddressLookupTable(t,e)}async getNonceAndContext(t,e){return this.connection.getNonceAndContext(t,e)}async getNonce(t,e){return this.connection.getNonce(t,e)}async getCompressedAccount(t,e){if(!e&&!t)throw new Error("Either hash or address must be provided");if(e&&t)throw new Error("Only one of hash or address must be provided");const r=await Wr(this.compressionApiEndpoint,"getCompressedAccount",{hash:e?rt(e):void 0,address:t?rt(t):void 0}),n=E(r,pr(y(gr)));if("error"in n)throw new l(n.error,`failed to get info for compressed account ${e?e.toString():t?t.toString():""}`);if(null===n.result.value)return null;const o=n.result.value;return ot(st(o.tree,Jr,o.hash.toArray("be",32),o.leafIndex),o.owner,tt(o.lamports),o.data?Hr(o.data):void 0,o.address||void 0)}async getCompressedBalance(t,e){if(!e&&!t)throw new Error("Either hash or address must be provided");if(e&&t)throw new Error("Only one of hash or address must be provided");const r=await Wr(this.compressionApiEndpoint,"getCompressedBalance",{hash:e?rt(e):void 0,address:t?rt(t):void 0}),n=E(r,pr(Br));if("error"in n)throw new l(n.error,`failed to get balance for compressed account ${e?e.toString():t?t.toString():""}`);return null===n.result.value?tt(0):tt(n.result.value)}async getCompressedBalanceByOwner(t){const e=await Wr(this.compressionApiEndpoint,"getCompressedBalanceByOwner",{owner:t.toBase58()}),r=E(e,pr(Br));if("error"in r)throw new l(r.error,`failed to get balance for compressed account ${t.toBase58()}`);return null===r.result.value?tt(0):tt(r.result.value)}async getCompressedAccountProof(t){const e=await Wr(this.compressionApiEndpoint,"getCompressedAccountProof",{hash:rt(t)}),r=E(e,pr(Tr));if("error"in r)throw new l(r.error,`failed to get proof for compressed account ${t.toString()}`);if(null===r.result.value)throw new Error(`failed to get proof for compressed account ${t.toString()}`);return{hash:r.result.value.hash.toArray("be",32),merkleTree:r.result.value.merkleTree,leafIndex:r.result.value.leafIndex,merkleProof:r.result.value.proof,nullifierQueue:Jr,rootIndex:r.result.value.rootSeq%2400,root:r.result.value.root}}async getMultipleCompressedAccounts(t){const e=await Wr(this.compressionApiEndpoint,"getMultipleCompressedAccounts",{hashes:t.map((t=>rt(t)))}),r=E(e,pr(vr));if("error"in r)throw new l(r.error,`failed to get info for compressed accounts ${t.map((t=>rt(t))).join(", ")}`);if(null===r.result.value)throw new Error(`failed to get info for compressed accounts ${t.map((t=>rt(t))).join(", ")}`);const n=[];return r.result.value.items.map((t=>{const e=ot(st(t.tree,Jr,t.hash.toArray("be",32),t.leafIndex),t.owner,tt(t.lamports),t.data?Hr(t.data):void 0,t.address||void 0);n.push(e)})),n.sort(((t,e)=>e.leafIndex-t.leafIndex))}async getMultipleCompressedAccountProofs(t){const e=await Wr(this.compressionApiEndpoint,"getMultipleCompressedAccountProofs",t.map((t=>rt(t)))),r=E(e,pr(v(Tr)));if("error"in r)throw new l(r.error,`failed to get proofs for compressed accounts ${t.map((t=>rt(t))).join(", ")}`);if(null===r.result.value)throw new Error(`failed to get proofs for compressed accounts ${t.map((t=>rt(t))).join(", ")}`);const n=[];for(const t of r.result.value){const e={hash:t.hash.toArray("be",32),merkleTree:t.merkleTree,leafIndex:t.leafIndex,merkleProof:t.proof,nullifierQueue:Yr,rootIndex:t.rootSeq%2400,root:t.root};n.push(e)}return n}async getCompressedAccountsByOwner(t,e){const r=await Wr(this.compressionApiEndpoint,"getCompressedAccountsByOwner",{owner:t.toBase58(),filters:e?.filters||[],dataSlice:e?.dataSlice,cursor:e?.cursor,limit:e?.limit?.toNumber()}),n=E(r,pr(Mr));if("error"in n)throw new l(n.error,`failed to get info for compressed accounts owned by ${t.toBase58()}`);if(null===n.result.value)return{items:[],cursor:null};const o=[];return n.result.value.items.map((t=>{const e=ot(st(t.tree,Jr,t.hash.toArray("be",32),t.leafIndex),t.owner,tt(t.lamports),t.data?Hr(t.data):void 0,t.address||void 0);o.push(e)})),{items:o.sort(((t,e)=>e.leafIndex-t.leafIndex)),cursor:n.result.value.cursor}}async getCompressedTokenAccountsByOwner(t,e){return e||(e={}),await Qr(this,t,e,0)}async getCompressedTokenAccountsByDelegate(t,e){return e||(e={}),Qr(this,t,e,1)}async getCompressedTokenAccountBalance(t){const e=await Wr(this.compressionApiEndpoint,"getCompressedTokenAccountBalance",{hash:rt(t)}),r=E(e,pr(Pr));if("error"in r)throw new l(r.error,`failed to get balance for compressed token account ${t.toString()}`);if(null===r.result.value)throw new Error(`failed to get balance for compressed token account ${t.toString()}`);return{amount:tt(r.result.value.amount)}}async getCompressedTokenBalancesByOwner(t,e){e||(e={});const r=await Wr(this.compressionApiEndpoint,"getCompressedTokenBalancesByOwner",{owner:t.toBase58(),mint:e.mint?.toBase58(),limit:e.limit?.toNumber(),cursor:e.cursor}),n=E(r,pr(Or));if("error"in n)throw new l(n.error,`failed to get compressed token balances for owner ${t.toBase58()}`);if(null===n.result.value)throw new Error(`failed to get compressed token balances for owner ${t.toBase58()}`);return{items:e.mint?n.result.value.tokenBalances.filter((t=>t.mint.toBase58()===e.mint.toBase58())):n.result.value.tokenBalances,cursor:n.result.value.cursor}}async getCompressedTokenBalancesByOwnerV2(t,e){e||(e={});const r=await Wr(this.compressionApiEndpoint,"getCompressedTokenBalancesByOwnerV2",{owner:t.toBase58(),mint:e.mint?.toBase58(),limit:e.limit?.toNumber(),cursor:e.cursor}),n=E(r,pr(Lr));if("error"in n)throw new l(n.error,`failed to get compressed token balances for owner ${t.toBase58()}`);if(null===n.result.value)throw new Error(`failed to get compressed token balances for owner ${t.toBase58()}`);const o=e.mint?n.result.value.items.filter((t=>t.mint.toBase58()===e.mint.toBase58())):n.result.value.items;return{context:n.result.context,value:{items:o,cursor:n.result.value.cursor}}}async getCompressionSignaturesForAccount(t){const e=await Wr(this.compressionApiEndpoint,"getCompressionSignaturesForAccount",{hash:rt(t)}),r=E(e,pr(qr));if("error"in r)throw new l(r.error,`failed to get signatures for compressed account ${t.toString()}`);return r.result.value.items}async getTransactionWithCompressionInfo(t){const e=await Wr(this.compressionApiEndpoint,"getTransactionWithCompressionInfo",{signature:t}),r=E(e,fr(Vr));if("error"in r)throw new l(r.error,"failed to get slot");if(null===r.result.transaction)return null;const n=[],o=[];r.result.compressionInfo.closedAccounts.map((t=>{n.push(Kr(t))})),r.result.compressionInfo.openedAccounts.map((t=>{o.push(Kr(t))}));const s=t=>{const e=Object.values(t.reduce(((t,{maybeTokenData:e})=>{if(e){const{owner:r,mint:n,amount:o}=e,s=`${r.toBase58()}_${n.toBase58()}`;s in t?t[s].amount=t[s].amount.add(o):t[s]={owner:r,mint:n,amount:o}}return t}),{}));return e.length>0?e:void 0},i=s(n),a=s(o);return{compressionInfo:{closedAccounts:n,openedAccounts:o,preTokenBalances:i,postTokenBalances:a},transaction:r.result.transaction}}async getCompressionSignaturesForAddress(t,e){const r=await Wr(this.compressionApiEndpoint,"getCompressionSignaturesForAddress",{address:t.toBase58(),cursor:e?.cursor,limit:e?.limit?.toNumber()}),n=E(r,pr(Fr));if("error"in n)throw new l(n.error,`failed to get signatures for address ${t.toBase58()}`);if(null===n.result.value)throw new Error(`failed to get signatures for address ${t.toBase58()}`);return n.result.value}async getCompressionSignaturesForOwner(t,e){const r=await Wr(this.compressionApiEndpoint,"getCompressionSignaturesForOwner",{owner:t.toBase58(),cursor:e?.cursor,limit:e?.limit?.toNumber()}),n=E(r,pr(Fr));if("error"in n)throw new l(n.error,`failed to get signatures for owner ${t.toBase58()}`);if(null===n.result.value)throw new Error(`failed to get signatures for owner ${t.toBase58()}`);return n.result.value}async getCompressionSignaturesForTokenOwner(t,e){const r=await Wr(this.compressionApiEndpoint,"getCompressionSignaturesForTokenOwner",{owner:t.toBase58(),cursor:e?.cursor,limit:e?.limit?.toNumber()}),n=E(r,pr(Fr));if("error"in n)throw new l(n.error,`failed to get signatures for owner ${t.toBase58()}`);if(null===n.result.value)throw new Error(`failed to get signatures for owner ${t.toBase58()}`);return n.result.value}async getIndexerHealth(){const t=await Wr(this.compressionApiEndpoint,"getIndexerHealth"),e=E(t,fr(Er));if("error"in e)throw new l(e.error,"failed to get health");return e.result}async confirmTransactionIndexed(t){const e=Date.now();for(;;){if(await this.getIndexerSlot()>=t)return 1;if(Date.now()-e>2e4)throw new Error("Timeout: Indexer slot did not reach the required slot within 20 seconds");await new Promise((t=>setTimeout(t,200)))}}async getIndexerSlot(){const t=await Wr(this.compressionApiEndpoint,"getIndexerSlot"),e=E(t,fr(Ar));if("error"in e)throw new l(e.error,"failed to get slot");return e.result}async getCompressedMintTokenHolders(t,e){const r=await Wr(this.compressionApiEndpoint,"getCompressedMintTokenHolders",{mint:t.toBase58(),cursor:e?.cursor,limit:e?.limit?.toNumber()}),n=E(r,pr(Ur));if("error"in n)throw new l(n.error,"failed to get mint token holders");return n.result}async getLatestCompressionSignatures(t,e){const r=await Wr(this.compressionApiEndpoint,"getLatestCompressionSignatures",{limit:e,cursor:t}),n=E(r,pr(kr));if("error"in n)throw new l(n.error,"failed to get latest non-voting signatures");return n.result}async getLatestNonVotingSignatures(t,e){const r=await Wr(this.compressionApiEndpoint,"getLatestNonVotingSignatures",{limit:t,cursor:e}),n=E(r,pr(Ir));if("error"in n)throw new l(n.error,"failed to get latest non-voting signatures");return n.result}async getMultipleNewAddressProofs(t){const e=await Wr(this.compressionApiEndpoint,"getMultipleNewAddressProofs",t.map((t=>rt(t)))),r=E(e,pr(v(xr)));if("error"in r)throw new l(r.error,`failed to get proofs for new addresses ${t.map((t=>rt(t))).join(", ")}`);if(null===r.result.value)throw new Error(`failed to get proofs for new addresses ${t.map((t=>rt(t))).join(", ")}`);const n=[];for(const t of r.result.value){const e={root:t.root,rootIndex:t.rootSeq%2400,value:t.address,leafLowerRangeValue:t.lowerRangeAddress,leafHigherRangeValue:t.higherRangeAddress,nextIndex:tt(t.nextIndex),merkleProofHashedIndexedElementLeaf:t.proof,indexHashedIndexedElementLeaf:tt(t.lowElementLeafIndex),merkleTree:t.merkleTree,nullifierQueue:Yr};n.push(e)}return n}async getValidityProofDirect(t=[],e=[]){let r;if(0===t.length&&0===e.length)throw new Error("Empty input. Provide hashes and/or new addresses.");if(t.length>0&&0===e.length){const e=await this.getMultipleCompressedAccountProofs(t),n=$r(e);r={compressedProof:await jr(this.proverEndpoint,"inclusion",n),roots:e.map((t=>t.root)),rootIndices:e.map((t=>t.rootIndex)),leafIndices:e.map((t=>t.leafIndex)),leaves:e.map((t=>tt(t.hash))),merkleTrees:e.map((t=>t.merkleTree)),nullifierQueues:e.map((t=>t.nullifierQueue))}}else if(0===t.length&&e.length>0){const t=await this.getMultipleNewAddressProofs(e),n=Zr(t);r={compressedProof:await jr(this.proverEndpoint,"new-address",n),roots:t.map((t=>t.root)),rootIndices:t.map((t=>t.rootIndex)),leafIndices:t.map((t=>t.nextIndex.toNumber())),leaves:t.map((t=>tt(t.value))),merkleTrees:t.map((t=>t.merkleTree)),nullifierQueues:t.map((t=>t.nullifierQueue))}}else{if(!(t.length>0&&e.length>0))throw new Error("Invalid input");{const n=await this.getMultipleCompressedAccountProofs(t),o=$r(n),s=await this.getMultipleNewAddressProofs(e),i=Zr(s);r={compressedProof:await jr(this.proverEndpoint,"combined",[o,i]),roots:n.map((t=>t.root)).concat(s.map((t=>t.root))),rootIndices:n.map((t=>t.rootIndex)).concat(s.map((t=>t.rootIndex))),leafIndices:n.map((t=>t.leafIndex)).concat(s.map((t=>t.nextIndex.toNumber()))),leaves:n.map((t=>tt(t.hash))).concat(s.map((t=>tt(t.value)))),merkleTrees:n.map((t=>t.merkleTree)).concat(s.map((t=>t.merkleTree))),nullifierQueues:n.map((t=>t.nullifierQueue)).concat(s.map((t=>t.nullifierQueue)))}}}return r}async getValidityProof(t=[],e=[]){const r=R().addressTree,n=R().addressQueue,o=R().merkleTree,s=R().nullifierQueue,i=t.map((t=>({hash:t,tree:o,queue:s}))),a=e.map((t=>({address:t,tree:r,queue:n})));return this.getValidityProofV0(i,a)}async getValidityProofV0(t=[],e=[]){const{value:r}=await this.getValidityProofAndRpcContext(t,e);return r}async getValidityProofAndRpcContext(t=[],e=[]){const r=await Wr(this.compressionApiEndpoint,"getValidityProof",{hashes:t.map((({hash:t})=>rt(t))),newAddressesWithTrees:e.map((({address:t,tree:e})=>({address:rt(t),tree:e.toBase58()})))}),n=E(r,pr(Sr));if("error"in n)throw new l(n.error,`failed to get ValidityProof for compressed accounts ${t.map((t=>t.toString()))}`);const o=n.result.value;if(null===o)throw new Error(`failed to get ValidityProof for compressed accounts ${t.map((t=>t.toString()))}`);return{value:{compressedProof:o.compressedProof,merkleTrees:o.merkleTrees,leafIndices:o.leafIndices,nullifierQueues:[...t.map((({queue:t})=>t)),...e.map((({queue:t})=>t))],rootIndices:o.rootIndices,roots:o.roots,leaves:o.leaves},context:n.result.context}}}class en{index;value;nextIndex;constructor(t,e,r){this.index=t,this.value=e,this.nextIndex=r}equals(t){return this.value.eq(t.value)}compareTo(t){return this.value.cmp(t.value)}hash(t,e){try{return t.poseidonHash([tt(this.value.toArray("be",32)).toString(),tt(this.nextIndex).toString(),tt(e.toArray("be",32)).toString()])}catch(t){throw new Error("Hashing failed")}}}class rn{newLowElement;newElement;newElementNextValue;constructor(t,e,r){this.newLowElement=t,this.newElement=e,this.newElementNextValue=r}}class nn{elements;currentNodeIndex;highestElementIndex;constructor(t,e,r){this.elements=t,this.currentNodeIndex=e,this.highestElementIndex=r}static default(){return new nn([new en(0,tt(0),0)],0,0)}get(t){return this.elements[t]}length(){return Number(this.currentNodeIndex)}isEmpty(){return 0===this.currentNodeIndex}findElement(t){return this.elements.slice(0,this.length()+1).find((e=>e.value===t))}init(){try{const t=N;return this.append(t)}catch(t){throw new Error(`Failed to initialize IndexedArray: ${t}`)}}findLowElementIndex(t){for(let e=0;e<=this.length();e++){const r=this.elements[e];if(this.elements[r.nextIndex].value.gt(t)&&r.value.lt(t))return e;if(r.value.eq(t))throw new Error("Element already exists in the array")}return this.highestElementIndex}findLowElement(t){const e=this.findLowElementIndex(t);if(void 0===e)return[void 0,void 0];const r=this.elements[e];return[r,this.elements[r.nextIndex].value]}hashElement(t,e){const r=this.elements[e];if(!r)return;const n=this.elements[r.nextIndex];return n?t.poseidonHash([tt(r.value.toArray("be",32)).toString(),tt(r.nextIndex).toString(),tt(n.value.toArray("be",32)).toString()]):void 0}append(t){const e=this.findLowElementIndex(t);if(void 0===e)throw new Error("Low element index not found.");return this.appendWithLowElementIndex(e,t)}appendWithLowElementIndex(t,e){const r=this.elements[t];if(0===r.nextIndex){if(e.lte(r.value))throw new Error("New element value must be greater than the low element value.")}else{const t=this.elements[r.nextIndex];if(e.lte(r.value))throw new Error("New element value must be greater than the low element value.");if(e.gte(t.value))throw new Error("New element value must be less than the next element value.")}const n=this.newElementWithLowElementIndex(t,e);return 0===r.nextIndex&&(this.highestElementIndex=n.newElement.index),this.currentNodeIndex=n.newElement.index,this.elements[this.length()]=n.newElement,this.elements[t]=n.newLowElement,n}lowest(){return this.elements.length>0?this.elements[0]:void 0}newElementWithLowElementIndex(t,e){const r=this.elements[t],n=this.currentNodeIndex+1,o=new en(n,e,r.nextIndex);r.nextIndex=n;const s=this.elements[o.nextIndex].value;return new rn(r,o,s)}newElement(t){const e=this.findLowElementIndex(t);if(void 0===e)throw new Error("Low element index not found.");return this.newElementWithLowElementIndex(e,t)}}const on="0";class sn{levels;capacity;zeroElement;_zeros;_layers;_lightWasm;constructor(t,e,r=[],{zeroElement:n="0"}={}){if(this.levels=t,this.capacity=2**t,this.zeroElement=n,this._lightWasm=e,r.length>this.capacity)throw new Error("Tree is full");this._zeros=[],this._layers=[],this._layers[0]=r,this._zeros[0]=this.zeroElement;for(let e=1;e<=t;e++)this._zeros[e]=this._lightWasm.poseidonHashString([this._zeros[e-1],this._zeros[e-1]]);this._rebuild()}_rebuild(){for(let t=1;t<=this.levels;t++){this._layers[t]=[];for(let e=0;e<Math.ceil(this._layers[t-1].length/2);e++)this._layers[t][e]=this._lightWasm.poseidonHashString([this._layers[t-1][2*e],2*e+1<this._layers[t-1].length?this._layers[t-1][2*e+1]:this._zeros[t-1]])}}root(){return this._layers[this.levels].length>0?this._layers[this.levels][0]:this._zeros[this.levels]}insert(t){if(this._layers[0].length>=this.capacity)throw new Error("Tree is full");this.update(this._layers[0].length,t)}bulkInsert(t){if(this._layers[0].length+t.length>this.capacity)throw new Error("Tree is full");this._layers[0].push(...t),this._rebuild()}update(t,e){if(isNaN(Number(t))||t<0||t>this._layers[0].length||t>=this.capacity)throw new Error("Insert index out of bounds: "+t);this._layers[0][t]=e;for(let e=1;e<=this.levels;e++)t>>=1,this._layers[e][t]=this._lightWasm.poseidonHashString([this._layers[e-1][2*t],2*t+1<this._layers[e-1].length?this._layers[e-1][2*t+1]:this._zeros[e-1]])}path(t){if(isNaN(Number(t))||t<0||t>=this._layers[0].length)throw new Error("Index out of bounds: "+t);const e=[],r=[];for(let n=0;n<this.levels;n++)r[n]=t%2,e[n]=(1^t)<this._layers[n].length?this._layers[n][1^t]:this._zeros[n],t>>=1;return{pathElements:e,pathIndices:r}}indexOf(t,e=null){return e?this._layers[0].findIndex((r=>e(t,r))):this._layers[0].indexOf(t)}elements(){return this._layers[0].slice()}serialize(){return{levels:this.levels,_zeros:this._zeros,_layers:this._layers}}static deserialize(t,e){const r=Object.assign(Object.create(this.prototype),t);return r._hash=e,r.capacity=2**r.levels,r.zeroElement=r._zeros[0],r}}async function an(t){const{noopProgram:e,accountCompressionProgram:r}=D(),n=(await t.getConfirmedSignaturesForAddress2(r,void 0,"confirmed")).map((t=>t.signature)),o=(await t.getParsedTransactions(n,{maxSupportedTransactionVersion:0,commitment:"confirmed"})).filter((t=>t?t.transaction.message.accountKeys.some((t=>("string"==typeof t?t:t.pubkey.toBase58())===e.toBase58())):0));return un(o,ln)}const un=(t,e)=>{const{noopProgram:r}=D(),n=[];return t.forEach((t=>{!t||!t.meta||t.meta.err||!t.meta.innerInstructions||t.meta.innerInstructions.length<=0||t.meta.innerInstructions.forEach((o=>{if(o.instructions.length>0){const s=o.instructions[o.instructions.length-1];if("data"in s&&s.data&&s.programId.toBase58()===r.toBase58()){const r=Y.decode(s.data),o=e(Buffer.from(r),t);null!=o&&n.push(o)}}}))})),n},ln=t=>{const e=Buffer.from(t.map((t=>t)));try{return Ne(e)}catch(t){return null}};async function hn(t,e){return(await cn(t)).find((t=>tt(t.hash).eq(e)))}async function cn(t){const e=(await an(t)).reverse(),r=[],n=[];for(const t of e){for(let e=0;e<t.outputCompressedAccounts.length;e++){const n=t.outputCompressedAccounts[e],o={merkleTree:R().merkleTree,nullifierQueue:R().nullifierQueue,hash:t.outputCompressedAccountHashes[e],leafIndex:t.outputLeafIndices[e]},s=ot(o,n.compressedAccount.owner,n.compressedAccount.lamports,n.compressedAccount.data??void 0,n.compressedAccount.address??void 0);r.push(s)}for(let e=0;e<t.inputCompressedAccountHashes.length;e++){const r=t.inputCompressedAccountHashes[e];n.push(tt(r))}}const o=r.filter((t=>!n.some((e=>e.eq(tt(t.hash))))));return o.sort(((t,e)=>e.leafIndex-t.leafIndex)),o}const dn=new e("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"),mn=Me.struct([Me.publicKey("mint"),Me.publicKey("owner"),Me.u64("amount"),Me.option(Me.publicKey(),"delegate"),Me.u8("state"),Me.option(Me.vecU8(),"tlv")]);function fn(t,e=dn){if(null===t.data)return null;const{data:r}=t.data;if(0===r.length)return null;if(t.owner.toBase58()!==e.toBase58())throw new Error(`Invalid owner ${t.owner.toBase58()} for token layout`);return mn.decode(Buffer.from(r))}async function pn(t){const e=await Promise.all(t.map((t=>async function(t){const e=t.pubkeyArray,r=t.outputCompressedAccountHashes,n=t.outputCompressedAccounts.map(((n,o)=>{const s={merkleTree:e[t.outputCompressedAccounts[o].merkleTreeIndex],nullifierQueue:R().nullifierQueue,hash:r[o],leafIndex:t.outputLeafIndices[o]};if(!n.compressedAccount.data)throw new Error("No data");const i=fn(n.compressedAccount);if(!i)throw new Error("Invalid token data");return{compressedAccount:ot(s,n.compressedAccount.owner,n.compressedAccount.lamports,n.compressedAccount.data,n.compressedAccount.address??void 0),parsed:i}}));return{inputCompressedAccountHashes:t.inputCompressedAccountHashes,outputCompressedAccounts:n}}(t)))),r=e.flatMap((t=>t.outputCompressedAccounts)),n=e.flatMap((t=>t.inputCompressedAccountHashes));return r.filter((t=>!n.some((e=>JSON.stringify(e)===JSON.stringify(t.compressedAccount.hash)))))}async function gn(t,e,r){const n=await an(t);return{items:(await pn(n)).filter((t=>t.parsed.owner.equals(e)&&t.parsed.mint.equals(r))).sort(((t,e)=>e.compressedAccount.leafIndex-t.compressedAccount.leafIndex)),cursor:null}}async function wn(t,e,r){const n=await an(t);return{items:(await pn(n)).filter((t=>t.parsed.delegate?.equals(e)&&t.parsed.mint.equals(r))),cursor:null}}async function yn(t,e){const r=await an(t),n=(await pn(r)).filter((t=>tt(t.compressedAccount.hash).eq(e)));if(0===n.length)throw new Error("No compressed account found");return n[0]}async function vn(t,e="http://127.0.0.1:8899",r="http://127.0.0.1:8784",n="http://127.0.0.1:3001",o,s,i,a=0){const u=R();return new Mn(e,t,r,n,void 0,{merkleTreeAddress:o||u.merkleTree,nullifierQueueAddress:s||u.nullifierQueue,depth:i||u.merkleTreeHeight,log:a})}class Mn extends s{connection;compressionApiEndpoint;proverEndpoint;merkleTreeAddress;nullifierQueueAddress;addressTreeAddress;addressQueueAddress;lightWasm;depth;log=0;constructor(t,e,r,n,o,i){super(t,o||"confirmed"),this.connection=new s(t,o||"confirmed"),this.compressionApiEndpoint=r,this.proverEndpoint=n;const{merkleTreeAddress:a,nullifierQueueAddress:u,depth:l,log:h,addressTreeAddress:c,addressQueueAddress:d}=i??{},{merkleTree:m,nullifierQueue:f,merkleTreeHeight:p,addressQueue:g,addressTree:w}=R();this.lightWasm=e,this.merkleTreeAddress=a??m,this.nullifierQueueAddress=u??f,this.addressTreeAddress=c??w,this.addressQueueAddress=d??g,this.depth=l??p,this.log=h??0}async getCompressedAccount(t,e){if(t)throw new Error("address is not supported in test-rpc");if(!e)throw new Error("hash is required");return await hn(this,e)??null}async getCompressedBalance(t,e){if(t)throw new Error("address is not supported in test-rpc");if(!e)throw new Error("hash is required");const r=await hn(this,e);if(!r)throw new Error("Account not found");return tt(r.lamports)}async getCompressedBalanceByOwner(t){return(await this.getCompressedAccountsByOwner(t)).items.reduce(((t,e)=>t.add(e.lamports)),tt(0))}async getCompressedAccountProof(t){return(await this.getMultipleCompressedAccountProofs([t]))[0]}async getMultipleCompressedAccounts(t){return await async function(t,e){return(await cn(t)).filter((t=>e.some((e=>tt(t.hash).eq(e))))).sort(((t,e)=>e.leafIndex-t.leafIndex))}(this,t)}async confirmTransactionIndexed(t){return 1}async getMultipleCompressedAccountProofs(t){const e=await an(this).then((t=>t.reverse())),r=[],n=[];for(const t of e)for(let e=0;e<t.outputCompressedAccounts.length;e++){const o=t.outputCompressedAccountHashes[e];r.push(o),n.push(t.outputLeafIndices[e])}const o=new sn(this.depth,this.lightWasm,r.map((t=>tt(t).toString()))),s=[];for(let e=0;e<t.length;e++){const n=o.indexOf(t[e].toString()),i=o.path(n).pathElements.map((t=>tt(t))),a=tt(o.root()),u={hash:t[e].toArray("be",32),merkleTree:this.merkleTreeAddress,leafIndex:n,merkleProof:i,nullifierQueue:this.nullifierQueueAddress,rootIndex:r.length,root:a};s.push(u)}return s.forEach(((t,e)=>{const r=t.leafIndex,n=o.elements()[r],s=tt(n).toArray("be",32);if(!s.every(((e,r)=>e===t.hash[r])))throw new Error(`Mismatch at index ${e}: expected ${t.hash.toString()}, got ${s.toString()}`)})),s}async getCompressedAccountsByOwner(t,e){const r=await async function(t,e){return(await cn(t)).filter((t=>t.owner.equals(e)))}(this,t);return{items:r,cursor:null}}async getLatestCompressionSignatures(t,e){throw new Error("getLatestNonVotingSignaturesWithContext not supported in test-rpc")}async getLatestNonVotingSignatures(t){throw new Error("getLatestNonVotingSignaturesWithContext not supported in test-rpc")}async getCompressedTokenAccountsByOwner(t,e){return await gn(this,t,e.mint)}async getCompressedTokenAccountsByDelegate(t,e){return await wn(this,t,e.mint)}async getCompressedTokenAccountBalance(t){const e=await yn(this,t);return{amount:tt(e.parsed.amount)}}async getCompressedTokenBalancesByOwner(t,e){return{items:(await gn(this,t,e.mint)).items.map((t=>({balance:tt(t.parsed.amount),mint:t.parsed.mint}))),cursor:null}}async getCompressedTokenBalancesByOwnerV2(t,e){return{context:{slot:1},value:{items:(await gn(this,t,e.mint)).items.map((t=>({balance:tt(t.parsed.amount),mint:t.parsed.mint}))),cursor:null}}}async getCompressionSignaturesForAccount(t){throw new Error("getCompressionSignaturesForAccount not implemented in test-rpc")}async getTransactionWithCompressionInfo(t){throw new Error("getCompressedTransaction not implemented in test-rpc")}async getCompressionSignaturesForAddress(t,e){throw new Error("getSignaturesForAddress3 not implemented")}async getCompressionSignaturesForOwner(t,e){throw new Error("getSignaturesForOwner not implemented")}async getCompressionSignaturesForTokenOwner(t,e){throw new Error("getSignaturesForTokenOwner not implemented")}async getIndexerHealth(){return"ok"}async getIndexerSlot(){return 1}async getMultipleNewAddressProofs(t){const e=nn.default(),r=[];e.init();const n=[];for(let t=0;t<r.length;t++)e.append(tt(r[t]));for(let t=0;t<e.elements.length;t++){const r=e.hashElement(this.lightWasm,t);n.push(tt(r))}const o=new sn(this.depth,this.lightWasm,n.map((t=>tt(t).toString()))),s=[];for(let r=0;r<t.length;r++){const[n]=e.findLowElement(t[r]);if(!n)throw new Error("Address not found");const i=n.index,a=o.path(i).pathElements.map((t=>tt(t))),u=e.get(n.nextIndex).value,l={root:tt(o.root()),rootIndex:3,value:t[r],leafLowerRangeValue:n.value,leafHigherRangeValue:u,nextIndex:tt(n.nextIndex),merkleProofHashedIndexedElementLeaf:a,indexHashedIndexedElementLeaf:tt(n.index),merkleTree:this.addressTreeAddress,nullifierQueue:this.addressQueueAddress};s.push(l)}return s}async getCompressedMintTokenHolders(t,e){throw new Error("getCompressedMintTokenHolders not implemented in test-rpc")}async getValidityProofDirect(t=[],e=[]){return this.getValidityProof(t,e)}async getValidityProofAndRpcContext(t=[],e=[]){if(e.some((t=>!(t instanceof _))))throw new Error("AddressWithTree is not supported in test-rpc");return{value:await this.getValidityProofV0(t,e),context:{slot:1}}}async getValidityProof(t=[],e=[]){if(e.some((t=>!(t instanceof _))))throw new Error("AddressWithTree is not supported in test-rpc");let r;if(0===t.length&&0===e.length)throw new Error("Empty input. Provide hashes and/or new addresses.");if(t.length>0&&0===e.length){const e=await this.getMultipleCompressedAccountProofs(t),n=$r(e);r={compressedProof:await jr(this.proverEndpoint,"inclusion",n,this.log),roots:e.map((t=>t.root)),rootIndices:e.map((t=>t.rootIndex)),leafIndices:e.map((t=>t.leafIndex)),leaves:e.map((t=>tt(t.hash))),merkleTrees:e.map((t=>t.merkleTree)),nullifierQueues:e.map((t=>t.nullifierQueue))}}else if(0===t.length&&e.length>0){const t=await this.getMultipleNewAddressProofs(e),n=Zr(t);r={compressedProof:await jr(this.proverEndpoint,"new-address",n,this.log),roots:t.map((t=>t.root)),rootIndices:t.map((()=>3)),leafIndices:t.map((t=>t.indexHashedIndexedElementLeaf.toNumber())),leaves:t.map((t=>tt(t.value))),merkleTrees:t.map((t=>t.merkleTree)),nullifierQueues:t.map((t=>t.nullifierQueue))}}else{if(!(t.length>0&&e.length>0))throw new Error("Invalid input");{const n=await this.getMultipleCompressedAccountProofs(t),o=$r(n),s=await this.getMultipleNewAddressProofs(e),i=Zr(s);r={compressedProof:await jr(this.proverEndpoint,"combined",[o,i],this.log),roots:n.map((t=>t.root)).concat(s.map((t=>t.root))),rootIndices:n.map((t=>t.rootIndex)).concat(s.map((()=>3))),leafIndices:n.map((t=>t.leafIndex)).concat(s.map((t=>t.indexHashedIndexedElementLeaf.toNumber()))),leaves:n.map((t=>tt(t.hash))).concat(s.map((t=>tt(t.value)))),merkleTrees:n.map((t=>t.merkleTree)).concat(s.map((t=>t.merkleTree))),nullifierQueues:n.map((t=>t.nullifierQueue)).concat(s.map((t=>t.nullifierQueue)))}}}return r}async getValidityProofV0(t=[],e=[]){return this.getValidityProof(t.map((t=>t.hash)),e.map((t=>t.address)))}}export{X as ADDRESS_QUEUE_ROLLOVER_FEE,J as ADDRESS_TREE_NETWORK_FEE,de as ALICE,Dr as AccountProofResult,me as BOB,Pr as BalanceResult,ir as BaseRpc,fe as CHARLIE,be as CompressedAccountLayout,gr as CompressedAccountResult,Mr as CompressedAccountsByOwnerResult,Ur as CompressedMintTokenHoldersResult,yr as CompressedTokenAccountResult,br as CompressedTokenAccountsByOwnerOrDelegateResult,Vr as CompressedTransactionResult,Ye as CreateUtxoError,Qe as CreateUtxoErrorCode,pe as DAVE,K as DEFAULT_MERKLE_TREE_HEIGHT,z as DEFAULT_MERKLE_TREE_ROOTS,on as DEFAULT_ZERO,S as FIELD_SIZE,N as HIGHEST_ADDRESS_PLUS_ONE,rr as HashError,We as HashErrorCode,Er as HealthResult,nn as IndexedArray,en as IndexedElement,rn as IndexedElementBundle,Ie as InstructionDataInvokeLayout,Ir as LatestNonVotingSignaturesResult,kr as LatestNonVotingSignaturesResultPaginated,Ce as LightSystemProgram,er as LookupTableError,ze as LookupTableErrorCode,Tr as MerkeProofResult,Ae as MerkleContextLayout,sn as MerkleTree,or as MerkleTreeError,$e as MerkleTreeErrorCode,vr as MultipleCompressedAccountsResult,Nr as MultipleMerkleProofsResult,Br as NativeBalanceResult,Ee as NewAddressParamsLayout,xr as NewAddressProofResult,nr as ProofError,je as ProofErrorCode,_e as PublicTransactionEventLayout,tn as Rpc,tr as RpcError,Ke as RpcErrorCode,G as STATE_MERKLE_TREE_NETWORK_FEE,Z as STATE_MERKLE_TREE_ROLLOVER_FEE,Je as SelectInUtxosError,He as SelectInUtxosErrorCode,qr as SignatureListResult,Fr as SignatureListWithCursorResult,Ar as SlotResult,$ as TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD,Mn as TestRpc,Or as TokenBalanceListResult,Lr as TokenBalanceListResultV2,Cr as TokenBalanceResult,mn as TokenDataLayout,wr as TokenDataResult,j as UTXO_MERGE_MAXIMUM,W as UTXO_MERGE_THRESHOLD,sr as UtilsError,Ze as UtilsErrorCode,Ge as UtxoError,Ve as UtxoErrorCode,Sr as ValidityProofResult,C as accountCompressionProgram,H as addressQueue,V as addressTree,Xt as airdropSol,tt as bn,Lt as bufToDecStr,le as buildAndSignTx,ie as buildTx,Bt as byteArrayToKeypair,ve as calculateComputeUnitPrice,Yt as checkValidityProofShape,Le as compress,Q as confirmConfig,Gt as confirmTransaction,ue as confirmTx,$r as convertMerkleProofsWithContextToHex,Zr as convertNonInclusionMerkleProofInputsToHex,Ue as createAccount,De as createAccountWithLamports,et as createBN254,nt as createCompressedAccount,ot as createCompressedAccountWithMerkleContext,st as createMerkleContext,zr as createRpc,dr as createRpcResult,Te as decodeInstructionDataInvoke,Ne as decodePublicTransactionEvent,Re as decompress,qe as dedupeSigner,U as defaultStaticAccounts,D as defaultStaticAccountsStruct,R as defaultTestStateTreeAccounts,$t as deriveAddress,jt as deriveAddressSeed,rt as encodeBN254toBase58,ke as encodeInstructionDataInvoke,Se as encodePublicTransactionEvent,L as getAccountCompressionAuthority,yn as getCompressedTokenAccountByHashTest,pn as getCompressedTokenAccounts,wn as getCompressedTokenAccountsByDelegateTest,gn as getCompressedTokenAccountsByOwnerTest,we as getConnection,Vt as getIndexOrAdd,an as getParsedEvents,Gr as getPublicInputHash,O as getRegisteredProgramPda,ye as getTestKeypair,vn as getTestRpc,Dt as hashToBn254FieldSizeBe,Rt as hashvToBn254FieldSizeBe,xe as invokeAccountsLayout,fr as jsonRpcResult,pr as jsonRpcResultAndContext,B as lightProgram,F as merkletreePubkey,ee as negateAndCompressProof,ge as newAccountWithLamports,P as noopProgram,q as nullifierQueuePubkey,Kt as packCompressedAccounts,Zt as packNewAddressParams,Ht as padOutputStateMerkleTrees,Hr as parseAccountData,un as parseEvents,ln as parsePublicTransactionEventWithIdl,fn as parseTokenLayoutWithIdl,se as pipe,Jt as placeholderValidityProof,te as proofFromJsonStruct,jr as proverRequest,qt as pushUniqueItems,Wr as rpcRequest,Oe as selectMinCompressedSolAccountsForTransfer,ae as sendAndConfirmTx,he as sleep,Pe as sumUpLamports,Qt as toAccountMetas,Ot as toArray,Ft as toCamelCase,Ct as toHex,Rr as toUnixTimestamp,Fe as transfer,Wt as validateSameOwner,zt as validateSufficientBalance};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|