@pooflabs/web 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/providers/mock-auth-provider.d.ts +7 -0
- package/dist/auth/providers/offchain-auth-provider.d.ts +13 -4
- package/dist/auth/providers/phantom-wallet-provider.d.ts +28 -1
- package/dist/auth/providers/privy-wallet-provider.d.ts +45 -1
- package/dist/{index-B3jRsGVB.js → index-BaNlnYmn.js} +1937 -349
- package/dist/index-BaNlnYmn.js.map +1 -0
- package/dist/{index-B08xJEBy.js → index-C-_15_Cq.js} +2 -2
- package/dist/{index-B08xJEBy.js.map → index-C-_15_Cq.js.map} +1 -1
- package/dist/{index-BshwKDlr.esm.js → index-CK_KC-Oy.esm.js} +1936 -351
- package/dist/index-CK_KC-Oy.esm.js.map +1 -0
- package/dist/{index-DD_zltED.esm.js → index-CfbGteXj.esm.js} +2 -2
- package/dist/{index-DD_zltED.esm.js.map → index-CfbGteXj.esm.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/index-B3jRsGVB.js.map +0 -1
- package/dist/index-BshwKDlr.esm.js.map +0 -1
|
@@ -11640,24 +11640,15 @@ async function genSolanaMessage(address, nonce) {
|
|
|
11640
11640
|
const statement = "Sign this message to authenticate with our application.";
|
|
11641
11641
|
const currentDate = new Date();
|
|
11642
11642
|
const issuedAt = currentDate.toISOString();
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
11646
|
-
const expirationTime = expirationDate.toISOString();
|
|
11647
|
-
return `${statement}\n\n` +
|
|
11648
|
-
`Wallet address:\n${address}\n\n` +
|
|
11649
|
-
`Domain: ${domain}\n` +
|
|
11650
|
-
`Origin: ${origin}\n` +
|
|
11651
|
-
`Nonce: ${nonce}\n` +
|
|
11652
|
-
`Issued At: ${issuedAt}\n` +
|
|
11653
|
-
`Expiration Time: ${expirationTime}`;
|
|
11654
|
-
}
|
|
11655
|
-
// Backward compatible: without nonce (for server-side usage)
|
|
11643
|
+
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
11644
|
+
const expirationTime = expirationDate.toISOString();
|
|
11656
11645
|
return `${statement}\n\n` +
|
|
11657
11646
|
`Wallet address:\n${address}\n\n` +
|
|
11658
11647
|
`Domain: ${domain}\n` +
|
|
11659
11648
|
`Origin: ${origin}\n` +
|
|
11660
|
-
`
|
|
11649
|
+
`Nonce: ${nonce}\n` +
|
|
11650
|
+
`Issued At: ${issuedAt}\n` +
|
|
11651
|
+
`Expiration Time: ${expirationTime}`;
|
|
11661
11652
|
}
|
|
11662
11653
|
// ─────────────────────────────────────────────────────────────
|
|
11663
11654
|
// Serialization Helpers
|
|
@@ -11825,6 +11816,7 @@ function loadKeypairFromEnv() {
|
|
|
11825
11816
|
async function createSession() {
|
|
11826
11817
|
const kp = loadKeypairFromEnv();
|
|
11827
11818
|
const address = kp.publicKey.toBase58();
|
|
11819
|
+
/* fetch nonce from auth API */
|
|
11828
11820
|
const nonce = await genAuthNonce();
|
|
11829
11821
|
const message = await genSolanaMessage(address, nonce);
|
|
11830
11822
|
/* sign the message */
|
|
@@ -12324,8 +12316,11 @@ async function setMany(many, options) {
|
|
|
12324
12316
|
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
12325
12317
|
var _a, _b, _c, _d, _e;
|
|
12326
12318
|
const config = await getConfig();
|
|
12327
|
-
// 1. Sign the transaction message using
|
|
12328
|
-
|
|
12319
|
+
// 1. Sign the transaction message using mock signing for offchain transactions
|
|
12320
|
+
// Use signMessageMock if available (OffchainAuthProvider), otherwise fall back to signMessage
|
|
12321
|
+
const signature = authProvider.signMessageMock
|
|
12322
|
+
? await authProvider.signMessageMock(tx.message)
|
|
12323
|
+
: await authProvider.signMessage(tx.message);
|
|
12329
12324
|
// 2. Create signed transaction
|
|
12330
12325
|
const signedTx = {
|
|
12331
12326
|
transaction: tx,
|
|
@@ -12436,6 +12431,27 @@ async function setFile(path, file) {
|
|
|
12436
12431
|
// Optionally return the file's public URL or some confirmation
|
|
12437
12432
|
return true;
|
|
12438
12433
|
}
|
|
12434
|
+
async function signMessage(message) {
|
|
12435
|
+
const config = await getConfig();
|
|
12436
|
+
if (!config.authProvider) {
|
|
12437
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
12438
|
+
}
|
|
12439
|
+
return config.authProvider.signMessage(message);
|
|
12440
|
+
}
|
|
12441
|
+
async function signTransaction(transaction) {
|
|
12442
|
+
const config = await getConfig();
|
|
12443
|
+
if (!config.authProvider) {
|
|
12444
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
12445
|
+
}
|
|
12446
|
+
return config.authProvider.signTransaction(transaction);
|
|
12447
|
+
}
|
|
12448
|
+
async function signAndSubmitTransaction(transaction, feePayer) {
|
|
12449
|
+
const config = await getConfig();
|
|
12450
|
+
if (!config.authProvider) {
|
|
12451
|
+
throw new Error('Auth provider not initialized. Please call init() first.');
|
|
12452
|
+
}
|
|
12453
|
+
return config.authProvider.signAndSubmitTransaction(transaction, feePayer);
|
|
12454
|
+
}
|
|
12439
12455
|
|
|
12440
12456
|
const activeConnections = {};
|
|
12441
12457
|
const responseCache = {};
|
|
@@ -12657,7 +12673,7 @@ async function loadDependencies() {
|
|
|
12657
12673
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
12658
12674
|
import('react'),
|
|
12659
12675
|
import('react-dom/client'),
|
|
12660
|
-
Promise.resolve().then(function () { return require('./index-
|
|
12676
|
+
Promise.resolve().then(function () { return require('./index-C-_15_Cq.js'); })
|
|
12661
12677
|
]);
|
|
12662
12678
|
React$1 = reactModule;
|
|
12663
12679
|
ReactDOM$1 = reactDomModule;
|
|
@@ -13103,18 +13119,15 @@ class PhantomWalletProvider {
|
|
|
13103
13119
|
await this.ensureSolanaReady();
|
|
13104
13120
|
}
|
|
13105
13121
|
catch (error) {
|
|
13106
|
-
// Reconnection failed - log user out and throw
|
|
13107
13122
|
console.error('Solana provider reconnection failed, logging out:', error.message);
|
|
13108
13123
|
await this.logout();
|
|
13109
13124
|
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13110
13125
|
}
|
|
13111
|
-
// Ensure connected
|
|
13112
13126
|
if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
|
|
13113
13127
|
const user = await this.login();
|
|
13114
13128
|
if (!user) {
|
|
13115
13129
|
throw new Error('Failed to connect wallet');
|
|
13116
13130
|
}
|
|
13117
|
-
// Wait for solana to be ready after login
|
|
13118
13131
|
try {
|
|
13119
13132
|
await this.ensureSolanaReady();
|
|
13120
13133
|
}
|
|
@@ -13127,21 +13140,7 @@ class PhantomWalletProvider {
|
|
|
13127
13140
|
if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
|
|
13128
13141
|
throw new Error('Solana signing not available');
|
|
13129
13142
|
}
|
|
13130
|
-
|
|
13131
|
-
if (this.networkUrl == null) {
|
|
13132
|
-
if (solTransactionData.network === 'solana_devnet') {
|
|
13133
|
-
rpcUrl = SOLANA_DEVNET_RPC_URL;
|
|
13134
|
-
}
|
|
13135
|
-
else if (solTransactionData.network === 'solana_mainnet') {
|
|
13136
|
-
rpcUrl = SOLANA_MAINNET_RPC_URL;
|
|
13137
|
-
}
|
|
13138
|
-
else if (solTransactionData.network === 'surfnet') {
|
|
13139
|
-
rpcUrl = SURFNET_RPC_URL;
|
|
13140
|
-
}
|
|
13141
|
-
else {
|
|
13142
|
-
throw new Error('Invalid network for Phantom wallet');
|
|
13143
|
-
}
|
|
13144
|
-
}
|
|
13143
|
+
const rpcUrl = this.getRpcUrl(solTransactionData.network);
|
|
13145
13144
|
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
13146
13145
|
try {
|
|
13147
13146
|
const remainingAccounts = convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
|
|
@@ -13181,7 +13180,7 @@ class PhantomWalletProvider {
|
|
|
13181
13180
|
finalDeduped.push(acc);
|
|
13182
13181
|
}
|
|
13183
13182
|
}
|
|
13184
|
-
const { tx
|
|
13183
|
+
const { tx } = await buildSetDocumentsTransaction(connection, solTransactionData.txArgs[0].idl, anchorProvider, publicKey, {
|
|
13185
13184
|
app_id,
|
|
13186
13185
|
documents: solTransactionData.txArgs[0].setDocumentData,
|
|
13187
13186
|
delete_paths: solTransactionData.txArgs[0].deletePaths,
|
|
@@ -13196,19 +13195,8 @@ class PhantomWalletProvider {
|
|
|
13196
13195
|
data: ""
|
|
13197
13196
|
};
|
|
13198
13197
|
}
|
|
13199
|
-
|
|
13200
|
-
const
|
|
13201
|
-
signature,
|
|
13202
|
-
blockhash,
|
|
13203
|
-
lastValidBlockHeight,
|
|
13204
|
-
}, 'confirmed');
|
|
13205
|
-
if (confirmation.value.err) {
|
|
13206
|
-
throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
|
|
13207
|
-
}
|
|
13208
|
-
const txInfo = await connection.getParsedTransaction(signature, {
|
|
13209
|
-
maxSupportedTransactionVersion: 0,
|
|
13210
|
-
commitment: 'confirmed'
|
|
13211
|
-
});
|
|
13198
|
+
// Submit using shared helper
|
|
13199
|
+
const { signature, txInfo } = await this.submitSignedTransaction(signedTx, connection);
|
|
13212
13200
|
return {
|
|
13213
13201
|
transactionSignature: signature,
|
|
13214
13202
|
blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
|
|
@@ -13234,6 +13222,16 @@ class PhantomWalletProvider {
|
|
|
13234
13222
|
throw new Error(`Failed to execute transaction: ${error.message}`);
|
|
13235
13223
|
}
|
|
13236
13224
|
}
|
|
13225
|
+
/**
|
|
13226
|
+
* Signs a Solana transaction without submitting it.
|
|
13227
|
+
*
|
|
13228
|
+
* This method handles blockhash automatically if not set - you do NOT need to
|
|
13229
|
+
* set recentBlockhash on the transaction before calling this method.
|
|
13230
|
+
* The network/RPC URL is derived from the provider's configuration (set during initialization).
|
|
13231
|
+
*
|
|
13232
|
+
* @param transaction - The transaction to sign (Transaction or VersionedTransaction)
|
|
13233
|
+
* @returns The signed transaction
|
|
13234
|
+
*/
|
|
13237
13235
|
async signTransaction(transaction) {
|
|
13238
13236
|
var _a, _b, _c, _d;
|
|
13239
13237
|
try {
|
|
@@ -13262,6 +13260,36 @@ class PhantomWalletProvider {
|
|
|
13262
13260
|
if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
|
|
13263
13261
|
throw new Error('Solana signing not available');
|
|
13264
13262
|
}
|
|
13263
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
13264
|
+
const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
|
|
13265
|
+
// Ensure blockhash is set before signing
|
|
13266
|
+
if (isLegacyTransaction) {
|
|
13267
|
+
const legacyTx = transaction;
|
|
13268
|
+
if (!legacyTx.recentBlockhash) {
|
|
13269
|
+
const rpcUrl = this.getRpcUrl();
|
|
13270
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
13271
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
|
|
13272
|
+
legacyTx.recentBlockhash = blockhash;
|
|
13273
|
+
legacyTx.lastValidBlockHeight = lastValidBlockHeight;
|
|
13274
|
+
}
|
|
13275
|
+
// Set feePayer if not already set
|
|
13276
|
+
if (!legacyTx.feePayer) {
|
|
13277
|
+
const solAddress = this.phantomMethods.addresses.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
|
|
13278
|
+
if (solAddress) {
|
|
13279
|
+
legacyTx.feePayer = new web3_js.PublicKey(solAddress.address);
|
|
13280
|
+
}
|
|
13281
|
+
}
|
|
13282
|
+
}
|
|
13283
|
+
else {
|
|
13284
|
+
// VersionedTransaction
|
|
13285
|
+
const versionedTx = transaction;
|
|
13286
|
+
if (!versionedTx.message.recentBlockhash) {
|
|
13287
|
+
const rpcUrl = this.getRpcUrl();
|
|
13288
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
13289
|
+
const { blockhash } = await connection.getLatestBlockhash('confirmed');
|
|
13290
|
+
versionedTx.message.recentBlockhash = blockhash;
|
|
13291
|
+
}
|
|
13292
|
+
}
|
|
13265
13293
|
try {
|
|
13266
13294
|
return await this.phantomMethods.solana.signTransaction(transaction);
|
|
13267
13295
|
}
|
|
@@ -13275,78 +13303,1401 @@ class PhantomWalletProvider {
|
|
|
13275
13303
|
throw new Error(`Failed to sign transaction: ${error.message}`);
|
|
13276
13304
|
}
|
|
13277
13305
|
}
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13306
|
+
/**
|
|
13307
|
+
* Signs and submits a Solana transaction to the network.
|
|
13308
|
+
*
|
|
13309
|
+
* This method handles blockhash and transaction confirmation automatically - you do NOT need to
|
|
13310
|
+
* set recentBlockhash or lastValidBlockHeight on the transaction before calling this method.
|
|
13311
|
+
* The network/RPC URL is derived from the provider's configuration (set during initialization).
|
|
13312
|
+
*
|
|
13313
|
+
* @param transaction - The transaction to sign and submit (Transaction or VersionedTransaction)
|
|
13314
|
+
* @param feePayer - Optional fee payer public key. If not provided and the transaction doesn't
|
|
13315
|
+
* already have a feePayer set, the connected wallet address will be used.
|
|
13316
|
+
* Useful for co-signing scenarios where a different account pays the fees.
|
|
13317
|
+
* @returns The transaction signature
|
|
13318
|
+
*/
|
|
13319
|
+
async signAndSubmitTransaction(transaction, feePayer) {
|
|
13320
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13321
|
+
try {
|
|
13322
|
+
await this.ensureSolanaReady();
|
|
13323
|
+
}
|
|
13324
|
+
catch (error) {
|
|
13325
|
+
console.error('Solana provider reconnection failed, logging out:', error.message);
|
|
13326
|
+
await this.logout();
|
|
13327
|
+
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13328
|
+
}
|
|
13329
|
+
if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
|
|
13330
|
+
const user = await this.login();
|
|
13331
|
+
if (!user) {
|
|
13332
|
+
throw new Error('Failed to connect wallet');
|
|
13333
|
+
}
|
|
13334
|
+
try {
|
|
13335
|
+
await this.ensureSolanaReady();
|
|
13336
|
+
}
|
|
13337
|
+
catch (error) {
|
|
13338
|
+
console.error('Solana provider reconnection failed after login, logging out:', error.message);
|
|
13339
|
+
await this.logout();
|
|
13340
|
+
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13341
|
+
}
|
|
13342
|
+
}
|
|
13343
|
+
if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
|
|
13344
|
+
throw new Error('Solana signing not available');
|
|
13345
|
+
}
|
|
13346
|
+
const rpcUrl = this.getRpcUrl();
|
|
13347
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
13348
|
+
try {
|
|
13349
|
+
// Get fresh blockhash and set it on the transaction before signing
|
|
13350
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
|
|
13351
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
13352
|
+
const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
|
|
13353
|
+
if (isLegacyTransaction) {
|
|
13354
|
+
const legacyTx = transaction;
|
|
13355
|
+
legacyTx.recentBlockhash = blockhash;
|
|
13356
|
+
legacyTx.lastValidBlockHeight = lastValidBlockHeight;
|
|
13357
|
+
// Set feePayer if not already set
|
|
13358
|
+
if (!legacyTx.feePayer) {
|
|
13359
|
+
if (feePayer) {
|
|
13360
|
+
legacyTx.feePayer = feePayer;
|
|
13361
|
+
}
|
|
13362
|
+
else {
|
|
13363
|
+
// Use connected wallet address as feePayer
|
|
13364
|
+
const solAddress = this.phantomMethods.addresses.find((addr) => addr.addressType === phantomReactSdk.AddressType.solana);
|
|
13365
|
+
if (solAddress) {
|
|
13366
|
+
legacyTx.feePayer = new web3_js.PublicKey(solAddress.address);
|
|
13367
|
+
}
|
|
13368
|
+
}
|
|
13369
|
+
}
|
|
13370
|
+
}
|
|
13371
|
+
else {
|
|
13372
|
+
// VersionedTransaction
|
|
13373
|
+
const versionedTx = transaction;
|
|
13374
|
+
versionedTx.message.recentBlockhash = blockhash;
|
|
13375
|
+
// Note: VersionedTransaction feePayer is set in the message at creation time
|
|
13376
|
+
// and cannot be modified after creation
|
|
13377
|
+
}
|
|
13378
|
+
// Sign the transaction
|
|
13379
|
+
const signedTx = await this.phantomMethods.solana.signTransaction(transaction);
|
|
13380
|
+
// Submit using shared helper with the blockhash we set
|
|
13381
|
+
const { signature } = await this.submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight);
|
|
13382
|
+
return signature;
|
|
13383
|
+
}
|
|
13384
|
+
catch (error) {
|
|
13385
|
+
// Check if this is a connection error - if so, log out
|
|
13386
|
+
if (((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not connected')) || ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('connect first'))) {
|
|
13387
|
+
console.error('Solana provider connection lost during transaction, logging out');
|
|
13388
|
+
await this.logout();
|
|
13389
|
+
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13390
|
+
}
|
|
13391
|
+
const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
|
|
13392
|
+
((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
|
|
13393
|
+
((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
|
|
13394
|
+
((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
|
|
13395
|
+
((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
|
|
13396
|
+
if (!isUserRejection) {
|
|
13397
|
+
console.error('Failed to execute transaction', error);
|
|
13398
|
+
}
|
|
13399
|
+
throw new Error(`Failed to execute transaction: ${error.message}`);
|
|
13400
|
+
}
|
|
13401
|
+
}
|
|
13402
|
+
async signMessage(message) {
|
|
13403
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13404
|
+
try {
|
|
13405
|
+
await this.ensureSolanaReady();
|
|
13406
|
+
}
|
|
13407
|
+
catch (error) {
|
|
13408
|
+
// Reconnection failed - log user out and throw
|
|
13409
|
+
console.error('Solana provider reconnection failed, logging out:', error.message);
|
|
13410
|
+
await this.logout();
|
|
13411
|
+
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13412
|
+
}
|
|
13413
|
+
if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
|
|
13414
|
+
const user = await this.login();
|
|
13415
|
+
if (!user) {
|
|
13416
|
+
throw new Error('Failed to connect wallet');
|
|
13417
|
+
}
|
|
13418
|
+
try {
|
|
13419
|
+
await this.ensureSolanaReady();
|
|
13420
|
+
}
|
|
13421
|
+
catch (error) {
|
|
13422
|
+
console.error('Solana provider reconnection failed after login, logging out:', error.message);
|
|
13423
|
+
await this.logout();
|
|
13424
|
+
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13425
|
+
}
|
|
13426
|
+
}
|
|
13427
|
+
if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
|
|
13428
|
+
throw new Error('Solana signing not available');
|
|
13429
|
+
}
|
|
13430
|
+
try {
|
|
13431
|
+
// signMessage returns { signature: Uint8Array, publicKey: string }
|
|
13432
|
+
const result = await this.phantomMethods.solana.signMessage(message);
|
|
13433
|
+
return bufferExports$1.Buffer.from(result.signature).toString('base64');
|
|
13434
|
+
}
|
|
13435
|
+
catch (error) {
|
|
13436
|
+
// Check if this is a connection error - if so, log out
|
|
13437
|
+
if (((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not connected')) || ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('connect first'))) {
|
|
13438
|
+
console.error('Solana provider connection lost during signing, logging out');
|
|
13439
|
+
await this.logout();
|
|
13440
|
+
throw new Error('Wallet connection lost. Please reconnect.');
|
|
13441
|
+
}
|
|
13442
|
+
const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
|
|
13443
|
+
((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
|
|
13444
|
+
((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
|
|
13445
|
+
((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
|
|
13446
|
+
((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
|
|
13447
|
+
if (!isUserRejection) {
|
|
13448
|
+
console.error('Failed to sign message', error);
|
|
13449
|
+
}
|
|
13450
|
+
throw new Error('Failed to sign message');
|
|
13451
|
+
}
|
|
13452
|
+
}
|
|
13453
|
+
async logout() {
|
|
13454
|
+
var _a;
|
|
13455
|
+
await this.ensureReady();
|
|
13456
|
+
try {
|
|
13457
|
+
if ((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected) {
|
|
13458
|
+
await this.phantomMethods.disconnect();
|
|
13459
|
+
}
|
|
13460
|
+
}
|
|
13461
|
+
catch (error) {
|
|
13462
|
+
console.error('Failed to disconnect from Phantom wallet', error);
|
|
13463
|
+
}
|
|
13464
|
+
// Always clear local state
|
|
13465
|
+
WebSessionManager.clearSession();
|
|
13466
|
+
setCurrentUser(null);
|
|
13467
|
+
}
|
|
13468
|
+
async getNativeMethods() {
|
|
13469
|
+
await this.ensureReady();
|
|
13470
|
+
return this.phantomMethods;
|
|
13471
|
+
}
|
|
13472
|
+
/* ----------------------------------------------------------- *
|
|
13473
|
+
* Private Helpers
|
|
13474
|
+
* ----------------------------------------------------------- */
|
|
13475
|
+
getRpcUrl(network) {
|
|
13476
|
+
if (this.networkUrl) {
|
|
13477
|
+
return this.networkUrl;
|
|
13478
|
+
}
|
|
13479
|
+
if (network === 'solana_devnet') {
|
|
13480
|
+
return SOLANA_DEVNET_RPC_URL;
|
|
13481
|
+
}
|
|
13482
|
+
else if (network === 'solana_mainnet') {
|
|
13483
|
+
return SOLANA_MAINNET_RPC_URL;
|
|
13484
|
+
}
|
|
13485
|
+
else if (network === 'surfnet') {
|
|
13486
|
+
return SURFNET_RPC_URL;
|
|
13487
|
+
}
|
|
13488
|
+
return SOLANA_MAINNET_RPC_URL; // default to mainnet
|
|
13489
|
+
}
|
|
13490
|
+
async submitSignedTransaction(signedTx, connection) {
|
|
13491
|
+
// Get fresh blockhash for confirmation
|
|
13492
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
|
|
13493
|
+
return this.submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight);
|
|
13494
|
+
}
|
|
13495
|
+
async submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight) {
|
|
13496
|
+
// Submit the transaction
|
|
13497
|
+
const signature = await connection.sendRawTransaction(signedTx.serialize(), {
|
|
13498
|
+
preflightCommitment: 'confirmed'
|
|
13499
|
+
});
|
|
13500
|
+
// Confirm using blockhash strategy (same as runTransaction)
|
|
13501
|
+
const confirmation = await connection.confirmTransaction({
|
|
13502
|
+
signature,
|
|
13503
|
+
blockhash,
|
|
13504
|
+
lastValidBlockHeight,
|
|
13505
|
+
}, 'confirmed');
|
|
13506
|
+
if (confirmation.value.err) {
|
|
13507
|
+
throw new Error(`Transaction failed: ${confirmation.value.err.toString()}`);
|
|
13508
|
+
}
|
|
13509
|
+
// Get transaction info
|
|
13510
|
+
const txInfo = await connection.getParsedTransaction(signature, {
|
|
13511
|
+
maxSupportedTransactionVersion: 0,
|
|
13512
|
+
commitment: 'confirmed'
|
|
13513
|
+
});
|
|
13514
|
+
return { signature, txInfo };
|
|
13515
|
+
}
|
|
13516
|
+
}
|
|
13517
|
+
PhantomWalletProvider.instance = null;
|
|
13518
|
+
|
|
13519
|
+
var lib = {};
|
|
13520
|
+
|
|
13521
|
+
var uaParser_min$1 = {exports: {}};
|
|
13522
|
+
|
|
13523
|
+
/* UAParser.js v1.0.41
|
|
13524
|
+
Copyright © 2012-2025 Faisal Salman <f@faisalman.com>
|
|
13525
|
+
MIT License */
|
|
13526
|
+
var uaParser_min = uaParser_min$1.exports;
|
|
13527
|
+
|
|
13528
|
+
var hasRequiredUaParser_min;
|
|
13529
|
+
|
|
13530
|
+
function requireUaParser_min () {
|
|
13531
|
+
if (hasRequiredUaParser_min) return uaParser_min$1.exports;
|
|
13532
|
+
hasRequiredUaParser_min = 1;
|
|
13533
|
+
(function (module, exports$1) {
|
|
13534
|
+
(function(window,undefined$1){var LIBVERSION="1.0.41",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",STR_TYPE="string",MAJOR="major",MODEL="model",NAME="name",TYPE="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",EMBEDDED="embedded",UA_MAX_LENGTH=500;var AMAZON="Amazon",APPLE="Apple",ASUS="ASUS",BLACKBERRY="BlackBerry",BROWSER="Browser",CHROME="Chrome",EDGE="Edge",FIREFOX="Firefox",GOOGLE="Google",HONOR="Honor",HUAWEI="Huawei",LENOVO="Lenovo",LG="LG",MICROSOFT="Microsoft",MOTOROLA="Motorola",NVIDIA="Nvidia",ONEPLUS="OnePlus",OPERA="Opera",OPPO="OPPO",SAMSUNG="Samsung",SHARP="Sharp",SONY="Sony",XIAOMI="Xiaomi",ZEBRA="Zebra",FACEBOOK="Facebook",CHROMIUM_OS="Chromium OS",MAC_OS="Mac OS",SUFFIX_BROWSER=" Browser";var extend=function(regexes,extensions){var mergedRegexes={};for(var i in regexes){if(extensions[i]&&extensions[i].length%2===0){mergedRegexes[i]=extensions[i].concat(regexes[i]);}else {mergedRegexes[i]=regexes[i];}}return mergedRegexes},enumerize=function(arr){var enums={};for(var i=0;i<arr.length;i++){enums[arr[i].toUpperCase()]=arr[i];}return enums},has=function(str1,str2){return typeof str1===STR_TYPE?lowerize(str2).indexOf(lowerize(str1))!==-1:false},lowerize=function(str){return str.toLowerCase()},majorize=function(version){return typeof version===STR_TYPE?version.replace(/[^\d\.]/g,EMPTY).split(".")[0]:undefined$1},trim=function(str,len){if(typeof str===STR_TYPE){str=str.replace(/^\s\s*/,EMPTY);return typeof len===UNDEF_TYPE?str:str.substring(0,UA_MAX_LENGTH)}};var rgxMapper=function(ua,arrays){var i=0,j,k,p,q,matches,match;while(i<arrays.length&&!matches){var regex=arrays[i],props=arrays[i+1];j=k=0;while(j<regex.length&&!matches){if(!regex[j]){break}matches=regex[j++].exec(ua);if(!!matches){for(p=0;p<props.length;p++){match=matches[++k];q=props[p];if(typeof q===OBJ_TYPE&&q.length>0){if(q.length===2){if(typeof q[1]==FUNC_TYPE){this[q[0]]=q[1].call(this,match);}else {this[q[0]]=q[1];}}else if(q.length===3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){this[q[0]]=match?q[1].call(this,match,q[2]):undefined$1;}else {this[q[0]]=match?match.replace(q[1],q[2]):undefined$1;}}else if(q.length===4){this[q[0]]=match?q[3].call(this,match.replace(q[1],q[2])):undefined$1;}}else {this[q]=match?match:undefined$1;}}}}i+=2;}},strMapper=function(str,map){for(var i in map){if(typeof map[i]===OBJ_TYPE&&map[i].length>0){for(var j=0;j<map[i].length;j++){if(has(map[i][j],str)){return i===UNKNOWN?undefined$1:i}}}else if(has(map[i],str)){return i===UNKNOWN?undefined$1:i}}return map.hasOwnProperty("*")?map["*"]:str};var oldSafariMap={"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},windowsVersionMap={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"};var regexes={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[VERSION,[NAME,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[VERSION,[NAME,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[NAME,VERSION],[/opios[\/ ]+([\w\.]+)/i],[VERSION,[NAME,OPERA+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[VERSION,[NAME,OPERA+" GX"]],[/\bopr\/([\w\.]+)/i],[VERSION,[NAME,OPERA]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[VERSION,[NAME,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[VERSION,[NAME,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[NAME,VERSION],[/quark(?:pc)?\/([-\w\.]+)/i],[VERSION,[NAME,"Quark"]],[/\bddg\/([\w\.]+)/i],[VERSION,[NAME,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[VERSION,[NAME,"UC"+BROWSER]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[VERSION,[NAME,"WeChat"]],[/konqueror\/([\w\.]+)/i],[VERSION,[NAME,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[VERSION,[NAME,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[VERSION,[NAME,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[VERSION,[NAME,"Smart Lenovo "+BROWSER]],[/(avast|avg)\/([\w\.]+)/i],[[NAME,/(.+)/,"$1 Secure "+BROWSER],VERSION],[/\bfocus\/([\w\.]+)/i],[VERSION,[NAME,FIREFOX+" Focus"]],[/\bopt\/([\w\.]+)/i],[VERSION,[NAME,OPERA+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[VERSION,[NAME,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[VERSION,[NAME,"Dolphin"]],[/coast\/([\w\.]+)/i],[VERSION,[NAME,OPERA+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[VERSION,[NAME,"MIUI"+SUFFIX_BROWSER]],[/fxios\/([\w\.-]+)/i],[VERSION,[NAME,FIREFOX]],[/\bqihoobrowser\/?([\w\.]*)/i],[VERSION,[NAME,"360"]],[/\b(qq)\/([\w\.]+)/i],[[NAME,/(.+)/,"$1Browser"],VERSION],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[NAME,/(.+)/,"$1"+SUFFIX_BROWSER],VERSION],[/samsungbrowser\/([\w\.]+)/i],[VERSION,[NAME,SAMSUNG+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[VERSION,[NAME,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[NAME,"Sogou Mobile"],VERSION],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[NAME,VERSION],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[NAME],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[VERSION,NAME],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[NAME,FACEBOOK],VERSION],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[NAME,VERSION],[/\bgsa\/([\w\.]+) .*safari\//i],[VERSION,[NAME,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[VERSION,[NAME,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[VERSION,[NAME,CHROME+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[NAME,CHROME+" WebView"],VERSION],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[VERSION,[NAME,"Android "+BROWSER]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[NAME,VERSION],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[VERSION,[NAME,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[VERSION,NAME],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[NAME,[VERSION,strMapper,oldSafariMap]],[/(webkit|khtml)\/([\w\.]+)/i],[NAME,VERSION],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[NAME,"Netscape"],VERSION],[/(wolvic|librewolf)\/([\w\.]+)/i],[NAME,VERSION],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[VERSION,[NAME,FIREFOX+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[NAME,[VERSION,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[NAME,[VERSION,/master.|lts./,""]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[ARCHITECTURE,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[ARCHITECTURE,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[ARCHITECTURE,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[ARCHITECTURE,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[ARCHITECTURE,"arm"]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[ARCHITECTURE,/ower/,EMPTY,lowerize]],[/ sun4\w[;\)]/i],[[ARCHITECTURE,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[ARCHITECTURE,lowerize]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[MODEL,[VENDOR,SAMSUNG],[TYPE,TABLET]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[MODEL,[VENDOR,SAMSUNG],[TYPE,MOBILE]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[MODEL,[VENDOR,APPLE],[TYPE,MOBILE]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[MODEL,[VENDOR,APPLE],[TYPE,TABLET]],[/(macintosh);/i],[MODEL,[VENDOR,APPLE]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[MODEL,[VENDOR,SHARP],[TYPE,MOBILE]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[MODEL,[VENDOR,HONOR],[TYPE,TABLET]],[/honor([-\w ]+)[;\)]/i],[MODEL,[VENDOR,HONOR],[TYPE,MOBILE]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[MODEL,[VENDOR,HUAWEI],[TYPE,TABLET]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[MODEL,[VENDOR,HUAWEI],[TYPE,MOBILE]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[MODEL,/_/g," "],[VENDOR,XIAOMI],[TYPE,TABLET]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[MODEL,/_/g," "],[VENDOR,XIAOMI],[TYPE,MOBILE]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[MODEL,[VENDOR,OPPO],[TYPE,MOBILE]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[MODEL,[VENDOR,strMapper,{OnePlus:["304","403","203"],"*":OPPO}],[TYPE,TABLET]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[MODEL,[VENDOR,"Vivo"],[TYPE,MOBILE]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[MODEL,[VENDOR,"Realme"],[TYPE,MOBILE]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto(?! 360)[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[MODEL,[VENDOR,MOTOROLA],[TYPE,MOBILE]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[MODEL,[VENDOR,MOTOROLA],[TYPE,TABLET]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[MODEL,[VENDOR,LG],[TYPE,TABLET]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv|watch)\w+)/i,/\blg-?([\d\w]+) bui/i],[MODEL,[VENDOR,LG],[TYPE,MOBILE]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[MODEL,[VENDOR,LENOVO],[TYPE,TABLET]],[/(nokia) (t[12][01])/i],[VENDOR,MODEL,[TYPE,TABLET]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[MODEL,/_/g," "],[TYPE,MOBILE],[VENDOR,"Nokia"]],[/(pixel (c|tablet))\b/i],[MODEL,[VENDOR,GOOGLE],[TYPE,TABLET]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[MODEL,[VENDOR,GOOGLE],[TYPE,MOBILE]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[MODEL,[VENDOR,SONY],[TYPE,MOBILE]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[MODEL,"Xperia Tablet"],[VENDOR,SONY],[TYPE,TABLET]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[MODEL,[VENDOR,ONEPLUS],[TYPE,MOBILE]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[MODEL,[VENDOR,AMAZON],[TYPE,TABLET]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[MODEL,/(.+)/g,"Fire Phone $1"],[VENDOR,AMAZON],[TYPE,MOBILE]],[/(playbook);[-\w\),; ]+(rim)/i],[MODEL,VENDOR,[TYPE,TABLET]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[MODEL,[VENDOR,BLACKBERRY],[TYPE,MOBILE]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[MODEL,[VENDOR,ASUS],[TYPE,TABLET]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[MODEL,[VENDOR,ASUS],[TYPE,MOBILE]],[/(nexus 9)/i],[MODEL,[VENDOR,"HTC"],[TYPE,TABLET]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[VENDOR,[MODEL,/_/g," "],[TYPE,MOBILE]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[MODEL,[VENDOR,"TCL"],[TYPE,TABLET]],[/(itel) ((\w+))/i],[[VENDOR,lowerize],MODEL,[TYPE,strMapper,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[MODEL,[VENDOR,"Acer"],[TYPE,TABLET]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[MODEL,[VENDOR,"Meizu"],[TYPE,MOBILE]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[MODEL,[VENDOR,"Ulefone"],[TYPE,MOBILE]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[MODEL,[VENDOR,"Energizer"],[TYPE,MOBILE]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[MODEL,[VENDOR,"Cat"],[TYPE,MOBILE]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[MODEL,[VENDOR,"Smartfren"],[TYPE,MOBILE]],[/droid.+; (a(?:015|06[35]|142p?))/i],[MODEL,[VENDOR,"Nothing"],[TYPE,MOBILE]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[MODEL,[VENDOR,"Archos"],[TYPE,TABLET]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[MODEL,[VENDOR,"Archos"],[TYPE,MOBILE]],[/(imo) (tab \w+)/i,/(infinix) (x1101b?)/i],[VENDOR,MODEL,[TYPE,TABLET]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (hmd|imo) ([\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,/(oppo) ?([\w ]+) bui/i],[VENDOR,MODEL,[TYPE,MOBILE]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[VENDOR,MODEL,[TYPE,TABLET]],[/(surface duo)/i],[MODEL,[VENDOR,MICROSOFT],[TYPE,TABLET]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[MODEL,[VENDOR,"Fairphone"],[TYPE,MOBILE]],[/(u304aa)/i],[MODEL,[VENDOR,"AT&T"],[TYPE,MOBILE]],[/\bsie-(\w*)/i],[MODEL,[VENDOR,"Siemens"],[TYPE,MOBILE]],[/\b(rct\w+) b/i],[MODEL,[VENDOR,"RCA"],[TYPE,TABLET]],[/\b(venue[\d ]{2,7}) b/i],[MODEL,[VENDOR,"Dell"],[TYPE,TABLET]],[/\b(q(?:mv|ta)\w+) b/i],[MODEL,[VENDOR,"Verizon"],[TYPE,TABLET]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[MODEL,[VENDOR,"Barnes & Noble"],[TYPE,TABLET]],[/\b(tm\d{3}\w+) b/i],[MODEL,[VENDOR,"NuVision"],[TYPE,TABLET]],[/\b(k88) b/i],[MODEL,[VENDOR,"ZTE"],[TYPE,TABLET]],[/\b(nx\d{3}j) b/i],[MODEL,[VENDOR,"ZTE"],[TYPE,MOBILE]],[/\b(gen\d{3}) b.+49h/i],[MODEL,[VENDOR,"Swiss"],[TYPE,MOBILE]],[/\b(zur\d{3}) b/i],[MODEL,[VENDOR,"Swiss"],[TYPE,TABLET]],[/\b((zeki)?tb.*\b) b/i],[MODEL,[VENDOR,"Zeki"],[TYPE,TABLET]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[VENDOR,"Dragon Touch"],MODEL,[TYPE,TABLET]],[/\b(ns-?\w{0,9}) b/i],[MODEL,[VENDOR,"Insignia"],[TYPE,TABLET]],[/\b((nxa|next)-?\w{0,9}) b/i],[MODEL,[VENDOR,"NextBook"],[TYPE,TABLET]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[VENDOR,"Voice"],MODEL,[TYPE,MOBILE]],[/\b(lvtel\-)?(v1[12]) b/i],[[VENDOR,"LvTel"],MODEL,[TYPE,MOBILE]],[/\b(ph-1) /i],[MODEL,[VENDOR,"Essential"],[TYPE,MOBILE]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[MODEL,[VENDOR,"Envizen"],[TYPE,TABLET]],[/\b(trio[-\w\. ]+) b/i],[MODEL,[VENDOR,"MachSpeed"],[TYPE,TABLET]],[/\btu_(1491) b/i],[MODEL,[VENDOR,"Rotor"],[TYPE,TABLET]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[MODEL,[VENDOR,NVIDIA],[TYPE,TABLET]],[/(sprint) (\w+)/i],[VENDOR,MODEL,[TYPE,MOBILE]],[/(kin\.[onetw]{3})/i],[[MODEL,/\./g," "],[VENDOR,MICROSOFT],[TYPE,MOBILE]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[MODEL,[VENDOR,ZEBRA],[TYPE,TABLET]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[MODEL,[VENDOR,ZEBRA],[TYPE,MOBILE]],[/smart-tv.+(samsung)/i],[VENDOR,[TYPE,SMARTTV]],[/hbbtv.+maple;(\d+)/i],[[MODEL,/^/,"SmartTV"],[VENDOR,SAMSUNG],[TYPE,SMARTTV]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[VENDOR,LG],[TYPE,SMARTTV]],[/(apple) ?tv/i],[VENDOR,[MODEL,APPLE+" TV"],[TYPE,SMARTTV]],[/crkey/i],[[MODEL,CHROME+"cast"],[VENDOR,GOOGLE],[TYPE,SMARTTV]],[/droid.+aft(\w+)( bui|\))/i],[MODEL,[VENDOR,AMAZON],[TYPE,SMARTTV]],[/(shield \w+ tv)/i],[MODEL,[VENDOR,NVIDIA],[TYPE,SMARTTV]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[MODEL,[VENDOR,SHARP],[TYPE,SMARTTV]],[/(bravia[\w ]+)( bui|\))/i],[MODEL,[VENDOR,SONY],[TYPE,SMARTTV]],[/(mi(tv|box)-?\w+) bui/i],[MODEL,[VENDOR,XIAOMI],[TYPE,SMARTTV]],[/Hbbtv.*(technisat) (.*);/i],[VENDOR,MODEL,[TYPE,SMARTTV]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[VENDOR,trim],[MODEL,trim],[TYPE,SMARTTV]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[MODEL,[TYPE,SMARTTV]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[TYPE,SMARTTV]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[VENDOR,MODEL,[TYPE,CONSOLE]],[/droid.+; (shield)( bui|\))/i],[MODEL,[VENDOR,NVIDIA],[TYPE,CONSOLE]],[/(playstation \w+)/i],[MODEL,[VENDOR,SONY],[TYPE,CONSOLE]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[MODEL,[VENDOR,MICROSOFT],[TYPE,CONSOLE]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[MODEL,[VENDOR,SAMSUNG],[TYPE,WEARABLE]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[VENDOR,MODEL,[TYPE,WEARABLE]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[MODEL,[VENDOR,OPPO],[TYPE,WEARABLE]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[MODEL,[VENDOR,APPLE],[TYPE,WEARABLE]],[/(opwwe\d{3})/i],[MODEL,[VENDOR,ONEPLUS],[TYPE,WEARABLE]],[/(moto 360)/i],[MODEL,[VENDOR,MOTOROLA],[TYPE,WEARABLE]],[/(smartwatch 3)/i],[MODEL,[VENDOR,SONY],[TYPE,WEARABLE]],[/(g watch r)/i],[MODEL,[VENDOR,LG],[TYPE,WEARABLE]],[/droid.+; (wt63?0{2,3})\)/i],[MODEL,[VENDOR,ZEBRA],[TYPE,WEARABLE]],[/droid.+; (glass) \d/i],[MODEL,[VENDOR,GOOGLE],[TYPE,WEARABLE]],[/(pico) (4|neo3(?: link|pro)?)/i],[VENDOR,MODEL,[TYPE,WEARABLE]],[/; (quest( \d| pro)?)/i],[MODEL,[VENDOR,FACEBOOK],[TYPE,WEARABLE]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[VENDOR,[TYPE,EMBEDDED]],[/(aeobc)\b/i],[MODEL,[VENDOR,AMAZON],[TYPE,EMBEDDED]],[/(homepod).+mac os/i],[MODEL,[VENDOR,APPLE],[TYPE,EMBEDDED]],[/windows iot/i],[[TYPE,EMBEDDED]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[MODEL,[TYPE,MOBILE]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[MODEL,[TYPE,TABLET]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[TYPE,TABLET]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[TYPE,MOBILE]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[MODEL,[VENDOR,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[VERSION,[NAME,EDGE+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[NAME,VERSION],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[VERSION,[NAME,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[NAME,VERSION],[/ladybird\//i],[[NAME,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[VERSION,NAME]],os:[[/microsoft (windows) (vista|xp)/i],[NAME,VERSION],[/(windows (?:phone(?: os)?|mobile|iot))[\/ ]?([\d\.\w ]*)/i],[NAME,[VERSION,strMapper,windowsVersionMap]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[VERSION,strMapper,windowsVersionMap],[NAME,"Windows"]],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[VERSION,/_/g,"."],[NAME,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[NAME,MAC_OS],[VERSION,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[VERSION,NAME],[/(ubuntu) ([\w\.]+) like android/i],[[NAME,/(.+)/,"$1 Touch"],VERSION],[/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen|webos)\w*[-\/; ]?([\d\.]*)/i],[NAME,VERSION],[/\(bb(10);/i],[VERSION,[NAME,BLACKBERRY]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[VERSION,[NAME,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[VERSION,[NAME,FIREFOX+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[VERSION,[NAME,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[VERSION,[NAME,"watchOS"]],[/crkey\/([\d\.]+)/i],[VERSION,[NAME,CHROME+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[NAME,CHROMIUM_OS],VERSION],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux)(?: arm\w*| x86\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[NAME,VERSION],[/(sunos) ?([\w\.\d]*)/i],[[NAME,"Solaris"],VERSION],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[NAME,VERSION]]};var UAParser=function(ua,extensions){if(typeof ua===OBJ_TYPE){extensions=ua;ua=undefined$1;}if(!(this instanceof UAParser)){return new UAParser(ua,extensions).getResult()}var _navigator=typeof window!==UNDEF_TYPE&&window.navigator?window.navigator:undefined$1;var _ua=ua||(_navigator&&_navigator.userAgent?_navigator.userAgent:EMPTY);var _uach=_navigator&&_navigator.userAgentData?_navigator.userAgentData:undefined$1;var _rgxmap=extensions?extend(regexes,extensions):regexes;var _isSelfNav=_navigator&&_navigator.userAgent==_ua;this.getBrowser=function(){var _browser={};_browser[NAME]=undefined$1;_browser[VERSION]=undefined$1;rgxMapper.call(_browser,_ua,_rgxmap.browser);_browser[MAJOR]=majorize(_browser[VERSION]);if(_isSelfNav&&_navigator&&_navigator.brave&&typeof _navigator.brave.isBrave==FUNC_TYPE){_browser[NAME]="Brave";}return _browser};this.getCPU=function(){var _cpu={};_cpu[ARCHITECTURE]=undefined$1;rgxMapper.call(_cpu,_ua,_rgxmap.cpu);return _cpu};this.getDevice=function(){var _device={};_device[VENDOR]=undefined$1;_device[MODEL]=undefined$1;_device[TYPE]=undefined$1;rgxMapper.call(_device,_ua,_rgxmap.device);if(_isSelfNav&&!_device[TYPE]&&_uach&&_uach.mobile){_device[TYPE]=MOBILE;}if(_isSelfNav&&_device[MODEL]=="Macintosh"&&_navigator&&typeof _navigator.standalone!==UNDEF_TYPE&&_navigator.maxTouchPoints&&_navigator.maxTouchPoints>2){_device[MODEL]="iPad";_device[TYPE]=TABLET;}return _device};this.getEngine=function(){var _engine={};_engine[NAME]=undefined$1;_engine[VERSION]=undefined$1;rgxMapper.call(_engine,_ua,_rgxmap.engine);return _engine};this.getOS=function(){var _os={};_os[NAME]=undefined$1;_os[VERSION]=undefined$1;rgxMapper.call(_os,_ua,_rgxmap.os);if(_isSelfNav&&!_os[NAME]&&_uach&&_uach.platform&&_uach.platform!="Unknown"){_os[NAME]=_uach.platform.replace(/chrome os/i,CHROMIUM_OS).replace(/macos/i,MAC_OS);}return _os};this.getResult=function(){return {ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}};this.getUA=function(){return _ua};this.setUA=function(ua){_ua=typeof ua===STR_TYPE&&ua.length>UA_MAX_LENGTH?trim(ua,UA_MAX_LENGTH):ua;return this};this.setUA(_ua);return this};UAParser.VERSION=LIBVERSION;UAParser.BROWSER=enumerize([NAME,VERSION,MAJOR]);UAParser.CPU=enumerize([ARCHITECTURE]);UAParser.DEVICE=enumerize([MODEL,VENDOR,TYPE,CONSOLE,MOBILE,SMARTTV,TABLET,WEARABLE,EMBEDDED]);UAParser.ENGINE=UAParser.OS=enumerize([NAME,VERSION]);{if(module.exports){exports$1=module.exports=UAParser;}exports$1.UAParser=UAParser;}var $=typeof window!==UNDEF_TYPE&&(window.jQuery||window.Zepto);if($&&!$.ua){var parser=new UAParser;$.ua=parser.getResult();$.ua.get=function(){return parser.getUA()};$.ua.set=function(ua){parser.setUA(ua);var result=parser.getResult();for(var prop in result){$.ua[prop]=result[prop];}};}})(typeof window==="object"?window:uaParser_min);
|
|
13535
|
+
} (uaParser_min$1, uaParser_min$1.exports));
|
|
13536
|
+
return uaParser_min$1.exports;
|
|
13537
|
+
}
|
|
13538
|
+
|
|
13539
|
+
var hasRequiredLib;
|
|
13540
|
+
|
|
13541
|
+
function requireLib () {
|
|
13542
|
+
if (hasRequiredLib) return lib;
|
|
13543
|
+
hasRequiredLib = 1;
|
|
13544
|
+
|
|
13545
|
+
Object.defineProperty(lib, '__esModule', { value: true });
|
|
13546
|
+
|
|
13547
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
13548
|
+
|
|
13549
|
+
var React = React$2;
|
|
13550
|
+
var React__default = _interopDefault(React);
|
|
13551
|
+
|
|
13552
|
+
var UAParser = requireUaParser_min();
|
|
13553
|
+
|
|
13554
|
+
var ClientUAInstance = new UAParser();
|
|
13555
|
+
var browser = ClientUAInstance.getBrowser();
|
|
13556
|
+
var cpu = ClientUAInstance.getCPU();
|
|
13557
|
+
var device = ClientUAInstance.getDevice();
|
|
13558
|
+
var engine = ClientUAInstance.getEngine();
|
|
13559
|
+
var os = ClientUAInstance.getOS();
|
|
13560
|
+
var ua = ClientUAInstance.getUA();
|
|
13561
|
+
var setUa = function setUa(userAgentString) {
|
|
13562
|
+
return ClientUAInstance.setUA(userAgentString);
|
|
13563
|
+
};
|
|
13564
|
+
var parseUserAgent = function parseUserAgent(userAgent) {
|
|
13565
|
+
if (!userAgent) {
|
|
13566
|
+
console.error('No userAgent string was provided');
|
|
13567
|
+
return;
|
|
13568
|
+
}
|
|
13569
|
+
|
|
13570
|
+
var UserAgentInstance = new UAParser(userAgent);
|
|
13571
|
+
return {
|
|
13572
|
+
UA: UserAgentInstance,
|
|
13573
|
+
browser: UserAgentInstance.getBrowser(),
|
|
13574
|
+
cpu: UserAgentInstance.getCPU(),
|
|
13575
|
+
device: UserAgentInstance.getDevice(),
|
|
13576
|
+
engine: UserAgentInstance.getEngine(),
|
|
13577
|
+
os: UserAgentInstance.getOS(),
|
|
13578
|
+
ua: UserAgentInstance.getUA(),
|
|
13579
|
+
setUserAgent: function setUserAgent(userAgentString) {
|
|
13580
|
+
return UserAgentInstance.setUA(userAgentString);
|
|
13581
|
+
}
|
|
13582
|
+
};
|
|
13583
|
+
};
|
|
13584
|
+
|
|
13585
|
+
var UAHelper = /*#__PURE__*/Object.freeze({
|
|
13586
|
+
ClientUAInstance: ClientUAInstance,
|
|
13587
|
+
browser: browser,
|
|
13588
|
+
cpu: cpu,
|
|
13589
|
+
device: device,
|
|
13590
|
+
engine: engine,
|
|
13591
|
+
os: os,
|
|
13592
|
+
ua: ua,
|
|
13593
|
+
setUa: setUa,
|
|
13594
|
+
parseUserAgent: parseUserAgent
|
|
13595
|
+
});
|
|
13596
|
+
|
|
13597
|
+
function ownKeys(object, enumerableOnly) {
|
|
13598
|
+
var keys = Object.keys(object);
|
|
13599
|
+
|
|
13600
|
+
if (Object.getOwnPropertySymbols) {
|
|
13601
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
13602
|
+
|
|
13603
|
+
if (enumerableOnly) {
|
|
13604
|
+
symbols = symbols.filter(function (sym) {
|
|
13605
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
13606
|
+
});
|
|
13607
|
+
}
|
|
13608
|
+
|
|
13609
|
+
keys.push.apply(keys, symbols);
|
|
13610
|
+
}
|
|
13611
|
+
|
|
13612
|
+
return keys;
|
|
13613
|
+
}
|
|
13614
|
+
|
|
13615
|
+
function _objectSpread2(target) {
|
|
13616
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13617
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
13618
|
+
|
|
13619
|
+
if (i % 2) {
|
|
13620
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
13621
|
+
_defineProperty(target, key, source[key]);
|
|
13622
|
+
});
|
|
13623
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
13624
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
13625
|
+
} else {
|
|
13626
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
13627
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
13628
|
+
});
|
|
13629
|
+
}
|
|
13630
|
+
}
|
|
13631
|
+
|
|
13632
|
+
return target;
|
|
13633
|
+
}
|
|
13634
|
+
|
|
13635
|
+
function _typeof(obj) {
|
|
13636
|
+
"@babel/helpers - typeof";
|
|
13637
|
+
|
|
13638
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
13639
|
+
_typeof = function (obj) {
|
|
13640
|
+
return typeof obj;
|
|
13641
|
+
};
|
|
13642
|
+
} else {
|
|
13643
|
+
_typeof = function (obj) {
|
|
13644
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
13645
|
+
};
|
|
13646
|
+
}
|
|
13647
|
+
|
|
13648
|
+
return _typeof(obj);
|
|
13649
|
+
}
|
|
13650
|
+
|
|
13651
|
+
function _classCallCheck(instance, Constructor) {
|
|
13652
|
+
if (!(instance instanceof Constructor)) {
|
|
13653
|
+
throw new TypeError("Cannot call a class as a function");
|
|
13654
|
+
}
|
|
13655
|
+
}
|
|
13656
|
+
|
|
13657
|
+
function _defineProperties(target, props) {
|
|
13658
|
+
for (var i = 0; i < props.length; i++) {
|
|
13659
|
+
var descriptor = props[i];
|
|
13660
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
13661
|
+
descriptor.configurable = true;
|
|
13662
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
13663
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13664
|
+
}
|
|
13665
|
+
}
|
|
13666
|
+
|
|
13667
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
13668
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
13669
|
+
return Constructor;
|
|
13670
|
+
}
|
|
13671
|
+
|
|
13672
|
+
function _defineProperty(obj, key, value) {
|
|
13673
|
+
if (key in obj) {
|
|
13674
|
+
Object.defineProperty(obj, key, {
|
|
13675
|
+
value: value,
|
|
13676
|
+
enumerable: true,
|
|
13677
|
+
configurable: true,
|
|
13678
|
+
writable: true
|
|
13679
|
+
});
|
|
13680
|
+
} else {
|
|
13681
|
+
obj[key] = value;
|
|
13682
|
+
}
|
|
13683
|
+
|
|
13684
|
+
return obj;
|
|
13685
|
+
}
|
|
13686
|
+
|
|
13687
|
+
function _extends() {
|
|
13688
|
+
_extends = Object.assign || function (target) {
|
|
13689
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13690
|
+
var source = arguments[i];
|
|
13691
|
+
|
|
13692
|
+
for (var key in source) {
|
|
13693
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13694
|
+
target[key] = source[key];
|
|
13695
|
+
}
|
|
13696
|
+
}
|
|
13697
|
+
}
|
|
13698
|
+
|
|
13699
|
+
return target;
|
|
13700
|
+
};
|
|
13701
|
+
|
|
13702
|
+
return _extends.apply(this, arguments);
|
|
13703
|
+
}
|
|
13704
|
+
|
|
13705
|
+
function _inherits(subClass, superClass) {
|
|
13706
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
13707
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
13708
|
+
}
|
|
13709
|
+
|
|
13710
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
13711
|
+
constructor: {
|
|
13712
|
+
value: subClass,
|
|
13713
|
+
writable: true,
|
|
13714
|
+
configurable: true
|
|
13715
|
+
}
|
|
13716
|
+
});
|
|
13717
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
13718
|
+
}
|
|
13719
|
+
|
|
13720
|
+
function _getPrototypeOf(o) {
|
|
13721
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
13722
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
13723
|
+
};
|
|
13724
|
+
return _getPrototypeOf(o);
|
|
13725
|
+
}
|
|
13726
|
+
|
|
13727
|
+
function _setPrototypeOf(o, p) {
|
|
13728
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
13729
|
+
o.__proto__ = p;
|
|
13730
|
+
return o;
|
|
13731
|
+
};
|
|
13732
|
+
|
|
13733
|
+
return _setPrototypeOf(o, p);
|
|
13734
|
+
}
|
|
13735
|
+
|
|
13736
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
13737
|
+
if (source == null) return {};
|
|
13738
|
+
var target = {};
|
|
13739
|
+
var sourceKeys = Object.keys(source);
|
|
13740
|
+
var key, i;
|
|
13741
|
+
|
|
13742
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
13743
|
+
key = sourceKeys[i];
|
|
13744
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
13745
|
+
target[key] = source[key];
|
|
13746
|
+
}
|
|
13747
|
+
|
|
13748
|
+
return target;
|
|
13749
|
+
}
|
|
13750
|
+
|
|
13751
|
+
function _objectWithoutProperties(source, excluded) {
|
|
13752
|
+
if (source == null) return {};
|
|
13753
|
+
|
|
13754
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
13755
|
+
|
|
13756
|
+
var key, i;
|
|
13757
|
+
|
|
13758
|
+
if (Object.getOwnPropertySymbols) {
|
|
13759
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
13760
|
+
|
|
13761
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
13762
|
+
key = sourceSymbolKeys[i];
|
|
13763
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
13764
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
13765
|
+
target[key] = source[key];
|
|
13766
|
+
}
|
|
13767
|
+
}
|
|
13768
|
+
|
|
13769
|
+
return target;
|
|
13770
|
+
}
|
|
13771
|
+
|
|
13772
|
+
function _assertThisInitialized(self) {
|
|
13773
|
+
if (self === void 0) {
|
|
13774
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13775
|
+
}
|
|
13776
|
+
|
|
13777
|
+
return self;
|
|
13778
|
+
}
|
|
13779
|
+
|
|
13780
|
+
function _possibleConstructorReturn(self, call) {
|
|
13781
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
13782
|
+
return call;
|
|
13783
|
+
} else if (call !== void 0) {
|
|
13784
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
13785
|
+
}
|
|
13786
|
+
|
|
13787
|
+
return _assertThisInitialized(self);
|
|
13788
|
+
}
|
|
13789
|
+
|
|
13790
|
+
function _slicedToArray(arr, i) {
|
|
13791
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
13792
|
+
}
|
|
13793
|
+
|
|
13794
|
+
function _arrayWithHoles(arr) {
|
|
13795
|
+
if (Array.isArray(arr)) return arr;
|
|
13796
|
+
}
|
|
13797
|
+
|
|
13798
|
+
function _iterableToArrayLimit(arr, i) {
|
|
13799
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
13800
|
+
|
|
13801
|
+
if (_i == null) return;
|
|
13802
|
+
var _arr = [];
|
|
13803
|
+
var _n = true;
|
|
13804
|
+
var _d = false;
|
|
13805
|
+
|
|
13806
|
+
var _s, _e;
|
|
13807
|
+
|
|
13808
|
+
try {
|
|
13809
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
13810
|
+
_arr.push(_s.value);
|
|
13811
|
+
|
|
13812
|
+
if (i && _arr.length === i) break;
|
|
13813
|
+
}
|
|
13814
|
+
} catch (err) {
|
|
13815
|
+
_d = true;
|
|
13816
|
+
_e = err;
|
|
13817
|
+
} finally {
|
|
13818
|
+
try {
|
|
13819
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
13820
|
+
} finally {
|
|
13821
|
+
if (_d) throw _e;
|
|
13822
|
+
}
|
|
13823
|
+
}
|
|
13824
|
+
|
|
13825
|
+
return _arr;
|
|
13826
|
+
}
|
|
13827
|
+
|
|
13828
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
13829
|
+
if (!o) return;
|
|
13830
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
13831
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
13832
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
13833
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
13834
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
13835
|
+
}
|
|
13836
|
+
|
|
13837
|
+
function _arrayLikeToArray(arr, len) {
|
|
13838
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
13839
|
+
|
|
13840
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
13841
|
+
|
|
13842
|
+
return arr2;
|
|
13843
|
+
}
|
|
13844
|
+
|
|
13845
|
+
function _nonIterableRest() {
|
|
13846
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
13847
|
+
}
|
|
13848
|
+
|
|
13849
|
+
var DeviceTypes = {
|
|
13850
|
+
Mobile: 'mobile',
|
|
13851
|
+
Tablet: 'tablet',
|
|
13852
|
+
SmartTv: 'smarttv',
|
|
13853
|
+
Console: 'console',
|
|
13854
|
+
Wearable: 'wearable',
|
|
13855
|
+
Embedded: 'embedded',
|
|
13856
|
+
Browser: undefined
|
|
13857
|
+
};
|
|
13858
|
+
var BrowserTypes = {
|
|
13859
|
+
Chrome: 'Chrome',
|
|
13860
|
+
Firefox: 'Firefox',
|
|
13861
|
+
Opera: 'Opera',
|
|
13862
|
+
Yandex: 'Yandex',
|
|
13863
|
+
Safari: 'Safari',
|
|
13864
|
+
InternetExplorer: 'Internet Explorer',
|
|
13865
|
+
Edge: 'Edge',
|
|
13866
|
+
Chromium: 'Chromium',
|
|
13867
|
+
Ie: 'IE',
|
|
13868
|
+
MobileSafari: 'Mobile Safari',
|
|
13869
|
+
EdgeChromium: 'Edge Chromium',
|
|
13870
|
+
MIUI: 'MIUI Browser',
|
|
13871
|
+
SamsungBrowser: 'Samsung Browser'
|
|
13872
|
+
};
|
|
13873
|
+
var OsTypes = {
|
|
13874
|
+
IOS: 'iOS',
|
|
13875
|
+
Android: 'Android',
|
|
13876
|
+
WindowsPhone: 'Windows Phone',
|
|
13877
|
+
Windows: 'Windows',
|
|
13878
|
+
MAC_OS: 'Mac OS'
|
|
13879
|
+
};
|
|
13880
|
+
var InitialDeviceTypes = {
|
|
13881
|
+
isMobile: false,
|
|
13882
|
+
isTablet: false,
|
|
13883
|
+
isBrowser: false,
|
|
13884
|
+
isSmartTV: false,
|
|
13885
|
+
isConsole: false,
|
|
13886
|
+
isWearable: false
|
|
13887
|
+
};
|
|
13888
|
+
|
|
13889
|
+
var checkDeviceType = function checkDeviceType(type) {
|
|
13890
|
+
switch (type) {
|
|
13891
|
+
case DeviceTypes.Mobile:
|
|
13892
|
+
return {
|
|
13893
|
+
isMobile: true
|
|
13894
|
+
};
|
|
13895
|
+
|
|
13896
|
+
case DeviceTypes.Tablet:
|
|
13897
|
+
return {
|
|
13898
|
+
isTablet: true
|
|
13899
|
+
};
|
|
13900
|
+
|
|
13901
|
+
case DeviceTypes.SmartTv:
|
|
13902
|
+
return {
|
|
13903
|
+
isSmartTV: true
|
|
13904
|
+
};
|
|
13905
|
+
|
|
13906
|
+
case DeviceTypes.Console:
|
|
13907
|
+
return {
|
|
13908
|
+
isConsole: true
|
|
13909
|
+
};
|
|
13910
|
+
|
|
13911
|
+
case DeviceTypes.Wearable:
|
|
13912
|
+
return {
|
|
13913
|
+
isWearable: true
|
|
13914
|
+
};
|
|
13915
|
+
|
|
13916
|
+
case DeviceTypes.Browser:
|
|
13917
|
+
return {
|
|
13918
|
+
isBrowser: true
|
|
13919
|
+
};
|
|
13920
|
+
|
|
13921
|
+
case DeviceTypes.Embedded:
|
|
13922
|
+
return {
|
|
13923
|
+
isEmbedded: true
|
|
13924
|
+
};
|
|
13925
|
+
|
|
13926
|
+
default:
|
|
13927
|
+
return InitialDeviceTypes;
|
|
13928
|
+
}
|
|
13929
|
+
};
|
|
13930
|
+
var setUserAgent = function setUserAgent(userAgent) {
|
|
13931
|
+
return setUa(userAgent);
|
|
13932
|
+
};
|
|
13933
|
+
var setDefaults = function setDefaults(p) {
|
|
13934
|
+
var d = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'none';
|
|
13935
|
+
return p ? p : d;
|
|
13936
|
+
};
|
|
13937
|
+
var getNavigatorInstance = function getNavigatorInstance() {
|
|
13938
|
+
if (typeof window !== 'undefined') {
|
|
13939
|
+
if (window.navigator || navigator) {
|
|
13940
|
+
return window.navigator || navigator;
|
|
13941
|
+
}
|
|
13942
|
+
}
|
|
13943
|
+
|
|
13944
|
+
return false;
|
|
13945
|
+
};
|
|
13946
|
+
var isIOS13Check = function isIOS13Check(type) {
|
|
13947
|
+
var nav = getNavigatorInstance();
|
|
13948
|
+
return nav && nav.platform && (nav.platform.indexOf(type) !== -1 || nav.platform === 'MacIntel' && nav.maxTouchPoints > 1 && !window.MSStream);
|
|
13949
|
+
};
|
|
13950
|
+
|
|
13951
|
+
var browserPayload = function browserPayload(isBrowser, browser, engine, os, ua) {
|
|
13952
|
+
return {
|
|
13953
|
+
isBrowser: isBrowser,
|
|
13954
|
+
browserMajorVersion: setDefaults(browser.major),
|
|
13955
|
+
browserFullVersion: setDefaults(browser.version),
|
|
13956
|
+
browserName: setDefaults(browser.name),
|
|
13957
|
+
engineName: setDefaults(engine.name),
|
|
13958
|
+
engineVersion: setDefaults(engine.version),
|
|
13959
|
+
osName: setDefaults(os.name),
|
|
13960
|
+
osVersion: setDefaults(os.version),
|
|
13961
|
+
userAgent: setDefaults(ua)
|
|
13962
|
+
};
|
|
13963
|
+
};
|
|
13964
|
+
var mobilePayload = function mobilePayload(type, device, os, ua) {
|
|
13965
|
+
return _objectSpread2({}, type, {
|
|
13966
|
+
vendor: setDefaults(device.vendor),
|
|
13967
|
+
model: setDefaults(device.model),
|
|
13968
|
+
os: setDefaults(os.name),
|
|
13969
|
+
osVersion: setDefaults(os.version),
|
|
13970
|
+
ua: setDefaults(ua)
|
|
13971
|
+
});
|
|
13972
|
+
};
|
|
13973
|
+
var smartTvPayload = function smartTvPayload(isSmartTV, engine, os, ua) {
|
|
13974
|
+
return {
|
|
13975
|
+
isSmartTV: isSmartTV,
|
|
13976
|
+
engineName: setDefaults(engine.name),
|
|
13977
|
+
engineVersion: setDefaults(engine.version),
|
|
13978
|
+
osName: setDefaults(os.name),
|
|
13979
|
+
osVersion: setDefaults(os.version),
|
|
13980
|
+
userAgent: setDefaults(ua)
|
|
13981
|
+
};
|
|
13982
|
+
};
|
|
13983
|
+
var consolePayload = function consolePayload(isConsole, engine, os, ua) {
|
|
13984
|
+
return {
|
|
13985
|
+
isConsole: isConsole,
|
|
13986
|
+
engineName: setDefaults(engine.name),
|
|
13987
|
+
engineVersion: setDefaults(engine.version),
|
|
13988
|
+
osName: setDefaults(os.name),
|
|
13989
|
+
osVersion: setDefaults(os.version),
|
|
13990
|
+
userAgent: setDefaults(ua)
|
|
13991
|
+
};
|
|
13992
|
+
};
|
|
13993
|
+
var wearablePayload = function wearablePayload(isWearable, engine, os, ua) {
|
|
13994
|
+
return {
|
|
13995
|
+
isWearable: isWearable,
|
|
13996
|
+
engineName: setDefaults(engine.name),
|
|
13997
|
+
engineVersion: setDefaults(engine.version),
|
|
13998
|
+
osName: setDefaults(os.name),
|
|
13999
|
+
osVersion: setDefaults(os.version),
|
|
14000
|
+
userAgent: setDefaults(ua)
|
|
14001
|
+
};
|
|
14002
|
+
};
|
|
14003
|
+
var embeddedPayload = function embeddedPayload(isEmbedded, device, engine, os, ua) {
|
|
14004
|
+
return {
|
|
14005
|
+
isEmbedded: isEmbedded,
|
|
14006
|
+
vendor: setDefaults(device.vendor),
|
|
14007
|
+
model: setDefaults(device.model),
|
|
14008
|
+
engineName: setDefaults(engine.name),
|
|
14009
|
+
engineVersion: setDefaults(engine.version),
|
|
14010
|
+
osName: setDefaults(os.name),
|
|
14011
|
+
osVersion: setDefaults(os.version),
|
|
14012
|
+
userAgent: setDefaults(ua)
|
|
14013
|
+
};
|
|
14014
|
+
};
|
|
14015
|
+
|
|
14016
|
+
function deviceDetect(userAgent) {
|
|
14017
|
+
var _ref = userAgent ? parseUserAgent(userAgent) : UAHelper,
|
|
14018
|
+
device = _ref.device,
|
|
14019
|
+
browser = _ref.browser,
|
|
14020
|
+
engine = _ref.engine,
|
|
14021
|
+
os = _ref.os,
|
|
14022
|
+
ua = _ref.ua;
|
|
14023
|
+
|
|
14024
|
+
var type = checkDeviceType(device.type);
|
|
14025
|
+
var isBrowser = type.isBrowser,
|
|
14026
|
+
isMobile = type.isMobile,
|
|
14027
|
+
isTablet = type.isTablet,
|
|
14028
|
+
isSmartTV = type.isSmartTV,
|
|
14029
|
+
isConsole = type.isConsole,
|
|
14030
|
+
isWearable = type.isWearable,
|
|
14031
|
+
isEmbedded = type.isEmbedded;
|
|
14032
|
+
|
|
14033
|
+
if (isBrowser) {
|
|
14034
|
+
return browserPayload(isBrowser, browser, engine, os, ua);
|
|
14035
|
+
}
|
|
14036
|
+
|
|
14037
|
+
if (isSmartTV) {
|
|
14038
|
+
return smartTvPayload(isSmartTV, engine, os, ua);
|
|
14039
|
+
}
|
|
14040
|
+
|
|
14041
|
+
if (isConsole) {
|
|
14042
|
+
return consolePayload(isConsole, engine, os, ua);
|
|
14043
|
+
}
|
|
14044
|
+
|
|
14045
|
+
if (isMobile) {
|
|
14046
|
+
return mobilePayload(type, device, os, ua);
|
|
14047
|
+
}
|
|
14048
|
+
|
|
14049
|
+
if (isTablet) {
|
|
14050
|
+
return mobilePayload(type, device, os, ua);
|
|
14051
|
+
}
|
|
14052
|
+
|
|
14053
|
+
if (isWearable) {
|
|
14054
|
+
return wearablePayload(isWearable, engine, os, ua);
|
|
14055
|
+
}
|
|
14056
|
+
|
|
14057
|
+
if (isEmbedded) {
|
|
14058
|
+
return embeddedPayload(isEmbedded, device, engine, os, ua);
|
|
14059
|
+
}
|
|
14060
|
+
}
|
|
14061
|
+
|
|
14062
|
+
var isMobileType = function isMobileType(_ref) {
|
|
14063
|
+
var type = _ref.type;
|
|
14064
|
+
return type === DeviceTypes.Mobile;
|
|
14065
|
+
};
|
|
14066
|
+
var isTabletType = function isTabletType(_ref2) {
|
|
14067
|
+
var type = _ref2.type;
|
|
14068
|
+
return type === DeviceTypes.Tablet;
|
|
14069
|
+
};
|
|
14070
|
+
var isMobileAndTabletType = function isMobileAndTabletType(_ref3) {
|
|
14071
|
+
var type = _ref3.type;
|
|
14072
|
+
return type === DeviceTypes.Mobile || type === DeviceTypes.Tablet;
|
|
14073
|
+
};
|
|
14074
|
+
var isSmartTVType = function isSmartTVType(_ref4) {
|
|
14075
|
+
var type = _ref4.type;
|
|
14076
|
+
return type === DeviceTypes.SmartTv;
|
|
14077
|
+
};
|
|
14078
|
+
var isBrowserType = function isBrowserType(_ref5) {
|
|
14079
|
+
var type = _ref5.type;
|
|
14080
|
+
return type === DeviceTypes.Browser;
|
|
14081
|
+
};
|
|
14082
|
+
var isWearableType = function isWearableType(_ref6) {
|
|
14083
|
+
var type = _ref6.type;
|
|
14084
|
+
return type === DeviceTypes.Wearable;
|
|
14085
|
+
};
|
|
14086
|
+
var isConsoleType = function isConsoleType(_ref7) {
|
|
14087
|
+
var type = _ref7.type;
|
|
14088
|
+
return type === DeviceTypes.Console;
|
|
14089
|
+
};
|
|
14090
|
+
var isEmbeddedType = function isEmbeddedType(_ref8) {
|
|
14091
|
+
var type = _ref8.type;
|
|
14092
|
+
return type === DeviceTypes.Embedded;
|
|
14093
|
+
};
|
|
14094
|
+
var getMobileVendor = function getMobileVendor(_ref9) {
|
|
14095
|
+
var vendor = _ref9.vendor;
|
|
14096
|
+
return setDefaults(vendor);
|
|
14097
|
+
};
|
|
14098
|
+
var getMobileModel = function getMobileModel(_ref10) {
|
|
14099
|
+
var model = _ref10.model;
|
|
14100
|
+
return setDefaults(model);
|
|
14101
|
+
};
|
|
14102
|
+
var getDeviceType = function getDeviceType(_ref11) {
|
|
14103
|
+
var type = _ref11.type;
|
|
14104
|
+
return setDefaults(type, 'browser');
|
|
14105
|
+
}; // os types
|
|
14106
|
+
|
|
14107
|
+
var isAndroidType = function isAndroidType(_ref12) {
|
|
14108
|
+
var name = _ref12.name;
|
|
14109
|
+
return name === OsTypes.Android;
|
|
14110
|
+
};
|
|
14111
|
+
var isWindowsType = function isWindowsType(_ref13) {
|
|
14112
|
+
var name = _ref13.name;
|
|
14113
|
+
return name === OsTypes.Windows;
|
|
14114
|
+
};
|
|
14115
|
+
var isMacOsType = function isMacOsType(_ref14) {
|
|
14116
|
+
var name = _ref14.name;
|
|
14117
|
+
return name === OsTypes.MAC_OS;
|
|
14118
|
+
};
|
|
14119
|
+
var isWinPhoneType = function isWinPhoneType(_ref15) {
|
|
14120
|
+
var name = _ref15.name;
|
|
14121
|
+
return name === OsTypes.WindowsPhone;
|
|
14122
|
+
};
|
|
14123
|
+
var isIOSType = function isIOSType(_ref16) {
|
|
14124
|
+
var name = _ref16.name;
|
|
14125
|
+
return name === OsTypes.IOS;
|
|
14126
|
+
};
|
|
14127
|
+
var getOsVersion = function getOsVersion(_ref17) {
|
|
14128
|
+
var version = _ref17.version;
|
|
14129
|
+
return setDefaults(version);
|
|
14130
|
+
};
|
|
14131
|
+
var getOsName = function getOsName(_ref18) {
|
|
14132
|
+
var name = _ref18.name;
|
|
14133
|
+
return setDefaults(name);
|
|
14134
|
+
}; // browser types
|
|
14135
|
+
|
|
14136
|
+
var isChromeType = function isChromeType(_ref19) {
|
|
14137
|
+
var name = _ref19.name;
|
|
14138
|
+
return name === BrowserTypes.Chrome;
|
|
14139
|
+
};
|
|
14140
|
+
var isFirefoxType = function isFirefoxType(_ref20) {
|
|
14141
|
+
var name = _ref20.name;
|
|
14142
|
+
return name === BrowserTypes.Firefox;
|
|
14143
|
+
};
|
|
14144
|
+
var isChromiumType = function isChromiumType(_ref21) {
|
|
14145
|
+
var name = _ref21.name;
|
|
14146
|
+
return name === BrowserTypes.Chromium;
|
|
14147
|
+
};
|
|
14148
|
+
var isEdgeType = function isEdgeType(_ref22) {
|
|
14149
|
+
var name = _ref22.name;
|
|
14150
|
+
return name === BrowserTypes.Edge;
|
|
14151
|
+
};
|
|
14152
|
+
var isYandexType = function isYandexType(_ref23) {
|
|
14153
|
+
var name = _ref23.name;
|
|
14154
|
+
return name === BrowserTypes.Yandex;
|
|
14155
|
+
};
|
|
14156
|
+
var isSafariType = function isSafariType(_ref24) {
|
|
14157
|
+
var name = _ref24.name;
|
|
14158
|
+
return name === BrowserTypes.Safari || name === BrowserTypes.MobileSafari;
|
|
14159
|
+
};
|
|
14160
|
+
var isMobileSafariType = function isMobileSafariType(_ref25) {
|
|
14161
|
+
var name = _ref25.name;
|
|
14162
|
+
return name === BrowserTypes.MobileSafari;
|
|
14163
|
+
};
|
|
14164
|
+
var isOperaType = function isOperaType(_ref26) {
|
|
14165
|
+
var name = _ref26.name;
|
|
14166
|
+
return name === BrowserTypes.Opera;
|
|
14167
|
+
};
|
|
14168
|
+
var isIEType = function isIEType(_ref27) {
|
|
14169
|
+
var name = _ref27.name;
|
|
14170
|
+
return name === BrowserTypes.InternetExplorer || name === BrowserTypes.Ie;
|
|
14171
|
+
};
|
|
14172
|
+
var isMIUIType = function isMIUIType(_ref28) {
|
|
14173
|
+
var name = _ref28.name;
|
|
14174
|
+
return name === BrowserTypes.MIUI;
|
|
14175
|
+
};
|
|
14176
|
+
var isSamsungBrowserType = function isSamsungBrowserType(_ref29) {
|
|
14177
|
+
var name = _ref29.name;
|
|
14178
|
+
return name === BrowserTypes.SamsungBrowser;
|
|
14179
|
+
};
|
|
14180
|
+
var getBrowserFullVersion = function getBrowserFullVersion(_ref30) {
|
|
14181
|
+
var version = _ref30.version;
|
|
14182
|
+
return setDefaults(version);
|
|
14183
|
+
};
|
|
14184
|
+
var getBrowserVersion = function getBrowserVersion(_ref31) {
|
|
14185
|
+
var major = _ref31.major;
|
|
14186
|
+
return setDefaults(major);
|
|
14187
|
+
};
|
|
14188
|
+
var getBrowserName = function getBrowserName(_ref32) {
|
|
14189
|
+
var name = _ref32.name;
|
|
14190
|
+
return setDefaults(name);
|
|
14191
|
+
}; // engine types
|
|
14192
|
+
|
|
14193
|
+
var getEngineName = function getEngineName(_ref33) {
|
|
14194
|
+
var name = _ref33.name;
|
|
14195
|
+
return setDefaults(name);
|
|
14196
|
+
};
|
|
14197
|
+
var getEngineVersion = function getEngineVersion(_ref34) {
|
|
14198
|
+
var version = _ref34.version;
|
|
14199
|
+
return setDefaults(version);
|
|
14200
|
+
};
|
|
14201
|
+
var isElectronType = function isElectronType() {
|
|
14202
|
+
var nav = getNavigatorInstance();
|
|
14203
|
+
var ua = nav && nav.userAgent && nav.userAgent.toLowerCase();
|
|
14204
|
+
return typeof ua === 'string' ? /electron/.test(ua) : false;
|
|
14205
|
+
};
|
|
14206
|
+
var isEdgeChromiumType = function isEdgeChromiumType(ua) {
|
|
14207
|
+
return typeof ua === 'string' && ua.indexOf('Edg/') !== -1;
|
|
14208
|
+
};
|
|
14209
|
+
var getIOS13 = function getIOS13() {
|
|
14210
|
+
var nav = getNavigatorInstance();
|
|
14211
|
+
return nav && (/iPad|iPhone|iPod/.test(nav.platform) || nav.platform === 'MacIntel' && nav.maxTouchPoints > 1) && !window.MSStream;
|
|
14212
|
+
};
|
|
14213
|
+
var getIPad13 = function getIPad13() {
|
|
14214
|
+
return isIOS13Check('iPad');
|
|
14215
|
+
};
|
|
14216
|
+
var getIphone13 = function getIphone13() {
|
|
14217
|
+
return isIOS13Check('iPhone');
|
|
14218
|
+
};
|
|
14219
|
+
var getIPod13 = function getIPod13() {
|
|
14220
|
+
return isIOS13Check('iPod');
|
|
14221
|
+
};
|
|
14222
|
+
var getUseragent = function getUseragent(userAg) {
|
|
14223
|
+
return setDefaults(userAg);
|
|
14224
|
+
};
|
|
14225
|
+
|
|
14226
|
+
function buildSelectorsObject(options) {
|
|
14227
|
+
var _ref = options ? options : UAHelper,
|
|
14228
|
+
device = _ref.device,
|
|
14229
|
+
browser = _ref.browser,
|
|
14230
|
+
os = _ref.os,
|
|
14231
|
+
engine = _ref.engine,
|
|
14232
|
+
ua = _ref.ua;
|
|
14233
|
+
|
|
14234
|
+
return {
|
|
14235
|
+
isSmartTV: isSmartTVType(device),
|
|
14236
|
+
isConsole: isConsoleType(device),
|
|
14237
|
+
isWearable: isWearableType(device),
|
|
14238
|
+
isEmbedded: isEmbeddedType(device),
|
|
14239
|
+
isMobileSafari: isMobileSafariType(browser) || getIPad13(),
|
|
14240
|
+
isChromium: isChromiumType(browser),
|
|
14241
|
+
isMobile: isMobileAndTabletType(device) || getIPad13(),
|
|
14242
|
+
isMobileOnly: isMobileType(device),
|
|
14243
|
+
isTablet: isTabletType(device) || getIPad13(),
|
|
14244
|
+
isBrowser: isBrowserType(device),
|
|
14245
|
+
isDesktop: isBrowserType(device),
|
|
14246
|
+
isAndroid: isAndroidType(os),
|
|
14247
|
+
isWinPhone: isWinPhoneType(os),
|
|
14248
|
+
isIOS: isIOSType(os) || getIPad13(),
|
|
14249
|
+
isChrome: isChromeType(browser),
|
|
14250
|
+
isFirefox: isFirefoxType(browser),
|
|
14251
|
+
isSafari: isSafariType(browser),
|
|
14252
|
+
isOpera: isOperaType(browser),
|
|
14253
|
+
isIE: isIEType(browser),
|
|
14254
|
+
osVersion: getOsVersion(os),
|
|
14255
|
+
osName: getOsName(os),
|
|
14256
|
+
fullBrowserVersion: getBrowserFullVersion(browser),
|
|
14257
|
+
browserVersion: getBrowserVersion(browser),
|
|
14258
|
+
browserName: getBrowserName(browser),
|
|
14259
|
+
mobileVendor: getMobileVendor(device),
|
|
14260
|
+
mobileModel: getMobileModel(device),
|
|
14261
|
+
engineName: getEngineName(engine),
|
|
14262
|
+
engineVersion: getEngineVersion(engine),
|
|
14263
|
+
getUA: getUseragent(ua),
|
|
14264
|
+
isEdge: isEdgeType(browser) || isEdgeChromiumType(ua),
|
|
14265
|
+
isYandex: isYandexType(browser),
|
|
14266
|
+
deviceType: getDeviceType(device),
|
|
14267
|
+
isIOS13: getIOS13(),
|
|
14268
|
+
isIPad13: getIPad13(),
|
|
14269
|
+
isIPhone13: getIphone13(),
|
|
14270
|
+
isIPod13: getIPod13(),
|
|
14271
|
+
isElectron: isElectronType(),
|
|
14272
|
+
isEdgeChromium: isEdgeChromiumType(ua),
|
|
14273
|
+
isLegacyEdge: isEdgeType(browser) && !isEdgeChromiumType(ua),
|
|
14274
|
+
isWindows: isWindowsType(os),
|
|
14275
|
+
isMacOs: isMacOsType(os),
|
|
14276
|
+
isMIUI: isMIUIType(browser),
|
|
14277
|
+
isSamsungBrowser: isSamsungBrowserType(browser)
|
|
14278
|
+
};
|
|
14279
|
+
}
|
|
14280
|
+
|
|
14281
|
+
var isSmartTV = isSmartTVType(device);
|
|
14282
|
+
var isConsole = isConsoleType(device);
|
|
14283
|
+
var isWearable = isWearableType(device);
|
|
14284
|
+
var isEmbedded = isEmbeddedType(device);
|
|
14285
|
+
var isMobileSafari = isMobileSafariType(browser) || getIPad13();
|
|
14286
|
+
var isChromium = isChromiumType(browser);
|
|
14287
|
+
var isMobile = isMobileAndTabletType(device) || getIPad13();
|
|
14288
|
+
var isMobileOnly = isMobileType(device);
|
|
14289
|
+
var isTablet = isTabletType(device) || getIPad13();
|
|
14290
|
+
var isBrowser = isBrowserType(device);
|
|
14291
|
+
var isDesktop = isBrowserType(device);
|
|
14292
|
+
var isAndroid = isAndroidType(os);
|
|
14293
|
+
var isWinPhone = isWinPhoneType(os);
|
|
14294
|
+
var isIOS = isIOSType(os) || getIPad13();
|
|
14295
|
+
var isChrome = isChromeType(browser);
|
|
14296
|
+
var isFirefox = isFirefoxType(browser);
|
|
14297
|
+
var isSafari = isSafariType(browser);
|
|
14298
|
+
var isOpera = isOperaType(browser);
|
|
14299
|
+
var isIE = isIEType(browser);
|
|
14300
|
+
var osVersion = getOsVersion(os);
|
|
14301
|
+
var osName = getOsName(os);
|
|
14302
|
+
var fullBrowserVersion = getBrowserFullVersion(browser);
|
|
14303
|
+
var browserVersion = getBrowserVersion(browser);
|
|
14304
|
+
var browserName = getBrowserName(browser);
|
|
14305
|
+
var mobileVendor = getMobileVendor(device);
|
|
14306
|
+
var mobileModel = getMobileModel(device);
|
|
14307
|
+
var engineName = getEngineName(engine);
|
|
14308
|
+
var engineVersion = getEngineVersion(engine);
|
|
14309
|
+
var getUA = getUseragent(ua);
|
|
14310
|
+
var isEdge = isEdgeType(browser) || isEdgeChromiumType(ua);
|
|
14311
|
+
var isYandex = isYandexType(browser);
|
|
14312
|
+
var deviceType = getDeviceType(device);
|
|
14313
|
+
var isIOS13 = getIOS13();
|
|
14314
|
+
var isIPad13 = getIPad13();
|
|
14315
|
+
var isIPhone13 = getIphone13();
|
|
14316
|
+
var isIPod13 = getIPod13();
|
|
14317
|
+
var isElectron = isElectronType();
|
|
14318
|
+
var isEdgeChromium = isEdgeChromiumType(ua);
|
|
14319
|
+
var isLegacyEdge = isEdgeType(browser) && !isEdgeChromiumType(ua);
|
|
14320
|
+
var isWindows = isWindowsType(os);
|
|
14321
|
+
var isMacOs = isMacOsType(os);
|
|
14322
|
+
var isMIUI = isMIUIType(browser);
|
|
14323
|
+
var isSamsungBrowser = isSamsungBrowserType(browser);
|
|
14324
|
+
var getSelectorsByUserAgent = function getSelectorsByUserAgent(userAgent) {
|
|
14325
|
+
if (!userAgent || typeof userAgent !== 'string') {
|
|
14326
|
+
console.error('No valid user agent string was provided');
|
|
14327
|
+
return;
|
|
14328
|
+
}
|
|
14329
|
+
|
|
14330
|
+
var _UAHelper$parseUserAg = parseUserAgent(userAgent),
|
|
14331
|
+
device = _UAHelper$parseUserAg.device,
|
|
14332
|
+
browser = _UAHelper$parseUserAg.browser,
|
|
14333
|
+
os = _UAHelper$parseUserAg.os,
|
|
14334
|
+
engine = _UAHelper$parseUserAg.engine,
|
|
14335
|
+
ua = _UAHelper$parseUserAg.ua;
|
|
14336
|
+
|
|
14337
|
+
return buildSelectorsObject({
|
|
14338
|
+
device: device,
|
|
14339
|
+
browser: browser,
|
|
14340
|
+
os: os,
|
|
14341
|
+
engine: engine,
|
|
14342
|
+
ua: ua
|
|
14343
|
+
});
|
|
14344
|
+
};
|
|
14345
|
+
|
|
14346
|
+
var AndroidView = function AndroidView(_ref) {
|
|
14347
|
+
var renderWithFragment = _ref.renderWithFragment,
|
|
14348
|
+
children = _ref.children,
|
|
14349
|
+
props = _objectWithoutProperties(_ref, ["renderWithFragment", "children"]);
|
|
14350
|
+
|
|
14351
|
+
return isAndroid ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14352
|
+
};
|
|
14353
|
+
var BrowserView = function BrowserView(_ref2) {
|
|
14354
|
+
var renderWithFragment = _ref2.renderWithFragment,
|
|
14355
|
+
children = _ref2.children,
|
|
14356
|
+
props = _objectWithoutProperties(_ref2, ["renderWithFragment", "children"]);
|
|
14357
|
+
|
|
14358
|
+
return isBrowser ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14359
|
+
};
|
|
14360
|
+
var IEView = function IEView(_ref3) {
|
|
14361
|
+
var renderWithFragment = _ref3.renderWithFragment,
|
|
14362
|
+
children = _ref3.children,
|
|
14363
|
+
props = _objectWithoutProperties(_ref3, ["renderWithFragment", "children"]);
|
|
14364
|
+
|
|
14365
|
+
return isIE ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14366
|
+
};
|
|
14367
|
+
var IOSView = function IOSView(_ref4) {
|
|
14368
|
+
var renderWithFragment = _ref4.renderWithFragment,
|
|
14369
|
+
children = _ref4.children,
|
|
14370
|
+
props = _objectWithoutProperties(_ref4, ["renderWithFragment", "children"]);
|
|
14371
|
+
|
|
14372
|
+
return isIOS ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14373
|
+
};
|
|
14374
|
+
var MobileView = function MobileView(_ref5) {
|
|
14375
|
+
var renderWithFragment = _ref5.renderWithFragment,
|
|
14376
|
+
children = _ref5.children,
|
|
14377
|
+
props = _objectWithoutProperties(_ref5, ["renderWithFragment", "children"]);
|
|
14378
|
+
|
|
14379
|
+
return isMobile ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14380
|
+
};
|
|
14381
|
+
var TabletView = function TabletView(_ref6) {
|
|
14382
|
+
var renderWithFragment = _ref6.renderWithFragment,
|
|
14383
|
+
children = _ref6.children,
|
|
14384
|
+
props = _objectWithoutProperties(_ref6, ["renderWithFragment", "children"]);
|
|
14385
|
+
|
|
14386
|
+
return isTablet ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14387
|
+
};
|
|
14388
|
+
var WinPhoneView = function WinPhoneView(_ref7) {
|
|
14389
|
+
var renderWithFragment = _ref7.renderWithFragment,
|
|
14390
|
+
children = _ref7.children,
|
|
14391
|
+
props = _objectWithoutProperties(_ref7, ["renderWithFragment", "children"]);
|
|
14392
|
+
|
|
14393
|
+
return isWinPhone ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14394
|
+
};
|
|
14395
|
+
var MobileOnlyView = function MobileOnlyView(_ref8) {
|
|
14396
|
+
var renderWithFragment = _ref8.renderWithFragment,
|
|
14397
|
+
children = _ref8.children;
|
|
14398
|
+
_ref8.viewClassName;
|
|
14399
|
+
_ref8.style;
|
|
14400
|
+
var props = _objectWithoutProperties(_ref8, ["renderWithFragment", "children", "viewClassName", "style"]);
|
|
14401
|
+
|
|
14402
|
+
return isMobileOnly ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14403
|
+
};
|
|
14404
|
+
var SmartTVView = function SmartTVView(_ref9) {
|
|
14405
|
+
var renderWithFragment = _ref9.renderWithFragment,
|
|
14406
|
+
children = _ref9.children,
|
|
14407
|
+
props = _objectWithoutProperties(_ref9, ["renderWithFragment", "children"]);
|
|
14408
|
+
|
|
14409
|
+
return isSmartTV ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14410
|
+
};
|
|
14411
|
+
var ConsoleView = function ConsoleView(_ref10) {
|
|
14412
|
+
var renderWithFragment = _ref10.renderWithFragment,
|
|
14413
|
+
children = _ref10.children,
|
|
14414
|
+
props = _objectWithoutProperties(_ref10, ["renderWithFragment", "children"]);
|
|
14415
|
+
|
|
14416
|
+
return isConsole ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14417
|
+
};
|
|
14418
|
+
var WearableView = function WearableView(_ref11) {
|
|
14419
|
+
var renderWithFragment = _ref11.renderWithFragment,
|
|
14420
|
+
children = _ref11.children,
|
|
14421
|
+
props = _objectWithoutProperties(_ref11, ["renderWithFragment", "children"]);
|
|
14422
|
+
|
|
14423
|
+
return isWearable ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14424
|
+
};
|
|
14425
|
+
var CustomView = function CustomView(_ref12) {
|
|
14426
|
+
var renderWithFragment = _ref12.renderWithFragment,
|
|
14427
|
+
children = _ref12.children;
|
|
14428
|
+
_ref12.viewClassName;
|
|
14429
|
+
_ref12.style;
|
|
14430
|
+
var condition = _ref12.condition,
|
|
14431
|
+
props = _objectWithoutProperties(_ref12, ["renderWithFragment", "children", "viewClassName", "style", "condition"]);
|
|
14432
|
+
|
|
14433
|
+
return condition ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", props, children) : null;
|
|
14434
|
+
};
|
|
14435
|
+
|
|
14436
|
+
function withOrientationChange(WrappedComponent) {
|
|
14437
|
+
return /*#__PURE__*/function (_React$Component) {
|
|
14438
|
+
_inherits(_class, _React$Component);
|
|
14439
|
+
|
|
14440
|
+
function _class(props) {
|
|
14441
|
+
var _this;
|
|
14442
|
+
|
|
14443
|
+
_classCallCheck(this, _class);
|
|
14444
|
+
|
|
14445
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, props));
|
|
14446
|
+
_this.isEventListenerAdded = false;
|
|
14447
|
+
_this.handleOrientationChange = _this.handleOrientationChange.bind(_assertThisInitialized(_this));
|
|
14448
|
+
_this.onOrientationChange = _this.onOrientationChange.bind(_assertThisInitialized(_this));
|
|
14449
|
+
_this.onPageLoad = _this.onPageLoad.bind(_assertThisInitialized(_this));
|
|
14450
|
+
_this.state = {
|
|
14451
|
+
isLandscape: false,
|
|
14452
|
+
isPortrait: false
|
|
14453
|
+
};
|
|
14454
|
+
return _this;
|
|
14455
|
+
}
|
|
14456
|
+
|
|
14457
|
+
_createClass(_class, [{
|
|
14458
|
+
key: "handleOrientationChange",
|
|
14459
|
+
value: function handleOrientationChange() {
|
|
14460
|
+
if (!this.isEventListenerAdded) {
|
|
14461
|
+
this.isEventListenerAdded = true;
|
|
14462
|
+
}
|
|
14463
|
+
|
|
14464
|
+
var orientation = window.innerWidth > window.innerHeight ? 90 : 0;
|
|
14465
|
+
this.setState({
|
|
14466
|
+
isPortrait: orientation === 0,
|
|
14467
|
+
isLandscape: orientation === 90
|
|
14468
|
+
});
|
|
14469
|
+
}
|
|
14470
|
+
}, {
|
|
14471
|
+
key: "onOrientationChange",
|
|
14472
|
+
value: function onOrientationChange() {
|
|
14473
|
+
this.handleOrientationChange();
|
|
14474
|
+
}
|
|
14475
|
+
}, {
|
|
14476
|
+
key: "onPageLoad",
|
|
14477
|
+
value: function onPageLoad() {
|
|
14478
|
+
this.handleOrientationChange();
|
|
14479
|
+
}
|
|
14480
|
+
}, {
|
|
14481
|
+
key: "componentDidMount",
|
|
14482
|
+
value: function componentDidMount() {
|
|
14483
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined && isMobile) {
|
|
14484
|
+
if (!this.isEventListenerAdded) {
|
|
14485
|
+
this.handleOrientationChange();
|
|
14486
|
+
window.addEventListener("load", this.onPageLoad, false);
|
|
14487
|
+
} else {
|
|
14488
|
+
window.removeEventListener("load", this.onPageLoad, false);
|
|
14489
|
+
}
|
|
14490
|
+
|
|
14491
|
+
window.addEventListener("resize", this.onOrientationChange, false);
|
|
14492
|
+
}
|
|
14493
|
+
}
|
|
14494
|
+
}, {
|
|
14495
|
+
key: "componentWillUnmount",
|
|
14496
|
+
value: function componentWillUnmount() {
|
|
14497
|
+
window.removeEventListener("resize", this.onOrientationChange, false);
|
|
14498
|
+
}
|
|
14499
|
+
}, {
|
|
14500
|
+
key: "render",
|
|
14501
|
+
value: function render() {
|
|
14502
|
+
return React__default.createElement(WrappedComponent, _extends({}, this.props, {
|
|
14503
|
+
isLandscape: this.state.isLandscape,
|
|
14504
|
+
isPortrait: this.state.isPortrait
|
|
14505
|
+
}));
|
|
14506
|
+
}
|
|
14507
|
+
}]);
|
|
14508
|
+
|
|
14509
|
+
return _class;
|
|
14510
|
+
}(React__default.Component);
|
|
14511
|
+
}
|
|
14512
|
+
|
|
14513
|
+
function useMobileOrientation() {
|
|
14514
|
+
var _useState = React.useState(function () {
|
|
14515
|
+
var orientation = window.innerWidth > window.innerHeight ? 90 : 0;
|
|
14516
|
+
return {
|
|
14517
|
+
isPortrait: orientation === 0,
|
|
14518
|
+
isLandscape: orientation === 90,
|
|
14519
|
+
orientation: orientation === 0 ? 'portrait' : 'landscape'
|
|
14520
|
+
};
|
|
14521
|
+
}),
|
|
14522
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14523
|
+
state = _useState2[0],
|
|
14524
|
+
setState = _useState2[1];
|
|
14525
|
+
|
|
14526
|
+
var handleOrientationChange = React.useCallback(function () {
|
|
14527
|
+
var orientation = window.innerWidth > window.innerHeight ? 90 : 0;
|
|
14528
|
+
var next = {
|
|
14529
|
+
isPortrait: orientation === 0,
|
|
14530
|
+
isLandscape: orientation === 90,
|
|
14531
|
+
orientation: orientation === 0 ? 'portrait' : 'landscape'
|
|
14532
|
+
};
|
|
14533
|
+
state.orientation !== next.orientation && setState(next);
|
|
14534
|
+
}, [state.orientation]);
|
|
14535
|
+
React.useEffect(function () {
|
|
14536
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined && isMobile) {
|
|
14537
|
+
handleOrientationChange();
|
|
14538
|
+
window.addEventListener("load", handleOrientationChange, false);
|
|
14539
|
+
window.addEventListener("resize", handleOrientationChange, false);
|
|
14540
|
+
}
|
|
14541
|
+
|
|
14542
|
+
return function () {
|
|
14543
|
+
window.removeEventListener("resize", handleOrientationChange, false);
|
|
14544
|
+
window.removeEventListener("load", handleOrientationChange, false);
|
|
14545
|
+
};
|
|
14546
|
+
}, [handleOrientationChange]);
|
|
14547
|
+
return state;
|
|
14548
|
+
}
|
|
14549
|
+
|
|
14550
|
+
function useDeviceData(userAgent) {
|
|
14551
|
+
var hookUserAgent = userAgent ? userAgent : window.navigator.userAgent;
|
|
14552
|
+
return parseUserAgent(hookUserAgent);
|
|
14553
|
+
}
|
|
14554
|
+
|
|
14555
|
+
function useDeviceSelectors(userAgent) {
|
|
14556
|
+
var hookUserAgent = userAgent ? userAgent : window.navigator.userAgent;
|
|
14557
|
+
var deviceData = useDeviceData(hookUserAgent);
|
|
14558
|
+
var selectors = buildSelectorsObject(deviceData);
|
|
14559
|
+
return [selectors, deviceData];
|
|
14560
|
+
}
|
|
14561
|
+
|
|
14562
|
+
lib.AndroidView = AndroidView;
|
|
14563
|
+
lib.BrowserTypes = BrowserTypes;
|
|
14564
|
+
lib.BrowserView = BrowserView;
|
|
14565
|
+
lib.ConsoleView = ConsoleView;
|
|
14566
|
+
lib.CustomView = CustomView;
|
|
14567
|
+
lib.IEView = IEView;
|
|
14568
|
+
lib.IOSView = IOSView;
|
|
14569
|
+
lib.MobileOnlyView = MobileOnlyView;
|
|
14570
|
+
lib.MobileView = MobileView;
|
|
14571
|
+
lib.OsTypes = OsTypes;
|
|
14572
|
+
lib.SmartTVView = SmartTVView;
|
|
14573
|
+
lib.TabletView = TabletView;
|
|
14574
|
+
lib.WearableView = WearableView;
|
|
14575
|
+
lib.WinPhoneView = WinPhoneView;
|
|
14576
|
+
lib.browserName = browserName;
|
|
14577
|
+
lib.browserVersion = browserVersion;
|
|
14578
|
+
lib.deviceDetect = deviceDetect;
|
|
14579
|
+
lib.deviceType = deviceType;
|
|
14580
|
+
lib.engineName = engineName;
|
|
14581
|
+
lib.engineVersion = engineVersion;
|
|
14582
|
+
lib.fullBrowserVersion = fullBrowserVersion;
|
|
14583
|
+
lib.getSelectorsByUserAgent = getSelectorsByUserAgent;
|
|
14584
|
+
lib.getUA = getUA;
|
|
14585
|
+
lib.isAndroid = isAndroid;
|
|
14586
|
+
lib.isBrowser = isBrowser;
|
|
14587
|
+
lib.isChrome = isChrome;
|
|
14588
|
+
lib.isChromium = isChromium;
|
|
14589
|
+
lib.isConsole = isConsole;
|
|
14590
|
+
lib.isDesktop = isDesktop;
|
|
14591
|
+
lib.isEdge = isEdge;
|
|
14592
|
+
lib.isEdgeChromium = isEdgeChromium;
|
|
14593
|
+
lib.isElectron = isElectron;
|
|
14594
|
+
lib.isEmbedded = isEmbedded;
|
|
14595
|
+
lib.isFirefox = isFirefox;
|
|
14596
|
+
lib.isIE = isIE;
|
|
14597
|
+
lib.isIOS = isIOS;
|
|
14598
|
+
lib.isIOS13 = isIOS13;
|
|
14599
|
+
lib.isIPad13 = isIPad13;
|
|
14600
|
+
lib.isIPhone13 = isIPhone13;
|
|
14601
|
+
lib.isIPod13 = isIPod13;
|
|
14602
|
+
lib.isLegacyEdge = isLegacyEdge;
|
|
14603
|
+
lib.isMIUI = isMIUI;
|
|
14604
|
+
lib.isMacOs = isMacOs;
|
|
14605
|
+
lib.isMobile = isMobile;
|
|
14606
|
+
lib.isMobileOnly = isMobileOnly;
|
|
14607
|
+
lib.isMobileSafari = isMobileSafari;
|
|
14608
|
+
lib.isOpera = isOpera;
|
|
14609
|
+
lib.isSafari = isSafari;
|
|
14610
|
+
lib.isSamsungBrowser = isSamsungBrowser;
|
|
14611
|
+
lib.isSmartTV = isSmartTV;
|
|
14612
|
+
lib.isTablet = isTablet;
|
|
14613
|
+
lib.isWearable = isWearable;
|
|
14614
|
+
lib.isWinPhone = isWinPhone;
|
|
14615
|
+
lib.isWindows = isWindows;
|
|
14616
|
+
lib.isYandex = isYandex;
|
|
14617
|
+
lib.mobileModel = mobileModel;
|
|
14618
|
+
lib.mobileVendor = mobileVendor;
|
|
14619
|
+
lib.osName = osName;
|
|
14620
|
+
lib.osVersion = osVersion;
|
|
14621
|
+
lib.parseUserAgent = parseUserAgent;
|
|
14622
|
+
lib.setUserAgent = setUserAgent;
|
|
14623
|
+
lib.useDeviceData = useDeviceData;
|
|
14624
|
+
lib.useDeviceSelectors = useDeviceSelectors;
|
|
14625
|
+
lib.useMobileOrientation = useMobileOrientation;
|
|
14626
|
+
lib.withOrientationChange = withOrientationChange;
|
|
14627
|
+
return lib;
|
|
14628
|
+
}
|
|
14629
|
+
|
|
14630
|
+
var libExports = requireLib();
|
|
14631
|
+
|
|
14632
|
+
const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
|
14633
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
14634
|
+
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
14635
|
+
function jsonParseTransform(key, value) {
|
|
14636
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
14637
|
+
warnKeyDropped(key);
|
|
14638
|
+
return;
|
|
14639
|
+
}
|
|
14640
|
+
return value;
|
|
14641
|
+
}
|
|
14642
|
+
function warnKeyDropped(key) {
|
|
14643
|
+
console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
|
|
14644
|
+
}
|
|
14645
|
+
function destr(value, options = {}) {
|
|
14646
|
+
if (typeof value !== "string") {
|
|
14647
|
+
return value;
|
|
14648
|
+
}
|
|
14649
|
+
if (value[0] === '"' && value[value.length - 1] === '"' && value.indexOf("\\") === -1) {
|
|
14650
|
+
return value.slice(1, -1);
|
|
14651
|
+
}
|
|
14652
|
+
const _value = value.trim();
|
|
14653
|
+
if (_value.length <= 9) {
|
|
14654
|
+
switch (_value.toLowerCase()) {
|
|
14655
|
+
case "true": {
|
|
14656
|
+
return true;
|
|
14657
|
+
}
|
|
14658
|
+
case "false": {
|
|
14659
|
+
return false;
|
|
14660
|
+
}
|
|
14661
|
+
case "undefined": {
|
|
14662
|
+
return void 0;
|
|
14663
|
+
}
|
|
14664
|
+
case "null": {
|
|
14665
|
+
return null;
|
|
14666
|
+
}
|
|
14667
|
+
case "nan": {
|
|
14668
|
+
return Number.NaN;
|
|
14669
|
+
}
|
|
14670
|
+
case "infinity": {
|
|
14671
|
+
return Number.POSITIVE_INFINITY;
|
|
14672
|
+
}
|
|
14673
|
+
case "-infinity": {
|
|
14674
|
+
return Number.NEGATIVE_INFINITY;
|
|
14675
|
+
}
|
|
14676
|
+
}
|
|
14677
|
+
}
|
|
14678
|
+
if (!JsonSigRx.test(value)) {
|
|
14679
|
+
if (options.strict) {
|
|
14680
|
+
throw new SyntaxError("[destr] Invalid JSON");
|
|
13328
14681
|
}
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
catch (error) {
|
|
13338
|
-
console.error('Failed to disconnect from Phantom wallet', error);
|
|
13339
|
-
}
|
|
13340
|
-
// Always clear local state
|
|
13341
|
-
WebSessionManager.clearSession();
|
|
13342
|
-
setCurrentUser(null);
|
|
14682
|
+
return value;
|
|
14683
|
+
}
|
|
14684
|
+
try {
|
|
14685
|
+
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
|
14686
|
+
if (options.strict) {
|
|
14687
|
+
throw new Error("[destr] Possible prototype pollution");
|
|
14688
|
+
}
|
|
14689
|
+
return JSON.parse(value, jsonParseTransform);
|
|
13343
14690
|
}
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
14691
|
+
return JSON.parse(value);
|
|
14692
|
+
} catch (error) {
|
|
14693
|
+
if (options.strict) {
|
|
14694
|
+
throw error;
|
|
13347
14695
|
}
|
|
14696
|
+
return value;
|
|
14697
|
+
}
|
|
13348
14698
|
}
|
|
13349
|
-
|
|
14699
|
+
|
|
14700
|
+
var a$5;let i$6 = class i extends Error{toString(){return `${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,s){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=s;}};let _$5 = class _ extends i$6{constructor(e,t,s){super(e,t,s),this.type="client_error";}};let o$8 = class o extends i$6{constructor(e,t,s){super(e,t,s),this.type="connector_error";}};((a$5={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",a$5.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",a$5.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",a$5.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",a$5.INVALID_DATA="invalid_data",a$5.INVALID_CAPTCHA="invalid_captcha",a$5.LINKED_TO_ANOTHER_USER="linked_to_another_user",a$5.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",a$5.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",a$5.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",a$5.USER_EXITED_UPDATE_FLOW="exited_update_flow",a$5.ALLOWLIST_REJECTED="allowlist_rejected",a$5.OAUTH_USER_DENIED="oauth_user_denied",a$5.OAUTH_UNEXPECTED="oauth_unexpected",a$5.UNKNOWN_AUTH_ERROR="unknown_auth_error",a$5.USER_EXITED_AUTH_FLOW="exited_auth_flow",a$5.USER_EXITED_LINK_FLOW="exited_link_flow",a$5.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",a$5.MUST_BE_AUTHENTICATED="must_be_authenticated",a$5.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",a$5.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",a$5.CLIENT_REQUEST_TIMEOUT="client_request_timeout",a$5.INVALID_CREDENTIALS="invalid_credentials",a$5.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",a$5.UNKNOWN_MFA_ERROR="unknown_mfa_error",a$5.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",a$5.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",a$5.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",a$5.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",a$5.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",a$5.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",a$5.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",a$5.TRANSACTION_FAILURE="transaction_failure",a$5.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",a$5.NOT_SUPPORTED="not_supported",a$5.CAPTCHA_TIMEOUT="captcha_timeout",a$5.INVALID_MESSAGE="invalid_message",a$5.UNABLE_TO_SIGN="unable_to_sign",a$5.CAPTCHA_FAILURE="captcha_failure",a$5.CAPTCHA_DISABLED="captcha_disabled",a$5.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",a$5.TOO_MANY_REQUESTS="too_many_requests",a$5.USER_LIMIT_REACHED="max_accounts_reached",a$5.DISALLOWED_LOGIN_METHOD="disallowed_login_method",a$5.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",a$5.PASSKEY_NOT_ALLOWED="passkey_not_allowed",a$5.USER_DOES_NOT_EXIST="user_does_not_exist",a$5.INSUFFICIENT_BALANCE="insufficient_balance",a$5.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",a$5.BUFFER_NOT_DEFINED="buffer_not_defined",a$5.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",a$5.NO_SOLANA_ACCOUNTS="no_solana_accounts",a$5.UNKNOWN_FUNDING_ERROR="unknown_funding_error",a$5);let T$6 = class T extends o$8{constructor(){super("No Solana accounts found in wallet",void 0,"no_solana_accounts");}};const N$a=e=>()=>{throw Error(e.trim())};
|
|
13350
14701
|
|
|
13351
14702
|
/**
|
|
13352
14703
|
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
@@ -14074,7 +15425,7 @@ const t$b={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:
|
|
|
14074
15425
|
|
|
14075
15426
|
const r$4={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:true};
|
|
14076
15427
|
|
|
14077
|
-
const a$
|
|
15428
|
+
const a$4={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};
|
|
14078
15429
|
|
|
14079
15430
|
const t$a={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:true};
|
|
14080
15431
|
|
|
@@ -14090,9 +15441,9 @@ const e$c={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:
|
|
|
14090
15441
|
|
|
14091
15442
|
const e$b={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:true};
|
|
14092
15443
|
|
|
14093
|
-
const i$
|
|
15444
|
+
const i$5={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};
|
|
14094
15445
|
|
|
14095
|
-
const i$
|
|
15446
|
+
const i$4={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};
|
|
14096
15447
|
|
|
14097
15448
|
const t$7={id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}};
|
|
14098
15449
|
|
|
@@ -14110,9 +15461,9 @@ const t$5={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ethe
|
|
|
14110
15461
|
|
|
14111
15462
|
const t$4={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:true};
|
|
14112
15463
|
|
|
14113
|
-
const o$
|
|
15464
|
+
const o$7={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};
|
|
14114
15465
|
|
|
14115
|
-
const o$
|
|
15466
|
+
const o$6={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:true};
|
|
14116
15467
|
|
|
14117
15468
|
const e$6={id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}};
|
|
14118
15469
|
|
|
@@ -14124,7 +15475,7 @@ const e$4={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrenc
|
|
|
14124
15475
|
|
|
14125
15476
|
const e$3={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:true};
|
|
14126
15477
|
|
|
14127
|
-
const x$8=[t$6,e$5,e$a,t$b,r$4,t$5,t$4,o$
|
|
15478
|
+
const x$8=[t$6,e$5,e$a,t$b,r$4,t$5,t$4,o$7,o$6,e$c,e$b,i$5,i$4,e$e,e$d,t$9,t$8,e$7,e$9,e$8,a$4,t$a,r$3,e$3,e$4,e$6,t$7];new Set(x$8.map((i=>i.id)));
|
|
14128
15479
|
|
|
14129
15480
|
var t$3;((t$3={}).MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",t$3.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",t$3.INVALID_DATA="invalid_data",t$3.LINKED_TO_ANOTHER_USER="linked_to_another_user",t$3.ALLOWLIST_REJECTED="allowlist_rejected",t$3.OAUTH_USER_DENIED="oauth_user_denied",t$3.UNKNOWN_AUTH_ERROR="unknown_auth_error",t$3.USER_EXITED_AUTH_FLOW="exited_auth_flow",t$3.MUST_BE_AUTHENTICATED="must_be_authenticated",t$3.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",t$3.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",t$3.CLIENT_REQUEST_TIMEOUT="client_request_timeout",t$3.INVALID_CREDENTIALS="invalid_credentials",t$3);const n$3={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:true},E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:true,retryable:true},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:true,retryable:false},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:true,retryable:false},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:true,retryable:true},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:true,retryable:true},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:true,retryable:false},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:true,retryable:false},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:true,retryable:false},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:true,retryable:false},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:true,retryable:true},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:true,retryable:false},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:true,retryable:false},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:true,retryable:true},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:true,retryable:true},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:true,retryable:false},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:true,retryable:false},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:true,retryable:false},E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:false},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don’t see your wallet? Check your other browser windows.",retryable:false},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don’t see your wallet? Check your other browser windows.",retryable:false},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:true}};
|
|
14130
15481
|
|
|
@@ -14478,7 +15829,7 @@ function requireEventemitter3 () {
|
|
|
14478
15829
|
var eventemitter3Exports = requireEventemitter3();
|
|
14479
15830
|
var EventEmitter4 = /*@__PURE__*/getDefaultExportFromCjs$1(eventemitter3Exports);
|
|
14480
15831
|
|
|
14481
|
-
function n$2(n,t){if(!Object.prototype.hasOwnProperty.call(n,t))throw TypeError("attempted to use private field on non-instance");return n}var t$2=0;function s$3(n){return "__private_"+t$2+++"_"+n}var a$
|
|
15832
|
+
function n$2(n,t){if(!Object.prototype.hasOwnProperty.call(n,t))throw TypeError("attempted to use private field on non-instance");return n}var t$2=0;function s$3(n){return "__private_"+t$2+++"_"+n}var a$3=/*#__PURE__*/s$3("_wallet"),e$2=/*#__PURE__*/s$3("_account");let r$2 = class r{get standardWallet(){return n$2(this,a$3)[a$3]}get address(){return n$2(this,e$2)[e$2].address}async disconnect(){if(!n$2(this,a$3)[a$3].features["standard:disconnect"]?.disconnect)throw Error("Wallet does not support disconnect");await n$2(this,a$3)[a$3].features["standard:disconnect"].disconnect();}async signMessage(...t){if(!n$2(this,a$3)[a$3].features["solana:signMessage"]?.signMessage)throw Error("Wallet does not support signMessage");let s=await n$2(this,a$3)[a$3].features["solana:signMessage"].signMessage(...t.map((t=>({...t,account:n$2(this,e$2)[e$2]}))));return 1===t.length?s[0]:[...s]}async signTransaction(...t){if(!n$2(this,a$3)[a$3].features["solana:signTransaction"]?.signTransaction)throw Error("Wallet does not support signTransaction");let s=await n$2(this,a$3)[a$3].features["solana:signTransaction"].signTransaction(...t.map((t=>({...t,account:n$2(this,e$2)[e$2]}))));return 1===t.length?s[0]:[...s]}async signAndSendTransaction(...t){if(!n$2(this,a$3)[a$3].features["solana:signAndSendTransaction"]?.signAndSendTransaction)throw Error("Wallet does not support signAndSendTransaction");let s=await n$2(this,a$3)[a$3].features["solana:signAndSendTransaction"].signAndSendTransaction(...t.map((t=>({...t,account:n$2(this,e$2)[e$2]}))));return 1===t.length?s[0]:[...s]}async signAndSendAllTransactions(t){if(!n$2(this,a$3)[a$3].features["solana:signAndSendTransaction"]?.signAndSendTransaction)throw Error("Wallet does not support signAndSendTransaction");return [...await n$2(this,a$3)[a$3].features["solana:signAndSendTransaction"].signAndSendTransaction(...t.map((t=>({...t,account:n$2(this,e$2)[e$2]}))))]}constructor({wallet:t,account:s}){Object.defineProperty(this,a$3,{writable:true,value:void 0}),Object.defineProperty(this,e$2,{writable:true,value:void 0}),n$2(this,a$3)[a$3]=t,n$2(this,e$2)[e$2]=s;}};
|
|
14482
15833
|
|
|
14483
15834
|
// This file is autogenerated. It's used to publish ESM to npm.
|
|
14484
15835
|
function _typeof(obj) {
|
|
@@ -15642,94 +16993,26 @@ function validateWCAG2Parms(parms) {
|
|
|
15642
16993
|
// If input parms are invalid, return {"level":"AA", "size":"small"}
|
|
15643
16994
|
var level, size;
|
|
15644
16995
|
parms = parms || {
|
|
15645
|
-
level: "AA",
|
|
15646
|
-
size: "small"
|
|
15647
|
-
};
|
|
15648
|
-
level = (parms.level || "AA").toUpperCase();
|
|
15649
|
-
size = (parms.size || "small").toLowerCase();
|
|
15650
|
-
if (level !== "AA" && level !== "AAA") {
|
|
15651
|
-
level = "AA";
|
|
15652
|
-
}
|
|
15653
|
-
if (size !== "small" && size !== "large") {
|
|
15654
|
-
size = "small";
|
|
15655
|
-
}
|
|
15656
|
-
return {
|
|
15657
|
-
level: level,
|
|
15658
|
-
size: size
|
|
15659
|
-
};
|
|
15660
|
-
}
|
|
15661
|
-
|
|
15662
|
-
const S$6="privy:connections",T$6={appearance:{landingHeader:"Log in or sign up",theme:"light",walletList:["detected_ethereum_wallets","detected_solana_wallets","metamask","coinbase_wallet","rainbow","base_account","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",captchaEnabled:false,_render:{standalone:false},fundingMethodConfig:{moonpay:{useSandbox:false}}};let N$9=new Set(["coinbase_wallet","base_account","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","wallet_connect_qr","wallet_connect_qr_solana","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack","binance","binanceus","bitget_wallet"]),$$6=e=>N$9.has(e),z$8=(e,t,n)=>n.indexOf(e)===t;const Y$5=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter($$6).filter(z$8):e?e.filter($$6).filter(z$8):T$6.appearance.walletList;function J$7(e,t){let n=Math.max(0,Math.min(1,e.toHsl().l+t));return tinycolor({...e.toHsl(),l:n})}function G$7(e,t){let n=e.getLuminance(),a=t.getLuminance();return (Math.max(n,a)+.05)/(Math.min(n,a)+.05)}function K$6(e,t){if(!e){let e=t?X$5:Z$3;return {accent:tinycolor(e.background.interactive),accentLight:tinycolor(e.background.interactive),accentHover:tinycolor(e.background["interactive-hover"]),accentDark:tinycolor(e.background["interactive-clicked"]),accentDarkest:tinycolor(e.background["interactive-disabled"])}}let n=tinycolor(e);return {accent:n,accentLight:J$7(n,.15),accentHover:J$7(n,.3),accentDark:J$7(n,-0.06),accentDarkest:J$7(n,-0.6)}}function V$6({backgroundTheme:e,accentHex:t}){let n,a;n=false;let o=n?"dark":"light",l=n?X$5:Z$3,{accent:r,accentLight:i,accentHover:c,accentDark:d,accentDarkest:u}=K$6(t,n),g=function(e){let t=tinycolor(Z$3.text.default),n=tinycolor(X$5.text.default),a=G$7(e,t),o=G$7(e,n),l=e.toHsl();return l.h>=220&&l.h<=300&&o>=3?X$5.text.default:a>o?Z$3.text.default:X$5.text.default}(r),h=tinycolor(g),f=G$7(r,tinycolor(l.background.default))>=3;return {colorScheme:o,background:a||l.background.default,background2:l.background.elevated,background3:l.background.interactive,foreground:l.text.default,foreground2:l.text.muted,foreground3:l.text.placeholder,foreground4:l.border.default,accent:r.toHslString(),accentLight:i.toHslString(),accentHover:c.toHslString(),accentDark:d.toHslString(),accentDarkest:u.toHslString(),foregroundAccent:h.toHslString(),success:l.background.success,successDark:l.text.success,successLight:l.background.success,error:l.text.error,errorLight:l.background.error,warn:l.background.warning,warnLight:l.background.warning,warningDark:l.text.warning,errorDark:l.text.error,successBg:l.background.success,errorBg:l.background.error,errorBgHover:l.background["error-hover"],warnBg:l.background.warning,infoBg:l.background.info,infoBgHover:l.background["info-hover"],borderDefault:l.border.default,borderHover:l.border["default-hover"],borderFocus:l.border.focused,borderError:l.border.error,borderSuccess:l.border.success,borderWarning:l.border.warning,borderInfo:l.border.info,borderInteractive:l.border.interactive,borderInteractiveHover:l.border["interactive-hover"],backgroundHover:l.background["default-hover"],backgroundClicked:l.background["default-clicked"],backgroundDisabled:l.background["default-disabled"],backgroundInteractive:l.background.interactive,backgroundInteractiveHover:l.background["interactive-hover"],backgroundInteractiveClicked:l.background["interactive-clicked"],backgroundInteractiveDisabled:l.background["interactive-disabled"],foregroundHover:l.text.default,foregroundClicked:l.text.default,foregroundDisabled:l.text["default-disabled"],foregroundInteractive:l.text.interactive,foregroundInteractiveHover:l.text["interactive-hover"],accentHasGoodContrast:f?"1":"0",linkNavigationColor:f?r.toHslString():l.text.default,linkNavigationDecoration:f?"none":"underline",iconDefault:l.icon.default,iconMuted:l.icon.muted,iconSubtle:l.icon.subtle,iconInverse:l.icon.inverse,iconSuccess:l.icon.success,iconWarning:l.icon.warning,iconError:l.icon.error,iconInteractive:l.icon.interactive,iconDefaultHover:l.icon["default-hover"],iconMutedHover:l.icon["muted-hover"],iconSubtleHover:l.icon["subtle-hover"],iconDefaultClicked:l.icon["default-clicked"],iconMutedClicked:l.icon["muted-clicked"],iconSubtleClicked:l.icon["subtle-clicked"],iconDefaultDisabled:l.icon["default-disabled"],iconMutedDisabled:l.icon["muted-disabled"],iconSubtleDisabled:l.icon["subtle-disabled"],iconErrorHover:l.icon["error-hover"],iconInteractiveHover:l.icon["interactive-hover"],iconErrorClicked:l.icon["error-clicked"],iconInteractiveClicked:l.icon["interactive-clicked"],iconMutedDisabledAlt:l.icon["muted-disabled"],iconSubtleDisabledAlt:l.icon["subtle-disabled"]}}const X$5={background:{default:"#020713",elevated:"#1A2230","default-hover":"#101724","default-clicked":"#1A2230","default-disabled":"#020713",success:"#0E3E2D",warning:"#373827",error:"#2E0C18",interactive:"#8B86FF","error-hover":"#441821","interactive-hover":"#7B73E5","interactive-clicked":"#6560CC","interactive-disabled":"#141824",info:"#1F2937","info-hover":"#141824"},icon:{default:"#F8F8F8",muted:"#9BA2AE",subtle:"#7B8491",inverse:"#020713",success:"#88E3B5",warning:"#FDF27B",error:"#EF4444",interactive:"#88B6FF","default-hover":"#F8F8F8","muted-hover":"#AEB3BD","subtle-hover":"#8B939E","default-clicked":"#F8F8F8","muted-clicked":"#9097A5","subtle-clicked":"#78818E","default-disabled":"#404452","muted-disabled":"#404452","subtle-disabled":"#404452","error-hover":"#F05555","interactive-hover":"#7B73E5","error-clicked":"#EF4444","interactive-clicked":"#6560CC"},text:{default:"#F8F8F8",muted:"#9BA2AE",placeholder:"#7B8491",success:"#ACEECB",warning:"#FEF9A0",error:"#FCA5A5",interactive:"#A29EFF","default-disabled":"#404452","interactive-hover":"#8C88E5"},border:{default:"#1F2937",interactive:"#88B0FF",focused:"#F8F8FC",info:"#5B83D3",success:"#317056",warning:"#FBBF24",error:"#F87171","default-hover":"#34304A","interactive-hover":"#88B0FF"}},Z$3={background:{default:"#FFFFFF",elevated:"#F1F2F9","default-hover":"#F8F9FC","default-clicked":"#F1F2F9","default-disabled":"#FFFFFF",success:"#DCFCE7",warning:"#FEF3C7",error:"#FEE2E2",interactive:"#5B4FFF","error-hover":"#FECACA","interactive-hover":"#4F46E5","interactive-clicked":"#4338CA","interactive-disabled":"#F1F2F9",info:"#E0E7FF","info-hover":"#EEF2FF"},icon:{default:"#110F2A",muted:"#64668B",subtle:"#9498B8",inverse:"#FFFFFF",success:"#33B287",warning:"#F59E0B",error:"#EF4444",interactive:"#564FFF","default-hover":"#1D1B35","muted-hover":"#64668B","subtle-hover":"#888AAE","default-clicked":"#060C23","muted-clicked":"#64668B","subtle-clicked":"#788804","default-disabled":"#CBCDE1","muted-disabled":"#CBCDE1","subtle-disabled":"#CBCDE1","error-hover":"#F06060","interactive-hover":"#4F46E5","error-clicked":"#DC3838","interactive-clicked":"#2BA482"},text:{default:"#040217",muted:"#64668B",placeholder:"#9498B8",success:"#135638",warning:"#906218",error:"#991B1B",interactive:"#5B4FFF","default-disabled":"#CBCDE1","interactive-hover":"#5B4FFF"},border:{default:"#E2E3F0",interactive:"#5B4FFF",focused:"#949DF9",info:"#F1F2F9",success:"#87D7B7",warning:"#FACD63",error:"#F69393","default-hover":"#E2E3F0","interactive-hover":"#5B4FFF"}};function Q$4(e,t,n,a,o){let l,s,d,u,g,h,f,p,_,b,m,v,w,k,F,C,y;(l=e.email_auth,s=e.sms_auth,u=e.wallet_auth||e.solana_wallet_auth,g=e.google_oauth,h=e.twitter_oauth,f=e.discord_oauth,k=e.github_oauth,m=e.spotify_oauth,v=e.instagram_oauth,p=e.tiktok_oauth,_=e.line_oauth,b=e.twitch_oauth,w=e.linkedin_oauth,F=e.apple_oauth,C=e.farcaster_auth,y=e.telegram_auth,d=e.passkey_auth),e.passkey_auth&&(d=true),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(d=false);let E=[l,s].filter(Boolean),A=[g,h,f,k,m,v,p,_,w,F,C,y].filter(Boolean),x=[u].filter(Boolean),B=false,D=e.passkeys_for_signup_enabled??false,W=[d&&(D||B)].filter(Boolean);if(E.length+A.length+x.length+W.length===0)throw Error("You must enable at least one login method");let S=e.show_wallet_login_first;S&&0===x.length?(S=false):S||A.length+E.length!==0||(S=true);let H=t?.externalWallets?.walletConnect?.enabled??true;let L=Y$5({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder});if((L.includes("wallet_connect_qr")||L.includes("wallet_connect"))&&L.includes("wallet_connect_qr_solana"))throw Error("wallet_connect_qr and wallet_connect_qr_solana cannot both be present in walletList due to WalletConnect session conflicts.");let I=(({input:e})=>{return;})({input:t?.loginMethodsAndOrder}),O=t?.intl?.defaultCountry??"US",{chains:U,defaultChain:q}=function({supportedChains:e,defaultChainFromConfig:t}){let n;n=[...x$8];let a=e?n[0]:t$6,o=t??a;if(!n.find((e=>e.id===o.id)))throw Error("`defaultChain` must be included in `supportedChains`");return {chains:n,defaultChain:o}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),P=false,j=t?.customAuth?.getCustomAccessToken,R=j?"all-users":e.embedded_wallet_config.ethereum.create_on_login,N=e.embedded_wallet_config.solana.create_on_login;e.solana_wallet_auth&&true&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`");let $=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,z=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0;return {id:e.id,appClientId:o,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??T$6.appearance.landingHeader,loginMessage:"string"=="undefined"?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:V$6({backgroundTheme:T$6.appearance.theme,accentHex:e.accent_color}),loginGroupPriority:S?"web3-first":"web2-first",hideDirectWeb2Inputs:false,walletList:L,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??false,solanaWalletAuth:e.solana_wallet_auth??false})},loginMethods:{wallet:u,email:l,sms:s,passkey:d,google:g,twitter:h,discord:f,github:k,spotify:m,instagram:v,tiktok:p,line:_,twitch:b,linkedin:w,apple:F,farcaster:C,telegram:y},customOAuthProviders:(e.custom_oauth_providers??[]).filter((e=>false!==e.enabled)),disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:I,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??false},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??T$6.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:U,defaultChain:q,intl:{defaultCountry:O,textLocalization:t?.intl?.textLocalization},shouldEnforceDefaultChainOnConnect:P,captchaEnabled:e.captcha_enabled??T$6.captchaEnabled,captchaSiteKey:e.captcha_site_key,externalWallets:{coinbaseWallet:{config:{appName:e.name,appLogoUrl:e.logo_url,preference:{options:"all",...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},baseAccount:{config:{appName:e.name,appLogoUrl:e.logo_url,...t?.externalWallets?.baseAccount?.config,preference:{...t?.externalWallets?.baseAccount?.config?.preference,telemetry:false}}},walletConnect:{enabled:H},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??false},embeddedWallets:{requireUserOwnedRecoveryOnCreate:!j&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??false),userOwnedRecoveryOptions:j?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:t?.embeddedWallets?.ethereum?.createOnLogin??R},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??N},disableAutomaticMigration:t?.embeddedWallets?.disableAutomaticMigration??false,mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??true,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??false,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??false,domain:t?.embeddedWallets?.transactionScanning?.domain??a??"https://auth.privy.io"}},mfa:{methods:e.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??false},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink,registration:t?.passkeys?.registration},customAuth:j?{enabled:true,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:$,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:false,render:{standalone:t?._render?.standalone??T$6._render.standalone},fundingConfig:z,fundingMethodConfig:{...T$6.fundingMethodConfig,moonpay:{...T$6.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??T$6.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled,customOAuthRedirectUrl:t?.customOAuthRedirectUrl,allowOAuthInEmbeddedBrowsers:t?.allowOAuthInEmbeddedBrowsers??false,solanaRpcs:{"solana:mainnet":t?.solana?.rpcs?.["solana:mainnet"]??null,"solana:devnet":t?.solana?.rpcs?.["solana:devnet"]??null,"solana:testnet":t?.solana?.rpcs?.["solana:testnet"]??null}}}const ee$5={show_wallet_login_first:true,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:true,email_auth:true,sms_auth:false,google_oauth:false,twitter_oauth:false,discord_oauth:false,github_oauth:false,linkedin_oauth:false,apple_oauth:false,disable_plus_emails:false,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:false,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},captcha_enabled:false,captcha_site_key:"",enforce_wallet_uis:false,legacy_wallet_ui_config:false,id:"",name:"",passkeys_for_signup_enabled:false,whatsapp_enabled:false};/*#__PURE__*/React$2.createContext({appConfig:Q$4(ee$5,void 0),isServerConfigLoaded:false});
|
|
15663
|
-
|
|
15664
|
-
const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
|
15665
|
-
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
15666
|
-
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
15667
|
-
function jsonParseTransform(key, value) {
|
|
15668
|
-
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
15669
|
-
warnKeyDropped(key);
|
|
15670
|
-
return;
|
|
15671
|
-
}
|
|
15672
|
-
return value;
|
|
15673
|
-
}
|
|
15674
|
-
function warnKeyDropped(key) {
|
|
15675
|
-
console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
|
|
15676
|
-
}
|
|
15677
|
-
function destr(value, options = {}) {
|
|
15678
|
-
if (typeof value !== "string") {
|
|
15679
|
-
return value;
|
|
15680
|
-
}
|
|
15681
|
-
if (value[0] === '"' && value[value.length - 1] === '"' && value.indexOf("\\") === -1) {
|
|
15682
|
-
return value.slice(1, -1);
|
|
15683
|
-
}
|
|
15684
|
-
const _value = value.trim();
|
|
15685
|
-
if (_value.length <= 9) {
|
|
15686
|
-
switch (_value.toLowerCase()) {
|
|
15687
|
-
case "true": {
|
|
15688
|
-
return true;
|
|
15689
|
-
}
|
|
15690
|
-
case "false": {
|
|
15691
|
-
return false;
|
|
15692
|
-
}
|
|
15693
|
-
case "undefined": {
|
|
15694
|
-
return void 0;
|
|
15695
|
-
}
|
|
15696
|
-
case "null": {
|
|
15697
|
-
return null;
|
|
15698
|
-
}
|
|
15699
|
-
case "nan": {
|
|
15700
|
-
return Number.NaN;
|
|
15701
|
-
}
|
|
15702
|
-
case "infinity": {
|
|
15703
|
-
return Number.POSITIVE_INFINITY;
|
|
15704
|
-
}
|
|
15705
|
-
case "-infinity": {
|
|
15706
|
-
return Number.NEGATIVE_INFINITY;
|
|
15707
|
-
}
|
|
15708
|
-
}
|
|
15709
|
-
}
|
|
15710
|
-
if (!JsonSigRx.test(value)) {
|
|
15711
|
-
if (options.strict) {
|
|
15712
|
-
throw new SyntaxError("[destr] Invalid JSON");
|
|
15713
|
-
}
|
|
15714
|
-
return value;
|
|
15715
|
-
}
|
|
15716
|
-
try {
|
|
15717
|
-
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
|
15718
|
-
if (options.strict) {
|
|
15719
|
-
throw new Error("[destr] Possible prototype pollution");
|
|
15720
|
-
}
|
|
15721
|
-
return JSON.parse(value, jsonParseTransform);
|
|
15722
|
-
}
|
|
15723
|
-
return JSON.parse(value);
|
|
15724
|
-
} catch (error) {
|
|
15725
|
-
if (options.strict) {
|
|
15726
|
-
throw error;
|
|
15727
|
-
}
|
|
15728
|
-
return value;
|
|
16996
|
+
level: "AA",
|
|
16997
|
+
size: "small"
|
|
16998
|
+
};
|
|
16999
|
+
level = (parms.level || "AA").toUpperCase();
|
|
17000
|
+
size = (parms.size || "small").toLowerCase();
|
|
17001
|
+
if (level !== "AA" && level !== "AAA") {
|
|
17002
|
+
level = "AA";
|
|
17003
|
+
}
|
|
17004
|
+
if (size !== "small" && size !== "large") {
|
|
17005
|
+
size = "small";
|
|
15729
17006
|
}
|
|
17007
|
+
return {
|
|
17008
|
+
level: level,
|
|
17009
|
+
size: size
|
|
17010
|
+
};
|
|
15730
17011
|
}
|
|
15731
17012
|
|
|
15732
|
-
var a$3;let i$4 = class i extends Error{toString(){return `${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(e,t,s){super(e),t instanceof Error&&(this.cause=t),this.privyErrorCode=s;}};let o$6 = class o extends i$4{constructor(e,t,s){super(e,t,s),this.type="connector_error";}};((a$3={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",a$3.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",a$3.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",a$3.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",a$3.INVALID_DATA="invalid_data",a$3.INVALID_CAPTCHA="invalid_captcha",a$3.LINKED_TO_ANOTHER_USER="linked_to_another_user",a$3.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",a$3.FAILED_TO_LINK_ACCOUNT="failed_to_link_account",a$3.FAILED_TO_UPDATE_ACCOUNT="failed_to_update_account",a$3.USER_EXITED_UPDATE_FLOW="exited_update_flow",a$3.ALLOWLIST_REJECTED="allowlist_rejected",a$3.OAUTH_USER_DENIED="oauth_user_denied",a$3.OAUTH_UNEXPECTED="oauth_unexpected",a$3.UNKNOWN_AUTH_ERROR="unknown_auth_error",a$3.USER_EXITED_AUTH_FLOW="exited_auth_flow",a$3.USER_EXITED_LINK_FLOW="exited_link_flow",a$3.USER_EXITED_SET_PASSWORD_FLOW="user_exited_set_password_flow",a$3.MUST_BE_AUTHENTICATED="must_be_authenticated",a$3.UNKNOWN_CONNECT_WALLET_ERROR="unknown_connect_wallet_error",a$3.GENERIC_CONNECT_WALLET_ERROR="generic_connect_wallet_error",a$3.CLIENT_REQUEST_TIMEOUT="client_request_timeout",a$3.INVALID_CREDENTIALS="invalid_credentials",a$3.MISSING_MFA_CREDENTIALS="missing_or_invalid_mfa",a$3.UNKNOWN_MFA_ERROR="unknown_mfa_error",a$3.EMBEDDED_WALLET_ALREADY_EXISTS="embedded_wallet_already_exists",a$3.EMBEDDED_WALLET_NOT_FOUND="embedded_wallet_not_found",a$3.EMBEDDED_WALLET_CREATE_ERROR="embedded_wallet_create_error",a$3.UNKNOWN_EMBEDDED_WALLET_ERROR="unknown_embedded_wallet_error",a$3.EMBEDDED_WALLET_PASSWORD_UNCONFIRMED="embedded_wallet_password_unconfirmed",a$3.EMBEDDED_WALLET_PASSWORD_ALREADY_EXISTS="embedded_wallet_password_already_exists",a$3.EMBEDDED_WALLET_RECOVERY_ALREADY_EXISTS="embedded_wallet_recovery_already_exists",a$3.TRANSACTION_FAILURE="transaction_failure",a$3.UNSUPPORTED_CHAIN_ID="unsupported_chain_id",a$3.NOT_SUPPORTED="not_supported",a$3.CAPTCHA_TIMEOUT="captcha_timeout",a$3.INVALID_MESSAGE="invalid_message",a$3.UNABLE_TO_SIGN="unable_to_sign",a$3.CAPTCHA_FAILURE="captcha_failure",a$3.CAPTCHA_DISABLED="captcha_disabled",a$3.SESSION_STORAGE_UNAVAILABLE="session_storage_unavailable",a$3.TOO_MANY_REQUESTS="too_many_requests",a$3.USER_LIMIT_REACHED="max_accounts_reached",a$3.DISALLOWED_LOGIN_METHOD="disallowed_login_method",a$3.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",a$3.PASSKEY_NOT_ALLOWED="passkey_not_allowed",a$3.USER_DOES_NOT_EXIST="user_does_not_exist",a$3.INSUFFICIENT_BALANCE="insufficient_balance",a$3.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",a$3.BUFFER_NOT_DEFINED="buffer_not_defined",a$3.UNSUPPORTED_WALLET_TYPE="unsupported_wallet_type",a$3);const h$5=e=>()=>{throw Error(e.trim())};
|
|
17013
|
+
const S$6="privy:connections",T$5={appearance:{landingHeader:"Log in or sign up",theme:"light",walletList:["detected_ethereum_wallets","detected_solana_wallets","metamask","coinbase_wallet","rainbow","base_account","wallet_connect","phantom"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",_render:{standalone:false},fundingMethodConfig:{moonpay:{useSandbox:false}}};let N$9=new Set(["coinbase_wallet","base_account","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","wallet_connect_qr","wallet_connect_qr_solana","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack","jupiter","binance","binanceus","bitget_wallet","kraken_wallet"]),$$6=e=>N$9.has(e),z$8=(e,t,a)=>a.indexOf(e)===t;const Y$5=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter($$6).filter(z$8):e?e.filter($$6).filter(z$8):T$5.appearance.walletList;let G$7=/paymaster\.biconomy\.io\/api/i,J$7={mode:"SPONSORED",calculateGasLimits:true,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const V$6=(e,t)=>e&&G$7.test(e)?J$7:t&&t.policy_id?{policyId:t.policy_id}:void 0;function K$5(e,t){let a=Math.max(0,Math.min(1,e.toHsl().l+t));return tinycolor({...e.toHsl(),l:a})}function X$5(e,t){let a=e.getLuminance(),n=t.getLuminance();return (Math.max(a,n)+.05)/(Math.min(a,n)+.05)}function Z$3(e,t){if(!e){let e=t?ee$5:te$5;return {accent:tinycolor(e.background.interactive),accentLight:tinycolor(e.background.interactive),accentHover:tinycolor(e.background["interactive-hover"]),accentDark:tinycolor(e.background["interactive-clicked"]),accentDarkest:tinycolor(e.background["interactive-disabled"])}}let a=tinycolor(e);return {accent:a,accentLight:K$5(a,.15),accentHover:K$5(a,.3),accentDark:K$5(a,-0.06),accentDarkest:K$5(a,-0.6)}}function Q$4({backgroundTheme:e,accentHex:t}){let a,n;a=false;let o=a?"dark":"light",r=a?ee$5:te$5,{accent:l,accentLight:i,accentHover:s,accentDark:d,accentDarkest:u}=Z$3(t,a),g=function(e){let t=tinycolor(te$5.text.default),a=tinycolor(ee$5.text.default),n=X$5(e,t),o=X$5(e,a),r=e.toHsl();return r.h>=220&&r.h<=300&&o>=3?ee$5.text.default:n>o?te$5.text.default:ee$5.text.default}(l),h=tinycolor(g),f=X$5(l,tinycolor(r.background.default))>=3;return {colorScheme:o,background:n||r.background.default,background2:r.background.elevated,background3:r.background.interactive,foreground:r.text.default,foreground2:r.text.muted,foreground3:r.text.placeholder,foreground4:r.border.default,accent:l.toHslString(),accentLight:i.toHslString(),accentHover:s.toHslString(),accentDark:d.toHslString(),accentDarkest:u.toHslString(),foregroundAccent:h.toHslString(),success:r.background.success,successDark:r.text.success,successLight:r.background.success,error:r.text.error,errorLight:r.background.error,warn:r.background.warning,warnLight:r.background.warning,warningDark:r.text.warning,errorDark:r.text.error,successBg:r.background.success,errorBg:r.background.error,errorBgHover:r.background["error-hover"],warnBg:r.background.warning,infoBg:r.background.info,infoBgHover:r.background["info-hover"],borderDefault:r.border.default,borderHover:r.border["default-hover"],borderFocus:r.border.focused,borderError:r.border.error,borderSuccess:r.border.success,borderWarning:r.border.warning,borderInfo:r.border.info,borderInteractive:r.border.interactive,borderInteractiveHover:r.border["interactive-hover"],backgroundHover:r.background["default-hover"],backgroundClicked:r.background["default-clicked"],backgroundDisabled:r.background["default-disabled"],backgroundInteractive:r.background.interactive,backgroundInteractiveHover:r.background["interactive-hover"],backgroundInteractiveClicked:r.background["interactive-clicked"],backgroundInteractiveDisabled:r.background["interactive-disabled"],foregroundHover:r.text.default,foregroundClicked:r.text.default,foregroundDisabled:r.text["default-disabled"],foregroundInteractive:r.text.interactive,foregroundInteractiveHover:r.text["interactive-hover"],accentHasGoodContrast:f?"1":"0",linkNavigationColor:f?l.toHslString():r.text.default,linkNavigationDecoration:f?"none":"underline",iconDefault:r.icon.default,iconMuted:r.icon.muted,iconSubtle:r.icon.subtle,iconInverse:r.icon.inverse,iconSuccess:r.icon.success,iconWarning:r.icon.warning,iconError:r.icon.error,iconInteractive:r.icon.interactive,iconDefaultHover:r.icon["default-hover"],iconMutedHover:r.icon["muted-hover"],iconSubtleHover:r.icon["subtle-hover"],iconDefaultClicked:r.icon["default-clicked"],iconMutedClicked:r.icon["muted-clicked"],iconSubtleClicked:r.icon["subtle-clicked"],iconDefaultDisabled:r.icon["default-disabled"],iconMutedDisabled:r.icon["muted-disabled"],iconSubtleDisabled:r.icon["subtle-disabled"],iconErrorHover:r.icon["error-hover"],iconInteractiveHover:r.icon["interactive-hover"],iconErrorClicked:r.icon["error-clicked"],iconInteractiveClicked:r.icon["interactive-clicked"],iconMutedDisabledAlt:r.icon["muted-disabled"],iconSubtleDisabledAlt:r.icon["subtle-disabled"]}}const ee$5={background:{default:"#020713",elevated:"#1A2230","default-hover":"#101724","default-clicked":"#1A2230","default-disabled":"#020713",success:"#0E3E2D",warning:"#373827",error:"#2E0C18",interactive:"#8B86FF","error-hover":"#441821","interactive-hover":"#7B73E5","interactive-clicked":"#6560CC","interactive-disabled":"#141824",info:"#1F2937","info-hover":"#141824"},icon:{default:"#F8F8F8",muted:"#9BA2AE",subtle:"#7B8491",inverse:"#020713",success:"#88E3B5",warning:"#FDF27B",error:"#EF4444",interactive:"#88B6FF","default-hover":"#F8F8F8","muted-hover":"#AEB3BD","subtle-hover":"#8B939E","default-clicked":"#F8F8F8","muted-clicked":"#9097A5","subtle-clicked":"#78818E","default-disabled":"#404452","muted-disabled":"#404452","subtle-disabled":"#404452","error-hover":"#F05555","interactive-hover":"#7B73E5","error-clicked":"#EF4444","interactive-clicked":"#6560CC"},text:{default:"#F8F8F8",muted:"#9BA2AE",placeholder:"#7B8491",success:"#ACEECB",warning:"#FEF9A0",error:"#FCA5A5",interactive:"#A29EFF","default-disabled":"#404452","interactive-hover":"#8C88E5"},border:{default:"#1F2937",interactive:"#88B0FF",focused:"#F8F8FC",info:"#5B83D3",success:"#317056",warning:"#FBBF24",error:"#F87171","default-hover":"#34304A","interactive-hover":"#88B0FF"}},te$5={background:{default:"#FFFFFF",elevated:"#F1F2F9","default-hover":"#F8F9FC","default-clicked":"#F1F2F9","default-disabled":"#FFFFFF",success:"#DCFCE7",warning:"#FEF3C7",error:"#FEE2E2",interactive:"#5B4FFF","error-hover":"#FECACA","interactive-hover":"#4F46E5","interactive-clicked":"#4338CA","interactive-disabled":"#F1F2F9",info:"#E0E7FF","info-hover":"#EEF2FF"},icon:{default:"#110F2A",muted:"#64668B",subtle:"#9498B8",inverse:"#FFFFFF",success:"#33B287",warning:"#F59E0B",error:"#EF4444",interactive:"#564FFF","default-hover":"#1D1B35","muted-hover":"#64668B","subtle-hover":"#888AAE","default-clicked":"#060C23","muted-clicked":"#64668B","subtle-clicked":"#788804","default-disabled":"#CBCDE1","muted-disabled":"#CBCDE1","subtle-disabled":"#CBCDE1","error-hover":"#F06060","interactive-hover":"#4F46E5","error-clicked":"#DC3838","interactive-clicked":"#2BA482"},text:{default:"#040217",muted:"#64668B",placeholder:"#9498B8",success:"#135638",warning:"#906218",error:"#991B1B",interactive:"#5B4FFF","default-disabled":"#CBCDE1","interactive-hover":"#5B4FFF"},border:{default:"#E2E3F0",interactive:"#5B4FFF",focused:"#949DF9",info:"#F1F2F9",success:"#87D7B7",warning:"#FACD63",error:"#F69393","default-hover":"#E2E3F0","interactive-hover":"#5B4FFF"}};function ae$4(e,t,a,n,o){let r,c,d,u,g,h,f,p,_,b,m,v,w,k,y,F,C,A=[];r=e.email_auth,c=e.sms_auth,u=e.wallet_auth||e.solana_wallet_auth,g=e.google_oauth,h=e.twitter_oauth,f=e.discord_oauth,k=e.github_oauth,m=e.spotify_oauth,v=e.instagram_oauth,p=e.tiktok_oauth,_=e.line_oauth,b=e.twitch_oauth,w=e.linkedin_oauth,y=e.apple_oauth,F=e.farcaster_auth,C=e.telegram_auth,d=e.passkey_auth;e.passkey_auth&&(d=true),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(d=false);let E=[r,c].filter(Boolean),x=[g,h,f,k,m,v,p,_,w,y,F,C].filter(Boolean),B=[u].filter(Boolean),D=false,W=e.passkeys_for_signup_enabled??false,S=[d&&(W||D)].filter(Boolean);if(E.length+x.length+B.length+S.length+A.length===0)throw Error("You must enable at least one login method");let L=e.show_wallet_login_first;L&&0===B.length?(L=false):L||x.length+E.length!==0||(L=true);let H=t?.externalWallets?.walletConnect?.enabled??true;let I=Y$5({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder});if((I.includes("wallet_connect_qr")||I.includes("wallet_connect"))&&I.includes("wallet_connect_qr_solana"))throw Error("wallet_connect_qr and wallet_connect_qr_solana cannot both be present in walletList due to WalletConnect session conflicts.");let O=(({input:e})=>{return;})({input:t?.loginMethodsAndOrder}),U=t?.intl?.defaultCountry??"US",{chains:P,defaultChain:q}=function({supportedChains:e,defaultChainFromConfig:t}){let a;a=[...x$8];let n=e?a[0]:t$6,o=t??n;if(!a.find((e=>e.id===o.id)))throw Error("`defaultChain` must be included in `supportedChains`");return {chains:a,defaultChain:o}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),j=false,R=t?.customAuth?.getCustomAccessToken,N=R?"all-users":e.embedded_wallet_config.ethereum.create_on_login,$=e.embedded_wallet_config.solana.create_on_login;e.solana_wallet_auth&&true&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`");let z=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,G=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0,J=e.smart_wallet_config;return {id:e.id,appClientId:o,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??T$5.appearance.landingHeader,loginMessage:"string"=="undefined"?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:Q$4({backgroundTheme:T$5.appearance.theme,accentHex:e.accent_color}),loginGroupPriority:L?"web3-first":"web2-first",hideDirectWeb2Inputs:false,walletList:I,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??false,solanaWalletAuth:e.solana_wallet_auth??false})},loginMethods:{wallet:u,email:r,sms:c,passkey:d,google:g,twitter:h,discord:f,github:k,spotify:m,instagram:v,tiktok:p,line:_,twitch:b,linkedin:w,apple:y,farcaster:F,telegram:C},customOAuthProviders:(e.custom_oauth_providers??[]).filter((e=>false!==e.enabled)),crossAppProviders:A,disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:O,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??false},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??T$5.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:P,defaultChain:q,intl:{defaultCountry:U,textLocalization:t?.intl?.textLocalization},shouldEnforceDefaultChainOnConnect:j,captcha:{enabledProvider:e.enabled_captcha_provider??null,siteKey:e.captcha_site_key},externalWallets:{coinbaseWallet:{config:{appName:e.name,appLogoUrl:e.logo_url,preference:{options:"all",...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},baseAccount:{config:{appName:e.name,appLogoUrl:e.logo_url,...t?.externalWallets?.baseAccount?.config,preference:{...t?.externalWallets?.baseAccount?.config?.preference,telemetry:false}}},walletConnect:{enabled:H},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??false},embeddedWallets:{requireUserOwnedRecoveryOnCreate:!R&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??false),userOwnedRecoveryOptions:R?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:t?.embeddedWallets?.ethereum?.createOnLogin??N},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??$},disableAutomaticMigration:t?.embeddedWallets?.disableAutomaticMigration??false,mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??true,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??false,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??false,domain:t?.embeddedWallets?.transactionScanning?.domain??n??"https://auth.privy.io"}},mfa:{methods:e.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??false},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink,registration:t?.passkeys?.registration},customAuth:R?{enabled:true,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:z,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:false,render:{standalone:t?._render?.standalone??T$5._render.standalone},fundingConfig:G,fundingMethodConfig:{...T$5.fundingMethodConfig,moonpay:{...T$5.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??T$5.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled,customOAuthRedirectUrl:t?.customOAuthRedirectUrl,allowOAuthInEmbeddedBrowsers:t?.allowOAuthInEmbeddedBrowsers??false,solanaRpcs:{"solana:mainnet":t?.solana?.rpcs?.["solana:mainnet"]??null,"solana:devnet":t?.solana?.rpcs?.["solana:devnet"]??null,"solana:testnet":t?.solana?.rpcs?.["solana:testnet"]??null},smartWallets:J?.enabled?{enabled:J.enabled,smartWalletVersion:J.smart_wallet_version,smartWalletType:J.smart_wallet_type,configuredNetworks:J.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:V$6(e.paymaster_url,e.paymaster_context)})))}:{enabled:J?.enabled??false}}}const ne$4={show_wallet_login_first:true,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:true,email_auth:true,sms_auth:false,google_oauth:false,twitter_oauth:false,discord_oauth:false,github_oauth:false,linkedin_oauth:false,apple_oauth:false,disable_plus_emails:false,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:false,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},captcha_site_key:"",enforce_wallet_uis:false,legacy_wallet_ui_config:false,id:"",name:"",passkeys_for_signup_enabled:false,whatsapp_enabled:false};/*#__PURE__*/React$2.createContext({appConfig:ae$4(ne$4,void 0),isServerConfigLoaded:false});
|
|
17014
|
+
|
|
17015
|
+
function D$4(e){return {name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function U$5(t,a){let n=D$4(a);if(libExports.isMobile&&n.universalLink)return L$7(n.universalLink,t);if(n.deepLink)return b$4(n.deepLink,t);if(n.universalLink)return L$7(n.universalLink,t);throw new _$5(`Unsupported wallet ${a.id}`)}function M$6(e){return e.startsWith("http://")||e.startsWith("https://")}function b$4(e,r){if(M$6(e))return L$7(e,r);let t=e;return t.includes("://")||(t=e.replaceAll("/","").replaceAll(":",""),t=`${t}://`),t.endsWith("/")||(t=`${t}/`),{redirect:`${t}wc?uri=${encodeURIComponent(r)}`,href:t}}function L$7(e,r){if(!M$6(e))return b$4(e,r);let t=e;return t.endsWith("/")||(t=`${t}/`),{redirect:`${t}wc?uri=${encodeURIComponent(r)}`,href:t}}
|
|
15733
17016
|
|
|
15734
17017
|
// src/codes.ts
|
|
15735
17018
|
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
|
@@ -19097,9 +20380,9 @@ const genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => chain(radix(58), alphabet$
|
|
|
19097
20380
|
*/
|
|
19098
20381
|
const base58$1 = genBase58('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
|
|
19099
20382
|
|
|
19100
|
-
const
|
|
20383
|
+
const x$7=e=>e instanceof o$8?e:e?.code?new O$6(e):new o$8("Unknown connector error",e);let S$5 = class S extends i$6{constructor(e,t,n){super(e),this.type="provider_error",this.code=t,this.data=n;}};let O$6 = class O extends S$5{constructor(t){super(t.message,t.code,t.data);let n=Object.values(n$3).find((e=>e.eipCode===t.code));this.details=n||n$3.UNKNOWN_ERROR,-32002===t.code&&(t.message?.includes("already pending for origin")?t.message?.includes("wallet_requestPermissions")?this.details=n$3.E32002_CONNECTION_ALREADY_PENDING:this.details=n$3.E32002_REQUEST_ALREADY_PENDING:t.message?.includes("Already processing")&&t.message.includes("eth_requestAccounts")&&(this.details=n$3.E32002_WALLET_LOCKED));}};let R$4 = class R{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){ void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e);}del(e){localStorage.removeItem(e);}getKeys(){return Object.entries(localStorage).map((([e])=>e))}};var v$7="undefined"!=typeof window&&window.localStorage?new R$4:new class{get(e){return this._cache[e]}put(e,t){ void 0!==t?this._cache[e]=t:this.del(e);}del(e){delete this._cache[e];}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={};}};let N$8 = class N extends EventEmitter4{constructor(e){super(),this.walletClientType=e,this.connected=false,this.initialized=false;}};const I$4=()=>{let e=v$7.get(S$6);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let j$7=["phantom","glow","solflare","backpack","okx_wallet","walletconnect","mobile_wallet_adapter","jupiter"];function W$5(e){return e.toLowerCase().split(" ").join("_")}let F$2 = class F extends N$8{get isInstalled(){return true}get wallet(){return this._wallet}buildConnectedWallet(){return this._wallet.accounts.map((e=>({type:"solana",provider:new r$2({wallet:this._wallet,account:e}),address:e.address,connectedAt:Date.now(),walletClientType:this._wallet.name,connectorType:this.connectorType,imported:false,meta:{name:this._wallet.name,id:this._wallet.name,icon:this._wallet.icon},isConnected:async()=>this._wallet.accounts.length>0,disconnect:async()=>{await this.disconnect();}})))}async syncAccounts(){this.wallets=this.buildConnectedWallet(),this.emit("walletsUpdated");}get walletBranding(){return {id:L$6(this.wallet)?"walletconnect_solana":this.wallet.name,name:this.wallet.name,icon:this.wallet.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&(await(this.wallet.features["standard:connect"]?.connect({silent:true}).catch((()=>{}))),await this.isConnected()&&await this.syncAccounts()),this.initialized=true,this.emit("initialized");}async connect(e){if(e.showPrompt)try{await this.promptConnection();}catch(e){if(0===this._wallet.accounts.length)throw new T$6;throw e}if(!await this.isConnected())throw new T$6;return await this.syncAccounts(),this.getConnectedWallet()}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this._wallet.accounts.length>0}subscribeListeners(){this._unsubscribeListeners=this.wallet.features["standard:events"]?.on("change",this.onChange);}unsubscribeListeners(){this._unsubscribeListeners?.();}shouldAttemptAutoConnect(){return !(!this.autoConnectEnabled||!j$7.includes(this.walletClientType))&&("phantom"!==this.walletClientType&&"metamask"!==this.walletClientType.toLowerCase()||I$4().some((({walletClientType:e})=>"phantom"===e||"metamask"===e.toLowerCase())))}constructor(e,t){super(W$5(L$6(e)?"walletconnect_solana":e.name)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=async()=>{await(this.wallet.features["standard:disconnect"]?.disconnect().catch((e=>console.error("Error disconnecting",e)))),await this.syncAccounts();},this.promptConnection=async()=>{try{await(this.wallet.features["standard:connect"]?.connect());}catch(e){throw x$7(e)}},this.onChange=()=>{this.syncAccounts();},this._wallet=e,this.autoConnectEnabled=t,this.wallets=[];}};function L$6(e){return "isWalletConnectSolana"in e&&e.isWalletConnectSolana}const _$4="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdzVixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC";({[t$6.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[e$5.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[t$5.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[t$4.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[o$7.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[o$6.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[e$e.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[e$d.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[a$4.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[t$a.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[t$b.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[r$4.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"});
|
|
19101
20384
|
|
|
19102
|
-
const P$7=["solana:mainnet","solana:devnet","solana:testnet"];function F$1(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw TypeError("attempted to use private field on non-instance");return e}var U$4=0,D$3="__private_"+U$4+++"__implementation";function N$7(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw TypeError("attempted to use private field on non-instance");return e}var B$4=0;function R$
|
|
20385
|
+
const P$7=["solana:mainnet","solana:devnet","solana:testnet"];function F$1(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw TypeError("attempted to use private field on non-instance");return e}var U$4=0,D$3="__private_"+U$4+++"__implementation";function N$7(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw TypeError("attempted to use private field on non-instance");return e}var B$4=0;function R$3(e){return "__private_"+B$4+++"_"+e}var x$6=/*#__PURE__*/R$3("_address"),L$5=/*#__PURE__*/R$3("_publicKey"),V$5=/*#__PURE__*/R$3("_chains"),Q$3=/*#__PURE__*/R$3("_features"),G$6=/*#__PURE__*/R$3("_label"),K$4=/*#__PURE__*/R$3("_icon");let J$6 = class J{get address(){return N$7(this,x$6)[x$6]}get publicKey(){return N$7(this,L$5)[L$5].slice()}get chains(){return N$7(this,V$5)[V$5].slice()}get features(){return N$7(this,Q$3)[Q$3].slice()}get label(){return N$7(this,G$6)[G$6]}get icon(){return N$7(this,K$4)[K$4]}constructor({address:e,publicKey:n,label:t,icon:a}){Object.defineProperty(this,x$6,{writable:true,value:void 0}),Object.defineProperty(this,L$5,{writable:true,value:void 0}),Object.defineProperty(this,V$5,{writable:true,value:void 0}),Object.defineProperty(this,Q$3,{writable:true,value:void 0}),Object.defineProperty(this,G$6,{writable:true,value:void 0}),Object.defineProperty(this,K$4,{writable:true,value:void 0}),N$7(this,x$6)[x$6]=e,N$7(this,L$5)[L$5]=n,N$7(this,V$5)[V$5]=P$7,N$7(this,G$6)[G$6]=t,N$7(this,K$4)[K$4]=a,N$7(this,Q$3)[Q$3]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],new.target===J&&Object.freeze(this);}};function Y$4(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw TypeError("attempted to use private field on non-instance");return e}var k$5=0;function H$3(e){return "__private_"+k$5+++"_"+e}var Z$2=/*#__PURE__*/H$3("_listeners"),z$7=/*#__PURE__*/H$3("_version"),q$2=/*#__PURE__*/H$3("_name"),X$4=/*#__PURE__*/H$3("_icon"),$$5=/*#__PURE__*/H$3("_injection"),ee$4=/*#__PURE__*/H$3("_isPrivyWallet"),ne$3=/*#__PURE__*/H$3("_accounts"),te$4=/*#__PURE__*/H$3("_on"),ae$3=/*#__PURE__*/H$3("_emit"),se$3=/*#__PURE__*/H$3("_off"),ie$3=/*#__PURE__*/H$3("_connected"),re$3=/*#__PURE__*/H$3("_connect"),oe$4=/*#__PURE__*/H$3("_disconnect"),ce$3=/*#__PURE__*/H$3("_signMessage"),le$4=/*#__PURE__*/H$3("_signAndSendTransaction"),de$4=/*#__PURE__*/H$3("_signTransaction");function ue$2(e,...n){Y$4(this,Z$2)[Z$2][e]?.forEach((e=>e.apply(null,n)));}function ge$5(e,n){Y$4(this,Z$2)[Z$2][e]=Y$4(this,Z$2)[Z$2][e]?.filter((e=>n!==e));}let we$5=new class extends EventEmitter4{setImplementation(e){F$1(this,D$3)[D$3]=e;}async signMessage(e){return F$1(this,D$3)[D$3].signMessage(e)}async signAndSendTransaction(e){return F$1(this,D$3)[D$3].signAndSendTransaction(e)}async signTransaction(e){return F$1(this,D$3)[D$3].signTransaction(e)}constructor(e){super(),Object.defineProperty(this,D$3,{writable:true,value:void 0}),F$1(this,D$3)[D$3]=e;}}({signTransaction:N$a("signTransaction was not injected"),signAndSendTransaction:N$a("signAndSendTransaction was not injected"),signMessage:N$a("signMessage was not injected")});new class{get version(){return Y$4(this,z$7)[z$7]}get name(){return Y$4(this,q$2)[q$2]}get icon(){return Y$4(this,X$4)[X$4]}get chains(){return P$7.slice()}get features(){return {"standard:connect":{version:"1.0.0",connect:Y$4(this,re$3)[re$3]},"standard:disconnect":{version:"1.0.0",disconnect:Y$4(this,oe$4)[oe$4]},"standard:events":{version:"1.0.0",on:Y$4(this,te$4)[te$4]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:Y$4(this,le$4)[le$4]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:Y$4(this,de$4)[de$4]},"solana:signMessage":{version:"1.0.0",signMessage:Y$4(this,ce$3)[ce$3]},"privy:":{privy:{signMessage:Y$4(this,$$5)[$$5].signMessage,signTransaction:Y$4(this,$$5)[$$5].signTransaction,signAndSendTransaction:Y$4(this,$$5)[$$5].signAndSendTransaction}}}}get accounts(){return Y$4(this,ne$3)[ne$3].slice()}get isPrivyWallet(){return Y$4(this,ee$4)[ee$4]}constructor({name:e,icon:n,version:t,injection:a,wallets:s}){Object.defineProperty(this,ae$3,{value:ue$2}),Object.defineProperty(this,se$3,{value:ge$5}),Object.defineProperty(this,Z$2,{writable:true,value:void 0}),Object.defineProperty(this,z$7,{writable:true,value:void 0}),Object.defineProperty(this,q$2,{writable:true,value:void 0}),Object.defineProperty(this,X$4,{writable:true,value:void 0}),Object.defineProperty(this,$$5,{writable:true,value:void 0}),Object.defineProperty(this,ee$4,{writable:true,value:void 0}),Object.defineProperty(this,ne$3,{writable:true,value:void 0}),Object.defineProperty(this,te$4,{writable:true,value:void 0}),Object.defineProperty(this,ie$3,{writable:true,value:void 0}),Object.defineProperty(this,re$3,{writable:true,value:void 0}),Object.defineProperty(this,oe$4,{writable:true,value:void 0}),Object.defineProperty(this,ce$3,{writable:true,value:void 0}),Object.defineProperty(this,le$4,{writable:true,value:void 0}),Object.defineProperty(this,de$4,{writable:true,value:void 0}),Y$4(this,Z$2)[Z$2]={},Y$4(this,te$4)[te$4]=(e,n)=>(Y$4(this,Z$2)[Z$2][e]?.push(n)||(Y$4(this,Z$2)[Z$2][e]=[n]),()=>Y$4(this,se$3)[se$3](e,n)),Y$4(this,ie$3)[ie$3]=e=>{null!=e&&(Y$4(this,ne$3)[ne$3]=e.map((({address:e})=>new J$6({address:e,publicKey:base58$1.decode(e)})))),Y$4(this,ae$3)[ae$3]("change",{accounts:this.accounts});},Y$4(this,re$3)[re$3]=async()=>(Y$4(this,ae$3)[ae$3]("change",{accounts:this.accounts}),{accounts:this.accounts}),Y$4(this,oe$4)[oe$4]=async()=>{Y$4(this,ae$3)[ae$3]("change",{accounts:this.accounts});},Y$4(this,ce$3)[ce$3]=async(...e)=>{let n=[];for(let{account:t,...a}of e){let{signature:e}=await Y$4(this,$$5)[$$5].signMessage({...a,address:t.address});n.push({signedMessage:a.message,signature:e});}return n},Y$4(this,le$4)[le$4]=async(...e)=>{let n=[];for(let t of e){let{signature:e}=await Y$4(this,$$5)[$$5].signAndSendTransaction({...t,transaction:t.transaction,address:t.account.address,chain:t.chain||"solana:mainnet",options:t.options});n.push({signature:e});}return n},Y$4(this,de$4)[de$4]=async(...e)=>{let n=[];for(let{transaction:t,account:a,options:s,chain:i}of e){let{signedTransaction:e}=await Y$4(this,$$5)[$$5].signTransaction({transaction:t,address:a.address,chain:i||"solana:mainnet",options:s});n.push({signedTransaction:e});}return n},Y$4(this,q$2)[q$2]=e,Y$4(this,X$4)[X$4]=n,Y$4(this,z$7)[z$7]=t,Y$4(this,$$5)[$$5]=a,Y$4(this,ne$3)[ne$3]=[],Y$4(this,ee$4)[ee$4]=true,a.on("accountChanged",Y$4(this,ie$3)[ie$3],this),Y$4(this,ie$3)[ie$3](s);}}({name:"Privy",version:"1.0.0",icon:"data:image/png;base64,AAABAAEAFBQAAAAAIABlAQAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAUAAAAFAgGAAAAjYkdDQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAQVJREFUeJxiYMANZIC4E4ivAPFPIP4FxDeAuB+IlfDowwBMQFwJxF+B+D8O/AOI66Bq8QJGIF6ExyB0vAqImfEZmEeCYTDcgMswPiB+T4aB34FYApuBsWQYBsP52AycToGBK7EZuJECAw9jM3AVBQbuwWZgIwUGTsZmoDkFBnpiMxAEjpJh2FV8iVsbiD+TYBgoDVrgMgwGnID4HRGGgTKBGyHDYEAaiBdCSxh0g/5AU4Q8sYYhAzEgjoGmABBOgFo2eACowFABYn0oVgViAVINkQTiZUD8DIj/ATF6GILEXgLxCiCWIsZAbiAuBeKtQHwHiEHJ6C8UfwHie0C8E4jLoWpRAAAAAP//rcbhsQAAAAZJREFUAwBYFs3VKJ0cuQAAAABJRU5ErkJggg==",wallets:[],injection:we$5});
|
|
19103
20386
|
|
|
19104
20387
|
var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
19105
20388
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
@@ -19719,7 +21002,7 @@ function requireEvents () {
|
|
|
19719
21002
|
}
|
|
19720
21003
|
|
|
19721
21004
|
var eventsExports = requireEvents();
|
|
19722
|
-
var xe$
|
|
21005
|
+
var xe$3 = /*@__PURE__*/getDefaultExportFromCjs$1(eventsExports);
|
|
19723
21006
|
|
|
19724
21007
|
var cjs$3 = {};
|
|
19725
21008
|
|
|
@@ -21048,7 +22331,7 @@ function safeJsonStringify(value) {
|
|
|
21048
22331
|
return typeof value === "string" ? value : JSONStringify(value) || "";
|
|
21049
22332
|
}
|
|
21050
22333
|
|
|
21051
|
-
const x$5="idb-keyval";var z$6=(i={})=>{const t=i.base&&i.base.length>0?`${i.base}:`:"",e=s=>t+s;let n;return i.dbName&&i.storeName&&(n=createStore(i.dbName,i.storeName)),{name:x$5,options:i,async hasItem(s){return !(typeof await get(e(s),n)>"u")},async getItem(s){return await get(e(s),n)??null},setItem(s,a){return set(e(s),a,n)},removeItem(s){return del(e(s),n)},getKeys(){return keys(n)},clear(){return clear(n)}}};const D$2="WALLET_CONNECT_V2_INDEXED_DB",E$4="keyvaluestorage";let _$3 = class _{constructor(){this.indexedDb=createStorage({driver:z$6({dbName:D$2,storeName:E$4})});}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const e=await this.indexedDb.getItem(t);if(e!==null)return e}async setItem(t,e){await this.indexedDb.setItem(t,safeJsonStringify(e));}async removeItem(t){await this.indexedDb.removeItem(t);}};var l$2=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c$5={exports:{}};(function(){let i;function t(){}i=t,i.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},i.prototype.setItem=function(e,n){this[e]=String(n);},i.prototype.removeItem=function(e){delete this[e];},i.prototype.clear=function(){const e=this;Object.keys(e).forEach(function(n){e[n]=void 0,delete e[n];});},i.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},i.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof l$2<"u"&&l$2.localStorage?c$5.exports=l$2.localStorage:typeof window<"u"&&window.localStorage?c$5.exports=window.localStorage:c$5.exports=new t;})();function k$4(i){var t;return [i[0],safeJsonParse((t=i[1])!=null?t:"")]}let K$
|
|
22334
|
+
const x$5="idb-keyval";var z$6=(i={})=>{const t=i.base&&i.base.length>0?`${i.base}:`:"",e=s=>t+s;let n;return i.dbName&&i.storeName&&(n=createStore(i.dbName,i.storeName)),{name:x$5,options:i,async hasItem(s){return !(typeof await get(e(s),n)>"u")},async getItem(s){return await get(e(s),n)??null},setItem(s,a){return set(e(s),a,n)},removeItem(s){return del(e(s),n)},getKeys(){return keys(n)},clear(){return clear(n)}}};const D$2="WALLET_CONNECT_V2_INDEXED_DB",E$4="keyvaluestorage";let _$3 = class _{constructor(){this.indexedDb=createStorage({driver:z$6({dbName:D$2,storeName:E$4})});}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return (await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const e=await this.indexedDb.getItem(t);if(e!==null)return e}async setItem(t,e){await this.indexedDb.setItem(t,safeJsonStringify(e));}async removeItem(t){await this.indexedDb.removeItem(t);}};var l$2=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c$5={exports:{}};(function(){let i;function t(){}i=t,i.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},i.prototype.setItem=function(e,n){this[e]=String(n);},i.prototype.removeItem=function(e){delete this[e];},i.prototype.clear=function(){const e=this;Object.keys(e).forEach(function(n){e[n]=void 0,delete e[n];});},i.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},i.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof l$2<"u"&&l$2.localStorage?c$5.exports=l$2.localStorage:typeof window<"u"&&window.localStorage?c$5.exports=window.localStorage:c$5.exports=new t;})();function k$4(i){var t;return [i[0],safeJsonParse((t=i[1])!=null?t:"")]}let K$3 = class K{constructor(){this.localStorage=c$5.exports;}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(k$4)}async getItem(t){const e=this.localStorage.getItem(t);if(e!==null)return safeJsonParse(e)}async setItem(t,e){this.localStorage.setItem(t,safeJsonStringify(e));}async removeItem(t){this.localStorage.removeItem(t);}};const N$6="wc_storage_version",y$3=1,O$5=async(i,t,e)=>{const n=N$6,s=await t.getItem(n);if(s&&s>=y$3){e(t);return}const a=await i.getKeys();if(!a.length){e(t);return}const m=[];for(;a.length;){const r=a.shift();if(!r)continue;const o=r.toLowerCase();if(o.includes("wc@")||o.includes("walletconnect")||o.includes("wc_")||o.includes("wallet_connect")){const f=await i.getItem(r);await t.setItem(r,f),m.push(r);}}await t.setItem(n,y$3),e(t),j$6(i,m);},j$6=async(i,t)=>{t.length&&t.forEach(async e=>{await i.removeItem(e);});};let h$4 = class h{constructor(){this.initialized=false,this.setInitialized=e=>{this.storage=e,this.initialized=true;};const t=new K$3;this.storage=t;try{const e=new _$3;O$5(t,e,this.setInitialized);}catch{this.initialized=true;}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,e){return await this.initialize(),this.storage.setItem(t,e)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const e=setInterval(()=>{this.initialized&&(clearInterval(e),t());},20);});}};
|
|
21052
22335
|
|
|
21053
22336
|
var browser$1 = {exports: {}};
|
|
21054
22337
|
|
|
@@ -21685,9 +22968,9 @@ var c$4 = /*@__PURE__*/getDefaultExportFromCjs$1(browserExports$1);
|
|
|
21685
22968
|
|
|
21686
22969
|
const b$3={level:"info"},l$1="custom_context",i$2=1e3*1024;var C$4=Object.defineProperty,B$3=(r,e,t)=>e in r?C$4(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,s$1=(r,e,t)=>B$3(r,typeof e!="symbol"?e+"":e,t);let S$4 = class S{constructor(e){s$1(this,"nodeValue"),s$1(this,"sizeInBytes"),s$1(this,"next"),this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null;}get value(){return this.nodeValue}get size(){return this.sizeInBytes}};let v$6 = class v{constructor(e){s$1(this,"lengthInNodes"),s$1(this,"sizeInBytes"),s$1(this,"head"),s$1(this,"tail"),s$1(this,"maxSizeInBytes"),this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0;}append(e){const t=new S$4(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size;}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size;}toArray(){const e=[];let t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return {next:()=>{if(!e)return {done:true,value:null};const t=e.value;return e=e.next,{done:false,value:t}}}}};var _$2=Object.defineProperty,x$4=(r,e,t)=>e in r?_$2(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,a$2=(r,e,t)=>x$4(r,typeof e!="symbol"?e+"":e,t);let L$4 = class L{constructor(e,t=i$2){a$2(this,"logs"),a$2(this,"level"),a$2(this,"levelValue"),a$2(this,"MAX_LOG_SIZE_IN_BYTES"),this.level=e??"error",this.levelValue=browserExports$1.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new v$6(this.MAX_LOG_SIZE_IN_BYTES);}forwardToConsole(e,t){t===browserExports$1.levels.values.error?console.error(e):t===browserExports$1.levels.values.warn?console.warn(e):t===browserExports$1.levels.values.debug?console.debug(e):t===browserExports$1.levels.values.trace?console.trace(e):console.log(e);}appendToLogs(e){this.logs.append(safeJsonStringify({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t);}getLogs(){return this.logs}clearLogs(){this.logs=new v$6(this.MAX_LOG_SIZE_IN_BYTES);}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(safeJsonStringify({extraMetadata:e})),new Blob(t,{type:"application/json"})}};var z$5=Object.defineProperty,T$4=(r,e,t)=>e in r?z$5(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,k$3=(r,e,t)=>T$4(r,e+"",t);let E$3 = class E{constructor(e,t=i$2){k$3(this,"baseChunkLogger"),this.baseChunkLogger=new L$4(e,t);}write(e){this.baseChunkLogger.appendToLogs(e);}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs();}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),o=document.createElement("a");o.href=t,o.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(t);}};var A$3=Object.defineProperty,$$4=(r,e,t)=>e in r?A$3(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,N$5=(r,e,t)=>$$4(r,e+"",t);let j$5 = class j{constructor(e,t=i$2){N$5(this,"baseChunkLogger"),this.baseChunkLogger=new L$4(e,t);}write(e){this.baseChunkLogger.appendToLogs(e);}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs();}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var P$6=Object.defineProperty,V$4=Object.defineProperties,G$5=Object.getOwnPropertyDescriptors,p$4=Object.getOwnPropertySymbols,M$5=Object.prototype.hasOwnProperty,U$3=Object.prototype.propertyIsEnumerable,f$6=(r,e,t)=>e in r?P$6(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,g$3=(r,e)=>{for(var t in e||(e={}))M$5.call(e,t)&&f$6(r,t,e[t]);if(p$4)for(var t of p$4(e))U$3.call(e,t)&&f$6(r,t,e[t]);return r},h$3=(r,e)=>V$4(r,G$5(e));function D$1(r){return h$3(g$3({},r),{level:r?.level||b$3.level})}function y$2(r,e,t=l$1){return r[t]=e,r}function w$3(r,e=l$1){return r[e]||""}function m$2(r,e,t=l$1){const o=w$3(r,t);return o.trim()?`${o}/${e}`:e}function X$3(r,e,t=l$1){const o=m$2(r,e,t),u=r.child({context:o});return y$2(u,o,t)}function I$3(r){var e,t;const o=new E$3((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return {logger:c$4(h$3(g$3({},r.opts),{level:"trace",browser:h$3(g$3({},(t=r.opts)==null?void 0:t.browser),{write:u=>o.write(u)})})),chunkLoggerController:o}}function O$4(r){var e;const t=new j$5((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return {logger:c$4(h$3(g$3({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Y$3(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?I$3(r):O$4(r)}
|
|
21687
22970
|
|
|
21688
|
-
var a$1=Object.defineProperty,u=(e,s,r)=>s in e?a$1(e,s,{enumerable:true,configurable:true,writable:true,value:r}):e[s]=r,c$3=(e,s,r)=>u(e,typeof s!="symbol"?s+"":s,r);let h$2 = class h extends IEvents{constructor(s){super(),this.opts=s,c$3(this,"protocol","wc"),c$3(this,"version",2);}};var p$3=Object.defineProperty,b$2=(e,s,r)=>s in e?p$3(e,s,{enumerable:true,configurable:true,writable:true,value:r}):e[s]=r,v$5=(e,s,r)=>b$2(e,s+"",r);let I$2 = class I extends IEvents{constructor(s,r){super(),this.core=s,this.logger=r,v$5(this,"records",new Map);}};let y$1 = class y{constructor(s,r){this.logger=s,this.core=r;}};let m$1 = class m extends IEvents{constructor(s,r){super(),this.relayer=s,this.logger=r;}};let d$4 = class d extends IEvents{constructor(s){super();}};let f$5 = class f{constructor(s,r,t,q){this.core=s,this.logger=r,this.name=t;}};let P$5 = class P extends IEvents{constructor(s,r){super(),this.relayer=s,this.logger=r;}};let S$3 = class S extends IEvents{constructor(s,r){super(),this.core=s,this.logger=r;}};let M$4 = class M{constructor(s,r,t){this.core=s,this.logger=r,this.store=t;}};let O$3 = class O{constructor(s,r){this.projectId=s,this.logger=r;}};let R$
|
|
22971
|
+
var a$1=Object.defineProperty,u=(e,s,r)=>s in e?a$1(e,s,{enumerable:true,configurable:true,writable:true,value:r}):e[s]=r,c$3=(e,s,r)=>u(e,typeof s!="symbol"?s+"":s,r);let h$2 = class h extends IEvents{constructor(s){super(),this.opts=s,c$3(this,"protocol","wc"),c$3(this,"version",2);}};var p$3=Object.defineProperty,b$2=(e,s,r)=>s in e?p$3(e,s,{enumerable:true,configurable:true,writable:true,value:r}):e[s]=r,v$5=(e,s,r)=>b$2(e,s+"",r);let I$2 = class I extends IEvents{constructor(s,r){super(),this.core=s,this.logger=r,v$5(this,"records",new Map);}};let y$1 = class y{constructor(s,r){this.logger=s,this.core=r;}};let m$1 = class m extends IEvents{constructor(s,r){super(),this.relayer=s,this.logger=r;}};let d$4 = class d extends IEvents{constructor(s){super();}};let f$5 = class f{constructor(s,r,t,q){this.core=s,this.logger=r,this.name=t;}};let P$5 = class P extends IEvents{constructor(s,r){super(),this.relayer=s,this.logger=r;}};let S$3 = class S extends IEvents{constructor(s,r){super(),this.core=s,this.logger=r;}};let M$4 = class M{constructor(s,r,t){this.core=s,this.logger=r,this.store=t;}};let O$3 = class O{constructor(s,r){this.projectId=s,this.logger=r;}};let R$2 = class R{constructor(s,r,t){this.core=s,this.logger=r,this.telemetryEnabled=t;}};var T$3=Object.defineProperty,k$2=(e,s,r)=>s in e?T$3(e,s,{enumerable:true,configurable:true,writable:true,value:r}):e[s]=r,i$1=(e,s,r)=>k$2(e,typeof s!="symbol"?s+"":s,r);let J$5 = class J{constructor(s){this.opts=s,i$1(this,"protocol","wc"),i$1(this,"version",2);}};let V$3 = class V{constructor(s){this.client=s;}};
|
|
21689
22972
|
|
|
21690
|
-
function En$2(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function fe$4(t,...e){if(!En$2(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function De$3(t,e=true){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function gn$2(t,e){fe$4(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const it$1=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _t$3=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function yn$2(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function de$3(t){return typeof t=="string"&&(t=yn$2(t)),fe$4(t),t}let xn$2 = class xn{clone(){return this._cloneInto()}};function Bn$2(t){const e=r=>t().update(de$3(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function he$4(t=32){if(it$1&&typeof it$1.getRandomValues=="function")return it$1.getRandomValues(new Uint8Array(t));if(it$1&&typeof it$1.randomBytes=="function")return it$1.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Cn$2(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),u=Number(n&s),i=r?4:0,D=r?0:4;t.setUint32(e+i,a,r),t.setUint32(e+D,u,r);}let An$2 = class An extends xn$2{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=false,this.length=0,this.pos=0,this.destroyed=false,this.buffer=new Uint8Array(e),this.view=_t$3(this.buffer);}update(e){De$3(this);const{view:n,buffer:r,blockLen:o}=this;e=de$3(e);const s=e.length;for(let a=0;a<s;){const u=Math.min(o-this.pos,s-a);if(u===o){const i=_t$3(e);for(;o<=s-a;a+=o)this.process(i,a);continue}r.set(e.subarray(a,a+u),this.pos),this.pos+=u,a+=u,this.pos===o&&(this.process(n,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){De$3(this),gn$2(e,this),this.finished=true;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let l=a;l<o;l++)n[l]=0;Cn$2(r,o-8,BigInt(this.length*8),s),this.process(r,0);const u=_t$3(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const D=i/4,c=this.get();if(D>c.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<D;l++)u.setUint32(4*l,c[l],s);}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:a,pos:u}=this;return e.length=o,e.pos=u,e.finished=s,e.destroyed=a,o%n&&e.buffer.set(r),e}};const wt$3=BigInt(2**32-1),St$4=BigInt(32);function le$3(t,e=false){return e?{h:Number(t&wt$3),l:Number(t>>St$4&wt$3)}:{h:Number(t>>St$4&wt$3)|0,l:Number(t&wt$3)|0}}function mn$2(t,e=false){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:s,l:a}=le$3(t[o],e);[n[o],r[o]]=[s,a];}return [n,r]}const _n$2=(t,e)=>BigInt(t>>>0)<<St$4|BigInt(e>>>0),Sn$2=(t,e,n)=>t>>>n,vn$2=(t,e,n)=>t<<32-n|e>>>n,In$2=(t,e,n)=>t>>>n|e<<32-n,Un$2=(t,e,n)=>t<<32-n|e>>>n,Tn$2=(t,e,n)=>t<<64-n|e>>>n-32,Fn$2=(t,e,n)=>t>>>n-32|e<<64-n,Nn$2=(t,e)=>e,Ln$2=(t,e)=>t,On$2=(t,e,n)=>t<<n|e>>>32-n,Hn$2=(t,e,n)=>e<<n|t>>>32-n,zn$2=(t,e,n)=>e<<n-32|t>>>64-n,Mn$2=(t,e,n)=>t<<n-32|e>>>64-n;function qn$2(t,e,n,r){const o=(e>>>0)+(r>>>0);return {h:t+n+(o/2**32|0)|0,l:o|0}}const $n$2=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),kn$2=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Rn$2=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),jn$2=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,Zn$2=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),Gn$2=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,x$3={fromBig:le$3,split:mn$2,toBig:_n$2,shrSH:Sn$2,shrSL:vn$2,rotrSH:In$2,rotrSL:Un$2,rotrBH:Tn$2,rotrBL:Fn$2,rotr32H:Nn$2,rotr32L:Ln$2,rotlSH:On$2,rotlSL:Hn$2,rotlBH:zn$2,rotlBL:Mn$2,add:qn$2,add3L:$n$2,add3H:kn$2,add4L:Rn$2,add4H:jn$2,add5H:Gn$2,add5L:Zn$2},[Vn$2,Yn$2]=(()=>x$3.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),P$4=new Uint32Array(80),Q$2=new Uint32Array(80);let Jn$2 = class Jn extends An$2{constructor(){super(128,64,16,false),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209;}get(){const{Ah:e,Al:n,Bh:r,Bl:o,Ch:s,Cl:a,Dh:u,Dl:i,Eh:D,El:c,Fh:l,Fl:p,Gh:w,Gl:h,Hh:g,Hl:S}=this;return [e,n,r,o,s,a,u,i,D,c,l,p,w,h,g,S]}set(e,n,r,o,s,a,u,i,D,c,l,p,w,h,g,S){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=u|0,this.Dl=i|0,this.Eh=D|0,this.El=c|0,this.Fh=l|0,this.Fl=p|0,this.Gh=w|0,this.Gl=h|0,this.Hh=g|0,this.Hl=S|0;}process(e,n){for(let d=0;d<16;d++,n+=4)P$4[d]=e.getUint32(n),Q$2[d]=e.getUint32(n+=4);for(let d=16;d<80;d++){const m=P$4[d-15]|0,F=Q$2[d-15]|0,q=x$3.rotrSH(m,F,1)^x$3.rotrSH(m,F,8)^x$3.shrSH(m,F,7),z=x$3.rotrSL(m,F,1)^x$3.rotrSL(m,F,8)^x$3.shrSL(m,F,7),I=P$4[d-2]|0,O=Q$2[d-2]|0,ot=x$3.rotrSH(I,O,19)^x$3.rotrBH(I,O,61)^x$3.shrSH(I,O,6),tt=x$3.rotrSL(I,O,19)^x$3.rotrBL(I,O,61)^x$3.shrSL(I,O,6),st=x$3.add4L(z,tt,Q$2[d-7],Q$2[d-16]),at=x$3.add4H(st,q,ot,P$4[d-7],P$4[d-16]);P$4[d]=at|0,Q$2[d]=st|0;}let{Ah:r,Al:o,Bh:s,Bl:a,Ch:u,Cl:i,Dh:D,Dl:c,Eh:l,El:p,Fh:w,Fl:h,Gh:g,Gl:S,Hh:v,Hl:L}=this;for(let d=0;d<80;d++){const m=x$3.rotrSH(l,p,14)^x$3.rotrSH(l,p,18)^x$3.rotrBH(l,p,41),F=x$3.rotrSL(l,p,14)^x$3.rotrSL(l,p,18)^x$3.rotrBL(l,p,41),q=l&w^~l&g,z=p&h^~p&S,I=x$3.add5L(L,F,z,Yn$2[d],Q$2[d]),O=x$3.add5H(I,v,m,q,Vn$2[d],P$4[d]),ot=I|0,tt=x$3.rotrSH(r,o,28)^x$3.rotrBH(r,o,34)^x$3.rotrBH(r,o,39),st=x$3.rotrSL(r,o,28)^x$3.rotrBL(r,o,34)^x$3.rotrBL(r,o,39),at=r&s^r&u^s&u,Ct=o&a^o&i^a&i;v=g|0,L=S|0,g=w|0,S=h|0,w=l|0,h=p|0,{h:l,l:p}=x$3.add(D|0,c|0,O|0,ot|0),D=u|0,c=i|0,u=s|0,i=a|0,s=r|0,a=o|0;const At=x$3.add3L(ot,st,Ct);r=x$3.add3H(At,O,tt,at),o=At|0;}(({h:r,l:o}=x$3.add(this.Ah|0,this.Al|0,r|0,o|0))),{h:s,l:a}=x$3.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:u,l:i}=x$3.add(this.Ch|0,this.Cl|0,u|0,i|0),{h:D,l:c}=x$3.add(this.Dh|0,this.Dl|0,D|0,c|0),{h:l,l:p}=x$3.add(this.Eh|0,this.El|0,l|0,p|0),{h:w,l:h}=x$3.add(this.Fh|0,this.Fl|0,w|0,h|0),{h:g,l:S}=x$3.add(this.Gh|0,this.Gl|0,g|0,S|0),{h:v,l:L}=x$3.add(this.Hh|0,this.Hl|0,v|0,L|0),this.set(r,o,s,a,u,i,D,c,l,p,w,h,g,S,v,L);}roundClean(){P$4.fill(0),Q$2.fill(0);}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}};const Kn$2=Bn$2(()=>new Jn$2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vt$3=BigInt(0),be$4=BigInt(1),Wn$2=BigInt(2);function It$4(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ut$3(t){if(!It$4(t))throw new Error("Uint8Array expected")}function Tt$3(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Xn$2=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ft$3(t){Ut$3(t);let e="";for(let n=0;n<t.length;n++)e+=Xn$2[t[n]];return e}function pe$4(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?vt$3:BigInt("0x"+t)}const K$3={_0:48,_9:57,A:65,F:70,a:97,f:102};function we$4(t){if(t>=K$3._0&&t<=K$3._9)return t-K$3._0;if(t>=K$3.A&&t<=K$3.F)return t-(K$3.A-10);if(t>=K$3.a&&t<=K$3.f)return t-(K$3.a-10)}function Ee$3(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const a=we$4(t.charCodeAt(s)),u=we$4(t.charCodeAt(s+1));if(a===void 0||u===void 0){const i=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+s)}r[o]=a*16+u;}return r}function Pn$2(t){return pe$4(Ft$3(t))}function Et$4(t){return Ut$3(t),pe$4(Ft$3(Uint8Array.from(t).reverse()))}function ge$4(t,e){return Ee$3(t.toString(16).padStart(e*2,"0"))}function Nt$3(t,e){return ge$4(t,e).reverse()}function W$4(t,e,n){let r;if(typeof e=="string")try{r=Ee$3(e);}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(It$4(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(t+" of length "+n+" expected, got "+o);return r}function ye$4(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];Ut$3(o),e+=o.length;}const n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){const s=t[r];n.set(s,o),o+=s.length;}return n}const Lt$3=t=>typeof t=="bigint"&&vt$3<=t;function Qn$1(t,e,n){return Lt$3(t)&&Lt$3(e)&&Lt$3(n)&&e<=t&&t<n}function ft$3(t,e,n,r){if(!Qn$1(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function tr(t){let e;for(e=0;t>vt$3;t>>=be$4,e+=1);return e}const er=t=>(Wn$2<<BigInt(t-1))-be$4,nr$1={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||It$4(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ot$3(t,e,n={}){const r=(o,s,a)=>{const u=nr$1[s];if(typeof u!="function")throw new Error("invalid validator function");const i=t[o];if(!(a&&i===void 0)&&!u(i,t))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+i)};for(const[o,s]of Object.entries(e))r(o,s,false);for(const[o,s]of Object.entries(n))r(o,s,true);return t}function xe$1(t){const e=new WeakMap;return (n,...r)=>{const o=e.get(n);if(o!==void 0)return o;const s=t(n,...r);return e.set(n,s),s}}const M$3=BigInt(0),N$4=BigInt(1),nt$2=BigInt(2),rr$1=BigInt(3),Ht$3=BigInt(4),Be$3=BigInt(5),Ce$3=BigInt(8);function H$2(t,e){const n=t%e;return n>=M$3?n:e+n}function or$2(t,e,n){if(e<M$3)throw new Error("invalid exponent, negatives unsupported");if(n<=M$3)throw new Error("invalid modulus");if(n===N$4)return M$3;let r=N$4;for(;e>M$3;)e&N$4&&(r=r*t%n),t=t*t%n,e>>=N$4;return r}function J$4(t,e,n){let r=t;for(;e-- >M$3;)r*=r,r%=n;return r}function Ae$3(t,e){if(t===M$3)throw new Error("invert: expected non-zero number");if(e<=M$3)throw new Error("invert: expected positive modulus, got "+e);let n=H$2(t,e),r=e,o=M$3,s=N$4;for(;n!==M$3;){const u=r/n,i=r%n,D=o-s*u;r=n,n=i,o=s,s=D;}if(r!==N$4)throw new Error("invert: does not exist");return H$2(o,e)}function sr(t){const e=(t-N$4)/nt$2;let n,r,o;for(n=t-N$4,r=0;n%nt$2===M$3;n/=nt$2,r++);for(o=nt$2;o<t&&or$2(o,e,t)!==t-N$4;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const a=(t+N$4)/Ht$3;return function(i,D){const c=i.pow(D,a);if(!i.eql(i.sqr(c),D))throw new Error("Cannot find square root");return c}}const s=(n+N$4)/nt$2;return function(u,i){if(u.pow(i,e)===u.neg(u.ONE))throw new Error("Cannot find square root");let D=r,c=u.pow(u.mul(u.ONE,o),n),l=u.pow(i,s),p=u.pow(i,n);for(;!u.eql(p,u.ONE);){if(u.eql(p,u.ZERO))return u.ZERO;let w=1;for(let g=u.sqr(p);w<D&&!u.eql(g,u.ONE);w++)g=u.sqr(g);const h=u.pow(c,N$4<<BigInt(D-w-1));c=u.sqr(h),l=u.mul(l,h),p=u.mul(p,c),D=w;}return l}}function ir$1(t){if(t%Ht$3===rr$1){const e=(t+N$4)/Ht$3;return function(r,o){const s=r.pow(o,e);if(!r.eql(r.sqr(s),o))throw new Error("Cannot find square root");return s}}if(t%Ce$3===Be$3){const e=(t-Be$3)/Ce$3;return function(r,o){const s=r.mul(o,nt$2),a=r.pow(s,e),u=r.mul(o,a),i=r.mul(r.mul(u,nt$2),a),D=r.mul(u,r.sub(i,r.ONE));if(!r.eql(r.sqr(D),o))throw new Error("Cannot find square root");return D}}return sr(t)}const ur$2=(t,e)=>(H$2(t,e)&N$4)===N$4,cr$1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ar$2(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=cr$1.reduce((r,o)=>(r[o]="function",r),e);return Ot$3(t,n)}function fr$1(t,e,n){if(n<M$3)throw new Error("invalid exponent, negatives unsupported");if(n===M$3)return t.ONE;if(n===N$4)return e;let r=t.ONE,o=e;for(;n>M$3;)n&N$4&&(r=t.mul(r,o)),o=t.sqr(o),n>>=N$4;return r}function Dr$2(t,e){const n=new Array(e.length),r=e.reduce((s,a,u)=>t.is0(a)?s:(n[u]=s,t.mul(s,a)),t.ONE),o=t.inv(r);return e.reduceRight((s,a,u)=>t.is0(a)?s:(n[u]=t.mul(s,n[u]),t.mul(s,a)),o),n}function me$5(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return {nBitLength:n,nByteLength:r}}function _e$4(t,e,n=false,r={}){if(t<=M$3)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:o,nByteLength:s}=me$5(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const u=Object.freeze({ORDER:t,isLE:n,BITS:o,BYTES:s,MASK:er(o),ZERO:M$3,ONE:N$4,create:i=>H$2(i,t),isValid:i=>{if(typeof i!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof i);return M$3<=i&&i<t},is0:i=>i===M$3,isOdd:i=>(i&N$4)===N$4,neg:i=>H$2(-i,t),eql:(i,D)=>i===D,sqr:i=>H$2(i*i,t),add:(i,D)=>H$2(i+D,t),sub:(i,D)=>H$2(i-D,t),mul:(i,D)=>H$2(i*D,t),pow:(i,D)=>fr$1(u,i,D),div:(i,D)=>H$2(i*Ae$3(D,t),t),sqrN:i=>i*i,addN:(i,D)=>i+D,subN:(i,D)=>i-D,mulN:(i,D)=>i*D,inv:i=>Ae$3(i,t),sqrt:r.sqrt||(i=>(a||(a=ir$1(t)),a(u,i))),invertBatch:i=>Dr$2(u,i),cmov:(i,D,c)=>c?D:i,toBytes:i=>n?Nt$3(i,s):ge$4(i,s),fromBytes:i=>{if(i.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+i.length);return n?Et$4(i):Pn$2(i)}});return Object.freeze(u)}const Se$3=BigInt(0),gt$3=BigInt(1);function zt$3(t,e){const n=e.negate();return t?n:e}function ve$4(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Mt$3(t,e){ve$4(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1);return {windows:n,windowSize:r}}function dr$2(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)});}function hr$1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)});}const qt$3=new WeakMap,Ie$2=new WeakMap;function $t$3(t){return Ie$2.get(t)||1}function lr$2(t,e){return {constTimeNegate:zt$3,hasPrecomputes(n){return $t$3(n)!==1},unsafeLadder(n,r,o=t.ZERO){let s=n;for(;r>Se$3;)r>$3&&(o=o.add(s)),s=s.double(),r>>=gt$3;return o},precomputeWindow(n,r){const{windows:o,windowSize:s}=Mt$3(r,e),a=[];let u=n,i=u;for(let D=0;D<o;D++){i=u,a.push(i);for(let c=1;c<s;c++)i=i.add(u),a.push(i);u=i.double();}return a},wNAF(n,r,o){const{windows:s,windowSize:a}=Mt$3(n,e);let u=t.ZERO,i=t.BASE;const D=BigInt(2**n-1),c=2**n,l=BigInt(n);for(let p=0;p<s;p++){const w=p*a;let h=Number(o&D);o>>=l,h>a&&(h-=c,o+=gt$3);const g=w,S=w+Math.abs(h)-1,v=p%2!==0,L=h<0;h===0?i=i.add(zt$3(v,r[g])):u=u.add(zt$3(L,r[S]));}return {p:u,f:i}},wNAFUnsafe(n,r,o,s=t.ZERO){const{windows:a,windowSize:u}=Mt$3(n,e),i=BigInt(2**n-1),D=2**n,c=BigInt(n);for(let l=0;l<a;l++){const p=l*u;if(o===Se$3)break;let w=Number(o&i);if(o>>=c,w>u&&(w-=D,o+=gt$3),w===0)continue;let h=r[p+Math.abs(w)-1];w<0&&(h=h.negate()),s=s.add(h);}return s},getPrecomputes(n,r,o){let s=qt$3.get(r);return s||(s=this.precomputeWindow(r,n),n!==1&&qt$3.set(r,o(s))),s},wNAFCached(n,r,o){const s=$t$3(n);return this.wNAF(s,this.getPrecomputes(s,n,o),r)},wNAFCachedUnsafe(n,r,o,s){const a=$t$3(n);return a===1?this.unsafeLadder(n,r,s):this.wNAFUnsafe(a,this.getPrecomputes(a,n,o),r,s)},setWindowSize(n,r){ve$4(r,e),Ie$2.set(n,r),qt$3.delete(n);}}}function br$2(t,e,n,r){if(dr$2(n,t),hr$1(r,e),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,s=tr(BigInt(n.length)),a=s>12?s-3:s>4?s-2:s?2:1,u=(1<<a)-1,i=new Array(u+1).fill(o),D=Math.floor((e.BITS-1)/a)*a;let c=o;for(let l=D;l>=0;l-=a){i.fill(o);for(let w=0;w<r.length;w++){const h=r[w],g=Number(h>>BigInt(l)&BigInt(u));i[g]=i[g].add(n[w]);}let p=o;for(let w=i.length-1,h=o;w>0;w--)h=h.add(i[w]),p=p.add(h);if(c=c.add(p),l!==0)for(let w=0;w<a;w++)c=c.double();}return c}function pr$2(t){return ar$2(t.Fp),Ot$3(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...me$5(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const G$4=BigInt(0),j$4=BigInt(1),yt$3=BigInt(2),wr$2=BigInt(8),Er$1={zip215:true};function gr$2(t){const e=pr$2(t);return Ot$3(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function yr$2(t){const e=gr$2(t),{Fp:n,n:r,prehash:o,hash:s,randomBytes:a,nByteLength:u,h:i}=e,D=yt$3<<BigInt(u*8)-j$4,c=n.create,l=_e$4(e.n,e.nBitLength),p=e.uvRatio||((y,f)=>{try{return {isValid:!0,value:n.sqrt(y*n.inv(f))}}catch{return {isValid:false,value:G$4}}}),w=e.adjustScalarBytes||(y=>y),h=e.domain||((y,f,b)=>{if(Tt$3("phflag",b),f.length||b)throw new Error("Contexts/pre-hash are not supported");return y});function g(y,f){ft$3("coordinate "+y,f,G$4,D);}function S(y){if(!(y instanceof d))throw new Error("ExtendedPoint expected")}const v=xe$1((y,f)=>{const{ex:b,ey:E,ez:B}=y,C=y.is0();f==null&&(f=C?wr$2:n.inv(B));const A=c(b*f),U=c(E*f),_=c(B*f);if(C)return {x:G$4,y:j$4};if(_!==j$4)throw new Error("invZ was invalid");return {x:A,y:U}}),L=xe$1(y=>{const{a:f,d:b}=e;if(y.is0())throw new Error("bad point: ZERO");const{ex:E,ey:B,ez:C,et:A}=y,U=c(E*E),_=c(B*B),T=c(C*C),$=c(T*T),R=c(U*f),V=c(T*c(R+_)),Y=c($+c(b*c(U*_)));if(V!==Y)throw new Error("bad point: equation left != right (1)");const Z=c(E*B),X=c(C*A);if(Z!==X)throw new Error("bad point: equation left != right (2)");return true});class d{constructor(f,b,E,B){this.ex=f,this.ey=b,this.ez=E,this.et=B,g("x",f),g("y",b),g("z",E),g("t",B),Object.freeze(this);}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(f){if(f instanceof d)throw new Error("extended point not allowed");const{x:b,y:E}=f||{};return g("x",b),g("y",E),new d(b,E,j$4,c(b*E))}static normalizeZ(f){const b=n.invertBatch(f.map(E=>E.ez));return f.map((E,B)=>E.toAffine(b[B])).map(d.fromAffine)}static msm(f,b){return br$2(d,l,f,b)}_setWindowSize(f){q.setWindowSize(this,f);}assertValidity(){L(this);}equals(f){S(f);const{ex:b,ey:E,ez:B}=this,{ex:C,ey:A,ez:U}=f,_=c(b*U),T=c(C*B),$=c(E*U),R=c(A*B);return _===T&&$===R}is0(){return this.equals(d.ZERO)}negate(){return new d(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){const{a:f}=e,{ex:b,ey:E,ez:B}=this,C=c(b*b),A=c(E*E),U=c(yt$3*c(B*B)),_=c(f*C),T=b+E,$=c(c(T*T)-C-A),R=_+A,V=R-U,Y=_-A,Z=c($*V),X=c(R*Y),et=c($*Y),pt=c(V*R);return new d(Z,X,pt,et)}add(f){S(f);const{a:b,d:E}=e,{ex:B,ey:C,ez:A,et:U}=this,{ex:_,ey:T,ez:$,et:R}=f;if(b===BigInt(-1)){const re=c((C-B)*(T+_)),oe=c((C+B)*(T-_)),mt=c(oe-re);if(mt===G$4)return this.double();const se=c(A*yt$3*R),ie=c(U*yt$3*$),ue=ie+se,ce=oe+re,ae=ie-se,Dn=c(ue*mt),dn=c(ce*ae),hn=c(ue*ae),ln=c(mt*ce);return new d(Dn,dn,ln,hn)}const V=c(B*_),Y=c(C*T),Z=c(U*E*R),X=c(A*$),et=c((B+C)*(_+T)-V-Y),pt=X-Z,ee=X+Z,ne=c(Y-b*V),un=c(et*pt),cn=c(ee*ne),an=c(et*ne),fn=c(pt*ee);return new d(un,cn,fn,an)}subtract(f){return this.add(f.negate())}wNAF(f){return q.wNAFCached(this,f,d.normalizeZ)}multiply(f){const b=f;ft$3("scalar",b,j$4,r);const{p:E,f:B}=this.wNAF(b);return d.normalizeZ([E,B])[0]}multiplyUnsafe(f,b=d.ZERO){const E=f;return ft$3("scalar",E,G$4,r),E===G$4?F:this.is0()||E===j$4?this:q.wNAFCachedUnsafe(this,E,d.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return q.unsafeLadder(this,r).is0()}toAffine(f){return v(this,f)}clearCofactor(){const{h:f}=e;return f===j$4?this:this.multiplyUnsafe(f)}static fromHex(f,b=false){const{d:E,a:B}=e,C=n.BYTES;f=W$4("pointHex",f,C),Tt$3("zip215",b);const A=f.slice(),U=f[C-1];A[C-1]=U&-129;const _=Et$4(A),T=b?D:n.ORDER;ft$3("pointHex.y",_,G$4,T);const $=c(_*_),R=c($-j$4),V=c(E*$-B);let{isValid:Y,value:Z}=p(R,V);if(!Y)throw new Error("Point.fromHex: invalid y coordinate");const X=(Z&j$4)===j$4,et=(U&128)!==0;if(!b&&Z===G$4&&et)throw new Error("Point.fromHex: x=0 and x_0=1");return et!==X&&(Z=c(-Z)),d.fromAffine({x:Z,y:_})}static fromPrivateKey(f){return O(f).point}toRawBytes(){const{x:f,y:b}=this.toAffine(),E=Nt$3(b,n.BYTES);return E[E.length-1]|=f&j$4?128:0,E}toHex(){return Ft$3(this.toRawBytes())}}d.BASE=new d(e.Gx,e.Gy,j$4,c(e.Gx*e.Gy)),d.ZERO=new d(G$4,j$4,j$4,G$4);const{BASE:m,ZERO:F}=d,q=lr$2(d,u*8);function z(y){return H$2(y,r)}function I(y){return z(Et$4(y))}function O(y){const f=n.BYTES;y=W$4("private key",y,f);const b=W$4("hashed private key",s(y),2*f),E=w(b.slice(0,f)),B=b.slice(f,2*f),C=I(E),A=m.multiply(C),U=A.toRawBytes();return {head:E,prefix:B,scalar:C,point:A,pointBytes:U}}function ot(y){return O(y).pointBytes}function tt(y=new Uint8Array,...f){const b=ye$4(...f);return I(s(h(b,W$4("context",y),!!o)))}function st(y,f,b={}){y=W$4("message",y),o&&(y=o(y));const{prefix:E,scalar:B,pointBytes:C}=O(f),A=tt(b.context,E,y),U=m.multiply(A).toRawBytes(),_=tt(b.context,U,C,y),T=z(A+_*B);ft$3("signature.s",T,G$4,r);const $=ye$4(U,Nt$3(T,n.BYTES));return W$4("result",$,n.BYTES*2)}const at=Er$1;function Ct(y,f,b,E=at){const{context:B,zip215:C}=E,A=n.BYTES;y=W$4("signature",y,2*A),f=W$4("message",f),b=W$4("publicKey",b,A),C!==void 0&&Tt$3("zip215",C),o&&(f=o(f));const U=Et$4(y.slice(A,2*A));let _,T,$;try{_=d.fromHex(b,C),T=d.fromHex(y.slice(0,A),C),$=m.multiplyUnsafe(U);}catch{return false}if(!C&&_.isSmallOrder())return false;const R=tt(B,T.toRawBytes(),_.toRawBytes(),f);return T.add(_.multiplyUnsafe(R)).subtract($).clearCofactor().equals(d.ZERO)}return m._setWindowSize(8),{CURVE:e,getPublicKey:ot,sign:st,verify:Ct,ExtendedPoint:d,utils:{getExtendedPublicKey:O,randomPrivateKey:()=>a(n.BYTES),precompute(y=8,f=d.BASE){return f._setWindowSize(y),f.multiply(BigInt(3)),f}}}}BigInt(0),BigInt(1);const kt$3=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ue$4=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const xr$1=BigInt(1),Te$3=BigInt(2);BigInt(3);const Br$2=BigInt(5),Cr$2=BigInt(8);function Ar$2(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=kt$3,u=t*t%s*t%s,i=J$4(u,Te$3,s)*u%s,D=J$4(i,xr$1,s)*t%s,c=J$4(D,Br$2,s)*D%s,l=J$4(c,e,s)*c%s,p=J$4(l,n,s)*l%s,w=J$4(p,r,s)*p%s,h=J$4(w,o,s)*w%s,g=J$4(h,o,s)*w%s,S=J$4(g,e,s)*c%s;return {pow_p_5_8:J$4(S,Te$3,s)*t%s,b2:u}}function mr$2(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function _r$2(t,e){const n=kt$3,r=H$2(e*e*e,n),o=H$2(r*r*e,n),s=Ar$2(t*o).pow_p_5_8;let a=H$2(t*r*s,n);const u=H$2(e*a*a,n),i=a,D=H$2(a*Ue$4,n),c=u===t,l=u===H$2(-t,n),p=u===H$2(-t*Ue$4,n);return c&&(a=i),(l||p)&&(a=D),ur$2(a,n)&&(a=H$2(-a,n)),{isValid:c||l,value:a}}const Sr$2=(()=>_e$4(kt$3,void 0,true))(),vr$1=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Sr$2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Cr$2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Kn$2,randomBytes:he$4,adjustScalarBytes:mr$2,uvRatio:_r$2}))(),Rt$4=(()=>yr$2(vr$1))(),jt$3="EdDSA",Zt$3="JWT",ut$3=".",Dt$2="base64url",Gt$3="utf8",xt$3="utf8",Vt$3=":",Yt$2="did",Jt$3="key",dt$3="base58btc",Kt$3="z",Wt$3="K36",Ne$1=32;function Xt$3(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Le$3(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Xt$3(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Oe$4(t,e){e||(e=t.reduce((o,s)=>o+s.length,0));const n=Le$3(e);let r=0;for(const o of t)n.set(o,r),r+=o.length;return Xt$3(n)}function Ir$2(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");n[a]=o;}var u=t.length,i=t.charAt(0),D=Math.log(u)/Math.log(256),c=Math.log(256)/Math.log(u);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return "";for(var g=0,S=0,v=0,L=h.length;v!==L&&h[v]===0;)v++,g++;for(var d=(L-v)*c+1>>>0,m=new Uint8Array(d);v!==L;){for(var F=h[v],q=0,z=d-1;(F!==0||q<S)&&z!==-1;z--,q++)F+=256*m[z]>>>0,m[z]=F%u>>>0,F=F/u>>>0;if(F!==0)throw new Error("Non-zero carry");S=q,v++;}for(var I=d-S;I!==d&&m[I]===0;)I++;for(var O=i.repeat(g);I<d;++I)O+=t.charAt(m[I]);return O}function p(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var S=0,v=0;h[g]===i;)S++,g++;for(var L=(h.length-g)*D+1>>>0,d=new Uint8Array(L);h[g];){var m=n[h.charCodeAt(g)];if(m===255)return;for(var F=0,q=L-1;(m!==0||F<v)&&q!==-1;q--,F++)m+=u*d[q]>>>0,d[q]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");v=F,g++;}if(h[g]!==" "){for(var z=L-v;z!==L&&d[z]===0;)z++;for(var I=new Uint8Array(S+(L-z)),O=S;z!==L;)I[O++]=d[z++];return I}}}function w(h){var g=p(h);if(g)return g;throw new Error(`Non-${e} character`)}return {encode:l,decodeUnsafe:p,decode:w}}var Ur$2=Ir$2,Tr$2=Ur$2;const He$3=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Fr$2=t=>new TextEncoder().encode(t),Nr$2=t=>new TextDecoder().decode(t);let Lr$2 = class Lr{constructor(e,n,r){this.name=e,this.prefix=n,this.baseEncode=r;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};let Or$2 = class Or{constructor(e,n,r){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ze$2(this,e)}};let Hr$2 = class Hr{constructor(e){this.decoders=e;}or(e){return ze$2(this,e)}decode(e){const n=e[0],r=this.decoders[n];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const ze$2=(t,e)=>new Hr$2({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let zr$2 = class zr{constructor(e,n,r,o){this.name=e,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new Lr$2(e,n,r),this.decoder=new Or$2(e,n,o);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Bt$3=({name:t,prefix:e,encode:n,decode:r})=>new zr$2(t,e,n,r),ht$2=({prefix:t,name:e,alphabet:n})=>{const{encode:r,decode:o}=Tr$2(n,e);return Bt$3({prefix:t,name:e,encode:r,decode:s=>He$3(o(s))})},Mr$2=(t,e,n,r)=>{const o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;const a=new Uint8Array(s*n/8|0);let u=0,i=0,D=0;for(let c=0;c<s;++c){const l=o[t[c]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);i=i<<n|l,u+=n,u>=8&&(u-=8,a[D++]=255&i>>u);}if(u>=n||255&i<<8-u)throw new SyntaxError("Unexpected end of data");return a},qr$2=(t,e,n)=>{const r=e[e.length-1]==="=",o=(1<<n)-1;let s="",a=0,u=0;for(let i=0;i<t.length;++i)for(u=u<<8|t[i],a+=8;a>n;)a-=n,s+=e[o&u>>a];if(a&&(s+=e[o&u<<n-a]),r)for(;s.length*n&7;)s+="=";return s},k$1=({name:t,prefix:e,bitsPerChar:n,alphabet:r})=>Bt$3({prefix:e,name:t,encode(o){return qr$2(o,r,n)},decode(o){return Mr$2(o,r,n,t)}}),$r$2=Bt$3({prefix:"\0",name:"identity",encode:t=>Nr$2(t),decode:t=>Fr$2(t)});var kr$2=Object.freeze({__proto__:null,identity:$r$2});const Rr$2=k$1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jr$2=Object.freeze({__proto__:null,base2:Rr$2});const Zr$2=k$1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gr$2=Object.freeze({__proto__:null,base8:Zr$2});const Vr$2=ht$2({prefix:"9",name:"base10",alphabet:"0123456789"});var Yr$2=Object.freeze({__proto__:null,base10:Vr$2});const Jr$2=k$1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kr$2=k$1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wr$2=Object.freeze({__proto__:null,base16:Jr$2,base16upper:Kr$2});const Xr$2=k$1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Pr$2=k$1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qr$2=k$1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),to$2=k$1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eo$2=k$1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),no$1=k$1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ro$1=k$1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oo$1=k$1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),so$2=k$1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var io$2=Object.freeze({__proto__:null,base32:Xr$2,base32upper:Pr$2,base32pad:Qr$2,base32padupper:to$2,base32hex:eo$2,base32hexupper:no$1,base32hexpad:ro$1,base32hexpadupper:oo$1,base32z:so$2});const uo$1=ht$2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),co$2=ht$2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ao$2=Object.freeze({__proto__:null,base36:uo$1,base36upper:co$2});const fo$1=ht$2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Do$2=ht$2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ho$2=Object.freeze({__proto__:null,base58btc:fo$1,base58flickr:Do$2});const lo$2=k$1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bo$2=k$1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),po$2=k$1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo$2=k$1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Eo$2=Object.freeze({__proto__:null,base64:lo$2,base64pad:bo$2,base64url:po$2,base64urlpad:wo$2});const Me$5=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),go$2=Me$5.reduce((t,e,n)=>(t[n]=e,t),[]),yo$2=Me$5.reduce((t,e,n)=>(t[e.codePointAt(0)]=n,t),[]);function xo$2(t){return t.reduce((e,n)=>(e+=go$2[n],e),"")}function Bo$2(t){const e=[];for(const n of t){const r=yo$2[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);e.push(r);}return new Uint8Array(e)}const Co$2=Bt$3({prefix:"\u{1F680}",name:"base256emoji",encode:xo$2,decode:Bo$2});var Ao$2=Object.freeze({__proto__:null,base256emoji:Co$2}),mo$2=$e$3,qe$2=128,So$2=-128,vo$2=Math.pow(2,31);function $e$3(t,e,n){e=e||[],n=n||0;for(var r=n;t>=vo$2;)e[n++]=t&255|qe$2,t/=128;for(;t&So$2;)e[n++]=t&255|qe$2,t>>>=7;return e[n]=t|0,$e$3.bytes=n-r+1,e}var Io$2=Pt$3,Uo$2=128,ke$4=127;function Pt$3(t,r){var n=0,r=r||0,o=0,s=r,a,u=t.length;do{if(s>=u)throw Pt$3.bytes=0,new RangeError("Could not decode varint");a=t[s++],n+=o<28?(a&ke$4)<<o:(a&ke$4)*Math.pow(2,o),o+=7;}while(a>=Uo$2);return Pt$3.bytes=s-r,n}var To$2=Math.pow(2,7),Fo$2=Math.pow(2,14),No$2=Math.pow(2,21),Lo$2=Math.pow(2,28),Oo$2=Math.pow(2,35),Ho$2=Math.pow(2,42),zo$2=Math.pow(2,49),Mo$2=Math.pow(2,56),qo$2=Math.pow(2,63),$o$2=function(t){return t<To$2?1:t<Fo$2?2:t<No$2?3:t<Lo$2?4:t<Oo$2?5:t<Ho$2?6:t<zo$2?7:t<Mo$2?8:t<qo$2?9:10},ko$2={encode:mo$2,decode:Io$2,encodingLength:$o$2},Re$1=ko$2;const je$2=(t,e,n=0)=>(Re$1.encode(t,e,n),e),Ze$3=t=>Re$1.encodingLength(t),Qt$3=(t,e)=>{const n=e.byteLength,r=Ze$3(t),o=r+Ze$3(n),s=new Uint8Array(o+n);return je$2(t,s,0),je$2(n,s,r),s.set(e,o),new Ro$2(t,n,e,s)};let Ro$2 = class Ro{constructor(e,n,r,o){this.code=e,this.size=n,this.digest=r,this.bytes=o;}};const Ge$3=({name:t,code:e,encode:n})=>new jo$2(t,e,n);let jo$2 = class jo{constructor(e,n,r){this.name=e,this.code=n,this.encode=r;}digest(e){if(e instanceof Uint8Array){const n=this.encode(e);return n instanceof Uint8Array?Qt$3(this.code,n):n.then(r=>Qt$3(this.code,r))}else throw Error("Unknown type, must be binary type")}};const Ve$4=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Zo$2=Ge$3({name:"sha2-256",code:18,encode:Ve$4("SHA-256")}),Go$2=Ge$3({name:"sha2-512",code:19,encode:Ve$4("SHA-512")});var Vo$2=Object.freeze({__proto__:null,sha256:Zo$2,sha512:Go$2});const Ye$3=0,Yo$2="identity",Je$3=He$3,Jo$2=t=>Qt$3(Ye$3,Je$3(t)),Ko$2={code:Ye$3,name:Yo$2,encode:Je$3,digest:Jo$2};var Wo$2=Object.freeze({__proto__:null,identity:Ko$2});new TextEncoder,new TextDecoder;const Ke$4={...kr$2,...jr$2,...Gr$2,...Yr$2,...Wr$2,...io$2,...ao$2,...ho$2,...Eo$2,...Ao$2};({...Vo$2,...Wo$2});function We$4(t,e,n,r){return {name:t,prefix:e,encoder:{name:t,prefix:e,encode:n},decoder:{decode:r}}}const Xe$2=We$4("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),te$3=We$4("ascii","a",t=>{let e="a";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e},t=>{t=t.substring(1);const e=Le$3(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}),Pe$4={utf8:Xe$2,"utf-8":Xe$2,hex:Ke$4.base16,latin1:te$3,ascii:te$3,binary:te$3,...Ke$4};function ct$2(t,e="utf8"){const n=Pe$4[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):n.encoder.encode(t).substring(1)}function rt$2(t,e="utf8"){const n=Pe$4[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Xt$3(globalThis.Buffer.from(t,"utf-8")):n.decoder.decode(`${n.prefix}${t}`)}function lt$2(t){return safeJsonParse(ct$2(rt$2(t,Dt$2),Gt$3))}function bt$2(t){return ct$2(rt$2(safeJsonStringify(t),Gt$3),Dt$2)}function Qe$2(t){const e=rt$2(Wt$3,dt$3),n=Kt$3+ct$2(Oe$4([e,t]),dt$3);return [Yt$2,Jt$3,n].join(Vt$3)}function en$2(t){return ct$2(t,Dt$2)}function nn(t){return rt$2(t,Dt$2)}function rn$2(t){return rt$2([bt$2(t.header),bt$2(t.payload)].join(ut$3),xt$3)}function on$2(t){return [bt$2(t.header),bt$2(t.payload),en$2(t.signature)].join(ut$3)}function sn$1(t){const e=t.split(ut$3),n=lt$2(e[0]),r=lt$2(e[1]),o=nn(e[2]),s=rt$2(e.slice(0,2).join(ut$3),xt$3);return {header:n,payload:r,signature:o,data:s}}function Po$2(t=he$4(Ne$1)){const e=Rt$4.getPublicKey(t);return {secretKey:Oe$4([t,e]),publicKey:e}}async function Qo$2(t,e,n,r,o=cjsExports$3.fromMiliseconds(Date.now())){const s={alg:jt$3,typ:Zt$3},a=Qe$2(r.publicKey),u=o+n,i={iss:a,sub:t,aud:e,iat:o,exp:u},D=rn$2({header:s,payload:i}),c=Rt$4.sign(D,r.secretKey.slice(0,32));return on$2({header:s,payload:i,signature:c})}
|
|
22973
|
+
function En$2(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function fe$4(t,...e){if(!En$2(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function De$3(t,e=true){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function gn$2(t,e){fe$4(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const it$1=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _t$3=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function yn$2(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function de$3(t){return typeof t=="string"&&(t=yn$2(t)),fe$4(t),t}let xn$2 = class xn{clone(){return this._cloneInto()}};function Bn$2(t){const e=r=>t().update(de$3(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function he$4(t=32){if(it$1&&typeof it$1.getRandomValues=="function")return it$1.getRandomValues(new Uint8Array(t));if(it$1&&typeof it$1.randomBytes=="function")return it$1.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Cn$2(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),u=Number(n&s),i=r?4:0,D=r?0:4;t.setUint32(e+i,a,r),t.setUint32(e+D,u,r);}let An$2 = class An extends xn$2{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=false,this.length=0,this.pos=0,this.destroyed=false,this.buffer=new Uint8Array(e),this.view=_t$3(this.buffer);}update(e){De$3(this);const{view:n,buffer:r,blockLen:o}=this;e=de$3(e);const s=e.length;for(let a=0;a<s;){const u=Math.min(o-this.pos,s-a);if(u===o){const i=_t$3(e);for(;o<=s-a;a+=o)this.process(i,a);continue}r.set(e.subarray(a,a+u),this.pos),this.pos+=u,a+=u,this.pos===o&&(this.process(n,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){De$3(this),gn$2(e,this),this.finished=true;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let l=a;l<o;l++)n[l]=0;Cn$2(r,o-8,BigInt(this.length*8),s),this.process(r,0);const u=_t$3(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const D=i/4,c=this.get();if(D>c.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<D;l++)u.setUint32(4*l,c[l],s);}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:a,pos:u}=this;return e.length=o,e.pos=u,e.finished=s,e.destroyed=a,o%n&&e.buffer.set(r),e}};const wt$3=BigInt(2**32-1),St$4=BigInt(32);function le$3(t,e=false){return e?{h:Number(t&wt$3),l:Number(t>>St$4&wt$3)}:{h:Number(t>>St$4&wt$3)|0,l:Number(t&wt$3)|0}}function mn$2(t,e=false){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:s,l:a}=le$3(t[o],e);[n[o],r[o]]=[s,a];}return [n,r]}const _n$2=(t,e)=>BigInt(t>>>0)<<St$4|BigInt(e>>>0),Sn$2=(t,e,n)=>t>>>n,vn$2=(t,e,n)=>t<<32-n|e>>>n,In$2=(t,e,n)=>t>>>n|e<<32-n,Un$2=(t,e,n)=>t<<32-n|e>>>n,Tn$2=(t,e,n)=>t<<64-n|e>>>n-32,Fn$2=(t,e,n)=>t>>>n-32|e<<64-n,Nn$2=(t,e)=>e,Ln$2=(t,e)=>t,On$2=(t,e,n)=>t<<n|e>>>32-n,Hn$2=(t,e,n)=>e<<n|t>>>32-n,zn$2=(t,e,n)=>e<<n-32|t>>>64-n,Mn$2=(t,e,n)=>t<<n-32|e>>>64-n;function qn$2(t,e,n,r){const o=(e>>>0)+(r>>>0);return {h:t+n+(o/2**32|0)|0,l:o|0}}const $n$2=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),kn$2=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Rn$2=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),jn$2=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,Zn$2=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),Gn$2=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,x$3={fromBig:le$3,split:mn$2,toBig:_n$2,shrSH:Sn$2,shrSL:vn$2,rotrSH:In$2,rotrSL:Un$2,rotrBH:Tn$2,rotrBL:Fn$2,rotr32H:Nn$2,rotr32L:Ln$2,rotlSH:On$2,rotlSL:Hn$2,rotlBH:zn$2,rotlBL:Mn$2,add:qn$2,add3L:$n$2,add3H:kn$2,add4L:Rn$2,add4H:jn$2,add5H:Gn$2,add5L:Zn$2},[Vn$2,Yn$2]=(()=>x$3.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),P$4=new Uint32Array(80),Q$2=new Uint32Array(80);let Jn$2 = class Jn extends An$2{constructor(){super(128,64,16,false),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209;}get(){const{Ah:e,Al:n,Bh:r,Bl:o,Ch:s,Cl:a,Dh:u,Dl:i,Eh:D,El:c,Fh:l,Fl:p,Gh:w,Gl:h,Hh:g,Hl:S}=this;return [e,n,r,o,s,a,u,i,D,c,l,p,w,h,g,S]}set(e,n,r,o,s,a,u,i,D,c,l,p,w,h,g,S){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=u|0,this.Dl=i|0,this.Eh=D|0,this.El=c|0,this.Fh=l|0,this.Fl=p|0,this.Gh=w|0,this.Gl=h|0,this.Hh=g|0,this.Hl=S|0;}process(e,n){for(let d=0;d<16;d++,n+=4)P$4[d]=e.getUint32(n),Q$2[d]=e.getUint32(n+=4);for(let d=16;d<80;d++){const m=P$4[d-15]|0,F=Q$2[d-15]|0,q=x$3.rotrSH(m,F,1)^x$3.rotrSH(m,F,8)^x$3.shrSH(m,F,7),z=x$3.rotrSL(m,F,1)^x$3.rotrSL(m,F,8)^x$3.shrSL(m,F,7),I=P$4[d-2]|0,O=Q$2[d-2]|0,ot=x$3.rotrSH(I,O,19)^x$3.rotrBH(I,O,61)^x$3.shrSH(I,O,6),tt=x$3.rotrSL(I,O,19)^x$3.rotrBL(I,O,61)^x$3.shrSL(I,O,6),st=x$3.add4L(z,tt,Q$2[d-7],Q$2[d-16]),at=x$3.add4H(st,q,ot,P$4[d-7],P$4[d-16]);P$4[d]=at|0,Q$2[d]=st|0;}let{Ah:r,Al:o,Bh:s,Bl:a,Ch:u,Cl:i,Dh:D,Dl:c,Eh:l,El:p,Fh:w,Fl:h,Gh:g,Gl:S,Hh:v,Hl:L}=this;for(let d=0;d<80;d++){const m=x$3.rotrSH(l,p,14)^x$3.rotrSH(l,p,18)^x$3.rotrBH(l,p,41),F=x$3.rotrSL(l,p,14)^x$3.rotrSL(l,p,18)^x$3.rotrBL(l,p,41),q=l&w^~l&g,z=p&h^~p&S,I=x$3.add5L(L,F,z,Yn$2[d],Q$2[d]),O=x$3.add5H(I,v,m,q,Vn$2[d],P$4[d]),ot=I|0,tt=x$3.rotrSH(r,o,28)^x$3.rotrBH(r,o,34)^x$3.rotrBH(r,o,39),st=x$3.rotrSL(r,o,28)^x$3.rotrBL(r,o,34)^x$3.rotrBL(r,o,39),at=r&s^r&u^s&u,Ct=o&a^o&i^a&i;v=g|0,L=S|0,g=w|0,S=h|0,w=l|0,h=p|0,{h:l,l:p}=x$3.add(D|0,c|0,O|0,ot|0),D=u|0,c=i|0,u=s|0,i=a|0,s=r|0,a=o|0;const At=x$3.add3L(ot,st,Ct);r=x$3.add3H(At,O,tt,at),o=At|0;}(({h:r,l:o}=x$3.add(this.Ah|0,this.Al|0,r|0,o|0))),{h:s,l:a}=x$3.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:u,l:i}=x$3.add(this.Ch|0,this.Cl|0,u|0,i|0),{h:D,l:c}=x$3.add(this.Dh|0,this.Dl|0,D|0,c|0),{h:l,l:p}=x$3.add(this.Eh|0,this.El|0,l|0,p|0),{h:w,l:h}=x$3.add(this.Fh|0,this.Fl|0,w|0,h|0),{h:g,l:S}=x$3.add(this.Gh|0,this.Gl|0,g|0,S|0),{h:v,l:L}=x$3.add(this.Hh|0,this.Hl|0,v|0,L|0),this.set(r,o,s,a,u,i,D,c,l,p,w,h,g,S,v,L);}roundClean(){P$4.fill(0),Q$2.fill(0);}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}};const Kn$2=Bn$2(()=>new Jn$2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vt$3=BigInt(0),be$4=BigInt(1),Wn$2=BigInt(2);function It$4(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ut$3(t){if(!It$4(t))throw new Error("Uint8Array expected")}function Tt$3(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Xn$2=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ft$3(t){Ut$3(t);let e="";for(let n=0;n<t.length;n++)e+=Xn$2[t[n]];return e}function pe$4(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?vt$3:BigInt("0x"+t)}const K$2={_0:48,_9:57,A:65,F:70,a:97,f:102};function we$4(t){if(t>=K$2._0&&t<=K$2._9)return t-K$2._0;if(t>=K$2.A&&t<=K$2.F)return t-(K$2.A-10);if(t>=K$2.a&&t<=K$2.f)return t-(K$2.a-10)}function Ee$3(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const a=we$4(t.charCodeAt(s)),u=we$4(t.charCodeAt(s+1));if(a===void 0||u===void 0){const i=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+s)}r[o]=a*16+u;}return r}function Pn$2(t){return pe$4(Ft$3(t))}function Et$4(t){return Ut$3(t),pe$4(Ft$3(Uint8Array.from(t).reverse()))}function ge$4(t,e){return Ee$3(t.toString(16).padStart(e*2,"0"))}function Nt$3(t,e){return ge$4(t,e).reverse()}function W$4(t,e,n){let r;if(typeof e=="string")try{r=Ee$3(e);}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(It$4(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(t+" of length "+n+" expected, got "+o);return r}function ye$4(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];Ut$3(o),e+=o.length;}const n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){const s=t[r];n.set(s,o),o+=s.length;}return n}const Lt$3=t=>typeof t=="bigint"&&vt$3<=t;function Qn$1(t,e,n){return Lt$3(t)&&Lt$3(e)&&Lt$3(n)&&e<=t&&t<n}function ft$3(t,e,n,r){if(!Qn$1(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function tr(t){let e;for(e=0;t>vt$3;t>>=be$4,e+=1);return e}const er=t=>(Wn$2<<BigInt(t-1))-be$4,nr$1={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||It$4(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ot$3(t,e,n={}){const r=(o,s,a)=>{const u=nr$1[s];if(typeof u!="function")throw new Error("invalid validator function");const i=t[o];if(!(a&&i===void 0)&&!u(i,t))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+i)};for(const[o,s]of Object.entries(e))r(o,s,false);for(const[o,s]of Object.entries(n))r(o,s,true);return t}function xe$2(t){const e=new WeakMap;return (n,...r)=>{const o=e.get(n);if(o!==void 0)return o;const s=t(n,...r);return e.set(n,s),s}}const M$3=BigInt(0),N$4=BigInt(1),nt$2=BigInt(2),rr$1=BigInt(3),Ht$3=BigInt(4),Be$3=BigInt(5),Ce$3=BigInt(8);function H$2(t,e){const n=t%e;return n>=M$3?n:e+n}function or$2(t,e,n){if(e<M$3)throw new Error("invalid exponent, negatives unsupported");if(n<=M$3)throw new Error("invalid modulus");if(n===N$4)return M$3;let r=N$4;for(;e>M$3;)e&N$4&&(r=r*t%n),t=t*t%n,e>>=N$4;return r}function J$4(t,e,n){let r=t;for(;e-- >M$3;)r*=r,r%=n;return r}function Ae$3(t,e){if(t===M$3)throw new Error("invert: expected non-zero number");if(e<=M$3)throw new Error("invert: expected positive modulus, got "+e);let n=H$2(t,e),r=e,o=M$3,s=N$4;for(;n!==M$3;){const u=r/n,i=r%n,D=o-s*u;r=n,n=i,o=s,s=D;}if(r!==N$4)throw new Error("invert: does not exist");return H$2(o,e)}function sr(t){const e=(t-N$4)/nt$2;let n,r,o;for(n=t-N$4,r=0;n%nt$2===M$3;n/=nt$2,r++);for(o=nt$2;o<t&&or$2(o,e,t)!==t-N$4;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const a=(t+N$4)/Ht$3;return function(i,D){const c=i.pow(D,a);if(!i.eql(i.sqr(c),D))throw new Error("Cannot find square root");return c}}const s=(n+N$4)/nt$2;return function(u,i){if(u.pow(i,e)===u.neg(u.ONE))throw new Error("Cannot find square root");let D=r,c=u.pow(u.mul(u.ONE,o),n),l=u.pow(i,s),p=u.pow(i,n);for(;!u.eql(p,u.ONE);){if(u.eql(p,u.ZERO))return u.ZERO;let w=1;for(let g=u.sqr(p);w<D&&!u.eql(g,u.ONE);w++)g=u.sqr(g);const h=u.pow(c,N$4<<BigInt(D-w-1));c=u.sqr(h),l=u.mul(l,h),p=u.mul(p,c),D=w;}return l}}function ir$1(t){if(t%Ht$3===rr$1){const e=(t+N$4)/Ht$3;return function(r,o){const s=r.pow(o,e);if(!r.eql(r.sqr(s),o))throw new Error("Cannot find square root");return s}}if(t%Ce$3===Be$3){const e=(t-Be$3)/Ce$3;return function(r,o){const s=r.mul(o,nt$2),a=r.pow(s,e),u=r.mul(o,a),i=r.mul(r.mul(u,nt$2),a),D=r.mul(u,r.sub(i,r.ONE));if(!r.eql(r.sqr(D),o))throw new Error("Cannot find square root");return D}}return sr(t)}const ur$2=(t,e)=>(H$2(t,e)&N$4)===N$4,cr$1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ar$2(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=cr$1.reduce((r,o)=>(r[o]="function",r),e);return Ot$3(t,n)}function fr$1(t,e,n){if(n<M$3)throw new Error("invalid exponent, negatives unsupported");if(n===M$3)return t.ONE;if(n===N$4)return e;let r=t.ONE,o=e;for(;n>M$3;)n&N$4&&(r=t.mul(r,o)),o=t.sqr(o),n>>=N$4;return r}function Dr$2(t,e){const n=new Array(e.length),r=e.reduce((s,a,u)=>t.is0(a)?s:(n[u]=s,t.mul(s,a)),t.ONE),o=t.inv(r);return e.reduceRight((s,a,u)=>t.is0(a)?s:(n[u]=t.mul(s,n[u]),t.mul(s,a)),o),n}function me$5(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return {nBitLength:n,nByteLength:r}}function _e$4(t,e,n=false,r={}){if(t<=M$3)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:o,nByteLength:s}=me$5(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const u=Object.freeze({ORDER:t,isLE:n,BITS:o,BYTES:s,MASK:er(o),ZERO:M$3,ONE:N$4,create:i=>H$2(i,t),isValid:i=>{if(typeof i!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof i);return M$3<=i&&i<t},is0:i=>i===M$3,isOdd:i=>(i&N$4)===N$4,neg:i=>H$2(-i,t),eql:(i,D)=>i===D,sqr:i=>H$2(i*i,t),add:(i,D)=>H$2(i+D,t),sub:(i,D)=>H$2(i-D,t),mul:(i,D)=>H$2(i*D,t),pow:(i,D)=>fr$1(u,i,D),div:(i,D)=>H$2(i*Ae$3(D,t),t),sqrN:i=>i*i,addN:(i,D)=>i+D,subN:(i,D)=>i-D,mulN:(i,D)=>i*D,inv:i=>Ae$3(i,t),sqrt:r.sqrt||(i=>(a||(a=ir$1(t)),a(u,i))),invertBatch:i=>Dr$2(u,i),cmov:(i,D,c)=>c?D:i,toBytes:i=>n?Nt$3(i,s):ge$4(i,s),fromBytes:i=>{if(i.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+i.length);return n?Et$4(i):Pn$2(i)}});return Object.freeze(u)}const Se$3=BigInt(0),gt$3=BigInt(1);function zt$3(t,e){const n=e.negate();return t?n:e}function ve$4(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Mt$3(t,e){ve$4(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1);return {windows:n,windowSize:r}}function dr$2(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)});}function hr$1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)});}const qt$3=new WeakMap,Ie$2=new WeakMap;function $t$3(t){return Ie$2.get(t)||1}function lr$2(t,e){return {constTimeNegate:zt$3,hasPrecomputes(n){return $t$3(n)!==1},unsafeLadder(n,r,o=t.ZERO){let s=n;for(;r>Se$3;)r>$3&&(o=o.add(s)),s=s.double(),r>>=gt$3;return o},precomputeWindow(n,r){const{windows:o,windowSize:s}=Mt$3(r,e),a=[];let u=n,i=u;for(let D=0;D<o;D++){i=u,a.push(i);for(let c=1;c<s;c++)i=i.add(u),a.push(i);u=i.double();}return a},wNAF(n,r,o){const{windows:s,windowSize:a}=Mt$3(n,e);let u=t.ZERO,i=t.BASE;const D=BigInt(2**n-1),c=2**n,l=BigInt(n);for(let p=0;p<s;p++){const w=p*a;let h=Number(o&D);o>>=l,h>a&&(h-=c,o+=gt$3);const g=w,S=w+Math.abs(h)-1,v=p%2!==0,L=h<0;h===0?i=i.add(zt$3(v,r[g])):u=u.add(zt$3(L,r[S]));}return {p:u,f:i}},wNAFUnsafe(n,r,o,s=t.ZERO){const{windows:a,windowSize:u}=Mt$3(n,e),i=BigInt(2**n-1),D=2**n,c=BigInt(n);for(let l=0;l<a;l++){const p=l*u;if(o===Se$3)break;let w=Number(o&i);if(o>>=c,w>u&&(w-=D,o+=gt$3),w===0)continue;let h=r[p+Math.abs(w)-1];w<0&&(h=h.negate()),s=s.add(h);}return s},getPrecomputes(n,r,o){let s=qt$3.get(r);return s||(s=this.precomputeWindow(r,n),n!==1&&qt$3.set(r,o(s))),s},wNAFCached(n,r,o){const s=$t$3(n);return this.wNAF(s,this.getPrecomputes(s,n,o),r)},wNAFCachedUnsafe(n,r,o,s){const a=$t$3(n);return a===1?this.unsafeLadder(n,r,s):this.wNAFUnsafe(a,this.getPrecomputes(a,n,o),r,s)},setWindowSize(n,r){ve$4(r,e),Ie$2.set(n,r),qt$3.delete(n);}}}function br$2(t,e,n,r){if(dr$2(n,t),hr$1(r,e),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,s=tr(BigInt(n.length)),a=s>12?s-3:s>4?s-2:s?2:1,u=(1<<a)-1,i=new Array(u+1).fill(o),D=Math.floor((e.BITS-1)/a)*a;let c=o;for(let l=D;l>=0;l-=a){i.fill(o);for(let w=0;w<r.length;w++){const h=r[w],g=Number(h>>BigInt(l)&BigInt(u));i[g]=i[g].add(n[w]);}let p=o;for(let w=i.length-1,h=o;w>0;w--)h=h.add(i[w]),p=p.add(h);if(c=c.add(p),l!==0)for(let w=0;w<a;w++)c=c.double();}return c}function pr$2(t){return ar$2(t.Fp),Ot$3(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...me$5(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const G$4=BigInt(0),j$4=BigInt(1),yt$3=BigInt(2),wr$2=BigInt(8),Er$1={zip215:true};function gr$2(t){const e=pr$2(t);return Ot$3(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function yr$2(t){const e=gr$2(t),{Fp:n,n:r,prehash:o,hash:s,randomBytes:a,nByteLength:u,h:i}=e,D=yt$3<<BigInt(u*8)-j$4,c=n.create,l=_e$4(e.n,e.nBitLength),p=e.uvRatio||((y,f)=>{try{return {isValid:!0,value:n.sqrt(y*n.inv(f))}}catch{return {isValid:false,value:G$4}}}),w=e.adjustScalarBytes||(y=>y),h=e.domain||((y,f,b)=>{if(Tt$3("phflag",b),f.length||b)throw new Error("Contexts/pre-hash are not supported");return y});function g(y,f){ft$3("coordinate "+y,f,G$4,D);}function S(y){if(!(y instanceof d))throw new Error("ExtendedPoint expected")}const v=xe$2((y,f)=>{const{ex:b,ey:E,ez:B}=y,C=y.is0();f==null&&(f=C?wr$2:n.inv(B));const A=c(b*f),U=c(E*f),_=c(B*f);if(C)return {x:G$4,y:j$4};if(_!==j$4)throw new Error("invZ was invalid");return {x:A,y:U}}),L=xe$2(y=>{const{a:f,d:b}=e;if(y.is0())throw new Error("bad point: ZERO");const{ex:E,ey:B,ez:C,et:A}=y,U=c(E*E),_=c(B*B),T=c(C*C),$=c(T*T),R=c(U*f),V=c(T*c(R+_)),Y=c($+c(b*c(U*_)));if(V!==Y)throw new Error("bad point: equation left != right (1)");const Z=c(E*B),X=c(C*A);if(Z!==X)throw new Error("bad point: equation left != right (2)");return true});class d{constructor(f,b,E,B){this.ex=f,this.ey=b,this.ez=E,this.et=B,g("x",f),g("y",b),g("z",E),g("t",B),Object.freeze(this);}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(f){if(f instanceof d)throw new Error("extended point not allowed");const{x:b,y:E}=f||{};return g("x",b),g("y",E),new d(b,E,j$4,c(b*E))}static normalizeZ(f){const b=n.invertBatch(f.map(E=>E.ez));return f.map((E,B)=>E.toAffine(b[B])).map(d.fromAffine)}static msm(f,b){return br$2(d,l,f,b)}_setWindowSize(f){q.setWindowSize(this,f);}assertValidity(){L(this);}equals(f){S(f);const{ex:b,ey:E,ez:B}=this,{ex:C,ey:A,ez:U}=f,_=c(b*U),T=c(C*B),$=c(E*U),R=c(A*B);return _===T&&$===R}is0(){return this.equals(d.ZERO)}negate(){return new d(c(-this.ex),this.ey,this.ez,c(-this.et))}double(){const{a:f}=e,{ex:b,ey:E,ez:B}=this,C=c(b*b),A=c(E*E),U=c(yt$3*c(B*B)),_=c(f*C),T=b+E,$=c(c(T*T)-C-A),R=_+A,V=R-U,Y=_-A,Z=c($*V),X=c(R*Y),et=c($*Y),pt=c(V*R);return new d(Z,X,pt,et)}add(f){S(f);const{a:b,d:E}=e,{ex:B,ey:C,ez:A,et:U}=this,{ex:_,ey:T,ez:$,et:R}=f;if(b===BigInt(-1)){const re=c((C-B)*(T+_)),oe=c((C+B)*(T-_)),mt=c(oe-re);if(mt===G$4)return this.double();const se=c(A*yt$3*R),ie=c(U*yt$3*$),ue=ie+se,ce=oe+re,ae=ie-se,Dn=c(ue*mt),dn=c(ce*ae),hn=c(ue*ae),ln=c(mt*ce);return new d(Dn,dn,ln,hn)}const V=c(B*_),Y=c(C*T),Z=c(U*E*R),X=c(A*$),et=c((B+C)*(_+T)-V-Y),pt=X-Z,ee=X+Z,ne=c(Y-b*V),un=c(et*pt),cn=c(ee*ne),an=c(et*ne),fn=c(pt*ee);return new d(un,cn,fn,an)}subtract(f){return this.add(f.negate())}wNAF(f){return q.wNAFCached(this,f,d.normalizeZ)}multiply(f){const b=f;ft$3("scalar",b,j$4,r);const{p:E,f:B}=this.wNAF(b);return d.normalizeZ([E,B])[0]}multiplyUnsafe(f,b=d.ZERO){const E=f;return ft$3("scalar",E,G$4,r),E===G$4?F:this.is0()||E===j$4?this:q.wNAFCachedUnsafe(this,E,d.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return q.unsafeLadder(this,r).is0()}toAffine(f){return v(this,f)}clearCofactor(){const{h:f}=e;return f===j$4?this:this.multiplyUnsafe(f)}static fromHex(f,b=false){const{d:E,a:B}=e,C=n.BYTES;f=W$4("pointHex",f,C),Tt$3("zip215",b);const A=f.slice(),U=f[C-1];A[C-1]=U&-129;const _=Et$4(A),T=b?D:n.ORDER;ft$3("pointHex.y",_,G$4,T);const $=c(_*_),R=c($-j$4),V=c(E*$-B);let{isValid:Y,value:Z}=p(R,V);if(!Y)throw new Error("Point.fromHex: invalid y coordinate");const X=(Z&j$4)===j$4,et=(U&128)!==0;if(!b&&Z===G$4&&et)throw new Error("Point.fromHex: x=0 and x_0=1");return et!==X&&(Z=c(-Z)),d.fromAffine({x:Z,y:_})}static fromPrivateKey(f){return O(f).point}toRawBytes(){const{x:f,y:b}=this.toAffine(),E=Nt$3(b,n.BYTES);return E[E.length-1]|=f&j$4?128:0,E}toHex(){return Ft$3(this.toRawBytes())}}d.BASE=new d(e.Gx,e.Gy,j$4,c(e.Gx*e.Gy)),d.ZERO=new d(G$4,j$4,j$4,G$4);const{BASE:m,ZERO:F}=d,q=lr$2(d,u*8);function z(y){return H$2(y,r)}function I(y){return z(Et$4(y))}function O(y){const f=n.BYTES;y=W$4("private key",y,f);const b=W$4("hashed private key",s(y),2*f),E=w(b.slice(0,f)),B=b.slice(f,2*f),C=I(E),A=m.multiply(C),U=A.toRawBytes();return {head:E,prefix:B,scalar:C,point:A,pointBytes:U}}function ot(y){return O(y).pointBytes}function tt(y=new Uint8Array,...f){const b=ye$4(...f);return I(s(h(b,W$4("context",y),!!o)))}function st(y,f,b={}){y=W$4("message",y),o&&(y=o(y));const{prefix:E,scalar:B,pointBytes:C}=O(f),A=tt(b.context,E,y),U=m.multiply(A).toRawBytes(),_=tt(b.context,U,C,y),T=z(A+_*B);ft$3("signature.s",T,G$4,r);const $=ye$4(U,Nt$3(T,n.BYTES));return W$4("result",$,n.BYTES*2)}const at=Er$1;function Ct(y,f,b,E=at){const{context:B,zip215:C}=E,A=n.BYTES;y=W$4("signature",y,2*A),f=W$4("message",f),b=W$4("publicKey",b,A),C!==void 0&&Tt$3("zip215",C),o&&(f=o(f));const U=Et$4(y.slice(A,2*A));let _,T,$;try{_=d.fromHex(b,C),T=d.fromHex(y.slice(0,A),C),$=m.multiplyUnsafe(U);}catch{return false}if(!C&&_.isSmallOrder())return false;const R=tt(B,T.toRawBytes(),_.toRawBytes(),f);return T.add(_.multiplyUnsafe(R)).subtract($).clearCofactor().equals(d.ZERO)}return m._setWindowSize(8),{CURVE:e,getPublicKey:ot,sign:st,verify:Ct,ExtendedPoint:d,utils:{getExtendedPublicKey:O,randomPrivateKey:()=>a(n.BYTES),precompute(y=8,f=d.BASE){return f._setWindowSize(y),f.multiply(BigInt(3)),f}}}}BigInt(0),BigInt(1);const kt$3=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ue$4=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const xr$1=BigInt(1),Te$3=BigInt(2);BigInt(3);const Br$2=BigInt(5),Cr$2=BigInt(8);function Ar$2(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=kt$3,u=t*t%s*t%s,i=J$4(u,Te$3,s)*u%s,D=J$4(i,xr$1,s)*t%s,c=J$4(D,Br$2,s)*D%s,l=J$4(c,e,s)*c%s,p=J$4(l,n,s)*l%s,w=J$4(p,r,s)*p%s,h=J$4(w,o,s)*w%s,g=J$4(h,o,s)*w%s,S=J$4(g,e,s)*c%s;return {pow_p_5_8:J$4(S,Te$3,s)*t%s,b2:u}}function mr$2(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function _r$2(t,e){const n=kt$3,r=H$2(e*e*e,n),o=H$2(r*r*e,n),s=Ar$2(t*o).pow_p_5_8;let a=H$2(t*r*s,n);const u=H$2(e*a*a,n),i=a,D=H$2(a*Ue$4,n),c=u===t,l=u===H$2(-t,n),p=u===H$2(-t*Ue$4,n);return c&&(a=i),(l||p)&&(a=D),ur$2(a,n)&&(a=H$2(-a,n)),{isValid:c||l,value:a}}const Sr$2=(()=>_e$4(kt$3,void 0,true))(),vr$1=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Sr$2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Cr$2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Kn$2,randomBytes:he$4,adjustScalarBytes:mr$2,uvRatio:_r$2}))(),Rt$4=(()=>yr$2(vr$1))(),jt$3="EdDSA",Zt$3="JWT",ut$3=".",Dt$2="base64url",Gt$3="utf8",xt$3="utf8",Vt$3=":",Yt$2="did",Jt$3="key",dt$3="base58btc",Kt$3="z",Wt$3="K36",Ne$1=32;function Xt$3(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Le$3(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Xt$3(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Oe$4(t,e){e||(e=t.reduce((o,s)=>o+s.length,0));const n=Le$3(e);let r=0;for(const o of t)n.set(o,r),r+=o.length;return Xt$3(n)}function Ir$2(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");n[a]=o;}var u=t.length,i=t.charAt(0),D=Math.log(u)/Math.log(256),c=Math.log(256)/Math.log(u);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return "";for(var g=0,S=0,v=0,L=h.length;v!==L&&h[v]===0;)v++,g++;for(var d=(L-v)*c+1>>>0,m=new Uint8Array(d);v!==L;){for(var F=h[v],q=0,z=d-1;(F!==0||q<S)&&z!==-1;z--,q++)F+=256*m[z]>>>0,m[z]=F%u>>>0,F=F/u>>>0;if(F!==0)throw new Error("Non-zero carry");S=q,v++;}for(var I=d-S;I!==d&&m[I]===0;)I++;for(var O=i.repeat(g);I<d;++I)O+=t.charAt(m[I]);return O}function p(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var S=0,v=0;h[g]===i;)S++,g++;for(var L=(h.length-g)*D+1>>>0,d=new Uint8Array(L);h[g];){var m=n[h.charCodeAt(g)];if(m===255)return;for(var F=0,q=L-1;(m!==0||F<v)&&q!==-1;q--,F++)m+=u*d[q]>>>0,d[q]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");v=F,g++;}if(h[g]!==" "){for(var z=L-v;z!==L&&d[z]===0;)z++;for(var I=new Uint8Array(S+(L-z)),O=S;z!==L;)I[O++]=d[z++];return I}}}function w(h){var g=p(h);if(g)return g;throw new Error(`Non-${e} character`)}return {encode:l,decodeUnsafe:p,decode:w}}var Ur$2=Ir$2,Tr$2=Ur$2;const He$3=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Fr$2=t=>new TextEncoder().encode(t),Nr$2=t=>new TextDecoder().decode(t);let Lr$2 = class Lr{constructor(e,n,r){this.name=e,this.prefix=n,this.baseEncode=r;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};let Or$2 = class Or{constructor(e,n,r){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ze$2(this,e)}};let Hr$2 = class Hr{constructor(e){this.decoders=e;}or(e){return ze$2(this,e)}decode(e){const n=e[0],r=this.decoders[n];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const ze$2=(t,e)=>new Hr$2({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let zr$2 = class zr{constructor(e,n,r,o){this.name=e,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new Lr$2(e,n,r),this.decoder=new Or$2(e,n,o);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Bt$3=({name:t,prefix:e,encode:n,decode:r})=>new zr$2(t,e,n,r),ht$2=({prefix:t,name:e,alphabet:n})=>{const{encode:r,decode:o}=Tr$2(n,e);return Bt$3({prefix:t,name:e,encode:r,decode:s=>He$3(o(s))})},Mr$2=(t,e,n,r)=>{const o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;const a=new Uint8Array(s*n/8|0);let u=0,i=0,D=0;for(let c=0;c<s;++c){const l=o[t[c]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);i=i<<n|l,u+=n,u>=8&&(u-=8,a[D++]=255&i>>u);}if(u>=n||255&i<<8-u)throw new SyntaxError("Unexpected end of data");return a},qr$2=(t,e,n)=>{const r=e[e.length-1]==="=",o=(1<<n)-1;let s="",a=0,u=0;for(let i=0;i<t.length;++i)for(u=u<<8|t[i],a+=8;a>n;)a-=n,s+=e[o&u>>a];if(a&&(s+=e[o&u<<n-a]),r)for(;s.length*n&7;)s+="=";return s},k$1=({name:t,prefix:e,bitsPerChar:n,alphabet:r})=>Bt$3({prefix:e,name:t,encode(o){return qr$2(o,r,n)},decode(o){return Mr$2(o,r,n,t)}}),$r$2=Bt$3({prefix:"\0",name:"identity",encode:t=>Nr$2(t),decode:t=>Fr$2(t)});var kr$2=Object.freeze({__proto__:null,identity:$r$2});const Rr$2=k$1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jr$2=Object.freeze({__proto__:null,base2:Rr$2});const Zr$2=k$1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gr$2=Object.freeze({__proto__:null,base8:Zr$2});const Vr$2=ht$2({prefix:"9",name:"base10",alphabet:"0123456789"});var Yr$2=Object.freeze({__proto__:null,base10:Vr$2});const Jr$2=k$1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kr$2=k$1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wr$2=Object.freeze({__proto__:null,base16:Jr$2,base16upper:Kr$2});const Xr$2=k$1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Pr$2=k$1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qr$2=k$1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),to$2=k$1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eo$2=k$1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),no$1=k$1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ro$1=k$1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oo$1=k$1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),so$2=k$1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var io$2=Object.freeze({__proto__:null,base32:Xr$2,base32upper:Pr$2,base32pad:Qr$2,base32padupper:to$2,base32hex:eo$2,base32hexupper:no$1,base32hexpad:ro$1,base32hexpadupper:oo$1,base32z:so$2});const uo$1=ht$2({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),co$2=ht$2({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ao$2=Object.freeze({__proto__:null,base36:uo$1,base36upper:co$2});const fo$1=ht$2({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Do$2=ht$2({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ho$2=Object.freeze({__proto__:null,base58btc:fo$1,base58flickr:Do$2});const lo$2=k$1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bo$2=k$1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),po$2=k$1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo$2=k$1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Eo$2=Object.freeze({__proto__:null,base64:lo$2,base64pad:bo$2,base64url:po$2,base64urlpad:wo$2});const Me$5=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),go$2=Me$5.reduce((t,e,n)=>(t[n]=e,t),[]),yo$2=Me$5.reduce((t,e,n)=>(t[e.codePointAt(0)]=n,t),[]);function xo$2(t){return t.reduce((e,n)=>(e+=go$2[n],e),"")}function Bo$2(t){const e=[];for(const n of t){const r=yo$2[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);e.push(r);}return new Uint8Array(e)}const Co$2=Bt$3({prefix:"\u{1F680}",name:"base256emoji",encode:xo$2,decode:Bo$2});var Ao$2=Object.freeze({__proto__:null,base256emoji:Co$2}),mo$2=$e$3,qe$2=128,So$2=-128,vo$2=Math.pow(2,31);function $e$3(t,e,n){e=e||[],n=n||0;for(var r=n;t>=vo$2;)e[n++]=t&255|qe$2,t/=128;for(;t&So$2;)e[n++]=t&255|qe$2,t>>>=7;return e[n]=t|0,$e$3.bytes=n-r+1,e}var Io$2=Pt$3,Uo$2=128,ke$4=127;function Pt$3(t,r){var n=0,r=r||0,o=0,s=r,a,u=t.length;do{if(s>=u)throw Pt$3.bytes=0,new RangeError("Could not decode varint");a=t[s++],n+=o<28?(a&ke$4)<<o:(a&ke$4)*Math.pow(2,o),o+=7;}while(a>=Uo$2);return Pt$3.bytes=s-r,n}var To$2=Math.pow(2,7),Fo$2=Math.pow(2,14),No$2=Math.pow(2,21),Lo$2=Math.pow(2,28),Oo$2=Math.pow(2,35),Ho$2=Math.pow(2,42),zo$2=Math.pow(2,49),Mo$2=Math.pow(2,56),qo$2=Math.pow(2,63),$o$2=function(t){return t<To$2?1:t<Fo$2?2:t<No$2?3:t<Lo$2?4:t<Oo$2?5:t<Ho$2?6:t<zo$2?7:t<Mo$2?8:t<qo$2?9:10},ko$2={encode:mo$2,decode:Io$2,encodingLength:$o$2},Re$1=ko$2;const je$2=(t,e,n=0)=>(Re$1.encode(t,e,n),e),Ze$3=t=>Re$1.encodingLength(t),Qt$3=(t,e)=>{const n=e.byteLength,r=Ze$3(t),o=r+Ze$3(n),s=new Uint8Array(o+n);return je$2(t,s,0),je$2(n,s,r),s.set(e,o),new Ro$2(t,n,e,s)};let Ro$2 = class Ro{constructor(e,n,r,o){this.code=e,this.size=n,this.digest=r,this.bytes=o;}};const Ge$3=({name:t,code:e,encode:n})=>new jo$2(t,e,n);let jo$2 = class jo{constructor(e,n,r){this.name=e,this.code=n,this.encode=r;}digest(e){if(e instanceof Uint8Array){const n=this.encode(e);return n instanceof Uint8Array?Qt$3(this.code,n):n.then(r=>Qt$3(this.code,r))}else throw Error("Unknown type, must be binary type")}};const Ve$4=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Zo$2=Ge$3({name:"sha2-256",code:18,encode:Ve$4("SHA-256")}),Go$2=Ge$3({name:"sha2-512",code:19,encode:Ve$4("SHA-512")});var Vo$2=Object.freeze({__proto__:null,sha256:Zo$2,sha512:Go$2});const Ye$3=0,Yo$2="identity",Je$3=He$3,Jo$2=t=>Qt$3(Ye$3,Je$3(t)),Ko$2={code:Ye$3,name:Yo$2,encode:Je$3,digest:Jo$2};var Wo$2=Object.freeze({__proto__:null,identity:Ko$2});new TextEncoder,new TextDecoder;const Ke$4={...kr$2,...jr$2,...Gr$2,...Yr$2,...Wr$2,...io$2,...ao$2,...ho$2,...Eo$2,...Ao$2};({...Vo$2,...Wo$2});function We$4(t,e,n,r){return {name:t,prefix:e,encoder:{name:t,prefix:e,encode:n},decoder:{decode:r}}}const Xe$2=We$4("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),te$3=We$4("ascii","a",t=>{let e="a";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e},t=>{t=t.substring(1);const e=Le$3(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}),Pe$4={utf8:Xe$2,"utf-8":Xe$2,hex:Ke$4.base16,latin1:te$3,ascii:te$3,binary:te$3,...Ke$4};function ct$2(t,e="utf8"){const n=Pe$4[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):n.encoder.encode(t).substring(1)}function rt$2(t,e="utf8"){const n=Pe$4[e];if(!n)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Xt$3(globalThis.Buffer.from(t,"utf-8")):n.decoder.decode(`${n.prefix}${t}`)}function lt$2(t){return safeJsonParse(ct$2(rt$2(t,Dt$2),Gt$3))}function bt$2(t){return ct$2(rt$2(safeJsonStringify(t),Gt$3),Dt$2)}function Qe$2(t){const e=rt$2(Wt$3,dt$3),n=Kt$3+ct$2(Oe$4([e,t]),dt$3);return [Yt$2,Jt$3,n].join(Vt$3)}function en$2(t){return ct$2(t,Dt$2)}function nn(t){return rt$2(t,Dt$2)}function rn$2(t){return rt$2([bt$2(t.header),bt$2(t.payload)].join(ut$3),xt$3)}function on$2(t){return [bt$2(t.header),bt$2(t.payload),en$2(t.signature)].join(ut$3)}function sn$1(t){const e=t.split(ut$3),n=lt$2(e[0]),r=lt$2(e[1]),o=nn(e[2]),s=rt$2(e.slice(0,2).join(ut$3),xt$3);return {header:n,payload:r,signature:o,data:s}}function Po$2(t=he$4(Ne$1)){const e=Rt$4.getPublicKey(t);return {secretKey:Oe$4([t,e]),publicKey:e}}async function Qo$2(t,e,n,r,o=cjsExports$3.fromMiliseconds(Date.now())){const s={alg:jt$3,typ:Zt$3},a=Qe$2(r.publicKey),u=o+n,i={iss:a,sub:t,aud:e,iat:o,exp:u},D=rn$2({header:s,payload:i}),c=Rt$4.sign(D,r.secretKey.slice(0,32));return on$2({header:s,payload:i,signature:c})}
|
|
21691
22974
|
|
|
21692
22975
|
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
21693
22976
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
@@ -26068,6 +27351,11 @@ function base$1 (ALPHABET) {
|
|
|
26068
27351
|
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
26069
27352
|
var bs58 = base$1(ALPHABET);
|
|
26070
27353
|
|
|
27354
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
27355
|
+
__proto__: null,
|
|
27356
|
+
default: bs58
|
|
27357
|
+
});
|
|
27358
|
+
|
|
26071
27359
|
function utf8Count(str) {
|
|
26072
27360
|
const strLength = str.length;
|
|
26073
27361
|
let byteLength = 0;
|
|
@@ -29772,7 +31060,7 @@ const i=1e3*1024;var C$2=Object.defineProperty,B$2=(r,e,t)=>e in r?C$2(r,e,{enum
|
|
|
29772
31060
|
const Ae$2=":";function Je$2(t){const[e,n]=t.split(Ae$2);return {namespace:e,reference:n}}function Ie$1(t,e){return t.includes(":")?[t]:e.chains||[]}var ei$1=Object.defineProperty,ni$1=Object.defineProperties,ri$1=Object.getOwnPropertyDescriptors,ar$1=Object.getOwnPropertySymbols,oi$1=Object.prototype.hasOwnProperty,si$1=Object.prototype.propertyIsEnumerable,en$1=(t,e,n)=>e in t?ei$1(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,ur$1=(t,e)=>{for(var n in e||(e={}))oi$1.call(e,n)&&en$1(t,n,e[n]);if(ar$1)for(var n of ar$1(e))si$1.call(e,n)&&en$1(t,n,e[n]);return t},ii$1=(t,e)=>ni$1(t,ri$1(e)),lr$1=(t,e,n)=>en$1(t,typeof e!="symbol"?e+"":e,n);const dr$1="ReactNative",et$2={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},pr$1="js";function rn$1(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function At$2(){return !cjsExports$2.getDocument()&&!!cjsExports$2.getNavigator()&&navigator.product===dr$1}function ai$1(){return At$2()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function ui$1(){return At$2()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Wt$2(){return !rn$1()&&!!cjsExports$2.getNavigator()&&!!cjsExports$2.getDocument()}function Vt$2(){return At$2()?et$2.reactNative:rn$1()?et$2.node:Wt$2()?et$2.browser:et$2.unknown}function li$1(){var t;try{return At$2()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function gr$1(t,e){const n=new URLSearchParams(t);return Object.entries(e).sort(([r],[o])=>r.localeCompare(o)).forEach(([r,o])=>{o!=null&&n.set(r,String(o));}),n.toString()}function di$1(t){var e,n;const r=br$1();try{return t!=null&&t.url&&r.url&&new URL(t.url).host!==new URL(r.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),t.url=r.url),(e=t?.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(o=>o!=="")),ii$1(ur$1(ur$1({},r),t),{url:t?.url||r.url,name:t?.name||r.name,description:t?.description||r.description,icons:(n=t?.icons)!=null&&n.length&&t.icons.length>0?t.icons:r.icons})}catch(o){return console.warn("Error populating app metadata",o),t||r}}function br$1(){return cjsExports$1.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function yr$1(){if(Vt$2()===et$2.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:n,Version:r}=global.Platform;return [n,r].join("-")}const t=detect();if(t===null)return "unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function mr$1(){var t;const e=Vt$2();return e===et$2.browser?[e,((t=cjsExports$2.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function wr$1(t,e,n){const r=yr$1(),o=mr$1();return [[t,e].join("-"),[pr$1,n].join("-"),r,o].join("/")}function pi$1({protocol:t,version:e,relayUrl:n,sdkVersion:r,auth:o,projectId:s,useOnCloseEvent:i,bundleId:c,packageName:f}){const u=n.split("?"),a=wr$1(t,e,r),l={auth:o,ua:a,projectId:s,useOnCloseEvent:i,packageName:f||void 0,bundleId:c||void 0},d=gr$1(u[1]||"",l);return u[0]+"?"+d}function It$3(t,e){return t.filter(n=>e.includes(n)).length===t.length}function mi$1(t){return Object.fromEntries(t.entries())}function wi$1(t){return new Map(Object.entries(t))}function Bi$1(t=cjsExports$3.FIVE_MINUTES,e){const n=cjsExports$3.toMiliseconds(t||cjsExports$3.FIVE_MINUTES);let r,o,s,i;return {resolve:c=>{s&&r&&(clearTimeout(s),r(c),i=Promise.resolve(c));},reject:c=>{s&&o&&(clearTimeout(s),o(c));},done:()=>new Promise((c,f)=>{if(i)return c(i);s=setTimeout(()=>{const u=new Error(e);i=Promise.reject(u),f(u);},n),r=c,o=f;})}}function Ai$1(t,e,n){return new Promise(async(r,o)=>{const s=setTimeout(()=>o(new Error(n)),e);try{const i=await t;r(i);}catch(i){o(i);}clearTimeout(s);})}function on$1(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return `topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return `id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function Ii$1(t){return on$1("topic",t)}function Si$1(t){return on$1("id",t)}function Oi$1(t){const[e,n]=t.split(":"),r={id:void 0,topic:void 0};if(e==="topic"&&typeof n=="string")r.topic=n;else if(e==="id"&&Number.isInteger(Number(n)))r.id=Number(n);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${n}`);return r}function Ni$1(t,e){return cjsExports$3.fromMiliseconds((Date.now())+cjsExports$3.toMiliseconds(t))}function Ui$1(t){return Date.now()>=cjsExports$3.toMiliseconds(t)}function _i$1(t,e){return `${t}${e?`:${e}`:""}`}function ut$2(t=[],e=[]){return [...new Set([...t,...e])]}async function Ri$1({id:t,topic:e,wcDeepLink:n}){var r;try{if(!n)return;const o=typeof n=="string"?JSON.parse(n):n,s=o?.href;if(typeof s!="string")return;const i=Br$1(s,t,e),c=Vt$2();if(c===et$2.browser){if(!((r=cjsExports$2.getDocument())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Ar$1(i);}else c===et$2.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(i);}catch(o){console.error(o);}}function Br$1(t,e,n){const r=`requestId=${e}&sessionTopic=${n}`;t.endsWith("/")&&(t=t.slice(0,-1));let o=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";o=`${o}${s}${Or$1(r,true)}`;}else o=`${o}/wc?${r}`;return o}function Ar$1(t){let e="_self";Sr$1()?e="_top":(Ir$1()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener");}async function $i$1(t,e){let n="";try{if(Wt$2()&&(n=localStorage.getItem(e),n))return n;n=await t.getItem(e);}catch(r){console.error(r);}return n}function Ti$1(t,e){if(!t.includes(e))return null;const n=t.split(/([&,?,=])/),r=n.indexOf(e);return n[r+2]}function Ci$1(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return (t==="x"?e:e&3|8).toString(16)})}function ji$1(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function Ir$1(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Sr$1(){try{return window.self!==window.top}catch{return false}}function Or$1(t,e=false){const n=Buffer.from(t).toString("base64");return e?n.replace(/[=]/g,""):n}function cn$1(t){return Buffer.from(t,"base64").toString("utf-8")}function Li$1(t){return new Promise(e=>setTimeout(e,t))}let ki$1 = class ki{constructor({limit:e}){lr$1(this,"limit"),lr$1(this,"set"),this.limit=e,this.set=new Set;}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const n=this.set.values().next().value;n&&this.set.delete(n);}this.set.add(e);}}has(e){return this.set.has(e)}};const Oe$3=BigInt(2**32-1),Nr$1=BigInt(32);function Ur$1(t,e=false){return e?{h:Number(t&Oe$3),l:Number(t>>Nr$1&Oe$3)}:{h:Number(t>>Nr$1&Oe$3)|0,l:Number(t&Oe$3)|0}}function _r$1(t,e=false){const n=t.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:i,l:c}=Ur$1(t[s],e);[r[s],o[s]]=[i,c];}return [r,o]}const Rr$1=(t,e,n)=>t>>>n,$r$1=(t,e,n)=>t<<32-n|e>>>n,St$3=(t,e,n)=>t>>>n|e<<32-n,Ot$2=(t,e,n)=>t<<32-n|e>>>n,de$2=(t,e,n)=>t<<64-n|e>>>n-32,he$3=(t,e,n)=>t>>>n-32|e<<64-n,Pi$1=(t,e)=>e,Hi$1=(t,e)=>t,Di$1=(t,e,n)=>t<<n|e>>>32-n,Vi$1=(t,e,n)=>e<<n|t>>>32-n,Mi$1=(t,e,n)=>e<<n-32|t>>>64-n,Ki$1=(t,e,n)=>t<<n-32|e>>>64-n;function dt$2(t,e,n,r){const o=(e>>>0)+(r>>>0);return {h:t+n+(o/2**32|0)|0,l:o|0}}const fn$1=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),an$1=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,qi$1=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Fi$1=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,Zi=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),Gi$1=(t,e,n,r,o,s)=>e+n+r+o+s+(t/2**32|0)|0,Xt$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ne(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function mt$2(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ht$1(t,...e){if(!Ne(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ue$3(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");mt$2(t.outputLen),mt$2(t.blockLen);}function Nt$2(t,e=true){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function un$1(t,e){ht$1(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function pe$3(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function lt$1(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function ln$1(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function bt$1(t,e){return t<<32-e|t>>>e}const Tr$1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Cr$1(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const wt$2=Tr$1?t=>t:t=>Cr$1(t);function zi$1(t){for(let e=0;e<t.length;e++)t[e]=Cr$1(t[e]);return t}const Ut$2=Tr$1?t=>t:zi$1,jr$1=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Yi=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Jt$2(t){if(ht$1(t),jr$1)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Yi[t[n]];return e}const vt$2={_0:48,_9:57,A:65,F:70,a:97,f:102};function Lr$1(t){if(t>=vt$2._0&&t<=vt$2._9)return t-vt$2._0;if(t>=vt$2.A&&t<=vt$2.F)return t-(vt$2.A-10);if(t>=vt$2.a&&t<=vt$2.f)return t-(vt$2.a-10)}function _e$3(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(jr$1)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=Lr$1(t.charCodeAt(s)),c=Lr$1(t.charCodeAt(s+1));if(i===void 0||c===void 0){const f=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}r[o]=i*16+c;}return r}function kr$1(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function pt$1(t){return typeof t=="string"&&(t=kr$1(t)),ht$1(t),t}function _t$2(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];ht$1(o),e+=o.length;}const n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){const s=t[r];n.set(s,o),o+=s.length;}return n}class Re{}function ge$3(t){const e=r=>t().update(pt$1(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Wi$1(t){const e=(r,o)=>t(o).update(pt$1(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}function Mt$2(t=32){if(Xt$2&&typeof Xt$2.getRandomValues=="function")return Xt$2.getRandomValues(new Uint8Array(t));if(Xt$2&&typeof Xt$2.randomBytes=="function")return Uint8Array.from(Xt$2.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const Xi=BigInt(0),be$3=BigInt(1),Ji=BigInt(2),Qi=BigInt(7),tc=BigInt(256),ec=BigInt(113),Pr$1=[],Hr$1=[],Dr$1=[];for(let t=0,e=be$3,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Pr$1.push(2*(5*r+n)),Hr$1.push((t+1)*(t+2)/2%64);let o=Xi;for(let s=0;s<7;s++)e=(e<<be$3^(e>>Qi)*ec)%tc,e&Ji&&(o^=be$3<<(be$3<<BigInt(s))-be$3);Dr$1.push(o);}const Vr$1=_r$1(Dr$1,true),nc=Vr$1[0],rc=Vr$1[1],Mr$1=(t,e,n)=>n>32?Mi$1(t,e,n):Di$1(t,e,n),Kr$1=(t,e,n)=>n>32?Ki$1(t,e,n):Vi$1(t,e,n);function oc(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let i=0;i<10;i++)n[i]=t[i]^t[i+10]^t[i+20]^t[i+30]^t[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,f=(i+2)%10,u=n[f],a=n[f+1],l=Mr$1(u,a,1)^n[c],d=Kr$1(u,a,1)^n[c+1];for(let h=0;h<50;h+=10)t[i+h]^=l,t[i+h+1]^=d;}let o=t[2],s=t[3];for(let i=0;i<24;i++){const c=Hr$1[i],f=Mr$1(o,s,c),u=Kr$1(o,s,c),a=Pr$1[i];o=t[a],s=t[a+1],t[a]=f,t[a+1]=u;}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=t[i+c];for(let c=0;c<10;c++)t[i+c]^=~n[(c+2)%10]&n[(c+4)%10];}t[0]^=nc[r],t[1]^=rc[r];}lt$1(n);}let Jn$1 = class Jn extends Re{constructor(e,n,r,o=false,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=false,this.destroyed=false,this.enableXOF=false,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,mt$2(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pe$3(this.state);}clone(){return this._cloneInto()}keccak(){Ut$2(this.state32),oc(this.state32,this.rounds),Ut$2(this.state32),this.posOut=0,this.pos=0;}update(e){Nt$2(this),e=pt$1(e),ht$1(e);const{blockLen:n,state:r}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);for(let c=0;c<i;c++)r[this.pos++]^=e[s++];this.pos===n&&this.keccak();}return this}finish(){if(this.finished)return;this.finished=true;const{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak();}writeInto(e){Nt$2(this,false),ht$1(e),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,s=e.length;o<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-o);e.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i;}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return mt$2(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(un$1(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=true,lt$1(this.state);}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return e||(e=new Jn(n,r,o,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}};const sc=(t,e,n)=>ge$3(()=>new Jn$1(e,t,n)),ic=sc(1,136,256/8);function cc(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),f=r?4:0,u=r?0:4;t.setUint32(e+f,i,r),t.setUint32(e+u,c,r);}function fc(t,e,n){return t&e^~t&n}function ac(t,e,n){return t&e^t&n^e&n}let qr$1 = class qr extends Re{constructor(e,n,r,o){super(),this.finished=false,this.length=0,this.pos=0,this.destroyed=false,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ln$1(this.buffer);}update(e){Nt$2(this),e=pt$1(e),ht$1(e);const{view:n,buffer:r,blockLen:o}=this,s=e.length;for(let i=0;i<s;){const c=Math.min(o-this.pos,s-i);if(c===o){const f=ln$1(e);for(;o<=s-i;i+=o)this.process(f,i);continue}r.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(n,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){Nt$2(this),un$1(e,this),this.finished=true;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,lt$1(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let l=i;l<o;l++)n[l]=0;cc(r,o-8,BigInt(this.length*8),s),this.process(r,0);const c=ln$1(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=f/4,a=this.get();if(u>a.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,a[l],s);}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}};const Rt$3=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),X$2=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),J$3=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),uc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$t$2=new Uint32Array(64);class lc extends qr$1{constructor(e=32){super(64,e,8,false),this.A=Rt$3[0]|0,this.B=Rt$3[1]|0,this.C=Rt$3[2]|0,this.D=Rt$3[3]|0,this.E=Rt$3[4]|0,this.F=Rt$3[5]|0,this.G=Rt$3[6]|0,this.H=Rt$3[7]|0;}get(){const{A:e,B:n,C:r,D:o,E:s,F:i,G:c,H:f}=this;return [e,n,r,o,s,i,c,f]}set(e,n,r,o,s,i,c,f){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0;}process(e,n){for(let l=0;l<16;l++,n+=4)$t$2[l]=e.getUint32(n,false);for(let l=16;l<64;l++){const d=$t$2[l-15],h=$t$2[l-2],y=bt$1(d,7)^bt$1(d,18)^d>>>3,m=bt$1(h,17)^bt$1(h,19)^h>>>10;$t$2[l]=m+$t$2[l-7]+y+$t$2[l-16]|0;}let{A:r,B:o,C:s,D:i,E:c,F:f,G:u,H:a}=this;for(let l=0;l<64;l++){const d=bt$1(c,6)^bt$1(c,11)^bt$1(c,25),h=a+d+fc(c,f,u)+uc[l]+$t$2[l]|0,m=(bt$1(r,2)^bt$1(r,13)^bt$1(r,22))+ac(r,o,s)|0;a=u,u=f,f=c,c=i+h|0,i=s,s=o,o=r,r=h+m|0;}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,u=u+this.G|0,a=a+this.H|0,this.set(r,o,s,i,c,f,u,a);}roundClean(){lt$1($t$2);}destroy(){this.set(0,0,0,0,0,0,0,0),lt$1(this.buffer);}}const Fr$1=_r$1(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),dc=Fr$1[0],hc=Fr$1[1],Tt$2=new Uint32Array(80),Ct$2=new Uint32Array(80);let dn$1 = class dn extends qr$1{constructor(e=64){super(128,e,16,false),this.Ah=J$3[0]|0,this.Al=J$3[1]|0,this.Bh=J$3[2]|0,this.Bl=J$3[3]|0,this.Ch=J$3[4]|0,this.Cl=J$3[5]|0,this.Dh=J$3[6]|0,this.Dl=J$3[7]|0,this.Eh=J$3[8]|0,this.El=J$3[9]|0,this.Fh=J$3[10]|0,this.Fl=J$3[11]|0,this.Gh=J$3[12]|0,this.Gl=J$3[13]|0,this.Hh=J$3[14]|0,this.Hl=J$3[15]|0;}get(){const{Ah:e,Al:n,Bh:r,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:u,El:a,Fh:l,Fl:d,Gh:h,Gl:y,Hh:m,Hl:v}=this;return [e,n,r,o,s,i,c,f,u,a,l,d,h,y,m,v]}set(e,n,r,o,s,i,c,f,u,a,l,d,h,y,m,v){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=u|0,this.El=a|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=y|0,this.Hh=m|0,this.Hl=v|0;}process(e,n){for(let R=0;R<16;R++,n+=4)Tt$2[R]=e.getUint32(n),Ct$2[R]=e.getUint32(n+=4);for(let R=16;R<80;R++){const Z=Tt$2[R-15]|0,H=Ct$2[R-15]|0,j=St$3(Z,H,1)^St$3(Z,H,8)^Rr$1(Z,H,7),L=Ot$2(Z,H,1)^Ot$2(Z,H,8)^$r$1(Z,H,7),k=Tt$2[R-2]|0,O=Ct$2[R-2]|0,T=St$3(k,O,19)^de$2(k,O,61)^Rr$1(k,O,6),C=Ot$2(k,O,19)^he$3(k,O,61)^$r$1(k,O,6),_=qi$1(L,C,Ct$2[R-7],Ct$2[R-16]),p=Fi$1(_,j,T,Tt$2[R-7],Tt$2[R-16]);Tt$2[R]=p|0,Ct$2[R]=_|0;}let{Ah:r,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:u,Dl:a,Eh:l,El:d,Fh:h,Fl:y,Gh:m,Gl:v,Hh:U,Hl:F}=this;for(let R=0;R<80;R++){const Z=St$3(l,d,14)^St$3(l,d,18)^de$2(l,d,41),H=Ot$2(l,d,14)^Ot$2(l,d,18)^he$3(l,d,41),j=l&h^~l&m,L=d&y^~d&v,k=Zi(F,H,L,hc[R],Ct$2[R]),O=Gi$1(k,U,Z,j,dc[R],Tt$2[R]),T=k|0,C=St$3(r,o,28)^de$2(r,o,34)^de$2(r,o,39),_=Ot$2(r,o,28)^he$3(r,o,34)^he$3(r,o,39),p=r&s^r&c^s&c,b=o&i^o&f^i&f;U=m|0,F=v|0,m=h|0,v=y|0,h=l|0,y=d|0,{h:l,l:d}=dt$2(u|0,a|0,O|0,T|0),u=c|0,a=f|0,c=s|0,f=i|0,s=r|0,i=o|0;const g=fn$1(T,_,b);r=an$1(g,O,C,p),o=g|0;}(({h:r,l:o}=dt$2(this.Ah|0,this.Al|0,r|0,o|0))),{h:s,l:i}=dt$2(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=dt$2(this.Ch|0,this.Cl|0,c|0,f|0),{h:u,l:a}=dt$2(this.Dh|0,this.Dl|0,u|0,a|0),{h:l,l:d}=dt$2(this.Eh|0,this.El|0,l|0,d|0),{h,l:y}=dt$2(this.Fh|0,this.Fl|0,h|0,y|0),{h:m,l:v}=dt$2(this.Gh|0,this.Gl|0,m|0,v|0),{h:U,l:F}=dt$2(this.Hh|0,this.Hl|0,U|0,F|0),this.set(r,o,s,i,c,f,u,a,l,d,h,y,m,v,U,F);}roundClean(){lt$1(Tt$2,Ct$2);}destroy(){lt$1(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}};class pc extends dn$1{constructor(){super(48),this.Ah=X$2[0]|0,this.Al=X$2[1]|0,this.Bh=X$2[2]|0,this.Bl=X$2[3]|0,this.Ch=X$2[4]|0,this.Cl=X$2[5]|0,this.Dh=X$2[6]|0,this.Dl=X$2[7]|0,this.Eh=X$2[8]|0,this.El=X$2[9]|0,this.Fh=X$2[10]|0,this.Fl=X$2[11]|0,this.Gh=X$2[12]|0,this.Gl=X$2[13]|0,this.Hh=X$2[14]|0,this.Hl=X$2[15]|0;}}const Q$1=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class gc extends dn$1{constructor(){super(32),this.Ah=Q$1[0]|0,this.Al=Q$1[1]|0,this.Bh=Q$1[2]|0,this.Bl=Q$1[3]|0,this.Ch=Q$1[4]|0,this.Cl=Q$1[5]|0,this.Dh=Q$1[6]|0,this.Dl=Q$1[7]|0,this.Eh=Q$1[8]|0,this.El=Q$1[9]|0,this.Fh=Q$1[10]|0,this.Fl=Q$1[11]|0,this.Gh=Q$1[12]|0,this.Gl=Q$1[13]|0,this.Hh=Q$1[14]|0,this.Hl=Q$1[15]|0;}}const $e$2=ge$3(()=>new lc),bc=ge$3(()=>new dn$1),yc=ge$3(()=>new pc),mc=ge$3(()=>new gc),wc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),z$3=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S$1=new Uint32Array(32);function jt$2(t,e,n,r,o,s){const i=o[s],c=o[s+1];let f=S$1[2*t],u=S$1[2*t+1],a=S$1[2*e],l=S$1[2*e+1],d=S$1[2*n],h=S$1[2*n+1],y=S$1[2*r],m=S$1[2*r+1],v=fn$1(f,a,i);u=an$1(v,u,l,c),f=v|0,{Dh:m,Dl:y}={Dh:m^u,Dl:y^f},{Dh:m,Dl:y}={Dh:Pi$1(m,y),Dl:Hi$1(m)},{h,l:d}=dt$2(h,d,m,y),{Bh:l,Bl:a}={Bh:l^h,Bl:a^d},{Bh:l,Bl:a}={Bh:St$3(l,a,24),Bl:Ot$2(l,a,24)},S$1[2*t]=f,S$1[2*t+1]=u,S$1[2*e]=a,S$1[2*e+1]=l,S$1[2*n]=d,S$1[2*n+1]=h,S$1[2*r]=y,S$1[2*r+1]=m;}function Lt$2(t,e,n,r,o,s){const i=o[s],c=o[s+1];let f=S$1[2*t],u=S$1[2*t+1],a=S$1[2*e],l=S$1[2*e+1],d=S$1[2*n],h=S$1[2*n+1],y=S$1[2*r],m=S$1[2*r+1],v=fn$1(f,a,i);u=an$1(v,u,l,c),f=v|0,{Dh:m,Dl:y}={Dh:m^u,Dl:y^f},{Dh:m,Dl:y}={Dh:St$3(m,y,16),Dl:Ot$2(m,y,16)},{h,l:d}=dt$2(h,d,m,y),{Bh:l,Bl:a}={Bh:l^h,Bl:a^d},{Bh:l,Bl:a}={Bh:de$2(l,a,63),Bl:he$3(l,a,63)},S$1[2*t]=f,S$1[2*t+1]=u,S$1[2*e]=a,S$1[2*e+1]=l,S$1[2*n]=d,S$1[2*n+1]=h,S$1[2*r]=y,S$1[2*r+1]=m;}function vc(t,e={},n,r,o){if(mt$2(n),t<0||t>n)throw new Error("outputLen bigger than keyLen");const{key:s,salt:i,personalization:c}=e;if(s!==void 0&&(s.length<1||s.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==o)throw new Error("personalization must be undefined or "+o)}class xc extends Re{constructor(e,n){super(),this.finished=false,this.destroyed=false,this.length=0,this.pos=0,mt$2(e),mt$2(n),this.blockLen=e,this.outputLen=n,this.buffer=new Uint8Array(e),this.buffer32=pe$3(this.buffer);}update(e){Nt$2(this),e=pt$1(e),ht$1(e);const{blockLen:n,buffer:r,buffer32:o}=this,s=e.length,i=e.byteOffset,c=e.buffer;for(let f=0;f<s;){this.pos===n&&(Ut$2(o),this.compress(o,0,false),Ut$2(o),this.pos=0);const u=Math.min(n-this.pos,s-f),a=i+f;if(u===n&&!(a%4)&&f+u<s){const l=new Uint32Array(c,a,Math.floor((s-f)/4));Ut$2(l);for(let d=0;f+n<s;d+=o.length,f+=n)this.length+=n,this.compress(l,d,false);Ut$2(l);continue}r.set(e.subarray(f,f+u),this.pos),this.pos+=u,this.length+=u,f+=u;}return this}digestInto(e){Nt$2(this),un$1(e,this);const{pos:n,buffer32:r}=this;this.finished=true,lt$1(this.buffer.subarray(n)),Ut$2(r),this.compress(r,0,true),Ut$2(r);const o=pe$3(e);this.get().forEach((s,i)=>o[i]=wt$2(s));}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){const{buffer:n,length:r,finished:o,destroyed:s,outputLen:i,pos:c}=this;return e||(e=new this.constructor({dkLen:i})),e.set(...this.get()),e.buffer.set(n),e.destroyed=s,e.finished=o,e.length=r,e.pos=c,e.outputLen=i,e}clone(){return this._cloneInto()}}class Ec extends xc{constructor(e={}){const n=e.dkLen===void 0?64:e.dkLen;super(128,n),this.v0l=z$3[0]|0,this.v0h=z$3[1]|0,this.v1l=z$3[2]|0,this.v1h=z$3[3]|0,this.v2l=z$3[4]|0,this.v2h=z$3[5]|0,this.v3l=z$3[6]|0,this.v3h=z$3[7]|0,this.v4l=z$3[8]|0,this.v4h=z$3[9]|0,this.v5l=z$3[10]|0,this.v5h=z$3[11]|0,this.v6l=z$3[12]|0,this.v6h=z$3[13]|0,this.v7l=z$3[14]|0,this.v7h=z$3[15]|0,vc(n,e,64,16,16);let{key:r,personalization:o,salt:s}=e,i=0;if(r!==void 0&&(r=pt$1(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,s!==void 0){s=pt$1(s);const c=pe$3(s);this.v4l^=wt$2(c[0]),this.v4h^=wt$2(c[1]),this.v5l^=wt$2(c[2]),this.v5h^=wt$2(c[3]);}if(o!==void 0){o=pt$1(o);const c=pe$3(o);this.v6l^=wt$2(c[0]),this.v6h^=wt$2(c[1]),this.v7l^=wt$2(c[2]),this.v7h^=wt$2(c[3]);}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c);}}get(){let{v0l:e,v0h:n,v1l:r,v1h:o,v2l:s,v2h:i,v3l:c,v3h:f,v4l:u,v4h:a,v5l:l,v5h:d,v6l:h,v6h:y,v7l:m,v7h:v}=this;return [e,n,r,o,s,i,c,f,u,a,l,d,h,y,m,v]}set(e,n,r,o,s,i,c,f,u,a,l,d,h,y,m,v){this.v0l=e|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=s|0,this.v2h=i|0,this.v3l=c|0,this.v3h=f|0,this.v4l=u|0,this.v4h=a|0,this.v5l=l|0,this.v5h=d|0,this.v6l=h|0,this.v6h=y|0,this.v7l=m|0,this.v7h=v|0;}compress(e,n,r){this.get().forEach((f,u)=>S$1[u]=f),S$1.set(z$3,16);let{h:o,l:s}=Ur$1(BigInt(this.length));S$1[24]=z$3[8]^s,S$1[25]=z$3[9]^o,r&&(S$1[28]=~S$1[28],S$1[29]=~S$1[29]);let i=0;const c=wc;for(let f=0;f<12;f++)jt$2(0,4,8,12,e,n+2*c[i++]),Lt$2(0,4,8,12,e,n+2*c[i++]),jt$2(1,5,9,13,e,n+2*c[i++]),Lt$2(1,5,9,13,e,n+2*c[i++]),jt$2(2,6,10,14,e,n+2*c[i++]),Lt$2(2,6,10,14,e,n+2*c[i++]),jt$2(3,7,11,15,e,n+2*c[i++]),Lt$2(3,7,11,15,e,n+2*c[i++]),jt$2(0,5,10,15,e,n+2*c[i++]),Lt$2(0,5,10,15,e,n+2*c[i++]),jt$2(1,6,11,12,e,n+2*c[i++]),Lt$2(1,6,11,12,e,n+2*c[i++]),jt$2(2,7,8,13,e,n+2*c[i++]),Lt$2(2,7,8,13,e,n+2*c[i++]),jt$2(3,4,9,14,e,n+2*c[i++]),Lt$2(3,4,9,14,e,n+2*c[i++]);this.v0l^=S$1[0]^S$1[16],this.v0h^=S$1[1]^S$1[17],this.v1l^=S$1[2]^S$1[18],this.v1h^=S$1[3]^S$1[19],this.v2l^=S$1[4]^S$1[20],this.v2h^=S$1[5]^S$1[21],this.v3l^=S$1[6]^S$1[22],this.v3h^=S$1[7]^S$1[23],this.v4l^=S$1[8]^S$1[24],this.v4h^=S$1[9]^S$1[25],this.v5l^=S$1[10]^S$1[26],this.v5h^=S$1[11]^S$1[27],this.v6l^=S$1[12]^S$1[28],this.v6h^=S$1[13]^S$1[29],this.v7l^=S$1[14]^S$1[30],this.v7h^=S$1[15]^S$1[31],lt$1(S$1);}destroy(){this.destroyed=true,lt$1(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}}const Bc=Wi$1(t=>new Ec(t)),Ac="https://rpc.walletconnect.org/v1";function hn$1(t){const e=`Ethereum Signed Message:
|
|
29773
31061
|
${t.length}`,n=new TextEncoder().encode(e+t);return "0x"+Buffer.from(ic(n)).toString("hex")}async function Zr$1(t,e,n,r,o,s){switch(n.t){case "eip191":return await Gr$1(t,e,n.s);case "eip1271":return await zr$1(t,e,n.s,r,o,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${n.t}`)}}function Gr$1(t,e,n){const r=fromHex(n);return recoverAddress({payload:hn$1(e),signature:r}).toLowerCase()===t.toLowerCase()}async function zr$1(t,e,n,r,o,s){const i=Je$2(r);if(!i.namespace||!i.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const c="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",u=n.substring(2),a=(u.length/2).toString(16).padStart(64,"0"),l=(e.startsWith("0x")?e:hn$1(e)).substring(2),d=c+l+f+a+u,h=await fetch(`${s||Ac}/?chainId=${r}&projectId=${o}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:Ic(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:y}=await h.json();return y?y.slice(0,c.length).toLowerCase()===c.toLowerCase():!1}catch(c){return console.error("isValidEip1271Signature: ",c),false}}function Ic(){return Date.now()+Math.floor(Math.random()*1e3)}function Sc(t){const e=atob(t),n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);const r=n[0];if(r===0)throw new Error("No signatures found");const o=1+r*64;if(n.length<o)throw new Error("Transaction data too short for claimed signature count");if(n.length<100)throw new Error("Transaction too short");const s=Buffer.from(t,"base64").slice(1,65);return bs58.encode(s)}function Oc(t){const e=new Uint8Array(Buffer.from(t,"base64")),n=Array.from("TransactionData::").map(s=>s.charCodeAt(0)),r=new Uint8Array(n.length+e.length);r.set(n),r.set(e,n.length);const o=Bc(r,{dkLen:32});return bs58.encode(o)}function Nc(t){const e=new Uint8Array($e$2(Yr$1(t)));return bs58.encode(e)}function Yr$1(t){if(t instanceof Uint8Array)return t;if(Array.isArray(t))return new Uint8Array(t);if(typeof t=="object"&&t!=null&&t.data)return new Uint8Array(Object.values(t.data));if(typeof t=="object"&&t)return new Uint8Array(Object.values(t));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function Uc(t){const e=Buffer.from(t,"base64"),n=decode$2(e).txn;if(!n)throw new Error("Invalid signed transaction: missing 'txn' field");const r=encode$2(n),o=Buffer.from("TX"),s=Buffer.concat([o,Buffer.from(r)]),i=mc(s);return base32$2.encode(i).replace(/=+$/,"")}function pn$1(t){const e=[];let n=BigInt(t);for(;n>=BigInt(128);)e.push(Number(n&BigInt(127)|BigInt(128))),n>>=BigInt(7);return e.push(Number(n)),Buffer.from(e)}function _c(t){const e=Buffer.from(t.signed.bodyBytes,"base64"),n=Buffer.from(t.signed.authInfoBytes,"base64"),r=Buffer.from(t.signature.signature,"base64"),o=[];o.push(Buffer.from([10])),o.push(pn$1(e.length)),o.push(e),o.push(Buffer.from([18])),o.push(pn$1(n.length)),o.push(n),o.push(Buffer.from([26])),o.push(pn$1(r.length)),o.push(r);const s=Buffer.concat(o),i=$e$2(s);return Buffer.from(i).toString("hex").toUpperCase()}function Rc(t){var e,n;const r=[];try{if(typeof t=="string")return r.push(t),r;if(typeof t!="object")return r;t!=null&&t.id&&r.push(t.id);const o=(n=(e=t?.capabilities)==null?void 0:e.caip345)==null?void 0:n.transactionHashes;o&&r.push(...o);}catch(o){console.warn("getWalletSendCallsHashes failed: ",o);}return r}var $c=Object.defineProperty,Tc=Object.defineProperties,Cc=Object.getOwnPropertyDescriptors,Wr$1=Object.getOwnPropertySymbols,jc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Xr$1=(t,e,n)=>e in t?$c(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,gn$1=(t,e)=>{for(var n in e||(e={}))jc.call(e,n)&&Xr$1(t,n,e[n]);if(Wr$1)for(var n of Wr$1(e))Lc.call(e,n)&&Xr$1(t,n,e[n]);return t},Jr$1=(t,e)=>Tc(t,Cc(e));const kc="did:pkh:",Te$2=t=>t?.split(":"),Qr$1=t=>{const e=t&&Te$2(t);if(e)return t.includes(kc)?e[3]:e[1]},to$1=t=>{const e=t&&Te$2(t);if(e)return e[2]+":"+e[3]},bn$1=t=>{const e=t&&Te$2(t);if(e)return e.pop()};async function Pc(t){const{cacao:e,projectId:n}=t,{s:r,p:o}=e,s=eo$1(o,o.iss),i=bn$1(o.iss);return await Zr$1(i,s,r,to$1(o.iss),n)}const eo$1=(t,e)=>{const n=`${t.domain} wants you to sign in with your Ethereum account:`,r=bn$1(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let o=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,i=`Version: ${t.version}`,c=`Chain ID: ${Qr$1(e)}`,f=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,a=t.exp?`Expiration Time: ${t.exp}`:void 0,l=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,h=t.resources?`Resources:${t.resources.map(m=>`
|
|
29774
31062
|
- ${m}`).join("")}`:void 0,y=je$1(t.resources);if(y){const m=kt$2(y);o=wn$1(o,m);}return [n,r,"",o,"",s,i,c,f,u,a,l,d,h].filter(m=>m!=null).join(`
|
|
29775
|
-
`)};function so$1(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function io$1(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function yt$2(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(n=>{const r=t.att[n];if(Array.isArray(r))throw new Error(`Resource must be an object: ${n}`);if(typeof r!="object")throw new Error(`Resource must be an object: ${n}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${n}`);Object.keys(r).forEach(o=>{const s=r[o];if(!Array.isArray(s))throw new Error(`Ability limits ${o} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${o} is empty array, must be an array with objects`);s.forEach(i=>{if(typeof i!="object")throw new Error(`Ability limits (${o}) must be an array of objects, found: ${i}`)});});});}function co$1(t,e,n,r={}){return n?.sort((o,s)=>o.localeCompare(s)),{att:{[t]:yn$1(e,n,r)}}}function yn$1(t,e,n={}){e=e?.sort((o,s)=>o.localeCompare(s));const r=e.map(o=>({[`${t}/${o}`]:[n]}));return Object.assign({},...r)}function Ce$2(t){return yt$2(t),`urn:recap:${so$1(t).replace(/=/g,"")}`}function kt$2(t){const e=io$1(t.replace("urn:recap:",""));return yt$2(e),e}function Kc(t,e,n){const r=co$1(t,e,n);return Ce$2(r)}function mn$1(t){return t&&t.includes("urn:recap:")}function qc(t,e){const n=kt$2(t),r=kt$2(e),o=ao$1(n,r);return Ce$2(o)}function ao$1(t,e){yt$2(t),yt$2(e);const n=Object.keys(t.att).concat(Object.keys(e.att)).sort((o,s)=>o.localeCompare(s)),r={att:{}};return n.forEach(o=>{var s,i;Object.keys(((s=t.att)==null?void 0:s[o])||{}).concat(Object.keys(((i=e.att)==null?void 0:i[o])||{})).sort((c,f)=>c.localeCompare(f)).forEach(c=>{var f,u;r.att[o]=Jr$1(gn$1({},r.att[o]),{[c]:((f=t.att[o])==null?void 0:f[c])||((u=e.att[o])==null?void 0:u[c])});});}),r}function wn$1(t="",e){yt$2(e);const n="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(n))return t;const r=[];let o=0;Object.keys(e.att).forEach(c=>{const f=Object.keys(e.att[c]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));f.sort((l,d)=>l.action.localeCompare(d.action));const u={};f.forEach(l=>{u[l.ability]||(u[l.ability]=[]),u[l.ability].push(l.action);});const a=Object.keys(u).map(l=>(o++,`(${o}) '${l}': '${u[l].join("', '")}' for '${c}'.`));r.push(a.join(", ").replace(".,","."));});const s=r.join(" "),i=`${n}${s}`;return `${t?t+" ":""}${i}`}function Fc(t){var e;const n=kt$2(t);yt$2(n);const r=(e=n.att)==null?void 0:e.eip155;return r?Object.keys(r).map(o=>o.split("/")[1]):[]}function Zc(t){const e=kt$2(t);yt$2(e);const n=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(o=>{var s;(s=o?.[0])!=null&&s.chains&&n.push(o[0].chains);});}),[...new Set(n.flat())]}function je$1(t){if(!t)return;const e=t?.[t.length-1];return mn$1(e)?e:void 0}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function lo$1(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function vn$1(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function xn$1(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ot$1(t,...e){if(!lo$1(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ho$1(t,e=true){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gc(t,e){ot$1(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Pt$2(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Qt$2(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function zc(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const Yc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Wc(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function En$1(t){if(typeof t=="string")t=Wc(t);else if(lo$1(t))t=Bn$1(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Xc(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Jc(t,e){if(t.length!==e.length)return false;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const Qc=(t,e)=>{function n(r,...o){if(ot$1(r),!Yc)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){const a=o[0];if(!a)throw new Error("nonce / iv required");t.varSizeNonce?ot$1(a):ot$1(a,t.nonceLength);}const s=t.tagLength;s&&o[1]!==void 0&&ot$1(o[1]);const i=e(r,...o),c=(a,l)=>{if(l!==void 0){if(a!==2)throw new Error("cipher output not supported");ot$1(l);}};let f=false;return {encrypt(a,l){if(f)throw new Error("cannot encrypt() twice with same key + nonce");return f=true,ot$1(a),c(i.encrypt.length,l),i.encrypt(a,l)},decrypt(a,l){if(ot$1(a),s&&a.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return c(i.decrypt.length,l),i.decrypt(a,l)}}}return Object.assign(n,t),n};function po$1(t,e,n=true){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(n&&!ef(e))throw new Error("invalid output, must be aligned");return e}function go$1(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),f=4,u=0;t.setUint32(e+f,i,r),t.setUint32(e+u,c,r);}function tf(t,e,n){vn$1(n);const r=new Uint8Array(16),o=zc(r);return go$1(o,0,BigInt(e),n),go$1(o,8,BigInt(t),n),r}function ef(t){return t.byteOffset%4===0}function Bn$1(t){return Uint8Array.from(t)}const bo$1=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),nf=bo$1("expand 16-byte k"),rf=bo$1("expand 32-byte k"),of=Pt$2(nf),sf=Pt$2(rf);function K$2(t,e){return t<<e|t>>>32-e}function An$1(t){return t.byteOffset%4===0}const Le$2=64,cf=16,yo$1=2**32-1,mo$1=new Uint32Array;function ff(t,e,n,r,o,s,i,c){const f=o.length,u=new Uint8Array(Le$2),a=Pt$2(u),l=An$1(o)&&An$1(s),d=l?Pt$2(o):mo$1,h=l?Pt$2(s):mo$1;for(let y=0;y<f;i++){if(t(e,n,r,a,i,c),i>=yo$1)throw new Error("arx: counter overflow");const m=Math.min(Le$2,f-y);if(l&&m===Le$2){const v=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let U=0,F;U<cf;U++)F=v+U,h[F]=d[F]^a[U];y+=Le$2;continue}for(let v=0,U;v<m;v++)U=y+v,s[U]=o[U]^u[v];y+=m;}}function af(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=Xc({allowShortKeys:false,counterLength:8,counterRight:false,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return xn$1(o),xn$1(i),vn$1(s),vn$1(n),(c,f,u,a,l=0)=>{ot$1(c),ot$1(f),ot$1(u);const d=u.length;if(a===void 0&&(a=new Uint8Array(d)),ot$1(a),xn$1(l),l<0||l>=yo$1)throw new Error("arx: counter overflow");if(a.length<d)throw new Error(`arx: output (${a.length}) is shorter than data (${d})`);const h=[];let y=c.length,m,v;if(y===32)h.push(m=Bn$1(c)),v=sf;else if(y===16&&n)m=new Uint8Array(32),m.set(c),m.set(c,16),v=of,h.push(m);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);An$1(f)||h.push(f=Bn$1(f));const U=Pt$2(m);if(r){if(f.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(v,U,Pt$2(f.subarray(0,16)),U),f=f.subarray(16);}const F=16-o;if(F!==f.length)throw new Error(`arx: nonce must be ${F} or 16 bytes`);if(F!==12){const Z=new Uint8Array(12);Z.set(f,s?0:12-f.length),f=Z,h.push(f);}const R=Pt$2(f);return ff(t,v,U,R,u,a,l,i),Qt$2(...h),a}}const W$3=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class uf{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=false,e=En$1(e),ot$1(e,32);const n=W$3(e,0),r=W$3(e,2),o=W$3(e,4),s=W$3(e,6),i=W$3(e,8),c=W$3(e,10),f=W$3(e,12),u=W$3(e,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|s<<9)&8191,this.r[4]=(s>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let a=0;a<8;a++)this.pad[a]=W$3(e,16+2*a);}process(e,n,r=false){const o=r?0:2048,{h:s,r:i}=this,c=i[0],f=i[1],u=i[2],a=i[3],l=i[4],d=i[5],h=i[6],y=i[7],m=i[8],v=i[9],U=W$3(e,n+0),F=W$3(e,n+2),R=W$3(e,n+4),Z=W$3(e,n+6),H=W$3(e,n+8),j=W$3(e,n+10),L=W$3(e,n+12),k=W$3(e,n+14);let O=s[0]+(U&8191),T=s[1]+((U>>>13|F<<3)&8191),C=s[2]+((F>>>10|R<<6)&8191),_=s[3]+((R>>>7|Z<<9)&8191),p=s[4]+((Z>>>4|H<<12)&8191),b=s[5]+(H>>>1&8191),g=s[6]+((H>>>14|j<<2)&8191),x=s[7]+((j>>>11|L<<5)&8191),E=s[8]+((L>>>8|k<<8)&8191),A=s[9]+(k>>>5|o),w=0,B=w+O*c+T*(5*v)+C*(5*m)+_*(5*y)+p*(5*h);w=B>>>13,B&=8191,B+=b*(5*d)+g*(5*l)+x*(5*a)+E*(5*u)+A*(5*f),w+=B>>>13,B&=8191;let I=w+O*f+T*c+C*(5*v)+_*(5*m)+p*(5*y);w=I>>>13,I&=8191,I+=b*(5*h)+g*(5*d)+x*(5*l)+E*(5*a)+A*(5*u),w+=I>>>13,I&=8191;let N=w+O*u+T*f+C*c+_*(5*v)+p*(5*m);w=N>>>13,N&=8191,N+=b*(5*y)+g*(5*h)+x*(5*d)+E*(5*l)+A*(5*a),w+=N>>>13,N&=8191;let D=w+O*a+T*u+C*f+_*c+p*(5*v);w=D>>>13,D&=8191,D+=b*(5*m)+g*(5*y)+x*(5*h)+E*(5*d)+A*(5*l),w+=D>>>13,D&=8191;let P=w+O*l+T*a+C*u+_*f+p*c;w=P>>>13,P&=8191,P+=b*(5*v)+g*(5*m)+x*(5*y)+E*(5*h)+A*(5*d),w+=P>>>13,P&=8191;let $=w+O*d+T*l+C*a+_*u+p*f;w=$>>>13,$&=8191,$+=b*c+g*(5*v)+x*(5*m)+E*(5*y)+A*(5*h),w+=$>>>13,$&=8191;let V=w+O*h+T*d+C*l+_*a+p*u;w=V>>>13,V&=8191,V+=b*f+g*c+x*(5*v)+E*(5*m)+A*(5*y),w+=V>>>13,V&=8191;let q=w+O*y+T*h+C*d+_*l+p*a;w=q>>>13,q&=8191,q+=b*u+g*f+x*c+E*(5*v)+A*(5*m),w+=q>>>13,q&=8191;let G=w+O*m+T*y+C*h+_*d+p*l;w=G>>>13,G&=8191,G+=b*a+g*u+x*f+E*c+A*(5*v),w+=G>>>13,G&=8191;let M=w+O*v+T*m+C*y+_*h+p*d;w=M>>>13,M&=8191,M+=b*l+g*a+x*u+E*f+A*c,w+=M>>>13,M&=8191,w=(w<<2)+w|0,w=w+B|0,B=w&8191,w=w>>>13,I+=w,s[0]=B,s[1]=I,s[2]=N,s[3]=D,s[4]=P,s[5]=$,s[6]=V,s[7]=q,s[8]=G,s[9]=M;}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let o=e[1]>>>13;e[1]&=8191;for(let c=2;c<10;c++)e[c]+=o,o=e[c]>>>13,e[c]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=e[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let s=(o^1)-1;for(let c=0;c<10;c++)r[c]&=s;s=~s;for(let c=0;c<10;c++)e[c]=e[c]&s|r[c];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+n[0];e[0]=i&65535;for(let c=1;c<8;c++)i=(e[c]+n[c]|0)+(i>>>16)|0,e[c]=i&65535;Qt$2(r);}update(e){ho$1(this),e=En$1(e),ot$1(e);const{buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i===r){for(;r<=o-s;s+=r)this.process(e,s);continue}n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(n,0,false),this.pos=0);}return this}destroy(){Qt$2(this.h,this.r,this.buffer,this.pad);}digestInto(e){ho$1(this),Gc(e,this),this.finished=true;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,true);}this.finalize();let s=0;for(let i=0;i<8;i++)e[s++]=r[i]>>>0,e[s++]=r[i]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function lf(t){const e=(r,o)=>t(o).update(En$1(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}const df=lf(t=>new uf(t));function hf(t,e,n,r,o,s=20){let i=t[0],c=t[1],f=t[2],u=t[3],a=e[0],l=e[1],d=e[2],h=e[3],y=e[4],m=e[5],v=e[6],U=e[7],F=o,R=n[0],Z=n[1],H=n[2],j=i,L=c,k=f,O=u,T=a,C=l,_=d,p=h,b=y,g=m,x=v,E=U,A=F,w=R,B=Z,I=H;for(let D=0;D<s;D+=2)j=j+T|0,A=K$2(A^j,16),b=b+A|0,T=K$2(T^b,12),j=j+T|0,A=K$2(A^j,8),b=b+A|0,T=K$2(T^b,7),L=L+C|0,w=K$2(w^L,16),g=g+w|0,C=K$2(C^g,12),L=L+C|0,w=K$2(w^L,8),g=g+w|0,C=K$2(C^g,7),k=k+_|0,B=K$2(B^k,16),x=x+B|0,_=K$2(_^x,12),k=k+_|0,B=K$2(B^k,8),x=x+B|0,_=K$2(_^x,7),O=O+p|0,I=K$2(I^O,16),E=E+I|0,p=K$2(p^E,12),O=O+p|0,I=K$2(I^O,8),E=E+I|0,p=K$2(p^E,7),j=j+C|0,I=K$2(I^j,16),x=x+I|0,C=K$2(C^x,12),j=j+C|0,I=K$2(I^j,8),x=x+I|0,C=K$2(C^x,7),L=L+_|0,A=K$2(A^L,16),E=E+A|0,_=K$2(_^E,12),L=L+_|0,A=K$2(A^L,8),E=E+A|0,_=K$2(_^E,7),k=k+p|0,w=K$2(w^k,16),b=b+w|0,p=K$2(p^b,12),k=k+p|0,w=K$2(w^k,8),b=b+w|0,p=K$2(p^b,7),O=O+T|0,B=K$2(B^O,16),g=g+B|0,T=K$2(T^g,12),O=O+T|0,B=K$2(B^O,8),g=g+B|0,T=K$2(T^g,7);let N=0;r[N++]=i+j|0,r[N++]=c+L|0,r[N++]=f+k|0,r[N++]=u+O|0,r[N++]=a+T|0,r[N++]=l+C|0,r[N++]=d+_|0,r[N++]=h+p|0,r[N++]=y+b|0,r[N++]=m+g|0,r[N++]=v+x|0,r[N++]=U+E|0,r[N++]=F+A|0,r[N++]=R+w|0,r[N++]=Z+B|0,r[N++]=H+I|0;}const pf=af(hf,{counterRight:false,counterLength:4,allowShortKeys:false}),gf=new Uint8Array(16),wo$1=(t,e)=>{t.update(e);const n=e.length%16;n&&t.update(gf.subarray(n));},bf=new Uint8Array(32);function vo$1(t,e,n,r,o){const s=t(e,n,bf),i=df.create(s);o&&wo$1(i,o),wo$1(i,r);const c=tf(r.length,o?o.length:0,true);i.update(c);const f=i.digest();return Qt$2(s,c),f}const yf=t=>(e,n,r)=>({encrypt(s,i){const c=s.length;i=po$1(c+16,i,false),i.set(s);const f=i.subarray(0,-16);t(e,n,f,f,1);const u=vo$1(t,e,n,f,r);return i.set(u,c),Qt$2(u),i},decrypt(s,i){i=po$1(s.length-16,i,false);const c=s.subarray(0,-16),f=s.subarray(-16),u=vo$1(t,e,n,c,r);if(!Jc(f,u))throw new Error("invalid tag");return i.set(s.subarray(0,-16)),t(e,n,i,i,1),Qt$2(u),i}}),xo$1=Qc({blockSize:64,nonceLength:12,tagLength:16},yf(pf));let Eo$1 = class Eo extends Re{constructor(e,n){super(),this.finished=false,this.destroyed=false,Ue$3(e);const r=pt$1(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),lt$1(s);}update(e){return Nt$2(this),this.iHash.update(e),this}digestInto(e){Nt$2(this),ht$1(e,this.outputLen),this.finished=true,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy();}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=true,this.oHash.destroy(),this.iHash.destroy();}};const ke$3=(t,e,n)=>new Eo$1(t,e).update(n).digest();ke$3.create=(t,e)=>new Eo$1(t,e);function mf(t,e,n){return Ue$3(t),n===void 0&&(n=new Uint8Array(t.outputLen)),ke$3(t,pt$1(n),pt$1(e))}const In$1=Uint8Array.from([0]),Bo$1=Uint8Array.of();function wf(t,e,n,r=32){Ue$3(t),mt$2(r);const o=t.outputLen;if(r>255*o)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(r/o);n===void 0&&(n=Bo$1);const i=new Uint8Array(s*o),c=ke$3.create(t,e),f=c._cloneInto(),u=new Uint8Array(c.outputLen);for(let a=0;a<s;a++)In$1[0]=a+1,f.update(a===0?Bo$1:u).update(n).update(In$1).digestInto(u),i.set(u,o*a),c._cloneInto(f);return c.destroy(),f.destroy(),lt$1(u,In$1),i.slice(0,r)}const vf=(t,e,n,r,o)=>wf(t,mf(t,e,n),r,o),Pe$3=$e$2,Sn$1=BigInt(0),On$1=BigInt(1);function He$2(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Kt$2(t,e,n=""){const r=Ne(t),o=t?.length,s=e!==void 0;if(!r||s&&o!==e){const i=n&&`"${n}" `,c=s?` of length ${e}`:"",f=r?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+f)}return t}function De$2(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Ao$1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Sn$1:BigInt("0x"+t)}function Ve$3(t){return Ao$1(Jt$2(t))}function Me$4(t){return ht$1(t),Ao$1(Jt$2(Uint8Array.from(t).reverse()))}function Nn$1(t,e){return _e$3(t.toString(16).padStart(e*2,"0"))}function Un$1(t,e){return Nn$1(t,e).reverse()}function tt$2(t,e,n){let r;if(typeof e=="string")try{r=_e$3(e);}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ne(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(t+" of length "+n+" expected, got "+o);return r}const _n$1=t=>typeof t=="bigint"&&Sn$1<=t;function xf(t,e,n){return _n$1(t)&&_n$1(e)&&_n$1(n)&&e<=t&&t<n}function Rn$1(t,e,n,r){if(!xf(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function Io$1(t){let e;for(e=0;t>Sn$1;t>>=On$1,e+=1);return e}const ye$3=t=>(On$1<<BigInt(t))-On$1;function Ef(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=h=>new Uint8Array(h),o=h=>Uint8Array.of(h);let s=r(t),i=r(t),c=0;const f=()=>{s.fill(1),i.fill(0),c=0;},u=(...h)=>n(i,s,...h),a=(h=r(0))=>{i=u(o(0),h),s=u(),h.length!==0&&(i=u(o(1),h),s=u());},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const y=[];for(;h<e;){s=u();const m=s.slice();y.push(m),h+=s.length;}return _t$2(...y)};return (h,y)=>{f(),a(h);let m;for(;!(m=y(l()));)a();return f(),m}}function Ke$3(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(o,s,i){const c=t[o];if(i&&c===void 0)return;const f=typeof c;if(f!==s||c===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${f}`)}Object.entries(e).forEach(([o,s])=>r(o,s,false)),Object.entries(n).forEach(([o,s])=>r(o,s,true));}function So$1(t){const e=new WeakMap;return (n,...r)=>{const o=e.get(n);if(o!==void 0)return o;const s=t(n,...r);return e.set(n,s),s}}const st$1=BigInt(0),nt$1=BigInt(1),qt$2=BigInt(2),Oo$1=BigInt(3),No$1=BigInt(4),Uo$1=BigInt(5),Bf=BigInt(7),_o$1=BigInt(8),Af=BigInt(9),Ro$1=BigInt(16);function ct$1(t,e){const n=t%e;return n>=st$1?n:e+n}function gt$2(t,e,n){let r=t;for(;e-- >st$1;)r*=r,r%=n;return r}function $o$1(t,e){if(t===st$1)throw new Error("invert: expected non-zero number");if(e<=st$1)throw new Error("invert: expected positive modulus, got "+e);let n=ct$1(t,e),r=e,o=st$1,s=nt$1;for(;n!==st$1;){const c=r/n,f=r%n,u=o-s*c;r=n,n=f,o=s,s=u;}if(r!==nt$1)throw new Error("invert: does not exist");return ct$1(o,e)}function $n$1(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function To$1(t,e){const n=(t.ORDER+nt$1)/No$1,r=t.pow(e,n);return $n$1(t,r,e),r}function If(t,e){const n=(t.ORDER-Uo$1)/_o$1,r=t.mul(e,qt$2),o=t.pow(r,n),s=t.mul(e,o),i=t.mul(t.mul(s,qt$2),o),c=t.mul(s,t.sub(i,t.ONE));return $n$1(t,c,e),c}function Sf(t){const e=Ht$2(t),n=Co$1(t),r=n(e,e.neg(e.ONE)),o=n(e,r),s=n(e,e.neg(r)),i=(t+Bf)/Ro$1;return (c,f)=>{let u=c.pow(f,i),a=c.mul(u,r);const l=c.mul(u,o),d=c.mul(u,s),h=c.eql(c.sqr(a),f),y=c.eql(c.sqr(l),f);u=c.cmov(u,a,h),a=c.cmov(d,l,y);const m=c.eql(c.sqr(a),f),v=c.cmov(u,a,m);return $n$1(c,v,f),v}}function Co$1(t){if(t<Oo$1)throw new Error("sqrt is not defined for small field");let e=t-nt$1,n=0;for(;e%qt$2===st$1;)e/=qt$2,n++;let r=qt$2;const o=Ht$2(t);for(;Lo$1(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return To$1;let s=o.pow(r,e);const i=(e+nt$1)/qt$2;return function(f,u){if(f.is0(u))return u;if(Lo$1(f,u)!==1)throw new Error("Cannot find square root");let a=n,l=f.mul(f.ONE,s),d=f.pow(u,e),h=f.pow(u,i);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let y=1,m=f.sqr(d);for(;!f.eql(m,f.ONE);)if(y++,m=f.sqr(m),y===a)throw new Error("Cannot find square root");const v=nt$1<<BigInt(a-y-1),U=f.pow(l,v);a=y,l=f.sqr(U),d=f.mul(d,l),h=f.mul(h,U);}return h}}function Of(t){return t%No$1===Oo$1?To$1:t%_o$1===Uo$1?If:t%Ro$1===Af?Sf(t):Co$1(t)}const Nf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uf(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Nf.reduce((r,o)=>(r[o]="function",r),e);return Ke$3(t,n),t}function _f(t,e,n){if(n<st$1)throw new Error("invalid exponent, negatives unsupported");if(n===st$1)return t.ONE;if(n===nt$1)return e;let r=t.ONE,o=e;for(;n>st$1;)n&nt$1&&(r=t.mul(r,o)),o=t.sqr(o),n>>=nt$1;return r}function jo$1(t,e,n=false){const r=new Array(e.length).fill(n?t.ZERO:void 0),o=e.reduce((i,c,f)=>t.is0(c)?i:(r[f]=i,t.mul(i,c)),t.ONE),s=t.inv(o);return e.reduceRight((i,c,f)=>t.is0(c)?i:(r[f]=t.mul(i,r[f]),t.mul(i,c)),s),r}function Lo$1(t,e){const n=(t.ORDER-nt$1)/qt$2,r=t.pow(e,n),o=t.eql(r,t.ONE),s=t.eql(r,t.ZERO),i=t.eql(r,t.neg(t.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function ko$1(t,e){e!==void 0&&mt$2(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return {nBitLength:n,nByteLength:r}}function Ht$2(t,e,n=false,r={}){if(t<=st$1)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,s,i=false,c;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=e;d.BITS&&(o=d.BITS),d.sqrt&&(s=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(i=d.modFromBytes),c=d.allowedLengths;}else typeof e=="number"&&(o=e),r.sqrt&&(s=r.sqrt);const{nBitLength:f,nByteLength:u}=ko$1(t,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const l=Object.freeze({ORDER:t,isLE:n,BITS:f,BYTES:u,MASK:ye$3(f),ZERO:st$1,ONE:nt$1,allowedLengths:c,create:d=>ct$1(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return st$1<=d&&d<t},is0:d=>d===st$1,isValidNot0:d=>!l.is0(d)&&l.isValid(d),isOdd:d=>(d&nt$1)===nt$1,neg:d=>ct$1(-d,t),eql:(d,h)=>d===h,sqr:d=>ct$1(d*d,t),add:(d,h)=>ct$1(d+h,t),sub:(d,h)=>ct$1(d-h,t),mul:(d,h)=>ct$1(d*h,t),pow:(d,h)=>_f(l,d,h),div:(d,h)=>ct$1(d*$o$1(h,t),t),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>$o$1(d,t),sqrt:s||(d=>(a||(a=Of(t)),a(l,d))),toBytes:d=>n?Un$1(d,u):Nn$1(d,u),fromBytes:(d,h=true)=>{if(c){if(!c.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);const m=new Uint8Array(u);m.set(d,n?0:m.length-d.length),d=m;}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let y=n?Me$4(d):Ve$3(d);if(i&&(y=ct$1(y,t)),!h&&!l.isValid(y))throw new Error("invalid field element: outside of range 0..ORDER");return y},invertBatch:d=>jo$1(l,d),cmov:(d,h,y)=>y?h:d});return Object.freeze(l)}function Po$1(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ho$1(t){const e=Po$1(t);return e+Math.ceil(e/2)}function Rf(t,e,n=false){const r=t.length,o=Po$1(e),s=Ho$1(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?Me$4(t):Ve$3(t),c=ct$1(i,e-nt$1)+nt$1;return n?Un$1(c,o):Nn$1(c,o)}const te$2=BigInt(0),Ft$2=BigInt(1);function qe$1(t,e){const n=e.negate();return t?n:e}function Tn$1(t,e){const n=jo$1(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function Do$1(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Cn$1(t,e){Do$1(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),o=2**t,s=ye$3(t),i=BigInt(t);return {windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function Vo$1(t,e,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let c=Number(t&o),f=t>>i;c>r&&(c-=s,f+=Ft$2);const u=e*r,a=u+Math.abs(c)-1,l=c===0,d=c<0,h=e%2!==0;return {nextN:f,offset:a,isZero:l,isNeg:d,isNegF:h,offsetF:u}}function $f(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)});}function Tf(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)});}const jn$1=new WeakMap,Mo$1=new WeakMap;function Ln$1(t){return Mo$1.get(t)||1}function Ko$1(t){if(t!==te$2)throw new Error("invalid wNAF")}class Cf{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n;}_unsafeLadder(e,n,r=this.ZERO){let o=e;for(;n>te$2;)n&Ft$2&&(r=r.add(o)),o=o.double(),n>>=Ft$2;return r}precomputeWindow(e,n){const{windows:r,windowSize:o}=Cn$1(n,this.bits),s=[];let i=e,c=i;for(let f=0;f<r;f++){c=i,s.push(c);for(let u=1;u<o;u++)c=c.add(i),s.push(c);i=c.double();}return s}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=Cn$1(e,this.bits);for(let c=0;c<i.windows;c++){const{nextN:f,offset:u,isZero:a,isNeg:l,isNegF:d,offsetF:h}=Vo$1(r,c,i);r=f,a?s=s.add(qe$1(d,n[h])):o=o.add(qe$1(l,n[u]));}return Ko$1(r),{p:o,f:s}}wNAFUnsafe(e,n,r,o=this.ZERO){const s=Cn$1(e,this.bits);for(let i=0;i<s.windows&&r!==te$2;i++){const{nextN:c,offset:f,isZero:u,isNeg:a}=Vo$1(r,i,s);if(r=c,!u){const l=n[f];o=o.add(a?l.negate():l);}}return Ko$1(r),o}getPrecomputes(e,n,r){let o=jn$1.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(o=r(o)),jn$1.set(n,o))),o}cached(e,n,r){const o=Ln$1(e);return this.wNAF(o,this.getPrecomputes(o,e,r),n)}unsafe(e,n,r,o){const s=Ln$1(e);return s===1?this._unsafeLadder(e,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),n,o)}createCache(e,n){Do$1(n,this.bits),Mo$1.set(e,n),jn$1.delete(e);}hasCache(e){return Ln$1(e)!==1}}function jf(t,e,n,r){let o=e,s=t.ZERO,i=t.ZERO;for(;n>te$2||r>te$2;)n&Ft$2&&(s=s.add(o)),r&Ft$2&&(i=i.add(o)),o=o.double(),n>>=Ft$2,r>>=Ft$2;return {p1:s,p2:i}}function Lf(t,e,n,r){$f(n,t),Tf(r,e);const o=n.length,s=r.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,c=Io$1(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const u=ye$3(f),a=new Array(Number(u)+1).fill(i),l=Math.floor((e.BITS-1)/f)*f;let d=i;for(let h=l;h>=0;h-=f){a.fill(i);for(let m=0;m<s;m++){const v=r[m],U=Number(v>>BigInt(h)&u);a[U]=a[U].add(n[m]);}let y=i;for(let m=a.length-1,v=i;m>0;m--)v=v.add(a[m]),y=y.add(v);if(d=d.add(y),h!==0)for(let m=0;m<f;m++)d=d.double();}return d}function qo$1(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Uf(e),e}else return Ht$2(t,{isLE:n})}function kf(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const f of ["p","n","h"]){const u=e[f];if(!(typeof u=="bigint"&&u>te$2))throw new Error(`CURVE.${f} must be positive bigint`)}const o=qo$1(e.p,n.Fp,r),s=qo$1(e.n,n.Fn,r),c=["Gx","Gy","a","b"];for(const f of c)if(!o.isValid(e[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}BigInt(0),BigInt(1),BigInt(2),BigInt(8),kr$1("HashToScalar-");const me$4=BigInt(0),ee$3=BigInt(1),Fe$2=BigInt(2);function Pf(t){return Ke$3(t,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...t})}function Hf(t){const e=Pf(t),{P:n,type:r,adjustScalarBytes:o,powPminus2:s,randomBytes:i}=e,c=r==="x25519";if(!c&&r!=="x448")throw new Error("invalid type");const f=i||Mt$2,u=c?255:448,a=c?32:56,l=BigInt(c?9:5),d=BigInt(c?121665:39081),h=c?Fe$2**BigInt(254):Fe$2**BigInt(447),y=c?BigInt(8)*Fe$2**BigInt(251)-ee$3:BigInt(4)*Fe$2**BigInt(445)-ee$3,m=h+y+ee$3,v=p=>ct$1(p,n),U=F(l);function F(p){return Un$1(v(p),a)}function R(p){const b=tt$2("u coordinate",p,a);return c&&(b[31]&=127),v(Me$4(b))}function Z(p){return Me$4(o(tt$2("scalar",p,a)))}function H(p,b){const g=k(R(b),Z(p));if(g===me$4)throw new Error("invalid private or public key received");return F(g)}function j(p){return H(p,U)}function L(p,b,g){const x=v(p*(b-g));return b=v(b-x),g=v(g+x),{x_2:b,x_3:g}}function k(p,b){Rn$1("u",p,me$4,n),Rn$1("scalar",b,h,m);const g=b,x=p;let E=ee$3,A=me$4,w=p,B=ee$3,I=me$4;for(let D=BigInt(u-1);D>=me$4;D--){const P=g>>D&ee$3;I^=P,{x_2:E,x_3:w}=L(I,E,w),{x_2:A,x_3:B}=L(I,A,B),I=P;const $=E+A,V=v($*$),q=E-A,G=v(q*q),M=V-G,Y=w+B,Yt=w-B,ce=v(Yt*$),fe=v(Y*q),Qn=ce+fe,tr=ce-fe;w=v(Qn*Qn),B=v(x*v(tr*tr)),E=v(V*G),A=v(M*(V+v(d*M)));}(({x_2:E,x_3:w}=L(I,E,w))),{x_2:A,x_3:B}=L(I,A,B);const N=s(A);return v(E*N)}const O={secretKey:a,publicKey:a,seed:a},T=(p=f(a))=>(ht$1(p,O.seed),p);function C(p){const b=T(p);return {secretKey:b,publicKey:j(b)}}return {keygen:C,getSharedSecret:(p,b)=>H(p,b),getPublicKey:p=>j(p),scalarMult:H,scalarMultBase:j,utils:{randomSecretKey:T,randomPrivateKey:T},GuBytes:U.slice(),lengths:O}}const Df=BigInt(1),Fo$1=BigInt(2),Vf=BigInt(3),Mf=BigInt(5);BigInt(8);const Zo$1=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),qf={p:Zo$1,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ff(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=Zo$1,c=t*t%s*t%s,f=gt$2(c,Fo$1,s)*c%s,u=gt$2(f,Df,s)*t%s,a=gt$2(u,Mf,s)*u%s,l=gt$2(a,e,s)*a%s,d=gt$2(l,n,s)*l%s,h=gt$2(d,r,s)*d%s,y=gt$2(h,o,s)*h%s,m=gt$2(y,o,s)*h%s,v=gt$2(m,e,s)*a%s;return {pow_p_5_8:gt$2(v,Fo$1,s)*t%s,b2:c}}function Zf(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Gf=Ht$2(qf.p,{isLE:true}),kn$1=(()=>{const t=Gf.ORDER;return Hf({P:t,type:"x25519",powPminus2:e=>{const{pow_p_5_8:n,b2:r}=Ff(e);return ct$1(gt$2(n,Vf,t)*r,t)},adjustScalarBytes:Zf})})(),Go$1=(t,e)=>(t+(t>=0?e:-e)/zo$1)/e;function zf(t,e,n){const[[r,o],[s,i]]=e,c=Go$1(i*t,n),f=Go$1(-o*t,n);let u=t-c*r-f*s,a=-c*o-f*i;const l=u<Et$3,d=a<Et$3;l&&(u=-u),d&&(a=-a);const h=ye$3(Math.ceil(Io$1(n)/2))+ne$2;if(u<Et$3||u>=h||a<Et$3||a>=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return {k1neg:l,k1:u,k2neg:d,k2:a}}function Pn$1(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Hn$1(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return He$2(n.lowS,"lowS"),He$2(n.prehash,"prehash"),n.format!==void 0&&Pn$1(n.format),n}class Yf extends Error{constructor(e=""){super(e);}}const xt$2={Err:Yf,_tlv:{encode:(t,e)=>{const{Err:n}=xt$2;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,o=De$2(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?De$2(o.length/2|128):"";return De$2(t)+s+o+e},decode(t,e){const{Err:n}=xt$2;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const o=e[r++],s=!!(o&128);let i=0;if(!s)i=o;else {const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+f);if(u.length!==f)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const a of u)i=i<<8|a;if(r+=f,i<128)throw new n("tlv.decode(long): not minimal encoding")}const c=e.subarray(r,r+i);if(c.length!==i)throw new n("tlv.decode: wrong value length");return {v:c,l:e.subarray(r+i)}}},_int:{encode(t){const{Err:e}=xt$2;if(t<Et$3)throw new e("integer: negative integers are not allowed");let n=De$2(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=xt$2;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ve$3(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=xt$2,o=tt$2("signature",t),{v:s,l:i}=r.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,s),{v:u,l:a}=r.decode(2,f);if(a.length)throw new e("invalid signature: left bytes after parsing");return {r:n.decode(c),s:n.decode(u)}},hexFromSig(t){const{_tlv:e,_int:n}=xt$2,r=e.encode(2,n.encode(t.r)),o=e.encode(2,n.encode(t.s)),s=r+o;return e.encode(48,s)}},Et$3=BigInt(0),ne$2=BigInt(1),zo$1=BigInt(2),Ze$2=BigInt(3),Wf=BigInt(4);function re$2(t,e){const{BYTES:n}=t;let r;if(typeof e=="bigint")r=e;else {let o=tt$2("private key",e);try{r=t.fromBytes(o);}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof e}`)}}if(!t.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Xf(t,e={}){const n=kf("weierstrass",t,e),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:c}=s;Ke$3(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=e;if(f&&(!r.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=Wo$1(r,o);function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(_,p,b){const{x:g,y:x}=p.toAffine(),E=r.toBytes(g);if(He$2(b,"isCompressed"),b){a();const A=!r.isOdd(x);return _t$2(Yo$1(A),E)}else return _t$2(Uint8Array.of(4),E,r.toBytes(x))}function d(_){Kt$2(_,void 0,"Point");const{publicKey:p,publicKeyUncompressed:b}=u,g=_.length,x=_[0],E=_.subarray(1);if(g===p&&(x===2||x===3)){const A=r.fromBytes(E);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");const w=m(A);let B;try{B=r.sqrt(w);}catch(D){const P=D instanceof Error?": "+D.message:"";throw new Error("bad point: is not on curve, sqrt error"+P)}a();const I=r.isOdd(B);return (x&1)===1!==I&&(B=r.neg(B)),{x:A,y:B}}else if(g===b&&x===4){const A=r.BYTES,w=r.fromBytes(E.subarray(0,A)),B=r.fromBytes(E.subarray(A,A*2));if(!v(w,B))throw new Error("bad point: is not on curve");return {x:w,y:B}}else throw new Error(`bad point: got length ${g}, expected compressed=${p} or uncompressed=${b}`)}const h=e.toBytes||l,y=e.fromBytes||d;function m(_){const p=r.sqr(_),b=r.mul(p,_);return r.add(r.add(b,r.mul(_,s.a)),s.b)}function v(_,p){const b=r.sqr(p),g=m(_);return r.eql(b,g)}if(!v(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const U=r.mul(r.pow(s.a,Ze$2),Wf),F=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(U,F)))throw new Error("bad curve params: a or b");function R(_,p,b=false){if(!r.isValid(p)||b&&r.is0(p))throw new Error(`bad point coordinate ${_}`);return p}function Z(_){if(!(_ instanceof O))throw new Error("ProjectivePoint expected")}function H(_){if(!f||!f.basises)throw new Error("no endo");return zf(_,f.basises,o.ORDER)}const j=So$1((_,p)=>{const{X:b,Y:g,Z:x}=_;if(r.eql(x,r.ONE))return {x:b,y:g};const E=_.is0();p==null&&(p=E?r.ONE:r.inv(x));const A=r.mul(b,p),w=r.mul(g,p),B=r.mul(x,p);if(E)return {x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return {x:A,y:w}}),L=So$1(_=>{if(_.is0()){if(e.allowInfinityPoint&&!r.is0(_.Y))return;throw new Error("bad point: ZERO")}const{x:p,y:b}=_.toAffine();if(!r.isValid(p)||!r.isValid(b))throw new Error("bad point: x or y not field elements");if(!v(p,b))throw new Error("bad point: equation left != right");if(!_.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return true});function k(_,p,b,g,x){return b=new O(r.mul(b.X,_),b.Y,b.Z),p=qe$1(g,p),b=qe$1(x,b),p.add(b)}class O{constructor(p,b,g){this.X=R("x",p),this.Y=R("y",b,true),this.Z=R("z",g),Object.freeze(this);}static CURVE(){return s}static fromAffine(p){const{x:b,y:g}=p||{};if(!p||!r.isValid(b)||!r.isValid(g))throw new Error("invalid affine point");if(p instanceof O)throw new Error("projective point not allowed");return r.is0(b)&&r.is0(g)?O.ZERO:new O(b,g,r.ONE)}static fromBytes(p){const b=O.fromAffine(y(Kt$2(p,void 0,"point")));return b.assertValidity(),b}static fromHex(p){return O.fromBytes(tt$2("pointHex",p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,b=true){return C.createCache(this,p),b||this.multiply(Ze$2),this}assertValidity(){L(this);}hasEvenY(){const{y:p}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return !r.isOdd(p)}equals(p){Z(p);const{X:b,Y:g,Z:x}=this,{X:E,Y:A,Z:w}=p,B=r.eql(r.mul(b,w),r.mul(E,x)),I=r.eql(r.mul(g,w),r.mul(A,x));return B&&I}negate(){return new O(this.X,r.neg(this.Y),this.Z)}double(){const{a:p,b}=s,g=r.mul(b,Ze$2),{X:x,Y:E,Z:A}=this;let w=r.ZERO,B=r.ZERO,I=r.ZERO,N=r.mul(x,x),D=r.mul(E,E),P=r.mul(A,A),$=r.mul(x,E);return $=r.add($,$),I=r.mul(x,A),I=r.add(I,I),w=r.mul(p,I),B=r.mul(g,P),B=r.add(w,B),w=r.sub(D,B),B=r.add(D,B),B=r.mul(w,B),w=r.mul($,w),I=r.mul(g,I),P=r.mul(p,P),$=r.sub(N,P),$=r.mul(p,$),$=r.add($,I),I=r.add(N,N),N=r.add(I,N),N=r.add(N,P),N=r.mul(N,$),B=r.add(B,N),P=r.mul(E,A),P=r.add(P,P),N=r.mul(P,$),w=r.sub(w,N),I=r.mul(P,D),I=r.add(I,I),I=r.add(I,I),new O(w,B,I)}add(p){Z(p);const{X:b,Y:g,Z:x}=this,{X:E,Y:A,Z:w}=p;let B=r.ZERO,I=r.ZERO,N=r.ZERO;const D=s.a,P=r.mul(s.b,Ze$2);let $=r.mul(b,E),V=r.mul(g,A),q=r.mul(x,w),G=r.add(b,g),M=r.add(E,A);G=r.mul(G,M),M=r.add($,V),G=r.sub(G,M),M=r.add(b,x);let Y=r.add(E,w);return M=r.mul(M,Y),Y=r.add($,q),M=r.sub(M,Y),Y=r.add(g,x),B=r.add(A,w),Y=r.mul(Y,B),B=r.add(V,q),Y=r.sub(Y,B),N=r.mul(D,M),B=r.mul(P,q),N=r.add(B,N),B=r.sub(V,N),N=r.add(V,N),I=r.mul(B,N),V=r.add($,$),V=r.add(V,$),q=r.mul(D,q),M=r.mul(P,M),V=r.add(V,q),q=r.sub($,q),q=r.mul(D,q),M=r.add(M,q),$=r.mul(V,M),I=r.add(I,$),$=r.mul(Y,M),B=r.mul(G,B),B=r.sub(B,$),$=r.mul(G,V),N=r.mul(Y,N),N=r.add(N,$),new O(B,I,N)}subtract(p){return this.add(p.negate())}is0(){return this.equals(O.ZERO)}multiply(p){const{endo:b}=e;if(!o.isValidNot0(p))throw new Error("invalid scalar: out of range");let g,x;const E=A=>C.cached(this,A,w=>Tn$1(O,w));if(b){const{k1neg:A,k1:w,k2neg:B,k2:I}=H(p),{p:N,f:D}=E(w),{p:P,f:$}=E(I);x=D.add($),g=k(b.beta,N,P,A,B);}else {const{p:A,f:w}=E(p);g=A,x=w;}return Tn$1(O,[g,x])[0]}multiplyUnsafe(p){const{endo:b}=e,g=this;if(!o.isValid(p))throw new Error("invalid scalar: out of range");if(p===Et$3||g.is0())return O.ZERO;if(p===ne$2)return g;if(C.hasCache(this))return this.multiply(p);if(b){const{k1neg:x,k1:E,k2neg:A,k2:w}=H(p),{p1:B,p2:I}=jf(O,g,E,w);return k(b.beta,B,I,x,A)}else return C.unsafe(g,p)}multiplyAndAddUnsafe(p,b,g){const x=this.multiplyUnsafe(b).add(p.multiplyUnsafe(g));return x.is0()?void 0:x}toAffine(p){return j(this,p)}isTorsionFree(){const{isTorsionFree:p}=e;return i===ne$2?true:p?p(O,this):C.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:p}=e;return i===ne$2?this:p?p(O,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(p=true){return He$2(p,"isCompressed"),this.assertValidity(),h(O,this,p)}toHex(p=true){return Jt$2(this.toBytes(p))}toString(){return `<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(p=true){return this.toBytes(p)}_setWindowSize(p){this.precompute(p);}static normalizeZ(p){return Tn$1(O,p)}static msm(p,b){return Lf(O,o,p,b)}static fromPrivateKey(p){return O.BASE.multiply(re$2(o,p))}}O.BASE=new O(s.Gx,s.Gy,r.ONE),O.ZERO=new O(r.ZERO,r.ONE,r.ZERO),O.Fp=r,O.Fn=o;const T=o.BITS,C=new Cf(O,e.endo?Math.ceil(T/2):T);return O.BASE.precompute(8),O}function Yo$1(t){return Uint8Array.of(t?2:3)}function Wo$1(t,e){return {secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:true,signature:2*e.BYTES}}function Jf(t,e={}){const{Fn:n}=t,r=e.randomBytes||Mt$2,o=Object.assign(Wo$1(t.Fp,n),{seed:Ho$1(n.ORDER)});function s(h){try{return !!re$2(n,h)}catch{return false}}function i(h,y){const{publicKey:m,publicKeyUncompressed:v}=o;try{const U=h.length;return y===!0&&U!==m||y===!1&&U!==v?!1:!!t.fromBytes(h)}catch{return false}}function c(h=r(o.seed)){return Rf(Kt$2(h,o.seed,"seed"),n.ORDER)}function f(h,y=true){return t.BASE.multiply(re$2(n,h)).toBytes(y)}function u(h){const y=c(h);return {secretKey:y,publicKey:f(y)}}function a(h){if(typeof h=="bigint")return false;if(h instanceof t)return true;const{secretKey:y,publicKey:m,publicKeyUncompressed:v}=o;if(n.allowedLengths||y===m)return;const U=tt$2("key",h).length;return U===m||U===v}function l(h,y,m=true){if(a(h)===true)throw new Error("first arg must be private key");if(a(y)===false)throw new Error("second arg must be public key");const v=re$2(n,h);return t.fromHex(y).multiply(v).toBytes(m)}return Object.freeze({getPublicKey:f,getSharedSecret:l,keygen:u,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:h=>re$2(n,h),precompute(h=8,y=t.BASE){return y.precompute(h,false)}},lengths:o})}function Qf(t,e,n={}){Ue$3(e),Ke$3(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Mt$2,o=n.hmac||((b,...g)=>ke$3(e,b,_t$2(...g))),{Fp:s,Fn:i}=t,{ORDER:c,BITS:f}=i,{keygen:u,getPublicKey:a,getSharedSecret:l,utils:d,lengths:h}=Jf(t,n),y={prehash:false,lowS:typeof n.lowS=="boolean"?n.lowS:false,format:void 0,extraEntropy:false},m="compact";function v(b){const g=c>>ne$2;return b>g}function U(b,g){if(!i.isValidNot0(g))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return g}function F(b,g){Pn$1(g);const x=h.signature,E=g==="compact"?x:g==="recovered"?x+1:void 0;return Kt$2(b,E,`${g} signature`)}class R{constructor(g,x,E){this.r=U("r",g),this.s=U("s",x),E!=null&&(this.recovery=E),Object.freeze(this);}static fromBytes(g,x=m){F(g,x);let E;if(x==="der"){const{r:I,s:N}=xt$2.toSig(Kt$2(g));return new R(I,N)}x==="recovered"&&(E=g[0],x="compact",g=g.subarray(1));const A=i.BYTES,w=g.subarray(0,A),B=g.subarray(A,A*2);return new R(i.fromBytes(w),i.fromBytes(B),E)}static fromHex(g,x){return this.fromBytes(_e$3(g),x)}addRecoveryBit(g){return new R(this.r,this.s,g)}recoverPublicKey(g){const x=s.ORDER,{r:E,s:A,recovery:w}=this;if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");if(c*zo$1<x&&w>1)throw new Error("recovery id is ambiguous for h>1 curve");const I=w===2||w===3?E+c:E;if(!s.isValid(I))throw new Error("recovery id 2 or 3 invalid");const N=s.toBytes(I),D=t.fromBytes(_t$2(Yo$1((w&1)===0),N)),P=i.inv(I),$=H(tt$2("msgHash",g)),V=i.create(-$*P),q=i.create(A*P),G=t.BASE.multiplyUnsafe(V).add(D.multiplyUnsafe(q));if(G.is0())throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return v(this.s)}toBytes(g=m){if(Pn$1(g),g==="der")return _e$3(xt$2.hexFromSig(this));const x=i.toBytes(this.r),E=i.toBytes(this.s);if(g==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return _t$2(Uint8Array.of(this.recovery),x,E)}return _t$2(x,E)}toHex(g){return Jt$2(this.toBytes(g))}assertValidity(){}static fromCompact(g){return R.fromBytes(tt$2("sig",g),"compact")}static fromDER(g){return R.fromBytes(tt$2("sig",g),"der")}normalizeS(){return this.hasHighS()?new R(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Jt$2(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Jt$2(this.toBytes("compact"))}}const Z=n.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");const x=Ve$3(g),E=g.length*8-f;return E>0?x>>BigInt(E):x},H=n.bits2int_modN||function(g){return i.create(Z(g))},j=ye$3(f);function L(b){return Rn$1("num < 2^"+f,b,Et$3,j),i.toBytes(b)}function k(b,g){return Kt$2(b,void 0,"message"),g?Kt$2(e(b),void 0,"prehashed message"):b}function O(b,g,x){if(["recovered","canonical"].some(V=>V in x))throw new Error("sign() legacy options not supported");const{lowS:E,prehash:A,extraEntropy:w}=Hn$1(x,y);b=k(b,A);const B=H(b),I=re$2(i,g),N=[L(I),L(B)];if(w!=null&&w!==false){const V=w===true?r(h.secretKey):w;N.push(tt$2("extraEntropy",V));}const D=_t$2(...N),P=B;function $(V){const q=Z(V);if(!i.isValidNot0(q))return;const G=i.inv(q),M=t.BASE.multiply(q).toAffine(),Y=i.create(M.x);if(Y===Et$3)return;const Yt=i.create(G*i.create(P+Y*I));if(Yt===Et$3)return;let ce=(M.x===Y?0:2)|Number(M.y&ne$2),fe=Yt;return E&&v(Yt)&&(fe=i.neg(Yt),ce^=1),new R(Y,fe,ce)}return {seed:D,k2sig:$}}function T(b,g,x={}){b=tt$2("message",b);const{seed:E,k2sig:A}=O(b,g,x);return Ef(e.outputLen,i.BYTES,o)(E,A)}function C(b){let g;const x=typeof b=="string"||Ne(b),E=!x&&b!==null&&typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint";if(!x&&!E)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(E)g=new R(b.r,b.s);else if(x){try{g=R.fromBytes(tt$2("sig",b),"der");}catch(A){if(!(A instanceof xt$2.Err))throw A}if(!g)try{g=R.fromBytes(tt$2("sig",b),"compact");}catch{return false}}return g||false}function _(b,g,x,E={}){const{lowS:A,prehash:w,format:B}=Hn$1(E,y);if(x=tt$2("publicKey",x),g=k(tt$2("message",g),w),"strict"in E)throw new Error("options.strict was renamed to lowS");const I=B===void 0?C(b):R.fromBytes(tt$2("sig",b),B);if(I===false)return false;try{const N=t.fromBytes(x);if(A&&I.hasHighS())return !1;const{r:D,s:P}=I,$=H(g),V=i.inv(P),q=i.create($*V),G=i.create(D*V),M=t.BASE.multiplyUnsafe(q).add(N.multiplyUnsafe(G));return M.is0()?!1:i.create(M.x)===D}catch{return false}}function p(b,g,x={}){const{prehash:E}=Hn$1(x,y);return g=k(g,E),R.fromBytes(b,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:a,getSharedSecret:l,utils:d,lengths:h,Point:t,sign:T,verify:_,recoverPublicKey:p,Signature:R,hash:e})}function ta$1(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp;let r=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const o=Ht$2(e.n,{BITS:t.nBitLength,allowedLengths:r,modFromBytes:t.wrapPrivateKey}),s={Fp:n,Fn:o,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return {CURVE:e,curveOpts:s}}function ea$1(t){const{CURVE:e,curveOpts:n}=ta$1(t),r={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return {CURVE:e,curveOpts:n,hash:t.hash,ecdsaOpts:r}}function na(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,ko$1(n.Fn.ORDER,n.Fn.BITS))})}function ra(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:o}=ea$1(t),s=Xf(e,n),i=Qf(s,r,o);return na(t,i)}function Dn$1(t,e){const n=r=>ra({...t,hash:r});return {...n(e),create:n}}const Xo$1={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},Jo$1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},Qo$1={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},oa=Ht$2(Xo$1.p),sa=Ht$2(Jo$1.p),ia=Ht$2(Qo$1.p),ca=Dn$1({...Xo$1,Fp:oa,lowS:false},$e$2);Dn$1({...Jo$1,Fp:sa,lowS:false},yc),Dn$1({...Qo$1,Fp:ia,lowS:false,allowedPrivateKeyLengths:[130,131,132]},bc);const fa=ca,Vn$1="base10",rt$1="base16",oe$3="base64pad",Ge$2="base64url",se$2="utf8",Mn$1=0,ie$2=1,we$3=2,aa=0,ts$1=1,ve$3=12,Kn$1=32;function ua(){const t=kn$1.utils.randomPrivateKey(),e=kn$1.getPublicKey(t);return {privateKey:toString(t,rt$1),publicKey:toString(e,rt$1)}}function la(){const t=Mt$2(Kn$1);return toString(t,rt$1)}function da(t,e){const n=kn$1.getSharedSecret(fromString(t,rt$1),fromString(e,rt$1)),r=vf(Pe$3,n,void 0,void 0,Kn$1);return toString(r,rt$1)}function ha(t){const e=Pe$3(fromString(t,rt$1));return toString(e,rt$1)}function pa(t){const e=Pe$3(fromString(t,se$2));return toString(e,rt$1)}function qn$1(t){return fromString(`${t}`,Vn$1)}function Zt$2(t){return Number(toString(t,Vn$1))}function es$1(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ns$1(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=(4-e.length%4)%4;return e+"=".repeat(n)}function ga(t){const e=qn$1(typeof t.type<"u"?t.type:Mn$1);if(Zt$2(e)===ie$2&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const n=typeof t.senderPublicKey<"u"?fromString(t.senderPublicKey,rt$1):void 0,r=typeof t.iv<"u"?fromString(t.iv,rt$1):Mt$2(ve$3),o=fromString(t.symKey,rt$1),s=xo$1(o,r).encrypt(fromString(t.message,se$2)),i=Fn$1({type:e,sealed:s,iv:r,senderPublicKey:n});return t.encoding===Ge$2?es$1(i):i}function ba(t){const e=fromString(t.symKey,rt$1),{sealed:n,iv:r}=ze$1({encoded:t.encoded,encoding:t.encoding}),o=xo$1(e,r).decrypt(n);if(o===null)throw new Error("Failed to decrypt");return toString(o,se$2)}function ya(t,e){const n=qn$1(we$3),r=Mt$2(ve$3),o=fromString(t,se$2),s=Fn$1({type:n,sealed:o,iv:r});return e===Ge$2?es$1(s):s}function ma(t,e){const{sealed:n}=ze$1({encoded:t,encoding:e});return toString(n,se$2)}function Fn$1(t){if(Zt$2(t.type)===we$3)return toString(concat([t.type,t.sealed]),oe$3);if(Zt$2(t.type)===ie$2){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return toString(concat([t.type,t.senderPublicKey,t.iv,t.sealed]),oe$3)}return toString(concat([t.type,t.iv,t.sealed]),oe$3)}function ze$1(t){const e=(t.encoding||oe$3)===Ge$2?ns$1(t.encoded):t.encoded,n=fromString(e,oe$3),r=n.slice(aa,ts$1),o=ts$1;if(Zt$2(r)===ie$2){const f=o+Kn$1,u=f+ve$3,a=n.slice(o,f),l=n.slice(f,u),d=n.slice(u);return {type:r,sealed:d,iv:l,senderPublicKey:a}}if(Zt$2(r)===we$3){const f=n.slice(o),u=Mt$2(ve$3);return {type:r,sealed:f,iv:u}}const s=o+ve$3,i=n.slice(o,s),c=n.slice(s);return {type:r,sealed:c,iv:i}}function wa(t,e){const n=ze$1({encoded:t,encoding:e?.encoding});return rs({type:Zt$2(n.type),senderPublicKey:typeof n.senderPublicKey<"u"?toString(n.senderPublicKey,rt$1):void 0,receiverPublicKey:e?.receiverPublicKey})}function rs(t){const e=t?.type||Mn$1;if(e===ie$2){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return {type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function va(t){return t.type===ie$2&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function xa(t){return t.type===we$3}function os(t){const e=Buffer.from(t.x,"base64"),n=Buffer.from(t.y,"base64");return concat([new Uint8Array([4]),e,n])}function Ea(t,e){const[n,r,o]=t.split("."),s=Buffer.from(ns$1(o),"base64");if(s.length!==64)throw new Error("Invalid signature length");const i=s.slice(0,32),c=s.slice(32,64),f=`${n}.${r}`,u=Pe$3(f),a=os(e);if(!fa.verify(concat([i,c]),u,a))throw new Error("Invalid signature");return sn$1(t).payload}const ss$1="irn";function Ba(t){return t?.relay||{protocol:ss$1}}function Aa(t){const e=C$3[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Ia=Object.defineProperty,Sa=Object.defineProperties,Oa=Object.getOwnPropertyDescriptors,is$1=Object.getOwnPropertySymbols,Na=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable,cs=(t,e,n)=>e in t?Ia(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,Zn$1=(t,e)=>{for(var n in e||(e={}))Na.call(e,n)&&cs(t,n,e[n]);if(is$1)for(var n of is$1(e))Ua.call(e,n)&&cs(t,n,e[n]);return t},_a=(t,e)=>Sa(t,Oa(e));function fs(t,e="-"){const n={},r="relay"+e;return Object.keys(t).forEach(o=>{if(o.startsWith(r)){const s=o.replace(r,""),i=t[o];n[s]=i;}}),n}function Ra(t){if(!t.includes("wc:")){const u=cn$1(t);u!=null&&u.includes("wc:")&&(t=u);}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),n=t.indexOf("?")!==-1?t.indexOf("?"):void 0,r=t.substring(0,e),o=t.substring(e+1,n).split("@"),s=typeof n<"u"?t.substring(n):"",i=new URLSearchParams(s),c=Object.fromEntries(i.entries()),f=typeof c.methods=="string"?c.methods.split(","):void 0;return {protocol:r,topic:as(o[0]),version:parseInt(o[1],10),symKey:c.symKey,relay:fs(c),methods:f,expiryTimestamp:c.expiryTimestamp?parseInt(c.expiryTimestamp,10):void 0}}function as(t){return t.startsWith("//")?t.substring(2):t}function us(t,e="-"){const n="relay",r={};return Object.keys(t).forEach(o=>{const s=o,i=n+e+s;t[s]&&(r[i]=t[s]);}),r}function $a(t){const e=new URLSearchParams,n=Zn$1(Zn$1(_a(Zn$1({},us(t.relay)),{symKey:t.symKey}),t.expiryTimestamp&&{expiryTimestamp:t.expiryTimestamp.toString()}),t.methods&&{methods:t.methods.join(",")});return Object.entries(n).sort(([r],[o])=>r.localeCompare(o)).forEach(([r,o])=>{o!==void 0&&e.append(r,String(o));}),`${t.protocol}:${t.topic}@${t.version}?${e}`}function Ta(t,e,n){return `${t}?wc_ev=${n}&topic=${e}`}var Ca=Object.defineProperty,ja=Object.defineProperties,La=Object.getOwnPropertyDescriptors,ls=Object.getOwnPropertySymbols,ka=Object.prototype.hasOwnProperty,Pa=Object.prototype.propertyIsEnumerable,ds=(t,e,n)=>e in t?Ca(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,Ha=(t,e)=>{for(var n in e||(e={}))ka.call(e,n)&&ds(t,n,e[n]);if(ls)for(var n of ls(e))Pa.call(e,n)&&ds(t,n,e[n]);return t},Da=(t,e)=>ja(t,La(e));function Gt$2(t){const e=[];return t.forEach(n=>{const[r,o]=n.split(":");e.push(`${r}:${o}`);}),e}function hs(t){const e=[];return Object.values(t).forEach(n=>{e.push(...Gt$2(n.accounts));}),e}function ps(t,e){const n=[];return Object.values(t).forEach(r=>{Gt$2(r.accounts).includes(e)&&n.push(...r.methods);}),n}function gs(t,e){const n=[];return Object.values(t).forEach(r=>{Gt$2(r.accounts).includes(e)&&n.push(...r.events);}),n}function Gn$1(t){return t.includes(":")}function bs$1(t){return Gn$1(t)?t.split(":")[0]:t}function xe(t){var e,n,r;const o={};if(!Ye$2(t))return o;for(const[s,i]of Object.entries(t)){const c=Gn$1(s)?[s]:i.chains,f=i.methods||[],u=i.events||[],a=bs$1(s);o[a]=Da(Ha({},o[a]),{chains:ut$2(c,(e=o[a])==null?void 0:e.chains),methods:ut$2(f,(n=o[a])==null?void 0:n.methods),events:ut$2(u,(r=o[a])==null?void 0:r.events)});}return o}function ys(t){const e={};return t?.forEach(n=>{var r;const[o,s]=n.split(":");e[o]||(e[o]={accounts:[],chains:[],events:[],methods:[]}),e[o].accounts.push(n),(r=e[o].chains)==null||r.push(`${o}:${s}`);}),e}function Ka(t,e){e=e.map(r=>r.replace("did:pkh:",""));const n=ys(e);for(const[r,o]of Object.entries(n))o.methods?o.methods=ut$2(o.methods,t):o.methods=t,o.events=["chainChanged","accountsChanged"];return n}function qa(t,e){var n,r,o,s,i,c;const f=xe(t),u=xe(e),a={},l=Object.keys(f).concat(Object.keys(u));for(const d of l)a[d]={chains:ut$2((n=f[d])==null?void 0:n.chains,(r=u[d])==null?void 0:r.chains),methods:ut$2((o=f[d])==null?void 0:o.methods,(s=u[d])==null?void 0:s.methods),events:ut$2((i=f[d])==null?void 0:i.events,(c=u[d])==null?void 0:c.events)};return a}const ms={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},ws={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Bt$2(t,e){const{message:n,code:r}=ws[t];return {message:e?`${n} ${e}`:n,code:r}}function zt$2(t,e){const{message:n,code:r}=ms[t];return {message:e?`${n} ${e}`:n,code:r}}function Ee$2(t,e){return Array.isArray(t)?true:false}function Ye$2(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Dt$1(t){return typeof t>"u"}function ft$2(t,e){return e&&Dt$1(t)?true:typeof t=="string"&&!!t.trim().length}function We$3(t,e){return e&&Dt$1(t)?true:typeof t=="number"&&!isNaN(t)}function Fa(t,e){const{requiredNamespaces:n}=e,r=Object.keys(t.namespaces),o=Object.keys(n);let s=true;return It$3(o,r)?(r.forEach(i=>{const{accounts:c,methods:f,events:u}=t.namespaces[i],a=Gt$2(c),l=n[i];(!It$3(Ie$1(i,l),a)||!It$3(l.methods,f)||!It$3(l.events,u))&&(s=false);}),s):false}function Be$2(t){return ft$2(t,false)&&t.includes(":")?t.split(":").length===2:false}function vs(t){if(ft$2(t,false)&&t.includes(":")){const e=t.split(":");if(e.length===3){const n=e[0]+":"+e[1];return !!e[2]&&Be$2(n)}}return false}function Za(t){function e(n){try{return typeof new URL(n)<"u"}catch{return false}}try{if(ft$2(t,!1)){if(e(t))return !0;const n=cn$1(t);return e(n)}}catch{}return false}function Ga(t){var e;return (e=t?.proposer)==null?void 0:e.publicKey}function za(t){return t?.topic}function Ya(t,e){let n=null;return ft$2(t?.publicKey,false)||(n=Bt$2("MISSING_OR_INVALID",`${e} controller public key should be a string`)),n}function zn$1(t){let e=true;return Ee$2(t)?t.length&&(e=t.every(n=>ft$2(n,false))):e=false,e}function xs$1(t,e,n){let r=null;return Ee$2(e)&&e.length?e.forEach(o=>{r||Be$2(o)||(r=zt$2("UNSUPPORTED_CHAINS",`${n}, chain ${o} should be a string and conform to "namespace:chainId" format`));}):Be$2(t)||(r=zt$2("UNSUPPORTED_CHAINS",`${n}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),r}function Es(t,e,n){let r=null;return Object.entries(t).forEach(([o,s])=>{if(r)return;const i=xs$1(o,Ie$1(o,s),`${e} ${n}`);i&&(r=i);}),r}function Bs(t,e){let n=null;return Ee$2(t)?t.forEach(r=>{n||vs(r)||(n=zt$2("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`));}):n=zt$2("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n}function As$1(t,e){let n=null;return Object.values(t).forEach(r=>{if(n)return;const o=Bs(r?.accounts,`${e} namespace`);o&&(n=o);}),n}function Is(t,e){let n=null;return zn$1(t?.methods)?zn$1(t?.events)||(n=zt$2("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):n=zt$2("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),n}function Yn$1(t,e){let n=null;return Object.values(t).forEach(r=>{if(n)return;const o=Is(r,`${e}, namespace`);o&&(n=o);}),n}function Wa(t,e,n){let r=null;if(t&&Ye$2(t)){const o=Yn$1(t,e);o&&(r=o);const s=Es(t,e,n);s&&(r=s);}else r=Bt$2("MISSING_OR_INVALID",`${e}, ${n} should be an object with data`);return r}function Ss(t,e){let n=null;if(t&&Ye$2(t)){const r=Yn$1(t,e);r&&(n=r);const o=As$1(t,e);o&&(n=o);}else n=Bt$2("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return n}function Os$1(t){return ft$2(t.protocol,true)}function Xa(t,e){let n=false;return !t?n=true:t&&Ee$2(t)&&t.length&&t.forEach(r=>{n=Os$1(r);}),n}function Ja(t){return typeof t=="number"}function Qa(t){return typeof t<"u"&&typeof t!==null}function tu(t){return !(!t||typeof t!="object"||!t.code||!We$3(t.code,false)||!t.message||!ft$2(t.message,false))}function eu(t){return !(Dt$1(t)||!ft$2(t.method,false))}function nu(t){return !(Dt$1(t)||Dt$1(t.result)&&Dt$1(t.error)||!We$3(t.id,false)||!ft$2(t.jsonrpc,false))}function ru(t){return !(Dt$1(t)||!ft$2(t.name,false))}function ou(t,e){return !(!Be$2(e)||!hs(t).includes(e))}function su(t,e,n){return ft$2(n,false)?ps(t,e).includes(n):false}function iu(t,e,n){return ft$2(n,false)?gs(t,e).includes(n):false}function Ns$1(t,e,n){let r=null;const o=cu(t),s=fu(e),i=Object.keys(o),c=Object.keys(s),f=Us$1(Object.keys(t)),u=Us$1(Object.keys(e)),a=f.filter(l=>!u.includes(l));return a.length&&(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces keys don't satisfy requiredNamespaces.
|
|
31063
|
+
`)};function so$1(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function io$1(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function yt$2(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(n=>{const r=t.att[n];if(Array.isArray(r))throw new Error(`Resource must be an object: ${n}`);if(typeof r!="object")throw new Error(`Resource must be an object: ${n}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${n}`);Object.keys(r).forEach(o=>{const s=r[o];if(!Array.isArray(s))throw new Error(`Ability limits ${o} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${o} is empty array, must be an array with objects`);s.forEach(i=>{if(typeof i!="object")throw new Error(`Ability limits (${o}) must be an array of objects, found: ${i}`)});});});}function co$1(t,e,n,r={}){return n?.sort((o,s)=>o.localeCompare(s)),{att:{[t]:yn$1(e,n,r)}}}function yn$1(t,e,n={}){e=e?.sort((o,s)=>o.localeCompare(s));const r=e.map(o=>({[`${t}/${o}`]:[n]}));return Object.assign({},...r)}function Ce$2(t){return yt$2(t),`urn:recap:${so$1(t).replace(/=/g,"")}`}function kt$2(t){const e=io$1(t.replace("urn:recap:",""));return yt$2(e),e}function Kc(t,e,n){const r=co$1(t,e,n);return Ce$2(r)}function mn$1(t){return t&&t.includes("urn:recap:")}function qc(t,e){const n=kt$2(t),r=kt$2(e),o=ao$1(n,r);return Ce$2(o)}function ao$1(t,e){yt$2(t),yt$2(e);const n=Object.keys(t.att).concat(Object.keys(e.att)).sort((o,s)=>o.localeCompare(s)),r={att:{}};return n.forEach(o=>{var s,i;Object.keys(((s=t.att)==null?void 0:s[o])||{}).concat(Object.keys(((i=e.att)==null?void 0:i[o])||{})).sort((c,f)=>c.localeCompare(f)).forEach(c=>{var f,u;r.att[o]=Jr$1(gn$1({},r.att[o]),{[c]:((f=t.att[o])==null?void 0:f[c])||((u=e.att[o])==null?void 0:u[c])});});}),r}function wn$1(t="",e){yt$2(e);const n="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(n))return t;const r=[];let o=0;Object.keys(e.att).forEach(c=>{const f=Object.keys(e.att[c]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));f.sort((l,d)=>l.action.localeCompare(d.action));const u={};f.forEach(l=>{u[l.ability]||(u[l.ability]=[]),u[l.ability].push(l.action);});const a=Object.keys(u).map(l=>(o++,`(${o}) '${l}': '${u[l].join("', '")}' for '${c}'.`));r.push(a.join(", ").replace(".,","."));});const s=r.join(" "),i=`${n}${s}`;return `${t?t+" ":""}${i}`}function Fc(t){var e;const n=kt$2(t);yt$2(n);const r=(e=n.att)==null?void 0:e.eip155;return r?Object.keys(r).map(o=>o.split("/")[1]):[]}function Zc(t){const e=kt$2(t);yt$2(e);const n=[];return Object.values(e.att).forEach(r=>{Object.values(r).forEach(o=>{var s;(s=o?.[0])!=null&&s.chains&&n.push(o[0].chains);});}),[...new Set(n.flat())]}function je$1(t){if(!t)return;const e=t?.[t.length-1];return mn$1(e)?e:void 0}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function lo$1(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function vn$1(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function xn$1(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ot$1(t,...e){if(!lo$1(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ho$1(t,e=true){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gc(t,e){ot$1(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Pt$2(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Qt$2(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function zc(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const Yc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Wc(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function En$1(t){if(typeof t=="string")t=Wc(t);else if(lo$1(t))t=Bn$1(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Xc(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Jc(t,e){if(t.length!==e.length)return false;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const Qc=(t,e)=>{function n(r,...o){if(ot$1(r),!Yc)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){const a=o[0];if(!a)throw new Error("nonce / iv required");t.varSizeNonce?ot$1(a):ot$1(a,t.nonceLength);}const s=t.tagLength;s&&o[1]!==void 0&&ot$1(o[1]);const i=e(r,...o),c=(a,l)=>{if(l!==void 0){if(a!==2)throw new Error("cipher output not supported");ot$1(l);}};let f=false;return {encrypt(a,l){if(f)throw new Error("cannot encrypt() twice with same key + nonce");return f=true,ot$1(a),c(i.encrypt.length,l),i.encrypt(a,l)},decrypt(a,l){if(ot$1(a),s&&a.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return c(i.decrypt.length,l),i.decrypt(a,l)}}}return Object.assign(n,t),n};function po$1(t,e,n=true){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(n&&!ef(e))throw new Error("invalid output, must be aligned");return e}function go$1(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),f=4,u=0;t.setUint32(e+f,i,r),t.setUint32(e+u,c,r);}function tf(t,e,n){vn$1(n);const r=new Uint8Array(16),o=zc(r);return go$1(o,0,BigInt(e),n),go$1(o,8,BigInt(t),n),r}function ef(t){return t.byteOffset%4===0}function Bn$1(t){return Uint8Array.from(t)}const bo$1=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),nf=bo$1("expand 16-byte k"),rf=bo$1("expand 32-byte k"),of=Pt$2(nf),sf=Pt$2(rf);function K$1(t,e){return t<<e|t>>>32-e}function An$1(t){return t.byteOffset%4===0}const Le$2=64,cf=16,yo$1=2**32-1,mo$1=new Uint32Array;function ff(t,e,n,r,o,s,i,c){const f=o.length,u=new Uint8Array(Le$2),a=Pt$2(u),l=An$1(o)&&An$1(s),d=l?Pt$2(o):mo$1,h=l?Pt$2(s):mo$1;for(let y=0;y<f;i++){if(t(e,n,r,a,i,c),i>=yo$1)throw new Error("arx: counter overflow");const m=Math.min(Le$2,f-y);if(l&&m===Le$2){const v=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let U=0,F;U<cf;U++)F=v+U,h[F]=d[F]^a[U];y+=Le$2;continue}for(let v=0,U;v<m;v++)U=y+v,s[U]=o[U]^u[v];y+=m;}}function af(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=Xc({allowShortKeys:false,counterLength:8,counterRight:false,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return xn$1(o),xn$1(i),vn$1(s),vn$1(n),(c,f,u,a,l=0)=>{ot$1(c),ot$1(f),ot$1(u);const d=u.length;if(a===void 0&&(a=new Uint8Array(d)),ot$1(a),xn$1(l),l<0||l>=yo$1)throw new Error("arx: counter overflow");if(a.length<d)throw new Error(`arx: output (${a.length}) is shorter than data (${d})`);const h=[];let y=c.length,m,v;if(y===32)h.push(m=Bn$1(c)),v=sf;else if(y===16&&n)m=new Uint8Array(32),m.set(c),m.set(c,16),v=of,h.push(m);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);An$1(f)||h.push(f=Bn$1(f));const U=Pt$2(m);if(r){if(f.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(v,U,Pt$2(f.subarray(0,16)),U),f=f.subarray(16);}const F=16-o;if(F!==f.length)throw new Error(`arx: nonce must be ${F} or 16 bytes`);if(F!==12){const Z=new Uint8Array(12);Z.set(f,s?0:12-f.length),f=Z,h.push(f);}const R=Pt$2(f);return ff(t,v,U,R,u,a,l,i),Qt$2(...h),a}}const W$3=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class uf{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=false,e=En$1(e),ot$1(e,32);const n=W$3(e,0),r=W$3(e,2),o=W$3(e,4),s=W$3(e,6),i=W$3(e,8),c=W$3(e,10),f=W$3(e,12),u=W$3(e,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|s<<9)&8191,this.r[4]=(s>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let a=0;a<8;a++)this.pad[a]=W$3(e,16+2*a);}process(e,n,r=false){const o=r?0:2048,{h:s,r:i}=this,c=i[0],f=i[1],u=i[2],a=i[3],l=i[4],d=i[5],h=i[6],y=i[7],m=i[8],v=i[9],U=W$3(e,n+0),F=W$3(e,n+2),R=W$3(e,n+4),Z=W$3(e,n+6),H=W$3(e,n+8),j=W$3(e,n+10),L=W$3(e,n+12),k=W$3(e,n+14);let O=s[0]+(U&8191),T=s[1]+((U>>>13|F<<3)&8191),C=s[2]+((F>>>10|R<<6)&8191),_=s[3]+((R>>>7|Z<<9)&8191),p=s[4]+((Z>>>4|H<<12)&8191),b=s[5]+(H>>>1&8191),g=s[6]+((H>>>14|j<<2)&8191),x=s[7]+((j>>>11|L<<5)&8191),E=s[8]+((L>>>8|k<<8)&8191),A=s[9]+(k>>>5|o),w=0,B=w+O*c+T*(5*v)+C*(5*m)+_*(5*y)+p*(5*h);w=B>>>13,B&=8191,B+=b*(5*d)+g*(5*l)+x*(5*a)+E*(5*u)+A*(5*f),w+=B>>>13,B&=8191;let I=w+O*f+T*c+C*(5*v)+_*(5*m)+p*(5*y);w=I>>>13,I&=8191,I+=b*(5*h)+g*(5*d)+x*(5*l)+E*(5*a)+A*(5*u),w+=I>>>13,I&=8191;let N=w+O*u+T*f+C*c+_*(5*v)+p*(5*m);w=N>>>13,N&=8191,N+=b*(5*y)+g*(5*h)+x*(5*d)+E*(5*l)+A*(5*a),w+=N>>>13,N&=8191;let D=w+O*a+T*u+C*f+_*c+p*(5*v);w=D>>>13,D&=8191,D+=b*(5*m)+g*(5*y)+x*(5*h)+E*(5*d)+A*(5*l),w+=D>>>13,D&=8191;let P=w+O*l+T*a+C*u+_*f+p*c;w=P>>>13,P&=8191,P+=b*(5*v)+g*(5*m)+x*(5*y)+E*(5*h)+A*(5*d),w+=P>>>13,P&=8191;let $=w+O*d+T*l+C*a+_*u+p*f;w=$>>>13,$&=8191,$+=b*c+g*(5*v)+x*(5*m)+E*(5*y)+A*(5*h),w+=$>>>13,$&=8191;let V=w+O*h+T*d+C*l+_*a+p*u;w=V>>>13,V&=8191,V+=b*f+g*c+x*(5*v)+E*(5*m)+A*(5*y),w+=V>>>13,V&=8191;let q=w+O*y+T*h+C*d+_*l+p*a;w=q>>>13,q&=8191,q+=b*u+g*f+x*c+E*(5*v)+A*(5*m),w+=q>>>13,q&=8191;let G=w+O*m+T*y+C*h+_*d+p*l;w=G>>>13,G&=8191,G+=b*a+g*u+x*f+E*c+A*(5*v),w+=G>>>13,G&=8191;let M=w+O*v+T*m+C*y+_*h+p*d;w=M>>>13,M&=8191,M+=b*l+g*a+x*u+E*f+A*c,w+=M>>>13,M&=8191,w=(w<<2)+w|0,w=w+B|0,B=w&8191,w=w>>>13,I+=w,s[0]=B,s[1]=I,s[2]=N,s[3]=D,s[4]=P,s[5]=$,s[6]=V,s[7]=q,s[8]=G,s[9]=M;}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let o=e[1]>>>13;e[1]&=8191;for(let c=2;c<10;c++)e[c]+=o,o=e[c]>>>13,e[c]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=e[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let s=(o^1)-1;for(let c=0;c<10;c++)r[c]&=s;s=~s;for(let c=0;c<10;c++)e[c]=e[c]&s|r[c];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+n[0];e[0]=i&65535;for(let c=1;c<8;c++)i=(e[c]+n[c]|0)+(i>>>16)|0,e[c]=i&65535;Qt$2(r);}update(e){ho$1(this),e=En$1(e),ot$1(e);const{buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const i=Math.min(r-this.pos,o-s);if(i===r){for(;r<=o-s;s+=r)this.process(e,s);continue}n.set(e.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(n,0,false),this.pos=0);}return this}destroy(){Qt$2(this.h,this.r,this.buffer,this.pad);}digestInto(e){ho$1(this),Gc(e,this),this.finished=true;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,true);}this.finalize();let s=0;for(let i=0;i<8;i++)e[s++]=r[i]>>>0,e[s++]=r[i]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function lf(t){const e=(r,o)=>t(o).update(En$1(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}const df=lf(t=>new uf(t));function hf(t,e,n,r,o,s=20){let i=t[0],c=t[1],f=t[2],u=t[3],a=e[0],l=e[1],d=e[2],h=e[3],y=e[4],m=e[5],v=e[6],U=e[7],F=o,R=n[0],Z=n[1],H=n[2],j=i,L=c,k=f,O=u,T=a,C=l,_=d,p=h,b=y,g=m,x=v,E=U,A=F,w=R,B=Z,I=H;for(let D=0;D<s;D+=2)j=j+T|0,A=K$1(A^j,16),b=b+A|0,T=K$1(T^b,12),j=j+T|0,A=K$1(A^j,8),b=b+A|0,T=K$1(T^b,7),L=L+C|0,w=K$1(w^L,16),g=g+w|0,C=K$1(C^g,12),L=L+C|0,w=K$1(w^L,8),g=g+w|0,C=K$1(C^g,7),k=k+_|0,B=K$1(B^k,16),x=x+B|0,_=K$1(_^x,12),k=k+_|0,B=K$1(B^k,8),x=x+B|0,_=K$1(_^x,7),O=O+p|0,I=K$1(I^O,16),E=E+I|0,p=K$1(p^E,12),O=O+p|0,I=K$1(I^O,8),E=E+I|0,p=K$1(p^E,7),j=j+C|0,I=K$1(I^j,16),x=x+I|0,C=K$1(C^x,12),j=j+C|0,I=K$1(I^j,8),x=x+I|0,C=K$1(C^x,7),L=L+_|0,A=K$1(A^L,16),E=E+A|0,_=K$1(_^E,12),L=L+_|0,A=K$1(A^L,8),E=E+A|0,_=K$1(_^E,7),k=k+p|0,w=K$1(w^k,16),b=b+w|0,p=K$1(p^b,12),k=k+p|0,w=K$1(w^k,8),b=b+w|0,p=K$1(p^b,7),O=O+T|0,B=K$1(B^O,16),g=g+B|0,T=K$1(T^g,12),O=O+T|0,B=K$1(B^O,8),g=g+B|0,T=K$1(T^g,7);let N=0;r[N++]=i+j|0,r[N++]=c+L|0,r[N++]=f+k|0,r[N++]=u+O|0,r[N++]=a+T|0,r[N++]=l+C|0,r[N++]=d+_|0,r[N++]=h+p|0,r[N++]=y+b|0,r[N++]=m+g|0,r[N++]=v+x|0,r[N++]=U+E|0,r[N++]=F+A|0,r[N++]=R+w|0,r[N++]=Z+B|0,r[N++]=H+I|0;}const pf=af(hf,{counterRight:false,counterLength:4,allowShortKeys:false}),gf=new Uint8Array(16),wo$1=(t,e)=>{t.update(e);const n=e.length%16;n&&t.update(gf.subarray(n));},bf=new Uint8Array(32);function vo$1(t,e,n,r,o){const s=t(e,n,bf),i=df.create(s);o&&wo$1(i,o),wo$1(i,r);const c=tf(r.length,o?o.length:0,true);i.update(c);const f=i.digest();return Qt$2(s,c),f}const yf=t=>(e,n,r)=>({encrypt(s,i){const c=s.length;i=po$1(c+16,i,false),i.set(s);const f=i.subarray(0,-16);t(e,n,f,f,1);const u=vo$1(t,e,n,f,r);return i.set(u,c),Qt$2(u),i},decrypt(s,i){i=po$1(s.length-16,i,false);const c=s.subarray(0,-16),f=s.subarray(-16),u=vo$1(t,e,n,c,r);if(!Jc(f,u))throw new Error("invalid tag");return i.set(s.subarray(0,-16)),t(e,n,i,i,1),Qt$2(u),i}}),xo$1=Qc({blockSize:64,nonceLength:12,tagLength:16},yf(pf));let Eo$1 = class Eo extends Re{constructor(e,n){super(),this.finished=false,this.destroyed=false,Ue$3(e);const r=pt$1(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),lt$1(s);}update(e){return Nt$2(this),this.iHash.update(e),this}digestInto(e){Nt$2(this),ht$1(e,this.outputLen),this.finished=true,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy();}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=true,this.oHash.destroy(),this.iHash.destroy();}};const ke$3=(t,e,n)=>new Eo$1(t,e).update(n).digest();ke$3.create=(t,e)=>new Eo$1(t,e);function mf(t,e,n){return Ue$3(t),n===void 0&&(n=new Uint8Array(t.outputLen)),ke$3(t,pt$1(n),pt$1(e))}const In$1=Uint8Array.from([0]),Bo$1=Uint8Array.of();function wf(t,e,n,r=32){Ue$3(t),mt$2(r);const o=t.outputLen;if(r>255*o)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(r/o);n===void 0&&(n=Bo$1);const i=new Uint8Array(s*o),c=ke$3.create(t,e),f=c._cloneInto(),u=new Uint8Array(c.outputLen);for(let a=0;a<s;a++)In$1[0]=a+1,f.update(a===0?Bo$1:u).update(n).update(In$1).digestInto(u),i.set(u,o*a),c._cloneInto(f);return c.destroy(),f.destroy(),lt$1(u,In$1),i.slice(0,r)}const vf=(t,e,n,r,o)=>wf(t,mf(t,e,n),r,o),Pe$3=$e$2,Sn$1=BigInt(0),On$1=BigInt(1);function He$2(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Kt$2(t,e,n=""){const r=Ne(t),o=t?.length,s=e!==void 0;if(!r||s&&o!==e){const i=n&&`"${n}" `,c=s?` of length ${e}`:"",f=r?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+f)}return t}function De$2(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Ao$1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Sn$1:BigInt("0x"+t)}function Ve$3(t){return Ao$1(Jt$2(t))}function Me$4(t){return ht$1(t),Ao$1(Jt$2(Uint8Array.from(t).reverse()))}function Nn$1(t,e){return _e$3(t.toString(16).padStart(e*2,"0"))}function Un$1(t,e){return Nn$1(t,e).reverse()}function tt$2(t,e,n){let r;if(typeof e=="string")try{r=_e$3(e);}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ne(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(t+" of length "+n+" expected, got "+o);return r}const _n$1=t=>typeof t=="bigint"&&Sn$1<=t;function xf(t,e,n){return _n$1(t)&&_n$1(e)&&_n$1(n)&&e<=t&&t<n}function Rn$1(t,e,n,r){if(!xf(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function Io$1(t){let e;for(e=0;t>Sn$1;t>>=On$1,e+=1);return e}const ye$3=t=>(On$1<<BigInt(t))-On$1;function Ef(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=h=>new Uint8Array(h),o=h=>Uint8Array.of(h);let s=r(t),i=r(t),c=0;const f=()=>{s.fill(1),i.fill(0),c=0;},u=(...h)=>n(i,s,...h),a=(h=r(0))=>{i=u(o(0),h),s=u(),h.length!==0&&(i=u(o(1),h),s=u());},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const y=[];for(;h<e;){s=u();const m=s.slice();y.push(m),h+=s.length;}return _t$2(...y)};return (h,y)=>{f(),a(h);let m;for(;!(m=y(l()));)a();return f(),m}}function Ke$3(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(o,s,i){const c=t[o];if(i&&c===void 0)return;const f=typeof c;if(f!==s||c===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${f}`)}Object.entries(e).forEach(([o,s])=>r(o,s,false)),Object.entries(n).forEach(([o,s])=>r(o,s,true));}function So$1(t){const e=new WeakMap;return (n,...r)=>{const o=e.get(n);if(o!==void 0)return o;const s=t(n,...r);return e.set(n,s),s}}const st$1=BigInt(0),nt$1=BigInt(1),qt$2=BigInt(2),Oo$1=BigInt(3),No$1=BigInt(4),Uo$1=BigInt(5),Bf=BigInt(7),_o$1=BigInt(8),Af=BigInt(9),Ro$1=BigInt(16);function ct$1(t,e){const n=t%e;return n>=st$1?n:e+n}function gt$2(t,e,n){let r=t;for(;e-- >st$1;)r*=r,r%=n;return r}function $o$1(t,e){if(t===st$1)throw new Error("invert: expected non-zero number");if(e<=st$1)throw new Error("invert: expected positive modulus, got "+e);let n=ct$1(t,e),r=e,o=st$1,s=nt$1;for(;n!==st$1;){const c=r/n,f=r%n,u=o-s*c;r=n,n=f,o=s,s=u;}if(r!==nt$1)throw new Error("invert: does not exist");return ct$1(o,e)}function $n$1(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function To$1(t,e){const n=(t.ORDER+nt$1)/No$1,r=t.pow(e,n);return $n$1(t,r,e),r}function If(t,e){const n=(t.ORDER-Uo$1)/_o$1,r=t.mul(e,qt$2),o=t.pow(r,n),s=t.mul(e,o),i=t.mul(t.mul(s,qt$2),o),c=t.mul(s,t.sub(i,t.ONE));return $n$1(t,c,e),c}function Sf(t){const e=Ht$2(t),n=Co$1(t),r=n(e,e.neg(e.ONE)),o=n(e,r),s=n(e,e.neg(r)),i=(t+Bf)/Ro$1;return (c,f)=>{let u=c.pow(f,i),a=c.mul(u,r);const l=c.mul(u,o),d=c.mul(u,s),h=c.eql(c.sqr(a),f),y=c.eql(c.sqr(l),f);u=c.cmov(u,a,h),a=c.cmov(d,l,y);const m=c.eql(c.sqr(a),f),v=c.cmov(u,a,m);return $n$1(c,v,f),v}}function Co$1(t){if(t<Oo$1)throw new Error("sqrt is not defined for small field");let e=t-nt$1,n=0;for(;e%qt$2===st$1;)e/=qt$2,n++;let r=qt$2;const o=Ht$2(t);for(;Lo$1(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return To$1;let s=o.pow(r,e);const i=(e+nt$1)/qt$2;return function(f,u){if(f.is0(u))return u;if(Lo$1(f,u)!==1)throw new Error("Cannot find square root");let a=n,l=f.mul(f.ONE,s),d=f.pow(u,e),h=f.pow(u,i);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let y=1,m=f.sqr(d);for(;!f.eql(m,f.ONE);)if(y++,m=f.sqr(m),y===a)throw new Error("Cannot find square root");const v=nt$1<<BigInt(a-y-1),U=f.pow(l,v);a=y,l=f.sqr(U),d=f.mul(d,l),h=f.mul(h,U);}return h}}function Of(t){return t%No$1===Oo$1?To$1:t%_o$1===Uo$1?If:t%Ro$1===Af?Sf(t):Co$1(t)}const Nf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uf(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Nf.reduce((r,o)=>(r[o]="function",r),e);return Ke$3(t,n),t}function _f(t,e,n){if(n<st$1)throw new Error("invalid exponent, negatives unsupported");if(n===st$1)return t.ONE;if(n===nt$1)return e;let r=t.ONE,o=e;for(;n>st$1;)n&nt$1&&(r=t.mul(r,o)),o=t.sqr(o),n>>=nt$1;return r}function jo$1(t,e,n=false){const r=new Array(e.length).fill(n?t.ZERO:void 0),o=e.reduce((i,c,f)=>t.is0(c)?i:(r[f]=i,t.mul(i,c)),t.ONE),s=t.inv(o);return e.reduceRight((i,c,f)=>t.is0(c)?i:(r[f]=t.mul(i,r[f]),t.mul(i,c)),s),r}function Lo$1(t,e){const n=(t.ORDER-nt$1)/qt$2,r=t.pow(e,n),o=t.eql(r,t.ONE),s=t.eql(r,t.ZERO),i=t.eql(r,t.neg(t.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function ko$1(t,e){e!==void 0&&mt$2(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return {nBitLength:n,nByteLength:r}}function Ht$2(t,e,n=false,r={}){if(t<=st$1)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,s,i=false,c;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=e;d.BITS&&(o=d.BITS),d.sqrt&&(s=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(i=d.modFromBytes),c=d.allowedLengths;}else typeof e=="number"&&(o=e),r.sqrt&&(s=r.sqrt);const{nBitLength:f,nByteLength:u}=ko$1(t,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const l=Object.freeze({ORDER:t,isLE:n,BITS:f,BYTES:u,MASK:ye$3(f),ZERO:st$1,ONE:nt$1,allowedLengths:c,create:d=>ct$1(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return st$1<=d&&d<t},is0:d=>d===st$1,isValidNot0:d=>!l.is0(d)&&l.isValid(d),isOdd:d=>(d&nt$1)===nt$1,neg:d=>ct$1(-d,t),eql:(d,h)=>d===h,sqr:d=>ct$1(d*d,t),add:(d,h)=>ct$1(d+h,t),sub:(d,h)=>ct$1(d-h,t),mul:(d,h)=>ct$1(d*h,t),pow:(d,h)=>_f(l,d,h),div:(d,h)=>ct$1(d*$o$1(h,t),t),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>$o$1(d,t),sqrt:s||(d=>(a||(a=Of(t)),a(l,d))),toBytes:d=>n?Un$1(d,u):Nn$1(d,u),fromBytes:(d,h=true)=>{if(c){if(!c.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);const m=new Uint8Array(u);m.set(d,n?0:m.length-d.length),d=m;}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let y=n?Me$4(d):Ve$3(d);if(i&&(y=ct$1(y,t)),!h&&!l.isValid(y))throw new Error("invalid field element: outside of range 0..ORDER");return y},invertBatch:d=>jo$1(l,d),cmov:(d,h,y)=>y?h:d});return Object.freeze(l)}function Po$1(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ho$1(t){const e=Po$1(t);return e+Math.ceil(e/2)}function Rf(t,e,n=false){const r=t.length,o=Po$1(e),s=Ho$1(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?Me$4(t):Ve$3(t),c=ct$1(i,e-nt$1)+nt$1;return n?Un$1(c,o):Nn$1(c,o)}const te$2=BigInt(0),Ft$2=BigInt(1);function qe$1(t,e){const n=e.negate();return t?n:e}function Tn$1(t,e){const n=jo$1(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function Do$1(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Cn$1(t,e){Do$1(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),o=2**t,s=ye$3(t),i=BigInt(t);return {windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function Vo$1(t,e,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let c=Number(t&o),f=t>>i;c>r&&(c-=s,f+=Ft$2);const u=e*r,a=u+Math.abs(c)-1,l=c===0,d=c<0,h=e%2!==0;return {nextN:f,offset:a,isZero:l,isNeg:d,isNegF:h,offsetF:u}}function $f(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)});}function Tf(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)});}const jn$1=new WeakMap,Mo$1=new WeakMap;function Ln$1(t){return Mo$1.get(t)||1}function Ko$1(t){if(t!==te$2)throw new Error("invalid wNAF")}class Cf{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n;}_unsafeLadder(e,n,r=this.ZERO){let o=e;for(;n>te$2;)n&Ft$2&&(r=r.add(o)),o=o.double(),n>>=Ft$2;return r}precomputeWindow(e,n){const{windows:r,windowSize:o}=Cn$1(n,this.bits),s=[];let i=e,c=i;for(let f=0;f<r;f++){c=i,s.push(c);for(let u=1;u<o;u++)c=c.add(i),s.push(c);i=c.double();}return s}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=Cn$1(e,this.bits);for(let c=0;c<i.windows;c++){const{nextN:f,offset:u,isZero:a,isNeg:l,isNegF:d,offsetF:h}=Vo$1(r,c,i);r=f,a?s=s.add(qe$1(d,n[h])):o=o.add(qe$1(l,n[u]));}return Ko$1(r),{p:o,f:s}}wNAFUnsafe(e,n,r,o=this.ZERO){const s=Cn$1(e,this.bits);for(let i=0;i<s.windows&&r!==te$2;i++){const{nextN:c,offset:f,isZero:u,isNeg:a}=Vo$1(r,i,s);if(r=c,!u){const l=n[f];o=o.add(a?l.negate():l);}}return Ko$1(r),o}getPrecomputes(e,n,r){let o=jn$1.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(o=r(o)),jn$1.set(n,o))),o}cached(e,n,r){const o=Ln$1(e);return this.wNAF(o,this.getPrecomputes(o,e,r),n)}unsafe(e,n,r,o){const s=Ln$1(e);return s===1?this._unsafeLadder(e,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),n,o)}createCache(e,n){Do$1(n,this.bits),Mo$1.set(e,n),jn$1.delete(e);}hasCache(e){return Ln$1(e)!==1}}function jf(t,e,n,r){let o=e,s=t.ZERO,i=t.ZERO;for(;n>te$2||r>te$2;)n&Ft$2&&(s=s.add(o)),r&Ft$2&&(i=i.add(o)),o=o.double(),n>>=Ft$2,r>>=Ft$2;return {p1:s,p2:i}}function Lf(t,e,n,r){$f(n,t),Tf(r,e);const o=n.length,s=r.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,c=Io$1(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const u=ye$3(f),a=new Array(Number(u)+1).fill(i),l=Math.floor((e.BITS-1)/f)*f;let d=i;for(let h=l;h>=0;h-=f){a.fill(i);for(let m=0;m<s;m++){const v=r[m],U=Number(v>>BigInt(h)&u);a[U]=a[U].add(n[m]);}let y=i;for(let m=a.length-1,v=i;m>0;m--)v=v.add(a[m]),y=y.add(v);if(d=d.add(y),h!==0)for(let m=0;m<f;m++)d=d.double();}return d}function qo$1(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Uf(e),e}else return Ht$2(t,{isLE:n})}function kf(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const f of ["p","n","h"]){const u=e[f];if(!(typeof u=="bigint"&&u>te$2))throw new Error(`CURVE.${f} must be positive bigint`)}const o=qo$1(e.p,n.Fp,r),s=qo$1(e.n,n.Fn,r),c=["Gx","Gy","a","b"];for(const f of c)if(!o.isValid(e[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}BigInt(0),BigInt(1),BigInt(2),BigInt(8),kr$1("HashToScalar-");const me$4=BigInt(0),ee$3=BigInt(1),Fe$3=BigInt(2);function Pf(t){return Ke$3(t,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...t})}function Hf(t){const e=Pf(t),{P:n,type:r,adjustScalarBytes:o,powPminus2:s,randomBytes:i}=e,c=r==="x25519";if(!c&&r!=="x448")throw new Error("invalid type");const f=i||Mt$2,u=c?255:448,a=c?32:56,l=BigInt(c?9:5),d=BigInt(c?121665:39081),h=c?Fe$3**BigInt(254):Fe$3**BigInt(447),y=c?BigInt(8)*Fe$3**BigInt(251)-ee$3:BigInt(4)*Fe$3**BigInt(445)-ee$3,m=h+y+ee$3,v=p=>ct$1(p,n),U=F(l);function F(p){return Un$1(v(p),a)}function R(p){const b=tt$2("u coordinate",p,a);return c&&(b[31]&=127),v(Me$4(b))}function Z(p){return Me$4(o(tt$2("scalar",p,a)))}function H(p,b){const g=k(R(b),Z(p));if(g===me$4)throw new Error("invalid private or public key received");return F(g)}function j(p){return H(p,U)}function L(p,b,g){const x=v(p*(b-g));return b=v(b-x),g=v(g+x),{x_2:b,x_3:g}}function k(p,b){Rn$1("u",p,me$4,n),Rn$1("scalar",b,h,m);const g=b,x=p;let E=ee$3,A=me$4,w=p,B=ee$3,I=me$4;for(let D=BigInt(u-1);D>=me$4;D--){const P=g>>D&ee$3;I^=P,{x_2:E,x_3:w}=L(I,E,w),{x_2:A,x_3:B}=L(I,A,B),I=P;const $=E+A,V=v($*$),q=E-A,G=v(q*q),M=V-G,Y=w+B,Yt=w-B,ce=v(Yt*$),fe=v(Y*q),Qn=ce+fe,tr=ce-fe;w=v(Qn*Qn),B=v(x*v(tr*tr)),E=v(V*G),A=v(M*(V+v(d*M)));}(({x_2:E,x_3:w}=L(I,E,w))),{x_2:A,x_3:B}=L(I,A,B);const N=s(A);return v(E*N)}const O={secretKey:a,publicKey:a,seed:a},T=(p=f(a))=>(ht$1(p,O.seed),p);function C(p){const b=T(p);return {secretKey:b,publicKey:j(b)}}return {keygen:C,getSharedSecret:(p,b)=>H(p,b),getPublicKey:p=>j(p),scalarMult:H,scalarMultBase:j,utils:{randomSecretKey:T,randomPrivateKey:T},GuBytes:U.slice(),lengths:O}}const Df=BigInt(1),Fo$1=BigInt(2),Vf=BigInt(3),Mf=BigInt(5);BigInt(8);const Zo$1=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),qf={p:Zo$1,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ff(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=Zo$1,c=t*t%s*t%s,f=gt$2(c,Fo$1,s)*c%s,u=gt$2(f,Df,s)*t%s,a=gt$2(u,Mf,s)*u%s,l=gt$2(a,e,s)*a%s,d=gt$2(l,n,s)*l%s,h=gt$2(d,r,s)*d%s,y=gt$2(h,o,s)*h%s,m=gt$2(y,o,s)*h%s,v=gt$2(m,e,s)*a%s;return {pow_p_5_8:gt$2(v,Fo$1,s)*t%s,b2:c}}function Zf(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Gf=Ht$2(qf.p,{isLE:true}),kn$1=(()=>{const t=Gf.ORDER;return Hf({P:t,type:"x25519",powPminus2:e=>{const{pow_p_5_8:n,b2:r}=Ff(e);return ct$1(gt$2(n,Vf,t)*r,t)},adjustScalarBytes:Zf})})(),Go$1=(t,e)=>(t+(t>=0?e:-e)/zo$1)/e;function zf(t,e,n){const[[r,o],[s,i]]=e,c=Go$1(i*t,n),f=Go$1(-o*t,n);let u=t-c*r-f*s,a=-c*o-f*i;const l=u<Et$3,d=a<Et$3;l&&(u=-u),d&&(a=-a);const h=ye$3(Math.ceil(Io$1(n)/2))+ne$2;if(u<Et$3||u>=h||a<Et$3||a>=h)throw new Error("splitScalar (endomorphism): failed, k="+t);return {k1neg:l,k1:u,k2neg:d,k2:a}}function Pn$1(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Hn$1(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return He$2(n.lowS,"lowS"),He$2(n.prehash,"prehash"),n.format!==void 0&&Pn$1(n.format),n}class Yf extends Error{constructor(e=""){super(e);}}const xt$2={Err:Yf,_tlv:{encode:(t,e)=>{const{Err:n}=xt$2;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,o=De$2(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?De$2(o.length/2|128):"";return De$2(t)+s+o+e},decode(t,e){const{Err:n}=xt$2;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const o=e[r++],s=!!(o&128);let i=0;if(!s)i=o;else {const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+f);if(u.length!==f)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const a of u)i=i<<8|a;if(r+=f,i<128)throw new n("tlv.decode(long): not minimal encoding")}const c=e.subarray(r,r+i);if(c.length!==i)throw new n("tlv.decode: wrong value length");return {v:c,l:e.subarray(r+i)}}},_int:{encode(t){const{Err:e}=xt$2;if(t<Et$3)throw new e("integer: negative integers are not allowed");let n=De$2(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=xt$2;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ve$3(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=xt$2,o=tt$2("signature",t),{v:s,l:i}=r.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,s),{v:u,l:a}=r.decode(2,f);if(a.length)throw new e("invalid signature: left bytes after parsing");return {r:n.decode(c),s:n.decode(u)}},hexFromSig(t){const{_tlv:e,_int:n}=xt$2,r=e.encode(2,n.encode(t.r)),o=e.encode(2,n.encode(t.s)),s=r+o;return e.encode(48,s)}},Et$3=BigInt(0),ne$2=BigInt(1),zo$1=BigInt(2),Ze$2=BigInt(3),Wf=BigInt(4);function re$2(t,e){const{BYTES:n}=t;let r;if(typeof e=="bigint")r=e;else {let o=tt$2("private key",e);try{r=t.fromBytes(o);}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof e}`)}}if(!t.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Xf(t,e={}){const n=kf("weierstrass",t,e),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:c}=s;Ke$3(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=e;if(f&&(!r.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=Wo$1(r,o);function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(_,p,b){const{x:g,y:x}=p.toAffine(),E=r.toBytes(g);if(He$2(b,"isCompressed"),b){a();const A=!r.isOdd(x);return _t$2(Yo$1(A),E)}else return _t$2(Uint8Array.of(4),E,r.toBytes(x))}function d(_){Kt$2(_,void 0,"Point");const{publicKey:p,publicKeyUncompressed:b}=u,g=_.length,x=_[0],E=_.subarray(1);if(g===p&&(x===2||x===3)){const A=r.fromBytes(E);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");const w=m(A);let B;try{B=r.sqrt(w);}catch(D){const P=D instanceof Error?": "+D.message:"";throw new Error("bad point: is not on curve, sqrt error"+P)}a();const I=r.isOdd(B);return (x&1)===1!==I&&(B=r.neg(B)),{x:A,y:B}}else if(g===b&&x===4){const A=r.BYTES,w=r.fromBytes(E.subarray(0,A)),B=r.fromBytes(E.subarray(A,A*2));if(!v(w,B))throw new Error("bad point: is not on curve");return {x:w,y:B}}else throw new Error(`bad point: got length ${g}, expected compressed=${p} or uncompressed=${b}`)}const h=e.toBytes||l,y=e.fromBytes||d;function m(_){const p=r.sqr(_),b=r.mul(p,_);return r.add(r.add(b,r.mul(_,s.a)),s.b)}function v(_,p){const b=r.sqr(p),g=m(_);return r.eql(b,g)}if(!v(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const U=r.mul(r.pow(s.a,Ze$2),Wf),F=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(U,F)))throw new Error("bad curve params: a or b");function R(_,p,b=false){if(!r.isValid(p)||b&&r.is0(p))throw new Error(`bad point coordinate ${_}`);return p}function Z(_){if(!(_ instanceof O))throw new Error("ProjectivePoint expected")}function H(_){if(!f||!f.basises)throw new Error("no endo");return zf(_,f.basises,o.ORDER)}const j=So$1((_,p)=>{const{X:b,Y:g,Z:x}=_;if(r.eql(x,r.ONE))return {x:b,y:g};const E=_.is0();p==null&&(p=E?r.ONE:r.inv(x));const A=r.mul(b,p),w=r.mul(g,p),B=r.mul(x,p);if(E)return {x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return {x:A,y:w}}),L=So$1(_=>{if(_.is0()){if(e.allowInfinityPoint&&!r.is0(_.Y))return;throw new Error("bad point: ZERO")}const{x:p,y:b}=_.toAffine();if(!r.isValid(p)||!r.isValid(b))throw new Error("bad point: x or y not field elements");if(!v(p,b))throw new Error("bad point: equation left != right");if(!_.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return true});function k(_,p,b,g,x){return b=new O(r.mul(b.X,_),b.Y,b.Z),p=qe$1(g,p),b=qe$1(x,b),p.add(b)}class O{constructor(p,b,g){this.X=R("x",p),this.Y=R("y",b,true),this.Z=R("z",g),Object.freeze(this);}static CURVE(){return s}static fromAffine(p){const{x:b,y:g}=p||{};if(!p||!r.isValid(b)||!r.isValid(g))throw new Error("invalid affine point");if(p instanceof O)throw new Error("projective point not allowed");return r.is0(b)&&r.is0(g)?O.ZERO:new O(b,g,r.ONE)}static fromBytes(p){const b=O.fromAffine(y(Kt$2(p,void 0,"point")));return b.assertValidity(),b}static fromHex(p){return O.fromBytes(tt$2("pointHex",p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,b=true){return C.createCache(this,p),b||this.multiply(Ze$2),this}assertValidity(){L(this);}hasEvenY(){const{y:p}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return !r.isOdd(p)}equals(p){Z(p);const{X:b,Y:g,Z:x}=this,{X:E,Y:A,Z:w}=p,B=r.eql(r.mul(b,w),r.mul(E,x)),I=r.eql(r.mul(g,w),r.mul(A,x));return B&&I}negate(){return new O(this.X,r.neg(this.Y),this.Z)}double(){const{a:p,b}=s,g=r.mul(b,Ze$2),{X:x,Y:E,Z:A}=this;let w=r.ZERO,B=r.ZERO,I=r.ZERO,N=r.mul(x,x),D=r.mul(E,E),P=r.mul(A,A),$=r.mul(x,E);return $=r.add($,$),I=r.mul(x,A),I=r.add(I,I),w=r.mul(p,I),B=r.mul(g,P),B=r.add(w,B),w=r.sub(D,B),B=r.add(D,B),B=r.mul(w,B),w=r.mul($,w),I=r.mul(g,I),P=r.mul(p,P),$=r.sub(N,P),$=r.mul(p,$),$=r.add($,I),I=r.add(N,N),N=r.add(I,N),N=r.add(N,P),N=r.mul(N,$),B=r.add(B,N),P=r.mul(E,A),P=r.add(P,P),N=r.mul(P,$),w=r.sub(w,N),I=r.mul(P,D),I=r.add(I,I),I=r.add(I,I),new O(w,B,I)}add(p){Z(p);const{X:b,Y:g,Z:x}=this,{X:E,Y:A,Z:w}=p;let B=r.ZERO,I=r.ZERO,N=r.ZERO;const D=s.a,P=r.mul(s.b,Ze$2);let $=r.mul(b,E),V=r.mul(g,A),q=r.mul(x,w),G=r.add(b,g),M=r.add(E,A);G=r.mul(G,M),M=r.add($,V),G=r.sub(G,M),M=r.add(b,x);let Y=r.add(E,w);return M=r.mul(M,Y),Y=r.add($,q),M=r.sub(M,Y),Y=r.add(g,x),B=r.add(A,w),Y=r.mul(Y,B),B=r.add(V,q),Y=r.sub(Y,B),N=r.mul(D,M),B=r.mul(P,q),N=r.add(B,N),B=r.sub(V,N),N=r.add(V,N),I=r.mul(B,N),V=r.add($,$),V=r.add(V,$),q=r.mul(D,q),M=r.mul(P,M),V=r.add(V,q),q=r.sub($,q),q=r.mul(D,q),M=r.add(M,q),$=r.mul(V,M),I=r.add(I,$),$=r.mul(Y,M),B=r.mul(G,B),B=r.sub(B,$),$=r.mul(G,V),N=r.mul(Y,N),N=r.add(N,$),new O(B,I,N)}subtract(p){return this.add(p.negate())}is0(){return this.equals(O.ZERO)}multiply(p){const{endo:b}=e;if(!o.isValidNot0(p))throw new Error("invalid scalar: out of range");let g,x;const E=A=>C.cached(this,A,w=>Tn$1(O,w));if(b){const{k1neg:A,k1:w,k2neg:B,k2:I}=H(p),{p:N,f:D}=E(w),{p:P,f:$}=E(I);x=D.add($),g=k(b.beta,N,P,A,B);}else {const{p:A,f:w}=E(p);g=A,x=w;}return Tn$1(O,[g,x])[0]}multiplyUnsafe(p){const{endo:b}=e,g=this;if(!o.isValid(p))throw new Error("invalid scalar: out of range");if(p===Et$3||g.is0())return O.ZERO;if(p===ne$2)return g;if(C.hasCache(this))return this.multiply(p);if(b){const{k1neg:x,k1:E,k2neg:A,k2:w}=H(p),{p1:B,p2:I}=jf(O,g,E,w);return k(b.beta,B,I,x,A)}else return C.unsafe(g,p)}multiplyAndAddUnsafe(p,b,g){const x=this.multiplyUnsafe(b).add(p.multiplyUnsafe(g));return x.is0()?void 0:x}toAffine(p){return j(this,p)}isTorsionFree(){const{isTorsionFree:p}=e;return i===ne$2?true:p?p(O,this):C.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:p}=e;return i===ne$2?this:p?p(O,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(p=true){return He$2(p,"isCompressed"),this.assertValidity(),h(O,this,p)}toHex(p=true){return Jt$2(this.toBytes(p))}toString(){return `<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(p=true){return this.toBytes(p)}_setWindowSize(p){this.precompute(p);}static normalizeZ(p){return Tn$1(O,p)}static msm(p,b){return Lf(O,o,p,b)}static fromPrivateKey(p){return O.BASE.multiply(re$2(o,p))}}O.BASE=new O(s.Gx,s.Gy,r.ONE),O.ZERO=new O(r.ZERO,r.ONE,r.ZERO),O.Fp=r,O.Fn=o;const T=o.BITS,C=new Cf(O,e.endo?Math.ceil(T/2):T);return O.BASE.precompute(8),O}function Yo$1(t){return Uint8Array.of(t?2:3)}function Wo$1(t,e){return {secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:true,signature:2*e.BYTES}}function Jf(t,e={}){const{Fn:n}=t,r=e.randomBytes||Mt$2,o=Object.assign(Wo$1(t.Fp,n),{seed:Ho$1(n.ORDER)});function s(h){try{return !!re$2(n,h)}catch{return false}}function i(h,y){const{publicKey:m,publicKeyUncompressed:v}=o;try{const U=h.length;return y===!0&&U!==m||y===!1&&U!==v?!1:!!t.fromBytes(h)}catch{return false}}function c(h=r(o.seed)){return Rf(Kt$2(h,o.seed,"seed"),n.ORDER)}function f(h,y=true){return t.BASE.multiply(re$2(n,h)).toBytes(y)}function u(h){const y=c(h);return {secretKey:y,publicKey:f(y)}}function a(h){if(typeof h=="bigint")return false;if(h instanceof t)return true;const{secretKey:y,publicKey:m,publicKeyUncompressed:v}=o;if(n.allowedLengths||y===m)return;const U=tt$2("key",h).length;return U===m||U===v}function l(h,y,m=true){if(a(h)===true)throw new Error("first arg must be private key");if(a(y)===false)throw new Error("second arg must be public key");const v=re$2(n,h);return t.fromHex(y).multiply(v).toBytes(m)}return Object.freeze({getPublicKey:f,getSharedSecret:l,keygen:u,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:h=>re$2(n,h),precompute(h=8,y=t.BASE){return y.precompute(h,false)}},lengths:o})}function Qf(t,e,n={}){Ue$3(e),Ke$3(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Mt$2,o=n.hmac||((b,...g)=>ke$3(e,b,_t$2(...g))),{Fp:s,Fn:i}=t,{ORDER:c,BITS:f}=i,{keygen:u,getPublicKey:a,getSharedSecret:l,utils:d,lengths:h}=Jf(t,n),y={prehash:false,lowS:typeof n.lowS=="boolean"?n.lowS:false,format:void 0,extraEntropy:false},m="compact";function v(b){const g=c>>ne$2;return b>g}function U(b,g){if(!i.isValidNot0(g))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return g}function F(b,g){Pn$1(g);const x=h.signature,E=g==="compact"?x:g==="recovered"?x+1:void 0;return Kt$2(b,E,`${g} signature`)}class R{constructor(g,x,E){this.r=U("r",g),this.s=U("s",x),E!=null&&(this.recovery=E),Object.freeze(this);}static fromBytes(g,x=m){F(g,x);let E;if(x==="der"){const{r:I,s:N}=xt$2.toSig(Kt$2(g));return new R(I,N)}x==="recovered"&&(E=g[0],x="compact",g=g.subarray(1));const A=i.BYTES,w=g.subarray(0,A),B=g.subarray(A,A*2);return new R(i.fromBytes(w),i.fromBytes(B),E)}static fromHex(g,x){return this.fromBytes(_e$3(g),x)}addRecoveryBit(g){return new R(this.r,this.s,g)}recoverPublicKey(g){const x=s.ORDER,{r:E,s:A,recovery:w}=this;if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");if(c*zo$1<x&&w>1)throw new Error("recovery id is ambiguous for h>1 curve");const I=w===2||w===3?E+c:E;if(!s.isValid(I))throw new Error("recovery id 2 or 3 invalid");const N=s.toBytes(I),D=t.fromBytes(_t$2(Yo$1((w&1)===0),N)),P=i.inv(I),$=H(tt$2("msgHash",g)),V=i.create(-$*P),q=i.create(A*P),G=t.BASE.multiplyUnsafe(V).add(D.multiplyUnsafe(q));if(G.is0())throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return v(this.s)}toBytes(g=m){if(Pn$1(g),g==="der")return _e$3(xt$2.hexFromSig(this));const x=i.toBytes(this.r),E=i.toBytes(this.s);if(g==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return _t$2(Uint8Array.of(this.recovery),x,E)}return _t$2(x,E)}toHex(g){return Jt$2(this.toBytes(g))}assertValidity(){}static fromCompact(g){return R.fromBytes(tt$2("sig",g),"compact")}static fromDER(g){return R.fromBytes(tt$2("sig",g),"der")}normalizeS(){return this.hasHighS()?new R(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Jt$2(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Jt$2(this.toBytes("compact"))}}const Z=n.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");const x=Ve$3(g),E=g.length*8-f;return E>0?x>>BigInt(E):x},H=n.bits2int_modN||function(g){return i.create(Z(g))},j=ye$3(f);function L(b){return Rn$1("num < 2^"+f,b,Et$3,j),i.toBytes(b)}function k(b,g){return Kt$2(b,void 0,"message"),g?Kt$2(e(b),void 0,"prehashed message"):b}function O(b,g,x){if(["recovered","canonical"].some(V=>V in x))throw new Error("sign() legacy options not supported");const{lowS:E,prehash:A,extraEntropy:w}=Hn$1(x,y);b=k(b,A);const B=H(b),I=re$2(i,g),N=[L(I),L(B)];if(w!=null&&w!==false){const V=w===true?r(h.secretKey):w;N.push(tt$2("extraEntropy",V));}const D=_t$2(...N),P=B;function $(V){const q=Z(V);if(!i.isValidNot0(q))return;const G=i.inv(q),M=t.BASE.multiply(q).toAffine(),Y=i.create(M.x);if(Y===Et$3)return;const Yt=i.create(G*i.create(P+Y*I));if(Yt===Et$3)return;let ce=(M.x===Y?0:2)|Number(M.y&ne$2),fe=Yt;return E&&v(Yt)&&(fe=i.neg(Yt),ce^=1),new R(Y,fe,ce)}return {seed:D,k2sig:$}}function T(b,g,x={}){b=tt$2("message",b);const{seed:E,k2sig:A}=O(b,g,x);return Ef(e.outputLen,i.BYTES,o)(E,A)}function C(b){let g;const x=typeof b=="string"||Ne(b),E=!x&&b!==null&&typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint";if(!x&&!E)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(E)g=new R(b.r,b.s);else if(x){try{g=R.fromBytes(tt$2("sig",b),"der");}catch(A){if(!(A instanceof xt$2.Err))throw A}if(!g)try{g=R.fromBytes(tt$2("sig",b),"compact");}catch{return false}}return g||false}function _(b,g,x,E={}){const{lowS:A,prehash:w,format:B}=Hn$1(E,y);if(x=tt$2("publicKey",x),g=k(tt$2("message",g),w),"strict"in E)throw new Error("options.strict was renamed to lowS");const I=B===void 0?C(b):R.fromBytes(tt$2("sig",b),B);if(I===false)return false;try{const N=t.fromBytes(x);if(A&&I.hasHighS())return !1;const{r:D,s:P}=I,$=H(g),V=i.inv(P),q=i.create($*V),G=i.create(D*V),M=t.BASE.multiplyUnsafe(q).add(N.multiplyUnsafe(G));return M.is0()?!1:i.create(M.x)===D}catch{return false}}function p(b,g,x={}){const{prehash:E}=Hn$1(x,y);return g=k(g,E),R.fromBytes(b,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:a,getSharedSecret:l,utils:d,lengths:h,Point:t,sign:T,verify:_,recoverPublicKey:p,Signature:R,hash:e})}function ta$1(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp;let r=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const o=Ht$2(e.n,{BITS:t.nBitLength,allowedLengths:r,modFromBytes:t.wrapPrivateKey}),s={Fp:n,Fn:o,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return {CURVE:e,curveOpts:s}}function ea$1(t){const{CURVE:e,curveOpts:n}=ta$1(t),r={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return {CURVE:e,curveOpts:n,hash:t.hash,ecdsaOpts:r}}function na(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,ko$1(n.Fn.ORDER,n.Fn.BITS))})}function ra(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:o}=ea$1(t),s=Xf(e,n),i=Qf(s,r,o);return na(t,i)}function Dn$1(t,e){const n=r=>ra({...t,hash:r});return {...n(e),create:n}}const Xo$1={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},Jo$1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},Qo$1={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},oa=Ht$2(Xo$1.p),sa=Ht$2(Jo$1.p),ia=Ht$2(Qo$1.p),ca=Dn$1({...Xo$1,Fp:oa,lowS:false},$e$2);Dn$1({...Jo$1,Fp:sa,lowS:false},yc),Dn$1({...Qo$1,Fp:ia,lowS:false,allowedPrivateKeyLengths:[130,131,132]},bc);const fa=ca,Vn$1="base10",rt$1="base16",oe$3="base64pad",Ge$2="base64url",se$2="utf8",Mn$1=0,ie$2=1,we$3=2,aa=0,ts$1=1,ve$3=12,Kn$1=32;function ua(){const t=kn$1.utils.randomPrivateKey(),e=kn$1.getPublicKey(t);return {privateKey:toString(t,rt$1),publicKey:toString(e,rt$1)}}function la(){const t=Mt$2(Kn$1);return toString(t,rt$1)}function da(t,e){const n=kn$1.getSharedSecret(fromString(t,rt$1),fromString(e,rt$1)),r=vf(Pe$3,n,void 0,void 0,Kn$1);return toString(r,rt$1)}function ha(t){const e=Pe$3(fromString(t,rt$1));return toString(e,rt$1)}function pa(t){const e=Pe$3(fromString(t,se$2));return toString(e,rt$1)}function qn$1(t){return fromString(`${t}`,Vn$1)}function Zt$2(t){return Number(toString(t,Vn$1))}function es$1(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ns$1(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=(4-e.length%4)%4;return e+"=".repeat(n)}function ga(t){const e=qn$1(typeof t.type<"u"?t.type:Mn$1);if(Zt$2(e)===ie$2&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const n=typeof t.senderPublicKey<"u"?fromString(t.senderPublicKey,rt$1):void 0,r=typeof t.iv<"u"?fromString(t.iv,rt$1):Mt$2(ve$3),o=fromString(t.symKey,rt$1),s=xo$1(o,r).encrypt(fromString(t.message,se$2)),i=Fn$1({type:e,sealed:s,iv:r,senderPublicKey:n});return t.encoding===Ge$2?es$1(i):i}function ba(t){const e=fromString(t.symKey,rt$1),{sealed:n,iv:r}=ze$1({encoded:t.encoded,encoding:t.encoding}),o=xo$1(e,r).decrypt(n);if(o===null)throw new Error("Failed to decrypt");return toString(o,se$2)}function ya(t,e){const n=qn$1(we$3),r=Mt$2(ve$3),o=fromString(t,se$2),s=Fn$1({type:n,sealed:o,iv:r});return e===Ge$2?es$1(s):s}function ma(t,e){const{sealed:n}=ze$1({encoded:t,encoding:e});return toString(n,se$2)}function Fn$1(t){if(Zt$2(t.type)===we$3)return toString(concat([t.type,t.sealed]),oe$3);if(Zt$2(t.type)===ie$2){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return toString(concat([t.type,t.senderPublicKey,t.iv,t.sealed]),oe$3)}return toString(concat([t.type,t.iv,t.sealed]),oe$3)}function ze$1(t){const e=(t.encoding||oe$3)===Ge$2?ns$1(t.encoded):t.encoded,n=fromString(e,oe$3),r=n.slice(aa,ts$1),o=ts$1;if(Zt$2(r)===ie$2){const f=o+Kn$1,u=f+ve$3,a=n.slice(o,f),l=n.slice(f,u),d=n.slice(u);return {type:r,sealed:d,iv:l,senderPublicKey:a}}if(Zt$2(r)===we$3){const f=n.slice(o),u=Mt$2(ve$3);return {type:r,sealed:f,iv:u}}const s=o+ve$3,i=n.slice(o,s),c=n.slice(s);return {type:r,sealed:c,iv:i}}function wa(t,e){const n=ze$1({encoded:t,encoding:e?.encoding});return rs({type:Zt$2(n.type),senderPublicKey:typeof n.senderPublicKey<"u"?toString(n.senderPublicKey,rt$1):void 0,receiverPublicKey:e?.receiverPublicKey})}function rs(t){const e=t?.type||Mn$1;if(e===ie$2){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return {type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function va(t){return t.type===ie$2&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function xa(t){return t.type===we$3}function os(t){const e=Buffer.from(t.x,"base64"),n=Buffer.from(t.y,"base64");return concat([new Uint8Array([4]),e,n])}function Ea(t,e){const[n,r,o]=t.split("."),s=Buffer.from(ns$1(o),"base64");if(s.length!==64)throw new Error("Invalid signature length");const i=s.slice(0,32),c=s.slice(32,64),f=`${n}.${r}`,u=Pe$3(f),a=os(e);if(!fa.verify(concat([i,c]),u,a))throw new Error("Invalid signature");return sn$1(t).payload}const ss$1="irn";function Ba(t){return t?.relay||{protocol:ss$1}}function Aa(t){const e=C$3[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Ia=Object.defineProperty,Sa=Object.defineProperties,Oa=Object.getOwnPropertyDescriptors,is$1=Object.getOwnPropertySymbols,Na=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable,cs=(t,e,n)=>e in t?Ia(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,Zn$1=(t,e)=>{for(var n in e||(e={}))Na.call(e,n)&&cs(t,n,e[n]);if(is$1)for(var n of is$1(e))Ua.call(e,n)&&cs(t,n,e[n]);return t},_a=(t,e)=>Sa(t,Oa(e));function fs(t,e="-"){const n={},r="relay"+e;return Object.keys(t).forEach(o=>{if(o.startsWith(r)){const s=o.replace(r,""),i=t[o];n[s]=i;}}),n}function Ra(t){if(!t.includes("wc:")){const u=cn$1(t);u!=null&&u.includes("wc:")&&(t=u);}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),n=t.indexOf("?")!==-1?t.indexOf("?"):void 0,r=t.substring(0,e),o=t.substring(e+1,n).split("@"),s=typeof n<"u"?t.substring(n):"",i=new URLSearchParams(s),c=Object.fromEntries(i.entries()),f=typeof c.methods=="string"?c.methods.split(","):void 0;return {protocol:r,topic:as(o[0]),version:parseInt(o[1],10),symKey:c.symKey,relay:fs(c),methods:f,expiryTimestamp:c.expiryTimestamp?parseInt(c.expiryTimestamp,10):void 0}}function as(t){return t.startsWith("//")?t.substring(2):t}function us(t,e="-"){const n="relay",r={};return Object.keys(t).forEach(o=>{const s=o,i=n+e+s;t[s]&&(r[i]=t[s]);}),r}function $a(t){const e=new URLSearchParams,n=Zn$1(Zn$1(_a(Zn$1({},us(t.relay)),{symKey:t.symKey}),t.expiryTimestamp&&{expiryTimestamp:t.expiryTimestamp.toString()}),t.methods&&{methods:t.methods.join(",")});return Object.entries(n).sort(([r],[o])=>r.localeCompare(o)).forEach(([r,o])=>{o!==void 0&&e.append(r,String(o));}),`${t.protocol}:${t.topic}@${t.version}?${e}`}function Ta(t,e,n){return `${t}?wc_ev=${n}&topic=${e}`}var Ca=Object.defineProperty,ja=Object.defineProperties,La=Object.getOwnPropertyDescriptors,ls=Object.getOwnPropertySymbols,ka=Object.prototype.hasOwnProperty,Pa=Object.prototype.propertyIsEnumerable,ds=(t,e,n)=>e in t?Ca(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n,Ha=(t,e)=>{for(var n in e||(e={}))ka.call(e,n)&&ds(t,n,e[n]);if(ls)for(var n of ls(e))Pa.call(e,n)&&ds(t,n,e[n]);return t},Da=(t,e)=>ja(t,La(e));function Gt$2(t){const e=[];return t.forEach(n=>{const[r,o]=n.split(":");e.push(`${r}:${o}`);}),e}function hs(t){const e=[];return Object.values(t).forEach(n=>{e.push(...Gt$2(n.accounts));}),e}function ps(t,e){const n=[];return Object.values(t).forEach(r=>{Gt$2(r.accounts).includes(e)&&n.push(...r.methods);}),n}function gs(t,e){const n=[];return Object.values(t).forEach(r=>{Gt$2(r.accounts).includes(e)&&n.push(...r.events);}),n}function Gn$1(t){return t.includes(":")}function bs$1(t){return Gn$1(t)?t.split(":")[0]:t}function xe$1(t){var e,n,r;const o={};if(!Ye$2(t))return o;for(const[s,i]of Object.entries(t)){const c=Gn$1(s)?[s]:i.chains,f=i.methods||[],u=i.events||[],a=bs$1(s);o[a]=Da(Ha({},o[a]),{chains:ut$2(c,(e=o[a])==null?void 0:e.chains),methods:ut$2(f,(n=o[a])==null?void 0:n.methods),events:ut$2(u,(r=o[a])==null?void 0:r.events)});}return o}function ys(t){const e={};return t?.forEach(n=>{var r;const[o,s]=n.split(":");e[o]||(e[o]={accounts:[],chains:[],events:[],methods:[]}),e[o].accounts.push(n),(r=e[o].chains)==null||r.push(`${o}:${s}`);}),e}function Ka(t,e){e=e.map(r=>r.replace("did:pkh:",""));const n=ys(e);for(const[r,o]of Object.entries(n))o.methods?o.methods=ut$2(o.methods,t):o.methods=t,o.events=["chainChanged","accountsChanged"];return n}function qa(t,e){var n,r,o,s,i,c;const f=xe$1(t),u=xe$1(e),a={},l=Object.keys(f).concat(Object.keys(u));for(const d of l)a[d]={chains:ut$2((n=f[d])==null?void 0:n.chains,(r=u[d])==null?void 0:r.chains),methods:ut$2((o=f[d])==null?void 0:o.methods,(s=u[d])==null?void 0:s.methods),events:ut$2((i=f[d])==null?void 0:i.events,(c=u[d])==null?void 0:c.events)};return a}const ms={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},ws={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Bt$2(t,e){const{message:n,code:r}=ws[t];return {message:e?`${n} ${e}`:n,code:r}}function zt$2(t,e){const{message:n,code:r}=ms[t];return {message:e?`${n} ${e}`:n,code:r}}function Ee$2(t,e){return Array.isArray(t)?true:false}function Ye$2(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Dt$1(t){return typeof t>"u"}function ft$2(t,e){return e&&Dt$1(t)?true:typeof t=="string"&&!!t.trim().length}function We$3(t,e){return e&&Dt$1(t)?true:typeof t=="number"&&!isNaN(t)}function Fa(t,e){const{requiredNamespaces:n}=e,r=Object.keys(t.namespaces),o=Object.keys(n);let s=true;return It$3(o,r)?(r.forEach(i=>{const{accounts:c,methods:f,events:u}=t.namespaces[i],a=Gt$2(c),l=n[i];(!It$3(Ie$1(i,l),a)||!It$3(l.methods,f)||!It$3(l.events,u))&&(s=false);}),s):false}function Be$2(t){return ft$2(t,false)&&t.includes(":")?t.split(":").length===2:false}function vs(t){if(ft$2(t,false)&&t.includes(":")){const e=t.split(":");if(e.length===3){const n=e[0]+":"+e[1];return !!e[2]&&Be$2(n)}}return false}function Za(t){function e(n){try{return typeof new URL(n)<"u"}catch{return false}}try{if(ft$2(t,!1)){if(e(t))return !0;const n=cn$1(t);return e(n)}}catch{}return false}function Ga(t){var e;return (e=t?.proposer)==null?void 0:e.publicKey}function za(t){return t?.topic}function Ya(t,e){let n=null;return ft$2(t?.publicKey,false)||(n=Bt$2("MISSING_OR_INVALID",`${e} controller public key should be a string`)),n}function zn$1(t){let e=true;return Ee$2(t)?t.length&&(e=t.every(n=>ft$2(n,false))):e=false,e}function xs$1(t,e,n){let r=null;return Ee$2(e)&&e.length?e.forEach(o=>{r||Be$2(o)||(r=zt$2("UNSUPPORTED_CHAINS",`${n}, chain ${o} should be a string and conform to "namespace:chainId" format`));}):Be$2(t)||(r=zt$2("UNSUPPORTED_CHAINS",`${n}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),r}function Es(t,e,n){let r=null;return Object.entries(t).forEach(([o,s])=>{if(r)return;const i=xs$1(o,Ie$1(o,s),`${e} ${n}`);i&&(r=i);}),r}function Bs(t,e){let n=null;return Ee$2(t)?t.forEach(r=>{n||vs(r)||(n=zt$2("UNSUPPORTED_ACCOUNTS",`${e}, account ${r} should be a string and conform to "namespace:chainId:address" format`));}):n=zt$2("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n}function As$1(t,e){let n=null;return Object.values(t).forEach(r=>{if(n)return;const o=Bs(r?.accounts,`${e} namespace`);o&&(n=o);}),n}function Is(t,e){let n=null;return zn$1(t?.methods)?zn$1(t?.events)||(n=zt$2("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):n=zt$2("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),n}function Yn$1(t,e){let n=null;return Object.values(t).forEach(r=>{if(n)return;const o=Is(r,`${e}, namespace`);o&&(n=o);}),n}function Wa(t,e,n){let r=null;if(t&&Ye$2(t)){const o=Yn$1(t,e);o&&(r=o);const s=Es(t,e,n);s&&(r=s);}else r=Bt$2("MISSING_OR_INVALID",`${e}, ${n} should be an object with data`);return r}function Ss(t,e){let n=null;if(t&&Ye$2(t)){const r=Yn$1(t,e);r&&(n=r);const o=As$1(t,e);o&&(n=o);}else n=Bt$2("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return n}function Os$1(t){return ft$2(t.protocol,true)}function Xa(t,e){let n=false;return !t?n=true:t&&Ee$2(t)&&t.length&&t.forEach(r=>{n=Os$1(r);}),n}function Ja(t){return typeof t=="number"}function Qa(t){return typeof t<"u"&&typeof t!==null}function tu(t){return !(!t||typeof t!="object"||!t.code||!We$3(t.code,false)||!t.message||!ft$2(t.message,false))}function eu(t){return !(Dt$1(t)||!ft$2(t.method,false))}function nu(t){return !(Dt$1(t)||Dt$1(t.result)&&Dt$1(t.error)||!We$3(t.id,false)||!ft$2(t.jsonrpc,false))}function ru(t){return !(Dt$1(t)||!ft$2(t.name,false))}function ou(t,e){return !(!Be$2(e)||!hs(t).includes(e))}function su(t,e,n){return ft$2(n,false)?ps(t,e).includes(n):false}function iu(t,e,n){return ft$2(n,false)?gs(t,e).includes(n):false}function Ns$1(t,e,n){let r=null;const o=cu(t),s=fu(e),i=Object.keys(o),c=Object.keys(s),f=Us$1(Object.keys(t)),u=Us$1(Object.keys(e)),a=f.filter(l=>!u.includes(l));return a.length&&(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces keys don't satisfy requiredNamespaces.
|
|
29776
31064
|
Required: ${a.toString()}
|
|
29777
31065
|
Received: ${Object.keys(e).toString()}`)),It$3(i,c)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces chains don't satisfy required namespaces.
|
|
29778
31066
|
Required: ${i.toString()}
|
|
@@ -29985,9 +31273,9 @@ let o$1 = class o extends r{constructor(t){super(t),this.events=new eventsExport
|
|
|
29985
31273
|
|
|
29986
31274
|
const v$3=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),w$2=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",d$3=r=>r.split("?")[0],h=10,b$1=v$3();let f$3 = class f{constructor(e){if(this.url=e,this.events=new eventsExports.EventEmitter,this.registering=false,!isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e;}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t);}once(e,t){this.events.once(e,t);}off(e,t){this.events.off(e,t);}removeListener(e,t){this.events.removeListener(e,t);}async open(e=this.url){await this.register(e);}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),e();},this.socket.close();})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(safeJsonStringify(e));}catch(t){this.onError(e.id,t);}}register(e=this.url){if(!isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((n,s)=>{this.events.once("register_error",o=>{this.resetMaxListeners(),s(o);}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));n(this.socket);});})}return this.url=e,this.registering=true,new Promise((t,n)=>{const s=cjsExports.isReactNative()?void 0:{rejectUnauthorized:!isLocalhostUrl(e)},o=new b$1(e,[],s);w$2()?o.onerror=i=>{const a=i;n(this.emitError(a.error));}:o.on("error",i=>{n(this.emitError(i));}),o.onopen=()=>{this.onOpen(o),t(o);};})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=false,this.events.emit("open");}onClose(e){this.socket=void 0,this.registering=false,this.events.emit("close",e);}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?safeJsonParse(e.data):e.data;this.events.emit("payload",t);}onError(e,t){const n=this.parseError(t),s=n.message||n.toString(),o=formatJsonRpcError(e,s);this.events.emit("payload",o);}parseError(e,t=this.url){return parseConnectionError(e,d$3(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>h&&this.events.setMaxListeners(h);}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${d$3(this.url)}`));return this.events.emit("register_error",t),t}};
|
|
29987
31275
|
|
|
29988
|
-
const Ue$2="wc",Fe$1=2,ge$2="core",W$2=`${Ue$2}@2:${ge$2}:`,Et$2={logger:"error"},It$2={database:":memory:"},Tt$1="crypto",Me$3="client_ed25519_seed",Ct$1=cjsExports$3.ONE_DAY,Pt$1="keychain",St$2="0.3",Ot$1="messages",Rt$2="0.3",At$1=cjsExports$3.SIX_HOURS,xt$1="publisher",Nt$1="irn",$t$1="error",Ke$2="wss://relay.walletconnect.org",zt$1="relayer",C$1={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Lt$1="_subscription",M$1={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},kt$1=.1,Pe$2="2.22.4",ee$2={link_mode:"link_mode",relay:"relay"},ye$2={inbound:"inbound",outbound:"outbound"},jt$1="0.3",Ut$1="WALLETCONNECT_CLIENT_ID",Be$1="WALLETCONNECT_LINK_MODE_APPS",j$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Ft$1="subscription",Mt$1="0.3",Kt$1="pairing",Bt$1="0.3",oe$2={wc_pairingDelete:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1e3},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1001}},wc_pairingPing:{req:{ttl:cjsExports$3.THIRTY_SECONDS,prompt:false,tag:1002},res:{ttl:cjsExports$3.THIRTY_SECONDS,prompt:false,tag:1003}},unregistered_method:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:0},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:0}}},ae$2={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},V$1={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Vt$1="history",qt$1="0.3",Gt$1="expirer",q$1={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Wt$1="0.3",Ht$1="verify-api",ir="https://verify.walletconnect.com",Yt$1="https://verify.walletconnect.org",be$2=Yt$1,Jt$1=`${be$2}/v3`,Xt$1=[ir,Yt$1],Zt$1="echo",Qt$1="https://echo.walletconnect.com",Y$1={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},X$1={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},rr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success",session_request_response_started:"session_request_response_started",session_request_response_validation_success:"session_request_response_validation_success",session_request_response_publish_started:"session_request_response_publish_started"},nr={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found",session_request_response_validation_failure:"session_request_response_validation_failure",session_request_response_publish_failure:"session_request_response_publish_failure"},or={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},ar={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},ei=.1,ti="event-client",ii=86400,si="https://pulse.walletconnect.org/batch";function cr(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<r.length;s++){var n=r.charAt(s),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=s;}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function g(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var m=0,D=0,w=0,E=u.length;w!==E&&u[w]===0;)w++,m++;for(var L=(E-w)*l+1>>>0,I=new Uint8Array(L);w!==E;){for(var k=u[w],T=0,S=L-1;(k!==0||T<D)&&S!==-1;S--,T++)k+=256*I[S]>>>0,I[S]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");D=T,w++;}for(var O=L-D;O!==L&&I[O]===0;)O++;for(var te=c.repeat(m);O<L;++O)te+=r.charAt(I[O]);return te}function y(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var m=0;if(u[m]!==" "){for(var D=0,w=0;u[m]===c;)D++,m++;for(var E=(u.length-m)*h+1>>>0,L=new Uint8Array(E);u[m];){var I=t[u.charCodeAt(m)];if(I===255)return;for(var k=0,T=E-1;(I!==0||k<w)&&T!==-1;T--,k++)I+=a*L[T]>>>0,L[T]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");w=k,m++;}if(u[m]!==" "){for(var S=E-w;S!==E&&L[S]===0;)S++;for(var O=new Uint8Array(D+(E-S)),te=D;S!==E;)O[te++]=L[S++];return O}}}function _(u){var m=y(u);if(m)return m;throw new Error(`Non-${e} character`)}return {encode:g,decodeUnsafe:y,decode:_}}var hr=cr,lr=hr;const ri=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},ur=r=>new TextEncoder().encode(r),dr=r=>new TextDecoder().decode(r);class pr{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class gr{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ni(this,e)}}class yr{constructor(e){this.decoders=e;}or(e){return ni(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ni=(r,e)=>new yr({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class br{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new pr(e,t,i),this.decoder=new gr(e,t,s);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Se$2=({name:r,prefix:e,encode:t,decode:i})=>new br(r,e,t,i),me$3=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:s}=lr(t,e);return Se$2({prefix:r,name:e,encode:i,decode:n=>ri(s(n))})},mr=(r,e,t,i)=>{const s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let n=r.length;for(;r[n-1]==="=";)--n;const o=new Uint8Array(n*t/8|0);let a=0,c=0,h=0;for(let l=0;l<n;++l){const g=s[r[l]];if(g===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<t|g,a+=t,a>=8&&(a-=8,o[h++]=255&c>>a);}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},fr=(r,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let n="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,n+=e[s&a>>o];if(o&&(n+=e[s&a<<t-o]),i)for(;n.length*t&7;)n+="=";return n},x$1=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Se$2({prefix:e,name:r,encode(s){return fr(s,i,t)},decode(s){return mr(s,i,t,r)}}),Dr=Se$2({prefix:"\0",name:"identity",encode:r=>dr(r),decode:r=>ur(r)});var vr=Object.freeze({__proto__:null,identity:Dr});const _r=x$1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wr=Object.freeze({__proto__:null,base2:_r});const Er=x$1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ir=Object.freeze({__proto__:null,base8:Er});const Tr=me$3({prefix:"9",name:"base10",alphabet:"0123456789"});var Cr=Object.freeze({__proto__:null,base10:Tr});const Pr=x$1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sr=x$1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Or=Object.freeze({__proto__:null,base16:Pr,base16upper:Sr});const Rr=x$1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ar=x$1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xr=x$1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Nr=x$1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$r=x$1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),zr=x$1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lr=x$1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),kr=x$1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),jr=x$1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ur=Object.freeze({__proto__:null,base32:Rr,base32upper:Ar,base32pad:xr,base32padupper:Nr,base32hex:$r,base32hexupper:zr,base32hexpad:Lr,base32hexpadupper:kr,base32z:jr});const Fr=me$3({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mr=me$3({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Kr=Object.freeze({__proto__:null,base36:Fr,base36upper:Mr});const Br=me$3({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vr=me$3({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qr=Object.freeze({__proto__:null,base58btc:Br,base58flickr:Vr});const Gr=x$1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wr=x$1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hr=x$1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Yr=x$1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jr=Object.freeze({__proto__:null,base64:Gr,base64pad:Wr,base64url:Hr,base64urlpad:Yr});const oi=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Xr=oi.reduce((r,e,t)=>(r[t]=e,r),[]),Zr=oi.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Qr(r){return r.reduce((e,t)=>(e+=Xr[t],e),"")}function en(r){const e=[];for(const t of r){const i=Zr[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i);}return new Uint8Array(e)}const tn=Se$2({prefix:"\u{1F680}",name:"base256emoji",encode:Qr,decode:en});var sn=Object.freeze({__proto__:null,base256emoji:tn}),rn=ci,ai=128,on=-128,an=Math.pow(2,31);function ci(r,e,t){e=e||[],t=t||0;for(var i=t;r>=an;)e[t++]=r&255|ai,r/=128;for(;r&on;)e[t++]=r&255|ai,r>>>=7;return e[t]=r|0,ci.bytes=t-i+1,e}var cn=Ve$2,hn=128,hi=127;function Ve$2(r,i){var t=0,i=i||0,s=0,n=i,o,a=r.length;do{if(n>=a)throw Ve$2.bytes=0,new RangeError("Could not decode varint");o=r[n++],t+=s<28?(o&hi)<<s:(o&hi)*Math.pow(2,s),s+=7;}while(o>=hn);return Ve$2.bytes=n-i,t}var ln=Math.pow(2,7),un=Math.pow(2,14),dn=Math.pow(2,21),pn=Math.pow(2,28),gn=Math.pow(2,35),yn=Math.pow(2,42),bn=Math.pow(2,49),mn=Math.pow(2,56),fn=Math.pow(2,63),Dn=function(r){return r<ln?1:r<un?2:r<dn?3:r<pn?4:r<gn?5:r<yn?6:r<bn?7:r<mn?8:r<fn?9:10},vn={encode:rn,decode:cn,encodingLength:Dn},li=vn;const ui=(r,e,t=0)=>(li.encode(r,e,t),e),di=r=>li.encodingLength(r),qe=(r,e)=>{const t=e.byteLength,i=di(r),s=i+di(t),n=new Uint8Array(s+t);return ui(r,n,0),ui(t,n,i),n.set(e,s),new _n(r,t,e,n)};class _n{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s;}}const pi=({name:r,code:e,encode:t})=>new wn(r,e,t);class wn{constructor(e,t,i){this.name=e,this.code=t,this.encode=i;}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?qe(this.code,t):t.then(i=>qe(this.code,i))}else throw Error("Unknown type, must be binary type")}}const gi=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),En=pi({name:"sha2-256",code:18,encode:gi("SHA-256")}),In=pi({name:"sha2-512",code:19,encode:gi("SHA-512")});var Tn=Object.freeze({__proto__:null,sha256:En,sha512:In});const yi=0,Cn="identity",bi=ri,Pn=r=>qe(yi,bi(r)),Sn={code:yi,name:Cn,encode:bi,digest:Pn};var On=Object.freeze({__proto__:null,identity:Sn});new TextEncoder,new TextDecoder;const mi={...vr,...wr,...Ir,...Cr,...Or,...Ur,...Kr,...qr,...Jr,...sn};({...Tn,...On});function fi(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Rn(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?fi(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Di(r,e,t,i){return {name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const vi=Di("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ge$1=Di("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=Rn(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),An={utf8:vi,"utf-8":vi,hex:mi.base16,latin1:Ge$1,ascii:Ge$1,binary:Ge$1,...mi};function xn(r,e="utf8"){const t=An[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?fi(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Nn=Object.defineProperty,$n=(r,e,t)=>e in r?Nn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,J$2=(r,e,t)=>$n(r,typeof e!="symbol"?e+"":e,t);class _i{constructor(e,t){this.core=e,this.logger=t,J$2(this,"keychain",new Map),J$2(this,"name",Pt$1),J$2(this,"version",St$2),J$2(this,"initialized",false),J$2(this,"storagePrefix",W$2),J$2(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=true;}}),J$2(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),J$2(this,"set",async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist();}),J$2(this,"get",i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:n}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return s}),J$2(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist();}),this.core=e,this.logger=X$3(t,this.name);}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,mi$1(e));}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?wi$1(e):void 0}async persist(){await this.setKeyChain(this.keychain);}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var zn=Object.defineProperty,Ln=(r,e,t)=>e in r?zn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,R$2=(r,e,t)=>Ln(r,typeof e!="symbol"?e+"":e,t);class wi{constructor(e,t,i){this.core=e,this.logger=t,R$2(this,"name",Tt$1),R$2(this,"keychain"),R$2(this,"randomSessionIdentifier",la()),R$2(this,"initialized",false),R$2(this,"clientId"),R$2(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=true);}),R$2(this,"hasKeys",s=>(this.isInitialized(),this.keychain.has(s))),R$2(this,"getClientId",async()=>{if(this.isInitialized(),this.clientId)return this.clientId;const s=await this.getClientSeed(),n=Po$2(s),o=Qe$2(n.publicKey);return this.clientId=o,o}),R$2(this,"generateKeyPair",()=>{this.isInitialized();const s=ua();return this.setPrivateKey(s.publicKey,s.privateKey)}),R$2(this,"signJWT",async s=>{this.isInitialized();const n=await this.getClientSeed(),o=Po$2(n),a=this.randomSessionIdentifier,c=Ct$1;return await Qo$2(a,s,c,o)}),R$2(this,"generateSharedKey",(s,n,o)=>{this.isInitialized();const a=this.getPrivateKey(s),c=da(a,n);return this.setSymKey(c,o)}),R$2(this,"setSymKey",async(s,n)=>{this.isInitialized();const o=n||ha(s);return await this.keychain.set(o,s),o}),R$2(this,"deleteKeyPair",async s=>{this.isInitialized(),await this.keychain.del(s);}),R$2(this,"deleteSymKey",async s=>{this.isInitialized(),await this.keychain.del(s);}),R$2(this,"encode",async(s,n,o)=>{this.isInitialized();const a=rs(o),c=safeJsonStringify(n);if(xa(a))return ya(c,o?.encoding);if(va(a)){const y=a.senderPublicKey,_=a.receiverPublicKey;s=await this.generateSharedKey(y,_);}const h=this.getSymKey(s),{type:l,senderPublicKey:g}=a;return ga({type:l,symKey:h,message:c,senderPublicKey:g,encoding:o?.encoding})}),R$2(this,"decode",async(s,n,o)=>{this.isInitialized();const a=wa(n,o);if(xa(a)){const c=ma(n,o?.encoding);return safeJsonParse(c)}if(va(a)){const c=a.receiverPublicKey,h=a.senderPublicKey;s=await this.generateSharedKey(c,h);}try{const c=this.getSymKey(s),h=ba({symKey:c,encoded:n,encoding:o?.encoding});return safeJsonParse(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(c);}}),R$2(this,"getPayloadType",(s,n=oe$3)=>{const o=ze$1({encoded:s,encoding:n});return Zt$2(o.type)}),R$2(this,"getPayloadSenderPublicKey",(s,n=oe$3)=>{const o=ze$1({encoded:s,encoding:n});return o.senderPublicKey?toString(o.senderPublicKey,rt$1):void 0}),this.core=e,this.logger=X$3(t,this.name),this.keychain=i||new _i(this.core,this.logger);}get context(){return w$3(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Me$3);}catch{e=la(),await this.keychain.set(Me$3,e);}return xn(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var kn=Object.defineProperty,jn=Object.defineProperties,Un=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Fn=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable,We$2=(r,e,t)=>e in r?kn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Kn=(r,e)=>{for(var t in e||(e={}))Fn.call(e,t)&&We$2(r,t,e[t]);if(Ei)for(var t of Ei(e))Mn.call(e,t)&&We$2(r,t,e[t]);return r},Bn=(r,e)=>jn(r,Un(e)),K$1=(r,e,t)=>We$2(r,typeof e!="symbol"?e+"":e,t);class Ii extends y$1{constructor(e,t){super(e,t),this.logger=e,this.core=t,K$1(this,"messages",new Map),K$1(this,"messagesWithoutClientAck",new Map),K$1(this,"name",Ot$1),K$1(this,"version",Rt$2),K$1(this,"initialized",false),K$1(this,"storagePrefix",W$2),K$1(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const s=await this.getRelayerMessagesWithoutClientAck();typeof s<"u"&&(this.messagesWithoutClientAck=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i);}finally{this.initialized=true;}}}),K$1(this,"set",async(i,s,n)=>{this.isInitialized();const o=pa(s);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=s,this.messages.set(i,a),n===ye$2.inbound){const c=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,Bn(Kn({},c),{[o]:s}));}return await this.persist(),o}),K$1(this,"get",i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s}),K$1(this,"getWithoutAck",i=>{this.isInitialized();const s={};for(const n of i){const o=this.messagesWithoutClientAck.get(n)||{};s[n]=Object.values(o);}return s}),K$1(this,"has",(i,s)=>{this.isInitialized();const n=this.get(i),o=pa(s);return typeof n[o]<"u"}),K$1(this,"ack",async(i,s)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(i);if(typeof n>"u")return;const o=pa(s);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,n),await this.persist();}),K$1(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist();}),this.logger=X$3(e,this.name),this.core=t;}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,mi$1(e));}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,mi$1(e));}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?wi$1(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?wi$1(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck);}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Vn=Object.defineProperty,qn=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,Ti=Object.getOwnPropertySymbols,Wn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,He$1=(r,e,t)=>e in r?Vn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ce$2=(r,e)=>{for(var t in e||(e={}))Wn.call(e,t)&&He$1(r,t,e[t]);if(Ti)for(var t of Ti(e))Hn.call(e,t)&&He$1(r,t,e[t]);return r},Ci=(r,e)=>qn(r,Gn(e)),G$2=(r,e,t)=>He$1(r,typeof e!="symbol"?e+"":e,t);class Yn extends m$1{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,G$2(this,"events",new eventsExports.EventEmitter),G$2(this,"name",xt$1),G$2(this,"queue",new Map),G$2(this,"publishTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_MINUTE)),G$2(this,"initialPublishTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND*15)),G$2(this,"needsTransportRestart",false),G$2(this,"publish",async(i,s,n)=>{var o,a,c,h,l;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:n}});const g=n?.ttl||At$1,y=n?.prompt||false,_=n?.tag||0,u=n?.id||getBigIntRpcId().toString(),m=Aa(Ba().protocol),D={id:u,method:n?.publishMethod||m.publish,params:ce$2({topic:i,message:s,ttl:g,prompt:y,tag:_,attestation:n?.attestation},n?.tvf)},w=`Failed to publish payload, please try again. id:${u} tag:${_}`;try{Dt$1((o=D.params)==null?void 0:o.prompt)&&((a=D.params)==null||delete a.prompt),Dt$1((c=D.params)==null?void 0:c.tag)&&((h=D.params)==null||delete h.tag);const E=new Promise(async L=>{const I=({id:T})=>{var S;((S=D.id)==null?void 0:S.toString())===T.toString()&&(this.removeRequestFromQueue(T),this.relayer.events.removeListener(C$1.publish,I),L());};this.relayer.events.on(C$1.publish,I);const k=Ai$1(new Promise((T,S)=>{this.rpcPublish(D,n).then(T).catch(O=>{this.logger.warn(O,O?.message),S(O);});}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${u} tag:${_}`);try{await k,this.events.removeListener(C$1.publish,I);}catch(T){this.queue.set(u,{request:D,opts:n,attempt:1}),this.logger.warn(T,T?.message);}});this.logger.trace({type:"method",method:"publish",params:{id:u,topic:i,message:s,opts:n}}),await Ai$1(E,this.publishTimeout,w);}catch(E){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(E),(l=n?.internal)!=null&&l.throwOnFailedPublish)throw E}finally{this.queue.delete(u);}}),G$2(this,"publishCustom",async i=>{var s,n,o,a,c;this.logger.debug("Publishing custom payload"),this.logger.trace({type:"method",method:"publishCustom",params:i});const{payload:h,opts:l={}}=i,{attestation:g,tvf:y,publishMethod:_,prompt:u,tag:m,ttl:D=cjsExports$3.FIVE_MINUTES}=l,w=l.id||getBigIntRpcId().toString(),E=Aa(Ba().protocol),L=_||E.publish,I={id:w,method:L,params:ce$2(Ci(ce$2({},h),{ttl:D,prompt:u,tag:m,attestation:g}),y)},k=`Failed to publish custom payload, please try again. id:${w} tag:${m}`;try{Dt$1((s=I.params)==null?void 0:s.prompt)&&((n=I.params)==null||delete n.prompt),Dt$1((o=I.params)==null?void 0:o.tag)&&((a=I.params)==null||delete a.tag);const T=new Promise(async S=>{const O=({id:Z})=>{var we;((we=I.id)==null?void 0:we.toString())===Z.toString()&&(this.removeRequestFromQueue(Z),this.relayer.events.removeListener(C$1.publish,O),S());};this.relayer.events.on(C$1.publish,O);const te=Ai$1(new Promise((Z,we)=>{this.rpcPublish(I,l).then(Z).catch(Ee=>{this.logger.warn(Ee,Ee?.message),we(Ee);});}),this.initialPublishTimeout,`Failed initial custom payload publish, retrying.... method:${L} id:${w} tag:${m}`);try{await te,this.events.removeListener(C$1.publish,O);}catch(Z){this.queue.set(w,{request:I,opts:l,attempt:1}),this.logger.warn(Z,Z?.message);}});this.logger.trace({type:"method",method:"publish",params:{id:w,payload:h,opts:l}}),await Ai$1(T,this.publishTimeout,k);}catch(T){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(T),(c=l?.internal)!=null&&c.throwOnFailedPublish)throw T}finally{this.queue.delete(w);}}),G$2(this,"on",(i,s)=>{this.events.on(i,s);}),G$2(this,"once",(i,s)=>{this.events.once(i,s);}),G$2(this,"off",(i,s)=>{this.events.off(i,s);}),G$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),this.relayer=e,this.logger=X$3(t,this.name),this.registerEventListeners();}get context(){return w$3(this.logger)}async rpcPublish(e,t){this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:e});const i=await this.relayer.request(e);return this.relayer.events.emit(C$1.publish,ce$2(ce$2({},e),t)),this.logger.debug("Successfully Published Payload"),i}removeRequestFromQueue(e){this.queue.delete(e);}checkQueue(){this.queue.forEach(async(e,t)=>{var i;const s=e.attempt+1;this.queue.set(t,Ci(ce$2({},e),{attempt:s})),this.logger.warn({},`Publisher: queue->publishing: ${e.request.id}, tag: ${(i=e.request.params)==null?void 0:i.tag}, attempt: ${s}`),await this.rpcPublish(e.request,e.opts),this.logger.warn({},`Publisher: queue->published: ${e.request.id}`);});}registerEventListeners(){this.relayer.core.heartbeat.on(r$1.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=false,this.relayer.events.emit(C$1.connection_stalled);return}this.checkQueue();}),this.relayer.on(C$1.message_ack,e=>{this.removeRequestFromQueue(e.id.toString());});}}var Jn=Object.defineProperty,Xn=(r,e,t)=>e in r?Jn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,he$2=(r,e,t)=>Xn(r,typeof e!="symbol"?e+"":e,t);class Zn{constructor(){he$2(this,"map",new Map),he$2(this,"set",(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t]);}),he$2(this,"get",e=>this.map.get(e)||[]),he$2(this,"exists",(e,t)=>this.get(e).includes(t)),he$2(this,"delete",(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(n=>n!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s);}),he$2(this,"clear",()=>{this.map.clear();});}get topics(){return Array.from(this.map.keys())}}var Qn=Object.defineProperty,eo=Object.defineProperties,to=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,io=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,Ye$1=(r,e,t)=>e in r?Qn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,fe$3=(r,e)=>{for(var t in e||(e={}))io.call(e,t)&&Ye$1(r,t,e[t]);if(Pi)for(var t of Pi(e))so.call(e,t)&&Ye$1(r,t,e[t]);return r},Je$1=(r,e)=>eo(r,to(e)),f$2=(r,e,t)=>Ye$1(r,typeof e!="symbol"?e+"":e,t);class Si extends P$5{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,f$2(this,"subscriptions",new Map),f$2(this,"topicMap",new Zn),f$2(this,"events",new eventsExports.EventEmitter),f$2(this,"name",Ft$1),f$2(this,"version",Mt$1),f$2(this,"pending",new Map),f$2(this,"cached",[]),f$2(this,"initialized",false),f$2(this,"storagePrefix",W$2),f$2(this,"subscribeTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_MINUTE)),f$2(this,"initialSubscribeTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND*15)),f$2(this,"clientId"),f$2(this,"batchSubscribeTopicsLimit",500),f$2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=true;}),f$2(this,"subscribe",async(i,s)=>{var n;this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const o=Ba(s),a={topic:i,relay:o,transportType:s?.transportType};(n=s?.internal)!=null&&n.skipSubscribe||this.pending.set(i,a);const c=await this.rpcSubscribe(i,o,s);return typeof c=="string"&&(this.onSubscribe(c,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),c}catch(o){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(o),o}}),f$2(this,"unsubscribe",async(i,s)=>{this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s);}),f$2(this,"isSubscribed",i=>new Promise(s=>{s(this.topicMap.topics.includes(i));})),f$2(this,"isKnownTopic",i=>new Promise(s=>{s(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(n=>n.topic===i));})),f$2(this,"on",(i,s)=>{this.events.on(i,s);}),f$2(this,"once",(i,s)=>{this.events.once(i,s);}),f$2(this,"off",(i,s)=>{this.events.off(i,s);}),f$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),f$2(this,"start",async()=>{await this.onConnect();}),f$2(this,"stop",async()=>{await this.onDisconnect();}),f$2(this,"restart",async()=>{await this.restore(),await this.onRestart();}),f$2(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(s=>{i.push(s);}),await this.batchSubscribe(i);}),f$2(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(r$1.pulse,async()=>{await this.checkPending();}),this.events.on(j$2.created,async i=>{const s=j$2.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist();}),this.events.on(j$2.deleted,async i=>{const s=j$2.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist();});}),this.relayer=e,this.logger=X$3(t,this.name),this.clientId="";}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let i=false;try{i=this.getSubscription(e).topic===t;}catch{}return i}reset(){this.cached=[],this.initialized=true;}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear();}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)));}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=Ba(i);await this.restartToComplete({topic:e,id:t,relay:s}),await this.rpcUnsubscribe(e,t,s);const n=zt$2("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t,i){var s,n;const o=await this.getSubscriptionId(e);if((s=i?.internal)!=null&&s.skipSubscribe)return o;(!i||i?.transportType===ee$2.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const a={method:Aa(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a});const c=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{if(i?.transportType===ee$2.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(a).catch(g=>this.logger.warn(g));},cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND)),o;const h=new Promise(async g=>{const y=_=>{_.topic===e&&(this.events.removeListener(j$2.created,y),g(_.id));};this.events.on(j$2.created,y);try{const _=await Ai$1(new Promise((u,m)=>{this.relayer.request(a).catch(D=>{this.logger.warn(D,D?.message),m(D);}).then(u);}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(j$2.created,y),g(_);}catch{}}),l=await Ai$1(h,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&c)throw new Error(`Subscribing to ${e} failed, please try again`);return l?o:null}catch(h){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(C$1.connection_stalled),c)throw h}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Aa(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Ai$1(new Promise(s=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(s);}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again");}catch{this.relayer.events.emit(C$1.connection_stalled);}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:Aa(t.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await Ai$1(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a);}).then(n);}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again");}catch{this.relayer.events.emit(C$1.connection_stalled);}return s}rpcUnsubscribe(e,t,i){const s={method:Aa(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,Je$1(fe$3({},t),{id:e})),this.pending.delete(t.topic);}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,fe$3({},t)),this.pending.delete(t.topic);});}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e);}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e);}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t);}addSubscription(e,t){this.subscriptions.set(e,fe$3({},t)),this.topicMap.set(t.topic,e),this.events.emit(j$2.created,t);}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(j$2.deleted,Je$1(fe$3({},i),{reason:t}));}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(j$2.sync);}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const s=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s);}}this.events.emit(j$2.resubscribed);}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size&&!e.every(t=>{var i;return t.topic===((i=this.subscriptions.get(t.id))==null?void 0:i.topic)})){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e);}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async t=>Je$1(fe$3({},t),{id:await this.getSubscriptionId(t.topic)})))));}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await Li$1(cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages));}async onConnect(){await this.restart(),this.reset();}onDisconnect(){this.onDisable();}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen());}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return pa(e+await this.getClientId())}}var ro=Object.defineProperty,Oi=Object.getOwnPropertySymbols,no=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,Xe$1=(r,e,t)=>e in r?ro(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Ri=(r,e)=>{for(var t in e||(e={}))no.call(e,t)&&Xe$1(r,t,e[t]);if(Oi)for(var t of Oi(e))oo.call(e,t)&&Xe$1(r,t,e[t]);return r},p$1=(r,e,t)=>Xe$1(r,typeof e!="symbol"?e+"":e,t);class Ai extends d$4{constructor(e){var t;super(e),p$1(this,"protocol","wc"),p$1(this,"version",2),p$1(this,"core"),p$1(this,"logger"),p$1(this,"events",new eventsExports.EventEmitter),p$1(this,"provider"),p$1(this,"messages"),p$1(this,"subscriber"),p$1(this,"publisher"),p$1(this,"name",zt$1),p$1(this,"transportExplicitlyClosed",false),p$1(this,"initialized",false),p$1(this,"connectionAttemptInProgress",false),p$1(this,"relayUrl"),p$1(this,"projectId"),p$1(this,"packageName"),p$1(this,"bundleId"),p$1(this,"hasExperiencedNetworkDisruption",false),p$1(this,"pingTimeout"),p$1(this,"heartBeatTimeout",cjsExports$3.toMiliseconds(cjsExports$3.THIRTY_SECONDS+cjsExports$3.FIVE_SECONDS)),p$1(this,"reconnectTimeout"),p$1(this,"connectPromise"),p$1(this,"reconnectInProgress",false),p$1(this,"requestsInFlight",[]),p$1(this,"connectTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND*15)),p$1(this,"request",async i=>{var s,n;this.logger.debug("Publishing Request Payload");const o=i.id||getBigIntRpcId().toString();await this.toEstablishConnection();try{this.logger.trace({id:o,method:i.method,topic:(s=i.params)==null?void 0:s.topic},"relayer.request - publishing...");const a=`${o}:${((n=i.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(a);const c=await this.provider.request(i);return this.requestsInFlight=this.requestsInFlight.filter(h=>h!==a),c}catch(a){throw this.logger.debug(`Failed to Publish Request: ${o}`),a}}),p$1(this,"resetPingTimeout",()=>{rn$1()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var i,s,n,o;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(o=(n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null?void 0:n.terminate)==null||o.call(n);}catch(a){this.logger.warn(a,a?.message);}},this.heartBeatTimeout));}),p$1(this,"onPayloadHandler",i=>{this.onProviderPayload(i),this.resetPingTimeout();}),p$1(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(C$1.connect);}),p$1(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect();}),p$1(this,"onProviderErrorHandler",i=>{this.logger.fatal(`Fatal socket error: ${i.message}`),this.events.emit(C$1.error,i),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose();}),p$1(this,"registerProviderListeners",()=>{this.provider.on(M$1.payload,this.onPayloadHandler),this.provider.on(M$1.connect,this.onConnectHandler),this.provider.on(M$1.disconnect,this.onDisconnectHandler),this.provider.on(M$1.error,this.onProviderErrorHandler);}),this.core=e.core,this.logger=wu({logger:(t=e.logger)!=null?t:$t$1,name:this.name}),this.messages=new Ii(this.logger,e.core),this.subscriber=new Si(this,this.logger),this.publisher=new Yn(this,this.logger),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Ke$2,ai$1()?this.packageName=li$1():ui$1()&&(this.bundleId=li$1()),this.provider={};}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=true,this.transportOpen().catch(e=>this.logger.warn(e,e?.message));}get context(){return w$3(this.logger)}get connected(){var e,t,i;return ((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1||false}get connecting(){var e,t,i;return ((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||false}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:ee$2.relay},ye$2.outbound);}async publishCustom(e){this.isInitialized(),await this.publisher.publishCustom(e);}async subscribe(e,t){var i,s,n;this.isInitialized(),(!(t!=null&&t.transportType)||t?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?true:(s=t?.internal)==null?void 0:s.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const h=l=>{l.topic===e&&(this.subscriber.off(j$2.created,h),c());};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(j$2.created,h);}),new Promise(async(l,g)=>{a=await this.subscriber.subscribe(e,Ri({internal:{throwOnFailedPublish:o}},t)).catch(y=>{o&&g(y);})||a,l();})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t);}on(e,t){this.events.on(e,t);}once(e,t){this.events.once(e,t);}off(e,t){this.events.off(e,t);}removeListener(e,t){this.events.removeListener(e,t);}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ai$1(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect();}async transportClose(){this.transportExplicitlyClosed=true,await this.transportDisconnect();}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.info("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0;});}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen());}async confirmOnlineStateOrThrow(){if(!await uu())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,s)=>i.publishedAt-s.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i);}catch(s){this.logger.warn(s,"Error while processing batch message event: "+s?.message);}this.logger.trace(`Batch of ${t.length} message events processed`);}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const s=Ni$1(cjsExports$3.FIVE_MINUTES),n={topic:i,expiry:s,relay:{protocol:"irn"},active:false};await this.core.pairing.pairings.set(i,n);}this.events.emit(C$1.message,e),await this.recordMessageEvent(e,ye$2.inbound);}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=true,this.transportExplicitlyClosed=false;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,s)=>{const n=()=>{s(new Error("Connection interrupted while trying to connect"));};this.provider.once(M$1.disconnect,n),await Ai$1(new Promise((o,a)=>{this.provider.connect().then(o).catch(a);}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{s(o);}).finally(()=>{this.provider.off(M$1.disconnect,n),clearTimeout(this.reconnectTimeout);}),await new Promise(async(o,a)=>{const c=()=>{s(new Error("Connection interrupted while trying to subscribe"));};this.provider.once(M$1.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(M$1.disconnect,c);});}),this.hasExperiencedNetworkDisruption=!1,i();});}catch(i){await this.subscriber.stop();const s=i;this.logger.warn({},s.message),this.hasExperiencedNetworkDisruption=true;}finally{this.connectionAttemptInProgress=false;}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,cjsExports$3.toMiliseconds(t*1))),t++;}}startPingTimeout(){var e,t,i,s,n;if(rn$1())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||n.on("ping",()=>{this.resetPingTimeout();})),this.resetPingTimeout();}catch(o){this.logger.warn(o,o?.message);}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new o$1(new f$3(pi$1({sdkVersion:Pe$2,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:true,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners();}async recordMessageEvent(e,t){const{topic:i,message:s}=e;await this.messages.set(i,s,t);}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),true;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),true;const s=this.messages.has(t,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),isJsonRpcRequest(e)){if(!e.method.endsWith(Lt$1))return;const t=e.params,{topic:i,message:s,publishedAt:n,attestation:o}=t.data,a={topic:i,message:s,publishedAt:n,transportType:ee$2.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Ri({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a);}else isJsonRpcResponse(e)&&this.events.emit(C$1.message_ack,e);}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,ye$2.inbound),this.events.emit(C$1.message,e));}async acknowledgePayload(e){const t=formatJsonRpcResult(e.id,true);await this.provider.connection.send(t);}unregisterProviderListeners(){this.provider.off(M$1.payload,this.onPayloadHandler),this.provider.off(M$1.connect,this.onConnectHandler),this.provider.off(M$1.disconnect,this.onDisconnectHandler),this.provider.off(M$1.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout);}async registerEventListeners(){let e=await uu();lu(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=true,await this.transportDisconnect(),this.transportExplicitlyClosed=false));}),this.core.heartbeat.on(r$1.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&du())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen();}catch(t){this.logger.warn(t,t?.message);}});}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(C$1.disconnect),this.connectionAttemptInProgress=false,!this.reconnectInProgress&&(this.reconnectInProgress=true,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=false;},cjsExports$3.toMiliseconds(kt$1)))));}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect();}}}function ao(r,e){return r===e||Number.isNaN(r)&&Number.isNaN(e)}function xi(r){return Object.getOwnPropertySymbols(r).filter(e=>Object.prototype.propertyIsEnumerable.call(r,e))}function Ni(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const co="[object RegExp]",ho="[object String]",lo="[object Number]",uo="[object Boolean]",$i="[object Arguments]",po="[object Symbol]",go="[object Date]",yo="[object Map]",bo="[object Set]",mo="[object Array]",fo="[object Function]",Do="[object ArrayBuffer]",Ze$1="[object Object]",vo="[object Error]",_o="[object DataView]",wo="[object Uint8Array]",Eo="[object Uint8ClampedArray]",Io="[object Uint16Array]",To="[object Uint32Array]",Co="[object BigUint64Array]",Po="[object Int8Array]",So="[object Int16Array]",Oo="[object Int32Array]",Ro="[object BigInt64Array]",Ao="[object Float32Array]",xo="[object Float64Array]";function No(){}function zi(r){if(!r||typeof r!="object")return false;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(r)==="[object Object]":false}function $o(r,e,t){return De$1(r,e,void 0,void 0,void 0,void 0,t)}function De$1(r,e,t,i,s,n,o){const a=o(r,e,t,i,s,n);if(a!==void 0)return a;if(typeof r==typeof e)switch(typeof r){case "bigint":case "string":case "boolean":case "symbol":case "undefined":return r===e;case "number":return r===e||Object.is(r,e);case "function":return r===e;case "object":return ve$2(r,e,n,o)}return ve$2(r,e,n,o)}function ve$2(r,e,t,i){if(Object.is(r,e))return true;let s=Ni(r),n=Ni(e);if(s===$i&&(s=Ze$1),n===$i&&(n=Ze$1),s!==n)return false;switch(s){case ho:return r.toString()===e.toString();case lo:{const c=r.valueOf(),h=e.valueOf();return ao(c,h)}case uo:case go:case po:return Object.is(r.valueOf(),e.valueOf());case co:return r.source===e.source&&r.flags===e.flags;case fo:return r===e}t=t??new Map;const o=t.get(r),a=t.get(e);if(o!=null&&a!=null)return o===e;t.set(r,e),t.set(e,r);try{switch(s){case yo:{if(r.size!==e.size)return !1;for(const[c,h]of r.entries())if(!e.has(c)||!De$1(h,e.get(c),c,r,e,t,i))return !1;return !0}case bo:{if(r.size!==e.size)return !1;const c=Array.from(r.values()),h=Array.from(e.values());for(let l=0;l<c.length;l++){const g=c[l],y=h.findIndex(_=>De$1(g,_,void 0,r,e,t,i));if(y===-1)return !1;h.splice(y,1);}return !0}case mo:case wo:case Eo:case Io:case To:case Co:case Po:case So:case Oo:case Ro:case Ao:case xo:{if(typeof Buffer<"u"&&Buffer.isBuffer(r)!==Buffer.isBuffer(e)||r.length!==e.length)return !1;for(let c=0;c<r.length;c++)if(!De$1(r[c],e[c],c,r,e,t,i))return !1;return !0}case Do:return r.byteLength!==e.byteLength?!1:ve$2(new Uint8Array(r),new Uint8Array(e),t,i);case _o:return r.byteLength!==e.byteLength||r.byteOffset!==e.byteOffset?!1:ve$2(new Uint8Array(r),new Uint8Array(e),t,i);case vo:return r.name===e.name&&r.message===e.message;case Ze$1:{if(!(ve$2(r.constructor,e.constructor,t,i)||zi(r)&&zi(e)))return !1;const h=[...Object.keys(r),...xi(r)],l=[...Object.keys(e),...xi(e)];if(h.length!==l.length)return !1;for(let g=0;g<h.length;g++){const y=h[g],_=r[y];if(!Object.hasOwn(e,y))return !1;const u=e[y];if(!De$1(_,u,y,r,e,t,i))return !1}return !0}default:return !1}}finally{t.delete(r),t.delete(e);}}function zo(r,e){return $o(r,e,No)}var Lo=Object.defineProperty,Li=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Qe$1=(r,e,t)=>e in r?Lo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ki=(r,e)=>{for(var t in e||(e={}))ko.call(e,t)&&Qe$1(r,t,e[t]);if(Li)for(var t of Li(e))jo.call(e,t)&&Qe$1(r,t,e[t]);return r},U$1=(r,e,t)=>Qe$1(r,typeof e!="symbol"?e+"":e,t);class ji extends f$5{constructor(e,t,i,s=W$2,n=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,U$1(this,"map",new Map),U$1(this,"version",jt$1),U$1(this,"cached",[]),U$1(this,"initialized",false),U$1(this,"getKey"),U$1(this,"storagePrefix",W$2),U$1(this,"recentlyDeleted",[]),U$1(this,"recentlyDeletedLimit",200),U$1(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Dt$1(o)?this.map.set(this.getKey(o),o):Ga(o)?this.map.set(o.id,o):za(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=true);}),U$1(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist());}),U$1(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),U$1(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>zo(a[c],o[c]))):this.values)),U$1(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=ki(ki({},this.getData(o)),a);this.map.set(o,c),await this.persist();}),U$1(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist());}),this.logger=X$3(t,this.name),this.storagePrefix=s,this.getKey=n;}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2);}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e);}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:s}=Bt$2("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values);}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e);}}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Uo=Object.defineProperty,Fo=(r,e,t)=>e in r?Uo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,d$2=(r,e,t)=>Fo(r,typeof e!="symbol"?e+"":e,t);class Ui{constructor(e,t){this.core=e,this.logger=t,d$2(this,"name",Kt$1),d$2(this,"version",Bt$1),d$2(this,"events",new xe$2),d$2(this,"pairings"),d$2(this,"initialized",false),d$2(this,"storagePrefix",W$2),d$2(this,"ignoredPayloadTypes",[ie$2]),d$2(this,"registeredMethods",[]),d$2(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=true,this.logger.trace("Initialized"));}),d$2(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])];}),d$2(this,"create",async i=>{this.isInitialized();const s=la(),n=await this.core.crypto.setSymKey(s),o=Ni$1(cjsExports$3.FIVE_MINUTES),a={protocol:Nt$1},c={topic:n,expiry:o,relay:a,active:false,methods:i?.methods},h=$a({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(ae$2.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:i?.transportType,internal:i?.internal}),{topic:n,uri:h}}),d$2(this,"pair",async i=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Y$1.pairing_started]}});this.isValidPair(i,s);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:h}=Ra(i.uri);s.props.properties.topic=n,s.addTrace(Y$1.pairing_uri_validation_success),s.addTrace(Y$1.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(n)){if(l=this.pairings.get(n),s.addTrace(Y$1.existing_pairing),l.active)throw s.setError(X$1.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(Y$1.pairing_not_expired);}const g=c||Ni$1(cjsExports$3.FIVE_MINUTES),y={topic:n,relay:a,expiry:g,active:false,methods:h};this.core.expirer.set(n,g),await this.pairings.set(n,y),s.addTrace(Y$1.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(ae$2.create,y),s.addTrace(Y$1.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(Y$1.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow();}catch{s.setError(X$1.no_internet_connection);}try{await this.core.relayer.subscribe(n,{relay:a});}catch(_){throw s.setError(X$1.subscribe_pairing_topic_failure),_}return s.addTrace(Y$1.subscribe_pairing_topic_success),y}),d$2(this,"activate",async({topic:i})=>{this.isInitialized();const s=Ni$1(cjsExports$3.FIVE_MINUTES);this.core.expirer.set(i,s),await this.pairings.update(i,{active:true,expiry:s});}),d$2(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:s}=i;if(this.pairings.keys.includes(s)){const n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Bi$1();this.events.once(_i$1("pairing_ping",n),({error:h})=>{h?c(h):a();}),await o();}}),d$2(this,"updateExpiry",async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s});}),d$2(this,"updateMetadata",async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s});}),d$2(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),d$2(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",zt$2("USER_DISCONNECTED")),await this.deletePairing(s));}),d$2(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:s,relay:n,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(s);return $a({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),d$2(this,"sendRequest",async(i,s,n)=>{const o=formatJsonRpcRequest(s,n),a=await this.core.crypto.encode(i,o),c=oe$2[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),d$2(this,"sendResult",async(i,s,n)=>{const o=formatJsonRpcResult(i,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,i)).request.method,h=oe$2[c].res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o);}),d$2(this,"sendError",async(i,s,n)=>{const o=formatJsonRpcError(i,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,i)).request.method,h=oe$2[c]?oe$2[c].res:oe$2.unregistered_method.res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o);}),d$2(this,"deletePairing",async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,zt$2("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)]);}),d$2(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(s=>Ui$1(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)));}),d$2(this,"onRelayEventRequest",async i=>{const{topic:s,payload:n}=i;switch(n.method){case "wc_pairingPing":return await this.onPairingPingRequest(s,n);case "wc_pairingDelete":return await this.onPairingDeleteRequest(s,n);default:return await this.onUnknownRpcMethodRequest(s,n)}}),d$2(this,"onRelayEventResponse",async i=>{const{topic:s,payload:n}=i,o=(await this.core.history.get(s,n.id)).request.method;switch(o){case "wc_pairingPing":return this.onPairingPingResponse(s,n);default:return this.onUnknownRpcMethodResponse(o)}}),d$2(this,"onPairingPingRequest",async(i,s)=>{const{id:n}=s;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(ae$2.ping,{id:n,topic:i});}catch(o){await this.sendError(n,i,o),this.logger.error(o);}}),d$2(this,"onPairingPingResponse",(i,s)=>{const{id:n}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(_i$1("pairing_ping",n),{}):isJsonRpcError(s)&&this.events.emit(_i$1("pairing_ping",n),{error:s.error});},500);}),d$2(this,"onPairingDeleteRequest",async(i,s)=>{const{id:n}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(ae$2.delete,{id:n,topic:i});}catch(o){await this.sendError(n,i,o),this.logger.error(o);}}),d$2(this,"onUnknownRpcMethodRequest",async(i,s)=>{const{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=zt$2("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a);}catch(a){await this.sendError(n,i,a),this.logger.error(a);}}),d$2(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(zt$2("WC_METHOD_UNSUPPORTED",i));}),d$2(this,"isValidPair",(i,s)=>{var n;if(!Qa(i)){const{message:a}=Bt$2("MISSING_OR_INVALID",`pair() params: ${i}`);throw s.setError(X$1.malformed_pairing_uri),new Error(a)}if(!Za(i.uri)){const{message:a}=Bt$2("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw s.setError(X$1.malformed_pairing_uri),new Error(a)}const o=Ra(i?.uri);if(!((n=o?.relay)!=null&&n.protocol)){const{message:a}=Bt$2("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(X$1.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=Bt$2("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(X$1.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&cjsExports$3.toMiliseconds(o?.expiryTimestamp)<Date.now()){s.setError(X$1.pairing_expired);const{message:a}=Bt$2("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),d$2(this,"isValidPing",async i=>{if(!Qa(i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s);}),d$2(this,"isValidDisconnect",async i=>{if(!Qa(i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s);}),d$2(this,"isValidPairingTopic",async i=>{if(!ft$2(i,false)){const{message:s}=Bt$2("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=Bt$2("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(Ui$1(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=Bt$2("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}}),this.core=e,this.logger=X$3(t,this.name),this.pairings=new ji(this.core,this.logger,this.name,this.storagePrefix);}get context(){return w$3(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(C$1.message,async e=>{const{topic:t,message:i,transportType:s}=e;if(this.pairings.keys.includes(t)&&s!==ee$2.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const n=await this.core.crypto.decode(t,i);isJsonRpcRequest(n)?(this.core.history.set(t,n),await this.onRelayEventRequest({topic:t,payload:n})):isJsonRpcResponse(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id)),await this.core.relayer.messages.ack(t,i);}catch(n){this.logger.error(n);}});}registerExpirerEvents(){this.core.expirer.on(q$1.expired,async e=>{const{topic:t}=Oi$1(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,true),this.events.emit(ae$2.expire,{topic:t}));});}}var Mo=Object.defineProperty,Ko=(r,e,t)=>e in r?Mo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,N$2=(r,e,t)=>Ko(r,typeof e!="symbol"?e+"":e,t);class Fi extends I$2{constructor(e,t){super(e,t),this.core=e,this.logger=t,N$2(this,"records",new Map),N$2(this,"events",new eventsExports.EventEmitter),N$2(this,"name",Vt$1),N$2(this,"version",qt$1),N$2(this,"cached",[]),N$2(this,"initialized",false),N$2(this,"storagePrefix",W$2),N$2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=true);}),N$2(this,"set",(i,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:n}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:n,expiry:Ni$1(cjsExports$3.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(V$1.created,o);}),N$2(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(V$1.updated,s));}),N$2(this,"get",async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s))),N$2(this,"delete",(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===i){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(V$1.deleted,n);}}),this.persist();}),N$2(this,"exists",async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:false)),N$2(this,"on",(i,s)=>{this.events.on(i,s);}),N$2(this,"once",(i,s)=>{this.events.once(i,s);}),N$2(this,"off",(i,s)=>{this.events.off(i,s);}),N$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),this.logger=X$3(t,this.name);}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e);}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(V$1.sync);}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e);}}registerEventListeners(){this.events.on(V$1.created,e=>{const t=V$1.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e});}),this.events.on(V$1.updated,e=>{const t=V$1.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e});}),this.events.on(V$1.deleted,e=>{const t=V$1.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e});}),this.core.heartbeat.on(r$1.pulse,()=>{this.cleanup();});}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{cjsExports$3.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(V$1.deleted,t,!1),e=!0);}),e&&this.persist();}catch(e){this.logger.warn(e);}}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Bo=Object.defineProperty,Vo=(r,e,t)=>e in r?Bo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,z$2=(r,e,t)=>Vo(r,typeof e!="symbol"?e+"":e,t);class Mi extends S$3{constructor(e,t){super(e,t),this.core=e,this.logger=t,z$2(this,"expirations",new Map),z$2(this,"events",new eventsExports.EventEmitter),z$2(this,"name",Gt$1),z$2(this,"version",Wt$1),z$2(this,"cached",[]),z$2(this,"initialized",false),z$2(this,"storagePrefix",W$2),z$2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=true);}),z$2(this,"has",i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return false}}),z$2(this,"set",(i,s)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(q$1.created,{target:n,expiration:o});}),z$2(this,"get",i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)}),z$2(this,"del",i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(q$1.deleted,{target:s,expiration:n});}}),z$2(this,"on",(i,s)=>{this.events.on(i,s);}),z$2(this,"once",(i,s)=>{this.events.once(i,s);}),z$2(this,"off",(i,s)=>{this.events.off(i,s);}),z$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),this.logger=X$3(t,this.name);}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Ii$1(e);if(typeof e=="number")return Si$1(e);const{message:t}=Bt$2("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e);}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(q$1.sync);}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e);}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;cjsExports$3.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t);}expire(e,t){this.expirations.delete(e),this.events.emit(q$1.expired,{target:e,expiration:t});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e));}registerEventListeners(){this.core.heartbeat.on(r$1.pulse,()=>this.checkExpirations()),this.events.on(q$1.created,e=>{const t=q$1.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(q$1.expired,e=>{const t=q$1.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(q$1.deleted,e=>{const t=q$1.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var qo=Object.defineProperty,Go=(r,e,t)=>e in r?qo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,P$2=(r,e,t)=>Go(r,typeof e!="symbol"?e+"":e,t);class Ki extends M$4{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,P$2(this,"name",Ht$1),P$2(this,"abortController"),P$2(this,"isDevEnv"),P$2(this,"verifyUrlV3",Jt$1),P$2(this,"storagePrefix",W$2),P$2(this,"version",Fe$1),P$2(this,"publicKey"),P$2(this,"fetchPromise"),P$2(this,"init",async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&cjsExports$3.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()));}),P$2(this,"register",async s=>{if(!Wt$2()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=s,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const h=cjsExports$2.getDocument(),l=this.startAbortTimer(cjsExports$3.ONE_SECOND*5),g=await new Promise((y,_)=>{const u=()=>{window.removeEventListener("message",D),h.body.removeChild(m),_("attestation aborted");};this.abortController.signal.addEventListener("abort",u);const m=h.createElement("iframe");m.src=c,m.style.display="none",m.addEventListener("error",u,{signal:this.abortController.signal});const D=w=>{if(w.data&&typeof w.data=="string")try{const E=JSON.parse(w.data);if(E.type==="verify_attestation"){if(sn$1(E.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(m),this.abortController.signal.removeEventListener("abort",u),window.removeEventListener("message",D),y(E.attestation===null?"":E.attestation);}}catch(E){this.logger.warn(E);}};h.body.appendChild(m),window.addEventListener("message",D,{signal:this.abortController.signal});});return this.logger.debug(g,"jwt attestation"),g}catch(h){this.logger.warn(h);}return ""}),P$2(this,"resolve",async s=>{if(this.isDevEnv)return "";const{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(sn$1(n).payload.id!==a)return;const h=await this.isValidJwtAttestation(n);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const c=this.getVerifyUrl(s?.verifyUrl);return this.fetchAttestation(o,c)}),P$2(this,"fetchAttestation",async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);const o=this.startAbortTimer(cjsExports$3.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),P$2(this,"getVerifyUrl",s=>{let n=s||be$2;return Xt$1.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${be$2}`),n=be$2),n}),P$2(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(cjsExports$3.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s);}}),P$2(this,"persistPublicKey",async s=>{this.logger.debug(s,"persisting public key to local storage"),await this.store.setItem(this.storeKey,s),this.publicKey=s;}),P$2(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0;}),P$2(this,"isValidJwtAttestation",async s=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}}),P$2(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),P$2(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o));});const s=await this.fetchPromise;return this.fetchPromise=void 0,s}),P$2(this,"validateAttestation",(s,n)=>{const o=Ea(s,n.publicKey),a={hasExpired:cjsExports$3.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return {origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=X$3(t,this.name),this.abortController=new AbortController,this.isDevEnv=ji$1(),this.init();}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return w$3(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjsExports$3.toMiliseconds(e))}}var Wo=Object.defineProperty,Ho=(r,e,t)=>e in r?Wo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Bi=(r,e,t)=>Ho(r,typeof e!="symbol"?e+"":e,t);class Vi extends O$3{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Bi(this,"context",Zt$1),Bi(this,"registerDeviceToken",async i=>{const{clientId:s,token:n,notificationType:o,enableEncrypted:a=false}=i,c=`${Qt$1}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})});}),this.logger=X$3(t,this.context);}}var Yo=Object.defineProperty,qi=Object.getOwnPropertySymbols,Jo=Object.prototype.hasOwnProperty,Xo=Object.prototype.propertyIsEnumerable,et$1=(r,e,t)=>e in r?Yo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,_e$2=(r,e)=>{for(var t in e||(e={}))Jo.call(e,t)&&et$1(r,t,e[t]);if(qi)for(var t of qi(e))Xo.call(e,t)&&et$1(r,t,e[t]);return r},A$1=(r,e,t)=>et$1(r,typeof e!="symbol"?e+"":e,t);class Gi extends R$3{constructor(e,t,i=true){super(e,t,i),this.core=e,this.logger=t,A$1(this,"context",ti),A$1(this,"storagePrefix",W$2),A$1(this,"storageVersion",ei),A$1(this,"events",new Map),A$1(this,"shouldPersist",false),A$1(this,"init",async()=>{if(!ji$1())try{const s={eventId:Ci$1(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:wr$1(this.core.relayer.protocol,this.core.relayer.version,Pe$2)}}};await this.sendEvent([s]);}catch(s){this.logger.warn(s);}}),A$1(this,"createEvent",s=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=s,h=Ci$1(),l=this.core.projectId||"",g=Date.now(),y=_e$2({eventId:h,timestamp:g,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,y),this.shouldPersist=true),y}),A$1(this,"getEvent",s=>{const{eventId:n,topic:o}=s;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return _e$2(_e$2({},a),this.setMethods(a.eventId))}),A$1(this,"deleteEvent",s=>{const{eventId:n}=s;this.events.delete(n),this.shouldPersist=true;}),A$1(this,"setEventListeners",()=>{this.core.heartbeat.on(r$1.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{cjsExports$3.fromMiliseconds(Date.now())-cjsExports$3.fromMiliseconds(s.timestamp)>ii&&(this.events.delete(s.eventId),this.shouldPersist=true);});});}),A$1(this,"setMethods",s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)})),A$1(this,"addTrace",(s,n)=>{const o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=true);}),A$1(this,"setError",(s,n)=>{const o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=true);}),A$1(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=false;}),A$1(this,"restore",async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,_e$2(_e$2({},n),this.setMethods(n.eventId)));});}catch(s){this.logger.warn(s);}}),A$1(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const n of s)this.events.delete(n.eventId),this.shouldPersist=!0;}catch(n){this.logger.warn(n);}}),A$1(this,"sendEvent",async s=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${si}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Pe$2}${n}`,{method:"POST",body:JSON.stringify(s)})}),A$1(this,"getAppDomain",()=>br$1().url),this.logger=X$3(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners();}):this.persist();}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Zo=Object.defineProperty,Wi=Object.getOwnPropertySymbols,Qo=Object.prototype.hasOwnProperty,ea=Object.prototype.propertyIsEnumerable,tt$1=(r,e,t)=>e in r?Zo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Hi=(r,e)=>{for(var t in e||(e={}))Qo.call(e,t)&&tt$1(r,t,e[t]);if(Wi)for(var t of Wi(e))ea.call(e,t)&&tt$1(r,t,e[t]);return r},v$2=(r,e,t)=>tt$1(r,typeof e!="symbol"?e+"":e,t);let Oe$2 = class Oe extends h$2{constructor(e){var t;super(e),v$2(this,"protocol",Ue$2),v$2(this,"version",Fe$1),v$2(this,"name",ge$2),v$2(this,"relayUrl"),v$2(this,"projectId"),v$2(this,"customStoragePrefix"),v$2(this,"events",new eventsExports.EventEmitter),v$2(this,"logger"),v$2(this,"heartbeat"),v$2(this,"relayer"),v$2(this,"crypto"),v$2(this,"storage"),v$2(this,"history"),v$2(this,"expirer"),v$2(this,"pairing"),v$2(this,"verify"),v$2(this,"echoClient"),v$2(this,"linkModeSupportedApps"),v$2(this,"eventClient"),v$2(this,"initialized",false),v$2(this,"logChunkController"),v$2(this,"on",(a,c)=>this.events.on(a,c)),v$2(this,"once",(a,c)=>this.events.once(a,c)),v$2(this,"off",(a,c)=>this.events.off(a,c)),v$2(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),v$2(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:h})=>{if(!a||!c)return;const l={topic:a,message:c,publishedAt:Date.now(),transportType:ee$2.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:h});});const i=this.getGlobalCore(e?.customStoragePrefix);if(i)try{return this.customStoragePrefix=i.customStoragePrefix,this.logger=i.logger,this.heartbeat=i.heartbeat,this.crypto=i.crypto,this.history=i.history,this.expirer=i.expirer,this.storage=i.storage,this.relayer=i.relayer,this.pairing=i.pairing,this.verify=i.verify,this.echoClient=i.echoClient,this.linkModeSupportedApps=i.linkModeSupportedApps,this.eventClient=i.eventClient,this.initialized=i.initialized,this.logChunkController=i.logChunkController,i}catch(a){console.warn("Failed to copy global core",a);}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Ke$2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=D$1({level:typeof e?.logger=="string"&&e.logger?e.logger:Et$2.logger,name:ge$2}),{logger:n,chunkLoggerController:o}=Y$3({opts:s,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=o,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}));}),this.logger=X$3(n,this.name),this.heartbeat=new i$3,this.crypto=new wi(this,this.logger,e?.keychain),this.history=new Fi(this,this.logger),this.expirer=new Mi(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new h$4(Hi(Hi({},It$2),e?.storageOptions)),this.relayer=new Ai({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Ui(this,this.logger),this.verify=new Ki(this,this.logger,this.storage),this.echoClient=new Vi(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Gi(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this);}static async init(e){const t=new Oe(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(Ut$1,i),t}get context(){return w$3(this.logger)}async start(){this.initialized||await this.initialize();}async getLogsBlob(){var e;return (e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Be$1,this.linkModeSupportedApps));}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Be$1)||[],this.initialized=!0,this.logger.info("Core Initialization Success");}catch(e){throw this.logger.warn(e,`Core Initialization Failure at epoch ${Date.now()}`),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const t=`_walletConnectCore_${e}`,i=`${t}_count`;return globalThis[i]=(globalThis[i]||0)+1,globalThis[i]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[i]} times.`),globalThis[t]}catch(t){console.warn("Failed to get global WalletConnect core",t);return}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;const i=`_walletConnectCore_${((t=e.opts)==null?void 0:t.customStoragePrefix)||""}`;globalThis[i]=e;}catch(i){console.warn("Failed to set global WalletConnect core",i);}}isGlobalCoreDisabled(){try{return typeof process<"u"&&process.env.DISABLE_GLOBAL_CORE==="true"}catch{return true}}};const ta=Oe$2;
|
|
31276
|
+
const Ue$2="wc",Fe$2=2,ge$2="core",W$2=`${Ue$2}@2:${ge$2}:`,Et$2={logger:"error"},It$2={database:":memory:"},Tt$1="crypto",Me$3="client_ed25519_seed",Ct$1=cjsExports$3.ONE_DAY,Pt$1="keychain",St$2="0.3",Ot$1="messages",Rt$2="0.3",At$1=cjsExports$3.SIX_HOURS,xt$1="publisher",Nt$1="irn",$t$1="error",Ke$2="wss://relay.walletconnect.org",zt$1="relayer",C$1={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Lt$1="_subscription",M$1={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},kt$1=.1,Pe$2="2.22.4",ee$2={link_mode:"link_mode",relay:"relay"},ye$2={inbound:"inbound",outbound:"outbound"},jt$1="0.3",Ut$1="WALLETCONNECT_CLIENT_ID",Be$1="WALLETCONNECT_LINK_MODE_APPS",j$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Ft$1="subscription",Mt$1="0.3",Kt$1="pairing",Bt$1="0.3",oe$2={wc_pairingDelete:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1e3},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1001}},wc_pairingPing:{req:{ttl:cjsExports$3.THIRTY_SECONDS,prompt:false,tag:1002},res:{ttl:cjsExports$3.THIRTY_SECONDS,prompt:false,tag:1003}},unregistered_method:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:0},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:0}}},ae$2={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},V$1={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Vt$1="history",qt$1="0.3",Gt$1="expirer",q$1={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Wt$1="0.3",Ht$1="verify-api",ir="https://verify.walletconnect.com",Yt$1="https://verify.walletconnect.org",be$2=Yt$1,Jt$1=`${be$2}/v3`,Xt$1=[ir,Yt$1],Zt$1="echo",Qt$1="https://echo.walletconnect.com",Y$1={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},X$1={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},rr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success",session_request_response_started:"session_request_response_started",session_request_response_validation_success:"session_request_response_validation_success",session_request_response_publish_started:"session_request_response_publish_started"},nr={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found",session_request_response_validation_failure:"session_request_response_validation_failure",session_request_response_publish_failure:"session_request_response_publish_failure"},or={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},ar={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},ei=.1,ti="event-client",ii=86400,si="https://pulse.walletconnect.org/batch";function cr(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<r.length;s++){var n=r.charAt(s),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=s;}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function g(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var m=0,D=0,w=0,E=u.length;w!==E&&u[w]===0;)w++,m++;for(var L=(E-w)*l+1>>>0,I=new Uint8Array(L);w!==E;){for(var k=u[w],T=0,S=L-1;(k!==0||T<D)&&S!==-1;S--,T++)k+=256*I[S]>>>0,I[S]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");D=T,w++;}for(var O=L-D;O!==L&&I[O]===0;)O++;for(var te=c.repeat(m);O<L;++O)te+=r.charAt(I[O]);return te}function y(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var m=0;if(u[m]!==" "){for(var D=0,w=0;u[m]===c;)D++,m++;for(var E=(u.length-m)*h+1>>>0,L=new Uint8Array(E);u[m];){var I=t[u.charCodeAt(m)];if(I===255)return;for(var k=0,T=E-1;(I!==0||k<w)&&T!==-1;T--,k++)I+=a*L[T]>>>0,L[T]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");w=k,m++;}if(u[m]!==" "){for(var S=E-w;S!==E&&L[S]===0;)S++;for(var O=new Uint8Array(D+(E-S)),te=D;S!==E;)O[te++]=L[S++];return O}}}function _(u){var m=y(u);if(m)return m;throw new Error(`Non-${e} character`)}return {encode:g,decodeUnsafe:y,decode:_}}var hr=cr,lr=hr;const ri=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},ur=r=>new TextEncoder().encode(r),dr=r=>new TextDecoder().decode(r);class pr{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class gr{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ni(this,e)}}class yr{constructor(e){this.decoders=e;}or(e){return ni(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ni=(r,e)=>new yr({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class br{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new pr(e,t,i),this.decoder=new gr(e,t,s);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Se$2=({name:r,prefix:e,encode:t,decode:i})=>new br(r,e,t,i),me$3=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:s}=lr(t,e);return Se$2({prefix:r,name:e,encode:i,decode:n=>ri(s(n))})},mr=(r,e,t,i)=>{const s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let n=r.length;for(;r[n-1]==="=";)--n;const o=new Uint8Array(n*t/8|0);let a=0,c=0,h=0;for(let l=0;l<n;++l){const g=s[r[l]];if(g===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<t|g,a+=t,a>=8&&(a-=8,o[h++]=255&c>>a);}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},fr=(r,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let n="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,n+=e[s&a>>o];if(o&&(n+=e[s&a<<t-o]),i)for(;n.length*t&7;)n+="=";return n},x$1=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Se$2({prefix:e,name:r,encode(s){return fr(s,i,t)},decode(s){return mr(s,i,t,r)}}),Dr=Se$2({prefix:"\0",name:"identity",encode:r=>dr(r),decode:r=>ur(r)});var vr=Object.freeze({__proto__:null,identity:Dr});const _r=x$1({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wr=Object.freeze({__proto__:null,base2:_r});const Er=x$1({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ir=Object.freeze({__proto__:null,base8:Er});const Tr=me$3({prefix:"9",name:"base10",alphabet:"0123456789"});var Cr=Object.freeze({__proto__:null,base10:Tr});const Pr=x$1({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sr=x$1({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Or=Object.freeze({__proto__:null,base16:Pr,base16upper:Sr});const Rr=x$1({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ar=x$1({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xr=x$1({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Nr=x$1({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$r=x$1({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),zr=x$1({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lr=x$1({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),kr=x$1({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),jr=x$1({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ur=Object.freeze({__proto__:null,base32:Rr,base32upper:Ar,base32pad:xr,base32padupper:Nr,base32hex:$r,base32hexupper:zr,base32hexpad:Lr,base32hexpadupper:kr,base32z:jr});const Fr=me$3({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mr=me$3({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Kr=Object.freeze({__proto__:null,base36:Fr,base36upper:Mr});const Br=me$3({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vr=me$3({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qr=Object.freeze({__proto__:null,base58btc:Br,base58flickr:Vr});const Gr=x$1({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wr=x$1({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hr=x$1({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Yr=x$1({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jr=Object.freeze({__proto__:null,base64:Gr,base64pad:Wr,base64url:Hr,base64urlpad:Yr});const oi=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Xr=oi.reduce((r,e,t)=>(r[t]=e,r),[]),Zr=oi.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Qr(r){return r.reduce((e,t)=>(e+=Xr[t],e),"")}function en(r){const e=[];for(const t of r){const i=Zr[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i);}return new Uint8Array(e)}const tn=Se$2({prefix:"\u{1F680}",name:"base256emoji",encode:Qr,decode:en});var sn=Object.freeze({__proto__:null,base256emoji:tn}),rn=ci,ai=128,on=-128,an=Math.pow(2,31);function ci(r,e,t){e=e||[],t=t||0;for(var i=t;r>=an;)e[t++]=r&255|ai,r/=128;for(;r&on;)e[t++]=r&255|ai,r>>>=7;return e[t]=r|0,ci.bytes=t-i+1,e}var cn=Ve$2,hn=128,hi=127;function Ve$2(r,i){var t=0,i=i||0,s=0,n=i,o,a=r.length;do{if(n>=a)throw Ve$2.bytes=0,new RangeError("Could not decode varint");o=r[n++],t+=s<28?(o&hi)<<s:(o&hi)*Math.pow(2,s),s+=7;}while(o>=hn);return Ve$2.bytes=n-i,t}var ln=Math.pow(2,7),un=Math.pow(2,14),dn=Math.pow(2,21),pn=Math.pow(2,28),gn=Math.pow(2,35),yn=Math.pow(2,42),bn=Math.pow(2,49),mn=Math.pow(2,56),fn=Math.pow(2,63),Dn=function(r){return r<ln?1:r<un?2:r<dn?3:r<pn?4:r<gn?5:r<yn?6:r<bn?7:r<mn?8:r<fn?9:10},vn={encode:rn,decode:cn,encodingLength:Dn},li=vn;const ui=(r,e,t=0)=>(li.encode(r,e,t),e),di=r=>li.encodingLength(r),qe=(r,e)=>{const t=e.byteLength,i=di(r),s=i+di(t),n=new Uint8Array(s+t);return ui(r,n,0),ui(t,n,i),n.set(e,s),new _n(r,t,e,n)};class _n{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s;}}const pi=({name:r,code:e,encode:t})=>new wn(r,e,t);class wn{constructor(e,t,i){this.name=e,this.code=t,this.encode=i;}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?qe(this.code,t):t.then(i=>qe(this.code,i))}else throw Error("Unknown type, must be binary type")}}const gi=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),En=pi({name:"sha2-256",code:18,encode:gi("SHA-256")}),In=pi({name:"sha2-512",code:19,encode:gi("SHA-512")});var Tn=Object.freeze({__proto__:null,sha256:En,sha512:In});const yi=0,Cn="identity",bi=ri,Pn=r=>qe(yi,bi(r)),Sn={code:yi,name:Cn,encode:bi,digest:Pn};var On=Object.freeze({__proto__:null,identity:Sn});new TextEncoder,new TextDecoder;const mi={...vr,...wr,...Ir,...Cr,...Or,...Ur,...Kr,...qr,...Jr,...sn};({...Tn,...On});function fi(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Rn(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?fi(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Di(r,e,t,i){return {name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const vi=Di("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ge$1=Di("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=Rn(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),An={utf8:vi,"utf-8":vi,hex:mi.base16,latin1:Ge$1,ascii:Ge$1,binary:Ge$1,...mi};function xn(r,e="utf8"){const t=An[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?fi(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Nn=Object.defineProperty,$n=(r,e,t)=>e in r?Nn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,J$2=(r,e,t)=>$n(r,typeof e!="symbol"?e+"":e,t);class _i{constructor(e,t){this.core=e,this.logger=t,J$2(this,"keychain",new Map),J$2(this,"name",Pt$1),J$2(this,"version",St$2),J$2(this,"initialized",false),J$2(this,"storagePrefix",W$2),J$2(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=true;}}),J$2(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),J$2(this,"set",async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist();}),J$2(this,"get",i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:n}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return s}),J$2(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist();}),this.core=e,this.logger=X$3(t,this.name);}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,mi$1(e));}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?wi$1(e):void 0}async persist(){await this.setKeyChain(this.keychain);}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var zn=Object.defineProperty,Ln=(r,e,t)=>e in r?zn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,R$1=(r,e,t)=>Ln(r,typeof e!="symbol"?e+"":e,t);class wi{constructor(e,t,i){this.core=e,this.logger=t,R$1(this,"name",Tt$1),R$1(this,"keychain"),R$1(this,"randomSessionIdentifier",la()),R$1(this,"initialized",false),R$1(this,"clientId"),R$1(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=true);}),R$1(this,"hasKeys",s=>(this.isInitialized(),this.keychain.has(s))),R$1(this,"getClientId",async()=>{if(this.isInitialized(),this.clientId)return this.clientId;const s=await this.getClientSeed(),n=Po$2(s),o=Qe$2(n.publicKey);return this.clientId=o,o}),R$1(this,"generateKeyPair",()=>{this.isInitialized();const s=ua();return this.setPrivateKey(s.publicKey,s.privateKey)}),R$1(this,"signJWT",async s=>{this.isInitialized();const n=await this.getClientSeed(),o=Po$2(n),a=this.randomSessionIdentifier,c=Ct$1;return await Qo$2(a,s,c,o)}),R$1(this,"generateSharedKey",(s,n,o)=>{this.isInitialized();const a=this.getPrivateKey(s),c=da(a,n);return this.setSymKey(c,o)}),R$1(this,"setSymKey",async(s,n)=>{this.isInitialized();const o=n||ha(s);return await this.keychain.set(o,s),o}),R$1(this,"deleteKeyPair",async s=>{this.isInitialized(),await this.keychain.del(s);}),R$1(this,"deleteSymKey",async s=>{this.isInitialized(),await this.keychain.del(s);}),R$1(this,"encode",async(s,n,o)=>{this.isInitialized();const a=rs(o),c=safeJsonStringify(n);if(xa(a))return ya(c,o?.encoding);if(va(a)){const y=a.senderPublicKey,_=a.receiverPublicKey;s=await this.generateSharedKey(y,_);}const h=this.getSymKey(s),{type:l,senderPublicKey:g}=a;return ga({type:l,symKey:h,message:c,senderPublicKey:g,encoding:o?.encoding})}),R$1(this,"decode",async(s,n,o)=>{this.isInitialized();const a=wa(n,o);if(xa(a)){const c=ma(n,o?.encoding);return safeJsonParse(c)}if(va(a)){const c=a.receiverPublicKey,h=a.senderPublicKey;s=await this.generateSharedKey(c,h);}try{const c=this.getSymKey(s),h=ba({symKey:c,encoded:n,encoding:o?.encoding});return safeJsonParse(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(c);}}),R$1(this,"getPayloadType",(s,n=oe$3)=>{const o=ze$1({encoded:s,encoding:n});return Zt$2(o.type)}),R$1(this,"getPayloadSenderPublicKey",(s,n=oe$3)=>{const o=ze$1({encoded:s,encoding:n});return o.senderPublicKey?toString(o.senderPublicKey,rt$1):void 0}),this.core=e,this.logger=X$3(t,this.name),this.keychain=i||new _i(this.core,this.logger);}get context(){return w$3(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Me$3);}catch{e=la(),await this.keychain.set(Me$3,e);}return xn(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var kn=Object.defineProperty,jn=Object.defineProperties,Un=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Fn=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable,We$2=(r,e,t)=>e in r?kn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Kn=(r,e)=>{for(var t in e||(e={}))Fn.call(e,t)&&We$2(r,t,e[t]);if(Ei)for(var t of Ei(e))Mn.call(e,t)&&We$2(r,t,e[t]);return r},Bn=(r,e)=>jn(r,Un(e)),K=(r,e,t)=>We$2(r,typeof e!="symbol"?e+"":e,t);class Ii extends y$1{constructor(e,t){super(e,t),this.logger=e,this.core=t,K(this,"messages",new Map),K(this,"messagesWithoutClientAck",new Map),K(this,"name",Ot$1),K(this,"version",Rt$2),K(this,"initialized",false),K(this,"storagePrefix",W$2),K(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const s=await this.getRelayerMessagesWithoutClientAck();typeof s<"u"&&(this.messagesWithoutClientAck=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i);}finally{this.initialized=true;}}}),K(this,"set",async(i,s,n)=>{this.isInitialized();const o=pa(s);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=s,this.messages.set(i,a),n===ye$2.inbound){const c=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,Bn(Kn({},c),{[o]:s}));}return await this.persist(),o}),K(this,"get",i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s}),K(this,"getWithoutAck",i=>{this.isInitialized();const s={};for(const n of i){const o=this.messagesWithoutClientAck.get(n)||{};s[n]=Object.values(o);}return s}),K(this,"has",(i,s)=>{this.isInitialized();const n=this.get(i),o=pa(s);return typeof n[o]<"u"}),K(this,"ack",async(i,s)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(i);if(typeof n>"u")return;const o=pa(s);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,n),await this.persist();}),K(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist();}),this.logger=X$3(e,this.name),this.core=t;}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,mi$1(e));}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,mi$1(e));}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?wi$1(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?wi$1(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck);}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Vn=Object.defineProperty,qn=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,Ti=Object.getOwnPropertySymbols,Wn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,He$1=(r,e,t)=>e in r?Vn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ce$2=(r,e)=>{for(var t in e||(e={}))Wn.call(e,t)&&He$1(r,t,e[t]);if(Ti)for(var t of Ti(e))Hn.call(e,t)&&He$1(r,t,e[t]);return r},Ci=(r,e)=>qn(r,Gn(e)),G$2=(r,e,t)=>He$1(r,typeof e!="symbol"?e+"":e,t);class Yn extends m$1{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,G$2(this,"events",new eventsExports.EventEmitter),G$2(this,"name",xt$1),G$2(this,"queue",new Map),G$2(this,"publishTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_MINUTE)),G$2(this,"initialPublishTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND*15)),G$2(this,"needsTransportRestart",false),G$2(this,"publish",async(i,s,n)=>{var o,a,c,h,l;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:n}});const g=n?.ttl||At$1,y=n?.prompt||false,_=n?.tag||0,u=n?.id||getBigIntRpcId().toString(),m=Aa(Ba().protocol),D={id:u,method:n?.publishMethod||m.publish,params:ce$2({topic:i,message:s,ttl:g,prompt:y,tag:_,attestation:n?.attestation},n?.tvf)},w=`Failed to publish payload, please try again. id:${u} tag:${_}`;try{Dt$1((o=D.params)==null?void 0:o.prompt)&&((a=D.params)==null||delete a.prompt),Dt$1((c=D.params)==null?void 0:c.tag)&&((h=D.params)==null||delete h.tag);const E=new Promise(async L=>{const I=({id:T})=>{var S;((S=D.id)==null?void 0:S.toString())===T.toString()&&(this.removeRequestFromQueue(T),this.relayer.events.removeListener(C$1.publish,I),L());};this.relayer.events.on(C$1.publish,I);const k=Ai$1(new Promise((T,S)=>{this.rpcPublish(D,n).then(T).catch(O=>{this.logger.warn(O,O?.message),S(O);});}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${u} tag:${_}`);try{await k,this.events.removeListener(C$1.publish,I);}catch(T){this.queue.set(u,{request:D,opts:n,attempt:1}),this.logger.warn(T,T?.message);}});this.logger.trace({type:"method",method:"publish",params:{id:u,topic:i,message:s,opts:n}}),await Ai$1(E,this.publishTimeout,w);}catch(E){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(E),(l=n?.internal)!=null&&l.throwOnFailedPublish)throw E}finally{this.queue.delete(u);}}),G$2(this,"publishCustom",async i=>{var s,n,o,a,c;this.logger.debug("Publishing custom payload"),this.logger.trace({type:"method",method:"publishCustom",params:i});const{payload:h,opts:l={}}=i,{attestation:g,tvf:y,publishMethod:_,prompt:u,tag:m,ttl:D=cjsExports$3.FIVE_MINUTES}=l,w=l.id||getBigIntRpcId().toString(),E=Aa(Ba().protocol),L=_||E.publish,I={id:w,method:L,params:ce$2(Ci(ce$2({},h),{ttl:D,prompt:u,tag:m,attestation:g}),y)},k=`Failed to publish custom payload, please try again. id:${w} tag:${m}`;try{Dt$1((s=I.params)==null?void 0:s.prompt)&&((n=I.params)==null||delete n.prompt),Dt$1((o=I.params)==null?void 0:o.tag)&&((a=I.params)==null||delete a.tag);const T=new Promise(async S=>{const O=({id:Z})=>{var we;((we=I.id)==null?void 0:we.toString())===Z.toString()&&(this.removeRequestFromQueue(Z),this.relayer.events.removeListener(C$1.publish,O),S());};this.relayer.events.on(C$1.publish,O);const te=Ai$1(new Promise((Z,we)=>{this.rpcPublish(I,l).then(Z).catch(Ee=>{this.logger.warn(Ee,Ee?.message),we(Ee);});}),this.initialPublishTimeout,`Failed initial custom payload publish, retrying.... method:${L} id:${w} tag:${m}`);try{await te,this.events.removeListener(C$1.publish,O);}catch(Z){this.queue.set(w,{request:I,opts:l,attempt:1}),this.logger.warn(Z,Z?.message);}});this.logger.trace({type:"method",method:"publish",params:{id:w,payload:h,opts:l}}),await Ai$1(T,this.publishTimeout,k);}catch(T){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(T),(c=l?.internal)!=null&&c.throwOnFailedPublish)throw T}finally{this.queue.delete(w);}}),G$2(this,"on",(i,s)=>{this.events.on(i,s);}),G$2(this,"once",(i,s)=>{this.events.once(i,s);}),G$2(this,"off",(i,s)=>{this.events.off(i,s);}),G$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),this.relayer=e,this.logger=X$3(t,this.name),this.registerEventListeners();}get context(){return w$3(this.logger)}async rpcPublish(e,t){this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:e});const i=await this.relayer.request(e);return this.relayer.events.emit(C$1.publish,ce$2(ce$2({},e),t)),this.logger.debug("Successfully Published Payload"),i}removeRequestFromQueue(e){this.queue.delete(e);}checkQueue(){this.queue.forEach(async(e,t)=>{var i;const s=e.attempt+1;this.queue.set(t,Ci(ce$2({},e),{attempt:s})),this.logger.warn({},`Publisher: queue->publishing: ${e.request.id}, tag: ${(i=e.request.params)==null?void 0:i.tag}, attempt: ${s}`),await this.rpcPublish(e.request,e.opts),this.logger.warn({},`Publisher: queue->published: ${e.request.id}`);});}registerEventListeners(){this.relayer.core.heartbeat.on(r$1.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=false,this.relayer.events.emit(C$1.connection_stalled);return}this.checkQueue();}),this.relayer.on(C$1.message_ack,e=>{this.removeRequestFromQueue(e.id.toString());});}}var Jn=Object.defineProperty,Xn=(r,e,t)=>e in r?Jn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,he$2=(r,e,t)=>Xn(r,typeof e!="symbol"?e+"":e,t);class Zn{constructor(){he$2(this,"map",new Map),he$2(this,"set",(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t]);}),he$2(this,"get",e=>this.map.get(e)||[]),he$2(this,"exists",(e,t)=>this.get(e).includes(t)),he$2(this,"delete",(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(n=>n!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s);}),he$2(this,"clear",()=>{this.map.clear();});}get topics(){return Array.from(this.map.keys())}}var Qn=Object.defineProperty,eo=Object.defineProperties,to=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,io=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,Ye$1=(r,e,t)=>e in r?Qn(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,fe$3=(r,e)=>{for(var t in e||(e={}))io.call(e,t)&&Ye$1(r,t,e[t]);if(Pi)for(var t of Pi(e))so.call(e,t)&&Ye$1(r,t,e[t]);return r},Je$1=(r,e)=>eo(r,to(e)),f$2=(r,e,t)=>Ye$1(r,typeof e!="symbol"?e+"":e,t);class Si extends P$5{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,f$2(this,"subscriptions",new Map),f$2(this,"topicMap",new Zn),f$2(this,"events",new eventsExports.EventEmitter),f$2(this,"name",Ft$1),f$2(this,"version",Mt$1),f$2(this,"pending",new Map),f$2(this,"cached",[]),f$2(this,"initialized",false),f$2(this,"storagePrefix",W$2),f$2(this,"subscribeTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_MINUTE)),f$2(this,"initialSubscribeTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND*15)),f$2(this,"clientId"),f$2(this,"batchSubscribeTopicsLimit",500),f$2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=true;}),f$2(this,"subscribe",async(i,s)=>{var n;this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const o=Ba(s),a={topic:i,relay:o,transportType:s?.transportType};(n=s?.internal)!=null&&n.skipSubscribe||this.pending.set(i,a);const c=await this.rpcSubscribe(i,o,s);return typeof c=="string"&&(this.onSubscribe(c,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),c}catch(o){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(o),o}}),f$2(this,"unsubscribe",async(i,s)=>{this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s);}),f$2(this,"isSubscribed",i=>new Promise(s=>{s(this.topicMap.topics.includes(i));})),f$2(this,"isKnownTopic",i=>new Promise(s=>{s(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(n=>n.topic===i));})),f$2(this,"on",(i,s)=>{this.events.on(i,s);}),f$2(this,"once",(i,s)=>{this.events.once(i,s);}),f$2(this,"off",(i,s)=>{this.events.off(i,s);}),f$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),f$2(this,"start",async()=>{await this.onConnect();}),f$2(this,"stop",async()=>{await this.onDisconnect();}),f$2(this,"restart",async()=>{await this.restore(),await this.onRestart();}),f$2(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(s=>{i.push(s);}),await this.batchSubscribe(i);}),f$2(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(r$1.pulse,async()=>{await this.checkPending();}),this.events.on(j$2.created,async i=>{const s=j$2.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist();}),this.events.on(j$2.deleted,async i=>{const s=j$2.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist();});}),this.relayer=e,this.logger=X$3(t,this.name),this.clientId="";}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let i=false;try{i=this.getSubscription(e).topic===t;}catch{}return i}reset(){this.cached=[],this.initialized=true;}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear();}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)));}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=Ba(i);await this.restartToComplete({topic:e,id:t,relay:s}),await this.rpcUnsubscribe(e,t,s);const n=zt$2("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t,i){var s,n;const o=await this.getSubscriptionId(e);if((s=i?.internal)!=null&&s.skipSubscribe)return o;(!i||i?.transportType===ee$2.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const a={method:Aa(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a});const c=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{if(i?.transportType===ee$2.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(a).catch(g=>this.logger.warn(g));},cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND)),o;const h=new Promise(async g=>{const y=_=>{_.topic===e&&(this.events.removeListener(j$2.created,y),g(_.id));};this.events.on(j$2.created,y);try{const _=await Ai$1(new Promise((u,m)=>{this.relayer.request(a).catch(D=>{this.logger.warn(D,D?.message),m(D);}).then(u);}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(j$2.created,y),g(_);}catch{}}),l=await Ai$1(h,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&c)throw new Error(`Subscribing to ${e} failed, please try again`);return l?o:null}catch(h){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(C$1.connection_stalled),c)throw h}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Aa(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Ai$1(new Promise(s=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(s);}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again");}catch{this.relayer.events.emit(C$1.connection_stalled);}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:Aa(t.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await Ai$1(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a);}).then(n);}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again");}catch{this.relayer.events.emit(C$1.connection_stalled);}return s}rpcUnsubscribe(e,t,i){const s={method:Aa(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,Je$1(fe$3({},t),{id:e})),this.pending.delete(t.topic);}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,fe$3({},t)),this.pending.delete(t.topic);});}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e);}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e);}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t);}addSubscription(e,t){this.subscriptions.set(e,fe$3({},t)),this.topicMap.set(t.topic,e),this.events.emit(j$2.created,t);}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(j$2.deleted,Je$1(fe$3({},i),{reason:t}));}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(j$2.sync);}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const s=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s);}}this.events.emit(j$2.resubscribed);}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size&&!e.every(t=>{var i;return t.topic===((i=this.subscriptions.get(t.id))==null?void 0:i.topic)})){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e);}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async t=>Je$1(fe$3({},t),{id:await this.getSubscriptionId(t.topic)})))));}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await Li$1(cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages));}async onConnect(){await this.restart(),this.reset();}onDisconnect(){this.onDisable();}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen());}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return pa(e+await this.getClientId())}}var ro=Object.defineProperty,Oi=Object.getOwnPropertySymbols,no=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,Xe$1=(r,e,t)=>e in r?ro(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Ri=(r,e)=>{for(var t in e||(e={}))no.call(e,t)&&Xe$1(r,t,e[t]);if(Oi)for(var t of Oi(e))oo.call(e,t)&&Xe$1(r,t,e[t]);return r},p$1=(r,e,t)=>Xe$1(r,typeof e!="symbol"?e+"":e,t);class Ai extends d$4{constructor(e){var t;super(e),p$1(this,"protocol","wc"),p$1(this,"version",2),p$1(this,"core"),p$1(this,"logger"),p$1(this,"events",new eventsExports.EventEmitter),p$1(this,"provider"),p$1(this,"messages"),p$1(this,"subscriber"),p$1(this,"publisher"),p$1(this,"name",zt$1),p$1(this,"transportExplicitlyClosed",false),p$1(this,"initialized",false),p$1(this,"connectionAttemptInProgress",false),p$1(this,"relayUrl"),p$1(this,"projectId"),p$1(this,"packageName"),p$1(this,"bundleId"),p$1(this,"hasExperiencedNetworkDisruption",false),p$1(this,"pingTimeout"),p$1(this,"heartBeatTimeout",cjsExports$3.toMiliseconds(cjsExports$3.THIRTY_SECONDS+cjsExports$3.FIVE_SECONDS)),p$1(this,"reconnectTimeout"),p$1(this,"connectPromise"),p$1(this,"reconnectInProgress",false),p$1(this,"requestsInFlight",[]),p$1(this,"connectTimeout",cjsExports$3.toMiliseconds(cjsExports$3.ONE_SECOND*15)),p$1(this,"request",async i=>{var s,n;this.logger.debug("Publishing Request Payload");const o=i.id||getBigIntRpcId().toString();await this.toEstablishConnection();try{this.logger.trace({id:o,method:i.method,topic:(s=i.params)==null?void 0:s.topic},"relayer.request - publishing...");const a=`${o}:${((n=i.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(a);const c=await this.provider.request(i);return this.requestsInFlight=this.requestsInFlight.filter(h=>h!==a),c}catch(a){throw this.logger.debug(`Failed to Publish Request: ${o}`),a}}),p$1(this,"resetPingTimeout",()=>{rn$1()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var i,s,n,o;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(o=(n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null?void 0:n.terminate)==null||o.call(n);}catch(a){this.logger.warn(a,a?.message);}},this.heartBeatTimeout));}),p$1(this,"onPayloadHandler",i=>{this.onProviderPayload(i),this.resetPingTimeout();}),p$1(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(C$1.connect);}),p$1(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect();}),p$1(this,"onProviderErrorHandler",i=>{this.logger.fatal(`Fatal socket error: ${i.message}`),this.events.emit(C$1.error,i),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose();}),p$1(this,"registerProviderListeners",()=>{this.provider.on(M$1.payload,this.onPayloadHandler),this.provider.on(M$1.connect,this.onConnectHandler),this.provider.on(M$1.disconnect,this.onDisconnectHandler),this.provider.on(M$1.error,this.onProviderErrorHandler);}),this.core=e.core,this.logger=wu({logger:(t=e.logger)!=null?t:$t$1,name:this.name}),this.messages=new Ii(this.logger,e.core),this.subscriber=new Si(this,this.logger),this.publisher=new Yn(this,this.logger),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Ke$2,ai$1()?this.packageName=li$1():ui$1()&&(this.bundleId=li$1()),this.provider={};}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=true,this.transportOpen().catch(e=>this.logger.warn(e,e?.message));}get context(){return w$3(this.logger)}get connected(){var e,t,i;return ((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1||false}get connecting(){var e,t,i;return ((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||false}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:ee$2.relay},ye$2.outbound);}async publishCustom(e){this.isInitialized(),await this.publisher.publishCustom(e);}async subscribe(e,t){var i,s,n;this.isInitialized(),(!(t!=null&&t.transportType)||t?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?true:(s=t?.internal)==null?void 0:s.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const h=l=>{l.topic===e&&(this.subscriber.off(j$2.created,h),c());};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(j$2.created,h);}),new Promise(async(l,g)=>{a=await this.subscriber.subscribe(e,Ri({internal:{throwOnFailedPublish:o}},t)).catch(y=>{o&&g(y);})||a,l();})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t);}on(e,t){this.events.on(e,t);}once(e,t){this.events.once(e,t);}off(e,t){this.events.off(e,t);}removeListener(e,t){this.events.removeListener(e,t);}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ai$1(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect();}async transportClose(){this.transportExplicitlyClosed=true,await this.transportDisconnect();}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.info("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0;});}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen());}async confirmOnlineStateOrThrow(){if(!await uu())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,s)=>i.publishedAt-s.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i);}catch(s){this.logger.warn(s,"Error while processing batch message event: "+s?.message);}this.logger.trace(`Batch of ${t.length} message events processed`);}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const s=Ni$1(cjsExports$3.FIVE_MINUTES),n={topic:i,expiry:s,relay:{protocol:"irn"},active:false};await this.core.pairing.pairings.set(i,n);}this.events.emit(C$1.message,e),await this.recordMessageEvent(e,ye$2.inbound);}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=true,this.transportExplicitlyClosed=false;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,s)=>{const n=()=>{s(new Error("Connection interrupted while trying to connect"));};this.provider.once(M$1.disconnect,n),await Ai$1(new Promise((o,a)=>{this.provider.connect().then(o).catch(a);}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{s(o);}).finally(()=>{this.provider.off(M$1.disconnect,n),clearTimeout(this.reconnectTimeout);}),await new Promise(async(o,a)=>{const c=()=>{s(new Error("Connection interrupted while trying to subscribe"));};this.provider.once(M$1.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(M$1.disconnect,c);});}),this.hasExperiencedNetworkDisruption=!1,i();});}catch(i){await this.subscriber.stop();const s=i;this.logger.warn({},s.message),this.hasExperiencedNetworkDisruption=true;}finally{this.connectionAttemptInProgress=false;}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,cjsExports$3.toMiliseconds(t*1))),t++;}}startPingTimeout(){var e,t,i,s,n;if(rn$1())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||n.on("ping",()=>{this.resetPingTimeout();})),this.resetPingTimeout();}catch(o){this.logger.warn(o,o?.message);}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new o$1(new f$3(pi$1({sdkVersion:Pe$2,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:true,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners();}async recordMessageEvent(e,t){const{topic:i,message:s}=e;await this.messages.set(i,s,t);}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),true;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),true;const s=this.messages.has(t,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),isJsonRpcRequest(e)){if(!e.method.endsWith(Lt$1))return;const t=e.params,{topic:i,message:s,publishedAt:n,attestation:o}=t.data,a={topic:i,message:s,publishedAt:n,transportType:ee$2.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Ri({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a);}else isJsonRpcResponse(e)&&this.events.emit(C$1.message_ack,e);}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,ye$2.inbound),this.events.emit(C$1.message,e));}async acknowledgePayload(e){const t=formatJsonRpcResult(e.id,true);await this.provider.connection.send(t);}unregisterProviderListeners(){this.provider.off(M$1.payload,this.onPayloadHandler),this.provider.off(M$1.connect,this.onConnectHandler),this.provider.off(M$1.disconnect,this.onDisconnectHandler),this.provider.off(M$1.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout);}async registerEventListeners(){let e=await uu();lu(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=true,await this.transportDisconnect(),this.transportExplicitlyClosed=false));}),this.core.heartbeat.on(r$1.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&du())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen();}catch(t){this.logger.warn(t,t?.message);}});}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(C$1.disconnect),this.connectionAttemptInProgress=false,!this.reconnectInProgress&&(this.reconnectInProgress=true,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=false;},cjsExports$3.toMiliseconds(kt$1)))));}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect();}}}function ao(r,e){return r===e||Number.isNaN(r)&&Number.isNaN(e)}function xi(r){return Object.getOwnPropertySymbols(r).filter(e=>Object.prototype.propertyIsEnumerable.call(r,e))}function Ni(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const co="[object RegExp]",ho="[object String]",lo="[object Number]",uo="[object Boolean]",$i="[object Arguments]",po="[object Symbol]",go="[object Date]",yo="[object Map]",bo="[object Set]",mo="[object Array]",fo="[object Function]",Do="[object ArrayBuffer]",Ze$1="[object Object]",vo="[object Error]",_o="[object DataView]",wo="[object Uint8Array]",Eo="[object Uint8ClampedArray]",Io="[object Uint16Array]",To="[object Uint32Array]",Co="[object BigUint64Array]",Po="[object Int8Array]",So="[object Int16Array]",Oo="[object Int32Array]",Ro="[object BigInt64Array]",Ao="[object Float32Array]",xo="[object Float64Array]";function No(){}function zi(r){if(!r||typeof r!="object")return false;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(r)==="[object Object]":false}function $o(r,e,t){return De$1(r,e,void 0,void 0,void 0,void 0,t)}function De$1(r,e,t,i,s,n,o){const a=o(r,e,t,i,s,n);if(a!==void 0)return a;if(typeof r==typeof e)switch(typeof r){case "bigint":case "string":case "boolean":case "symbol":case "undefined":return r===e;case "number":return r===e||Object.is(r,e);case "function":return r===e;case "object":return ve$2(r,e,n,o)}return ve$2(r,e,n,o)}function ve$2(r,e,t,i){if(Object.is(r,e))return true;let s=Ni(r),n=Ni(e);if(s===$i&&(s=Ze$1),n===$i&&(n=Ze$1),s!==n)return false;switch(s){case ho:return r.toString()===e.toString();case lo:{const c=r.valueOf(),h=e.valueOf();return ao(c,h)}case uo:case go:case po:return Object.is(r.valueOf(),e.valueOf());case co:return r.source===e.source&&r.flags===e.flags;case fo:return r===e}t=t??new Map;const o=t.get(r),a=t.get(e);if(o!=null&&a!=null)return o===e;t.set(r,e),t.set(e,r);try{switch(s){case yo:{if(r.size!==e.size)return !1;for(const[c,h]of r.entries())if(!e.has(c)||!De$1(h,e.get(c),c,r,e,t,i))return !1;return !0}case bo:{if(r.size!==e.size)return !1;const c=Array.from(r.values()),h=Array.from(e.values());for(let l=0;l<c.length;l++){const g=c[l],y=h.findIndex(_=>De$1(g,_,void 0,r,e,t,i));if(y===-1)return !1;h.splice(y,1);}return !0}case mo:case wo:case Eo:case Io:case To:case Co:case Po:case So:case Oo:case Ro:case Ao:case xo:{if(typeof Buffer<"u"&&Buffer.isBuffer(r)!==Buffer.isBuffer(e)||r.length!==e.length)return !1;for(let c=0;c<r.length;c++)if(!De$1(r[c],e[c],c,r,e,t,i))return !1;return !0}case Do:return r.byteLength!==e.byteLength?!1:ve$2(new Uint8Array(r),new Uint8Array(e),t,i);case _o:return r.byteLength!==e.byteLength||r.byteOffset!==e.byteOffset?!1:ve$2(new Uint8Array(r),new Uint8Array(e),t,i);case vo:return r.name===e.name&&r.message===e.message;case Ze$1:{if(!(ve$2(r.constructor,e.constructor,t,i)||zi(r)&&zi(e)))return !1;const h=[...Object.keys(r),...xi(r)],l=[...Object.keys(e),...xi(e)];if(h.length!==l.length)return !1;for(let g=0;g<h.length;g++){const y=h[g],_=r[y];if(!Object.hasOwn(e,y))return !1;const u=e[y];if(!De$1(_,u,y,r,e,t,i))return !1}return !0}default:return !1}}finally{t.delete(r),t.delete(e);}}function zo(r,e){return $o(r,e,No)}var Lo=Object.defineProperty,Li=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Qe$1=(r,e,t)=>e in r?Lo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ki=(r,e)=>{for(var t in e||(e={}))ko.call(e,t)&&Qe$1(r,t,e[t]);if(Li)for(var t of Li(e))jo.call(e,t)&&Qe$1(r,t,e[t]);return r},U$1=(r,e,t)=>Qe$1(r,typeof e!="symbol"?e+"":e,t);class ji extends f$5{constructor(e,t,i,s=W$2,n=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,U$1(this,"map",new Map),U$1(this,"version",jt$1),U$1(this,"cached",[]),U$1(this,"initialized",false),U$1(this,"getKey"),U$1(this,"storagePrefix",W$2),U$1(this,"recentlyDeleted",[]),U$1(this,"recentlyDeletedLimit",200),U$1(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Dt$1(o)?this.map.set(this.getKey(o),o):Ga(o)?this.map.set(o.id,o):za(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=true);}),U$1(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist());}),U$1(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),U$1(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>zo(a[c],o[c]))):this.values)),U$1(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=ki(ki({},this.getData(o)),a);this.map.set(o,c),await this.persist();}),U$1(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist());}),this.logger=X$3(t,this.name),this.storagePrefix=s,this.getKey=n;}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2);}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e);}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:s}=Bt$2("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values);}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e);}}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Uo=Object.defineProperty,Fo=(r,e,t)=>e in r?Uo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,d$2=(r,e,t)=>Fo(r,typeof e!="symbol"?e+"":e,t);class Ui{constructor(e,t){this.core=e,this.logger=t,d$2(this,"name",Kt$1),d$2(this,"version",Bt$1),d$2(this,"events",new xe$3),d$2(this,"pairings"),d$2(this,"initialized",false),d$2(this,"storagePrefix",W$2),d$2(this,"ignoredPayloadTypes",[ie$2]),d$2(this,"registeredMethods",[]),d$2(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=true,this.logger.trace("Initialized"));}),d$2(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])];}),d$2(this,"create",async i=>{this.isInitialized();const s=la(),n=await this.core.crypto.setSymKey(s),o=Ni$1(cjsExports$3.FIVE_MINUTES),a={protocol:Nt$1},c={topic:n,expiry:o,relay:a,active:false,methods:i?.methods},h=$a({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(ae$2.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:i?.transportType,internal:i?.internal}),{topic:n,uri:h}}),d$2(this,"pair",async i=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Y$1.pairing_started]}});this.isValidPair(i,s);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:h}=Ra(i.uri);s.props.properties.topic=n,s.addTrace(Y$1.pairing_uri_validation_success),s.addTrace(Y$1.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(n)){if(l=this.pairings.get(n),s.addTrace(Y$1.existing_pairing),l.active)throw s.setError(X$1.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(Y$1.pairing_not_expired);}const g=c||Ni$1(cjsExports$3.FIVE_MINUTES),y={topic:n,relay:a,expiry:g,active:false,methods:h};this.core.expirer.set(n,g),await this.pairings.set(n,y),s.addTrace(Y$1.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(ae$2.create,y),s.addTrace(Y$1.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(Y$1.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow();}catch{s.setError(X$1.no_internet_connection);}try{await this.core.relayer.subscribe(n,{relay:a});}catch(_){throw s.setError(X$1.subscribe_pairing_topic_failure),_}return s.addTrace(Y$1.subscribe_pairing_topic_success),y}),d$2(this,"activate",async({topic:i})=>{this.isInitialized();const s=Ni$1(cjsExports$3.FIVE_MINUTES);this.core.expirer.set(i,s),await this.pairings.update(i,{active:true,expiry:s});}),d$2(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:s}=i;if(this.pairings.keys.includes(s)){const n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Bi$1();this.events.once(_i$1("pairing_ping",n),({error:h})=>{h?c(h):a();}),await o();}}),d$2(this,"updateExpiry",async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s});}),d$2(this,"updateMetadata",async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s});}),d$2(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),d$2(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",zt$2("USER_DISCONNECTED")),await this.deletePairing(s));}),d$2(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:s,relay:n,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(s);return $a({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),d$2(this,"sendRequest",async(i,s,n)=>{const o=formatJsonRpcRequest(s,n),a=await this.core.crypto.encode(i,o),c=oe$2[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),d$2(this,"sendResult",async(i,s,n)=>{const o=formatJsonRpcResult(i,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,i)).request.method,h=oe$2[c].res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o);}),d$2(this,"sendError",async(i,s,n)=>{const o=formatJsonRpcError(i,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,i)).request.method,h=oe$2[c]?oe$2[c].res:oe$2.unregistered_method.res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o);}),d$2(this,"deletePairing",async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,zt$2("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)]);}),d$2(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(s=>Ui$1(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)));}),d$2(this,"onRelayEventRequest",async i=>{const{topic:s,payload:n}=i;switch(n.method){case "wc_pairingPing":return await this.onPairingPingRequest(s,n);case "wc_pairingDelete":return await this.onPairingDeleteRequest(s,n);default:return await this.onUnknownRpcMethodRequest(s,n)}}),d$2(this,"onRelayEventResponse",async i=>{const{topic:s,payload:n}=i,o=(await this.core.history.get(s,n.id)).request.method;switch(o){case "wc_pairingPing":return this.onPairingPingResponse(s,n);default:return this.onUnknownRpcMethodResponse(o)}}),d$2(this,"onPairingPingRequest",async(i,s)=>{const{id:n}=s;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(ae$2.ping,{id:n,topic:i});}catch(o){await this.sendError(n,i,o),this.logger.error(o);}}),d$2(this,"onPairingPingResponse",(i,s)=>{const{id:n}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(_i$1("pairing_ping",n),{}):isJsonRpcError(s)&&this.events.emit(_i$1("pairing_ping",n),{error:s.error});},500);}),d$2(this,"onPairingDeleteRequest",async(i,s)=>{const{id:n}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(ae$2.delete,{id:n,topic:i});}catch(o){await this.sendError(n,i,o),this.logger.error(o);}}),d$2(this,"onUnknownRpcMethodRequest",async(i,s)=>{const{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=zt$2("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a);}catch(a){await this.sendError(n,i,a),this.logger.error(a);}}),d$2(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(zt$2("WC_METHOD_UNSUPPORTED",i));}),d$2(this,"isValidPair",(i,s)=>{var n;if(!Qa(i)){const{message:a}=Bt$2("MISSING_OR_INVALID",`pair() params: ${i}`);throw s.setError(X$1.malformed_pairing_uri),new Error(a)}if(!Za(i.uri)){const{message:a}=Bt$2("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw s.setError(X$1.malformed_pairing_uri),new Error(a)}const o=Ra(i?.uri);if(!((n=o?.relay)!=null&&n.protocol)){const{message:a}=Bt$2("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(X$1.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=Bt$2("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(X$1.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&cjsExports$3.toMiliseconds(o?.expiryTimestamp)<Date.now()){s.setError(X$1.pairing_expired);const{message:a}=Bt$2("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),d$2(this,"isValidPing",async i=>{if(!Qa(i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s);}),d$2(this,"isValidDisconnect",async i=>{if(!Qa(i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s);}),d$2(this,"isValidPairingTopic",async i=>{if(!ft$2(i,false)){const{message:s}=Bt$2("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=Bt$2("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(Ui$1(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=Bt$2("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}}),this.core=e,this.logger=X$3(t,this.name),this.pairings=new ji(this.core,this.logger,this.name,this.storagePrefix);}get context(){return w$3(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(C$1.message,async e=>{const{topic:t,message:i,transportType:s}=e;if(this.pairings.keys.includes(t)&&s!==ee$2.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const n=await this.core.crypto.decode(t,i);isJsonRpcRequest(n)?(this.core.history.set(t,n),await this.onRelayEventRequest({topic:t,payload:n})):isJsonRpcResponse(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id)),await this.core.relayer.messages.ack(t,i);}catch(n){this.logger.error(n);}});}registerExpirerEvents(){this.core.expirer.on(q$1.expired,async e=>{const{topic:t}=Oi$1(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,true),this.events.emit(ae$2.expire,{topic:t}));});}}var Mo=Object.defineProperty,Ko=(r,e,t)=>e in r?Mo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,N$2=(r,e,t)=>Ko(r,typeof e!="symbol"?e+"":e,t);class Fi extends I$2{constructor(e,t){super(e,t),this.core=e,this.logger=t,N$2(this,"records",new Map),N$2(this,"events",new eventsExports.EventEmitter),N$2(this,"name",Vt$1),N$2(this,"version",qt$1),N$2(this,"cached",[]),N$2(this,"initialized",false),N$2(this,"storagePrefix",W$2),N$2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=true);}),N$2(this,"set",(i,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:n}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:n,expiry:Ni$1(cjsExports$3.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(V$1.created,o);}),N$2(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(V$1.updated,s));}),N$2(this,"get",async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s))),N$2(this,"delete",(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===i){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(V$1.deleted,n);}}),this.persist();}),N$2(this,"exists",async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:false)),N$2(this,"on",(i,s)=>{this.events.on(i,s);}),N$2(this,"once",(i,s)=>{this.events.once(i,s);}),N$2(this,"off",(i,s)=>{this.events.off(i,s);}),N$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),this.logger=X$3(t,this.name);}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e);}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(V$1.sync);}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e);}}registerEventListeners(){this.events.on(V$1.created,e=>{const t=V$1.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e});}),this.events.on(V$1.updated,e=>{const t=V$1.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e});}),this.events.on(V$1.deleted,e=>{const t=V$1.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e});}),this.core.heartbeat.on(r$1.pulse,()=>{this.cleanup();});}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{cjsExports$3.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(V$1.deleted,t,!1),e=!0);}),e&&this.persist();}catch(e){this.logger.warn(e);}}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Bo=Object.defineProperty,Vo=(r,e,t)=>e in r?Bo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,z$2=(r,e,t)=>Vo(r,typeof e!="symbol"?e+"":e,t);class Mi extends S$3{constructor(e,t){super(e,t),this.core=e,this.logger=t,z$2(this,"expirations",new Map),z$2(this,"events",new eventsExports.EventEmitter),z$2(this,"name",Gt$1),z$2(this,"version",Wt$1),z$2(this,"cached",[]),z$2(this,"initialized",false),z$2(this,"storagePrefix",W$2),z$2(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=true);}),z$2(this,"has",i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return false}}),z$2(this,"set",(i,s)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(q$1.created,{target:n,expiration:o});}),z$2(this,"get",i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)}),z$2(this,"del",i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(q$1.deleted,{target:s,expiration:n});}}),z$2(this,"on",(i,s)=>{this.events.on(i,s);}),z$2(this,"once",(i,s)=>{this.events.once(i,s);}),z$2(this,"off",(i,s)=>{this.events.off(i,s);}),z$2(this,"removeListener",(i,s)=>{this.events.removeListener(i,s);}),this.logger=X$3(t,this.name);}get context(){return w$3(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Ii$1(e);if(typeof e=="number")return Si$1(e);const{message:t}=Bt$2("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e);}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(q$1.sync);}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=Bt$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e);}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=Bt$2("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;cjsExports$3.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t);}expire(e,t){this.expirations.delete(e),this.events.emit(q$1.expired,{target:e,expiration:t});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e));}registerEventListeners(){this.core.heartbeat.on(r$1.pulse,()=>this.checkExpirations()),this.events.on(q$1.created,e=>{const t=q$1.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(q$1.expired,e=>{const t=q$1.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(q$1.deleted,e=>{const t=q$1.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(e)}}}var qo=Object.defineProperty,Go=(r,e,t)=>e in r?qo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,P$2=(r,e,t)=>Go(r,typeof e!="symbol"?e+"":e,t);class Ki extends M$4{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,P$2(this,"name",Ht$1),P$2(this,"abortController"),P$2(this,"isDevEnv"),P$2(this,"verifyUrlV3",Jt$1),P$2(this,"storagePrefix",W$2),P$2(this,"version",Fe$2),P$2(this,"publicKey"),P$2(this,"fetchPromise"),P$2(this,"init",async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&cjsExports$3.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()));}),P$2(this,"register",async s=>{if(!Wt$2()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=s,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const h=cjsExports$2.getDocument(),l=this.startAbortTimer(cjsExports$3.ONE_SECOND*5),g=await new Promise((y,_)=>{const u=()=>{window.removeEventListener("message",D),h.body.removeChild(m),_("attestation aborted");};this.abortController.signal.addEventListener("abort",u);const m=h.createElement("iframe");m.src=c,m.style.display="none",m.addEventListener("error",u,{signal:this.abortController.signal});const D=w=>{if(w.data&&typeof w.data=="string")try{const E=JSON.parse(w.data);if(E.type==="verify_attestation"){if(sn$1(E.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(m),this.abortController.signal.removeEventListener("abort",u),window.removeEventListener("message",D),y(E.attestation===null?"":E.attestation);}}catch(E){this.logger.warn(E);}};h.body.appendChild(m),window.addEventListener("message",D,{signal:this.abortController.signal});});return this.logger.debug(g,"jwt attestation"),g}catch(h){this.logger.warn(h);}return ""}),P$2(this,"resolve",async s=>{if(this.isDevEnv)return "";const{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(sn$1(n).payload.id!==a)return;const h=await this.isValidJwtAttestation(n);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const c=this.getVerifyUrl(s?.verifyUrl);return this.fetchAttestation(o,c)}),P$2(this,"fetchAttestation",async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);const o=this.startAbortTimer(cjsExports$3.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),P$2(this,"getVerifyUrl",s=>{let n=s||be$2;return Xt$1.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${be$2}`),n=be$2),n}),P$2(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(cjsExports$3.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s);}}),P$2(this,"persistPublicKey",async s=>{this.logger.debug(s,"persisting public key to local storage"),await this.store.setItem(this.storeKey,s),this.publicKey=s;}),P$2(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0;}),P$2(this,"isValidJwtAttestation",async s=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}}),P$2(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),P$2(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o));});const s=await this.fetchPromise;return this.fetchPromise=void 0,s}),P$2(this,"validateAttestation",(s,n)=>{const o=Ea(s,n.publicKey),a={hasExpired:cjsExports$3.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return {origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=X$3(t,this.name),this.abortController=new AbortController,this.isDevEnv=ji$1(),this.init();}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return w$3(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjsExports$3.toMiliseconds(e))}}var Wo=Object.defineProperty,Ho=(r,e,t)=>e in r?Wo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Bi=(r,e,t)=>Ho(r,typeof e!="symbol"?e+"":e,t);class Vi extends O$3{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Bi(this,"context",Zt$1),Bi(this,"registerDeviceToken",async i=>{const{clientId:s,token:n,notificationType:o,enableEncrypted:a=false}=i,c=`${Qt$1}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})});}),this.logger=X$3(t,this.context);}}var Yo=Object.defineProperty,qi=Object.getOwnPropertySymbols,Jo=Object.prototype.hasOwnProperty,Xo=Object.prototype.propertyIsEnumerable,et$1=(r,e,t)=>e in r?Yo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,_e$2=(r,e)=>{for(var t in e||(e={}))Jo.call(e,t)&&et$1(r,t,e[t]);if(qi)for(var t of qi(e))Xo.call(e,t)&&et$1(r,t,e[t]);return r},A$1=(r,e,t)=>et$1(r,typeof e!="symbol"?e+"":e,t);class Gi extends R$2{constructor(e,t,i=true){super(e,t,i),this.core=e,this.logger=t,A$1(this,"context",ti),A$1(this,"storagePrefix",W$2),A$1(this,"storageVersion",ei),A$1(this,"events",new Map),A$1(this,"shouldPersist",false),A$1(this,"init",async()=>{if(!ji$1())try{const s={eventId:Ci$1(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:wr$1(this.core.relayer.protocol,this.core.relayer.version,Pe$2)}}};await this.sendEvent([s]);}catch(s){this.logger.warn(s);}}),A$1(this,"createEvent",s=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=s,h=Ci$1(),l=this.core.projectId||"",g=Date.now(),y=_e$2({eventId:h,timestamp:g,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,y),this.shouldPersist=true),y}),A$1(this,"getEvent",s=>{const{eventId:n,topic:o}=s;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return _e$2(_e$2({},a),this.setMethods(a.eventId))}),A$1(this,"deleteEvent",s=>{const{eventId:n}=s;this.events.delete(n),this.shouldPersist=true;}),A$1(this,"setEventListeners",()=>{this.core.heartbeat.on(r$1.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{cjsExports$3.fromMiliseconds(Date.now())-cjsExports$3.fromMiliseconds(s.timestamp)>ii&&(this.events.delete(s.eventId),this.shouldPersist=true);});});}),A$1(this,"setMethods",s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)})),A$1(this,"addTrace",(s,n)=>{const o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=true);}),A$1(this,"setError",(s,n)=>{const o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=true);}),A$1(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=false;}),A$1(this,"restore",async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,_e$2(_e$2({},n),this.setMethods(n.eventId)));});}catch(s){this.logger.warn(s);}}),A$1(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const n of s)this.events.delete(n.eventId),this.shouldPersist=!0;}catch(n){this.logger.warn(n);}}),A$1(this,"sendEvent",async s=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${si}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Pe$2}${n}`,{method:"POST",body:JSON.stringify(s)})}),A$1(this,"getAppDomain",()=>br$1().url),this.logger=X$3(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners();}):this.persist();}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Zo=Object.defineProperty,Wi=Object.getOwnPropertySymbols,Qo=Object.prototype.hasOwnProperty,ea=Object.prototype.propertyIsEnumerable,tt$1=(r,e,t)=>e in r?Zo(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Hi=(r,e)=>{for(var t in e||(e={}))Qo.call(e,t)&&tt$1(r,t,e[t]);if(Wi)for(var t of Wi(e))ea.call(e,t)&&tt$1(r,t,e[t]);return r},v$2=(r,e,t)=>tt$1(r,typeof e!="symbol"?e+"":e,t);let Oe$2 = class Oe extends h$2{constructor(e){var t;super(e),v$2(this,"protocol",Ue$2),v$2(this,"version",Fe$2),v$2(this,"name",ge$2),v$2(this,"relayUrl"),v$2(this,"projectId"),v$2(this,"customStoragePrefix"),v$2(this,"events",new eventsExports.EventEmitter),v$2(this,"logger"),v$2(this,"heartbeat"),v$2(this,"relayer"),v$2(this,"crypto"),v$2(this,"storage"),v$2(this,"history"),v$2(this,"expirer"),v$2(this,"pairing"),v$2(this,"verify"),v$2(this,"echoClient"),v$2(this,"linkModeSupportedApps"),v$2(this,"eventClient"),v$2(this,"initialized",false),v$2(this,"logChunkController"),v$2(this,"on",(a,c)=>this.events.on(a,c)),v$2(this,"once",(a,c)=>this.events.once(a,c)),v$2(this,"off",(a,c)=>this.events.off(a,c)),v$2(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),v$2(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:h})=>{if(!a||!c)return;const l={topic:a,message:c,publishedAt:Date.now(),transportType:ee$2.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:h});});const i=this.getGlobalCore(e?.customStoragePrefix);if(i)try{return this.customStoragePrefix=i.customStoragePrefix,this.logger=i.logger,this.heartbeat=i.heartbeat,this.crypto=i.crypto,this.history=i.history,this.expirer=i.expirer,this.storage=i.storage,this.relayer=i.relayer,this.pairing=i.pairing,this.verify=i.verify,this.echoClient=i.echoClient,this.linkModeSupportedApps=i.linkModeSupportedApps,this.eventClient=i.eventClient,this.initialized=i.initialized,this.logChunkController=i.logChunkController,i}catch(a){console.warn("Failed to copy global core",a);}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Ke$2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=D$1({level:typeof e?.logger=="string"&&e.logger?e.logger:Et$2.logger,name:ge$2}),{logger:n,chunkLoggerController:o}=Y$3({opts:s,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=o,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}));}),this.logger=X$3(n,this.name),this.heartbeat=new i$3,this.crypto=new wi(this,this.logger,e?.keychain),this.history=new Fi(this,this.logger),this.expirer=new Mi(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new h$4(Hi(Hi({},It$2),e?.storageOptions)),this.relayer=new Ai({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Ui(this,this.logger),this.verify=new Ki(this,this.logger,this.storage),this.echoClient=new Vi(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Gi(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this);}static async init(e){const t=new Oe(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(Ut$1,i),t}get context(){return w$3(this.logger)}async start(){this.initialized||await this.initialize();}async getLogsBlob(){var e;return (e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Be$1,this.linkModeSupportedApps));}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Be$1)||[],this.initialized=!0,this.logger.info("Core Initialization Success");}catch(e){throw this.logger.warn(e,`Core Initialization Failure at epoch ${Date.now()}`),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const t=`_walletConnectCore_${e}`,i=`${t}_count`;return globalThis[i]=(globalThis[i]||0)+1,globalThis[i]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[i]} times.`),globalThis[t]}catch(t){console.warn("Failed to get global WalletConnect core",t);return}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;const i=`_walletConnectCore_${((t=e.opts)==null?void 0:t.customStoragePrefix)||""}`;globalThis[i]=e;}catch(i){console.warn("Failed to set global WalletConnect core",i);}}isGlobalCoreDisabled(){try{return typeof process<"u"&&process.env.DISABLE_GLOBAL_CORE==="true"}catch{return true}}};const ta=Oe$2;
|
|
29989
31277
|
|
|
29990
|
-
const Ve$1="wc",ke$2=2,De="client",we$2=`${Ve$1}@${ke$2}:${De}:`,me$2={name:De,logger:"error"},Le$1="WALLETCONNECT_DEEPLINK_CHOICE",dt$1="proposal",Me$2="Proposal expired",ut$1="session",W$1=cjsExports$3.SEVEN_DAYS,gt$1="engine",P$1={wc_sessionPropose:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:true,tag:1100},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1101},reject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1120},autoReject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1121}},wc_sessionSettle:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1102},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1103}},wc_sessionUpdate:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1104},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1105}},wc_sessionExtend:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1106},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1107}},wc_sessionRequest:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:true,tag:1108},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1109}},wc_sessionEvent:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:true,tag:1110},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1111}},wc_sessionDelete:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1112},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1113}},wc_sessionPing:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1114},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1115}},wc_sessionAuthenticate:{req:{ttl:cjsExports$3.ONE_HOUR,prompt:true,tag:1116},res:{ttl:cjsExports$3.ONE_HOUR,prompt:false,tag:1117},reject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1118},autoReject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1119}}},_e$1={min:cjsExports$3.FIVE_MINUTES,max:cjsExports$3.SEVEN_DAYS},$$2={idle:"IDLE",active:"ACTIVE"},yt$1={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""},cosmos_signDirect:{key:""}},wt$1="request",mt$1=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_t$1="wc",ft$1="auth",Et$1="authKeys",St$1="pairingTopics",Rt$1="requests",le$2=`${_t$1}@${1.5}:${ft$1}:`,pe$2=`${le$2}:PUB_KEY`;var Ns=Object.defineProperty,Os=Object.defineProperties,bs=Object.getOwnPropertyDescriptors,vt$1=Object.getOwnPropertySymbols,As=Object.prototype.hasOwnProperty,xs=Object.prototype.propertyIsEnumerable,$e$1=(E,o,t)=>o in E?Ns(E,o,{enumerable:true,configurable:true,writable:true,value:t}):E[o]=t,R$1=(E,o)=>{for(var t in o||(o={}))As.call(o,t)&&$e$1(E,t,o[t]);if(vt$1)for(var t of vt$1(o))xs.call(o,t)&&$e$1(E,t,o[t]);return E},O$1=(E,o)=>Os(E,bs(o)),c$1=(E,o,t)=>$e$1(E,typeof o!="symbol"?o+"":o,t);class Cs extends V$3{constructor(o){super(o),c$1(this,"name",gt$1),c$1(this,"events",new xe$2),c$1(this,"initialized",false),c$1(this,"requestQueue",{state:$$2.idle,queue:[]}),c$1(this,"sessionRequestQueue",{state:$$2.idle,queue:[]}),c$1(this,"emittedSessionRequests",new ki$1({limit:500})),c$1(this,"requestQueueDelay",cjsExports$3.ONE_SECOND),c$1(this,"expectedPairingMethodMap",new Map),c$1(this,"recentlyDeletedMap",new Map),c$1(this,"recentlyDeletedLimit",200),c$1(this,"relayMessageCache",[]),c$1(this,"pendingSessions",new Map),c$1(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(P$1)}),this.initialized=true,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue();},cjsExports$3.toMiliseconds(this.requestQueueDelay)));}),c$1(this,"connect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const e=O$1(R$1({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(e),e.optionalNamespaces=qa(e.requiredNamespaces,e.optionalNamespaces),e.requiredNamespaces={};const{pairingTopic:s,requiredNamespaces:i,optionalNamespaces:r,sessionProperties:n,scopedProperties:a,relays:l}=e;let p=s,h,u=false;try{if(p){const T=this.client.core.pairing.pairings.get(p);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),u=T.active;}}catch(T){throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`),T}if(!p||!u){const{topic:T,uri:K}=await this.client.core.pairing.create({internal:{skipSubscribe:true}});p=T,h=K;}if(!p){const{message:T}=Bt$2("NO_MATCHING_KEY",`connect() pairing topic: ${p}`);throw new Error(T)}const d=await this.client.core.crypto.generateKeyPair(),y=P$1.wc_sessionPropose.req.ttl||cjsExports$3.FIVE_MINUTES,w=Ni$1(y),m=O$1(R$1(R$1({requiredNamespaces:i,optionalNamespaces:r,relays:l??[{protocol:Nt$1}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:w,pairingTopic:p},n&&{sessionProperties:n}),a&&{scopedProperties:a}),{id:payloadId()}),S=_i$1("session_connect",m.id),{reject:_,resolve:b,done:V}=Bi$1(y,Me$2),I=({id:T})=>{T===m.id&&(this.client.events.off("proposal_expire",I),this.pendingSessions.delete(m.id),this.events.emit(S,{error:{message:Me$2,code:0}}));};return this.client.events.on("proposal_expire",I),this.events.once(S,({error:T,session:K})=>{this.client.events.off("proposal_expire",I),T?_(T):K&&b(K);}),await this.sendProposeSession({proposal:m,publishOpts:{internal:{throwOnFailedPublish:true},tvf:{correlationId:m.id}}}),await this.setProposal(m.id,m),{uri:h,approval:V}}),c$1(this,"pair",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(e){throw this.client.logger.error("pair() failed"),e}}),c$1(this,"approve",async t=>{var e,s,i;const r=this.client.core.eventClient.createEvent({properties:{topic:(e=t?.id)==null?void 0:e.toString(),trace:[rr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow();}catch(N){throw r.setError(nr.no_internet_connection),N}try{await this.isValidProposalId(t?.id);}catch(N){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),r.setError(nr.proposal_not_found),N}try{await this.isValidApprove(t);}catch(N){throw this.client.logger.error("approve() -> isValidApprove() failed"),r.setError(nr.session_approve_namespace_validation_failure),N}const{id:n,relayProtocol:a,namespaces:l,sessionProperties:p,scopedProperties:h,sessionConfig:u}=t,d=this.client.proposal.get(n);this.client.core.eventClient.deleteEvent({eventId:r.eventId});const{pairingTopic:y,proposer:w,requiredNamespaces:m,optionalNamespaces:S}=d;let _=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:y});_||(_=(i=this.client.core.eventClient)==null?void 0:i.createEvent({type:rr.session_approve_started,properties:{topic:y,trace:[rr.session_approve_started,rr.session_namespaces_validation_success]}}));const b=await this.client.core.crypto.generateKeyPair(),V=w.publicKey,I=await this.client.core.crypto.generateSharedKey(b,V),T=R$1(R$1(R$1({relay:{protocol:a??"irn"},namespaces:l,controller:{publicKey:b,metadata:this.client.metadata},expiry:Ni$1(W$1)},p&&{sessionProperties:p}),h&&{scopedProperties:h}),u&&{sessionConfig:u}),K=ee$2.relay;_.addTrace(rr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:K,internal:{skipSubscribe:!0}});}catch(N){throw _.setError(nr.subscribe_session_topic_failure),N}_.addTrace(rr.subscribe_session_topic_success);const Ee=O$1(R$1({},T),{topic:I,requiredNamespaces:m,optionalNamespaces:S,pairingTopic:y,acknowledged:false,self:T.controller,peer:{publicKey:w.publicKey,metadata:w.metadata},controller:b,transportType:ee$2.relay});await this.client.session.set(I,Ee),_.addTrace(rr.store_session);try{await this.sendApproveSession({sessionTopic:I,proposal:d,pairingProposalResponse:{relay:{protocol:a??"irn"},responderPublicKey:b},sessionSettleRequest:T,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:n}}}),_.addTrace(rr.session_approve_publish_success);}catch(N){throw this.client.logger.error(N),this.client.session.delete(I,zt$2("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(I),N}return this.client.core.eventClient.deleteEvent({eventId:_.eventId}),await this.client.core.pairing.updateMetadata({topic:y,metadata:w.metadata}),await this.deleteProposal(n),await this.client.core.pairing.activate({topic:y}),await this.setExpiry(I,Ni$1(W$1)),{topic:I,acknowledged:()=>Promise.resolve(this.client.session.get(I))}}),c$1(this,"reject",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t);}catch(r){throw this.client.logger.error("reject() -> isValidReject() failed"),r}const{id:e,reason:s}=t;let i;try{i=this.client.proposal.get(e).pairingTopic;}catch(r){throw this.client.logger.error(`reject() -> proposal.get(${e}) failed`),r}i&&await this.sendError({id:e,topic:i,error:s,rpcOpts:P$1.wc_sessionPropose.reject}),await this.deleteProposal(e);}),c$1(this,"update",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t);}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:e,namespaces:s}=t,{done:i,resolve:r,reject:n}=Bi$1(),a=payloadId(),l=getBigIntRpcId().toString(),p=this.client.session.get(e).namespaces;return this.events.once(_i$1("session_update",a),({error:h})=>{h?n(h):r();}),await this.client.session.update(e,{namespaces:s}),await this.sendRequest({topic:e,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:true,clientRpcId:a,relayRpcId:l}).catch(h=>{this.client.logger.error(h),this.client.session.update(e,{namespaces:p}),n(h);}),{acknowledged:i}}),c$1(this,"extend",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t);}catch(a){throw this.client.logger.error("extend() -> isValidExtend() failed"),a}const{topic:e}=t,s=payloadId(),{done:i,resolve:r,reject:n}=Bi$1();return this.events.once(_i$1("session_extend",s),({error:a})=>{a?n(a):r();}),await this.setExpiry(e,Ni$1(W$1)),this.sendRequest({topic:e,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:true}).catch(a=>{n(a);}),{acknowledged:i}}),c$1(this,"request",async t=>{this.isInitialized();try{await this.isValidRequest(t);}catch(m){throw this.client.logger.error("request() -> isValidRequest() failed"),m}const{chainId:e,request:s,topic:i,expiry:r=P$1.wc_sessionRequest.req.ttl}=t,n=this.client.session.get(i);n?.transportType===ee$2.relay&&await this.confirmOnlineStateOrThrow();const a=payloadId(),l=getBigIntRpcId().toString(),{done:p,resolve:h,reject:u}=Bi$1(r,"Request expired. Please try again.");this.events.once(_i$1("session_request",a),({error:m,result:S})=>{m?u(m):h(S);});const d="wc_sessionRequest",y=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);if(y)return await this.sendRequest({clientRpcId:a,relayRpcId:l,topic:i,method:d,params:{request:O$1(R$1({},s),{expiryTimestamp:Ni$1(r)}),chainId:e},expiry:r,throwOnFailedPublish:true,appLink:y}).catch(m=>u(m)),this.client.events.emit("session_request_sent",{topic:i,request:s,chainId:e,id:a}),await p();const w={request:O$1(R$1({},s),{expiryTimestamp:Ni$1(r)}),chainId:e};return await Promise.all([new Promise(async m=>{await this.sendRequest({clientRpcId:a,relayRpcId:l,topic:i,method:d,params:w,expiry:r,throwOnFailedPublish:true,tvf:this.getTVFParams(a,w)}).catch(S=>u(S)),this.client.events.emit("session_request_sent",{topic:i,request:s,chainId:e,id:a}),m();}),new Promise(async m=>{var S;if(!((S=n.sessionConfig)!=null&&S.disableDeepLink)){const _=await $i$1(this.client.core.storage,Le$1);await Ri$1({id:a,topic:i,wcDeepLink:_});}m();}),p()]).then(m=>m[2])}),c$1(this,"respond",async t=>{var e,s;this.isInitialized();const i=this.client.core.eventClient.createEvent({properties:{topic:t?.topic||((s=(e=t?.response)==null?void 0:e.id)==null?void 0:s.toString()),trace:[rr.session_request_response_started]}});try{await this.isValidRespond(t);}catch(h){throw i.addTrace(h?.message),i.setError(nr.session_request_response_validation_failure),h}i.addTrace(rr.session_request_response_validation_success);const{topic:r,response:n}=t,{id:a}=n,l=this.client.session.get(r);l.transportType===ee$2.relay&&await this.confirmOnlineStateOrThrow();const p=this.getAppLinkIfEnabled(l.peer.metadata,l.transportType);try{i.addTrace(rr.session_request_response_publish_started),isJsonRpcResult(n)?await this.sendResult({id:a,topic:r,result:n.result,throwOnFailedPublish:!0,appLink:p}):isJsonRpcError(n)&&await this.sendError({id:a,topic:r,error:n.error,appLink:p}),this.cleanupAfterResponse(t);}catch(h){throw i.addTrace(h?.message),i.setError(nr.session_request_response_publish_failure),h}}),c$1(this,"ping",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t);}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:e}=t;if(this.client.session.keys.includes(e)){const s=payloadId(),i=getBigIntRpcId().toString(),{done:r,resolve:n,reject:a}=Bi$1();this.events.once(_i$1("session_ping",s),({error:l})=>{l?a(l):n();}),await Promise.all([this.sendRequest({topic:e,method:"wc_sessionPing",params:{},throwOnFailedPublish:true,clientRpcId:s,relayRpcId:i}),r()]);}else this.client.core.pairing.pairings.keys.includes(e)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:e}));}),c$1(this,"emit",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:e,event:s,chainId:i}=t,r=getBigIntRpcId().toString(),n=payloadId();await this.sendRequest({topic:e,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:true,relayRpcId:r,clientRpcId:n});}),c$1(this,"disconnect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:e}=t;if(this.client.session.keys.includes(e))await this.sendRequest({topic:e,method:"wc_sessionDelete",params:zt$2("USER_DISCONNECTED"),throwOnFailedPublish:true}),await this.deleteSession({topic:e,emitEvent:false});else if(this.client.core.pairing.pairings.keys.includes(e))await this.client.core.pairing.disconnect({topic:e});else {const{message:s}=Bt$2("MISMATCHED_TOPIC",`Session or pairing topic not found: ${e}`);throw new Error(s)}}),c$1(this,"find",t=>(this.isInitialized(),this.client.session.getAll().filter(e=>Fa(e,t)))),c$1(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),c$1(this,"authenticate",async(t,e)=>{var s;this.isInitialized(),this.isValidAuthenticate(t);const i=e&&this.client.core.linkModeSupportedApps.includes(e)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),r=i?ee$2.link_mode:ee$2.relay;r===ee$2.relay&&await this.confirmOnlineStateOrThrow();const{chains:n,statement:a="",uri:l,domain:p,nonce:h,type:u,exp:d,nbf:y,methods:w=[],expiry:m}=t,S=[...t.resources||[]],{topic:_,uri:b}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:r});this.client.logger.info({message:"Generated new pairing",pairing:{topic:_,uri:b}});const V=await this.client.core.crypto.generateKeyPair(),I=ha(V);if(await Promise.all([this.client.auth.authKeys.set(pe$2,{responseTopic:I,publicKey:V}),this.client.auth.pairingTopics.set(I,{topic:I,pairingTopic:_})]),await this.client.core.relayer.subscribe(I,{transportType:r}),this.client.logger.info(`sending request to new pairing topic: ${_}`),w.length>0){const{namespace:A}=Je$2(n[0]);let k=Kc(A,"request",w);je$1(S)&&(k=qc(k,S.pop())),S.push(k);}const T=m&&m>P$1.wc_sessionAuthenticate.req.ttl?m:P$1.wc_sessionAuthenticate.req.ttl,K={authPayload:{type:u??"caip122",chains:n,statement:a,aud:l,domain:p,version:"1",nonce:h,iat:new Date().toISOString(),exp:d,nbf:y,resources:S},requester:{publicKey:V,metadata:this.client.metadata},expiryTimestamp:Ni$1(T)},Ee={eip155:{chains:n,methods:[...new Set(["personal_sign",...w])],events:["chainChanged","accountsChanged"]}},N={requiredNamespaces:{},optionalNamespaces:Ee,relays:[{protocol:"irn"}],pairingTopic:_,proposer:{publicKey:V,metadata:this.client.metadata},expiryTimestamp:Ni$1(P$1.wc_sessionPropose.req.ttl),id:payloadId()},{done:Tt,resolve:Ue,reject:Se}=Bi$1(T,"Request expired"),ie=payloadId(),he=_i$1("session_connect",N.id),Re=_i$1("session_request",ie),de=async({error:A,session:k})=>{this.events.off(Re,ve),A?Se(A):k&&Ue({session:k});},ve=async A=>{var k,Ge,je;if(await this.deletePendingAuthRequest(ie,{message:"fulfilled",code:0}),A.error){const ne=zt$2("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return A.error.code===ne.code?void 0:(this.events.off(he,de),Se(A.error.message))}await this.deleteProposal(N.id),this.events.off(he,de);const{cacaos:Fe,responder:H}=A.result,Te=[],Qe=[];for(const ne of Fe){await Pc({cacao:ne,projectId:this.client.core.projectId})||(this.client.logger.error(ne,"Signature verification failed"),Se(zt$2("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:qe}=ne,Pe=je$1(qe.resources),He=[to$1(qe.iss)],qt=bn$1(qe.iss);if(Pe){const Ne=Fc(Pe),Pt=Zc(Pe);Te.push(...Ne),He.push(...Pt);}for(const Ne of He)Qe.push(`${Ne}:${qt}`);}const re=await this.client.core.crypto.generateSharedKey(V,H.publicKey);let ue;Te.length>0&&(ue={topic:re,acknowledged:true,self:{publicKey:V,metadata:this.client.metadata},peer:H,controller:H.publicKey,expiry:Ni$1(W$1),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:_,namespaces:Ka([...new Set(Te)],[...new Set(Qe)]),transportType:r},await this.client.core.relayer.subscribe(re,{transportType:r}),await this.client.session.set(re,ue),_&&await this.client.core.pairing.updateMetadata({topic:_,metadata:H.metadata}),ue=this.client.session.get(re)),(k=this.client.metadata.redirect)!=null&&k.linkMode&&(Ge=H.metadata.redirect)!=null&&Ge.linkMode&&(je=H.metadata.redirect)!=null&&je.universal&&e&&(this.client.core.addLinkModeSupportedApp(H.metadata.redirect.universal),this.client.session.update(re,{transportType:ee$2.link_mode})),Ue({auths:Fe,session:ue});};this.events.once(he,de),this.events.once(Re,ve);let Ie;try{if(i){const A=formatJsonRpcRequest("wc_sessionAuthenticate",K,ie);this.client.core.history.set(_,A);const k=await this.client.core.crypto.encode("",A,{type:we$3,encoding:Ge$2});Ie=Ta(e,_,k);}else await Promise.all([this.sendRequest({topic:_,method:"wc_sessionAuthenticate",params:K,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:ie}),this.sendRequest({topic:_,method:"wc_sessionPropose",params:N,expiry:P$1.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:N.id})]);}catch(A){throw this.events.off(he,de),this.events.off(Re,ve),A}return await this.setProposal(N.id,N),await this.setAuthRequest(ie,{request:O$1(R$1({},K),{verifyContext:{}}),pairingTopic:_,transportType:r}),{uri:Ie??b,response:Tt}}),c$1(this,"approveSessionAuthenticate",async t=>{const{id:e,auths:s}=t,i=this.client.core.eventClient.createEvent({properties:{topic:e.toString(),trace:[or.authenticated_session_approve_started]}});try{this.isInitialized();}catch(m){throw i.setError(ar.no_internet_connection),m}const r=this.getPendingAuthRequest(e);if(!r)throw i.setError(ar.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${e}`);const n=r.transportType||ee$2.relay;n===ee$2.relay&&await this.confirmOnlineStateOrThrow();const a=r.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),p=ha(a),h={type:ie$2,receiverPublicKey:a,senderPublicKey:l},u=[],d=[];for(const m of s){if(!await Pc({cacao:m,projectId:this.client.core.projectId})){i.setError(ar.invalid_cacao);const I=zt$2("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:e,topic:p,error:I,encodeOpts:h}),new Error(I.message)}i.addTrace(or.cacaos_verified);const{p:S}=m,_=je$1(S.resources),b=[to$1(S.iss)],V=bn$1(S.iss);if(_){const I=Fc(_),T=Zc(_);u.push(...I),b.push(...T);}for(const I of b)d.push(`${I}:${V}`);}const y=await this.client.core.crypto.generateSharedKey(l,a);i.addTrace(or.create_authenticated_session_topic);let w;if(u?.length>0){w={topic:y,acknowledged:true,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:a,metadata:r.requester.metadata},controller:a,expiry:Ni$1(W$1),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:r.pairingTopic,namespaces:Ka([...new Set(u)],[...new Set(d)]),transportType:n},i.addTrace(or.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(y,{transportType:n});}catch(m){throw i.setError(ar.subscribe_authenticated_session_topic_failure),m}i.addTrace(or.subscribe_authenticated_session_topic_success),await this.client.session.set(y,w),i.addTrace(or.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:r.pairingTopic,metadata:r.requester.metadata});}i.addTrace(or.publishing_authenticated_session_approve);try{await this.sendResult({topic:p,id:e,result:{cacaos:s,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(r.requester.metadata,n)});}catch(m){throw i.setError(ar.authenticated_session_approve_publish_failure),m}return await this.client.auth.requests.delete(e,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:r.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:i.eventId}),{session:w}}),c$1(this,"rejectSessionAuthenticate",async t=>{this.isInitialized();const{id:e,reason:s}=t,i=this.getPendingAuthRequest(e);if(!i)throw new Error(`Could not find pending auth request with id ${e}`);i.transportType===ee$2.relay&&await this.confirmOnlineStateOrThrow();const r=i.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),a=ha(r),l={type:ie$2,receiverPublicKey:r,senderPublicKey:n};await this.sendError({id:e,topic:a,error:s,encodeOpts:l,rpcOpts:P$1.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(e,{message:"rejected",code:0}),await this.deleteProposal(e);}),c$1(this,"formatAuthMessage",t=>{this.isInitialized();const{request:e,iss:s}=t;return eo$1(e,s)}),c$1(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t);}catch(t){this.client.logger.error(t);}},50);}),c$1(this,"cleanupDuplicatePairings",async t=>{if(t.pairingTopic)try{const e=this.client.core.pairing.pairings.get(t.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(i=>{var r,n;return ((r=i.peerMetadata)==null?void 0:r.url)&&((n=i.peerMetadata)==null?void 0:n.url)===t.peer.metadata.url&&i.topic&&i.topic!==e.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished");}catch(e){this.client.logger.error(e);}}),c$1(this,"deleteSession",async t=>{var e;const{topic:s,expirerHasDeleted:i=false,emitEvent:r=true,id:n=0}=t,{self:a}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,zt$2("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(Le$1).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===s&&this.deletePendingSessionRequest(l.id,zt$2("USER_DISCONNECTED"));}),s===((e=this.sessionRequestQueue.queue[0])==null?void 0:e.topic)&&(this.sessionRequestQueue.state=$$2.idle),r&&this.client.events.emit("session_delete",{id:n,topic:s});}),c$1(this,"deleteProposal",async(t,e)=>{if(e)try{const s=this.client.proposal.get(t),i=this.client.core.eventClient.getEvent({topic:s.pairingTopic});i?.setError(nr.proposal_expired);}catch{}await Promise.all([this.client.proposal.delete(t,zt$2("USER_DISCONNECTED")),e?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal");}),c$1(this,"deletePendingSessionRequest",async(t,e,s=false)=>{await Promise.all([this.client.pendingRequest.delete(t,e),s?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==t),s&&(this.sessionRequestQueue.state=$$2.idle,this.client.events.emit("session_request_expire",{id:t}));}),c$1(this,"deletePendingAuthRequest",async(t,e,s=false)=>{await Promise.all([this.client.auth.requests.delete(t,e),s?Promise.resolve():this.client.core.expirer.del(t)]);}),c$1(this,"setExpiry",async(t,e)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,e),await this.client.session.update(t,{expiry:e}));}),c$1(this,"setProposal",async(t,e)=>{this.client.core.expirer.set(t,Ni$1(P$1.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,e);}),c$1(this,"setAuthRequest",async(t,e)=>{const{request:s,pairingTopic:i,transportType:r=ee$2.relay}=e;this.client.core.expirer.set(t,s.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:t,pairingTopic:i,verifyContext:s.verifyContext,transportType:r});}),c$1(this,"setPendingSessionRequest",async t=>{const{id:e,topic:s,params:i,verifyContext:r}=t,n=i.request.expiryTimestamp||Ni$1(P$1.wc_sessionRequest.req.ttl);this.client.core.expirer.set(e,n),await this.client.pendingRequest.set(e,{id:e,topic:s,params:i,verifyContext:r});}),c$1(this,"sendRequest",async t=>{const{topic:e,method:s,params:i,expiry:r,relayRpcId:n,clientRpcId:a,throwOnFailedPublish:l,appLink:p,tvf:h,publishOpts:u={}}=t,d=formatJsonRpcRequest(s,i,a);let y;const w=!!p;try{const _=w?Ge$2:oe$3;y=await this.client.core.crypto.encode(e,d,{encoding:_});}catch(_){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e} failed`),_}let m;if(mt$1.includes(s)){const _=pa(JSON.stringify(d)),b=pa(y);m=await this.client.core.verify.register({id:b,decryptedId:_});}const S=R$1(R$1({},P$1[s].req),u);if(S.attestation=m,r&&(S.ttl=r),n&&(S.id=n),this.client.core.history.set(e,d),w){const _=Ta(p,e,y);await global.Linking.openURL(_,this.client.name);}else S.tvf=O$1(R$1({},h),{correlationId:d.id}),l?(S.internal=O$1(R$1({},S.internal),{throwOnFailedPublish:true}),await this.client.core.relayer.publish(e,y,S)):this.client.core.relayer.publish(e,y,S).catch(_=>this.client.logger.error(_));return d.id}),c$1(this,"sendProposeSession",async t=>{const{proposal:e,publishOpts:s}=t,i=formatJsonRpcRequest("wc_sessionPropose",e,e.id);this.client.core.history.set(e.pairingTopic,i);const r=await this.client.core.crypto.encode(e.pairingTopic,i,{encoding:oe$3}),n=pa(JSON.stringify(i)),a=pa(r),l=await this.client.core.verify.register({id:a,decryptedId:n});await this.client.core.relayer.publishCustom({payload:{pairingTopic:e.pairingTopic,sessionProposal:r},opts:O$1(R$1({},s),{publishMethod:"wc_proposeSession",attestation:l})});}),c$1(this,"sendApproveSession",async t=>{const{sessionTopic:e,pairingProposalResponse:s,proposal:i,sessionSettleRequest:r,publishOpts:n}=t,a=formatJsonRpcResult(i.id,s),l=await this.client.core.crypto.encode(i.pairingTopic,a,{encoding:oe$3}),p=formatJsonRpcRequest("wc_sessionSettle",r,n?.id),h=await this.client.core.crypto.encode(e,p,{encoding:oe$3});this.client.core.history.set(e,p),await this.client.core.relayer.publishCustom({payload:{sessionTopic:e,pairingTopic:i.pairingTopic,sessionProposalResponse:l,sessionSettlementRequest:h},opts:O$1(R$1({},n),{publishMethod:"wc_approveSession"})});}),c$1(this,"sendResult",async t=>{const{id:e,topic:s,result:i,throwOnFailedPublish:r,encodeOpts:n,appLink:a}=t,l=formatJsonRpcResult(e,i);let p;const h=a&&typeof(global==null?void 0:global.Linking)<"u";try{const y=h?Ge$2:oe$3;p=await this.client.core.crypto.encode(s,l,O$1(R$1({},n||{}),{encoding:y}));}catch(y){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),y}let u,d;try{u=await this.client.core.history.get(s,e);const y=u.request;try{d=this.getTVFParams(e,y.params,i);}catch(w){this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${w?.message}`);}}catch(y){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${e}) failed`),y}if(h){const y=Ta(a,s,p);await global.Linking.openURL(y,this.client.name);}else {const y=u.request.method,w=P$1[y].res;w.tvf=O$1(R$1({},d),{correlationId:e}),r?(w.internal=O$1(R$1({},w.internal),{throwOnFailedPublish:true}),await this.client.core.relayer.publish(s,p,w)):this.client.core.relayer.publish(s,p,w).catch(m=>this.client.logger.error(m));}await this.client.core.history.resolve(l);}),c$1(this,"sendError",async t=>{const{id:e,topic:s,error:i,encodeOpts:r,rpcOpts:n,appLink:a}=t,l=formatJsonRpcError(e,i);let p;const h=a&&typeof(global==null?void 0:global.Linking)<"u";try{const d=h?Ge$2:oe$3;p=await this.client.core.crypto.encode(s,l,O$1(R$1({},r||{}),{encoding:d}));}catch(d){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),d}let u;try{u=await this.client.core.history.get(s,e);}catch(d){throw this.client.logger.error(`sendError() -> history.get(${s}, ${e}) failed`),d}if(h){const d=Ta(a,s,p);await global.Linking.openURL(d,this.client.name);}else {const d=u.request.method,y=n||P$1[d].res;this.client.core.relayer.publish(s,p,y);}await this.client.core.history.resolve(l);}),c$1(this,"cleanup",async()=>{const t=[],e=[];this.client.session.getAll().forEach(s=>{let i=false;Ui$1(s.expiry)&&(i=true),this.client.core.crypto.keychain.has(s.topic)||(i=true),i&&t.push(s.topic);}),this.client.proposal.getAll().forEach(s=>{Ui$1(s.expiryTimestamp)&&e.push(s.id);}),await Promise.all([...t.map(s=>this.deleteSession({topic:s})),...e.map(s=>this.deleteProposal(s))]);}),c$1(this,"onProviderMessageEvent",async t=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(t):await this.onRelayMessage(t);}),c$1(this,"onRelayEventRequest",async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue();}),c$1(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===$$2.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=$$2.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t);}catch(e){this.client.logger.warn(e);}}this.requestQueue.state=$$2.idle;}),c$1(this,"processRequest",async t=>{const{topic:e,payload:s,attestation:i,transportType:r,encryptedId:n}=t,a=s.method;if(!this.shouldIgnorePairingRequest({topic:e,requestMethod:a}))switch(a){case "wc_sessionPropose":return await this.onSessionProposeRequest({topic:e,payload:s,attestation:i,encryptedId:n});case "wc_sessionSettle":return await this.onSessionSettleRequest(e,s);case "wc_sessionUpdate":return await this.onSessionUpdateRequest(e,s);case "wc_sessionExtend":return await this.onSessionExtendRequest(e,s);case "wc_sessionPing":return await this.onSessionPingRequest(e,s);case "wc_sessionDelete":return await this.onSessionDeleteRequest(e,s);case "wc_sessionRequest":return await this.onSessionRequest({topic:e,payload:s,attestation:i,encryptedId:n,transportType:r});case "wc_sessionEvent":return await this.onSessionEventRequest(e,s);case "wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:e,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${a}`)}}),c$1(this,"onRelayEventResponse",async t=>{const{topic:e,payload:s,transportType:i}=t,r=(await this.client.core.history.get(e,s.id)).request.method;switch(r){case "wc_sessionPropose":return this.onSessionProposeResponse(e,s,i);case "wc_sessionSettle":return this.onSessionSettleResponse(e,s);case "wc_sessionUpdate":return this.onSessionUpdateResponse(e,s);case "wc_sessionExtend":return this.onSessionExtendResponse(e,s);case "wc_sessionPing":return this.onSessionPingResponse(e,s);case "wc_sessionRequest":return this.onSessionRequestResponse(e,s);case "wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(e,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),c$1(this,"onRelayEventUnknownPayload",t=>{const{topic:e}=t,{message:s}=Bt$2("MISSING_OR_INVALID",`Decoded payload on topic ${e} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),c$1(this,"shouldIgnorePairingRequest",t=>{const{topic:e,requestMethod:s}=t,i=this.expectedPairingMethodMap.get(e);return !i||i.includes(s)?false:!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),c$1(this,"onSessionProposeRequest",async t=>{const{topic:e,payload:s,attestation:i,encryptedId:r}=t,{params:n,id:a}=s;try{const l=this.client.core.eventClient.getEvent({topic:e});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l?.setError(X$1.proposal_listener_not_found)),this.isValidConnect(R$1({},s.params));const p=n.expiryTimestamp||Ni$1(P$1.wc_sessionPropose.req.ttl),h=R$1({id:a,pairingTopic:e,expiryTimestamp:p,attestation:i,encryptedId:r},n);await this.setProposal(a,h);const u=await this.getVerifyContext({attestationId:i,hash:pa(JSON.stringify(s)),encryptedId:r,metadata:h.proposer.metadata});l?.addTrace(Y$1.emit_session_proposal),this.client.events.emit("session_proposal",{id:a,params:h,verifyContext:u});}catch(l){await this.sendError({id:a,topic:e,error:l,rpcOpts:P$1.wc_sessionPropose.autoReject}),this.client.logger.error(l);}}),c$1(this,"onSessionProposeResponse",async(t,e,s)=>{const{id:i}=e;if(isJsonRpcResult(e)){const{result:r}=e;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const a=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:a});const l=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const p=await this.client.core.crypto.generateSharedKey(a,l);this.pendingSessions.set(i,{sessionTopic:p,pairingTopic:t,proposalId:i,publicKey:a});const h=await this.client.core.relayer.subscribe(p,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:t});}else if(isJsonRpcError(e)){await this.deleteProposal(i);const r=_i$1("session_connect",i);if(this.events.listenerCount(r)===0)throw new Error(`emitting ${r} without any listeners, 954`);this.events.emit(r,{error:e.error});}}),c$1(this,"onSessionSettleRequest",async(t,e)=>{const{id:s,params:i}=e;try{this.isValidSessionSettleRequest(i);const{relay:r,controller:n,expiry:a,namespaces:l,sessionProperties:p,scopedProperties:h,sessionConfig:u}=e.params,d=[...this.pendingSessions.values()].find(m=>m.sessionTopic===t);if(!d)return this.client.logger.error(`Pending session not found for topic ${t}`);const y=this.client.proposal.get(d.proposalId),w=O$1(R$1(R$1(R$1({topic:t,relay:r,expiry:a,namespaces:l,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:y.requiredNamespaces,optionalNamespaces:y.optionalNamespaces,controller:n.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},p&&{sessionProperties:p}),h&&{scopedProperties:h}),u&&{sessionConfig:u}),{transportType:ee$2.relay});await this.client.session.set(w.topic,w),await this.setExpiry(w.topic,w.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:w.peer.metadata}),this.client.events.emit("session_connect",{session:w}),this.events.emit(_i$1("session_connect",d.proposalId),{session:w}),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(w),await this.sendResult({id:e.id,topic:t,result:!0});}catch(r){await this.sendError({id:s,topic:t,error:r}),this.client.logger.error(r);}}),c$1(this,"onSessionSettleResponse",async(t,e)=>{const{id:s}=e;isJsonRpcResult(e)?(await this.client.session.update(t,{acknowledged:true}),this.events.emit(_i$1("session_approve",s),{})):isJsonRpcError(e)&&(await this.client.session.delete(t,zt$2("USER_DISCONNECTED")),this.events.emit(_i$1("session_approve",s),{error:e.error}));}),c$1(this,"onSessionUpdateRequest",async(t,e)=>{const{params:s,id:i}=e;try{const r=`${t}_session_update`,n=hu.get(r);if(n&&this.isRequestOutOfSync(n,i)){this.client.logger.warn(`Discarding out of sync request - ${i}`),this.sendError({id:i,topic:t,error:zt$2("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(R$1({topic:t},s));try{hu.set(r,i),await this.client.session.update(t,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:t,result:!0});}catch(a){throw hu.delete(r),a}this.client.events.emit("session_update",{id:i,topic:t,params:s});}catch(r){await this.sendError({id:i,topic:t,error:r}),this.client.logger.error(r);}}),c$1(this,"isRequestOutOfSync",(t,e)=>e.toString().slice(0,-3)<t.toString().slice(0,-3)),c$1(this,"onSessionUpdateResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_update",s);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);isJsonRpcResult(e)?this.events.emit(_i$1("session_update",s),{}):isJsonRpcError(e)&&this.events.emit(_i$1("session_update",s),{error:e.error});}),c$1(this,"onSessionExtendRequest",async(t,e)=>{const{id:s}=e;try{this.isValidExtend({topic:t}),await this.setExpiry(t,Ni$1(W$1)),await this.sendResult({id:s,topic:t,result:!0}),this.client.events.emit("session_extend",{id:s,topic:t});}catch(i){await this.sendError({id:s,topic:t,error:i}),this.client.logger.error(i);}}),c$1(this,"onSessionExtendResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_extend",s);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);isJsonRpcResult(e)?this.events.emit(_i$1("session_extend",s),{}):isJsonRpcError(e)&&this.events.emit(_i$1("session_extend",s),{error:e.error});}),c$1(this,"onSessionPingRequest",async(t,e)=>{const{id:s}=e;try{this.isValidPing({topic:t}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:t});}catch(i){await this.sendError({id:s,topic:t,error:i}),this.client.logger.error(i);}}),c$1(this,"onSessionPingResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_ping",s);setTimeout(()=>{if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners 2176`);isJsonRpcResult(e)?this.events.emit(_i$1("session_ping",s),{}):isJsonRpcError(e)&&this.events.emit(_i$1("session_ping",s),{error:e.error});},500);}),c$1(this,"onSessionDeleteRequest",async(t,e)=>{const{id:s}=e;try{this.isValidDisconnect({topic:t,reason:e.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(C$1.publish,async()=>{i(await this.deleteSession({topic:t,id:s}));});}),this.sendResult({id:s,topic:t,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:zt$2("USER_DISCONNECTED")})]).catch(i=>this.client.logger.error(i));}catch(i){this.client.logger.error(i);}}),c$1(this,"onSessionRequest",async t=>{var e,s,i;const{topic:r,payload:n,attestation:a,encryptedId:l,transportType:p}=t,{id:h,params:u}=n;try{await this.isValidRequest(R$1({topic:r},u));const d=this.client.session.get(r),y=await this.getVerifyContext({attestationId:a,hash:pa(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",u,h))),encryptedId:l,metadata:d.peer.metadata,transportType:p}),w={id:h,topic:r,params:u,verifyContext:y};await this.setPendingSessionRequest(w),p===ee$2.link_mode&&(e=d.peer.metadata.redirect)!=null&&e.universal&&this.client.core.addLinkModeSupportedApp((s=d.peer.metadata.redirect)==null?void 0:s.universal),(i=this.client.signConfig)!=null&&i.disableRequestQueue?this.emitSessionRequest(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue());}catch(d){await this.sendError({id:h,topic:r,error:d}),this.client.logger.error(d);}}),c$1(this,"onSessionRequestResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_request",s);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);isJsonRpcResult(e)?this.events.emit(_i$1("session_request",s),{result:e.result}):isJsonRpcError(e)&&this.events.emit(_i$1("session_request",s),{error:e.error});}),c$1(this,"onSessionEventRequest",async(t,e)=>{const{id:s,params:i}=e;try{const r=`${t}_session_event_${i.event.name}`,n=hu.get(r);if(n&&this.isRequestOutOfSync(n,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(R$1({topic:t},i)),this.client.events.emit("session_event",{id:s,topic:t,params:i}),hu.set(r,s);}catch(r){await this.sendError({id:s,topic:t,error:r}),this.client.logger.error(r);}}),c$1(this,"onSessionAuthenticateResponse",(t,e)=>{const{id:s}=e;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:e}),isJsonRpcResult(e)?this.events.emit(_i$1("session_request",s),{result:e.result}):isJsonRpcError(e)&&this.events.emit(_i$1("session_request",s),{error:e.error});}),c$1(this,"onSessionAuthenticateRequest",async t=>{var e;const{topic:s,payload:i,attestation:r,encryptedId:n,transportType:a}=t;try{const{requester:l,authPayload:p,expiryTimestamp:h}=i.params,u=await this.getVerifyContext({attestationId:r,hash:pa(JSON.stringify(i)),encryptedId:n,metadata:l.metadata,transportType:a}),d={requester:l,pairingTopic:s,id:i.id,authPayload:p,verifyContext:u,expiryTimestamp:h};await this.setAuthRequest(i.id,{request:d,pairingTopic:s,transportType:a}),a===ee$2.link_mode&&(e=l.metadata.redirect)!=null&&e.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:i.params,id:i.id,verifyContext:u});}catch(l){this.client.logger.error(l);const p=i.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),u=this.getAppLinkIfEnabled(i.params.requester.metadata,a),d={type:ie$2,receiverPublicKey:p,senderPublicKey:h};await this.sendError({id:i.id,topic:s,error:l,encodeOpts:d,rpcOpts:P$1.wc_sessionAuthenticate.autoReject,appLink:u});}}),c$1(this,"addSessionRequestToSessionRequestQueue",t=>{this.sessionRequestQueue.queue.push(t);}),c$1(this,"cleanupAfterResponse",t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=$$2.idle,this.processSessionRequestQueue();},cjsExports$3.toMiliseconds(this.requestQueueDelay));}),c$1(this,"cleanupPendingSentRequestsForTopic",({topic:t,error:e})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(i=>i.topic===t&&i.request.method==="wc_sessionRequest").forEach(i=>{const r=i.request.id,n=_i$1("session_request",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);this.events.emit(_i$1("session_request",i.request.id),{error:e});});}),c$1(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===$$2.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.emitSessionRequest(t);}catch(e){this.client.logger.error(e);}}),c$1(this,"emitSessionRequest",t=>{if(this.emittedSessionRequests.has(t.id)){this.client.logger.warn({id:t.id},`Skipping emitting \`session_request\` event for duplicate request. id: ${t.id}`);return}this.sessionRequestQueue.state=$$2.active,this.emittedSessionRequests.add(t.id),this.client.events.emit("session_request",t);}),c$1(this,"onPairingCreated",t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const e=this.client.proposal.getAll().find(s=>s.pairingTopic===t.topic);e&&this.onSessionProposeRequest({topic:t.topic,payload:formatJsonRpcRequest("wc_sessionPropose",O$1(R$1({},e),{requiredNamespaces:e.requiredNamespaces,optionalNamespaces:e.optionalNamespaces,relays:e.relays,proposer:e.proposer,sessionProperties:e.sessionProperties,scopedProperties:e.scopedProperties}),e.id),attestation:e.attestation,encryptedId:e.encryptedId});}),c$1(this,"isValidConnect",async t=>{if(!Qa(t)){const{message:l}=Bt$2("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(l)}const{pairingTopic:e,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,scopedProperties:n,relays:a}=t;if(Dt$1(e)||await this.isValidPairingTopic(e),!Xa(a)){const{message:l}=Bt$2("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(l)}if(s&&!Dt$1(s)&&Ye$2(s)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(s,"requiredNamespaces");}if(i&&!Dt$1(i)&&Ye$2(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),r&&!Dt$1(r)&&this.validateSessionProps(r,"sessionProperties"),n&&!Dt$1(n)){this.validateSessionProps(n,"scopedProperties");const l=Object.keys(s||{}).concat(Object.keys(i||{}));if(!Object.keys(n).every(p=>l.includes(p.split(":")[0])))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),c$1(this,"validateNamespaces",(t,e)=>{const s=Wa(t,"connect()",e);if(s)throw new Error(s.message)}),c$1(this,"isValidApprove",async t=>{if(!Qa(t))throw new Error(Bt$2("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:e,namespaces:s,relayProtocol:i,sessionProperties:r,scopedProperties:n}=t;this.checkRecentlyDeleted(e),await this.isValidProposalId(e);const a=this.client.proposal.get(e),l=Ss(s,"approve()");if(l)throw new Error(l.message);const p=Ns$1(a.requiredNamespaces,s,"approve()");if(p)throw new Error(p.message);if(!ft$2(i,true)){const{message:h}=Bt$2("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(h)}if(r&&!Dt$1(r)&&this.validateSessionProps(r,"sessionProperties"),n&&!Dt$1(n)){this.validateSessionProps(n,"scopedProperties");const h=new Set(Object.keys(s));if(!Object.keys(n).every(u=>h.has(u.split(":")[0])))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),c$1(this,"isValidReject",async t=>{if(!Qa(t)){const{message:i}=Bt$2("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(i)}const{id:e,reason:s}=t;if(this.checkRecentlyDeleted(e),await this.isValidProposalId(e),!tu(s)){const{message:i}=Bt$2("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(i)}}),c$1(this,"isValidSessionSettleRequest",t=>{if(!Qa(t)){const{message:l}=Bt$2("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(l)}const{relay:e,controller:s,namespaces:i,expiry:r}=t;if(!Os$1(e)){const{message:l}=Bt$2("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const n=Ya(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const a=Ss(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);if(Ui$1(r)){const{message:l}=Bt$2("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),c$1(this,"isValidUpdate",async t=>{if(!Qa(t)){const{message:a}=Bt$2("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(a)}const{topic:e,namespaces:s}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const i=this.client.session.get(e),r=Ss(s,"update()");if(r)throw new Error(r.message);const n=Ns$1(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)}),c$1(this,"isValidExtend",async t=>{if(!Qa(t)){const{message:s}=Bt$2("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(s)}const{topic:e}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);}),c$1(this,"isValidRequest",async t=>{if(!Qa(t)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(a)}const{topic:e,request:s,chainId:i,expiry:r}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const{namespaces:n}=this.client.session.get(e);if(!ou(n,i)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(a)}if(!eu(s)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(a)}if(!su(n,i,s.method)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(a)}if(r&&!au(r,_e$1)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${_e$1.min} and ${_e$1.max}`);throw new Error(a)}}),c$1(this,"isValidRespond",async t=>{var e;if(!Qa(t)){const{message:n}=Bt$2("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(n)}const{topic:s,response:i}=t;try{await this.isValidSessionTopic(s);}catch(n){throw (e=t?.response)!=null&&e.id&&this.cleanupAfterResponse(t),n}if(!nu(i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(n)}const r=this.client.pendingRequest.get(i.id);if(r.topic!==s){const{message:n}=Bt$2("MISMATCHED_TOPIC",`Request response topic mismatch. reqId: ${i.id}, expected topic: ${r.topic}, received topic: ${s}`);throw new Error(n)}}),c$1(this,"isValidPing",async t=>{if(!Qa(t)){const{message:s}=Bt$2("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(s)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e);}),c$1(this,"isValidEmit",async t=>{if(!Qa(t)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(n)}const{topic:e,event:s,chainId:i}=t;await this.isValidSessionTopic(e);const{namespaces:r}=this.client.session.get(e);if(!ou(r,i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(n)}if(!ru(s)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(n)}if(!iu(r,i,s.name)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(n)}}),c$1(this,"isValidDisconnect",async t=>{if(!Qa(t)){const{message:s}=Bt$2("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(s)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e);}),c$1(this,"isValidAuthenticate",t=>{const{chains:e,uri:s,domain:i,nonce:r}=t;if(!Array.isArray(e)||e.length===0)throw new Error("chains is required and must be a non-empty array");if(!ft$2(s,false))throw new Error("uri is required parameter");if(!ft$2(i,false))throw new Error("domain is required parameter");if(!ft$2(r,false))throw new Error("nonce is required parameter");if([...new Set(e.map(a=>Je$2(a).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=Je$2(e[0]);if(n!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),c$1(this,"getVerifyContext",async t=>{const{attestationId:e,hash:s,encryptedId:i,metadata:r,transportType:n}=t,a={verified:{verifyUrl:r.verifyUrl||be$2,validation:"UNKNOWN",origin:r.url||""}};try{if(n===ee$2.link_mode){const p=this.getAppLinkIfEnabled(r,n);return a.verified.validation=p&&new URL(p).origin===new URL(r.url).origin?"VALID":"INVALID",a}const l=await this.client.core.verify.resolve({attestationId:e,hash:s,encryptedId:i,verifyUrl:r.verifyUrl});l&&(a.verified.origin=l.origin,a.verified.isScam=l.isScam,a.verified.validation=l.origin===new URL(r.url).origin?"VALID":"INVALID");}catch(l){this.client.logger.warn(l);}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),c$1(this,"validateSessionProps",(t,e)=>{Object.values(t).forEach((s,i)=>{if(s==null){const{message:r}=Bt$2("MISSING_OR_INVALID",`${e} must contain an existing value for each key. Received: ${s} for key ${Object.keys(t)[i]}`);throw new Error(r)}});}),c$1(this,"getPendingAuthRequest",t=>{const e=this.client.auth.requests.get(t);return typeof e=="object"?e:void 0}),c$1(this,"addToRecentlyDeleted",(t,e)=>{if(this.recentlyDeletedMap.set(t,e),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const i=this.recentlyDeletedLimit/2;for(const r of this.recentlyDeletedMap.keys()){if(s++>=i)break;this.recentlyDeletedMap.delete(r);}}}),c$1(this,"checkRecentlyDeleted",t=>{const e=this.recentlyDeletedMap.get(t);if(e){const{message:s}=Bt$2("MISSING_OR_INVALID",`Record was recently deleted - ${e}: ${t}`);throw new Error(s)}}),c$1(this,"isLinkModeEnabled",(t,e)=>{var s,i,r,n,a,l,p,h,u;return !t||e!==ee$2.link_mode?false:((i=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:i.linkMode)===true&&((n=(r=this.client.metadata)==null?void 0:r.redirect)==null?void 0:n.universal)!==void 0&&((l=(a=this.client.metadata)==null?void 0:a.redirect)==null?void 0:l.universal)!==""&&((p=t?.redirect)==null?void 0:p.universal)!==void 0&&((h=t?.redirect)==null?void 0:h.universal)!==""&&((u=t?.redirect)==null?void 0:u.linkMode)===true&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),c$1(this,"getAppLinkIfEnabled",(t,e)=>{var s;return this.isLinkModeEnabled(t,e)?(s=t?.redirect)==null?void 0:s.universal:void 0}),c$1(this,"handleLinkModeMessage",({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const e=Ti$1(t,"topic")||"",s=decodeURIComponent(Ti$1(t,"wc_ev")||""),i=this.client.session.keys.includes(e);i&&this.client.session.update(e,{transportType:ee$2.link_mode}),this.client.core.dispatchEnvelope({topic:e,message:s,sessionExists:i});}),c$1(this,"registerLinkModeListeners",async()=>{var t;if(ji$1()||At$2()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const e=global==null?void 0:global.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const s=await e.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s});},50);}}}),c$1(this,"getTVFParams",(t,e,s)=>{var i,r,n;if(!((i=e.request)!=null&&i.method))return {};const a={correlationId:t,rpcMethods:[e.request.method],chainId:e.chainId};try{const l=this.extractTxHashesFromResult(e.request,s);a.txHashes=l,a.contractAddresses=this.isValidContractData(e.request.params)?[(n=(r=e.request.params)==null?void 0:r[0])==null?void 0:n.to]:[];}catch(l){this.client.logger.warn(l,"Error getting TVF params");}return a}),c$1(this,"isValidContractData",t=>{var e;if(!t)return false;try{const s=t?.data||((e=t?.[0])==null?void 0:e.data);if(!s.startsWith("0x"))return !1;const i=s.slice(2);return /^[0-9a-fA-F]*$/.test(i)?i.length%2===0:!1}catch{}return false}),c$1(this,"extractTxHashesFromResult",(t,e)=>{var s;try{if(!e)return [];const i=t.method,r=yt$1[i];if(i==="sui_signTransaction")return [Oc(e.transactionBytes)];if(i==="near_signTransaction")return [Nc(e)];if(i==="near_signTransactions")return e.map(a=>Nc(a));if(i==="xrpl_signTransactionFor"||i==="xrpl_signTransaction")return [(s=e.tx_json)==null?void 0:s.hash];if(i==="polkadot_signTransaction")return [mu({transaction:t.params.transactionPayload,signature:e.signature})];if(i==="algo_signTxn")return Ee$2(e)?e.map(a=>Uc(a)):[Uc(e)];if(i==="cosmos_signDirect")return [_c(e)];if(i==="wallet_sendCalls")return Rc(e);if(typeof e=="string")return [e];const n=e[r.key];if(Ee$2(n))return i==="solana_signAllTransactions"?n.map(a=>Sc(a)):n;if(typeof n=="string")return [n]}catch(i){this.client.logger.warn(i,"Error extracting tx hashes from result");}return []});}async processPendingMessageEvents(){try{const o=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(o);for(const[e,s]of Object.entries(t))for(const i of s)try{await this.onProviderMessageEvent({topic:e,message:i,publishedAt:Date.now()});}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${i}`);}}catch(o){this.client.logger.warn(o,"processPendingMessageEvents failed");}}isInitialized(){if(!this.initialized){const{message:o}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(o)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow();}registerRelayerEvents(){this.client.core.relayer.on(C$1.message,o=>{this.onProviderMessageEvent(o);});}async onRelayMessage(o){const{topic:t,message:e,attestation:s,transportType:i}=o,{publicKey:r}=this.client.auth.authKeys.keys.includes(pe$2)?this.client.auth.authKeys.get(pe$2):{publicKey:void 0};try{const n=await this.client.core.crypto.decode(t,e,{receiverPublicKey:r,encoding:i===ee$2.link_mode?Ge$2:oe$3});isJsonRpcRequest(n)?(this.client.core.history.set(t,n),await this.onRelayEventRequest({topic:t,payload:n,attestation:s,transportType:i,encryptedId:pa(e)})):isJsonRpcResponse(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n,transportType:i}),this.client.core.history.delete(t,n.id)):await this.onRelayEventUnknownPayload({topic:t,payload:n,transportType:i}),await this.client.core.relayer.messages.ack(t,e);}catch(n){this.client.logger.error(n);}}registerExpirerEvents(){this.client.core.expirer.on(q$1.expired,async o=>{const{topic:t,id:e}=Oi$1(o.target);if(e&&this.client.pendingRequest.keys.includes(e))return await this.deletePendingSessionRequest(e,Bt$2("EXPIRED"),true);if(e&&this.client.auth.requests.keys.includes(e))return await this.deletePendingAuthRequest(e,Bt$2("EXPIRED"),true);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:true}),this.client.events.emit("session_expire",{topic:t})):e&&(await this.deleteProposal(e,true),this.client.events.emit("proposal_expire",{id:e}));});}registerPairingEvents(){this.client.core.pairing.events.on(ae$2.create,o=>this.onPairingCreated(o)),this.client.core.pairing.events.on(ae$2.delete,o=>{this.addToRecentlyDeleted(o.topic,"pairing");});}isValidPairingTopic(o){if(!ft$2(o,false)){const{message:t}=Bt$2("MISSING_OR_INVALID",`pairing topic should be a string: ${o}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(o)){const{message:t}=Bt$2("NO_MATCHING_KEY",`pairing topic doesn't exist: ${o}`);throw new Error(t)}if(Ui$1(this.client.core.pairing.pairings.get(o).expiry)){const{message:t}=Bt$2("EXPIRED",`pairing topic: ${o}`);throw new Error(t)}}async isValidSessionTopic(o){if(!ft$2(o,false)){const{message:t}=Bt$2("MISSING_OR_INVALID",`session topic should be a string: ${o}`);throw new Error(t)}if(this.checkRecentlyDeleted(o),!this.client.session.keys.includes(o)){const{message:t}=Bt$2("NO_MATCHING_KEY",`session topic doesn't exist: ${o}`);throw new Error(t)}if(Ui$1(this.client.session.get(o).expiry)){await this.deleteSession({topic:o});const{message:t}=Bt$2("EXPIRED",`session topic: ${o}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(o)){const{message:t}=Bt$2("MISSING_OR_INVALID",`session topic does not exist in keychain: ${o}`);throw await this.deleteSession({topic:o}),new Error(t)}}async isValidSessionOrPairingTopic(o){if(this.checkRecentlyDeleted(o),this.client.session.keys.includes(o))await this.isValidSessionTopic(o);else if(this.client.core.pairing.pairings.keys.includes(o))this.isValidPairingTopic(o);else if(ft$2(o,false)){const{message:t}=Bt$2("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${o}`);throw new Error(t)}else {const{message:t}=Bt$2("MISSING_OR_INVALID",`session or pairing topic should be a string: ${o}`);throw new Error(t)}}async isValidProposalId(o){if(!Ja(o)){const{message:t}=Bt$2("MISSING_OR_INVALID",`proposal id should be a number: ${o}`);throw new Error(t)}if(!this.client.proposal.keys.includes(o)){const{message:t}=Bt$2("NO_MATCHING_KEY",`proposal id doesn't exist: ${o}`);throw new Error(t)}if(Ui$1(this.client.proposal.get(o).expiryTimestamp)){await this.deleteProposal(o);const{message:t}=Bt$2("EXPIRED",`proposal id: ${o}`);throw new Error(t)}}}class Vs extends ji{constructor(o,t){super(o,t,dt$1,we$2),this.core=o,this.logger=t;}}let It$1 = class It extends ji{constructor(o,t){super(o,t,ut$1,we$2),this.core=o,this.logger=t;}};class ks extends ji{constructor(o,t){super(o,t,wt$1,we$2,e=>e.id),this.core=o,this.logger=t;}}class Ds extends ji{constructor(o,t){super(o,t,Et$1,le$2,()=>pe$2),this.core=o,this.logger=t;}}class Ls extends ji{constructor(o,t){super(o,t,St$1,le$2),this.core=o,this.logger=t;}}class Ms extends ji{constructor(o,t){super(o,t,Rt$1,le$2,e=>e.id),this.core=o,this.logger=t;}}var $s=Object.defineProperty,Ks=(E,o,t)=>o in E?$s(E,o,{enumerable:true,configurable:true,writable:true,value:t}):E[o]=t,Ke$1=(E,o,t)=>Ks(E,typeof o!="symbol"?o+"":o,t);class Us{constructor(o,t){this.core=o,this.logger=t,Ke$1(this,"authKeys"),Ke$1(this,"pairingTopics"),Ke$1(this,"requests"),this.authKeys=new Ds(this.core,this.logger),this.pairingTopics=new Ls(this.core,this.logger),this.requests=new Ms(this.core,this.logger);}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init();}}var Gs=Object.defineProperty,js=(E,o,t)=>o in E?Gs(E,o,{enumerable:true,configurable:true,writable:true,value:t}):E[o]=t,f$1=(E,o,t)=>js(E,typeof o!="symbol"?o+"":o,t);let fe$2 = class fe extends J$5{constructor(o){super(o),f$1(this,"protocol",Ve$1),f$1(this,"version",ke$2),f$1(this,"name",me$2.name),f$1(this,"metadata"),f$1(this,"core"),f$1(this,"logger"),f$1(this,"events",new eventsExports.EventEmitter),f$1(this,"engine"),f$1(this,"session"),f$1(this,"proposal"),f$1(this,"pendingRequest"),f$1(this,"auth"),f$1(this,"signConfig"),f$1(this,"on",(e,s)=>this.events.on(e,s)),f$1(this,"once",(e,s)=>this.events.once(e,s)),f$1(this,"off",(e,s)=>this.events.off(e,s)),f$1(this,"removeListener",(e,s)=>this.events.removeListener(e,s)),f$1(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),f$1(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"update",async e=>{try{return await this.engine.update(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"request",async e=>{try{return await this.engine.request(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"find",e=>{try{return this.engine.find(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),f$1(this,"authenticate",async(e,s)=>{try{return await this.engine.authenticate(e,s)}catch(i){throw this.logger.error(i.message),i}}),f$1(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(s){throw this.logger.error(s.message),s}}),this.name=o?.name||me$2.name,this.metadata=di$1(o?.metadata),this.signConfig=o?.signConfig;const t=wu({logger:o?.logger||me$2.logger,name:this.name});this.logger=t,this.core=o?.core||new ta(o),this.session=new It$1(this.core,this.logger),this.proposal=new Vs(this.core,this.logger),this.pendingRequest=new ks(this.core,this.logger),this.engine=new Cs(this),this.auth=new Us(this.core,this.logger);}static async init(o){const t=new fe(o);return await t.initialize(),t}get context(){return w$3(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success");}catch(o){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(o.message),o}}};const Qs=fe$2;
|
|
31278
|
+
const Ve$1="wc",ke$2=2,De="client",we$2=`${Ve$1}@${ke$2}:${De}:`,me$2={name:De,logger:"error"},Le$1="WALLETCONNECT_DEEPLINK_CHOICE",dt$1="proposal",Me$2="Proposal expired",ut$1="session",W$1=cjsExports$3.SEVEN_DAYS,gt$1="engine",P$1={wc_sessionPropose:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:true,tag:1100},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1101},reject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1120},autoReject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1121}},wc_sessionSettle:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1102},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1103}},wc_sessionUpdate:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1104},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1105}},wc_sessionExtend:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1106},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1107}},wc_sessionRequest:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:true,tag:1108},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1109}},wc_sessionEvent:{req:{ttl:cjsExports$3.FIVE_MINUTES,prompt:true,tag:1110},res:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1111}},wc_sessionDelete:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1112},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1113}},wc_sessionPing:{req:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1114},res:{ttl:cjsExports$3.ONE_DAY,prompt:false,tag:1115}},wc_sessionAuthenticate:{req:{ttl:cjsExports$3.ONE_HOUR,prompt:true,tag:1116},res:{ttl:cjsExports$3.ONE_HOUR,prompt:false,tag:1117},reject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1118},autoReject:{ttl:cjsExports$3.FIVE_MINUTES,prompt:false,tag:1119}}},_e$1={min:cjsExports$3.FIVE_MINUTES,max:cjsExports$3.SEVEN_DAYS},$$2={idle:"IDLE",active:"ACTIVE"},yt$1={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""},cosmos_signDirect:{key:""}},wt$1="request",mt$1=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_t$1="wc",ft$1="auth",Et$1="authKeys",St$1="pairingTopics",Rt$1="requests",le$2=`${_t$1}@${1.5}:${ft$1}:`,pe$2=`${le$2}:PUB_KEY`;var Ns=Object.defineProperty,Os=Object.defineProperties,bs=Object.getOwnPropertyDescriptors,vt$1=Object.getOwnPropertySymbols,As=Object.prototype.hasOwnProperty,xs=Object.prototype.propertyIsEnumerable,$e$1=(E,o,t)=>o in E?Ns(E,o,{enumerable:true,configurable:true,writable:true,value:t}):E[o]=t,R=(E,o)=>{for(var t in o||(o={}))As.call(o,t)&&$e$1(E,t,o[t]);if(vt$1)for(var t of vt$1(o))xs.call(o,t)&&$e$1(E,t,o[t]);return E},O$1=(E,o)=>Os(E,bs(o)),c$1=(E,o,t)=>$e$1(E,typeof o!="symbol"?o+"":o,t);class Cs extends V$3{constructor(o){super(o),c$1(this,"name",gt$1),c$1(this,"events",new xe$3),c$1(this,"initialized",false),c$1(this,"requestQueue",{state:$$2.idle,queue:[]}),c$1(this,"sessionRequestQueue",{state:$$2.idle,queue:[]}),c$1(this,"emittedSessionRequests",new ki$1({limit:500})),c$1(this,"requestQueueDelay",cjsExports$3.ONE_SECOND),c$1(this,"expectedPairingMethodMap",new Map),c$1(this,"recentlyDeletedMap",new Map),c$1(this,"recentlyDeletedLimit",200),c$1(this,"relayMessageCache",[]),c$1(this,"pendingSessions",new Map),c$1(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(P$1)}),this.initialized=true,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue();},cjsExports$3.toMiliseconds(this.requestQueueDelay)));}),c$1(this,"connect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const e=O$1(R({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(e),e.optionalNamespaces=qa(e.requiredNamespaces,e.optionalNamespaces),e.requiredNamespaces={};const{pairingTopic:s,requiredNamespaces:i,optionalNamespaces:r,sessionProperties:n,scopedProperties:a,relays:l}=e;let p=s,h,u=false;try{if(p){const T=this.client.core.pairing.pairings.get(p);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),u=T.active;}}catch(T){throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`),T}if(!p||!u){const{topic:T,uri:K}=await this.client.core.pairing.create({internal:{skipSubscribe:true}});p=T,h=K;}if(!p){const{message:T}=Bt$2("NO_MATCHING_KEY",`connect() pairing topic: ${p}`);throw new Error(T)}const d=await this.client.core.crypto.generateKeyPair(),y=P$1.wc_sessionPropose.req.ttl||cjsExports$3.FIVE_MINUTES,w=Ni$1(y),m=O$1(R(R({requiredNamespaces:i,optionalNamespaces:r,relays:l??[{protocol:Nt$1}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:w,pairingTopic:p},n&&{sessionProperties:n}),a&&{scopedProperties:a}),{id:payloadId()}),S=_i$1("session_connect",m.id),{reject:_,resolve:b,done:V}=Bi$1(y,Me$2),I=({id:T})=>{T===m.id&&(this.client.events.off("proposal_expire",I),this.pendingSessions.delete(m.id),this.events.emit(S,{error:{message:Me$2,code:0}}));};return this.client.events.on("proposal_expire",I),this.events.once(S,({error:T,session:K})=>{this.client.events.off("proposal_expire",I),T?_(T):K&&b(K);}),await this.sendProposeSession({proposal:m,publishOpts:{internal:{throwOnFailedPublish:true},tvf:{correlationId:m.id}}}),await this.setProposal(m.id,m),{uri:h,approval:V}}),c$1(this,"pair",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(e){throw this.client.logger.error("pair() failed"),e}}),c$1(this,"approve",async t=>{var e,s,i;const r=this.client.core.eventClient.createEvent({properties:{topic:(e=t?.id)==null?void 0:e.toString(),trace:[rr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow();}catch(N){throw r.setError(nr.no_internet_connection),N}try{await this.isValidProposalId(t?.id);}catch(N){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),r.setError(nr.proposal_not_found),N}try{await this.isValidApprove(t);}catch(N){throw this.client.logger.error("approve() -> isValidApprove() failed"),r.setError(nr.session_approve_namespace_validation_failure),N}const{id:n,relayProtocol:a,namespaces:l,sessionProperties:p,scopedProperties:h,sessionConfig:u}=t,d=this.client.proposal.get(n);this.client.core.eventClient.deleteEvent({eventId:r.eventId});const{pairingTopic:y,proposer:w,requiredNamespaces:m,optionalNamespaces:S}=d;let _=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:y});_||(_=(i=this.client.core.eventClient)==null?void 0:i.createEvent({type:rr.session_approve_started,properties:{topic:y,trace:[rr.session_approve_started,rr.session_namespaces_validation_success]}}));const b=await this.client.core.crypto.generateKeyPair(),V=w.publicKey,I=await this.client.core.crypto.generateSharedKey(b,V),T=R(R(R({relay:{protocol:a??"irn"},namespaces:l,controller:{publicKey:b,metadata:this.client.metadata},expiry:Ni$1(W$1)},p&&{sessionProperties:p}),h&&{scopedProperties:h}),u&&{sessionConfig:u}),K=ee$2.relay;_.addTrace(rr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:K,internal:{skipSubscribe:!0}});}catch(N){throw _.setError(nr.subscribe_session_topic_failure),N}_.addTrace(rr.subscribe_session_topic_success);const Ee=O$1(R({},T),{topic:I,requiredNamespaces:m,optionalNamespaces:S,pairingTopic:y,acknowledged:false,self:T.controller,peer:{publicKey:w.publicKey,metadata:w.metadata},controller:b,transportType:ee$2.relay});await this.client.session.set(I,Ee),_.addTrace(rr.store_session);try{await this.sendApproveSession({sessionTopic:I,proposal:d,pairingProposalResponse:{relay:{protocol:a??"irn"},responderPublicKey:b},sessionSettleRequest:T,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:n}}}),_.addTrace(rr.session_approve_publish_success);}catch(N){throw this.client.logger.error(N),this.client.session.delete(I,zt$2("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(I),N}return this.client.core.eventClient.deleteEvent({eventId:_.eventId}),await this.client.core.pairing.updateMetadata({topic:y,metadata:w.metadata}),await this.deleteProposal(n),await this.client.core.pairing.activate({topic:y}),await this.setExpiry(I,Ni$1(W$1)),{topic:I,acknowledged:()=>Promise.resolve(this.client.session.get(I))}}),c$1(this,"reject",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t);}catch(r){throw this.client.logger.error("reject() -> isValidReject() failed"),r}const{id:e,reason:s}=t;let i;try{i=this.client.proposal.get(e).pairingTopic;}catch(r){throw this.client.logger.error(`reject() -> proposal.get(${e}) failed`),r}i&&await this.sendError({id:e,topic:i,error:s,rpcOpts:P$1.wc_sessionPropose.reject}),await this.deleteProposal(e);}),c$1(this,"update",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t);}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:e,namespaces:s}=t,{done:i,resolve:r,reject:n}=Bi$1(),a=payloadId(),l=getBigIntRpcId().toString(),p=this.client.session.get(e).namespaces;return this.events.once(_i$1("session_update",a),({error:h})=>{h?n(h):r();}),await this.client.session.update(e,{namespaces:s}),await this.sendRequest({topic:e,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:true,clientRpcId:a,relayRpcId:l}).catch(h=>{this.client.logger.error(h),this.client.session.update(e,{namespaces:p}),n(h);}),{acknowledged:i}}),c$1(this,"extend",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t);}catch(a){throw this.client.logger.error("extend() -> isValidExtend() failed"),a}const{topic:e}=t,s=payloadId(),{done:i,resolve:r,reject:n}=Bi$1();return this.events.once(_i$1("session_extend",s),({error:a})=>{a?n(a):r();}),await this.setExpiry(e,Ni$1(W$1)),this.sendRequest({topic:e,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:true}).catch(a=>{n(a);}),{acknowledged:i}}),c$1(this,"request",async t=>{this.isInitialized();try{await this.isValidRequest(t);}catch(m){throw this.client.logger.error("request() -> isValidRequest() failed"),m}const{chainId:e,request:s,topic:i,expiry:r=P$1.wc_sessionRequest.req.ttl}=t,n=this.client.session.get(i);n?.transportType===ee$2.relay&&await this.confirmOnlineStateOrThrow();const a=payloadId(),l=getBigIntRpcId().toString(),{done:p,resolve:h,reject:u}=Bi$1(r,"Request expired. Please try again.");this.events.once(_i$1("session_request",a),({error:m,result:S})=>{m?u(m):h(S);});const d="wc_sessionRequest",y=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);if(y)return await this.sendRequest({clientRpcId:a,relayRpcId:l,topic:i,method:d,params:{request:O$1(R({},s),{expiryTimestamp:Ni$1(r)}),chainId:e},expiry:r,throwOnFailedPublish:true,appLink:y}).catch(m=>u(m)),this.client.events.emit("session_request_sent",{topic:i,request:s,chainId:e,id:a}),await p();const w={request:O$1(R({},s),{expiryTimestamp:Ni$1(r)}),chainId:e};return await Promise.all([new Promise(async m=>{await this.sendRequest({clientRpcId:a,relayRpcId:l,topic:i,method:d,params:w,expiry:r,throwOnFailedPublish:true,tvf:this.getTVFParams(a,w)}).catch(S=>u(S)),this.client.events.emit("session_request_sent",{topic:i,request:s,chainId:e,id:a}),m();}),new Promise(async m=>{var S;if(!((S=n.sessionConfig)!=null&&S.disableDeepLink)){const _=await $i$1(this.client.core.storage,Le$1);await Ri$1({id:a,topic:i,wcDeepLink:_});}m();}),p()]).then(m=>m[2])}),c$1(this,"respond",async t=>{var e,s;this.isInitialized();const i=this.client.core.eventClient.createEvent({properties:{topic:t?.topic||((s=(e=t?.response)==null?void 0:e.id)==null?void 0:s.toString()),trace:[rr.session_request_response_started]}});try{await this.isValidRespond(t);}catch(h){throw i.addTrace(h?.message),i.setError(nr.session_request_response_validation_failure),h}i.addTrace(rr.session_request_response_validation_success);const{topic:r,response:n}=t,{id:a}=n,l=this.client.session.get(r);l.transportType===ee$2.relay&&await this.confirmOnlineStateOrThrow();const p=this.getAppLinkIfEnabled(l.peer.metadata,l.transportType);try{i.addTrace(rr.session_request_response_publish_started),isJsonRpcResult(n)?await this.sendResult({id:a,topic:r,result:n.result,throwOnFailedPublish:!0,appLink:p}):isJsonRpcError(n)&&await this.sendError({id:a,topic:r,error:n.error,appLink:p}),this.cleanupAfterResponse(t);}catch(h){throw i.addTrace(h?.message),i.setError(nr.session_request_response_publish_failure),h}}),c$1(this,"ping",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t);}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:e}=t;if(this.client.session.keys.includes(e)){const s=payloadId(),i=getBigIntRpcId().toString(),{done:r,resolve:n,reject:a}=Bi$1();this.events.once(_i$1("session_ping",s),({error:l})=>{l?a(l):n();}),await Promise.all([this.sendRequest({topic:e,method:"wc_sessionPing",params:{},throwOnFailedPublish:true,clientRpcId:s,relayRpcId:i}),r()]);}else this.client.core.pairing.pairings.keys.includes(e)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:e}));}),c$1(this,"emit",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:e,event:s,chainId:i}=t,r=getBigIntRpcId().toString(),n=payloadId();await this.sendRequest({topic:e,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:true,relayRpcId:r,clientRpcId:n});}),c$1(this,"disconnect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:e}=t;if(this.client.session.keys.includes(e))await this.sendRequest({topic:e,method:"wc_sessionDelete",params:zt$2("USER_DISCONNECTED"),throwOnFailedPublish:true}),await this.deleteSession({topic:e,emitEvent:false});else if(this.client.core.pairing.pairings.keys.includes(e))await this.client.core.pairing.disconnect({topic:e});else {const{message:s}=Bt$2("MISMATCHED_TOPIC",`Session or pairing topic not found: ${e}`);throw new Error(s)}}),c$1(this,"find",t=>(this.isInitialized(),this.client.session.getAll().filter(e=>Fa(e,t)))),c$1(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),c$1(this,"authenticate",async(t,e)=>{var s;this.isInitialized(),this.isValidAuthenticate(t);const i=e&&this.client.core.linkModeSupportedApps.includes(e)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),r=i?ee$2.link_mode:ee$2.relay;r===ee$2.relay&&await this.confirmOnlineStateOrThrow();const{chains:n,statement:a="",uri:l,domain:p,nonce:h,type:u,exp:d,nbf:y,methods:w=[],expiry:m}=t,S=[...t.resources||[]],{topic:_,uri:b}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:r});this.client.logger.info({message:"Generated new pairing",pairing:{topic:_,uri:b}});const V=await this.client.core.crypto.generateKeyPair(),I=ha(V);if(await Promise.all([this.client.auth.authKeys.set(pe$2,{responseTopic:I,publicKey:V}),this.client.auth.pairingTopics.set(I,{topic:I,pairingTopic:_})]),await this.client.core.relayer.subscribe(I,{transportType:r}),this.client.logger.info(`sending request to new pairing topic: ${_}`),w.length>0){const{namespace:A}=Je$2(n[0]);let k=Kc(A,"request",w);je$1(S)&&(k=qc(k,S.pop())),S.push(k);}const T=m&&m>P$1.wc_sessionAuthenticate.req.ttl?m:P$1.wc_sessionAuthenticate.req.ttl,K={authPayload:{type:u??"caip122",chains:n,statement:a,aud:l,domain:p,version:"1",nonce:h,iat:new Date().toISOString(),exp:d,nbf:y,resources:S},requester:{publicKey:V,metadata:this.client.metadata},expiryTimestamp:Ni$1(T)},Ee={eip155:{chains:n,methods:[...new Set(["personal_sign",...w])],events:["chainChanged","accountsChanged"]}},N={requiredNamespaces:{},optionalNamespaces:Ee,relays:[{protocol:"irn"}],pairingTopic:_,proposer:{publicKey:V,metadata:this.client.metadata},expiryTimestamp:Ni$1(P$1.wc_sessionPropose.req.ttl),id:payloadId()},{done:Tt,resolve:Ue,reject:Se}=Bi$1(T,"Request expired"),ie=payloadId(),he=_i$1("session_connect",N.id),Re=_i$1("session_request",ie),de=async({error:A,session:k})=>{this.events.off(Re,ve),A?Se(A):k&&Ue({session:k});},ve=async A=>{var k,Ge,je;if(await this.deletePendingAuthRequest(ie,{message:"fulfilled",code:0}),A.error){const ne=zt$2("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return A.error.code===ne.code?void 0:(this.events.off(he,de),Se(A.error.message))}await this.deleteProposal(N.id),this.events.off(he,de);const{cacaos:Fe,responder:H}=A.result,Te=[],Qe=[];for(const ne of Fe){await Pc({cacao:ne,projectId:this.client.core.projectId})||(this.client.logger.error(ne,"Signature verification failed"),Se(zt$2("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:qe}=ne,Pe=je$1(qe.resources),He=[to$1(qe.iss)],qt=bn$1(qe.iss);if(Pe){const Ne=Fc(Pe),Pt=Zc(Pe);Te.push(...Ne),He.push(...Pt);}for(const Ne of He)Qe.push(`${Ne}:${qt}`);}const re=await this.client.core.crypto.generateSharedKey(V,H.publicKey);let ue;Te.length>0&&(ue={topic:re,acknowledged:true,self:{publicKey:V,metadata:this.client.metadata},peer:H,controller:H.publicKey,expiry:Ni$1(W$1),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:_,namespaces:Ka([...new Set(Te)],[...new Set(Qe)]),transportType:r},await this.client.core.relayer.subscribe(re,{transportType:r}),await this.client.session.set(re,ue),_&&await this.client.core.pairing.updateMetadata({topic:_,metadata:H.metadata}),ue=this.client.session.get(re)),(k=this.client.metadata.redirect)!=null&&k.linkMode&&(Ge=H.metadata.redirect)!=null&&Ge.linkMode&&(je=H.metadata.redirect)!=null&&je.universal&&e&&(this.client.core.addLinkModeSupportedApp(H.metadata.redirect.universal),this.client.session.update(re,{transportType:ee$2.link_mode})),Ue({auths:Fe,session:ue});};this.events.once(he,de),this.events.once(Re,ve);let Ie;try{if(i){const A=formatJsonRpcRequest("wc_sessionAuthenticate",K,ie);this.client.core.history.set(_,A);const k=await this.client.core.crypto.encode("",A,{type:we$3,encoding:Ge$2});Ie=Ta(e,_,k);}else await Promise.all([this.sendRequest({topic:_,method:"wc_sessionAuthenticate",params:K,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:ie}),this.sendRequest({topic:_,method:"wc_sessionPropose",params:N,expiry:P$1.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:N.id})]);}catch(A){throw this.events.off(he,de),this.events.off(Re,ve),A}return await this.setProposal(N.id,N),await this.setAuthRequest(ie,{request:O$1(R({},K),{verifyContext:{}}),pairingTopic:_,transportType:r}),{uri:Ie??b,response:Tt}}),c$1(this,"approveSessionAuthenticate",async t=>{const{id:e,auths:s}=t,i=this.client.core.eventClient.createEvent({properties:{topic:e.toString(),trace:[or.authenticated_session_approve_started]}});try{this.isInitialized();}catch(m){throw i.setError(ar.no_internet_connection),m}const r=this.getPendingAuthRequest(e);if(!r)throw i.setError(ar.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${e}`);const n=r.transportType||ee$2.relay;n===ee$2.relay&&await this.confirmOnlineStateOrThrow();const a=r.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),p=ha(a),h={type:ie$2,receiverPublicKey:a,senderPublicKey:l},u=[],d=[];for(const m of s){if(!await Pc({cacao:m,projectId:this.client.core.projectId})){i.setError(ar.invalid_cacao);const I=zt$2("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:e,topic:p,error:I,encodeOpts:h}),new Error(I.message)}i.addTrace(or.cacaos_verified);const{p:S}=m,_=je$1(S.resources),b=[to$1(S.iss)],V=bn$1(S.iss);if(_){const I=Fc(_),T=Zc(_);u.push(...I),b.push(...T);}for(const I of b)d.push(`${I}:${V}`);}const y=await this.client.core.crypto.generateSharedKey(l,a);i.addTrace(or.create_authenticated_session_topic);let w;if(u?.length>0){w={topic:y,acknowledged:true,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:a,metadata:r.requester.metadata},controller:a,expiry:Ni$1(W$1),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:r.pairingTopic,namespaces:Ka([...new Set(u)],[...new Set(d)]),transportType:n},i.addTrace(or.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(y,{transportType:n});}catch(m){throw i.setError(ar.subscribe_authenticated_session_topic_failure),m}i.addTrace(or.subscribe_authenticated_session_topic_success),await this.client.session.set(y,w),i.addTrace(or.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:r.pairingTopic,metadata:r.requester.metadata});}i.addTrace(or.publishing_authenticated_session_approve);try{await this.sendResult({topic:p,id:e,result:{cacaos:s,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(r.requester.metadata,n)});}catch(m){throw i.setError(ar.authenticated_session_approve_publish_failure),m}return await this.client.auth.requests.delete(e,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:r.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:i.eventId}),{session:w}}),c$1(this,"rejectSessionAuthenticate",async t=>{this.isInitialized();const{id:e,reason:s}=t,i=this.getPendingAuthRequest(e);if(!i)throw new Error(`Could not find pending auth request with id ${e}`);i.transportType===ee$2.relay&&await this.confirmOnlineStateOrThrow();const r=i.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),a=ha(r),l={type:ie$2,receiverPublicKey:r,senderPublicKey:n};await this.sendError({id:e,topic:a,error:s,encodeOpts:l,rpcOpts:P$1.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(e,{message:"rejected",code:0}),await this.deleteProposal(e);}),c$1(this,"formatAuthMessage",t=>{this.isInitialized();const{request:e,iss:s}=t;return eo$1(e,s)}),c$1(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t);}catch(t){this.client.logger.error(t);}},50);}),c$1(this,"cleanupDuplicatePairings",async t=>{if(t.pairingTopic)try{const e=this.client.core.pairing.pairings.get(t.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(i=>{var r,n;return ((r=i.peerMetadata)==null?void 0:r.url)&&((n=i.peerMetadata)==null?void 0:n.url)===t.peer.metadata.url&&i.topic&&i.topic!==e.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished");}catch(e){this.client.logger.error(e);}}),c$1(this,"deleteSession",async t=>{var e;const{topic:s,expirerHasDeleted:i=false,emitEvent:r=true,id:n=0}=t,{self:a}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,zt$2("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(Le$1).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===s&&this.deletePendingSessionRequest(l.id,zt$2("USER_DISCONNECTED"));}),s===((e=this.sessionRequestQueue.queue[0])==null?void 0:e.topic)&&(this.sessionRequestQueue.state=$$2.idle),r&&this.client.events.emit("session_delete",{id:n,topic:s});}),c$1(this,"deleteProposal",async(t,e)=>{if(e)try{const s=this.client.proposal.get(t),i=this.client.core.eventClient.getEvent({topic:s.pairingTopic});i?.setError(nr.proposal_expired);}catch{}await Promise.all([this.client.proposal.delete(t,zt$2("USER_DISCONNECTED")),e?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal");}),c$1(this,"deletePendingSessionRequest",async(t,e,s=false)=>{await Promise.all([this.client.pendingRequest.delete(t,e),s?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==t),s&&(this.sessionRequestQueue.state=$$2.idle,this.client.events.emit("session_request_expire",{id:t}));}),c$1(this,"deletePendingAuthRequest",async(t,e,s=false)=>{await Promise.all([this.client.auth.requests.delete(t,e),s?Promise.resolve():this.client.core.expirer.del(t)]);}),c$1(this,"setExpiry",async(t,e)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,e),await this.client.session.update(t,{expiry:e}));}),c$1(this,"setProposal",async(t,e)=>{this.client.core.expirer.set(t,Ni$1(P$1.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,e);}),c$1(this,"setAuthRequest",async(t,e)=>{const{request:s,pairingTopic:i,transportType:r=ee$2.relay}=e;this.client.core.expirer.set(t,s.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:t,pairingTopic:i,verifyContext:s.verifyContext,transportType:r});}),c$1(this,"setPendingSessionRequest",async t=>{const{id:e,topic:s,params:i,verifyContext:r}=t,n=i.request.expiryTimestamp||Ni$1(P$1.wc_sessionRequest.req.ttl);this.client.core.expirer.set(e,n),await this.client.pendingRequest.set(e,{id:e,topic:s,params:i,verifyContext:r});}),c$1(this,"sendRequest",async t=>{const{topic:e,method:s,params:i,expiry:r,relayRpcId:n,clientRpcId:a,throwOnFailedPublish:l,appLink:p,tvf:h,publishOpts:u={}}=t,d=formatJsonRpcRequest(s,i,a);let y;const w=!!p;try{const _=w?Ge$2:oe$3;y=await this.client.core.crypto.encode(e,d,{encoding:_});}catch(_){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e} failed`),_}let m;if(mt$1.includes(s)){const _=pa(JSON.stringify(d)),b=pa(y);m=await this.client.core.verify.register({id:b,decryptedId:_});}const S=R(R({},P$1[s].req),u);if(S.attestation=m,r&&(S.ttl=r),n&&(S.id=n),this.client.core.history.set(e,d),w){const _=Ta(p,e,y);await global.Linking.openURL(_,this.client.name);}else S.tvf=O$1(R({},h),{correlationId:d.id}),l?(S.internal=O$1(R({},S.internal),{throwOnFailedPublish:true}),await this.client.core.relayer.publish(e,y,S)):this.client.core.relayer.publish(e,y,S).catch(_=>this.client.logger.error(_));return d.id}),c$1(this,"sendProposeSession",async t=>{const{proposal:e,publishOpts:s}=t,i=formatJsonRpcRequest("wc_sessionPropose",e,e.id);this.client.core.history.set(e.pairingTopic,i);const r=await this.client.core.crypto.encode(e.pairingTopic,i,{encoding:oe$3}),n=pa(JSON.stringify(i)),a=pa(r),l=await this.client.core.verify.register({id:a,decryptedId:n});await this.client.core.relayer.publishCustom({payload:{pairingTopic:e.pairingTopic,sessionProposal:r},opts:O$1(R({},s),{publishMethod:"wc_proposeSession",attestation:l})});}),c$1(this,"sendApproveSession",async t=>{const{sessionTopic:e,pairingProposalResponse:s,proposal:i,sessionSettleRequest:r,publishOpts:n}=t,a=formatJsonRpcResult(i.id,s),l=await this.client.core.crypto.encode(i.pairingTopic,a,{encoding:oe$3}),p=formatJsonRpcRequest("wc_sessionSettle",r,n?.id),h=await this.client.core.crypto.encode(e,p,{encoding:oe$3});this.client.core.history.set(e,p),await this.client.core.relayer.publishCustom({payload:{sessionTopic:e,pairingTopic:i.pairingTopic,sessionProposalResponse:l,sessionSettlementRequest:h},opts:O$1(R({},n),{publishMethod:"wc_approveSession"})});}),c$1(this,"sendResult",async t=>{const{id:e,topic:s,result:i,throwOnFailedPublish:r,encodeOpts:n,appLink:a}=t,l=formatJsonRpcResult(e,i);let p;const h=a&&typeof(global==null?void 0:global.Linking)<"u";try{const y=h?Ge$2:oe$3;p=await this.client.core.crypto.encode(s,l,O$1(R({},n||{}),{encoding:y}));}catch(y){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),y}let u,d;try{u=await this.client.core.history.get(s,e);const y=u.request;try{d=this.getTVFParams(e,y.params,i);}catch(w){this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${w?.message}`);}}catch(y){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${e}) failed`),y}if(h){const y=Ta(a,s,p);await global.Linking.openURL(y,this.client.name);}else {const y=u.request.method,w=P$1[y].res;w.tvf=O$1(R({},d),{correlationId:e}),r?(w.internal=O$1(R({},w.internal),{throwOnFailedPublish:true}),await this.client.core.relayer.publish(s,p,w)):this.client.core.relayer.publish(s,p,w).catch(m=>this.client.logger.error(m));}await this.client.core.history.resolve(l);}),c$1(this,"sendError",async t=>{const{id:e,topic:s,error:i,encodeOpts:r,rpcOpts:n,appLink:a}=t,l=formatJsonRpcError(e,i);let p;const h=a&&typeof(global==null?void 0:global.Linking)<"u";try{const d=h?Ge$2:oe$3;p=await this.client.core.crypto.encode(s,l,O$1(R({},r||{}),{encoding:d}));}catch(d){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),d}let u;try{u=await this.client.core.history.get(s,e);}catch(d){throw this.client.logger.error(`sendError() -> history.get(${s}, ${e}) failed`),d}if(h){const d=Ta(a,s,p);await global.Linking.openURL(d,this.client.name);}else {const d=u.request.method,y=n||P$1[d].res;this.client.core.relayer.publish(s,p,y);}await this.client.core.history.resolve(l);}),c$1(this,"cleanup",async()=>{const t=[],e=[];this.client.session.getAll().forEach(s=>{let i=false;Ui$1(s.expiry)&&(i=true),this.client.core.crypto.keychain.has(s.topic)||(i=true),i&&t.push(s.topic);}),this.client.proposal.getAll().forEach(s=>{Ui$1(s.expiryTimestamp)&&e.push(s.id);}),await Promise.all([...t.map(s=>this.deleteSession({topic:s})),...e.map(s=>this.deleteProposal(s))]);}),c$1(this,"onProviderMessageEvent",async t=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(t):await this.onRelayMessage(t);}),c$1(this,"onRelayEventRequest",async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue();}),c$1(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===$$2.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=$$2.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t);}catch(e){this.client.logger.warn(e);}}this.requestQueue.state=$$2.idle;}),c$1(this,"processRequest",async t=>{const{topic:e,payload:s,attestation:i,transportType:r,encryptedId:n}=t,a=s.method;if(!this.shouldIgnorePairingRequest({topic:e,requestMethod:a}))switch(a){case "wc_sessionPropose":return await this.onSessionProposeRequest({topic:e,payload:s,attestation:i,encryptedId:n});case "wc_sessionSettle":return await this.onSessionSettleRequest(e,s);case "wc_sessionUpdate":return await this.onSessionUpdateRequest(e,s);case "wc_sessionExtend":return await this.onSessionExtendRequest(e,s);case "wc_sessionPing":return await this.onSessionPingRequest(e,s);case "wc_sessionDelete":return await this.onSessionDeleteRequest(e,s);case "wc_sessionRequest":return await this.onSessionRequest({topic:e,payload:s,attestation:i,encryptedId:n,transportType:r});case "wc_sessionEvent":return await this.onSessionEventRequest(e,s);case "wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:e,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${a}`)}}),c$1(this,"onRelayEventResponse",async t=>{const{topic:e,payload:s,transportType:i}=t,r=(await this.client.core.history.get(e,s.id)).request.method;switch(r){case "wc_sessionPropose":return this.onSessionProposeResponse(e,s,i);case "wc_sessionSettle":return this.onSessionSettleResponse(e,s);case "wc_sessionUpdate":return this.onSessionUpdateResponse(e,s);case "wc_sessionExtend":return this.onSessionExtendResponse(e,s);case "wc_sessionPing":return this.onSessionPingResponse(e,s);case "wc_sessionRequest":return this.onSessionRequestResponse(e,s);case "wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(e,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),c$1(this,"onRelayEventUnknownPayload",t=>{const{topic:e}=t,{message:s}=Bt$2("MISSING_OR_INVALID",`Decoded payload on topic ${e} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),c$1(this,"shouldIgnorePairingRequest",t=>{const{topic:e,requestMethod:s}=t,i=this.expectedPairingMethodMap.get(e);return !i||i.includes(s)?false:!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),c$1(this,"onSessionProposeRequest",async t=>{const{topic:e,payload:s,attestation:i,encryptedId:r}=t,{params:n,id:a}=s;try{const l=this.client.core.eventClient.getEvent({topic:e});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l?.setError(X$1.proposal_listener_not_found)),this.isValidConnect(R({},s.params));const p=n.expiryTimestamp||Ni$1(P$1.wc_sessionPropose.req.ttl),h=R({id:a,pairingTopic:e,expiryTimestamp:p,attestation:i,encryptedId:r},n);await this.setProposal(a,h);const u=await this.getVerifyContext({attestationId:i,hash:pa(JSON.stringify(s)),encryptedId:r,metadata:h.proposer.metadata});l?.addTrace(Y$1.emit_session_proposal),this.client.events.emit("session_proposal",{id:a,params:h,verifyContext:u});}catch(l){await this.sendError({id:a,topic:e,error:l,rpcOpts:P$1.wc_sessionPropose.autoReject}),this.client.logger.error(l);}}),c$1(this,"onSessionProposeResponse",async(t,e,s)=>{const{id:i}=e;if(isJsonRpcResult(e)){const{result:r}=e;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const a=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:a});const l=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const p=await this.client.core.crypto.generateSharedKey(a,l);this.pendingSessions.set(i,{sessionTopic:p,pairingTopic:t,proposalId:i,publicKey:a});const h=await this.client.core.relayer.subscribe(p,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:t});}else if(isJsonRpcError(e)){await this.deleteProposal(i);const r=_i$1("session_connect",i);if(this.events.listenerCount(r)===0)throw new Error(`emitting ${r} without any listeners, 954`);this.events.emit(r,{error:e.error});}}),c$1(this,"onSessionSettleRequest",async(t,e)=>{const{id:s,params:i}=e;try{this.isValidSessionSettleRequest(i);const{relay:r,controller:n,expiry:a,namespaces:l,sessionProperties:p,scopedProperties:h,sessionConfig:u}=e.params,d=[...this.pendingSessions.values()].find(m=>m.sessionTopic===t);if(!d)return this.client.logger.error(`Pending session not found for topic ${t}`);const y=this.client.proposal.get(d.proposalId),w=O$1(R(R(R({topic:t,relay:r,expiry:a,namespaces:l,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:y.requiredNamespaces,optionalNamespaces:y.optionalNamespaces,controller:n.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},p&&{sessionProperties:p}),h&&{scopedProperties:h}),u&&{sessionConfig:u}),{transportType:ee$2.relay});await this.client.session.set(w.topic,w),await this.setExpiry(w.topic,w.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:w.peer.metadata}),this.client.events.emit("session_connect",{session:w}),this.events.emit(_i$1("session_connect",d.proposalId),{session:w}),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(w),await this.sendResult({id:e.id,topic:t,result:!0});}catch(r){await this.sendError({id:s,topic:t,error:r}),this.client.logger.error(r);}}),c$1(this,"onSessionSettleResponse",async(t,e)=>{const{id:s}=e;isJsonRpcResult(e)?(await this.client.session.update(t,{acknowledged:true}),this.events.emit(_i$1("session_approve",s),{})):isJsonRpcError(e)&&(await this.client.session.delete(t,zt$2("USER_DISCONNECTED")),this.events.emit(_i$1("session_approve",s),{error:e.error}));}),c$1(this,"onSessionUpdateRequest",async(t,e)=>{const{params:s,id:i}=e;try{const r=`${t}_session_update`,n=hu.get(r);if(n&&this.isRequestOutOfSync(n,i)){this.client.logger.warn(`Discarding out of sync request - ${i}`),this.sendError({id:i,topic:t,error:zt$2("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(R({topic:t},s));try{hu.set(r,i),await this.client.session.update(t,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:t,result:!0});}catch(a){throw hu.delete(r),a}this.client.events.emit("session_update",{id:i,topic:t,params:s});}catch(r){await this.sendError({id:i,topic:t,error:r}),this.client.logger.error(r);}}),c$1(this,"isRequestOutOfSync",(t,e)=>e.toString().slice(0,-3)<t.toString().slice(0,-3)),c$1(this,"onSessionUpdateResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_update",s);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);isJsonRpcResult(e)?this.events.emit(_i$1("session_update",s),{}):isJsonRpcError(e)&&this.events.emit(_i$1("session_update",s),{error:e.error});}),c$1(this,"onSessionExtendRequest",async(t,e)=>{const{id:s}=e;try{this.isValidExtend({topic:t}),await this.setExpiry(t,Ni$1(W$1)),await this.sendResult({id:s,topic:t,result:!0}),this.client.events.emit("session_extend",{id:s,topic:t});}catch(i){await this.sendError({id:s,topic:t,error:i}),this.client.logger.error(i);}}),c$1(this,"onSessionExtendResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_extend",s);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);isJsonRpcResult(e)?this.events.emit(_i$1("session_extend",s),{}):isJsonRpcError(e)&&this.events.emit(_i$1("session_extend",s),{error:e.error});}),c$1(this,"onSessionPingRequest",async(t,e)=>{const{id:s}=e;try{this.isValidPing({topic:t}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:t});}catch(i){await this.sendError({id:s,topic:t,error:i}),this.client.logger.error(i);}}),c$1(this,"onSessionPingResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_ping",s);setTimeout(()=>{if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners 2176`);isJsonRpcResult(e)?this.events.emit(_i$1("session_ping",s),{}):isJsonRpcError(e)&&this.events.emit(_i$1("session_ping",s),{error:e.error});},500);}),c$1(this,"onSessionDeleteRequest",async(t,e)=>{const{id:s}=e;try{this.isValidDisconnect({topic:t,reason:e.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(C$1.publish,async()=>{i(await this.deleteSession({topic:t,id:s}));});}),this.sendResult({id:s,topic:t,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:zt$2("USER_DISCONNECTED")})]).catch(i=>this.client.logger.error(i));}catch(i){this.client.logger.error(i);}}),c$1(this,"onSessionRequest",async t=>{var e,s,i;const{topic:r,payload:n,attestation:a,encryptedId:l,transportType:p}=t,{id:h,params:u}=n;try{await this.isValidRequest(R({topic:r},u));const d=this.client.session.get(r),y=await this.getVerifyContext({attestationId:a,hash:pa(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",u,h))),encryptedId:l,metadata:d.peer.metadata,transportType:p}),w={id:h,topic:r,params:u,verifyContext:y};await this.setPendingSessionRequest(w),p===ee$2.link_mode&&(e=d.peer.metadata.redirect)!=null&&e.universal&&this.client.core.addLinkModeSupportedApp((s=d.peer.metadata.redirect)==null?void 0:s.universal),(i=this.client.signConfig)!=null&&i.disableRequestQueue?this.emitSessionRequest(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue());}catch(d){await this.sendError({id:h,topic:r,error:d}),this.client.logger.error(d);}}),c$1(this,"onSessionRequestResponse",(t,e)=>{const{id:s}=e,i=_i$1("session_request",s);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);isJsonRpcResult(e)?this.events.emit(_i$1("session_request",s),{result:e.result}):isJsonRpcError(e)&&this.events.emit(_i$1("session_request",s),{error:e.error});}),c$1(this,"onSessionEventRequest",async(t,e)=>{const{id:s,params:i}=e;try{const r=`${t}_session_event_${i.event.name}`,n=hu.get(r);if(n&&this.isRequestOutOfSync(n,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(R({topic:t},i)),this.client.events.emit("session_event",{id:s,topic:t,params:i}),hu.set(r,s);}catch(r){await this.sendError({id:s,topic:t,error:r}),this.client.logger.error(r);}}),c$1(this,"onSessionAuthenticateResponse",(t,e)=>{const{id:s}=e;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:e}),isJsonRpcResult(e)?this.events.emit(_i$1("session_request",s),{result:e.result}):isJsonRpcError(e)&&this.events.emit(_i$1("session_request",s),{error:e.error});}),c$1(this,"onSessionAuthenticateRequest",async t=>{var e;const{topic:s,payload:i,attestation:r,encryptedId:n,transportType:a}=t;try{const{requester:l,authPayload:p,expiryTimestamp:h}=i.params,u=await this.getVerifyContext({attestationId:r,hash:pa(JSON.stringify(i)),encryptedId:n,metadata:l.metadata,transportType:a}),d={requester:l,pairingTopic:s,id:i.id,authPayload:p,verifyContext:u,expiryTimestamp:h};await this.setAuthRequest(i.id,{request:d,pairingTopic:s,transportType:a}),a===ee$2.link_mode&&(e=l.metadata.redirect)!=null&&e.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:i.params,id:i.id,verifyContext:u});}catch(l){this.client.logger.error(l);const p=i.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),u=this.getAppLinkIfEnabled(i.params.requester.metadata,a),d={type:ie$2,receiverPublicKey:p,senderPublicKey:h};await this.sendError({id:i.id,topic:s,error:l,encodeOpts:d,rpcOpts:P$1.wc_sessionAuthenticate.autoReject,appLink:u});}}),c$1(this,"addSessionRequestToSessionRequestQueue",t=>{this.sessionRequestQueue.queue.push(t);}),c$1(this,"cleanupAfterResponse",t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=$$2.idle,this.processSessionRequestQueue();},cjsExports$3.toMiliseconds(this.requestQueueDelay));}),c$1(this,"cleanupPendingSentRequestsForTopic",({topic:t,error:e})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(i=>i.topic===t&&i.request.method==="wc_sessionRequest").forEach(i=>{const r=i.request.id,n=_i$1("session_request",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);this.events.emit(_i$1("session_request",i.request.id),{error:e});});}),c$1(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===$$2.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.emitSessionRequest(t);}catch(e){this.client.logger.error(e);}}),c$1(this,"emitSessionRequest",t=>{if(this.emittedSessionRequests.has(t.id)){this.client.logger.warn({id:t.id},`Skipping emitting \`session_request\` event for duplicate request. id: ${t.id}`);return}this.sessionRequestQueue.state=$$2.active,this.emittedSessionRequests.add(t.id),this.client.events.emit("session_request",t);}),c$1(this,"onPairingCreated",t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const e=this.client.proposal.getAll().find(s=>s.pairingTopic===t.topic);e&&this.onSessionProposeRequest({topic:t.topic,payload:formatJsonRpcRequest("wc_sessionPropose",O$1(R({},e),{requiredNamespaces:e.requiredNamespaces,optionalNamespaces:e.optionalNamespaces,relays:e.relays,proposer:e.proposer,sessionProperties:e.sessionProperties,scopedProperties:e.scopedProperties}),e.id),attestation:e.attestation,encryptedId:e.encryptedId});}),c$1(this,"isValidConnect",async t=>{if(!Qa(t)){const{message:l}=Bt$2("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(l)}const{pairingTopic:e,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,scopedProperties:n,relays:a}=t;if(Dt$1(e)||await this.isValidPairingTopic(e),!Xa(a)){const{message:l}=Bt$2("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(l)}if(s&&!Dt$1(s)&&Ye$2(s)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(s,"requiredNamespaces");}if(i&&!Dt$1(i)&&Ye$2(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),r&&!Dt$1(r)&&this.validateSessionProps(r,"sessionProperties"),n&&!Dt$1(n)){this.validateSessionProps(n,"scopedProperties");const l=Object.keys(s||{}).concat(Object.keys(i||{}));if(!Object.keys(n).every(p=>l.includes(p.split(":")[0])))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),c$1(this,"validateNamespaces",(t,e)=>{const s=Wa(t,"connect()",e);if(s)throw new Error(s.message)}),c$1(this,"isValidApprove",async t=>{if(!Qa(t))throw new Error(Bt$2("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:e,namespaces:s,relayProtocol:i,sessionProperties:r,scopedProperties:n}=t;this.checkRecentlyDeleted(e),await this.isValidProposalId(e);const a=this.client.proposal.get(e),l=Ss(s,"approve()");if(l)throw new Error(l.message);const p=Ns$1(a.requiredNamespaces,s,"approve()");if(p)throw new Error(p.message);if(!ft$2(i,true)){const{message:h}=Bt$2("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(h)}if(r&&!Dt$1(r)&&this.validateSessionProps(r,"sessionProperties"),n&&!Dt$1(n)){this.validateSessionProps(n,"scopedProperties");const h=new Set(Object.keys(s));if(!Object.keys(n).every(u=>h.has(u.split(":")[0])))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),c$1(this,"isValidReject",async t=>{if(!Qa(t)){const{message:i}=Bt$2("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(i)}const{id:e,reason:s}=t;if(this.checkRecentlyDeleted(e),await this.isValidProposalId(e),!tu(s)){const{message:i}=Bt$2("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(i)}}),c$1(this,"isValidSessionSettleRequest",t=>{if(!Qa(t)){const{message:l}=Bt$2("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(l)}const{relay:e,controller:s,namespaces:i,expiry:r}=t;if(!Os$1(e)){const{message:l}=Bt$2("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const n=Ya(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const a=Ss(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);if(Ui$1(r)){const{message:l}=Bt$2("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),c$1(this,"isValidUpdate",async t=>{if(!Qa(t)){const{message:a}=Bt$2("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(a)}const{topic:e,namespaces:s}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const i=this.client.session.get(e),r=Ss(s,"update()");if(r)throw new Error(r.message);const n=Ns$1(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)}),c$1(this,"isValidExtend",async t=>{if(!Qa(t)){const{message:s}=Bt$2("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(s)}const{topic:e}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);}),c$1(this,"isValidRequest",async t=>{if(!Qa(t)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(a)}const{topic:e,request:s,chainId:i,expiry:r}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const{namespaces:n}=this.client.session.get(e);if(!ou(n,i)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(a)}if(!eu(s)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(a)}if(!su(n,i,s.method)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(a)}if(r&&!au(r,_e$1)){const{message:a}=Bt$2("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${_e$1.min} and ${_e$1.max}`);throw new Error(a)}}),c$1(this,"isValidRespond",async t=>{var e;if(!Qa(t)){const{message:n}=Bt$2("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(n)}const{topic:s,response:i}=t;try{await this.isValidSessionTopic(s);}catch(n){throw (e=t?.response)!=null&&e.id&&this.cleanupAfterResponse(t),n}if(!nu(i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(n)}const r=this.client.pendingRequest.get(i.id);if(r.topic!==s){const{message:n}=Bt$2("MISMATCHED_TOPIC",`Request response topic mismatch. reqId: ${i.id}, expected topic: ${r.topic}, received topic: ${s}`);throw new Error(n)}}),c$1(this,"isValidPing",async t=>{if(!Qa(t)){const{message:s}=Bt$2("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(s)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e);}),c$1(this,"isValidEmit",async t=>{if(!Qa(t)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(n)}const{topic:e,event:s,chainId:i}=t;await this.isValidSessionTopic(e);const{namespaces:r}=this.client.session.get(e);if(!ou(r,i)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(n)}if(!ru(s)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(n)}if(!iu(r,i,s.name)){const{message:n}=Bt$2("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(n)}}),c$1(this,"isValidDisconnect",async t=>{if(!Qa(t)){const{message:s}=Bt$2("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(s)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e);}),c$1(this,"isValidAuthenticate",t=>{const{chains:e,uri:s,domain:i,nonce:r}=t;if(!Array.isArray(e)||e.length===0)throw new Error("chains is required and must be a non-empty array");if(!ft$2(s,false))throw new Error("uri is required parameter");if(!ft$2(i,false))throw new Error("domain is required parameter");if(!ft$2(r,false))throw new Error("nonce is required parameter");if([...new Set(e.map(a=>Je$2(a).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=Je$2(e[0]);if(n!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),c$1(this,"getVerifyContext",async t=>{const{attestationId:e,hash:s,encryptedId:i,metadata:r,transportType:n}=t,a={verified:{verifyUrl:r.verifyUrl||be$2,validation:"UNKNOWN",origin:r.url||""}};try{if(n===ee$2.link_mode){const p=this.getAppLinkIfEnabled(r,n);return a.verified.validation=p&&new URL(p).origin===new URL(r.url).origin?"VALID":"INVALID",a}const l=await this.client.core.verify.resolve({attestationId:e,hash:s,encryptedId:i,verifyUrl:r.verifyUrl});l&&(a.verified.origin=l.origin,a.verified.isScam=l.isScam,a.verified.validation=l.origin===new URL(r.url).origin?"VALID":"INVALID");}catch(l){this.client.logger.warn(l);}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),c$1(this,"validateSessionProps",(t,e)=>{Object.values(t).forEach((s,i)=>{if(s==null){const{message:r}=Bt$2("MISSING_OR_INVALID",`${e} must contain an existing value for each key. Received: ${s} for key ${Object.keys(t)[i]}`);throw new Error(r)}});}),c$1(this,"getPendingAuthRequest",t=>{const e=this.client.auth.requests.get(t);return typeof e=="object"?e:void 0}),c$1(this,"addToRecentlyDeleted",(t,e)=>{if(this.recentlyDeletedMap.set(t,e),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const i=this.recentlyDeletedLimit/2;for(const r of this.recentlyDeletedMap.keys()){if(s++>=i)break;this.recentlyDeletedMap.delete(r);}}}),c$1(this,"checkRecentlyDeleted",t=>{const e=this.recentlyDeletedMap.get(t);if(e){const{message:s}=Bt$2("MISSING_OR_INVALID",`Record was recently deleted - ${e}: ${t}`);throw new Error(s)}}),c$1(this,"isLinkModeEnabled",(t,e)=>{var s,i,r,n,a,l,p,h,u;return !t||e!==ee$2.link_mode?false:((i=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:i.linkMode)===true&&((n=(r=this.client.metadata)==null?void 0:r.redirect)==null?void 0:n.universal)!==void 0&&((l=(a=this.client.metadata)==null?void 0:a.redirect)==null?void 0:l.universal)!==""&&((p=t?.redirect)==null?void 0:p.universal)!==void 0&&((h=t?.redirect)==null?void 0:h.universal)!==""&&((u=t?.redirect)==null?void 0:u.linkMode)===true&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),c$1(this,"getAppLinkIfEnabled",(t,e)=>{var s;return this.isLinkModeEnabled(t,e)?(s=t?.redirect)==null?void 0:s.universal:void 0}),c$1(this,"handleLinkModeMessage",({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const e=Ti$1(t,"topic")||"",s=decodeURIComponent(Ti$1(t,"wc_ev")||""),i=this.client.session.keys.includes(e);i&&this.client.session.update(e,{transportType:ee$2.link_mode}),this.client.core.dispatchEnvelope({topic:e,message:s,sessionExists:i});}),c$1(this,"registerLinkModeListeners",async()=>{var t;if(ji$1()||At$2()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const e=global==null?void 0:global.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const s=await e.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s});},50);}}}),c$1(this,"getTVFParams",(t,e,s)=>{var i,r,n;if(!((i=e.request)!=null&&i.method))return {};const a={correlationId:t,rpcMethods:[e.request.method],chainId:e.chainId};try{const l=this.extractTxHashesFromResult(e.request,s);a.txHashes=l,a.contractAddresses=this.isValidContractData(e.request.params)?[(n=(r=e.request.params)==null?void 0:r[0])==null?void 0:n.to]:[];}catch(l){this.client.logger.warn(l,"Error getting TVF params");}return a}),c$1(this,"isValidContractData",t=>{var e;if(!t)return false;try{const s=t?.data||((e=t?.[0])==null?void 0:e.data);if(!s.startsWith("0x"))return !1;const i=s.slice(2);return /^[0-9a-fA-F]*$/.test(i)?i.length%2===0:!1}catch{}return false}),c$1(this,"extractTxHashesFromResult",(t,e)=>{var s;try{if(!e)return [];const i=t.method,r=yt$1[i];if(i==="sui_signTransaction")return [Oc(e.transactionBytes)];if(i==="near_signTransaction")return [Nc(e)];if(i==="near_signTransactions")return e.map(a=>Nc(a));if(i==="xrpl_signTransactionFor"||i==="xrpl_signTransaction")return [(s=e.tx_json)==null?void 0:s.hash];if(i==="polkadot_signTransaction")return [mu({transaction:t.params.transactionPayload,signature:e.signature})];if(i==="algo_signTxn")return Ee$2(e)?e.map(a=>Uc(a)):[Uc(e)];if(i==="cosmos_signDirect")return [_c(e)];if(i==="wallet_sendCalls")return Rc(e);if(typeof e=="string")return [e];const n=e[r.key];if(Ee$2(n))return i==="solana_signAllTransactions"?n.map(a=>Sc(a)):n;if(typeof n=="string")return [n]}catch(i){this.client.logger.warn(i,"Error extracting tx hashes from result");}return []});}async processPendingMessageEvents(){try{const o=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(o);for(const[e,s]of Object.entries(t))for(const i of s)try{await this.onProviderMessageEvent({topic:e,message:i,publishedAt:Date.now()});}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${i}`);}}catch(o){this.client.logger.warn(o,"processPendingMessageEvents failed");}}isInitialized(){if(!this.initialized){const{message:o}=Bt$2("NOT_INITIALIZED",this.name);throw new Error(o)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow();}registerRelayerEvents(){this.client.core.relayer.on(C$1.message,o=>{this.onProviderMessageEvent(o);});}async onRelayMessage(o){const{topic:t,message:e,attestation:s,transportType:i}=o,{publicKey:r}=this.client.auth.authKeys.keys.includes(pe$2)?this.client.auth.authKeys.get(pe$2):{publicKey:void 0};try{const n=await this.client.core.crypto.decode(t,e,{receiverPublicKey:r,encoding:i===ee$2.link_mode?Ge$2:oe$3});isJsonRpcRequest(n)?(this.client.core.history.set(t,n),await this.onRelayEventRequest({topic:t,payload:n,attestation:s,transportType:i,encryptedId:pa(e)})):isJsonRpcResponse(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n,transportType:i}),this.client.core.history.delete(t,n.id)):await this.onRelayEventUnknownPayload({topic:t,payload:n,transportType:i}),await this.client.core.relayer.messages.ack(t,e);}catch(n){this.client.logger.error(n);}}registerExpirerEvents(){this.client.core.expirer.on(q$1.expired,async o=>{const{topic:t,id:e}=Oi$1(o.target);if(e&&this.client.pendingRequest.keys.includes(e))return await this.deletePendingSessionRequest(e,Bt$2("EXPIRED"),true);if(e&&this.client.auth.requests.keys.includes(e))return await this.deletePendingAuthRequest(e,Bt$2("EXPIRED"),true);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:true}),this.client.events.emit("session_expire",{topic:t})):e&&(await this.deleteProposal(e,true),this.client.events.emit("proposal_expire",{id:e}));});}registerPairingEvents(){this.client.core.pairing.events.on(ae$2.create,o=>this.onPairingCreated(o)),this.client.core.pairing.events.on(ae$2.delete,o=>{this.addToRecentlyDeleted(o.topic,"pairing");});}isValidPairingTopic(o){if(!ft$2(o,false)){const{message:t}=Bt$2("MISSING_OR_INVALID",`pairing topic should be a string: ${o}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(o)){const{message:t}=Bt$2("NO_MATCHING_KEY",`pairing topic doesn't exist: ${o}`);throw new Error(t)}if(Ui$1(this.client.core.pairing.pairings.get(o).expiry)){const{message:t}=Bt$2("EXPIRED",`pairing topic: ${o}`);throw new Error(t)}}async isValidSessionTopic(o){if(!ft$2(o,false)){const{message:t}=Bt$2("MISSING_OR_INVALID",`session topic should be a string: ${o}`);throw new Error(t)}if(this.checkRecentlyDeleted(o),!this.client.session.keys.includes(o)){const{message:t}=Bt$2("NO_MATCHING_KEY",`session topic doesn't exist: ${o}`);throw new Error(t)}if(Ui$1(this.client.session.get(o).expiry)){await this.deleteSession({topic:o});const{message:t}=Bt$2("EXPIRED",`session topic: ${o}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(o)){const{message:t}=Bt$2("MISSING_OR_INVALID",`session topic does not exist in keychain: ${o}`);throw await this.deleteSession({topic:o}),new Error(t)}}async isValidSessionOrPairingTopic(o){if(this.checkRecentlyDeleted(o),this.client.session.keys.includes(o))await this.isValidSessionTopic(o);else if(this.client.core.pairing.pairings.keys.includes(o))this.isValidPairingTopic(o);else if(ft$2(o,false)){const{message:t}=Bt$2("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${o}`);throw new Error(t)}else {const{message:t}=Bt$2("MISSING_OR_INVALID",`session or pairing topic should be a string: ${o}`);throw new Error(t)}}async isValidProposalId(o){if(!Ja(o)){const{message:t}=Bt$2("MISSING_OR_INVALID",`proposal id should be a number: ${o}`);throw new Error(t)}if(!this.client.proposal.keys.includes(o)){const{message:t}=Bt$2("NO_MATCHING_KEY",`proposal id doesn't exist: ${o}`);throw new Error(t)}if(Ui$1(this.client.proposal.get(o).expiryTimestamp)){await this.deleteProposal(o);const{message:t}=Bt$2("EXPIRED",`proposal id: ${o}`);throw new Error(t)}}}class Vs extends ji{constructor(o,t){super(o,t,dt$1,we$2),this.core=o,this.logger=t;}}let It$1 = class It extends ji{constructor(o,t){super(o,t,ut$1,we$2),this.core=o,this.logger=t;}};class ks extends ji{constructor(o,t){super(o,t,wt$1,we$2,e=>e.id),this.core=o,this.logger=t;}}class Ds extends ji{constructor(o,t){super(o,t,Et$1,le$2,()=>pe$2),this.core=o,this.logger=t;}}class Ls extends ji{constructor(o,t){super(o,t,St$1,le$2),this.core=o,this.logger=t;}}class Ms extends ji{constructor(o,t){super(o,t,Rt$1,le$2,e=>e.id),this.core=o,this.logger=t;}}var $s=Object.defineProperty,Ks=(E,o,t)=>o in E?$s(E,o,{enumerable:true,configurable:true,writable:true,value:t}):E[o]=t,Ke$1=(E,o,t)=>Ks(E,typeof o!="symbol"?o+"":o,t);class Us{constructor(o,t){this.core=o,this.logger=t,Ke$1(this,"authKeys"),Ke$1(this,"pairingTopics"),Ke$1(this,"requests"),this.authKeys=new Ds(this.core,this.logger),this.pairingTopics=new Ls(this.core,this.logger),this.requests=new Ms(this.core,this.logger);}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init();}}var Gs=Object.defineProperty,js=(E,o,t)=>o in E?Gs(E,o,{enumerable:true,configurable:true,writable:true,value:t}):E[o]=t,f$1=(E,o,t)=>js(E,typeof o!="symbol"?o+"":o,t);let fe$2 = class fe extends J$5{constructor(o){super(o),f$1(this,"protocol",Ve$1),f$1(this,"version",ke$2),f$1(this,"name",me$2.name),f$1(this,"metadata"),f$1(this,"core"),f$1(this,"logger"),f$1(this,"events",new eventsExports.EventEmitter),f$1(this,"engine"),f$1(this,"session"),f$1(this,"proposal"),f$1(this,"pendingRequest"),f$1(this,"auth"),f$1(this,"signConfig"),f$1(this,"on",(e,s)=>this.events.on(e,s)),f$1(this,"once",(e,s)=>this.events.once(e,s)),f$1(this,"off",(e,s)=>this.events.off(e,s)),f$1(this,"removeListener",(e,s)=>this.events.removeListener(e,s)),f$1(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),f$1(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"update",async e=>{try{return await this.engine.update(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"request",async e=>{try{return await this.engine.request(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"find",e=>{try{return this.engine.find(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),f$1(this,"authenticate",async(e,s)=>{try{return await this.engine.authenticate(e,s)}catch(i){throw this.logger.error(i.message),i}}),f$1(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(s){throw this.logger.error(s.message),s}}),f$1(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(s){throw this.logger.error(s.message),s}}),this.name=o?.name||me$2.name,this.metadata=di$1(o?.metadata),this.signConfig=o?.signConfig;const t=wu({logger:o?.logger||me$2.logger,name:this.name});this.logger=t,this.core=o?.core||new ta(o),this.session=new It$1(this.core,this.logger),this.proposal=new Vs(this.core,this.logger),this.pendingRequest=new ks(this.core,this.logger),this.engine=new Cs(this),this.auth=new Us(this.core,this.logger);}static async init(o){const t=new fe(o);return await t.initialize(),t}get context(){return w$3(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success");}catch(o){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(o.message),o}}};const Qs=fe$2;
|
|
29991
31279
|
|
|
29992
31280
|
var browserPonyfill = {exports: {}};
|
|
29993
31281
|
|
|
@@ -30692,9 +31980,9 @@ var o = /*@__PURE__*/getDefaultExportFromCjs$1(browserPonyfillExports);
|
|
|
30692
31980
|
|
|
30693
31981
|
var P=Object.defineProperty,w$1=Object.defineProperties,E$1=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,L$2=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,l=(r,t,e)=>t in r?P(r,t,{enumerable:true,configurable:true,writable:true,value:e}):r[t]=e,p=(r,t)=>{for(var e in t||(t={}))L$2.call(t,e)&&l(r,e,t[e]);if(c)for(var e of c(t))O.call(t,e)&&l(r,e,t[e]);return r},v$1=(r,t)=>w$1(r,E$1(t));const j$1={Accept:"application/json","Content-Type":"application/json"},T$1="POST",d$1={headers:j$1,method:T$1},g$1=10;class f{constructor(t,e=false){if(this.url=t,this.disableProviderPing=e,this.events=new eventsExports.EventEmitter,this.isAvailable=false,this.registering=false,!isHttpUrl(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e;}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e);}once(t,e){this.events.once(t,e);}off(t,e){this.events.off(t,e);}removeListener(t,e){this.events.removeListener(t,e);}async open(t=this.url){await this.register(t);}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose();}async send(t){this.isAvailable||await this.register();try{const e=safeJsonStringify(t),s=await(await o(this.url,v$1(p({},d$1),{body:e}))).json();this.onPayload({data:s});}catch(e){this.onError(t.id,e);}}async register(t=this.url){if(!isHttpUrl(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((s,i)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),i(n);}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));s();});})}this.url=t,this.registering=true;try{if(!this.disableProviderPing){const e=safeJsonStringify({id:1,jsonrpc:"2.0",method:"test",params:[]});await o(t,v$1(p({},d$1),{body:e}));}this.onOpen();}catch(e){const s=this.parseError(e);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=true,this.registering=false,this.events.emit("open");}onClose(){this.isAvailable=false,this.registering=false,this.events.emit("close");}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?safeJsonParse(t.data):t.data;this.events.emit("payload",e);}onError(t,e){const s=this.parseError(e),i=s.message||s.toString(),n=formatJsonRpcError(t,i);this.events.emit("payload",n);}parseError(t,e=this.url){return parseConnectionError(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>g$1&&this.events.setMaxListeners(g$1);}}
|
|
30694
31982
|
|
|
30695
|
-
function _(t){return t==null||typeof t!="object"&&typeof t!="function"}function Z$1(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function T(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Fe="[object RegExp]",ee$1="[object String]",te$1="[object Number]",se$1="[object Boolean]",ie$1="[object Arguments]",He="[object Symbol]",Ue$1="[object Date]",Be="[object Map]",Le="[object Set]",Me$1="[object Array]",ze="[object ArrayBuffer]",Ge="[object Object]",We$1="[object DataView]",Je="[object Uint8Array]",Ke="[object Uint8ClampedArray]",Ve="[object Uint16Array]",Ye="[object Uint32Array]",Xe="[object Int8Array]",ke$1="[object Int16Array]",Qe="[object Int32Array]",Ze="[object Float32Array]",Te$1="[object Float64Array]";function x(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function et(t,e){return y(t,void 0,t,new Map,e)}function y(t,e,s,i=new Map,r=void 0){const a=r?.(t,e,s,i);if(a!=null)return a;if(_(t))return t;if(i.has(t))return i.get(t);if(Array.isArray(t)){const n=new Array(t.length);i.set(t,n);for(let c=0;c<t.length;c++)n[c]=y(t[c],c,s,i,r);return Object.hasOwn(t,"index")&&(n.index=t.index),Object.hasOwn(t,"input")&&(n.input=t.input),n}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const n=new RegExp(t.source,t.flags);return n.lastIndex=t.lastIndex,n}if(t instanceof Map){const n=new Map;i.set(t,n);for(const[c,o]of t)n.set(c,y(o,c,s,i,r));return n}if(t instanceof Set){const n=new Set;i.set(t,n);for(const c of t)n.add(y(c,void 0,s,i,r));return n}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(x(t)){const n=new(Object.getPrototypeOf(t)).constructor(t.length);i.set(t,n);for(let c=0;c<t.length;c++)n[c]=y(t[c],c,s,i,r);return n}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const n=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return i.set(t,n),m(n,t,s,i,r),n}if(typeof File<"u"&&t instanceof File){const n=new File([t],t.name,{type:t.type});return i.set(t,n),m(n,t,s,i,r),n}if(t instanceof Blob){const n=new Blob([t],{type:t.type});return i.set(t,n),m(n,t,s,i,r),n}if(t instanceof Error){const n=new t.constructor;return i.set(t,n),n.message=t.message,n.name=t.name,n.stack=t.stack,n.cause=t.cause,m(n,t,s,i,r),n}if(typeof t=="object"&&tt(t)){const n=Object.create(Object.getPrototypeOf(t));return i.set(t,n),m(n,t,s,i,r),n}return t}function m(t,e,s=t,i,r){const a=[...Object.keys(e),...Z$1(e)];for(let n=0;n<a.length;n++){const c=a[n],o=Object.getOwnPropertyDescriptor(t,c);(o==null||o.writable)&&(t[c]=y(e[c],c,s,i,r));}}function tt(t){switch(T(t)){case ie$1:case Me$1:case ze:case We$1:case se$1:case Ue$1:case Ze:case Te$1:case Xe:case ke$1:case Qe:case Be:case te$1:case Ge:case Fe:case Le:case ee$1:case He:case Je:case Ke:case Ve:case Ye:return true;default:return false}}function st(t,e){return et(t,(s,i,r,a)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case te$1:case ee$1:case se$1:{const c=new t.constructor(t?.valueOf());return m(c,t),c}case ie$1:{const c={};return m(c,t),c.length=t.length,c[Symbol.iterator]=t[Symbol.iterator],c}default:return}})}function ne$1(t){return st(t)}function re$1(t){return t!==null&&typeof t=="object"&&T(t)==="[object Arguments]"}function ae$1(t){return typeof t=="object"&&t!==null}function it(){}function nt(t){return x(t)}function rt(t){if(typeof t!="object"||t==null)return false;if(Object.getPrototypeOf(t)===null)return true;if(Object.prototype.toString.call(t)!=="[object Object]"){const s=t[Symbol.toStringTag];return s==null||!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable?false:t.toString()===`[object ${s}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function at(t){if(_(t))return t;if(Array.isArray(t)||x(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const i=new s(t);return i.lastIndex=t.lastIndex,i}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){const i=new s(t.message);return i.stack=t.stack,i.name=t.name,i.cause=t.cause,i}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const i=Object.create(e);return Object.assign(i,t)}return t}function ct(t,...e){const s=e.slice(0,-1),i=e[e.length-1];let r=t;for(let a=0;a<s.length;a++){const n=s[a];r=$$1(r,n,i,new Map);}return r}function $$1(t,e,s,i){if(_(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(i.has(e))return at(i.get(e));if(i.set(e,t),Array.isArray(e)){e=e.slice();for(let a=0;a<e.length;a++)e[a]=e[a]??void 0;}const r=[...Object.keys(e),...Z$1(e)];for(let a=0;a<r.length;a++){const n=r[a];let c=e[n],o=t[n];if(re$1(c)&&(c={...c}),re$1(o)&&(o={...o}),typeof Buffer<"u"&&Buffer.isBuffer(c)&&(c=ne$1(c)),Array.isArray(c))if(typeof o=="object"&&o!=null){const l=[],p=Reflect.ownKeys(o);for(let f=0;f<p.length;f++){const u=p[f];l[u]=o[u];}o=l;}else o=[];const h=s(o,c,n,t,e,i);h!=null?t[n]=h:Array.isArray(c)||ae$1(o)&&ae$1(c)?t[n]=$$1(o,c,s,i):o==null&&rt(c)?t[n]=$$1({},c,s,i):o==null&&nt(c)?t[n]=ne$1(c):(o===void 0||c!==void 0)&&(t[n]=c);}return t}function ot(t,...e){return ct(t,...e,it)}const ce$1="error",pt="wss://relay.walletconnect.org",ht="wc",oe$1="universal_provider",A=`${ht}@2:${oe$1}:`,pe$1="https://rpc.walletconnect.org/v1/",he$1="generic",lt=`${pe$1}bundler`,v="call_status",ut=86400,F={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var dt=Object.defineProperty,ft=Object.defineProperties,mt=Object.getOwnPropertyDescriptors,le$1=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,ue$1=(t,e,s)=>e in t?dt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,E=(t,e)=>{for(var s in e||(e={}))gt.call(e,s)&&ue$1(t,s,e[s]);if(le$1)for(var s of le$1(e))yt.call(e,s)&&ue$1(t,s,e[s]);return t},vt=(t,e)=>ft(t,mt(e));function de$1(t,e,s){var i;const r=Je$2(t);return ((i=e.rpcMap)==null?void 0:i[r.reference])||`${pe$1}?chainId=${r.namespace}:${r.reference}&projectId=${s}`}function wt(t){return t.includes(":")?t.split(":")[1]:t}function fe$1(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function bt(t,e){const s=Object.keys(e.namespaces).filter(r=>r.includes(t));if(!s.length)return [];const i=[];return s.forEach(r=>{const a=e.namespaces[r].accounts;i.push(...a);}),i}function me$1(t){return Object.fromEntries(Object.entries(t).filter(([e,s])=>{var i,r;return ((i=s?.chains)==null?void 0:i.length)&&((r=s?.chains)==null?void 0:r.length)>0}))}function C(t={},e={}){const s=me$1(ge$1(t)),i=me$1(ge$1(e));return ot(s,i)}function ge$1(t){var e,s,i,r,a;const n={};if(!Ye$2(t))return n;for(const[c,o]of Object.entries(t)){const h=Gn$1(c)?[c]:o.chains,l=o.methods||[],p=o.events||[],f=o.rpcMap||{},u=bs$1(c);n[u]=vt(E(E({},n[u]),o),{chains:ut$2(h,(e=n[u])==null?void 0:e.chains),methods:ut$2(l,(s=n[u])==null?void 0:s.methods),events:ut$2(p,(i=n[u])==null?void 0:i.events)}),(Ye$2(f)||Ye$2(((r=n[u])==null?void 0:r.rpcMap)||{}))&&(n[u].rpcMap=E(E({},f),(a=n[u])==null?void 0:a.rpcMap));}return n}function ye$1(t){return t.includes(":")?t.split(":")[2]:t}function ve$1(t){const e={};for(const[s,i]of Object.entries(t)){const r=i.methods||[],a=i.events||[],n=i.accounts||[],c=Gn$1(s)?[s]:i.chains?i.chains:fe$1(i.accounts);e[s]={chains:c,methods:r,events:a,accounts:n};}return e}function H$1(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}function Pt(t){try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)}catch{return false}}const we$1={},w=t=>we$1[t],U=(t,e)=>{we$1[t]=e;};var Ot=Object.defineProperty,be$1=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Pe$1=(t,e,s)=>e in t?Ot(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,Oe$1=(t,e)=>{for(var s in e||(e={}))It.call(e,s)&&Pe$1(t,s,e[s]);if(be$1)for(var s of be$1(e))St.call(e,s)&&Pe$1(t,s,e[s]);return t};const Ie="eip155",$t=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],At=t=>t&&t.startsWith("0x")?BigInt(t).toString(10):t,B$1=t=>t&&t.startsWith("0x")?t:`0x${BigInt(t).toString(16)}`,Se$1=t=>Object.keys(t).filter(e=>$t.includes(e)).reduce((e,s)=>(e[s]=Et(t[s]),e),{}),Et=t=>typeof t=="string"&&Pt(t)?JSON.parse(t):t,Ct=(t,e,s)=>{const{sessionProperties:i={},scopedProperties:r={}}=t,a={};if(!Ye$2(r)&&!Ye$2(i))return;const n=Se$1(i);for(const c of s){const o=At(c);if(!o)continue;a[B$1(o)]=n;const h=r?.[`${Ie}:${o}`];if(h){const l=h?.[`${Ie}:${o}:${e}`];a[B$1(o)]=Oe$1(Oe$1({},a[B$1(o)]),Se$1(l||h));}}for(const[c,o]of Object.entries(a))Object.keys(o).length===0&&delete a[c];return Object.keys(a).length>0?a:void 0};var jt=Object.defineProperty,Nt=(t,e,s)=>e in t?jt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,qt=(t,e,s)=>Nt(t,e+"",s);let L$1;let J$1 = class J{constructor(e){qt(this,"storage"),this.storage=e;}async getItem(e){return await this.storage.getItem(e)}async setItem(e,s){return await this.storage.setItem(e,s)}async removeItem(e){return await this.storage.removeItem(e)}static getStorage(e){return L$1||(L$1=new J(e)),L$1}};var Dt=Object.defineProperty,Rt=Object.defineProperties,_t=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Ae$1=(t,e,s)=>e in t?Dt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,Ht=(t,e)=>{for(var s in e||(e={}))xt.call(e,s)&&Ae$1(t,s,e[s]);if($e)for(var s of $e(e))Ft.call(e,s)&&Ae$1(t,s,e[s]);return t},Ut=(t,e)=>Rt(t,_t(e));async function Bt(t,e){const s=Je$2(t.result.capabilities.caip345.caip2),i=t.result.capabilities.caip345.transactionHashes,r=await Promise.allSettled(i.map(p=>Lt(s.reference,p,e))),a=r.filter(p=>p.status==="fulfilled").map(p=>p.value).filter(p=>p);r.filter(p=>p.status==="rejected").forEach(p=>console.warn("Failed to fetch transaction receipt:",p.reason));const n=!a.length||a.some(p=>!p),c=a.every(p=>p?.status==="0x1"),o=a.every(p=>p?.status==="0x0"),h=a.some(p=>p?.status==="0x0");let l;return n?l=100:c?l=200:o?l=500:h&&(l=600),{id:t.result.id,version:t.request.version,atomic:t.request.atomicRequired,chainId:t.request.chainId,capabilities:t.result.capabilities,receipts:a,status:l}}async function Lt(t,e,s){return await s(parseInt(t)).request(formatJsonRpcRequest("eth_getTransactionReceipt",[e]))}async function Mt({sendCalls:t,storage:e}){const s=await e.getItem(v);await e.setItem(v,Ut(Ht({},s),{[t.result.id]:{request:t.request,result:t.result,expiry:Ni$1(ut)}}));}async function zt({resultId:t,storage:e}){const s=await e.getItem(v);if(s){delete s[t],await e.setItem(v,s);for(const i in s)Ui$1(s[i].expiry)&&delete s[i];await e.setItem(v,s);}}async function Gt({resultId:t,storage:e}){const s=await e.getItem(v),i=s?.[t];if(i&&!Ui$1(i.expiry))return i;await zt({resultId:t,storage:e});}var Wt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Ee$1=Object.getOwnPropertySymbols,Vt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,M=(t,e,s)=>e in t?Wt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,z$1=(t,e)=>{for(var s in e||(e={}))Vt.call(e,s)&&M(t,s,e[s]);if(Ee$1)for(var s of Ee$1(e))Yt.call(e,s)&&M(t,s,e[s]);return t},G$1=(t,e)=>Jt(t,Kt(e)),g=(t,e,s)=>M(t,typeof e!="symbol"?e+"":e,s);class Xt{constructor(e){g(this,"name","eip155"),g(this,"client"),g(this,"chainId"),g(this,"namespace"),g(this,"httpProviders"),g(this,"events"),g(this,"storage"),this.namespace=e.namespace,this.events=w("events"),this.client=w("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=J$1.getStorage(this.client.core.storage);}async request(e){switch(e.request.method){case "eth_requestAccounts":return this.getAccounts();case "eth_accounts":return this.getAccounts();case "wallet_switchEthereumChain":return await this.handleSwitchChain(e);case "eth_chainId":return parseInt(this.getDefaultChain());case "wallet_getCapabilities":return await this.getCapabilities(e);case "wallet_getCallsStatus":return await this.getCallStatus(e);case "wallet_sendCalls":return await this.sendCalls(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e);}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s);const i=this.chainId;this.chainId=parseInt(e),this.events.emit(F.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${i}`});}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,s){const i=s||de$1(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new o$1(new f(i,w("disableProviderPing")))}setHttpProvider(e,s){const i=this.createHttpProvider(e,s);i&&(this.httpProviders[e]=i);}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var i;const r=parseInt(wt(s));e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[s]);}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(e){const s=e||this.chainId;return this.httpProviders[s]||(this.httpProviders=G$1(z$1({},this.httpProviders),{[s]:this.createHttpProvider(s)}),this.httpProviders[s])}async handleSwitchChain(e){var s,i;let r=e.request.params?(s=e.request.params[0])==null?void 0:s.chainId:"0x0";r=r.startsWith("0x")?r:`0x${r}`;const a=parseInt(r,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:r}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var s,i,r,a,n;const c=(i=(s=e.request)==null?void 0:s.params)==null?void 0:i[0],o=((a=(r=e.request)==null?void 0:r.params)==null?void 0:a[1])||[];if(!c)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(e.topic),l=((n=h?.sessionProperties)==null?void 0:n.capabilities)||{},p=`${c}${o.join(",")}`,f=l?.[p];if(f)return f;let u;try{u=Ct(h,c,o);}catch(q){console.warn("Failed to extract capabilities from session",q);}if(u)return u;const K=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:G$1(z$1({},h.sessionProperties||{}),{capabilities:G$1(z$1({},l||{}),{[p]:K})})});}catch(q){console.warn("Failed to update session with capabilities",q);}return K}async getCallStatus(e){var s,i,r;const a=this.client.session.get(e.topic),n=(s=a.sessionProperties)==null?void 0:s.bundler_name;if(n){const h=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(h,e)}catch(l){console.warn("Failed to fetch call status from bundler",l,h);}}const c=(i=a.sessionProperties)==null?void 0:i.bundler_url;if(c)try{return await this.getUserOperationReceipt(c,e)}catch(h){console.warn("Failed to fetch call status from custom bundler",h,c);}const o=await Gt({resultId:(r=e.request.params)==null?void 0:r[0],storage:this.storage});if(o)try{return await Bt(o,this.getHttpProvider.bind(this))}catch(h){console.warn("Failed to fetch call status from stored send calls",h,o);}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,s){var i;const r=new URL(e),a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(formatJsonRpcRequest("eth_getUserOperationReceipt",[(i=s.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,s){return `${lt}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}async sendCalls(e){var s,i,r;const a=await this.client.request(e),n=(s=e.request.params)==null?void 0:s[0],c=a?.id,o=a?.capabilities||{},h=(i=o?.caip345)==null?void 0:i.caip2,l=(r=o?.caip345)==null?void 0:r.transactionHashes;return !c||!h||!(l!=null&&l.length)||await Mt({sendCalls:{request:n,result:a},storage:this.storage}),a}}var kt=Object.defineProperty,Qt=(t,e,s)=>e in t?kt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,b=(t,e,s)=>Qt(t,typeof e!="symbol"?e+"":e,s);class Zt{constructor(e){b(this,"name",he$1),b(this,"client"),b(this,"httpProviders"),b(this,"events"),b(this,"namespace"),b(this,"chainId"),this.namespace=e.namespace,this.events=w("events"),this.client=w("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),this.httpProviders=this.createHttpProviders();}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders();}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s);const i=this.chainId;this.chainId=e,this.events.emit(F.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${i}`});}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getNamespaceName(){const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return Je$2(e).namespace}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var e,s;const i={};return (s=(e=this.namespace)==null?void 0:e.accounts)==null||s.forEach(r=>{var a,n;const c=Je$2(r),o=(n=(a=this.namespace)==null?void 0:a.rpcMap)==null?void 0:n[`${c.namespace}:${c.reference}`];i[c.reference]=this.createHttpProvider(r,o);}),i}getHttpProvider(e){const s=Je$2(e).reference,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,s){const i=this.createHttpProvider(e,s);i&&(this.httpProviders[e]=i);}createHttpProvider(e,s){const i=s||de$1(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new o$1(new f(i,w("disableProviderPing")))}}var Tt=Object.defineProperty,es=Object.defineProperties,ts=Object.getOwnPropertyDescriptors,Ce$1=Object.getOwnPropertySymbols,ss=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,W=(t,e,s)=>e in t?Tt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,S=(t,e)=>{for(var s in e||(e={}))ss.call(e,s)&&W(t,s,e[s]);if(Ce$1)for(var s of Ce$1(e))is.call(e,s)&&W(t,s,e[s]);return t},j=(t,e)=>es(t,ts(e)),d=(t,e,s)=>W(t,typeof e!="symbol"?e+"":e,s);let N$1 = class N{constructor(e){d(this,"client"),d(this,"namespaces"),d(this,"optionalNamespaces"),d(this,"sessionProperties"),d(this,"scopedProperties"),d(this,"events",new xe$2),d(this,"rpcProviders",{}),d(this,"session"),d(this,"providerOpts"),d(this,"logger"),d(this,"uri"),d(this,"disableProviderPing",false);var s,i;this.providerOpts=e,this.logger=wu({logger:(s=e.logger)!=null?s:ce$1,name:(i=this.providerOpts.name)!=null?i:oe$1}),this.disableProviderPing=e?.disableProviderPing||false;}static async init(e){const s=new N(e);return await s.initialize(),s}async request(e,s,i){const[r,a]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:S({},e),chainId:`${r}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,s,i,r){const a=new Date().getTime();this.request(e,i,r).then(n=>s(null,formatJsonRpcResult(a,n))).catch(n=>s(n,void 0));}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:zt$2("USER_DISCONNECTED")}),await this.cleanup();}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:r}=await this.client.authenticate(e,s);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await r();if(this.session=a.session,this.session){const n=ve$1(this.session.namespaces);this.namespaces=C(this.namespaces,n),await this.persist("namespaces",this.namespaces),this.onConnect();}return a}on(e,s){this.events.on(e,s);}once(e,s){this.events.once(e,s);}removeListener(e,s){this.events.removeListener(e,s);}off(e,s){this.events.off(e,s);}get isWalletConnect(){return true}async pair(e){const{uri:s,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});s&&(this.uri=s,this.events.emit("display_uri",s));const r=await i();this.session=r;const a=ve$1(r.namespaces);return this.namespaces=C(this.namespaces,a),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[i,r]=this.validateChain(e);this.getProvider(i).setDefaultChain(r,s);}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){try{this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(!Ee$2(s))return;for(const i of s)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`);}catch(s){this.logger.warn(s,"Failed to cleanup pending pairings");}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.");}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders();}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners();}async createClient(){var e,s;if(this.client=this.providerOpts.client||await Qs.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ce$1,relayUrl:this.providerOpts.relayUrl||pt,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic);}catch(i){throw this.logger.error(i,"Failed to get session"),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else {const i=this.client.session.getAll();this.session=i[0];}this.logger.trace("SignClient Initialized");}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(s=>bs$1(s)))];U("client",this.client),U("events",this.events),U("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const i=bt(s,this.session);if(i?.length===0)return;const r=fe$1(i),a=C(this.namespaces,this.optionalNamespaces),n=j(S({},a[s]),{accounts:i,chains:r});switch(s){case "eip155":this.rpcProviders[s]=new Xt({namespace:n});break;default:this.rpcProviders[s]=new Zt({namespace:n});}});}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var s;const{topic:i}=e;i===((s=this.session)==null?void 0:s.topic)&&this.events.emit("session_ping",e);}),this.client.on("session_event",e=>{var s;const{params:i,topic:r}=e;if(r!==((s=this.session)==null?void 0:s.topic))return;const{event:a}=i;if(a.name==="accountsChanged"){const n=a.data;n&&Ee$2(n)&&this.events.emit("accountsChanged",n.map(ye$1));}else if(a.name==="chainChanged"){const n=i.chainId,c=i.event.data,o=bs$1(n),h=H$1(n)!==H$1(c)?`${o}:${H$1(c)}`:n;this.onChainChanged({currentCaipChainId:h});}else this.events.emit(a.name,a.data);this.events.emit("session_event",e);}),this.client.on("session_update",({topic:e,params:s})=>{var i,r;if(e!==((i=this.session)==null?void 0:i.topic))return;const{namespaces:a}=s,n=(r=this.client)==null?void 0:r.session.get(e);this.session=j(S({},n),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s});}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",j(S({},zt$2("USER_DISCONNECTED")),{data:e.topic})));}),this.on(F.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(j(S({},e),{internal:true}));});}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[he$1]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e]);});}setNamespaces(e){const{namespaces:s={},optionalNamespaces:i={},sessionProperties:r,scopedProperties:a}=e;this.optionalNamespaces=C(s,i),this.sessionProperties=r,this.scopedProperties=a;}validateChain(e){const[s,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return [s,i];if(s&&!Object.keys(this.namespaces||{}).map(n=>bs$1(n)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&i)return [s,i];const r=bs$1(Object.keys(this.namespaces)[0]),a=this.rpcProviders[r].getDefaultChain();return [r,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged({currentCaipChainId:e,previousCaipChainId:s,internal:i=false}){if(!this.namespaces)return;const[r,a]=this.validateChain(e);a&&(this.updateNamespaceChain(r,a),i?(this.events.emit("chainChanged",a),this.emitAccountsChangedOnChainChange({namespace:r,currentCaipChainId:e,previousCaipChainId:s})):this.getProvider(r).setDefaultChain(a),await this.persist("namespaces",this.namespaces));}emitAccountsChangedOnChainChange({namespace:e,currentCaipChainId:s,previousCaipChainId:i}){var r,a;try{if(i===s)return;const n=(a=(r=this.session)==null?void 0:r.namespaces[e])==null?void 0:a.accounts;if(!n)return;const c=n.filter(o=>o.includes(`${s}:`)).map(ye$1);if(!Ee$2(c))return;this.events.emit("accountsChanged",c);}catch(n){this.logger.warn(n,"Failed to emit accountsChanged on chain change");}}updateNamespaceChain(e,s){if(!this.namespaces)return;const i=this.namespaces[e]?e:`${e}:${s}`,r={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[i]?this.namespaces[i]&&(this.namespaces[i].defaultChain=s):this.namespaces[i]=r;}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session});}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:true}),await this.cleanupStorage();}async persist(e,s){var i;const r=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${A}/${e}${r}`,s);}async getFromStore(e){var s;const i=((s=this.session)==null?void 0:s.topic)||"";return await this.client.core.storage.getItem(`${A}/${e}${i}`)}async deleteFromStore(e){var s;const i=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${A}/${e}${i}`);}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const i of s)i.startsWith(A)&&await this.client.core.storage.removeItem(i);}catch(s){this.logger.warn(s,"Failed to cleanup storage");}}};const ns=N$1;
|
|
31983
|
+
function _(t){return t==null||typeof t!="object"&&typeof t!="function"}function Z$1(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function T(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Fe$1="[object RegExp]",ee$1="[object String]",te$1="[object Number]",se$1="[object Boolean]",ie$1="[object Arguments]",He="[object Symbol]",Ue$1="[object Date]",Be="[object Map]",Le="[object Set]",Me$1="[object Array]",ze="[object ArrayBuffer]",Ge="[object Object]",We$1="[object DataView]",Je="[object Uint8Array]",Ke="[object Uint8ClampedArray]",Ve="[object Uint16Array]",Ye="[object Uint32Array]",Xe="[object Int8Array]",ke$1="[object Int16Array]",Qe="[object Int32Array]",Ze="[object Float32Array]",Te$1="[object Float64Array]";function x(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function et(t,e){return y(t,void 0,t,new Map,e)}function y(t,e,s,i=new Map,r=void 0){const a=r?.(t,e,s,i);if(a!=null)return a;if(_(t))return t;if(i.has(t))return i.get(t);if(Array.isArray(t)){const n=new Array(t.length);i.set(t,n);for(let c=0;c<t.length;c++)n[c]=y(t[c],c,s,i,r);return Object.hasOwn(t,"index")&&(n.index=t.index),Object.hasOwn(t,"input")&&(n.input=t.input),n}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const n=new RegExp(t.source,t.flags);return n.lastIndex=t.lastIndex,n}if(t instanceof Map){const n=new Map;i.set(t,n);for(const[c,o]of t)n.set(c,y(o,c,s,i,r));return n}if(t instanceof Set){const n=new Set;i.set(t,n);for(const c of t)n.add(y(c,void 0,s,i,r));return n}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(x(t)){const n=new(Object.getPrototypeOf(t)).constructor(t.length);i.set(t,n);for(let c=0;c<t.length;c++)n[c]=y(t[c],c,s,i,r);return n}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const n=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return i.set(t,n),m(n,t,s,i,r),n}if(typeof File<"u"&&t instanceof File){const n=new File([t],t.name,{type:t.type});return i.set(t,n),m(n,t,s,i,r),n}if(t instanceof Blob){const n=new Blob([t],{type:t.type});return i.set(t,n),m(n,t,s,i,r),n}if(t instanceof Error){const n=new t.constructor;return i.set(t,n),n.message=t.message,n.name=t.name,n.stack=t.stack,n.cause=t.cause,m(n,t,s,i,r),n}if(typeof t=="object"&&tt(t)){const n=Object.create(Object.getPrototypeOf(t));return i.set(t,n),m(n,t,s,i,r),n}return t}function m(t,e,s=t,i,r){const a=[...Object.keys(e),...Z$1(e)];for(let n=0;n<a.length;n++){const c=a[n],o=Object.getOwnPropertyDescriptor(t,c);(o==null||o.writable)&&(t[c]=y(e[c],c,s,i,r));}}function tt(t){switch(T(t)){case ie$1:case Me$1:case ze:case We$1:case se$1:case Ue$1:case Ze:case Te$1:case Xe:case ke$1:case Qe:case Be:case te$1:case Ge:case Fe$1:case Le:case ee$1:case He:case Je:case Ke:case Ve:case Ye:return true;default:return false}}function st(t,e){return et(t,(s,i,r,a)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case te$1:case ee$1:case se$1:{const c=new t.constructor(t?.valueOf());return m(c,t),c}case ie$1:{const c={};return m(c,t),c.length=t.length,c[Symbol.iterator]=t[Symbol.iterator],c}default:return}})}function ne$1(t){return st(t)}function re$1(t){return t!==null&&typeof t=="object"&&T(t)==="[object Arguments]"}function ae$1(t){return typeof t=="object"&&t!==null}function it(){}function nt(t){return x(t)}function rt(t){if(typeof t!="object"||t==null)return false;if(Object.getPrototypeOf(t)===null)return true;if(Object.prototype.toString.call(t)!=="[object Object]"){const s=t[Symbol.toStringTag];return s==null||!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable?false:t.toString()===`[object ${s}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function at(t){if(_(t))return t;if(Array.isArray(t)||x(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const i=new s(t);return i.lastIndex=t.lastIndex,i}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){const i=new s(t.message);return i.stack=t.stack,i.name=t.name,i.cause=t.cause,i}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const i=Object.create(e);return Object.assign(i,t)}return t}function ct(t,...e){const s=e.slice(0,-1),i=e[e.length-1];let r=t;for(let a=0;a<s.length;a++){const n=s[a];r=$$1(r,n,i,new Map);}return r}function $$1(t,e,s,i){if(_(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(i.has(e))return at(i.get(e));if(i.set(e,t),Array.isArray(e)){e=e.slice();for(let a=0;a<e.length;a++)e[a]=e[a]??void 0;}const r=[...Object.keys(e),...Z$1(e)];for(let a=0;a<r.length;a++){const n=r[a];let c=e[n],o=t[n];if(re$1(c)&&(c={...c}),re$1(o)&&(o={...o}),typeof Buffer<"u"&&Buffer.isBuffer(c)&&(c=ne$1(c)),Array.isArray(c))if(typeof o=="object"&&o!=null){const l=[],p=Reflect.ownKeys(o);for(let f=0;f<p.length;f++){const u=p[f];l[u]=o[u];}o=l;}else o=[];const h=s(o,c,n,t,e,i);h!=null?t[n]=h:Array.isArray(c)||ae$1(o)&&ae$1(c)?t[n]=$$1(o,c,s,i):o==null&&rt(c)?t[n]=$$1({},c,s,i):o==null&&nt(c)?t[n]=ne$1(c):(o===void 0||c!==void 0)&&(t[n]=c);}return t}function ot(t,...e){return ct(t,...e,it)}const ce$1="error",pt="wss://relay.walletconnect.org",ht="wc",oe$1="universal_provider",A=`${ht}@2:${oe$1}:`,pe$1="https://rpc.walletconnect.org/v1/",he$1="generic",lt=`${pe$1}bundler`,v="call_status",ut=86400,F={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var dt=Object.defineProperty,ft=Object.defineProperties,mt=Object.getOwnPropertyDescriptors,le$1=Object.getOwnPropertySymbols,gt=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable,ue$1=(t,e,s)=>e in t?dt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,E=(t,e)=>{for(var s in e||(e={}))gt.call(e,s)&&ue$1(t,s,e[s]);if(le$1)for(var s of le$1(e))yt.call(e,s)&&ue$1(t,s,e[s]);return t},vt=(t,e)=>ft(t,mt(e));function de$1(t,e,s){var i;const r=Je$2(t);return ((i=e.rpcMap)==null?void 0:i[r.reference])||`${pe$1}?chainId=${r.namespace}:${r.reference}&projectId=${s}`}function wt(t){return t.includes(":")?t.split(":")[1]:t}function fe$1(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function bt(t,e){const s=Object.keys(e.namespaces).filter(r=>r.includes(t));if(!s.length)return [];const i=[];return s.forEach(r=>{const a=e.namespaces[r].accounts;i.push(...a);}),i}function me$1(t){return Object.fromEntries(Object.entries(t).filter(([e,s])=>{var i,r;return ((i=s?.chains)==null?void 0:i.length)&&((r=s?.chains)==null?void 0:r.length)>0}))}function C(t={},e={}){const s=me$1(ge$1(t)),i=me$1(ge$1(e));return ot(s,i)}function ge$1(t){var e,s,i,r,a;const n={};if(!Ye$2(t))return n;for(const[c,o]of Object.entries(t)){const h=Gn$1(c)?[c]:o.chains,l=o.methods||[],p=o.events||[],f=o.rpcMap||{},u=bs$1(c);n[u]=vt(E(E({},n[u]),o),{chains:ut$2(h,(e=n[u])==null?void 0:e.chains),methods:ut$2(l,(s=n[u])==null?void 0:s.methods),events:ut$2(p,(i=n[u])==null?void 0:i.events)}),(Ye$2(f)||Ye$2(((r=n[u])==null?void 0:r.rpcMap)||{}))&&(n[u].rpcMap=E(E({},f),(a=n[u])==null?void 0:a.rpcMap));}return n}function ye$1(t){return t.includes(":")?t.split(":")[2]:t}function ve$1(t){const e={};for(const[s,i]of Object.entries(t)){const r=i.methods||[],a=i.events||[],n=i.accounts||[],c=Gn$1(s)?[s]:i.chains?i.chains:fe$1(i.accounts);e[s]={chains:c,methods:r,events:a,accounts:n};}return e}function H$1(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}function Pt(t){try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)}catch{return false}}const we$1={},w=t=>we$1[t],U=(t,e)=>{we$1[t]=e;};var Ot=Object.defineProperty,be$1=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Pe$1=(t,e,s)=>e in t?Ot(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,Oe$1=(t,e)=>{for(var s in e||(e={}))It.call(e,s)&&Pe$1(t,s,e[s]);if(be$1)for(var s of be$1(e))St.call(e,s)&&Pe$1(t,s,e[s]);return t};const Ie="eip155",$t=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],At=t=>t&&t.startsWith("0x")?BigInt(t).toString(10):t,B$1=t=>t&&t.startsWith("0x")?t:`0x${BigInt(t).toString(16)}`,Se$1=t=>Object.keys(t).filter(e=>$t.includes(e)).reduce((e,s)=>(e[s]=Et(t[s]),e),{}),Et=t=>typeof t=="string"&&Pt(t)?JSON.parse(t):t,Ct=(t,e,s)=>{const{sessionProperties:i={},scopedProperties:r={}}=t,a={};if(!Ye$2(r)&&!Ye$2(i))return;const n=Se$1(i);for(const c of s){const o=At(c);if(!o)continue;a[B$1(o)]=n;const h=r?.[`${Ie}:${o}`];if(h){const l=h?.[`${Ie}:${o}:${e}`];a[B$1(o)]=Oe$1(Oe$1({},a[B$1(o)]),Se$1(l||h));}}for(const[c,o]of Object.entries(a))Object.keys(o).length===0&&delete a[c];return Object.keys(a).length>0?a:void 0};var jt=Object.defineProperty,Nt=(t,e,s)=>e in t?jt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,qt=(t,e,s)=>Nt(t,e+"",s);let L$1;let J$1 = class J{constructor(e){qt(this,"storage"),this.storage=e;}async getItem(e){return await this.storage.getItem(e)}async setItem(e,s){return await this.storage.setItem(e,s)}async removeItem(e){return await this.storage.removeItem(e)}static getStorage(e){return L$1||(L$1=new J(e)),L$1}};var Dt=Object.defineProperty,Rt=Object.defineProperties,_t=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Ae$1=(t,e,s)=>e in t?Dt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,Ht=(t,e)=>{for(var s in e||(e={}))xt.call(e,s)&&Ae$1(t,s,e[s]);if($e)for(var s of $e(e))Ft.call(e,s)&&Ae$1(t,s,e[s]);return t},Ut=(t,e)=>Rt(t,_t(e));async function Bt(t,e){const s=Je$2(t.result.capabilities.caip345.caip2),i=t.result.capabilities.caip345.transactionHashes,r=await Promise.allSettled(i.map(p=>Lt(s.reference,p,e))),a=r.filter(p=>p.status==="fulfilled").map(p=>p.value).filter(p=>p);r.filter(p=>p.status==="rejected").forEach(p=>console.warn("Failed to fetch transaction receipt:",p.reason));const n=!a.length||a.some(p=>!p),c=a.every(p=>p?.status==="0x1"),o=a.every(p=>p?.status==="0x0"),h=a.some(p=>p?.status==="0x0");let l;return n?l=100:c?l=200:o?l=500:h&&(l=600),{id:t.result.id,version:t.request.version,atomic:t.request.atomicRequired,chainId:t.request.chainId,capabilities:t.result.capabilities,receipts:a,status:l}}async function Lt(t,e,s){return await s(parseInt(t)).request(formatJsonRpcRequest("eth_getTransactionReceipt",[e]))}async function Mt({sendCalls:t,storage:e}){const s=await e.getItem(v);await e.setItem(v,Ut(Ht({},s),{[t.result.id]:{request:t.request,result:t.result,expiry:Ni$1(ut)}}));}async function zt({resultId:t,storage:e}){const s=await e.getItem(v);if(s){delete s[t],await e.setItem(v,s);for(const i in s)Ui$1(s[i].expiry)&&delete s[i];await e.setItem(v,s);}}async function Gt({resultId:t,storage:e}){const s=await e.getItem(v),i=s?.[t];if(i&&!Ui$1(i.expiry))return i;await zt({resultId:t,storage:e});}var Wt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Ee$1=Object.getOwnPropertySymbols,Vt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,M=(t,e,s)=>e in t?Wt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,z$1=(t,e)=>{for(var s in e||(e={}))Vt.call(e,s)&&M(t,s,e[s]);if(Ee$1)for(var s of Ee$1(e))Yt.call(e,s)&&M(t,s,e[s]);return t},G$1=(t,e)=>Jt(t,Kt(e)),g=(t,e,s)=>M(t,typeof e!="symbol"?e+"":e,s);class Xt{constructor(e){g(this,"name","eip155"),g(this,"client"),g(this,"chainId"),g(this,"namespace"),g(this,"httpProviders"),g(this,"events"),g(this,"storage"),this.namespace=e.namespace,this.events=w("events"),this.client=w("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=J$1.getStorage(this.client.core.storage);}async request(e){switch(e.request.method){case "eth_requestAccounts":return this.getAccounts();case "eth_accounts":return this.getAccounts();case "wallet_switchEthereumChain":return await this.handleSwitchChain(e);case "eth_chainId":return parseInt(this.getDefaultChain());case "wallet_getCapabilities":return await this.getCapabilities(e);case "wallet_getCallsStatus":return await this.getCallStatus(e);case "wallet_sendCalls":return await this.sendCalls(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e);}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s);const i=this.chainId;this.chainId=parseInt(e),this.events.emit(F.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${i}`});}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,s){const i=s||de$1(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new o$1(new f(i,w("disableProviderPing")))}setHttpProvider(e,s){const i=this.createHttpProvider(e,s);i&&(this.httpProviders[e]=i);}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var i;const r=parseInt(wt(s));e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[s]);}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(e){const s=e||this.chainId;return this.httpProviders[s]||(this.httpProviders=G$1(z$1({},this.httpProviders),{[s]:this.createHttpProvider(s)}),this.httpProviders[s])}async handleSwitchChain(e){var s,i;let r=e.request.params?(s=e.request.params[0])==null?void 0:s.chainId:"0x0";r=r.startsWith("0x")?r:`0x${r}`;const a=parseInt(r,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:r}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var s,i,r,a,n;const c=(i=(s=e.request)==null?void 0:s.params)==null?void 0:i[0],o=((a=(r=e.request)==null?void 0:r.params)==null?void 0:a[1])||[];if(!c)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(e.topic),l=((n=h?.sessionProperties)==null?void 0:n.capabilities)||{},p=`${c}${o.join(",")}`,f=l?.[p];if(f)return f;let u;try{u=Ct(h,c,o);}catch(q){console.warn("Failed to extract capabilities from session",q);}if(u)return u;const K=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:G$1(z$1({},h.sessionProperties||{}),{capabilities:G$1(z$1({},l||{}),{[p]:K})})});}catch(q){console.warn("Failed to update session with capabilities",q);}return K}async getCallStatus(e){var s,i,r;const a=this.client.session.get(e.topic),n=(s=a.sessionProperties)==null?void 0:s.bundler_name;if(n){const h=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(h,e)}catch(l){console.warn("Failed to fetch call status from bundler",l,h);}}const c=(i=a.sessionProperties)==null?void 0:i.bundler_url;if(c)try{return await this.getUserOperationReceipt(c,e)}catch(h){console.warn("Failed to fetch call status from custom bundler",h,c);}const o=await Gt({resultId:(r=e.request.params)==null?void 0:r[0],storage:this.storage});if(o)try{return await Bt(o,this.getHttpProvider.bind(this))}catch(h){console.warn("Failed to fetch call status from stored send calls",h,o);}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,s){var i;const r=new URL(e),a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(formatJsonRpcRequest("eth_getUserOperationReceipt",[(i=s.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,s){return `${lt}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}async sendCalls(e){var s,i,r;const a=await this.client.request(e),n=(s=e.request.params)==null?void 0:s[0],c=a?.id,o=a?.capabilities||{},h=(i=o?.caip345)==null?void 0:i.caip2,l=(r=o?.caip345)==null?void 0:r.transactionHashes;return !c||!h||!(l!=null&&l.length)||await Mt({sendCalls:{request:n,result:a},storage:this.storage}),a}}var kt=Object.defineProperty,Qt=(t,e,s)=>e in t?kt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,b=(t,e,s)=>Qt(t,typeof e!="symbol"?e+"":e,s);class Zt{constructor(e){b(this,"name",he$1),b(this,"client"),b(this,"httpProviders"),b(this,"events"),b(this,"namespace"),b(this,"chainId"),this.namespace=e.namespace,this.events=w("events"),this.client=w("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),this.httpProviders=this.createHttpProviders();}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders();}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s);const i=this.chainId;this.chainId=e,this.events.emit(F.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${i}`});}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getNamespaceName(){const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return Je$2(e).namespace}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var e,s;const i={};return (s=(e=this.namespace)==null?void 0:e.accounts)==null||s.forEach(r=>{var a,n;const c=Je$2(r),o=(n=(a=this.namespace)==null?void 0:a.rpcMap)==null?void 0:n[`${c.namespace}:${c.reference}`];i[c.reference]=this.createHttpProvider(r,o);}),i}getHttpProvider(e){const s=Je$2(e).reference,i=this.httpProviders[s];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,s){const i=this.createHttpProvider(e,s);i&&(this.httpProviders[e]=i);}createHttpProvider(e,s){const i=s||de$1(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new o$1(new f(i,w("disableProviderPing")))}}var Tt=Object.defineProperty,es=Object.defineProperties,ts=Object.getOwnPropertyDescriptors,Ce$1=Object.getOwnPropertySymbols,ss=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,W=(t,e,s)=>e in t?Tt(t,e,{enumerable:true,configurable:true,writable:true,value:s}):t[e]=s,S=(t,e)=>{for(var s in e||(e={}))ss.call(e,s)&&W(t,s,e[s]);if(Ce$1)for(var s of Ce$1(e))is.call(e,s)&&W(t,s,e[s]);return t},j=(t,e)=>es(t,ts(e)),d=(t,e,s)=>W(t,typeof e!="symbol"?e+"":e,s);let N$1 = class N{constructor(e){d(this,"client"),d(this,"namespaces"),d(this,"optionalNamespaces"),d(this,"sessionProperties"),d(this,"scopedProperties"),d(this,"events",new xe$3),d(this,"rpcProviders",{}),d(this,"session"),d(this,"providerOpts"),d(this,"logger"),d(this,"uri"),d(this,"disableProviderPing",false);var s,i;this.providerOpts=e,this.logger=wu({logger:(s=e.logger)!=null?s:ce$1,name:(i=this.providerOpts.name)!=null?i:oe$1}),this.disableProviderPing=e?.disableProviderPing||false;}static async init(e){const s=new N(e);return await s.initialize(),s}async request(e,s,i){const[r,a]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:S({},e),chainId:`${r}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,s,i,r){const a=new Date().getTime();this.request(e,i,r).then(n=>s(null,formatJsonRpcResult(a,n))).catch(n=>s(n,void 0));}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:zt$2("USER_DISCONNECTED")}),await this.cleanup();}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:r}=await this.client.authenticate(e,s);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await r();if(this.session=a.session,this.session){const n=ve$1(this.session.namespaces);this.namespaces=C(this.namespaces,n),await this.persist("namespaces",this.namespaces),this.onConnect();}return a}on(e,s){this.events.on(e,s);}once(e,s){this.events.once(e,s);}removeListener(e,s){this.events.removeListener(e,s);}off(e,s){this.events.off(e,s);}get isWalletConnect(){return true}async pair(e){const{uri:s,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});s&&(this.uri=s,this.events.emit("display_uri",s));const r=await i();this.session=r;const a=ve$1(r.namespaces);return this.namespaces=C(this.namespaces,a),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[i,r]=this.validateChain(e);this.getProvider(i).setDefaultChain(r,s);}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){try{this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(!Ee$2(s))return;for(const i of s)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`);}catch(s){this.logger.warn(s,"Failed to cleanup pending pairings");}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.");}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders();}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners();}async createClient(){var e,s;if(this.client=this.providerOpts.client||await Qs.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ce$1,relayUrl:this.providerOpts.relayUrl||pt,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic);}catch(i){throw this.logger.error(i,"Failed to get session"),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else {const i=this.client.session.getAll();this.session=i[0];}this.logger.trace("SignClient Initialized");}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(s=>bs$1(s)))];U("client",this.client),U("events",this.events),U("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const i=bt(s,this.session);if(i?.length===0)return;const r=fe$1(i),a=C(this.namespaces,this.optionalNamespaces),n=j(S({},a[s]),{accounts:i,chains:r});switch(s){case "eip155":this.rpcProviders[s]=new Xt({namespace:n});break;default:this.rpcProviders[s]=new Zt({namespace:n});}});}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var s;const{topic:i}=e;i===((s=this.session)==null?void 0:s.topic)&&this.events.emit("session_ping",e);}),this.client.on("session_event",e=>{var s;const{params:i,topic:r}=e;if(r!==((s=this.session)==null?void 0:s.topic))return;const{event:a}=i;if(a.name==="accountsChanged"){const n=a.data;n&&Ee$2(n)&&this.events.emit("accountsChanged",n.map(ye$1));}else if(a.name==="chainChanged"){const n=i.chainId,c=i.event.data,o=bs$1(n),h=H$1(n)!==H$1(c)?`${o}:${H$1(c)}`:n;this.onChainChanged({currentCaipChainId:h});}else this.events.emit(a.name,a.data);this.events.emit("session_event",e);}),this.client.on("session_update",({topic:e,params:s})=>{var i,r;if(e!==((i=this.session)==null?void 0:i.topic))return;const{namespaces:a}=s,n=(r=this.client)==null?void 0:r.session.get(e);this.session=j(S({},n),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s});}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",j(S({},zt$2("USER_DISCONNECTED")),{data:e.topic})));}),this.on(F.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(j(S({},e),{internal:true}));});}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[he$1]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e]);});}setNamespaces(e){const{namespaces:s={},optionalNamespaces:i={},sessionProperties:r,scopedProperties:a}=e;this.optionalNamespaces=C(s,i),this.sessionProperties=r,this.scopedProperties=a;}validateChain(e){const[s,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return [s,i];if(s&&!Object.keys(this.namespaces||{}).map(n=>bs$1(n)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&i)return [s,i];const r=bs$1(Object.keys(this.namespaces)[0]),a=this.rpcProviders[r].getDefaultChain();return [r,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged({currentCaipChainId:e,previousCaipChainId:s,internal:i=false}){if(!this.namespaces)return;const[r,a]=this.validateChain(e);a&&(this.updateNamespaceChain(r,a),i?(this.events.emit("chainChanged",a),this.emitAccountsChangedOnChainChange({namespace:r,currentCaipChainId:e,previousCaipChainId:s})):this.getProvider(r).setDefaultChain(a),await this.persist("namespaces",this.namespaces));}emitAccountsChangedOnChainChange({namespace:e,currentCaipChainId:s,previousCaipChainId:i}){var r,a;try{if(i===s)return;const n=(a=(r=this.session)==null?void 0:r.namespaces[e])==null?void 0:a.accounts;if(!n)return;const c=n.filter(o=>o.includes(`${s}:`)).map(ye$1);if(!Ee$2(c))return;this.events.emit("accountsChanged",c);}catch(n){this.logger.warn(n,"Failed to emit accountsChanged on chain change");}}updateNamespaceChain(e,s){if(!this.namespaces)return;const i=this.namespaces[e]?e:`${e}:${s}`,r={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[i]?this.namespaces[i]&&(this.namespaces[i].defaultChain=s):this.namespaces[i]=r;}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session});}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:true}),await this.cleanupStorage();}async persist(e,s){var i;const r=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${A}/${e}${r}`,s);}async getFromStore(e){var s;const i=((s=this.session)==null?void 0:s.topic)||"";return await this.client.core.storage.getItem(`${A}/${e}${i}`)}async deleteFromStore(e){var s;const i=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${A}/${e}${i}`);}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const i of s)i.startsWith(A)&&await this.client.core.storage.removeItem(i);}catch(s){this.logger.warn(s,"Failed to cleanup storage");}}};const ns=N$1;
|
|
30696
31984
|
|
|
30697
|
-
const R=e=>{let t,{get:s,on:i}=getWallets(),n=true,a=new W$5(new Ce,n),r=new Map,o=[];function l(...e){e.forEach((e=>{!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet||r.has(e.name))&&e.chains.some((e=>"string"==typeof e&&e.startsWith("solana:")))&&r.set(e.name,e);})),o=Array.from(r.values()).map((e=>new W$5(e,n))).concat(a),t?.(o);}function c(...e){Array.from(r.values()).forEach((t=>!e.includes(t)&&r.delete(t.name))),o=Array.from(r.values()).map((e=>new W$5(e,n))).concat(a),t?.(o);}let d=[i("register",l),i("unregister",c)];return l(...s()),{_setOnConnectorsUpdated:e=>{t=e;},onMount:()=>{d[0]||(d[0]=i("register",l)),d[1]||(d[1]=i("unregister",c));},onUnmount:()=>{let e=d.pop();for(;e;)e(),e=d.pop();},get:()=>o}};function K(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var q=0;function V(e){return "__private_"+q+++"_"+e}var D=/*#__PURE__*/V("_address"),I=/*#__PURE__*/V("_publicKey"),z=/*#__PURE__*/V("_chains"),B=/*#__PURE__*/V("_features"),J=/*#__PURE__*/V("_label"),N=/*#__PURE__*/V("_icon");class L{get address(){return K(this,D)[D]}get publicKey(){return K(this,I)[I].slice()}get chains(){return K(this,z)[z].slice()}get features(){return K(this,B)[B].slice()}get label(){return K(this,J)[J]}get icon(){return K(this,N)[N]}constructor({address:e,publicKey:t,label:s,icon:i}){Object.defineProperty(this,D,{writable:true,value:void 0}),Object.defineProperty(this,I,{writable:true,value:void 0}),Object.defineProperty(this,z,{writable:true,value:void 0}),Object.defineProperty(this,B,{writable:true,value:void 0}),Object.defineProperty(this,J,{writable:true,value:void 0}),Object.defineProperty(this,N,{writable:true,value:void 0}),K(this,D)[D]=e,K(this,I)[I]=t,K(this,z)[z]=P$7,K(this,B)[B]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],K(this,J)[J]=s,K(this,N)[N]=i;}}function Y(e){if("string"==typeof e)return base58$1.decode(e);if(e instanceof Uint8Array)return e;let t=e.signature;return "string"==typeof t?base58$1.decode(t):t}function $(e){if("string"==typeof e){try{return base58$1.decode(e)}catch{}return base64$2.decode(e)}if(e instanceof Uint8Array)return e;let t=e.transaction;if("string"==typeof t){try{return base58$1.decode(t)}catch{}return base64$2.decode(t)}return t}function Z(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var G=0;function H(e){return "__private_"+G+++"_"+e}let Q="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",X="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";var ee=/*#__PURE__*/H("_listeners"),te=/*#__PURE__*/H("_version"),se=/*#__PURE__*/H("_name"),ie=/*#__PURE__*/H("_icon"),ne=/*#__PURE__*/H("_provider"),ae=/*#__PURE__*/H("_accounts"),re=/*#__PURE__*/H("_privyAppName"),oe=/*#__PURE__*/H("_walletConnectCloudProjectId"),le=/*#__PURE__*/H("_walletEntry"),ce=/*#__PURE__*/H("_onDisplayUriCallback"),de=/*#__PURE__*/H("_providerEventListeners"),he=/*#__PURE__*/H("_on"),ue=/*#__PURE__*/H("_emit"),pe=/*#__PURE__*/H("_off"),fe=/*#__PURE__*/H("_connected"),ge=/*#__PURE__*/H("_disconnected"),ve=/*#__PURE__*/H("_connect"),me=/*#__PURE__*/H("_disconnect"),ye=/*#__PURE__*/H("_signMessage"),we=/*#__PURE__*/H("_signAndSendTransaction"),be=/*#__PURE__*/H("_signTransaction"),je=/*#__PURE__*/H("_getOrCreateProvider"),_e=/*#__PURE__*/H("_getOrCreateSession"),Pe=/*#__PURE__*/H("_restoreSession"),Oe=/*#__PURE__*/H("_addProviderEventListener"),Se=/*#__PURE__*/H("_destroySession"),Te=/*#__PURE__*/H("_makeRpcRequest"),We=/*#__PURE__*/H("_onDisplayUri"),Ae=/*#__PURE__*/H("_onSessionDelete");class Ce{get version(){return Z(this,te)[te]}get name(){return Z(this,se)[se]}get icon(){return Z(this,ie)[ie]}get chains(){return P$7.slice()}get features(){return {"standard:connect":{version:"1.0.0",connect:Z(this,ve)[ve]},"standard:disconnect":{version:"1.0.0",disconnect:Z(this,me)[me]},"standard:events":{version:"1.0.0",on:Z(this,he)[he]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:Z(this,we)[we]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:Z(this,be)[be]},"solana:signMessage":{version:"1.0.0",signMessage:Z(this,ye)[ye]}}}get accounts(){return Z(this,ae)[ae].slice()}get isWalletConnectSolana(){return true}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){Z(this,oe)[oe]=e,Z(this,re)[re]=t,await Z(this,je)[je](),await Z(this,Pe)[Pe]();}setWalletEntry(e,t){Z(this,le)[le]=e,Z(this,ce)[ce]=t;}constructor(){Object.defineProperty(this,ue,{value:Ee}),Object.defineProperty(this,pe,{value:Me}),Object.defineProperty(this,ee,{writable:true,value:void 0}),Object.defineProperty(this,te,{writable:true,value:void 0}),Object.defineProperty(this,se,{writable:true,value:void 0}),Object.defineProperty(this,ie,{writable:true,value:void 0}),Object.defineProperty(this,ne,{writable:true,value:void 0}),Object.defineProperty(this,ae,{writable:true,value:void 0}),Object.defineProperty(this,re,{writable:true,value:void 0}),Object.defineProperty(this,oe,{writable:true,value:void 0}),Object.defineProperty(this,le,{writable:true,value:void 0}),Object.defineProperty(this,ce,{writable:true,value:void 0}),Object.defineProperty(this,de,{writable:true,value:void 0}),Object.defineProperty(this,he,{writable:true,value:void 0}),Object.defineProperty(this,fe,{writable:true,value:void 0}),Object.defineProperty(this,ge,{writable:true,value:void 0}),Object.defineProperty(this,ve,{writable:true,value:void 0}),Object.defineProperty(this,me,{writable:true,value:void 0}),Object.defineProperty(this,ye,{writable:true,value:void 0}),Object.defineProperty(this,we,{writable:true,value:void 0}),Object.defineProperty(this,be,{writable:true,value:void 0}),Object.defineProperty(this,je,{writable:true,value:void 0}),Object.defineProperty(this,_e,{writable:true,value:void 0}),Object.defineProperty(this,Pe,{writable:true,value:void 0}),Object.defineProperty(this,Oe,{writable:true,value:void 0}),Object.defineProperty(this,Se,{writable:true,value:void 0}),Object.defineProperty(this,Te,{writable:true,value:void 0}),Object.defineProperty(this,We,{writable:true,value:void 0}),Object.defineProperty(this,Ae,{writable:true,value:void 0}),Z(this,ee)[ee]={},Z(this,te)[te]="1.0.0",Z(this,se)[se]="WalletConnect",Z(this,ie)[ie]=U$5,Z(this,ne)[ne]=null,Z(this,ae)[ae]=[],Z(this,re)[re]="",Z(this,oe)[oe]="",Z(this,de)[de]=new Map,Z(this,he)[he]=(e,t)=>(Z(this,ee)[ee][e]?.push(t)||(Z(this,ee)[ee][e]=[t]),()=>Z(this,pe)[pe](e,t)),Z(this,fe)[fe]=e=>{Z(this,se)[se]=Z(this,ne)[ne]?.session?.peer?.metadata?.name||Z(this,le)[le]?.name||"WalletConnect",Z(this,ie)[ie]=Z(this,ne)[ne]?.session?.peer?.metadata?.icons?.[0]||Z(this,le)[le]?.image_url?.sm||Z(this,ie)[ie],Z(this,ae)[ae]=e.map((e=>new L({address:e,publicKey:base58$1.decode(e),label:Z(this,se)[se],icon:Z(this,ie)[ie]}))),Z(this,ue)[ue]("change",{accounts:this.accounts});},Z(this,ge)[ge]=()=>{Z(this,ae)[ae]=[],Z(this,ue)[ue]("change",{accounts:this.accounts});},Z(this,ve)[ve]=async()=>(this.accounts.length||await Z(this,_e)[_e](),{accounts:this.accounts}),Z(this,me)[me]=async()=>{await Z(this,Se)[Se](),Z(this,ue)[ue]("change",{accounts:this.accounts});},Z(this,ye)[ye]=async(...e)=>{let t=[];for(let{account:s,message:i}of e){let e=base58$1.encode(i);try{let n=await Z(this,Te)[Te]("solana_signMessage",{message:e,pubkey:s.address},Ue("solana:mainnet"));t.push({signedMessage:i,signature:Y(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await Z(this,Te)[Te]("solana:signMessage",{message:e,pubkey:s.address},Ue("solana:mainnet"));t.push({signedMessage:i,signature:Y(n)});}throw n}}return t},Z(this,we)[we]=async(...e)=>{let t=[];for(let{account:s,chain:i,transaction:n,options:a}of e){let e=base64$2.encode(n);try{let n=await Z(this,Te)[Te]("solana_signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Ue(i));t.push({signature:Y(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await Z(this,Te)[Te]("solana:signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Ue(i));t.push({signature:Y(n)});}}}return t},Z(this,be)[be]=async(...e)=>{let t=[];for(let{account:s,chain:i,transaction:n}of e){let e=base64$2.encode(n);try{let n=await Z(this,Te)[Te]("solana_signTransaction",{transaction:e,pubkey:s.address},Ue(i||"solana:mainnet"));t.push({signedTransaction:$(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await Z(this,Te)[Te]("solana:signTransaction",{transaction:e,pubkey:s.address},Ue(i||"solana:mainnet"));t.push({signedTransaction:$(n)});}}}return t},Z(this,je)[je]=async()=>{if(Z(this,ne)[ne])return Z(this,ne)[ne];if(!Z(this,oe)[oe])throw Error("WalletConnect Cloud Project ID is required");return Z(this,ne)[ne]=await ns.init({projectId:Z(this,oe)[oe],metadata:{name:Z(this,re)[re],description:Z(this,re)[re],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:false}),Z(this,Oe)[Oe]("display_uri",Z(this,We)[We]),Z(this,Oe)[Oe]("session_delete",Z(this,Ae)[Ae]),Z(this,Oe)[Oe]("session_ping",(()=>{})),Z(this,Oe)[Oe]("session_event",(()=>{})),Z(this,Oe)[Oe]("session_update",(()=>{})),Z(this,ne)[ne]},Z(this,_e)[_e]=async()=>{if(!Z(this,ne)[ne])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(Z(this,ne)[ne].session)return Z(this,ne)[ne].session;let e=await Z(this,ne)[ne].connect({optionalNamespaces:{solana:{chains:[Q,X],methods:["solana_signMessage","solana_signTransaction","solana_signAndSendTransaction"],events:[]}}});if(!e)throw Error("WalletConnectSolana: Failed to create new session");return Z(this,fe)[fe](ke(e)),e},Z(this,Pe)[Pe]=async()=>{let e=Z(this,ne)[ne]?.session;if(e){if(!e.namespaces?.solana)return await(Z(this,ne)[ne]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(Z(this,ne)[ne].session=void 0);Z(this,fe)[fe](ke(e));}},Z(this,Oe)[Oe]=(e,t)=>{let s=Z(this,de)[de].get(e);s&&(Z(this,ne)[ne]?.off(e,s),Z(this,de)[de].delete(e)),Z(this,ne)[ne]?.on(e,t),Z(this,de)[de].set(e,t);},Z(this,Se)[Se]=async()=>{try{if(Z(this,ne)[ne]?.session&&await(Z(this,ne)[ne]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),Z(this,ne)[ne]?.client){let e=Z(this,ne)[ne].client.proposal.getAll();await Promise.allSettled(e.map((e=>Z(this,ne)[ne]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=Z(this,ne)[ne].client.pairing.getAll();await Promise.allSettled(t.map((e=>Z(this,ne)[ne]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))));}Z(this,ge)[ge]();}catch(e){console.error("WalletConnectSolana: Error destroying session",e);}},Z(this,Te)[Te]=async(e,t,s)=>{try{return await Z(this,ne)[ne].request({method:e,params:t},s)}catch(t){if(console.error(`WalletConnectSolana: RPC Error - ${e}:`,t),t?.message?.includes("without any listeners")&&t.result)return t.result;if(t?.message?.includes("session topic does not exist in keychain"))throw Error("WalletConnectSolana: Wallet connection lost. Please reconnect.");throw t}},Z(this,We)[We]=e=>{null==Z(this,ce)[ce]||Z(this,ce)[ce].call(this,{native:e,universal:void 0});},Z(this,Ae)[Ae]=()=>{Z(this,ge)[ge]();};}}function Ee(e,...t){Z(this,ee)[ee][e]?.forEach((e=>e.apply(null,t)));}function Me(e,t){Z(this,ee)[ee][e]=Z(this,ee)[ee][e]?.filter((e=>t!==e));}function ke(e){return e.namespaces.solana.accounts.reduce(((e,t)=>{let s=t.split(":").at(-1);return e.includes(s)||e.push(s),e}),[])}function Ue(e){switch(e){case "solana:mainnet":return Q;case "solana:devnet":return X;default:return e}}
|
|
31985
|
+
const q=e=>{let t,{get:s,on:i}=getWallets(),n=true,a=new F$2(new Me,n),r=new Map,o=[];function l(...e){e.forEach((e=>{!(e.features["privy:"]&&"isPrivyWallet"in e&&e.isPrivyWallet||r.has(e.name))&&e.chains.some((e=>"string"==typeof e&&e.startsWith("solana:")))&&r.set(e.name,e);})),o=Array.from(r.values()).map((e=>new F$2(e,n))).concat(a),t?.(o);}function c(...e){Array.from(r.values()).forEach((t=>!e.includes(t)&&r.delete(t.name))),o=Array.from(r.values()).map((e=>new F$2(e,n))).concat(a),t?.(o);}let d=[i("register",l),i("unregister",c)];return l(...s()),{_setOnConnectorsUpdated:e=>{t=e;},onMount:()=>{d[0]||(d[0]=i("register",l)),d[1]||(d[1]=i("unregister",c));},onUnmount:()=>{let e=d.pop();for(;e;)e(),e=d.pop();},get:()=>o}};function V(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var I=0;function D(e){return "__private_"+I+++"_"+e}var z=/*#__PURE__*/D("_address"),B=/*#__PURE__*/D("_publicKey"),J=/*#__PURE__*/D("_chains"),N=/*#__PURE__*/D("_features"),L=/*#__PURE__*/D("_label"),Y=/*#__PURE__*/D("_icon");class H{get address(){return V(this,z)[z]}get publicKey(){return V(this,B)[B].slice()}get chains(){return V(this,J)[J].slice()}get features(){return V(this,N)[N].slice()}get label(){return V(this,L)[L]}get icon(){return V(this,Y)[Y]}constructor({address:e,publicKey:t,label:s,icon:i}){Object.defineProperty(this,z,{writable:true,value:void 0}),Object.defineProperty(this,B,{writable:true,value:void 0}),Object.defineProperty(this,J,{writable:true,value:void 0}),Object.defineProperty(this,N,{writable:true,value:void 0}),Object.defineProperty(this,L,{writable:true,value:void 0}),Object.defineProperty(this,Y,{writable:true,value:void 0}),V(this,z)[z]=e,V(this,B)[B]=t,V(this,J)[J]=P$7,V(this,N)[N]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],V(this,L)[L]=s,V(this,Y)[Y]=i;}}function G(e){if("string"==typeof e)return base58$1.decode(e);if(e instanceof Uint8Array)return e;let t=e.signature;return "string"==typeof t?base58$1.decode(t):t}function Z(e){if("string"==typeof e){try{return base58$1.decode(e)}catch{}return base64$2.decode(e)}if(e instanceof Uint8Array)return e;let t=e.transaction??e.signature;if(!t)throw Error("Invalid result from signTransaction or signAndSendTransaction attempt");if("string"==typeof t){try{return base58$1.decode(t)}catch{}return base64$2.decode(t)}return t}function $(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Q=0;function X(e){return "__private_"+Q+++"_"+e}let ee="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",te="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";var se=/*#__PURE__*/X("_listeners"),ie=/*#__PURE__*/X("_version"),ne=/*#__PURE__*/X("_name"),ae=/*#__PURE__*/X("_icon"),re=/*#__PURE__*/X("_provider"),oe=/*#__PURE__*/X("_accounts"),le=/*#__PURE__*/X("_privyAppName"),ce=/*#__PURE__*/X("_walletConnectCloudProjectId"),de=/*#__PURE__*/X("_walletEntry"),he=/*#__PURE__*/X("_onDisplayUriCallback"),ue=/*#__PURE__*/X("_providerEventListeners"),pe=/*#__PURE__*/X("_on"),fe=/*#__PURE__*/X("_emit"),ge=/*#__PURE__*/X("_off"),ve=/*#__PURE__*/X("_connected"),me=/*#__PURE__*/X("_disconnected"),ye=/*#__PURE__*/X("_connect"),we=/*#__PURE__*/X("_disconnect"),be=/*#__PURE__*/X("_signMessage"),je=/*#__PURE__*/X("_signAndSendTransaction"),_e=/*#__PURE__*/X("_signTransaction"),Pe=/*#__PURE__*/X("_getOrCreateProvider"),Oe=/*#__PURE__*/X("_getOrCreateSession"),Se=/*#__PURE__*/X("_restoreSession"),Te=/*#__PURE__*/X("_addProviderEventListener"),Ae=/*#__PURE__*/X("_destroySession"),We=/*#__PURE__*/X("_makeRpcRequest"),Ce=/*#__PURE__*/X("_onDisplayUri"),Ee=/*#__PURE__*/X("_onSessionDelete");class Me{get version(){return $(this,ie)[ie]}get name(){return $(this,ne)[ne]}get icon(){return $(this,ae)[ae]}get chains(){return P$7.slice()}get features(){return {"standard:connect":{version:"1.0.0",connect:$(this,ye)[ye]},"standard:disconnect":{version:"1.0.0",disconnect:$(this,we)[we]},"standard:events":{version:"1.0.0",on:$(this,pe)[pe]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:$(this,je)[je]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:$(this,_e)[_e]},"solana:signMessage":{version:"1.0.0",signMessage:$(this,be)[be]}}}get accounts(){return $(this,oe)[oe].slice()}get isWalletConnectSolana(){return true}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){$(this,ce)[ce]=e,$(this,le)[le]=t,await $(this,Pe)[Pe](),await $(this,Se)[Se]();}setWalletEntry(e,t){$(this,de)[de]=e,$(this,he)[he]=t;}constructor(){Object.defineProperty(this,fe,{value:ke}),Object.defineProperty(this,ge,{value:Ue}),Object.defineProperty(this,se,{writable:true,value:void 0}),Object.defineProperty(this,ie,{writable:true,value:void 0}),Object.defineProperty(this,ne,{writable:true,value:void 0}),Object.defineProperty(this,ae,{writable:true,value:void 0}),Object.defineProperty(this,re,{writable:true,value:void 0}),Object.defineProperty(this,oe,{writable:true,value:void 0}),Object.defineProperty(this,le,{writable:true,value:void 0}),Object.defineProperty(this,ce,{writable:true,value:void 0}),Object.defineProperty(this,de,{writable:true,value:void 0}),Object.defineProperty(this,he,{writable:true,value:void 0}),Object.defineProperty(this,ue,{writable:true,value:void 0}),Object.defineProperty(this,pe,{writable:true,value:void 0}),Object.defineProperty(this,ve,{writable:true,value:void 0}),Object.defineProperty(this,me,{writable:true,value:void 0}),Object.defineProperty(this,ye,{writable:true,value:void 0}),Object.defineProperty(this,we,{writable:true,value:void 0}),Object.defineProperty(this,be,{writable:true,value:void 0}),Object.defineProperty(this,je,{writable:true,value:void 0}),Object.defineProperty(this,_e,{writable:true,value:void 0}),Object.defineProperty(this,Pe,{writable:true,value:void 0}),Object.defineProperty(this,Oe,{writable:true,value:void 0}),Object.defineProperty(this,Se,{writable:true,value:void 0}),Object.defineProperty(this,Te,{writable:true,value:void 0}),Object.defineProperty(this,Ae,{writable:true,value:void 0}),Object.defineProperty(this,We,{writable:true,value:void 0}),Object.defineProperty(this,Ce,{writable:true,value:void 0}),Object.defineProperty(this,Ee,{writable:true,value:void 0}),$(this,se)[se]={},$(this,ie)[ie]="1.0.0",$(this,ne)[ne]="WalletConnect",$(this,ae)[ae]=_$4,$(this,re)[re]=null,$(this,oe)[oe]=[],$(this,le)[le]="",$(this,ce)[ce]="",$(this,ue)[ue]=new Map,$(this,pe)[pe]=(e,t)=>($(this,se)[se][e]?.push(t)||($(this,se)[se][e]=[t]),()=>$(this,ge)[ge](e,t)),$(this,ve)[ve]=e=>{$(this,ne)[ne]=$(this,re)[re]?.session?.peer?.metadata?.name||$(this,de)[de]?.name||"WalletConnect",$(this,ae)[ae]=$(this,re)[re]?.session?.peer?.metadata?.icons?.[0]||$(this,de)[de]?.image_url?.sm||$(this,ae)[ae],$(this,oe)[oe]=e.map((e=>new H({address:e,publicKey:base58$1.decode(e),label:$(this,ne)[ne],icon:$(this,ae)[ae]}))),$(this,fe)[fe]("change",{accounts:this.accounts});},$(this,me)[me]=()=>{$(this,oe)[oe]=[],$(this,fe)[fe]("change",{accounts:this.accounts});},$(this,ye)[ye]=async()=>(this.accounts.length||await $(this,Oe)[Oe](),{accounts:this.accounts}),$(this,we)[we]=async()=>{await $(this,Ae)[Ae](),$(this,fe)[fe]("change",{accounts:this.accounts});},$(this,be)[be]=async(...e)=>{let t=[];for(let{account:s,message:i}of e){let e=base58$1.encode(i);try{let n=await $(this,We)[We]("solana_signMessage",{message:e,pubkey:s.address},Fe("solana:mainnet"));t.push({signedMessage:i,signature:G(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await $(this,We)[We]("solana:signMessage",{message:e,pubkey:s.address},Fe("solana:mainnet"));t.push({signedMessage:i,signature:G(n)});}throw n}}return t},$(this,je)[je]=async(...e)=>{let t=[];for(let{account:s,chain:i,transaction:n,options:a}of e){let e=base64$2.encode(n);try{let n=await $(this,We)[We]("solana_signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Fe(i));t.push({signature:G(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await $(this,We)[We]("solana:signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Fe(i));t.push({signature:G(n)});}}}return t},$(this,_e)[_e]=async(...e)=>{let t=[];for(let{account:s,chain:i,transaction:n}of e){let e=base64$2.encode(n);try{let n=await $(this,We)[We]("solana_signTransaction",{transaction:e,pubkey:s.address},Fe(i||"solana:mainnet"));t.push({signedTransaction:Z(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await $(this,We)[We]("solana:signTransaction",{transaction:e,pubkey:s.address},Fe(i||"solana:mainnet"));t.push({signedTransaction:Z(n)});}}}return t},$(this,Pe)[Pe]=async()=>{if($(this,re)[re])return $(this,re)[re];if(!$(this,ce)[ce])throw Error("WalletConnect Cloud Project ID is required");return $(this,re)[re]=await ns.init({projectId:$(this,ce)[ce],metadata:{name:$(this,le)[le],description:$(this,le)[le],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:false}),$(this,Te)[Te]("display_uri",$(this,Ce)[Ce]),$(this,Te)[Te]("session_delete",$(this,Ee)[Ee]),$(this,Te)[Te]("session_ping",(()=>{})),$(this,Te)[Te]("session_event",(()=>{})),$(this,Te)[Te]("session_update",(()=>{})),$(this,re)[re]},$(this,Oe)[Oe]=async()=>{if(!$(this,re)[re])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if($(this,re)[re].session)return $(this,re)[re].session;let e=await $(this,re)[re].connect({optionalNamespaces:{solana:{chains:[ee,te],methods:["solana_signMessage","solana_signTransaction","solana_signAndSendTransaction"],events:[]}}});if(!e)throw Error("WalletConnectSolana: Failed to create new session");return $(this,ve)[ve](xe(e)),e},$(this,Se)[Se]=async()=>{let e=$(this,re)[re]?.session;if(e){if(!e.namespaces?.solana)return await($(this,re)[re]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void($(this,re)[re].session=void 0);$(this,ve)[ve](xe(e));}},$(this,Te)[Te]=(e,t)=>{let s=$(this,ue)[ue].get(e);s&&($(this,re)[re]?.off(e,s),$(this,ue)[ue].delete(e)),$(this,re)[re]?.on(e,t),$(this,ue)[ue].set(e,t);},$(this,Ae)[Ae]=async()=>{try{if($(this,re)[re]?.session&&await($(this,re)[re]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),$(this,re)[re]?.client){let e=$(this,re)[re].client.proposal.getAll();await Promise.allSettled(e.map((e=>$(this,re)[re]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=$(this,re)[re].client.pairing.getAll();await Promise.allSettled(t.map((e=>$(this,re)[re]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))));}$(this,me)[me]();}catch(e){console.error("WalletConnectSolana: Error destroying session",e);}},$(this,We)[We]=async(e,t,s)=>{try{return await $(this,re)[re].request({method:e,params:t},s)}catch(t){if(console.error(`WalletConnectSolana: RPC Error - ${e}:`,t),t?.message?.includes("without any listeners")&&t.result)return t.result;if(t?.message?.includes("session topic does not exist in keychain"))throw Error("WalletConnectSolana: Wallet connection lost. Please reconnect.");throw t}},$(this,Ce)[Ce]=e=>{if(libExports.isMobile&&$(this,de)[de]){let{redirect:s}=U$5(e,$(this,de)[de]);null==$(this,he)[he]||$(this,he)[he].call(this,{native:s,universal:s});}else null==$(this,he)[he]||$(this,he)[he].call(this,{native:e,universal:void 0});},$(this,Ee)[Ee]=()=>{$(this,me)[me]();};}}function ke(e,...t){$(this,se)[se][e]?.forEach((e=>e.apply(null,t)));}function Ue(e,t){$(this,se)[se][e]=$(this,se)[se][e]?.filter((e=>t!==e));}function xe(e){return e.namespaces.solana.accounts.reduce(((e,t)=>{let s=t.split(":").at(-1);return e.includes(s)||e.push(s),e}),[])}function Fe(e){switch(e){case "solana:mainnet":return ee;case "solana:devnet":return te;default:return e}}
|
|
30698
31986
|
|
|
30699
31987
|
const SURFNET_RPC_URL$1 = "https://surfpool.fly.dev";
|
|
30700
31988
|
let React;
|
|
@@ -30719,7 +32007,7 @@ const defaultPrivyConfig = {
|
|
|
30719
32007
|
appearance: {
|
|
30720
32008
|
walletChainType: 'solana-only',
|
|
30721
32009
|
},
|
|
30722
|
-
externalWallets: { solana: { connectors:
|
|
32010
|
+
externalWallets: { solana: { connectors: q() } }
|
|
30723
32011
|
}
|
|
30724
32012
|
};
|
|
30725
32013
|
class PrivyWalletProvider {
|
|
@@ -30736,6 +32024,8 @@ class PrivyWalletProvider {
|
|
|
30736
32024
|
this.pendingSignTransaction = null;
|
|
30737
32025
|
// This is used to store pending signMessage calls until the wallet is connected
|
|
30738
32026
|
this.pendingSignMessage = null;
|
|
32027
|
+
// This is used to store pending signAndSubmitTransaction calls until the wallet is connected
|
|
32028
|
+
this.pendingSignAndSubmitTransaction = null;
|
|
30739
32029
|
this.networkUrl = networkUrl;
|
|
30740
32030
|
if (typeof window === 'undefined') {
|
|
30741
32031
|
throw new Error('PrivyWalletProvider can only be instantiated in a browser environment');
|
|
@@ -30807,6 +32097,7 @@ class PrivyWalletProvider {
|
|
|
30807
32097
|
const useFundWalletSolana = privySolana.useFundWallet();
|
|
30808
32098
|
const useSendTransactionSolana = privySolana.useSignAndSendTransaction();
|
|
30809
32099
|
const { signTransaction } = privySolana.useSignTransaction();
|
|
32100
|
+
const { signMessage: signMessageHook } = privySolana.useSignMessage();
|
|
30810
32101
|
const { ready: walletReady, wallets } = privySolana.useWallets();
|
|
30811
32102
|
const { createWallet } = privySolana.useCreateWallet();
|
|
30812
32103
|
const { exportWallet } = privySolana.useExportWallet();
|
|
@@ -30851,6 +32142,18 @@ class PrivyWalletProvider {
|
|
|
30851
32142
|
}
|
|
30852
32143
|
that.pendingSignMessage = null;
|
|
30853
32144
|
}
|
|
32145
|
+
// If there's a pending signAndSubmitTransaction, execute it now
|
|
32146
|
+
if (that.pendingSignAndSubmitTransaction) {
|
|
32147
|
+
const { transaction, feePayer, resolve, reject } = that.pendingSignAndSubmitTransaction;
|
|
32148
|
+
try {
|
|
32149
|
+
const result = await that.signAndSubmitTransaction(transaction, feePayer);
|
|
32150
|
+
resolve(result);
|
|
32151
|
+
}
|
|
32152
|
+
catch (error) {
|
|
32153
|
+
reject(error);
|
|
32154
|
+
}
|
|
32155
|
+
that.pendingSignAndSubmitTransaction = null;
|
|
32156
|
+
}
|
|
30854
32157
|
},
|
|
30855
32158
|
onError: (error) => {
|
|
30856
32159
|
// Only log errors that aren't user-initiated cancellations
|
|
@@ -30869,6 +32172,10 @@ class PrivyWalletProvider {
|
|
|
30869
32172
|
that.pendingSignMessage.reject(error);
|
|
30870
32173
|
that.pendingSignMessage = null;
|
|
30871
32174
|
}
|
|
32175
|
+
if (that.pendingSignAndSubmitTransaction) {
|
|
32176
|
+
that.pendingSignAndSubmitTransaction.reject(error);
|
|
32177
|
+
that.pendingSignAndSubmitTransaction = null;
|
|
32178
|
+
}
|
|
30872
32179
|
}
|
|
30873
32180
|
});
|
|
30874
32181
|
const { login } = privyImports.useLogin({
|
|
@@ -30944,6 +32251,7 @@ class PrivyWalletProvider {
|
|
|
30944
32251
|
useSendTransactionSolana: useSendTransactionSolana,
|
|
30945
32252
|
useSolanaWallets: useSolanaWallets,
|
|
30946
32253
|
signTransaction: signTransaction,
|
|
32254
|
+
signMessage: signMessageHook,
|
|
30947
32255
|
};
|
|
30948
32256
|
}
|
|
30949
32257
|
}, [privy.ready, privy.authenticated, wallets, login, logout, walletReady]);
|
|
@@ -31014,7 +32322,7 @@ class PrivyWalletProvider {
|
|
|
31014
32322
|
await this.privyMethods.logout();
|
|
31015
32323
|
}
|
|
31016
32324
|
async runTransaction(_evmTransactionData, solTransactionData, options) {
|
|
31017
|
-
var _a
|
|
32325
|
+
var _a;
|
|
31018
32326
|
await this.ensureReady();
|
|
31019
32327
|
let session = await WebSessionManager.getSession();
|
|
31020
32328
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
@@ -31049,21 +32357,7 @@ class PrivyWalletProvider {
|
|
|
31049
32357
|
if (solTransactionData == null) {
|
|
31050
32358
|
throw new Error("Solana transaction data is required");
|
|
31051
32359
|
}
|
|
31052
|
-
|
|
31053
|
-
if (this.networkUrl == null) {
|
|
31054
|
-
if (solTransactionData.network === 'solana_devnet') {
|
|
31055
|
-
rpcUrl = SOLANA_DEVNET_RPC_URL;
|
|
31056
|
-
}
|
|
31057
|
-
else if (solTransactionData.network === 'solana_mainnet') {
|
|
31058
|
-
rpcUrl = SOLANA_MAINNET_RPC_URL;
|
|
31059
|
-
}
|
|
31060
|
-
else if (solTransactionData.network === 'surfnet') {
|
|
31061
|
-
rpcUrl = SURFNET_RPC_URL$1;
|
|
31062
|
-
}
|
|
31063
|
-
else {
|
|
31064
|
-
throw new Error('Invalid network for Phantom wallet');
|
|
31065
|
-
}
|
|
31066
|
-
}
|
|
32360
|
+
const rpcUrl = this.getRpcUrl(solTransactionData.network);
|
|
31067
32361
|
const connection = new web3_js.Connection(rpcUrl, "confirmed");
|
|
31068
32362
|
const remainingAccounts = convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
|
|
31069
32363
|
let app_id = solTransactionData.appId;
|
|
@@ -31089,71 +32383,28 @@ class PrivyWalletProvider {
|
|
|
31089
32383
|
}
|
|
31090
32384
|
}
|
|
31091
32385
|
const { tx, blockhash, lastValidBlockHeight } = await buildSetDocumentsTransaction(connection, solTransactionData.txArgs[0].idl, anchorProvider, new web3_js.PublicKey(wallet.address), { app_id, documents: solTransactionData.txArgs[0].setDocumentData, delete_paths: solTransactionData.txArgs[0].deletePaths, txData: solTransactionData.txArgs[0].txData }, finalDeduped, solTransactionData.lutKey, solTransactionData.preInstructions, false);
|
|
31092
|
-
|
|
32386
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
32387
|
+
const isLegacyTx = 'recentBlockhash' in tx && !('message' in tx && 'staticAccountKeys' in tx.message);
|
|
32388
|
+
if (isLegacyTx) {
|
|
31093
32389
|
tx.recentBlockhash = blockhash;
|
|
31094
32390
|
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
31095
32391
|
}
|
|
31096
|
-
else
|
|
32392
|
+
else {
|
|
31097
32393
|
tx.message.recentBlockhash = blockhash;
|
|
31098
32394
|
}
|
|
31099
32395
|
try {
|
|
31100
32396
|
if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
|
|
31101
|
-
//
|
|
31102
|
-
|
|
31103
|
-
if (tx instanceof web3_js.Transaction) {
|
|
31104
|
-
serializedTx = tx.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
31105
|
-
}
|
|
31106
|
-
else {
|
|
31107
|
-
serializedTx = tx.serialize();
|
|
31108
|
-
}
|
|
31109
|
-
const signedTx = await ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.signTransaction({
|
|
31110
|
-
transaction: serializedTx,
|
|
31111
|
-
wallet: privyWallet,
|
|
31112
|
-
chain: this.chainId
|
|
31113
|
-
}));
|
|
32397
|
+
// Just sign, don't submit - return raw signed bytes (same as original runTransaction)
|
|
32398
|
+
const signedTx = await this.signTransactionRaw(tx, privyWallet);
|
|
31114
32399
|
return {
|
|
31115
|
-
signedTransaction: signedTx,
|
|
32400
|
+
signedTransaction: signedTx, // Raw Uint8Array from Privy
|
|
31116
32401
|
blockNumber: 0,
|
|
31117
32402
|
gasUsed: "0",
|
|
31118
32403
|
data: ""
|
|
31119
32404
|
};
|
|
31120
32405
|
}
|
|
31121
|
-
|
|
31122
|
-
|
|
31123
|
-
if (isSurfnet) {
|
|
31124
|
-
// v3 API: serialize transaction and pass wallet/chain
|
|
31125
|
-
let serializedForSign;
|
|
31126
|
-
if (tx instanceof web3_js.Transaction) {
|
|
31127
|
-
serializedForSign = tx.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
31128
|
-
}
|
|
31129
|
-
else {
|
|
31130
|
-
serializedForSign = tx.serialize();
|
|
31131
|
-
}
|
|
31132
|
-
const signedTx = await ((_c = this.privyMethods) === null || _c === void 0 ? void 0 : _c.signTransaction({
|
|
31133
|
-
transaction: serializedForSign,
|
|
31134
|
-
wallet: privyWallet,
|
|
31135
|
-
chain: this.chainId
|
|
31136
|
-
}));
|
|
31137
|
-
txSignature = await connection.sendRawTransaction(signedTx);
|
|
31138
|
-
}
|
|
31139
|
-
else {
|
|
31140
|
-
// v3 API: transaction must be Uint8Array, pass wallet object
|
|
31141
|
-
// Serialize without requiring signatures - Privy will sign it
|
|
31142
|
-
let serializedTx;
|
|
31143
|
-
if (tx instanceof web3_js.Transaction) {
|
|
31144
|
-
serializedTx = tx.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
31145
|
-
}
|
|
31146
|
-
else {
|
|
31147
|
-
// VersionedTransaction
|
|
31148
|
-
serializedTx = tx.serialize();
|
|
31149
|
-
}
|
|
31150
|
-
const result = await ((_d = this.privyMethods) === null || _d === void 0 ? void 0 : _d.useSendTransactionSolana.signAndSendTransaction({
|
|
31151
|
-
transaction: serializedTx,
|
|
31152
|
-
wallet: privyWallet,
|
|
31153
|
-
chain: this.chainId
|
|
31154
|
-
}));
|
|
31155
|
-
txSignature = result.signature;
|
|
31156
|
-
}
|
|
32406
|
+
// Sign and submit using shared helper
|
|
32407
|
+
const txSignature = await this.signAndSubmitInternal(tx, privyWallet, rpcUrl);
|
|
31157
32408
|
return {
|
|
31158
32409
|
transactionSignature: txSignature,
|
|
31159
32410
|
blockNumber: 0,
|
|
@@ -31166,62 +32417,266 @@ class PrivyWalletProvider {
|
|
|
31166
32417
|
throw err;
|
|
31167
32418
|
}
|
|
31168
32419
|
}
|
|
32420
|
+
/**
|
|
32421
|
+
* Signs a Solana transaction without submitting it.
|
|
32422
|
+
*
|
|
32423
|
+
* This method handles blockhash automatically if not set - you do NOT need to
|
|
32424
|
+
* set recentBlockhash on the transaction before calling this method.
|
|
32425
|
+
* The network/RPC URL is derived from the provider's configuration (set during initialization).
|
|
32426
|
+
*
|
|
32427
|
+
* @param transaction - The transaction to sign (Transaction or VersionedTransaction)
|
|
32428
|
+
* @returns The signed transaction
|
|
32429
|
+
*/
|
|
31169
32430
|
async signTransaction(transaction) {
|
|
31170
|
-
var _a
|
|
32431
|
+
var _a;
|
|
32432
|
+
await this.ensureReady();
|
|
32433
|
+
let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
|
|
32434
|
+
let session = await WebSessionManager.getSession();
|
|
32435
|
+
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
32436
|
+
let privyWallet = privyWallets === null || privyWallets === void 0 ? void 0 : privyWallets.find((wallet) => wallet.address === sessionAddress);
|
|
32437
|
+
// If there's already a pending sign transaction, throw an error to prevent overlapping calls
|
|
32438
|
+
if (this.pendingSignTransaction) {
|
|
32439
|
+
throw new Error("Oops... something went wrong. Please try again.");
|
|
32440
|
+
}
|
|
32441
|
+
// If wallet not connected, trigger connection and queue the signing
|
|
32442
|
+
if (!privyWallets || privyWallets.length === 0 || !privyWallet) {
|
|
32443
|
+
return new Promise((resolve, reject) => {
|
|
32444
|
+
this.pendingSignTransaction = {
|
|
32445
|
+
resolve,
|
|
32446
|
+
reject,
|
|
32447
|
+
transaction
|
|
32448
|
+
};
|
|
32449
|
+
this.privyMethods.connectWallet();
|
|
32450
|
+
// Set a timeout to reject the promise if connection takes too long
|
|
32451
|
+
setTimeout(() => {
|
|
32452
|
+
if (this.pendingSignTransaction) {
|
|
32453
|
+
this.pendingSignTransaction.reject(new Error("Wallet connection timed out"));
|
|
32454
|
+
this.pendingSignTransaction = null;
|
|
32455
|
+
}
|
|
32456
|
+
}, 30000); // 30 seconds timeout
|
|
32457
|
+
});
|
|
32458
|
+
}
|
|
32459
|
+
// Privy requires serialized transaction bytes, which requires a blockhash.
|
|
32460
|
+
// If the transaction doesn't have one, get a fresh blockhash and set it.
|
|
32461
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
32462
|
+
const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
|
|
32463
|
+
if (isLegacyTransaction) {
|
|
32464
|
+
const legacyTx = transaction;
|
|
32465
|
+
if (!legacyTx.recentBlockhash) {
|
|
32466
|
+
const rpcUrl = this.getRpcUrl();
|
|
32467
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
32468
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
|
|
32469
|
+
legacyTx.recentBlockhash = blockhash;
|
|
32470
|
+
legacyTx.lastValidBlockHeight = lastValidBlockHeight;
|
|
32471
|
+
}
|
|
32472
|
+
// Set feePayer if not already set
|
|
32473
|
+
if (!legacyTx.feePayer) {
|
|
32474
|
+
legacyTx.feePayer = new web3_js.PublicKey(privyWallet.address);
|
|
32475
|
+
}
|
|
32476
|
+
}
|
|
32477
|
+
else {
|
|
32478
|
+
// VersionedTransaction
|
|
32479
|
+
const versionedTx = transaction;
|
|
32480
|
+
if (!versionedTx.message.recentBlockhash) {
|
|
32481
|
+
const rpcUrl = this.getRpcUrl();
|
|
32482
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
32483
|
+
const { blockhash } = await connection.getLatestBlockhash('confirmed');
|
|
32484
|
+
versionedTx.message.recentBlockhash = blockhash;
|
|
32485
|
+
}
|
|
32486
|
+
}
|
|
32487
|
+
// Sign using raw method, then deserialize for the public API
|
|
32488
|
+
const signedTxRaw = await this.signTransactionRaw(transaction, privyWallet);
|
|
32489
|
+
return this.deserializeSignedTransaction(signedTxRaw);
|
|
32490
|
+
}
|
|
32491
|
+
/**
|
|
32492
|
+
* Signs and submits a Solana transaction to the network.
|
|
32493
|
+
*
|
|
32494
|
+
* This method handles blockhash and transaction confirmation automatically - you do NOT need to
|
|
32495
|
+
* set recentBlockhash or lastValidBlockHeight on the transaction before calling this method.
|
|
32496
|
+
* The network/RPC URL is derived from the provider's configuration (set during initialization).
|
|
32497
|
+
*
|
|
32498
|
+
* @param transaction - The transaction to sign and submit (Transaction or VersionedTransaction)
|
|
32499
|
+
* @param feePayer - Optional fee payer public key. If not provided and the transaction doesn't
|
|
32500
|
+
* already have a feePayer set, the connected wallet address will be used.
|
|
32501
|
+
* Useful for co-signing scenarios where a different account pays the fees.
|
|
32502
|
+
* @returns The transaction signature
|
|
32503
|
+
*/
|
|
32504
|
+
async signAndSubmitTransaction(transaction, feePayer) {
|
|
32505
|
+
var _a;
|
|
32506
|
+
await this.ensureReady();
|
|
32507
|
+
let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
|
|
32508
|
+
let session = await WebSessionManager.getSession();
|
|
32509
|
+
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
32510
|
+
let privyWallet = privyWallets === null || privyWallets === void 0 ? void 0 : privyWallets.find((wallet) => wallet.address === sessionAddress);
|
|
32511
|
+
// If there's already a pending signAndSubmitTransaction, throw an error to prevent overlapping calls
|
|
32512
|
+
if (this.pendingSignAndSubmitTransaction) {
|
|
32513
|
+
throw new Error("Oops... something went wrong. Please try again.");
|
|
32514
|
+
}
|
|
32515
|
+
// If wallet not connected, trigger connection and queue the signing
|
|
32516
|
+
if (!privyWallets || privyWallets.length === 0 || !privyWallet) {
|
|
32517
|
+
return new Promise((resolve, reject) => {
|
|
32518
|
+
this.pendingSignAndSubmitTransaction = {
|
|
32519
|
+
resolve,
|
|
32520
|
+
reject,
|
|
32521
|
+
transaction,
|
|
32522
|
+
feePayer
|
|
32523
|
+
};
|
|
32524
|
+
this.privyMethods.connectWallet();
|
|
32525
|
+
// Set a timeout to reject the promise if connection takes too long
|
|
32526
|
+
setTimeout(() => {
|
|
32527
|
+
if (this.pendingSignAndSubmitTransaction) {
|
|
32528
|
+
this.pendingSignAndSubmitTransaction.reject(new Error("Wallet connection timed out"));
|
|
32529
|
+
this.pendingSignAndSubmitTransaction = null;
|
|
32530
|
+
}
|
|
32531
|
+
}, 30000); // 30 seconds timeout
|
|
32532
|
+
});
|
|
32533
|
+
}
|
|
32534
|
+
// Get RPC URL and create connection
|
|
32535
|
+
const rpcUrl = this.getRpcUrl();
|
|
32536
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
32537
|
+
// Get fresh blockhash and set it on the transaction before signing
|
|
32538
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
|
|
32539
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
32540
|
+
const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
|
|
32541
|
+
if (isLegacyTransaction) {
|
|
32542
|
+
const legacyTx = transaction;
|
|
32543
|
+
legacyTx.recentBlockhash = blockhash;
|
|
32544
|
+
legacyTx.lastValidBlockHeight = lastValidBlockHeight;
|
|
32545
|
+
// Set feePayer if not already set
|
|
32546
|
+
if (!legacyTx.feePayer) {
|
|
32547
|
+
legacyTx.feePayer = feePayer !== null && feePayer !== void 0 ? feePayer : new web3_js.PublicKey(privyWallet.address);
|
|
32548
|
+
}
|
|
32549
|
+
}
|
|
32550
|
+
else {
|
|
32551
|
+
// VersionedTransaction
|
|
32552
|
+
const versionedTx = transaction;
|
|
32553
|
+
versionedTx.message.recentBlockhash = blockhash;
|
|
32554
|
+
// Note: VersionedTransaction feePayer is set in the message at creation time
|
|
32555
|
+
// and cannot be modified after creation
|
|
32556
|
+
}
|
|
32557
|
+
// Use shared sign and submit logic
|
|
32558
|
+
return this.signAndSubmitInternal(transaction, privyWallet, rpcUrl);
|
|
32559
|
+
}
|
|
32560
|
+
// ============ Private Helpers ============
|
|
32561
|
+
getRpcUrl(network) {
|
|
32562
|
+
if (this.networkUrl) {
|
|
32563
|
+
return this.networkUrl;
|
|
32564
|
+
}
|
|
32565
|
+
if (network === 'solana_devnet') {
|
|
32566
|
+
return SOLANA_DEVNET_RPC_URL;
|
|
32567
|
+
}
|
|
32568
|
+
else if (network === 'solana_mainnet') {
|
|
32569
|
+
return SOLANA_MAINNET_RPC_URL;
|
|
32570
|
+
}
|
|
32571
|
+
else if (network === 'surfnet') {
|
|
32572
|
+
return SURFNET_RPC_URL$1;
|
|
32573
|
+
}
|
|
32574
|
+
return SOLANA_MAINNET_RPC_URL; // default to mainnet
|
|
32575
|
+
}
|
|
32576
|
+
/**
|
|
32577
|
+
* Internal sign transaction - serializes and signs via Privy
|
|
32578
|
+
* Returns the raw result from Privy (Uint8Array)
|
|
32579
|
+
* This mirrors exactly what runTransaction was doing
|
|
32580
|
+
*/
|
|
32581
|
+
async signTransactionRaw(transaction, privyWallet) {
|
|
32582
|
+
var _a;
|
|
32583
|
+
// Serialize the transaction
|
|
32584
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
32585
|
+
const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
|
|
32586
|
+
let serializedForSign;
|
|
32587
|
+
if (isLegacyTransaction) {
|
|
32588
|
+
serializedForSign = transaction.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
32589
|
+
}
|
|
32590
|
+
else {
|
|
32591
|
+
serializedForSign = transaction.serialize();
|
|
32592
|
+
}
|
|
32593
|
+
// Sign via Privy - returns { signedTransaction: Uint8Array }
|
|
32594
|
+
const result = await ((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.signTransaction({
|
|
32595
|
+
transaction: serializedForSign,
|
|
32596
|
+
wallet: privyWallet,
|
|
32597
|
+
chain: this.chainId
|
|
32598
|
+
}));
|
|
32599
|
+
// Privy returns { signedTransaction: Uint8Array }, unwrap it
|
|
32600
|
+
const signedTx = (result === null || result === void 0 ? void 0 : result.signedTransaction) || result;
|
|
32601
|
+
return signedTx;
|
|
32602
|
+
}
|
|
32603
|
+
/**
|
|
32604
|
+
* Deserialize a signed transaction from Uint8Array to Transaction object
|
|
32605
|
+
*/
|
|
32606
|
+
deserializeSignedTransaction(signedTxRaw) {
|
|
32607
|
+
// Handle different formats Privy might return
|
|
32608
|
+
let signedTx;
|
|
32609
|
+
if (signedTxRaw instanceof Uint8Array) {
|
|
32610
|
+
signedTx = signedTxRaw;
|
|
32611
|
+
}
|
|
32612
|
+
else if (Array.isArray(signedTxRaw)) {
|
|
32613
|
+
signedTx = new Uint8Array(signedTxRaw);
|
|
32614
|
+
}
|
|
32615
|
+
else if (signedTxRaw && typeof signedTxRaw === 'object' && 'signedTransaction' in signedTxRaw) {
|
|
32616
|
+
// Privy might wrap the result
|
|
32617
|
+
signedTx = signedTxRaw.signedTransaction instanceof Uint8Array
|
|
32618
|
+
? signedTxRaw.signedTransaction
|
|
32619
|
+
: new Uint8Array(signedTxRaw.signedTransaction);
|
|
32620
|
+
}
|
|
32621
|
+
else if (Buffer.isBuffer(signedTxRaw)) {
|
|
32622
|
+
signedTx = new Uint8Array(signedTxRaw);
|
|
32623
|
+
}
|
|
32624
|
+
else {
|
|
32625
|
+
throw new Error(`Unexpected signed transaction format: ${typeof signedTxRaw}`);
|
|
32626
|
+
}
|
|
32627
|
+
// Try to deserialize as VersionedTransaction first, fall back to legacy Transaction
|
|
31171
32628
|
try {
|
|
31172
|
-
|
|
31173
|
-
|
|
31174
|
-
|
|
31175
|
-
|
|
31176
|
-
|
|
31177
|
-
|
|
31178
|
-
|
|
31179
|
-
|
|
32629
|
+
return web3_js.VersionedTransaction.deserialize(signedTx);
|
|
32630
|
+
}
|
|
32631
|
+
catch (_a) {
|
|
32632
|
+
return web3_js.Transaction.from(signedTx);
|
|
32633
|
+
}
|
|
32634
|
+
}
|
|
32635
|
+
/**
|
|
32636
|
+
* Internal sign and submit - handles Surfnet vs non-Surfnet logic
|
|
32637
|
+
* This is the core submission logic used by both signAndSubmitTransaction and runTransaction
|
|
32638
|
+
*
|
|
32639
|
+
* For Surfnet: sign with signTransactionRaw, then sendRawTransaction
|
|
32640
|
+
* For non-Surfnet: use Privy's signAndSendTransaction (combined operation)
|
|
32641
|
+
*/
|
|
32642
|
+
async signAndSubmitInternal(transaction, privyWallet, rpcUrl) {
|
|
32643
|
+
var _a;
|
|
32644
|
+
const isSurfnet = rpcUrl === SURFNET_RPC_URL$1;
|
|
32645
|
+
if (isSurfnet) {
|
|
32646
|
+
// For Surfnet: sign with signTransactionRaw, then sendRawTransaction
|
|
32647
|
+
const signedTx = await this.signTransactionRaw(transaction, privyWallet);
|
|
32648
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
32649
|
+
const signature = await connection.sendRawTransaction(signedTx);
|
|
32650
|
+
return signature;
|
|
32651
|
+
}
|
|
32652
|
+
else {
|
|
32653
|
+
// For non-Surfnet: use Privy's combined signAndSendTransaction
|
|
32654
|
+
// Serialize the transaction for Privy API
|
|
32655
|
+
// Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
|
|
32656
|
+
const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
|
|
32657
|
+
let serializedTx;
|
|
32658
|
+
if (isLegacyTransaction) {
|
|
32659
|
+
serializedTx = transaction.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
31180
32660
|
}
|
|
31181
|
-
|
|
31182
|
-
|
|
31183
|
-
return new Promise((resolve, reject) => {
|
|
31184
|
-
this.pendingSignTransaction = {
|
|
31185
|
-
resolve,
|
|
31186
|
-
reject,
|
|
31187
|
-
transaction
|
|
31188
|
-
};
|
|
31189
|
-
this.privyMethods.connectWallet();
|
|
31190
|
-
// Set a timeout to reject the promise if connection takes too long
|
|
31191
|
-
setTimeout(() => {
|
|
31192
|
-
if (this.pendingSignTransaction) {
|
|
31193
|
-
this.pendingSignTransaction.reject(new Error("Wallet connection timed out"));
|
|
31194
|
-
this.pendingSignTransaction = null;
|
|
31195
|
-
}
|
|
31196
|
-
}, 30000); // 30 seconds timeout
|
|
31197
|
-
});
|
|
32661
|
+
else {
|
|
32662
|
+
serializedTx = transaction.serialize();
|
|
31198
32663
|
}
|
|
31199
|
-
const
|
|
31200
|
-
|
|
31201
|
-
transaction: serializedForSign,
|
|
32664
|
+
const result = await ((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.useSendTransactionSolana.signAndSendTransaction({
|
|
32665
|
+
transaction: serializedTx,
|
|
31202
32666
|
wallet: privyWallet,
|
|
31203
32667
|
chain: this.chainId
|
|
31204
32668
|
}));
|
|
31205
|
-
//
|
|
31206
|
-
|
|
31207
|
-
if (
|
|
31208
|
-
//
|
|
31209
|
-
|
|
31210
|
-
return web3_js.VersionedTransaction.deserialize(signedBytes);
|
|
31211
|
-
}
|
|
31212
|
-
catch (_c) {
|
|
31213
|
-
return web3_js.Transaction.from(signedBytes);
|
|
31214
|
-
}
|
|
32669
|
+
// Handle case where signature might be bytes instead of string
|
|
32670
|
+
let signature = result.signature;
|
|
32671
|
+
if (signature instanceof Uint8Array || Array.isArray(signature)) {
|
|
32672
|
+
// Convert bytes to base58
|
|
32673
|
+
signature = bs58.encode(signature instanceof Uint8Array ? signature : new Uint8Array(signature));
|
|
31215
32674
|
}
|
|
31216
|
-
|
|
31217
|
-
return signedBytes;
|
|
31218
|
-
}
|
|
31219
|
-
catch (error) {
|
|
31220
|
-
throw new Error(`Failed to sign and send serialized transaction: ${error.message}`);
|
|
32675
|
+
return signature;
|
|
31221
32676
|
}
|
|
31222
32677
|
}
|
|
31223
32678
|
async signMessage(message) {
|
|
31224
|
-
var _a;
|
|
32679
|
+
var _a, _b;
|
|
31225
32680
|
await this.ensureReady();
|
|
31226
32681
|
const session = await WebSessionManager.getSession();
|
|
31227
32682
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
@@ -31256,18 +32711,21 @@ class PrivyWalletProvider {
|
|
|
31256
32711
|
const session = await WebSessionManager.getSession();
|
|
31257
32712
|
sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
31258
32713
|
if (!sessionAddress) {
|
|
31259
|
-
throw new Error('No wallet connected or logged in to
|
|
32714
|
+
throw new Error('No wallet connected or logged in to sign message');
|
|
31260
32715
|
}
|
|
31261
32716
|
privyWallet = this.privyMethods.wallets[0];
|
|
31262
32717
|
}
|
|
31263
|
-
|
|
31264
|
-
|
|
31265
|
-
const
|
|
31266
|
-
const
|
|
31267
|
-
|
|
31268
|
-
|
|
31269
|
-
});
|
|
31270
|
-
|
|
32718
|
+
// Use the Privy signMessage hook for Solana wallets
|
|
32719
|
+
// The message needs to be passed as a Uint8Array
|
|
32720
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
32721
|
+
const result = await ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.signMessage({
|
|
32722
|
+
message: messageBytes,
|
|
32723
|
+
wallet: privyWallet,
|
|
32724
|
+
}));
|
|
32725
|
+
// The signature is returned as a Uint8Array, encode it as base58 (standard Solana format)
|
|
32726
|
+
const signatureBytes = (result === null || result === void 0 ? void 0 : result.signature) || result;
|
|
32727
|
+
const bs58 = await Promise.resolve().then(function () { return index; });
|
|
32728
|
+
return bs58.default.encode(signatureBytes);
|
|
31271
32729
|
}
|
|
31272
32730
|
async restoreSession() {
|
|
31273
32731
|
const session = await WebSessionManager.getSession();
|
|
@@ -31368,6 +32826,17 @@ class MockAuthProvider {
|
|
|
31368
32826
|
});
|
|
31369
32827
|
return fakeSignature;
|
|
31370
32828
|
}
|
|
32829
|
+
async signMessageMock(message) {
|
|
32830
|
+
const address = sessionStorage.getItem('test-user-address') || DEFAULT_TEST_ADDRESS;
|
|
32831
|
+
// Generate a fake signature
|
|
32832
|
+
const fakeSignature = `mock_sig_${Math.random().toString(36).substring(2, 15)}`;
|
|
32833
|
+
console.log('[MockAuth] Mock message signed:', {
|
|
32834
|
+
address,
|
|
32835
|
+
message,
|
|
32836
|
+
signature: fakeSignature
|
|
32837
|
+
});
|
|
32838
|
+
return fakeSignature;
|
|
32839
|
+
}
|
|
31371
32840
|
/**
|
|
31372
32841
|
* Mock transaction signing - returns the transaction as-is (no actual signing)
|
|
31373
32842
|
*/
|
|
@@ -31375,6 +32844,14 @@ class MockAuthProvider {
|
|
|
31375
32844
|
console.log('[MockAuth] Mock transaction signing (no-op)');
|
|
31376
32845
|
return transaction;
|
|
31377
32846
|
}
|
|
32847
|
+
/**
|
|
32848
|
+
* Sign and submit transaction - not supported in mock environment.
|
|
32849
|
+
* See the real providers (PhantomWalletProvider, PrivyWalletProvider, SolanaKeypairProvider)
|
|
32850
|
+
* for the full implementation with blockhash handling and feePayer support.
|
|
32851
|
+
*/
|
|
32852
|
+
async signAndSubmitTransaction(_transaction, _feePayer) {
|
|
32853
|
+
throw new Error('signAndSubmitTransaction is not supported in the mock environment');
|
|
32854
|
+
}
|
|
31378
32855
|
/**
|
|
31379
32856
|
* Restore session - only restores if user previously called login() explicitly.
|
|
31380
32857
|
* This prevents auto-login on first page load, but allows session persistence after login.
|
|
@@ -31416,11 +32893,11 @@ class MockAuthProvider {
|
|
|
31416
32893
|
}
|
|
31417
32894
|
|
|
31418
32895
|
/**
|
|
31419
|
-
* OffchainAuthProvider wraps a real auth provider (e.g., Privy)
|
|
31420
|
-
* transaction signing via a custom modal for the poofnet environment.
|
|
32896
|
+
* OffchainAuthProvider wraps a real auth provider (e.g., Privy, Phantom) for the poofnet environment.
|
|
31421
32897
|
*
|
|
31422
|
-
*
|
|
31423
|
-
*
|
|
32898
|
+
* For signMessageMock, this shows a custom confirmation modal and generates a mock signature.
|
|
32899
|
+
* This is used for offchain transaction signing. For real wallet signing, use signMessage
|
|
32900
|
+
* which delegates to the wrapped provider.
|
|
31424
32901
|
*/
|
|
31425
32902
|
class OffchainAuthProvider {
|
|
31426
32903
|
constructor(wrappedProvider, config = {}) {
|
|
@@ -31452,11 +32929,26 @@ class OffchainAuthProvider {
|
|
|
31452
32929
|
async signTransaction(tx) {
|
|
31453
32930
|
return this.wrappedProvider.signTransaction(tx);
|
|
31454
32931
|
}
|
|
32932
|
+
/**
|
|
32933
|
+
* Sign and submit transaction - not supported in poofnet environment.
|
|
32934
|
+
* See the real providers (PhantomWalletProvider, PrivyWalletProvider, SolanaKeypairProvider)
|
|
32935
|
+
* for the full implementation with blockhash handling and feePayer support.
|
|
32936
|
+
*/
|
|
32937
|
+
async signAndSubmitTransaction(_transaction, _feePayer) {
|
|
32938
|
+
// Show modal explaining poofnet doesn't support real transactions
|
|
32939
|
+
await this.showUnsupportedTransactionModal();
|
|
32940
|
+
throw new Error('Poofnet does not support real Solana transactions. Deploy your project to mainnet to use this feature.');
|
|
32941
|
+
}
|
|
31455
32942
|
async getNativeMethods() {
|
|
31456
32943
|
return this.wrappedProvider.getNativeMethods();
|
|
31457
32944
|
}
|
|
31458
|
-
// ============
|
|
32945
|
+
// ============ signMessage delegates to wrapped provider ============
|
|
31459
32946
|
async signMessage(message) {
|
|
32947
|
+
// Delegate to wrapped provider for real wallet signing
|
|
32948
|
+
return this.wrappedProvider.signMessage(message);
|
|
32949
|
+
}
|
|
32950
|
+
// ============ Mock signMessage with Custom Modal for Offchain Transactions ============
|
|
32951
|
+
async signMessageMock(message) {
|
|
31460
32952
|
var _a, _b, _c, _d, _e, _f;
|
|
31461
32953
|
// Callback: signing started
|
|
31462
32954
|
(_b = (_a = this.config).onSigningStart) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
@@ -31479,6 +32971,99 @@ class OffchainAuthProvider {
|
|
|
31479
32971
|
}
|
|
31480
32972
|
}
|
|
31481
32973
|
// ============ Modal Implementation ============
|
|
32974
|
+
async showUnsupportedTransactionModal() {
|
|
32975
|
+
return new Promise((resolve) => {
|
|
32976
|
+
// Create modal container
|
|
32977
|
+
this.modalContainer = document.createElement("div");
|
|
32978
|
+
this.modalContainer.id = "poofnet-unsupported-modal";
|
|
32979
|
+
this.modalContainer.innerHTML = this.getUnsupportedModalHTML();
|
|
32980
|
+
document.body.appendChild(this.modalContainer);
|
|
32981
|
+
// Add styles
|
|
32982
|
+
const style = document.createElement("style");
|
|
32983
|
+
style.textContent = this.getModalStyles();
|
|
32984
|
+
this.modalContainer.appendChild(style);
|
|
32985
|
+
// Mark all other body children as inert
|
|
32986
|
+
document.body.childNodes.forEach((child) => {
|
|
32987
|
+
if (child !== this.modalContainer &&
|
|
32988
|
+
child instanceof HTMLElement) {
|
|
32989
|
+
child.setAttribute("inert", "");
|
|
32990
|
+
}
|
|
32991
|
+
});
|
|
32992
|
+
// Animate in
|
|
32993
|
+
requestAnimationFrame(() => {
|
|
32994
|
+
var _a, _b;
|
|
32995
|
+
const overlay = (_a = this.modalContainer) === null || _a === void 0 ? void 0 : _a.querySelector(".poofnet-modal-overlay");
|
|
32996
|
+
const content = (_b = this.modalContainer) === null || _b === void 0 ? void 0 : _b.querySelector(".poofnet-modal-content");
|
|
32997
|
+
if (overlay)
|
|
32998
|
+
overlay.style.opacity = "1";
|
|
32999
|
+
if (content) {
|
|
33000
|
+
content.style.opacity = "1";
|
|
33001
|
+
content.style.transform = "translateY(0)";
|
|
33002
|
+
}
|
|
33003
|
+
});
|
|
33004
|
+
// Handle close button
|
|
33005
|
+
const closeBtn = this.modalContainer.querySelector("#poofnet-close-btn");
|
|
33006
|
+
closeBtn === null || closeBtn === void 0 ? void 0 : closeBtn.addEventListener("click", () => {
|
|
33007
|
+
this.closeModal();
|
|
33008
|
+
resolve();
|
|
33009
|
+
});
|
|
33010
|
+
// Handle cancel button
|
|
33011
|
+
const cancelBtn = this.modalContainer.querySelector("#poofnet-cancel-btn");
|
|
33012
|
+
cancelBtn === null || cancelBtn === void 0 ? void 0 : cancelBtn.addEventListener("click", () => {
|
|
33013
|
+
this.closeModal();
|
|
33014
|
+
resolve();
|
|
33015
|
+
});
|
|
33016
|
+
// Handle overlay click
|
|
33017
|
+
const overlay = this.modalContainer.querySelector(".poofnet-modal-overlay");
|
|
33018
|
+
overlay === null || overlay === void 0 ? void 0 : overlay.addEventListener("click", (e) => {
|
|
33019
|
+
if (e.target === overlay) {
|
|
33020
|
+
this.closeModal();
|
|
33021
|
+
resolve();
|
|
33022
|
+
}
|
|
33023
|
+
});
|
|
33024
|
+
// Handle escape key
|
|
33025
|
+
const escHandler = (e) => {
|
|
33026
|
+
if (e.key === "Escape") {
|
|
33027
|
+
document.removeEventListener("keydown", escHandler);
|
|
33028
|
+
this.closeModal();
|
|
33029
|
+
resolve();
|
|
33030
|
+
}
|
|
33031
|
+
};
|
|
33032
|
+
document.addEventListener("keydown", escHandler);
|
|
33033
|
+
});
|
|
33034
|
+
}
|
|
33035
|
+
getUnsupportedModalHTML() {
|
|
33036
|
+
return `
|
|
33037
|
+
<div class="poofnet-modal-overlay">
|
|
33038
|
+
<div class="poofnet-modal-content">
|
|
33039
|
+
<button id="poofnet-close-btn" class="poofnet-close-btn" aria-label="Close">
|
|
33040
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
33041
|
+
<path d="M1 1L13 13M1 13L13 1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
33042
|
+
</svg>
|
|
33043
|
+
</button>
|
|
33044
|
+
<div class="poofnet-modal-header">
|
|
33045
|
+
<div class="poofnet-modal-icon">⚠️</div>
|
|
33046
|
+
<h2 class="poofnet-modal-title">Transaction Not Supported</h2>
|
|
33047
|
+
<p class="poofnet-modal-subtitle">Poofnet Simulated Blockchain</p>
|
|
33048
|
+
</div>
|
|
33049
|
+
|
|
33050
|
+
<div class="poofnet-modal-body">
|
|
33051
|
+
<div class="poofnet-info-box" style="background: #fef3c7;">
|
|
33052
|
+
<span class="poofnet-info-icon">ℹ️</span>
|
|
33053
|
+
<span class="poofnet-info-text" style="color: #92400e;">
|
|
33054
|
+
Poofnet is a simulated blockchain and does not support real Solana transactions.
|
|
33055
|
+
Deploy your project to mainnet to test real transactions.
|
|
33056
|
+
</span>
|
|
33057
|
+
</div>
|
|
33058
|
+
</div>
|
|
33059
|
+
|
|
33060
|
+
<div class="poofnet-modal-footer">
|
|
33061
|
+
<button id="poofnet-cancel-btn" class="poofnet-btn poofnet-btn-cancel" style="flex: 1;">Close</button>
|
|
33062
|
+
</div>
|
|
33063
|
+
</div>
|
|
33064
|
+
</div>
|
|
33065
|
+
`;
|
|
33066
|
+
}
|
|
31482
33067
|
async showTransactionModal(message) {
|
|
31483
33068
|
return new Promise((resolve) => {
|
|
31484
33069
|
// Parse the transaction message for display
|
|
@@ -32248,7 +33833,10 @@ exports.runQueryMany = runQueryMany;
|
|
|
32248
33833
|
exports.set = set$1;
|
|
32249
33834
|
exports.setFile = setFile;
|
|
32250
33835
|
exports.setMany = setMany;
|
|
33836
|
+
exports.signAndSubmitTransaction = signAndSubmitTransaction;
|
|
33837
|
+
exports.signMessage = signMessage;
|
|
32251
33838
|
exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
33839
|
+
exports.signTransaction = signTransaction;
|
|
32252
33840
|
exports.subscribe = subscribe;
|
|
32253
33841
|
exports.useAuth = useAuth;
|
|
32254
|
-
//# sourceMappingURL=index-
|
|
33842
|
+
//# sourceMappingURL=index-BaNlnYmn.js.map
|