@pooflabs/web 0.0.70-rc.2 → 0.0.70
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/{index-DarQ4sGV.esm.js → index-Buv6IzVV.esm.js} +863 -383
- package/dist/index-Buv6IzVV.esm.js.map +1 -0
- package/dist/{index-DUOitTCO.js → index-De5j2Ofs.js} +2 -2
- package/dist/{index-DUOitTCO.js.map → index-De5j2Ofs.js.map} +1 -1
- package/dist/{index-CGCShasV.esm.js → index-DgZ0DRmj.esm.js} +2 -2
- package/dist/{index-CGCShasV.esm.js.map → index-DgZ0DRmj.esm.js.map} +1 -1
- package/dist/{index-DaaCdje_.js → index-Rzm01Zbu.js} +863 -383
- package/dist/index-Rzm01Zbu.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/index-DaaCdje_.js.map +0 -1
- package/dist/index-DarQ4sGV.esm.js.map +0 -1
|
@@ -8985,15 +8985,15 @@ function requireBuffer$1 () {
|
|
|
8985
8985
|
|
|
8986
8986
|
var bufferExports$1 = requireBuffer$1();
|
|
8987
8987
|
|
|
8988
|
-
var safeBuffer
|
|
8988
|
+
var safeBuffer = {exports: {}};
|
|
8989
8989
|
|
|
8990
8990
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
8991
8991
|
|
|
8992
|
-
var hasRequiredSafeBuffer
|
|
8992
|
+
var hasRequiredSafeBuffer;
|
|
8993
8993
|
|
|
8994
|
-
function requireSafeBuffer
|
|
8995
|
-
if (hasRequiredSafeBuffer
|
|
8996
|
-
hasRequiredSafeBuffer
|
|
8994
|
+
function requireSafeBuffer () {
|
|
8995
|
+
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
8996
|
+
hasRequiredSafeBuffer = 1;
|
|
8997
8997
|
(function (module, exports$1) {
|
|
8998
8998
|
/* eslint-disable node/no-deprecated-api */
|
|
8999
8999
|
var buffer = requireBuffer$1();
|
|
@@ -9059,23 +9059,23 @@ function requireSafeBuffer$1 () {
|
|
|
9059
9059
|
}
|
|
9060
9060
|
return buffer.SlowBuffer(size)
|
|
9061
9061
|
};
|
|
9062
|
-
} (safeBuffer
|
|
9063
|
-
return safeBuffer
|
|
9062
|
+
} (safeBuffer, safeBuffer.exports));
|
|
9063
|
+
return safeBuffer.exports;
|
|
9064
9064
|
}
|
|
9065
9065
|
|
|
9066
|
-
var src$
|
|
9067
|
-
var hasRequiredSrc
|
|
9066
|
+
var src$1;
|
|
9067
|
+
var hasRequiredSrc;
|
|
9068
9068
|
|
|
9069
|
-
function requireSrc
|
|
9070
|
-
if (hasRequiredSrc
|
|
9071
|
-
hasRequiredSrc
|
|
9069
|
+
function requireSrc () {
|
|
9070
|
+
if (hasRequiredSrc) return src$1;
|
|
9071
|
+
hasRequiredSrc = 1;
|
|
9072
9072
|
// base-x encoding / decoding
|
|
9073
9073
|
// Copyright (c) 2018 base-x contributors
|
|
9074
9074
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
9075
9075
|
// Distributed under the MIT software license, see the accompanying
|
|
9076
9076
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
9077
9077
|
// @ts-ignore
|
|
9078
|
-
var _Buffer = requireSafeBuffer
|
|
9078
|
+
var _Buffer = requireSafeBuffer().Buffer;
|
|
9079
9079
|
function base (ALPHABET) {
|
|
9080
9080
|
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
9081
9081
|
var BASE_MAP = new Uint8Array(256);
|
|
@@ -9190,8 +9190,8 @@ function requireSrc$1 () {
|
|
|
9190
9190
|
decode: decode
|
|
9191
9191
|
}
|
|
9192
9192
|
}
|
|
9193
|
-
src$
|
|
9194
|
-
return src$
|
|
9193
|
+
src$1 = base;
|
|
9194
|
+
return src$1;
|
|
9195
9195
|
}
|
|
9196
9196
|
|
|
9197
9197
|
var bs58$1$1;
|
|
@@ -9200,7 +9200,7 @@ var hasRequiredBs58$1;
|
|
|
9200
9200
|
function requireBs58$1 () {
|
|
9201
9201
|
if (hasRequiredBs58$1) return bs58$1$1;
|
|
9202
9202
|
hasRequiredBs58$1 = 1;
|
|
9203
|
-
var basex = requireSrc
|
|
9203
|
+
var basex = requireSrc();
|
|
9204
9204
|
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
9205
9205
|
|
|
9206
9206
|
bs58$1$1 = basex(ALPHABET);
|
|
@@ -13561,7 +13561,7 @@ async function loadDependencies() {
|
|
|
13561
13561
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
13562
13562
|
import('react'),
|
|
13563
13563
|
import('react-dom/client'),
|
|
13564
|
-
import('./index-
|
|
13564
|
+
import('./index-DgZ0DRmj.esm.js')
|
|
13565
13565
|
]);
|
|
13566
13566
|
// Extract default export from ESM module namespace
|
|
13567
13567
|
// Dynamic import() returns { default: Module, ...exports }, not the module directly
|
|
@@ -13676,14 +13676,10 @@ class PhantomWalletProvider {
|
|
|
13676
13676
|
// Keep Phantom UI above host overlays while avoiding global click-capture.
|
|
13677
13677
|
this.containerElement.style.position = 'fixed';
|
|
13678
13678
|
this.containerElement.style.zIndex = '2147483647';
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
this.containerElement.style.pointerEvents = 'none';
|
|
13684
|
-
}
|
|
13685
|
-
// When Privy fallback is off, the container just hosts PhantomProvider
|
|
13686
|
-
// without covering the viewport or blocking pointer events
|
|
13679
|
+
// Full-viewport overlay for custom modal; pointer-events: none lets
|
|
13680
|
+
// clicks pass through to page except where the modal sets 'auto'
|
|
13681
|
+
this.containerElement.style.inset = '0';
|
|
13682
|
+
this.containerElement.style.pointerEvents = 'none';
|
|
13687
13683
|
document.body.appendChild(this.containerElement);
|
|
13688
13684
|
const that = this;
|
|
13689
13685
|
const { PhantomProvider: ReactPhantomProvider, usePhantom, useConnect, useDisconnect, useModal, useSolana, useDiscoveredWallets, AddressType, darkTheme, lightTheme } = phantomReactSdk;
|
|
@@ -13809,7 +13805,7 @@ class PhantomWalletProvider {
|
|
|
13809
13805
|
}, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable, disconnect]);
|
|
13810
13806
|
// Suppress SDK modal if it opens during custom modal login flow
|
|
13811
13807
|
React$1.useEffect(() => {
|
|
13812
|
-
if (modal.isOpened && that.loginInProgress
|
|
13808
|
+
if (modal.isOpened && that.loginInProgress) {
|
|
13813
13809
|
modal.close();
|
|
13814
13810
|
}
|
|
13815
13811
|
}, [modal.isOpened]);
|
|
@@ -13986,8 +13982,8 @@ class PhantomWalletProvider {
|
|
|
13986
13982
|
that.loginInProgress = false;
|
|
13987
13983
|
}
|
|
13988
13984
|
};
|
|
13989
|
-
// --- Custom modal
|
|
13990
|
-
if (!showWalletModal
|
|
13985
|
+
// --- Custom wallet modal ---
|
|
13986
|
+
if (!showWalletModal) {
|
|
13991
13987
|
return null;
|
|
13992
13988
|
}
|
|
13993
13989
|
const theme = that.config.theme === 'light' ? lightTheme : darkTheme;
|
|
@@ -14017,6 +14013,47 @@ class PhantomWalletProvider {
|
|
|
14017
14013
|
transition: 'background-color 0.2s',
|
|
14018
14014
|
});
|
|
14019
14015
|
const walletButtons = [];
|
|
14016
|
+
// Google OAuth button — shown when 'google' is in resolved providers
|
|
14017
|
+
if (sdkProviders.includes('google')) {
|
|
14018
|
+
walletButtons.push(React$1.createElement('button', {
|
|
14019
|
+
key: 'google-oauth',
|
|
14020
|
+
style: buttonStyle('google-oauth'),
|
|
14021
|
+
onClick: () => handleWalletClick({ provider: 'google' }),
|
|
14022
|
+
onMouseEnter: () => setHoveredBtn('google-oauth'),
|
|
14023
|
+
onMouseLeave: () => setHoveredBtn(null),
|
|
14024
|
+
}, React$1.createElement('svg', {
|
|
14025
|
+
width: '20', height: '20', viewBox: '0 0 24 24',
|
|
14026
|
+
style: { flexShrink: '0' },
|
|
14027
|
+
}, React$1.createElement('path', {
|
|
14028
|
+
d: 'M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z',
|
|
14029
|
+
fill: '#4285F4',
|
|
14030
|
+
}), React$1.createElement('path', {
|
|
14031
|
+
d: 'M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z',
|
|
14032
|
+
fill: '#34A853',
|
|
14033
|
+
}), React$1.createElement('path', {
|
|
14034
|
+
d: 'M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A11.96 11.96 0 0 0 1 12c0 1.94.46 3.77 1.18 5.41l3.66-2.84z',
|
|
14035
|
+
fill: '#FBBC05',
|
|
14036
|
+
}), React$1.createElement('path', {
|
|
14037
|
+
d: 'M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z',
|
|
14038
|
+
fill: '#EA4335',
|
|
14039
|
+
})), 'Continue with Google'));
|
|
14040
|
+
}
|
|
14041
|
+
// Apple OAuth button — shown when 'apple' is in resolved providers
|
|
14042
|
+
if (sdkProviders.includes('apple')) {
|
|
14043
|
+
walletButtons.push(React$1.createElement('button', {
|
|
14044
|
+
key: 'apple-oauth',
|
|
14045
|
+
style: buttonStyle('apple-oauth'),
|
|
14046
|
+
onClick: () => handleWalletClick({ provider: 'apple' }),
|
|
14047
|
+
onMouseEnter: () => setHoveredBtn('apple-oauth'),
|
|
14048
|
+
onMouseLeave: () => setHoveredBtn(null),
|
|
14049
|
+
}, React$1.createElement('svg', {
|
|
14050
|
+
width: '20', height: '20', viewBox: '0 0 24 24',
|
|
14051
|
+
fill: textColor,
|
|
14052
|
+
style: { flexShrink: '0' },
|
|
14053
|
+
}, React$1.createElement('path', {
|
|
14054
|
+
d: 'M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z',
|
|
14055
|
+
})), 'Continue with Apple'));
|
|
14056
|
+
}
|
|
14020
14057
|
// Fallback icon for Phantom — uses the official SVG path from @phantom/wallet-sdk-ui
|
|
14021
14058
|
// (SDK intentionally leaves wallet.icon empty for Phantom, expecting its own UI to render it)
|
|
14022
14059
|
const PHANTOM_ICON = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHJ4PSI2IiBmaWxsPSIjQUI5RkYyIi8+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNCw0KSI+PHBhdGggZD0iTTIuMzY2NTUgMTguMzI3MUM0LjkxODcxIDE4LjMyNzEgNi44MzY3IDE2LjEwNzYgNy45ODEzMSAxNC4zNTM3QzcuODQyMSAxNC43NDE3IDcuNzY0NzYgMTUuMTI5OCA3Ljc2NDc2IDE1LjUwMjNDNy43NjQ3NiAxNi41MjY3IDguMzUyNTMgMTcuMjU2MiA5LjUxMjYgMTcuMjU2MkMxMS4xMDU4IDE3LjI1NjIgMTIuODA3MiAxNS44NTkzIDEzLjY4ODkgMTQuMzUzN0MxMy42MjcgMTQuNTcxIDEzLjU5NjEgMTQuNzcyOCAxMy41OTYxIDE0Ljk1OUMxMy41OTYxIDE1LjY3MyAxMy45OTgyIDE2LjEyMzEgMTQuODE4IDE2LjEyMzFDMTcuNDAxMSAxNi4xMjMxIDE5Ljk5OTcgMTEuNTQ0NCAxOS45OTk3IDcuNTM5ODdDMTkuOTk5NyA0LjQyMDExIDE4LjQyMiAxLjY3Mjg1IDE0LjQ2MjIgMS42NzI4NUM3LjUwMTgxIDEuNjcyODUgMCAxMC4xNzg1IDAgMTUuNjczQzAgMTcuODMwNSAxLjE2MDA3IDE4LjMyNzEgMi4zNjY1NSAxOC4zMjcxWk0xMi4wNjQ4IDcuMTk4NDFDMTIuMDY0OCA2LjQyMjM1IDEyLjQ5NzkgNS44NzkxIDEzLjEzMiA1Ljg3OTFDMTMuNzUwNyA1Ljg3OTEgMTQuMTgzOCA2LjQyMjM1IDE0LjE4MzggNy4xOTg0MUMxNC4xODM4IDcuOTc0NDcgMTMuNzUwNyA4LjUzMzIzIDEzLjEzMiA4LjUzMzIzQzEyLjQ5NzkgOC41MzMyMyAxMi4wNjQ4IDcuOTc0NDcgMTIuMDY0OCA3LjE5ODQxWk0xNS4zNzQ4IDcuMTk4NDFDMTUuMzc0OCA2LjQyMjM1IDE1LjgwNzkgNS44NzkxIDE2LjQ0MjEgNS44NzkxQzE3LjA2MDggNS44NzkxIDE3LjQ5MzkgNi40MjIzNSAxNy40OTM5IDcuMTk4NDFDMTcuNDkzOSA3Ljk3NDQ3IDE3LjA2MDggOC41MzMyMyAxNi40NDIxIDguNTMzMjNDMTUuODA3OSA4LjUzMzIzIDE1LjM3NDggNy45NzQ0NyAxNS4zNzQ4IDcuMTk4NDFaIiBmaWxsPSJ3aGl0ZSIvPjwvZz48L3N2Zz4=';
|
|
@@ -14084,25 +14121,27 @@ class PhantomWalletProvider {
|
|
|
14084
14121
|
stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
|
|
14085
14122
|
})), 'Connect Mobile Wallet'));
|
|
14086
14123
|
}
|
|
14087
|
-
// Email button
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14124
|
+
// Email button — only when Privy fallback is enabled
|
|
14125
|
+
if (that.config.enablePrivyFallback) {
|
|
14126
|
+
walletButtons.push(React$1.createElement('button', {
|
|
14127
|
+
key: 'email-login',
|
|
14128
|
+
style: buttonStyle('email-login'),
|
|
14129
|
+
onClick: handleEmailClick,
|
|
14130
|
+
onMouseEnter: () => setHoveredBtn('email-login'),
|
|
14131
|
+
onMouseLeave: () => setHoveredBtn(null),
|
|
14132
|
+
},
|
|
14133
|
+
// Email icon
|
|
14134
|
+
React$1.createElement('svg', {
|
|
14135
|
+
width: '20', height: '20', viewBox: '0 0 24 24', fill: 'none',
|
|
14136
|
+
style: { flexShrink: '0' },
|
|
14137
|
+
}, React$1.createElement('path', {
|
|
14138
|
+
d: 'M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z',
|
|
14139
|
+
stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
|
|
14140
|
+
}), React$1.createElement('path', {
|
|
14141
|
+
d: 'M22 6l-10 7L2 6',
|
|
14142
|
+
stroke: textColor, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', fill: 'none',
|
|
14143
|
+
})), 'Log in with email'));
|
|
14144
|
+
}
|
|
14106
14145
|
// Render custom modal
|
|
14107
14146
|
return React$1.createElement('div', {
|
|
14108
14147
|
// Overlay
|
|
@@ -14325,13 +14364,8 @@ class PhantomWalletProvider {
|
|
|
14325
14364
|
return new Promise((resolve, reject) => {
|
|
14326
14365
|
this.pendingLogin = { resolve, reject };
|
|
14327
14366
|
this.loginInProgress = true;
|
|
14328
|
-
//
|
|
14329
|
-
|
|
14330
|
-
this.phantomMethods.showCustomModal();
|
|
14331
|
-
}
|
|
14332
|
-
else {
|
|
14333
|
-
this.phantomMethods.openModal();
|
|
14334
|
-
}
|
|
14367
|
+
// Always use our custom wallet modal
|
|
14368
|
+
this.phantomMethods.showCustomModal();
|
|
14335
14369
|
// Safety timeout
|
|
14336
14370
|
setTimeout(() => {
|
|
14337
14371
|
if (this.pendingLogin) {
|
|
@@ -15975,7 +16009,7 @@ function destr(value, options = {}) {
|
|
|
15975
16009
|
}
|
|
15976
16010
|
}
|
|
15977
16011
|
|
|
15978
|
-
var a$
|
|
16012
|
+
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())};
|
|
15979
16013
|
|
|
15980
16014
|
/**
|
|
15981
16015
|
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
@@ -16703,7 +16737,7 @@ const t$b={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:
|
|
|
16703
16737
|
|
|
16704
16738
|
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};
|
|
16705
16739
|
|
|
16706
|
-
const a$
|
|
16740
|
+
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"}}};
|
|
16707
16741
|
|
|
16708
16742
|
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};
|
|
16709
16743
|
|
|
@@ -16719,9 +16753,9 @@ const e$c={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:
|
|
|
16719
16753
|
|
|
16720
16754
|
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};
|
|
16721
16755
|
|
|
16722
|
-
const i$
|
|
16756
|
+
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"}}};
|
|
16723
16757
|
|
|
16724
|
-
const i$
|
|
16758
|
+
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"}}};
|
|
16725
16759
|
|
|
16726
16760
|
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"}}};
|
|
16727
16761
|
|
|
@@ -16753,11 +16787,11 @@ const e$4={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrenc
|
|
|
16753
16787
|
|
|
16754
16788
|
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};
|
|
16755
16789
|
|
|
16756
|
-
const x$
|
|
16790
|
+
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)));
|
|
16757
16791
|
|
|
16758
16792
|
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}};
|
|
16759
16793
|
|
|
16760
|
-
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$
|
|
16794
|
+
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;}};
|
|
16761
16795
|
|
|
16762
16796
|
// This file is autogenerated. It's used to publish ESM to npm.
|
|
16763
16797
|
function _typeof(obj) {
|
|
@@ -17938,9 +17972,9 @@ function validateWCAG2Parms(parms) {
|
|
|
17938
17972
|
};
|
|
17939
17973
|
}
|
|
17940
17974
|
|
|
17941
|
-
const S$5="privy:connections",T$4={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$8=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"]),$$5=e=>N$8.has(e),z$7=(e,t,a)=>a.indexOf(e)===t;const Y$4=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter($$5).filter(z$7):e?e.filter($$5).filter(z$7):T$4.appearance.walletList;let G$6=/paymaster\.biconomy\.io\/api/i,J$7={mode:"SPONSORED",calculateGasLimits:true,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const V$5=(e,t)=>e&&G$6.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$4({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$7];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$4.appearance.landingHeader,loginMessage:"string"=="undefined"?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:Q$4({backgroundTheme:T$4.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$4.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$4._render.standalone},fundingConfig:G,fundingMethodConfig:{...T$4.fundingMethodConfig,moonpay:{...T$4.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??T$4.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$5(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__*/createContext({appConfig:ae$4(ne$4,void 0),isServerConfigLoaded:false});
|
|
17975
|
+
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__*/createContext({appConfig:ae$4(ne$4,void 0),isServerConfigLoaded:false});
|
|
17942
17976
|
|
|
17943
|
-
function D$4(e){return {name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function U$
|
|
17977
|
+
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}}
|
|
17944
17978
|
|
|
17945
17979
|
// src/codes.ts
|
|
17946
17980
|
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
|
@@ -21658,9 +21692,9 @@ const genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => chain(radix(58), alphabet$
|
|
|
21658
21692
|
*/
|
|
21659
21693
|
const base58$1 = genBase58('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
|
|
21660
21694
|
|
|
21661
|
-
const x$
|
|
21695
|
+
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 EventEmitter{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$1 = 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"});
|
|
21662
21696
|
|
|
21663
|
-
const P$
|
|
21697
|
+
const P$7=["solana:mainnet","solana:devnet","solana:testnet"];function C$5(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$3(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 EventEmitter{setImplementation(e){C$5(this,D$3)[D$3]=e;}async signMessage(e){return C$5(this,D$3)[D$3].signMessage(e)}async signAndSendTransaction(e){return C$5(this,D$3)[D$3].signAndSendTransaction(e)}async signTransaction(e){return C$5(this,D$3)[D$3].signTransaction(e)}constructor(e){super(),Object.defineProperty(this,D$3,{writable:true,value:void 0}),C$5(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$3}),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});
|
|
21664
21698
|
|
|
21665
21699
|
var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
21666
21700
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
@@ -22282,7 +22316,7 @@ function requireEvents () {
|
|
|
22282
22316
|
var eventsExports = requireEvents();
|
|
22283
22317
|
var xe$3 = /*@__PURE__*/getDefaultExportFromCjs$1(eventsExports);
|
|
22284
22318
|
|
|
22285
|
-
var cjs$
|
|
22319
|
+
var cjs$4 = {};
|
|
22286
22320
|
|
|
22287
22321
|
/******************************************************************************
|
|
22288
22322
|
Copyright (c) Microsoft Corporation.
|
|
@@ -22931,11 +22965,11 @@ function requireTypes () {
|
|
|
22931
22965
|
return types;
|
|
22932
22966
|
}
|
|
22933
22967
|
|
|
22934
|
-
var hasRequiredCjs$
|
|
22968
|
+
var hasRequiredCjs$4;
|
|
22935
22969
|
|
|
22936
|
-
function requireCjs$
|
|
22937
|
-
if (hasRequiredCjs$
|
|
22938
|
-
hasRequiredCjs$
|
|
22970
|
+
function requireCjs$4 () {
|
|
22971
|
+
if (hasRequiredCjs$4) return cjs$4;
|
|
22972
|
+
hasRequiredCjs$4 = 1;
|
|
22939
22973
|
(function (exports$1) {
|
|
22940
22974
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
22941
22975
|
const tslib_1 = require$$0;
|
|
@@ -22944,16 +22978,16 @@ function requireCjs$3 () {
|
|
|
22944
22978
|
tslib_1.__exportStar(requireTypes(), exports$1);
|
|
22945
22979
|
tslib_1.__exportStar(requireConstants(), exports$1);
|
|
22946
22980
|
|
|
22947
|
-
} (cjs$
|
|
22948
|
-
return cjs$
|
|
22981
|
+
} (cjs$4));
|
|
22982
|
+
return cjs$4;
|
|
22949
22983
|
}
|
|
22950
22984
|
|
|
22951
|
-
var cjsExports$3 = requireCjs$
|
|
22985
|
+
var cjsExports$3 = requireCjs$4();
|
|
22952
22986
|
|
|
22953
22987
|
class IEvents {
|
|
22954
22988
|
}
|
|
22955
22989
|
|
|
22956
|
-
let n$1 = class n extends IEvents{constructor(e){super();}};const s$
|
|
22990
|
+
let n$1 = class n extends IEvents{constructor(e){super();}};const s$2=cjsExports$3.FIVE_SECONDS,r$1={pulse:"heartbeat_pulse"};let i$3 = class i extends n$1{constructor(e){super(e),this.events=new eventsExports.EventEmitter,this.interval=s$2,this.interval=e?.interval||s$2;}static async init(e){const t=new i(e);return await t.init(),t}async init(){await this.initialize();}stop(){clearInterval(this.intervalRef);}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 initialize(){this.intervalRef=setInterval(()=>this.pulse(),cjsExports$3.toMiliseconds(this.interval));}pulse(){this.events.emit(r$1.pulse);}};
|
|
22957
22991
|
|
|
22958
22992
|
function wrapToPromise(value) {
|
|
22959
22993
|
if (!value || typeof value.then !== "function") {
|
|
@@ -23609,9 +23643,9 @@ function safeJsonStringify(value) {
|
|
|
23609
23643
|
return typeof value === "string" ? value : JSONStringify(value) || "";
|
|
23610
23644
|
}
|
|
23611
23645
|
|
|
23612
|
-
const x$
|
|
23646
|
+
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);});}};
|
|
23613
23647
|
|
|
23614
|
-
var browser = {exports: {}};
|
|
23648
|
+
var browser$1 = {exports: {}};
|
|
23615
23649
|
|
|
23616
23650
|
var quickFormatUnescaped;
|
|
23617
23651
|
var hasRequiredQuickFormatUnescaped;
|
|
@@ -23730,15 +23764,15 @@ function requireQuickFormatUnescaped () {
|
|
|
23730
23764
|
return quickFormatUnescaped;
|
|
23731
23765
|
}
|
|
23732
23766
|
|
|
23733
|
-
var hasRequiredBrowser;
|
|
23767
|
+
var hasRequiredBrowser$1;
|
|
23734
23768
|
|
|
23735
|
-
function requireBrowser () {
|
|
23736
|
-
if (hasRequiredBrowser) return browser.exports;
|
|
23737
|
-
hasRequiredBrowser = 1;
|
|
23769
|
+
function requireBrowser$1 () {
|
|
23770
|
+
if (hasRequiredBrowser$1) return browser$1.exports;
|
|
23771
|
+
hasRequiredBrowser$1 = 1;
|
|
23738
23772
|
|
|
23739
23773
|
const format = requireQuickFormatUnescaped();
|
|
23740
23774
|
|
|
23741
|
-
browser.exports = pino;
|
|
23775
|
+
browser$1.exports = pino;
|
|
23742
23776
|
|
|
23743
23777
|
const _console = pfGlobalThisOrFallback().console || {};
|
|
23744
23778
|
const stdSerializers = {
|
|
@@ -24236,19 +24270,19 @@ function requireBrowser () {
|
|
|
24236
24270
|
}
|
|
24237
24271
|
/* eslint-enable */
|
|
24238
24272
|
|
|
24239
|
-
browser.exports.default = pino;
|
|
24240
|
-
browser.exports.pino = pino;
|
|
24241
|
-
return browser.exports;
|
|
24273
|
+
browser$1.exports.default = pino;
|
|
24274
|
+
browser$1.exports.pino = pino;
|
|
24275
|
+
return browser$1.exports;
|
|
24242
24276
|
}
|
|
24243
24277
|
|
|
24244
|
-
var browserExports = requireBrowser();
|
|
24245
|
-
var c$
|
|
24278
|
+
var browserExports$1 = requireBrowser$1();
|
|
24279
|
+
var c$4 = /*@__PURE__*/getDefaultExportFromCjs$1(browserExports$1);
|
|
24246
24280
|
|
|
24247
|
-
const b$3={level:"info"},l$1="custom_context",i$
|
|
24281
|
+
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)}
|
|
24248
24282
|
|
|
24249
|
-
var a=Object.defineProperty,u=(e,s,r)=>s in e?a(e,s,{enumerable:true,configurable:true,writable:true,value:r}):e[s]=r,c$
|
|
24283
|
+
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;}};
|
|
24250
24284
|
|
|
24251
|
-
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$2={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$2.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$3=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$3[d]=e.getUint32(n),Q$2[d]=e.getUint32(n+=4);for(let d=16;d<80;d++){const m=P$3[d-15]|0,F=Q$2[d-15]|0,q=x$2.rotrSH(m,F,1)^x$2.rotrSH(m,F,8)^x$2.shrSH(m,F,7),z=x$2.rotrSL(m,F,1)^x$2.rotrSL(m,F,8)^x$2.shrSL(m,F,7),I=P$3[d-2]|0,O=Q$2[d-2]|0,ot=x$2.rotrSH(I,O,19)^x$2.rotrBH(I,O,61)^x$2.shrSH(I,O,6),tt=x$2.rotrSL(I,O,19)^x$2.rotrBL(I,O,61)^x$2.shrSL(I,O,6),st=x$2.add4L(z,tt,Q$2[d-7],Q$2[d-16]),at=x$2.add4H(st,q,ot,P$3[d-7],P$3[d-16]);P$3[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$2.rotrSH(l,p,14)^x$2.rotrSH(l,p,18)^x$2.rotrBH(l,p,41),F=x$2.rotrSL(l,p,14)^x$2.rotrSL(l,p,18)^x$2.rotrBL(l,p,41),q=l&w^~l&g,z=p&h^~p&S,I=x$2.add5L(L,F,z,Yn$2[d],Q$2[d]),O=x$2.add5H(I,v,m,q,Vn$2[d],P$3[d]),ot=I|0,tt=x$2.rotrSH(r,o,28)^x$2.rotrBH(r,o,34)^x$2.rotrBH(r,o,39),st=x$2.rotrSL(r,o,28)^x$2.rotrBL(r,o,34)^x$2.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$2.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$2.add3L(ot,st,Ct);r=x$2.add3H(At,O,tt,at),o=At|0;}(({h:r,l:o}=x$2.add(this.Ah|0,this.Al|0,r|0,o|0))),{h:s,l:a}=x$2.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:u,l:i}=x$2.add(this.Ch|0,this.Cl|0,u|0,i|0),{h:D,l:c}=x$2.add(this.Dh|0,this.Dl|0,D|0,c|0),{h:l,l:p}=x$2.add(this.Eh|0,this.El|0,l|0,p|0),{h:w,l:h}=x$2.add(this.Fh|0,this.Fl|0,w|0,h|0),{h:g,l:S}=x$2.add(this.Gh|0,this.Gl|0,g|0,S|0),{h:v,l:L}=x$2.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$3.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$2=BigInt(0),N$3=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$2?n:e+n}function or$2(t,e,n){if(e<M$2)throw new Error("invalid exponent, negatives unsupported");if(n<=M$2)throw new Error("invalid modulus");if(n===N$3)return M$2;let r=N$3;for(;e>M$2;)e&N$3&&(r=r*t%n),t=t*t%n,e>>=N$3;return r}function J$4(t,e,n){let r=t;for(;e-- >M$2;)r*=r,r%=n;return r}function Ae$3(t,e){if(t===M$2)throw new Error("invert: expected non-zero number");if(e<=M$2)throw new Error("invert: expected positive modulus, got "+e);let n=H$2(t,e),r=e,o=M$2,s=N$3;for(;n!==M$2;){const u=r/n,i=r%n,D=o-s*u;r=n,n=i,o=s,s=D;}if(r!==N$3)throw new Error("invert: does not exist");return H$2(o,e)}function sr(t){const e=(t-N$3)/nt$2;let n,r,o;for(n=t-N$3,r=0;n%nt$2===M$2;n/=nt$2,r++);for(o=nt$2;o<t&&or$2(o,e,t)!==t-N$3;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const a=(t+N$3)/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$3)/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$3<<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$3)/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$3)===N$3,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$2)throw new Error("invalid exponent, negatives unsupported");if(n===M$2)return t.ONE;if(n===N$3)return e;let r=t.ONE,o=e;for(;n>M$2;)n&N$3&&(r=t.mul(r,o)),o=t.sqr(o),n>>=N$3;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$2)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$2,ONE:N$3,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$2<=i&&i<t},is0:i=>i===M$2,isOdd:i=>(i&N$3)===N$3,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$3=BigInt(0),j$3=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$3,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$3}}}),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$3,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$3,y:j$3};if(_!==j$3)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$3,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$3)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$3,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$3,r),E===G$3?F:this.is0()||E===j$3?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$3?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$3,T);const $=c(_*_),R=c($-j$3),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$3)===j$3,et=(U&128)!==0;if(!b&&Z===G$3&&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$3?128:0,E}toHex(){return Ft$3(this.toRawBytes())}}d.BASE=new d(e.Gx,e.Gy,j$3,c(e.Gx*e.Gy)),d.ZERO=new d(G$3,j$3,j$3,G$3);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$3,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=({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({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jr$2=Object.freeze({__proto__:null,base2:Rr$2});const Zr$2=k({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({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kr$2=k({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({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Pr$2=k({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qr$2=k({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),to$2=k({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eo$2=k({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),no$1=k({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ro$1=k({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oo$1=k({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),so$2=k({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({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bo$2=k({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),po$2=k({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo$2=k({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})}
|
|
24285
|
+
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})}
|
|
24252
24286
|
|
|
24253
24287
|
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
24254
24288
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
@@ -24453,15 +24487,15 @@ function createVersionParts(count) {
|
|
|
24453
24487
|
return output;
|
|
24454
24488
|
}
|
|
24455
24489
|
|
|
24456
|
-
var cjs$
|
|
24490
|
+
var cjs$3 = {};
|
|
24457
24491
|
|
|
24458
|
-
var hasRequiredCjs$
|
|
24492
|
+
var hasRequiredCjs$3;
|
|
24459
24493
|
|
|
24460
|
-
function requireCjs$
|
|
24461
|
-
if (hasRequiredCjs$
|
|
24462
|
-
hasRequiredCjs$
|
|
24463
|
-
Object.defineProperty(cjs$
|
|
24464
|
-
cjs$
|
|
24494
|
+
function requireCjs$3 () {
|
|
24495
|
+
if (hasRequiredCjs$3) return cjs$3;
|
|
24496
|
+
hasRequiredCjs$3 = 1;
|
|
24497
|
+
Object.defineProperty(cjs$3, "__esModule", { value: true });
|
|
24498
|
+
cjs$3.getLocalStorage = cjs$3.getLocalStorageOrThrow = cjs$3.getCrypto = cjs$3.getCryptoOrThrow = cjs$3.getLocation = cjs$3.getLocationOrThrow = cjs$3.getNavigator = cjs$3.getNavigatorOrThrow = cjs$3.getDocument = cjs$3.getDocumentOrThrow = cjs$3.getFromWindowOrThrow = cjs$3.getFromWindow = void 0;
|
|
24465
24499
|
function getFromWindow(name) {
|
|
24466
24500
|
let res = undefined;
|
|
24467
24501
|
if (typeof window !== "undefined" && typeof window[name] !== "undefined") {
|
|
@@ -24469,7 +24503,7 @@ function requireCjs$2 () {
|
|
|
24469
24503
|
}
|
|
24470
24504
|
return res;
|
|
24471
24505
|
}
|
|
24472
|
-
cjs$
|
|
24506
|
+
cjs$3.getFromWindow = getFromWindow;
|
|
24473
24507
|
function getFromWindowOrThrow(name) {
|
|
24474
24508
|
const res = getFromWindow(name);
|
|
24475
24509
|
if (!res) {
|
|
@@ -24477,63 +24511,63 @@ function requireCjs$2 () {
|
|
|
24477
24511
|
}
|
|
24478
24512
|
return res;
|
|
24479
24513
|
}
|
|
24480
|
-
cjs$
|
|
24514
|
+
cjs$3.getFromWindowOrThrow = getFromWindowOrThrow;
|
|
24481
24515
|
function getDocumentOrThrow() {
|
|
24482
24516
|
return getFromWindowOrThrow("document");
|
|
24483
24517
|
}
|
|
24484
|
-
cjs$
|
|
24518
|
+
cjs$3.getDocumentOrThrow = getDocumentOrThrow;
|
|
24485
24519
|
function getDocument() {
|
|
24486
24520
|
return getFromWindow("document");
|
|
24487
24521
|
}
|
|
24488
|
-
cjs$
|
|
24522
|
+
cjs$3.getDocument = getDocument;
|
|
24489
24523
|
function getNavigatorOrThrow() {
|
|
24490
24524
|
return getFromWindowOrThrow("navigator");
|
|
24491
24525
|
}
|
|
24492
|
-
cjs$
|
|
24526
|
+
cjs$3.getNavigatorOrThrow = getNavigatorOrThrow;
|
|
24493
24527
|
function getNavigator() {
|
|
24494
24528
|
return getFromWindow("navigator");
|
|
24495
24529
|
}
|
|
24496
|
-
cjs$
|
|
24530
|
+
cjs$3.getNavigator = getNavigator;
|
|
24497
24531
|
function getLocationOrThrow() {
|
|
24498
24532
|
return getFromWindowOrThrow("location");
|
|
24499
24533
|
}
|
|
24500
|
-
cjs$
|
|
24534
|
+
cjs$3.getLocationOrThrow = getLocationOrThrow;
|
|
24501
24535
|
function getLocation() {
|
|
24502
24536
|
return getFromWindow("location");
|
|
24503
24537
|
}
|
|
24504
|
-
cjs$
|
|
24538
|
+
cjs$3.getLocation = getLocation;
|
|
24505
24539
|
function getCryptoOrThrow() {
|
|
24506
24540
|
return getFromWindowOrThrow("crypto");
|
|
24507
24541
|
}
|
|
24508
|
-
cjs$
|
|
24542
|
+
cjs$3.getCryptoOrThrow = getCryptoOrThrow;
|
|
24509
24543
|
function getCrypto() {
|
|
24510
24544
|
return getFromWindow("crypto");
|
|
24511
24545
|
}
|
|
24512
|
-
cjs$
|
|
24546
|
+
cjs$3.getCrypto = getCrypto;
|
|
24513
24547
|
function getLocalStorageOrThrow() {
|
|
24514
24548
|
return getFromWindowOrThrow("localStorage");
|
|
24515
24549
|
}
|
|
24516
|
-
cjs$
|
|
24550
|
+
cjs$3.getLocalStorageOrThrow = getLocalStorageOrThrow;
|
|
24517
24551
|
function getLocalStorage() {
|
|
24518
24552
|
return getFromWindow("localStorage");
|
|
24519
24553
|
}
|
|
24520
|
-
cjs$
|
|
24554
|
+
cjs$3.getLocalStorage = getLocalStorage;
|
|
24521
24555
|
|
|
24522
|
-
return cjs$
|
|
24556
|
+
return cjs$3;
|
|
24523
24557
|
}
|
|
24524
24558
|
|
|
24525
|
-
var cjsExports$2 = requireCjs$
|
|
24559
|
+
var cjsExports$2 = requireCjs$3();
|
|
24526
24560
|
|
|
24527
|
-
var cjs$
|
|
24561
|
+
var cjs$2 = {};
|
|
24528
24562
|
|
|
24529
|
-
var hasRequiredCjs$
|
|
24563
|
+
var hasRequiredCjs$2;
|
|
24530
24564
|
|
|
24531
|
-
function requireCjs$
|
|
24532
|
-
if (hasRequiredCjs$
|
|
24533
|
-
hasRequiredCjs$
|
|
24534
|
-
Object.defineProperty(cjs$
|
|
24535
|
-
cjs$
|
|
24536
|
-
const window_getters_1 = requireCjs$
|
|
24565
|
+
function requireCjs$2 () {
|
|
24566
|
+
if (hasRequiredCjs$2) return cjs$2;
|
|
24567
|
+
hasRequiredCjs$2 = 1;
|
|
24568
|
+
Object.defineProperty(cjs$2, "__esModule", { value: true });
|
|
24569
|
+
cjs$2.getWindowMetadata = void 0;
|
|
24570
|
+
const window_getters_1 = requireCjs$3();
|
|
24537
24571
|
function getWindowMetadata() {
|
|
24538
24572
|
let doc;
|
|
24539
24573
|
let loc;
|
|
@@ -24626,12 +24660,12 @@ function requireCjs$1 () {
|
|
|
24626
24660
|
};
|
|
24627
24661
|
return meta;
|
|
24628
24662
|
}
|
|
24629
|
-
cjs$
|
|
24663
|
+
cjs$2.getWindowMetadata = getWindowMetadata;
|
|
24630
24664
|
|
|
24631
|
-
return cjs$
|
|
24665
|
+
return cjs$2;
|
|
24632
24666
|
}
|
|
24633
24667
|
|
|
24634
|
-
var cjsExports$1 = requireCjs$
|
|
24668
|
+
var cjsExports$1 = requireCjs$2();
|
|
24635
24669
|
|
|
24636
24670
|
/** @internal */
|
|
24637
24671
|
const version = '0.1.1';
|
|
@@ -30467,8 +30501,8 @@ function base(ALPHABET, name) {
|
|
|
30467
30501
|
decode: decode
|
|
30468
30502
|
};
|
|
30469
30503
|
}
|
|
30470
|
-
var src
|
|
30471
|
-
var _brrp__multiformats_scope_baseX = src
|
|
30504
|
+
var src = base;
|
|
30505
|
+
var _brrp__multiformats_scope_baseX = src;
|
|
30472
30506
|
|
|
30473
30507
|
const coerce = o => {
|
|
30474
30508
|
if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
|
|
@@ -30955,7 +30989,7 @@ function toString(array, encoding = 'utf8') {
|
|
|
30955
30989
|
return base.encoder.encode(array).substring(1);
|
|
30956
30990
|
}
|
|
30957
30991
|
|
|
30958
|
-
const C$
|
|
30992
|
+
const C$3={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};
|
|
30959
30993
|
|
|
30960
30994
|
var util;
|
|
30961
30995
|
var hasRequiredUtil;
|
|
@@ -31812,134 +31846,652 @@ function requireBlakejs () {
|
|
|
31812
31846
|
|
|
31813
31847
|
var blakejsExports = requireBlakejs();
|
|
31814
31848
|
|
|
31815
|
-
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:
|
|
31816
|
-
${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 ue$2.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 ue$2.encode(o)}function Nc(t){const e=new Uint8Array($e$2(Yr$1(t)));return ue$2.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=>`
|
|
31817
|
-
- ${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(`
|
|
31818
|
-
`)};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$2[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.
|
|
31819
|
-
Required: ${a.toString()}
|
|
31820
|
-
Received: ${Object.keys(e).toString()}`)),It$3(i,c)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces chains don't satisfy required namespaces.
|
|
31821
|
-
Required: ${i.toString()}
|
|
31822
|
-
Approved: ${c.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||r)return;const d=Gt$2(e[l].accounts);d.includes(l)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces accounts don't satisfy namespace accounts for ${l}
|
|
31823
|
-
Required: ${l}
|
|
31824
|
-
Approved: ${d.toString()}`));}),i.forEach(l=>{r||(It$3(o[l].methods,s[l].methods)?It$3(o[l].events,s[l].events)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces events don't satisfy namespace events for ${l}`)):r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces methods don't satisfy namespace methods for ${l}`));}),r}function cu(t){const e={};return Object.keys(t).forEach(n=>{var r;n.includes(":")?e[n]=t[n]:(r=t[n].chains)==null||r.forEach(o=>{e[o]={methods:t[n].methods,events:t[n].events};});}),e}function Us$1(t){return [...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function fu(t){const e={};return Object.keys(t).forEach(n=>{if(n.includes(":"))e[n]=t[n];else {const r=Gt$2(t[n].accounts);r?.forEach(o=>{e[o]={accounts:t[n].accounts.filter(s=>s.includes(`${o}:`)),methods:t[n].methods,events:t[n].events};});}}),e}function au(t,e){return We$3(t,false)&&t<=e.max&&t>=e.min}function uu(){const t=Vt$2();return new Promise(e=>{switch(t){case et$2.browser:e(_s());break;case et$2.reactNative:e(Rs());break;case et$2.node:e($s$1());break;default:e(true);}})}function _s(){return Wt$2()&&navigator?.onLine}async function Rs(){if(At$2()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t?.isConnected}return true}function $s$1(){return true}function lu(t){switch(Vt$2()){case et$2.browser:Ts(t);break;case et$2.reactNative:Cs$1(t);break;}}function Ts(t){!At$2()&&Wt$2()&&(window.addEventListener("online",()=>t(true)),window.addEventListener("offline",()=>t(false)));}function Cs$1(t){At$2()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected));}function du(){var t;return Wt$2()&&cjsExports$2.getDocument()?((t=cjsExports$2.getDocument())==null?void 0:t.visibilityState)==="visible":true}const Wn$1={};class hu{static get(e){return Wn$1[e]}static set(e,n){Wn$1[e]=n;}static delete(e){delete Wn$1[e];}}function js$1(t){const e=ue$2.decode(t);if(e.length<33)throw new Error("Too short to contain a public key");return e.slice(1,33)}function Ls$1({publicKey:t,signature:e,payload:n}){var r;const o=Xn$1(n.method),s=128|parseInt(((r=n.version)==null?void 0:r.toString())||"4"),i=gu(n.address),c=n.era==="00"?new Uint8Array([0]):Xn$1(n.era);if(c.length!==1&&c.length!==2)throw new Error("Invalid era length");const f=parseInt(n.nonce,16),u=new Uint8Array([f&255,f>>8&255]),a=BigInt(`0x${pu(n.tip)}`),l=yu(a),d=new Uint8Array([0,...t,i,...e,...c,...u,...l,...o]),h=bu(d.length+1);return new Uint8Array([...h,s,...d])}function ks$1(t){const e=Xn$1(t),n=blakejsExports.blake2b(e,void 0,32);return "0x"+Buffer.from(n).toString("hex")}function Xn$1(t){return new Uint8Array(t.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}function pu(t){return t.startsWith("0x")?t.slice(2):t}function gu(t){const e=ue$2.decode(t)[0];return e===42?0:e===60?2:1}function bu(t){if(t<64)return new Uint8Array([t<<2]);if(t<16384){const e=t<<2|1;return new Uint8Array([e&255,e>>8&255])}else if(t<1<<30){const e=t<<2|2;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}else throw new Error("Compact encoding > 2^30 not supported")}function yu(t){if(t<BigInt(1)<<BigInt(6))return new Uint8Array([Number(t<<BigInt(2))]);if(t<BigInt(1)<<BigInt(14)){const e=t<<BigInt(2)|BigInt(1);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255))])}else if(t<BigInt(1)<<BigInt(30)){const e=t<<BigInt(2)|BigInt(2);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255)),Number(e>>BigInt(16)&BigInt(255)),Number(e>>BigInt(24)&BigInt(255))])}else throw new Error("BigInt compact encoding not supported > 2^30")}function mu(t){const e=Uint8Array.from(Buffer.from(t.signature,"hex")),n=js$1(t.transaction.address),r=Ls$1({publicKey:n,signature:e,payload:t.transaction}),o=Buffer.from(r).toString("hex");return ks$1(o)}function wu({logger:t,name:e}){const n=typeof t=="string"?Y$2({opts:{level:t,name:e}}).logger:t;return n.level=typeof t=="string"?t:t.level,n}
|
|
31825
|
-
|
|
31826
|
-
const PARSE_ERROR = "PARSE_ERROR";
|
|
31827
|
-
const INVALID_REQUEST = "INVALID_REQUEST";
|
|
31828
|
-
const METHOD_NOT_FOUND = "METHOD_NOT_FOUND";
|
|
31829
|
-
const INVALID_PARAMS = "INVALID_PARAMS";
|
|
31830
|
-
const INTERNAL_ERROR = "INTERNAL_ERROR";
|
|
31831
|
-
const SERVER_ERROR = "SERVER_ERROR";
|
|
31832
|
-
const RESERVED_ERROR_CODES = [-32700, -32600, -32601, -32602, -32603];
|
|
31833
|
-
const STANDARD_ERROR_MAP = {
|
|
31834
|
-
[PARSE_ERROR]: { code: -32700, message: "Parse error" },
|
|
31835
|
-
[INVALID_REQUEST]: { code: -32600, message: "Invalid Request" },
|
|
31836
|
-
[METHOD_NOT_FOUND]: { code: -32601, message: "Method not found" },
|
|
31837
|
-
[INVALID_PARAMS]: { code: -32602, message: "Invalid params" },
|
|
31838
|
-
[INTERNAL_ERROR]: { code: -32603, message: "Internal error" },
|
|
31839
|
-
[SERVER_ERROR]: { code: -32e3, message: "Server error" },
|
|
31840
|
-
};
|
|
31841
|
-
const DEFAULT_ERROR = SERVER_ERROR;
|
|
31849
|
+
var browser = {exports: {}};
|
|
31842
31850
|
|
|
31843
|
-
|
|
31844
|
-
return RESERVED_ERROR_CODES.includes(code);
|
|
31845
|
-
}
|
|
31846
|
-
function getError(type) {
|
|
31847
|
-
if (!Object.keys(STANDARD_ERROR_MAP).includes(type)) {
|
|
31848
|
-
return STANDARD_ERROR_MAP[DEFAULT_ERROR];
|
|
31849
|
-
}
|
|
31850
|
-
return STANDARD_ERROR_MAP[type];
|
|
31851
|
-
}
|
|
31852
|
-
function getErrorByCode(code) {
|
|
31853
|
-
const match = Object.values(STANDARD_ERROR_MAP).find(e => e.code === code);
|
|
31854
|
-
if (!match) {
|
|
31855
|
-
return STANDARD_ERROR_MAP[DEFAULT_ERROR];
|
|
31856
|
-
}
|
|
31857
|
-
return match;
|
|
31858
|
-
}
|
|
31859
|
-
function parseConnectionError(e, url, type) {
|
|
31860
|
-
return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED")
|
|
31861
|
-
? new Error(`Unavailable ${type} RPC url at ${url}`)
|
|
31862
|
-
: e;
|
|
31863
|
-
}
|
|
31851
|
+
var hasRequiredBrowser;
|
|
31864
31852
|
|
|
31865
|
-
|
|
31853
|
+
function requireBrowser () {
|
|
31854
|
+
if (hasRequiredBrowser) return browser.exports;
|
|
31855
|
+
hasRequiredBrowser = 1;
|
|
31866
31856
|
|
|
31867
|
-
|
|
31857
|
+
const format = requireQuickFormatUnescaped();
|
|
31868
31858
|
|
|
31869
|
-
|
|
31859
|
+
browser.exports = pino;
|
|
31870
31860
|
|
|
31871
|
-
|
|
31872
|
-
|
|
31873
|
-
|
|
31874
|
-
|
|
31875
|
-
|
|
31876
|
-
|
|
31877
|
-
|
|
31878
|
-
|
|
31879
|
-
|
|
31880
|
-
|
|
31881
|
-
|
|
31882
|
-
|
|
31883
|
-
|
|
31884
|
-
|
|
31885
|
-
|
|
31886
|
-
|
|
31861
|
+
const _console = pfGlobalThisOrFallback().console || {};
|
|
31862
|
+
const stdSerializers = {
|
|
31863
|
+
mapHttpRequest: mock,
|
|
31864
|
+
mapHttpResponse: mock,
|
|
31865
|
+
wrapRequestSerializer: passthrough,
|
|
31866
|
+
wrapResponseSerializer: passthrough,
|
|
31867
|
+
wrapErrorSerializer: passthrough,
|
|
31868
|
+
req: mock,
|
|
31869
|
+
res: mock,
|
|
31870
|
+
err: asErrValue,
|
|
31871
|
+
errWithCause: asErrValue
|
|
31872
|
+
};
|
|
31873
|
+
function levelToValue (level, logger) {
|
|
31874
|
+
return level === 'silent'
|
|
31875
|
+
? Infinity
|
|
31876
|
+
: logger.levels.values[level]
|
|
31887
31877
|
}
|
|
31888
|
-
|
|
31889
|
-
|
|
31890
|
-
return crypto$1;
|
|
31891
|
-
}
|
|
31892
|
-
|
|
31893
|
-
var env = {};
|
|
31878
|
+
const baseLogFunctionSymbol = Symbol('pino.logFuncs');
|
|
31879
|
+
const hierarchySymbol = Symbol('pino.hierarchy');
|
|
31894
31880
|
|
|
31895
|
-
|
|
31881
|
+
const logFallbackMap = {
|
|
31882
|
+
error: 'log',
|
|
31883
|
+
fatal: 'error',
|
|
31884
|
+
warn: 'error',
|
|
31885
|
+
info: 'log',
|
|
31886
|
+
debug: 'log',
|
|
31887
|
+
trace: 'log'
|
|
31888
|
+
};
|
|
31896
31889
|
|
|
31897
|
-
function
|
|
31898
|
-
|
|
31899
|
-
|
|
31900
|
-
|
|
31901
|
-
|
|
31902
|
-
|
|
31903
|
-
return (typeof document === "undefined" &&
|
|
31904
|
-
typeof navigator !== "undefined" &&
|
|
31905
|
-
navigator.product === "ReactNative");
|
|
31890
|
+
function appendChildLogger (parentLogger, childLogger) {
|
|
31891
|
+
const newEntry = {
|
|
31892
|
+
logger: childLogger,
|
|
31893
|
+
parent: parentLogger[hierarchySymbol]
|
|
31894
|
+
};
|
|
31895
|
+
childLogger[hierarchySymbol] = newEntry;
|
|
31906
31896
|
}
|
|
31907
|
-
|
|
31908
|
-
function
|
|
31909
|
-
|
|
31910
|
-
|
|
31911
|
-
|
|
31897
|
+
|
|
31898
|
+
function setupBaseLogFunctions (logger, levels, proto) {
|
|
31899
|
+
const logFunctions = {};
|
|
31900
|
+
levels.forEach(level => {
|
|
31901
|
+
logFunctions[level] = proto[level] ? proto[level] : (_console[level] || _console[logFallbackMap[level] || 'log'] || noop);
|
|
31902
|
+
});
|
|
31903
|
+
logger[baseLogFunctionSymbol] = logFunctions;
|
|
31912
31904
|
}
|
|
31913
|
-
|
|
31914
|
-
function
|
|
31915
|
-
|
|
31905
|
+
|
|
31906
|
+
function shouldSerialize (serialize, serializers) {
|
|
31907
|
+
if (Array.isArray(serialize)) {
|
|
31908
|
+
const hasToFilter = serialize.filter(function (k) {
|
|
31909
|
+
return k !== '!stdSerializers.err'
|
|
31910
|
+
});
|
|
31911
|
+
return hasToFilter
|
|
31912
|
+
} else if (serialize === true) {
|
|
31913
|
+
return Object.keys(serializers)
|
|
31914
|
+
}
|
|
31915
|
+
|
|
31916
|
+
return false
|
|
31916
31917
|
}
|
|
31917
|
-
env.isBrowser = isBrowser;
|
|
31918
|
-
|
|
31919
|
-
return env;
|
|
31920
|
-
}
|
|
31921
31918
|
|
|
31922
|
-
|
|
31919
|
+
function pino (opts) {
|
|
31920
|
+
opts = opts || {};
|
|
31921
|
+
opts.browser = opts.browser || {};
|
|
31923
31922
|
|
|
31924
|
-
|
|
31925
|
-
|
|
31926
|
-
hasRequiredCjs = 1;
|
|
31927
|
-
(function (exports$1) {
|
|
31928
|
-
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
31929
|
-
const tslib_1 = require$$0;
|
|
31930
|
-
tslib_1.__exportStar(requireCrypto(), exports$1);
|
|
31931
|
-
tslib_1.__exportStar(requireEnv(), exports$1);
|
|
31932
|
-
|
|
31933
|
-
} (cjs));
|
|
31934
|
-
return cjs;
|
|
31935
|
-
}
|
|
31923
|
+
const transmit = opts.browser.transmit;
|
|
31924
|
+
if (transmit && typeof transmit.send !== 'function') { throw Error('pino: transmit option must have a send function') }
|
|
31936
31925
|
|
|
31937
|
-
|
|
31926
|
+
const proto = opts.browser.write || _console;
|
|
31927
|
+
if (opts.browser.write) opts.browser.asObject = true;
|
|
31928
|
+
const serializers = opts.serializers || {};
|
|
31929
|
+
const serialize = shouldSerialize(opts.browser.serialize, serializers);
|
|
31930
|
+
let stdErrSerialize = opts.browser.serialize;
|
|
31938
31931
|
|
|
31939
|
-
|
|
31940
|
-
|
|
31941
|
-
|
|
31942
|
-
|
|
31932
|
+
if (
|
|
31933
|
+
Array.isArray(opts.browser.serialize) &&
|
|
31934
|
+
opts.browser.serialize.indexOf('!stdSerializers.err') > -1
|
|
31935
|
+
) stdErrSerialize = false;
|
|
31936
|
+
|
|
31937
|
+
const customLevels = Object.keys(opts.customLevels || {});
|
|
31938
|
+
const levels = ['error', 'fatal', 'warn', 'info', 'debug', 'trace'].concat(customLevels);
|
|
31939
|
+
|
|
31940
|
+
if (typeof proto === 'function') {
|
|
31941
|
+
levels.forEach(function (level) {
|
|
31942
|
+
proto[level] = proto;
|
|
31943
|
+
});
|
|
31944
|
+
}
|
|
31945
|
+
if (opts.enabled === false || opts.browser.disabled) opts.level = 'silent';
|
|
31946
|
+
const level = opts.level || 'info';
|
|
31947
|
+
const logger = Object.create(proto);
|
|
31948
|
+
if (!logger.log) logger.log = noop;
|
|
31949
|
+
|
|
31950
|
+
setupBaseLogFunctions(logger, levels, proto);
|
|
31951
|
+
// setup root hierarchy entry
|
|
31952
|
+
appendChildLogger({}, logger);
|
|
31953
|
+
|
|
31954
|
+
Object.defineProperty(logger, 'levelVal', {
|
|
31955
|
+
get: getLevelVal
|
|
31956
|
+
});
|
|
31957
|
+
Object.defineProperty(logger, 'level', {
|
|
31958
|
+
get: getLevel,
|
|
31959
|
+
set: setLevel
|
|
31960
|
+
});
|
|
31961
|
+
|
|
31962
|
+
const setOpts = {
|
|
31963
|
+
transmit,
|
|
31964
|
+
serialize,
|
|
31965
|
+
asObject: opts.browser.asObject,
|
|
31966
|
+
asObjectBindingsOnly: opts.browser.asObjectBindingsOnly,
|
|
31967
|
+
formatters: opts.browser.formatters,
|
|
31968
|
+
levels,
|
|
31969
|
+
timestamp: getTimeFunction(opts),
|
|
31970
|
+
messageKey: opts.messageKey || 'msg',
|
|
31971
|
+
onChild: opts.onChild || noop
|
|
31972
|
+
};
|
|
31973
|
+
logger.levels = getLevels(opts);
|
|
31974
|
+
logger.level = level;
|
|
31975
|
+
|
|
31976
|
+
logger.isLevelEnabled = function (level) {
|
|
31977
|
+
if (!this.levels.values[level]) {
|
|
31978
|
+
return false
|
|
31979
|
+
}
|
|
31980
|
+
|
|
31981
|
+
return this.levels.values[level] >= this.levels.values[this.level]
|
|
31982
|
+
};
|
|
31983
|
+
logger.setMaxListeners = logger.getMaxListeners =
|
|
31984
|
+
logger.emit = logger.addListener = logger.on =
|
|
31985
|
+
logger.prependListener = logger.once =
|
|
31986
|
+
logger.prependOnceListener = logger.removeListener =
|
|
31987
|
+
logger.removeAllListeners = logger.listeners =
|
|
31988
|
+
logger.listenerCount = logger.eventNames =
|
|
31989
|
+
logger.write = logger.flush = noop;
|
|
31990
|
+
logger.serializers = serializers;
|
|
31991
|
+
logger._serialize = serialize;
|
|
31992
|
+
logger._stdErrSerialize = stdErrSerialize;
|
|
31993
|
+
logger.child = function (...args) { return child.call(this, setOpts, ...args) };
|
|
31994
|
+
|
|
31995
|
+
if (transmit) logger._logEvent = createLogEventShape();
|
|
31996
|
+
|
|
31997
|
+
function getLevelVal () {
|
|
31998
|
+
return levelToValue(this.level, this)
|
|
31999
|
+
}
|
|
32000
|
+
|
|
32001
|
+
function getLevel () {
|
|
32002
|
+
return this._level
|
|
32003
|
+
}
|
|
32004
|
+
function setLevel (level) {
|
|
32005
|
+
if (level !== 'silent' && !this.levels.values[level]) {
|
|
32006
|
+
throw Error('unknown level ' + level)
|
|
32007
|
+
}
|
|
32008
|
+
this._level = level;
|
|
32009
|
+
|
|
32010
|
+
set(this, setOpts, logger, 'error'); // <-- must stay first
|
|
32011
|
+
set(this, setOpts, logger, 'fatal');
|
|
32012
|
+
set(this, setOpts, logger, 'warn');
|
|
32013
|
+
set(this, setOpts, logger, 'info');
|
|
32014
|
+
set(this, setOpts, logger, 'debug');
|
|
32015
|
+
set(this, setOpts, logger, 'trace');
|
|
32016
|
+
|
|
32017
|
+
customLevels.forEach((level) => {
|
|
32018
|
+
set(this, setOpts, logger, level);
|
|
32019
|
+
});
|
|
32020
|
+
}
|
|
32021
|
+
|
|
32022
|
+
function child (setOpts, bindings, childOptions) {
|
|
32023
|
+
if (!bindings) {
|
|
32024
|
+
throw new Error('missing bindings for child Pino')
|
|
32025
|
+
}
|
|
32026
|
+
childOptions = childOptions || {};
|
|
32027
|
+
if (serialize && bindings.serializers) {
|
|
32028
|
+
childOptions.serializers = bindings.serializers;
|
|
32029
|
+
}
|
|
32030
|
+
const childOptionsSerializers = childOptions.serializers;
|
|
32031
|
+
if (serialize && childOptionsSerializers) {
|
|
32032
|
+
var childSerializers = Object.assign({}, serializers, childOptionsSerializers);
|
|
32033
|
+
var childSerialize = opts.browser.serialize === true
|
|
32034
|
+
? Object.keys(childSerializers)
|
|
32035
|
+
: serialize;
|
|
32036
|
+
delete bindings.serializers;
|
|
32037
|
+
applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize);
|
|
32038
|
+
}
|
|
32039
|
+
function Child (parent) {
|
|
32040
|
+
this._childLevel = (parent._childLevel | 0) + 1;
|
|
32041
|
+
|
|
32042
|
+
// make sure bindings are available in the `set` function
|
|
32043
|
+
this.bindings = bindings;
|
|
32044
|
+
|
|
32045
|
+
if (childSerializers) {
|
|
32046
|
+
this.serializers = childSerializers;
|
|
32047
|
+
this._serialize = childSerialize;
|
|
32048
|
+
}
|
|
32049
|
+
if (transmit) {
|
|
32050
|
+
this._logEvent = createLogEventShape(
|
|
32051
|
+
[].concat(parent._logEvent.bindings, bindings)
|
|
32052
|
+
);
|
|
32053
|
+
}
|
|
32054
|
+
}
|
|
32055
|
+
Child.prototype = this;
|
|
32056
|
+
const newLogger = new Child(this);
|
|
32057
|
+
|
|
32058
|
+
// must happen before the level is assigned
|
|
32059
|
+
appendChildLogger(this, newLogger);
|
|
32060
|
+
newLogger.child = function (...args) { return child.call(this, setOpts, ...args) };
|
|
32061
|
+
// required to actually initialize the logger functions for any given child
|
|
32062
|
+
newLogger.level = childOptions.level || this.level; // allow level to be set by childOptions
|
|
32063
|
+
setOpts.onChild(newLogger);
|
|
32064
|
+
|
|
32065
|
+
return newLogger
|
|
32066
|
+
}
|
|
32067
|
+
return logger
|
|
32068
|
+
}
|
|
32069
|
+
|
|
32070
|
+
function getLevels (opts) {
|
|
32071
|
+
const customLevels = opts.customLevels || {};
|
|
32072
|
+
|
|
32073
|
+
const values = Object.assign({}, pino.levels.values, customLevels);
|
|
32074
|
+
const labels = Object.assign({}, pino.levels.labels, invertObject(customLevels));
|
|
32075
|
+
|
|
32076
|
+
return {
|
|
32077
|
+
values,
|
|
32078
|
+
labels
|
|
32079
|
+
}
|
|
32080
|
+
}
|
|
32081
|
+
|
|
32082
|
+
function invertObject (obj) {
|
|
32083
|
+
const inverted = {};
|
|
32084
|
+
Object.keys(obj).forEach(function (key) {
|
|
32085
|
+
inverted[obj[key]] = key;
|
|
32086
|
+
});
|
|
32087
|
+
return inverted
|
|
32088
|
+
}
|
|
32089
|
+
|
|
32090
|
+
pino.levels = {
|
|
32091
|
+
values: {
|
|
32092
|
+
fatal: 60,
|
|
32093
|
+
error: 50,
|
|
32094
|
+
warn: 40,
|
|
32095
|
+
info: 30,
|
|
32096
|
+
debug: 20,
|
|
32097
|
+
trace: 10
|
|
32098
|
+
},
|
|
32099
|
+
labels: {
|
|
32100
|
+
10: 'trace',
|
|
32101
|
+
20: 'debug',
|
|
32102
|
+
30: 'info',
|
|
32103
|
+
40: 'warn',
|
|
32104
|
+
50: 'error',
|
|
32105
|
+
60: 'fatal'
|
|
32106
|
+
}
|
|
32107
|
+
};
|
|
32108
|
+
|
|
32109
|
+
pino.stdSerializers = stdSerializers;
|
|
32110
|
+
pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime });
|
|
32111
|
+
|
|
32112
|
+
function getBindingChain (logger) {
|
|
32113
|
+
const bindings = [];
|
|
32114
|
+
if (logger.bindings) {
|
|
32115
|
+
bindings.push(logger.bindings);
|
|
32116
|
+
}
|
|
32117
|
+
|
|
32118
|
+
// traverse up the tree to get all bindings
|
|
32119
|
+
let hierarchy = logger[hierarchySymbol];
|
|
32120
|
+
while (hierarchy.parent) {
|
|
32121
|
+
hierarchy = hierarchy.parent;
|
|
32122
|
+
if (hierarchy.logger.bindings) {
|
|
32123
|
+
bindings.push(hierarchy.logger.bindings);
|
|
32124
|
+
}
|
|
32125
|
+
}
|
|
32126
|
+
|
|
32127
|
+
return bindings.reverse()
|
|
32128
|
+
}
|
|
32129
|
+
|
|
32130
|
+
function set (self, opts, rootLogger, level) {
|
|
32131
|
+
// override the current log functions with either `noop` or the base log function
|
|
32132
|
+
Object.defineProperty(self, level, {
|
|
32133
|
+
value: (levelToValue(self.level, rootLogger) > levelToValue(level, rootLogger)
|
|
32134
|
+
? noop
|
|
32135
|
+
: rootLogger[baseLogFunctionSymbol][level]),
|
|
32136
|
+
writable: true,
|
|
32137
|
+
enumerable: true,
|
|
32138
|
+
configurable: true
|
|
32139
|
+
});
|
|
32140
|
+
|
|
32141
|
+
if (self[level] === noop) {
|
|
32142
|
+
if (!opts.transmit) return
|
|
32143
|
+
|
|
32144
|
+
const transmitLevel = opts.transmit.level || self.level;
|
|
32145
|
+
const transmitValue = levelToValue(transmitLevel, rootLogger);
|
|
32146
|
+
const methodValue = levelToValue(level, rootLogger);
|
|
32147
|
+
if (methodValue < transmitValue) return
|
|
32148
|
+
}
|
|
32149
|
+
|
|
32150
|
+
// make sure the log format is correct
|
|
32151
|
+
self[level] = createWrap(self, opts, rootLogger, level);
|
|
32152
|
+
|
|
32153
|
+
// prepend bindings if it is not the root logger
|
|
32154
|
+
const bindings = getBindingChain(self);
|
|
32155
|
+
if (bindings.length === 0) {
|
|
32156
|
+
// early exit in case for rootLogger
|
|
32157
|
+
return
|
|
32158
|
+
}
|
|
32159
|
+
self[level] = prependBindingsInArguments(bindings, self[level]);
|
|
32160
|
+
}
|
|
32161
|
+
|
|
32162
|
+
function prependBindingsInArguments (bindings, logFunc) {
|
|
32163
|
+
return function () {
|
|
32164
|
+
return logFunc.apply(this, [...bindings, ...arguments])
|
|
32165
|
+
}
|
|
32166
|
+
}
|
|
32167
|
+
|
|
32168
|
+
function createWrap (self, opts, rootLogger, level) {
|
|
32169
|
+
return (function (write) {
|
|
32170
|
+
return function LOG () {
|
|
32171
|
+
const ts = opts.timestamp();
|
|
32172
|
+
const args = new Array(arguments.length);
|
|
32173
|
+
const proto = (Object.getPrototypeOf && Object.getPrototypeOf(this) === _console) ? _console : this;
|
|
32174
|
+
for (var i = 0; i < args.length; i++) args[i] = arguments[i];
|
|
32175
|
+
|
|
32176
|
+
var argsIsSerialized = false;
|
|
32177
|
+
if (opts.serialize) {
|
|
32178
|
+
applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize);
|
|
32179
|
+
argsIsSerialized = true;
|
|
32180
|
+
}
|
|
32181
|
+
if (opts.asObject || opts.formatters) {
|
|
32182
|
+
write.call(proto, ...asObject(this, level, args, ts, opts));
|
|
32183
|
+
} else write.apply(proto, args);
|
|
32184
|
+
|
|
32185
|
+
if (opts.transmit) {
|
|
32186
|
+
const transmitLevel = opts.transmit.level || self._level;
|
|
32187
|
+
const transmitValue = levelToValue(transmitLevel, rootLogger);
|
|
32188
|
+
const methodValue = levelToValue(level, rootLogger);
|
|
32189
|
+
if (methodValue < transmitValue) return
|
|
32190
|
+
transmit(this, {
|
|
32191
|
+
ts,
|
|
32192
|
+
methodLevel: level,
|
|
32193
|
+
methodValue,
|
|
32194
|
+
transmitValue: rootLogger.levels.values[opts.transmit.level || self._level],
|
|
32195
|
+
send: opts.transmit.send,
|
|
32196
|
+
val: levelToValue(self._level, rootLogger)
|
|
32197
|
+
}, args, argsIsSerialized);
|
|
32198
|
+
}
|
|
32199
|
+
}
|
|
32200
|
+
})(self[baseLogFunctionSymbol][level])
|
|
32201
|
+
}
|
|
32202
|
+
|
|
32203
|
+
function asObject (logger, level, args, ts, opts) {
|
|
32204
|
+
const {
|
|
32205
|
+
level: levelFormatter,
|
|
32206
|
+
log: logObjectFormatter = (obj) => obj
|
|
32207
|
+
} = opts.formatters || {};
|
|
32208
|
+
const argsCloned = args.slice();
|
|
32209
|
+
let msg = argsCloned[0];
|
|
32210
|
+
const logObject = {};
|
|
32211
|
+
|
|
32212
|
+
let lvl = (logger._childLevel | 0) + 1;
|
|
32213
|
+
if (lvl < 1) lvl = 1;
|
|
32214
|
+
|
|
32215
|
+
if (ts) {
|
|
32216
|
+
logObject.time = ts;
|
|
32217
|
+
}
|
|
32218
|
+
|
|
32219
|
+
if (levelFormatter) {
|
|
32220
|
+
const formattedLevel = levelFormatter(level, logger.levels.values[level]);
|
|
32221
|
+
Object.assign(logObject, formattedLevel);
|
|
32222
|
+
} else {
|
|
32223
|
+
logObject.level = logger.levels.values[level];
|
|
32224
|
+
}
|
|
32225
|
+
|
|
32226
|
+
if (opts.asObjectBindingsOnly) {
|
|
32227
|
+
if (msg !== null && typeof msg === 'object') {
|
|
32228
|
+
while (lvl-- && typeof argsCloned[0] === 'object') {
|
|
32229
|
+
Object.assign(logObject, argsCloned.shift());
|
|
32230
|
+
}
|
|
32231
|
+
}
|
|
32232
|
+
|
|
32233
|
+
const formattedLogObject = logObjectFormatter(logObject);
|
|
32234
|
+
return [formattedLogObject, ...argsCloned]
|
|
32235
|
+
} else {
|
|
32236
|
+
// deliberate, catching objects, arrays
|
|
32237
|
+
if (msg !== null && typeof msg === 'object') {
|
|
32238
|
+
while (lvl-- && typeof argsCloned[0] === 'object') {
|
|
32239
|
+
Object.assign(logObject, argsCloned.shift());
|
|
32240
|
+
}
|
|
32241
|
+
msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : undefined;
|
|
32242
|
+
} else if (typeof msg === 'string') msg = format(argsCloned.shift(), argsCloned);
|
|
32243
|
+
if (msg !== undefined) logObject[opts.messageKey] = msg;
|
|
32244
|
+
|
|
32245
|
+
const formattedLogObject = logObjectFormatter(logObject);
|
|
32246
|
+
return [formattedLogObject]
|
|
32247
|
+
}
|
|
32248
|
+
}
|
|
32249
|
+
|
|
32250
|
+
function applySerializers (args, serialize, serializers, stdErrSerialize) {
|
|
32251
|
+
for (const i in args) {
|
|
32252
|
+
if (stdErrSerialize && args[i] instanceof Error) {
|
|
32253
|
+
args[i] = pino.stdSerializers.err(args[i]);
|
|
32254
|
+
} else if (typeof args[i] === 'object' && !Array.isArray(args[i]) && serialize) {
|
|
32255
|
+
for (const k in args[i]) {
|
|
32256
|
+
if (serialize.indexOf(k) > -1 && k in serializers) {
|
|
32257
|
+
args[i][k] = serializers[k](args[i][k]);
|
|
32258
|
+
}
|
|
32259
|
+
}
|
|
32260
|
+
}
|
|
32261
|
+
}
|
|
32262
|
+
}
|
|
32263
|
+
|
|
32264
|
+
function transmit (logger, opts, args, argsIsSerialized = false) {
|
|
32265
|
+
const send = opts.send;
|
|
32266
|
+
const ts = opts.ts;
|
|
32267
|
+
const methodLevel = opts.methodLevel;
|
|
32268
|
+
const methodValue = opts.methodValue;
|
|
32269
|
+
const val = opts.val;
|
|
32270
|
+
const bindings = logger._logEvent.bindings;
|
|
32271
|
+
|
|
32272
|
+
if (!argsIsSerialized) {
|
|
32273
|
+
applySerializers(
|
|
32274
|
+
args,
|
|
32275
|
+
logger._serialize || Object.keys(logger.serializers),
|
|
32276
|
+
logger.serializers,
|
|
32277
|
+
logger._stdErrSerialize === undefined ? true : logger._stdErrSerialize
|
|
32278
|
+
);
|
|
32279
|
+
}
|
|
32280
|
+
|
|
32281
|
+
logger._logEvent.ts = ts;
|
|
32282
|
+
logger._logEvent.messages = args.filter(function (arg) {
|
|
32283
|
+
// bindings can only be objects, so reference equality check via indexOf is fine
|
|
32284
|
+
return bindings.indexOf(arg) === -1
|
|
32285
|
+
});
|
|
32286
|
+
|
|
32287
|
+
logger._logEvent.level.label = methodLevel;
|
|
32288
|
+
logger._logEvent.level.value = methodValue;
|
|
32289
|
+
|
|
32290
|
+
send(methodLevel, logger._logEvent, val);
|
|
32291
|
+
|
|
32292
|
+
logger._logEvent = createLogEventShape(bindings);
|
|
32293
|
+
}
|
|
32294
|
+
|
|
32295
|
+
function createLogEventShape (bindings) {
|
|
32296
|
+
return {
|
|
32297
|
+
ts: 0,
|
|
32298
|
+
messages: [],
|
|
32299
|
+
bindings: bindings || [],
|
|
32300
|
+
level: { label: '', value: 0 }
|
|
32301
|
+
}
|
|
32302
|
+
}
|
|
32303
|
+
|
|
32304
|
+
function asErrValue (err) {
|
|
32305
|
+
const obj = {
|
|
32306
|
+
type: err.constructor.name,
|
|
32307
|
+
msg: err.message,
|
|
32308
|
+
stack: err.stack
|
|
32309
|
+
};
|
|
32310
|
+
for (const key in err) {
|
|
32311
|
+
if (obj[key] === undefined) {
|
|
32312
|
+
obj[key] = err[key];
|
|
32313
|
+
}
|
|
32314
|
+
}
|
|
32315
|
+
return obj
|
|
32316
|
+
}
|
|
32317
|
+
|
|
32318
|
+
function getTimeFunction (opts) {
|
|
32319
|
+
if (typeof opts.timestamp === 'function') {
|
|
32320
|
+
return opts.timestamp
|
|
32321
|
+
}
|
|
32322
|
+
if (opts.timestamp === false) {
|
|
32323
|
+
return nullTime
|
|
32324
|
+
}
|
|
32325
|
+
return epochTime
|
|
32326
|
+
}
|
|
32327
|
+
|
|
32328
|
+
function mock () { return {} }
|
|
32329
|
+
function passthrough (a) { return a }
|
|
32330
|
+
function noop () {}
|
|
32331
|
+
|
|
32332
|
+
function nullTime () { return false }
|
|
32333
|
+
function epochTime () { return Date.now() }
|
|
32334
|
+
function unixTime () { return Math.round(Date.now() / 1000.0) }
|
|
32335
|
+
function isoTime () { return new Date(Date.now()).toISOString() } // using Date.now() for testability
|
|
32336
|
+
|
|
32337
|
+
/* eslint-disable */
|
|
32338
|
+
/* istanbul ignore next */
|
|
32339
|
+
function pfGlobalThisOrFallback () {
|
|
32340
|
+
function defd (o) { return typeof o !== 'undefined' && o }
|
|
32341
|
+
try {
|
|
32342
|
+
if (typeof globalThis !== 'undefined') return globalThis
|
|
32343
|
+
Object.defineProperty(Object.prototype, 'globalThis', {
|
|
32344
|
+
get: function () {
|
|
32345
|
+
delete Object.prototype.globalThis;
|
|
32346
|
+
return (this.globalThis = this)
|
|
32347
|
+
},
|
|
32348
|
+
configurable: true
|
|
32349
|
+
});
|
|
32350
|
+
return globalThis
|
|
32351
|
+
} catch (e) {
|
|
32352
|
+
return defd(self) || defd(window) || defd(this) || {}
|
|
32353
|
+
}
|
|
32354
|
+
}
|
|
32355
|
+
/* eslint-enable */
|
|
32356
|
+
|
|
32357
|
+
browser.exports.default = pino;
|
|
32358
|
+
browser.exports.pino = pino;
|
|
32359
|
+
return browser.exports;
|
|
32360
|
+
}
|
|
32361
|
+
|
|
32362
|
+
var browserExports = requireBrowser();
|
|
32363
|
+
var c$2 = /*@__PURE__*/getDefaultExportFromCjs$1(browserExports);
|
|
32364
|
+
|
|
32365
|
+
const i=1e3*1024;var C$2=Object.defineProperty,B$2=(r,e,t)=>e in r?C$2(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,s=(r,e,t)=>B$2(r,typeof e!="symbol"?e+"":e,t);let S$2 = class S{constructor(e){s(this,"nodeValue"),s(this,"sizeInBytes"),s(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$4 = class v{constructor(e){s(this,"lengthInNodes"),s(this,"sizeInBytes"),s(this,"head"),s(this,"tail"),s(this,"maxSizeInBytes"),this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0;}append(e){const t=new S$2(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 _$1=Object.defineProperty,x$2=(r,e,t)=>e in r?_$1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,a=(r,e,t)=>x$2(r,typeof e!="symbol"?e+"":e,t);let L$3 = class L{constructor(e,t=i){a(this,"logs"),a(this,"level"),a(this,"levelValue"),a(this,"MAX_LOG_SIZE_IN_BYTES"),this.level=e??"error",this.levelValue=browserExports.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new v$4(this.MAX_LOG_SIZE_IN_BYTES);}forwardToConsole(e,t){t===browserExports.levels.values.error?console.error(e):t===browserExports.levels.values.warn?console.warn(e):t===browserExports.levels.values.debug?console.debug(e):t===browserExports.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$4(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$4=Object.defineProperty,T$2=(r,e,t)=>e in r?z$4(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,k=(r,e,t)=>T$2(r,e+"",t);let E$2 = class E{constructor(e,t=i){k(this,"baseChunkLogger"),this.baseChunkLogger=new L$3(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$2=Object.defineProperty,$$3=(r,e,t)=>e in r?A$2(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,N$3=(r,e,t)=>$$3(r,e+"",t);let j$3 = class j{constructor(e,t=i){N$3(this,"baseChunkLogger"),this.baseChunkLogger=new L$3(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$3=Object.defineProperty,V$2=Object.defineProperties,G$3=Object.getOwnPropertyDescriptors,p$2=Object.getOwnPropertySymbols,M$2=Object.prototype.hasOwnProperty,U$2=Object.prototype.propertyIsEnumerable,f$4=(r,e,t)=>e in r?P$3(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,g$2=(r,e)=>{for(var t in e||(e={}))M$2.call(e,t)&&f$4(r,t,e[t]);if(p$2)for(var t of p$2(e))U$2.call(e,t)&&f$4(r,t,e[t]);return r},h$1=(r,e)=>V$2(r,G$3(e));function I$1(r){var e,t;const o=new E$2((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return {logger:c$2(h$1(g$2({},r.opts),{level:"trace",browser:h$1(g$2({},(t=r.opts)==null?void 0:t.browser),{write:u=>o.write(u)})})),chunkLoggerController:o}}function O$2(r){var e;const t=new j$3((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return {logger:c$2(h$1(g$2({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Y$2(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?I$1(r):O$2(r)}
|
|
32366
|
+
|
|
32367
|
+
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:
|
|
32368
|
+
${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 ue$2.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 ue$2.encode(o)}function Nc(t){const e=new Uint8Array($e$2(Yr$1(t)));return ue$2.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=>`
|
|
32369
|
+
- ${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(`
|
|
32370
|
+
`)};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.
|
|
32371
|
+
Required: ${a.toString()}
|
|
32372
|
+
Received: ${Object.keys(e).toString()}`)),It$3(i,c)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces chains don't satisfy required namespaces.
|
|
32373
|
+
Required: ${i.toString()}
|
|
32374
|
+
Approved: ${c.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||r)return;const d=Gt$2(e[l].accounts);d.includes(l)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces accounts don't satisfy namespace accounts for ${l}
|
|
32375
|
+
Required: ${l}
|
|
32376
|
+
Approved: ${d.toString()}`));}),i.forEach(l=>{r||(It$3(o[l].methods,s[l].methods)?It$3(o[l].events,s[l].events)||(r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces events don't satisfy namespace events for ${l}`)):r=Bt$2("NON_CONFORMING_NAMESPACES",`${n} namespaces methods don't satisfy namespace methods for ${l}`));}),r}function cu(t){const e={};return Object.keys(t).forEach(n=>{var r;n.includes(":")?e[n]=t[n]:(r=t[n].chains)==null||r.forEach(o=>{e[o]={methods:t[n].methods,events:t[n].events};});}),e}function Us$1(t){return [...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function fu(t){const e={};return Object.keys(t).forEach(n=>{if(n.includes(":"))e[n]=t[n];else {const r=Gt$2(t[n].accounts);r?.forEach(o=>{e[o]={accounts:t[n].accounts.filter(s=>s.includes(`${o}:`)),methods:t[n].methods,events:t[n].events};});}}),e}function au(t,e){return We$3(t,false)&&t<=e.max&&t>=e.min}function uu(){const t=Vt$2();return new Promise(e=>{switch(t){case et$2.browser:e(_s());break;case et$2.reactNative:e(Rs());break;case et$2.node:e($s$1());break;default:e(true);}})}function _s(){return Wt$2()&&navigator?.onLine}async function Rs(){if(At$2()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t?.isConnected}return true}function $s$1(){return true}function lu(t){switch(Vt$2()){case et$2.browser:Ts(t);break;case et$2.reactNative:Cs$1(t);break;}}function Ts(t){!At$2()&&Wt$2()&&(window.addEventListener("online",()=>t(true)),window.addEventListener("offline",()=>t(false)));}function Cs$1(t){At$2()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected));}function du(){var t;return Wt$2()&&cjsExports$2.getDocument()?((t=cjsExports$2.getDocument())==null?void 0:t.visibilityState)==="visible":true}const Wn$1={};class hu{static get(e){return Wn$1[e]}static set(e,n){Wn$1[e]=n;}static delete(e){delete Wn$1[e];}}function js$1(t){const e=ue$2.decode(t);if(e.length<33)throw new Error("Too short to contain a public key");return e.slice(1,33)}function Ls$1({publicKey:t,signature:e,payload:n}){var r;const o=Xn$1(n.method),s=128|parseInt(((r=n.version)==null?void 0:r.toString())||"4"),i=gu(n.address),c=n.era==="00"?new Uint8Array([0]):Xn$1(n.era);if(c.length!==1&&c.length!==2)throw new Error("Invalid era length");const f=parseInt(n.nonce,16),u=new Uint8Array([f&255,f>>8&255]),a=BigInt(`0x${pu(n.tip)}`),l=yu(a),d=new Uint8Array([0,...t,i,...e,...c,...u,...l,...o]),h=bu(d.length+1);return new Uint8Array([...h,s,...d])}function ks$1(t){const e=Xn$1(t),n=blakejsExports.blake2b(e,void 0,32);return "0x"+Buffer.from(n).toString("hex")}function Xn$1(t){return new Uint8Array(t.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}function pu(t){return t.startsWith("0x")?t.slice(2):t}function gu(t){const e=ue$2.decode(t)[0];return e===42?0:e===60?2:1}function bu(t){if(t<64)return new Uint8Array([t<<2]);if(t<16384){const e=t<<2|1;return new Uint8Array([e&255,e>>8&255])}else if(t<1<<30){const e=t<<2|2;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}else throw new Error("Compact encoding > 2^30 not supported")}function yu(t){if(t<BigInt(1)<<BigInt(6))return new Uint8Array([Number(t<<BigInt(2))]);if(t<BigInt(1)<<BigInt(14)){const e=t<<BigInt(2)|BigInt(1);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255))])}else if(t<BigInt(1)<<BigInt(30)){const e=t<<BigInt(2)|BigInt(2);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255)),Number(e>>BigInt(16)&BigInt(255)),Number(e>>BigInt(24)&BigInt(255))])}else throw new Error("BigInt compact encoding not supported > 2^30")}function mu(t){const e=Uint8Array.from(Buffer.from(t.signature,"hex")),n=js$1(t.transaction.address),r=Ls$1({publicKey:n,signature:e,payload:t.transaction}),o=Buffer.from(r).toString("hex");return ks$1(o)}function wu({logger:t,name:e}){const n=typeof t=="string"?Y$2({opts:{level:t,name:e}}).logger:t;return n.level=typeof t=="string"?t:t.level,n}
|
|
32377
|
+
|
|
32378
|
+
const PARSE_ERROR = "PARSE_ERROR";
|
|
32379
|
+
const INVALID_REQUEST = "INVALID_REQUEST";
|
|
32380
|
+
const METHOD_NOT_FOUND = "METHOD_NOT_FOUND";
|
|
32381
|
+
const INVALID_PARAMS = "INVALID_PARAMS";
|
|
32382
|
+
const INTERNAL_ERROR = "INTERNAL_ERROR";
|
|
32383
|
+
const SERVER_ERROR = "SERVER_ERROR";
|
|
32384
|
+
const RESERVED_ERROR_CODES = [-32700, -32600, -32601, -32602, -32603];
|
|
32385
|
+
const STANDARD_ERROR_MAP = {
|
|
32386
|
+
[PARSE_ERROR]: { code: -32700, message: "Parse error" },
|
|
32387
|
+
[INVALID_REQUEST]: { code: -32600, message: "Invalid Request" },
|
|
32388
|
+
[METHOD_NOT_FOUND]: { code: -32601, message: "Method not found" },
|
|
32389
|
+
[INVALID_PARAMS]: { code: -32602, message: "Invalid params" },
|
|
32390
|
+
[INTERNAL_ERROR]: { code: -32603, message: "Internal error" },
|
|
32391
|
+
[SERVER_ERROR]: { code: -32e3, message: "Server error" },
|
|
32392
|
+
};
|
|
32393
|
+
const DEFAULT_ERROR = SERVER_ERROR;
|
|
32394
|
+
|
|
32395
|
+
function isReservedErrorCode(code) {
|
|
32396
|
+
return RESERVED_ERROR_CODES.includes(code);
|
|
32397
|
+
}
|
|
32398
|
+
function getError(type) {
|
|
32399
|
+
if (!Object.keys(STANDARD_ERROR_MAP).includes(type)) {
|
|
32400
|
+
return STANDARD_ERROR_MAP[DEFAULT_ERROR];
|
|
32401
|
+
}
|
|
32402
|
+
return STANDARD_ERROR_MAP[type];
|
|
32403
|
+
}
|
|
32404
|
+
function getErrorByCode(code) {
|
|
32405
|
+
const match = Object.values(STANDARD_ERROR_MAP).find(e => e.code === code);
|
|
32406
|
+
if (!match) {
|
|
32407
|
+
return STANDARD_ERROR_MAP[DEFAULT_ERROR];
|
|
32408
|
+
}
|
|
32409
|
+
return match;
|
|
32410
|
+
}
|
|
32411
|
+
function parseConnectionError(e, url, type) {
|
|
32412
|
+
return e.message.includes("getaddrinfo ENOTFOUND") || e.message.includes("connect ECONNREFUSED")
|
|
32413
|
+
? new Error(`Unavailable ${type} RPC url at ${url}`)
|
|
32414
|
+
: e;
|
|
32415
|
+
}
|
|
32416
|
+
|
|
32417
|
+
var cjs$1 = {};
|
|
32418
|
+
|
|
32419
|
+
var crypto$1 = {};
|
|
32420
|
+
|
|
32421
|
+
var hasRequiredCrypto;
|
|
32422
|
+
|
|
32423
|
+
function requireCrypto () {
|
|
32424
|
+
if (hasRequiredCrypto) return crypto$1;
|
|
32425
|
+
hasRequiredCrypto = 1;
|
|
32426
|
+
Object.defineProperty(crypto$1, "__esModule", { value: true });
|
|
32427
|
+
crypto$1.isBrowserCryptoAvailable = crypto$1.getSubtleCrypto = crypto$1.getBrowerCrypto = void 0;
|
|
32428
|
+
function getBrowerCrypto() {
|
|
32429
|
+
return (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.crypto) || (commonjsGlobal === null || commonjsGlobal === void 0 ? void 0 : commonjsGlobal.msCrypto) || {};
|
|
32430
|
+
}
|
|
32431
|
+
crypto$1.getBrowerCrypto = getBrowerCrypto;
|
|
32432
|
+
function getSubtleCrypto() {
|
|
32433
|
+
const browserCrypto = getBrowerCrypto();
|
|
32434
|
+
return browserCrypto.subtle || browserCrypto.webkitSubtle;
|
|
32435
|
+
}
|
|
32436
|
+
crypto$1.getSubtleCrypto = getSubtleCrypto;
|
|
32437
|
+
function isBrowserCryptoAvailable() {
|
|
32438
|
+
return !!getBrowerCrypto() && !!getSubtleCrypto();
|
|
32439
|
+
}
|
|
32440
|
+
crypto$1.isBrowserCryptoAvailable = isBrowserCryptoAvailable;
|
|
32441
|
+
|
|
32442
|
+
return crypto$1;
|
|
32443
|
+
}
|
|
32444
|
+
|
|
32445
|
+
var env = {};
|
|
32446
|
+
|
|
32447
|
+
var hasRequiredEnv;
|
|
32448
|
+
|
|
32449
|
+
function requireEnv () {
|
|
32450
|
+
if (hasRequiredEnv) return env;
|
|
32451
|
+
hasRequiredEnv = 1;
|
|
32452
|
+
Object.defineProperty(env, "__esModule", { value: true });
|
|
32453
|
+
env.isBrowser = env.isNode = env.isReactNative = void 0;
|
|
32454
|
+
function isReactNative() {
|
|
32455
|
+
return (typeof document === "undefined" &&
|
|
32456
|
+
typeof navigator !== "undefined" &&
|
|
32457
|
+
navigator.product === "ReactNative");
|
|
32458
|
+
}
|
|
32459
|
+
env.isReactNative = isReactNative;
|
|
32460
|
+
function isNode() {
|
|
32461
|
+
return (typeof process !== "undefined" &&
|
|
32462
|
+
typeof process.versions !== "undefined" &&
|
|
32463
|
+
typeof process.versions.node !== "undefined");
|
|
32464
|
+
}
|
|
32465
|
+
env.isNode = isNode;
|
|
32466
|
+
function isBrowser() {
|
|
32467
|
+
return !isReactNative() && !isNode();
|
|
32468
|
+
}
|
|
32469
|
+
env.isBrowser = isBrowser;
|
|
32470
|
+
|
|
32471
|
+
return env;
|
|
32472
|
+
}
|
|
32473
|
+
|
|
32474
|
+
var hasRequiredCjs$1;
|
|
32475
|
+
|
|
32476
|
+
function requireCjs$1 () {
|
|
32477
|
+
if (hasRequiredCjs$1) return cjs$1;
|
|
32478
|
+
hasRequiredCjs$1 = 1;
|
|
32479
|
+
(function (exports$1) {
|
|
32480
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
32481
|
+
const tslib_1 = require$$0;
|
|
32482
|
+
tslib_1.__exportStar(requireCrypto(), exports$1);
|
|
32483
|
+
tslib_1.__exportStar(requireEnv(), exports$1);
|
|
32484
|
+
|
|
32485
|
+
} (cjs$1));
|
|
32486
|
+
return cjs$1;
|
|
32487
|
+
}
|
|
32488
|
+
|
|
32489
|
+
var cjsExports = requireCjs$1();
|
|
32490
|
+
|
|
32491
|
+
function payloadId(entropy = 3) {
|
|
32492
|
+
const date = Date.now() * Math.pow(10, entropy);
|
|
32493
|
+
const extra = Math.floor(Math.random() * Math.pow(10, entropy));
|
|
32494
|
+
return date + extra;
|
|
31943
32495
|
}
|
|
31944
32496
|
function getBigIntRpcId(entropy = 6) {
|
|
31945
32497
|
return BigInt(payloadId(entropy));
|
|
@@ -32028,9 +32580,9 @@ let o$1 = class o extends r{constructor(t){super(t),this.events=new eventsExport
|
|
|
32028
32580
|
|
|
32029
32581
|
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}};
|
|
32030
32582
|
|
|
32031
|
-
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$4{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$4{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$1{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$2{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$3{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$2{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$1{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$2({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$2,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$3(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;
|
|
32583
|
+
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;
|
|
32032
32584
|
|
|
32033
|
-
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$2{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;
|
|
32585
|
+
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;
|
|
32034
32586
|
|
|
32035
32587
|
var browserPonyfill = {exports: {}};
|
|
32036
32588
|
|
|
@@ -32737,137 +33289,64 @@ var P=Object.defineProperty,w$1=Object.defineProperties,E$1=Object.getOwnPropert
|
|
|
32737
33289
|
|
|
32738
33290
|
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;
|
|
32739
33291
|
|
|
32740
|
-
const q=e=>{let t,{get:s,on:i}=getWallets(),n=true,a=new F$1(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$1(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$1(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 G{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$6,V(this,N)[N]=["solana:signAndSendTransaction","solana:signTransaction","solana:signMessage"],V(this,L)[L]=s,V(this,Y)[Y]=i;}}function Z(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??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 H(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 H(this,ie)[ie]}get name(){return H(this,ne)[ne]}get icon(){return H(this,ae)[ae]}get chains(){return P$6.slice()}get features(){return {"standard:connect":{version:"1.0.0",connect:H(this,ye)[ye]},"standard:disconnect":{version:"1.0.0",disconnect:H(this,we)[we]},"standard:events":{version:"1.0.0",on:H(this,pe)[pe]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:H(this,je)[je]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:H(this,_e)[_e]},"solana:signMessage":{version:"1.0.0",signMessage:H(this,be)[be]}}}get accounts(){return H(this,oe)[oe].slice()}get isWalletConnectSolana(){return true}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){H(this,ce)[ce]=e,H(this,le)[le]=t,await H(this,Pe)[Pe](),await H(this,Se)[Se]();}setWalletEntry(e,t){H(this,de)[de]=e,H(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}),H(this,se)[se]={},H(this,ie)[ie]="1.0.0",H(this,ne)[ne]="WalletConnect",H(this,ae)[ae]=_$3,H(this,re)[re]=null,H(this,oe)[oe]=[],H(this,le)[le]="",H(this,ce)[ce]="",H(this,ue)[ue]=new Map,H(this,pe)[pe]=(e,t)=>(H(this,se)[se][e]?.push(t)||(H(this,se)[se][e]=[t]),()=>H(this,ge)[ge](e,t)),H(this,ve)[ve]=e=>{H(this,ne)[ne]=H(this,re)[re]?.session?.peer?.metadata?.name||H(this,de)[de]?.name||"WalletConnect",H(this,ae)[ae]=H(this,re)[re]?.session?.peer?.metadata?.icons?.[0]||H(this,de)[de]?.image_url?.sm||H(this,ae)[ae],H(this,oe)[oe]=e.map((e=>new G({address:e,publicKey:base58$1.decode(e),label:H(this,ne)[ne],icon:H(this,ae)[ae]}))),H(this,fe)[fe]("change",{accounts:this.accounts});},H(this,me)[me]=()=>{H(this,oe)[oe]=[],H(this,fe)[fe]("change",{accounts:this.accounts});},H(this,ye)[ye]=async()=>(this.accounts.length||await H(this,Oe)[Oe](),{accounts:this.accounts}),H(this,we)[we]=async()=>{await H(this,Ae)[Ae](),H(this,fe)[fe]("change",{accounts:this.accounts});},H(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 H(this,We)[We]("solana_signMessage",{message:e,pubkey:s.address},Fe("solana:mainnet"));t.push({signedMessage:i,signature:Z(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await H(this,We)[We]("solana:signMessage",{message:e,pubkey:s.address},Fe("solana:mainnet"));t.push({signedMessage:i,signature:Z(n)});}throw n}}return t},H(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 H(this,We)[We]("solana_signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Fe(i));t.push({signature:Z(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await H(this,We)[We]("solana:signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Fe(i));t.push({signature:Z(n)});}}}return t},H(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 H(this,We)[We]("solana_signTransaction",{transaction:e,pubkey:s.address},Fe(i||"solana:mainnet"));t.push({signedTransaction:$(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await H(this,We)[We]("solana:signTransaction",{transaction:e,pubkey:s.address},Fe(i||"solana:mainnet"));t.push({signedTransaction:$(n)});}}}return t},H(this,Pe)[Pe]=async()=>{if(H(this,re)[re])return H(this,re)[re];if(!H(this,ce)[ce])throw Error("WalletConnect Cloud Project ID is required");return H(this,re)[re]=await ns.init({projectId:H(this,ce)[ce],metadata:{name:H(this,le)[le],description:H(this,le)[le],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:false}),H(this,Te)[Te]("display_uri",H(this,Ce)[Ce]),H(this,Te)[Te]("session_delete",H(this,Ee)[Ee]),H(this,Te)[Te]("session_ping",(()=>{})),H(this,Te)[Te]("session_event",(()=>{})),H(this,Te)[Te]("session_update",(()=>{})),H(this,re)[re]},H(this,Oe)[Oe]=async()=>{if(!H(this,re)[re])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(H(this,re)[re].session)return H(this,re)[re].session;let e=await H(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 H(this,ve)[ve](xe(e)),e},H(this,Se)[Se]=async()=>{let e=H(this,re)[re]?.session;if(e){if(!e.namespaces?.solana)return await(H(this,re)[re]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(H(this,re)[re].session=void 0);H(this,ve)[ve](xe(e));}},H(this,Te)[Te]=(e,t)=>{let s=H(this,ue)[ue].get(e);s&&(H(this,re)[re]?.off(e,s),H(this,ue)[ue].delete(e)),H(this,re)[re]?.on(e,t),H(this,ue)[ue].set(e,t);},H(this,Ae)[Ae]=async()=>{try{if(H(this,re)[re]?.session&&await(H(this,re)[re]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),H(this,re)[re]?.client){let e=H(this,re)[re].client.proposal.getAll();await Promise.allSettled(e.map((e=>H(this,re)[re]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=H(this,re)[re].client.pairing.getAll();await Promise.allSettled(t.map((e=>H(this,re)[re]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))));}H(this,me)[me]();}catch(e){console.error("WalletConnectSolana: Error destroying session",e);}},H(this,We)[We]=async(e,t,s)=>{try{return await H(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}},H(this,Ce)[Ce]=e=>{if(libExports.isMobile&&H(this,de)[de]){let{redirect:s}=U$4(e,H(this,de)[de]);null==H(this,he)[he]||H(this,he)[he].call(this,{native:s,universal:s});}else null==H(this,he)[he]||H(this,he)[he].call(this,{native:e,universal:void 0});},H(this,Ee)[Ee]=()=>{H(this,me)[me]();};}}function ke(e,...t){H(this,se)[se][e]?.forEach((e=>e.apply(null,t)));}function Ue(e,t){H(this,se)[se][e]=H(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}}
|
|
32741
|
-
|
|
32742
|
-
var safeBuffer = {exports: {}};
|
|
32743
|
-
|
|
32744
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
32745
|
-
|
|
32746
|
-
var hasRequiredSafeBuffer;
|
|
32747
|
-
|
|
32748
|
-
function requireSafeBuffer () {
|
|
32749
|
-
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
32750
|
-
hasRequiredSafeBuffer = 1;
|
|
32751
|
-
(function (module, exports$1) {
|
|
32752
|
-
/* eslint-disable node/no-deprecated-api */
|
|
32753
|
-
var buffer = requireBuffer();
|
|
32754
|
-
var Buffer = buffer.Buffer;
|
|
32755
|
-
|
|
32756
|
-
// alternative to using Object.keys for old browsers
|
|
32757
|
-
function copyProps (src, dst) {
|
|
32758
|
-
for (var key in src) {
|
|
32759
|
-
dst[key] = src[key];
|
|
32760
|
-
}
|
|
32761
|
-
}
|
|
32762
|
-
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
32763
|
-
module.exports = buffer;
|
|
32764
|
-
} else {
|
|
32765
|
-
// Copy properties from require('buffer')
|
|
32766
|
-
copyProps(buffer, exports$1);
|
|
32767
|
-
exports$1.Buffer = SafeBuffer;
|
|
32768
|
-
}
|
|
32769
|
-
|
|
32770
|
-
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
32771
|
-
return Buffer(arg, encodingOrOffset, length)
|
|
32772
|
-
}
|
|
32773
|
-
|
|
32774
|
-
SafeBuffer.prototype = Object.create(Buffer.prototype);
|
|
32775
|
-
|
|
32776
|
-
// Copy static methods from Buffer
|
|
32777
|
-
copyProps(Buffer, SafeBuffer);
|
|
32778
|
-
|
|
32779
|
-
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
32780
|
-
if (typeof arg === 'number') {
|
|
32781
|
-
throw new TypeError('Argument must not be a number')
|
|
32782
|
-
}
|
|
32783
|
-
return Buffer(arg, encodingOrOffset, length)
|
|
32784
|
-
};
|
|
32785
|
-
|
|
32786
|
-
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
32787
|
-
if (typeof size !== 'number') {
|
|
32788
|
-
throw new TypeError('Argument must be a number')
|
|
32789
|
-
}
|
|
32790
|
-
var buf = Buffer(size);
|
|
32791
|
-
if (fill !== undefined) {
|
|
32792
|
-
if (typeof encoding === 'string') {
|
|
32793
|
-
buf.fill(fill, encoding);
|
|
32794
|
-
} else {
|
|
32795
|
-
buf.fill(fill);
|
|
32796
|
-
}
|
|
32797
|
-
} else {
|
|
32798
|
-
buf.fill(0);
|
|
32799
|
-
}
|
|
32800
|
-
return buf
|
|
32801
|
-
};
|
|
32802
|
-
|
|
32803
|
-
SafeBuffer.allocUnsafe = function (size) {
|
|
32804
|
-
if (typeof size !== 'number') {
|
|
32805
|
-
throw new TypeError('Argument must be a number')
|
|
32806
|
-
}
|
|
32807
|
-
return Buffer(size)
|
|
32808
|
-
};
|
|
33292
|
+
const q=e=>{let t,{get:s,on:i}=getWallets(),n=true,a=new F$1(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$1(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$1(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 G{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 Z(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??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 H(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 H(this,ie)[ie]}get name(){return H(this,ne)[ne]}get icon(){return H(this,ae)[ae]}get chains(){return P$7.slice()}get features(){return {"standard:connect":{version:"1.0.0",connect:H(this,ye)[ye]},"standard:disconnect":{version:"1.0.0",disconnect:H(this,we)[we]},"standard:events":{version:"1.0.0",on:H(this,pe)[pe]},"solana:signAndSendTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:H(this,je)[je]},"solana:signTransaction":{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:H(this,_e)[_e]},"solana:signMessage":{version:"1.0.0",signMessage:H(this,be)[be]}}}get accounts(){return H(this,oe)[oe].slice()}get isWalletConnectSolana(){return true}async initialize({walletConnectCloudProjectId:e,privyAppName:t}){H(this,ce)[ce]=e,H(this,le)[le]=t,await H(this,Pe)[Pe](),await H(this,Se)[Se]();}setWalletEntry(e,t){H(this,de)[de]=e,H(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}),H(this,se)[se]={},H(this,ie)[ie]="1.0.0",H(this,ne)[ne]="WalletConnect",H(this,ae)[ae]=_$4,H(this,re)[re]=null,H(this,oe)[oe]=[],H(this,le)[le]="",H(this,ce)[ce]="",H(this,ue)[ue]=new Map,H(this,pe)[pe]=(e,t)=>(H(this,se)[se][e]?.push(t)||(H(this,se)[se][e]=[t]),()=>H(this,ge)[ge](e,t)),H(this,ve)[ve]=e=>{H(this,ne)[ne]=H(this,re)[re]?.session?.peer?.metadata?.name||H(this,de)[de]?.name||"WalletConnect",H(this,ae)[ae]=H(this,re)[re]?.session?.peer?.metadata?.icons?.[0]||H(this,de)[de]?.image_url?.sm||H(this,ae)[ae],H(this,oe)[oe]=e.map((e=>new G({address:e,publicKey:base58$1.decode(e),label:H(this,ne)[ne],icon:H(this,ae)[ae]}))),H(this,fe)[fe]("change",{accounts:this.accounts});},H(this,me)[me]=()=>{H(this,oe)[oe]=[],H(this,fe)[fe]("change",{accounts:this.accounts});},H(this,ye)[ye]=async()=>(this.accounts.length||await H(this,Oe)[Oe](),{accounts:this.accounts}),H(this,we)[we]=async()=>{await H(this,Ae)[Ae](),H(this,fe)[fe]("change",{accounts:this.accounts});},H(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 H(this,We)[We]("solana_signMessage",{message:e,pubkey:s.address},Fe("solana:mainnet"));t.push({signedMessage:i,signature:Z(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await H(this,We)[We]("solana:signMessage",{message:e,pubkey:s.address},Fe("solana:mainnet"));t.push({signedMessage:i,signature:Z(n)});}throw n}}return t},H(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 H(this,We)[We]("solana_signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Fe(i));t.push({signature:Z(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await H(this,We)[We]("solana:signAndSendTransaction",{transaction:e,pubkey:s.address,sendOptions:a},Fe(i));t.push({signature:Z(n)});}}}return t},H(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 H(this,We)[We]("solana_signTransaction",{transaction:e,pubkey:s.address},Fe(i||"solana:mainnet"));t.push({signedTransaction:$(n)});}catch(n){if(n?.message?.includes("Missing or invalid")){let n=await H(this,We)[We]("solana:signTransaction",{transaction:e,pubkey:s.address},Fe(i||"solana:mainnet"));t.push({signedTransaction:$(n)});}}}return t},H(this,Pe)[Pe]=async()=>{if(H(this,re)[re])return H(this,re)[re];if(!H(this,ce)[ce])throw Error("WalletConnect Cloud Project ID is required");return H(this,re)[re]=await ns.init({projectId:H(this,ce)[ce],metadata:{name:H(this,le)[le],description:H(this,le)[le],url:window.location.origin,icons:[]},relayUrl:"wss://relay.walletconnect.com",telemetryEnabled:false}),H(this,Te)[Te]("display_uri",H(this,Ce)[Ce]),H(this,Te)[Te]("session_delete",H(this,Ee)[Ee]),H(this,Te)[Te]("session_ping",(()=>{})),H(this,Te)[Te]("session_event",(()=>{})),H(this,Te)[Te]("session_update",(()=>{})),H(this,re)[re]},H(this,Oe)[Oe]=async()=>{if(!H(this,re)[re])throw Error("WalletConnectSolana: Failed to get or create session. Provider not initialized");if(H(this,re)[re].session)return H(this,re)[re].session;let e=await H(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 H(this,ve)[ve](xe(e)),e},H(this,Se)[Se]=async()=>{let e=H(this,re)[re]?.session;if(e){if(!e.namespaces?.solana)return await(H(this,re)[re]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),void(H(this,re)[re].session=void 0);H(this,ve)[ve](xe(e));}},H(this,Te)[Te]=(e,t)=>{let s=H(this,ue)[ue].get(e);s&&(H(this,re)[re]?.off(e,s),H(this,ue)[ue].delete(e)),H(this,re)[re]?.on(e,t),H(this,ue)[ue].set(e,t);},H(this,Ae)[Ae]=async()=>{try{if(H(this,re)[re]?.session&&await(H(this,re)[re]?.disconnect().catch((e=>console.error("WalletConnectSolana: Error disconnecting session",e)))),H(this,re)[re]?.client){let e=H(this,re)[re].client.proposal.getAll();await Promise.allSettled(e.map((e=>H(this,re)[re]?.client.proposal.delete(e.id,{code:6e3,message:"User disconnected"}))));let t=H(this,re)[re].client.pairing.getAll();await Promise.allSettled(t.map((e=>H(this,re)[re]?.client.pairing.delete(e.topic,{code:6e3,message:"User disconnected"}))));}H(this,me)[me]();}catch(e){console.error("WalletConnectSolana: Error destroying session",e);}},H(this,We)[We]=async(e,t,s)=>{try{return await H(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}},H(this,Ce)[Ce]=e=>{if(libExports.isMobile&&H(this,de)[de]){let{redirect:s}=U$5(e,H(this,de)[de]);null==H(this,he)[he]||H(this,he)[he].call(this,{native:s,universal:s});}else null==H(this,he)[he]||H(this,he)[he].call(this,{native:e,universal:void 0});},H(this,Ee)[Ee]=()=>{H(this,me)[me]();};}}function ke(e,...t){H(this,se)[se][e]?.forEach((e=>e.apply(null,t)));}function Ue(e,t){H(this,se)[se][e]=H(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}}
|
|
32809
33293
|
|
|
32810
|
-
|
|
32811
|
-
if (typeof size !== 'number') {
|
|
32812
|
-
throw new TypeError('Argument must be a number')
|
|
32813
|
-
}
|
|
32814
|
-
return buffer.SlowBuffer(size)
|
|
32815
|
-
};
|
|
32816
|
-
} (safeBuffer, safeBuffer.exports));
|
|
32817
|
-
return safeBuffer.exports;
|
|
32818
|
-
}
|
|
33294
|
+
var cjs = {};
|
|
32819
33295
|
|
|
32820
|
-
var
|
|
32821
|
-
var hasRequiredSrc;
|
|
33296
|
+
var hasRequiredCjs;
|
|
32822
33297
|
|
|
32823
|
-
function
|
|
32824
|
-
if (
|
|
32825
|
-
|
|
33298
|
+
function requireCjs () {
|
|
33299
|
+
if (hasRequiredCjs) return cjs;
|
|
33300
|
+
hasRequiredCjs = 1;
|
|
32826
33301
|
// base-x encoding / decoding
|
|
32827
33302
|
// Copyright (c) 2018 base-x contributors
|
|
32828
33303
|
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
32829
33304
|
// Distributed under the MIT software license, see the accompanying
|
|
32830
33305
|
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
32831
|
-
|
|
32832
|
-
var _Buffer = requireSafeBuffer().Buffer;
|
|
33306
|
+
Object.defineProperty(cjs, '__esModule', { value: true });
|
|
32833
33307
|
function base (ALPHABET) {
|
|
32834
33308
|
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
32835
|
-
|
|
32836
|
-
for (
|
|
33309
|
+
const BASE_MAP = new Uint8Array(256);
|
|
33310
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
32837
33311
|
BASE_MAP[j] = 255;
|
|
32838
33312
|
}
|
|
32839
|
-
for (
|
|
32840
|
-
|
|
32841
|
-
|
|
33313
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
33314
|
+
const x = ALPHABET.charAt(i);
|
|
33315
|
+
const xc = x.charCodeAt(0);
|
|
32842
33316
|
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
32843
33317
|
BASE_MAP[xc] = i;
|
|
32844
33318
|
}
|
|
32845
|
-
|
|
32846
|
-
|
|
32847
|
-
|
|
32848
|
-
|
|
33319
|
+
const BASE = ALPHABET.length;
|
|
33320
|
+
const LEADER = ALPHABET.charAt(0);
|
|
33321
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
33322
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
32849
33323
|
function encode (source) {
|
|
32850
|
-
|
|
32851
|
-
if (
|
|
33324
|
+
// eslint-disable-next-line no-empty
|
|
33325
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
33326
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
33327
|
+
} else if (Array.isArray(source)) {
|
|
33328
|
+
source = Uint8Array.from(source);
|
|
33329
|
+
}
|
|
33330
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
32852
33331
|
if (source.length === 0) { return '' }
|
|
32853
|
-
|
|
32854
|
-
|
|
32855
|
-
|
|
32856
|
-
|
|
32857
|
-
|
|
33332
|
+
// Skip & count leading zeroes.
|
|
33333
|
+
let zeroes = 0;
|
|
33334
|
+
let length = 0;
|
|
33335
|
+
let pbegin = 0;
|
|
33336
|
+
const pend = source.length;
|
|
32858
33337
|
while (pbegin !== pend && source[pbegin] === 0) {
|
|
32859
33338
|
pbegin++;
|
|
32860
33339
|
zeroes++;
|
|
32861
33340
|
}
|
|
32862
|
-
|
|
32863
|
-
|
|
32864
|
-
|
|
32865
|
-
|
|
33341
|
+
// Allocate enough space in big-endian base58 representation.
|
|
33342
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
33343
|
+
const b58 = new Uint8Array(size);
|
|
33344
|
+
// Process the bytes.
|
|
32866
33345
|
while (pbegin !== pend) {
|
|
32867
|
-
|
|
32868
|
-
|
|
32869
|
-
|
|
32870
|
-
for (
|
|
33346
|
+
let carry = source[pbegin];
|
|
33347
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
33348
|
+
let i = 0;
|
|
33349
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
32871
33350
|
carry += (256 * b58[it1]) >>> 0;
|
|
32872
33351
|
b58[it1] = (carry % BASE) >>> 0;
|
|
32873
33352
|
carry = (carry / BASE) >>> 0;
|
|
@@ -32876,42 +33355,42 @@ function requireSrc () {
|
|
|
32876
33355
|
length = i;
|
|
32877
33356
|
pbegin++;
|
|
32878
33357
|
}
|
|
32879
|
-
|
|
32880
|
-
|
|
33358
|
+
// Skip leading zeroes in base58 result.
|
|
33359
|
+
let it2 = size - length;
|
|
32881
33360
|
while (it2 !== size && b58[it2] === 0) {
|
|
32882
33361
|
it2++;
|
|
32883
33362
|
}
|
|
32884
|
-
|
|
32885
|
-
|
|
33363
|
+
// Translate the result into a string.
|
|
33364
|
+
let str = LEADER.repeat(zeroes);
|
|
32886
33365
|
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
32887
33366
|
return str
|
|
32888
33367
|
}
|
|
32889
33368
|
function decodeUnsafe (source) {
|
|
32890
33369
|
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
32891
|
-
if (source.length === 0) { return
|
|
32892
|
-
|
|
32893
|
-
|
|
32894
|
-
|
|
32895
|
-
|
|
33370
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
33371
|
+
let psz = 0;
|
|
33372
|
+
// Skip and count leading '1's.
|
|
33373
|
+
let zeroes = 0;
|
|
33374
|
+
let length = 0;
|
|
32896
33375
|
while (source[psz] === LEADER) {
|
|
32897
33376
|
zeroes++;
|
|
32898
33377
|
psz++;
|
|
32899
33378
|
}
|
|
32900
|
-
|
|
32901
|
-
|
|
32902
|
-
|
|
32903
|
-
|
|
33379
|
+
// Allocate enough space in big-endian base256 representation.
|
|
33380
|
+
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
33381
|
+
const b256 = new Uint8Array(size);
|
|
33382
|
+
// Process the characters.
|
|
32904
33383
|
while (psz < source.length) {
|
|
32905
|
-
|
|
32906
|
-
|
|
32907
|
-
|
|
33384
|
+
// Find code of next character
|
|
33385
|
+
const charCode = source.charCodeAt(psz);
|
|
33386
|
+
// Base map can not be indexed using char code
|
|
32908
33387
|
if (charCode > 255) { return }
|
|
32909
|
-
|
|
32910
|
-
|
|
32911
|
-
|
|
33388
|
+
// Decode character
|
|
33389
|
+
let carry = BASE_MAP[charCode];
|
|
33390
|
+
// Invalid character
|
|
32912
33391
|
if (carry === 255) { return }
|
|
32913
|
-
|
|
32914
|
-
for (
|
|
33392
|
+
let i = 0;
|
|
33393
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
32915
33394
|
carry += (BASE * b256[it3]) >>> 0;
|
|
32916
33395
|
b256[it3] = (carry % 256) >>> 0;
|
|
32917
33396
|
carry = (carry / 256) >>> 0;
|
|
@@ -32920,32 +33399,31 @@ function requireSrc () {
|
|
|
32920
33399
|
length = i;
|
|
32921
33400
|
psz++;
|
|
32922
33401
|
}
|
|
32923
|
-
|
|
32924
|
-
|
|
33402
|
+
// Skip leading zeroes in b256.
|
|
33403
|
+
let it4 = size - length;
|
|
32925
33404
|
while (it4 !== size && b256[it4] === 0) {
|
|
32926
33405
|
it4++;
|
|
32927
33406
|
}
|
|
32928
|
-
|
|
32929
|
-
|
|
32930
|
-
var j = zeroes;
|
|
33407
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
33408
|
+
let j = zeroes;
|
|
32931
33409
|
while (it4 !== size) {
|
|
32932
33410
|
vch[j++] = b256[it4++];
|
|
32933
33411
|
}
|
|
32934
33412
|
return vch
|
|
32935
33413
|
}
|
|
32936
33414
|
function decode (string) {
|
|
32937
|
-
|
|
33415
|
+
const buffer = decodeUnsafe(string);
|
|
32938
33416
|
if (buffer) { return buffer }
|
|
32939
33417
|
throw new Error('Non-base' + BASE + ' character')
|
|
32940
33418
|
}
|
|
32941
33419
|
return {
|
|
32942
|
-
encode
|
|
32943
|
-
decodeUnsafe
|
|
32944
|
-
decode
|
|
33420
|
+
encode,
|
|
33421
|
+
decodeUnsafe,
|
|
33422
|
+
decode
|
|
32945
33423
|
}
|
|
32946
33424
|
}
|
|
32947
|
-
|
|
32948
|
-
return
|
|
33425
|
+
cjs.default = base;
|
|
33426
|
+
return cjs;
|
|
32949
33427
|
}
|
|
32950
33428
|
|
|
32951
33429
|
var bs58$1;
|
|
@@ -32954,7 +33432,7 @@ var hasRequiredBs58;
|
|
|
32954
33432
|
function requireBs58 () {
|
|
32955
33433
|
if (hasRequiredBs58) return bs58$1;
|
|
32956
33434
|
hasRequiredBs58 = 1;
|
|
32957
|
-
var basex =
|
|
33435
|
+
var basex = requireCjs();
|
|
32958
33436
|
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
32959
33437
|
|
|
32960
33438
|
bs58$1 = basex(ALPHABET);
|
|
@@ -35408,11 +35886,13 @@ async function getAuthProvider(config) {
|
|
|
35408
35886
|
break;
|
|
35409
35887
|
case "phantom":
|
|
35410
35888
|
currentAuthProvider = new PhantomWalletProvider(rpcUrl, config.phantomConfig);
|
|
35889
|
+
// MWA hot-swap is always available (custom modal shows MWA button on Android)
|
|
35890
|
+
currentAuthProvider.onSwitchToMWA =
|
|
35891
|
+
() => hotSwapToMWAProvider(config);
|
|
35892
|
+
// Privy hot-swap only when enablePrivyFallback is on
|
|
35411
35893
|
if ((_d = config.phantomConfig) === null || _d === void 0 ? void 0 : _d.enablePrivyFallback) {
|
|
35412
35894
|
currentAuthProvider.onSwitchToPrivy =
|
|
35413
35895
|
() => hotSwapToPrivyProvider(config);
|
|
35414
|
-
currentAuthProvider.onSwitchToMWA =
|
|
35415
|
-
() => hotSwapToMWAProvider(config);
|
|
35416
35896
|
}
|
|
35417
35897
|
break;
|
|
35418
35898
|
case "mobile-wallet-adapter":
|
|
@@ -35634,4 +36114,4 @@ async function getIdToken() {
|
|
|
35634
36114
|
}
|
|
35635
36115
|
|
|
35636
36116
|
export { useAuth as A, getIdToken as B, PrivyWalletProvider as C, DEFAULT_TEST_ADDRESS as D, isMobileWalletAvailable as E, registerMobileWalletAdapter as F, ServerSessionManager as G, buildSetDocumentsTransaction as H, clearCache as I, closeAllSubscriptions as J, convertRemainingAccounts as K, createSessionWithPrivy as L, MockAuthProvider as M, createSessionWithSignature as N, OffchainAuthProvider as O, PhantomWalletProvider as P, genAuthNonce as Q, genSolanaMessage as R, SolanaMobileWalletProvider as S, getCachedData as T, reconnectWithNewAuth as U, refreshSession as V, WebSessionManager as W, signSessionCreateMessage as X, getCurrentUser as a, bufferExports as b, onAuthLoadingChanged as c, getAuthLoading as d, logout as e, getConfig as f, getDefaultExportFromCjs$1 as g, getAuthProvider as h, init as i, get$2 as j, setMany as k, login as l, setFile as m, getFiles as n, onAuthStateChanged as o, runQueryMany as p, runExpression as q, runQuery as r, set$1 as s, runExpressionMany as t, signMessage as u, signTransaction as v, signAndSubmitTransaction as w, count as x, aggregate as y, subscribe as z };
|
|
35637
|
-
//# sourceMappingURL=index-
|
|
36117
|
+
//# sourceMappingURL=index-Buv6IzVV.esm.js.map
|