@solana/web3.js 2.0.0-preview.3.20240730155551.62c366680964b87fcb7976f532e4f760b95cb46d → 2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +162 -188
- package/dist/index.development.js +1 -1
- package/dist/index.production.min.js +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
@@ -6,15 +6,15 @@
|
|
6
6
|
|
7
7
|
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
|
8
8
|
[code-style-prettier-url]: https://github.com/prettier/prettier
|
9
|
-
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/web3.js/
|
10
|
-
[npm-image]: https://img.shields.io/npm/v/@solana/web3.js/
|
11
|
-
[npm-url]: https://www.npmjs.com/package/@solana/web3.js/v/
|
9
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/web3.js/preview.svg?style=flat
|
10
|
+
[npm-image]: https://img.shields.io/npm/v/@solana/web3.js/preview.svg?style=flat
|
11
|
+
[npm-url]: https://www.npmjs.com/package/@solana/web3.js/v/preview
|
12
12
|
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
13
13
|
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
14
14
|
|
15
|
-
# Solana JavaScript SDK
|
15
|
+
# Solana JavaScript SDK 2.0 Release Candidate
|
16
16
|
|
17
|
-
If you build JavaScript applications on Solana, it’s likely you’ve worked with `@solana/web3.js` or a library powered by it. With
|
17
|
+
If you build JavaScript applications on Solana, it’s likely you’ve worked with `@solana/web3.js` or a library powered by it. With 350K+ weekly downloads on npm, it’s the most-used library in the ecosystem for building program clients, web applications, block explorers, and more.
|
18
18
|
|
19
19
|
Here’s an example of a common code snippet from `@solana/web3.js`:
|
20
20
|
|
@@ -25,37 +25,39 @@ const transaction = new Transaction().add(instruction);
|
|
25
25
|
await sendAndConfirmTransaction(connection, transaction, [payer]);
|
26
26
|
```
|
27
27
|
|
28
|
-
In response to your feedback, we began a process of modernizing the library to prepare for the next generation of Solana applications. A
|
28
|
+
In response to your feedback, we began a process of modernizing the library to prepare for the next generation of Solana applications. A Release Candidate of the new web3.js is now available for you to evaluate.
|
29
29
|
|
30
|
-
|
30
|
+
Before leaving the Release Candidate stage, we want to collect as much of your feeback and bug reports as possible. If you find a bug or can not achieve your goals because of the design of the new APIs, please file [a GitHub issue here](https://github.com/solana-labs/solana-web3.js/issues/new/choose).
|
31
31
|
|
32
|
-
|
32
|
+
# Installation
|
33
33
|
|
34
|
-
|
34
|
+
For use in a Node.js or web application:
|
35
35
|
|
36
36
|
```shell
|
37
|
-
npm install --save @solana/web3.js@
|
37
|
+
npm install --save @solana/web3.js@rc
|
38
38
|
```
|
39
39
|
|
40
|
-
|
40
|
+
For use in a browser, without a build system:
|
41
41
|
|
42
42
|
```html
|
43
43
|
<!-- Development (debug mode, unminified) -->
|
44
|
-
<script src="https://unpkg.com/@solana/web3.js@
|
44
|
+
<script src="https://unpkg.com/@solana/web3.js@rc/dist/index.development.js"></script>
|
45
45
|
|
46
46
|
<!-- Production (minified) -->
|
47
|
-
<script src="https://unpkg.com/@solana/web3.js@
|
47
|
+
<script src="https://unpkg.com/@solana/web3.js@rc/dist/index.production.min.js"></script>
|
48
48
|
```
|
49
49
|
|
50
|
-
|
50
|
+
# Examples
|
51
51
|
|
52
|
-
|
52
|
+
To get a feel for the new API, run and modify the live examples in the `examples/` directory. There, you will find a series of single-purpose Node scripts that demonstrate a specific feature or use case. You will also find a React application that you can run in a browser, that demonstrates being able to create, sign, and send transactions using browser wallets.
|
53
53
|
|
54
|
-
|
54
|
+
# What's New
|
55
55
|
|
56
|
-
|
56
|
+
Version 2.0 of the Solana JavaScript SDK is a response to many of the pain points you have communicated to us when developing Solana applications with web3.js. We’ve heard you loud and clear.
|
57
57
|
|
58
|
-
|
58
|
+
## Tree-Shakability
|
59
|
+
|
60
|
+
The object-oriented design of the web3.js (1.x) API prevents optimizing compilers from being able to ‘tree-shake’ unused code from your production builds. No matter how much of the web3.js API you use in your application, you have until now been forced to package all of it.
|
59
61
|
|
60
62
|
Read more about tree-shaking here:
|
61
63
|
|
@@ -67,46 +69,7 @@ One example of an API that can’t be tree-shaken is the `Connection` class. It
|
|
67
69
|
|
68
70
|
Needlessly large JavaScript bundles can cause issues with deployments to cloud compute providers like Cloudflare or AWS Lambda. They also impact webapp startup performance because of longer download and JavaScript parse times.
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
Depending on your use case and your tolerance for certain application behaviours, you may be willing to configure your application to make a different set of tradeoffs than another developer. The default tradeoffs that we codify into the web3.js API on the other hand have to work for as large a population as possible, in the common case.
|
73
|
-
|
74
|
-
The inability to customize web3.js has been a source of frustration for some:
|
75
|
-
|
76
|
-
- The Mango team wanted to customize the transaction confirmation strategy, but all of that functionality is hidden away behind `confirmTransaction` – a static method of `Connection`. [Here’s the code for `confirmTransaction` on GitHub](https://github.com/solana-labs/solana-web3.js/blob/69a8ad25ef09f9e6d5bff1ffa8428d9be0bd32ac/packages/library-legacy/src/connection.ts#L3734).
|
77
|
-
- Solana developer ‘mPaella’ [wanted us to add a feature in the RPC](https://github.com/solana-labs/solana-web3.js/issues/1143#issuecomment-1435927152) that would failover to a set of backup URLs in case the primary one failed.
|
78
|
-
- Solana developer ‘epicfaace’ wanted first-class support for automatic time-windowed batching in the RPC transport. [Here’s their pull request](https://github.com/solana-labs/solana/pull/23628).
|
79
|
-
- Multiple folks have expressed the need for custom retry logic for failed requests or transactions. [Here’s a pull request from ‘dafyddd’](https://github.com/solana-labs/solana/pull/11811) and [another from ‘abrkn’](https://github.com/solana-labs/solana-web3.js/issues/1041) attempting to modify retry logic to suit their individual use cases.
|
80
|
-
|
81
|
-
## Lagging Behind Modern JavaScript
|
82
|
-
|
83
|
-
The advance of modern JavaScript features presents an opportunity to developers of crypto applications, such as the ability to use native Ed25519 keys and to express large values as native `bigint`.
|
84
|
-
|
85
|
-
The Web Incubator Community Group has advocated for the addition of Ed25519 support to the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API), and support has already landed in _most_ modern JavaScript runtimes.
|
86
|
-
|
87
|
-
Support for `bigint` values has also become commonplace. The older `number` primitive in JavaScript has a maximum value of 2^53 - 1, whereas Rust’s `u64` can represent values up to 2^64.
|
88
|
-
|
89
|
-
## Class-Based Architecture
|
90
|
-
|
91
|
-
The object oriented, class-based architecture of the legacy library causes unnecessary bundle bloat. Your application has no choice but to bundle _all_ of the functionality and dependencies of a class no matter how many methods you actually use at runtime.
|
92
|
-
|
93
|
-
Class-based architecture also presents unique risks to developers who trigger the dual-package hazard. This describes a situation you can find yourself in if you build for both CommonJS and ES modules. The situation arises when two “copies” of the same class are present in the dependency tree, causing checks like `instanceof` to fail, which introduces aggravating and difficult to debug problems.
|
94
|
-
|
95
|
-
Read more about dual-package hazard:
|
96
|
-
|
97
|
-
- [NodeJS: Dual Package Hazard](https://nodejs.org/api/packages.html#dual-package-hazard)
|
98
|
-
|
99
|
-
# The New web3.js
|
100
|
-
|
101
|
-
Enter web3.js 2.0. The new API aims to deliver a re-imagined experience of building Solana applications, a high level of performance by default, and all with a minimum of code. From the ability to customize the behaviour of the library through composition, to the joy of being able to catch common errors during build time before they make it to production, we hope that you enjoy building with it as much as we’ve enjoyed creating it.
|
102
|
-
|
103
|
-
## Features
|
104
|
-
|
105
|
-
The new (2.0) version of `@solana/web3.js` aims to address shortcomings in the legacy library first, then goes even further.
|
106
|
-
|
107
|
-
### Tree-Shaking
|
108
|
-
|
109
|
-
The 2.0 library is tree-shakable, and that tree-shakeability is enforced in the CI. Anything you don’t use from web3.js 2.0 can now be discarded from your bundle by an optimizing compiler.
|
72
|
+
Version 2.0 is fully tree-shakable and will remain so, enforced by build-time checks. Optimizing compilers can now eliminate those parts of the library that your application does not use.
|
110
73
|
|
111
74
|
The new library itself is comprised of several smaller, modular packages under the `@solana` organization, including:
|
112
75
|
|
@@ -123,61 +86,73 @@ The new library itself is comprised of several smaller, modular packages under t
|
|
123
86
|
|
124
87
|
Some of these packages are themselves composed of smaller packages. For instance, `@solana/rpc` is composed of `@solana/rpc-spec` (for core JSON RPC specification types), `@solana/rpc-api` (for the Solana-specific RPC methods), `@solana/rpc-transport-http` (for the default HTTP transport) and so on.
|
125
88
|
|
126
|
-
Developers can use the default configurations within the library
|
89
|
+
Developers can use the default configurations within the main library (`@solana/web3.js@rc`) or import any of its subpackages where customization-through-composition is desired.
|
127
90
|
|
128
|
-
|
91
|
+
## Composable Internals
|
129
92
|
|
130
|
-
|
93
|
+
Depending on your use case and your tolerance for certain application behaviours, you may wish to configure your application to make a different set of tradeoffs than another developer. The web3.js (1.x) API imposed a rigid set of common-case defaults on _all_ developers, some of which were impossible to change.
|
131
94
|
|
132
|
-
|
95
|
+
The inability to customize web3.js up until now has been a source of frustration:
|
96
|
+
|
97
|
+
- The Mango team wanted to customize the transaction confirmation strategy, but all of that functionality is hidden away behind `confirmTransaction` – a static method of `Connection`. [Here’s the code for `confirmTransaction` on GitHub](https://github.com/solana-labs/solana-web3.js/blob/69a8ad25ef09f9e6d5bff1ffa8428d9be0bd32ac/packages/library-legacy/src/connection.ts#L3734).
|
98
|
+
- Solana developer ‘mPaella’ [wanted us to add a feature in the RPC](https://github.com/solana-labs/solana-web3.js/issues/1143#issuecomment-1435927152) that would failover to a set of backup URLs in case the primary one failed.
|
99
|
+
- Solana developer ‘epicfaace’ wanted first-class support for automatic time-windowed batching in the RPC transport. [Here’s their pull request](https://github.com/solana-labs/solana/pull/23628).
|
100
|
+
- Multiple folks have expressed the need for custom retry logic for failed requests or transactions. [Here’s a pull request from ‘dafyddd’](https://github.com/solana-labs/solana/pull/11811) and [another from ‘abrkn’](https://github.com/solana-labs/solana-web3.js/issues/1041) attempting to modify retry logic to suit their individual use cases.
|
101
|
+
|
102
|
+
Version 2.0 exposes far more of its internals, particularly where communication with an RPC is concerned, and allows willing developers the ability to compose new implementations from the default ones that manifest a nearly limitless array of customizations.
|
103
|
+
|
104
|
+
The individual modules that make up web3.js are assembled in a **default** configuration reminiscent of the legacy library as part of the npm package `@solana/web3.js@rc`, but those who wish to assemble them in different configurations may do so.
|
105
|
+
|
106
|
+
Generic types are offered in numerous places, allowing you to specify new functionality, to make extensions to each API via composition and supertypes, and to encourage you to create higher-level opinionated abstractions of your own.
|
133
107
|
|
134
108
|
In fact, we expect you to do so, and to open source some of those for use by others with similar needs.
|
135
109
|
|
136
|
-
|
110
|
+
## Modern JavaScript; Zero-Dependency
|
137
111
|
|
138
|
-
The
|
112
|
+
The advance of modern JavaScript features presents an opportunity to developers of crypto applications, such as the ability to use native Ed25519 keys and to express large values as native `bigint`.
|
139
113
|
|
140
|
-
|
114
|
+
The Web Incubator Community Group has advocated for the addition of Ed25519 support to the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API), and support has already landed in _most_ modern JavaScript runtimes.
|
141
115
|
|
142
|
-
|
116
|
+
Engine support for `bigint` values has also become commonplace. The older `number` primitive in JavaScript has a maximum value of 2^53 - 1, whereas Rust’s `u64` can represent values up to 2^64.
|
143
117
|
|
144
|
-
|
145
|
-
- [Node JS Documentation: Web Crypto API](https://nodejs.org/api/webcrypto.html)
|
146
|
-
- [Nieky Allen (Blog): The Web Crypto API in Action](https://medium.com/slalom-build/the-web-cryptography-api-in-action-89b2f68c602c)
|
118
|
+
Version 2.0 eliminates userspace implementations of Ed25519 cryptography, large number polyfills, and more, in favour of custom implementations or the use of native JavaScript features, reducing the size of the library. It has no third-party dependencies.
|
147
119
|
|
148
|
-
|
120
|
+
## Functional Architecture
|
149
121
|
|
150
|
-
|
122
|
+
The object oriented, class-based architecture of web3.js (1.x) causes unnecessary bundle bloat. Your application has no choice but to bundle _all_ of the functionality and dependencies of a class no matter how many methods you actually use at runtime.
|
151
123
|
|
152
|
-
|
124
|
+
Class-based architecture also presents unique risks to developers who trigger the dual-package hazard. This describes a situation you can find yourself in if you build for both CommonJS and ES modules. It arises when two copies of the same class are present in the dependency tree, causing checks like `instanceof` to fail. This introduces aggravating and difficult to debug problems.
|
153
125
|
|
154
|
-
|
126
|
+
Read more about dual-package hazard:
|
127
|
+
|
128
|
+
- [NodeJS: Dual Package Hazard](https://nodejs.org/api/packages.html#dual-package-hazard)
|
129
|
+
|
130
|
+
Version 2.0 implements no classes (with the notable exception of the `SolanaError` class) and implements the thinnest possible interfaces at function boundaries.
|
155
131
|
|
156
132
|
## Statistics
|
157
133
|
|
158
|
-
Consider these statistical comparisons between
|
134
|
+
Consider these statistical comparisons between version 2.0 and the legacy 1.x.
|
159
135
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
| Total minified size of library
|
163
|
-
| Total minified size of library (when runtime supports Ed25519)
|
164
|
-
| Bundled size of a web application that
|
165
|
-
| Bundled size of a web application that
|
166
|
-
|
|
167
|
-
|
|
168
|
-
| First-load size for Solana Explorer | 311 KB | 228 KB | -26% |
|
136
|
+
| | 1.x (Legacy) | 2.0 | +/- % |
|
137
|
+
| ------------------------------------------------------------------------------------------------------ | ------------ | ---------- | ----- |
|
138
|
+
| Total minified size of library | 81 KB | 57.5 KB | -29% |
|
139
|
+
| Total minified size of library (when runtime supports Ed25519) | 81 KB | 53 KB | -33% |
|
140
|
+
| Bundled size of a web application that executes a transfer of lamports | 111 KB | 23.9 KB | -78% |
|
141
|
+
| Bundled size of a web application that executes a transfer of lamports (when runtime supports Ed25519) | 111 KB | 18.2 KB | -83% |
|
142
|
+
| Performance of key generation, signing, and verifying signatures (Brave with Experimental API flag) | 700 ops/s | 7000 ops/s | +900% |
|
143
|
+
| First-load size for Solana Explorer | 311 KB | 228 KB | -26% |
|
169
144
|
|
170
145
|
The re-engineered library achieves these speedups and reductions in bundle size in large part through use of modern JavaScript APIs.
|
171
146
|
|
172
147
|
To validate our work, we replaced the legacy 1.x library with the new 2.0 library on the homepage of the Solana Explorer. Total first-load bundle size dropped by 26% without removing a single feature. [Here’s an X thread](https://twitter.com/callum_codes/status/1679124485218226176) by Callum McIntyre if you would like to dig deeper.
|
173
148
|
|
174
|
-
# A
|
149
|
+
# A Tour of the Version 2.0 API
|
175
150
|
|
176
151
|
Here’s an overview of how to use the new library to interact with the RPC, configure network transports, work with Ed25519 keys, and to serialize data.
|
177
152
|
|
178
153
|
## RPC
|
179
154
|
|
180
|
-
|
155
|
+
Version 2.0 ships with an implementation of the [JSON RPC specification](https://www.jsonrpc.org/specification) and a type spec for the [Solana JSON RPC](https://docs.solana.com/api).
|
181
156
|
|
182
157
|
The main package responsible for managing communication with an RPC is `@solana/rpc`. However, this package makes use of more granular packages to break down the RPC logic into smaller pieces. Namely, these packages are:
|
183
158
|
|
@@ -188,11 +163,11 @@ The main package responsible for managing communication with an RPC is `@solana/
|
|
188
163
|
- `@solana/rpc-spec-types`: Shared JSON RPC specifications types and helpers that are used by both `@solana/rpc` and `@solana/rpc-subscriptions` (described in the next section).
|
189
164
|
- `@solana/rpc-types`: Shared Solana RPC types and helpers that are used by both `@solana/rpc` and `@solana/rpc-subscriptions`.
|
190
165
|
|
191
|
-
|
166
|
+
The main `@solana/web3.js` package re-exports the `@solana/rpc` package so, going forward, we will import RPC types and functions from the library directly.
|
192
167
|
|
193
|
-
###
|
168
|
+
### RPC Calls
|
194
169
|
|
195
|
-
|
170
|
+
You can use the `createSolanaRpc` function by providing the URL of a Solana JSON RPC server. This will create a default client for interacting with the Solana JSON RPC API.
|
196
171
|
|
197
172
|
```ts
|
198
173
|
import { createSolanaRpc } from '@solana/web3.js';
|
@@ -205,9 +180,9 @@ const rpc = createSolanaRpc('http://127.0.0.1:8899');
|
|
205
180
|
const slot = await rpc.getSlot().send();
|
206
181
|
```
|
207
182
|
|
208
|
-
###
|
183
|
+
### Custom RPC Transports
|
209
184
|
|
210
|
-
The `createSolanaRpc` function communicates with the RPC server using a default HTTP transport that should satisfy most use cases.
|
185
|
+
The `createSolanaRpc` function communicates with the RPC server using a default HTTP transport that should satisfy most use cases. You can provide your own transport or wrap an existing one to communicate with RPC servers in any way you see fit. In the example below, we explicitly create a transport and use it to create a new RPC client via the `createSolanaRpcFromTransport` function.
|
211
186
|
|
212
187
|
```ts
|
213
188
|
import { createSolanaRpcFromTransport, createDefaultRpcTransport } from '@solana/web3.js';
|
@@ -223,11 +198,11 @@ const rpc = createSolanaRpcFromTransport(transport);
|
|
223
198
|
const slot = await rpc.getSlot().send();
|
224
199
|
```
|
225
200
|
|
226
|
-
|
201
|
+
A custom transport can implement specialized functionality such as coordinating multiple transports, implementing retries, and more. Let's take a look at some concrete examples.
|
227
202
|
|
228
203
|
#### Round Robin
|
229
204
|
|
230
|
-
|
205
|
+
A ‘round robin’ transport is one that distributes requests to a list of endpoints in sequence.
|
231
206
|
|
232
207
|
```ts
|
233
208
|
import { createDefaultRpcTransport, createSolanaRpcFromTransport, type RpcTransport } from '@solana/web3.js';
|
@@ -239,7 +214,7 @@ const transports = [
|
|
239
214
|
createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-3.com' }),
|
240
215
|
];
|
241
216
|
|
242
|
-
// Set up the round-robin
|
217
|
+
// Set up the round-robin transport.
|
243
218
|
let nextTransport = 0;
|
244
219
|
async function roundRobinTransport<TResponse>(...args: Parameters<RpcTransport>): Promise<TResponse> {
|
245
220
|
const transport = transports[nextTransport];
|
@@ -247,21 +222,53 @@ async function roundRobinTransport<TResponse>(...args: Parameters<RpcTransport>)
|
|
247
222
|
return await transport(...args);
|
248
223
|
}
|
249
224
|
|
250
|
-
// Create
|
225
|
+
// Create an RPC client using the round-robin transport.
|
251
226
|
const rpc = createSolanaRpcFromTransport(roundRobinTransport);
|
252
227
|
```
|
253
228
|
|
254
229
|
#### Sharding
|
255
230
|
|
256
|
-
|
231
|
+
A sharding transport is a kind of distributing transport that sends requests to a particular server based on something about the request itself. Here’s an example that sends requests to different servers depending on the name of the method:
|
257
232
|
|
258
233
|
```ts
|
259
|
-
|
234
|
+
import { createDefaultRpcTransport, createSolanaRpcFromTransport, type RpcTransport } from '@solana/web3.js';
|
235
|
+
|
236
|
+
// Create multiple transports.
|
237
|
+
const transportA = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-1.com' });
|
238
|
+
const transportB = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-2.com' });
|
239
|
+
const transportC = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-3.com' });
|
240
|
+
const transportD = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-4.com' });
|
241
|
+
|
242
|
+
// Function to determine which shard to use based on the request method.
|
243
|
+
function selectShard(method: string): RpcTransport {
|
244
|
+
switch (method) {
|
245
|
+
case 'getAccountInfo':
|
246
|
+
case 'getBalance':
|
247
|
+
return transportA;
|
248
|
+
case 'getTransaction':
|
249
|
+
case 'getRecentBlockhash':
|
250
|
+
return transportB;
|
251
|
+
case 'sendTransaction':
|
252
|
+
return transportC;
|
253
|
+
default:
|
254
|
+
return transportD;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
// Create a transport that selects the correct transport given the request method name.
|
259
|
+
async function shardingTransport<TResponse>(...args: Parameters<RpcTransport>): Promise<TResponse> {
|
260
|
+
const payload = args[0].payload as { method: string };
|
261
|
+
const selectedTransport = selectShard(payload.method);
|
262
|
+
return (await selectedTransport(...args)) as TResponse;
|
263
|
+
}
|
264
|
+
|
265
|
+
// Create an RPC client using the sharding transport.
|
266
|
+
const rpc = createSolanaRpcFromTransport(shardingTransport);
|
260
267
|
```
|
261
268
|
|
262
|
-
#### Retry
|
269
|
+
#### Retry
|
263
270
|
|
264
|
-
|
271
|
+
A custom transport is a good place to implement global retry logic for every request:
|
265
272
|
|
266
273
|
```ts
|
267
274
|
import { createDefaultRpcTransport, createSolanaRpcFromTransport, type RpcTransport } from '@solana/web3.js';
|
@@ -307,55 +314,19 @@ const rpc = createSolanaRpcFromTransport(retryingTransport);
|
|
307
314
|
|
308
315
|
#### Failover
|
309
316
|
|
310
|
-
Support for handling
|
317
|
+
Support for handling network failures can be implemented in the transport itself. Here’s an example of some failover logic integrated into a transport:
|
311
318
|
|
312
319
|
```ts
|
313
320
|
// TODO: Your turn; send us a pull request with an example.
|
314
321
|
```
|
315
322
|
|
316
|
-
|
323
|
+
### Augmenting/Constraining the RPC API
|
317
324
|
|
318
|
-
|
325
|
+
Using the `createSolanaRpc` or `createSolanaRpcFromTransport` methods, we always get the same API that includes the Solana RPC API methods. Since the RPC API is described using types only, it is possible to augment those types to add your own methods.
|
319
326
|
|
320
|
-
|
321
|
-
import { createDefaultRpcTransport, createSolanaRpcFromTransport, type RpcTransport } from '@solana/web3.js';
|
327
|
+
When constraining the API scope, keep in mind that types don’t affect bundle size. You may still like to constrain the type-spec for a variety of reasons, including reducing TypeScript noise.
|
322
328
|
|
323
|
-
|
324
|
-
const transportA = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-1.com' });
|
325
|
-
const transportB = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-2.com' });
|
326
|
-
const transportC = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-3.com' });
|
327
|
-
const transportD = createDefaultRpcTransport({ url: 'https://mainnet-beta.my-server-4.com' });
|
328
|
-
|
329
|
-
// Function to determine which shard to use based on the request method.
|
330
|
-
function selectShard(method: string): RpcTransport {
|
331
|
-
switch (method) {
|
332
|
-
case 'getAccountInfo':
|
333
|
-
case 'getBalance':
|
334
|
-
return transportA;
|
335
|
-
case 'getTransaction':
|
336
|
-
case 'getRecentBlockhash':
|
337
|
-
return transportB;
|
338
|
-
case 'sendTransaction':
|
339
|
-
return transportC;
|
340
|
-
default:
|
341
|
-
return transportD;
|
342
|
-
}
|
343
|
-
}
|
344
|
-
|
345
|
-
const rpc = createSolanaRpcFromTransport(async <TResponse>(...args: Parameters<RpcTransport>): Promise<TResponse> => {
|
346
|
-
const payload = args[0].payload as { method: string };
|
347
|
-
const selectedTransport = selectShard(payload.method);
|
348
|
-
return (await selectedTransport(...args)) as TResponse;
|
349
|
-
});
|
350
|
-
```
|
351
|
-
|
352
|
-
### Scoping the RPC API
|
353
|
-
|
354
|
-
Using the `createSolanaRpc` or `createSolanaRpcFromTransport` methods, we always get the same RPC API, including all Solana RPC methods. However, since the RPC API is described using types only, it is possible to scope the API to a specific set of methods and even add your own custom methods.
|
355
|
-
|
356
|
-
When reducing the API scope, keep in mind that types don’t affect bundle size. However, you may choose to scope the type-spec for a variety of reasons, including reducing TypeScript noise.
|
357
|
-
|
358
|
-
#### Scoping by Cluster
|
329
|
+
#### Constraining by Cluster
|
359
330
|
|
360
331
|
If you're using a specific cluster, you may wrap your RPC URL inside a helper function like `mainnet` or `devnet` to inject that information into the RPC type system.
|
361
332
|
|
@@ -369,11 +340,11 @@ const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
|
|
369
340
|
// ^? RpcDevnet<SolanaRpcApiDevnet>
|
370
341
|
```
|
371
342
|
|
372
|
-
In the example above, `devnetRpc.requestAirdrop(..)` will work, but `mainnetRpc.requestAirdrop(..)` will
|
343
|
+
In the example above, `devnetRpc.requestAirdrop(..)` will work, but `mainnetRpc.requestAirdrop(..)` will raise a TypeScript error since `requestAirdrop` is not a valid method of the mainnet cluster.
|
373
344
|
|
374
345
|
#### Cherry-Picking API Methods
|
375
346
|
|
376
|
-
You
|
347
|
+
You can constrain the API’s type-spec even further so you are left only with the methods you need. The simplest way to do this is to cast the created RPC client to a type that only includes the required methods.
|
377
348
|
|
378
349
|
```ts
|
379
350
|
import { createSolanaRpc, type Rpc, type GetAccountInfoApi, type GetMultipleAccountsApi } from '@solana/web3.js';
|
@@ -381,7 +352,7 @@ import { createSolanaRpc, type Rpc, type GetAccountInfoApi, type GetMultipleAcco
|
|
381
352
|
const rpc = createSolanaRpc('http://127.0.0.1:8899') as Rpc<GetAccountInfoApi & GetMultipleAccountsApi>;
|
382
353
|
```
|
383
354
|
|
384
|
-
Alternatively, you
|
355
|
+
Alternatively, you can explicitly create the RPC API using the `createSolanaRpcApi` function. You will need to create your own transport and bind the two together using the `createRpc` function.
|
385
356
|
|
386
357
|
```ts
|
387
358
|
import {
|
@@ -401,38 +372,44 @@ const rpc = createRpc({ api, transport });
|
|
401
372
|
|
402
373
|
Note that the `createSolanaRpcApi` function is a wrapper on top of the `createRpcApi` function which adds some Solana-specific transformers such as setting a default commitment on all methods or throwing an error when an integer overflow is detected.
|
403
374
|
|
404
|
-
#### Creating
|
375
|
+
#### Creating Your Own API Methods
|
405
376
|
|
406
377
|
The new library’s RPC specification supports an _infinite_ number of JSON-RPC methods with **zero increase** in bundle size.
|
407
378
|
|
408
|
-
This means the library can support future additions to the official [Solana JSON RPC](https://docs.solana.com/api), or [custom RPC methods](https://
|
379
|
+
This means the library can support future additions to the official [Solana JSON RPC](https://docs.solana.com/api), or [custom RPC methods](https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset) defined by some RPC provider.
|
409
380
|
|
410
|
-
Here’s an example of how a developer at
|
381
|
+
Here’s an example of how a developer at might build a custom RPC type-spec for an RPC provider's implementation of the Metaplex Digital Asset Standard's `getAsset` method:
|
411
382
|
|
412
383
|
```ts
|
413
384
|
import { RpcApiMethods } from '@solana/web3.js';
|
414
385
|
|
415
386
|
// Define the method's response payload.
|
416
|
-
type
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
387
|
+
type GetAssetApiResponse = Readonly<{
|
388
|
+
interface: DasApiAssetInterface;
|
389
|
+
id: Address;
|
390
|
+
content: Readonly<{
|
391
|
+
files?: readonly {
|
392
|
+
mime?: string;
|
393
|
+
uri?: string;
|
394
|
+
[key: string]: unknown;
|
395
|
+
}[];
|
396
|
+
json_uri: string;
|
397
|
+
links?: readonly {
|
398
|
+
[key: string]: unknown;
|
399
|
+
}[];
|
400
|
+
metadata: DasApiMetadata;
|
401
|
+
}>;
|
402
|
+
/* ...etc... */
|
426
403
|
}>;
|
427
404
|
|
428
405
|
// Set up an interface for the request method.
|
429
|
-
interface
|
406
|
+
interface GetAssetApi extends RpcApiMethods {
|
430
407
|
// Define the method's name, parameters and response type
|
431
|
-
|
408
|
+
getAsset(args: { id: Address }): GetAssetApiResponse;
|
432
409
|
}
|
433
410
|
|
434
411
|
// Export the type spec for downstream users.
|
435
|
-
export type
|
412
|
+
export type MetaplexDASApi = GetAssetApi;
|
436
413
|
```
|
437
414
|
|
438
415
|
Here’s how a developer might use it:
|
@@ -441,17 +418,19 @@ Here’s how a developer might use it:
|
|
441
418
|
import { createDefaultRpcTransport, createRpc, createRpcApi } from '@solana/web3.js';
|
442
419
|
|
443
420
|
// Create the custom API.
|
444
|
-
const api = createRpcApi<
|
421
|
+
const api = createRpcApi<MetaplexDASApi>();
|
445
422
|
|
446
|
-
// Set up an HTTP transport.
|
447
|
-
const transport = createDefaultRpcTransport({
|
423
|
+
// Set up an HTTP transport to a server that supports the custom API.
|
424
|
+
const transport = createDefaultRpcTransport({
|
425
|
+
url: 'https://mainnet.helius-rpc.com/?api-key=<api_key>',
|
426
|
+
});
|
448
427
|
|
449
428
|
// Create the RPC client.
|
450
|
-
const
|
451
|
-
// ^? Rpc<
|
429
|
+
const metaplexDASRpc = createRpc({ api, transport });
|
430
|
+
// ^? Rpc<MetaplexDASApi>
|
452
431
|
```
|
453
432
|
|
454
|
-
As long as a particular JSON RPC method adheres to the [official JSON RPC specification](https://www.jsonrpc.org/specification), it will be supported by
|
433
|
+
As long as a particular JSON RPC method adheres to the [official JSON RPC specification](https://www.jsonrpc.org/specification), it will be supported by version 2.0.
|
455
434
|
|
456
435
|
### Aborting RPC Requests
|
457
436
|
|
@@ -463,7 +442,7 @@ const pendingRequest: PendingRpcRequest<Slot> = rpc.getSlot();
|
|
463
442
|
const slot: Slot = await pendingRequest.send();
|
464
443
|
```
|
465
444
|
|
466
|
-
|
445
|
+
The arguments of the `getSlot` method are reserved for the request payload, but the `send` method is where additional arguments such as an `AbortSignal` can be accepted in the context of the request.
|
467
446
|
|
468
447
|
Aborting RPC requests can be useful for a variety of things such as setting a timeout on a request or cancelling a request when a user navigates away from a page.
|
469
448
|
|
@@ -484,7 +463,7 @@ function onUserNavigateAway() {
|
|
484
463
|
const slot = await rpc.getSlot().send({ abortSignal: abortController.signal });
|
485
464
|
```
|
486
465
|
|
487
|
-
Read more about `AbortController`
|
466
|
+
Read more about `AbortController` here:
|
488
467
|
|
489
468
|
- [Mozilla Developer Docs: `AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
|
490
469
|
- [Mozilla Developer Docs: `AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
@@ -507,7 +486,7 @@ Since the main `@solana/web3.js` library also re-exports the `@solana/rpc-subscr
|
|
507
486
|
|
508
487
|
### Getting Started with RPC Subscriptions
|
509
488
|
|
510
|
-
To get started with RPC Subscriptions, you may use the `createSolanaRpcSubscriptions` function by providing the WebSocket URL of
|
489
|
+
To get started with RPC Subscriptions, you may use the `createSolanaRpcSubscriptions` function by providing the WebSocket URL of a Solana JSON RPC server. This will create a default client for interacting with Solana RPC Subscriptions.
|
511
490
|
|
512
491
|
```ts
|
513
492
|
import { createSolanaRpcSubscriptions } from '@solana/web3.js';
|
@@ -517,7 +496,7 @@ const rpcSubscriptions = createSolanaRpcSubscriptions('ws://127.0.0.1:8900');
|
|
517
496
|
// ^? RpcSubscriptions<SolanaRpcSubscriptionsApi>
|
518
497
|
```
|
519
498
|
|
520
|
-
### Subscriptions as
|
499
|
+
### Subscriptions as `AsyncIterators`
|
521
500
|
|
522
501
|
The new subscriptions API vends subscription notifications as an `AsyncIterator`. The `AsyncIterator` conforms to the [async iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols), which allows developers to consume messages using a `for await...of` loop.
|
523
502
|
|
@@ -615,7 +594,7 @@ for await (const notification of accountNotifications) {
|
|
615
594
|
}
|
616
595
|
```
|
617
596
|
|
618
|
-
### Failed
|
597
|
+
### Failed vs. Aborted Subscriptions
|
619
598
|
|
620
599
|
It is important to note that a subscription failure behaves differently from a subscription abort. A subscription failure occurs when the subscription goes down and will throw an error that can be intercepted in a `try/catch`. However, an aborted subscription will not throw an error, but will instead exit the `for await...of` loop.
|
621
600
|
|
@@ -671,11 +650,11 @@ const rpcSubscriptions = createSolanaRpcSubscriptionsFromTransport(transport);
|
|
671
650
|
// ^? RpcSubscriptions<SolanaRpcSubscriptionsApi>
|
672
651
|
```
|
673
652
|
|
674
|
-
###
|
653
|
+
### Augmenting/Constraining the RPC Subscriptions API
|
675
654
|
|
676
|
-
Using the `createSolanaRpcSubscriptions` or `createSolanaRpcSubscriptionsFromTransport` functions, we always get the same RPC Subscriptions API, including all Solana RPC stable subscriptions. However, since the RPC Subscriptions API is described using types only, it is possible to
|
655
|
+
Using the `createSolanaRpcSubscriptions` or `createSolanaRpcSubscriptionsFromTransport` functions, we always get the same RPC Subscriptions API, including all Solana RPC stable subscriptions. However, since the RPC Subscriptions API is described using types only, it is possible to constrain the API to a specific set of subscriptions or even add your own custom subscriptions.
|
677
656
|
|
678
|
-
####
|
657
|
+
#### Constraining by Cluster
|
679
658
|
|
680
659
|
If you're using a specific cluster, you may wrap your RPC URL inside a helper function like `mainnet` or `devnet` to inject that information into the RPC type system.
|
681
660
|
|
@@ -711,7 +690,7 @@ const rpcSubscriptions = createSolanaRpcSubscriptionsFromTransport_UNSTABLE(tran
|
|
711
690
|
|
712
691
|
#### Cherry-Picking API Methods
|
713
692
|
|
714
|
-
You may
|
693
|
+
You may constrain the scope of the Subscription API even further so you are left only with the subscriptions you need. The simplest way to do this is to cast the created RPC client to a type that only includes the methods you need.
|
715
694
|
|
716
695
|
```ts
|
717
696
|
import {
|
@@ -881,7 +860,7 @@ const signedTransaction = await signTransaction([signer], transactionMessageWith
|
|
881
860
|
// => "Property 'lifetimeConstraint' is missing in type"
|
882
861
|
```
|
883
862
|
|
884
|
-
### Calibrating
|
863
|
+
### Calibrating a Transaction Message's Compute Unit Budget
|
885
864
|
|
886
865
|
Correctly budgeting a compute unit limit for your transaction message can increase the probability that your transaction will be accepted for processing. If you don't declare a compute unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU) per instruction.
|
887
866
|
|
@@ -1098,7 +1077,7 @@ const blockWithRewardsAndTransactionsResponse = await rpc
|
|
1098
1077
|
|
1099
1078
|
### Catching Compile-Time Bugs with TypeScript
|
1100
1079
|
|
1101
|
-
As previously mentioned, the type coverage in
|
1080
|
+
As previously mentioned, the type coverage in version 2.0 allows developers to catch common bugs at compile time, rather than runtime.
|
1102
1081
|
|
1103
1082
|
In the example below, a transaction message is created and then attempted to be signed without setting the fee payer. This would result in a runtime error from the RPC, but instead you will see a type error from TypeScript as you type:
|
1104
1083
|
|
@@ -1297,11 +1276,11 @@ account.data.lastExtendedSlot; // Slot
|
|
1297
1276
|
account.data.lastExtendedSlotStartIndex; // number
|
1298
1277
|
```
|
1299
1278
|
|
1300
|
-
### How
|
1279
|
+
### How Does This Work?
|
1301
1280
|
|
1302
1281
|
All of this code is 100% auto-generated by Kinobi from a tree of standardized nodes that represent our programs. It contains obvious nodes such as `AccountNode` but also more specified nodes such as `ConditionalValueNode` that allows us to resolve account or argument default values conditionally.
|
1303
1282
|
|
1304
|
-
Kinobi allows us to hydrate our tree of nodes from IDLs which are typically generated by program frameworks such as [Anchor](https://github.com/coral-xyz/anchor) or [Shank](https://github.com/metaplex-foundation/shank). Additionally, visitors can be used on our nodes to expand the knowledge of our programs since the IDL itself doesn’t yet contain that level of information. Finally, special visitors called
|
1283
|
+
Kinobi allows us to hydrate our tree of nodes from IDLs which are typically generated by program frameworks such as [Anchor](https://github.com/coral-xyz/anchor) or [Shank](https://github.com/metaplex-foundation/shank). Additionally, visitors can be used on our nodes to expand the knowledge of our programs since the IDL itself doesn’t yet contain that level of information. Finally, special visitors called ‘renderers’ visit our tree to generate clients such as this JavaScript client.
|
1305
1284
|
|
1306
1285
|
Currently, there is one other renderer that generates Rust clients but this is only the beginning. In the future, you can expect renderers for auto-generated Python clients, documentation, CLIs, etc.
|
1307
1286
|
|
@@ -1327,12 +1306,6 @@ This [`create-solana-program`](https://github.com/solana-program/create-solana-p
|
|
1327
1306
|
|
1328
1307
|
When selecting the JavaScript client, you will get a fully generated library compatible with the new web3.js much like the `@solana-program` packages showcased above.
|
1329
1308
|
|
1330
|
-
# Going Forward
|
1331
|
-
|
1332
|
-
This Technology Preview is just that, and development on the new web3.js is ongoing. We are working on tooling to accompany the new library to make building web applications on Solana easier, safer, and more scalable.
|
1333
|
-
|
1334
|
-
Although this new approach to JavaScript tooling is drastically different than the tooling you are used to, we are confident that the customizability, performance, bundle size, and safety characteristics of the new library will make it worth the migration. We’re here to help you every step of the way, via Github issues when you find problems with the library, and on the [Solana Stack Exchange](https://sola.na/sse) when you have questions on how something is supposed to work.
|
1335
|
-
|
1336
1309
|
## GraphQL
|
1337
1310
|
|
1338
1311
|
Though not directly related to web3.js, we wanted to hijack your attention to show you something else that we’re working on, of particular interest to frontend developers. It’s a new API for interacting with the RPC: a GraphQL API.
|
@@ -1442,15 +1415,16 @@ See more in the package’s [README on GitHub](https://github.com/solana-labs/so
|
|
1442
1415
|
|
1443
1416
|
## Development
|
1444
1417
|
|
1445
|
-
You can see all development of
|
1418
|
+
You can see all development of this library and associated GraphQL tooling in the web3.js repository on GitHub.
|
1446
1419
|
|
1447
|
-
https://github.com/solana-labs/solana-web3.js
|
1420
|
+
- https://github.com/solana-labs/solana-web3.js
|
1448
1421
|
|
1449
|
-
|
1422
|
+
You can follow along with program client generator development in the `@solana-program` org and the `@kinobi-so/kinobi` repository.
|
1450
1423
|
|
1451
|
-
|
1424
|
+
- https://github.com/solana-program/
|
1425
|
+
- https://github.com/kinobi-so/kinobi
|
1452
1426
|
|
1453
|
-
|
1427
|
+
Solana Labs develops these tools in public, as open source. We encourage any and all developers who would like to work on these tools to contribute to the codebase.
|
1454
1428
|
|
1455
1429
|
## Thank you
|
1456
1430
|
|
@@ -3950,7 +3950,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
3950
3950
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
3951
3951
|
...{
|
3952
3952
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
3953
|
-
"solana-client": (_a = `js/${"2.0.0-preview.3.
|
3953
|
+
"solana-client": (_a = `js/${"2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4"}`) != null ? _a : "UNKNOWN"
|
3954
3954
|
}
|
3955
3955
|
}
|
3956
3956
|
}),
|
@@ -2,7 +2,7 @@ this.globalThis = this.globalThis || {};
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
3
3
|
'use strict';
|
4
4
|
|
5
|
-
var Ti=Object.defineProperty;var mi=(e,t,n)=>t in e?Ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Et=(e,t,n)=>mi(e,typeof t!="symbol"?t+"":t,n);var St=1,Pe=2,Ot=3,Nt=4,Tt=5,mt=6,gt=7,pt=8,It=9,ro=-32700,oo=-32603,ao=-32602,io=-32601,so=-32600,gi=-32016,co=-32015,_o=-32014,pi=-32013,uo=-32012,Ii=-32011,lo=-32010,Ro=-32009,Ci=-32008,fo=-32007,Eo=-32006,hi=-32005,Ao=-32004,Li=-32003,At=-32002,So=-32001,Ct=28e5,ht=2800001,bi=2800002,Lt=2800003,bt=2800004,Dt=2800005,yt=2800006,xe=2800007,Ue=2800008,vt=2800009,wt=2800010,Pt=323e4,xt=32300001,Ut=3230002,Bt=3230003,Mt=3230004,Ft=361e4,zt=3610001,kt=3610002,Vt=3610003,Gt=3610004,Ht=3610005,Wt=3610006,$t=3611e3,Yt=3704e3,Xt=3704001,Kt=3704002,jt=3704003,qt=3704004,Jt=4128e3,Zt=4128001,Qt=4128002,Oo=4615e3,Di=4615001,yi=4615002,vi=4615003,wi=4615004,Pi=4615005,xi=4615006,Ui=4615007,Bi=4615008,Mi=4615009,Fi=4615010,zi=4615011,ki=4615012,Vi=4615013,Gi=4615014,Hi=4615015,Wi=4615016,$i=4615017,Yi=4615018,Xi=4615019,Ki=4615020,ji=4615021,qi=4615022,Ji=4615023,Zi=4615024,Qi=4615025,Be=4615026,es=4615027,ts=4615028,ns=4615029,rs=4615030,os=4615031,as=4615032,is=4615033,ss=4615034,cs=4615035,_s=4615036,us=4615037,ds=4615038,ls=4615039,Rs=4615040,fs=4615041,Es=4615042,As=4615043,Ss=4615044,No=4615045,Os=4615046,Ns=4615047,Ts=4615048,ms=4615049,gs=4615050,ps=4615051,Is=4615052,Cs=4615053,hs=4615054,en=5508e3,tn=5508001,nn=5508002,rn=5508003,on=5508004,an=5508005,sn=5508006,cn=5508007,_n=5508008,un=5508009,Me=5508010,Ls=5508011,dn=5663e3,Fe=5663001,ln=5663002,Rn=5663003,fn=5663004,En=5663005,An=5663006,Sn=5663007,On=5663008,Nn=5663009,bs=5663010,Ds=5663011,Tn=5663012,ys=5663013,vs=5663014,mn=5663015,gn=5663016,pn=5663017,ze=5663018,To=705e4,ws=7050001,Ps=7050002,xs=7050003,Us=7050004,Bs=7050005,Ms=7050006,Fs=7050007,zs=7050008,ks=7050009,Vs=7050010,Gs=7050011,Hs=7050012,Ws=7050013,$s=7050014,Ys=7050015,Xs=7050016,Ks=7050017,js=7050018,qs=7050019,Js=7050020,Zs=7050021,Qs=7050022,ec=7050023,tc=7050024,nc=7050025,rc=7050026,oc=7050027,ac=7050028,ic=7050029,mo=7050030,go=7050031,sc=7050032,cc=7050033,_c=7050034,po=7050035,uc=7050036,In=8078e3,Cn=8078001,hn=8078002,Ln=8078003,bn=8078004,Dn=8078005,yn=8078006,vn=8078007,wn=8078008,Pn=8078009,xn=8078010,Un=8078011,$=8078012,Oe=8078013,Bn=8078014,dc=8078015,lc=8078016,Mn=8078017,Fn=8078018,Rc=8078019,zn=8078020,kn=8078021,ke=8078022,Ne=81e5,Io=8100001,Vn=8100002,Gn=819e4,Hn=8190001,Wn=8190002,$n=8190003,Yn=8190004,Xn=99e5,Kn=9900001,jn=9900002,qn=9900003;function Co(e){return Array.isArray(e)?"%5B"+e.map(Co).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function fc([e,t]){return `${e}=${Co(t)}`}function Ec(e){let t=Object.entries(e).map(fc).join("&");return btoa(t)}function Ac(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Ec(t)}'`),`${n}\``}}function Ve(e,t){return e instanceof Error&&e.name==="SolanaError"?t!==void 0?e.context.__code===t:!0:!1}var u=class extends Error{constructor(...[t,n]){let r,o;if(n){let{cause:i,...s}=n;i&&(o={cause:i}),Object.keys(s).length>0&&(r=s);}let a=Ac(t,r);super(a,o);Et(this,"cause",this.cause);Et(this,"context");this.context={__code:t,...r},this.name="SolanaError";}};function se(...e){"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e);}function ho({errorCodeBaseOffset:e,getErrorContext:t,orderedErrorNames:n,rpcEnumError:r},o){let a,i;typeof r=="string"?a=r:(a=Object.keys(r)[0],i=r[a]);let s=n.indexOf(a),c=e+s,_=t(c,a,i),d=new u(c,_);return se(d,o),d}var Sc=["GenericError","InvalidArgument","InvalidInstructionData","InvalidAccountData","AccountDataTooSmall","InsufficientFunds","IncorrectProgramId","MissingRequiredSignature","AccountAlreadyInitialized","UninitializedAccount","UnbalancedInstruction","ModifiedProgramId","ExternalAccountLamportSpend","ExternalAccountDataModified","ReadonlyLamportChange","ReadonlyDataModified","DuplicateAccountIndex","ExecutableModified","RentEpochModified","NotEnoughAccountKeys","AccountDataSizeChanged","AccountNotExecutable","AccountBorrowFailed","AccountBorrowOutstanding","DuplicateAccountOutOfSync","Custom","InvalidError","ExecutableDataModified","ExecutableLamportChange","ExecutableAccountNotRentExempt","UnsupportedProgramId","CallDepth","MissingAccount","ReentrancyNotAllowed","MaxSeedLengthExceeded","InvalidSeeds","InvalidRealloc","ComputationalBudgetExceeded","PrivilegeEscalation","ProgramEnvironmentSetupFailure","ProgramFailedToComplete","ProgramFailedToCompile","Immutable","IncorrectAuthority","BorshIoError","AccountNotRentExempt","InvalidAccountOwner","ArithmeticOverflow","UnsupportedSysvar","IllegalOwner","MaxAccountsDataAllocationsExceeded","MaxAccountsExceeded","MaxInstructionTraceLengthExceeded","BuiltinProgramsMustConsumeComputeUnits"];function Lo(e,t){return ho({errorCodeBaseOffset:4615001,getErrorContext(n,r,o){return n===Oo?{errorName:r,index:e,...o!==void 0?{instructionErrorContext:o}:null}:n===Be?{code:o,index:e}:n===No?{encodedData:o,index:e}:{index:e}},orderedErrorNames:Sc,rpcEnumError:t},Lo)}var Oc=["AccountInUse","AccountLoadedTwice","AccountNotFound","ProgramAccountNotFound","InsufficientFundsForFee","InvalidAccountForFee","AlreadyProcessed","BlockhashNotFound","CallChainTooDeep","MissingSignatureForFee","InvalidAccountIndex","SignatureFailure","InvalidProgramForExecution","SanitizeFailure","ClusterMaintenance","AccountBorrowOutstanding","WouldExceedMaxBlockCostLimit","UnsupportedVersion","InvalidWritableAccount","WouldExceedMaxAccountCostLimit","WouldExceedAccountDataBlockLimit","TooManyAccountLocks","AddressLookupTableNotFound","InvalidAddressLookupTableOwner","InvalidAddressLookupTableData","InvalidAddressLookupTableIndex","InvalidRentPayingAccount","WouldExceedMaxVoteCostLimit","WouldExceedAccountDataTotalLimit","DuplicateInstruction","InsufficientFundsForRent","MaxLoadedAccountsDataSizeExceeded","InvalidLoadedAccountsDataSizeLimit","ResanitizationNeeded","ProgramExecutionTemporarilyRestricted","UnbalancedTransaction"];function Ge(e){return typeof e=="object"&&"InstructionError"in e?Lo(...e.InstructionError):ho({errorCodeBaseOffset:7050001,getErrorContext(t,n,r){if(t===To)return {errorName:n,...r!==void 0?{transactionErrorContext:r}:null};if(t===mo)return {index:r};if(t===go||t===po)return {accountIndex:r.account_index}},orderedErrorNames:Oc,rpcEnumError:e},Ge)}function Te({code:e,data:t,message:n}){let r;if(e===At){let{err:o,...a}=t,i=o?{cause:Ge(o)}:null;r=new u(At,{...a,...i});}else {let o;switch(e){case oo:case ao:case so:case io:case ro:case uo:case So:case Ao:case _o:case lo:case Ro:case fo:case Eo:case co:o={__serverMessage:n};break;default:typeof t=="object"&&!Array.isArray(t)&&(o=t);}r=new u(e,o);}return se(r,Te),r}var Hd=e=>{let t=e.filter(a=>a.length);if(t.length===0)return e.length?e[0]:new Uint8Array;if(t.length===1)return t[0];let n=t.reduce((a,i)=>a+i.length,0),r=new Uint8Array(n),o=0;return t.forEach(a=>{r.set(a,o),o+=a.length;}),r},Nc=(e,t)=>{if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n},Tc=(e,t)=>Nc(e.length<=t?e:e.slice(0,t),t);function ce(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?!1:t.every((o,a)=>o===r[a])}function V(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function O(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(V(t,e));return e.write(t,n,0),n}})}function T(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function mc(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0],encode:t=>{let n=new Uint8Array(V(t,e));return e.write(t,n,0),n}})}function m(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function q(e){if(!m(e))throw new u(hn)}function bo(e){return !m(e)}function Wd(e){if(!bo(e))throw new u(Ln)}function E(e,t){if(m(e)!==m(t))throw new u(bn);if(m(e)&&m(t)&&e.fixedSize!==t.fixedSize)throw new u(Dn,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!m(e)&&!m(t)&&e.maxSize!==t.maxSize)throw new u(yn,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return {...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function gc(e,t){let n=(r,o,a)=>{let i=e.encode(r);if(Do(i,t)>=0)throw new u(zn,{encodedBytes:i,hexEncodedBytes:He(i),hexSentinel:He(t),sentinel:t});return o.set(i,a),a+=i.length,o.set(t,a),a+=t.length,a};return m(e)?O({...e,fixedSize:e.fixedSize+t.length,write:n}):O({...e,...e.maxSize!=null?{maxSize:e.maxSize+t.length}:{},getSizeFromValue:r=>e.getSizeFromValue(r)+t.length,write:n})}function pc(e,t){let n=(r,o)=>{let a=o===0?r:r.slice(o),i=Do(a,t);if(i===-1)throw new u(kn,{decodedBytes:a,hexDecodedBytes:He(a),hexSentinel:He(t),sentinel:t});let s=a.slice(0,i);return [e.decode(s),o+s.length+t.length]};return m(e)?T({...e,fixedSize:e.fixedSize+t.length,read:n}):T({...e,...e.maxSize!=null?{maxSize:e.maxSize+t.length}:{},read:n})}function $d(e,t){return E(gc(e,t),pc(e,t))}function Do(e,t){return e.findIndex((n,r,o)=>t.length===1?n===t[0]:ce(o,t,r))}function He(e){return e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),"")}function yo(e,t,n=0){if(t.length-n<=0)throw new u(In,{codecDescription:e})}function _e(e,t,n,r=0){let o=n.length-r;if(o<t)throw new u(Cn,{bytesLength:o,codecDescription:e,expected:t})}function We(e,t,n){if(t<0||t>n)throw new u(Bn,{bytesLength:n,codecDescription:e,offset:t})}function Jn(e,t){var i,s;let n=(c,_,d)=>{let l=e.encode(c);return d=t.write(l.length,_,d),_.set(l,d),d+l.length};if(m(t)&&m(e))return O({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=m(t)?t.fixedSize:(i=t.maxSize)!=null?i:null,o=m(e)?e.fixedSize:(s=e.maxSize)!=null?s:null,a=r!==null&&o!==null?r+o:null;return O({...e,...a!==null?{maxSize:a}:{},getSizeFromValue:c=>{let _=V(c,e);return V(_,t)+_},write:n})}function Zn(e,t){var i,s;let n=(c,_)=>{let[d,l]=t.read(c,_),f=Number(d);return _=l,(_>0||c.length>f)&&(c=c.slice(_,_+f)),_e("addDecoderSizePrefix",f,c),[e.decode(c),_+f]};if(m(t)&&m(e))return T({...e,fixedSize:t.fixedSize+e.fixedSize,read:n});let r=m(t)?t.fixedSize:(i=t.maxSize)!=null?i:null,o=m(e)?e.fixedSize:(s=e.maxSize)!=null?s:null,a=r!==null&&o!==null?r+o:null;return T({...e,...a!==null?{maxSize:a}:{},read:n})}function Yd(e,t){return E(Jn(e,t),Zn(e,t))}function v(e,t){return O({fixedSize:t,write:(n,r,o)=>{let a=e.encode(n),i=a.length>t?a.slice(0,t):a;return r.set(i,o),o+t}})}function w(e,t){return T({fixedSize:t,read:(n,r)=>{_e("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),m(e)&&(n=Tc(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function Xd(e,t){return E(v(e,t),w(e,t))}function Qn(e,t){return O({...e,write:(n,r,o)=>{let a=_=>vo(_,r.length),i=t.preOffset?t.preOffset({bytes:r,preOffset:o,wrapBytes:a}):o;We("offsetEncoder",i,r.length);let s=e.write(n,r,i),c=t.postOffset?t.postOffset({bytes:r,newPreOffset:i,postOffset:s,preOffset:o,wrapBytes:a}):s;return We("offsetEncoder",c,r.length),c}})}function er(e,t){return T({...e,read:(n,r)=>{let o=_=>vo(_,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;We("offsetDecoder",a,n.length);let[i,s]=e.read(n,a),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:a,postOffset:s,preOffset:r,wrapBytes:o}):s;return We("offsetDecoder",c,n.length),[i,c]}})}function Kd(e,t){return E(Qn(e,t),er(e,t))}function vo(e,t){return t===0?0:(e%t+t)%t}function tr(e,t){if(m(e)){let n=t(e.fixedSize);if(n<0)throw new u(Oe,{bytesLength:n,codecDescription:"resizeEncoder"});return O({...e,fixedSize:n})}return O({...e,getSizeFromValue:n=>{let r=t(e.getSizeFromValue(n));if(r<0)throw new u(Oe,{bytesLength:r,codecDescription:"resizeEncoder"});return r}})}function nr(e,t){if(m(e)){let n=t(e.fixedSize);if(n<0)throw new u(Oe,{bytesLength:n,codecDescription:"resizeDecoder"});return T({...e,fixedSize:n})}return e}function jd(e,t){return E(tr(e,t),nr(e,t))}function Ic(e,t){return Qn(tr(e,n=>n+t),{preOffset:({preOffset:n})=>n+t})}function Cc(e,t){return Qn(tr(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function hc(e,t){return er(nr(e,n=>n+t),{preOffset:({preOffset:n})=>n+t})}function rr(e,t){return er(nr(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function qd(e,t){return E(Ic(e,t),hc(e,t))}function Jd(e,t){return E(Cc(e,t),rr(e,t))}function wo(e,t,n,r,o=0){for(;n<--r;){let a=e[n];t[n+o]=e[r],t[r+o]=a,n++;}n===r&&(t[n+o]=e[n]);}function Lc(e){return q(e),O({...e,write:(t,n,r)=>{let o=e.write(t,n,r);return wo(n,n,r,r+e.fixedSize),o}})}function bc(e){return q(e),T({...e,read:(t,n)=>{let r=t.slice();return wo(t,r,n,n+e.fixedSize),e.read(r,n)}})}function Zd(e){return E(Lc(e),bc(e))}function p(e,t){return O({...bo(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function I(e,t){return T({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function Qd(e,t,n){return mc({...p(e,t),read:n?I(e,n).read:e.read})}function Fo(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new u($,{alphabet:e,base:e.length,value:n})}var ar=e=>O({getSizeFromValue:t=>{let[n,r]=Po(t,e[0]);if(!r)return t.length;let o=xo(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Fo(e,t),t==="")return r;let[o,a]=Po(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=xo(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),ir=e=>T({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,_)=>c*256n+BigInt(_),0n),s=Dc(i,e);return [a+s,t.length]}}),zo=e=>E(ar(e),ir(e));function Po(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function xo(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Dc(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var sr="0123456789",rl=()=>ar(sr),ol=()=>ir(sr),al=()=>zo(sr),Uo={alphabet:"0123456789abcdef",base:16};function or(e){if(e>=48&&e<=57)return e-48;if(e>=65&&e<=70)return e-55;if(e>=97&&e<=102)return e-87}var yc=()=>O({getSizeFromValue:e=>Math.ceil(e.length/2),write(e,t,n){let r=e.length,o=r/2;if(r===1){let i=e.charCodeAt(0),s=or(i);if(s===void 0)throw new u($,{...Uo,value:e});return t.set([s],n),1+n}let a=new Uint8Array(o);for(let i=0,s=0;i<o;i++){let c=e.charCodeAt(s++),_=e.charCodeAt(s++),d=or(c),l=or(_);if(d===void 0||l===void 0&&!Number.isNaN(_))throw new u($,{...Uo,value:e});a[i]=Number.isNaN(_)?d:d<<4|(l!=null?l:0);}return t.set(a,n),a.length+n}}),vc=()=>T({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}}),il=()=>E(yc(),vc()),cr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Y=()=>ar(cr),J=()=>ir(cr),sl=()=>zo(cr),wc=(e,t)=>O({getSizeFromValue:n=>Math.floor(n.length*t/8),write(n,r,o){if(Fo(e,n),n==="")return o;let a=[...n].map(s=>e.indexOf(s)),i=ko(a,t,8,!1);return r.set(i,o),i.length+o}}),Pc=(e,t)=>T({read(n,r=0){let o=r===0?n:n.slice(r);return o.length===0?["",n.length]:[ko([...o],8,t,!0).map(i=>e[i]).join(""),n.length]}}),cl=(e,t)=>E(wc(e,t),Pc(e,t));function ko(e,t,n,r){let o=[],a=0,i=0,s=(1<<n)-1;for(let c of e)for(a=a<<t|c,i+=t;i>=n;)i-=n,o.push(a>>i&s);return r&&i>0&&o.push(a<<n-i&s),o}var Bo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",me=()=>O({getSizeFromValue:e=>{try{return atob(e).length}catch{throw new u($,{alphabet:Bo,base:64,value:e})}},write(e,t,n){try{let r=atob(e).split("").map(o=>o.charCodeAt(0));return t.set(r,n),r.length+n}catch{throw new u($,{alphabet:Bo,base:64,value:e})}}}),_r=()=>T({read(e,t=0){let n=e.slice(t);return [btoa(String.fromCharCode(...n)),e.length]}}),_l=()=>E(me(),_r()),xc=e=>e.replace(/\u0000/g,""),ul=(e,t)=>e.padEnd(t,"\0"),Uc=globalThis.TextDecoder,Mo=globalThis.TextEncoder,Bc=()=>{let e;return O({getSizeFromValue:t=>(e||(e=new Mo)).encode(t).length,write:(t,n,r)=>{let o=(e||(e=new Mo)).encode(t);return n.set(o,r),r+o.length}})},Mc=()=>{let e;return T({read(t,n){let r=(e||(e=new Uc)).decode(t.slice(n));return [xc(r),t.length]}})},dl=()=>E(Bc(),Mc());var El=128;function Al(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new u(Ut,{address:e.address})}}function Vo(e){return !("exists"in e)||"exists"in e&&e.exists}function Sl(e){if(Vo(e)&&e.data instanceof Uint8Array)throw new u(Bt,{address:e.address})}function Go(e){let t=e.filter(n=>Vo(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new u(Mt,{addresses:n})}}function $e(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=me().encode(t.data[0]);return Object.freeze({...ur(t),address:e,data:n,exists:!0})}function Ol(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=Y().encode(typeof t.data=="string"?t.data:t.data[0]);return Object.freeze({...ur(t),address:e,data:n,exists:!0})}function Ho(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=t.data.parsed.info;return Object.freeze({...ur(t),address:e,data:n,exists:!0})}function ur(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner})}async function Nl(e,t,n={}){let{abortSignal:r,...o}=n,a=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return $e(t,a.value)}async function Tl(e,t,n={}){let{abortSignal:r,...o}=n,{value:a}=await e.getAccountInfo(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r});return a&&typeof a=="object"&&"parsed"in a.data?Ho(t,a):$e(t,a)}async function ml(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"base64"}).send({abortSignal:r})).value.map((i,s)=>$e(t[s],i))}async function Wo(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((i,s)=>i&&typeof i=="object"&&"parsed"in i.data?Ho(t[s],i):$e(t[s],i))}function gl(e){if(!e.exists)throw new u(Pt,{address:e.address})}function $o(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new u(xt,{addresses:n})}}function ge(){if(!globalThis.isSecureContext)throw new u(Ft)}var oe;async function Fc(e){return oe===void 0&&(oe=new Promise(t=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{t(oe=!1);}).then(()=>{t(oe=!0);});})),typeof oe=="boolean"?oe:await oe}function Yo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.digest)!="function")throw new u(zt)}async function Xo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.generateKey)!="function")throw new u(Gt);if(!await Fc(globalThis.crypto.subtle))throw new u(kt)}function Ko(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.exportKey)!="function")throw new u(Vt)}function jo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.sign)!="function")throw new u(Ht)}function qo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.verify)!="function")throw new u(Wt)}function Jo(){if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function")throw new u($t)}var dr,lr;function Rr(){return dr||(dr=Y()),dr}function zc(){return lr||(lr=J()),lr}function fr(e){return !(e.length<32||e.length>44||Rr().encode(e).byteLength!==32)}function pe(e){if(e.length<32||e.length>44)throw new u(ht,{actualLength:e.length});let r=Rr().encode(e).byteLength;if(r!==32)throw new u(Ct,{actualLength:r})}function kc(e){return pe(e),e}function Ke(){return p(v(Rr(),32),e=>kc(e))}function ae(){return w(zc(),32)}function ea(){return E(Ke(),ae())}function je(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var Vc=37095705934669439343138083508754565189542113879843219016388785533085940283555n,D=57896044618658097711785492504343953926634992332820282019728792003956564819949n,Zo=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function x(e){let t=e%D;return t>=0n?t:D+t}function G(e,t){let n=e;for(;t-- >0n;)n*=n,n%=D;return n}function Gc(e){let n=e*e%D*e%D,r=G(n,2n)*n%D,o=G(r,1n)*e%D,a=G(o,5n)*o%D,i=G(a,10n)*a%D,s=G(i,20n)*i%D,c=G(s,40n)*s%D,_=G(c,80n)*c%D,d=G(_,80n)*c%D,l=G(d,10n)*a%D;return G(l,2n)*e%D}function Hc(e,t){let n=x(t*t*t),r=x(n*n*t),o=Gc(e*r),a=x(e*n*o),i=x(t*a*a),s=a,c=x(a*Zo),_=i===e,d=i===x(-e),l=i===x(-e*Zo);return _&&(a=s),(d||l)&&(a=c),(x(a)&1n)===1n&&(a=x(-a)),!_&&!d?null:a}function Wc(e,t){let n=x(e*e),r=x(n-1n),o=x(Vc*n+1n),a=Hc(r,o);if(a===null)return !1;let i=(t&128)!==0;return !(a===0n&&i)}function $c(e){let t=e.toString(16);return t.length===1?`0${t}`:t}function Yc(e){let n=`0x${e.reduce((r,o,a)=>`${$c(a===31?o&-129:o)}${r}`,"")}`;return BigInt(n)}function Xc(e){if(e.byteLength!==32)return !1;let t=Yc(e);return Wc(t,e[31])}function yl(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"&&e[1]>=0&&e[1]<=255&&fr(e[0])}function vl(e){if(!(Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"))throw new u(bt);if(e[1]<0||e[1]>255)throw new u(Dt,{bump:e[1]});pe(e[0]);}var Xe=32,Qo=16,Ye=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function Kc({programAddress:e,seeds:t}){if(Yo(),t.length>Qo)throw new u(yt,{actual:t.length,maxSeeds:Qo});let n,r=t.reduce((c,_,d)=>{let l=typeof _=="string"?(n||(n=new TextEncoder)).encode(_):_;if(l.byteLength>Xe)throw new u(xe,{actual:l.byteLength,index:d,maxSeedLength:Xe});return c.push(...l),c},[]),o=ea(),a=o.encode(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...r,...a,...Ye])),s=new Uint8Array(i);if(Xc(s))throw new u(Ue);return o.decode(s)}async function wl({programAddress:e,seeds:t}){let n=255;for(;n>0;)try{return [await Kc({programAddress:e,seeds:[...t,new Uint8Array([n])]}),n]}catch(r){if(Ve(r,Ue))n--;else throw r}throw new u(vt)}async function Pl({baseAddress:e,programAddress:t,seed:n}){let{encode:r,decode:o}=ea(),a=typeof n=="string"?new TextEncoder().encode(n):n;if(a.byteLength>Xe)throw new u(xe,{actual:a.byteLength,index:0,maxSeedLength:Xe});let i=r(t);if(i.length>=Ye.length&&i.slice(-Ye.length).every((_,d)=>_===Ye[d]))throw new u(wt);let s=await crypto.subtle.digest("SHA-256",new Uint8Array([...r(e),...a,...i])),c=new Uint8Array(s);return o(c)}async function qe(e){if(Ko(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new u(Lt);let t=await crypto.subtle.exportKey("raw",e);return ae().decode(new Uint8Array(t))}function ta(e,t,n,r){if(r<t||r>n)throw new u(Un,{codecDescription:e,max:n,min:t,value:r})}var jc=(e=>(e[e.Little=0]="Little",e[e.Big=1]="Big",e))(jc||{});function na(e){return (e==null?void 0:e.endian)!==1}function U(e){return O({fixedSize:e.size,write(t,n,r){e.range&&ta(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,na(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function B(e){return T({fixedSize:e.size,read(t,n=0){yo(e.name,t,n),_e(e.name,e.size,t,n);let r=new DataView(qc(t,n,e.size));return [e.get(r,na(e.config)),n+e.size]}})}function qc(e,t,n){let r=e.byteOffset+(t!=null?t:0),o=n!=null?n:e.byteLength;return e.buffer.slice(r,r+o)}var Jc=(e={})=>U({config:e,name:"f32",set:(t,n,r)=>t.setFloat32(0,Number(n),r),size:4}),Zc=(e={})=>B({config:e,get:(t,n)=>t.getFloat32(0,n),name:"f32",size:4}),Ml=(e={})=>E(Jc(e),Zc(e)),Qc=(e={})=>U({config:e,name:"f64",set:(t,n,r)=>t.setFloat64(0,Number(n),r),size:8}),e_=(e={})=>B({config:e,get:(t,n)=>t.getFloat64(0,n),name:"f64",size:8}),Fl=(e={})=>E(Qc(e),e_(e)),t_=(e={})=>U({config:e,name:"i128",range:[-BigInt("0x7fffffffffffffffffffffffffffffff")-1n,BigInt("0x7fffffffffffffffffffffffffffffff")],set:(t,n,r)=>{let o=r?8:0,a=r?0:8,i=0xffffffffffffffffn;t.setBigInt64(o,BigInt(n)>>64n,r),t.setBigUint64(a,BigInt(n)&i,r);},size:16}),n_=(e={})=>B({config:e,get:(t,n)=>{let r=n?8:0,o=n?0:8,a=t.getBigInt64(r,n),i=t.getBigUint64(o,n);return (a<<64n)+i},name:"i128",size:16}),zl=(e={})=>E(t_(e),n_(e)),r_=(e={})=>U({config:e,name:"i16",range:[-+"0x7fff"-1,+"0x7fff"],set:(t,n,r)=>t.setInt16(0,Number(n),r),size:2}),o_=(e={})=>B({config:e,get:(t,n)=>t.getInt16(0,n),name:"i16",size:2}),kl=(e={})=>E(r_(e),o_(e)),a_=(e={})=>U({config:e,name:"i32",range:[-+"0x7fffffff"-1,+"0x7fffffff"],set:(t,n,r)=>t.setInt32(0,Number(n),r),size:4}),i_=(e={})=>B({config:e,get:(t,n)=>t.getInt32(0,n),name:"i32",size:4}),Vl=(e={})=>E(a_(e),i_(e)),s_=(e={})=>U({config:e,name:"i64",range:[-BigInt("0x7fffffffffffffff")-1n,BigInt("0x7fffffffffffffff")],set:(t,n,r)=>t.setBigInt64(0,BigInt(n),r),size:8}),c_=(e={})=>B({config:e,get:(t,n)=>t.getBigInt64(0,n),name:"i64",size:8}),Gl=(e={})=>E(s_(e),c_(e)),__=()=>U({name:"i8",range:[-+"0x7f"-1,+"0x7f"],set:(e,t)=>e.setInt8(0,Number(t)),size:1}),u_=()=>B({get:e=>e.getInt8(0),name:"i8",size:1}),Hl=()=>E(__(),u_()),k=()=>O({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{ta("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let a=Number(e)>>o*7;if(a===0)break;let i=127&a;r[o]=i,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}}),M=()=>T({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,a=e[t+o],i=127&a;if(n|=i<<o*7,!(a&128))break}return [n,t+r]}}),Wl=()=>E(k(),M()),d_=(e={})=>U({config:e,name:"u128",range:[0n,BigInt("0xffffffffffffffffffffffffffffffff")],set:(t,n,r)=>{let o=r?8:0,a=r?0:8,i=0xffffffffffffffffn;t.setBigUint64(o,BigInt(n)>>64n,r),t.setBigUint64(a,BigInt(n)&i,r);},size:16}),l_=(e={})=>B({config:e,get:(t,n)=>{let r=n?8:0,o=n?0:8,a=t.getBigUint64(r,n),i=t.getBigUint64(o,n);return (a<<64n)+i},name:"u128",size:16}),$l=(e={})=>E(d_(e),l_(e)),R_=(e={})=>U({config:e,name:"u16",range:[0,+"0xffff"],set:(t,n,r)=>t.setUint16(0,Number(n),r),size:2}),f_=(e={})=>B({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2}),Yl=(e={})=>E(R_(e),f_(e)),Ie=(e={})=>U({config:e,name:"u32",range:[0,+"0xffffffff"],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Er=(e={})=>B({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4}),Xl=(e={})=>E(Ie(e),Er(e)),Ar=(e={})=>U({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),Sr=(e={})=>B({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8}),Kl=(e={})=>E(Ar(e),Sr(e)),y=()=>U({name:"u8",range:[0,+"0xff"],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),b=()=>B({get:e=>e.getUint8(0),name:"u8",size:1}),jl=()=>E(y(),b());function ra(e,t,n){if(t!==n)throw new u(vn,{actual:n,codecDescription:e,expected:t})}function E_(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function ee(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function ue(e){return m(e)?e.fixedSize:null}function ie(e){var t;return m(e)?e.fixedSize:(t=e.maxSize)!=null?t:null}function z(e,t={}){var a,i;let n=(a=t.size)!=null?a:Ie(),r=Je(n,ue(e)),o=(i=Je(n,ie(e)))!=null?i:void 0;return O({...r!==null?{fixedSize:r}:{getSizeFromValue:s=>(typeof n=="object"?V(s.length,n):0)+[...s].reduce((_,d)=>_+V(d,e),0),maxSize:o},write:(s,c,_)=>(typeof n=="number"&&ra("array",n,s.length),typeof n=="object"&&(_=n.write(s.length,c,_)),s.forEach(d=>{_=e.write(d,c,_);}),_)})}function P(e,t={}){var i,s;let n=(i=t.size)!=null?i:Er(),r=ue(e),o=Je(n,r),a=(s=Je(n,ie(e)))!=null?s:void 0;return T({...o!==null?{fixedSize:o}:{maxSize:a},read:(c,_)=>{let d=[];if(typeof n=="object"&&c.slice(_).length===0)return [d,_];if(n==="remainder"){for(;_<c.length;){let[N,S]=e.read(c,_);_=S,d.push(N);}return [d,_]}let[l,f]=typeof n=="number"?[n,_]:n.read(c,_);_=f;for(let N=0;N<l;N+=1){let[S,A]=e.read(c,_);_=A,d.push(S);}return [d,_]}})}function eR(e,t={}){return E(z(e,t),P(e,t))}function Je(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function A_(e,t={}){var o;let r=(o=(typeof t=="boolean"?{backward:t}:t).backward)!=null?o:!1;return O({fixedSize:e,write(a,i,s){var _;let c=[];for(let d=0;d<e;d+=1){let l=0;for(let f=0;f<8;f+=1){let N=Number((_=a[d*8+f])!=null?_:0);l|=N<<(r?f:7-f);}r?c.unshift(l):c.push(l);}return i.set(c,s),e}})}function S_(e,t={}){var o;let r=(o=(typeof t=="boolean"?{backward:t}:t).backward)!=null?o:!1;return T({fixedSize:e,read(a,i){_e("bitArray",e,a,i);let s=[],c=a.slice(i,i+e);return c=r?c.reverse():c,c.forEach(_=>{for(let d=0;d<8;d+=1)r?(s.push(!!(_&1)),_>>=1):(s.push(!!(_&128)),_<<=1);}),[s,i+e]}})}function tR(e,t={}){return E(A_(e,t),S_(e,t))}function Ze(e={}){var t;return p((t=e.size)!=null?t:y(),n=>n?1:0)}function Qe(e={}){var t;return I((t=e.size)!=null?t:b(),n=>Number(n)===1)}function nR(e={}){return E(Ze(e),Qe(e))}function de(){return O({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}function le(){return T({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function rR(){return E(de(),le())}var O_=()=>T({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function et(e){return O({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function tt(e){return T({fixedSize:e.length,read:(t,n)=>{let r=O_();if(!ce(t,e,n))throw new u(Fn,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function oR(e){return E(et(e),tt(e))}function H(e){var r;let t=ee(e.map(ue)),n=(r=ee(e.map(ie)))!=null?r:void 0;return O({...t===null?{getSizeFromValue:o=>e.map((a,i)=>V(o[i],a)).reduce((a,i)=>a+i,0),maxSize:n}:{fixedSize:t},write:(o,a,i)=>(ra("tuple",e.length,o.length),e.forEach((s,c)=>{i=s.write(o[c],a,i);}),i)})}function F(e){var r;let t=ee(e.map(ue)),n=(r=ee(e.map(ie)))!=null?r:void 0;return T({...t===null?{maxSize:n}:{fixedSize:t},read:(o,a)=>{let i=[];return e.forEach(s=>{let[c,_]=s.read(o,a);i.push(c),a=_;}),[i,a]}})}function aR(e){return E(H(e),F(e))}function Ce(e,t){let n=oa(e),r=(a,i,s)=>{let c=t(a);return Or(e,c),e[c].write(a,i,s)};if(n!==null)return O({fixedSize:n,write:r});let o=aa(e);return O({...o!==null?{maxSize:o}:{},getSizeFromValue:a=>{let i=t(a);return Or(e,i),V(a,e[i])},write:r})}function he(e,t){let n=oa(e),r=(a,i)=>{let s=t(a,i);return Or(e,s),e[s].read(a,i)};if(n!==null)return T({fixedSize:n,read:r});let o=aa(e);return T({...o!==null?{maxSize:o}:{},read:r})}function iR(e,t,n){return E(Ce(e,t),he(e,n))}function Or(e,t){if(typeof e[t]>"u")throw new u(Mn,{maxRange:e.length-1,minRange:0,variant:t})}function oa(e){if(e.length===0)return 0;if(!m(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>m(r)&&r.fixedSize===t)?t:null}function aa(e){return E_(e.map(t=>ie(t)))}function ia(e,t={}){var o,a;let n=(o=t.discriminator)!=null?o:"__kind",r=(a=t.size)!=null?a:y();return Ce(e.map(([,i],s)=>p(H([r,i]),c=>[s,c])),i=>T_(e,i[n]))}function sa(e,t={}){var o,a;let n=(o=t.discriminator)!=null?o:"__kind",r=(a=t.size)!=null?a:b();return he(e.map(([i,s])=>I(F([r,s]),([,c])=>({[n]:i,...c}))),(i,s)=>Number(r.read(i,s)[0]))}function N_(e,t={}){return E(ia(e,t),sa(e,t))}function T_(e,t){let n=e.findIndex(([r])=>t===r);if(n<0)throw new u(Pn,{value:t,variants:e.map(([r])=>r)});return n}var sR=ia,cR=sa,_R=N_;function ca(e){let t=[...new Set(Object.values(e).filter(i=>typeof i=="number"))].sort(),n=Object.fromEntries(Object.entries(e).slice(t.length)),r=Object.keys(n),o=Object.values(n),a=[...new Set([...r,...o.filter(i=>typeof i=="string")])];return {enumKeys:r,enumRecord:n,enumValues:o,numericalValues:t,stringValues:a}}function m_({enumKeys:e,enumValues:t,variant:n}){let r=_a(t,o=>o===n);return r>=0?r:e.findIndex(o=>o===n)}function g_({discriminator:e,enumKeys:t,enumValues:n,useValuesAsDiscriminators:r}){return r?_a(n,o=>o===e):e>=0&&e<t.length?e:-1}function _a(e,t){let n=e.length;for(;n--;)if(t(e[n],n,e))return n;return -1}function ua(e){if(e.length===0)return "";let t=[e[0],e[0]],n=[];for(let r=1;r<e.length;r++){let o=e[r];t[1]+1===o?t[1]=o:(n.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),t=[o,o]);}return n.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),n.join(", ")}function da(e,t={}){var c,_;let n=(c=t.size)!=null?c:y(),r=(_=t.useValuesAsDiscriminators)!=null?_:!1,{enumKeys:o,enumValues:a,numericalValues:i,stringValues:s}=ca(e);if(r&&a.some(d=>typeof d=="string"))throw new u(ke,{stringValues:a.filter(d=>typeof d=="string")});return p(n,d=>{let l=m_({enumKeys:o,enumValues:a,variant:d});if(l<0)throw new u(xn,{formattedNumericalValues:ua(i),numericalValues:i,stringValues:s,variant:d});return r?a[l]:l})}function la(e,t={}){var s,c;let n=(s=t.size)!=null?s:b(),r=(c=t.useValuesAsDiscriminators)!=null?c:!1,{enumKeys:o,enumValues:a,numericalValues:i}=ca(e);if(r&&a.some(_=>typeof _=="string"))throw new u(ke,{stringValues:a.filter(_=>typeof _=="string")});return I(n,_=>{let d=Number(_),l=g_({discriminator:d,enumKeys:o,enumValues:a,useValuesAsDiscriminators:r});if(l<0){let f=r?i:[...Array(o.length).keys()];throw new u(wn,{discriminator:d,formattedValidDiscriminators:ua(f),validDiscriminators:f})}return a[l]})}function p_(e,t={}){return E(da(e,t),la(e,t))}var uR=da,dR=la,lR=p_;function I_(e,t){return p(H([...t,e]),n=>[...t.map(()=>{}),n])}function C_(e,t){return I(F([...t,e]),n=>n[n.length-1])}function RR(e,t){return E(I_(e,t),C_(e,t))}function h_(e,t){return p(H([e,...t]),n=>[n,...t.map(()=>{})])}function L_(e,t){return I(F([e,...t]),n=>n[0])}function fR(e,t){return E(h_(e,t),L_(e,t))}function b_(e,t,n={}){return p(z(H([e,t]),n),r=>[...r.entries()])}function D_(e,t,n={}){return I(P(F([e,t]),n),r=>new Map(r))}function ER(e,t,n={}){return E(b_(e,t,n),D_(e,t,n))}function Z(){return O({fixedSize:0,write:(e,t,n)=>n})}function Q(){return T({fixedSize:0,read:(e,t)=>[void 0,t]})}function AR(){return E(Z(),Q())}function y_(e,t={}){let n=(()=>{var o;return t.prefix===null?p(Z(),a=>{}):Ze({size:(o=t.prefix)!=null?o:y()})})(),r=t.noneValue==="zeroes"?(q(e),v(Z(),e.fixedSize)):t.noneValue?et(t.noneValue):Z();return Ce([p(H([n,r]),o=>[!1,void 0]),p(H([n,e]),o=>[!0,o])],o=>+(o!==null))}function v_(e,t={}){let n=(()=>{var o;return t.prefix===null?I(Q(),()=>!1):Qe({size:(o=t.prefix)!=null?o:b()})})(),r=t.noneValue==="zeroes"?(q(e),w(Q(),e.fixedSize)):t.noneValue?tt(t.noneValue):Q();return he([I(F([n,r]),()=>null),I(F([n,e]),([,o])=>o)],(o,a)=>{if(t.prefix===null&&!t.noneValue)return +(a<o.length);if(t.prefix===null&&t.noneValue!=null){let i=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return ce(o,i,a)?0:1}return Number(n.read(o,a)[0])})}function SR(e,t={}){return E(y_(e,t),v_(e,t))}function w_(e,t={}){return p(z(e,t),n=>[...n])}function P_(e,t={}){return I(P(e,t),n=>new Set(n))}function OR(e,t={}){return E(w_(e,t),P_(e,t))}function X(e){var o;let t=e.map(([,a])=>a),n=ee(t.map(ue)),r=(o=ee(t.map(ie)))!=null?o:void 0;return O({...n===null?{getSizeFromValue:a=>e.map(([i,s])=>V(a[i],s)).reduce((i,s)=>i+s,0),maxSize:r}:{fixedSize:n},write:(a,i,s)=>(e.forEach(([c,_])=>{s=_.write(a[c],i,s);}),s)})}function te(e){var o;let t=e.map(([,a])=>a),n=ee(t.map(ue)),r=(o=ee(t.map(ie)))!=null?o:void 0;return T({...n===null?{maxSize:r}:{fixedSize:n},read:(a,i)=>{let s={};return e.forEach(([c,_])=>{let[d,l]=_.read(a,i);i=l,s[c]=d;}),[s,i]}})}function NR(e){return E(X(e),te(e))}var fa=e=>({__option:"Some",value:e}),Ea=()=>({__option:"None"}),Nr=e=>!!(e&&typeof e=="object"&&"__option"in e&&(e.__option==="Some"&&"value"in e||e.__option==="None")),nt=e=>e.__option==="Some",IR=e=>e.__option==="None";function CR(e,t){return nt(e)?e.value:t?t():null}var x_=e=>e!==null?fa(e):Ea();function U_(e,t={}){let n=(()=>{var o;return t.prefix===null?p(Z(),a=>{}):Ze({size:(o=t.prefix)!=null?o:y()})})(),r=t.noneValue==="zeroes"?(q(e),v(Z(),e.fixedSize)):t.noneValue?et(t.noneValue):Z();return Ce([p(H([n,r]),o=>[!1,void 0]),p(H([n,e]),o=>[!0,Nr(o)&&nt(o)?o.value:o])],o=>{let a=Nr(o)?o:x_(o);return Number(nt(a))})}function B_(e,t={}){let n=(()=>{var o;return t.prefix===null?I(Q(),()=>!1):Qe({size:(o=t.prefix)!=null?o:b()})})(),r=t.noneValue==="zeroes"?(q(e),w(Q(),e.fixedSize)):t.noneValue?tt(t.noneValue):Q();return he([I(F([n,r]),()=>Ea()),I(F([n,e]),([,o])=>fa(o))],(o,a)=>{if(t.prefix===null&&!t.noneValue)return +(a<o.length);if(t.prefix===null&&t.noneValue!=null){let i=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return ce(o,i,a)?0:1}return Number(n.read(o,a)[0])})}function hR(e,t={}){return E(U_(e,t),B_(e,t))}function Ra(e,t){if(!e||ArrayBuffer.isView(e))return e;let n=r=>t?Ra(r,t):Ra(r);return Nr(e)?nt(e)?n(e.value):t?t():null:Array.isArray(e)?e.map(n):typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,n(o)])):e}function K(e,...t){return t.reduce((n,r)=>r(n),e)}function Aa(e,t){return e.programAddress===t}function yR(e,t){if(e.programAddress!==t)throw new u(Qt,{actualProgramAddress:e.programAddress,expectedProgramAddress:t})}function vR(e){return e.accounts!==void 0}function wR(e){if(e.accounts===void 0)throw new u(Jt,{data:e.data,programAddress:e.programAddress})}function Sa(e){return e.data!==void 0}function PR(e){var t;if(e.data===void 0)throw new u(Zt,{accountAddresses:(t=e.accounts)==null?void 0:t.map(n=>n.address),programAddress:e.programAddress})}var L=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(L||{}),Oa=2,Tr=1;function xR(e){return e&~Oa}function UR(e){return e&~Tr}function W(e){return e>=2}function Re(e){return (e&Tr)!==0}function mr(e,t){return e|t}function BR(e){return e|Oa}function MR(e){return e|Tr}function M_(e){return new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32,...e])}async function F_(e,t){let n=e.byteLength;if(n!==32)throw new u(Xt,{actualLength:n});let r=M_(e);return await crypto.subtle.importKey("pkcs8",r,"Ed25519",t!=null?t:!1,["sign"])}var fe;function z_(e){if(fe||(fe=Y()),e.length<64||e.length>88)throw new u(jt,{actualLength:e.length});let n=fe.encode(e).byteLength;if(n!==64)throw new u(Kt,{actualLength:n})}function GR(e){return fe||(fe=Y()),!(e.length<64||e.length>88||fe.encode(e).byteLength!==64)}async function Le(e,t){jo();let n=await crypto.subtle.sign("Ed25519",e,t);return new Uint8Array(n)}function HR(e){return z_(e),e}async function k_(e,t,n){return qo(),await crypto.subtle.verify("Ed25519",e,t,n)}async function Na(){return await Xo(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function Ta(e,t){if(Jo(),e.byteLength!==64)throw new u(Yt,{byteLength:e.byteLength});let[n,r]=await Promise.all([crypto.subtle.importKey("raw",e.slice(32),"Ed25519",!0,["verify"]),F_(e.slice(0,32),t)]),o=new Uint8Array(32);crypto.getRandomValues(o);let a=await Le(r,o);if(!await k_(n,a,o))throw new u(qt);return {privateKey:r,publicKey:n}}function YR(e,t,n,r){var a;if(!Ve(e,Be))return !1;let o=(a=t.instructions[e.context.index])==null?void 0:a.programAddress;return !o||o!==n?!1:typeof r>"u"||e.context.code===r}var gr=0;function V_(){let e=gr;return gr=(gr+1)%Number.MAX_SAFE_INTEGER,e}function be(e,t){return {id:V_(),jsonrpc:"2.0",method:e,params:t}}function ma(e){return G_(e)}function G_(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(t,n,r){return function(...o){let a=n.toString(),i=Reflect.get(t,a,r),s=i?i(...o):{methodName:a,params:o};return H_(e,s)}}})}function H_(e,t){return {async send(n){let{methodName:r,params:o,responseTransformer:a}=t,i=be(r,o),s=await e.transport({payload:i,signal:n==null?void 0:n.abortSignal});return a?a(s,r):s}}}function ga(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...t){let[n,r]=t,o=r.toString();return function(...a){let i=e!=null&&e.parametersTransformer?e==null?void 0:e.parametersTransformer(a,o):a,s=e!=null&&e.responseTransformer?e==null?void 0:e.responseTransformer:c=>c;return {methodName:o,params:i,responseTransformer:s}}}})}function W_({commitmentPropertyName:e,params:t,optionsObjectPositionInParams:n,overrideCommitment:r}){let o=t[n];if(o===void 0||o&&typeof o=="object"&&!Array.isArray(o)){if(o&&e in o){if(!o[e]||o[e]==="finalized"){let a=[...t],{[e]:i,...s}=o;return Object.keys(s).length>0?a[n]=s:n===a.length-1?a.length--:a[n]=void 0,a}}else if(r!=="finalized"){let a=[...t];return a[n]={...o,[e]:r},a}}return t}function $_(e){return typeof e=="bigint"?Number(e):e}function Y_(e){return (t,{keyPath:n})=>(typeof t=="bigint"&&e&&(t>Number.MAX_SAFE_INTEGER||t<-Number.MAX_SAFE_INTEGER)&&e(n,t),t)}var X_={accountNotifications:1,blockNotifications:1,getAccountInfo:1,getBalance:1,getBlock:1,getBlockHeight:0,getBlockProduction:0,getBlocks:2,getBlocksWithLimit:2,getConfirmedBlock:1,getConfirmedBlocks:1,getConfirmedBlocksWithLimit:2,getConfirmedSignaturesForAddress2:1,getConfirmedTransaction:1,getEpochInfo:0,getFeeCalculatorForBlockhash:1,getFeeForMessage:1,getFees:1,getInflationGovernor:0,getInflationReward:1,getLargestAccounts:0,getLatestBlockhash:0,getLeaderSchedule:1,getMinimumBalanceForRentExemption:1,getMultipleAccounts:1,getProgramAccounts:1,getRecentBlockhash:1,getSignaturesForAddress:1,getSlot:0,getSlotLeader:0,getStakeActivation:1,getStakeMinimumDelegation:0,getSupply:0,getTokenAccountBalance:1,getTokenAccountsByDelegate:2,getTokenAccountsByOwner:2,getTokenLargestAccounts:1,getTokenSupply:1,getTransaction:1,getTransactionCount:0,getVoteAccounts:0,isBlockhashValid:1,logsNotifications:1,programNotifications:1,requestAirdrop:2,sendTransaction:1,signatureNotifications:1,simulateTransaction:1},R={};function pa(e){return function t(n,r){if(Array.isArray(n))return n.map((o,a)=>{let i={...r,keyPath:[...r.keyPath,a]};return t(o,i)});if(typeof n=="object"&&n!==null){let o={};for(let a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;let i={...r,keyPath:[...r.keyPath,a]};o[a]=t(n[a],i);}return o}else return e.reduce((o,a)=>a(o,r),n)}}function rt(e){let t=e==null?void 0:e.defaultCommitment,n=e==null?void 0:e.onIntegerOverflow;return (r,o)=>{let s=pa([...n?[Y_((..._)=>n(o,..._))]:[],$_])(r,{keyPath:[]});if(!Array.isArray(s))return s;let c=X_[o];return c==null?s:K(s,_=>W_({commitmentPropertyName:o==="sendTransaction"?"preflightCommitment":"commitment",optionsObjectPositionInParams:c,overrideCommitment:t,params:_}),_=>o==="sendTransaction"?K_(_):_)}}function K_(e){var t;return ((t=e[1])==null?void 0:t.skipPreflight)!==!0?e:[e[0],{...e[1],preflightCommitment:"processed"},...e.slice(2)]}function j_(e,t){return t.some(n=>{if(n.length!==e.length)return !1;for(let r=e.length-1;r>=0;r--){let o=e[r],a=n[r];if(a!==o&&(a!==R||typeof o!="number"))return !1}return !0})}function q_(e){return function(n,{keyPath:r}){return typeof n=="number"&&Number.isInteger(n)&&!j_(r,e)?BigInt(n):n}}function ot(e){return (t,n)=>{if("error"in t)throw Te(t.error);let r=e!=null&&e.allowedNumericKeyPaths&&n?e.allowedNumericKeyPaths[n]:void 0,o=pa([q_(r!=null?r:[])]),a={keyPath:[]};return o(t.result,a)}}var at=[["data","parsed","info","tokenAmount","decimals"],["data","parsed","info","tokenAmount","uiAmount"],["data","parsed","info","rentExemptReserve","decimals"],["data","parsed","info","rentExemptReserve","uiAmount"],["data","parsed","info","delegatedAmount","decimals"],["data","parsed","info","delegatedAmount","uiAmount"],["data","parsed","info","extensions",R,"state","olderTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",R,"state","newerTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",R,"state","preUpdateAverageRate"],["data","parsed","info","extensions",R,"state","currentRate"]],ne=[...at,["data","parsed","info","lastExtendedSlotStartIndex"],["data","parsed","info","slashPenalty"],["data","parsed","info","warmupCooldownRate"],["data","parsed","info","decimals"],["data","parsed","info","numRequiredSigners"],["data","parsed","info","numValidSigners"],["data","parsed","info","stake","delegation","warmupCooldownRate"],["data","parsed","info","exemptionThreshold"],["data","parsed","info","burnPercent"],["data","parsed","info","commission"],["data","parsed","info","votes",R,"confirmationCount"]],it=[["index"],["instructions",R,"accounts",R],["instructions",R,"programIdIndex"],["instructions",R,"stackHeight"]],pr=[["addressTableLookups",R,"writableIndexes",R],["addressTableLookups",R,"readonlyIndexes",R],["header","numReadonlySignedAccounts"],["header","numReadonlyUnsignedAccounts"],["header","numRequiredSignatures"],["instructions",R,"accounts",R],["instructions",R,"programIdIndex"],["instructions",R,"stackHeight"]];function Ia(e){return ga({parametersTransformer:rt(e),responseTransformer:ot({allowedNumericKeyPaths:J_()})})}var Ir;function J_(){return Ir||(Ir={getAccountInfo:ne.map(e=>["value",...e]),getBlock:[["blockTime"],["transactions",R,"meta","preTokenBalances",R,"accountIndex"],["transactions",R,"meta","preTokenBalances",R,"uiTokenAmount","decimals"],["transactions",R,"meta","postTokenBalances",R,"accountIndex"],["transactions",R,"meta","postTokenBalances",R,"uiTokenAmount","decimals"],["transactions",R,"meta","rewards",R,"commission"],...it.map(e=>["transactions",R,"meta","innerInstructions",R,...e]),...pr.map(e=>["transactions",R,"transaction","message",...e]),["rewards",R,"commission"]],getBlockTime:[[]],getClusterNodes:[[R,"featureSet"],[R,"shredVersion"]],getInflationGovernor:[["initial"],["foundation"],["foundationTerm"],["taper"],["terminal"]],getInflationRate:[["foundation"],["total"],["validator"]],getInflationReward:[[R,"commission"]],getMultipleAccounts:ne.map(e=>["value",R,...e]),getProgramAccounts:ne.flatMap(e=>[["value",R,"account",...e],[R,"account",...e]]),getRecentPerformanceSamples:[[R,"samplePeriodSecs"]],getTokenAccountBalance:[["value","decimals"],["value","uiAmount"]],getTokenAccountsByDelegate:at.map(e=>["value",R,"account",...e]),getTokenAccountsByOwner:at.map(e=>["value",R,"account",...e]),getTokenLargestAccounts:[["value",R,"decimals"],["value",R,"uiAmount"]],getTokenSupply:[["value","decimals"],["value","uiAmount"]],getTransaction:[["meta","preTokenBalances",R,"accountIndex"],["meta","preTokenBalances",R,"uiTokenAmount","decimals"],["meta","postTokenBalances",R,"accountIndex"],["meta","postTokenBalances",R,"uiTokenAmount","decimals"],["meta","rewards",R,"commission"],...it.map(e=>["meta","innerInstructions",R,...e]),...pr.map(e=>["transaction","message",...e])],getVersion:[["feature-set"]],getVoteAccounts:[["current",R,"commission"],["delinquent",R,"commission"]],simulateTransaction:[...ne.map(e=>["value","accounts",R,...e]),...it.map(e=>["value","innerInstructions",R,...e])]}),Ir}function Z_(e){let t={};for(let n in e)t[n.toLowerCase()]=e[n];return t}function Ca(e){let{headers:t,url:n}=e,r,o=t&&Z_(t);return async function({payload:i,signal:s}){let c=JSON.stringify(i),_={...r,body:c,headers:{...o,accept:"application/json","content-length":c.length.toString(),"content-type":"application/json; charset=utf-8"},method:"POST",signal:s},d=await fetch(n,_);if(!d.ok)throw new u(Vn,{message:d.statusText,statusCode:d.status});return await d.json()}}var Q_=Object.prototype.toString,eu=Object.keys||function(e){let t=[];for(let n in e)t.push(n);return t};function De(e,t){let n,r,o,a,i,s,c;if(e===!0)return "true";if(e===!1)return "false";switch(typeof e){case"object":if(e===null)return null;if("toJSON"in e&&typeof e.toJSON=="function")return De(e.toJSON(),t);if(c=Q_.call(e),c==="[object Array]"){for(o="[",r=e.length-1,n=0;n<r;n++)o+=De(e[n],!0)+",";return r>-1&&(o+=De(e[n],!0)),o+"]"}else if(c==="[object Object]"){for(a=eu(e).sort(),r=a.length,o="",n=0;n<r;)i=a[n],s=De(e[i],!1),s!==void 0&&(o&&(o+=","),o+=JSON.stringify(i)+":"+s),n++;return "{"+o+"}"}else return JSON.stringify(e);case"function":case"undefined":return t?null:void 0;case"bigint":return `${e.toString()}n`;case"string":return JSON.stringify(e);default:return isFinite(e)?e:null}}function st(e){let t=De(e,!1);if(t!==void 0)return ""+t}function ba(e,t,n){let r="";if(typeof t[0]=="number"){let i=t[0]+1,s=i%10,c=i%100;s==1&&c!=11?r=i+"st":s==2&&c!=12?r=i+"nd":s==3&&c!=13?r=i+"rd":r=i+"th";}else r=`\`${t[0].toString()}\``;let o=t.length>1?t.slice(1).map(i=>typeof i=="number"?`[${i}]`:i).join("."):void 0,a=new u(Ne,{argumentLabel:r,keyPath:t,methodName:e,optionalPathLabel:o?` at path \`${o}\``:"",value:n,...o!==void 0?{path:o}:void 0});return se(a,ba),a}var tu={defaultCommitment:"confirmed",onIntegerOverflow(e,t,n){throw ba(e,t,n)}},ha;function La(){return {}}function nu(e,t){let n;return async function(o){let{payload:a,signal:i}=o,s=t(a);if(s===void 0)return await e(o);if(n||(Promise.resolve().then(()=>{n=void 0;}),n={}),n[s]==null){let _=new AbortController,d=(async()=>{try{return await e({...o,signal:_.signal})}catch(l){if(l===(ha||(ha=La())))return;throw l}})();n[s]={abortController:_,numConsumers:0,responsePromise:d};}let c=n[s];if(c.numConsumers++,i){let _=c.responsePromise;return await new Promise((d,l)=>{let f=N=>{i.removeEventListener("abort",f),c.numConsumers-=1,Promise.resolve().then(()=>{c.numConsumers===0&&c.abortController.abort(ha||(ha=La()));}),l(N.target.reason);};i.addEventListener("abort",f),_.then(d).catch(l).finally(()=>{i.removeEventListener("abort",f);});})}else return await c.responsePromise}}function ru(e){return e==null||typeof e!="object"||Array.isArray(e)?!1:"jsonrpc"in e&&e.jsonrpc==="2.0"&&"method"in e&&typeof e.method=="string"&&"params"in e}function ou(e){return ru(e)?st([e.method,e.params]):void 0}function au(e){let t={};for(let n in e)t[n.toLowerCase()]=e[n];return t}function iu(e){return K(Ca({...e,headers:{...e.headers?au(e.headers):void 0,"solana-client":"js/2.0.0-preview.3.20240730155551.62c366680964b87fcb7976f532e4f760b95cb46d"}}),t=>nu(t,ou))}function Rf(e,t){return su(iu({url:e,...t}))}function su(e){return ma({api:Ia(tu),transport:e})}function Da(e){return cu(e)}function cu(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(t,n,r){return function(...o){let a=n.toString(),i=Reflect.get(t,a,r);if(n.toString().endsWith("Notifications")===!1&&!i)throw new u(Gn,{notificationName:a});let s=i?i(...o):{params:o,subscribeMethodName:a.replace(/Notifications$/,"Subscribe"),unsubscribeMethodName:a.replace(/Notifications$/,"Unsubscribe")};return uu(e,s)}}})}function _u(e,t){(async()=>{try{for await(let n of e);}catch{}finally{t();}})();}function uu(e,{params:t,subscribeMethodName:n,unsubscribeMethodName:r,responseTransformer:o}){return {async subscribe({abortSignal:a}){a.throwIfAborted();let i;function s(){if(i!==void 0){let f=be(r,[i]);d.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(f).finally(()=>{c.abort();});}else c.abort();}a.addEventListener("abort",s);let c=new AbortController,_=be(n,t),d=await e.transport({payload:_,signal:c.signal});function l(){a.removeEventListener("abort",s);}_u(d,l);for await(let f of d)if("id"in f&&f.id===_.id){if("error"in f)throw Te(f.error);i=f.result;break}if(i==null)throw new u(Hn);return {async*[Symbol.asyncIterator](){for await(let f of d){if(!("params"in f)||f.params.subscription!==i)continue;let N=f.params;yield o?o(N,n):N;}}}}}}function ya(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...t){let[n,r]=t,o=r.toString();return function(...a){let i=e!=null&&e.parametersTransformer?e==null?void 0:e.parametersTransformer(a,o):a,s=e!=null&&e.responseTransformer?e==null?void 0:e.responseTransformer:d=>d,c=e!=null&&e.subscribeNotificationNameTransformer?e==null?void 0:e.subscribeNotificationNameTransformer(o):o,_=e!=null&&e.unsubscribeNotificationNameTransformer?e==null?void 0:e.unsubscribeNotificationNameTransformer(o):o;return {params:i,responseTransformer:s,subscribeMethodName:c,unsubscribeMethodName:_}}}})}function va(e){return ya({parametersTransformer:rt(e),responseTransformer:ot({allowedNumericKeyPaths:du()}),subscribeNotificationNameTransformer:t=>t.replace(/Notifications$/,"Subscribe"),unsubscribeNotificationNameTransformer:t=>t.replace(/Notifications$/,"Unsubscribe")})}function wa(e){return va(e)}function gf(e){return va(e)}var Cr;function du(){return Cr||(Cr={accountNotifications:ne.map(e=>["value",...e]),blockNotifications:[["value","block","blockTime"],["value","block","transactions",R,"meta","preTokenBalances",R,"accountIndex"],["value","block","transactions",R,"meta","preTokenBalances",R,"uiTokenAmount","decimals"],["value","block","transactions",R,"meta","postTokenBalances",R,"accountIndex"],["value","block","transactions",R,"meta","postTokenBalances",R,"uiTokenAmount","decimals"],["value","block","transactions",R,"meta","rewards",R,"commission"],["value","block","transactions",R,"meta","innerInstructions",R,"index"],["value","block","transactions",R,"meta","innerInstructions",R,"instructions",R,"programIdIndex"],["value","block","transactions",R,"meta","innerInstructions",R,"instructions",R,"accounts",R],["value","block","transactions",R,"transaction","message","addressTableLookups",R,"writableIndexes",R],["value","block","transactions",R,"transaction","message","addressTableLookups",R,"readonlyIndexes",R],["value","block","transactions",R,"transaction","message","instructions",R,"programIdIndex"],["value","block","transactions",R,"transaction","message","instructions",R,"accounts",R],["value","block","transactions",R,"transaction","message","header","numReadonlySignedAccounts"],["value","block","transactions",R,"transaction","message","header","numReadonlyUnsignedAccounts"],["value","block","transactions",R,"transaction","message","header","numRequiredSignatures"],["value","block","rewards",R,"commission"]],programNotifications:ne.flatMap(e=>[["value",R,"account",...e],[R,"account",...e]])}),Cr}var ye=globalThis.WebSocket,Pa;function xa(){return Symbol(void 0)}async function lu({sendBufferHighWatermark:e,signal:t,url:n}){return await new Promise((r,o)=>{t.addEventListener("abort",s,{once:!0});let a=new Map;function i(A){let g=[...a.values()].filter(h=>h.__hasPolled).map(({onError:h})=>h);a.clear(),g.forEach(h=>{try{h(A);}catch{}});}function s(){i(Pa||(Pa=xa())),S.readyState!==ye.CLOSED&&S.readyState!==ye.CLOSING&&S.close(1e3);}function c(A){l==null||l.onCancel(),t.removeEventListener("abort",s),S.removeEventListener("close",c),S.removeEventListener("error",_),S.removeEventListener("open",f),S.removeEventListener("message",N),i(A);}function _(A){d||o(new u(Yn,{errorEvent:A}));}let d=!1,l;function f(){d=!0,r({async send(A){let g=JSON.stringify(A);if(!l&&S.readyState===ye.OPEN&&S.bufferedAmount>e){let h,j=new Promise((Se,Ni)=>{let no=setInterval(()=>{(S.readyState!==ye.OPEN||!(S.bufferedAmount>e))&&(clearInterval(no),l=void 0,Se());},16);h=()=>{l=void 0,clearInterval(no),Ni(new u(Wn));};});l={onCancel:h,promise:j};}l&&await l.promise,S.send(g);},async*[Symbol.asyncIterator](){let A=Symbol();a.set(A,{__hasPolled:!1,queuedMessages:[]});try{for(;;){let g=a.get(A);if(!g)throw new u(Xn);if(g.__hasPolled)throw new u(Kn);let h=g.queuedMessages;if(h.length)g.queuedMessages=[],yield*h;else try{yield await new Promise((j,Se)=>{a.set(A,{__hasPolled:!0,onError:Se,onMessage:j});});}catch(j){if(j===(Pa||(Pa=xa())))return;throw new u($n,{cause:j})}}}finally{a.delete(A);}}});}function N({data:A}){let g=JSON.parse(A);a.forEach((h,j)=>{if(h.__hasPolled){let{onMessage:Se}=h;a.set(j,{__hasPolled:!1,queuedMessages:[]}),Se(g);}else h.queuedMessages.push(g);});}let S=new ye(n);S.addEventListener("close",c),S.addEventListener("error",_),S.addEventListener("open",f),S.addEventListener("message",N);})}function Ua({sendBufferHighWatermark:e,url:t}){if(/^wss?:/i.test(t)===!1){let n=t.match(/^([^:]+):/);throw new DOMException(n?`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${n[1]}:' is not allowed.`:`Failed to construct 'WebSocket': The URL '${t}' is invalid.`)}return async function({payload:r,signal:o}){o==null||o.throwIfAborted();let a=await lu({sendBufferHighWatermark:e,signal:o,url:t});return o==null||o.throwIfAborted(),await a.send(r),{[Symbol.asyncIterator]:a[Symbol.asyncIterator].bind(a),send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:a.send.bind(a)}}}function Ba(e,t,n){let r="";if(typeof t[0]=="number"){let i=t[0]+1,s=i%10,c=i%100;s==1&&c!=11?r=i+"st":s==2&&c!=12?r=i+"nd":s==3&&c!=13?r=i+"rd":r=i+"th";}else r=`\`${t[0].toString()}\``;let o=t.length>1?t.slice(1).map(i=>typeof i=="number"?`[${i}]`:i).join("."):void 0,a=new u(Ne,{argumentLabel:r,keyPath:t,methodName:e,optionalPathLabel:o?` at path \`${o}\``:"",value:n,...o!==void 0?{path:o}:void 0});return se(a,Ba),a}var Ru={defaultCommitment:"confirmed",onIntegerOverflow(e,t,n){throw Ba(e,t,n)}};function fu(e,t){(async()=>{try{for await(let n of e);}catch{}finally{t();}})();}function Ma({getAbortSignalFromInputArgs:e,getCacheKeyFromInputArgs:t,onCacheHit:n,onCreateIterable:r}){let o=new Map;function a(i){let s=o.get(i);if(!s)throw new u(jn,{cacheKey:i.toString()});return s}return async(...i)=>{let s=t(...i),c=e(...i);if(s===void 0)return await r(c,...i);let _=()=>{o.delete(s),c.removeEventListener("abort",d);},d=()=>{let l=a(s);l.purgeScheduled!==!0&&(l.purgeScheduled=!0,globalThis.queueMicrotask(()=>{l.purgeScheduled=!1,l.referenceCount===0&&(l.abortController.abort(),_());})),l.referenceCount--;};c.addEventListener("abort",d);try{let l=o.get(s);if(l){l.referenceCount++;let f=l.iterable,N="then"in f?await f:f;return await n(N,...i),N}else {let f=new AbortController,N=r(f.signal,...i),S={abortController:f,iterable:N,purgeScheduled:!1,referenceCount:1};o.set(s,S);let A=await N;return fu(A,_),S.iterable=A,A}}catch(l){throw _(),l}}}var hr;function Lr(){return Symbol(void 0)}function Eu(e,t){(async()=>{try{for await(let n of e);}catch{}finally{t();}})();}function Au({getDeduplicationKey:e,rpcSubscriptions:t}){let n=new Map;return new Proxy(t,{defineProperty(){return !1},deleteProperty(){return !1},get(r,o,a){let i=Reflect.get(r,o,a);return typeof i!="function"?i:function(...s){let c=e(o,s);if(c===void 0)return i(...s);if(n.has(c))return n.get(c);let _=Ma({getAbortSignalFromInputArgs:({abortSignal:l})=>l,getCacheKeyFromInputArgs:()=>c,async onCacheHit(l,f){},async onCreateIterable(l,f){let S=await i(...s).subscribe({...f,abortSignal:l});return Eu(S,()=>{n.delete(c);}),S}}),d={async subscribe(...l){let f=await _(...l),{abortSignal:N}=l[0],S;return {...f,async*[Symbol.asyncIterator](){S||(S=N.aborted?Promise.reject(hr||(hr=Lr())):new Promise((A,g)=>{N.addEventListener("abort",()=>{g(hr||(hr=Lr()));});}));try{let A=f[Symbol.asyncIterator]();for(;;){let g=await Promise.race([A.next(),S]);if(g.done)return;yield g.value;}}catch(A){if(A===(hr||(hr=Lr())))return;throw n.delete(c),A}}}}};return n.set(c,d),d}}})}var Su={jsonrpc:"2.0",method:"ping"};function Ou({intervalMs:e,transport:t}){let n=new Map;return async(...r)=>{let o=await t(...r),a;function i(){o.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(Su);}function s(){clearInterval(a),a=setInterval(i,e);}if(n.has(o)===!1){n.set(o,{[Symbol.asyncIterator]:o[Symbol.asyncIterator].bind(o),send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:(...d)=>(s(),o.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...d))}),(async()=>{try{for await(let d of o)s();}catch{}finally{n.delete(o),clearInterval(a),c&&globalThis.window.removeEventListener("offline",c),_&&globalThis.window.removeEventListener("online",_);}})(),globalThis.navigator.onLine&&s();let c,_;c=()=>{clearInterval(a);},_=()=>{i(),s();},globalThis.window.addEventListener("offline",c),globalThis.window.addEventListener("online",_);}return n.get(o)}}var Nu;function Tu(){return Symbol(void 0)}function mu({getShard:e,transport:t}){return Ma({getAbortSignalFromInputArgs:({signal:n})=>n,getCacheKeyFromInputArgs:({payload:n})=>e?e(n):Nu||(Nu=Tu()),onCacheHit:(n,{payload:r})=>n.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(r),onCreateIterable:(n,r)=>t({...r,signal:n})})}function gu(e){var o;let{getShard:t,intervalMs:n,...r}=e;return K(Ua({...r,sendBufferHighWatermark:(o=e.sendBufferHighWatermark)!=null?o:131072}),a=>Ou({intervalMs:n!=null?n:5e3,transport:a}),a=>mu({getShard:t,transport:a}))}function pu(e,t){let n=gu({url:e,...t});return Fa(n)}function wf(e,t){return pu(e,t)}function Fa(e){return K(Da({api:wa(Ru),transport:e}),t=>Au({getDeduplicationKey:(...n)=>st(n),rpcSubscriptions:t}))}function Pf(e){return Fa(e)}var br,Dr;function wr(){return br||(br=Y()),br}function Iu(){return Dr||(Dr=J()),Dr}function Vf(e){return !(e.length<32||e.length>44||wr().encode(e).byteLength!==32)}function Pr(e){if(e.length<32||e.length>44)throw new u(Nt,{actualLength:e.length});let r=wr().encode(e).byteLength;if(r!==32)throw new u(Tt,{actualLength:r})}function Cu(e){return Pr(e),e}function hu(){return p(v(wr(),32),e=>Cu(e))}function Lu(){return w(Iu(),32)}function Gf(){return E(hu(),Lu())}function Hf(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function Wf(e){return e}function $f(e){return e}function Yf(e){return e}function za(e){switch(e){case"finalized":return 2;case"confirmed":return 1;case"processed":return 0;default:throw new u(qn,{unexpectedValue:e})}}function ct(e,t){return e===t?0:za(e)<za(t)?-1:1}var ka=18446744073709551615n,yr,vr;function bu(){return yr||(yr=Ar()),yr}function Du(){return vr||(vr=Sr()),vr}function Xf(e){return e>=0&&e<=ka}function yu(e){if(e<0||e>ka)throw new u(mt)}function vu(e){return yu(e),e}function wu(){return bu()}function Kf(e){return e}function Pu(){return Va(Du())}function Va(e){return I(e,t=>vu(typeof t=="bigint"?t:BigInt(t)))}function jf(){return E(wu(),Pu())}function qf(e){return E(e,Va(e))}function Jf(e){try{return BigInt(e),!0}catch{return !1}}function xu(e){try{BigInt(e);}catch{throw new u(gt,{value:e})}}function Zf(e){return xu(e),e}function Qf(e){return !Number.isNaN(Number(e))}function Uu(e){if(Number.isNaN(Number(e)))throw new u(pt,{value:e})}function eE(e){return Uu(e),e}function tE(e){return !(e>864e13||e<-864e13)}function Bu(e){if(e>864e13||e<-864e13)throw new u(It,{value:e})}function nE(e){return Bu(e),e}function ve(e){if(!("lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"))return !1;try{return Pr(e.lifetimeConstraint.blockhash),!0}catch{return !1}}function lE(e){if(!ve(e))throw new u(ln)}function Hr(e,t){if("lifetimeConstraint"in t&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return t;let n={...t,lifetimeConstraint:Object.freeze(e)};return Object.freeze(n),n}function Mu(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new u($,{alphabet:e,base:e.length,value:n})}var Fu=e=>O({getSizeFromValue:t=>{let[n,r]=Ga(t,e[0]);if(!r)return t.length;let o=Ha(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Mu(e,t),t==="")return r;let[o,a]=Ga(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=Ha(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),zu=e=>T({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,_)=>c*256n+BigInt(_),0n),s=ku(i,e);return [a+s,t.length]}});function Ga(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ha(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function ku(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Ka="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Vu=()=>Fu(Ka),Gu=()=>zu(Ka),xr;function Hu(){return xr||(xr=X([["lookupTableAddress",Ke()],["writableIndices",z(y(),{size:k()})],["readableIndices",z(y(),{size:k()})]])),xr}var Ur;function Wu(){return Ur||(Ur=te([["lookupTableAddress",ae()],["writableIndices",P(b(),{size:M()})],["readableIndices",P(b(),{size:M()})]])),Ur}var Br;function Mr(){return Br||(Br=y()),Br}var Fr;function zr(){return Fr||(Fr=b()),Fr}function $u(){return X([["numSignerAccounts",Mr()],["numReadonlySignerAccounts",Mr()],["numReadonlyNonSignerAccounts",Mr()]])}function Yu(){return te([["numSignerAccounts",zr()],["numReadonlySignerAccounts",zr()],["numReadonlyNonSignerAccounts",zr()]])}var kr;function Xu(){return kr||(kr=p(X([["programAddressIndex",y()],["accountIndices",z(y(),{size:k()})],["data",Jn(de(),k())]]),e=>{var t,n;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(t=e.accountIndices)!=null?t:[],data:(n=e.data)!=null?n:new Uint8Array(0)}})),kr}var Vr;function Ku(){return Vr||(Vr=I(te([["programAddressIndex",b()],["accountIndices",P(b(),{size:M()})],["data",Zn(le(),M())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:n,...r}=e;return {...r,...t.length?{accountIndices:t}:null,...n.byteLength?{data:n}:null}})),Vr}var Gr=128;function ja(){return O({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new u(fn,{actualVersion:e});return t.set([e|Gr],n),n+1}})}function _t(){return T({maxSize:1,read:(e,t)=>{let n=e[t];return n&Gr?[n^Gr,t+1]:["legacy",t]}})}function RE(){return E(ja(),_t())}function Wa(){return X(qa())}function $a(){return p(X([...qa(),["addressTableLookups",qu()]]),e=>{var t;return e.version==="legacy"?e:{...e,addressTableLookups:(t=e.addressTableLookups)!=null?t:[]}})}function qa(){return [["version",ja()],["header",$u()],["staticAccounts",z(Ke(),{size:k()})],["lifetimeToken",v(Vu(),32)],["instructions",z(Xu(),{size:k()})]]}function ju(){return [["version",_t()],["header",Yu()],["staticAccounts",P(ae(),{size:M()})],["lifetimeToken",w(Gu(),32)],["instructions",P(Ku(),{size:M()})],["addressTableLookups",Ju()]]}function qu(){return z(Hu(),{size:k()})}function Ju(){return P(Wu(),{size:M()})}function Wr(){return O({getSizeFromValue:e=>e.version==="legacy"?Wa().getSizeFromValue(e):$a().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?Wa().write(e,t,n):$a().write(e,t,n)})}function Zu(){return I(te(ju()),({addressTableLookups:e,...t})=>t.version==="legacy"||!(e!=null&&e.length)?t:{...t,addressTableLookups:e})}function fE(){return E(Wr(),Zu())}function Ya(e,t,n){var r;e[t]=n((r=e[t])!=null?r:{role:L.READONLY});}var C=Symbol("AddressMapTypeProperty");function Qu(e,t){let n={[e]:{[C]:0,role:L.WRITABLE_SIGNER}},r=new Set;for(let o of t){Ya(n,o.programAddress,i=>{if(r.add(o.programAddress),C in i){if(Re(i.role))switch(i[C]){case 0:throw new u(dn,{programAddress:o.programAddress});default:throw new u(Fe,{programAddress:o.programAddress})}if(i[C]===2)return i}return {[C]:2,role:L.READONLY}});let a;if(o.accounts)for(let i of o.accounts)Ya(n,i.address,s=>{let{address:c,..._}=i;if(C in s)switch(s[C]){case 0:return s;case 1:{let d=mr(s.role,_.role);if("lookupTableAddress"in _){if(s.lookupTableAddress!==_.lookupTableAddress&&(a||(a=je()))(_.lookupTableAddress,s.lookupTableAddress)<0)return {[C]:1,..._,role:d}}else if(W(_.role))return {[C]:2,role:d};return s.role!==d?{...s,role:d}:s}case 2:{let d=mr(s.role,_.role);if(r.has(i.address)){if(Re(_.role))throw new u(Fe,{programAddress:i.address});return s.role!==d?{...s,role:d}:s}else return "lookupTableAddress"in _&&!W(s.role)?{..._,[C]:1,role:d}:s.role!==d?{...s,role:d}:s}}return "lookupTableAddress"in _?{..._,[C]:1}:{..._,[C]:2}});}return n}function ed(e){let t;return Object.entries(e).sort(([r,o],[a,i])=>{if(o[C]!==i[C]){if(o[C]===0)return -1;if(i[C]===0)return 1;if(o[C]===2)return -1;if(i[C]===2)return 1}let s=W(o.role);if(s!==W(i.role))return s?-1:1;let c=Re(o.role);return c!==Re(i.role)?c?-1:1:(t||(t=je()),o[C]===1&&i[C]===1&&o.lookupTableAddress!==i.lookupTableAddress?t(o.lookupTableAddress,i.lookupTableAddress):t(r,a))}).map(([r,o])=>({address:r,...o}))}function td(e){var n;let t={};for(let r of e){if(!("lookupTableAddress"in r))continue;let o=t[n=r.lookupTableAddress]||(t[n]={readableIndices:[],writableIndices:[]});r.role===L.WRITABLE?o.writableIndices.push(r.addressIndex):o.readableIndices.push(r.addressIndex);}return Object.keys(t).sort(je()).map(r=>({lookupTableAddress:r,...t[r]}))}function nd(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let a=Re(o.role);W(o.role)?(r++,a||n++):a||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function rd(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function od(e,t){let n=rd(t);return e.map(({accounts:r,data:o,programAddress:a})=>({programAddressIndex:n[a],...r?{accountIndices:r.map(({address:i})=>n[i])}:null,...o?{data:o}:null}))}function ad(e){return "nonce"in e?e.nonce:e.blockhash}function id(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Ja(e){let t=Qu(e.feePayer,e.instructions),n=ed(t);return {...e.version!=="legacy"?{addressTableLookups:td(n)}:null,header:nd(n),instructions:od(e.instructions,n),lifetimeToken:ad(e.lifetimeConstraint),staticAccounts:id(n),version:e.version}}function sd(e,t,n){for(let[r,o]of Object.entries(n))for(let a=0;a<o.length;a++)if(e===o[a])return {address:e,addressIndex:a,lookupTableAddress:r,role:t}}function EE(e,t){let n=new Set(Object.values(t).flatMap(a=>a)),r=[],o=!1;for(let a of e.instructions){if(!a.accounts){r.push(a);continue}let i=[],s=!1;for(let c of a.accounts){if("lookupTableAddress"in c||!n.has(c.address)||W(c.role)){i.push(c);continue}let _=sd(c.address,c.role,t);i.push(Object.freeze(_)),s=!0,o=!0;}r.push(Object.freeze(s?{...a,accounts:i}:a));}return Object.freeze(o?{...e,instructions:r}:e)}function cd({version:e}){return Object.freeze({instructions:Object.freeze([]),version:e})}var Za="SysvarRecentB1ockHashes11111111111111111111",Qa="11111111111111111111111111111111";function AE(e){if(!ut(e))throw new u(Rn)}function Xa(e,t){return {accounts:[{address:e,role:L.WRITABLE},{address:Za,role:L.READONLY},{address:t,role:L.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Qa}}function $r(e){var t;return e.programAddress===Qa&&e.data!=null&&_d(e.data)&&((t=e.accounts)==null?void 0:t.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===L.WRITABLE&&e.accounts[1].address===Za&&e.accounts[1].role===L.READONLY&&e.accounts[2].address!=null&&W(e.accounts[2].role)}function _d(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function ut(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&$r(e.instructions[0])}function ud(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function dd({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,a=r.instructions[0];if(a&&$r(a))if(ud(a,t,n)){if(ut(r)&&r.lifetimeConstraint.nonce===e)return r;o=[a,...r.instructions.slice(1)];}else o=[Object.freeze(Xa(t,n)),...r.instructions.slice(1)];else o=[Object.freeze(Xa(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function ld(e,t){if("feePayer"in t&&e===t.feePayer)return t;let n={...t,feePayer:e};return Object.freeze(n),n}function Yr(e,t){return Rd([e],t)}function Rd(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function SE(e,t){return fd([e],t)}function fd(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}function Ed(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],a=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[a],role:L.WRITABLE_SIGNER}),a++;for(let i=0;i<t.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[a],role:L.READONLY_SIGNER}),a++;for(let i=0;i<r;i++)o.push({address:e.staticAccounts[a],role:L.WRITABLE}),a++;for(let i=0;i<t.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[a],role:L.READONLY}),a++;return o}function Ad(e,t){let r=e.map(i=>i.lookupTableAddress).filter(i=>t[i]===void 0);if(r.length>0)throw new u(En,{lookupTableAddresses:r});let o=[],a=[];for(let i of e){let s=t[i.lookupTableAddress],c=Math.max(...i.readableIndices,...i.writableIndices);if(c>=s.length)throw new u(An,{highestKnownIndex:s.length-1,highestRequestedIndex:c,lookupTableAddress:i.lookupTableAddress});let _=i.readableIndices.map(l=>({address:s[l],addressIndex:l,lookupTableAddress:i.lookupTableAddress,role:L.READONLY}));o.push(..._);let d=i.writableIndices.map(l=>({address:s[l],addressIndex:l,lookupTableAddress:i.lookupTableAddress,role:L.WRITABLE}));a.push(...d);}return [...a,...o]}function Sd(e,t){var a,i;let n=(a=t[e.programAddressIndex])==null?void 0:a.address;if(!n)throw new u(Sn,{index:e.programAddressIndex});let r=(i=e.accountIndices)==null?void 0:i.map(s=>t[s]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function Od(e,t,n){if(!t||!$r(t))return {blockhash:e,lastValidBlockHeight:n!=null?n:2n**64n-1n};{let r=t.accounts[0].address;pe(r);let o=t.accounts[2].address;return pe(o),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:o}}}function ei(e,t){var _;let n=e.staticAccounts[0];if(!n)throw new u(On);let r=Ed(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?Ad(e.addressTableLookups,(_=t==null?void 0:t.addressesByLookupTableAddress)!=null?_:{}):[],a=[...r,...o],i=e.instructions.map(d=>Sd(d,a)),s=i[0],c=Od(e.lifetimeToken,s,t==null?void 0:t.lastValidBlockHeight);return K(cd({version:e.version}),d=>ld(n,d),d=>i.reduce((l,f)=>Yr(f,l),d),d=>"blockhash"in c?Hr(c,d):dd(c,d))}function Nd(e){let t=Object.values(e);if(t.length===0)throw new u(gn);return t.map(n=>n||new Uint8Array(64).fill(0))}function Td(){return p(z(v(de(),64),{size:k()}),Nd)}function ti(){return X([["signatures",Td()],["messageBytes",de()]])}function md(){return I(te([["signatures",P(w(le(),64),{size:M()})],["messageBytes",le()]]),gd)}function LE(){return E(ti(),md())}function gd(e){let{messageBytes:t,signatures:n}=e,r=F([_t(),rr(b(),2),P(ae(),{size:M()})]),[o,a,i]=r.decode(t),s=i.slice(0,a);if(s.length!==n.length)throw new u(pn,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((_,d)=>{let l=n[d];l.every(f=>f===0)?c[_]=null:c[_]=l;}),{messageBytes:t,signatures:Object.freeze(c)}}function dt(e){let t=Ja(e),n=Wr().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let s of r)o[s]=null;let a;ve(e)?a={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:a={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address};let i={lifetimeConstraint:a,messageBytes:n,signatures:Object.freeze(o)};return Object.freeze(i)}var Xr;function Kr(e){Xr||(Xr=J());let t=Object.values(e.signatures)[0];if(!t)throw new u(Tn);return Xr.decode(t)}function pd(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}async function jr(e,t){let n,r;if(await Promise.all(e.map(async o=>{let a=await qe(o.publicKey),i=t.signatures[a];if(i===void 0){r||(r=new Set),r.add(a);return}if(r)return;let s=await Le(o.privateKey,t.messageBytes);i!==null&&pd(s,i)||(n||(n={}),n[a]=s);})),r&&r.size>0){let o=Object.keys(t.signatures);throw new u(mn,{expectedAddresses:o,unexpectedAddresses:[...r]})}return n?Object.freeze({...t,signatures:Object.freeze({...t.signatures,...n})}):t}async function bE(e,t){let n=await jr(e,t);return qr(n),Object.freeze(n),n}function qr(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new u(Nn,{addresses:t})}function lt(e){let t=ti().encode(e);return _r().decode(t)}function we(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new u(en,{address:n.address})}),Object.values(t)}function Id(e){var t;return we(((t=e.accounts)!=null?t:[]).flatMap(n=>"signer"in n?n.signer:[]))}function Jr(e){return we([...e.feePayerSigner?[e.feePayerSigner]:[],...e.instructions.flatMap(Id)])}function Cd(e,t){if(!t.accounts||t.accounts.length===0)return t;let n=new Map(we(e).map(r=>[r.address,r]));return Object.freeze({...t,accounts:t.accounts.map(r=>{let o=n.get(r.address);return !W(r.role)||"signer"in r||!o?r:Object.freeze({...r,signer:o})})})}function UE(e,t){return t.instructions.length===0?t:Object.freeze({...t,instructions:t.instructions.map(n=>Cd(e,n))})}function BE(e,t){if("feePayer"in t&&e.address===t.feePayer){if("feePayerSigner"in t)return t;let r={...t,feePayerSigner:e};return Object.freeze(r),r}let n={...t,feePayer:e.address,feePayerSigner:e};return Object.freeze(n),n}function Zr(e){return "signMessages"in e&&typeof e.signMessages=="function"}function ME(e){if(!Zr(e))throw new u(on,{address:e.address})}function re(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function FE(e){if(!re(e))throw new u(cn,{address:e.address})}function hd(e){return "keyPair"in e&&typeof e.keyPair=="object"&&Zr(e)&&re(e)}function zE(e){if(!hd(e))throw new u(tn,{address:e.address})}async function ni(e){let t=await qe(e.publicKey);return Object.freeze({address:t,keyPair:e,signMessages:r=>Promise.all(r.map(async o=>Object.freeze({[t]:await Le(e.privateKey,o.content)}))),signTransactions:r=>Promise.all(r.map(async o=>{let a=await jr([e],o);return Object.freeze({[t]:a.signatures[t]})}))})}async function kE(){return await ni(await Na())}async function VE(e,t){return await ni(await Ta(e,t))}function ri(e){return fr(e.address)&&"modifyAndSignMessages"in e&&typeof e.modifyAndSignMessages=="function"}function GE(e){if(!ri(e))throw new u(rn,{address:e.address})}function Ld(e){return Zr(e)||ri(e)}function HE(e){if(!Ld(e))throw new u(nn,{address:e.address})}function WE(e){return Object.freeze({address:e,signMessages:n=>Promise.resolve(n.map(()=>Object.freeze({}))),signTransactions:n=>Promise.resolve(n.map(()=>Object.freeze({})))})}function Ee(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function $E(e){if(!Ee(e))throw new u(sn,{address:e.address})}function Rt(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function YE(e){if(!Rt(e))throw new u(_n,{address:e.address})}function Qr(e){return re(e)||Ee(e)||Rt(e)}function XE(e){if(!Qr(e))throw new u(an,{address:e.address})}function KE(e){try{return oi(e),!0}catch{return !1}}function oi(e){let n=Jr(e).filter(Rt);if(n.length===0)throw new u(Me);if(n.filter(o=>!re(o)&&!Ee(o)).length>1)throw new u(un)}async function bd(e,t){let{partialSigners:n,modifyingSigners:r}=ai(we(Jr(e).filter(Qr)),{identifySendingSigner:!1});return await ii(e,r,n,t)}async function jE(e,t){let n=await bd(e,t);return qr(n),n}async function qE(e,t){oi(e);let n=t==null?void 0:t.abortSignal,{partialSigners:r,modifyingSigners:o,sendingSigner:a}=ai(we(Jr(e).filter(Qr)));n==null||n.throwIfAborted();let i=await ii(e,o,r,t);if(!a)throw new u(Me);n==null||n.throwIfAborted();let[s]=await a.signAndSendTransactions([i],t);return n==null||n.throwIfAborted(),s}function ai(e,t={}){var s;let r=((s=t.identifySendingSigner)!=null?s:!0)?Dd(e):null,o=e.filter(c=>c!==r&&(Ee(c)||re(c))),a=yd(o),i=o.filter(re).filter(c=>!a.includes(c));return Object.freeze({modifyingSigners:a,partialSigners:i,sendingSigner:r})}function Dd(e){let t=e.filter(Rt);if(t.length===0)return null;let n=t.filter(r=>!Ee(r)&&!re(r));return n.length>0?n[0]:t[0]}function yd(e){let t=e.filter(Ee);if(t.length===0)return [];let n=t.filter(r=>!re(r));return n.length>0?n:[t[0]]}async function ii(e,t=[],n=[],r){var c,_;let o=dt(e),a=await t.reduce(async(d,l)=>{var N;(N=r==null?void 0:r.abortSignal)==null||N.throwIfAborted();let[f]=await l.modifyAndSignTransactions([await d],r);return Object.freeze(f)},Promise.resolve(o));(c=r==null?void 0:r.abortSignal)==null||c.throwIfAborted();let i=await Promise.all(n.map(async d=>{let[l]=await d.signTransactions([a],r);return l})),s={...a,signatures:Object.freeze(i.reduce((d,l)=>({...d,...l}),(_=a.signatures)!=null?_:{}))};return Object.freeze(s)}var vd=globalThis.TextEncoder;function JE(e,t={}){return Object.freeze({content:typeof e=="string"?new vd().encode(e):e,signatures:Object.freeze({...t})})}function si({rpc:e,rpcSubscriptions:t}){return async function({abortSignal:r,commitment:o,lastValidBlockHeight:a}){let i=new AbortController,s=()=>{i.abort();};r.addEventListener("abort",s,{signal:i.signal});async function c(){let{absoluteSlot:_,blockHeight:d}=await e.getEpochInfo({commitment:o}).send({abortSignal:i.signal});return {blockHeight:d,differenceBetweenSlotHeightAndBlockHeight:_-d}}try{let[_,{blockHeight:d,differenceBetweenSlotHeightAndBlockHeight:l}]=await Promise.all([t.slotNotifications().subscribe({abortSignal:i.signal}),c()]),f=d;if(f<=a){let N=l;for await(let S of _){let{slot:A}=S;if(A-N>a){let{blockHeight:g,differenceBetweenSlotHeightAndBlockHeight:h}=await c();if(f=g,f>a)break;N=h;}}}throw new u(St,{currentBlockHeight:f,lastValidBlockHeight:a})}finally{i.abort();}}}var eo=40;function ci({rpc:e,rpcSubscriptions:t}){return async function({abortSignal:r,commitment:o,currentNonceValue:a,nonceAccountAddress:i}){let s=new AbortController;function c(){s.abort();}r.addEventListener("abort",c,{signal:s.signal});let _=await t.accountNotifications(i,{commitment:o,encoding:"base64"}).subscribe({abortSignal:s.signal}),d=J(),l=me();function f([A]){let h=l.encode(A).slice(eo,eo+32);return d.decode(h)}let N=(async()=>{for await(let A of _){let g=f(A.value.data);if(g!==a)throw new u(Pe,{actualNonceValue:g,expectedNonceValue:a})}})(),S=(async()=>{let{value:A}=await e.getAccountInfo(i,{commitment:o,dataSlice:{length:32,offset:eo},encoding:"base58"}).send({abortSignal:s.signal});if(!A)throw new u(Ot,{nonceAccountAddress:i});let g=A.data[0];if(g!==a)throw new u(Pe,{actualNonceValue:g,expectedNonceValue:a});await new Promise(()=>{});})();try{return await Promise.race([N,S])}finally{s.abort();}}}function Ae({rpc:e,rpcSubscriptions:t}){return async function({abortSignal:r,commitment:o,signature:a}){let i=new AbortController;function s(){i.abort();}r.addEventListener("abort",s,{signal:i.signal});let c=await t.signatureNotifications(a,{commitment:o}).subscribe({abortSignal:i.signal}),_=(async()=>{for await(let l of c){if(l.value.err)throw Ge(l.value.err);return}})(),d=(async()=>{let{value:l}=await e.getSignatureStatuses([a]).send({abortSignal:i.signal}),f=l[0];f&&f.confirmationStatus&&ct(f.confirmationStatus,o)>=0||await new Promise(()=>{});})();try{return await Promise.race([_,d])}finally{i.abort();}}}async function _i({abortSignal:e,commitment:t}){return await new Promise((n,r)=>{let o=c=>{clearTimeout(s);let _=new DOMException(c.target.reason,"AbortError");r(_);};e.addEventListener("abort",o);let a=t==="processed"?3e4:6e4,i=performance.now(),s=setTimeout(()=>{let c=performance.now()-i;r(new DOMException(`Timeout elapsed after ${c} ms`,"TimeoutError"));},a);})}async function to(e,t,n){let{abortSignal:r,commitment:o,getRecentSignatureConfirmationPromise:a}=t;r==null||r.throwIfAborted();let i=new AbortController;if(r){let s=()=>{i.abort();};r.addEventListener("abort",s,{signal:i.signal});}try{let s=n({...t,abortSignal:i.signal});return await Promise.race([a({abortSignal:i.signal,commitment:o,signature:e}),...s])}finally{i.abort();}}async function ui(e){await to(Kr(e.transaction),e,function({abortSignal:n,commitment:r,getNonceInvalidationPromise:o,transaction:a}){return [o({abortSignal:n,commitment:r,currentNonceValue:a.lifetimeConstraint.nonce,nonceAccountAddress:a.lifetimeConstraint.nonceAccountAddress})]});}async function di(e){await to(Kr(e.transaction),e,function({abortSignal:n,commitment:r,getBlockHeightExceedencePromise:o,transaction:a}){return [o({abortSignal:n,commitment:r,lastValidBlockHeight:a.lifetimeConstraint.lastValidBlockHeight})]});}async function li(e){await to(e.signature,e,function({abortSignal:n,commitment:r,getTimeoutPromise:o}){return [o({abortSignal:n,commitment:r})]});}async function Ri({abortSignal:e,commitment:t,confirmSignatureOnlyTransaction:n,lamports:r,recipientAddress:o,rpc:a}){let i=await a.requestAirdrop(o,r,{commitment:t}).send({abortSignal:e});return await n({abortSignal:e,commitment:t,signature:i}),i}function sA({rpc:e,rpcSubscriptions:t}){let n=Ae({rpc:e,rpcSubscriptions:t});async function r(o){await li({...o,getRecentSignatureConfirmationPromise:n,getTimeoutPromise:_i});}return async function(a){return await Ri({...a,confirmSignatureOnlyTransaction:r,rpc:e})}}var fi="ComputeBudget111111111111111111111111111111",wd={blockhash:"11111111111111111111111111111111",lastValidBlockHeight:0n},Ei=2;function Pd(e){let t=new Uint8Array(5);return t[0]=Ei,Ie().write(e,t,1),Object.freeze({data:t,programAddress:fi})}function xd(e){return Aa(e,fi)&&Sa(e)&&e.data[0]===Ei}async function Ai({abortSignal:e,rpc:t,transactionMessage:n,...r}){let o=ut(n),a;o||ve(n)?a=n:a=Hr(wd,n);let i=n.instructions.findIndex(xd),s=Pd(14e5);if(i===-1)a=Yr(s,a);else {let d=[...a.instructions];d.splice(i,1,s),a=Object.freeze({...a,instructions:d});}let c=dt(a),_=lt(c);try{let{value:{unitsConsumed:d}}=await t.simulateTransaction(_,{...r,encoding:"base64",replaceRecentBlockhash:!o,sigVerify:!1}).send({abortSignal:e});if(d==null)throw new u(ze);return d>4294967295n?4294967295:Number(d)}catch(d){throw new u(ze,{cause:d})}}function mA({rpc:e}){return async function(n,r){return await Ai({...r,rpc:e,transactionMessage:n})}}async function Ud(e,t,n){let r=await Wo(t,e,n);return Go(r),$o(r),r.reduce((o,a)=>({...o,[a.address]:a.data.addresses}),{})}async function LA(e,t,n){let o=("addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups:[]).map(c=>c.lookupTableAddress),{lastValidBlockHeight:a,...i}=n!=null?n:{},s=o.length>0?await Ud(o,t,i):{};return ei(e,{addressesByLookupTableAddress:s,lastValidBlockHeight:a})}function Bd(e,t){return !(t!=null&&t.preflightCommitment)&&ct(e,"finalized")<0?{...t,preflightCommitment:e}:t}async function ft({abortSignal:e,commitment:t,rpc:n,transaction:r,...o}){let a=lt(r);return await n.sendTransaction(a,{...Bd(t,o),encoding:"base64"}).send({abortSignal:e})}async function Si({abortSignal:e,commitment:t,confirmDurableNonceTransaction:n,rpc:r,transaction:o,...a}){let i=await ft({...a,abortSignal:e,commitment:t,rpc:r,transaction:o});return await n({abortSignal:e,commitment:t,transaction:o}),i}async function Oi({abortSignal:e,commitment:t,confirmRecentTransaction:n,rpc:r,transaction:o,...a}){let i=await ft({...a,abortSignal:e,commitment:t,rpc:r,transaction:o});return await n({abortSignal:e,commitment:t,transaction:o}),i}function FA({rpc:e,rpcSubscriptions:t}){let n=ci({rpc:e,rpcSubscriptions:t}),r=Ae({rpc:e,rpcSubscriptions:t});async function o(a){await ui({...a,getNonceInvalidationPromise:n,getRecentSignatureConfirmationPromise:r});}return async function(i,s){await Si({...s,confirmDurableNonceTransaction:o,rpc:e,transaction:i});}}function GA({rpc:e,rpcSubscriptions:t}){let n=si({rpc:e,rpcSubscriptions:t}),r=Ae({rpc:e,rpcSubscriptions:t});async function o(a){await di({...a,getBlockHeightExceedencePromise:n,getRecentSignatureConfirmationPromise:r});}return async function(i,s){await Oi({...s,confirmRecentTransaction:o,rpc:e,transaction:i});}}function $A({rpc:e}){return async function(n,r){await ft({...r,rpc:e,transaction:n});}}
|
5
|
+
var Ti=Object.defineProperty;var mi=(e,t,n)=>t in e?Ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Et=(e,t,n)=>mi(e,typeof t!="symbol"?t+"":t,n);var St=1,Pe=2,Ot=3,Nt=4,Tt=5,mt=6,gt=7,pt=8,It=9,ro=-32700,oo=-32603,ao=-32602,io=-32601,so=-32600,gi=-32016,co=-32015,_o=-32014,pi=-32013,uo=-32012,Ii=-32011,lo=-32010,Ro=-32009,Ci=-32008,fo=-32007,Eo=-32006,hi=-32005,Ao=-32004,Li=-32003,At=-32002,So=-32001,Ct=28e5,ht=2800001,bi=2800002,Lt=2800003,bt=2800004,Dt=2800005,yt=2800006,xe=2800007,Ue=2800008,vt=2800009,wt=2800010,Pt=323e4,xt=32300001,Ut=3230002,Bt=3230003,Mt=3230004,Ft=361e4,zt=3610001,kt=3610002,Vt=3610003,Gt=3610004,Ht=3610005,Wt=3610006,$t=3611e3,Yt=3704e3,Xt=3704001,Kt=3704002,jt=3704003,qt=3704004,Jt=4128e3,Zt=4128001,Qt=4128002,Oo=4615e3,Di=4615001,yi=4615002,vi=4615003,wi=4615004,Pi=4615005,xi=4615006,Ui=4615007,Bi=4615008,Mi=4615009,Fi=4615010,zi=4615011,ki=4615012,Vi=4615013,Gi=4615014,Hi=4615015,Wi=4615016,$i=4615017,Yi=4615018,Xi=4615019,Ki=4615020,ji=4615021,qi=4615022,Ji=4615023,Zi=4615024,Qi=4615025,Be=4615026,es=4615027,ts=4615028,ns=4615029,rs=4615030,os=4615031,as=4615032,is=4615033,ss=4615034,cs=4615035,_s=4615036,us=4615037,ds=4615038,ls=4615039,Rs=4615040,fs=4615041,Es=4615042,As=4615043,Ss=4615044,No=4615045,Os=4615046,Ns=4615047,Ts=4615048,ms=4615049,gs=4615050,ps=4615051,Is=4615052,Cs=4615053,hs=4615054,en=5508e3,tn=5508001,nn=5508002,rn=5508003,on=5508004,an=5508005,sn=5508006,cn=5508007,_n=5508008,un=5508009,Me=5508010,Ls=5508011,dn=5663e3,Fe=5663001,ln=5663002,Rn=5663003,fn=5663004,En=5663005,An=5663006,Sn=5663007,On=5663008,Nn=5663009,bs=5663010,Ds=5663011,Tn=5663012,ys=5663013,vs=5663014,mn=5663015,gn=5663016,pn=5663017,ze=5663018,To=705e4,ws=7050001,Ps=7050002,xs=7050003,Us=7050004,Bs=7050005,Ms=7050006,Fs=7050007,zs=7050008,ks=7050009,Vs=7050010,Gs=7050011,Hs=7050012,Ws=7050013,$s=7050014,Ys=7050015,Xs=7050016,Ks=7050017,js=7050018,qs=7050019,Js=7050020,Zs=7050021,Qs=7050022,ec=7050023,tc=7050024,nc=7050025,rc=7050026,oc=7050027,ac=7050028,ic=7050029,mo=7050030,go=7050031,sc=7050032,cc=7050033,_c=7050034,po=7050035,uc=7050036,In=8078e3,Cn=8078001,hn=8078002,Ln=8078003,bn=8078004,Dn=8078005,yn=8078006,vn=8078007,wn=8078008,Pn=8078009,xn=8078010,Un=8078011,$=8078012,Oe=8078013,Bn=8078014,dc=8078015,lc=8078016,Mn=8078017,Fn=8078018,Rc=8078019,zn=8078020,kn=8078021,ke=8078022,Ne=81e5,Io=8100001,Vn=8100002,Gn=819e4,Hn=8190001,Wn=8190002,$n=8190003,Yn=8190004,Xn=99e5,Kn=9900001,jn=9900002,qn=9900003;function Co(e){return Array.isArray(e)?"%5B"+e.map(Co).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function fc([e,t]){return `${e}=${Co(t)}`}function Ec(e){let t=Object.entries(e).map(fc).join("&");return btoa(t)}function Ac(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Ec(t)}'`),`${n}\``}}function Ve(e,t){return e instanceof Error&&e.name==="SolanaError"?t!==void 0?e.context.__code===t:!0:!1}var u=class extends Error{constructor(...[t,n]){let r,o;if(n){let{cause:i,...s}=n;i&&(o={cause:i}),Object.keys(s).length>0&&(r=s);}let a=Ac(t,r);super(a,o);Et(this,"cause",this.cause);Et(this,"context");this.context={__code:t,...r},this.name="SolanaError";}};function se(...e){"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e);}function ho({errorCodeBaseOffset:e,getErrorContext:t,orderedErrorNames:n,rpcEnumError:r},o){let a,i;typeof r=="string"?a=r:(a=Object.keys(r)[0],i=r[a]);let s=n.indexOf(a),c=e+s,_=t(c,a,i),d=new u(c,_);return se(d,o),d}var Sc=["GenericError","InvalidArgument","InvalidInstructionData","InvalidAccountData","AccountDataTooSmall","InsufficientFunds","IncorrectProgramId","MissingRequiredSignature","AccountAlreadyInitialized","UninitializedAccount","UnbalancedInstruction","ModifiedProgramId","ExternalAccountLamportSpend","ExternalAccountDataModified","ReadonlyLamportChange","ReadonlyDataModified","DuplicateAccountIndex","ExecutableModified","RentEpochModified","NotEnoughAccountKeys","AccountDataSizeChanged","AccountNotExecutable","AccountBorrowFailed","AccountBorrowOutstanding","DuplicateAccountOutOfSync","Custom","InvalidError","ExecutableDataModified","ExecutableLamportChange","ExecutableAccountNotRentExempt","UnsupportedProgramId","CallDepth","MissingAccount","ReentrancyNotAllowed","MaxSeedLengthExceeded","InvalidSeeds","InvalidRealloc","ComputationalBudgetExceeded","PrivilegeEscalation","ProgramEnvironmentSetupFailure","ProgramFailedToComplete","ProgramFailedToCompile","Immutable","IncorrectAuthority","BorshIoError","AccountNotRentExempt","InvalidAccountOwner","ArithmeticOverflow","UnsupportedSysvar","IllegalOwner","MaxAccountsDataAllocationsExceeded","MaxAccountsExceeded","MaxInstructionTraceLengthExceeded","BuiltinProgramsMustConsumeComputeUnits"];function Lo(e,t){return ho({errorCodeBaseOffset:4615001,getErrorContext(n,r,o){return n===Oo?{errorName:r,index:e,...o!==void 0?{instructionErrorContext:o}:null}:n===Be?{code:o,index:e}:n===No?{encodedData:o,index:e}:{index:e}},orderedErrorNames:Sc,rpcEnumError:t},Lo)}var Oc=["AccountInUse","AccountLoadedTwice","AccountNotFound","ProgramAccountNotFound","InsufficientFundsForFee","InvalidAccountForFee","AlreadyProcessed","BlockhashNotFound","CallChainTooDeep","MissingSignatureForFee","InvalidAccountIndex","SignatureFailure","InvalidProgramForExecution","SanitizeFailure","ClusterMaintenance","AccountBorrowOutstanding","WouldExceedMaxBlockCostLimit","UnsupportedVersion","InvalidWritableAccount","WouldExceedMaxAccountCostLimit","WouldExceedAccountDataBlockLimit","TooManyAccountLocks","AddressLookupTableNotFound","InvalidAddressLookupTableOwner","InvalidAddressLookupTableData","InvalidAddressLookupTableIndex","InvalidRentPayingAccount","WouldExceedMaxVoteCostLimit","WouldExceedAccountDataTotalLimit","DuplicateInstruction","InsufficientFundsForRent","MaxLoadedAccountsDataSizeExceeded","InvalidLoadedAccountsDataSizeLimit","ResanitizationNeeded","ProgramExecutionTemporarilyRestricted","UnbalancedTransaction"];function Ge(e){return typeof e=="object"&&"InstructionError"in e?Lo(...e.InstructionError):ho({errorCodeBaseOffset:7050001,getErrorContext(t,n,r){if(t===To)return {errorName:n,...r!==void 0?{transactionErrorContext:r}:null};if(t===mo)return {index:r};if(t===go||t===po)return {accountIndex:r.account_index}},orderedErrorNames:Oc,rpcEnumError:e},Ge)}function Te({code:e,data:t,message:n}){let r;if(e===At){let{err:o,...a}=t,i=o?{cause:Ge(o)}:null;r=new u(At,{...a,...i});}else {let o;switch(e){case oo:case ao:case so:case io:case ro:case uo:case So:case Ao:case _o:case lo:case Ro:case fo:case Eo:case co:o={__serverMessage:n};break;default:typeof t=="object"&&!Array.isArray(t)&&(o=t);}r=new u(e,o);}return se(r,Te),r}var Hd=e=>{let t=e.filter(a=>a.length);if(t.length===0)return e.length?e[0]:new Uint8Array;if(t.length===1)return t[0];let n=t.reduce((a,i)=>a+i.length,0),r=new Uint8Array(n),o=0;return t.forEach(a=>{r.set(a,o),o+=a.length;}),r},Nc=(e,t)=>{if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n},Tc=(e,t)=>Nc(e.length<=t?e:e.slice(0,t),t);function ce(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?!1:t.every((o,a)=>o===r[a])}function V(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function O(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(V(t,e));return e.write(t,n,0),n}})}function T(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function mc(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0],encode:t=>{let n=new Uint8Array(V(t,e));return e.write(t,n,0),n}})}function m(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function q(e){if(!m(e))throw new u(hn)}function bo(e){return !m(e)}function Wd(e){if(!bo(e))throw new u(Ln)}function E(e,t){if(m(e)!==m(t))throw new u(bn);if(m(e)&&m(t)&&e.fixedSize!==t.fixedSize)throw new u(Dn,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!m(e)&&!m(t)&&e.maxSize!==t.maxSize)throw new u(yn,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return {...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function gc(e,t){let n=(r,o,a)=>{let i=e.encode(r);if(Do(i,t)>=0)throw new u(zn,{encodedBytes:i,hexEncodedBytes:He(i),hexSentinel:He(t),sentinel:t});return o.set(i,a),a+=i.length,o.set(t,a),a+=t.length,a};return m(e)?O({...e,fixedSize:e.fixedSize+t.length,write:n}):O({...e,...e.maxSize!=null?{maxSize:e.maxSize+t.length}:{},getSizeFromValue:r=>e.getSizeFromValue(r)+t.length,write:n})}function pc(e,t){let n=(r,o)=>{let a=o===0?r:r.slice(o),i=Do(a,t);if(i===-1)throw new u(kn,{decodedBytes:a,hexDecodedBytes:He(a),hexSentinel:He(t),sentinel:t});let s=a.slice(0,i);return [e.decode(s),o+s.length+t.length]};return m(e)?T({...e,fixedSize:e.fixedSize+t.length,read:n}):T({...e,...e.maxSize!=null?{maxSize:e.maxSize+t.length}:{},read:n})}function $d(e,t){return E(gc(e,t),pc(e,t))}function Do(e,t){return e.findIndex((n,r,o)=>t.length===1?n===t[0]:ce(o,t,r))}function He(e){return e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),"")}function yo(e,t,n=0){if(t.length-n<=0)throw new u(In,{codecDescription:e})}function _e(e,t,n,r=0){let o=n.length-r;if(o<t)throw new u(Cn,{bytesLength:o,codecDescription:e,expected:t})}function We(e,t,n){if(t<0||t>n)throw new u(Bn,{bytesLength:n,codecDescription:e,offset:t})}function Jn(e,t){var i,s;let n=(c,_,d)=>{let l=e.encode(c);return d=t.write(l.length,_,d),_.set(l,d),d+l.length};if(m(t)&&m(e))return O({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=m(t)?t.fixedSize:(i=t.maxSize)!=null?i:null,o=m(e)?e.fixedSize:(s=e.maxSize)!=null?s:null,a=r!==null&&o!==null?r+o:null;return O({...e,...a!==null?{maxSize:a}:{},getSizeFromValue:c=>{let _=V(c,e);return V(_,t)+_},write:n})}function Zn(e,t){var i,s;let n=(c,_)=>{let[d,l]=t.read(c,_),f=Number(d);return _=l,(_>0||c.length>f)&&(c=c.slice(_,_+f)),_e("addDecoderSizePrefix",f,c),[e.decode(c),_+f]};if(m(t)&&m(e))return T({...e,fixedSize:t.fixedSize+e.fixedSize,read:n});let r=m(t)?t.fixedSize:(i=t.maxSize)!=null?i:null,o=m(e)?e.fixedSize:(s=e.maxSize)!=null?s:null,a=r!==null&&o!==null?r+o:null;return T({...e,...a!==null?{maxSize:a}:{},read:n})}function Yd(e,t){return E(Jn(e,t),Zn(e,t))}function v(e,t){return O({fixedSize:t,write:(n,r,o)=>{let a=e.encode(n),i=a.length>t?a.slice(0,t):a;return r.set(i,o),o+t}})}function w(e,t){return T({fixedSize:t,read:(n,r)=>{_e("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),m(e)&&(n=Tc(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function Xd(e,t){return E(v(e,t),w(e,t))}function Qn(e,t){return O({...e,write:(n,r,o)=>{let a=_=>vo(_,r.length),i=t.preOffset?t.preOffset({bytes:r,preOffset:o,wrapBytes:a}):o;We("offsetEncoder",i,r.length);let s=e.write(n,r,i),c=t.postOffset?t.postOffset({bytes:r,newPreOffset:i,postOffset:s,preOffset:o,wrapBytes:a}):s;return We("offsetEncoder",c,r.length),c}})}function er(e,t){return T({...e,read:(n,r)=>{let o=_=>vo(_,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;We("offsetDecoder",a,n.length);let[i,s]=e.read(n,a),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:a,postOffset:s,preOffset:r,wrapBytes:o}):s;return We("offsetDecoder",c,n.length),[i,c]}})}function Kd(e,t){return E(Qn(e,t),er(e,t))}function vo(e,t){return t===0?0:(e%t+t)%t}function tr(e,t){if(m(e)){let n=t(e.fixedSize);if(n<0)throw new u(Oe,{bytesLength:n,codecDescription:"resizeEncoder"});return O({...e,fixedSize:n})}return O({...e,getSizeFromValue:n=>{let r=t(e.getSizeFromValue(n));if(r<0)throw new u(Oe,{bytesLength:r,codecDescription:"resizeEncoder"});return r}})}function nr(e,t){if(m(e)){let n=t(e.fixedSize);if(n<0)throw new u(Oe,{bytesLength:n,codecDescription:"resizeDecoder"});return T({...e,fixedSize:n})}return e}function jd(e,t){return E(tr(e,t),nr(e,t))}function Ic(e,t){return Qn(tr(e,n=>n+t),{preOffset:({preOffset:n})=>n+t})}function Cc(e,t){return Qn(tr(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function hc(e,t){return er(nr(e,n=>n+t),{preOffset:({preOffset:n})=>n+t})}function rr(e,t){return er(nr(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function qd(e,t){return E(Ic(e,t),hc(e,t))}function Jd(e,t){return E(Cc(e,t),rr(e,t))}function wo(e,t,n,r,o=0){for(;n<--r;){let a=e[n];t[n+o]=e[r],t[r+o]=a,n++;}n===r&&(t[n+o]=e[n]);}function Lc(e){return q(e),O({...e,write:(t,n,r)=>{let o=e.write(t,n,r);return wo(n,n,r,r+e.fixedSize),o}})}function bc(e){return q(e),T({...e,read:(t,n)=>{let r=t.slice();return wo(t,r,n,n+e.fixedSize),e.read(r,n)}})}function Zd(e){return E(Lc(e),bc(e))}function p(e,t){return O({...bo(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function I(e,t){return T({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function Qd(e,t,n){return mc({...p(e,t),read:n?I(e,n).read:e.read})}function Fo(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new u($,{alphabet:e,base:e.length,value:n})}var ar=e=>O({getSizeFromValue:t=>{let[n,r]=Po(t,e[0]);if(!r)return t.length;let o=xo(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Fo(e,t),t==="")return r;let[o,a]=Po(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=xo(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),ir=e=>T({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,_)=>c*256n+BigInt(_),0n),s=Dc(i,e);return [a+s,t.length]}}),zo=e=>E(ar(e),ir(e));function Po(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function xo(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Dc(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var sr="0123456789",rl=()=>ar(sr),ol=()=>ir(sr),al=()=>zo(sr),Uo={alphabet:"0123456789abcdef",base:16};function or(e){if(e>=48&&e<=57)return e-48;if(e>=65&&e<=70)return e-55;if(e>=97&&e<=102)return e-87}var yc=()=>O({getSizeFromValue:e=>Math.ceil(e.length/2),write(e,t,n){let r=e.length,o=r/2;if(r===1){let i=e.charCodeAt(0),s=or(i);if(s===void 0)throw new u($,{...Uo,value:e});return t.set([s],n),1+n}let a=new Uint8Array(o);for(let i=0,s=0;i<o;i++){let c=e.charCodeAt(s++),_=e.charCodeAt(s++),d=or(c),l=or(_);if(d===void 0||l===void 0&&!Number.isNaN(_))throw new u($,{...Uo,value:e});a[i]=Number.isNaN(_)?d:d<<4|(l!=null?l:0);}return t.set(a,n),a.length+n}}),vc=()=>T({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}}),il=()=>E(yc(),vc()),cr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Y=()=>ar(cr),J=()=>ir(cr),sl=()=>zo(cr),wc=(e,t)=>O({getSizeFromValue:n=>Math.floor(n.length*t/8),write(n,r,o){if(Fo(e,n),n==="")return o;let a=[...n].map(s=>e.indexOf(s)),i=ko(a,t,8,!1);return r.set(i,o),i.length+o}}),Pc=(e,t)=>T({read(n,r=0){let o=r===0?n:n.slice(r);return o.length===0?["",n.length]:[ko([...o],8,t,!0).map(i=>e[i]).join(""),n.length]}}),cl=(e,t)=>E(wc(e,t),Pc(e,t));function ko(e,t,n,r){let o=[],a=0,i=0,s=(1<<n)-1;for(let c of e)for(a=a<<t|c,i+=t;i>=n;)i-=n,o.push(a>>i&s);return r&&i>0&&o.push(a<<n-i&s),o}var Bo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",me=()=>O({getSizeFromValue:e=>{try{return atob(e).length}catch{throw new u($,{alphabet:Bo,base:64,value:e})}},write(e,t,n){try{let r=atob(e).split("").map(o=>o.charCodeAt(0));return t.set(r,n),r.length+n}catch{throw new u($,{alphabet:Bo,base:64,value:e})}}}),_r=()=>T({read(e,t=0){let n=e.slice(t);return [btoa(String.fromCharCode(...n)),e.length]}}),_l=()=>E(me(),_r()),xc=e=>e.replace(/\u0000/g,""),ul=(e,t)=>e.padEnd(t,"\0"),Uc=globalThis.TextDecoder,Mo=globalThis.TextEncoder,Bc=()=>{let e;return O({getSizeFromValue:t=>(e||(e=new Mo)).encode(t).length,write:(t,n,r)=>{let o=(e||(e=new Mo)).encode(t);return n.set(o,r),r+o.length}})},Mc=()=>{let e;return T({read(t,n){let r=(e||(e=new Uc)).decode(t.slice(n));return [xc(r),t.length]}})},dl=()=>E(Bc(),Mc());var El=128;function Al(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new u(Ut,{address:e.address})}}function Vo(e){return !("exists"in e)||"exists"in e&&e.exists}function Sl(e){if(Vo(e)&&e.data instanceof Uint8Array)throw new u(Bt,{address:e.address})}function Go(e){let t=e.filter(n=>Vo(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new u(Mt,{addresses:n})}}function $e(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=me().encode(t.data[0]);return Object.freeze({...ur(t),address:e,data:n,exists:!0})}function Ol(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=Y().encode(typeof t.data=="string"?t.data:t.data[0]);return Object.freeze({...ur(t),address:e,data:n,exists:!0})}function Ho(e,t){if(!t)return Object.freeze({address:e,exists:!1});let n=t.data.parsed.info;return Object.freeze({...ur(t),address:e,data:n,exists:!0})}function ur(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner})}async function Nl(e,t,n={}){let{abortSignal:r,...o}=n,a=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return $e(t,a.value)}async function Tl(e,t,n={}){let{abortSignal:r,...o}=n,{value:a}=await e.getAccountInfo(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r});return a&&typeof a=="object"&&"parsed"in a.data?Ho(t,a):$e(t,a)}async function ml(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"base64"}).send({abortSignal:r})).value.map((i,s)=>$e(t[s],i))}async function Wo(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((i,s)=>i&&typeof i=="object"&&"parsed"in i.data?Ho(t[s],i):$e(t[s],i))}function gl(e){if(!e.exists)throw new u(Pt,{address:e.address})}function $o(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new u(xt,{addresses:n})}}function ge(){if(!globalThis.isSecureContext)throw new u(Ft)}var oe;async function Fc(e){return oe===void 0&&(oe=new Promise(t=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{t(oe=!1);}).then(()=>{t(oe=!0);});})),typeof oe=="boolean"?oe:await oe}function Yo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.digest)!="function")throw new u(zt)}async function Xo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.generateKey)!="function")throw new u(Gt);if(!await Fc(globalThis.crypto.subtle))throw new u(kt)}function Ko(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.exportKey)!="function")throw new u(Vt)}function jo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.sign)!="function")throw new u(Ht)}function qo(){var e;if(ge(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.verify)!="function")throw new u(Wt)}function Jo(){if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function")throw new u($t)}var dr,lr;function Rr(){return dr||(dr=Y()),dr}function zc(){return lr||(lr=J()),lr}function fr(e){return !(e.length<32||e.length>44||Rr().encode(e).byteLength!==32)}function pe(e){if(e.length<32||e.length>44)throw new u(ht,{actualLength:e.length});let r=Rr().encode(e).byteLength;if(r!==32)throw new u(Ct,{actualLength:r})}function kc(e){return pe(e),e}function Ke(){return p(v(Rr(),32),e=>kc(e))}function ae(){return w(zc(),32)}function ea(){return E(Ke(),ae())}function je(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var Vc=37095705934669439343138083508754565189542113879843219016388785533085940283555n,D=57896044618658097711785492504343953926634992332820282019728792003956564819949n,Zo=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function x(e){let t=e%D;return t>=0n?t:D+t}function G(e,t){let n=e;for(;t-- >0n;)n*=n,n%=D;return n}function Gc(e){let n=e*e%D*e%D,r=G(n,2n)*n%D,o=G(r,1n)*e%D,a=G(o,5n)*o%D,i=G(a,10n)*a%D,s=G(i,20n)*i%D,c=G(s,40n)*s%D,_=G(c,80n)*c%D,d=G(_,80n)*c%D,l=G(d,10n)*a%D;return G(l,2n)*e%D}function Hc(e,t){let n=x(t*t*t),r=x(n*n*t),o=Gc(e*r),a=x(e*n*o),i=x(t*a*a),s=a,c=x(a*Zo),_=i===e,d=i===x(-e),l=i===x(-e*Zo);return _&&(a=s),(d||l)&&(a=c),(x(a)&1n)===1n&&(a=x(-a)),!_&&!d?null:a}function Wc(e,t){let n=x(e*e),r=x(n-1n),o=x(Vc*n+1n),a=Hc(r,o);if(a===null)return !1;let i=(t&128)!==0;return !(a===0n&&i)}function $c(e){let t=e.toString(16);return t.length===1?`0${t}`:t}function Yc(e){let n=`0x${e.reduce((r,o,a)=>`${$c(a===31?o&-129:o)}${r}`,"")}`;return BigInt(n)}function Xc(e){if(e.byteLength!==32)return !1;let t=Yc(e);return Wc(t,e[31])}function yl(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"&&e[1]>=0&&e[1]<=255&&fr(e[0])}function vl(e){if(!(Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="number"))throw new u(bt);if(e[1]<0||e[1]>255)throw new u(Dt,{bump:e[1]});pe(e[0]);}var Xe=32,Qo=16,Ye=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function Kc({programAddress:e,seeds:t}){if(Yo(),t.length>Qo)throw new u(yt,{actual:t.length,maxSeeds:Qo});let n,r=t.reduce((c,_,d)=>{let l=typeof _=="string"?(n||(n=new TextEncoder)).encode(_):_;if(l.byteLength>Xe)throw new u(xe,{actual:l.byteLength,index:d,maxSeedLength:Xe});return c.push(...l),c},[]),o=ea(),a=o.encode(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...r,...a,...Ye])),s=new Uint8Array(i);if(Xc(s))throw new u(Ue);return o.decode(s)}async function wl({programAddress:e,seeds:t}){let n=255;for(;n>0;)try{return [await Kc({programAddress:e,seeds:[...t,new Uint8Array([n])]}),n]}catch(r){if(Ve(r,Ue))n--;else throw r}throw new u(vt)}async function Pl({baseAddress:e,programAddress:t,seed:n}){let{encode:r,decode:o}=ea(),a=typeof n=="string"?new TextEncoder().encode(n):n;if(a.byteLength>Xe)throw new u(xe,{actual:a.byteLength,index:0,maxSeedLength:Xe});let i=r(t);if(i.length>=Ye.length&&i.slice(-Ye.length).every((_,d)=>_===Ye[d]))throw new u(wt);let s=await crypto.subtle.digest("SHA-256",new Uint8Array([...r(e),...a,...i])),c=new Uint8Array(s);return o(c)}async function qe(e){if(Ko(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new u(Lt);let t=await crypto.subtle.exportKey("raw",e);return ae().decode(new Uint8Array(t))}function ta(e,t,n,r){if(r<t||r>n)throw new u(Un,{codecDescription:e,max:n,min:t,value:r})}var jc=(e=>(e[e.Little=0]="Little",e[e.Big=1]="Big",e))(jc||{});function na(e){return (e==null?void 0:e.endian)!==1}function U(e){return O({fixedSize:e.size,write(t,n,r){e.range&&ta(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,na(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function B(e){return T({fixedSize:e.size,read(t,n=0){yo(e.name,t,n),_e(e.name,e.size,t,n);let r=new DataView(qc(t,n,e.size));return [e.get(r,na(e.config)),n+e.size]}})}function qc(e,t,n){let r=e.byteOffset+(t!=null?t:0),o=n!=null?n:e.byteLength;return e.buffer.slice(r,r+o)}var Jc=(e={})=>U({config:e,name:"f32",set:(t,n,r)=>t.setFloat32(0,Number(n),r),size:4}),Zc=(e={})=>B({config:e,get:(t,n)=>t.getFloat32(0,n),name:"f32",size:4}),Ml=(e={})=>E(Jc(e),Zc(e)),Qc=(e={})=>U({config:e,name:"f64",set:(t,n,r)=>t.setFloat64(0,Number(n),r),size:8}),e_=(e={})=>B({config:e,get:(t,n)=>t.getFloat64(0,n),name:"f64",size:8}),Fl=(e={})=>E(Qc(e),e_(e)),t_=(e={})=>U({config:e,name:"i128",range:[-BigInt("0x7fffffffffffffffffffffffffffffff")-1n,BigInt("0x7fffffffffffffffffffffffffffffff")],set:(t,n,r)=>{let o=r?8:0,a=r?0:8,i=0xffffffffffffffffn;t.setBigInt64(o,BigInt(n)>>64n,r),t.setBigUint64(a,BigInt(n)&i,r);},size:16}),n_=(e={})=>B({config:e,get:(t,n)=>{let r=n?8:0,o=n?0:8,a=t.getBigInt64(r,n),i=t.getBigUint64(o,n);return (a<<64n)+i},name:"i128",size:16}),zl=(e={})=>E(t_(e),n_(e)),r_=(e={})=>U({config:e,name:"i16",range:[-+"0x7fff"-1,+"0x7fff"],set:(t,n,r)=>t.setInt16(0,Number(n),r),size:2}),o_=(e={})=>B({config:e,get:(t,n)=>t.getInt16(0,n),name:"i16",size:2}),kl=(e={})=>E(r_(e),o_(e)),a_=(e={})=>U({config:e,name:"i32",range:[-+"0x7fffffff"-1,+"0x7fffffff"],set:(t,n,r)=>t.setInt32(0,Number(n),r),size:4}),i_=(e={})=>B({config:e,get:(t,n)=>t.getInt32(0,n),name:"i32",size:4}),Vl=(e={})=>E(a_(e),i_(e)),s_=(e={})=>U({config:e,name:"i64",range:[-BigInt("0x7fffffffffffffff")-1n,BigInt("0x7fffffffffffffff")],set:(t,n,r)=>t.setBigInt64(0,BigInt(n),r),size:8}),c_=(e={})=>B({config:e,get:(t,n)=>t.getBigInt64(0,n),name:"i64",size:8}),Gl=(e={})=>E(s_(e),c_(e)),__=()=>U({name:"i8",range:[-+"0x7f"-1,+"0x7f"],set:(e,t)=>e.setInt8(0,Number(t)),size:1}),u_=()=>B({get:e=>e.getInt8(0),name:"i8",size:1}),Hl=()=>E(__(),u_()),k=()=>O({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{ta("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let a=Number(e)>>o*7;if(a===0)break;let i=127&a;r[o]=i,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}}),M=()=>T({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,a=e[t+o],i=127&a;if(n|=i<<o*7,!(a&128))break}return [n,t+r]}}),Wl=()=>E(k(),M()),d_=(e={})=>U({config:e,name:"u128",range:[0n,BigInt("0xffffffffffffffffffffffffffffffff")],set:(t,n,r)=>{let o=r?8:0,a=r?0:8,i=0xffffffffffffffffn;t.setBigUint64(o,BigInt(n)>>64n,r),t.setBigUint64(a,BigInt(n)&i,r);},size:16}),l_=(e={})=>B({config:e,get:(t,n)=>{let r=n?8:0,o=n?0:8,a=t.getBigUint64(r,n),i=t.getBigUint64(o,n);return (a<<64n)+i},name:"u128",size:16}),$l=(e={})=>E(d_(e),l_(e)),R_=(e={})=>U({config:e,name:"u16",range:[0,+"0xffff"],set:(t,n,r)=>t.setUint16(0,Number(n),r),size:2}),f_=(e={})=>B({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2}),Yl=(e={})=>E(R_(e),f_(e)),Ie=(e={})=>U({config:e,name:"u32",range:[0,+"0xffffffff"],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Er=(e={})=>B({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4}),Xl=(e={})=>E(Ie(e),Er(e)),Ar=(e={})=>U({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),Sr=(e={})=>B({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8}),Kl=(e={})=>E(Ar(e),Sr(e)),y=()=>U({name:"u8",range:[0,+"0xff"],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),b=()=>B({get:e=>e.getUint8(0),name:"u8",size:1}),jl=()=>E(y(),b());function ra(e,t,n){if(t!==n)throw new u(vn,{actual:n,codecDescription:e,expected:t})}function E_(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function ee(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function ue(e){return m(e)?e.fixedSize:null}function ie(e){var t;return m(e)?e.fixedSize:(t=e.maxSize)!=null?t:null}function z(e,t={}){var a,i;let n=(a=t.size)!=null?a:Ie(),r=Je(n,ue(e)),o=(i=Je(n,ie(e)))!=null?i:void 0;return O({...r!==null?{fixedSize:r}:{getSizeFromValue:s=>(typeof n=="object"?V(s.length,n):0)+[...s].reduce((_,d)=>_+V(d,e),0),maxSize:o},write:(s,c,_)=>(typeof n=="number"&&ra("array",n,s.length),typeof n=="object"&&(_=n.write(s.length,c,_)),s.forEach(d=>{_=e.write(d,c,_);}),_)})}function P(e,t={}){var i,s;let n=(i=t.size)!=null?i:Er(),r=ue(e),o=Je(n,r),a=(s=Je(n,ie(e)))!=null?s:void 0;return T({...o!==null?{fixedSize:o}:{maxSize:a},read:(c,_)=>{let d=[];if(typeof n=="object"&&c.slice(_).length===0)return [d,_];if(n==="remainder"){for(;_<c.length;){let[N,S]=e.read(c,_);_=S,d.push(N);}return [d,_]}let[l,f]=typeof n=="number"?[n,_]:n.read(c,_);_=f;for(let N=0;N<l;N+=1){let[S,A]=e.read(c,_);_=A,d.push(S);}return [d,_]}})}function eR(e,t={}){return E(z(e,t),P(e,t))}function Je(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function A_(e,t={}){var o;let r=(o=(typeof t=="boolean"?{backward:t}:t).backward)!=null?o:!1;return O({fixedSize:e,write(a,i,s){var _;let c=[];for(let d=0;d<e;d+=1){let l=0;for(let f=0;f<8;f+=1){let N=Number((_=a[d*8+f])!=null?_:0);l|=N<<(r?f:7-f);}r?c.unshift(l):c.push(l);}return i.set(c,s),e}})}function S_(e,t={}){var o;let r=(o=(typeof t=="boolean"?{backward:t}:t).backward)!=null?o:!1;return T({fixedSize:e,read(a,i){_e("bitArray",e,a,i);let s=[],c=a.slice(i,i+e);return c=r?c.reverse():c,c.forEach(_=>{for(let d=0;d<8;d+=1)r?(s.push(!!(_&1)),_>>=1):(s.push(!!(_&128)),_<<=1);}),[s,i+e]}})}function tR(e,t={}){return E(A_(e,t),S_(e,t))}function Ze(e={}){var t;return p((t=e.size)!=null?t:y(),n=>n?1:0)}function Qe(e={}){var t;return I((t=e.size)!=null?t:b(),n=>Number(n)===1)}function nR(e={}){return E(Ze(e),Qe(e))}function de(){return O({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}function le(){return T({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function rR(){return E(de(),le())}var O_=()=>T({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function et(e){return O({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function tt(e){return T({fixedSize:e.length,read:(t,n)=>{let r=O_();if(!ce(t,e,n))throw new u(Fn,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function oR(e){return E(et(e),tt(e))}function H(e){var r;let t=ee(e.map(ue)),n=(r=ee(e.map(ie)))!=null?r:void 0;return O({...t===null?{getSizeFromValue:o=>e.map((a,i)=>V(o[i],a)).reduce((a,i)=>a+i,0),maxSize:n}:{fixedSize:t},write:(o,a,i)=>(ra("tuple",e.length,o.length),e.forEach((s,c)=>{i=s.write(o[c],a,i);}),i)})}function F(e){var r;let t=ee(e.map(ue)),n=(r=ee(e.map(ie)))!=null?r:void 0;return T({...t===null?{maxSize:n}:{fixedSize:t},read:(o,a)=>{let i=[];return e.forEach(s=>{let[c,_]=s.read(o,a);i.push(c),a=_;}),[i,a]}})}function aR(e){return E(H(e),F(e))}function Ce(e,t){let n=oa(e),r=(a,i,s)=>{let c=t(a);return Or(e,c),e[c].write(a,i,s)};if(n!==null)return O({fixedSize:n,write:r});let o=aa(e);return O({...o!==null?{maxSize:o}:{},getSizeFromValue:a=>{let i=t(a);return Or(e,i),V(a,e[i])},write:r})}function he(e,t){let n=oa(e),r=(a,i)=>{let s=t(a,i);return Or(e,s),e[s].read(a,i)};if(n!==null)return T({fixedSize:n,read:r});let o=aa(e);return T({...o!==null?{maxSize:o}:{},read:r})}function iR(e,t,n){return E(Ce(e,t),he(e,n))}function Or(e,t){if(typeof e[t]>"u")throw new u(Mn,{maxRange:e.length-1,minRange:0,variant:t})}function oa(e){if(e.length===0)return 0;if(!m(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>m(r)&&r.fixedSize===t)?t:null}function aa(e){return E_(e.map(t=>ie(t)))}function ia(e,t={}){var o,a;let n=(o=t.discriminator)!=null?o:"__kind",r=(a=t.size)!=null?a:y();return Ce(e.map(([,i],s)=>p(H([r,i]),c=>[s,c])),i=>T_(e,i[n]))}function sa(e,t={}){var o,a;let n=(o=t.discriminator)!=null?o:"__kind",r=(a=t.size)!=null?a:b();return he(e.map(([i,s])=>I(F([r,s]),([,c])=>({[n]:i,...c}))),(i,s)=>Number(r.read(i,s)[0]))}function N_(e,t={}){return E(ia(e,t),sa(e,t))}function T_(e,t){let n=e.findIndex(([r])=>t===r);if(n<0)throw new u(Pn,{value:t,variants:e.map(([r])=>r)});return n}var sR=ia,cR=sa,_R=N_;function ca(e){let t=[...new Set(Object.values(e).filter(i=>typeof i=="number"))].sort(),n=Object.fromEntries(Object.entries(e).slice(t.length)),r=Object.keys(n),o=Object.values(n),a=[...new Set([...r,...o.filter(i=>typeof i=="string")])];return {enumKeys:r,enumRecord:n,enumValues:o,numericalValues:t,stringValues:a}}function m_({enumKeys:e,enumValues:t,variant:n}){let r=_a(t,o=>o===n);return r>=0?r:e.findIndex(o=>o===n)}function g_({discriminator:e,enumKeys:t,enumValues:n,useValuesAsDiscriminators:r}){return r?_a(n,o=>o===e):e>=0&&e<t.length?e:-1}function _a(e,t){let n=e.length;for(;n--;)if(t(e[n],n,e))return n;return -1}function ua(e){if(e.length===0)return "";let t=[e[0],e[0]],n=[];for(let r=1;r<e.length;r++){let o=e[r];t[1]+1===o?t[1]=o:(n.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),t=[o,o]);}return n.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),n.join(", ")}function da(e,t={}){var c,_;let n=(c=t.size)!=null?c:y(),r=(_=t.useValuesAsDiscriminators)!=null?_:!1,{enumKeys:o,enumValues:a,numericalValues:i,stringValues:s}=ca(e);if(r&&a.some(d=>typeof d=="string"))throw new u(ke,{stringValues:a.filter(d=>typeof d=="string")});return p(n,d=>{let l=m_({enumKeys:o,enumValues:a,variant:d});if(l<0)throw new u(xn,{formattedNumericalValues:ua(i),numericalValues:i,stringValues:s,variant:d});return r?a[l]:l})}function la(e,t={}){var s,c;let n=(s=t.size)!=null?s:b(),r=(c=t.useValuesAsDiscriminators)!=null?c:!1,{enumKeys:o,enumValues:a,numericalValues:i}=ca(e);if(r&&a.some(_=>typeof _=="string"))throw new u(ke,{stringValues:a.filter(_=>typeof _=="string")});return I(n,_=>{let d=Number(_),l=g_({discriminator:d,enumKeys:o,enumValues:a,useValuesAsDiscriminators:r});if(l<0){let f=r?i:[...Array(o.length).keys()];throw new u(wn,{discriminator:d,formattedValidDiscriminators:ua(f),validDiscriminators:f})}return a[l]})}function p_(e,t={}){return E(da(e,t),la(e,t))}var uR=da,dR=la,lR=p_;function I_(e,t){return p(H([...t,e]),n=>[...t.map(()=>{}),n])}function C_(e,t){return I(F([...t,e]),n=>n[n.length-1])}function RR(e,t){return E(I_(e,t),C_(e,t))}function h_(e,t){return p(H([e,...t]),n=>[n,...t.map(()=>{})])}function L_(e,t){return I(F([e,...t]),n=>n[0])}function fR(e,t){return E(h_(e,t),L_(e,t))}function b_(e,t,n={}){return p(z(H([e,t]),n),r=>[...r.entries()])}function D_(e,t,n={}){return I(P(F([e,t]),n),r=>new Map(r))}function ER(e,t,n={}){return E(b_(e,t,n),D_(e,t,n))}function Z(){return O({fixedSize:0,write:(e,t,n)=>n})}function Q(){return T({fixedSize:0,read:(e,t)=>[void 0,t]})}function AR(){return E(Z(),Q())}function y_(e,t={}){let n=(()=>{var o;return t.prefix===null?p(Z(),a=>{}):Ze({size:(o=t.prefix)!=null?o:y()})})(),r=t.noneValue==="zeroes"?(q(e),v(Z(),e.fixedSize)):t.noneValue?et(t.noneValue):Z();return Ce([p(H([n,r]),o=>[!1,void 0]),p(H([n,e]),o=>[!0,o])],o=>+(o!==null))}function v_(e,t={}){let n=(()=>{var o;return t.prefix===null?I(Q(),()=>!1):Qe({size:(o=t.prefix)!=null?o:b()})})(),r=t.noneValue==="zeroes"?(q(e),w(Q(),e.fixedSize)):t.noneValue?tt(t.noneValue):Q();return he([I(F([n,r]),()=>null),I(F([n,e]),([,o])=>o)],(o,a)=>{if(t.prefix===null&&!t.noneValue)return +(a<o.length);if(t.prefix===null&&t.noneValue!=null){let i=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return ce(o,i,a)?0:1}return Number(n.read(o,a)[0])})}function SR(e,t={}){return E(y_(e,t),v_(e,t))}function w_(e,t={}){return p(z(e,t),n=>[...n])}function P_(e,t={}){return I(P(e,t),n=>new Set(n))}function OR(e,t={}){return E(w_(e,t),P_(e,t))}function X(e){var o;let t=e.map(([,a])=>a),n=ee(t.map(ue)),r=(o=ee(t.map(ie)))!=null?o:void 0;return O({...n===null?{getSizeFromValue:a=>e.map(([i,s])=>V(a[i],s)).reduce((i,s)=>i+s,0),maxSize:r}:{fixedSize:n},write:(a,i,s)=>(e.forEach(([c,_])=>{s=_.write(a[c],i,s);}),s)})}function te(e){var o;let t=e.map(([,a])=>a),n=ee(t.map(ue)),r=(o=ee(t.map(ie)))!=null?o:void 0;return T({...n===null?{maxSize:r}:{fixedSize:n},read:(a,i)=>{let s={};return e.forEach(([c,_])=>{let[d,l]=_.read(a,i);i=l,s[c]=d;}),[s,i]}})}function NR(e){return E(X(e),te(e))}var fa=e=>({__option:"Some",value:e}),Ea=()=>({__option:"None"}),Nr=e=>!!(e&&typeof e=="object"&&"__option"in e&&(e.__option==="Some"&&"value"in e||e.__option==="None")),nt=e=>e.__option==="Some",IR=e=>e.__option==="None";function CR(e,t){return nt(e)?e.value:t?t():null}var x_=e=>e!==null?fa(e):Ea();function U_(e,t={}){let n=(()=>{var o;return t.prefix===null?p(Z(),a=>{}):Ze({size:(o=t.prefix)!=null?o:y()})})(),r=t.noneValue==="zeroes"?(q(e),v(Z(),e.fixedSize)):t.noneValue?et(t.noneValue):Z();return Ce([p(H([n,r]),o=>[!1,void 0]),p(H([n,e]),o=>[!0,Nr(o)&&nt(o)?o.value:o])],o=>{let a=Nr(o)?o:x_(o);return Number(nt(a))})}function B_(e,t={}){let n=(()=>{var o;return t.prefix===null?I(Q(),()=>!1):Qe({size:(o=t.prefix)!=null?o:b()})})(),r=t.noneValue==="zeroes"?(q(e),w(Q(),e.fixedSize)):t.noneValue?tt(t.noneValue):Q();return he([I(F([n,r]),()=>Ea()),I(F([n,e]),([,o])=>fa(o))],(o,a)=>{if(t.prefix===null&&!t.noneValue)return +(a<o.length);if(t.prefix===null&&t.noneValue!=null){let i=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return ce(o,i,a)?0:1}return Number(n.read(o,a)[0])})}function hR(e,t={}){return E(U_(e,t),B_(e,t))}function Ra(e,t){if(!e||ArrayBuffer.isView(e))return e;let n=r=>t?Ra(r,t):Ra(r);return Nr(e)?nt(e)?n(e.value):t?t():null:Array.isArray(e)?e.map(n):typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,n(o)])):e}function K(e,...t){return t.reduce((n,r)=>r(n),e)}function Aa(e,t){return e.programAddress===t}function yR(e,t){if(e.programAddress!==t)throw new u(Qt,{actualProgramAddress:e.programAddress,expectedProgramAddress:t})}function vR(e){return e.accounts!==void 0}function wR(e){if(e.accounts===void 0)throw new u(Jt,{data:e.data,programAddress:e.programAddress})}function Sa(e){return e.data!==void 0}function PR(e){var t;if(e.data===void 0)throw new u(Zt,{accountAddresses:(t=e.accounts)==null?void 0:t.map(n=>n.address),programAddress:e.programAddress})}var L=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(L||{}),Oa=2,Tr=1;function xR(e){return e&~Oa}function UR(e){return e&~Tr}function W(e){return e>=2}function Re(e){return (e&Tr)!==0}function mr(e,t){return e|t}function BR(e){return e|Oa}function MR(e){return e|Tr}function M_(e){return new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32,...e])}async function F_(e,t){let n=e.byteLength;if(n!==32)throw new u(Xt,{actualLength:n});let r=M_(e);return await crypto.subtle.importKey("pkcs8",r,"Ed25519",t!=null?t:!1,["sign"])}var fe;function z_(e){if(fe||(fe=Y()),e.length<64||e.length>88)throw new u(jt,{actualLength:e.length});let n=fe.encode(e).byteLength;if(n!==64)throw new u(Kt,{actualLength:n})}function GR(e){return fe||(fe=Y()),!(e.length<64||e.length>88||fe.encode(e).byteLength!==64)}async function Le(e,t){jo();let n=await crypto.subtle.sign("Ed25519",e,t);return new Uint8Array(n)}function HR(e){return z_(e),e}async function k_(e,t,n){return qo(),await crypto.subtle.verify("Ed25519",e,t,n)}async function Na(){return await Xo(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function Ta(e,t){if(Jo(),e.byteLength!==64)throw new u(Yt,{byteLength:e.byteLength});let[n,r]=await Promise.all([crypto.subtle.importKey("raw",e.slice(32),"Ed25519",!0,["verify"]),F_(e.slice(0,32),t)]),o=new Uint8Array(32);crypto.getRandomValues(o);let a=await Le(r,o);if(!await k_(n,a,o))throw new u(qt);return {privateKey:r,publicKey:n}}function YR(e,t,n,r){var a;if(!Ve(e,Be))return !1;let o=(a=t.instructions[e.context.index])==null?void 0:a.programAddress;return !o||o!==n?!1:typeof r>"u"||e.context.code===r}var gr=0;function V_(){let e=gr;return gr=(gr+1)%Number.MAX_SAFE_INTEGER,e}function be(e,t){return {id:V_(),jsonrpc:"2.0",method:e,params:t}}function ma(e){return G_(e)}function G_(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(t,n,r){return function(...o){let a=n.toString(),i=Reflect.get(t,a,r),s=i?i(...o):{methodName:a,params:o};return H_(e,s)}}})}function H_(e,t){return {async send(n){let{methodName:r,params:o,responseTransformer:a}=t,i=be(r,o),s=await e.transport({payload:i,signal:n==null?void 0:n.abortSignal});return a?a(s,r):s}}}function ga(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...t){let[n,r]=t,o=r.toString();return function(...a){let i=e!=null&&e.parametersTransformer?e==null?void 0:e.parametersTransformer(a,o):a,s=e!=null&&e.responseTransformer?e==null?void 0:e.responseTransformer:c=>c;return {methodName:o,params:i,responseTransformer:s}}}})}function W_({commitmentPropertyName:e,params:t,optionsObjectPositionInParams:n,overrideCommitment:r}){let o=t[n];if(o===void 0||o&&typeof o=="object"&&!Array.isArray(o)){if(o&&e in o){if(!o[e]||o[e]==="finalized"){let a=[...t],{[e]:i,...s}=o;return Object.keys(s).length>0?a[n]=s:n===a.length-1?a.length--:a[n]=void 0,a}}else if(r!=="finalized"){let a=[...t];return a[n]={...o,[e]:r},a}}return t}function $_(e){return typeof e=="bigint"?Number(e):e}function Y_(e){return (t,{keyPath:n})=>(typeof t=="bigint"&&e&&(t>Number.MAX_SAFE_INTEGER||t<-Number.MAX_SAFE_INTEGER)&&e(n,t),t)}var X_={accountNotifications:1,blockNotifications:1,getAccountInfo:1,getBalance:1,getBlock:1,getBlockHeight:0,getBlockProduction:0,getBlocks:2,getBlocksWithLimit:2,getConfirmedBlock:1,getConfirmedBlocks:1,getConfirmedBlocksWithLimit:2,getConfirmedSignaturesForAddress2:1,getConfirmedTransaction:1,getEpochInfo:0,getFeeCalculatorForBlockhash:1,getFeeForMessage:1,getFees:1,getInflationGovernor:0,getInflationReward:1,getLargestAccounts:0,getLatestBlockhash:0,getLeaderSchedule:1,getMinimumBalanceForRentExemption:1,getMultipleAccounts:1,getProgramAccounts:1,getRecentBlockhash:1,getSignaturesForAddress:1,getSlot:0,getSlotLeader:0,getStakeActivation:1,getStakeMinimumDelegation:0,getSupply:0,getTokenAccountBalance:1,getTokenAccountsByDelegate:2,getTokenAccountsByOwner:2,getTokenLargestAccounts:1,getTokenSupply:1,getTransaction:1,getTransactionCount:0,getVoteAccounts:0,isBlockhashValid:1,logsNotifications:1,programNotifications:1,requestAirdrop:2,sendTransaction:1,signatureNotifications:1,simulateTransaction:1},R={};function pa(e){return function t(n,r){if(Array.isArray(n))return n.map((o,a)=>{let i={...r,keyPath:[...r.keyPath,a]};return t(o,i)});if(typeof n=="object"&&n!==null){let o={};for(let a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;let i={...r,keyPath:[...r.keyPath,a]};o[a]=t(n[a],i);}return o}else return e.reduce((o,a)=>a(o,r),n)}}function rt(e){let t=e==null?void 0:e.defaultCommitment,n=e==null?void 0:e.onIntegerOverflow;return (r,o)=>{let s=pa([...n?[Y_((..._)=>n(o,..._))]:[],$_])(r,{keyPath:[]});if(!Array.isArray(s))return s;let c=X_[o];return c==null?s:K(s,_=>W_({commitmentPropertyName:o==="sendTransaction"?"preflightCommitment":"commitment",optionsObjectPositionInParams:c,overrideCommitment:t,params:_}),_=>o==="sendTransaction"?K_(_):_)}}function K_(e){var t;return ((t=e[1])==null?void 0:t.skipPreflight)!==!0?e:[e[0],{...e[1],preflightCommitment:"processed"},...e.slice(2)]}function j_(e,t){return t.some(n=>{if(n.length!==e.length)return !1;for(let r=e.length-1;r>=0;r--){let o=e[r],a=n[r];if(a!==o&&(a!==R||typeof o!="number"))return !1}return !0})}function q_(e){return function(n,{keyPath:r}){return typeof n=="number"&&Number.isInteger(n)&&!j_(r,e)?BigInt(n):n}}function ot(e){return (t,n)=>{if("error"in t)throw Te(t.error);let r=e!=null&&e.allowedNumericKeyPaths&&n?e.allowedNumericKeyPaths[n]:void 0,o=pa([q_(r!=null?r:[])]),a={keyPath:[]};return o(t.result,a)}}var at=[["data","parsed","info","tokenAmount","decimals"],["data","parsed","info","tokenAmount","uiAmount"],["data","parsed","info","rentExemptReserve","decimals"],["data","parsed","info","rentExemptReserve","uiAmount"],["data","parsed","info","delegatedAmount","decimals"],["data","parsed","info","delegatedAmount","uiAmount"],["data","parsed","info","extensions",R,"state","olderTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",R,"state","newerTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",R,"state","preUpdateAverageRate"],["data","parsed","info","extensions",R,"state","currentRate"]],ne=[...at,["data","parsed","info","lastExtendedSlotStartIndex"],["data","parsed","info","slashPenalty"],["data","parsed","info","warmupCooldownRate"],["data","parsed","info","decimals"],["data","parsed","info","numRequiredSigners"],["data","parsed","info","numValidSigners"],["data","parsed","info","stake","delegation","warmupCooldownRate"],["data","parsed","info","exemptionThreshold"],["data","parsed","info","burnPercent"],["data","parsed","info","commission"],["data","parsed","info","votes",R,"confirmationCount"]],it=[["index"],["instructions",R,"accounts",R],["instructions",R,"programIdIndex"],["instructions",R,"stackHeight"]],pr=[["addressTableLookups",R,"writableIndexes",R],["addressTableLookups",R,"readonlyIndexes",R],["header","numReadonlySignedAccounts"],["header","numReadonlyUnsignedAccounts"],["header","numRequiredSignatures"],["instructions",R,"accounts",R],["instructions",R,"programIdIndex"],["instructions",R,"stackHeight"]];function Ia(e){return ga({parametersTransformer:rt(e),responseTransformer:ot({allowedNumericKeyPaths:J_()})})}var Ir;function J_(){return Ir||(Ir={getAccountInfo:ne.map(e=>["value",...e]),getBlock:[["blockTime"],["transactions",R,"meta","preTokenBalances",R,"accountIndex"],["transactions",R,"meta","preTokenBalances",R,"uiTokenAmount","decimals"],["transactions",R,"meta","postTokenBalances",R,"accountIndex"],["transactions",R,"meta","postTokenBalances",R,"uiTokenAmount","decimals"],["transactions",R,"meta","rewards",R,"commission"],...it.map(e=>["transactions",R,"meta","innerInstructions",R,...e]),...pr.map(e=>["transactions",R,"transaction","message",...e]),["rewards",R,"commission"]],getBlockTime:[[]],getClusterNodes:[[R,"featureSet"],[R,"shredVersion"]],getInflationGovernor:[["initial"],["foundation"],["foundationTerm"],["taper"],["terminal"]],getInflationRate:[["foundation"],["total"],["validator"]],getInflationReward:[[R,"commission"]],getMultipleAccounts:ne.map(e=>["value",R,...e]),getProgramAccounts:ne.flatMap(e=>[["value",R,"account",...e],[R,"account",...e]]),getRecentPerformanceSamples:[[R,"samplePeriodSecs"]],getTokenAccountBalance:[["value","decimals"],["value","uiAmount"]],getTokenAccountsByDelegate:at.map(e=>["value",R,"account",...e]),getTokenAccountsByOwner:at.map(e=>["value",R,"account",...e]),getTokenLargestAccounts:[["value",R,"decimals"],["value",R,"uiAmount"]],getTokenSupply:[["value","decimals"],["value","uiAmount"]],getTransaction:[["meta","preTokenBalances",R,"accountIndex"],["meta","preTokenBalances",R,"uiTokenAmount","decimals"],["meta","postTokenBalances",R,"accountIndex"],["meta","postTokenBalances",R,"uiTokenAmount","decimals"],["meta","rewards",R,"commission"],...it.map(e=>["meta","innerInstructions",R,...e]),...pr.map(e=>["transaction","message",...e])],getVersion:[["feature-set"]],getVoteAccounts:[["current",R,"commission"],["delinquent",R,"commission"]],simulateTransaction:[...ne.map(e=>["value","accounts",R,...e]),...it.map(e=>["value","innerInstructions",R,...e])]}),Ir}function Z_(e){let t={};for(let n in e)t[n.toLowerCase()]=e[n];return t}function Ca(e){let{headers:t,url:n}=e,r,o=t&&Z_(t);return async function({payload:i,signal:s}){let c=JSON.stringify(i),_={...r,body:c,headers:{...o,accept:"application/json","content-length":c.length.toString(),"content-type":"application/json; charset=utf-8"},method:"POST",signal:s},d=await fetch(n,_);if(!d.ok)throw new u(Vn,{message:d.statusText,statusCode:d.status});return await d.json()}}var Q_=Object.prototype.toString,eu=Object.keys||function(e){let t=[];for(let n in e)t.push(n);return t};function De(e,t){let n,r,o,a,i,s,c;if(e===!0)return "true";if(e===!1)return "false";switch(typeof e){case"object":if(e===null)return null;if("toJSON"in e&&typeof e.toJSON=="function")return De(e.toJSON(),t);if(c=Q_.call(e),c==="[object Array]"){for(o="[",r=e.length-1,n=0;n<r;n++)o+=De(e[n],!0)+",";return r>-1&&(o+=De(e[n],!0)),o+"]"}else if(c==="[object Object]"){for(a=eu(e).sort(),r=a.length,o="",n=0;n<r;)i=a[n],s=De(e[i],!1),s!==void 0&&(o&&(o+=","),o+=JSON.stringify(i)+":"+s),n++;return "{"+o+"}"}else return JSON.stringify(e);case"function":case"undefined":return t?null:void 0;case"bigint":return `${e.toString()}n`;case"string":return JSON.stringify(e);default:return isFinite(e)?e:null}}function st(e){let t=De(e,!1);if(t!==void 0)return ""+t}function ba(e,t,n){let r="";if(typeof t[0]=="number"){let i=t[0]+1,s=i%10,c=i%100;s==1&&c!=11?r=i+"st":s==2&&c!=12?r=i+"nd":s==3&&c!=13?r=i+"rd":r=i+"th";}else r=`\`${t[0].toString()}\``;let o=t.length>1?t.slice(1).map(i=>typeof i=="number"?`[${i}]`:i).join("."):void 0,a=new u(Ne,{argumentLabel:r,keyPath:t,methodName:e,optionalPathLabel:o?` at path \`${o}\``:"",value:n,...o!==void 0?{path:o}:void 0});return se(a,ba),a}var tu={defaultCommitment:"confirmed",onIntegerOverflow(e,t,n){throw ba(e,t,n)}},ha;function La(){return {}}function nu(e,t){let n;return async function(o){let{payload:a,signal:i}=o,s=t(a);if(s===void 0)return await e(o);if(n||(Promise.resolve().then(()=>{n=void 0;}),n={}),n[s]==null){let _=new AbortController,d=(async()=>{try{return await e({...o,signal:_.signal})}catch(l){if(l===(ha||(ha=La())))return;throw l}})();n[s]={abortController:_,numConsumers:0,responsePromise:d};}let c=n[s];if(c.numConsumers++,i){let _=c.responsePromise;return await new Promise((d,l)=>{let f=N=>{i.removeEventListener("abort",f),c.numConsumers-=1,Promise.resolve().then(()=>{c.numConsumers===0&&c.abortController.abort(ha||(ha=La()));}),l(N.target.reason);};i.addEventListener("abort",f),_.then(d).catch(l).finally(()=>{i.removeEventListener("abort",f);});})}else return await c.responsePromise}}function ru(e){return e==null||typeof e!="object"||Array.isArray(e)?!1:"jsonrpc"in e&&e.jsonrpc==="2.0"&&"method"in e&&typeof e.method=="string"&&"params"in e}function ou(e){return ru(e)?st([e.method,e.params]):void 0}function au(e){let t={};for(let n in e)t[n.toLowerCase()]=e[n];return t}function iu(e){return K(Ca({...e,headers:{...e.headers?au(e.headers):void 0,"solana-client":"js/2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4"}}),t=>nu(t,ou))}function Rf(e,t){return su(iu({url:e,...t}))}function su(e){return ma({api:Ia(tu),transport:e})}function Da(e){return cu(e)}function cu(e){return new Proxy(e.api,{defineProperty(){return !1},deleteProperty(){return !1},get(t,n,r){return function(...o){let a=n.toString(),i=Reflect.get(t,a,r);if(n.toString().endsWith("Notifications")===!1&&!i)throw new u(Gn,{notificationName:a});let s=i?i(...o):{params:o,subscribeMethodName:a.replace(/Notifications$/,"Subscribe"),unsubscribeMethodName:a.replace(/Notifications$/,"Unsubscribe")};return uu(e,s)}}})}function _u(e,t){(async()=>{try{for await(let n of e);}catch{}finally{t();}})();}function uu(e,{params:t,subscribeMethodName:n,unsubscribeMethodName:r,responseTransformer:o}){return {async subscribe({abortSignal:a}){a.throwIfAborted();let i;function s(){if(i!==void 0){let f=be(r,[i]);d.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(f).finally(()=>{c.abort();});}else c.abort();}a.addEventListener("abort",s);let c=new AbortController,_=be(n,t),d=await e.transport({payload:_,signal:c.signal});function l(){a.removeEventListener("abort",s);}_u(d,l);for await(let f of d)if("id"in f&&f.id===_.id){if("error"in f)throw Te(f.error);i=f.result;break}if(i==null)throw new u(Hn);return {async*[Symbol.asyncIterator](){for await(let f of d){if(!("params"in f)||f.params.subscription!==i)continue;let N=f.params;yield o?o(N,n):N;}}}}}}function ya(e){return new Proxy({},{defineProperty(){return !1},deleteProperty(){return !1},get(...t){let[n,r]=t,o=r.toString();return function(...a){let i=e!=null&&e.parametersTransformer?e==null?void 0:e.parametersTransformer(a,o):a,s=e!=null&&e.responseTransformer?e==null?void 0:e.responseTransformer:d=>d,c=e!=null&&e.subscribeNotificationNameTransformer?e==null?void 0:e.subscribeNotificationNameTransformer(o):o,_=e!=null&&e.unsubscribeNotificationNameTransformer?e==null?void 0:e.unsubscribeNotificationNameTransformer(o):o;return {params:i,responseTransformer:s,subscribeMethodName:c,unsubscribeMethodName:_}}}})}function va(e){return ya({parametersTransformer:rt(e),responseTransformer:ot({allowedNumericKeyPaths:du()}),subscribeNotificationNameTransformer:t=>t.replace(/Notifications$/,"Subscribe"),unsubscribeNotificationNameTransformer:t=>t.replace(/Notifications$/,"Unsubscribe")})}function wa(e){return va(e)}function gf(e){return va(e)}var Cr;function du(){return Cr||(Cr={accountNotifications:ne.map(e=>["value",...e]),blockNotifications:[["value","block","blockTime"],["value","block","transactions",R,"meta","preTokenBalances",R,"accountIndex"],["value","block","transactions",R,"meta","preTokenBalances",R,"uiTokenAmount","decimals"],["value","block","transactions",R,"meta","postTokenBalances",R,"accountIndex"],["value","block","transactions",R,"meta","postTokenBalances",R,"uiTokenAmount","decimals"],["value","block","transactions",R,"meta","rewards",R,"commission"],["value","block","transactions",R,"meta","innerInstructions",R,"index"],["value","block","transactions",R,"meta","innerInstructions",R,"instructions",R,"programIdIndex"],["value","block","transactions",R,"meta","innerInstructions",R,"instructions",R,"accounts",R],["value","block","transactions",R,"transaction","message","addressTableLookups",R,"writableIndexes",R],["value","block","transactions",R,"transaction","message","addressTableLookups",R,"readonlyIndexes",R],["value","block","transactions",R,"transaction","message","instructions",R,"programIdIndex"],["value","block","transactions",R,"transaction","message","instructions",R,"accounts",R],["value","block","transactions",R,"transaction","message","header","numReadonlySignedAccounts"],["value","block","transactions",R,"transaction","message","header","numReadonlyUnsignedAccounts"],["value","block","transactions",R,"transaction","message","header","numRequiredSignatures"],["value","block","rewards",R,"commission"]],programNotifications:ne.flatMap(e=>[["value",R,"account",...e],[R,"account",...e]])}),Cr}var ye=globalThis.WebSocket,Pa;function xa(){return Symbol(void 0)}async function lu({sendBufferHighWatermark:e,signal:t,url:n}){return await new Promise((r,o)=>{t.addEventListener("abort",s,{once:!0});let a=new Map;function i(A){let g=[...a.values()].filter(h=>h.__hasPolled).map(({onError:h})=>h);a.clear(),g.forEach(h=>{try{h(A);}catch{}});}function s(){i(Pa||(Pa=xa())),S.readyState!==ye.CLOSED&&S.readyState!==ye.CLOSING&&S.close(1e3);}function c(A){l==null||l.onCancel(),t.removeEventListener("abort",s),S.removeEventListener("close",c),S.removeEventListener("error",_),S.removeEventListener("open",f),S.removeEventListener("message",N),i(A);}function _(A){d||o(new u(Yn,{errorEvent:A}));}let d=!1,l;function f(){d=!0,r({async send(A){let g=JSON.stringify(A);if(!l&&S.readyState===ye.OPEN&&S.bufferedAmount>e){let h,j=new Promise((Se,Ni)=>{let no=setInterval(()=>{(S.readyState!==ye.OPEN||!(S.bufferedAmount>e))&&(clearInterval(no),l=void 0,Se());},16);h=()=>{l=void 0,clearInterval(no),Ni(new u(Wn));};});l={onCancel:h,promise:j};}l&&await l.promise,S.send(g);},async*[Symbol.asyncIterator](){let A=Symbol();a.set(A,{__hasPolled:!1,queuedMessages:[]});try{for(;;){let g=a.get(A);if(!g)throw new u(Xn);if(g.__hasPolled)throw new u(Kn);let h=g.queuedMessages;if(h.length)g.queuedMessages=[],yield*h;else try{yield await new Promise((j,Se)=>{a.set(A,{__hasPolled:!0,onError:Se,onMessage:j});});}catch(j){if(j===(Pa||(Pa=xa())))return;throw new u($n,{cause:j})}}}finally{a.delete(A);}}});}function N({data:A}){let g=JSON.parse(A);a.forEach((h,j)=>{if(h.__hasPolled){let{onMessage:Se}=h;a.set(j,{__hasPolled:!1,queuedMessages:[]}),Se(g);}else h.queuedMessages.push(g);});}let S=new ye(n);S.addEventListener("close",c),S.addEventListener("error",_),S.addEventListener("open",f),S.addEventListener("message",N);})}function Ua({sendBufferHighWatermark:e,url:t}){if(/^wss?:/i.test(t)===!1){let n=t.match(/^([^:]+):/);throw new DOMException(n?`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${n[1]}:' is not allowed.`:`Failed to construct 'WebSocket': The URL '${t}' is invalid.`)}return async function({payload:r,signal:o}){o==null||o.throwIfAborted();let a=await lu({sendBufferHighWatermark:e,signal:o,url:t});return o==null||o.throwIfAborted(),await a.send(r),{[Symbol.asyncIterator]:a[Symbol.asyncIterator].bind(a),send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:a.send.bind(a)}}}function Ba(e,t,n){let r="";if(typeof t[0]=="number"){let i=t[0]+1,s=i%10,c=i%100;s==1&&c!=11?r=i+"st":s==2&&c!=12?r=i+"nd":s==3&&c!=13?r=i+"rd":r=i+"th";}else r=`\`${t[0].toString()}\``;let o=t.length>1?t.slice(1).map(i=>typeof i=="number"?`[${i}]`:i).join("."):void 0,a=new u(Ne,{argumentLabel:r,keyPath:t,methodName:e,optionalPathLabel:o?` at path \`${o}\``:"",value:n,...o!==void 0?{path:o}:void 0});return se(a,Ba),a}var Ru={defaultCommitment:"confirmed",onIntegerOverflow(e,t,n){throw Ba(e,t,n)}};function fu(e,t){(async()=>{try{for await(let n of e);}catch{}finally{t();}})();}function Ma({getAbortSignalFromInputArgs:e,getCacheKeyFromInputArgs:t,onCacheHit:n,onCreateIterable:r}){let o=new Map;function a(i){let s=o.get(i);if(!s)throw new u(jn,{cacheKey:i.toString()});return s}return async(...i)=>{let s=t(...i),c=e(...i);if(s===void 0)return await r(c,...i);let _=()=>{o.delete(s),c.removeEventListener("abort",d);},d=()=>{let l=a(s);l.purgeScheduled!==!0&&(l.purgeScheduled=!0,globalThis.queueMicrotask(()=>{l.purgeScheduled=!1,l.referenceCount===0&&(l.abortController.abort(),_());})),l.referenceCount--;};c.addEventListener("abort",d);try{let l=o.get(s);if(l){l.referenceCount++;let f=l.iterable,N="then"in f?await f:f;return await n(N,...i),N}else {let f=new AbortController,N=r(f.signal,...i),S={abortController:f,iterable:N,purgeScheduled:!1,referenceCount:1};o.set(s,S);let A=await N;return fu(A,_),S.iterable=A,A}}catch(l){throw _(),l}}}var hr;function Lr(){return Symbol(void 0)}function Eu(e,t){(async()=>{try{for await(let n of e);}catch{}finally{t();}})();}function Au({getDeduplicationKey:e,rpcSubscriptions:t}){let n=new Map;return new Proxy(t,{defineProperty(){return !1},deleteProperty(){return !1},get(r,o,a){let i=Reflect.get(r,o,a);return typeof i!="function"?i:function(...s){let c=e(o,s);if(c===void 0)return i(...s);if(n.has(c))return n.get(c);let _=Ma({getAbortSignalFromInputArgs:({abortSignal:l})=>l,getCacheKeyFromInputArgs:()=>c,async onCacheHit(l,f){},async onCreateIterable(l,f){let S=await i(...s).subscribe({...f,abortSignal:l});return Eu(S,()=>{n.delete(c);}),S}}),d={async subscribe(...l){let f=await _(...l),{abortSignal:N}=l[0],S;return {...f,async*[Symbol.asyncIterator](){S||(S=N.aborted?Promise.reject(hr||(hr=Lr())):new Promise((A,g)=>{N.addEventListener("abort",()=>{g(hr||(hr=Lr()));});}));try{let A=f[Symbol.asyncIterator]();for(;;){let g=await Promise.race([A.next(),S]);if(g.done)return;yield g.value;}}catch(A){if(A===(hr||(hr=Lr())))return;throw n.delete(c),A}}}}};return n.set(c,d),d}}})}var Su={jsonrpc:"2.0",method:"ping"};function Ou({intervalMs:e,transport:t}){let n=new Map;return async(...r)=>{let o=await t(...r),a;function i(){o.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(Su);}function s(){clearInterval(a),a=setInterval(i,e);}if(n.has(o)===!1){n.set(o,{[Symbol.asyncIterator]:o[Symbol.asyncIterator].bind(o),send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:(...d)=>(s(),o.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...d))}),(async()=>{try{for await(let d of o)s();}catch{}finally{n.delete(o),clearInterval(a),c&&globalThis.window.removeEventListener("offline",c),_&&globalThis.window.removeEventListener("online",_);}})(),globalThis.navigator.onLine&&s();let c,_;c=()=>{clearInterval(a);},_=()=>{i(),s();},globalThis.window.addEventListener("offline",c),globalThis.window.addEventListener("online",_);}return n.get(o)}}var Nu;function Tu(){return Symbol(void 0)}function mu({getShard:e,transport:t}){return Ma({getAbortSignalFromInputArgs:({signal:n})=>n,getCacheKeyFromInputArgs:({payload:n})=>e?e(n):Nu||(Nu=Tu()),onCacheHit:(n,{payload:r})=>n.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(r),onCreateIterable:(n,r)=>t({...r,signal:n})})}function gu(e){var o;let{getShard:t,intervalMs:n,...r}=e;return K(Ua({...r,sendBufferHighWatermark:(o=e.sendBufferHighWatermark)!=null?o:131072}),a=>Ou({intervalMs:n!=null?n:5e3,transport:a}),a=>mu({getShard:t,transport:a}))}function pu(e,t){let n=gu({url:e,...t});return Fa(n)}function wf(e,t){return pu(e,t)}function Fa(e){return K(Da({api:wa(Ru),transport:e}),t=>Au({getDeduplicationKey:(...n)=>st(n),rpcSubscriptions:t}))}function Pf(e){return Fa(e)}var br,Dr;function wr(){return br||(br=Y()),br}function Iu(){return Dr||(Dr=J()),Dr}function Vf(e){return !(e.length<32||e.length>44||wr().encode(e).byteLength!==32)}function Pr(e){if(e.length<32||e.length>44)throw new u(Nt,{actualLength:e.length});let r=wr().encode(e).byteLength;if(r!==32)throw new u(Tt,{actualLength:r})}function Cu(e){return Pr(e),e}function hu(){return p(v(wr(),32),e=>Cu(e))}function Lu(){return w(Iu(),32)}function Gf(){return E(hu(),Lu())}function Hf(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function Wf(e){return e}function $f(e){return e}function Yf(e){return e}function za(e){switch(e){case"finalized":return 2;case"confirmed":return 1;case"processed":return 0;default:throw new u(qn,{unexpectedValue:e})}}function ct(e,t){return e===t?0:za(e)<za(t)?-1:1}var ka=18446744073709551615n,yr,vr;function bu(){return yr||(yr=Ar()),yr}function Du(){return vr||(vr=Sr()),vr}function Xf(e){return e>=0&&e<=ka}function yu(e){if(e<0||e>ka)throw new u(mt)}function vu(e){return yu(e),e}function wu(){return bu()}function Kf(e){return e}function Pu(){return Va(Du())}function Va(e){return I(e,t=>vu(typeof t=="bigint"?t:BigInt(t)))}function jf(){return E(wu(),Pu())}function qf(e){return E(e,Va(e))}function Jf(e){try{return BigInt(e),!0}catch{return !1}}function xu(e){try{BigInt(e);}catch{throw new u(gt,{value:e})}}function Zf(e){return xu(e),e}function Qf(e){return !Number.isNaN(Number(e))}function Uu(e){if(Number.isNaN(Number(e)))throw new u(pt,{value:e})}function eE(e){return Uu(e),e}function tE(e){return !(e>864e13||e<-864e13)}function Bu(e){if(e>864e13||e<-864e13)throw new u(It,{value:e})}function nE(e){return Bu(e),e}function ve(e){if(!("lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"))return !1;try{return Pr(e.lifetimeConstraint.blockhash),!0}catch{return !1}}function lE(e){if(!ve(e))throw new u(ln)}function Hr(e,t){if("lifetimeConstraint"in t&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return t;let n={...t,lifetimeConstraint:Object.freeze(e)};return Object.freeze(n),n}function Mu(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new u($,{alphabet:e,base:e.length,value:n})}var Fu=e=>O({getSizeFromValue:t=>{let[n,r]=Ga(t,e[0]);if(!r)return t.length;let o=Ha(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Mu(e,t),t==="")return r;let[o,a]=Ga(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=Ha(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),zu=e=>T({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,_)=>c*256n+BigInt(_),0n),s=ku(i,e);return [a+s,t.length]}});function Ga(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ha(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function ku(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Ka="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Vu=()=>Fu(Ka),Gu=()=>zu(Ka),xr;function Hu(){return xr||(xr=X([["lookupTableAddress",Ke()],["writableIndices",z(y(),{size:k()})],["readableIndices",z(y(),{size:k()})]])),xr}var Ur;function Wu(){return Ur||(Ur=te([["lookupTableAddress",ae()],["writableIndices",P(b(),{size:M()})],["readableIndices",P(b(),{size:M()})]])),Ur}var Br;function Mr(){return Br||(Br=y()),Br}var Fr;function zr(){return Fr||(Fr=b()),Fr}function $u(){return X([["numSignerAccounts",Mr()],["numReadonlySignerAccounts",Mr()],["numReadonlyNonSignerAccounts",Mr()]])}function Yu(){return te([["numSignerAccounts",zr()],["numReadonlySignerAccounts",zr()],["numReadonlyNonSignerAccounts",zr()]])}var kr;function Xu(){return kr||(kr=p(X([["programAddressIndex",y()],["accountIndices",z(y(),{size:k()})],["data",Jn(de(),k())]]),e=>{var t,n;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(t=e.accountIndices)!=null?t:[],data:(n=e.data)!=null?n:new Uint8Array(0)}})),kr}var Vr;function Ku(){return Vr||(Vr=I(te([["programAddressIndex",b()],["accountIndices",P(b(),{size:M()})],["data",Zn(le(),M())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:n,...r}=e;return {...r,...t.length?{accountIndices:t}:null,...n.byteLength?{data:n}:null}})),Vr}var Gr=128;function ja(){return O({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new u(fn,{actualVersion:e});return t.set([e|Gr],n),n+1}})}function _t(){return T({maxSize:1,read:(e,t)=>{let n=e[t];return n&Gr?[n^Gr,t+1]:["legacy",t]}})}function RE(){return E(ja(),_t())}function Wa(){return X(qa())}function $a(){return p(X([...qa(),["addressTableLookups",qu()]]),e=>{var t;return e.version==="legacy"?e:{...e,addressTableLookups:(t=e.addressTableLookups)!=null?t:[]}})}function qa(){return [["version",ja()],["header",$u()],["staticAccounts",z(Ke(),{size:k()})],["lifetimeToken",v(Vu(),32)],["instructions",z(Xu(),{size:k()})]]}function ju(){return [["version",_t()],["header",Yu()],["staticAccounts",P(ae(),{size:M()})],["lifetimeToken",w(Gu(),32)],["instructions",P(Ku(),{size:M()})],["addressTableLookups",Ju()]]}function qu(){return z(Hu(),{size:k()})}function Ju(){return P(Wu(),{size:M()})}function Wr(){return O({getSizeFromValue:e=>e.version==="legacy"?Wa().getSizeFromValue(e):$a().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?Wa().write(e,t,n):$a().write(e,t,n)})}function Zu(){return I(te(ju()),({addressTableLookups:e,...t})=>t.version==="legacy"||!(e!=null&&e.length)?t:{...t,addressTableLookups:e})}function fE(){return E(Wr(),Zu())}function Ya(e,t,n){var r;e[t]=n((r=e[t])!=null?r:{role:L.READONLY});}var C=Symbol("AddressMapTypeProperty");function Qu(e,t){let n={[e]:{[C]:0,role:L.WRITABLE_SIGNER}},r=new Set;for(let o of t){Ya(n,o.programAddress,i=>{if(r.add(o.programAddress),C in i){if(Re(i.role))switch(i[C]){case 0:throw new u(dn,{programAddress:o.programAddress});default:throw new u(Fe,{programAddress:o.programAddress})}if(i[C]===2)return i}return {[C]:2,role:L.READONLY}});let a;if(o.accounts)for(let i of o.accounts)Ya(n,i.address,s=>{let{address:c,..._}=i;if(C in s)switch(s[C]){case 0:return s;case 1:{let d=mr(s.role,_.role);if("lookupTableAddress"in _){if(s.lookupTableAddress!==_.lookupTableAddress&&(a||(a=je()))(_.lookupTableAddress,s.lookupTableAddress)<0)return {[C]:1,..._,role:d}}else if(W(_.role))return {[C]:2,role:d};return s.role!==d?{...s,role:d}:s}case 2:{let d=mr(s.role,_.role);if(r.has(i.address)){if(Re(_.role))throw new u(Fe,{programAddress:i.address});return s.role!==d?{...s,role:d}:s}else return "lookupTableAddress"in _&&!W(s.role)?{..._,[C]:1,role:d}:s.role!==d?{...s,role:d}:s}}return "lookupTableAddress"in _?{..._,[C]:1}:{..._,[C]:2}});}return n}function ed(e){let t;return Object.entries(e).sort(([r,o],[a,i])=>{if(o[C]!==i[C]){if(o[C]===0)return -1;if(i[C]===0)return 1;if(o[C]===2)return -1;if(i[C]===2)return 1}let s=W(o.role);if(s!==W(i.role))return s?-1:1;let c=Re(o.role);return c!==Re(i.role)?c?-1:1:(t||(t=je()),o[C]===1&&i[C]===1&&o.lookupTableAddress!==i.lookupTableAddress?t(o.lookupTableAddress,i.lookupTableAddress):t(r,a))}).map(([r,o])=>({address:r,...o}))}function td(e){var n;let t={};for(let r of e){if(!("lookupTableAddress"in r))continue;let o=t[n=r.lookupTableAddress]||(t[n]={readableIndices:[],writableIndices:[]});r.role===L.WRITABLE?o.writableIndices.push(r.addressIndex):o.readableIndices.push(r.addressIndex);}return Object.keys(t).sort(je()).map(r=>({lookupTableAddress:r,...t[r]}))}function nd(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let a=Re(o.role);W(o.role)?(r++,a||n++):a||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function rd(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function od(e,t){let n=rd(t);return e.map(({accounts:r,data:o,programAddress:a})=>({programAddressIndex:n[a],...r?{accountIndices:r.map(({address:i})=>n[i])}:null,...o?{data:o}:null}))}function ad(e){return "nonce"in e?e.nonce:e.blockhash}function id(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Ja(e){let t=Qu(e.feePayer,e.instructions),n=ed(t);return {...e.version!=="legacy"?{addressTableLookups:td(n)}:null,header:nd(n),instructions:od(e.instructions,n),lifetimeToken:ad(e.lifetimeConstraint),staticAccounts:id(n),version:e.version}}function sd(e,t,n){for(let[r,o]of Object.entries(n))for(let a=0;a<o.length;a++)if(e===o[a])return {address:e,addressIndex:a,lookupTableAddress:r,role:t}}function EE(e,t){let n=new Set(Object.values(t).flatMap(a=>a)),r=[],o=!1;for(let a of e.instructions){if(!a.accounts){r.push(a);continue}let i=[],s=!1;for(let c of a.accounts){if("lookupTableAddress"in c||!n.has(c.address)||W(c.role)){i.push(c);continue}let _=sd(c.address,c.role,t);i.push(Object.freeze(_)),s=!0,o=!0;}r.push(Object.freeze(s?{...a,accounts:i}:a));}return Object.freeze(o?{...e,instructions:r}:e)}function cd({version:e}){return Object.freeze({instructions:Object.freeze([]),version:e})}var Za="SysvarRecentB1ockHashes11111111111111111111",Qa="11111111111111111111111111111111";function AE(e){if(!ut(e))throw new u(Rn)}function Xa(e,t){return {accounts:[{address:e,role:L.WRITABLE},{address:Za,role:L.READONLY},{address:t,role:L.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Qa}}function $r(e){var t;return e.programAddress===Qa&&e.data!=null&&_d(e.data)&&((t=e.accounts)==null?void 0:t.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===L.WRITABLE&&e.accounts[1].address===Za&&e.accounts[1].role===L.READONLY&&e.accounts[2].address!=null&&W(e.accounts[2].role)}function _d(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function ut(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&$r(e.instructions[0])}function ud(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function dd({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,a=r.instructions[0];if(a&&$r(a))if(ud(a,t,n)){if(ut(r)&&r.lifetimeConstraint.nonce===e)return r;o=[a,...r.instructions.slice(1)];}else o=[Object.freeze(Xa(t,n)),...r.instructions.slice(1)];else o=[Object.freeze(Xa(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function ld(e,t){if("feePayer"in t&&e===t.feePayer)return t;let n={...t,feePayer:e};return Object.freeze(n),n}function Yr(e,t){return Rd([e],t)}function Rd(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function SE(e,t){return fd([e],t)}function fd(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}function Ed(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],a=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[a],role:L.WRITABLE_SIGNER}),a++;for(let i=0;i<t.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[a],role:L.READONLY_SIGNER}),a++;for(let i=0;i<r;i++)o.push({address:e.staticAccounts[a],role:L.WRITABLE}),a++;for(let i=0;i<t.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[a],role:L.READONLY}),a++;return o}function Ad(e,t){let r=e.map(i=>i.lookupTableAddress).filter(i=>t[i]===void 0);if(r.length>0)throw new u(En,{lookupTableAddresses:r});let o=[],a=[];for(let i of e){let s=t[i.lookupTableAddress],c=Math.max(...i.readableIndices,...i.writableIndices);if(c>=s.length)throw new u(An,{highestKnownIndex:s.length-1,highestRequestedIndex:c,lookupTableAddress:i.lookupTableAddress});let _=i.readableIndices.map(l=>({address:s[l],addressIndex:l,lookupTableAddress:i.lookupTableAddress,role:L.READONLY}));o.push(..._);let d=i.writableIndices.map(l=>({address:s[l],addressIndex:l,lookupTableAddress:i.lookupTableAddress,role:L.WRITABLE}));a.push(...d);}return [...a,...o]}function Sd(e,t){var a,i;let n=(a=t[e.programAddressIndex])==null?void 0:a.address;if(!n)throw new u(Sn,{index:e.programAddressIndex});let r=(i=e.accountIndices)==null?void 0:i.map(s=>t[s]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function Od(e,t,n){if(!t||!$r(t))return {blockhash:e,lastValidBlockHeight:n!=null?n:2n**64n-1n};{let r=t.accounts[0].address;pe(r);let o=t.accounts[2].address;return pe(o),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:o}}}function ei(e,t){var _;let n=e.staticAccounts[0];if(!n)throw new u(On);let r=Ed(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?Ad(e.addressTableLookups,(_=t==null?void 0:t.addressesByLookupTableAddress)!=null?_:{}):[],a=[...r,...o],i=e.instructions.map(d=>Sd(d,a)),s=i[0],c=Od(e.lifetimeToken,s,t==null?void 0:t.lastValidBlockHeight);return K(cd({version:e.version}),d=>ld(n,d),d=>i.reduce((l,f)=>Yr(f,l),d),d=>"blockhash"in c?Hr(c,d):dd(c,d))}function Nd(e){let t=Object.values(e);if(t.length===0)throw new u(gn);return t.map(n=>n||new Uint8Array(64).fill(0))}function Td(){return p(z(v(de(),64),{size:k()}),Nd)}function ti(){return X([["signatures",Td()],["messageBytes",de()]])}function md(){return I(te([["signatures",P(w(le(),64),{size:M()})],["messageBytes",le()]]),gd)}function LE(){return E(ti(),md())}function gd(e){let{messageBytes:t,signatures:n}=e,r=F([_t(),rr(b(),2),P(ae(),{size:M()})]),[o,a,i]=r.decode(t),s=i.slice(0,a);if(s.length!==n.length)throw new u(pn,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((_,d)=>{let l=n[d];l.every(f=>f===0)?c[_]=null:c[_]=l;}),{messageBytes:t,signatures:Object.freeze(c)}}function dt(e){let t=Ja(e),n=Wr().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let s of r)o[s]=null;let a;ve(e)?a={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:a={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address};let i={lifetimeConstraint:a,messageBytes:n,signatures:Object.freeze(o)};return Object.freeze(i)}var Xr;function Kr(e){Xr||(Xr=J());let t=Object.values(e.signatures)[0];if(!t)throw new u(Tn);return Xr.decode(t)}function pd(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}async function jr(e,t){let n,r;if(await Promise.all(e.map(async o=>{let a=await qe(o.publicKey),i=t.signatures[a];if(i===void 0){r||(r=new Set),r.add(a);return}if(r)return;let s=await Le(o.privateKey,t.messageBytes);i!==null&&pd(s,i)||(n||(n={}),n[a]=s);})),r&&r.size>0){let o=Object.keys(t.signatures);throw new u(mn,{expectedAddresses:o,unexpectedAddresses:[...r]})}return n?Object.freeze({...t,signatures:Object.freeze({...t.signatures,...n})}):t}async function bE(e,t){let n=await jr(e,t);return qr(n),Object.freeze(n),n}function qr(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new u(Nn,{addresses:t})}function lt(e){let t=ti().encode(e);return _r().decode(t)}function we(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new u(en,{address:n.address})}),Object.values(t)}function Id(e){var t;return we(((t=e.accounts)!=null?t:[]).flatMap(n=>"signer"in n?n.signer:[]))}function Jr(e){return we([...e.feePayerSigner?[e.feePayerSigner]:[],...e.instructions.flatMap(Id)])}function Cd(e,t){if(!t.accounts||t.accounts.length===0)return t;let n=new Map(we(e).map(r=>[r.address,r]));return Object.freeze({...t,accounts:t.accounts.map(r=>{let o=n.get(r.address);return !W(r.role)||"signer"in r||!o?r:Object.freeze({...r,signer:o})})})}function UE(e,t){return t.instructions.length===0?t:Object.freeze({...t,instructions:t.instructions.map(n=>Cd(e,n))})}function BE(e,t){if("feePayer"in t&&e.address===t.feePayer){if("feePayerSigner"in t)return t;let r={...t,feePayerSigner:e};return Object.freeze(r),r}let n={...t,feePayer:e.address,feePayerSigner:e};return Object.freeze(n),n}function Zr(e){return "signMessages"in e&&typeof e.signMessages=="function"}function ME(e){if(!Zr(e))throw new u(on,{address:e.address})}function re(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function FE(e){if(!re(e))throw new u(cn,{address:e.address})}function hd(e){return "keyPair"in e&&typeof e.keyPair=="object"&&Zr(e)&&re(e)}function zE(e){if(!hd(e))throw new u(tn,{address:e.address})}async function ni(e){let t=await qe(e.publicKey);return Object.freeze({address:t,keyPair:e,signMessages:r=>Promise.all(r.map(async o=>Object.freeze({[t]:await Le(e.privateKey,o.content)}))),signTransactions:r=>Promise.all(r.map(async o=>{let a=await jr([e],o);return Object.freeze({[t]:a.signatures[t]})}))})}async function kE(){return await ni(await Na())}async function VE(e,t){return await ni(await Ta(e,t))}function ri(e){return fr(e.address)&&"modifyAndSignMessages"in e&&typeof e.modifyAndSignMessages=="function"}function GE(e){if(!ri(e))throw new u(rn,{address:e.address})}function Ld(e){return Zr(e)||ri(e)}function HE(e){if(!Ld(e))throw new u(nn,{address:e.address})}function WE(e){return Object.freeze({address:e,signMessages:n=>Promise.resolve(n.map(()=>Object.freeze({}))),signTransactions:n=>Promise.resolve(n.map(()=>Object.freeze({})))})}function Ee(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function $E(e){if(!Ee(e))throw new u(sn,{address:e.address})}function Rt(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function YE(e){if(!Rt(e))throw new u(_n,{address:e.address})}function Qr(e){return re(e)||Ee(e)||Rt(e)}function XE(e){if(!Qr(e))throw new u(an,{address:e.address})}function KE(e){try{return oi(e),!0}catch{return !1}}function oi(e){let n=Jr(e).filter(Rt);if(n.length===0)throw new u(Me);if(n.filter(o=>!re(o)&&!Ee(o)).length>1)throw new u(un)}async function bd(e,t){let{partialSigners:n,modifyingSigners:r}=ai(we(Jr(e).filter(Qr)),{identifySendingSigner:!1});return await ii(e,r,n,t)}async function jE(e,t){let n=await bd(e,t);return qr(n),n}async function qE(e,t){oi(e);let n=t==null?void 0:t.abortSignal,{partialSigners:r,modifyingSigners:o,sendingSigner:a}=ai(we(Jr(e).filter(Qr)));n==null||n.throwIfAborted();let i=await ii(e,o,r,t);if(!a)throw new u(Me);n==null||n.throwIfAborted();let[s]=await a.signAndSendTransactions([i],t);return n==null||n.throwIfAborted(),s}function ai(e,t={}){var s;let r=((s=t.identifySendingSigner)!=null?s:!0)?Dd(e):null,o=e.filter(c=>c!==r&&(Ee(c)||re(c))),a=yd(o),i=o.filter(re).filter(c=>!a.includes(c));return Object.freeze({modifyingSigners:a,partialSigners:i,sendingSigner:r})}function Dd(e){let t=e.filter(Rt);if(t.length===0)return null;let n=t.filter(r=>!Ee(r)&&!re(r));return n.length>0?n[0]:t[0]}function yd(e){let t=e.filter(Ee);if(t.length===0)return [];let n=t.filter(r=>!re(r));return n.length>0?n:[t[0]]}async function ii(e,t=[],n=[],r){var c,_;let o=dt(e),a=await t.reduce(async(d,l)=>{var N;(N=r==null?void 0:r.abortSignal)==null||N.throwIfAborted();let[f]=await l.modifyAndSignTransactions([await d],r);return Object.freeze(f)},Promise.resolve(o));(c=r==null?void 0:r.abortSignal)==null||c.throwIfAborted();let i=await Promise.all(n.map(async d=>{let[l]=await d.signTransactions([a],r);return l})),s={...a,signatures:Object.freeze(i.reduce((d,l)=>({...d,...l}),(_=a.signatures)!=null?_:{}))};return Object.freeze(s)}var vd=globalThis.TextEncoder;function JE(e,t={}){return Object.freeze({content:typeof e=="string"?new vd().encode(e):e,signatures:Object.freeze({...t})})}function si({rpc:e,rpcSubscriptions:t}){return async function({abortSignal:r,commitment:o,lastValidBlockHeight:a}){let i=new AbortController,s=()=>{i.abort();};r.addEventListener("abort",s,{signal:i.signal});async function c(){let{absoluteSlot:_,blockHeight:d}=await e.getEpochInfo({commitment:o}).send({abortSignal:i.signal});return {blockHeight:d,differenceBetweenSlotHeightAndBlockHeight:_-d}}try{let[_,{blockHeight:d,differenceBetweenSlotHeightAndBlockHeight:l}]=await Promise.all([t.slotNotifications().subscribe({abortSignal:i.signal}),c()]),f=d;if(f<=a){let N=l;for await(let S of _){let{slot:A}=S;if(A-N>a){let{blockHeight:g,differenceBetweenSlotHeightAndBlockHeight:h}=await c();if(f=g,f>a)break;N=h;}}}throw new u(St,{currentBlockHeight:f,lastValidBlockHeight:a})}finally{i.abort();}}}var eo=40;function ci({rpc:e,rpcSubscriptions:t}){return async function({abortSignal:r,commitment:o,currentNonceValue:a,nonceAccountAddress:i}){let s=new AbortController;function c(){s.abort();}r.addEventListener("abort",c,{signal:s.signal});let _=await t.accountNotifications(i,{commitment:o,encoding:"base64"}).subscribe({abortSignal:s.signal}),d=J(),l=me();function f([A]){let h=l.encode(A).slice(eo,eo+32);return d.decode(h)}let N=(async()=>{for await(let A of _){let g=f(A.value.data);if(g!==a)throw new u(Pe,{actualNonceValue:g,expectedNonceValue:a})}})(),S=(async()=>{let{value:A}=await e.getAccountInfo(i,{commitment:o,dataSlice:{length:32,offset:eo},encoding:"base58"}).send({abortSignal:s.signal});if(!A)throw new u(Ot,{nonceAccountAddress:i});let g=A.data[0];if(g!==a)throw new u(Pe,{actualNonceValue:g,expectedNonceValue:a});await new Promise(()=>{});})();try{return await Promise.race([N,S])}finally{s.abort();}}}function Ae({rpc:e,rpcSubscriptions:t}){return async function({abortSignal:r,commitment:o,signature:a}){let i=new AbortController;function s(){i.abort();}r.addEventListener("abort",s,{signal:i.signal});let c=await t.signatureNotifications(a,{commitment:o}).subscribe({abortSignal:i.signal}),_=(async()=>{for await(let l of c){if(l.value.err)throw Ge(l.value.err);return}})(),d=(async()=>{let{value:l}=await e.getSignatureStatuses([a]).send({abortSignal:i.signal}),f=l[0];f&&f.confirmationStatus&&ct(f.confirmationStatus,o)>=0||await new Promise(()=>{});})();try{return await Promise.race([_,d])}finally{i.abort();}}}async function _i({abortSignal:e,commitment:t}){return await new Promise((n,r)=>{let o=c=>{clearTimeout(s);let _=new DOMException(c.target.reason,"AbortError");r(_);};e.addEventListener("abort",o);let a=t==="processed"?3e4:6e4,i=performance.now(),s=setTimeout(()=>{let c=performance.now()-i;r(new DOMException(`Timeout elapsed after ${c} ms`,"TimeoutError"));},a);})}async function to(e,t,n){let{abortSignal:r,commitment:o,getRecentSignatureConfirmationPromise:a}=t;r==null||r.throwIfAborted();let i=new AbortController;if(r){let s=()=>{i.abort();};r.addEventListener("abort",s,{signal:i.signal});}try{let s=n({...t,abortSignal:i.signal});return await Promise.race([a({abortSignal:i.signal,commitment:o,signature:e}),...s])}finally{i.abort();}}async function ui(e){await to(Kr(e.transaction),e,function({abortSignal:n,commitment:r,getNonceInvalidationPromise:o,transaction:a}){return [o({abortSignal:n,commitment:r,currentNonceValue:a.lifetimeConstraint.nonce,nonceAccountAddress:a.lifetimeConstraint.nonceAccountAddress})]});}async function di(e){await to(Kr(e.transaction),e,function({abortSignal:n,commitment:r,getBlockHeightExceedencePromise:o,transaction:a}){return [o({abortSignal:n,commitment:r,lastValidBlockHeight:a.lifetimeConstraint.lastValidBlockHeight})]});}async function li(e){await to(e.signature,e,function({abortSignal:n,commitment:r,getTimeoutPromise:o}){return [o({abortSignal:n,commitment:r})]});}async function Ri({abortSignal:e,commitment:t,confirmSignatureOnlyTransaction:n,lamports:r,recipientAddress:o,rpc:a}){let i=await a.requestAirdrop(o,r,{commitment:t}).send({abortSignal:e});return await n({abortSignal:e,commitment:t,signature:i}),i}function sA({rpc:e,rpcSubscriptions:t}){let n=Ae({rpc:e,rpcSubscriptions:t});async function r(o){await li({...o,getRecentSignatureConfirmationPromise:n,getTimeoutPromise:_i});}return async function(a){return await Ri({...a,confirmSignatureOnlyTransaction:r,rpc:e})}}var fi="ComputeBudget111111111111111111111111111111",wd={blockhash:"11111111111111111111111111111111",lastValidBlockHeight:0n},Ei=2;function Pd(e){let t=new Uint8Array(5);return t[0]=Ei,Ie().write(e,t,1),Object.freeze({data:t,programAddress:fi})}function xd(e){return Aa(e,fi)&&Sa(e)&&e.data[0]===Ei}async function Ai({abortSignal:e,rpc:t,transactionMessage:n,...r}){let o=ut(n),a;o||ve(n)?a=n:a=Hr(wd,n);let i=n.instructions.findIndex(xd),s=Pd(14e5);if(i===-1)a=Yr(s,a);else {let d=[...a.instructions];d.splice(i,1,s),a=Object.freeze({...a,instructions:d});}let c=dt(a),_=lt(c);try{let{value:{unitsConsumed:d}}=await t.simulateTransaction(_,{...r,encoding:"base64",replaceRecentBlockhash:!o,sigVerify:!1}).send({abortSignal:e});if(d==null)throw new u(ze);return d>4294967295n?4294967295:Number(d)}catch(d){throw new u(ze,{cause:d})}}function mA({rpc:e}){return async function(n,r){return await Ai({...r,rpc:e,transactionMessage:n})}}async function Ud(e,t,n){let r=await Wo(t,e,n);return Go(r),$o(r),r.reduce((o,a)=>({...o,[a.address]:a.data.addresses}),{})}async function LA(e,t,n){let o=("addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups:[]).map(c=>c.lookupTableAddress),{lastValidBlockHeight:a,...i}=n!=null?n:{},s=o.length>0?await Ud(o,t,i):{};return ei(e,{addressesByLookupTableAddress:s,lastValidBlockHeight:a})}function Bd(e,t){return !(t!=null&&t.preflightCommitment)&&ct(e,"finalized")<0?{...t,preflightCommitment:e}:t}async function ft({abortSignal:e,commitment:t,rpc:n,transaction:r,...o}){let a=lt(r);return await n.sendTransaction(a,{...Bd(t,o),encoding:"base64"}).send({abortSignal:e})}async function Si({abortSignal:e,commitment:t,confirmDurableNonceTransaction:n,rpc:r,transaction:o,...a}){let i=await ft({...a,abortSignal:e,commitment:t,rpc:r,transaction:o});return await n({abortSignal:e,commitment:t,transaction:o}),i}async function Oi({abortSignal:e,commitment:t,confirmRecentTransaction:n,rpc:r,transaction:o,...a}){let i=await ft({...a,abortSignal:e,commitment:t,rpc:r,transaction:o});return await n({abortSignal:e,commitment:t,transaction:o}),i}function FA({rpc:e,rpcSubscriptions:t}){let n=ci({rpc:e,rpcSubscriptions:t}),r=Ae({rpc:e,rpcSubscriptions:t});async function o(a){await ui({...a,getNonceInvalidationPromise:n,getRecentSignatureConfirmationPromise:r});}return async function(i,s){await Si({...s,confirmDurableNonceTransaction:o,rpc:e,transaction:i});}}function GA({rpc:e,rpcSubscriptions:t}){let n=si({rpc:e,rpcSubscriptions:t}),r=Ae({rpc:e,rpcSubscriptions:t});async function o(a){await di({...a,getBlockHeightExceedencePromise:n,getRecentSignatureConfirmationPromise:r});}return async function(i,s){await Oi({...s,confirmRecentTransaction:o,rpc:e,transaction:i});}}function $A({rpc:e}){return async function(n,r){await ft({...r,rpc:e,transaction:n});}}
|
6
6
|
|
7
7
|
exports.AccountRole = L;
|
8
8
|
exports.BASE_ACCOUNT_SIZE = El;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@solana/web3.js",
|
3
|
-
"version": "2.0.0-preview.3.
|
3
|
+
"version": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
4
4
|
"description": "Solana Javascript API",
|
5
5
|
"exports": {
|
6
6
|
"browser": {
|
@@ -49,23 +49,23 @@
|
|
49
49
|
"maintained node versions"
|
50
50
|
],
|
51
51
|
"dependencies": {
|
52
|
-
"@solana/accounts": "2.0.0-preview.3.
|
53
|
-
"@solana/codecs": "2.0.0-preview.3.
|
54
|
-
"@solana/
|
55
|
-
"@solana/
|
56
|
-
"@solana/
|
57
|
-
"@solana/keys": "2.0.0-preview.3.
|
58
|
-
"@solana/
|
59
|
-
"@solana/
|
60
|
-
"@solana/rpc-
|
61
|
-
"@solana/rpc
|
62
|
-
"@solana/rpc-
|
63
|
-
"@solana/
|
64
|
-
"@solana/
|
65
|
-
"@solana/transaction-
|
66
|
-
"@solana/transaction-
|
67
|
-
"@solana/transactions": "2.0.0-preview.3.
|
68
|
-
"@solana/
|
52
|
+
"@solana/accounts": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
53
|
+
"@solana/codecs": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
54
|
+
"@solana/addresses": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
55
|
+
"@solana/errors": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
56
|
+
"@solana/functional": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
57
|
+
"@solana/keys": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
58
|
+
"@solana/instructions": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
59
|
+
"@solana/programs": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
60
|
+
"@solana/rpc-parsed-types": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
61
|
+
"@solana/rpc": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
62
|
+
"@solana/rpc-subscriptions": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
63
|
+
"@solana/rpc-types": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
64
|
+
"@solana/signers": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
65
|
+
"@solana/transaction-messages": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
66
|
+
"@solana/transaction-confirmation": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
67
|
+
"@solana/transactions": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4",
|
68
|
+
"@solana/sysvars": "2.0.0-preview.3.20240730161108.1b391f9d971c87160ffaba66a915b05511e971f4"
|
69
69
|
},
|
70
70
|
"peerDependencies": {
|
71
71
|
"typescript": ">=5"
|