diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index a3f4e25106..2b0bad37c9 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -1,49 +1,50 @@ import NimQml, sequtils, sugar, chronicles, uuids -import ../../app_service/service/general/service as general_service -import ../../app_service/service/keychain/service as keychain_service -import ../../app_service/service/keycard/service as keycard_service -import ../../app_service/service/accounts/service as accounts_service -import ../../app_service/service/contacts/service as contacts_service -import ../../app_service/service/language/service as language_service -import ../../app_service/service/chat/service as chat_service -import ../../app_service/service/community/service as community_service -import ../../app_service/service/message/service as message_service -import ../../app_service/service/token/service as token_service -import ../../app_service/service/collectible/service as collectible_service -import ../../app_service/service/currency/service as currency_service -import ../../app_service/service/transaction/service as transaction_service -import ../../app_service/service/wallet_account/service as wallet_account_service -import ../../app_service/service/bookmarks/service as bookmark_service -import ../../app_service/service/dapp_permissions/service as dapp_permissions_service -import ../../app_service/service/privacy/service as privacy_service -import ../../app_service/service/provider/service as provider_service -import ../../app_service/service/node/service as node_service -import ../../app_service/service/profile/service as profile_service -import ../../app_service/service/settings/service as settings_service -import ../../app_service/service/stickers/service as stickers_service -import ../../app_service/service/about/service as about_service -import ../../app_service/service/node_configuration/service as node_configuration_service -import ../../app_service/service/network/service as network_service -import ../../app_service/service/activity_center/service as activity_center_service -import ../../app_service/service/saved_address/service as saved_address_service -import ../../app_service/service/devices/service as devices_service -import ../../app_service/service/mailservers/service as mailservers_service -import ../../app_service/service/gif/service as gif_service -import ../../app_service/service/ens/service as ens_service -import ../../app_service/service/community_tokens/service as tokens_service -import ../../app_service/service/network_connection/service as network_connection_service -import ../../app_service/service/shared_urls/service as shared_urls_service +import app_service/service/general/service as general_service +import app_service/service/keychain/service as keychain_service +import app_service/service/keycard/service as keycard_service +import app_service/service/accounts/service as accounts_service +import app_service/service/contacts/service as contacts_service +import app_service/service/language/service as language_service +import app_service/service/chat/service as chat_service +import app_service/service/community/service as community_service +import app_service/service/message/service as message_service +import app_service/service/token/service as token_service +import app_service/service/collectible/service as collectible_service +import app_service/service/currency/service as currency_service +import app_service/service/transaction/service as transaction_service +import app_service/service/wallet_account/service as wallet_account_service +import app_service/service/wallet_connect/service as wallet_connect_service +import app_service/service/bookmarks/service as bookmark_service +import app_service/service/dapp_permissions/service as dapp_permissions_service +import app_service/service/privacy/service as privacy_service +import app_service/service/provider/service as provider_service +import app_service/service/node/service as node_service +import app_service/service/profile/service as profile_service +import app_service/service/settings/service as settings_service +import app_service/service/stickers/service as stickers_service +import app_service/service/about/service as about_service +import app_service/service/node_configuration/service as node_configuration_service +import app_service/service/network/service as network_service +import app_service/service/activity_center/service as activity_center_service +import app_service/service/saved_address/service as saved_address_service +import app_service/service/devices/service as devices_service +import app_service/service/mailservers/service as mailservers_service +import app_service/service/gif/service as gif_service +import app_service/service/ens/service as ens_service +import app_service/service/community_tokens/service as tokens_service +import app_service/service/network_connection/service as network_connection_service +import app_service/service/shared_urls/service as shared_urls_service -import ../modules/shared_modules/keycard_popup/module as keycard_shared_module -import ../modules/startup/module as startup_module -import ../modules/main/module as main_module -import ../core/notifications/notifications_manager -import ../../constants as main_constants +import app/modules/shared_modules/keycard_popup/module as keycard_shared_module +import app/modules/startup/module as startup_module +import app/modules/main/module as main_module +import app/core/notifications/notifications_manager import app/global/global_singleton import app/global/app_signals +import app/core/[main] -import ../core/[main] +import constants as main_constants logScope: topics = "app-controller" @@ -80,6 +81,7 @@ type currencyService: currency_service.Service transactionService: transaction_service.Service walletAccountService: wallet_account_service.Service + walletConnectService: wallet_connect_service.Service bookmarkService: bookmark_service.Service dappPermissionsService: dapp_permissions_service.Service providerService: provider_service.Service @@ -190,6 +192,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = statusFoundation.events, statusFoundation.threadpool, result.settingsService, result.accountsService, result.tokenService, result.networkService, result.currencyService ) + result.walletConnectService = wallet_connect_service.newService(statusFoundation.events, statusFoundation.threadpool) result.messageService = message_service.newService( statusFoundation.events, statusFoundation.threadpool, @@ -324,6 +327,7 @@ proc delete*(self: AppController) = self.tokenService.delete self.transactionService.delete self.walletAccountService.delete + self.walletConnectService.delete self.aboutService.delete self.networkService.delete self.activityCenterService.delete @@ -451,6 +455,7 @@ proc load(self: AppController) = self.collectibleService.init() self.currencyService.init() self.walletAccountService.init() + self.walletConnectService.init() # Apply runtime log level settings if not main_constants.runtimeLogLevelSet(): diff --git a/src/app/modules/main/wallet_section/module.nim b/src/app/modules/main/wallet_section/module.nim index d415c25c91..68fa09addd 100644 --- a/src/app/modules/main/wallet_section/module.nim +++ b/src/app/modules/main/wallet_section/module.nim @@ -16,7 +16,7 @@ import ./send/module as send_module import ./activity/controller as activityc import ./activity/details_controller as activity_detailsc -import ./wallet_connect/controller as wcc +import ./poc_wallet_connect/controller as wcc import app/modules/shared_modules/collectible_details/controller as collectible_detailsc diff --git a/src/app/modules/main/wallet_section/wallet_connect/controller.nim b/src/app/modules/main/wallet_section/poc_wallet_connect/controller.nim similarity index 97% rename from src/app/modules/main/wallet_section/wallet_connect/controller.nim rename to src/app/modules/main/wallet_section/poc_wallet_connect/controller.nim index 36c667bcf6..8c3abf5cbb 100644 --- a/src/app/modules/main/wallet_section/wallet_connect/controller.nim +++ b/src/app/modules/main/wallet_section/poc_wallet_connect/controller.nim @@ -1,7 +1,11 @@ +################################################################################ +# WalletConnect POC - to remove this file +################################################################################ + import NimQml, strutils, json, chronicles import backend/wallet as backend_wallet -import backend/wallet_connect as backend_wallet_connect +import backend/poc_wallet_connect as backend_wallet_connect import app/global/global_singleton import app/global/app_signals diff --git a/src/app/modules/main/wallet_section/wallet_connect/helpers.nim b/src/app/modules/main/wallet_section/poc_wallet_connect/helpers.nim similarity index 86% rename from src/app/modules/main/wallet_section/wallet_connect/helpers.nim rename to src/app/modules/main/wallet_section/poc_wallet_connect/helpers.nim index 889dd3ce36..6dc1339c58 100644 --- a/src/app/modules/main/wallet_section/wallet_connect/helpers.nim +++ b/src/app/modules/main/wallet_section/poc_wallet_connect/helpers.nim @@ -1,3 +1,7 @@ +################################################################################ +# WalletConnect POC - to remove this file +################################################################################ + import json, strutils import uri diff --git a/src/app/modules/main/wallet_section/wallet_connect/tx_response_dto.nim b/src/app/modules/main/wallet_section/poc_wallet_connect/tx_response_dto.nim similarity index 76% rename from src/app/modules/main/wallet_section/wallet_connect/tx_response_dto.nim rename to src/app/modules/main/wallet_section/poc_wallet_connect/tx_response_dto.nim index 915c831b33..10196dc260 100644 --- a/src/app/modules/main/wallet_section/wallet_connect/tx_response_dto.nim +++ b/src/app/modules/main/wallet_section/poc_wallet_connect/tx_response_dto.nim @@ -1,3 +1,7 @@ +################################################################################ +# WalletConnect POC - to remove this file +################################################################################ + import json include app_service/common/json_utils diff --git a/src/app/modules/main/wallet_section/view.nim b/src/app/modules/main/wallet_section/view.nim index 58f52f4e09..65b36865af 100644 --- a/src/app/modules/main/wallet_section/view.nim +++ b/src/app/modules/main/wallet_section/view.nim @@ -5,7 +5,7 @@ import ./activity/details_controller as activity_detailsc import app/modules/shared_modules/collectible_details/controller as collectible_detailsc import ./io_interface import ../../shared_models/currency_amount -import ./wallet_connect/controller as wcc +import ./poc_wallet_connect/controller as wcc type ActivityControllerArray* = array[2, activityc.Controller] diff --git a/src/app/modules/shared_modules/wallet_connect/controller.nim b/src/app/modules/shared_modules/wallet_connect/controller.nim new file mode 100644 index 0000000000..68285316aa --- /dev/null +++ b/src/app/modules/shared_modules/wallet_connect/controller.nim @@ -0,0 +1,32 @@ +import chronicles +import io_interface + +import app/core/eventemitter +import app_service/service/wallet_account/service as wallet_account_service +import app_service/service/wallet_connect/service as wallet_connect_service + +logScope: + topics = "wallet-connect-controller" + +type + Controller* = ref object of RootObj + delegate: io_interface.AccessInterface + events: EventEmitter + walletAccountService: wallet_account_service.Service + walletConnectService: wallet_connect_service.Service + +proc newController*(delegate: io_interface.AccessInterface, + events: EventEmitter, + walletAccountService: wallet_account_service.Service, + walletConnectService: wallet_connect_service.Service): Controller = + result = Controller() + result.delegate = delegate + result.events = events + result.walletAccountService = walletAccountService + result.walletConnectService = walletConnectService + +proc delete*(self: Controller) = + self.disconnectAll() + +proc init*(self: Controller) = + discard \ No newline at end of file diff --git a/src/app/modules/shared_modules/wallet_connect/io_interface.nim b/src/app/modules/shared_modules/wallet_connect/io_interface.nim new file mode 100644 index 0000000000..9d6679ac3c --- /dev/null +++ b/src/app/modules/shared_modules/wallet_connect/io_interface.nim @@ -0,0 +1,14 @@ +import NimQml + +type + AccessInterface* {.pure inheritable.} = ref object of RootObj + +method delete*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} = + raise newException(ValueError, "No implementation available") + + +type + DelegateInterface* = concept c diff --git a/src/app/modules/shared_modules/wallet_connect/module.nim b/src/app/modules/shared_modules/wallet_connect/module.nim new file mode 100644 index 0000000000..c8c51e7532 --- /dev/null +++ b/src/app/modules/shared_modules/wallet_connect/module.nim @@ -0,0 +1,49 @@ +import NimQml, chronicles + +import io_interface +import view, controller +import app/core/eventemitter + +import app_service/service/wallet_account/service as wallet_account_service +import app_service/service/wallet_connect/service as wallet_connect_service +import app_service/service/keychain/service as keychain_service + +export io_interface + +logScope: + topics = "wallet-connect-module" + +type + Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface + delegate: T + view: View + viewVariant: QVariant + controller: Controller + +proc newModule*[T](delegate: T, + uniqueIdentifier: string, + events: EventEmitter, + walletAccountService: wallet_account_service.Service, + walletConnectService: wallet_connect_service.Service): + Module[T] = + result = Module[T]() + result.delegate = delegate + result.view = view.newView(result) + result.viewVariant = newQVariant(result.view) + result.controller = controller.newController(result, walletAccountService, walletConnectService) + +{.push warning[Deprecated]: off.} + +method delete*[T](self: Module[T]) = + self.view.delete + self.viewVariant.delete + self.controller.delete + +proc init[T](self: Module[T], fullConnect = true) = + self.controller.init() + +method getModuleAsVariant*[T](self: Module[T]): QVariant = + return self.viewVariant + + +{.pop.} diff --git a/src/app/modules/shared_modules/wallet_connect/view.nim b/src/app/modules/shared_modules/wallet_connect/view.nim new file mode 100644 index 0000000000..1b1e8044e3 --- /dev/null +++ b/src/app/modules/shared_modules/wallet_connect/view.nim @@ -0,0 +1,15 @@ +import NimQml +import io_interface + +QtObject: + type + View* = ref object of QObject + delegate: io_interface.AccessInterface + + proc delete*(self: View) = + self.QObject.delete + + proc newView*(delegate: io_interface.AccessInterface): View = + new(result, delete) + result.QObject.setup + result.delegate = delegate \ No newline at end of file diff --git a/src/app_service/service/wallet_connect/async_tasks.nim b/src/app_service/service/wallet_connect/async_tasks.nim new file mode 100644 index 0000000000..661a54e173 --- /dev/null +++ b/src/app_service/service/wallet_connect/async_tasks.nim @@ -0,0 +1,3 @@ +################################################# +# Async +################################################# diff --git a/src/app_service/service/wallet_connect/service.nim b/src/app_service/service/wallet_connect/service.nim new file mode 100644 index 0000000000..f539eedcf3 --- /dev/null +++ b/src/app_service/service/wallet_connect/service.nim @@ -0,0 +1,34 @@ +import NimQml, chronicles + +# import backend/wallet_connect as status_go_wallet_connect + +import app/global/global_singleton + +import app/core/eventemitter +import app/core/signals/types +import app/core/tasks/[threadpool] + +logScope: + topics = "wallet-connect-service" + +# include async_tasks + +QtObject: + type Service* = ref object of QObject + events: EventEmitter + threadpool: ThreadPool + + proc delete*(self: Service) = + self.QObject.delete + + proc newService*( + events: EventEmitter, + threadpool: ThreadPool, + ): Service = + new(result, delete) + result.QObject.setup + result.events = events + result.threadpool = threadpool + + proc init*(self: Service) = + discard \ No newline at end of file diff --git a/src/backend/poc_wallet_connect.nim b/src/backend/poc_wallet_connect.nim new file mode 100644 index 0000000000..d3d61d1413 --- /dev/null +++ b/src/backend/poc_wallet_connect.nim @@ -0,0 +1,97 @@ +################################################################################ +# WalletConnect POC - to remove this file +################################################################################ + +import options, logging +import json +import core, response_type + +from gen import rpc +import backend + +# Declared in services/wallet/walletconnect/walletconnect.go +const eventWCProposeUserPair*: string = "WalletConnectProposeUserPair" + +# Declared in services/wallet/walletconnect/walletconnect.go +const ErrorChainsNotSupported*: string = "chains not supported" + +rpc(wCSignMessage, "wallet"): + message: string + address: string + password: string + +rpc(wCBuildRawTransaction, "wallet"): + signature: string + + +rpc(wCSendTransactionWithSignature, "wallet"): + signature: string + +rpc(wCPairSessionProposal, "wallet"): + sessionProposalJson: string + +rpc(wCSaveOrUpdateSession, "wallet"): + sessionJson: string + +rpc(wCChangeSessionState, "wallet"): + topic: string + active: bool + +rpc(wCSessionRequest, "wallet"): + sessionRequestJson: string + +rpc(wCAuthRequest, "wallet"): + address: string + message: string + + +proc isErrorResponse(rpcResponse: RpcResponse[JsonNode]): bool = + return not rpcResponse.error.isNil + +proc prepareResponse(res: var JsonNode, rpcResponse: RpcResponse[JsonNode]): string = + if isErrorResponse(rpcResponse): + return rpcResponse.error.message + if rpcResponse.result.isNil: + return "no result" + res = rpcResponse.result + +# TODO #12434: async answer +proc pair*(res: var JsonNode, sessionProposalJson: string): string = + try: + let response = wCPairSessionProposal(sessionProposalJson) + return prepareResponse(res, response) + except Exception as e: + warn e.msg + return e.msg + +proc saveOrUpdateSession*(sessionJson: string): bool = + try: + let response = wCSaveOrUpdateSession(sessionJson) + return not isErrorResponse(response) + except Exception as e: + warn e.msg + return false + +proc deleteSession*(topic: string): bool = + try: + let response = wCChangeSessionState(topic, false) + return not isErrorResponse(response) + except Exception as e: + warn e.msg + return false + +proc sessionRequest*(res: var JsonNode, sessionRequestJson: string): string = + try: + let response = wCSessionRequest(sessionRequestJson) + return prepareResponse(res, response) + except Exception as e: + warn e.msg + return e.msg + +proc authRequest*(res: var JsonNode, address: string, authMessage: string): string = + try: + let response = wCAuthRequest(address, authMessage) + return prepareResponse(res, response) + except Exception as e: + warn e.msg + return e.msg \ No newline at end of file diff --git a/src/backend/wallet_connect.nim b/src/backend/wallet_connect.nim index aad94dc63c..56966c4776 100644 --- a/src/backend/wallet_connect.nim +++ b/src/backend/wallet_connect.nim @@ -1,93 +1,2 @@ -import options, logging import json import core, response_type - -from gen import rpc -import backend - -# Declared in services/wallet/walletconnect/walletconnect.go -const eventWCProposeUserPair*: string = "WalletConnectProposeUserPair" - -# Declared in services/wallet/walletconnect/walletconnect.go -const ErrorChainsNotSupported*: string = "chains not supported" - -rpc(wCSignMessage, "wallet"): - message: string - address: string - password: string - -rpc(wCBuildRawTransaction, "wallet"): - signature: string - - -rpc(wCSendTransactionWithSignature, "wallet"): - signature: string - -rpc(wCPairSessionProposal, "wallet"): - sessionProposalJson: string - -rpc(wCSaveOrUpdateSession, "wallet"): - sessionJson: string - -rpc(wCChangeSessionState, "wallet"): - topic: string - active: bool - -rpc(wCSessionRequest, "wallet"): - sessionRequestJson: string - -rpc(wCAuthRequest, "wallet"): - address: string - message: string - - -proc isErrorResponse(rpcResponse: RpcResponse[JsonNode]): bool = - return not rpcResponse.error.isNil - -proc prepareResponse(res: var JsonNode, rpcResponse: RpcResponse[JsonNode]): string = - if isErrorResponse(rpcResponse): - return rpcResponse.error.message - if rpcResponse.result.isNil: - return "no result" - res = rpcResponse.result - -# TODO #12434: async answer -proc pair*(res: var JsonNode, sessionProposalJson: string): string = - try: - let response = wCPairSessionProposal(sessionProposalJson) - return prepareResponse(res, response) - except Exception as e: - warn e.msg - return e.msg - -proc saveOrUpdateSession*(sessionJson: string): bool = - try: - let response = wCSaveOrUpdateSession(sessionJson) - return not isErrorResponse(response) - except Exception as e: - warn e.msg - return false - -proc deleteSession*(topic: string): bool = - try: - let response = wCChangeSessionState(topic, false) - return not isErrorResponse(response) - except Exception as e: - warn e.msg - return false - -proc sessionRequest*(res: var JsonNode, sessionRequestJson: string): string = - try: - let response = wCSessionRequest(sessionRequestJson) - return prepareResponse(res, response) - except Exception as e: - warn e.msg - return e.msg - -proc authRequest*(res: var JsonNode, address: string, authMessage: string): string = - try: - let response = wCAuthRequest(address, authMessage) - return prepareResponse(res, response) - except Exception as e: - warn e.msg - return e.msg \ No newline at end of file diff --git a/storybook/stubs/AppLayouts/Wallet/views/walletconnect/src/index.html b/storybook/stubs/AppLayouts/Wallet/views/walletconnect/src/index.html index 247e63e2a3..dba7580200 100644 --- a/storybook/stubs/AppLayouts/Wallet/views/walletconnect/src/index.html +++ b/storybook/stubs/AppLayouts/Wallet/views/walletconnect/src/index.html @@ -4,7 +4,7 @@ - + diff --git a/test/nim/wallet_connect_tests.nim b/test/nim/wallet_connect_tests.nim index 1b7f4a8b42..ea47cda27f 100644 --- a/test/nim/wallet_connect_tests.nim +++ b/test/nim/wallet_connect_tests.nim @@ -1,6 +1,6 @@ import unittest -import app/modules/main/wallet_section/wallet_connect/helpers +import app/modules/main/wallet_section/poc_wallet_connect/helpers suite "wallet connect": diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 37c6ba98fe..7a6f196121 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -65,6 +65,9 @@ StatusSectionLayout { case Constants.settingsSubsection.keycard: keycardView.item.handleBackAction() break; + case Constants.settingsSubsection.dapps: + dappsView.item.handleBackAction() + break; } Global.settingsSubSubsection = -1 } @@ -130,6 +133,8 @@ StatusSectionLayout { walletView.item.resetStack() } else if (currentIndex === Constants.settingsSubsection.keycard) { keycardView.item.handleBackAction() + } else if (currentIndex === Constants.settingsSubsection.dapps) { + dappsView.item.handleBackAction() } } @@ -257,6 +262,21 @@ StatusSectionLayout { onLoaded: root.store.backButtonName = "" } + Loader { + id: dappsView + active: false + asynchronous: true + sourceComponent: DappsView { + implicitWidth: parent.width + implicitHeight: parent.height + profileSectionStore: root.store + sectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.dapps) + mainSectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.dapps) + contentWidth: d.contentWidth + } + onLoaded: root.store.backButtonName = "" + } + Loader { active: false asynchronous: true diff --git a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml index 73af073b35..f5961083cd 100644 --- a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml @@ -122,6 +122,9 @@ QtObject { append({subsection: Constants.settingsSubsection.wallet, text: qsTr("Wallet"), icon: "wallet"}) + append({subsection: Constants.settingsSubsection.dapps, + text: qsTr("dApps"), + icon: "dapp"}) append({subsection: Constants.settingsSubsection.browserSettings, text: qsTr("Browser"), icon: "browser"}) diff --git a/ui/app/AppLayouts/Profile/views/AdvancedView.qml b/ui/app/AppLayouts/Profile/views/AdvancedView.qml index 5e8128f985..b2fe227287 100644 --- a/ui/app/AppLayouts/Profile/views/AdvancedView.qml +++ b/ui/app/AppLayouts/Profile/views/AdvancedView.qml @@ -24,10 +24,10 @@ import "../controls" import "../popups" import "../panels" -// TODO: remove DEV import -import AppLayouts.Wallet.stores 1.0 as WalletStores -import AppLayouts.Wallet.views.walletconnect 1.0 -// TODO end +///////////////////////////////////////////////////// +// WalletConnect POC - to remove +import AppLayouts.Wallet.views.pocwalletconnect 1.0 +///////////////////////////////////////////////////// SettingsContentBase { id: root @@ -171,16 +171,19 @@ SettingsContentBase { } } + ///////////////////////////////////////////////////// + // WalletConnect POC - to remove StatusSettingsLineButton { anchors.leftMargin: 0 anchors.rightMargin: 0 - text: qsTr("Debug Wallet Connect") + text: qsTr("POC Wallet Connect") visible: root.advancedStore.isDebugEnabled onClicked: { Global.popupWalletConnect() } } + ///////////////////////////////////////////////////// Separator { width: parent.width diff --git a/ui/app/AppLayouts/Profile/views/DappsView.qml b/ui/app/AppLayouts/Profile/views/DappsView.qml new file mode 100644 index 0000000000..e058c3d98f --- /dev/null +++ b/ui/app/AppLayouts/Profile/views/DappsView.qml @@ -0,0 +1,88 @@ +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.14 +import QtQml.Models 2.14 + +import StatusQ.Core 0.1 +import StatusQ.Controls 0.1 +import StatusQ.Core.Theme 0.1 + +import utils 1.0 + +import "../stores" +import "./dapps" + +SettingsContentBase { + id: root + + required property ProfileSectionStore profileSectionStore + required property string mainSectionTitle + + titleRowComponentLoader.sourceComponent: stackLayout.currentIndex === d.mainViewIndex || + stackLayout.currentIndex === d.connectedDappsIndex? + d.headerButton : undefined + + function handleBackAction() { + if (stackLayout.currentIndex !== d.mainViewIndex) { + root.profileSectionStore.backButtonName = "" + root.sectionTitle = root.mainSectionTitle + stackLayout.currentIndex = d.mainViewIndex + } + } + + StackLayout { + id: stackLayout + + currentIndex: d.mainViewIndex + + QtObject { + id: d + + readonly property int mainViewIndex: 0 + readonly property int connectedDappsIndex: 1 + readonly property int approvalsIndex: 2 + readonly property int trustLevelsIndex: 3 + readonly property int securityIndex: 4 + + function changeSubsection(title, index) { + root.profileSectionStore.backButtonName = root.mainSectionTitle + root.sectionTitle = title + stackLayout.currentIndex = index + } + + property Component headerButton: Component { + StatusButton { + text: qsTr("Connect a dApp via WalletConnect") + onClicked: { + console.warn("TODO: run wallet connect popup...") + } + } + } + } + + Main { + Layout.preferredWidth: root.contentWidth + + onDisplayConnectedDapps: d.changeSubsection(title, d.connectedDappsIndex) + onDisplayApprovals: d.changeSubsection(title, d.approvalsIndex) + onDisplayTrustLevels: d.changeSubsection(title, d.trustLevelsIndex) + onDisplaySecurity: d.changeSubsection(title, d.securityIndex) + } + + ConnectedDapps { + Layout.preferredWidth: root.contentWidth + } + + Approvals { + Layout.preferredWidth: root.contentWidth + } + + TrustLevels { + Layout.preferredWidth: root.contentWidth + } + + Security { + Layout.preferredWidth: root.contentWidth + } + } +} diff --git a/ui/app/AppLayouts/Profile/views/dapps/Approvals.qml b/ui/app/AppLayouts/Profile/views/dapps/Approvals.qml new file mode 100644 index 0000000000..d5434f9abe --- /dev/null +++ b/ui/app/AppLayouts/Profile/views/dapps/Approvals.qml @@ -0,0 +1,44 @@ +import QtQuick 2.14 +import QtQuick.Layouts 1.14 + +import StatusQ.Controls 0.1 + +import utils 1.0 +import shared.controls 1.0 + +ColumnLayout { + id: root + + spacing: Constants.settingsSection.itemSpacing + + QtObject { + id: d + } + + StatusTabBar { + id: walletTabBar + Layout.fillWidth: true + + StatusTabButton { + leftPadding: 0 + width: implicitWidth + text: qsTr("By dApp") + } + + StatusTabButton { + width: implicitWidth + text: qsTr("By token") + } + + StatusTabButton { + width: implicitWidth + text: qsTr("By account") + } + } + + ShapeRectangle { + Layout.fillWidth: true + Layout.preferredHeight: implicitHeight + text: qsTr("Your dApp approvals will appear here") + } +} diff --git a/ui/app/AppLayouts/Profile/views/dapps/ConnectedDapps.qml b/ui/app/AppLayouts/Profile/views/dapps/ConnectedDapps.qml new file mode 100644 index 0000000000..a7fca1415d --- /dev/null +++ b/ui/app/AppLayouts/Profile/views/dapps/ConnectedDapps.qml @@ -0,0 +1,39 @@ +import QtQuick 2.14 +import QtQuick.Layouts 1.14 + +import StatusQ.Controls 0.1 + +import utils 1.0 +import shared.controls 1.0 + +ColumnLayout { + id: root + + spacing: Constants.settingsSection.itemSpacing + + QtObject { + id: d + } + + StatusTabBar { + id: walletTabBar + Layout.fillWidth: true + + StatusTabButton { + leftPadding: 0 + width: implicitWidth + text: qsTr("By dApp") + } + + StatusTabButton { + width: implicitWidth + text: qsTr("By account") + } + } + + ShapeRectangle { + Layout.fillWidth: true + Layout.preferredHeight: implicitHeight + text: qsTr("Your connected dApps will appear here") + } +} diff --git a/ui/app/AppLayouts/Profile/views/dapps/Main.qml b/ui/app/AppLayouts/Profile/views/dapps/Main.qml new file mode 100644 index 0000000000..c9c9388dcf --- /dev/null +++ b/ui/app/AppLayouts/Profile/views/dapps/Main.qml @@ -0,0 +1,79 @@ +import QtQuick 2.14 +import QtQuick.Layouts 1.14 + +import StatusQ.Core 0.1 +import StatusQ.Core.Theme 0.1 +import StatusQ.Components 0.1 + +import utils 1.0 + +ColumnLayout { + id: root + + signal displayConnectedDapps(string title) + signal displayApprovals(string title) + signal displayTrustLevels(string title) + signal displaySecurity(string title) + + spacing: Constants.settingsSection.itemSpacing + + QtObject { + id: d + } + + StatusListItem { + Layout.fillWidth: true + title: qsTr("Connected") + components: [ + StatusIcon { + icon: "next" + color: Theme.palette.baseColor1 + } + ] + onClicked: { + root.displayConnectedDapps(title) + } + } + + StatusListItem { + Layout.fillWidth: true + title: qsTr("Approvals") + components: [ + StatusIcon { + icon: "next" + color: Theme.palette.baseColor1 + } + ] + onClicked: { + root.displayApprovals(title) + } + } + + StatusListItem { + Layout.fillWidth: true + title: qsTr("Trust levels") + components: [ + StatusIcon { + icon: "next" + color: Theme.palette.baseColor1 + } + ] + onClicked: { + root.displayTrustLevels(title) + } + } + + StatusListItem { + Layout.fillWidth: true + title: qsTr("Security") + components: [ + StatusIcon { + icon: "next" + color: Theme.palette.baseColor1 + } + ] + onClicked: { + root.displaySecurity(title) + } + } +} diff --git a/ui/app/AppLayouts/Profile/views/dapps/Security.qml b/ui/app/AppLayouts/Profile/views/dapps/Security.qml new file mode 100644 index 0000000000..8d650ee7e4 --- /dev/null +++ b/ui/app/AppLayouts/Profile/views/dapps/Security.qml @@ -0,0 +1,14 @@ +import QtQuick 2.14 +import QtQuick.Layouts 1.14 + +import utils 1.0 + +ColumnLayout { + id: root + + spacing: Constants.settingsSection.itemSpacing + + QtObject { + id: d + } +} diff --git a/ui/app/AppLayouts/Profile/views/dapps/TrustLevels.qml b/ui/app/AppLayouts/Profile/views/dapps/TrustLevels.qml new file mode 100644 index 0000000000..bf9435f651 --- /dev/null +++ b/ui/app/AppLayouts/Profile/views/dapps/TrustLevels.qml @@ -0,0 +1,23 @@ +import QtQuick 2.14 +import QtQuick.Layouts 1.14 + +import StatusQ.Controls 0.1 + +import utils 1.0 +import shared.controls 1.0 + +ColumnLayout { + id: root + + spacing: Constants.settingsSection.itemSpacing + + QtObject { + id: d + } + + ShapeRectangle { + Layout.fillWidth: true + Layout.preferredHeight: implicitHeight + text: qsTr("Your trust level for dApps you have interacted with will appear here") + } +} diff --git a/ui/app/AppLayouts/Wallet/controls/ConnectedDappsButton.qml b/ui/app/AppLayouts/Wallet/controls/ConnectedDappsButton.qml new file mode 100644 index 0000000000..901c1bc5cf --- /dev/null +++ b/ui/app/AppLayouts/Wallet/controls/ConnectedDappsButton.qml @@ -0,0 +1,90 @@ +import QtQuick 2.15 +import QtGraphicalEffects 1.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 + +import shared.controls 1.0 + +import StatusQ.Core.Theme 0.1 +import StatusQ.Controls 0.1 + +StatusButton { + id: root + + property int menuWidth: 312 + + signal connectDapp() + + borderColor: Theme.palette.directColor7 + normalColor: Theme.palette.transparent + hoverColor: Theme.palette.baseColor2 + textPosition: StatusBaseButton.TextPosition.Left + textColor: Theme.palette.baseColor1 + + icon.name: "dapp" + icon.height: 16 + icon.width: 16 + icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1 + + highlighted: popup.opened + + onClicked: { + if (popup.opened) { + popup.close() + return + } + popup.x = width - root.menuWidth - 2 * popup.padding + popup.y = height + 4 + popup.open() + } + + Popup { + id: popup + contentWidth: root.menuWidth + contentHeight: list.height + modal: false + padding: 8 + closePolicy: Popup.CloseOnEscape | Popup.CloseOnOutsideClick | Popup.CloseOnPressOutside + + background: Rectangle { + id: bckgContent + color: Theme.palette.statusMenu.backgroundColor + radius: 8 + layer.enabled: true + layer.effect: DropShadow { + anchors.fill: parent + source: bckgContent + horizontalOffset: 0 + verticalOffset: 4 + radius: 12 + samples: 25 + spread: 0.2 + color: Theme.palette.dropShadow + } + } + + ColumnLayout { + id: list + anchors.left: parent.left + anchors.right: parent.right + width: parent.width + spacing: 8 + + ShapeRectangle { + Layout.fillWidth: true + Layout.preferredHeight: implicitHeight + text: qsTr("Connected dApps will appear here") + } + + StatusButton { + Layout.fillWidth: true + Layout.preferredHeight: implicitHeight + + text: qsTr("Connect a dApp via WalletConnect") + onClicked: { + root.connectDapp() + } + } + } + } +} diff --git a/ui/app/AppLayouts/Wallet/controls/qmldir b/ui/app/AppLayouts/Wallet/controls/qmldir index cd2b1d480b..2213db7aa0 100644 --- a/ui/app/AppLayouts/Wallet/controls/qmldir +++ b/ui/app/AppLayouts/Wallet/controls/qmldir @@ -13,3 +13,4 @@ ManageTokensGroupDelegate 1.0 ManageTokensGroupDelegate.qml InformationTileAssetDetails 1.0 InformationTileAssetDetails.qml StatusNetworkListItemTag 1.0 StatusNetworkListItemTag.qml CollectibleBalanceTag 1.0 CollectibleBalanceTag.qml +ConnectedDappsButton 1.0 ConnectedDappsButton.qml diff --git a/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml b/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml index 39881fdf45..8a9ff83617 100644 --- a/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml +++ b/ui/app/AppLayouts/Wallet/panels/WalletHeader.qml @@ -7,6 +7,7 @@ import StatusQ.Controls 0.1 import StatusQ.Components 0.1 import StatusQ.Core.Theme 0.1 import StatusQ.Core.Utils 0.1 as StatusQUtils +import StatusQ.Popups 0.1 import SortFilterProxyModel 0.2 @@ -73,6 +74,19 @@ Item { Layout.alignment: Qt.AlignTrailing Layout.topMargin: 5 + ConnectedDappsButton { + Layout.preferredHeight: 38 + Layout.alignment: Qt.AlignTop + + spacing: 8 + size: StatusBaseButton.Size.Small + visible: !root.walletStore.showSavedAddresses + + onConnectDapp: { + console.warn("TODO: run ConnectDappPopup...") + } + } + StatusButton { id: headerButton objectName: "walletHeaderButton" diff --git a/ui/app/AppLayouts/Wallet/stores/RootStore.qml b/ui/app/AppLayouts/Wallet/stores/RootStore.qml index c104d82ab4..825a66a39a 100644 --- a/ui/app/AppLayouts/Wallet/stores/RootStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/RootStore.qml @@ -56,7 +56,6 @@ QtObject { property var activityDetailsController: walletSectionInst.activityDetailsController property string signingPhrase: walletSectionInst.signingPhrase property string mnemonicBackedUp: walletSectionInst.isMnemonicBackedUp - property var walletConnectController: walletSectionInst.walletConnectController property CollectiblesStore collectiblesStore: CollectiblesStore {} diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/Pairings.qml b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCPairings.qml similarity index 88% rename from ui/app/AppLayouts/Wallet/views/walletconnect/Pairings.qml rename to ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCPairings.qml index 41fdc7daa4..1f23b5028d 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/Pairings.qml +++ b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCPairings.qml @@ -1,3 +1,7 @@ +///////////////////////////////////////////////////// +// WalletConnect POC - to remove this file +///////////////////////////////////////////////////// + import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/SelectAccount.qml b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCSelectAccount.qml similarity index 80% rename from ui/app/AppLayouts/Wallet/views/walletconnect/SelectAccount.qml rename to ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCSelectAccount.qml index 4b9b67407a..7165208bde 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/SelectAccount.qml +++ b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCSelectAccount.qml @@ -1,3 +1,7 @@ +///////////////////////////////////////////////////// +// WalletConnect POC - to remove this file +///////////////////////////////////////////////////// + import QtQuick 2.15 import QtQuick.Controls 2.15 diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/Sessions.qml b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCSessions.qml similarity index 97% rename from ui/app/AppLayouts/Wallet/views/walletconnect/Sessions.qml rename to ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCSessions.qml index 9251af3609..3618e4918f 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/Sessions.qml +++ b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCSessions.qml @@ -1,3 +1,7 @@ +///////////////////////////////////////////////////// +// WalletConnect POC - to remove this file +///////////////////////////////////////////////////// + import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnect.qml b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCWalletConnect.qml similarity index 78% rename from ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnect.qml rename to ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCWalletConnect.qml index 0cd3609d1e..37f38c668d 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnect.qml +++ b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCWalletConnect.qml @@ -1,7 +1,13 @@ +///////////////////////////////////////////////////// +// WalletConnect POC - to remove this file +///////////////////////////////////////////////////// + import QtQuick 2.15 import AppLayouts.Wallet.stores 1.0 as WalletStores +import shared.popups.walletconnect 1.0 + Item { id: root @@ -11,7 +17,7 @@ Item { property alias sdk: sdk property alias url: sdk.url - WalletConnectModal { + POCWalletConnectModal { id: modal controller: root.controller diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCWalletConnectModal.qml similarity index 98% rename from ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml rename to ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCWalletConnectModal.qml index 1758234621..22fbc06d58 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectModal.qml +++ b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/POCWalletConnectModal.qml @@ -1,3 +1,7 @@ +///////////////////////////////////////////////////// +// WalletConnect POC - to remove this file +///////////////////////////////////////////////////// + import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 @@ -6,6 +10,8 @@ import StatusQ.Controls 0.1 import StatusQ.Core 0.1 import StatusQ.Popups 0.1 +import shared.popups.walletconnect 1.0 + Popup { id: root @@ -147,7 +153,7 @@ Popup { id: selAccBtnGroup } - SelectAccount { + POCSelectAccount { Layout.fillWidth: true Layout.preferredHeight: contentHeight @@ -201,7 +207,7 @@ Popup { ColumnLayout { Layout.fillWidth: true - Sessions { + POCSessions { Layout.fillWidth: true Layout.preferredHeight: contentHeight @@ -220,7 +226,7 @@ Popup { ColumnLayout { Layout.fillWidth: true - Pairings { + POCPairings { Layout.fillWidth: true Layout.preferredHeight: contentHeight diff --git a/ui/app/AppLayouts/Wallet/views/pocwalletconnect/qmldir b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/qmldir new file mode 100644 index 0000000000..48d62c094a --- /dev/null +++ b/ui/app/AppLayouts/Wallet/views/pocwalletconnect/qmldir @@ -0,0 +1,3 @@ +POCWalletConnect 1.0 POCWalletConnect.qml +POCWalletConnectModal 1.0 POCWalletConnectModal.qml +POCPairings 1.0 POCPairings.qml diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/qmldir b/ui/app/AppLayouts/Wallet/views/walletconnect/qmldir deleted file mode 100644 index fb795772d3..0000000000 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -WalletConnect 1.0 WalletConnect.qml -WalletConnectModal 1.0 WalletConnectModal.qml -WalletConnectSDK 1.0 WalletConnectSDK.qml -Pairings 1.0 Pairings.qml \ No newline at end of file diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/generated/bundle.js b/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/generated/bundle.js deleted file mode 100644 index 2aba86974b..0000000000 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/generated/bundle.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see bundle.js.LICENSE.txt */ -var e={8099:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var i=r(7117);function n(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}function s(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function o(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function a(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function h(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function c(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function u(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function l(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function f(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),u(e/4294967296>>>0,t,r),u(e>>>0,t,r+4),t}function d(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),l(e>>>0,t,r),l(e/4294967296>>>0,t,r+4),t}t.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},t.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},t.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},t.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},t.writeUint16BE=n,t.writeInt16BE=n,t.writeUint16LE=s,t.writeInt16LE=s,t.readInt32BE=o,t.readUint32BE=a,t.readInt32LE=h,t.readUint32LE=c,t.writeUint32BE=u,t.writeInt32BE=u,t.writeUint32LE=l,t.writeInt32LE=l,t.readInt64BE=function(e,t){void 0===t&&(t=0);var r=o(e,t),i=o(e,t+4);return 4294967296*r+i-4294967296*(i>>31)},t.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*a(e,t)+a(e,t+4)},t.readInt64LE=function(e,t){void 0===t&&(t=0);var r=h(e,t);return 4294967296*h(e,t+4)+r-4294967296*(r>>31)},t.readUint64LE=function(e,t){void 0===t&&(t=0);var r=c(e,t);return 4294967296*c(e,t+4)+r},t.writeUint64BE=f,t.writeInt64BE=f,t.writeUint64LE=d,t.writeInt64LE=d,t.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=e/8+r-1;s>=r;s--)i+=t[s]*n,n*=256;return i},t.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=r;s=n;o--)r[o]=t/s&255,s*=256;return r},t.writeUintLE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!i.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var s=1,o=n;o{Object.defineProperty(t,"__esModule",{value:!0});var i=r(8099),n=r(7309),s=20;function o(e,t,r){for(var n=1634760805,o=857760878,a=2036477234,h=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],u=r[7]<<24|r[6]<<16|r[5]<<8|r[4],l=r[11]<<24|r[10]<<16|r[9]<<8|r[8],f=r[15]<<24|r[14]<<16|r[13]<<8|r[12],d=r[19]<<24|r[18]<<16|r[17]<<8|r[16],p=r[23]<<24|r[22]<<16|r[21]<<8|r[20],g=r[27]<<24|r[26]<<16|r[25]<<8|r[24],y=r[31]<<24|r[30]<<16|r[29]<<8|r[28],m=t[3]<<24|t[2]<<16|t[1]<<8|t[0],v=t[7]<<24|t[6]<<16|t[5]<<8|t[4],w=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],_=n,E=o,S=a,I=h,M=c,A=u,O=l,x=f,P=d,N=p,R=g,T=y,L=m,C=v,U=w,k=b,j=0;j>>16|L<<16)|0)>>>20|M<<12,A=(A^=N=N+(C=(C^=E=E+A|0)>>>16|C<<16)|0)>>>20|A<<12,O=(O^=R=R+(U=(U^=S=S+O|0)>>>16|U<<16)|0)>>>20|O<<12,x=(x^=T=T+(k=(k^=I=I+x|0)>>>16|k<<16)|0)>>>20|x<<12,O=(O^=R=R+(U=(U^=S=S+O|0)>>>24|U<<8)|0)>>>25|O<<7,x=(x^=T=T+(k=(k^=I=I+x|0)>>>24|k<<8)|0)>>>25|x<<7,A=(A^=N=N+(C=(C^=E=E+A|0)>>>24|C<<8)|0)>>>25|A<<7,M=(M^=P=P+(L=(L^=_=_+M|0)>>>24|L<<8)|0)>>>25|M<<7,A=(A^=R=R+(k=(k^=_=_+A|0)>>>16|k<<16)|0)>>>20|A<<12,O=(O^=T=T+(L=(L^=E=E+O|0)>>>16|L<<16)|0)>>>20|O<<12,x=(x^=P=P+(C=(C^=S=S+x|0)>>>16|C<<16)|0)>>>20|x<<12,M=(M^=N=N+(U=(U^=I=I+M|0)>>>16|U<<16)|0)>>>20|M<<12,x=(x^=P=P+(C=(C^=S=S+x|0)>>>24|C<<8)|0)>>>25|x<<7,M=(M^=N=N+(U=(U^=I=I+M|0)>>>24|U<<8)|0)>>>25|M<<7,O=(O^=T=T+(L=(L^=E=E+O|0)>>>24|L<<8)|0)>>>25|O<<7,A=(A^=R=R+(k=(k^=_=_+A|0)>>>24|k<<8)|0)>>>25|A<<7;i.writeUint32LE(_+n|0,e,0),i.writeUint32LE(E+o|0,e,4),i.writeUint32LE(S+a|0,e,8),i.writeUint32LE(I+h|0,e,12),i.writeUint32LE(M+c|0,e,16),i.writeUint32LE(A+u|0,e,20),i.writeUint32LE(O+l|0,e,24),i.writeUint32LE(x+f|0,e,28),i.writeUint32LE(P+d|0,e,32),i.writeUint32LE(N+p|0,e,36),i.writeUint32LE(R+g|0,e,40),i.writeUint32LE(T+y|0,e,44),i.writeUint32LE(L+m|0,e,48),i.writeUint32LE(C+v|0,e,52),i.writeUint32LE(U+w|0,e,56),i.writeUint32LE(k+b|0,e,60)}function a(e,t,r,i,s){if(void 0===s&&(s=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,t++;if(i>0)throw new Error("ChaCha: counter overflow")}t.streamXOR=a,t.stream=function(e,t,r,i){return void 0===i&&(i=0),n.wipe(r),a(e,t,r,r,i)}},5501:(e,t,r)=>{var i=r(5439),n=r(3027),s=r(7309),o=r(8099),a=r(4153);t.Cv=32,t.WH=12,t.pg=16;var h=new Uint8Array(16),c=function(){function e(e){if(this.nonceLength=t.WH,this.tagLength=t.pg,e.length!==t.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return e.prototype.seal=function(e,t,r,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(e,o.length-e.length);var a=new Uint8Array(32);i.stream(this._key,o,a,4);var h,c=t.length+this.tagLength;if(n){if(n.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");h=n}else h=new Uint8Array(c);return i.streamXOR(this._key,o,t,h,4),this._authenticate(h.subarray(h.length-this.tagLength,h.length),a,h.subarray(0,h.length-this.tagLength),r),s.wipe(o),h},e.prototype.open=function(e,t,r,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&a.update(h.subarray(i.length%16))),a.update(r),r.length%16>0&&a.update(h.subarray(r.length%16));var c=new Uint8Array(8);i&&o.writeUint64LE(i.length,c),a.update(c),o.writeUint64LE(r.length,c),a.update(c);for(var u=a.digest(),l=0;l{function r(e,t){if(e.length!==t.length)return 0;for(var r=0,i=0;i>>8}Object.defineProperty(t,"__esModule",{value:!0}),t.select=function(e,t,r){return~(e-1)&t|e-1&r},t.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},t.compare=r,t.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==r(e,t)}},1050:(e,t,r)=>{t.Xx=t._w=t.aP=t.KS=t.jQ=void 0;r(1416);const i=r(3350);r(7309);function n(e){const t=new Float64Array(16);if(e)for(let r=0;r>16&1),r[e-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,f(i,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&i[t],e[2*t+1]=i[t]>>8}function p(e){const t=new Uint8Array(32);return d(t,e),1&t[0]}function g(e,t,r){for(let i=0;i<16;i++)e[i]=t[i]+r[i]}function y(e,t,r){for(let i=0;i<16;i++)e[i]=t[i]-r[i]}function m(e,t,r){let i,n,s=0,o=0,a=0,h=0,c=0,u=0,l=0,f=0,d=0,p=0,g=0,y=0,m=0,v=0,w=0,b=0,_=0,E=0,S=0,I=0,M=0,A=0,O=0,x=0,P=0,N=0,R=0,T=0,L=0,C=0,U=0,k=r[0],j=r[1],q=r[2],D=r[3],z=r[4],$=r[5],K=r[6],B=r[7],F=r[8],V=r[9],H=r[10],W=r[11],G=r[12],J=r[13],Y=r[14],X=r[15];i=t[0],s+=i*k,o+=i*j,a+=i*q,h+=i*D,c+=i*z,u+=i*$,l+=i*K,f+=i*B,d+=i*F,p+=i*V,g+=i*H,y+=i*W,m+=i*G,v+=i*J,w+=i*Y,b+=i*X,i=t[1],o+=i*k,a+=i*j,h+=i*q,c+=i*D,u+=i*z,l+=i*$,f+=i*K,d+=i*B,p+=i*F,g+=i*V,y+=i*H,m+=i*W,v+=i*G,w+=i*J,b+=i*Y,_+=i*X,i=t[2],a+=i*k,h+=i*j,c+=i*q,u+=i*D,l+=i*z,f+=i*$,d+=i*K,p+=i*B,g+=i*F,y+=i*V,m+=i*H,v+=i*W,w+=i*G,b+=i*J,_+=i*Y,E+=i*X,i=t[3],h+=i*k,c+=i*j,u+=i*q,l+=i*D,f+=i*z,d+=i*$,p+=i*K,g+=i*B,y+=i*F,m+=i*V,v+=i*H,w+=i*W,b+=i*G,_+=i*J,E+=i*Y,S+=i*X,i=t[4],c+=i*k,u+=i*j,l+=i*q,f+=i*D,d+=i*z,p+=i*$,g+=i*K,y+=i*B,m+=i*F,v+=i*V,w+=i*H,b+=i*W,_+=i*G,E+=i*J,S+=i*Y,I+=i*X,i=t[5],u+=i*k,l+=i*j,f+=i*q,d+=i*D,p+=i*z,g+=i*$,y+=i*K,m+=i*B,v+=i*F,w+=i*V,b+=i*H,_+=i*W,E+=i*G,S+=i*J,I+=i*Y,M+=i*X,i=t[6],l+=i*k,f+=i*j,d+=i*q,p+=i*D,g+=i*z,y+=i*$,m+=i*K,v+=i*B,w+=i*F,b+=i*V,_+=i*H,E+=i*W,S+=i*G,I+=i*J,M+=i*Y,A+=i*X,i=t[7],f+=i*k,d+=i*j,p+=i*q,g+=i*D,y+=i*z,m+=i*$,v+=i*K,w+=i*B,b+=i*F,_+=i*V,E+=i*H,S+=i*W,I+=i*G,M+=i*J,A+=i*Y,O+=i*X,i=t[8],d+=i*k,p+=i*j,g+=i*q,y+=i*D,m+=i*z,v+=i*$,w+=i*K,b+=i*B,_+=i*F,E+=i*V,S+=i*H,I+=i*W,M+=i*G,A+=i*J,O+=i*Y,x+=i*X,i=t[9],p+=i*k,g+=i*j,y+=i*q,m+=i*D,v+=i*z,w+=i*$,b+=i*K,_+=i*B,E+=i*F,S+=i*V,I+=i*H,M+=i*W,A+=i*G,O+=i*J,x+=i*Y,P+=i*X,i=t[10],g+=i*k,y+=i*j,m+=i*q,v+=i*D,w+=i*z,b+=i*$,_+=i*K,E+=i*B,S+=i*F,I+=i*V,M+=i*H,A+=i*W,O+=i*G,x+=i*J,P+=i*Y,N+=i*X,i=t[11],y+=i*k,m+=i*j,v+=i*q,w+=i*D,b+=i*z,_+=i*$,E+=i*K,S+=i*B,I+=i*F,M+=i*V,A+=i*H,O+=i*W,x+=i*G,P+=i*J,N+=i*Y,R+=i*X,i=t[12],m+=i*k,v+=i*j,w+=i*q,b+=i*D,_+=i*z,E+=i*$,S+=i*K,I+=i*B,M+=i*F,A+=i*V,O+=i*H,x+=i*W,P+=i*G,N+=i*J,R+=i*Y,T+=i*X,i=t[13],v+=i*k,w+=i*j,b+=i*q,_+=i*D,E+=i*z,S+=i*$,I+=i*K,M+=i*B,A+=i*F,O+=i*V,x+=i*H,P+=i*W,N+=i*G,R+=i*J,T+=i*Y,L+=i*X,i=t[14],w+=i*k,b+=i*j,_+=i*q,E+=i*D,S+=i*z,I+=i*$,M+=i*K,A+=i*B,O+=i*F,x+=i*V,P+=i*H,N+=i*W,R+=i*G,T+=i*J,L+=i*Y,C+=i*X,i=t[15],b+=i*k,_+=i*j,E+=i*q,S+=i*D,I+=i*z,M+=i*$,A+=i*K,O+=i*B,x+=i*F,P+=i*V,N+=i*H,R+=i*W,T+=i*G,L+=i*J,C+=i*Y,U+=i*X,s+=38*_,o+=38*E,a+=38*S,h+=38*I,c+=38*M,u+=38*A,l+=38*O,f+=38*x,d+=38*P,p+=38*N,g+=38*R,y+=38*T,m+=38*L,v+=38*C,w+=38*U,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-65536*n,i=o+n+65535,n=Math.floor(i/65536),o=i-65536*n,i=a+n+65535,n=Math.floor(i/65536),a=i-65536*n,i=h+n+65535,n=Math.floor(i/65536),h=i-65536*n,i=c+n+65535,n=Math.floor(i/65536),c=i-65536*n,i=u+n+65535,n=Math.floor(i/65536),u=i-65536*n,i=l+n+65535,n=Math.floor(i/65536),l=i-65536*n,i=f+n+65535,n=Math.floor(i/65536),f=i-65536*n,i=d+n+65535,n=Math.floor(i/65536),d=i-65536*n,i=p+n+65535,n=Math.floor(i/65536),p=i-65536*n,i=g+n+65535,n=Math.floor(i/65536),g=i-65536*n,i=y+n+65535,n=Math.floor(i/65536),y=i-65536*n,i=m+n+65535,n=Math.floor(i/65536),m=i-65536*n,i=v+n+65535,n=Math.floor(i/65536),v=i-65536*n,i=w+n+65535,n=Math.floor(i/65536),w=i-65536*n,i=b+n+65535,n=Math.floor(i/65536),b=i-65536*n,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-65536*n,i=o+n+65535,n=Math.floor(i/65536),o=i-65536*n,i=a+n+65535,n=Math.floor(i/65536),a=i-65536*n,i=h+n+65535,n=Math.floor(i/65536),h=i-65536*n,i=c+n+65535,n=Math.floor(i/65536),c=i-65536*n,i=u+n+65535,n=Math.floor(i/65536),u=i-65536*n,i=l+n+65535,n=Math.floor(i/65536),l=i-65536*n,i=f+n+65535,n=Math.floor(i/65536),f=i-65536*n,i=d+n+65535,n=Math.floor(i/65536),d=i-65536*n,i=p+n+65535,n=Math.floor(i/65536),p=i-65536*n,i=g+n+65535,n=Math.floor(i/65536),g=i-65536*n,i=y+n+65535,n=Math.floor(i/65536),y=i-65536*n,i=m+n+65535,n=Math.floor(i/65536),m=i-65536*n,i=v+n+65535,n=Math.floor(i/65536),v=i-65536*n,i=w+n+65535,n=Math.floor(i/65536),w=i-65536*n,i=b+n+65535,n=Math.floor(i/65536),b=i-65536*n,s+=n-1+37*(n-1),e[0]=s,e[1]=o,e[2]=a,e[3]=h,e[4]=c,e[5]=u,e[6]=l,e[7]=f,e[8]=d,e[9]=p,e[10]=g,e[11]=y,e[12]=m,e[13]=v,e[14]=w,e[15]=b}function v(e,t){m(e,t,t)}function w(e,t){const r=n(),i=n(),s=n(),o=n(),h=n(),c=n(),u=n(),l=n(),f=n();y(r,e[1],e[0]),y(f,t[1],t[0]),m(r,r,f),g(i,e[0],e[1]),g(f,t[0],t[1]),m(i,i,f),m(s,e[3],t[3]),m(s,s,a),m(o,e[2],t[2]),g(o,o,o),y(h,i,r),y(c,o,s),g(u,o,s),g(l,i,r),m(e[0],h,c),m(e[1],l,u),m(e[2],u,c),m(e[3],h,l)}function b(e,t,r){for(let i=0;i<4;i++)f(e[i],t[i],r)}function _(e,t){const r=n(),i=n(),s=n();(function(e,t){const r=n();let i;for(i=0;i<16;i++)r[i]=t[i];for(i=253;i>=0;i--)v(r,r),2!==i&&4!==i&&m(r,r,t);for(i=0;i<16;i++)e[i]=r[i]})(s,t[2]),m(r,t[0],s),m(i,t[1],s),d(e,i),e[31]^=p(r)<<7}function E(e,t){const r=[n(),n(),n(),n()];u(r[0],h),u(r[1],c),u(r[2],o),m(r[3],h,c),function(e,t,r){u(e[0],s),u(e[1],o),u(e[2],o),u(e[3],s);for(let i=255;i>=0;--i){const n=r[i/8|0]>>(7&i)&1;b(e,t,n),w(t,e),w(e,e),b(e,t,n)}}(e,r,t)}t._w=function(e){if(e.length!==t.aP)throw new Error(`ed25519: seed must be ${t.aP} bytes`);const r=(0,i.hash)(e);r[0]&=248,r[31]&=127,r[31]|=64;const s=new Uint8Array(32),o=[n(),n(),n(),n()];E(o,r),_(s,o);const a=new Uint8Array(64);return a.set(e),a.set(s,32),{publicKey:s,secretKey:a}};const S=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function I(e,t){let r,i,n,s;for(i=63;i>=32;--i){for(r=0,n=i-32,s=i-12;n>4)*S[n],r=t[n]>>8,t[n]&=255;for(n=0;n<32;n++)t[n]-=r*S[n];for(i=0;i<32;i++)t[i+1]+=t[i]>>8,e[i]=255&t[i]}function M(e){const t=new Float64Array(64);for(let r=0;r<64;r++)t[r]=e[r];for(let t=0;t<64;t++)e[t]=0;I(e,t)}t.Xx=function(e,t){const r=new Float64Array(64),s=[n(),n(),n(),n()],o=(0,i.hash)(e.subarray(0,32));o[0]&=248,o[31]&=127,o[31]|=64;const a=new Uint8Array(64);a.set(o.subarray(32),32);const h=new i.SHA512;h.update(a.subarray(32)),h.update(t);const c=h.digest();h.clean(),M(c),E(s,c),_(a,s),h.reset(),h.update(a.subarray(0,32)),h.update(e.subarray(32)),h.update(t);const u=h.digest();M(u);for(let e=0;e<32;e++)r[e]=c[e];for(let e=0;e<32;e++)for(let t=0;t<32;t++)r[e+t]+=u[e]*o[t];return I(a.subarray(32),r),a}},9984:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSerializableHash=function(e){return void 0!==e.saveState&&void 0!==e.restoreState&&void 0!==e.cleanSavedState}},512:(e,t,r)=>{var i=r(5629),n=r(7309),s=function(){function e(e,t,r,n){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=i.hmac(this._hash,r,t);this._hmac=new i.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;r{Object.defineProperty(t,"__esModule",{value:!0});var i=r(9984),n=r(4153),s=r(7309),o=function(){function e(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var n=0;n{Object.defineProperty(t,"__esModule",{value:!0}),t.mul=Math.imul||function(e,t){var r=65535&e,i=65535&t;return r*i+((e>>>16&65535)*i+r*(t>>>16&65535)<<16>>>0)|0},t.add=function(e,t){return e+t|0},t.sub=function(e,t){return e-t|0},t.rotl=function(e,t){return e<>>32-t},t.rotr=function(e,t){return e<<32-t|e>>>t},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(e){return t.isInteger(e)&&e>=-t.MAX_SAFE_INTEGER&&e<=t.MAX_SAFE_INTEGER}},3027:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var i=r(4153),n=r(7309);t.DIGEST_LENGTH=16;var s=function(){function e(e){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=e[0]|e[1]<<8;this._r[0]=8191&r;var i=e[2]|e[3]<<8;this._r[1]=8191&(r>>>13|i<<3);var n=e[4]|e[5]<<8;this._r[2]=7939&(i>>>10|n<<6);var s=e[6]|e[7]<<8;this._r[3]=8191&(n>>>7|s<<9);var o=e[8]|e[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var h=e[12]|e[13]<<8;this._r[7]=8065&(a>>>11|h<<5);var c=e[14]|e[15]<<8;this._r[8]=8191&(h>>>8|c<<8),this._r[9]=c>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return e.prototype._blocks=function(e,t,r){for(var i=this._fin?0:2048,n=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],h=this._h[4],c=this._h[5],u=this._h[6],l=this._h[7],f=this._h[8],d=this._h[9],p=this._r[0],g=this._r[1],y=this._r[2],m=this._r[3],v=this._r[4],w=this._r[5],b=this._r[6],_=this._r[7],E=this._r[8],S=this._r[9];r>=16;){var I=e[t+0]|e[t+1]<<8;n+=8191&I;var M=e[t+2]|e[t+3]<<8;s+=8191&(I>>>13|M<<3);var A=e[t+4]|e[t+5]<<8;o+=8191&(M>>>10|A<<6);var O=e[t+6]|e[t+7]<<8;a+=8191&(A>>>7|O<<9);var x=e[t+8]|e[t+9]<<8;h+=8191&(O>>>4|x<<12),c+=x>>>1&8191;var P=e[t+10]|e[t+11]<<8;u+=8191&(x>>>14|P<<2);var N=e[t+12]|e[t+13]<<8;l+=8191&(P>>>11|N<<5);var R=e[t+14]|e[t+15]<<8,T=0,L=T;L+=n*p,L+=s*(5*S),L+=o*(5*E),L+=a*(5*_),T=(L+=h*(5*b))>>>13,L&=8191,L+=c*(5*w),L+=u*(5*v),L+=l*(5*m),L+=(f+=8191&(N>>>8|R<<8))*(5*y);var C=T+=(L+=(d+=R>>>5|i)*(5*g))>>>13;C+=n*g,C+=s*p,C+=o*(5*S),C+=a*(5*E),T=(C+=h*(5*_))>>>13,C&=8191,C+=c*(5*b),C+=u*(5*w),C+=l*(5*v),C+=f*(5*m),T+=(C+=d*(5*y))>>>13,C&=8191;var U=T;U+=n*y,U+=s*g,U+=o*p,U+=a*(5*S),T=(U+=h*(5*E))>>>13,U&=8191,U+=c*(5*_),U+=u*(5*b),U+=l*(5*w),U+=f*(5*v);var k=T+=(U+=d*(5*m))>>>13;k+=n*m,k+=s*y,k+=o*g,k+=a*p,T=(k+=h*(5*S))>>>13,k&=8191,k+=c*(5*E),k+=u*(5*_),k+=l*(5*b),k+=f*(5*w);var j=T+=(k+=d*(5*v))>>>13;j+=n*v,j+=s*m,j+=o*y,j+=a*g,T=(j+=h*p)>>>13,j&=8191,j+=c*(5*S),j+=u*(5*E),j+=l*(5*_),j+=f*(5*b);var q=T+=(j+=d*(5*w))>>>13;q+=n*w,q+=s*v,q+=o*m,q+=a*y,T=(q+=h*g)>>>13,q&=8191,q+=c*p,q+=u*(5*S),q+=l*(5*E),q+=f*(5*_);var D=T+=(q+=d*(5*b))>>>13;D+=n*b,D+=s*w,D+=o*v,D+=a*m,T=(D+=h*y)>>>13,D&=8191,D+=c*g,D+=u*p,D+=l*(5*S),D+=f*(5*E);var z=T+=(D+=d*(5*_))>>>13;z+=n*_,z+=s*b,z+=o*w,z+=a*v,T=(z+=h*m)>>>13,z&=8191,z+=c*y,z+=u*g,z+=l*p,z+=f*(5*S);var $=T+=(z+=d*(5*E))>>>13;$+=n*E,$+=s*_,$+=o*b,$+=a*w,T=($+=h*v)>>>13,$&=8191,$+=c*m,$+=u*y,$+=l*g,$+=f*p;var K=T+=($+=d*(5*S))>>>13;K+=n*S,K+=s*E,K+=o*_,K+=a*b,T=(K+=h*w)>>>13,K&=8191,K+=c*v,K+=u*m,K+=l*y,K+=f*g,n=L=8191&(T=(T=((T+=(K+=d*p)>>>13)<<2)+T|0)+(L&=8191)|0),s=C+=T>>>=13,o=U&=8191,a=k&=8191,h=j&=8191,c=q&=8191,u=D&=8191,l=z&=8191,f=$&=8191,d=K&=8191,t+=16,r-=16}this._h[0]=n,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=h,this._h[5]=c,this._h[6]=u,this._h[7]=l,this._h[8]=f,this._h[9]=d},e.prototype.finish=function(e,t){void 0===t&&(t=0);var r,i,n,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,i=(1^r)-1,s=0;s<10;s++)o[s]&=i;for(i=~i,s=0;s<10;s++)this._h[s]=this._h[s]&i|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),n=this._h[0]+this._pad[0],this._h[0]=65535&n,s=1;s<8;s++)n=(this._h[s]+this._pad[s]|0)+(n>>>16)|0,this._h[s]=65535&n;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},e.prototype.update=function(e){var t,r=0,i=e.length;if(this._leftover){(t=16-this._leftover)>i&&(t=i);for(var n=0;n=16&&(t=i-i%16,this._blocks(e,r,t),r+=t,i-=t),i){for(n=0;n{Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const i=r(6008),n=r(8099),s=r(7309);function o(e,r=t.defaultRandomSource){return r.randomBytes(e)}t.defaultRandomSource=new i.SystemRandomSource,t.randomBytes=o,t.randomUint32=function(e=t.defaultRandomSource){const r=o(4,e),i=(0,n.readUint32LE)(r);return(0,s.wipe)(r),i};const a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(e,r=a,i=t.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let n="";const h=r.length,c=256-256%h;for(;e>0;){const t=o(Math.ceil(256*e/c),i);for(let i=0;i0;i++){const s=t[i];s{Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserRandomSource=void 0,t.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&void 0!==e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.NodeRandomSource=void 0;const i=r(7309);t.NodeRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const e=r(5883);e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(e);for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemRandomSource=void 0;const i=r(5455),n=r(8871);t.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new i.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new n.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}},3294:(e,t,r)=>{var i=r(8099),n=r(7309);t.k=32,t.cn=64;var s=function(){function e(){this.digestLength=t.k,this.blockSize=t.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return e.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){n.wipe(this._buffer),n.wipe(this._temp),this.reset()},e.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=a(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},e.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,r=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[r]=128;for(var h=r+1;h0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},e.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(e){n.wipe(e.state),e.buffer&&n.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},e}();t.mE=s;var o=new Int32Array([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]);function a(e,t,r,n,s){for(;s>=64;){for(var a=t[0],h=t[1],c=t[2],u=t[3],l=t[4],f=t[5],d=t[6],p=t[7],g=0;g<16;g++){var y=n+4*g;e[g]=i.readUint32BE(r,y)}for(g=16;g<64;g++){var m=e[g-2],v=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,w=((m=e[g-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;e[g]=(v+e[g-7]|0)+(w+e[g-16]|0)}for(g=0;g<64;g++)v=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&d)|0)+(p+(o[g]+e[g]|0)|0)|0,w=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&h^a&c^h&c)|0,p=d,d=f,f=l,l=u+v|0,u=c,c=h,h=a,a=v+w|0;t[0]+=a,t[1]+=h,t[2]+=c,t[3]+=u,t[4]+=l,t[5]+=f,t[6]+=d,t[7]+=p,n+=64,s-=64}return n}t.vp=function(e){var t=new s;t.update(e);var r=t.digest();return t.clean(),r}},3350:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var i=r(8099),n=r(7309);t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var s=function(){function e(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return e.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){n.wipe(this._buffer),n.wipe(this._tempHi),n.wipe(this._tempLo),this.reset()},e.prototype.update=function(e,r){if(void 0===r&&(r=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],r--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(i=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[i++],r--;return this},e.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,r=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[r]=128;for(var h=r+1;h0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},e.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(e){n.wipe(e.stateHi),n.wipe(e.stateLo),e.buffer&&n.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},e}();t.SHA512=s;var o=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function a(e,t,r,n,s,a,h){for(var c,u,l,f,d,p,g,y,m=r[0],v=r[1],w=r[2],b=r[3],_=r[4],E=r[5],S=r[6],I=r[7],M=n[0],A=n[1],O=n[2],x=n[3],P=n[4],N=n[5],R=n[6],T=n[7];h>=128;){for(var L=0;L<16;L++){var C=8*L+a;e[L]=i.readUint32BE(s,C),t[L]=i.readUint32BE(s,C+4)}for(L=0;L<80;L++){var U,k,j=m,q=v,D=w,z=b,$=_,K=E,B=S,F=M,V=A,H=O,W=x,G=P,J=N,Y=R;if(d=65535&(u=T),p=u>>>16,g=65535&(c=I),y=c>>>16,d+=65535&(u=(P>>>14|_<<18)^(P>>>18|_<<14)^(_>>>9|P<<23)),p+=u>>>16,g+=65535&(c=(_>>>14|P<<18)^(_>>>18|P<<14)^(P>>>9|_<<23)),y+=c>>>16,d+=65535&(u=P&N^~P&R),p+=u>>>16,g+=65535&(c=_&E^~_&S),y+=c>>>16,c=o[2*L],d+=65535&(u=o[2*L+1]),p+=u>>>16,g+=65535&c,y+=c>>>16,c=e[L%16],p+=(u=t[L%16])>>>16,g+=65535&c,y+=c>>>16,g+=(p+=(d+=65535&u)>>>16)>>>16,d=65535&(u=f=65535&d|p<<16),p=u>>>16,g=65535&(c=l=65535&g|(y+=g>>>16)<<16),y=c>>>16,d+=65535&(u=(M>>>28|m<<4)^(m>>>2|M<<30)^(m>>>7|M<<25)),p+=u>>>16,g+=65535&(c=(m>>>28|M<<4)^(M>>>2|m<<30)^(M>>>7|m<<25)),y+=c>>>16,p+=(u=M&A^M&O^A&O)>>>16,g+=65535&(c=m&v^m&w^v&w),y+=c>>>16,U=65535&(g+=(p+=(d+=65535&u)>>>16)>>>16)|(y+=g>>>16)<<16,k=65535&d|p<<16,d=65535&(u=W),p=u>>>16,g=65535&(c=z),y=c>>>16,p+=(u=f)>>>16,g+=65535&(c=l),y+=c>>>16,v=j,w=q,b=D,_=z=65535&(g+=(p+=(d+=65535&u)>>>16)>>>16)|(y+=g>>>16)<<16,E=$,S=K,I=B,m=U,A=F,O=V,x=H,P=W=65535&d|p<<16,N=G,R=J,T=Y,M=k,L%16==15)for(C=0;C<16;C++)c=e[C],d=65535&(u=t[C]),p=u>>>16,g=65535&c,y=c>>>16,c=e[(C+9)%16],d+=65535&(u=t[(C+9)%16]),p+=u>>>16,g+=65535&c,y+=c>>>16,l=e[(C+1)%16],d+=65535&(u=((f=t[(C+1)%16])>>>1|l<<31)^(f>>>8|l<<24)^(f>>>7|l<<25)),p+=u>>>16,g+=65535&(c=(l>>>1|f<<31)^(l>>>8|f<<24)^l>>>7),y+=c>>>16,l=e[(C+14)%16],p+=(u=((f=t[(C+14)%16])>>>19|l<<13)^(l>>>29|f<<3)^(f>>>6|l<<26))>>>16,g+=65535&(c=(l>>>19|f<<13)^(f>>>29|l<<3)^l>>>6),y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,e[C]=65535&g|y<<16,t[C]=65535&d|p<<16}d=65535&(u=M),p=u>>>16,g=65535&(c=m),y=c>>>16,c=r[0],p+=(u=n[0])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[0]=m=65535&g|y<<16,n[0]=M=65535&d|p<<16,d=65535&(u=A),p=u>>>16,g=65535&(c=v),y=c>>>16,c=r[1],p+=(u=n[1])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[1]=v=65535&g|y<<16,n[1]=A=65535&d|p<<16,d=65535&(u=O),p=u>>>16,g=65535&(c=w),y=c>>>16,c=r[2],p+=(u=n[2])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[2]=w=65535&g|y<<16,n[2]=O=65535&d|p<<16,d=65535&(u=x),p=u>>>16,g=65535&(c=b),y=c>>>16,c=r[3],p+=(u=n[3])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[3]=b=65535&g|y<<16,n[3]=x=65535&d|p<<16,d=65535&(u=P),p=u>>>16,g=65535&(c=_),y=c>>>16,c=r[4],p+=(u=n[4])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[4]=_=65535&g|y<<16,n[4]=P=65535&d|p<<16,d=65535&(u=N),p=u>>>16,g=65535&(c=E),y=c>>>16,c=r[5],p+=(u=n[5])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[5]=E=65535&g|y<<16,n[5]=N=65535&d|p<<16,d=65535&(u=R),p=u>>>16,g=65535&(c=S),y=c>>>16,c=r[6],p+=(u=n[6])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[6]=S=65535&g|y<<16,n[6]=R=65535&d|p<<16,d=65535&(u=T),p=u>>>16,g=65535&(c=I),y=c>>>16,c=r[7],p+=(u=n[7])>>>16,g+=65535&c,y+=c>>>16,y+=(g+=(p+=(d+=65535&u)>>>16)>>>16)>>>16,r[7]=I=65535&g|y<<16,n[7]=T=65535&d|p<<16,a+=128,h-=128}return a}t.hash=function(e){var t=new s;t.update(e);var r=t.digest();return t.clean(),r}},7309:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wipe=function(e){for(var t=0;t{t.gi=t.Au=t.KS=t.kz=void 0;const i=r(1416),n=r(7309);function s(e){const t=new Float64Array(16);if(e)for(let r=0;r=0;--e){const t=r[e>>>3]>>>(7&e)&1;c(n,o,t),c(p,g,t),u(y,n,p),l(n,n,p),u(p,o,g),l(o,o,g),d(g,y),d(m,n),f(n,p,n),f(p,o,y),u(y,n,p),l(n,n,p),d(o,n),l(p,g,m),f(n,p,a),u(n,n,g),f(p,p,n),f(n,g,m),f(g,o,i),d(o,y),c(n,o,t),c(p,g,t)}for(let e=0;e<16;e++)i[e+16]=n[e],i[e+32]=p[e],i[e+48]=o[e],i[e+64]=g[e];const v=i.subarray(32),w=i.subarray(16);!function(e,t){const r=s();for(let e=0;e<16;e++)r[e]=t[e];for(let e=253;e>=0;e--)d(r,r),2!==e&&4!==e&&f(r,r,t);for(let t=0;t<16;t++)e[t]=r[t]}(v,v),f(w,w,v);const b=new Uint8Array(32);return function(e,t){const r=s(),i=s();for(let e=0;e<16;e++)i[e]=t[e];h(i),h(i),h(i);for(let e=0;e<2;e++){r[0]=i[0]-65517;for(let e=1;e<15;e++)r[e]=i[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,c(i,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&i[t],e[2*t+1]=i[t]>>8}(b,w),b}t.Au=function(e){const r=(0,i.randomBytes)(32,e),s=function(e){if(e.length!==t.KS)throw new Error(`x25519: seed must be ${t.KS} bytes`);const r=new Uint8Array(e);return{publicKey:(i=r,p(i,o)),secretKey:r};var i}(r);return(0,n.wipe)(r),s},t.gi=function(e,r,i=!1){if(e.length!==t.kz)throw new Error("X25519: incorrect secret key length");if(r.length!==t.kz)throw new Error("X25519: incorrect public key length");const n=p(e,r);if(i){let e=0;for(let t=0;t{function i(){return(null===r.g||void 0===r.g?void 0:r.g.crypto)||(null===r.g||void 0===r.g?void 0:r.g.msCrypto)||{}}function n(){const e=i();return e.subtle||e.webkitSubtle}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowserCryptoAvailable=t.getSubtleCrypto=t.getBrowerCrypto=void 0,t.getBrowerCrypto=i,t.getSubtleCrypto=n,t.isBrowserCryptoAvailable=function(){return!!i()&&!!n()}},8618:(e,t)=>{function r(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function i(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=t.isNode=t.isReactNative=void 0,t.isReactNative=r,t.isNode=i,t.isBrowser=function(){return!r()&&!i()}},1468:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(655);i.__exportStar(r(926),t),i.__exportStar(r(8618),t)},8200:(e,t,r)=>{r.d(t,{q:()=>i});class i{}},997:(e,t,r)=>{r.r(t),r.d(t,{IEvents:()=>i.q});var i=r(8200)},2568:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HEARTBEAT_EVENTS=t.HEARTBEAT_INTERVAL=void 0;const i=r(6736);t.HEARTBEAT_INTERVAL=i.FIVE_SECONDS,t.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"}},3401:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),r(655).__exportStar(r(2568),t)},8969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HeartBeat=void 0;const i=r(655),n=r(7187),s=r(6736),o=r(1614),a=r(3401);class h extends o.IHeartBeat{constructor(e){super(e),this.events=new n.EventEmitter,this.interval=a.HEARTBEAT_INTERVAL,this.interval=(null==e?void 0:e.interval)||a.HEARTBEAT_INTERVAL}static init(e){return i.__awaiter(this,void 0,void 0,(function*(){const t=new h(e);return yield t.init(),t}))}init(){return i.__awaiter(this,void 0,void 0,(function*(){yield 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)}initialize(){return i.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),s.toMiliseconds(this.interval))}))}pulse(){this.events.emit(a.HEARTBEAT_EVENTS.pulse)}}t.HeartBeat=h},159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(655);i.__exportStar(r(8969),t),i.__exportStar(r(1614),t),i.__exportStar(r(3401),t)},4174:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IHeartBeat=void 0;const i=r(997);class n extends i.IEvents{constructor(e){super()}}t.IHeartBeat=n},1614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),r(655).__exportStar(r(4174),t)},5727:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PINO_CUSTOM_CONTEXT_KEY=t.PINO_LOGGER_DEFAULTS=void 0,t.PINO_LOGGER_DEFAULTS={level:"info"},t.PINO_CUSTOM_CONTEXT_KEY="custom_context"},9107:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pino=void 0;const i=r(655),n=i.__importDefault(r(6559));Object.defineProperty(t,"pino",{enumerable:!0,get:function(){return n.default}}),i.__exportStar(r(5727),t),i.__exportStar(r(8048),t)},8048:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.generateChildLogger=t.formatChildLoggerContext=t.getLoggerContext=t.setBrowserLoggerContext=t.getBrowserLoggerContext=t.getDefaultLoggerOptions=void 0;const i=r(5727);function n(e,t=i.PINO_CUSTOM_CONTEXT_KEY){return e[t]||""}function s(e,t,r=i.PINO_CUSTOM_CONTEXT_KEY){return e[r]=t,e}function o(e,t=i.PINO_CUSTOM_CONTEXT_KEY){let r="";return r=void 0===e.bindings?n(e,t):e.bindings().context||"",r}function a(e,t,r=i.PINO_CUSTOM_CONTEXT_KEY){const n=o(e,r);return n.trim()?`${n}/${t}`:t}t.getDefaultLoggerOptions=function(e){return Object.assign(Object.assign({},e),{level:(null==e?void 0:e.level)||i.PINO_LOGGER_DEFAULTS.level})},t.getBrowserLoggerContext=n,t.setBrowserLoggerContext=s,t.getLoggerContext=o,t.formatChildLoggerContext=a,t.generateChildLogger=function(e,t,r=i.PINO_CUSTOM_CONTEXT_KEY){const n=a(e,t,r);return s(e.child({context:n}),n,r)}},1882:()=>{},3014:()=>{},6900:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(655);i.__exportStar(r(6869),t),i.__exportStar(r(8033),t)},6869:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_THOUSAND=t.ONE_HUNDRED=void 0,t.ONE_HUNDRED=100,t.ONE_THOUSAND=1e3},8033:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=5*t.ONE_MINUTE,t.TEN_MINUTES=10*t.ONE_MINUTE,t.THIRTY_MINUTES=30*t.ONE_MINUTE,t.SIXTY_MINUTES=60*t.ONE_MINUTE,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=3*t.ONE_HOUR,t.SIX_HOURS=6*t.ONE_HOUR,t.TWELVE_HOURS=12*t.ONE_HOUR,t.TWENTY_FOUR_HOURS=24*t.ONE_HOUR,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=3*t.ONE_DAY,t.FIVE_DAYS=5*t.ONE_DAY,t.SEVEN_DAYS=7*t.ONE_DAY,t.THIRTY_DAYS=30*t.ONE_DAY,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=2*t.ONE_WEEK,t.THREE_WEEKS=3*t.ONE_WEEK,t.FOUR_WEEKS=4*t.ONE_WEEK,t.ONE_YEAR=365*t.ONE_DAY},6736:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(655);i.__exportStar(r(4273),t),i.__exportStar(r(7001),t),i.__exportStar(r(2939),t),i.__exportStar(r(6900),t)},2939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),r(655).__exportStar(r(8766),t)},8766:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IWatch=void 0,t.IWatch=class{}},3207:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fromMiliseconds=t.toMiliseconds=void 0;const i=r(6900);t.toMiliseconds=function(e){return e*i.ONE_THOUSAND},t.fromMiliseconds=function(e){return Math.floor(e/i.ONE_THOUSAND)}},3873:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delay=void 0,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t(!0)}),e)}))}},4273:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=r(655);i.__exportStar(r(3873),t),i.__exportStar(r(3207),t)},7001:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const t=this.get(e);if(void 0!==t.elapsed)throw new Error(`Watch already stopped for label: ${e}`);const r=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:r})}get(e){const t=this.timestamps.get(e);if(void 0===t)throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){const t=this.get(e);return t.elapsed||Date.now()-t.started}}t.Watch=r,t.default=r},2873:(e,t)=>{function r(e){let t;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function i(e){const t=r(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalStorage=t.getLocalStorageOrThrow=t.getCrypto=t.getCryptoOrThrow=t.getLocation=t.getLocationOrThrow=t.getNavigator=t.getNavigatorOrThrow=t.getDocument=t.getDocumentOrThrow=t.getFromWindowOrThrow=t.getFromWindow=void 0,t.getFromWindow=r,t.getFromWindowOrThrow=i,t.getDocumentOrThrow=function(){return i("document")},t.getDocument=function(){return r("document")},t.getNavigatorOrThrow=function(){return i("navigator")},t.getNavigator=function(){return r("navigator")},t.getLocationOrThrow=function(){return i("location")},t.getLocation=function(){return r("location")},t.getCryptoOrThrow=function(){return i("crypto")},t.getCrypto=function(){return r("crypto")},t.getLocalStorageOrThrow=function(){return i("localStorage")},t.getLocalStorage=function(){return r("localStorage")}},5755:(e,t,r)=>{t.D=void 0;const i=r(2873);t.D=function(){let e,t;try{e=i.getDocumentOrThrow(),t=i.getLocationOrThrow()}catch(e){return null}function r(...t){const r=e.getElementsByTagName("meta");for(let e=0;ei.getAttribute(e))).filter((e=>!!e&&t.includes(e)));if(n.length&&n){const e=i.getAttribute("content");if(e)return e}}return""}const n=function(){let t=r("name","og:site_name","og:title","twitter:title");return t||(t=e.title),t}();return{description:r("description","og:description","twitter:description","keywords"),url:t.origin,icons:function(){const r=e.getElementsByTagName("link"),i=[];for(let e=0;e-1){const e=n.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let r=t.protocol+"//"+t.host;if(0===e.indexOf("/"))r+=e;else{const i=t.pathname.split("/");i.pop(),r+=i.join("/")+"/"+e}i.push(r)}else if(0===e.indexOf("//")){const r=t.protocol+e;i.push(r)}else i.push(e)}}return i}(),name:n}}},3550:function(e,t,r){!function(e,t){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function s(e,t,r){if(s.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(6601).Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+e)}function h(e,t,r){var i=a(e,r);return r-1>=t&&(i|=a(e,r-1)<<4),i}function c(e,t,r,n){for(var s=0,o=0,a=Math.min(e.length,r),h=t;h=49?c-49+10:c>=17?c-17+10:c,i(c>=0&&o0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n=0;n-=3)o=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i=t;i-=2)n=h(e,t,i)<=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(e.length-t)%2==0?t+1:t;i=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},s.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var s=e.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(e){s.prototype.inspect=l}else s.prototype.inspect=l;function l(){return(this.red?""}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function g(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],s=0|t.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var c=1;c>>26,l=67108863&h,f=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=f;d++){var p=c-d|0;u+=(o=(n=0|e.words[p])*(s=0|t.words[d])+l)/67108864|0,l=67108863&o}r.words[c]=0|l,h=0|u}return 0!==h?r.words[c]=0|h:r.length--,r._strip()}s.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,s=0,o=0;o>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=d[e],u=p[e];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var g=l.modrn(u).toString(e);r=(l=l.idivn(u)).isZero()?g+r:f[c-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0");var o=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,s);return this["_toArrayLike"+("le"===t?"LE":"BE")](o,n),o},s.prototype._toArrayLikeLE=function(e,t){for(var r=0,i=0,n=0,s=0;n>8&255),r>16&255),6===s?(r>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r=0&&(e[r--]=o>>8&255),r>=0&&(e[r--]=o>>16&255),6===s?(r>=0&&(e[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(e[r--]=i;r>=0;)e[r--]=0},Math.clz32?s.prototype._countBits=function(e){return 32-Math.clz32(e)}:s.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,i=e):(r=e,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,y=0|o[2],m=8191&y,v=y>>>13,w=0|o[3],b=8191&w,_=w>>>13,E=0|o[4],S=8191&E,I=E>>>13,M=0|o[5],A=8191&M,O=M>>>13,x=0|o[6],P=8191&x,N=x>>>13,R=0|o[7],T=8191&R,L=R>>>13,C=0|o[8],U=8191&C,k=C>>>13,j=0|o[9],q=8191&j,D=j>>>13,z=0|a[0],$=8191&z,K=z>>>13,B=0|a[1],F=8191&B,V=B>>>13,H=0|a[2],W=8191&H,G=H>>>13,J=0|a[3],Y=8191&J,X=J>>>13,Q=0|a[4],Z=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ie=te>>>13,ne=0|a[6],se=8191&ne,oe=ne>>>13,ae=0|a[7],he=8191&ae,ce=ae>>>13,ue=0|a[8],le=8191&ue,fe=ue>>>13,de=0|a[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(i=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,K))+Math.imul(f,$)|0))<<13)|0;c=((s=Math.imul(f,K))+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(p,$),n=(n=Math.imul(p,K))+Math.imul(g,$)|0,s=Math.imul(g,K);var me=(c+(i=i+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(f,F)|0))<<13)|0;c=((s=s+Math.imul(f,V)|0)+(n>>>13)|0)+(me>>>26)|0,me&=67108863,i=Math.imul(m,$),n=(n=Math.imul(m,K))+Math.imul(v,$)|0,s=Math.imul(v,K),i=i+Math.imul(p,F)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(g,F)|0,s=s+Math.imul(g,V)|0;var ve=(c+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,G)|0)+Math.imul(f,W)|0))<<13)|0;c=((s=s+Math.imul(f,G)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(b,$),n=(n=Math.imul(b,K))+Math.imul(_,$)|0,s=Math.imul(_,K),i=i+Math.imul(m,F)|0,n=(n=n+Math.imul(m,V)|0)+Math.imul(v,F)|0,s=s+Math.imul(v,V)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(g,W)|0,s=s+Math.imul(g,G)|0;var we=(c+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(f,Y)|0))<<13)|0;c=((s=s+Math.imul(f,X)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(S,$),n=(n=Math.imul(S,K))+Math.imul(I,$)|0,s=Math.imul(I,K),i=i+Math.imul(b,F)|0,n=(n=n+Math.imul(b,V)|0)+Math.imul(_,F)|0,s=s+Math.imul(_,V)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,G)|0)+Math.imul(v,W)|0,s=s+Math.imul(v,G)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,X)|0;var be=(c+(i=i+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,ee)|0)+Math.imul(f,Z)|0))<<13)|0;c=((s=s+Math.imul(f,ee)|0)+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(A,$),n=(n=Math.imul(A,K))+Math.imul(O,$)|0,s=Math.imul(O,K),i=i+Math.imul(S,F)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(I,F)|0,s=s+Math.imul(I,V)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,G)|0,i=i+Math.imul(m,Y)|0,n=(n=n+Math.imul(m,X)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(g,Z)|0,s=s+Math.imul(g,ee)|0;var _e=(c+(i=i+Math.imul(l,re)|0)|0)+((8191&(n=(n=n+Math.imul(l,ie)|0)+Math.imul(f,re)|0))<<13)|0;c=((s=s+Math.imul(f,ie)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(P,$),n=(n=Math.imul(P,K))+Math.imul(N,$)|0,s=Math.imul(N,K),i=i+Math.imul(A,F)|0,n=(n=n+Math.imul(A,V)|0)+Math.imul(O,F)|0,s=s+Math.imul(O,V)|0,i=i+Math.imul(S,W)|0,n=(n=n+Math.imul(S,G)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,G)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,X)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,ee)|0)+Math.imul(v,Z)|0,s=s+Math.imul(v,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(g,re)|0,s=s+Math.imul(g,ie)|0;var Ee=(c+(i=i+Math.imul(l,se)|0)|0)+((8191&(n=(n=n+Math.imul(l,oe)|0)+Math.imul(f,se)|0))<<13)|0;c=((s=s+Math.imul(f,oe)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(T,$),n=(n=Math.imul(T,K))+Math.imul(L,$)|0,s=Math.imul(L,K),i=i+Math.imul(P,F)|0,n=(n=n+Math.imul(P,V)|0)+Math.imul(N,F)|0,s=s+Math.imul(N,V)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,G)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,ee)|0)+Math.imul(_,Z)|0,s=s+Math.imul(_,ee)|0,i=i+Math.imul(m,re)|0,n=(n=n+Math.imul(m,ie)|0)+Math.imul(v,re)|0,s=s+Math.imul(v,ie)|0,i=i+Math.imul(p,se)|0,n=(n=n+Math.imul(p,oe)|0)+Math.imul(g,se)|0,s=s+Math.imul(g,oe)|0;var Se=(c+(i=i+Math.imul(l,he)|0)|0)+((8191&(n=(n=n+Math.imul(l,ce)|0)+Math.imul(f,he)|0))<<13)|0;c=((s=s+Math.imul(f,ce)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(U,$),n=(n=Math.imul(U,K))+Math.imul(k,$)|0,s=Math.imul(k,K),i=i+Math.imul(T,F)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(L,F)|0,s=s+Math.imul(L,V)|0,i=i+Math.imul(P,W)|0,n=(n=n+Math.imul(P,G)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,G)|0,i=i+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,X)|0,i=i+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,ee)|0)+Math.imul(I,Z)|0,s=s+Math.imul(I,ee)|0,i=i+Math.imul(b,re)|0,n=(n=n+Math.imul(b,ie)|0)+Math.imul(_,re)|0,s=s+Math.imul(_,ie)|0,i=i+Math.imul(m,se)|0,n=(n=n+Math.imul(m,oe)|0)+Math.imul(v,se)|0,s=s+Math.imul(v,oe)|0,i=i+Math.imul(p,he)|0,n=(n=n+Math.imul(p,ce)|0)+Math.imul(g,he)|0,s=s+Math.imul(g,ce)|0;var Ie=(c+(i=i+Math.imul(l,le)|0)|0)+((8191&(n=(n=n+Math.imul(l,fe)|0)+Math.imul(f,le)|0))<<13)|0;c=((s=s+Math.imul(f,fe)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(q,$),n=(n=Math.imul(q,K))+Math.imul(D,$)|0,s=Math.imul(D,K),i=i+Math.imul(U,F)|0,n=(n=n+Math.imul(U,V)|0)+Math.imul(k,F)|0,s=s+Math.imul(k,V)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(L,W)|0,s=s+Math.imul(L,G)|0,i=i+Math.imul(P,Y)|0,n=(n=n+Math.imul(P,X)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(A,Z)|0,n=(n=n+Math.imul(A,ee)|0)+Math.imul(O,Z)|0,s=s+Math.imul(O,ee)|0,i=i+Math.imul(S,re)|0,n=(n=n+Math.imul(S,ie)|0)+Math.imul(I,re)|0,s=s+Math.imul(I,ie)|0,i=i+Math.imul(b,se)|0,n=(n=n+Math.imul(b,oe)|0)+Math.imul(_,se)|0,s=s+Math.imul(_,oe)|0,i=i+Math.imul(m,he)|0,n=(n=n+Math.imul(m,ce)|0)+Math.imul(v,he)|0,s=s+Math.imul(v,ce)|0,i=i+Math.imul(p,le)|0,n=(n=n+Math.imul(p,fe)|0)+Math.imul(g,le)|0,s=s+Math.imul(g,fe)|0;var Me=(c+(i=i+Math.imul(l,pe)|0)|0)+((8191&(n=(n=n+Math.imul(l,ge)|0)+Math.imul(f,pe)|0))<<13)|0;c=((s=s+Math.imul(f,ge)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(q,F),n=(n=Math.imul(q,V))+Math.imul(D,F)|0,s=Math.imul(D,V),i=i+Math.imul(U,W)|0,n=(n=n+Math.imul(U,G)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,G)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(L,Y)|0,s=s+Math.imul(L,X)|0,i=i+Math.imul(P,Z)|0,n=(n=n+Math.imul(P,ee)|0)+Math.imul(N,Z)|0,s=s+Math.imul(N,ee)|0,i=i+Math.imul(A,re)|0,n=(n=n+Math.imul(A,ie)|0)+Math.imul(O,re)|0,s=s+Math.imul(O,ie)|0,i=i+Math.imul(S,se)|0,n=(n=n+Math.imul(S,oe)|0)+Math.imul(I,se)|0,s=s+Math.imul(I,oe)|0,i=i+Math.imul(b,he)|0,n=(n=n+Math.imul(b,ce)|0)+Math.imul(_,he)|0,s=s+Math.imul(_,ce)|0,i=i+Math.imul(m,le)|0,n=(n=n+Math.imul(m,fe)|0)+Math.imul(v,le)|0,s=s+Math.imul(v,fe)|0;var Ae=(c+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;c=((s=s+Math.imul(g,ge)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(q,W),n=(n=Math.imul(q,G))+Math.imul(D,W)|0,s=Math.imul(D,G),i=i+Math.imul(U,Y)|0,n=(n=n+Math.imul(U,X)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,X)|0,i=i+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,ee)|0)+Math.imul(L,Z)|0,s=s+Math.imul(L,ee)|0,i=i+Math.imul(P,re)|0,n=(n=n+Math.imul(P,ie)|0)+Math.imul(N,re)|0,s=s+Math.imul(N,ie)|0,i=i+Math.imul(A,se)|0,n=(n=n+Math.imul(A,oe)|0)+Math.imul(O,se)|0,s=s+Math.imul(O,oe)|0,i=i+Math.imul(S,he)|0,n=(n=n+Math.imul(S,ce)|0)+Math.imul(I,he)|0,s=s+Math.imul(I,ce)|0,i=i+Math.imul(b,le)|0,n=(n=n+Math.imul(b,fe)|0)+Math.imul(_,le)|0,s=s+Math.imul(_,fe)|0;var Oe=(c+(i=i+Math.imul(m,pe)|0)|0)+((8191&(n=(n=n+Math.imul(m,ge)|0)+Math.imul(v,pe)|0))<<13)|0;c=((s=s+Math.imul(v,ge)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,i=Math.imul(q,Y),n=(n=Math.imul(q,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),i=i+Math.imul(U,Z)|0,n=(n=n+Math.imul(U,ee)|0)+Math.imul(k,Z)|0,s=s+Math.imul(k,ee)|0,i=i+Math.imul(T,re)|0,n=(n=n+Math.imul(T,ie)|0)+Math.imul(L,re)|0,s=s+Math.imul(L,ie)|0,i=i+Math.imul(P,se)|0,n=(n=n+Math.imul(P,oe)|0)+Math.imul(N,se)|0,s=s+Math.imul(N,oe)|0,i=i+Math.imul(A,he)|0,n=(n=n+Math.imul(A,ce)|0)+Math.imul(O,he)|0,s=s+Math.imul(O,ce)|0,i=i+Math.imul(S,le)|0,n=(n=n+Math.imul(S,fe)|0)+Math.imul(I,le)|0,s=s+Math.imul(I,fe)|0;var xe=(c+(i=i+Math.imul(b,pe)|0)|0)+((8191&(n=(n=n+Math.imul(b,ge)|0)+Math.imul(_,pe)|0))<<13)|0;c=((s=s+Math.imul(_,ge)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(q,Z),n=(n=Math.imul(q,ee))+Math.imul(D,Z)|0,s=Math.imul(D,ee),i=i+Math.imul(U,re)|0,n=(n=n+Math.imul(U,ie)|0)+Math.imul(k,re)|0,s=s+Math.imul(k,ie)|0,i=i+Math.imul(T,se)|0,n=(n=n+Math.imul(T,oe)|0)+Math.imul(L,se)|0,s=s+Math.imul(L,oe)|0,i=i+Math.imul(P,he)|0,n=(n=n+Math.imul(P,ce)|0)+Math.imul(N,he)|0,s=s+Math.imul(N,ce)|0,i=i+Math.imul(A,le)|0,n=(n=n+Math.imul(A,fe)|0)+Math.imul(O,le)|0,s=s+Math.imul(O,fe)|0;var Pe=(c+(i=i+Math.imul(S,pe)|0)|0)+((8191&(n=(n=n+Math.imul(S,ge)|0)+Math.imul(I,pe)|0))<<13)|0;c=((s=s+Math.imul(I,ge)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(q,re),n=(n=Math.imul(q,ie))+Math.imul(D,re)|0,s=Math.imul(D,ie),i=i+Math.imul(U,se)|0,n=(n=n+Math.imul(U,oe)|0)+Math.imul(k,se)|0,s=s+Math.imul(k,oe)|0,i=i+Math.imul(T,he)|0,n=(n=n+Math.imul(T,ce)|0)+Math.imul(L,he)|0,s=s+Math.imul(L,ce)|0,i=i+Math.imul(P,le)|0,n=(n=n+Math.imul(P,fe)|0)+Math.imul(N,le)|0,s=s+Math.imul(N,fe)|0;var Ne=(c+(i=i+Math.imul(A,pe)|0)|0)+((8191&(n=(n=n+Math.imul(A,ge)|0)+Math.imul(O,pe)|0))<<13)|0;c=((s=s+Math.imul(O,ge)|0)+(n>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,i=Math.imul(q,se),n=(n=Math.imul(q,oe))+Math.imul(D,se)|0,s=Math.imul(D,oe),i=i+Math.imul(U,he)|0,n=(n=n+Math.imul(U,ce)|0)+Math.imul(k,he)|0,s=s+Math.imul(k,ce)|0,i=i+Math.imul(T,le)|0,n=(n=n+Math.imul(T,fe)|0)+Math.imul(L,le)|0,s=s+Math.imul(L,fe)|0;var Re=(c+(i=i+Math.imul(P,pe)|0)|0)+((8191&(n=(n=n+Math.imul(P,ge)|0)+Math.imul(N,pe)|0))<<13)|0;c=((s=s+Math.imul(N,ge)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(q,he),n=(n=Math.imul(q,ce))+Math.imul(D,he)|0,s=Math.imul(D,ce),i=i+Math.imul(U,le)|0,n=(n=n+Math.imul(U,fe)|0)+Math.imul(k,le)|0,s=s+Math.imul(k,fe)|0;var Te=(c+(i=i+Math.imul(T,pe)|0)|0)+((8191&(n=(n=n+Math.imul(T,ge)|0)+Math.imul(L,pe)|0))<<13)|0;c=((s=s+Math.imul(L,ge)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(q,le),n=(n=Math.imul(q,fe))+Math.imul(D,le)|0,s=Math.imul(D,fe);var Le=(c+(i=i+Math.imul(U,pe)|0)|0)+((8191&(n=(n=n+Math.imul(U,ge)|0)+Math.imul(k,pe)|0))<<13)|0;c=((s=s+Math.imul(k,ge)|0)+(n>>>13)|0)+(Le>>>26)|0,Le&=67108863;var Ce=(c+(i=Math.imul(q,pe))|0)+((8191&(n=(n=Math.imul(q,ge))+Math.imul(D,pe)|0))<<13)|0;return c=((s=Math.imul(D,ge))+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,h[0]=ye,h[1]=me,h[2]=ve,h[3]=we,h[4]=be,h[5]=_e,h[6]=Ee,h[7]=Se,h[8]=Ie,h[9]=Me,h[10]=Ae,h[11]=Oe,h[12]=xe,h[13]=Pe,h[14]=Ne,h[15]=Re,h[16]=Te,h[17]=Le,h[18]=Ce,0!==c&&(h[19]=c,r.length++),r};function m(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function v(e,t,r){return m(e,t,r)}function w(e,t){this.x=e,this.y=t}Math.imul||(y=g),s.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?y(this,e,t):r<63?g(this,e,t):r<1024?m(this,e,t):v(this,e,t)},w.prototype.makeRBT=function(e){for(var t=new Array(e),r=s.prototype._countBits(e)-1,i=0;i>=1;return i},w.prototype.permute=function(e,t,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),t?this.ineg():this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>n&1}return t}(e);if(0===t.length)return new s(1);for(var r=this,i=0;i=0);var t,r=e%26,n=(e-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t=0),n=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,c=0;c=0&&(0!==u||c>=n);c--){var l=0|this.words[c];this.words[c]=u<<26-s|l>>>s,u=l&a}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==t){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var c=0;c=0;l--){var f=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(n,f,l);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=f)}return a&&a._strip(),i._strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(n=a.div.neg()),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:n,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modrn(e.words[0]))}:this._wordDiv(e,t);var n,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modrn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var r=(1<<26)%e,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%e;return t?-n:n},s.prototype.modn=function(e){return this.modrn(e)},s.prototype.idivn=function(e){var t=e<0;t&&(e=-e),i(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/e|0,r=s%e}return this._strip(),t?this.ineg():this},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var u=r.clone(),l=t.clone();!t.isZero();){for(var f=0,d=1;0==(t.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(u),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(u),h.isub(l)),a.iushrn(1),h.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(a),o.isub(h)):(r.isub(t),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(c)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,u=1;0==(t.words[0]&u)&&c<26;++c,u<<=1);if(c>0)for(t.iushrn(c);c-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,f=1;0==(r.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(a)):(r.isub(t),a.isub(o))}return(n=0===t.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(e),n},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var s=t;t=r,r=s}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){in&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new A(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function _(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function E(){_.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){_.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){_.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){_.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}_.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},_.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},_.prototype.split=function(e,t){e.iushrn(this.n,0,t)},_.prototype.imulK=function(e){return e.imul(this.k)},n(E,_),E.prototype.split=function(e,t){for(var r=4194303,i=Math.min(e.length,9),n=0;n>>22,s=o}s>>>=22,e.words[n-10]=s,0===s&&e.length>10?e.length-=10:e.length-=9},E.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new E;else if("p224"===e)t=new S;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new M}return b[e]=t,t},A.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new s(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),c=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new s(2*u*u).toRed(this);0!==this.pow(u,c).cmp(h);)u.redIAdd(h);for(var l=this.pow(u,n),f=this.pow(e,n.addn(1).iushrn(1)),d=this.pow(e,n),p=o;0!==d.cmp(a);){for(var g=d,y=0;0!==g.cmp(a);y++)g=g.redSqr();i(y=0;i--){for(var c=t.words[i],u=h-1;u>=0;u--){var l=c>>u&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===i&&0===u)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new O(e)},n(O,A),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=r.nmd(e),this)},4020:e=>{var t="%[a-f0-9]{2}",r=new RegExp("("+t+")|([^%]+?)","gi"),i=new RegExp("("+t+")+","gi");function n(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),i=e.slice(t);return Array.prototype.concat.call([],n(r),n(i))}function s(e){try{return decodeURIComponent(e)}catch(s){for(var t=e.match(r)||[],i=1;i{var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}g(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,{once:!0})}(e,n)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function c(e,t,r,i){var n,s,o,c;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=h(e))>0&&o.length>n&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,c=u,console&&console.warn&&console.warn(c)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=u.bind(i);return n.listener=r,i.wrapFn=n,n}function f(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)i(h,this,t);else{var c=h.length,u=p(h,c);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},2806:e=>{e.exports=function(e,t){for(var r={},i=Object.keys(e),n=Array.isArray(t),s=0;s{var i=t;i.utils=r(6436),i.common=r(5772),i.sha=r(9041),i.ripemd=r(2949),i.hmac=r(2344),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},5772:(e,t,r)=>{var i=r(6436),n=r(9746);function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=s,s.prototype.update=function(e,t){if(e=i.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=i.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s{var i=r(6436),n=r(9746);function s(e,t,r){if(!(this instanceof s))return new s(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(t,r))}e.exports=s,s.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),n(e.length<=this.blockSize);for(var t=e.length;t{var i=r(6436),n=r(5772),s=i.rotl32,o=i.sum32,a=i.sum32_3,h=i.sum32_4,c=n.BlockHash;function u(){if(!(this instanceof u))return new u;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(e,t,r,i){return e<=15?t^r^i:e<=31?t&r|~t&i:e<=47?(t|~r)^i:e<=63?t&i|r&~i:t^(r|~i)}function f(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function d(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}i.inherits(u,c),t.ripemd160=u,u.blockSize=512,u.outSize=160,u.hmacStrength=192,u.padLength=64,u.prototype._update=function(e,t){for(var r=this.h[0],i=this.h[1],n=this.h[2],c=this.h[3],u=this.h[4],v=r,w=i,b=n,_=c,E=u,S=0;S<80;S++){var I=o(s(h(r,l(S,i,n,c),e[p[S]+t],f(S)),y[S]),u);r=u,u=c,c=s(n,10),n=i,i=I,I=o(s(h(v,l(79-S,w,b,_),e[g[S]+t],d(S)),m[S]),E),v=E,E=_,_=s(b,10),b=w,w=I}I=a(this.h[1],n,_),this.h[1]=a(this.h[2],c,E),this.h[2]=a(this.h[3],u,v),this.h[3]=a(this.h[4],r,w),this.h[4]=a(this.h[0],i,b),this.h[0]=I},u.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],g=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],m=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},9041:(e,t,r)=>{t.sha1=r(4761),t.sha224=r(799),t.sha256=r(9344),t.sha384=r(772),t.sha512=r(5900)},4761:(e,t,r)=>{var i=r(6436),n=r(5772),s=r(7038),o=i.rotl32,a=i.sum32,h=i.sum32_5,c=s.ft_1,u=n.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(f,u),e.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;i{var i=r(6436),n=r(9344);function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(s,n),e.exports=s,s.blockSize=512,s.outSize=224,s.hmacStrength=192,s.padLength=64,s.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},9344:(e,t,r)=>{var i=r(6436),n=r(5772),s=r(7038),o=r(9746),a=i.sum32,h=i.sum32_4,c=i.sum32_5,u=s.ch32,l=s.maj32,f=s.s0_256,d=s.s1_256,p=s.g0_256,g=s.g1_256,y=n.BlockHash,m=[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];function v(){if(!(this instanceof v))return new v;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}i.inherits(v,y),e.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;i{var i=r(6436),n=r(5900);function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(s,n),e.exports=s,s.blockSize=1024,s.outSize=384,s.hmacStrength=192,s.padLength=128,s.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},5900:(e,t,r)=>{var i=r(6436),n=r(5772),s=r(9746),o=i.rotr64_hi,a=i.rotr64_lo,h=i.shr64_hi,c=i.shr64_lo,u=i.sum64,l=i.sum64_hi,f=i.sum64_lo,d=i.sum64_4_hi,p=i.sum64_4_lo,g=i.sum64_5_hi,y=i.sum64_5_lo,m=n.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function w(){if(!(this instanceof w))return new w;m.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function b(e,t,r,i,n){var s=e&r^~e&n;return s<0&&(s+=4294967296),s}function _(e,t,r,i,n,s){var o=t&i^~t&s;return o<0&&(o+=4294967296),o}function E(e,t,r,i,n){var s=e&r^e&n^r&n;return s<0&&(s+=4294967296),s}function S(e,t,r,i,n,s){var o=t&i^t&s^i&s;return o<0&&(o+=4294967296),o}function I(e,t){var r=o(e,t,28)^o(t,e,2)^o(t,e,7);return r<0&&(r+=4294967296),r}function M(e,t){var r=a(e,t,28)^a(t,e,2)^a(t,e,7);return r<0&&(r+=4294967296),r}function A(e,t){var r=a(e,t,14)^a(e,t,18)^a(t,e,9);return r<0&&(r+=4294967296),r}function O(e,t){var r=o(e,t,1)^o(e,t,8)^h(e,t,7);return r<0&&(r+=4294967296),r}function x(e,t){var r=a(e,t,1)^a(e,t,8)^c(e,t,7);return r<0&&(r+=4294967296),r}function P(e,t){var r=a(e,t,19)^a(t,e,29)^c(e,t,6);return r<0&&(r+=4294967296),r}i.inherits(w,m),e.exports=w,w.blockSize=1024,w.outSize=512,w.hmacStrength=192,w.padLength=128,w.prototype._prepareBlock=function(e,t){for(var r=this.W,i=0;i<32;i++)r[i]=e[t+i];for(;i{var i=r(6436).rotr32;function n(e,t,r){return e&t^~e&r}function s(e,t,r){return e&t^e&r^t&r}function o(e,t,r){return e^t^r}t.ft_1=function(e,t,r,i){return 0===e?n(t,r,i):1===e||3===e?o(t,r,i):2===e?s(t,r,i):void 0},t.ch32=n,t.maj32=s,t.p32=o,t.s0_256=function(e){return i(e,2)^i(e,13)^i(e,22)},t.s1_256=function(e){return i(e,6)^i(e,11)^i(e,25)},t.g0_256=function(e){return i(e,7)^i(e,18)^e>>>3},t.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},6436:(e,t,r)=>{var i=r(9746),n=r(5717);function s(e,t){return 55296==(64512&e.charCodeAt(t))&&!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1))}function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function h(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=n,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,r[i++]=63&o|128):s(e,n)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n>>0}return o},t.split32=function(e,t){for(var r=new Array(4*e.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,i){return e+t+r+i>>>0},t.sum32_5=function(e,t,r,i,n){return e+t+r+i+n>>>0},t.sum64=function(e,t,r,i){var n=e[t],s=i+e[t+1]>>>0,o=(s>>0,e[t+1]=s},t.sum64_hi=function(e,t,r,i){return(t+i>>>0>>0},t.sum64_lo=function(e,t,r,i){return t+i>>>0},t.sum64_4_hi=function(e,t,r,i,n,s,o,a){var h=0,c=t;return h+=(c=c+i>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,i,n,s,o,a){return t+i+s+a>>>0},t.sum64_5_hi=function(e,t,r,i,n,s,o,a,h,c){var u=0,l=t;return u+=(l=l+i>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,i,n,s,o,a,h,c){return t+i+s+a+c>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},5717:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},204:(e,t,r)=>{e.exports=self.fetch||(self.fetch=r(5869).default||r(5869))},1094:(e,t,r)=>{var i;!function(){var n="input is invalid type",s="object"==typeof window,o=s?window:{};o.JS_SHA3_NO_WINDOW&&(s=!1);var a=!s&&"object"==typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?o=r.g:a&&(o=self);var h=!o.JS_SHA3_NO_COMMON_JS&&e.exports,c=r.amdO,u=!o.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),f=[4,1024,262144,67108864],d=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],y=[128,256],m=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};!o.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var w=function(e,t,r){return function(i){return new C(e,t,e).update(i)[r]()}},b=function(e,t,r){return function(i,n){return new C(e,t,n).update(i)[r]()}},_=function(e,t,r){return function(t,i,n,s){return A["cshake"+e].update(t,i,n,s)[r]()}},E=function(e,t,r){return function(t,i,n,s){return A["kmac"+e].update(t,i,n,s)[r]()}},S=function(e,t,r,i){for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var i=0;i<50;++i)this.s[i]=0}function U(e,t,r){C.call(this,e,t,r)}C.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(n);if(null===e)throw new Error(n);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(n);t=!0}for(var i,s,o=this.blocks,a=this.byteCount,h=e.length,c=this.blockCount,l=0,f=this.s;l>2]|=e[l]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(o[i>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=a){for(this.start=i-a,this.block=o[c],i=0;i>=8);r>0;)n.unshift(r),r=255&(e>>=8),++i;return t?n.push(i):n.unshift(i),this.update(n),n.length},C.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(n);if(null===e)throw new Error(n);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(n);t=!0}var i=0,s=e.length;if(t)i=s;else for(var o=0;o=57344?i+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++o)),i+=4)}return i+=this.encode(8*i),this.update(e),i},C.prototype.bytepad=function(e,t){for(var r=this.encode(t),i=0;i>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+l[15&e]+l[e>>12&15]+l[e>>8&15]+l[e>>20&15]+l[e>>16&15]+l[e>>28&15]+l[e>>24&15];o%t==0&&(k(r),s=0)}return n&&(e=r[s],a+=l[e>>4&15]+l[15&e],n>1&&(a+=l[e>>12&15]+l[e>>8&15]),n>2&&(a+=l[e>>20&15]+l[e>>16&15])),a},C.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,s=0,o=0,a=this.outputBits>>3;e=n?new ArrayBuffer(i+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(e);o>8&255,h[e+2]=t>>16&255,h[e+3]=t>>24&255;a%r==0&&k(i)}return s&&(e=a<<2,t=i[o],h[e]=255&t,s>1&&(h[e+1]=t>>8&255),s>2&&(h[e+2]=t>>16&255)),h},U.prototype=new C,U.prototype.finalize=function(){return this.encode(this.outputBits,!0),C.prototype.finalize.call(this)};var k=function(e){var t,r,i,n,s,o,a,h,c,u,l,f,d,g,y,m,v,w,b,_,E,S,I,M,A,O,x,P,N,R,T,L,C,U,k,j,q,D,z,$,K,B,F,V,H,W,G,J,Y,X,Q,Z,ee,te,re,ie,ne,se,oe,ae,he,ce,ue;for(i=0;i<48;i+=2)n=e[0]^e[10]^e[20]^e[30]^e[40],s=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],h=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],u=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(f=e[8]^e[18]^e[28]^e[38]^e[48])^(o<<1|a>>>31),r=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|o>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=n^(h<<1|c>>>31),r=s^(c<<1|h>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=o^(u<<1|l>>>31),r=a^(l<<1|u>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=h^(f<<1|d>>>31),r=c^(d<<1|f>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=u^(n<<1|s>>>31),r=l^(s<<1|n>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,g=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,G=e[10]<<4|e[11]>>>28,P=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,he=e[30]<<9|e[31]>>>23,B=e[40]<<18|e[41]>>>14,F=e[41]<<18|e[40]>>>14,U=e[2]<<1|e[3]>>>31,k=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,J=e[22]<<10|e[23]>>>22,Y=e[23]<<10|e[22]>>>22,R=e[33]<<13|e[32]>>>19,T=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,ue=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,j=e[14]<<6|e[15]>>>26,q=e[15]<<6|e[14]>>>26,w=e[25]<<11|e[24]>>>21,b=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,L=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,M=e[6]<<28|e[7]>>>4,A=e[7]<<28|e[6]>>>4,ie=e[17]<<23|e[16]>>>9,ne=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,z=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,H=e[9]<<27|e[8]>>>5,O=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,se=e[29]<<7|e[28]>>>25,oe=e[28]<<7|e[29]>>>25,$=e[38]<<8|e[39]>>>24,K=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,I=e[49]<<14|e[48]>>>18,e[0]=g^~m&w,e[1]=y^~v&b,e[10]=M^~O&P,e[11]=A^~x&N,e[20]=U^~j&D,e[21]=k^~q&z,e[30]=V^~W&J,e[31]=H^~G&Y,e[40]=te^~ie&se,e[41]=re^~ne&oe,e[2]=m^~w&_,e[3]=v^~b&E,e[12]=O^~P&R,e[13]=x^~N&T,e[22]=j^~D&$,e[23]=q^~z&K,e[32]=W^~J&X,e[33]=G^~Y&Q,e[42]=ie^~se&ae,e[43]=ne^~oe&he,e[4]=w^~_&S,e[5]=b^~E&I,e[14]=P^~R&L,e[15]=N^~T&C,e[24]=D^~$&B,e[25]=z^~K&F,e[34]=J^~X&Z,e[35]=Y^~Q&ee,e[44]=se^~ae&ce,e[45]=oe^~he&ue,e[6]=_^~S&g,e[7]=E^~I&y,e[16]=R^~L&M,e[17]=T^~C&A,e[26]=$^~B&U,e[27]=K^~F&k,e[36]=X^~Z&V,e[37]=Q^~ee&H,e[46]=ae^~ce&te,e[47]=he^~ue&re,e[8]=S^~g&m,e[9]=I^~y&v,e[18]=L^~M&O,e[19]=C^~A&x,e[28]=B^~U&j,e[29]=F^~k&q,e[38]=Z^~V&W,e[39]=ee^~H&G,e[48]=ce^~te&ie,e[49]=ue^~re&ne,e[0]^=p[i],e[1]^=p[i+1]};if(h)e.exports=A;else{for(x=0;x{e=r.nmd(e);var i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",h="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",l="[object Date]",f="[object Error]",d="[object Function]",p="[object GeneratorFunction]",g="[object Map]",y="[object Number]",m="[object Null]",v="[object Object]",w="[object Promise]",b="[object Proxy]",_="[object RegExp]",E="[object Set]",S="[object String]",I="[object Undefined]",M="[object WeakMap]",A="[object ArrayBuffer]",O="[object DataView]",x=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,N={};N["[object Float32Array]"]=N["[object Float64Array]"]=N["[object Int8Array]"]=N["[object Int16Array]"]=N["[object Int32Array]"]=N["[object Uint8Array]"]=N["[object Uint8ClampedArray]"]=N["[object Uint16Array]"]=N["[object Uint32Array]"]=!0,N[a]=N[h]=N[A]=N[u]=N[O]=N[l]=N[f]=N[d]=N[g]=N[y]=N[v]=N[_]=N[E]=N[S]=N[M]=!1;var R="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,T="object"==typeof self&&self&&self.Object===Object&&self,L=R||T||Function("return this")(),C=t&&!t.nodeType&&t,U=C&&e&&!e.nodeType&&e,k=U&&U.exports===C,j=k&&R.process,q=function(){try{return j&&j.binding&&j.binding("util")}catch(e){}}(),D=q&&q.isTypedArray;function z(e,t){for(var r=-1,i=null==e?0:e.length;++rc))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var f=-1,d=!0,p=r&s?new Ae:void 0;for(a.set(e,t),a.set(t,e);++f-1},Ie.prototype.set=function(e,t){var r=this.__data__,i=xe(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this},Me.prototype.clear=function(){this.size=0,this.__data__={hash:new Se,map:new(le||Ie),string:new Se}},Me.prototype.delete=function(e){var t=Ce(this,e).delete(e);return this.size-=t?1:0,t},Me.prototype.get=function(e){return Ce(this,e).get(e)},Me.prototype.has=function(e){return Ce(this,e).has(e)},Me.prototype.set=function(e,t){var r=Ce(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this},Ae.prototype.add=Ae.prototype.push=function(e){return this.__data__.set(e,i),this},Ae.prototype.has=function(e){return this.__data__.has(e)},Oe.prototype.clear=function(){this.__data__=new Ie,this.size=0},Oe.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Oe.prototype.get=function(e){return this.__data__.get(e)},Oe.prototype.has=function(e){return this.__data__.has(e)},Oe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ie){var i=r.__data__;if(!le||i.length<199)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new Me(i)}return r.set(e,t),this.size=r.size,this};var ke=ae?function(e){return null==e?[]:(e=Object(e),function(t,r){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i-1&&e%1==0&&e-1&&e%1==0&&e<=o}function He(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function We(e){return null!=e&&"object"==typeof e}var Ge=D?function(e){return function(t){return e(t)}}(D):function(e){return We(e)&&Ve(e.length)&&!!N[Pe(e)]};function Je(e){return null!=(t=e)&&Ve(t.length)&&!Fe(t)?function(e,t){var r=Ke(e),i=!r&&$e(e),n=!r&&!i&&Be(e),s=!r&&!i&&!n&&Ge(e),o=r||i||n||s,a=o?function(e,t){for(var r=-1,i=Array(e);++r{function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},7563:(e,t,r)=>{const i=r(610),n=r(4020),s=r(500),o=r(2806),a=Symbol("encodeFragmentIdentifier");function h(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function c(e,t){return t.encode?t.strict?i(e):encodeURIComponent(e):e}function u(e,t){return t.decode?n(e):e}function l(e){return Array.isArray(e)?e.sort():"object"==typeof e?l(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function f(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function d(e){const t=(e=f(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function p(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function g(e,t){h((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,i)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===i[e]&&(i[e]={}),i[e][t[1]]=r):i[e]=r};case"bracket":return(e,r,i)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==i[e]?i[e]=[].concat(i[e],r):i[e]=[r]:i[e]=r};case"colon-list-separator":return(e,r,i)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==i[e]?i[e]=[].concat(i[e],r):i[e]=[r]:i[e]=r};case"comma":case"separator":return(t,r,i)=>{const n="string"==typeof r&&r.includes(e.arrayFormatSeparator),s="string"==typeof r&&!n&&u(r,e).includes(e.arrayFormatSeparator);r=s?u(r,e):r;const o=n||s?r.split(e.arrayFormatSeparator).map((t=>u(t,e))):null===r?r:u(r,e);i[t]=o};case"bracket-separator":return(t,r,i)=>{const n=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!n)return void(i[t]=r?u(r,e):r);const s=null===r?[]:r.split(e.arrayFormatSeparator).map((t=>u(t,e)));void 0!==i[t]?i[t]=[].concat(i[t],s):i[t]=s};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),i=Object.create(null);if("string"!=typeof e)return i;if(!(e=e.trim().replace(/^[?#&]/,"")))return i;for(const n of e.split("&")){if(""===n)continue;let[e,o]=s(t.decode?n.replace(/\+/g," "):n,"=");o=void 0===o?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?o:u(o,t),r(u(e,t),o,i)}for(const e of Object.keys(i)){const r=i[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=p(r[e],t);else i[e]=p(r,t)}return!1===t.sort?i:(!0===t.sort?Object.keys(i).sort():Object.keys(i).sort(t.sort)).reduce(((e,t)=>{const r=i[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=l(r):e[t]=r,e}),Object.create(null))}t.extract=d,t.parse=g,t.stringify=(e,t)=>{if(!e)return"";h((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],i=function(e){switch(e.arrayFormat){case"index":return t=>(r,i)=>{const n=r.length;return void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?r:null===i?[...r,[c(t,e),"[",n,"]"].join("")]:[...r,[c(t,e),"[",c(n,e),"]=",c(i,e)].join("")]};case"bracket":return t=>(r,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?r:null===i?[...r,[c(t,e),"[]"].join("")]:[...r,[c(t,e),"[]=",c(i,e)].join("")];case"colon-list-separator":return t=>(r,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?r:null===i?[...r,[c(t,e),":list="].join("")]:[...r,[c(t,e),":list=",c(i,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(i,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?i:(n=null===n?"":n,0===i.length?[[c(r,e),t,c(n,e)].join("")]:[[i,c(n,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?r:null===i?[...r,c(t,e)]:[...r,[c(t,e),"=",c(i,e)].join("")]}}(t),n={};for(const t of Object.keys(e))r(t)||(n[t]=e[t]);const s=Object.keys(n);return!1!==t.sort&&s.sort(t.sort),s.map((r=>{const n=e[r];return void 0===n?"":null===n?c(r,t):Array.isArray(n)?0===n.length&&"bracket-separator"===t.arrayFormat?c(r,t)+"[]":n.reduce(i(r),[]).join("&"):c(r,t)+"="+c(n,t)})).filter((e=>e.length>0)).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,i]=s(e,"#");return Object.assign({url:r.split("?")[0]||"",query:g(d(e),t)},t&&t.parseFragmentIdentifier&&i?{fragmentIdentifier:u(i,t)}:{})},t.stringifyUrl=(e,r)=>{r=Object.assign({encode:!0,strict:!0,[a]:!0},r);const i=f(e.url).split("?")[0]||"",n=t.extract(e.url),s=t.parse(n,{sort:!1}),o=Object.assign(s,e.query);let h=t.stringify(o,r);h&&(h=`?${h}`);let u=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(e.url);return e.fragmentIdentifier&&(u=`#${r[a]?c(e.fragmentIdentifier,r):e.fragmentIdentifier}`),`${i}${h}${u}`},t.pick=(e,r,i)=>{i=Object.assign({parseFragmentIdentifier:!0,[a]:!1},i);const{url:n,query:s,fragmentIdentifier:h}=t.parseUrl(e,i);return t.stringifyUrl({url:n,query:o(s,r),fragmentIdentifier:h},i)},t.exclude=(e,r,i)=>{const n=Array.isArray(r)?e=>!r.includes(e):(e,t)=>!r(e,t);return t.pick(e,n,i)}},5346:e=>{function t(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}e.exports=function(e,r,i){var n=i&&i.stringify||t;if("object"==typeof e&&null!==e){var s=r.length+1;if(1===s)return e;var o=new Array(s);o[0]=n(e);for(var a=1;a-1?l:0,e.charCodeAt(d+1)){case 100:case 102:if(u>=h)break;if(null==r[u])break;l=h)break;if(null==r[u])break;l=h)break;if(void 0===r[u])break;l",l=d+2,d++;break}c+=n(r[u]),l=d+2,d++;break;case 115:if(u>=h)break;l{e.exports=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},610:e=>{e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`))},655:(e,t,r)=>{r.r(t),r.d(t,{__assign:()=>s,__asyncDelegator:()=>b,__asyncGenerator:()=>w,__asyncValues:()=>_,__await:()=>v,__awaiter:()=>u,__classPrivateFieldGet:()=>M,__classPrivateFieldSet:()=>A,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>d,__extends:()=>n,__generator:()=>l,__importDefault:()=>I,__importStar:()=>S,__makeTemplateObject:()=>E,__metadata:()=>c,__param:()=>h,__read:()=>g,__rest:()=>o,__spread:()=>y,__spreadArrays:()=>m,__values:()=>p});var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},i(e,t)};function n(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return s=Object.assign||function(e){for(var t,r=1,i=arguments.length;r=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function h(e,t){return function(r,i){t(r,i,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{h(i.next(e))}catch(e){s(e)}}function a(e){try{h(i.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}h((i=i.apply(e,t||[])).next())}))}function l(e,t){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function y(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{(r=n[e](t)).value instanceof v?Promise.resolve(r.value.v).then(h,c):u(s[0][2],r)}catch(e){u(s[0][3],e)}var r}function h(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function b(e){var t,r;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,n){t[i]=e[i]?function(t){return(r=!r)?{value:v(e[i](t)),done:"return"===i}:n?n(t):t}:n}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=p(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(r){t[r]=e[r]&&function(t){return new Promise((function(i,n){!function(e,t,r,i){Promise.resolve(i).then((function(t){e({value:t,done:r})}),t)}(i,n,(t=e[r](t)).done,t.value)}))}}}function E(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function I(e){return e&&e.__esModule?e:{default:e}}function M(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function A(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},5869:(e,t,r)=>{function i(e,t){return t=t||{},new Promise((function(r,i){var n=new XMLHttpRequest,s=[],o=[],a={},h=function(){return{ok:2==(n.status/100|0),statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:h,headers:{keys:function(){return s},entries:function(){return o},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in n.open(t.method||"get",e,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,r){s.push(t=t.toLowerCase()),o.push([t,r]),a[t]=a[t]?a[t]+","+r:r})),r(h())},n.onerror=i,n.withCredentials="include"==t.credentials,t.headers)n.setRequestHeader(c,t.headers[c]);n.send(t.body||null)}))}r.r(t),r.d(t,{default:()=>i})},7026:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},5883:()=>{},6601:()=>{},6559:(e,t,r)=>{const i=r(5346);e.exports=o;const n=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},s={mapHttpRequest:f,mapHttpResponse:f,wrapRequestSerializer:d,wrapResponseSerializer:d,wrapErrorSerializer:d,req:f,res:f,err:function(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}};function o(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!=typeof t.send)throw Error("pino: transmit option must have a send function");const r=e.browser.write||n;e.browser.write&&(e.browser.asObject=!0);const i=e.serializers||{},s=function(e,t){return Array.isArray(e)?e.filter((function(e){return"!stdSerializers.err"!==e})):!0===e&&Object.keys(t)}(e.browser.serialize,i);let f=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(f=!1),"function"==typeof r&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),!1===e.enabled&&(e.level="silent");const d=e.level||"info",g=Object.create(r);g.log||(g.log=p),Object.defineProperty(g,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(g,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,a(y,g,"error","log"),a(y,g,"fatal","error"),a(y,g,"warn","error"),a(y,g,"info","log"),a(y,g,"debug","log"),a(y,g,"trace","log")}});const y={transmit:t,serialize:s,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:l(e)};return g.levels=o.levels,g.level=d,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=p,g.serializers=i,g._serialize=s,g._stdErrSerialize=f,g.child=function(r,n){if(!r)throw new Error("missing bindings for child Pino");n=n||{},s&&r.serializers&&(n.serializers=r.serializers);const o=n.serializers;if(s&&o){var a=Object.assign({},i,o),l=!0===e.browser.serialize?Object.keys(a):s;delete r.serializers,h([r],l,a,this._stdErrSerialize)}function f(e){this._childLevel=1+(0|e._childLevel),this.error=c(e,r,"error"),this.fatal=c(e,r,"fatal"),this.warn=c(e,r,"warn"),this.info=c(e,r,"info"),this.debug=c(e,r,"debug"),this.trace=c(e,r,"trace"),a&&(this.serializers=a,this._serialize=l),t&&(this._logEvent=u([].concat(e._logEvent.bindings,r)))}return f.prototype=this,new f(this)},t&&(g._logEvent=u()),g}function a(e,t,r,s){const a=Object.getPrototypeOf(t);t[r]=t.levelVal>t.levels.values[r]?p:a[r]?a[r]:n[r]||n[s]||p,function(e,t,r){var s;(e.transmit||t[r]!==p)&&(t[r]=(s=t[r],function(){const a=e.timestamp(),c=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===n?n:this;for(var f=0;f-1&&i in r&&(e[n][i]=r[i](e[n][i]))}function c(e,t,r){return function(){const i=new Array(1+arguments.length);i[0]=t;for(var n=1;n{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={};r.r(e),r.d(e,{identity:()=>Te});var t={};r.r(t),r.d(t,{base2:()=>Le});var i={};r.r(i),r.d(i,{base8:()=>Ce});var n={};r.r(n),r.d(n,{base10:()=>Ue});var s={};r.r(s),r.d(s,{base16:()=>ke,base16upper:()=>je});var o={};r.r(o),r.d(o,{base32:()=>qe,base32hex:()=>Ke,base32hexpad:()=>Fe,base32hexpadupper:()=>Ve,base32hexupper:()=>Be,base32pad:()=>ze,base32padupper:()=>$e,base32upper:()=>De,base32z:()=>He});var a={};r.r(a),r.d(a,{base36:()=>We,base36upper:()=>Ge});var h={};r.r(h),r.d(h,{base58btc:()=>Je,base58flickr:()=>Ye});var c={};r.r(c),r.d(c,{base64:()=>Xe,base64pad:()=>Qe,base64url:()=>Ze,base64urlpad:()=>et});var u={};r.r(u),r.d(u,{base256emoji:()=>nt});var l={};r.r(l),r.d(l,{sha256:()=>At,sha512:()=>Ot});var f={};r.r(f),r.d(f,{identity:()=>Pt});var d={};r.r(d),r.d(d,{code:()=>Rt,decode:()=>Lt,encode:()=>Tt,name:()=>Nt});var p={};r.r(p),r.d(p,{code:()=>jt,decode:()=>Dt,encode:()=>qt,name:()=>kt});var g=r(7187),y=r.n(g);const m=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,v=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,w=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function b(e,t){if(!("__proto__"===e||"constructor"===e&&t&&"object"==typeof t&&"prototype"in t))return t;!function(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}(e)}function _(e,t={}){if("string"!=typeof e)return e;const r=e.trim();if('"'===e[0]&&'"'===e.at(-1)&&!e.includes("\\"))return r.slice(1,-1);if(r.length<=9){const e=r.toLowerCase();if("true"===e)return!0;if("false"===e)return!1;if("undefined"===e)return;if("null"===e)return null;if("nan"===e)return Number.NaN;if("infinity"===e)return Number.POSITIVE_INFINITY;if("-infinity"===e)return Number.NEGATIVE_INFINITY}if(!w.test(e)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return e}try{if(m.test(e)||v.test(e)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(e,b)}return JSON.parse(e)}catch(r){if(t.strict)throw r;return e}}function E(e,...t){try{return(r=e(...t))&&"function"==typeof r.then?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}var r}function S(e){if(function(e){const t=typeof e;return null===e||"object"!==t&&"function"!==t}(e))return String(e);if(function(e){const t=Object.getPrototypeOf(e);return!t||t.isPrototypeOf(Object)}(e)||Array.isArray(e))return JSON.stringify(e);if("function"==typeof e.toJSON)return S(e.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function I(){if(void 0===typeof Buffer)throw new TypeError("[unstorage] Buffer is not supported!")}const M="base64:";function A(e){return e?e.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function O(...e){return A(e.join(":"))}function x(e){return(e=A(e))?e+":":""}const P=()=>{const e=new Map;return{name:"memory",options:{},hasItem:t=>e.has(t),getItem:t=>e.get(t)??null,getItemRaw:t=>e.get(t)??null,setItem(t,r){e.set(t,r)},setItemRaw(t,r){e.set(t,r)},removeItem(t){e.delete(t)},getKeys:()=>Array.from(e.keys()),clear(){e.clear()},dispose(){e.clear()}}};function N(e,t,r){return e.watch?e.watch(((e,i)=>t(e,r+i))):()=>{}}async function R(e){"function"==typeof e.dispose&&await E(e.dispose)}function T(e){return new Promise(((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error)}))}function L(e,t){const r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);const i=T(r);return(e,r)=>i.then((i=>r(i.transaction(t,e).objectStore(t))))}let C;function U(){return C||(C=L("keyval-store","keyval")),C}function k(e,t=U()){return t("readonly",(t=>T(t.get(e))))}const j=e=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString()+"n":t)),q=e=>{const t=e.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3');return JSON.parse(t,((e,t)=>"string"==typeof t&&t.match(/^\d+n$/)?BigInt(t.substring(0,t.length-1)):t))};function D(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return q(e)}catch(t){return e}}function z(e){return"string"==typeof e?e:j(e)||""}var $=(e={})=>{const t=e.base&&e.base.length>0?`${e.base}:`:"",r=e=>t+e;let i;return e.dbName&&e.storeName&&(i=L(e.dbName,e.storeName)),{name:"idb-keyval",options:e,hasItem:async e=>!(typeof await k(r(e),i)>"u"),getItem:async e=>await k(r(e),i)??null,setItem:(e,t)=>function(e,t,r=U()){return r("readwrite",(r=>(r.put(t,e),T(r.transaction))))}(r(e),t,i),removeItem:e=>function(e,t=U()){return t("readwrite",(t=>(t.delete(e),T(t.transaction))))}(r(e),i),getKeys:()=>function(e=U()){return e("readonly",(e=>{if(e.getAllKeys)return T(e.getAllKeys());const t=[];return function(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},T(e.transaction)}(e,(e=>t.push(e.key))).then((()=>t))}))}(i),clear:()=>function(e=U()){return e("readwrite",(e=>(e.clear(),T(e.transaction))))}(i)}};class K{constructor(){this.indexedDb=function(e={}){const t={mounts:{"":e.driver||P()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=e=>{for(const r of t.mountpoints)if(e.startsWith(r))return{base:r,relativeKey:e.slice(r.length),driver:t.mounts[r]};return{base:"",relativeKey:e,driver:t.mounts[""]}},i=(e,r)=>t.mountpoints.filter((t=>t.startsWith(e)||r&&e.startsWith(t))).map((r=>({relativeBase:e.length>r.length?e.slice(r.length):void 0,mountpoint:r,driver:t.mounts[r]}))),n=(e,r)=>{if(t.watching){r=A(r);for(const i of t.watchListeners)i(e,r)}},s=async()=>{if(t.watching){for(const e in t.unwatch)await t.unwatch[e]();t.unwatch={},t.watching=!1}},o=(e,t,i)=>{const n=new Map,s=e=>{let t=n.get(e.base);return t||(t={driver:e.driver,base:e.base,items:[]},n.set(e.base,t)),t};for(const i of e){const e="string"==typeof i,n=A(e?i:i.key),o=e?void 0:i.value,a=e||!i.options?t:{...t,...i.options},h=r(n);s(h).items.push({key:n,value:o,relativeKey:h.relativeKey,options:a})}return Promise.all([...n.values()].map((e=>i(e)))).then((e=>e.flat()))},a={hasItem(e,t={}){e=A(e);const{relativeKey:i,driver:n}=r(e);return E(n.hasItem,i,t)},getItem(e,t={}){e=A(e);const{relativeKey:i,driver:n}=r(e);return E(n.getItem,i,t).then((e=>_(e)))},getItems:(e,t)=>o(e,t,(e=>e.driver.getItems?E(e.driver.getItems,e.items.map((e=>({key:e.relativeKey,options:e.options}))),t).then((t=>t.map((t=>({key:O(e.base,t.key),value:_(t.value)}))))):Promise.all(e.items.map((t=>E(e.driver.getItem,t.relativeKey,t.options).then((e=>({key:t.key,value:_(e)})))))))),getItemRaw(e,t={}){e=A(e);const{relativeKey:i,driver:n}=r(e);return n.getItemRaw?E(n.getItemRaw,i,t):E(n.getItem,i,t).then((e=>function(e){return"string"!=typeof e?e:e.startsWith(M)?(I(),Buffer.from(e.slice(7),"base64")):e}(e)))},async setItem(e,t,i={}){if(void 0===t)return a.removeItem(e);e=A(e);const{relativeKey:s,driver:o}=r(e);o.setItem&&(await E(o.setItem,s,S(t),i),o.watch||n("update",e))},async setItems(e,t){await o(e,t,(async e=>{e.driver.setItems&&await E(e.driver.setItems,e.items.map((e=>({key:e.relativeKey,value:S(e.value),options:e.options}))),t),e.driver.setItem&&await Promise.all(e.items.map((t=>E(e.driver.setItem,t.relativeKey,S(t.value),t.options))))}))},async setItemRaw(e,t,i={}){if(void 0===t)return a.removeItem(e,i);e=A(e);const{relativeKey:s,driver:o}=r(e);if(o.setItemRaw)await E(o.setItemRaw,s,t,i);else{if(!o.setItem)return;await E(o.setItem,s,function(e){if("string"==typeof e)return e;I();const t=Buffer.from(e).toString("base64");return M+t}(t),i)}o.watch||n("update",e)},async removeItem(e,t={}){"boolean"==typeof t&&(t={removeMeta:t}),e=A(e);const{relativeKey:i,driver:s}=r(e);s.removeItem&&(await E(s.removeItem,i,t),(t.removeMeta||t.removeMata)&&await E(s.removeItem,i+"$",t),s.watch||n("remove",e))},async getMeta(e,t={}){"boolean"==typeof t&&(t={nativeOnly:t}),e=A(e);const{relativeKey:i,driver:n}=r(e),s=Object.create(null);if(n.getMeta&&Object.assign(s,await E(n.getMeta,i,t)),!t.nativeOnly){const e=await E(n.getItem,i+"$",t).then((e=>_(e)));e&&"object"==typeof e&&("string"==typeof e.atime&&(e.atime=new Date(e.atime)),"string"==typeof e.mtime&&(e.mtime=new Date(e.mtime)),Object.assign(s,e))}return s},setMeta(e,t,r={}){return this.setItem(e+"$",t,r)},removeMeta(e,t={}){return this.removeItem(e+"$",t)},async getKeys(e,t={}){e=x(e);const r=i(e,!0);let n=[];const s=[];for(const e of r){const r=(await E(e.driver.getKeys,e.relativeBase,t)).map((t=>e.mountpoint+A(t))).filter((e=>!n.some((t=>e.startsWith(t)))));s.push(...r),n=[e.mountpoint,...n.filter((t=>!t.startsWith(e.mountpoint)))]}return e?s.filter((t=>t.startsWith(e)&&!t.endsWith("$"))):s.filter((e=>!e.endsWith("$")))},async clear(e,t={}){e=x(e),await Promise.all(i(e,!1).map((async e=>{if(e.driver.clear)return E(e.driver.clear,e.relativeBase,t);if(e.driver.removeItem){const r=await e.driver.getKeys(e.relativeBase||"",t);return Promise.all(r.map((r=>e.driver.removeItem(r,t))))}})))},async dispose(){await Promise.all(Object.values(t.mounts).map((e=>R(e))))},watch:async e=>(await(async()=>{if(!t.watching){t.watching=!0;for(const e in t.mounts)t.unwatch[e]=await N(t.mounts[e],n,e)}})(),t.watchListeners.push(e),async()=>{t.watchListeners=t.watchListeners.filter((t=>t!==e)),0===t.watchListeners.length&&await s()}),async unwatch(){t.watchListeners=[],await s()},mount(e,r){if((e=x(e))&&t.mounts[e])throw new Error(`already mounted at ${e}`);return e&&(t.mountpoints.push(e),t.mountpoints.sort(((e,t)=>t.length-e.length))),t.mounts[e]=r,t.watching&&Promise.resolve(N(r,n,e)).then((r=>{t.unwatch[e]=r})).catch(console.error),a},async unmount(e,r=!0){(e=x(e))&&t.mounts[e]&&(t.watching&&e in t.unwatch&&(t.unwatch[e](),delete t.unwatch[e]),r&&await R(t.mounts[e]),t.mountpoints=t.mountpoints.filter((t=>t!==e)),delete t.mounts[e])},getMount(e=""){e=A(e)+":";const t=r(e);return{driver:t.driver,base:t.base}},getMounts:(e="",t={})=>(e=A(e),i(e,t.parents).map((e=>({driver:e.driver,base:e.mountpoint}))))};return a}({driver:$({dbName:"WALLET_CONNECT_V2_INDEXED_DB",storeName:"keyvaluestorage"})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map((e=>[e.key,e.value]))}async getItem(e){const t=await this.indexedDb.getItem(e);if(null!==t)return t}async setItem(e,t){await this.indexedDb.setItem(e,z(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var B=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof r.g<"u"?r.g:typeof self<"u"?self:{},F={exports:{}};function V(e){var t;return[e[0],D(null!=(t=e[1])?t:"")]}!function(){let e;function t(){}e=t,e.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},e.prototype.setItem=function(e,t){this[e]=String(t)},e.prototype.removeItem=function(e){delete this[e]},e.prototype.clear=function(){const e=this;Object.keys(e).forEach((function(t){e[t]=void 0,delete e[t]}))},e.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},e.prototype.__defineGetter__("length",(function(){return Object.keys(this).length})),typeof B<"u"&&B.localStorage?F.exports=B.localStorage:typeof window<"u"&&window.localStorage?F.exports=window.localStorage:F.exports=new t}();class H{constructor(){this.localStorage=F.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(V)}async getItem(e){const t=this.localStorage.getItem(e);if(null!==t)return D(t)}async setItem(e,t){this.localStorage.setItem(e,z(t))}async removeItem(e){this.localStorage.removeItem(e)}}class W{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const e=new H;this.storage=e;try{(async(e,t,r)=>{const i="wc_storage_version",n=await t.getItem(i);if(n&&n>=1)return void r(t);const s=await e.getKeys();if(!s.length)return void r(t);const o=[];for(;s.length;){const r=s.shift();if(!r)continue;const i=r.toLowerCase();if(i.includes("wc@")||i.includes("walletconnect")||i.includes("wc_")||i.includes("wallet_connect")){const i=await e.getItem(r);await t.setItem(r,i),o.push(r)}}await t.setItem(i,1),r(t),(async(e,t)=>{t.length&&t.forEach((async t=>{await e.removeItem(t)}))})(e,o)})(e,new K,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise((e=>{const t=setInterval((()=>{this.initialized&&(clearInterval(t),e())}),20)}))}}var G=r(159),J=r(9107),Y=r(8200);class X extends Y.q{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Q extends Y.q{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Z{constructor(e,t){this.logger=e,this.core=t}}class ee extends Y.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class te extends Y.q{constructor(e){super()}}class re{constructor(e,t,r,i){this.core=e,this.logger=t,this.name=r}}class ie extends Y.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class ne extends Y.q{constructor(e,t){super(),this.core=e,this.logger=t}}class se{constructor(e,t){this.projectId=e,this.logger=t}}class oe{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class ae{constructor(e){this.client=e}}var he=r(1050),ce=r(1416),ue=r(6736);const le="base64url",fe="utf8",de=":",pe="did",ge="key",ye="base58btc",me="z",ve="K36";function we(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function be(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?we(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function _e(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=be(t);let i=0;for(const t of e)r.set(t,i),i+=t.length;return we(r)}const Ee=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var l=0,f=s-1;(0!==u||l>>0,o[f]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");n=l,t++}if(" "!==e[t]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,n=0,s=t.length;n!==s&&0===t[n];)n++,r++;for(var o=(s-n)*u+1>>>0,c=new Uint8Array(o);n!==s;){for(var l=t[n],f=0,d=o-1;(0!==l||f>>0,c[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===c[p];)p++;for(var g=h.repeat(r);p{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")});class Ie{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Me{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return Oe(this,e)}}class Ae{constructor(e){this.decoders=e}or(e){return Oe(this,e)}decode(e){const t=e[0],r=this.decoders[t];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 Oe=(e,t)=>new Ae({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class xe{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new Ie(e,t,r),this.decoder=new Me(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Pe=({name:e,prefix:t,encode:r,decode:i})=>new xe(e,t,r,i),Ne=({prefix:e,name:t,alphabet:r})=>{const{encode:i,decode:n}=Ee(r,t);return Pe({prefix:e,name:t,encode:i,decode:e=>Se(n(e))})},Re=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>Pe({prefix:t,name:e,encode:e=>((e,t,r)=>{const i="="===t[t.length-1],n=(1<r;)o-=r,s+=t[n&a>>o];if(o&&(s+=t[n&a<((e,t,r,i)=>{const n={};for(let e=0;e=8&&(a-=8,o[c++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,r,e)}),Te=Pe({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)}),Le=Re({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Ce=Re({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Ue=Ne({prefix:"9",name:"base10",alphabet:"0123456789"}),ke=Re({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),je=Re({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),qe=Re({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),De=Re({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ze=Re({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$e=Re({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ke=Re({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Be=Re({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fe=Re({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ve=Re({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),He=Re({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),We=Ne({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ge=Ne({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Je=Ne({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ye=Ne({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Xe=Re({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qe=Re({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ze=Re({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),et=Re({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),tt=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),rt=tt.reduce(((e,t,r)=>(e[r]=t,e)),[]),it=tt.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]),nt=Pe({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+rt[t]),"")},decode:function(e){const t=[];for(const r of e){const e=it[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var st=128,ot=-128,at=Math.pow(2,31),ht=Math.pow(2,7),ct=Math.pow(2,14),ut=Math.pow(2,21),lt=Math.pow(2,28),ft=Math.pow(2,35),dt=Math.pow(2,42),pt=Math.pow(2,49),gt=Math.pow(2,56),yt=Math.pow(2,63);const mt=function e(t,r,i){r=r||[];for(var n=i=i||0;t>=at;)r[i++]=255&t|st,t/=128;for(;t&ot;)r[i++]=255&t|st,t>>>=7;return r[i]=0|t,e.bytes=i-n+1,r},vt=function(e){return e(mt(e,t,r),t),bt=e=>vt(e),_t=(e,t)=>{const r=t.byteLength,i=bt(e),n=i+bt(r),s=new Uint8Array(n+r);return wt(e,s,0),wt(r,s,i),s.set(t,n),new Et(e,r,t,s)};class Et{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const St=({name:e,code:t,encode:r})=>new It(e,t,r);class It{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?_t(this.code,t):t.then((e=>_t(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Mt=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),At=St({name:"sha2-256",code:18,encode:Mt("SHA-256")}),Ot=St({name:"sha2-512",code:19,encode:Mt("SHA-512")}),xt=Se,Pt={code:0,name:"identity",encode:xt,digest:e=>_t(0,xt(e))},Nt="raw",Rt=85,Tt=e=>Se(e),Lt=e=>Se(e),Ct=new TextEncoder,Ut=new TextDecoder,kt="json",jt=512,qt=e=>Ct.encode(JSON.stringify(e)),Dt=e=>JSON.parse(Ut.decode(e));Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"),Symbol.for("@ipld/js-cid/CID");const zt={...e,...t,...i,...n,...s,...o,...a,...h,...c,...u};function $t(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}const Kt=$t("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Bt=$t("ascii","a",(e=>{let t="a";for(let r=0;r{const t=be((e=e.substring(1)).length);for(let r=0;r"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function Ar(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}var Or=Object.defineProperty,xr=Object.getOwnPropertySymbols,Pr=Object.prototype.hasOwnProperty,Nr=Object.prototype.propertyIsEnumerable,Rr=(e,t,r)=>t in e?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tr=(e,t)=>{for(var r in t||(t={}))Pr.call(t,r)&&Rr(e,r,t[r]);if(xr)for(var r of xr(t))Nr.call(t,r)&&Rr(e,r,t[r]);return e};const Lr="ReactNative",Cr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Ur="js";function kr(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function jr(){return!(0,lr.getDocument)()&&!!(0,lr.getNavigator)()&&navigator.product===Lr}function qr(){return!kr()&&!!(0,lr.getNavigator)()}function Dr(){return jr()?Cr.reactNative:kr()?Cr.node:qr()?Cr.browser:Cr.unknown}function zr(e,t,i){const n=function(){if(Dr()===Cr.reactNative&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Platform)<"u"){const{OS:e,Version:t}=r.g.Platform;return[e,t].join("-")}const e=t?ur(t):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new sr:"undefined"!=typeof navigator?ur(navigator.userAgent):"undefined"!=typeof process&&process.version?new rr(process.version.slice(1)):null;var t;if(null===e)return"unknown";const i=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[i,e.name,e.version].join("-"):[i,e.version].join("-")}(),s=function(){var e;const t=Dr();return t===Cr.browser?[t,(null==(e=(0,lr.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[Ur,i].join("-"),n,s].join("/")}function $r(e,t){return e.filter((e=>t.includes(e))).length===e.length}function Kr(e){return Object.fromEntries(e.entries())}function Br(e){return new Map(Object.entries(e))}function Fr(e=ue.FIVE_MINUTES,t){const r=(0,ue.toMiliseconds)(e||ue.FIVE_MINUTES);let i,n,s;return{resolve:e=>{s&&i&&(clearTimeout(s),i(e))},reject:e=>{s&&n&&(clearTimeout(s),n(e))},done:()=>new Promise(((e,o)=>{s=setTimeout((()=>{o(new Error(t))}),r),i=e,n=o}))}}function Vr(e,t,r){return new Promise((async(i,n)=>{const s=setTimeout((()=>n(new Error(r))),t);try{i(await e)}catch(e){n(e)}clearTimeout(s)}))}function Hr(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function Wr(e){const[t,r]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)i.topic=r;else{if("id"!==t||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);i.id=Number(r)}return i}function Gr(e,t){return(0,ue.fromMiliseconds)((t||Date.now())+(0,ue.toMiliseconds)(e))}function Jr(e){return Date.now()>=(0,ue.toMiliseconds)(e)}function Yr(e,t){return`${e}${t?`:${t}`:""}`}function Xr(e=[],t=[]){return[...new Set([...e,...t])]}function Qr(e){return e?.relay||{protocol:"irn"}}function Zr(e){const t=pr[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}var ei=Object.defineProperty,ti=Object.getOwnPropertySymbols,ri=Object.prototype.hasOwnProperty,ii=Object.prototype.propertyIsEnumerable,ni=(e,t,r)=>t in e?ei(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function si(e,t="-"){const r={},i="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(i)){const n=t.replace(i,""),s=e[t];r[n]=s}})),r}function oi(e){return e.startsWith("//")?e.substring(2):e}var ai=Object.defineProperty,hi=Object.defineProperties,ci=Object.getOwnPropertyDescriptors,ui=Object.getOwnPropertySymbols,li=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,di=(e,t,r)=>t in e?ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pi=(e,t)=>{for(var r in t||(t={}))li.call(t,r)&&di(e,r,t[r]);if(ui)for(var r of ui(t))fi.call(t,r)&&di(e,r,t[r]);return e},gi=(e,t)=>hi(e,ci(t));function yi(e){const t=[];return e.forEach((e=>{const[r,i]=e.split(":");t.push(`${r}:${i}`)})),t}function mi(e){return e.includes(":")}function vi(e){return mi(e)?e.split(":")[0]:e}function wi(e){var t,r,i;const n={};if(!Mi(e))return n;for(const[s,o]of Object.entries(e)){const e=mi(s)?[s]:o.chains,a=o.methods||[],h=o.events||[],c=vi(s);n[c]=gi(pi({},n[c]),{chains:Xr(e,null==(t=n[c])?void 0:t.chains),methods:Xr(a,null==(r=n[c])?void 0:r.methods),events:Xr(h,null==(i=n[c])?void 0:i.events)})}return n}const bi={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}},_i={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 Ei(e,t){const{message:r,code:i}=_i[e];return{message:t?`${r} ${t}`:r,code:i}}function Si(e,t){const{message:r,code:i}=bi[e];return{message:t?`${r} ${t}`:r,code:i}}function Ii(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Mi(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Ai(e){return typeof e>"u"}function Oi(e,t){return!(!t||!Ai(e))||"string"==typeof e&&!!e.trim().length}function xi(e,t){return!(!t||!Ai(e))||"number"==typeof e&&!isNaN(e)}function Pi(e){return!(!Oi(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Ni(e){if(Oi(e,!1))try{return typeof new URL(e)<"u"}catch{return!1}return!1}function Ri(e){let t=!0;return Ii(e)?e.length&&(t=e.every((e=>Oi(e,!1)))):t=!1,t}function Ti(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const i=function(e,t){let r=null;return Ri(e?.methods)?Ri(e?.events)||(r=Si("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=Si("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}(e,`${t}, namespace`);i&&(r=i)})),r}function Li(e,t){let r=null;if(e&&Mi(e)){const i=Ti(e,t);i&&(r=i);const n=function(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const i=function(e,t){let r=null;return Ii(e)?e.forEach((e=>{r||function(e){if(Oi(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Pi(e)}}return!1}(e)||(r=Si("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):r=Si("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}(e?.accounts,`${t} namespace`);i&&(r=i)})),r}(e,t);n&&(r=n)}else r=Ei("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Ci(e){return Oi(e.protocol,!0)}function Ui(e){return typeof e<"u"&&null!==typeof e}function ki(e,t){return!(!Pi(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...yi(e.accounts))})),t}(e).includes(t))}function ji(e,t,r){let i=null;const n=function(e){const t={};return Object.keys(e).forEach((r=>{var i;r.includes(":")?t[r]=e[r]:null==(i=e[r].chains)||i.forEach((i=>{t[i]={methods:e[r].methods,events:e[r].events}}))})),t}(e),s=function(e){const t={};return Object.keys(e).forEach((r=>{if(r.includes(":"))t[r]=e[r];else{const i=yi(e[r].accounts);i?.forEach((i=>{t[i]={accounts:e[r].accounts.filter((e=>e.includes(`${i}:`))),methods:e[r].methods,events:e[r].events}}))}})),t}(t),o=Object.keys(n),a=Object.keys(s),h=qi(Object.keys(e)),c=qi(Object.keys(t)),u=h.filter((e=>!c.includes(e)));return u.length&&(i=Ei("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${u.toString()}\n Received: ${Object.keys(t).toString()}`)),$r(o,a)||(i=Ei("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||i)return;const n=yi(t[e].accounts);n.includes(e)||(i=Ei("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${n.toString()}`))})),o.forEach((e=>{i||($r(n[e].methods,s[e].methods)?$r(n[e].events,s[e].events)||(i=Ei("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):i=Ei("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))})),i}function qi(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}function Di(e,t){return xi(e,!1)&&e<=t.max&&e>=t.min}function zi(){const e=Dr();return new Promise((t=>{switch(e){case Cr.browser:t(qr()&&navigator?.onLine);break;case Cr.reactNative:t(async function(){if(jr()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo){const e=await(null==r.g?void 0:r.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case Cr.node:default:t(!0)}}))}const $i={};class Ki{static get(e){return $i[e]}static set(e,t){$i[e]=t}static delete(e){delete $i[e]}}const Bi="INTERNAL_ERROR",Fi="SERVER_ERROR",Vi=[-32700,-32600,-32601,-32602,-32603],Hi={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[Bi]:{code:-32603,message:"Internal error"},[Fi]:{code:-32e3,message:"Server error"}},Wi=Fi;function Gi(e){return Object.keys(Hi).includes(e)?Hi[e]:Hi[Wi]}var Ji=r(1468);function Yi(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function Xi(e=6){return BigInt(Yi(e))}function Qi(e,t,r){return{id:r||Yi(),jsonrpc:"2.0",method:e,params:t}}function Zi(e,t){return{id:e,jsonrpc:"2.0",result:t}}function en(e,t,r){return{id:e,jsonrpc:"2.0",error:tn(t,r)}}function tn(e,t){return void 0===e?Gi(Bi):("string"==typeof e&&(e=Object.assign(Object.assign({},Gi(Fi)),{message:e})),void 0!==t&&(e.data=t),r=e.code,Vi.includes(r)&&(e=function(e){return Object.values(Hi).find((t=>t.code===e))||Hi[Wi]}(e.code)),e);var r}class rn{}class nn extends rn{constructor(){super()}}class sn extends nn{constructor(e){super()}}function on(e){return function(e,t){const r=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==r&&new RegExp(t).test(r)}(e,"^wss?:")}function an(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function hn(e){return an(e)&&"method"in e}function cn(e){return an(e)&&(un(e)||ln(e))}function un(e){return"result"in e}function ln(e){return"error"in e}class fn extends sn{constructor(e){super(e),this.events=new g.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}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 request(e,t){return this.requestStrict(Qi(e.method,e.params||[],e.id||Xi().toString()),t)}async requestStrict(e,t){return new Promise((async(r,i)=>{if(!this.connection.connected)try{await this.open()}catch(e){i(e)}this.events.on(`${e.id}`,(e=>{ln(e)?i(e.error):r(e.result)}));try{await this.connection.send(e,t)}catch(e){i(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),cn(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const dn=e=>e.split("?")[0],pn=typeof WebSocket<"u"?WebSocket:typeof r.g<"u"&&typeof r.g.WebSocket<"u"?r.g.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:r(7026);class gn{constructor(e){if(this.url=e,this.events=new g.EventEmitter,this.registering=!1,!on(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)=>{typeof this.socket>"u"?t(new Error("Connection already closed")):(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close())}))}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(z(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!on(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,i)=>{const n=new URLSearchParams(e).get("origin"),s=(0,Ji.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:(a=e,!new RegExp("wss?://localhost(:d{2,5})?").test(a))},o=new pn(e,[],s);var a;typeof WebSocket<"u"||typeof r.g<"u"&&typeof r.g.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u"?o.onerror=e=>{const t=e;i(this.emitError(t.error))}:o.on("error",(e=>{i(this.emitError(e))})),o.onopen=()=>{this.onOpen(o),t(o)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t="string"==typeof e.data?D(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),i=en(e,r.message||r.toString());this.events.emit("payload",i)}parseError(e,t=this.url){return function(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable WS RPC url at ${t}`):e}(e,dn(t))}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${dn(this.url)}`));return this.events.emit("register_error",t),t}}var yn=r(2307),mn=r.n(yn),vn=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var l=0,f=s-1;(0!==u||l>>0,o[f]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");n=l,t++}if(" "!==e[t]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,n=0,s=t.length;n!==s&&0===t[n];)n++,r++;for(var o=(s-n)*u+1>>>0,c=new Uint8Array(o);n!==s;){for(var l=t[n],f=0,d=o-1;(0!==l||f>>0,c[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===c[p];)p++;for(var g=h.repeat(r);p{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class bn{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class _n{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return Sn(this,e)}}class En{constructor(e){this.decoders=e}or(e){return Sn(this,e)}decode(e){const t=e[0],r=this.decoders[t];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 Sn=(e,t)=>new En({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class In{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new bn(e,t,r),this.decoder=new _n(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Mn=({name:e,prefix:t,encode:r,decode:i})=>new In(e,t,r,i),An=({prefix:e,name:t,alphabet:r})=>{const{encode:i,decode:n}=vn(r,t);return Mn({prefix:e,name:t,encode:i,decode:e=>wn(n(e))})},On=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>Mn({prefix:t,name:e,encode:e=>((e,t,r)=>{const i="="===t[t.length-1],n=(1<r;)o-=r,s+=t[n&a>>o];if(o&&(s+=t[n&a<((e,t,r,i)=>{const n={};for(let e=0;e=8&&(a-=8,o[c++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,r,e)}),xn=Mn({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var Pn=Object.freeze({__proto__:null,identity:xn});const Nn=On({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rn=Object.freeze({__proto__:null,base2:Nn});const Tn=On({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ln=Object.freeze({__proto__:null,base8:Tn});const Cn=An({prefix:"9",name:"base10",alphabet:"0123456789"});var Un=Object.freeze({__proto__:null,base10:Cn});const kn=On({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),jn=On({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qn=Object.freeze({__proto__:null,base16:kn,base16upper:jn});const Dn=On({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zn=On({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$n=On({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kn=On({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bn=On({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fn=On({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Vn=On({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hn=On({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wn=On({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gn=Object.freeze({__proto__:null,base32:Dn,base32upper:zn,base32pad:$n,base32padupper:Kn,base32hex:Bn,base32hexupper:Fn,base32hexpad:Vn,base32hexpadupper:Hn,base32z:Wn});const Jn=An({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yn=An({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xn=Object.freeze({__proto__:null,base36:Jn,base36upper:Yn});const Qn=An({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zn=An({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var es=Object.freeze({__proto__:null,base58btc:Qn,base58flickr:Zn});const ts=On({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),rs=On({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),is=On({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ns=On({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ss=Object.freeze({__proto__:null,base64:ts,base64pad:rs,base64url:is,base64urlpad:ns});const os=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),as=os.reduce(((e,t,r)=>(e[r]=t,e)),[]),hs=os.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]),cs=Mn({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+as[t]),"")},decode:function(e){const t=[];for(const r of e){const e=hs[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var us=Object.freeze({__proto__:null,base256emoji:cs}),ls=128,fs=-128,ds=Math.pow(2,31),ps=Math.pow(2,7),gs=Math.pow(2,14),ys=Math.pow(2,21),ms=Math.pow(2,28),vs=Math.pow(2,35),ws=Math.pow(2,42),bs=Math.pow(2,49),_s=Math.pow(2,56),Es=Math.pow(2,63),Ss=function e(t,r,i){r=r||[];for(var n=i=i||0;t>=ds;)r[i++]=255&t|ls,t/=128;for(;t&fs;)r[i++]=255&t|ls,t>>>=7;return r[i]=0|t,e.bytes=i-n+1,r},Is=function(e){return e(Ss(e,t,r),t),As=e=>Is(e),Os=(e,t)=>{const r=t.byteLength,i=As(e),n=i+As(r),s=new Uint8Array(n+r);return Ms(e,s,0),Ms(r,s,i),s.set(t,n),new xs(e,r,t,s)};class xs{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const Ps=({name:e,code:t,encode:r})=>new Ns(e,t,r);class Ns{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Os(this.code,t):t.then((e=>Os(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Rs=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Ts=Ps({name:"sha2-256",code:18,encode:Rs("SHA-256")}),Ls=Ps({name:"sha2-512",code:19,encode:Rs("SHA-512")});Object.freeze({__proto__:null,sha256:Ts,sha512:Ls});const Cs=wn,Us={code:0,name:"identity",encode:Cs,digest:e=>Os(0,Cs(e))};Object.freeze({__proto__:null,identity:Us}),new TextEncoder,new TextDecoder;const ks={...Pn,...Rn,...Ln,...Un,...qn,...Gn,...Xn,...es,...ss,...us};function js(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function qs(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}const Ds=qs("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),zs=qs("ascii","a",(e=>{let t="a";for(let r=0;r{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?js(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=Ei("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=(0,J.generateChildLogger)(t,this.name)}get context(){return(0,J.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Kr(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Br(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Mo{constructor(e,t,r){this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>(this.isInitialized(),Gt(Jt(await this.getClientSeed()).publicKey)),this.generateKeyPair=()=>{this.isInitialized();const e=function(){const e=Zt.Au();return{privateKey:Vt(e.secretKey,mr),publicKey:Vt(e.publicKey,mr)}}();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=Jt(await this.getClientSeed()),r=br(),i=Hs;return await async function(e,t,r,i,n=(0,ue.fromMiliseconds)(Date.now())){const s={alg:"EdDSA",typ:"JWT"},o={iss:Gt(i.publicKey),sub:e,aud:t,iat:n,exp:n+r},a=Ht([Wt((h={header:s,payload:o}).header),Wt(h.payload)].join("."),"utf8");var h;return function(e){return[Wt(e.header),Wt(e.payload),(t=e.signature,Vt(t,le))].join(".");var t}({header:s,payload:o,signature:he.Xx(i.secretKey,a)})}(r,e,i,t)},this.generateSharedKey=(e,t,r)=>{this.isInitialized();const i=function(e,t){const r=Zt.gi(Ht(e,mr),Ht(t,mr),!0);return Vt(new Xt.t(Qt.mE,r).expand(32),mr)}(this.getPrivateKey(e),t);return this.setSymKey(i,r)},this.setSymKey=async(e,t)=>{this.isInitialized();const r=t||_r(e);return await this.keychain.set(r,e),r},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,r)=>{this.isInitialized();const i=Mr(r),n=z(t);if(Ar(i)){const t=i.senderPublicKey,r=i.receiverPublicKey;e=await this.generateSharedKey(t,r)}const s=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return function(e){const t=function(e){return Ht(`${e}`,yr)}(typeof e.type<"u"?e.type:0);if(1===Sr(t)&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof e.senderPublicKey<"u"?Ht(e.senderPublicKey,mr):void 0,i=typeof e.iv<"u"?Ht(e.iv,mr):(0,ce.randomBytes)(12);return function(e){if(1===Sr(e.type)){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Vt(_e([e.type,e.senderPublicKey,e.iv,e.sealed]),vr)}return Vt(_e([e.type,e.iv,e.sealed]),vr)}({type:t,sealed:new Yt.OK(Ht(e.symKey,mr)).seal(i,Ht(e.message,wr)),iv:i,senderPublicKey:r})}({type:o,symKey:s,message:n,senderPublicKey:a})},this.decode=async(e,t,r)=>{this.isInitialized();const i=function(e,t){const r=Ir(e);return Mr({type:Sr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Vt(r.senderPublicKey,mr):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,r);if(Ar(i)){const t=i.receiverPublicKey,r=i.senderPublicKey;e=await this.generateSharedKey(t,r)}try{const r=function(e){const t=new Yt.OK(Ht(e.symKey,mr)),{sealed:r,iv:i}=Ir(e.encoded),n=t.open(i,r);if(null===n)throw new Error("Failed to decrypt");return Vt(n,wr)}({symKey:this.getSymKey(e),encoded:t});return D(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}},this.getPayloadType=e=>Sr(Ir(e).type),this.getPayloadSenderPublicKey=e=>{const t=Ir(e);return t.senderPublicKey?Vt(t.senderPublicKey,mr):void 0},this.core=e,this.logger=(0,J.generateChildLogger)(t,this.name),this.keychain=r||new Io(this.core,this.logger)}get context(){return(0,J.getLoggerContext)(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(Vs)}catch{e=br(),await this.keychain.set(Vs,e)}return function(e,t="utf8"){const r=$s[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):js(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Ao extends Z{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const r=Er(t);let i=this.messages.get(e);return typeof i>"u"&&(i={}),typeof i[r]<"u"||(i[r]=t,this.messages.set(e,i),await this.persist()),r},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>(this.isInitialized(),typeof this.get(e)[Er(t)]<"u"),this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=(0,J.generateChildLogger)(e,this.name),this.core=t}get context(){return(0,J.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Kr(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Br(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Oo extends ee{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new g.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,ue.toMiliseconds)(ue.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,r)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});try{const n=r?.ttl||Ws,s=Qr(r),o=r?.prompt||!1,a=r?.tag||0,h=r?.id||Xi().toString(),c={topic:e,message:t,opts:{ttl:n,relay:s,prompt:o,tag:a,id:h}},u=setTimeout((()=>this.queue.set(h,c)),this.publishTimeout);try{await await Vr(this.rpcPublish(e,t,n,s,o,a,h),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(h),this.relayer.events.emit(to,c)}catch(e){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,null!=(i=r?.internal)&&i.throwOnFailedPublish)throw this.removeRequestFromQueue(h),e;return}finally{clearTimeout(u)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=e,this.logger=(0,J.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return(0,J.getLoggerContext)(this.logger)}rpcPublish(e,t,r,i,n,s,o){var a,h,c,u;const l={method:Zr(i.protocol).publish,params:{topic:e,message:t,ttl:r,prompt:n,tag:s},id:o};return Ai(null==(a=l.params)?void 0:a.prompt)&&(null==(h=l.params)||delete h.prompt),Ai(null==(c=l.params)?void 0:c.tag)&&(null==(u=l.params)||delete u.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:r,opts:i}=e;await this.publish(t,r,i)}))}registerEventListeners(){this.relayer.core.heartbeat.on(G.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(eo);this.checkQueue()})),this.relayer.on(Xs,(e=>{this.removeRequestFromQueue(e.id.toString())}))}}class xo{constructor(){this.map=new Map,this.set=(e,t)=>{const r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,t))return;const i=r.filter((e=>e!==t));i.length?this.map.set(e,i):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Po=Object.defineProperty,No=Object.defineProperties,Ro=Object.getOwnPropertyDescriptors,To=Object.getOwnPropertySymbols,Lo=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable,Uo=(e,t,r)=>t in e?Po(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ko=(e,t)=>{for(var r in t||(t={}))Lo.call(t,r)&&Uo(e,r,t[r]);if(To)for(var r of To(t))Co.call(t,r)&&Uo(e,r,t[r]);return e},jo=(e,t)=>No(e,Ro(t));class qo extends ie{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new xo,this.events=new g.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Bs,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const r=Qr(t),i={topic:e,relay:r};this.pending.set(e,i);const n=await this.rpcSubscribe(e,r);return this.onSubscribe(n,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),n}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,r)=>{const i=new ue.Watch;i.start(this.pendingSubscriptionWatchLabel);const n=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(n),i.stop(this.pendingSubscriptionWatchLabel),t(!0)),i.elapsed(this.pendingSubscriptionWatchLabel)>=uo&&(clearInterval(n),i.stop(this.pendingSubscriptionWatchLabel),r(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=(0,J.generateChildLogger)(t,this.name),this.clientId=""}get context(){return(0,J.getLoggerContext)(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}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const r=this.topicMap.get(e);await Promise.all(r.map((async r=>await this.unsubscribeById(e,r,t))))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{const i=Qr(r);await this.rpcUnsubscribe(e,t,i);const n=Si("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:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const r={method:Zr(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await Vr(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(eo)}return Er(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:Zr(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await Vr(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(eo)}}rpcUnsubscribe(e,t,r){const i={method:Zr(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,jo(ko({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,ko({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),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.subscriptions.has(e)||(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,ko({},t)),this.topicMap.set(t.topic,e),this.events.emit(ao,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:t}=Ei("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(ho,jo(ko({},r),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=Ei("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}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){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);Ii(t)&&this.onBatchSubscribe(t.map(((t,r)=>jo(ko({},e[r]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(G.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(Qs,(async()=>{await this.onConnect()})),this.relayer.on(Zs,(()=>{this.onDisconnect()})),this.events.on(ao,(async e=>{const t=ao;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(ho,(async e=>{const t=ho;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var Do=Object.defineProperty,zo=Object.getOwnPropertySymbols,$o=Object.prototype.hasOwnProperty,Ko=Object.prototype.propertyIsEnumerable,Bo=(e,t,r)=>t in e?Do(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class Fo extends te{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new g.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.onPayloadHandler=e=>{this.onProviderPayload(e)},this.onConnectHandler=()=>{this.events.emit(Qs)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=e=>{this.logger.error(e),this.events.emit("relayer_error",e),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(ro,this.onPayloadHandler),this.provider.on(io,this.onConnectHandler),this.provider.on(no,this.onDisconnectHandler),this.provider.on(so,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,J.generateChildLogger)(e.logger,this.name):(0,J.pino)((0,J.getDefaultLoggerOptions)({level:e.logger||"error"})),this.messages=new Ao(this.logger,e.core),this.subscriber=new qo(this,this.logger),this.publisher=new Oo(this,this.logger),this.relayUrl=e?.relayUrl||Gs,this.projectId=e.projectId,this.bundleId=function(){var e;try{return jr()&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Application)<"u"?null==(e=r.g.Application)?void 0:e.applicationId:void 0}catch{return}}(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Js}...`),await this.restartTransport(Js)}this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),1e4)}get context(){return(0,J.getLoggerContext)(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var r;this.isInitialized();let i,n=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";if(n)return n;const s=t=>{t.topic===e&&(this.subscriber.off(ao,s),i())};return await Promise.all([new Promise((e=>{i=e,this.subscriber.on(ao,s)})),new Promise((async r=>{n=await this.subscriber.subscribe(e,t),r()}))]),n}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 transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await Vr(this.provider.disconnect(),1e3,"provider.disconnect()").catch((()=>this.onProviderDisconnect())):this.connected&&await this.provider.disconnect()}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise((e=>{if(!this.initialized)return e();this.subscriber.once(co,(()=>{e()}))})),new Promise((async(e,t)=>{try{await Vr(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(e){return void t(e)}e()}))])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.provider.events.emit(no)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await zi())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new fn(new gn(function({protocol:e,version:t,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){const h=r.split("?"),c={auth:n,ua:zr(e,t,i),projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},u=function(e,t){let r=dr.parse(e);return r=Tr(Tr({},r),t),dr.stringify(r)}(h[1]||"",c);return h[0]+"?"+u}({sdkVersion:"2.10.5",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:r}=e;await this.messages.set(t,r)}async shouldIgnoreMessageEvent(e){const{topic:t,message:r}=e;if(!r||0===r.length)return this.logger.debug(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const i=this.messages.has(t,r);return i&&this.logger.debug(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),hn(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:r,message:i,publishedAt:n}=t.data,s={topic:r,message:i,publishedAt:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((e,t)=>{for(var r in t||(t={}))$o.call(t,r)&&Bo(e,r,t[r]);if(zo)for(var r of zo(t))Ko.call(t,r)&&Bo(e,r,t[r]);return e})({type:"event",event:t.id},s)),this.events.emit(t.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}else cn(e)&&this.events.emit(Xs,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ys,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Zi(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(ro,this.onPayloadHandler),this.provider.off(io,this.onConnectHandler),this.provider.off(no,this.onDisconnectHandler),this.provider.off(so,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(eo,(()=>{this.restartTransport().catch((e=>this.logger.error(e)))}));let e=await zi();!function(e){switch(Dr()){case Cr.browser:!function(e){!jr()&&qr()&&(window.addEventListener("online",(()=>e(!0))),window.addEventListener("offline",(()=>e(!1))))}(e);break;case Cr.reactNative:!function(e){jr()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo&&r.g?.NetInfo.addEventListener((t=>e(t?.isConnected)))}(e);case Cr.node:}}((async t=>{this.initialized&&e!==t&&(e=t,t?await this.restartTransport().catch((e=>this.logger.error(e))):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch((e=>this.logger.error(e)))))}))}onProviderDisconnect(){this.events.emit(Zs),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout((async()=>{await this.restartTransport().catch((e=>this.logger.error(e)))}),(0,ue.toMiliseconds)(oo)))}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var Vo=Object.defineProperty,Ho=Object.getOwnPropertySymbols,Wo=Object.prototype.hasOwnProperty,Go=Object.prototype.propertyIsEnumerable,Jo=(e,t,r)=>t in e?Vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yo=(e,t)=>{for(var r in t||(t={}))Wo.call(t,r)&&Jo(e,r,t[r]);if(Ho)for(var r of Ho(t))Go.call(t,r)&&Jo(e,r,t[r]);return e};class Xo extends re{constructor(e,t,r,i=Bs,n=void 0){super(e,t,r,i),this.core=e,this.logger=t,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!Ai(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return e?.topic}(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((r=>mn()(t[r],e[r]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const r=Yo(Yo({},this.getData(e)),t);this.map.set(e,r),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=(0,J.generateChildLogger)(t,this.name),this.storagePrefix=i,this.getKey=n}get context(){return(0,J.getLoggerContext)(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())}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){const{message:t}=Ei("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}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:e}=Ei("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Qo{constructor(e,t){this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new(y()),this.initialized=!1,this.storagePrefix=Bs,this.ignoredPayloadTypes=[1],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=br(),t=await this.core.crypto.setSymKey(e),r=Gr(ue.FIVE_MINUTES),i={protocol:"irn"},n={topic:t,expiry:r,relay:i,active:!1},s=function(e){return`${e.protocol}:${e.topic}@${e.version}?`+dr.stringify(((e,t)=>{for(var r in t||(t={}))ri.call(t,r)&&ni(e,r,t[r]);if(ti)for(var r of ti(t))ii.call(t,r)&&ni(e,r,t[r]);return e})({symKey:e.symKey},function(e,t="-"){const r={};return Object.keys(e).forEach((i=>{const n="relay"+t+i;e[i]&&(r[n]=e[i])})),r}(e.relay)))}({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:i});return await this.pairings.set(t,n),await this.core.relayer.subscribe(t),this.core.expirer.set(t,r),{topic:t,uri:s}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:r,relay:i}=function(e){const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),r=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),n=e.substring(t+1,r).split("@"),s=typeof r<"u"?e.substring(r):"",o=dr.parse(s);return{protocol:i,topic:oi(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:si(o)}}(e.uri);let n;if(this.pairings.keys.includes(t)&&(n=this.pairings.get(t),n.active))throw new Error(`Pairing already exists: ${t}. Please try again with a new connection URI.`);this.core.crypto.keychain.has(t)||(await this.core.crypto.setSymKey(r,t),await this.core.relayer.subscribe(t,{relay:i}));const s=Gr(ue.FIVE_MINUTES),o={topic:t,relay:i,expiry:s,active:!1};return await this.pairings.set(t,o),this.core.expirer.set(t,s),e.activatePairing&&await this.activate({topic:t}),this.events.emit(fo,o),o},this.activate=async({topic:e})=>{this.isInitialized();const t=Gr(ue.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:i,reject:n}=Fr();this.events.once(Yr("pairing_ping",e),(({error:e})=>{e?n(e):i()})),await r()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",Si("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,r)=>{const i=Qi(t,r),n=await this.core.crypto.encode(e,i),s=lo[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,n,s),i.id},this.sendResult=async(e,t,r)=>{const i=Zi(e,r),n=await this.core.crypto.encode(t,i),s=await this.core.history.get(t,e),o=lo[s.request.method].res;await this.core.relayer.publish(t,n,o),await this.core.history.resolve(i)},this.sendError=async(e,t,r)=>{const i=en(e,r),n=await this.core.crypto.encode(t,i),s=await this.core.history.get(t,e),o=lo[s.request.method]?lo[s.request.method].res:lo.unregistered_method.res;await this.core.relayer.publish(t,n,o),await this.core.history.resolve(i)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,Si("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>Jr(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(t,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,r);default:return this.onUnknownRpcMethodRequest(t,r)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,i=(await this.core.history.get(t,r.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,r):this.onUnknownRpcMethodResponse(i)},this.onPairingPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit("pairing_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onPairingPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{un(t)?this.events.emit(Yr("pairing_ping",r),{}):ln(t)&&this.events.emit(Yr("pairing_ping",r),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:r,method:i}=t;try{if(this.registeredMethods.includes(i))return;const t=Si("WC_METHOD_UNSUPPORTED",i);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error(Si("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!Ni(e.uri)){const{message:t}=Ei("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!Oi(e,!1)){const{message:t}=Ei("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=Ei("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Jr(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=Ei("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=(0,J.generateChildLogger)(t,this.name),this.pairings=new Xo(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,J.getLoggerContext)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ys,(async e=>{const{topic:t,message:r}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const i=await this.core.crypto.decode(t,r);try{hn(i)?(this.core.history.set(t,i),this.onRelayEventRequest({topic:t,payload:i})):cn(i)&&(await this.core.history.resolve(i),await this.onRelayEventResponse({topic:t,payload:i}),this.core.history.delete(t,i.id))}catch(e){this.logger.error(e)}}))}registerExpirerEvents(){this.core.expirer.on(wo,(async e=>{const{topic:t}=Wr(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class Zo extends Q{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new g.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;const i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:Gr(ue.THIRTY_DAYS)};this.records.set(i.id,i),this.events.emit(po,i)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=ln(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(go,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((r=>{if(r.topic===e){if(typeof t<"u"&&r.id!==t)return;this.records.delete(r.id),this.events.emit(yo,r)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=(0,J.generateChildLogger)(t,this.name)}get context(){return(0,J.getLoggerContext)(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 r={topic:t.topic,request:Qi(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)})),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:t}=Ei("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=Ei("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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(po,(e=>{const t=po;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(go,(e=>{const t=go;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(yo,(e=>{const t=yo;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(G.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{(0,ue.toMiliseconds)(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))}))}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}}class ea extends ne{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new g.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const r=this.formatTarget(e),i={target:r,expiry:t};this.expirations.set(r,i),this.checkExpiry(r,i),this.events.emit(mo,{target:r,expiration:i})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(vo,{target:t,expiration:r})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=(0,J.generateChildLogger)(t,this.name)}get context(){return(0,J.getLoggerContext)(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("string"==typeof e)return function(e){return Hr("topic",e)}(e);if("number"==typeof e)return function(e){return Hr("id",e)}(e);const{message:t}=Ei("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("expirer_sync")}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=Ei("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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:t}=Ei("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:r}=t;(0,ue.toMiliseconds)(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(wo,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(G.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(mo,(e=>{const t=mo;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(wo,(e=>{const t=wo;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(vo,(e=>{const t=vo;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}}class ta extends se{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=bo,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async e=>{if(this.verifyDisabled||jr()||!qr())return;const t=this.getVerifyUrl(e?.verifyUrl);this.verifyUrl!==t&&this.removeIframe(),this.verifyUrl=t;try{await this.createIframe()}catch(e){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(e)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Eo;try{await this.createIframe()}catch(e){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(e),this.verifyDisabled=!0}}},this.register=async e=>{this.initialized?this.sendPost(e.attestationId):(this.addToQueue(e.attestationId),await this.init())},this.resolve=async e=>{if(this.isDevEnv)return"";const t=this.getVerifyUrl(e?.verifyUrl);let r;try{r=await this.fetchAttestation(e.attestationId,t)}catch(i){this.logger.info(`failed to resolve attestation: ${e.attestationId} from url: ${t}`),this.logger.info(i),r=await this.fetchAttestation(e.attestationId,Eo)}return r},this.fetchAttestation=async(e,t)=>{this.logger.info(`resolving attestation: ${e} from url: ${t}`);const r=this.startAbortTimer(2*ue.ONE_SECOND),i=await fetch(`${t}/attestation/${e}`,{signal:this.abortController.signal});return clearTimeout(r),200===i.status?await i.json():void 0},this.addToQueue=e=>{this.queue.push(e)},this.processQueue=()=>{0!==this.queue.length&&(this.queue.forEach((e=>this.sendPost(e))),this.queue=[])},this.sendPost=e=>{var t;try{if(!this.iframe)return;null==(t=this.iframe.contentWindow)||t.postMessage(e,"*"),this.logger.info(`postMessage sent: ${e} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let e;const t=r=>{"verify_ready"===r.data&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",t),e())};await Promise.race([new Promise((r=>{if(document.getElementById(bo))return r();window.addEventListener("message",t);const i=document.createElement("iframe");i.id=bo,i.src=`${this.verifyUrl}/${this.projectId}`,i.style.display="none",document.body.append(i),this.iframe=i,e=r})),new Promise(((e,r)=>setTimeout((()=>{window.removeEventListener("message",t),r("verify iframe load timeout")}),(0,ue.toMiliseconds)(ue.FIVE_SECONDS))))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=e=>{let t=e||_o;return So.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${_o}`),t=_o),t},this.logger=(0,J.generateChildLogger)(t,this.name),this.verifyUrl=_o,this.abortController=new AbortController,this.isDevEnv=kr()&&process.env.IS_VITEST}get context(){return(0,J.getLoggerContext)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout((()=>this.abortController.abort()),(0,ue.toMiliseconds)(e))}}var ra=Object.defineProperty,ia=Object.getOwnPropertySymbols,na=Object.prototype.hasOwnProperty,sa=Object.prototype.propertyIsEnumerable,oa=(e,t,r)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,aa=(e,t)=>{for(var r in t||(t={}))na.call(t,r)&&oa(e,r,t[r]);if(ia)for(var r of ia(t))sa.call(t,r)&&oa(e,r,t[r]);return e};class ha extends X{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=Ks,this.events=new g.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Gs,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,J.pino)((0,J.getDefaultLoggerOptions)({level:e?.logger||"error"}));this.logger=(0,J.generateChildLogger)(t,this.name),this.heartbeat=new G.HeartBeat,this.crypto=new Mo(this,this.logger,e?.keychain),this.history=new Zo(this,this.logger),this.expirer=new ea(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new W(aa(aa({},Fs),e?.storageOptions)),this.relayer=new Fo({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Qo(this,this.logger),this.verify=new ta(this.projectId||"",this.logger)}static async init(e){const t=new ha(e);await t.initialize();const r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return(0,J.getLoggerContext)(this.logger)}async start(){this.initialized||await this.initialize()}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.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const ca=ha;let ua=!1,la=!1;const fa={debug:1,default:2,info:2,warning:3,error:4,off:5};let da=fa.default,pa=null;const ga=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var ya,ma;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(ya||(ya={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(ma||(ma={}));const va="0123456789abcdef";class wa{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==fa[r]&&this.throwArgumentError("invalid log level name","logLevel",e),da>fa[r]||console.log.apply(console,t)}debug(...e){this._log(wa.levels.DEBUG,e)}info(...e){this._log(wa.levels.INFO,e)}warn(...e){this._log(wa.levels.WARNING,e)}makeError(e,t,r){if(la)return this.makeError("censored error",t,{});t||(t=wa.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((e=>{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e>4],r+=va[15&t[e]];i.push(e+"=Uint8Array(0x"+r+")")}else i.push(e+"="+JSON.stringify(t))}catch(t){i.push(e+"="+JSON.stringify(r[e].toString()))}})),i.push(`code=${t}`),i.push(`version=${this.version}`);const n=e;let s="";switch(t){case ma.NUMERIC_FAULT:{s="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":s+="-"+t;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case ma.CALL_EXCEPTION:case ma.INSUFFICIENT_FUNDS:case ma.MISSING_NEW:case ma.NONCE_EXPIRED:case ma.REPLACEMENT_UNDERPRICED:case ma.TRANSACTION_REPLACED:case ma.UNPREDICTABLE_GAS_LIMIT:s=t}s&&(e+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(e+=" ("+i.join(", ")+")");const o=new Error(e);return o.reason=n,o.code=t,Object.keys(r).forEach((function(e){o[e]=r[e]})),o}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,wa.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,i){e||this.throwError(t,r,i)}assertArgument(e,t,r,i){e||this.throwArgumentError(t,r,i)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),ga&&this.throwError("platform missing String.prototype.normalize",wa.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ga})}checkSafeUint53(e,t){"number"==typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,wa.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,wa.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",et&&this.throwError("too many arguments"+r,wa.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",wa.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",wa.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",wa.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return pa||(pa=new wa("logger/5.7.0")),pa}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",wa.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),ua){if(!e)return;this.globalLogger().throwError("error censorship permanent",wa.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}la=!!e,ua=!!t}static setLogLevel(e){const t=fa[e.toLowerCase()];null!=t?da=t:wa.globalLogger().warn("invalid log level - "+e)}static from(e){return new wa(e)}}wa.errors=ma,wa.levels=ya;const ba=new wa("bytes/5.7.0");function _a(e){return!!e.toHexString}function Ea(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return Ea(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function Sa(e){return"number"==typeof e&&e==e&&e%1==0}function Ia(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(!Sa(e.length)||e.length<0)return!1;for(let t=0;t=256)return!1}return!0}function Ma(e,t){if(t||(t={}),"number"==typeof e){ba.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),Ea(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),_a(e)&&(e=e.toHexString()),Aa(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0"+r:"right"===t.hexPad?r+="0":ba.throwArgumentError("hex data is odd-length","value",e));const i=[];for(let e=0;e>4]+Oa[15&i]}return t}return ba.throwArgumentError("invalid hexlify value","value",e)}function Pa(e,t,r){return"string"!=typeof e?e=xa(e):(!Aa(e)||e.length%2)&&ba.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=r?"0x"+e.substring(t,2+2*r):"0x"+e.substring(t)}function Na(e,t){for("string"!=typeof e?e=xa(e):Aa(e)||ba.throwArgumentError("invalid hex string","value",e),e.length>2*t+2&&ba.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function Ra(e){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Aa(r=e)&&!(r.length%2)||Ia(r)){let r=Ma(e);64===r.length?(t.v=27+(r[32]>>7),r[32]&=127,t.r=xa(r.slice(0,32)),t.s=xa(r.slice(32,64))):65===r.length?(t.r=xa(r.slice(0,32)),t.s=xa(r.slice(32,64)),t.v=r[64]):ba.throwArgumentError("invalid signature string","signature",e),t.v<27&&(0===t.v||1===t.v?t.v+=27:ba.throwArgumentError("signature invalid v byte","signature",e)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(r[32]|=128),t._vs=xa(r.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t._vs){const r=function(e,t){(e=Ma(e)).length>t&&ba.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(t);return r.set(e,t-e.length),Ea(r)}(Ma(t._vs),32);t._vs=xa(r);const i=r[0]>=128?1:0;null==t.recoveryParam?t.recoveryParam=i:t.recoveryParam!==i&&ba.throwArgumentError("signature recoveryParam mismatch _vs","signature",e),r[0]&=127;const n=xa(r);null==t.s?t.s=n:t.s!==n&&ba.throwArgumentError("signature v mismatch _vs","signature",e)}if(null==t.recoveryParam)null==t.v?ba.throwArgumentError("signature missing v and recoveryParam","signature",e):0===t.v||1===t.v?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(null==t.v)t.v=27+t.recoveryParam;else{const r=0===t.v||1===t.v?t.v:1-t.v%2;t.recoveryParam!==r&&ba.throwArgumentError("signature recoveryParam mismatch v","signature",e)}null!=t.r&&Aa(t.r)?t.r=Na(t.r,32):ba.throwArgumentError("signature missing or invalid r","signature",e),null!=t.s&&Aa(t.s)?t.s=Na(t.s,32):ba.throwArgumentError("signature missing or invalid s","signature",e);const r=Ma(t.s);r[0]>=128&&ba.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(r[0]|=128);const i=xa(r);t._vs&&(Aa(t._vs)||ba.throwArgumentError("signature invalid _vs","signature",e),t._vs=Na(t._vs,32)),null==t._vs?t._vs=i:t._vs!==i&&ba.throwArgumentError("signature _vs mismatch v and s","signature",e)}var r;return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}var Ta=r(1094),La=r.n(Ta);function Ca(e){return"0x"+La().keccak_256(Ma(e))}const Ua=new wa("strings/5.7.0");var ka,ja;function qa(e,t,r,i,n){if(e===ja.BAD_PREFIX||e===ja.UNEXPECTED_CONTINUE){let e=0;for(let i=t+1;i>6==2;i++)e++;return e}return e===ja.OVERRUN?r.length-t-1:0}function Da(e,t=ka.current){t!=ka.current&&(Ua.checkNormalize(),e=e.normalize(t));let r=[];for(let t=0;t>6|192),r.push(63&i|128);else if(55296==(64512&i)){t++;const n=e.charCodeAt(t);if(t>=e.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const s=65536+((1023&i)<<10)+(1023&n);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return Ma(r)}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(ka||(ka={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(ja||(ja={})),Object.freeze({error:function(e,t,r,i,n){return Ua.throwArgumentError(`invalid codepoint at offset ${t}; ${e}`,"bytes",r)},ignore:qa,replace:function(e,t,r,i,n){return e===ja.OVERLONG?(i.push(n),0):(i.push(65533),qa(e,t,r))}});const za="Ethereum Signed Message:\n";function $a(e){return"string"==typeof e&&(e=Da(e)),Ca(function(e){const t=e.map((e=>Ma(e))),r=t.reduce(((e,t)=>e+t.length),0),i=new Uint8Array(r);return t.reduce(((e,t)=>(i.set(t,e),e+t.length)),0),Ea(i)}([Da(za),Da(String(e.length)),e]))}var Ka=r(3550),Ba=r.n(Ka),Fa=Ba().BN;new wa("bignumber/5.7.0");const Va=new wa("address/5.7.0");function Ha(e){Aa(e,20)||Va.throwArgumentError("invalid address","address",e);const t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let e=0;e<40;e++)r[e]=t[e].charCodeAt(0);const i=Ma(Ca(r));for(let e=0;e<40;e+=2)i[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(15&i[e>>1])>=8&&(t[e+1]=t[e+1].toUpperCase());return"0x"+t.join("")}const Wa={};for(let e=0;e<10;e++)Wa[String(e)]=String(e);for(let e=0;e<26;e++)Wa[String.fromCharCode(65+e)]=String(10+e);const Ga=Math.floor((Ja=9007199254740991,Math.log10?Math.log10(Ja):Math.log(Ja)/Math.LN10));var Ja;function Ya(e){let t=null;if("string"!=typeof e&&Va.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=Ha(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&Va.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==function(e){let t=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((e=>Wa[e])).join("");for(;t.length>=Ga;){let e=t.substring(0,Ga);t=parseInt(e,10)%97+t.substring(e.length)}let r=String(98-parseInt(t,10)%97);for(;r.length<2;)r="0"+r;return r}(e)&&Va.throwArgumentError("bad icap checksum","address",e),r=e.substring(4),t=new Fa(r,36).toString(16);t.length<40;)t="0"+t;t=Ha("0x"+t)}else Va.throwArgumentError("invalid address","address",e);var r;return t}var Xa=r(3715),Qa=r.n(Xa);function Za(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},r.exports),r.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self&&self;var eh=th;function th(e,t){if(!e)throw new Error(t||"Assertion failed")}th.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)};var rh=Za((function(e,t){var r=t;function i(e){return 1===e.length?"0"+e:e}function n(e){for(var t="",r=0;r>8,o=255&n;s?r.push(s,o):r.push(o)}return r},r.zero2=i,r.toHex=n,r.encode=function(e,t){return"hex"===t?n(e):e}})),ih=Za((function(e,t){var r=t;r.assert=eh,r.toArray=rh.toArray,r.zero2=rh.zero2,r.toHex=rh.toHex,r.encode=rh.encode,r.getNAF=function(e,t,r){var i=new Array(Math.max(e.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},r.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var i,n=0,s=0;e.cmpn(-n)>0||t.cmpn(-s)>0;){var o,a,h=e.andln(3)+n&3,c=t.andln(3)+s&3;3===h&&(h=-1),3===c&&(c=-1),o=0==(1&h)?0:3!=(i=e.andln(7)+n&7)&&5!==i||2!==c?h:-h,r[0].push(o),a=0==(1&c)?0:3!=(i=t.andln(7)+s&7)&&5!==i||2!==h?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new(Ba())(e,"hex","le")}})),nh=ih.getNAF,sh=ih.getJSF,oh=ih.assert;function ah(e,t){this.type=e,this.p=new(Ba())(t.p,16),this.red=t.prime?Ba().red(t.prime):Ba().mont(this.p),this.zero=new(Ba())(0).toRed(this.red),this.one=new(Ba())(1).toRed(this.red),this.two=new(Ba())(2).toRed(this.red),this.n=t.n&&new(Ba())(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var hh=ah;function ch(e,t){this.curve=e,this.type=t,this.precomputed=null}ah.prototype.point=function(){throw new Error("Not implemented")},ah.prototype.validate=function(){throw new Error("Not implemented")},ah.prototype._fixedNafMul=function(e,t){oh(e.precomputed);var r=e._getDoubles(),i=nh(t,1,this._bitLength),n=(1<=s;h--)o=(o<<1)+i[h];a.push(o)}for(var c=this.jpoint(null,null,null),u=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var h=0;a>=0&&0===s[a];a--)h++;if(a>=0&&h++,o=o.dblp(h),a<0)break;var c=s[a];oh(0!==c),o="affine"===e.type?c>0?o.mixedAdd(n[c-1>>1]):o.mixedAdd(n[-c-1>>1].neg()):c>0?o.add(n[c-1>>1]):o.add(n[-c-1>>1].neg())}return"affine"===e.type?o.toP():o},ah.prototype._wnafMulAdd=function(e,t,r,i,n){var s,o,a,h=this._wnafT1,c=this._wnafT2,u=this._wnafT3,l=0;for(s=0;s=1;s-=2){var d=s-1,p=s;if(1===h[d]&&1===h[p]){var g=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(g[1]=t[d].add(t[p]),g[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(g[1]=t[d].toJ().mixedAdd(t[p]),g[2]=t[d].add(t[p].neg())):(g[1]=t[d].toJ().mixedAdd(t[p]),g[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=sh(r[d],r[p]);for(l=Math.max(m[0].length,l),u[d]=new Array(l),u[p]=new Array(l),o=0;o=0;s--){for(var E=0;s>=0;){var S=!0;for(o=0;o=0&&E++,b=b.dblp(E),s<0)break;for(o=0;o0?a=c[o][I-1>>1]:I<0&&(a=c[o][-I-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(s=0;s=Math.ceil((e.bitLength()+1)/t.step)},ch.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n=0&&(s=t,o=r),i.negative&&(i=i.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:n},{a:s,b:o}]},fh.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),s=r.b.neg().mul(e).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),h=n.mul(r.b),c=s.mul(i.b);return{k1:e.sub(o).sub(a),k2:h.add(c).neg()}},fh.prototype.pointFromX=function(e,t){(e=new(Ba())(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(t&&!n||!t&&n)&&(i=i.redNeg()),this.point(e,i)},fh.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},fh.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},ph.prototype.isInfinity=function(){return this.inf},ph.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},ph.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},ph.prototype.getX=function(){return this.x.fromRed()},ph.prototype.getY=function(){return this.y.fromRed()},ph.prototype.mul=function(e){return e=new(Ba())(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},ph.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},ph.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},ph.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},ph.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},ph.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},uh(gh,hh.BasePoint),fh.prototype.jpoint=function(e,t,r){return new gh(this,e,t,r)},gh.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},gh.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},gh.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),s=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(r.redMul(this.z)),a=i.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),u=c.redMul(a),l=i.redMul(c),f=h.redSqr().redIAdd(u).redISub(l).redISub(l),d=h.redMul(l.redISub(f)).redISub(s.redMul(u)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(f,d,p)},gh.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,s=e.y.redMul(t).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),c=h.redMul(o),u=r.redMul(h),l=a.redSqr().redIAdd(c).redISub(u).redISub(u),f=a.redMul(u.redISub(l)).redISub(n.redMul(c)),d=this.z.redMul(o);return this.curve.jpoint(l,f,d)},gh.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},gh.prototype.inspect=function(){return this.isInfinity()?"":""},gh.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var yh=Za((function(e,t){var r=t;r.base=hh,r.short=dh,r.mont=null,r.edwards=null})),mh=Za((function(e,t){var r,i=t,n=ih.assert;function s(e){"short"===e.type?this.curve=new yh.short(e):"edwards"===e.type?this.curve=new yh.edwards(e):this.curve=new yh.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new s(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Qa().sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Qa().sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Qa().sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Qa().sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Qa().sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Qa().sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Qa().sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(e){r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Qa().sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function vh(e){if(!(this instanceof vh))return new vh(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=rh.toArray(e.entropy,e.entropyEnc||"hex"),r=rh.toArray(e.nonce,e.nonceEnc||"hex"),i=rh.toArray(e.pers,e.persEnc||"hex");eh(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}var wh=vh;vh.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},vh.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=rh.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length"};var Sh=ih.assert;function Ih(e,t){if(e instanceof Ih)return e;this._importDER(e,t)||(Sh(e.r&&e.s,"Signature without r or s"),this.r=new(Ba())(e.r,16),this.s=new(Ba())(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Mh=Ih;function Ah(){this.place=0}function Oh(e,t){var r=e[t.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=t.place;s>>=0;return!(n<=127)&&(t.place=o,n)}function xh(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Ih.prototype._importDER=function(e,t){e=ih.toArray(e,t);var r=new Ah;if(48!==e[r.place++])return!1;var i=Oh(e,r);if(!1===i)return!1;if(i+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Oh(e,r);if(!1===n)return!1;var s=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Oh(e,r);if(!1===o)return!1;if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new(Ba())(s),this.s=new(Ba())(a),this.recoveryParam=null,!0},Ih.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=xh(t),r=xh(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];Ph(i,t.length),(i=i.concat(t)).push(2),Ph(i,r.length);var n=i.concat(r),s=[48];return Ph(s,n.length),s=s.concat(n),ih.encode(s,e)};var Nh=function(){throw new Error("unsupported")},Rh=ih.assert;function Th(e){if(!(this instanceof Th))return new Th(e);"string"==typeof e&&(Rh(Object.prototype.hasOwnProperty.call(mh,e),"Unknown curve "+e),e=mh[e]),e instanceof mh.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var Lh=Th;Th.prototype.keyPair=function(e){return new Eh(this,e)},Th.prototype.keyFromPrivate=function(e,t){return Eh.fromPrivate(this,e,t)},Th.prototype.keyFromPublic=function(e,t){return Eh.fromPublic(this,e,t)},Th.prototype.genKeyPair=function(e){e||(e={});for(var t=new wh({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Nh(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new(Ba())(2));;){var n=new(Ba())(t.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Th.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},Th.prototype.sign=function(e,t,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new(Ba())(e,16));for(var n=this.n.byteLength(),s=t.getPrivate().toArray("be",n),o=e.toArray("be",n),a=new wh({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),h=this.n.sub(new(Ba())(1)),c=0;;c++){var u=i.k?i.k(c):new(Ba())(a.generate(this.n.byteLength()));if(!((u=this._truncateToN(u,!0)).cmpn(1)<=0||u.cmp(h)>=0)){var l=this.g.mul(u);if(!l.isInfinity()){var f=l.getX(),d=f.umod(this.n);if(0!==d.cmpn(0)){var p=u.invm(this.n).mul(d.mul(t.getPrivate()).iadd(e));if(0!==(p=p.umod(this.n)).cmpn(0)){var g=(l.getY().isOdd()?1:0)|(0!==f.cmp(d)?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),g^=1),new Mh({r:d,s:p,recoveryParam:g})}}}}}},Th.prototype.verify=function(e,t,r,i){e=this._truncateToN(new(Ba())(e,16)),r=this.keyFromPublic(r,i);var n=(t=new Mh(t,"hex")).r,s=t.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),h=a.mul(e).umod(this.n),c=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,r.getPublic(),c)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,r.getPublic(),c)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},Th.prototype.recoverPubKey=function(e,t,r,i){Rh((3&r)===r,"The recovery param is more than two bits"),t=new Mh(t,i);var n=this.n,s=new(Ba())(e),o=t.r,a=t.s,h=1&r,c=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");o=c?this.curve.pointFromX(o.add(this.curve.n),h):this.curve.pointFromX(o,h);var u=t.r.invm(n),l=n.sub(s).mul(u).umod(n),f=a.mul(u).umod(n);return this.g.mulAdd(l,o,f)},Th.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new Mh(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(e,t,n)}catch(e){continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Ch=Za((function(e,t){var r=t;r.version="6.5.4",r.utils=ih,r.rand=function(){throw new Error("unsupported")},r.curve=yh,r.curves=mh,r.ec=Lh,r.eddsa=null})).ec;function Uh(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}new wa("properties/5.7.0");const kh=new wa("signing-key/5.7.0");let jh=null;function qh(){return jh||(jh=new Ch("secp256k1")),jh}class Dh{constructor(e){Uh(this,"curve","secp256k1"),Uh(this,"privateKey",xa(e)),32!==function(e){if("string"!=typeof e)e=xa(e);else if(!Aa(e)||e.length%2)return null;return(e.length-2)/2}(this.privateKey)&&kh.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=qh().keyFromPrivate(Ma(this.privateKey));Uh(this,"publicKey","0x"+t.getPublic(!1,"hex")),Uh(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Uh(this,"_isSigningKey",!0)}_addPoint(e){const t=qh().keyFromPublic(Ma(this.publicKey)),r=qh().keyFromPublic(Ma(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")}signDigest(e){const t=qh().keyFromPrivate(Ma(this.privateKey)),r=Ma(e);32!==r.length&&kh.throwArgumentError("bad digest length","digest",e);const i=t.sign(r,{canonical:!0});return Ra({recoveryParam:i.recoveryParam,r:Na("0x"+i.r.toString(16),32),s:Na("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const t=qh().keyFromPrivate(Ma(this.privateKey)),r=qh().keyFromPublic(Ma(zh(e)));return Na("0x"+t.derive(r.getPublic()).toString(16),32)}static isSigningKey(e){return!(!e||!e._isSigningKey)}}function zh(e,t){const r=Ma(e);if(32===r.length){const e=new Dh(r);return t?"0x"+qh().keyFromPrivate(r).getPublic(!0,"hex"):e.publicKey}return 33===r.length?t?xa(r):"0x"+qh().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?t?"0x"+qh().keyFromPublic(r).getPublic(!0,"hex"):xa(r):kh.throwArgumentError("invalid public or private key","key","[REDACTED]")}var $h;new wa("transactions/5.7.0"),function(e){e[e.legacy=0]="legacy",e[e.eip2930=1]="eip2930",e[e.eip1559=2]="eip1559"}($h||($h={}));var Kh=r(204),Bh=r.n(Kh);class Fh{constructor(e){this.client=e}}class Vh{constructor(e){this.opts=e}}const Hh={wc_authRequest:{req:{ttl:ue.ONE_DAY,prompt:!0,tag:3e3},res:{ttl:ue.ONE_DAY,prompt:!1,tag:3001}}},Wh={min:ue.FIVE_MINUTES,max:ue.SEVEN_DAYS},Gh="authClient",Jh="wc@1:auth:",Yh=`${Jh}:PUB_KEY`;function Xh(e){return e?.split(":")}function Qh(e){const t=e&&Xh(e);if(t)return t.pop()}async function Zh(e,t,r,i,n){switch(r.t){case"eip191":return function(e,t,r){return function(e,t){return function(e){return Ya(Pa(Ca(Pa(zh(e),1)),12))}(function(e,t){const r=Ra(t),i={r:Ma(r.r),s:Ma(r.s)};return"0x"+qh().recoverPubKey(Ma(e),i,r.recoveryParam).encode("hex",!1)}(Ma(e),t))}($a(t),r).toLowerCase()===e.toLowerCase()}(e,t,r.s);case"eip1271":return await async function(e,t,r,i,n){try{const s="0x1626ba7e",o="0000000000000000000000000000000000000000000000000000000000000040",a="0000000000000000000000000000000000000000000000000000000000000041",h=r.substring(2),c=s+$a(t).substring(2)+o+a+h,u=await Bh()(`https://rpc.walletconnect.com/v1/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:c},"latest"]})}),{result:l}=await u.json();return!!l&&l.slice(0,s.length).toLowerCase()===s.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,r.s,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function ec(e){return e.getAll().filter((e=>"requester"in e))}function tc(e,t){return ec(e).find((e=>e.id===t))}var rc=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var l=0,f=s-1;(0!==u||l>>0,o[f]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");n=l,t++}if(" "!==e[t]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,n=0,s=t.length;n!==s&&0===t[n];)n++,r++;for(var o=(s-n)*u+1>>>0,c=new Uint8Array(o);n!==s;){for(var l=t[n],f=0,d=o-1;(0!==l||f>>0,c[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===c[p];)p++;for(var g=h.repeat(r);p{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class nc{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class sc{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return ac(this,e)}}class oc{constructor(e){this.decoders=e}or(e){return ac(this,e)}decode(e){const t=e[0],r=this.decoders[t];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 ac=(e,t)=>new oc({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class hc{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new nc(e,t,r),this.decoder=new sc(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const cc=({name:e,prefix:t,encode:r,decode:i})=>new hc(e,t,r,i),uc=({prefix:e,name:t,alphabet:r})=>{const{encode:i,decode:n}=rc(r,t);return cc({prefix:e,name:t,encode:i,decode:e=>ic(n(e))})},lc=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>cc({prefix:t,name:e,encode:e=>((e,t,r)=>{const i="="===t[t.length-1],n=(1<r;)o-=r,s+=t[n&a>>o];if(o&&(s+=t[n&a<((e,t,r,i)=>{const n={};for(let e=0;e=8&&(a-=8,o[c++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,r,e)}),fc=cc({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var dc=Object.freeze({__proto__:null,identity:fc});const pc=lc({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var gc=Object.freeze({__proto__:null,base2:pc});const yc=lc({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mc=Object.freeze({__proto__:null,base8:yc});const vc=uc({prefix:"9",name:"base10",alphabet:"0123456789"});var bc=Object.freeze({__proto__:null,base10:vc});const _c=lc({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ec=lc({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Sc=Object.freeze({__proto__:null,base16:_c,base16upper:Ec});const Ic=lc({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mc=lc({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ac=lc({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oc=lc({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xc=lc({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pc=lc({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Nc=lc({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rc=lc({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tc=lc({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Lc=Object.freeze({__proto__:null,base32:Ic,base32upper:Mc,base32pad:Ac,base32padupper:Oc,base32hex:xc,base32hexupper:Pc,base32hexpad:Nc,base32hexpadupper:Rc,base32z:Tc});const Cc=uc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Uc=uc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var kc=Object.freeze({__proto__:null,base36:Cc,base36upper:Uc});const jc=uc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qc=uc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Dc=Object.freeze({__proto__:null,base58btc:jc,base58flickr:qc});const zc=lc({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$c=lc({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Kc=lc({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bc=lc({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fc=Object.freeze({__proto__:null,base64:zc,base64pad:$c,base64url:Kc,base64urlpad:Bc});const Vc=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Hc=Vc.reduce(((e,t,r)=>(e[r]=t,e)),[]),Wc=Vc.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]),Gc=cc({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+Hc[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Wc[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var Jc=Object.freeze({__proto__:null,base256emoji:Gc}),Yc=128,Xc=-128,Qc=Math.pow(2,31),Zc=Math.pow(2,7),eu=Math.pow(2,14),tu=Math.pow(2,21),ru=Math.pow(2,28),iu=Math.pow(2,35),nu=Math.pow(2,42),su=Math.pow(2,49),ou=Math.pow(2,56),au=Math.pow(2,63),hu=function e(t,r,i){r=r||[];for(var n=i=i||0;t>=Qc;)r[i++]=255&t|Yc,t/=128;for(;t&Xc;)r[i++]=255&t|Yc,t>>>=7;return r[i]=0|t,e.bytes=i-n+1,r},cu=function(e){return e(hu(e,t,r),t),lu=e=>cu(e),fu=(e,t)=>{const r=t.byteLength,i=lu(e),n=i+lu(r),s=new Uint8Array(n+r);return uu(e,s,0),uu(r,s,i),s.set(t,n),new du(e,r,t,s)};class du{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const pu=({name:e,code:t,encode:r})=>new gu(e,t,r);class gu{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?fu(this.code,t):t.then((e=>fu(this.code,e)))}throw Error("Unknown type, must be binary type")}}const yu=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),mu=pu({name:"sha2-256",code:18,encode:yu("SHA-256")}),vu=pu({name:"sha2-512",code:19,encode:yu("SHA-512")});Object.freeze({__proto__:null,sha256:mu,sha512:vu});const wu=ic,bu={code:0,name:"identity",encode:wu,digest:e=>fu(0,wu(e))};Object.freeze({__proto__:null,identity:bu}),new TextEncoder,new TextDecoder;const _u={...dc,...gc,...mc,...bc,...Sc,...Lc,...kc,...Dc,...Fc,...Jc};function Eu(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}const Su=Eu("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Iu=Eu("ascii","a",(e=>{let t="a";for(let r=0;r{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;rt in e?Ou(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Cu=(e,t)=>{for(var r in t||(t={}))Ru.call(t,r)&&Lu(e,r,t[r]);if(Nu)for(var r of Nu(t))Tu.call(t,r)&&Lu(e,r,t[r]);return e},Uu=(e,t)=>xu(e,Pu(t));class ku extends Fh{constructor(e){super(e),this.initialized=!1,this.name="authEngine",this.init=()=>{this.initialized||(this.registerRelayerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(Hh)}),this.initialized=!0)},this.request=async(e,t)=>{if(this.isInitialized(),!function(e){const t=Ni(e.aud),r=new RegExp(`${e.domain}`).test(e.aud),i=!!e.nonce,n=!e.type||"eip4361"===e.type,s=e.expiry;if(s&&!Di(s,Wh)){const{message:e}=Ei("MISSING_OR_INVALID",`request() expiry: ${s}. Expiry must be a number (in seconds) between ${Wh.min} and ${Wh.max}`);throw new Error(e)}return!!(t&&r&&i&&n)}(e))throw new Error("Invalid request");if(null!=t&&t.topic)return await this.requestOnKnownPairing(t.topic,e);const{chainId:r,statement:i,aud:n,domain:s,nonce:o,type:a,exp:h,nbf:c}=e,{topic:u,uri:l}=await this.client.core.pairing.create();this.client.logger.info({message:"Generated new pairing",pairing:{topic:u,uri:l}});const f=await this.client.core.crypto.generateKeyPair(),d=_r(f);await this.client.authKeys.set(Yh,{responseTopic:d,publicKey:f}),await this.client.pairingTopics.set(d,{topic:d,pairingTopic:u}),await this.client.core.relayer.subscribe(d),this.client.logger.info(`sending request to new pairing topic: ${u}`);const p=await this.sendRequest(u,"wc_authRequest",{payloadParams:{type:a??"eip4361",chainId:r,statement:i,aud:n,domain:s,version:"1",nonce:o,iat:(new Date).toISOString(),exp:h,nbf:c},requester:{publicKey:f,metadata:this.client.metadata}},{},e.expiry);return this.client.logger.info(`sent request to new pairing topic: ${u}`),{uri:l,id:p}},this.respond=async(e,t)=>{if(this.isInitialized(),!function(e,t){return!!tc(t,e.id)}(e,this.client.requests))throw new Error("Invalid response");const r=tc(this.client.requests,e.id);if(!r)throw new Error(`Could not find pending auth request with id ${e.id}`);const i=r.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),s=_r(i),o={type:1,receiverPublicKey:i,senderPublicKey:n};if("error"in e)return void await this.sendError(r.id,s,e,o);const a={h:{t:"eip4361"},p:Uu(Cu({},r.cacaoPayload),{iss:t}),s:e.signature};await this.sendResult(r.id,s,a,o),await this.client.core.pairing.activate({topic:r.pairingTopic}),await this.client.requests.update(r.id,Cu({},a))},this.getPendingRequests=()=>ec(this.client.requests),this.formatMessage=(e,t)=>{this.client.logger.debug(`formatMessage, cacao is: ${JSON.stringify(e)}`);const r=`${e.domain} wants you to sign in with your Ethereum account:`,i=Qh(t),n=e.statement,s=`URI: ${e.aud}`,o=`Version: ${e.version}`,a=`Chain ID: ${function(e){const t=e&&Xh(e);if(t)return t[3]}(t)}`;return[r,i,"",n,"",s,o,a,`Nonce: ${e.nonce}`,`Issued At: ${e.iat}`,e.exp?`Expiry: ${e.exp}`:void 0,e.resources&&e.resources.length>0?`Resources:\n${e.resources.map((e=>`- ${e}`)).join("\n")}`:void 0].filter((e=>null!=e)).join("\n")},this.setExpiry=async(e,t)=>{this.client.core.pairing.pairings.keys.includes(e)&&await this.client.core.pairing.updateExpiry({topic:e,expiry:t}),this.client.core.expirer.set(e,t)},this.sendRequest=async(e,t,r,i,n)=>{const s=Qi(t,r),o=await this.client.core.crypto.encode(e,s,i),a=Hh[t].req;if(n&&(a.ttl=n),this.client.core.history.set(e,s),qr()){const e=Au(JSON.stringify(s));this.client.core.verify.register({attestationId:e})}return await this.client.core.relayer.publish(e,o,Uu(Cu({},a),{internal:{throwOnFailedPublish:!0}})),s.id},this.sendResult=async(e,t,r,i)=>{const n=Zi(e,r),s=await this.client.core.crypto.encode(t,n,i),o=await this.client.core.history.get(t,e),a=Hh[o.request.method].res;return await this.client.core.relayer.publish(t,s,Uu(Cu({},a),{internal:{throwOnFailedPublish:!0}})),await this.client.core.history.resolve(n),n.id},this.sendError=async(e,t,r,i)=>{const n=en(e,r.error),s=await this.client.core.crypto.encode(t,n,i),o=await this.client.core.history.get(t,e),a=Hh[o.request.method].res;return await this.client.core.relayer.publish(t,s,a),await this.client.core.history.resolve(n),n.id},this.requestOnKnownPairing=async(e,t)=>{const r=this.client.core.pairing.pairings.getAll({active:!0}).find((t=>t.topic===e));if(!r)throw new Error(`Could not find pairing for provided topic ${e}`);const{publicKey:i}=this.client.authKeys.get(Yh),{chainId:n,statement:s,aud:o,domain:a,nonce:h,type:c}=t,u=await this.sendRequest(r.topic,"wc_authRequest",{payloadParams:{type:c??"eip4361",chainId:n,statement:s,aud:o,domain:a,version:"1",nonce:h,iat:(new Date).toISOString()},requester:{publicKey:i,metadata:this.client.metadata}},{},t.expiry);return this.client.logger.info(`sent request to known pairing topic: ${r.topic}`),{id:u}},this.onPairingCreated=e=>{const t=this.getPendingRequests();if(t){const r=Object.values(t).find((t=>t.pairingTopic===e.topic));r&&this.handleAuthRequest(r)}},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,i=r.method;return"wc_authRequest"===i?this.onAuthRequest(t,r):this.client.logger.info(`Unsupported request method ${i}`)},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,i=(await this.client.core.history.get(t,r.id)).request.method;return"wc_authRequest"===i?this.onAuthResponse(t,r):this.client.logger.info(`Unsupported response method ${i}`)},this.onAuthRequest=async(e,t)=>{const{requester:r,payloadParams:i}=t.params;this.client.logger.info({type:"onAuthRequest",topic:e,payload:t});const n=Au(JSON.stringify(t)),s=await this.getVerifyContext(n,this.client.metadata),o={requester:r,pairingTopic:e,id:t.id,cacaoPayload:i,verifyContext:s};await this.client.requests.set(t.id,o),this.handleAuthRequest(o)},this.handleAuthRequest=async e=>{const{id:t,pairingTopic:r,requester:i,cacaoPayload:n,verifyContext:s}=e;try{this.client.emit("auth_request",{id:t,topic:r,params:{requester:i,cacaoPayload:n},verifyContext:s})}catch(t){await this.sendError(e.id,e.pairingTopic,t),this.client.logger.error(t)}},this.onAuthResponse=async(e,t)=>{const{id:r}=t;if(this.client.logger.info({type:"onAuthResponse",topic:e,response:t}),un(t)){const{pairingTopic:i}=this.client.pairingTopics.get(e);await this.client.core.pairing.activate({topic:i});const{s:n,p:s}=t.result;await this.client.requests.set(r,Cu({id:r,pairingTopic:i},t.result));const o=this.formatMessage(s,s.iss);this.client.logger.debug("reconstructed message:\n",JSON.stringify(o)),this.client.logger.debug("payload.iss:",s.iss),this.client.logger.debug("signature:",n);const a=Qh(s.iss),h=function(e){const t=e&&Xh(e);if(t)return t[2]+":"+t[3]}(s.iss);if(!a)throw new Error("Could not derive address from `payload.iss`");if(!h)throw new Error("Could not derive chainId from `payload.iss`");this.client.logger.debug("walletAddress extracted from `payload.iss`:",a),await Zh(a,o,n,h,this.client.projectId)?this.client.emit("auth_response",{id:r,topic:e,params:t}):this.client.emit("auth_response",{id:r,topic:e,params:{message:"Invalid signature",code:-1}})}else ln(t)&&this.client.emit("auth_response",{id:r,topic:e,params:t})},this.getVerifyContext=async(e,t)=>{const r={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});i&&(r.verified.origin=i.origin,r.verified.isScam=i.isScam,r.verified.validation=origin===new URL(t.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.error(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r}}isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Ys,(async e=>{const{topic:t,message:r}=e,{responseTopic:i,publicKey:n}=this.client.authKeys.keys.includes(Yh)?this.client.authKeys.get(Yh):{responseTopic:void 0,publicKey:void 0};if(i&&t!==i)return void this.client.logger.debug("[Auth] Ignoring message from unknown topic",t);const s=await this.client.core.crypto.decode(t,r,{receiverPublicKey:n});hn(s)?(this.client.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):cn(s)&&(await this.client.core.history.resolve(s),this.onRelayEventResponse({topic:t,payload:s}))}))}registerPairingEvents(){this.client.core.pairing.events.on(fo,(e=>this.onPairingCreated(e)))}}class ju extends Vh{constructor(e){super(e),this.protocol="wc",this.version=1,this.name=Gh,this.events=new g.EventEmitter,this.emit=(e,t)=>this.events.emit(e,t),this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.request=async(e,t)=>{try{return await this.engine.request(e,t)}catch(e){throw this.logger.error(e.message),e}},this.respond=async(e,t)=>{try{return await this.engine.respond(e,t)}catch(e){throw this.logger.error(e.message),e}},this.getPendingRequests=()=>{try{return this.engine.getPendingRequests()}catch(e){throw this.logger.error(e.message),e}},this.formatMessage=(e,t)=>{try{return this.engine.formatMessage(e,t)}catch(e){throw this.logger.error(e.message),e}};const t=typeof e.logger<"u"&&"string"!=typeof e.logger?e.logger:(0,J.pino)((0,J.getDefaultLoggerOptions)({level:e.logger||"error"}));this.name=e?.name||Gh,this.metadata=e.metadata,this.projectId=e.projectId,this.core=e.core||new ca(e),this.logger=(0,J.generateChildLogger)(t,this.name),this.authKeys=new Xo(this.core,this.logger,"authKeys",Jh,(()=>Yh)),this.pairingTopics=new Xo(this.core,this.logger,"pairingTopics",Jh),this.requests=new Xo(this.core,this.logger,"requests",Jh,(e=>e.id)),this.engine=new ku(this)}static async init(e){const t=new ju(e);return await t.initialize(),t}get context(){return(0,J.getLoggerContext)(this.logger)}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.authKeys.init(),await this.requests.init(),await this.pairingTopics.init(),await this.engine.init(),this.logger.info("AuthClient Initialization Success"),this.logger.info({authClient:this})}catch(e){throw this.logger.info("AuthClient Initialization Failure"),this.logger.error(e.message),e}}}const qu=ju,Du="client",zu=`wc@2:${Du}:`,$u=Du,Ku="WALLETCONNECT_DEEPLINK_CHOICE",Bu=ue.SEVEN_DAYS,Fu={wc_sessionPropose:{req:{ttl:ue.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ue.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:ue.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ue.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ue.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ue.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ue.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ue.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ue.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ue.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ue.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ue.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ue.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ue.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ue.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:ue.THIRTY_SECONDS,prompt:!1,tag:1115}}},Vu={min:ue.FIVE_MINUTES,max:ue.SEVEN_DAYS},Hu="IDLE",Wu="ACTIVE",Gu=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Ju=Object.defineProperty,Yu=Object.defineProperties,Xu=Object.getOwnPropertyDescriptors,Qu=Object.getOwnPropertySymbols,Zu=Object.prototype.hasOwnProperty,el=Object.prototype.propertyIsEnumerable,tl=(e,t,r)=>t in e?Ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rl=(e,t)=>{for(var r in t||(t={}))Zu.call(t,r)&&tl(e,r,t[r]);if(Qu)for(var r of Qu(t))el.call(t,r)&&tl(e,r,t[r]);return e},il=(e,t)=>Yu(e,Xu(t));class nl extends ae{constructor(e){super(e),this.name="engine",this.events=new(y()),this.initialized=!1,this.ignoredPayloadTypes=[1],this.requestQueue={state:Hu,queue:[]},this.sessionRequestQueue={state:Hu,queue:[]},this.requestQueueDelay=ue.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(Fu)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,ue.toMiliseconds)(this.requestQueueDelay)))},this.connect=async e=>{await this.isInitialized();const t=il(rl({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:s,relays:o}=t;let a,h=r,c=!1;if(h&&(c=this.client.core.pairing.pairings.get(h).active),!h||!c){const{topic:e,uri:t}=await this.client.core.pairing.create();h=e,a=t}const u=await this.client.core.crypto.generateKeyPair(),l=rl({requiredNamespaces:i,optionalNamespaces:n,relays:o??[{protocol:"irn"}],proposer:{publicKey:u,metadata:this.client.metadata}},s&&{sessionProperties:s}),{reject:f,resolve:d,done:p}=Fr(ue.FIVE_MINUTES,"Proposal expired");if(this.events.once(Yr("session_connect"),(async({error:e,session:t})=>{if(e)f(e);else if(t){t.self.publicKey=u;const e=il(rl({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:t.peer.metadata}),d(e)}})),!h){const{message:e}=Ei("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(e)}const g=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:l}),y=Gr(ue.FIVE_MINUTES);return await this.setProposal(g,rl({id:g,expiry:y},l)),{uri:a,approval:p}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:r,namespaces:i,sessionProperties:n}=e,s=this.client.proposal.get(t);let{pairingTopic:o,proposer:a,requiredNamespaces:h,optionalNamespaces:c}=s;o=o||"",Mi(h)||(h=function(e,t){const r=Li(e,"approve()");if(r)throw new Error(r.message);const i={};for(const[t,r]of Object.entries(e))i[t]={methods:r.methods,events:r.events,chains:r.accounts.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))};return i}(i));const u=await this.client.core.crypto.generateKeyPair(),l=a.publicKey,f=await this.client.core.crypto.generateSharedKey(u,l);o&&t&&(await this.client.core.pairing.updateMetadata({topic:o,metadata:a.metadata}),await this.sendResult({id:t,topic:o,result:{relay:{protocol:r??"irn"},responderPublicKey:u}}),await this.client.proposal.delete(t,Si("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:o}));const d=rl({relay:{protocol:r??"irn"},namespaces:i,requiredNamespaces:h,optionalNamespaces:c,pairingTopic:o,controller:{publicKey:u,metadata:this.client.metadata},expiry:Gr(Bu)},n&&{sessionProperties:n});await this.client.core.relayer.subscribe(f),await this.sendRequest({topic:f,method:"wc_sessionSettle",params:d,throwOnFailedPublish:!0});const p=il(rl({},d),{topic:f,pairingTopic:o,acknowledged:!1,self:d.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:u});return await this.client.session.set(f,p),await this.setExpiry(f,Gr(Bu)),{topic:f,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(f))),500)))}},this.reject=async e=>{await this.isInitialized(),await this.isValidReject(e);const{id:t,reason:r}=e,{pairingTopic:i}=this.client.proposal.get(t);i&&(await this.sendError(t,i,r),await this.client.proposal.delete(t,Si("USER_DISCONNECTED")))},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:r}=e,i=await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:r}}),{done:n,resolve:s,reject:o}=Fr();return this.events.once(Yr("session_update",i),(({error:e})=>{e?o(e):s()})),await this.client.session.update(t,{namespaces:r}),{acknowledged:n}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,r=await this.sendRequest({topic:t,method:"wc_sessionExtend",params:{}}),{done:i,resolve:n,reject:s}=Fr();return this.events.once(Yr("session_extend",r),(({error:e})=>{e?s(e):n()})),await this.setExpiry(t,Gr(Bu)),{acknowledged:i}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:i,topic:n,expiry:s}=e,o=Yi(),{done:a,resolve:h,reject:c}=Fr(s,"Request expired. Please try again.");return this.events.once(Yr("session_request",o),(({error:e,result:t})=>{e?c(e):h(t)})),await Promise.all([new Promise((async e=>{await this.sendRequest({clientRpcId:o,topic:n,method:"wc_sessionRequest",params:{request:i,chainId:t},expiry:s,throwOnFailedPublish:!0}).catch((e=>c(e))),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:t,id:o}),e()})),new Promise((async e=>{const t=await this.client.core.storage.getItem(Ku);(async function({id:e,topic:t,wcDeepLink:i}){try{if(!i)return;const n="string"==typeof i?JSON.parse(i):i;let s=n?.href;if("string"!=typeof s)return;s.endsWith("/")&&(s=s.slice(0,-1));const o=`${s}/wc?requestId=${e}&sessionTopic=${t}`,a=Dr();a===Cr.browser?o.startsWith("https://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,"_self","noreferrer noopener"):a===Cr.reactNative&&typeof(null==r.g?void 0:r.g.Linking)<"u"&&await r.g.Linking.openURL(o)}catch(e){console.error(e)}})({id:o,topic:n,wcDeepLink:t}),e()})),a()]).then((e=>e[2]))},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:r}=e,{id:i}=r;un(r)?await this.sendResult({id:i,topic:t,result:r.result,throwOnFailedPublish:!0}):ln(r)&&await this.sendError(i,t,r.error),this.cleanupAfterResponse(e)},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest({topic:t,method:"wc_sessionPing",params:{}}),{done:r,resolve:i,reject:n}=Fr();this.events.once(Yr("session_ping",e),(({error:e})=>{e?n(e):i()})),await r()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:r,chainId:i}=e;await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:r,chainId:i}})},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.client.session.keys.includes(t)?(await this.sendRequest({topic:t,method:"wc_sessionDelete",params:Si("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(t)):await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>function(e,t){const{requiredNamespaces:r}=t,i=Object.keys(e.namespaces),n=Object.keys(r);let s=!0;return!!$r(n,i)&&(i.forEach((t=>{const{accounts:i,methods:n,events:o}=e.namespaces[t],a=yi(i),h=r[t];$r(gr(t,h),a)&&$r(h.methods,n)&&$r(h.events,o)||(s=!1)})),s)}(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter((r=>{var i,n;return(null==(i=r.peerMetadata)?void 0:i.url)&&(null==(n=r.peerMetadata)?void 0:n.url)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(e,t)=>{const{self:r}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,Si("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(r.publicKey)&&await this.client.core.crypto.deleteKeyPair(r.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e),this.client.core.storage.removeItem(Ku).catch((e=>this.client.logger.warn(e)))},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,Si("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((t=>t.id!==e)),r&&(this.sessionRequestQueue.state=Hu)},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=Fu.wc_sessionRequest.req.ttl,{id:r,topic:i,params:n,verifyContext:s}=e;await this.client.pendingRequest.set(r,{id:r,topic:i,params:n,verifyContext:s}),t&&this.client.core.expirer.set(r,Gr(t))},this.sendRequest=async e=>{const{topic:t,method:r,params:i,expiry:n,relayRpcId:s,clientRpcId:o,throwOnFailedPublish:a}=e,h=Qi(r,i,o);if(qr()&&Gu.includes(r)){const e=Er(JSON.stringify(h));this.client.core.verify.register({attestationId:e})}const c=await this.client.core.crypto.encode(t,h),u=Fu[r].req;return n&&(u.ttl=n),s&&(u.id=s),this.client.core.history.set(t,h),a?(u.internal=il(rl({},u.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,c,u)):this.client.core.relayer.publish(t,c,u).catch((e=>this.client.logger.error(e))),h.id},this.sendResult=async e=>{const{id:t,topic:r,result:i,throwOnFailedPublish:n}=e,s=Zi(t,i),o=await this.client.core.crypto.encode(r,s),a=await this.client.core.history.get(r,t),h=Fu[a.request.method].res;n?(h.internal=il(rl({},h.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,o,h)):this.client.core.relayer.publish(r,o,h).catch((e=>this.client.logger.error(e))),await this.client.core.history.resolve(s)},this.sendError=async(e,t,r)=>{const i=en(e,r),n=await this.client.core.crypto.encode(t,i),s=await this.client.core.history.get(t,e),o=Fu[s.request.method].res;this.client.core.relayer.publish(t,n,o),await this.client.core.history.resolve(i)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{Jr(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{Jr(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==Wu){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Wu;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise((e=>setTimeout(e,300)))}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=Hu}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=e=>{const{topic:t,payload:r}=e,i=r.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeRequest(t,r);case"wc_sessionSettle":return this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return this.onSessionExtendRequest(t,r);case"wc_sessionPing":return this.onSessionPingRequest(t,r);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return this.onSessionRequest(t,r);case"wc_sessionEvent":return this.onSessionEventRequest(t,r);default:return this.client.logger.info(`Unsupported request method ${i}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,i=(await this.client.core.history.get(t,r.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${i}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:r}=Ei("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)},this.onSessionProposeRequest=async(e,t)=>{const{params:r,id:i}=t;try{this.isValidConnect(rl({},t.params));const n=Gr(ue.FIVE_MINUTES),s=rl({id:i,pairingTopic:e,expiry:n},r);await this.setProposal(i,s);const o=Er(JSON.stringify(t)),a=await this.getVerifyContext(o,s.proposer.metadata);this.client.events.emit("session_proposal",{id:i,params:s,verifyContext:a})}catch(t){await this.sendError(i,e,t),this.client.logger.error(t)}},this.onSessionProposeResponse=async(e,t)=>{const{id:r}=t;if(un(t)){const{result:i}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(r);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const s=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:s});const o=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:o});const a=await this.client.core.crypto.generateSharedKey(s,o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const h=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else ln(t)&&(await this.client.proposal.delete(r,Si("USER_DISCONNECTED")),this.events.emit(Yr("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:r,params:i}=t;try{this.isValidSessionSettleRequest(i);const{relay:r,controller:n,expiry:s,namespaces:o,requiredNamespaces:a,optionalNamespaces:h,sessionProperties:c,pairingTopic:u}=t.params,l=rl({topic:e,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:u,requiredNamespaces:a,optionalNamespaces:h,controller:n.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},c&&{sessionProperties:c});await this.sendResult({id:t.id,topic:e,result:!0}),this.events.emit(Yr("session_connect"),{session:l}),this.cleanupDuplicatePairings(l)}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:r}=t;un(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(Yr("session_approve",r),{})):ln(t)&&(await this.client.session.delete(e,Si("USER_DISCONNECTED")),this.events.emit(Yr("session_approve",r),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:r,id:i}=t;try{const t=`${e}_session_update`,n=Ki.get(t);if(n&&this.isRequestOutOfSync(n,i))return void this.client.logger.info(`Discarding out of sync request - ${i}`);this.isValidUpdate(rl({topic:e},r)),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_update",{id:i,topic:e,params:r}),Ki.set(t,i)}catch(t){await this.sendError(i,e,t),this.client.logger.error(t)}},this.isRequestOutOfSync=(e,t)=>parseInt(t.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,t)=>{const{id:r}=t;un(t)?this.events.emit(Yr("session_update",r),{}):ln(t)&&this.events.emit(Yr("session_update",r),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,Gr(Bu)),await this.sendResult({id:r,topic:e,result:!0}),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:r}=t;un(t)?this.events.emit(Yr("session_extend",r),{}):ln(t)&&this.events.emit(Yr("session_extend",r),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:r,topic:e,result:!0}),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{un(t)?this.events.emit(Yr("session_ping",r),{}):ln(t)&&this.events.emit(Yr("session_ping",r),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(to,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult({id:r,topic:e,result:!0})]),this.client.events.emit("session_delete",{id:r,topic:e})}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async(e,t)=>{const{id:r,params:i}=t;try{this.isValidRequest(rl({topic:e},i));const t=Er(JSON.stringify(Qi("wc_sessionRequest",i,r))),n=this.client.session.get(e),s={id:r,topic:e,params:i,verifyContext:await this.getVerifyContext(t,n.peer.metadata)};await this.setPendingSessionRequest(s),this.addSessionRequestToSessionRequestQueue(s),this.processSessionRequestQueue()}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:r}=t;un(t)?this.events.emit(Yr("session_request",r),{result:t.result}):ln(t)&&this.events.emit(Yr("session_request",r),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:r,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,n=Ki.get(t);if(n&&this.isRequestOutOfSync(n,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(rl({topic:e},i)),this.client.events.emit("session_event",{id:r,topic:e,params:i}),Ki.set(t,r)}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=Hu,this.processSessionRequestQueue()}),(0,ue.toMiliseconds)(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Wu)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=Wu,this.client.events.emit("session_request",e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.onPairingCreated=e=>{if(e.active)return;const t=this.client.proposal.getAll().find((t=>t.pairingTopic===e.topic));t&&this.onSessionProposeRequest(e.topic,Qi("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer},t.id))},this.isValidConnect=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:n,relays:s}=e;if(Ai(t)||await this.isValidPairingTopic(t),!function(e,t){let r=!1;return e?e&&Ii(e)&&e.length&&e.forEach((e=>{r=Ci(e)})):r=!0,r}(s)){const{message:e}=Ei("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(e)}!Ai(r)&&0!==Mi(r)&&this.validateNamespaces(r,"requiredNamespaces"),!Ai(i)&&0!==Mi(i)&&this.validateNamespaces(i,"optionalNamespaces"),Ai(n)||this.validateSessionProps(n,"sessionProperties")},this.validateNamespaces=(e,t)=>{const r=function(e,t,r){let i=null;if(e&&Mi(e)){const n=Ti(e,t);n&&(i=n);const s=function(e,t,r){let i=null;return Object.entries(e).forEach((([e,n])=>{if(i)return;const s=function(e,t,r){let i=null;return Ii(t)&&t.length?t.forEach((e=>{i||Pi(e)||(i=Si("UNSUPPORTED_CHAINS",`${r}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):Pi(e)||(i=Si("UNSUPPORTED_CHAINS",`${r}, 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"] }`)),i}(e,gr(e,n),`${t} ${r}`);s&&(i=s)})),i}(e,t,r);s&&(i=s)}else i=Ei("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return i}(e,"connect()",t);if(r)throw new Error(r.message)},this.isValidApprove=async e=>{if(!Ui(e))throw new Error(Ei("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:r,relayProtocol:i,sessionProperties:n}=e;await this.isValidProposalId(t);const s=this.client.proposal.get(t),o=Li(r,"approve()");if(o)throw new Error(o.message);const a=ji(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!Oi(i,!0)){const{message:e}=Ei("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}Ai(n)||this.validateSessionProps(n,"sessionProperties")},this.isValidReject=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:r}=e;if(await this.isValidProposalId(t),!function(e){return!!(e&&"object"==typeof e&&e.code&&xi(e.code,!1)&&e.message&&Oi(e.message,!1))}(r)){const{message:e}=Ei("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:r,namespaces:i,expiry:n}=e;if(!Ci(t)){const{message:e}=Ei("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const s=function(e,t){let r=null;return Oi(e?.publicKey,!1)||(r=Ei("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),r}(r);if(s)throw new Error(s.message);const o=Li(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(Jr(n)){const{message:e}=Ei("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:r}=e;await this.isValidSessionTopic(t);const i=this.client.session.get(t),n=Li(r,"update()");if(n)throw new Error(n.message);const s=ji(i.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:r,chainId:i,expiry:n}=e;await this.isValidSessionTopic(t);const{namespaces:s}=this.client.session.get(t);if(!ki(s,i)){const{message:e}=Ei("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!function(e){return!(Ai(e)||!Oi(e.method,!1))}(r)){const{message:e}=Ei("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(e)}if(!function(e,t,r){return!!Oi(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{yi(e.accounts).includes(t)&&r.push(...e.methods)})),r}(e,t).includes(r)}(s,i,r.method)){const{message:e}=Ei("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(e)}if(n&&!Di(n,Vu)){const{message:e}=Ei("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${Vu.min} and ${Vu.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:r}=e;if(await this.isValidSessionTopic(t),!function(e){return!(Ai(e)||Ai(e.result)&&Ai(e.error)||!xi(e.id,!1)||!Oi(e.jsonrpc,!1))}(r)){const{message:e}=Ei("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:r,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!ki(n,i)){const{message:e}=Ei("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!function(e){return!(Ai(e)||!Oi(e.name,!1))}(r)){const{message:e}=Ei("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}if(!function(e,t,r){return!!Oi(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{yi(e.accounts).includes(t)&&r.push(...e.events)})),r}(e,t).includes(r)}(n,i,r.name)){const{message:e}=Ei("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!Ui(e)){const{message:t}=Ei("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const r={verified:{verifyUrl:t.verifyUrl||_o,validation:"UNKNOWN",origin:t.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});i&&(r.verified.origin=i.origin,r.verified.isScam=i.isScam,r.verified.validation=i.origin===new URL(t.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.info(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!Oi(e,!1)){const{message:r}=Ei("MISSING_OR_INVALID",`${t} must be in Record format. Received: ${JSON.stringify(e)}`);throw new Error(r)}}))}}async isInitialized(){if(!this.initialized){const{message:e}=Ei("NOT_INITIALIZED",this.name);throw new Error(e)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ys,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(r)))return;const i=await this.client.core.crypto.decode(t,r);try{hn(i)?(this.client.core.history.set(t,i),this.onRelayEventRequest({topic:t,payload:i})):cn(i)?(await this.client.core.history.resolve(i),await this.onRelayEventResponse({topic:t,payload:i}),this.client.core.history.delete(t,i.id)):this.onRelayEventUnknownPayload({topic:t,payload:i})}catch(e){this.client.logger.error(e)}}))}registerExpirerEvents(){this.client.core.expirer.on(wo,(async e=>{const{topic:t,id:r}=Wr(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,Ei("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))}))}registerPairingEvents(){this.client.core.pairing.events.on(fo,(e=>this.onPairingCreated(e)))}isValidPairingTopic(e){if(!Oi(e,!1)){const{message:t}=Ei("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Ei("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Jr(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Ei("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Oi(e,!1)){const{message:t}=Ei("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=Ei("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Jr(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=Ei("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(Oi(e,!1)){const{message:t}=Ei("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=Ei("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if("number"!=typeof e){const{message:t}=Ei("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=Ei("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Jr(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=Ei("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class sl extends Xo{constructor(e,t){super(e,t,"proposal",zu),this.core=e,this.logger=t}}class ol extends Xo{constructor(e,t){super(e,t,"session",zu),this.core=e,this.logger=t}}class al extends Xo{constructor(e,t){super(e,t,"request",zu,(e=>e.id)),this.core=e,this.logger=t}}class hl extends oe{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=$u,this.events=new g.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=e?.name||$u,this.metadata=e?.metadata||(0,fr.D)()||{name:"",description:"",url:"",icons:[""]};const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,J.pino)((0,J.getDefaultLoggerOptions)({level:e?.logger||"error"}));this.core=e?.core||new ca(e),this.logger=(0,J.generateChildLogger)(t,this.name),this.session=new ol(this.core,this.logger),this.proposal=new sl(this.core,this.logger),this.pendingRequest=new al(this.core,this.logger),this.engine=new nl(this)}static async init(e){const t=new hl(e);return await t.initialize(),t}get context(){return(0,J.getLoggerContext)(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.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const cl=hl;var ul,ll={exports:{}},fl="object"==typeof Reflect?Reflect:null,dl=fl&&"function"==typeof fl.apply?fl.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};ul=fl&&"function"==typeof fl.ownKeys?fl.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var pl=Number.isNaN||function(e){return e!=e};function gl(){gl.init.call(this)}ll.exports=gl,ll.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}Ml(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Ml(e,"error",t,{once:!0})}(e,n)}))},gl.EventEmitter=gl,gl.prototype._events=void 0,gl.prototype._eventsCount=0,gl.prototype._maxListeners=void 0;var yl=10;function ml(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function vl(e){return void 0===e._maxListeners?gl.defaultMaxListeners:e._maxListeners}function wl(e,t,r,i){var n,s,o;if(ml(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=vl(e))>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function bl(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _l(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=bl.bind(i);return n.listener=r,i.wrapFn=n,n}function El(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=n[e];if(void 0===a)return!1;if("function"==typeof a)dl(a,this,t);else{var h=a.length,c=Il(a,h);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},gl.prototype.listeners=function(e){return El(this,e,!0)},gl.prototype.rawListeners=function(e){return El(this,e,!1)},gl.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Sl.call(e,t)},gl.prototype.listenerCount=Sl,gl.prototype.eventNames=function(){return this._eventsCount>0?ul(this._events):[]};ll.exports;class Al{constructor(e){this.opts=e}}class Ol{constructor(e){this.client=e}}class xl extends Ol{constructor(e){super(e),this.init=async()=>{this.signClient=await cl.init({core:this.client.core,metadata:this.client.metadata}),this.authClient=await qu.init({core:this.client.core,projectId:"",metadata:this.client.metadata}),this.initializeEventListeners()},this.pair=async e=>{await this.client.core.pairing.pair(e)},this.approveSession=async e=>{const{topic:t,acknowledged:r}=await this.signClient.approve({id:e.id,namespaces:e.namespaces});return await r(),this.signClient.session.get(t)},this.rejectSession=async e=>await this.signClient.reject(e),this.updateSession=async e=>await(await this.signClient.update(e)).acknowledged(),this.extendSession=async e=>await(await this.signClient.extend(e)).acknowledged(),this.respondSessionRequest=async e=>await this.signClient.respond(e),this.disconnectSession=async e=>await this.signClient.disconnect(e),this.emitSessionEvent=async e=>await this.signClient.emit(e),this.getActiveSessions=()=>this.signClient.session.getAll().reduce(((e,t)=>(e[t.topic]=t,e)),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.respondAuthRequest=async(e,t)=>await this.authClient.respond(e,t),this.getPendingAuthRequests=()=>this.authClient.requests.getAll().filter((e=>"requester"in e)),this.formatMessage=(e,t)=>this.authClient.formatMessage(e,t),this.onSessionRequest=e=>{this.client.events.emit("session_request",e)},this.onSessionProposal=e=>{this.client.events.emit("session_proposal",e)},this.onSessionDelete=e=>{this.client.events.emit("session_delete",e)},this.onAuthRequest=e=>{this.client.events.emit("auth_request",e)},this.initializeEventListeners=()=>{this.signClient.events.on("session_proposal",this.onSessionProposal),this.signClient.events.on("session_request",this.onSessionRequest),this.signClient.events.on("session_delete",this.onSessionDelete),this.authClient.on("auth_request",this.onAuthRequest)},this.signClient={},this.authClient={}}}class Pl extends Al{constructor(e){super(e),this.events=new ll.exports,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(e){throw this.logger.error(e.message),e}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(e){throw this.logger.error(e.message),e}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(e){throw this.logger.error(e.message),e}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(e){throw this.logger.error(e.message),e}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(e){throw this.logger.error(e.message),e}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(e){throw this.logger.error(e.message),e}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.respondAuthRequest=async(e,t)=>{try{return await this.engine.respondAuthRequest(e,t)}catch(e){throw this.logger.error(e.message),e}},this.getPendingAuthRequests=()=>{try{return this.engine.getPendingAuthRequests()}catch(e){throw this.logger.error(e.message),e}},this.formatMessage=(e,t)=>{try{return this.engine.formatMessage(e,t)}catch(e){throw this.logger.error(e.message),e}},this.metadata=e.metadata,this.name=e.name||"Web3Wallet",this.core=e.core,this.logger=this.core.logger,this.engine=new xl(this)}static async init(e){const t=new Pl(e);return await t.initialize(),t}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("Web3Wallet Initialization Success")}catch(e){throw this.logger.info("Web3Wallet Initialization Failure"),this.logger.error(e.message),e}}}const Nl=Pl;window.wc={core:null,web3wallet:null,authClient:null,statusObject:null,init:function(e){return new Promise((async(t,r)=>{if(!window.statusq){const e='missing window.statusq! Forgot to execute "ui/StatusQ/src/StatusQ/Components/private/qwebchannel/helpers.js" first?';console.error(e),r(e)}if(window.statusq.error){const e="Failed initializing WebChannel: "+window.statusq.error;console.error(e),r(e)}if(wc.statusObject=window.statusq.channel.objects.statusObject,!wc.statusObject){const e="Failed initializing WebChannel or initialization not run";console.error(e),r(e)}window.wc.core=new ca({projectId:e}),window.wc.web3wallet=await Nl.init({core:window.wc.core,metadata:{name:"Status",description:"Status Wallet",url:"http://localhost",icons:["https://status.im/img/status-footer-logo.svg"]}}),window.wc.authClient=await ju.init({projectId:e,metadata:window.wc.web3wallet.metadata}),window.wc.web3wallet.on("session_proposal",(e=>{wc.statusObject.onSessionProposal(e)})),window.wc.web3wallet.on("session_update",(e=>{wc.statusObject.onSessionUpdate(e)})),window.wc.web3wallet.on("session_extend",(e=>{wc.statusObject.onSessionExtend(e)})),window.wc.web3wallet.on("session_ping",(e=>{wc.statusObject.onSessionPing(e)})),window.wc.web3wallet.on("session_delete",(e=>{wc.statusObject.onSessionDelete(e)})),window.wc.web3wallet.on("session_expire",(e=>{wc.statusObject.onSessionExpire(e)})),window.wc.web3wallet.on("session_request",(e=>{wc.statusObject.onSessionRequest(e)})),window.wc.web3wallet.on("session_request_sent",(e=>{wc.statusObject.onSessionRequestSent(e)})),window.wc.web3wallet.on("session_event",(e=>{wc.statusObject.onSessionEvent(e)})),window.wc.web3wallet.on("proposal_expire",(e=>{wc.statusObject.onProposalExpire(e)})),window.wc.authClient.on("auth_request",(e=>{wc.statusObject.onAuthRequest(e)})),wc.statusObject.sdkInitialized(""),t("")}))},pair:async function(e){await window.wc.web3wallet.pair({uri:e})},getPairings:function(){return window.wc.web3wallet.core.pairing.getPairings()},getActiveSessions:function(){return window.wc.web3wallet.getActiveSessions()},disconnect:async function(e){await window.wc.web3wallet.disconnectSession({topic:e,reason:Si("USER_DISCONNECTED")})},ping:async function(e){await window.wc.web3wallet.engine.signClient.ping({topic:e})},approveSession:async function(e,t){const{id:r,params:i}=e,{relays:n}=i,s=function(e){const{proposal:{requiredNamespaces:t,optionalNamespaces:r={}},supportedNamespaces:i}=e,n=wi(t),s=wi(r),o={};Object.keys(i).forEach((e=>{const t=i[e].chains,r=i[e].methods,n=i[e].events,s=i[e].accounts;t.forEach((t=>{if(!s.some((e=>e.includes(t))))throw new Error(`No accounts provided for chain ${t} in namespace ${e}`)})),o[e]={chains:t,methods:r,events:n,accounts:s}}));const a=ji(t,o,"approve()");if(a)throw new Error(a.message);const h={};return Object.keys(t).length||Object.keys(r).length?(Object.keys(n).forEach((e=>{const t=i[e].chains.filter((t=>{var r,i;return null==(i=null==(r=n[e])?void 0:r.chains)?void 0:i.includes(t)})),r=i[e].methods.filter((t=>{var r,i;return null==(i=null==(r=n[e])?void 0:r.methods)?void 0:i.includes(t)})),s=i[e].events.filter((t=>{var r,i;return null==(i=null==(r=n[e])?void 0:r.events)?void 0:i.includes(t)})),o=t.map((t=>i[e].accounts.filter((e=>e.includes(`${t}:`))))).flat();h[e]={chains:t,methods:r,events:s,accounts:o}})),Object.keys(s).forEach((e=>{var t,r,n,o,a,c;if(!i[e])return;const u=null==(r=null==(t=s[e])?void 0:t.chains)?void 0:r.filter((t=>i[e].chains.includes(t))),l=i[e].methods.filter((t=>{var r,i;return null==(i=null==(r=s[e])?void 0:r.methods)?void 0:i.includes(t)})),f=i[e].events.filter((t=>{var r,i;return null==(i=null==(r=s[e])?void 0:r.events)?void 0:i.includes(t)})),d=u?.map((t=>i[e].accounts.filter((e=>e.includes(`${t}:`))))).flat();h[e]={chains:Xr(null==(n=h[e])?void 0:n.chains,u),methods:Xr(null==(o=h[e])?void 0:o.methods,l),events:Xr(null==(a=h[e])?void 0:a.events,f),accounts:Xr(null==(c=h[e])?void 0:c.accounts,d)}})),h):o}({proposal:i,supportedNamespaces:t});return await window.wc.web3wallet.approveSession({id:r,relayProtocol:n[0].protocol,namespaces:s})},rejectSession:async function(e){await window.wc.web3wallet.rejectSession({id:e,reason:Si("USER_REJECTED")})},auth:async function(e){await window.wc.authClient.core.pairing.pair({uri:e})},formatAuthMessage:function(e,t){const r=`did:pkh:eip155:1:${t}`;return window.wc.authClient.formatMessage(e,r)},approveAuth:async function(e,t,r){const{id:i}=e,n=`did:pkh:eip155:1:${t}`;await window.wc.authClient.respond({id:i,signature:{s:r,t:"eip191"}},n)},rejectAuth:async function(e,t){const r=`did:pkh:eip155:1:${t}`;await window.wc.authClient.respond({id:e,error:{code:4001,message:"Auth request has been rejected"}},r)},respondSessionRequest:async function(e,t,r){const i=Zi(t,r);await window.wc.web3wallet.respondSessionRequest({topic:e,response:i})},rejectSessionRequest:async function(e,t,r=!1){const i=r?"SESSION_SETTLEMENT_FAILED":"USER_REJECTED";await window.wc.web3wallet.respondSessionRequest({topic:e,response:en(t,Si(i))})}}})(); \ No newline at end of file diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index faf5ca4d49..b150c5c98b 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -42,7 +42,11 @@ import AppLayouts.Chat.stores 1.0 as ChatStores import AppLayouts.Communities.stores 1.0 import AppLayouts.Wallet.stores 1.0 as WalletStore import AppLayouts.Wallet.popups 1.0 as WalletPopups -import AppLayouts.Wallet.views.walletconnect 1.0 + +///////////////////////////////////////////////////// +// WalletConnect POC - to remove +import AppLayouts.Wallet.views.pocwalletconnect 1.0 +///////////////////////////////////////////////////// import mainui.activitycenter.stores 1.0 import mainui.activitycenter.popups 1.0 @@ -2029,13 +2033,15 @@ Item { } } - WalletConnect { + ///////////////////////////////////////////////////// + // WalletConnect POC - to remove + POCWalletConnect { id: walletConnect anchors.top: parent.bottom width: 100 height: 100 - controller: WalletStore.RootStore.walletConnectController + controller: WalletStore.RootStore.walletSectionInst.walletConnectController Connections { target: Global @@ -2044,4 +2050,5 @@ Item { } } } + ///////////////////////////////////////////////////// } diff --git a/ui/imports/shared/popups/walletconnect/ConnectDappPopup.qml b/ui/imports/shared/popups/walletconnect/ConnectDappPopup.qml new file mode 100644 index 0000000000..a6aca1e02a --- /dev/null +++ b/ui/imports/shared/popups/walletconnect/ConnectDappPopup.qml @@ -0,0 +1,57 @@ +import QtQuick 2.15 + +import StatusQ.Core 0.1 +import StatusQ.Popups 0.1 +import StatusQ.Controls 0.1 + +import utils 1.0 + +StatusModal { + id: root + + width: Constants.dapps.connectDappPopupWidth + + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + + headerSettings.title: qsTr("Connect a Dapp via WalletConnect") + + StatusScrollView { + id: scrollView + + anchors.fill: parent + padding: 0 + contentWidth: availableWidth + + Item { + id: content + + implicitWidth: loader.implicitWidth + implicitHeight: loader.implicitHeight + width: scrollView.availableWidth + + Loader { + id: loader + width: parent.width + sourceComponent: { + // TODO + + return undefined + } + } + } + } + + rightButtons: [ + StatusButton { + id: primaryButton + height: Constants.dapps.footerButtonsHeight + text: qsTr("Done") + visible: text !== "" + enabled: root.store.primaryPopupButtonEnabled + + onClicked: { + console.warn("TODO: done...") + } + } + ] +} diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml b/ui/imports/shared/popups/walletconnect/WalletConnectSDK.qml similarity index 99% rename from ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml rename to ui/imports/shared/popups/walletconnect/WalletConnectSDK.qml index e01fbd0627..44807a45a9 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/WalletConnectSDK.qml +++ b/ui/imports/shared/popups/walletconnect/WalletConnectSDK.qml @@ -537,7 +537,7 @@ Item { anchors.fill: parent - url: "qrc:/app/AppLayouts/Wallet/views/walletconnect/sdk/src/index.html" + url: "qrc:/imports/shared/popups/walletconnect/sdk/src/index.html" webChannelObjects: [ statusObject ] onPageLoaded: function() { diff --git a/ui/imports/shared/popups/walletconnect/qmldir b/ui/imports/shared/popups/walletconnect/qmldir new file mode 100644 index 0000000000..4e770088fa --- /dev/null +++ b/ui/imports/shared/popups/walletconnect/qmldir @@ -0,0 +1,2 @@ +WalletConnectSDK 1.0 WalletConnectSDK.qml +ConnectDappPopup 1.0 ConnectDappPopup.qml diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/README.md b/ui/imports/shared/popups/walletconnect/sdk/README.md similarity index 100% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/README.md rename to ui/imports/shared/popups/walletconnect/sdk/README.md diff --git a/ui/imports/shared/popups/walletconnect/sdk/generated/bundle.js b/ui/imports/shared/popups/walletconnect/sdk/generated/bundle.js new file mode 100644 index 0000000000..f1a3bb2d58 --- /dev/null +++ b/ui/imports/shared/popups/walletconnect/sdk/generated/bundle.js @@ -0,0 +1,2 @@ +/*! For license information please see bundle.js.LICENSE.txt */ +var t={972:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=r(4512);function n(t,e,r){return void 0===e&&(e=new Uint8Array(2)),void 0===r&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}function s(t,e,r){return void 0===e&&(e=new Uint8Array(2)),void 0===r&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}function o(t,e){return void 0===e&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function a(t,e){return void 0===e&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function h(t,e){return void 0===e&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function u(t,e){return void 0===e&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}function c(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}function l(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}function f(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),c(t/4294967296>>>0,e,r),c(t>>>0,e,r+4),e}function d(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),l(t>>>0,e,r),l(t/4294967296>>>0,e,r+4),e}e.readInt16BE=function(t,e){return void 0===e&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16},e.readUint16BE=function(t,e){return void 0===e&&(e=0),(t[e+0]<<8|t[e+1])>>>0},e.readInt16LE=function(t,e){return void 0===e&&(e=0),(t[e+1]<<8|t[e])<<16>>16},e.readUint16LE=function(t,e){return void 0===e&&(e=0),(t[e+1]<<8|t[e])>>>0},e.writeUint16BE=n,e.writeInt16BE=n,e.writeUint16LE=s,e.writeInt16LE=s,e.readInt32BE=o,e.readUint32BE=a,e.readInt32LE=h,e.readUint32LE=u,e.writeUint32BE=c,e.writeInt32BE=c,e.writeUint32LE=l,e.writeInt32LE=l,e.readInt64BE=function(t,e){void 0===e&&(e=0);var r=o(t,e),i=o(t,e+4);return 4294967296*r+i-4294967296*(i>>31)},e.readUint64BE=function(t,e){return void 0===e&&(e=0),4294967296*a(t,e)+a(t,e+4)},e.readInt64LE=function(t,e){void 0===e&&(e=0);var r=h(t,e);return 4294967296*h(t,e+4)+r-4294967296*(r>>31)},e.readUint64LE=function(t,e){void 0===e&&(e=0);var r=u(t,e);return 4294967296*u(t,e+4)+r},e.writeUint64BE=f,e.writeInt64BE=f,e.writeUint64LE=d,e.writeInt64LE=d,e.readUintBE=function(t,e,r){if(void 0===r&&(r=0),t%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=t/8+r-1;s>=r;s--)i+=e[s]*n,n*=256;return i},e.readUintLE=function(t,e,r){if(void 0===r&&(r=0),t%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=r;s=n;o--)r[o]=e/s&255,s*=256;return r},e.writeUintLE=function(t,e,r,n){if(void 0===r&&(r=new Uint8Array(t/8)),void 0===n&&(n=0),t%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!i.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var s=1,o=n;o{Object.defineProperty(e,"__esModule",{value:!0});var i=r(972),n=r(6228),s=20;function o(t,e,r){for(var n=1634760805,o=857760878,a=2036477234,h=1797285236,u=r[3]<<24|r[2]<<16|r[1]<<8|r[0],c=r[7]<<24|r[6]<<16|r[5]<<8|r[4],l=r[11]<<24|r[10]<<16|r[9]<<8|r[8],f=r[15]<<24|r[14]<<16|r[13]<<8|r[12],d=r[19]<<24|r[18]<<16|r[17]<<8|r[16],p=r[23]<<24|r[22]<<16|r[21]<<8|r[20],g=r[27]<<24|r[26]<<16|r[25]<<8|r[24],m=r[31]<<24|r[30]<<16|r[29]<<8|r[28],y=e[3]<<24|e[2]<<16|e[1]<<8|e[0],v=e[7]<<24|e[6]<<16|e[5]<<8|e[4],w=e[11]<<24|e[10]<<16|e[9]<<8|e[8],b=e[15]<<24|e[14]<<16|e[13]<<8|e[12],_=n,A=o,E=a,S=h,M=u,I=c,x=l,N=f,O=d,P=p,R=g,T=m,C=y,k=v,U=w,L=b,D=0;D>>16|C<<16)|0)>>>20|M<<12,I=(I^=P=P+(k=(k^=A=A+I|0)>>>16|k<<16)|0)>>>20|I<<12,x=(x^=R=R+(U=(U^=E=E+x|0)>>>16|U<<16)|0)>>>20|x<<12,N=(N^=T=T+(L=(L^=S=S+N|0)>>>16|L<<16)|0)>>>20|N<<12,x=(x^=R=R+(U=(U^=E=E+x|0)>>>24|U<<8)|0)>>>25|x<<7,N=(N^=T=T+(L=(L^=S=S+N|0)>>>24|L<<8)|0)>>>25|N<<7,I=(I^=P=P+(k=(k^=A=A+I|0)>>>24|k<<8)|0)>>>25|I<<7,M=(M^=O=O+(C=(C^=_=_+M|0)>>>24|C<<8)|0)>>>25|M<<7,I=(I^=R=R+(L=(L^=_=_+I|0)>>>16|L<<16)|0)>>>20|I<<12,x=(x^=T=T+(C=(C^=A=A+x|0)>>>16|C<<16)|0)>>>20|x<<12,N=(N^=O=O+(k=(k^=E=E+N|0)>>>16|k<<16)|0)>>>20|N<<12,M=(M^=P=P+(U=(U^=S=S+M|0)>>>16|U<<16)|0)>>>20|M<<12,N=(N^=O=O+(k=(k^=E=E+N|0)>>>24|k<<8)|0)>>>25|N<<7,M=(M^=P=P+(U=(U^=S=S+M|0)>>>24|U<<8)|0)>>>25|M<<7,x=(x^=T=T+(C=(C^=A=A+x|0)>>>24|C<<8)|0)>>>25|x<<7,I=(I^=R=R+(L=(L^=_=_+I|0)>>>24|L<<8)|0)>>>25|I<<7;i.writeUint32LE(_+n|0,t,0),i.writeUint32LE(A+o|0,t,4),i.writeUint32LE(E+a|0,t,8),i.writeUint32LE(S+h|0,t,12),i.writeUint32LE(M+u|0,t,16),i.writeUint32LE(I+c|0,t,20),i.writeUint32LE(x+l|0,t,24),i.writeUint32LE(N+f|0,t,28),i.writeUint32LE(O+d|0,t,32),i.writeUint32LE(P+p|0,t,36),i.writeUint32LE(R+g|0,t,40),i.writeUint32LE(T+m|0,t,44),i.writeUint32LE(C+y|0,t,48),i.writeUint32LE(k+v|0,t,52),i.writeUint32LE(U+w|0,t,56),i.writeUint32LE(L+b|0,t,60)}function a(t,e,r,i,s){if(void 0===s&&(s=0),32!==t.length)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}e.streamXOR=a,e.stream=function(t,e,r,i){return void 0===i&&(i=0),n.wipe(r),a(t,e,r,r,i)}},1612:(t,e,r)=>{var i=r(9918),n=r(7360),s=r(6228),o=r(972),a=r(6452);e.J4=32,e.PX=12,e.iW=16;var h=new Uint8Array(16),u=function(){function t(t){if(this.nonceLength=e.PX,this.tagLength=e.iW,t.length!==e.J4)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(t)}return t.prototype.seal=function(t,e,r,n){if(t.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(t,o.length-t.length);var a=new Uint8Array(32);i.stream(this._key,o,a,4);var h,u=e.length+this.tagLength;if(n){if(n.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");h=n}else h=new Uint8Array(u);return i.streamXOR(this._key,o,e,h,4),this._authenticate(h.subarray(h.length-this.tagLength,h.length),a,h.subarray(0,h.length-this.tagLength),r),s.wipe(o),h},t.prototype.open=function(t,e,r,n){if(t.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(e.length0&&a.update(h.subarray(i.length%16))),a.update(r),r.length%16>0&&a.update(h.subarray(r.length%16));var u=new Uint8Array(8);i&&o.writeUint64LE(i.length,u),a.update(u),o.writeUint64LE(r.length,u),a.update(u);for(var c=a.digest(),l=0;l{function r(t,e){if(t.length!==e.length)return 0;for(var r=0,i=0;i>>8}Object.defineProperty(e,"__esModule",{value:!0}),e.select=function(t,e,r){return~(t-1)&e|t-1&r},e.lessOrEqual=function(t,e){return(0|t)-(0|e)-1>>>31&1},e.compare=r,e.equal=function(t,e){return 0!==t.length&&0!==e.length&&0!==r(t,e)}},4904:(t,e,r)=>{e._S=e.K=e.TP=e.wE=e.Ee=void 0;r(7052);const i=r(4974);r(6228);function n(t){const e=new Float64Array(16);if(t)for(let r=0;r>16&1),r[t-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const t=r[15]>>16&1;r[14]&=65535,f(i,r,1-t)}for(let e=0;e<16;e++)t[2*e]=255&i[e],t[2*e+1]=i[e]>>8}function p(t){const e=new Uint8Array(32);return d(e,t),1&e[0]}function g(t,e,r){for(let i=0;i<16;i++)t[i]=e[i]+r[i]}function m(t,e,r){for(let i=0;i<16;i++)t[i]=e[i]-r[i]}function y(t,e,r){let i,n,s=0,o=0,a=0,h=0,u=0,c=0,l=0,f=0,d=0,p=0,g=0,m=0,y=0,v=0,w=0,b=0,_=0,A=0,E=0,S=0,M=0,I=0,x=0,N=0,O=0,P=0,R=0,T=0,C=0,k=0,U=0,L=r[0],D=r[1],q=r[2],B=r[3],j=r[4],z=r[5],F=r[6],K=r[7],H=r[8],V=r[9],G=r[10],W=r[11],$=r[12],J=r[13],Y=r[14],Q=r[15];i=e[0],s+=i*L,o+=i*D,a+=i*q,h+=i*B,u+=i*j,c+=i*z,l+=i*F,f+=i*K,d+=i*H,p+=i*V,g+=i*G,m+=i*W,y+=i*$,v+=i*J,w+=i*Y,b+=i*Q,i=e[1],o+=i*L,a+=i*D,h+=i*q,u+=i*B,c+=i*j,l+=i*z,f+=i*F,d+=i*K,p+=i*H,g+=i*V,m+=i*G,y+=i*W,v+=i*$,w+=i*J,b+=i*Y,_+=i*Q,i=e[2],a+=i*L,h+=i*D,u+=i*q,c+=i*B,l+=i*j,f+=i*z,d+=i*F,p+=i*K,g+=i*H,m+=i*V,y+=i*G,v+=i*W,w+=i*$,b+=i*J,_+=i*Y,A+=i*Q,i=e[3],h+=i*L,u+=i*D,c+=i*q,l+=i*B,f+=i*j,d+=i*z,p+=i*F,g+=i*K,m+=i*H,y+=i*V,v+=i*G,w+=i*W,b+=i*$,_+=i*J,A+=i*Y,E+=i*Q,i=e[4],u+=i*L,c+=i*D,l+=i*q,f+=i*B,d+=i*j,p+=i*z,g+=i*F,m+=i*K,y+=i*H,v+=i*V,w+=i*G,b+=i*W,_+=i*$,A+=i*J,E+=i*Y,S+=i*Q,i=e[5],c+=i*L,l+=i*D,f+=i*q,d+=i*B,p+=i*j,g+=i*z,m+=i*F,y+=i*K,v+=i*H,w+=i*V,b+=i*G,_+=i*W,A+=i*$,E+=i*J,S+=i*Y,M+=i*Q,i=e[6],l+=i*L,f+=i*D,d+=i*q,p+=i*B,g+=i*j,m+=i*z,y+=i*F,v+=i*K,w+=i*H,b+=i*V,_+=i*G,A+=i*W,E+=i*$,S+=i*J,M+=i*Y,I+=i*Q,i=e[7],f+=i*L,d+=i*D,p+=i*q,g+=i*B,m+=i*j,y+=i*z,v+=i*F,w+=i*K,b+=i*H,_+=i*V,A+=i*G,E+=i*W,S+=i*$,M+=i*J,I+=i*Y,x+=i*Q,i=e[8],d+=i*L,p+=i*D,g+=i*q,m+=i*B,y+=i*j,v+=i*z,w+=i*F,b+=i*K,_+=i*H,A+=i*V,E+=i*G,S+=i*W,M+=i*$,I+=i*J,x+=i*Y,N+=i*Q,i=e[9],p+=i*L,g+=i*D,m+=i*q,y+=i*B,v+=i*j,w+=i*z,b+=i*F,_+=i*K,A+=i*H,E+=i*V,S+=i*G,M+=i*W,I+=i*$,x+=i*J,N+=i*Y,O+=i*Q,i=e[10],g+=i*L,m+=i*D,y+=i*q,v+=i*B,w+=i*j,b+=i*z,_+=i*F,A+=i*K,E+=i*H,S+=i*V,M+=i*G,I+=i*W,x+=i*$,N+=i*J,O+=i*Y,P+=i*Q,i=e[11],m+=i*L,y+=i*D,v+=i*q,w+=i*B,b+=i*j,_+=i*z,A+=i*F,E+=i*K,S+=i*H,M+=i*V,I+=i*G,x+=i*W,N+=i*$,O+=i*J,P+=i*Y,R+=i*Q,i=e[12],y+=i*L,v+=i*D,w+=i*q,b+=i*B,_+=i*j,A+=i*z,E+=i*F,S+=i*K,M+=i*H,I+=i*V,x+=i*G,N+=i*W,O+=i*$,P+=i*J,R+=i*Y,T+=i*Q,i=e[13],v+=i*L,w+=i*D,b+=i*q,_+=i*B,A+=i*j,E+=i*z,S+=i*F,M+=i*K,I+=i*H,x+=i*V,N+=i*G,O+=i*W,P+=i*$,R+=i*J,T+=i*Y,C+=i*Q,i=e[14],w+=i*L,b+=i*D,_+=i*q,A+=i*B,E+=i*j,S+=i*z,M+=i*F,I+=i*K,x+=i*H,N+=i*V,O+=i*G,P+=i*W,R+=i*$,T+=i*J,C+=i*Y,k+=i*Q,i=e[15],b+=i*L,_+=i*D,A+=i*q,E+=i*B,S+=i*j,M+=i*z,I+=i*F,x+=i*K,N+=i*H,O+=i*V,P+=i*G,R+=i*W,T+=i*$,C+=i*J,k+=i*Y,U+=i*Q,s+=38*_,o+=38*A,a+=38*E,h+=38*S,u+=38*M,c+=38*I,l+=38*x,f+=38*N,d+=38*O,p+=38*P,g+=38*R,m+=38*T,y+=38*C,v+=38*k,w+=38*U,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-65536*n,i=o+n+65535,n=Math.floor(i/65536),o=i-65536*n,i=a+n+65535,n=Math.floor(i/65536),a=i-65536*n,i=h+n+65535,n=Math.floor(i/65536),h=i-65536*n,i=u+n+65535,n=Math.floor(i/65536),u=i-65536*n,i=c+n+65535,n=Math.floor(i/65536),c=i-65536*n,i=l+n+65535,n=Math.floor(i/65536),l=i-65536*n,i=f+n+65535,n=Math.floor(i/65536),f=i-65536*n,i=d+n+65535,n=Math.floor(i/65536),d=i-65536*n,i=p+n+65535,n=Math.floor(i/65536),p=i-65536*n,i=g+n+65535,n=Math.floor(i/65536),g=i-65536*n,i=m+n+65535,n=Math.floor(i/65536),m=i-65536*n,i=y+n+65535,n=Math.floor(i/65536),y=i-65536*n,i=v+n+65535,n=Math.floor(i/65536),v=i-65536*n,i=w+n+65535,n=Math.floor(i/65536),w=i-65536*n,i=b+n+65535,n=Math.floor(i/65536),b=i-65536*n,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-65536*n,i=o+n+65535,n=Math.floor(i/65536),o=i-65536*n,i=a+n+65535,n=Math.floor(i/65536),a=i-65536*n,i=h+n+65535,n=Math.floor(i/65536),h=i-65536*n,i=u+n+65535,n=Math.floor(i/65536),u=i-65536*n,i=c+n+65535,n=Math.floor(i/65536),c=i-65536*n,i=l+n+65535,n=Math.floor(i/65536),l=i-65536*n,i=f+n+65535,n=Math.floor(i/65536),f=i-65536*n,i=d+n+65535,n=Math.floor(i/65536),d=i-65536*n,i=p+n+65535,n=Math.floor(i/65536),p=i-65536*n,i=g+n+65535,n=Math.floor(i/65536),g=i-65536*n,i=m+n+65535,n=Math.floor(i/65536),m=i-65536*n,i=y+n+65535,n=Math.floor(i/65536),y=i-65536*n,i=v+n+65535,n=Math.floor(i/65536),v=i-65536*n,i=w+n+65535,n=Math.floor(i/65536),w=i-65536*n,i=b+n+65535,n=Math.floor(i/65536),b=i-65536*n,s+=n-1+37*(n-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=u,t[5]=c,t[6]=l,t[7]=f,t[8]=d,t[9]=p,t[10]=g,t[11]=m,t[12]=y,t[13]=v,t[14]=w,t[15]=b}function v(t,e){y(t,e,e)}function w(t,e){const r=n(),i=n(),s=n(),o=n(),h=n(),u=n(),c=n(),l=n(),f=n();m(r,t[1],t[0]),m(f,e[1],e[0]),y(r,r,f),g(i,t[0],t[1]),g(f,e[0],e[1]),y(i,i,f),y(s,t[3],e[3]),y(s,s,a),y(o,t[2],e[2]),g(o,o,o),m(h,i,r),m(u,o,s),g(c,o,s),g(l,i,r),y(t[0],h,u),y(t[1],l,c),y(t[2],c,u),y(t[3],h,l)}function b(t,e,r){for(let i=0;i<4;i++)f(t[i],e[i],r)}function _(t,e){const r=n(),i=n(),s=n();(function(t,e){const r=n();let i;for(i=0;i<16;i++)r[i]=e[i];for(i=253;i>=0;i--)v(r,r),2!==i&&4!==i&&y(r,r,e);for(i=0;i<16;i++)t[i]=r[i]})(s,e[2]),y(r,e[0],s),y(i,e[1],s),d(t,i),t[31]^=p(r)<<7}function A(t,e){const r=[n(),n(),n(),n()];c(r[0],h),c(r[1],u),c(r[2],o),y(r[3],h,u),function(t,e,r){c(t[0],s),c(t[1],o),c(t[2],o),c(t[3],s);for(let i=255;i>=0;--i){const n=r[i/8|0]>>(7&i)&1;b(t,e,n),w(e,t),w(t,t),b(t,e,n)}}(t,r,e)}e.K=function(t){if(t.length!==e.TP)throw new Error(`ed25519: seed must be ${e.TP} bytes`);const r=(0,i.hash)(t);r[0]&=248,r[31]&=127,r[31]|=64;const s=new Uint8Array(32),o=[n(),n(),n(),n()];A(o,r),_(s,o);const a=new Uint8Array(64);return a.set(t),a.set(s,32),{publicKey:s,secretKey:a}};const E=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function S(t,e){let r,i,n,s;for(i=63;i>=32;--i){for(r=0,n=i-32,s=i-12;n>4)*E[n],r=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=r*E[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,t[i]=255&e[i]}function M(t){const e=new Float64Array(64);for(let r=0;r<64;r++)e[r]=t[r];for(let e=0;e<64;e++)t[e]=0;S(t,e)}e._S=function(t,e){const r=new Float64Array(64),s=[n(),n(),n(),n()],o=(0,i.hash)(t.subarray(0,32));o[0]&=248,o[31]&=127,o[31]|=64;const a=new Uint8Array(64);a.set(o.subarray(32),32);const h=new i.SHA512;h.update(a.subarray(32)),h.update(e);const u=h.digest();h.clean(),M(u),A(s,u),_(a,s),h.reset(),h.update(a.subarray(0,32)),h.update(t.subarray(32)),h.update(e);const c=h.digest();M(c);for(let t=0;t<32;t++)r[t]=u[t];for(let t=0;t<32;t++)for(let e=0;e<32;e++)r[t+e]+=c[t]*o[e];return S(a.subarray(32),r),a}},2670:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isSerializableHash=function(t){return void 0!==t.saveState&&void 0!==t.restoreState&&void 0!==t.cleanSavedState}},6804:(t,e,r)=>{var i=r(2412),n=r(6228),s=function(){function t(t,e,r,n){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=t,this._info=n;var s=i.hmac(this._hash,r,e);this._hmac=new i.HMAC(t,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var t=this._counter[0];if(0===t)throw new Error("hkdf: cannot expand more");this._hmac.reset(),t>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(t){for(var e=new Uint8Array(t),r=0;r{Object.defineProperty(e,"__esModule",{value:!0});var i=r(2670),n=r(6452),s=r(6228),o=function(){function t(t,e){this._finished=!1,this._inner=new t,this._outer=new t,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);e.length>this.blockSize?this._inner.update(e).finish(r).clean():r.set(e);for(var n=0;n{Object.defineProperty(e,"__esModule",{value:!0}),e.mul=Math.imul||function(t,e){var r=65535&t,i=65535&e;return r*i+((t>>>16&65535)*i+r*(e>>>16&65535)<<16>>>0)|0},e.add=function(t,e){return t+e|0},e.sub=function(t,e){return t-e|0},e.rotl=function(t,e){return t<>>32-e},e.rotr=function(t,e){return t<<32-e|t>>>e},e.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},e.MAX_SAFE_INTEGER=9007199254740991,e.isSafeInteger=function(t){return e.isInteger(t)&&t>=-e.MAX_SAFE_INTEGER&&t<=e.MAX_SAFE_INTEGER}},7360:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=r(6452),n=r(6228);e.DIGEST_LENGTH=16;var s=function(){function t(t){this.digestLength=e.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=t[0]|t[1]<<8;this._r[0]=8191&r;var i=t[2]|t[3]<<8;this._r[1]=8191&(r>>>13|i<<3);var n=t[4]|t[5]<<8;this._r[2]=7939&(i>>>10|n<<6);var s=t[6]|t[7]<<8;this._r[3]=8191&(n>>>7|s<<9);var o=t[8]|t[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=t[10]|t[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var h=t[12]|t[13]<<8;this._r[7]=8065&(a>>>11|h<<5);var u=t[14]|t[15]<<8;this._r[8]=8191&(h>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=t[16]|t[17]<<8,this._pad[1]=t[18]|t[19]<<8,this._pad[2]=t[20]|t[21]<<8,this._pad[3]=t[22]|t[23]<<8,this._pad[4]=t[24]|t[25]<<8,this._pad[5]=t[26]|t[27]<<8,this._pad[6]=t[28]|t[29]<<8,this._pad[7]=t[30]|t[31]<<8}return t.prototype._blocks=function(t,e,r){for(var i=this._fin?0:2048,n=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],h=this._h[4],u=this._h[5],c=this._h[6],l=this._h[7],f=this._h[8],d=this._h[9],p=this._r[0],g=this._r[1],m=this._r[2],y=this._r[3],v=this._r[4],w=this._r[5],b=this._r[6],_=this._r[7],A=this._r[8],E=this._r[9];r>=16;){var S=t[e+0]|t[e+1]<<8;n+=8191&S;var M=t[e+2]|t[e+3]<<8;s+=8191&(S>>>13|M<<3);var I=t[e+4]|t[e+5]<<8;o+=8191&(M>>>10|I<<6);var x=t[e+6]|t[e+7]<<8;a+=8191&(I>>>7|x<<9);var N=t[e+8]|t[e+9]<<8;h+=8191&(x>>>4|N<<12),u+=N>>>1&8191;var O=t[e+10]|t[e+11]<<8;c+=8191&(N>>>14|O<<2);var P=t[e+12]|t[e+13]<<8;l+=8191&(O>>>11|P<<5);var R=t[e+14]|t[e+15]<<8,T=0,C=T;C+=n*p,C+=s*(5*E),C+=o*(5*A),C+=a*(5*_),T=(C+=h*(5*b))>>>13,C&=8191,C+=u*(5*w),C+=c*(5*v),C+=l*(5*y),C+=(f+=8191&(P>>>8|R<<8))*(5*m);var k=T+=(C+=(d+=R>>>5|i)*(5*g))>>>13;k+=n*g,k+=s*p,k+=o*(5*E),k+=a*(5*A),T=(k+=h*(5*_))>>>13,k&=8191,k+=u*(5*b),k+=c*(5*w),k+=l*(5*v),k+=f*(5*y),T+=(k+=d*(5*m))>>>13,k&=8191;var U=T;U+=n*m,U+=s*g,U+=o*p,U+=a*(5*E),T=(U+=h*(5*A))>>>13,U&=8191,U+=u*(5*_),U+=c*(5*b),U+=l*(5*w),U+=f*(5*v);var L=T+=(U+=d*(5*y))>>>13;L+=n*y,L+=s*m,L+=o*g,L+=a*p,T=(L+=h*(5*E))>>>13,L&=8191,L+=u*(5*A),L+=c*(5*_),L+=l*(5*b),L+=f*(5*w);var D=T+=(L+=d*(5*v))>>>13;D+=n*v,D+=s*y,D+=o*m,D+=a*g,T=(D+=h*p)>>>13,D&=8191,D+=u*(5*E),D+=c*(5*A),D+=l*(5*_),D+=f*(5*b);var q=T+=(D+=d*(5*w))>>>13;q+=n*w,q+=s*v,q+=o*y,q+=a*m,T=(q+=h*g)>>>13,q&=8191,q+=u*p,q+=c*(5*E),q+=l*(5*A),q+=f*(5*_);var B=T+=(q+=d*(5*b))>>>13;B+=n*b,B+=s*w,B+=o*v,B+=a*y,T=(B+=h*m)>>>13,B&=8191,B+=u*g,B+=c*p,B+=l*(5*E),B+=f*(5*A);var j=T+=(B+=d*(5*_))>>>13;j+=n*_,j+=s*b,j+=o*w,j+=a*v,T=(j+=h*y)>>>13,j&=8191,j+=u*m,j+=c*g,j+=l*p,j+=f*(5*E);var z=T+=(j+=d*(5*A))>>>13;z+=n*A,z+=s*_,z+=o*b,z+=a*w,T=(z+=h*v)>>>13,z&=8191,z+=u*y,z+=c*m,z+=l*g,z+=f*p;var F=T+=(z+=d*(5*E))>>>13;F+=n*E,F+=s*A,F+=o*_,F+=a*b,T=(F+=h*w)>>>13,F&=8191,F+=u*v,F+=c*y,F+=l*m,F+=f*g,n=C=8191&(T=(T=((T+=(F+=d*p)>>>13)<<2)+T|0)+(C&=8191)|0),s=k+=T>>>=13,o=U&=8191,a=L&=8191,h=D&=8191,u=q&=8191,c=B&=8191,l=j&=8191,f=z&=8191,d=F&=8191,e+=16,r-=16}this._h[0]=n,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=h,this._h[5]=u,this._h[6]=c,this._h[7]=l,this._h[8]=f,this._h[9]=d},t.prototype.finish=function(t,e){void 0===e&&(e=0);var r,i,n,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,i=(1^r)-1,s=0;s<10;s++)o[s]&=i;for(i=~i,s=0;s<10;s++)this._h[s]=this._h[s]&i|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),n=this._h[0]+this._pad[0],this._h[0]=65535&n,s=1;s<8;s++)n=(this._h[s]+this._pad[s]|0)+(n>>>16)|0,this._h[s]=65535&n;return t[e+0]=this._h[0]>>>0,t[e+1]=this._h[0]>>>8,t[e+2]=this._h[1]>>>0,t[e+3]=this._h[1]>>>8,t[e+4]=this._h[2]>>>0,t[e+5]=this._h[2]>>>8,t[e+6]=this._h[3]>>>0,t[e+7]=this._h[3]>>>8,t[e+8]=this._h[4]>>>0,t[e+9]=this._h[4]>>>8,t[e+10]=this._h[5]>>>0,t[e+11]=this._h[5]>>>8,t[e+12]=this._h[6]>>>0,t[e+13]=this._h[6]>>>8,t[e+14]=this._h[7]>>>0,t[e+15]=this._h[7]>>>8,this._finished=!0,this},t.prototype.update=function(t){var e,r=0,i=t.length;if(this._leftover){(e=16-this._leftover)>i&&(e=i);for(var n=0;n=16&&(e=i-i%16,this._blocks(t,r,e),r+=e,i-=e),i){for(n=0;n{Object.defineProperty(e,"__esModule",{value:!0}),e.randomStringForEntropy=e.randomString=e.randomUint32=e.randomBytes=e.defaultRandomSource=void 0;const i=r(5492),n=r(972),s=r(6228);function o(t,r=e.defaultRandomSource){return r.randomBytes(t)}e.defaultRandomSource=new i.SystemRandomSource,e.randomBytes=o,e.randomUint32=function(t=e.defaultRandomSource){const r=o(4,t),i=(0,n.readUint32LE)(r);return(0,s.wipe)(r),i};const a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function h(t,r=a,i=e.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let n="";const h=r.length,u=256-256%h;for(;t>0;){const e=o(Math.ceil(256*t/u),i);for(let i=0;i0;i++){const s=e[i];s{Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserRandomSource=void 0,e.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&void 0!==t.getRandomValues&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.NodeRandomSource=void 0;const i=r(6228);e.NodeRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const t=r(9432);t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(t);if(e.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(t);for(let t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.SystemRandomSource=void 0;const i=r(7029),n=r(5821);e.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new i.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new n.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}},204:(t,e,r)=>{var i=r(972),n=r(6228);e.On=32,e.cS=64;var s=function(){function t(){this.digestLength=e.On,this.blockSize=e.cS,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return t.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){n.wipe(this._buffer),n.wipe(this._temp),this.reset()},t.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=e,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=t[r++],e--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(e>=this.blockSize&&(r=a(this._temp,this._state,t,r,e),e%=this.blockSize);e>0;)this._buffer[this._bufferLength++]=t[r++],e--;return this},t.prototype.finish=function(t){if(!this._finished){var e=this._bytesHashed,r=this._bufferLength,n=e/536870912|0,s=e<<3,o=e%64<56?64:128;this._buffer[r]=128;for(var h=r+1;h0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(t){return this._state.set(t.state),this._bufferLength=t.bufferLength,t.buffer&&this._buffer.set(t.buffer),this._bytesHashed=t.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(t){n.wipe(t.state),t.buffer&&n.wipe(t.buffer),t.bufferLength=0,t.bytesHashed=0},t}();e.aD=s;var o=new Int32Array([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]);function a(t,e,r,n,s){for(;s>=64;){for(var a=e[0],h=e[1],u=e[2],c=e[3],l=e[4],f=e[5],d=e[6],p=e[7],g=0;g<16;g++){var m=n+4*g;t[g]=i.readUint32BE(r,m)}for(g=16;g<64;g++){var y=t[g-2],v=(y>>>17|y<<15)^(y>>>19|y<<13)^y>>>10,w=((y=t[g-15])>>>7|y<<25)^(y>>>18|y<<14)^y>>>3;t[g]=(v+t[g-7]|0)+(w+t[g-16]|0)}for(g=0;g<64;g++)v=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&d)|0)+(p+(o[g]+t[g]|0)|0)|0,w=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&h^a&u^h&u)|0,p=d,d=f,f=l,l=c+v|0,c=u,u=h,h=a,a=v+w|0;e[0]+=a,e[1]+=h,e[2]+=u,e[3]+=c,e[4]+=l,e[5]+=f,e[6]+=d,e[7]+=p,n+=64,s-=64}return n}e.tW=function(t){var e=new s;e.update(t);var r=e.digest();return e.clean(),r}},4974:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=r(972),n=r(6228);e.DIGEST_LENGTH=64,e.BLOCK_SIZE=128;var s=function(){function t(){this.digestLength=e.DIGEST_LENGTH,this.blockSize=e.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return t.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){n.wipe(this._buffer),n.wipe(this._tempHi),n.wipe(this._tempLo),this.reset()},t.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=t[i++],r--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(i=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,t,i,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=t[i++],r--;return this},t.prototype.finish=function(t){if(!this._finished){var e=this._bytesHashed,r=this._bufferLength,n=e/536870912|0,s=e<<3,o=e%128<112?128:256;this._buffer[r]=128;for(var h=r+1;h0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(t){return this._stateHi.set(t.stateHi),this._stateLo.set(t.stateLo),this._bufferLength=t.bufferLength,t.buffer&&this._buffer.set(t.buffer),this._bytesHashed=t.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(t){n.wipe(t.stateHi),n.wipe(t.stateLo),t.buffer&&n.wipe(t.buffer),t.bufferLength=0,t.bytesHashed=0},t}();e.SHA512=s;var o=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function a(t,e,r,n,s,a,h){for(var u,c,l,f,d,p,g,m,y=r[0],v=r[1],w=r[2],b=r[3],_=r[4],A=r[5],E=r[6],S=r[7],M=n[0],I=n[1],x=n[2],N=n[3],O=n[4],P=n[5],R=n[6],T=n[7];h>=128;){for(var C=0;C<16;C++){var k=8*C+a;t[C]=i.readUint32BE(s,k),e[C]=i.readUint32BE(s,k+4)}for(C=0;C<80;C++){var U,L,D=y,q=v,B=w,j=b,z=_,F=A,K=E,H=M,V=I,G=x,W=N,$=O,J=P,Y=R;if(d=65535&(c=T),p=c>>>16,g=65535&(u=S),m=u>>>16,d+=65535&(c=(O>>>14|_<<18)^(O>>>18|_<<14)^(_>>>9|O<<23)),p+=c>>>16,g+=65535&(u=(_>>>14|O<<18)^(_>>>18|O<<14)^(O>>>9|_<<23)),m+=u>>>16,d+=65535&(c=O&P^~O&R),p+=c>>>16,g+=65535&(u=_&A^~_&E),m+=u>>>16,u=o[2*C],d+=65535&(c=o[2*C+1]),p+=c>>>16,g+=65535&u,m+=u>>>16,u=t[C%16],p+=(c=e[C%16])>>>16,g+=65535&u,m+=u>>>16,g+=(p+=(d+=65535&c)>>>16)>>>16,d=65535&(c=f=65535&d|p<<16),p=c>>>16,g=65535&(u=l=65535&g|(m+=g>>>16)<<16),m=u>>>16,d+=65535&(c=(M>>>28|y<<4)^(y>>>2|M<<30)^(y>>>7|M<<25)),p+=c>>>16,g+=65535&(u=(y>>>28|M<<4)^(M>>>2|y<<30)^(M>>>7|y<<25)),m+=u>>>16,p+=(c=M&I^M&x^I&x)>>>16,g+=65535&(u=y&v^y&w^v&w),m+=u>>>16,U=65535&(g+=(p+=(d+=65535&c)>>>16)>>>16)|(m+=g>>>16)<<16,L=65535&d|p<<16,d=65535&(c=W),p=c>>>16,g=65535&(u=j),m=u>>>16,p+=(c=f)>>>16,g+=65535&(u=l),m+=u>>>16,v=D,w=q,b=B,_=j=65535&(g+=(p+=(d+=65535&c)>>>16)>>>16)|(m+=g>>>16)<<16,A=z,E=F,S=K,y=U,I=H,x=V,N=G,O=W=65535&d|p<<16,P=$,R=J,T=Y,M=L,C%16==15)for(k=0;k<16;k++)u=t[k],d=65535&(c=e[k]),p=c>>>16,g=65535&u,m=u>>>16,u=t[(k+9)%16],d+=65535&(c=e[(k+9)%16]),p+=c>>>16,g+=65535&u,m+=u>>>16,l=t[(k+1)%16],d+=65535&(c=((f=e[(k+1)%16])>>>1|l<<31)^(f>>>8|l<<24)^(f>>>7|l<<25)),p+=c>>>16,g+=65535&(u=(l>>>1|f<<31)^(l>>>8|f<<24)^l>>>7),m+=u>>>16,l=t[(k+14)%16],p+=(c=((f=e[(k+14)%16])>>>19|l<<13)^(l>>>29|f<<3)^(f>>>6|l<<26))>>>16,g+=65535&(u=(l>>>19|f<<13)^(f>>>29|l<<3)^l>>>6),m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,t[k]=65535&g|m<<16,e[k]=65535&d|p<<16}d=65535&(c=M),p=c>>>16,g=65535&(u=y),m=u>>>16,u=r[0],p+=(c=n[0])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[0]=y=65535&g|m<<16,n[0]=M=65535&d|p<<16,d=65535&(c=I),p=c>>>16,g=65535&(u=v),m=u>>>16,u=r[1],p+=(c=n[1])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[1]=v=65535&g|m<<16,n[1]=I=65535&d|p<<16,d=65535&(c=x),p=c>>>16,g=65535&(u=w),m=u>>>16,u=r[2],p+=(c=n[2])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[2]=w=65535&g|m<<16,n[2]=x=65535&d|p<<16,d=65535&(c=N),p=c>>>16,g=65535&(u=b),m=u>>>16,u=r[3],p+=(c=n[3])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[3]=b=65535&g|m<<16,n[3]=N=65535&d|p<<16,d=65535&(c=O),p=c>>>16,g=65535&(u=_),m=u>>>16,u=r[4],p+=(c=n[4])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[4]=_=65535&g|m<<16,n[4]=O=65535&d|p<<16,d=65535&(c=P),p=c>>>16,g=65535&(u=A),m=u>>>16,u=r[5],p+=(c=n[5])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[5]=A=65535&g|m<<16,n[5]=P=65535&d|p<<16,d=65535&(c=R),p=c>>>16,g=65535&(u=E),m=u>>>16,u=r[6],p+=(c=n[6])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[6]=E=65535&g|m<<16,n[6]=R=65535&d|p<<16,d=65535&(c=T),p=c>>>16,g=65535&(u=S),m=u>>>16,u=r[7],p+=(c=n[7])>>>16,g+=65535&u,m+=u>>>16,m+=(g+=(p+=(d+=65535&c)>>>16)>>>16)>>>16,r[7]=S=65535&g|m<<16,n[7]=T=65535&d|p<<16,a+=128,h-=128}return a}e.hash=function(t){var e=new s;e.update(t);var r=e.digest();return e.clean(),r}},6228:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wipe=function(t){for(var e=0;e{e.Tc=e.TZ=e.wE=e.Xx=void 0;const i=r(7052),n=r(6228);function s(t){const e=new Float64Array(16);if(t)for(let r=0;r=0;--t){const e=r[t>>>3]>>>(7&t)&1;u(n,o,e),u(p,g,e),c(m,n,p),l(n,n,p),c(p,o,g),l(o,o,g),d(g,m),d(y,n),f(n,p,n),f(p,o,m),c(m,n,p),l(n,n,p),d(o,n),l(p,g,y),f(n,p,a),c(n,n,g),f(p,p,n),f(n,g,y),f(g,o,i),d(o,m),u(n,o,e),u(p,g,e)}for(let t=0;t<16;t++)i[t+16]=n[t],i[t+32]=p[t],i[t+48]=o[t],i[t+64]=g[t];const v=i.subarray(32),w=i.subarray(16);!function(t,e){const r=s();for(let t=0;t<16;t++)r[t]=e[t];for(let t=253;t>=0;t--)d(r,r),2!==t&&4!==t&&f(r,r,e);for(let e=0;e<16;e++)t[e]=r[e]}(v,v),f(w,w,v);const b=new Uint8Array(32);return function(t,e){const r=s(),i=s();for(let t=0;t<16;t++)i[t]=e[t];h(i),h(i),h(i);for(let t=0;t<2;t++){r[0]=i[0]-65517;for(let t=1;t<15;t++)r[t]=i[t]-65535-(r[t-1]>>16&1),r[t-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const t=r[15]>>16&1;r[14]&=65535,u(i,r,1-t)}for(let e=0;e<16;e++)t[2*e]=255&i[e],t[2*e+1]=i[e]>>8}(b,w),b}e.TZ=function(t){const r=(0,i.randomBytes)(32,t),s=function(t){if(t.length!==e.wE)throw new Error(`x25519: seed must be ${e.wE} bytes`);const r=new Uint8Array(t);return{publicKey:(i=r,p(i,o)),secretKey:r};var i}(r);return(0,n.wipe)(r),s},e.Tc=function(t,r,i=!1){if(t.length!==e.Xx)throw new Error("X25519: incorrect secret key length");if(r.length!==e.Xx)throw new Error("X25519: incorrect public key length");const n=p(t,r);if(i){let t=0;for(let e=0;e{function i(){return(null===r.g||void 0===r.g?void 0:r.g.crypto)||(null===r.g||void 0===r.g?void 0:r.g.msCrypto)||{}}function n(){const t=i();return t.subtle||t.webkitSubtle}Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowserCryptoAvailable=e.getSubtleCrypto=e.getBrowerCrypto=void 0,e.getBrowerCrypto=i,e.getSubtleCrypto=n,e.isBrowserCryptoAvailable=function(){return!!i()&&!!n()}},1089:(t,e)=>{function r(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function i(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node}Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowser=e.isNode=e.isReactNative=void 0,e.isReactNative=r,e.isNode=i,e.isBrowser=function(){return!r()&&!i()}},5682:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(5215);i.__exportStar(r(7173),e),i.__exportStar(r(1089),e)},4556:(t,e,r)=>{r.d(e,{H:()=>i});class i{}},4833:(t,e,r)=>{r.r(e),r.d(e,{IEvents:()=>i.H});var i=r(4556)},8859:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HEARTBEAT_EVENTS=e.HEARTBEAT_INTERVAL=void 0;const i=r(8900);e.HEARTBEAT_INTERVAL=i.FIVE_SECONDS,e.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"}},6223:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),r(5215).__exportStar(r(8859),e)},6401:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HeartBeat=void 0;const i=r(5215),n=r(7007),s=r(8900),o=r(4359),a=r(6223);class h extends o.IHeartBeat{constructor(t){super(t),this.events=new n.EventEmitter,this.interval=a.HEARTBEAT_INTERVAL,this.interval=(null==t?void 0:t.interval)||a.HEARTBEAT_INTERVAL}static init(t){return i.__awaiter(this,void 0,void 0,(function*(){const e=new h(t);return yield e.init(),e}))}init(){return i.__awaiter(this,void 0,void 0,(function*(){yield this.initialize()}))}stop(){clearInterval(this.intervalRef)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}initialize(){return i.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),s.toMiliseconds(this.interval))}))}pulse(){this.events.emit(a.HEARTBEAT_EVENTS.pulse)}}e.HeartBeat=h},6545:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(5215);i.__exportStar(r(6401),e),i.__exportStar(r(4359),e),i.__exportStar(r(6223),e)},8451:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IHeartBeat=void 0;const i=r(4833);class n extends i.IEvents{constructor(t){super()}}e.IHeartBeat=n},4359:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),r(5215).__exportStar(r(8451),e)},5825:()=>{},5665:()=>{},9026:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(5215);i.__exportStar(r(9244),e),i.__exportStar(r(1861),e)},9244:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_THOUSAND=e.ONE_HUNDRED=void 0,e.ONE_HUNDRED=100,e.ONE_THOUSAND=1e3},1861:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=5*e.ONE_MINUTE,e.TEN_MINUTES=10*e.ONE_MINUTE,e.THIRTY_MINUTES=30*e.ONE_MINUTE,e.SIXTY_MINUTES=60*e.ONE_MINUTE,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=3*e.ONE_HOUR,e.SIX_HOURS=6*e.ONE_HOUR,e.TWELVE_HOURS=12*e.ONE_HOUR,e.TWENTY_FOUR_HOURS=24*e.ONE_HOUR,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=3*e.ONE_DAY,e.FIVE_DAYS=5*e.ONE_DAY,e.SEVEN_DAYS=7*e.ONE_DAY,e.THIRTY_DAYS=30*e.ONE_DAY,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=2*e.ONE_WEEK,e.THREE_WEEKS=3*e.ONE_WEEK,e.FOUR_WEEKS=4*e.ONE_WEEK,e.ONE_YEAR=365*e.ONE_DAY},8900:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(5215);i.__exportStar(r(9606),e),i.__exportStar(r(9883),e),i.__exportStar(r(2010),e),i.__exportStar(r(9026),e)},2010:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),r(5215).__exportStar(r(3093),e)},3093:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IWatch=void 0,e.IWatch=class{}},221:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fromMiliseconds=e.toMiliseconds=void 0;const i=r(9026);e.toMiliseconds=function(t){return t*i.ONE_THOUSAND},e.fromMiliseconds=function(t){return Math.floor(t/i.ONE_THOUSAND)}},2985:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.delay=void 0,e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}},9606:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=r(5215);i.__exportStar(r(2985),e),i.__exportStar(r(221),e)},9883:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const e=this.get(t);if(void 0!==e.elapsed)throw new Error(`Watch already stopped for label: ${t}`);const r=Date.now()-e.started;this.timestamps.set(t,{started:e.started,elapsed:r})}get(t){const e=this.timestamps.get(t);if(void 0===e)throw new Error(`No timestamp found for label: ${t}`);return e}elapsed(t){const e=this.get(t);return e.elapsed||Date.now()-e.started}}e.Watch=r,e.default=r},8196:(t,e)=>{function r(t){let e;return"undefined"!=typeof window&&void 0!==window[t]&&(e=window[t]),e}function i(t){const e=r(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Object.defineProperty(e,"__esModule",{value:!0}),e.getLocalStorage=e.getLocalStorageOrThrow=e.getCrypto=e.getCryptoOrThrow=e.getLocation=e.getLocationOrThrow=e.getNavigator=e.getNavigatorOrThrow=e.getDocument=e.getDocumentOrThrow=e.getFromWindowOrThrow=e.getFromWindow=void 0,e.getFromWindow=r,e.getFromWindowOrThrow=i,e.getDocumentOrThrow=function(){return i("document")},e.getDocument=function(){return r("document")},e.getNavigatorOrThrow=function(){return i("navigator")},e.getNavigator=function(){return r("navigator")},e.getLocationOrThrow=function(){return i("location")},e.getLocation=function(){return r("location")},e.getCryptoOrThrow=function(){return i("crypto")},e.getCrypto=function(){return r("crypto")},e.getLocalStorageOrThrow=function(){return i("localStorage")},e.getLocalStorage=function(){return r("localStorage")}},2063:(t,e,r)=>{e.g=void 0;const i=r(8196);e.g=function(){let t,e;try{t=i.getDocumentOrThrow(),e=i.getLocationOrThrow()}catch(t){return null}function r(...e){const r=t.getElementsByTagName("meta");for(let t=0;ti.getAttribute(t))).filter((t=>!!t&&e.includes(t)));if(n.length&&n){const t=i.getAttribute("content");if(t)return t}}return""}const n=function(){let e=r("name","og:site_name","og:title","twitter:title");return e||(e=t.title),e}();return{description:r("description","og:description","twitter:description","keywords"),url:e.origin,icons:function(){const r=t.getElementsByTagName("link"),i=[];for(let t=0;t-1){const t=n.getAttribute("href");if(t)if(-1===t.toLowerCase().indexOf("https:")&&-1===t.toLowerCase().indexOf("http:")&&0!==t.indexOf("//")){let r=e.protocol+"//"+e.host;if(0===t.indexOf("/"))r+=t;else{const i=e.pathname.split("/");i.pop(),r+=i.join("/")+"/"+t}i.push(r)}else if(0===t.indexOf("//")){const r=e.protocol+t;i.push(r)}else i.push(t)}}return i}(),name:n}}},9404:function(t,e,r){!function(t,e){function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(7790).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+t)}function h(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function u(t,e,r,n){for(var s=0,o=0,a=Math.min(t.length,r),h=e;h=49?u-49+10:u>=17?u-17+10:u,i(u>=0&&o0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=h(t,e,i)<=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){s.prototype.inspect=l}else s.prototype.inspect=l;function l(){return(this.red?""}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function g(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,l=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;c+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|c}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==s||o!==this.length-1?f[6-h.length]+h+r:h+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],c=p[t];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var g=l.modrn(c).toString(t);r=(l=l.idivn(c)).isZero()?g+r:f[u-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,n),o},s.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,s=0;n>8&255),r>16&255),6===s?(r>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,m=0|o[2],y=8191&m,v=m>>>13,w=0|o[3],b=8191&w,_=w>>>13,A=0|o[4],E=8191&A,S=A>>>13,M=0|o[5],I=8191&M,x=M>>>13,N=0|o[6],O=8191&N,P=N>>>13,R=0|o[7],T=8191&R,C=R>>>13,k=0|o[8],U=8191&k,L=k>>>13,D=0|o[9],q=8191&D,B=D>>>13,j=0|a[0],z=8191&j,F=j>>>13,K=0|a[1],H=8191&K,V=K>>>13,G=0|a[2],W=8191&G,$=G>>>13,J=0|a[3],Y=8191&J,Q=J>>>13,X=0|a[4],Z=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ct=0|a[8],lt=8191&ct,ft=ct>>>13,dt=0|a[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(i=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(f,z)|0))<<13)|0;u=((s=Math.imul(f,F))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,z),n=(n=Math.imul(p,F))+Math.imul(g,z)|0,s=Math.imul(g,F);var yt=(u+(i=i+Math.imul(l,H)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(f,H)|0))<<13)|0;u=((s=s+Math.imul(f,V)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,z),n=(n=Math.imul(y,F))+Math.imul(v,z)|0,s=Math.imul(v,F),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(g,H)|0,s=s+Math.imul(g,V)|0;var vt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,$)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(b,z),n=(n=Math.imul(b,F))+Math.imul(_,z)|0,s=Math.imul(_,F),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,V)|0)+Math.imul(v,H)|0,s=s+Math.imul(v,V)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(g,W)|0,s=s+Math.imul(g,$)|0;var wt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,Q)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,Q)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(E,z),n=(n=Math.imul(E,F))+Math.imul(S,z)|0,s=Math.imul(S,F),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,V)|0)+Math.imul(_,H)|0,s=s+Math.imul(_,V)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(v,W)|0,s=s+Math.imul(v,$)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,Q)|0;var bt=(u+(i=i+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(f,Z)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(I,z),n=(n=Math.imul(I,F))+Math.imul(x,z)|0,s=Math.imul(x,F),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,V)|0)+Math.imul(S,H)|0,s=s+Math.imul(S,V)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,Q)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Z)|0,s=s+Math.imul(g,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(O,z),n=(n=Math.imul(O,F))+Math.imul(P,z)|0,s=Math.imul(P,F),i=i+Math.imul(I,H)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(x,H)|0,s=s+Math.imul(x,V)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,$)|0)+Math.imul(S,W)|0,s=s+Math.imul(S,$)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,Q)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,Q)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,Z)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,s=s+Math.imul(g,it)|0;var At=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(T,z),n=(n=Math.imul(T,F))+Math.imul(C,z)|0,s=Math.imul(C,F),i=i+Math.imul(O,H)|0,n=(n=n+Math.imul(O,V)|0)+Math.imul(P,H)|0,s=s+Math.imul(P,V)|0,i=i+Math.imul(I,W)|0,n=(n=n+Math.imul(I,$)|0)+Math.imul(x,W)|0,s=s+Math.imul(x,$)|0,i=i+Math.imul(E,Y)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,Q)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(_,Z)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(g,st)|0,s=s+Math.imul(g,ot)|0;var Et=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,z),n=(n=Math.imul(U,F))+Math.imul(L,z)|0,s=Math.imul(L,F),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(C,H)|0,s=s+Math.imul(C,V)|0,i=i+Math.imul(O,W)|0,n=(n=n+Math.imul(O,$)|0)+Math.imul(P,W)|0,s=s+Math.imul(P,$)|0,i=i+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,Q)|0)+Math.imul(x,Y)|0,s=s+Math.imul(x,Q)|0,i=i+Math.imul(E,Z)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,Z)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(g,ht)|0,s=s+Math.imul(g,ut)|0;var St=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(q,z),n=(n=Math.imul(q,F))+Math.imul(B,z)|0,s=Math.imul(B,F),i=i+Math.imul(U,H)|0,n=(n=n+Math.imul(U,V)|0)+Math.imul(L,H)|0,s=s+Math.imul(L,V)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,Q)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,Q)|0,i=i+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(x,Z)|0,s=s+Math.imul(x,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(g,lt)|0,s=s+Math.imul(g,ft)|0;var Mt=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,gt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,gt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(q,H),n=(n=Math.imul(q,V))+Math.imul(B,H)|0,s=Math.imul(B,V),i=i+Math.imul(U,W)|0,n=(n=n+Math.imul(U,$)|0)+Math.imul(L,W)|0,s=s+Math.imul(L,$)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,Q)|0,i=i+Math.imul(O,Z)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(x,rt)|0,s=s+Math.imul(x,it)|0,i=i+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(v,lt)|0,s=s+Math.imul(v,ft)|0;var It=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((s=s+Math.imul(g,gt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(q,W),n=(n=Math.imul(q,$))+Math.imul(B,W)|0,s=Math.imul(B,$),i=i+Math.imul(U,Y)|0,n=(n=n+Math.imul(U,Q)|0)+Math.imul(L,Y)|0,s=s+Math.imul(L,Q)|0,i=i+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Z)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(x,st)|0,s=s+Math.imul(x,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,ut)|0,i=i+Math.imul(b,lt)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ft)|0;var xt=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((s=s+Math.imul(v,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(q,Y),n=(n=Math.imul(q,Q))+Math.imul(B,Y)|0,s=Math.imul(B,Q),i=i+Math.imul(U,Z)|0,n=(n=n+Math.imul(U,tt)|0)+Math.imul(L,Z)|0,s=s+Math.imul(L,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,i=i+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(x,ht)|0,s=s+Math.imul(x,ut)|0,i=i+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ft)|0)+Math.imul(S,lt)|0,s=s+Math.imul(S,ft)|0;var Nt=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,gt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(q,Z),n=(n=Math.imul(q,tt))+Math.imul(B,Z)|0,s=Math.imul(B,tt),i=i+Math.imul(U,rt)|0,n=(n=n+Math.imul(U,it)|0)+Math.imul(L,rt)|0,s=s+Math.imul(L,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,i=i+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,ft)|0)+Math.imul(x,lt)|0,s=s+Math.imul(x,ft)|0;var Ot=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,gt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((s=s+Math.imul(S,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(q,rt),n=(n=Math.imul(q,it))+Math.imul(B,rt)|0,s=Math.imul(B,it),i=i+Math.imul(U,st)|0,n=(n=n+Math.imul(U,ot)|0)+Math.imul(L,st)|0,s=s+Math.imul(L,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(O,lt)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,ft)|0;var Pt=(u+(i=i+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,gt)|0)+Math.imul(x,pt)|0))<<13)|0;u=((s=s+Math.imul(x,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(q,st),n=(n=Math.imul(q,ot))+Math.imul(B,st)|0,s=Math.imul(B,ot),i=i+Math.imul(U,ht)|0,n=(n=n+Math.imul(U,ut)|0)+Math.imul(L,ht)|0,s=s+Math.imul(L,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ft)|0;var Rt=(u+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(q,ht),n=(n=Math.imul(q,ut))+Math.imul(B,ht)|0,s=Math.imul(B,ut),i=i+Math.imul(U,lt)|0,n=(n=n+Math.imul(U,ft)|0)+Math.imul(L,lt)|0,s=s+Math.imul(L,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,gt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(q,lt),n=(n=Math.imul(q,ft))+Math.imul(B,lt)|0,s=Math.imul(B,ft);var Ct=(u+(i=i+Math.imul(U,pt)|0)|0)+((8191&(n=(n=n+Math.imul(U,gt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((s=s+Math.imul(L,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var kt=(u+(i=Math.imul(q,pt))|0)+((8191&(n=(n=Math.imul(q,gt))+Math.imul(B,pt)|0))<<13)|0;return u=((s=Math.imul(B,gt))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h[0]=mt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=_t,h[6]=At,h[7]=Et,h[8]=St,h[9]=Mt,h[10]=It,h[11]=xt,h[12]=Nt,h[13]=Ot,h[14]=Pt,h[15]=Rt,h[16]=Tt,h[17]=Ct,h[18]=kt,0!==u&&(h[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function v(t,e,r){return y(t,e,r)}function w(t,e){this.x=t,this.y=e}Math.imul||(m=g),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?g(this,t,e):r<1024?y(this,t,e):v(this,t,e)},w.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i>=1;return i},w.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),e?this.ineg():this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n&1}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==c||u>=n);u--){var l=0|this.words[u];this.words[u]=c<<26-s|l>>>s,c=l&a}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,h=i.length-n.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var f=67108864*(0|i.words[n.length+l])+(0|i.words[n.length+l-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(n,f,l);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=f)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):this.negative&t.negative?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%t;return e?-n:n},s.prototype.modn=function(t){return this.modrn(t)},s.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/t|0,r=s%t}return this._strip(),e?this.ineg():this},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),h=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),l=e.clone();!e.isZero();){for(var f=0,d=1;!(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(c),o.isub(l)),n.iushrn(1),o.iushrn(1);for(var p=0,g=1;!(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(c),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(h)):(r.isub(e),a.isub(n),h.isub(o))}return{a,b:h,gcd:r.iushln(u)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),h=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;!(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,f=1;!(r.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new I(t)},s.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var b={k256:null,p224:null,p192:null,p25519:null};function _(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function A(){_.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){_.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){_.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){_.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function I(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){I.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}_.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},_.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},_.prototype.split=function(t,e){t.iushrn(this.n,0,e)},_.prototype.imulK=function(t){return t.imul(this.k)},n(A,_),A.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},A.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(b[t])return b[t];var e;if("k256"===t)e=new A;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return b[t]=e,e},I.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},I.prototype._verify2=function(t,e){i(!(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},I.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},I.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},I.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},I.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},I.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},I.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},I.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},I.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},I.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},I.prototype.isqr=function(t){return this.imul(t,t.clone())},I.prototype.sqr=function(t){return this.mul(t,t)},I.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new s(2*c*c).toRed(this);0!==this.pow(c,u).cmp(h);)c.redIAdd(h);for(var l=this.pow(c,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(a);){for(var g=d,m=0;0!==g.cmp(a);m++)g=g.redSqr();i(m=0;i--){for(var u=e.words[i],c=h-1;c>=0;c--){var l=u>>c&1;n!==r[0]&&(n=this.sqr(n)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===i&&0===c)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}h=26}return n},I.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},I.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new x(t)},n(x,I),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},454:t=>{var e="%[a-f0-9]{2}",r=new RegExp("("+e+")|([^%]+?)","gi"),i=new RegExp("("+e+")+","gi");function n(t,e){try{return[decodeURIComponent(t.join(""))]}catch(t){}if(1===t.length)return t;e=e||1;var r=t.slice(0,e),i=t.slice(e);return Array.prototype.concat.call([],n(r),n(i))}function s(t){try{return decodeURIComponent(t)}catch(s){for(var e=t.match(r)||[],i=1;i{var e,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,s),i(r)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",n),r([].slice.call(arguments))}g(t,e,s,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&g(t,"error",e,{once:!0})}(t,n)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function u(t,e,r,i){var n,s,o,u;if(a(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),void 0===o)o=s[e]=r,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=h(t))>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,u=c,console&&console.warn&&console.warn(u)}return t}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=c.bind(i);return n.listener=r,i.wrapFn=n,n}function f(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var u=h.length,c=p(h,u);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},3055:t=>{t.exports=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s{var i=e;i.utils=r(7426),i.common=r(6166),i.sha=r(6229),i.ripemd=r(6784),i.hmac=r(8948),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},6166:(t,e,r)=>{var i=r(7426),n=r(3349);function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=s,s.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s{var i=r(7426),n=r(3349);function s(t,e,r){if(!(this instanceof s))return new s(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,r))}t.exports=s,s.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),n(t.length<=this.blockSize);for(var e=t.length;e{var i=r(7426),n=r(6166),s=i.rotl32,o=i.sum32,a=i.sum32_3,h=i.sum32_4,u=n.BlockHash;function c(){if(!(this instanceof c))return new c;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function f(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function d(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(c,u),e.ripemd160=c,c.blockSize=512,c.outSize=160,c.hmacStrength=192,c.padLength=64,c.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],u=this.h[3],c=this.h[4],v=r,w=i,b=n,_=u,A=c,E=0;E<80;E++){var S=o(s(h(r,l(E,i,n,u),t[p[E]+e],f(E)),m[E]),c);r=c,c=u,u=s(n,10),n=i,i=S,S=o(s(h(v,l(79-E,w,b,_),t[g[E]+e],d(E)),y[E]),A),v=A,A=_,_=s(b,10),b=w,w=S}S=a(this.h[1],n,_),this.h[1]=a(this.h[2],u,A),this.h[2]=a(this.h[3],c,v),this.h[3]=a(this.h[4],r,w),this.h[4]=a(this.h[0],i,b),this.h[0]=S},c.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],g=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],y=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},6229:(t,e,r)=>{e.sha1=r(3917),e.sha224=r(7714),e.sha256=r(2287),e.sha384=r(1911),e.sha512=r(7766)},3917:(t,e,r)=>{var i=r(7426),n=r(6166),s=r(6225),o=i.rotl32,a=i.sum32,h=i.sum32_5,u=s.ft_1,c=n.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(f,c),t.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i{var i=r(7426),n=r(2287);function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(s,n),t.exports=s,s.blockSize=512,s.outSize=224,s.hmacStrength=192,s.padLength=64,s.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},2287:(t,e,r)=>{var i=r(7426),n=r(6166),s=r(6225),o=r(3349),a=i.sum32,h=i.sum32_4,u=i.sum32_5,c=s.ch32,l=s.maj32,f=s.s0_256,d=s.s1_256,p=s.g0_256,g=s.g1_256,m=n.BlockHash,y=[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];function v(){if(!(this instanceof v))return new v;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}i.inherits(v,m),t.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i{var i=r(7426),n=r(7766);function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(s,n),t.exports=s,s.blockSize=1024,s.outSize=384,s.hmacStrength=192,s.padLength=128,s.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},7766:(t,e,r)=>{var i=r(7426),n=r(6166),s=r(3349),o=i.rotr64_hi,a=i.rotr64_lo,h=i.shr64_hi,u=i.shr64_lo,c=i.sum64,l=i.sum64_hi,f=i.sum64_lo,d=i.sum64_4_hi,p=i.sum64_4_lo,g=i.sum64_5_hi,m=i.sum64_5_lo,y=n.BlockHash,v=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function w(){if(!(this instanceof w))return new w;y.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function b(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function _(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function A(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function E(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function S(t,e){var r=o(t,e,28)^o(e,t,2)^o(e,t,7);return r<0&&(r+=4294967296),r}function M(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function I(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function x(t,e){var r=o(t,e,1)^o(t,e,8)^h(t,e,7);return r<0&&(r+=4294967296),r}function N(t,e){var r=a(t,e,1)^a(t,e,8)^u(t,e,7);return r<0&&(r+=4294967296),r}function O(t,e){var r=a(t,e,19)^a(e,t,29)^u(t,e,6);return r<0&&(r+=4294967296),r}i.inherits(w,y),t.exports=w,w.blockSize=1024,w.outSize=512,w.hmacStrength=192,w.padLength=128,w.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i{var i=r(7426).rotr32;function n(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}function o(t,e,r){return t^e^r}e.ft_1=function(t,e,r,i){return 0===t?n(e,r,i):1===t||3===t?o(e,r,i):2===t?s(e,r,i):void 0},e.ch32=n,e.maj32=s,e.p32=o,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},7426:(t,e,r)=>{var i=r(3349),n=r(6698);function s(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function o(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function h(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=n,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>6|192,r[i++]=63&o|128):s(t,n)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n>>0}return o},e.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},e.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},e.sum64=function(t,e,r,i){var n=t[e],s=i+t[e+1]>>>0,o=(s>>0,t[e+1]=s},e.sum64_hi=function(t,e,r,i){return(e+i>>>0>>0},e.sum64_lo=function(t,e,r,i){return e+i>>>0},e.sum64_4_hi=function(t,e,r,i,n,s,o,a){var h=0,u=e;return h+=(u=u+i>>>0)>>0)>>0)>>0},e.sum64_4_lo=function(t,e,r,i,n,s,o,a){return e+i+s+a>>>0},e.sum64_5_hi=function(t,e,r,i,n,s,o,a,h,u){var c=0,l=e;return c+=(l=l+i>>>0)>>0)>>0)>>0)>>0},e.sum64_5_lo=function(t,e,r,i,n,s,o,a,h,u){return e+i+s+a+u>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},916:(t,e,r)=>{t.exports=self.fetch||(self.fetch=r(6782).default||r(6782))},1176:(t,e,r)=>{var i;!function(){var n="input is invalid type",s="object"==typeof window,o=s?window:{};o.JS_SHA3_NO_WINDOW&&(s=!1);var a=!s&&"object"==typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?o=r.g:a&&(o=self);var h=!o.JS_SHA3_NO_COMMON_JS&&t.exports,u=r.amdO,c=!o.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),f=[4,1024,262144,67108864],d=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],m=[128,256],y=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};!o.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!c||!o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var w=function(t,e,r){return function(i){return new k(t,e,t).update(i)[r]()}},b=function(t,e,r){return function(i,n){return new k(t,e,n).update(i)[r]()}},_=function(t,e,r){return function(e,i,n,s){return I["cshake"+t].update(e,i,n,s)[r]()}},A=function(t,e,r){return function(e,i,n,s){return I["kmac"+t].update(e,i,n,s)[r]()}},E=function(t,e,r,i){for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var i=0;i<50;++i)this.s[i]=0}function U(t,e,r){k.call(this,t,e,r)}k.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var e,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(n);if(null===t)throw new Error(n);if(c&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||c&&ArrayBuffer.isView(t)))throw new Error(n);e=!0}for(var i,s,o=this.blocks,a=this.byteCount,h=t.length,u=this.blockCount,l=0,f=this.s;l>2]|=t[l]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(o[i>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=a){for(this.start=i-a,this.block=o[u],i=0;i>=8);r>0;)n.unshift(r),r=255&(t>>=8),++i;return e?n.push(i):n.unshift(i),this.update(n),n.length},k.prototype.encodeString=function(t){var e,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(n);if(null===t)throw new Error(n);if(c&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||c&&ArrayBuffer.isView(t)))throw new Error(n);e=!0}var i=0,s=t.length;if(e)i=s;else for(var o=0;o=57344?i+=3:(a=65536+((1023&a)<<10|1023&t.charCodeAt(++o)),i+=4)}return i+=this.encode(8*i),this.update(t),i},k.prototype.bytepad=function(t,e){for(var r=this.encode(e),i=0;i>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+l[15&t]+l[t>>12&15]+l[t>>8&15]+l[t>>20&15]+l[t>>16&15]+l[t>>28&15]+l[t>>24&15];o%e==0&&(L(r),s=0)}return n&&(t=r[s],a+=l[t>>4&15]+l[15&t],n>1&&(a+=l[t>>12&15]+l[t>>8&15]),n>2&&(a+=l[t>>20&15]+l[t>>16&15])),a},k.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=n?new ArrayBuffer(i+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);o>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&L(i)}return s&&(t=a<<2,e=i[o],h[t]=255&e,s>1&&(h[t+1]=e>>8&255),s>2&&(h[t+2]=e>>16&255)),h},U.prototype=new k,U.prototype.finalize=function(){return this.encode(this.outputBits,!0),k.prototype.finalize.call(this)};var L=function(t){var e,r,i,n,s,o,a,h,u,c,l,f,d,g,m,y,v,w,b,_,A,E,S,M,I,x,N,O,P,R,T,C,k,U,L,D,q,B,j,z,F,K,H,V,G,W,$,J,Y,Q,X,Z,tt,et,rt,it,nt,st,ot,at,ht,ut,ct;for(i=0;i<48;i+=2)n=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],o=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],h=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],c=t[6]^t[16]^t[26]^t[36]^t[46],l=t[7]^t[17]^t[27]^t[37]^t[47],e=(f=t[8]^t[18]^t[28]^t[38]^t[48])^(o<<1|a>>>31),r=(d=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|o>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=n^(h<<1|u>>>31),r=s^(u<<1|h>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=o^(c<<1|l>>>31),r=a^(l<<1|c>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=h^(f<<1|d>>>31),r=u^(d<<1|f>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=c^(n<<1|s>>>31),r=l^(s<<1|n>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,g=t[0],m=t[1],W=t[11]<<4|t[10]>>>28,$=t[10]<<4|t[11]>>>28,O=t[20]<<3|t[21]>>>29,P=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,K=t[40]<<18|t[41]>>>14,H=t[41]<<18|t[40]>>>14,U=t[2]<<1|t[3]>>>31,L=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,J=t[22]<<10|t[23]>>>22,Y=t[23]<<10|t[22]>>>22,R=t[33]<<13|t[32]>>>19,T=t[32]<<13|t[33]>>>19,ut=t[42]<<2|t[43]>>>30,ct=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,q=t[15]<<6|t[14]>>>26,w=t[25]<<11|t[24]>>>21,b=t[24]<<11|t[25]>>>21,Q=t[34]<<15|t[35]>>>17,X=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,k=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,I=t[7]<<28|t[6]>>>4,it=t[17]<<23|t[16]>>>9,nt=t[16]<<23|t[17]>>>9,B=t[26]<<25|t[27]>>>7,j=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,A=t[37]<<21|t[36]>>>11,Z=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,V=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,N=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,z=t[38]<<8|t[39]>>>24,F=t[39]<<8|t[38]>>>24,E=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=g^~y&w,t[1]=m^~v&b,t[10]=M^~x&O,t[11]=I^~N&P,t[20]=U^~D&B,t[21]=L^~q&j,t[30]=V^~W&J,t[31]=G^~$&Y,t[40]=et^~it&st,t[41]=rt^~nt&ot,t[2]=y^~w&_,t[3]=v^~b&A,t[12]=x^~O&R,t[13]=N^~P&T,t[22]=D^~B&z,t[23]=q^~j&F,t[32]=W^~J&Q,t[33]=$^~Y&X,t[42]=it^~st&at,t[43]=nt^~ot&ht,t[4]=w^~_&E,t[5]=b^~A&S,t[14]=O^~R&C,t[15]=P^~T&k,t[24]=B^~z&K,t[25]=j^~F&H,t[34]=J^~Q&Z,t[35]=Y^~X&tt,t[44]=st^~at&ut,t[45]=ot^~ht&ct,t[6]=_^~E&g,t[7]=A^~S&m,t[16]=R^~C&M,t[17]=T^~k&I,t[26]=z^~K&U,t[27]=F^~H&L,t[36]=Q^~Z&V,t[37]=X^~tt&G,t[46]=at^~ut&et,t[47]=ht^~ct&rt,t[8]=E^~g&y,t[9]=S^~m&v,t[18]=C^~M&x,t[19]=k^~I&N,t[28]=K^~U&D,t[29]=H^~L&q,t[38]=Z^~V&W,t[39]=tt^~G&$,t[48]=ut^~et&it,t[49]=ct^~rt&nt,t[0]^=p[i],t[1]^=p[i+1]};if(h)t.exports=I;else{for(N=0;N{t=r.nmd(t);var i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",h="[object Array]",u="[object AsyncFunction]",c="[object Boolean]",l="[object Date]",f="[object Error]",d="[object Function]",p="[object GeneratorFunction]",g="[object Map]",m="[object Number]",y="[object Null]",v="[object Object]",w="[object Promise]",b="[object Proxy]",_="[object RegExp]",A="[object Set]",E="[object String]",S="[object Undefined]",M="[object WeakMap]",I="[object ArrayBuffer]",x="[object DataView]",N=/^\[object .+?Constructor\]$/,O=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P[a]=P[h]=P[I]=P[c]=P[x]=P[l]=P[f]=P[d]=P[g]=P[m]=P[v]=P[_]=P[A]=P[E]=P[M]=!1;var R="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,T="object"==typeof self&&self&&self.Object===Object&&self,C=R||T||Function("return this")(),k=e&&!e.nodeType&&e,U=k&&t&&!t.nodeType&&t,L=U&&U.exports===k,D=L&&R.process,q=function(){try{return D&&D.binding&&D.binding("util")}catch(t){}}(),B=q&&q.isTypedArray;function j(t,e){for(var r=-1,i=null==t?0:t.length;++ru))return!1;var l=a.get(t);if(l&&a.get(e))return l==e;var f=-1,d=!0,p=r&s?new It:void 0;for(a.set(t,e),a.set(e,t);++f-1},St.prototype.set=function(t,e){var r=this.__data__,i=Nt(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this},Mt.prototype.clear=function(){this.size=0,this.__data__={hash:new Et,map:new(lt||St),string:new Et}},Mt.prototype.delete=function(t){var e=kt(this,t).delete(t);return this.size-=e?1:0,e},Mt.prototype.get=function(t){return kt(this,t).get(t)},Mt.prototype.has=function(t){return kt(this,t).has(t)},Mt.prototype.set=function(t,e){var r=kt(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this},It.prototype.add=It.prototype.push=function(t){return this.__data__.set(t,i),this},It.prototype.has=function(t){return this.__data__.has(t)},xt.prototype.clear=function(){this.__data__=new St,this.size=0},xt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},xt.prototype.get=function(t){return this.__data__.get(t)},xt.prototype.has=function(t){return this.__data__.has(t)},xt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof St){var i=r.__data__;if(!lt||i.length<199)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new Mt(i)}return r.set(t,e),this.size=r.size,this};var Lt=at?function(t){return null==t?[]:(t=Object(t),function(e,r){for(var i=-1,n=null==e?0:e.length,s=0,o=[];++i-1&&t%1==0&&t-1&&t%1==0&&t<=o}function Gt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Wt(t){return null!=t&&"object"==typeof t}var $t=B?function(t){return function(e){return t(e)}}(B):function(t){return Wt(t)&&Vt(t.length)&&!!P[Ot(t)]};function Jt(t){return null!=(e=t)&&Vt(e.length)&&!Ht(e)?function(t,e){var r=Ft(t),i=!r&&zt(t),n=!r&&!i&&Kt(t),s=!r&&!i&&!n&&$t(t),o=r||i||n||s,a=o?function(t,e){for(var r=-1,i=Array(t);++r{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},6663:(t,e,r)=>{const i=r(4280),n=r(454),s=r(528),o=r(3055),a=Symbol("encodeFragmentIdentifier");function h(t){if("string"!=typeof t||1!==t.length)throw new TypeError("arrayFormatSeparator must be single character string")}function u(t,e){return e.encode?e.strict?i(t):encodeURIComponent(t):t}function c(t,e){return e.decode?n(t):t}function l(t){return Array.isArray(t)?t.sort():"object"==typeof t?l(Object.keys(t)).sort(((t,e)=>Number(t)-Number(e))).map((e=>t[e])):t}function f(t){const e=t.indexOf("#");return-1!==e&&(t=t.slice(0,e)),t}function d(t){const e=(t=f(t)).indexOf("?");return-1===e?"":t.slice(e+1)}function p(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&"string"==typeof t&&""!==t.trim()?t=Number(t):!e.parseBooleans||null===t||"true"!==t.toLowerCase()&&"false"!==t.toLowerCase()||(t="true"===t.toLowerCase()),t}function g(t,e){h((e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e)).arrayFormatSeparator);const r=function(t){let e;switch(t.arrayFormat){case"index":return(t,r,i)=>{e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),e?(void 0===i[t]&&(i[t]={}),i[t][e[1]]=r):i[t]=r};case"bracket":return(t,r,i)=>{e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),e?void 0!==i[t]?i[t]=[].concat(i[t],r):i[t]=[r]:i[t]=r};case"colon-list-separator":return(t,r,i)=>{e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),e?void 0!==i[t]?i[t]=[].concat(i[t],r):i[t]=[r]:i[t]=r};case"comma":case"separator":return(e,r,i)=>{const n="string"==typeof r&&r.includes(t.arrayFormatSeparator),s="string"==typeof r&&!n&&c(r,t).includes(t.arrayFormatSeparator);r=s?c(r,t):r;const o=n||s?r.split(t.arrayFormatSeparator).map((e=>c(e,t))):null===r?r:c(r,t);i[e]=o};case"bracket-separator":return(e,r,i)=>{const n=/(\[\])$/.test(e);if(e=e.replace(/\[\]$/,""),!n)return void(i[e]=r?c(r,t):r);const s=null===r?[]:r.split(t.arrayFormatSeparator).map((e=>c(e,t)));void 0!==i[e]?i[e]=[].concat(i[e],s):i[e]=s};default:return(t,e,r)=>{void 0!==r[t]?r[t]=[].concat(r[t],e):r[t]=e}}}(e),i=Object.create(null);if("string"!=typeof t)return i;if(!(t=t.trim().replace(/^[?#&]/,"")))return i;for(const n of t.split("&")){if(""===n)continue;let[t,o]=s(e.decode?n.replace(/\+/g," "):n,"=");o=void 0===o?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:c(o,e),r(c(t,e),o,i)}for(const t of Object.keys(i)){const r=i[t];if("object"==typeof r&&null!==r)for(const t of Object.keys(r))r[t]=p(r[t],e);else i[t]=p(r,e)}return!1===e.sort?i:(!0===e.sort?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce(((t,e)=>{const r=i[e];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?t[e]=l(r):t[e]=r,t}),Object.create(null))}e.extract=d,e.parse=g,e.stringify=(t,e)=>{if(!t)return"";h((e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e)).arrayFormatSeparator);const r=r=>e.skipNull&&null==t[r]||e.skipEmptyString&&""===t[r],i=function(t){switch(t.arrayFormat){case"index":return e=>(r,i)=>{const n=r.length;return void 0===i||t.skipNull&&null===i||t.skipEmptyString&&""===i?r:null===i?[...r,[u(e,t),"[",n,"]"].join("")]:[...r,[u(e,t),"[",u(n,t),"]=",u(i,t)].join("")]};case"bracket":return e=>(r,i)=>void 0===i||t.skipNull&&null===i||t.skipEmptyString&&""===i?r:null===i?[...r,[u(e,t),"[]"].join("")]:[...r,[u(e,t),"[]=",u(i,t)].join("")];case"colon-list-separator":return e=>(r,i)=>void 0===i||t.skipNull&&null===i||t.skipEmptyString&&""===i?r:null===i?[...r,[u(e,t),":list="].join("")]:[...r,[u(e,t),":list=",u(i,t)].join("")];case"comma":case"separator":case"bracket-separator":{const e="bracket-separator"===t.arrayFormat?"[]=":"=";return r=>(i,n)=>void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?i:(n=null===n?"":n,0===i.length?[[u(r,t),e,u(n,t)].join("")]:[[i,u(n,t)].join(t.arrayFormatSeparator)])}default:return e=>(r,i)=>void 0===i||t.skipNull&&null===i||t.skipEmptyString&&""===i?r:null===i?[...r,u(e,t)]:[...r,[u(e,t),"=",u(i,t)].join("")]}}(e),n={};for(const e of Object.keys(t))r(e)||(n[e]=t[e]);const s=Object.keys(n);return!1!==e.sort&&s.sort(e.sort),s.map((r=>{const n=t[r];return void 0===n?"":null===n?u(r,e):Array.isArray(n)?0===n.length&&"bracket-separator"===e.arrayFormat?u(r,e)+"[]":n.reduce(i(r),[]).join("&"):u(r,e)+"="+u(n,e)})).filter((t=>t.length>0)).join("&")},e.parseUrl=(t,e)=>{e=Object.assign({decode:!0},e);const[r,i]=s(t,"#");return Object.assign({url:r.split("?")[0]||"",query:g(d(t),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:c(i,e)}:{})},e.stringifyUrl=(t,r)=>{r=Object.assign({encode:!0,strict:!0,[a]:!0},r);const i=f(t.url).split("?")[0]||"",n=e.extract(t.url),s=e.parse(n,{sort:!1}),o=Object.assign(s,t.query);let h=e.stringify(o,r);h&&(h=`?${h}`);let c=function(t){let e="";const r=t.indexOf("#");return-1!==r&&(e=t.slice(r)),e}(t.url);return t.fragmentIdentifier&&(c=`#${r[a]?u(t.fragmentIdentifier,r):t.fragmentIdentifier}`),`${i}${h}${c}`},e.pick=(t,r,i)=>{i=Object.assign({parseFragmentIdentifier:!0,[a]:!1},i);const{url:n,query:s,fragmentIdentifier:h}=e.parseUrl(t,i);return e.stringifyUrl({url:n,query:o(s,r),fragmentIdentifier:h},i)},e.exclude=(t,r,i)=>{const n=Array.isArray(r)?t=>!r.includes(t):(t,e)=>!r(t,e);return e.pick(t,n,i)}},793:t=>{function e(t){try{return JSON.stringify(t)}catch(t){return'"[Circular]"'}}t.exports=function(t,r,i){var n=i&&i.stringify||e;if("object"==typeof t&&null!==t){var s=r.length+1;if(1===s)return t;var o=new Array(s);o[0]=n(t);for(var a=1;a-1?l:0,t.charCodeAt(d+1)){case 100:case 102:if(c>=h)break;if(null==r[c])break;l=h)break;if(null==r[c])break;l=h)break;if(void 0===r[c])break;l",l=d+2,d++;break}u+=n(r[c]),l=d+2,d++;break;case 115:if(c>=h)break;l{t.exports=(t,e)=>{if("string"!=typeof t||"string"!=typeof e)throw new TypeError("Expected the arguments to be of type `string`");if(""===e)return[t];const r=t.indexOf(e);return-1===r?[t]:[t.slice(0,r),t.slice(r+e.length)]}},4280:t=>{t.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,(t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`))},5215:(t,e,r)=>{r.r(e),r.d(e,{__assign:()=>s,__asyncDelegator:()=>b,__asyncGenerator:()=>w,__asyncValues:()=>_,__await:()=>v,__awaiter:()=>c,__classPrivateFieldGet:()=>M,__classPrivateFieldSet:()=>I,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>d,__extends:()=>n,__generator:()=>l,__importDefault:()=>S,__importStar:()=>E,__makeTemplateObject:()=>A,__metadata:()=>u,__param:()=>h,__read:()=>g,__rest:()=>o,__spread:()=>m,__spreadArrays:()=>y,__values:()=>p});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},i(t,e)};function n(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,i=arguments.length;r=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,r,o):n(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function h(t,e){return function(r,i){e(r,i,t)}}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,r,i){return new(r||(r=Promise))((function(n,s){function o(t){try{h(i.next(t))}catch(t){s(t)}}function a(t){try{h(i.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}h((i=i.apply(t,e||[])).next())}))}function l(t,e){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function m(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=n[t](e)).value instanceof v?Promise.resolve(r.value.v).then(h,u):c(s[0][2],r)}catch(t){c(s[0][3],t)}var r}function h(t){a("next",t)}function u(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function b(t){var e,r;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,n){e[i]=t[i]?function(e){return(r=!r)?{value:v(t[i](e)),done:"return"===i}:n?n(e):e}:n}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=p(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(r){e[r]=t[r]&&function(e){return new Promise((function(i,n){!function(t,e,r,i){Promise.resolve(i).then((function(e){t({value:e,done:r})}),e)}(i,n,(e=t[r](e)).done,e.value)}))}}}function A(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function E(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function S(t){return t&&t.__esModule?t:{default:t}}function M(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function I(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},6782:(t,e,r)=>{function i(t,e){return e=e||{},new Promise((function(r,i){var n=new XMLHttpRequest,s=[],o=[],a={},h=function(){return{ok:2==(n.status/100|0),statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:h,headers:{keys:function(){return s},entries:function(){return o},get:function(t){return a[t.toLowerCase()]},has:function(t){return t.toLowerCase()in a}}}};for(var u in n.open(e.method||"get",t,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,r){s.push(e=e.toLowerCase()),o.push([e,r]),a[e]=a[e]?a[e]+","+r:r})),r(h())},n.onerror=i,n.withCredentials="include"==e.credentials,e.headers)n.setRequestHeader(u,e.headers[u]);n.send(e.body||null)}))}r.r(e),r.d(e,{default:()=>i})},1591:t=>{t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},9432:()=>{},7790:()=>{},4874:(t,e,r)=>{const i=r(793);t.exports=o;const n=function(){function t(t){return void 0!==t&&t}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(e){return t(self)||t(window)||t(this)||{}}}().console||{},s={mapHttpRequest:f,mapHttpResponse:f,wrapRequestSerializer:d,wrapResponseSerializer:d,wrapErrorSerializer:d,req:f,res:f,err:function(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)void 0===e[r]&&(e[r]=t[r]);return e}};function o(t){(t=t||{}).browser=t.browser||{};const e=t.browser.transmit;if(e&&"function"!=typeof e.send)throw Error("pino: transmit option must have a send function");const r=t.browser.write||n;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},s=function(t,e){return Array.isArray(t)?t.filter((function(t){return"!stdSerializers.err"!==t})):!0===t&&Object.keys(e)}(t.browser.serialize,i);let f=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(f=!1),"function"==typeof r&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),!1===t.enabled&&(t.level="silent");const d=t.level||"info",g=Object.create(r);g.log||(g.log=p),Object.defineProperty(g,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(g,"level",{get:function(){return this._level},set:function(t){if("silent"!==t&&!this.levels.values[t])throw Error("unknown level "+t);this._level=t,a(m,g,"error","log"),a(m,g,"fatal","error"),a(m,g,"warn","error"),a(m,g,"info","log"),a(m,g,"debug","log"),a(m,g,"trace","log")}});const m={transmit:e,serialize:s,asObject:t.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:l(t)};return g.levels=o.levels,g.level=d,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=p,g.serializers=i,g._serialize=s,g._stdErrSerialize=f,g.child=function(r,n){if(!r)throw new Error("missing bindings for child Pino");n=n||{},s&&r.serializers&&(n.serializers=r.serializers);const o=n.serializers;if(s&&o){var a=Object.assign({},i,o),l=!0===t.browser.serialize?Object.keys(a):s;delete r.serializers,h([r],l,a,this._stdErrSerialize)}function f(t){this._childLevel=1+(0|t._childLevel),this.error=u(t,r,"error"),this.fatal=u(t,r,"fatal"),this.warn=u(t,r,"warn"),this.info=u(t,r,"info"),this.debug=u(t,r,"debug"),this.trace=u(t,r,"trace"),a&&(this.serializers=a,this._serialize=l),e&&(this._logEvent=c([].concat(t._logEvent.bindings,r)))}return f.prototype=this,new f(this)},e&&(g._logEvent=c()),g}function a(t,e,r,s){const a=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?p:a[r]?a[r]:n[r]||n[s]||p,function(t,e,r){var s;(t.transmit||e[r]!==p)&&(e[r]=(s=e[r],function(){const a=t.timestamp(),u=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===n?n:this;for(var f=0;f-1&&i in r&&(t[n][i]=r[i](t[n][i]))}function u(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t={};r.r(t),r.d(t,{identity:()=>Zt});var e={};r.r(e),r.d(e,{base2:()=>te});var i={};r.r(i),r.d(i,{base8:()=>ee});var n={};r.r(n),r.d(n,{base10:()=>re});var s={};r.r(s),r.d(s,{base16:()=>ie,base16upper:()=>ne});var o={};r.r(o),r.d(o,{base32:()=>se,base32hex:()=>ue,base32hexpad:()=>le,base32hexpadupper:()=>fe,base32hexupper:()=>ce,base32pad:()=>ae,base32padupper:()=>he,base32upper:()=>oe,base32z:()=>de});var a={};r.r(a),r.d(a,{base36:()=>pe,base36upper:()=>ge});var h={};r.r(h),r.d(h,{base58btc:()=>me,base58flickr:()=>ye});var u={};r.r(u),r.d(u,{base64:()=>ve,base64pad:()=>we,base64url:()=>be,base64urlpad:()=>_e});var c={};r.r(c),r.d(c,{base256emoji:()=>Me});var l={};r.r(l),r.d(l,{sha256:()=>We,sha512:()=>$e});var f={};r.r(f),r.d(f,{identity:()=>Ye});var d={};r.r(d),r.d(d,{code:()=>Xe,decode:()=>tr,encode:()=>Ze,name:()=>Qe});var p={};r.r(p),r.d(p,{code:()=>nr,decode:()=>or,encode:()=>sr,name:()=>ir});var g=r(7007),m=r.n(g);const y=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,v=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,w=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function b(t,e){if(!("__proto__"===t||"constructor"===t&&e&&"object"==typeof e&&"prototype"in e))return e;!function(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}(t)}function _(t,e={}){if("string"!=typeof t)return t;const r=t.trim();if('"'===t[0]&&'"'===t.at(-1)&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const t=r.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;if("undefined"===t)return;if("null"===t)return null;if("nan"===t)return Number.NaN;if("infinity"===t)return Number.POSITIVE_INFINITY;if("-infinity"===t)return Number.NEGATIVE_INFINITY}if(!w.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(y.test(t)||v.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,b)}return JSON.parse(t)}catch(r){if(e.strict)throw r;return t}}function A(t,...e){try{return(r=t(...e))&&"function"==typeof r.then?r:Promise.resolve(r)}catch(t){return Promise.reject(t)}var r}function E(t){if(function(t){const e=typeof t;return null===t||"object"!==e&&"function"!==e}(t))return String(t);if(function(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}(t)||Array.isArray(t))return JSON.stringify(t);if("function"==typeof t.toJSON)return E(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function S(){if(void 0===typeof Buffer)throw new TypeError("[unstorage] Buffer is not supported!")}const M="base64:";function I(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function x(...t){return I(t.join(":"))}function N(t){return(t=I(t))?t+":":""}const O=()=>{const t=new Map;return{name:"memory",options:{},hasItem:e=>t.has(e),getItem:e=>t.get(e)??null,getItemRaw:e=>t.get(e)??null,setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys:()=>Array.from(t.keys()),clear(){t.clear()},dispose(){t.clear()}}};function P(t,e,r){return t.watch?t.watch(((t,i)=>e(t,r+i))):()=>{}}async function R(t){"function"==typeof t.dispose&&await A(t.dispose)}function T(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function C(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=T(r);return(t,r)=>i.then((i=>r(i.transaction(e,t).objectStore(e))))}let k;function U(){return k||(k=C("keyval-store","keyval")),k}function L(t,e=U()){return e("readonly",(e=>T(e.get(t))))}const D=t=>JSON.stringify(t,((t,e)=>"bigint"==typeof e?e.toString()+"n":e)),q=t=>{const e=t.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3');return JSON.parse(e,((t,e)=>"string"==typeof e&&e.match(/^\d+n$/)?BigInt(e.substring(0,e.length-1)):e))};function B(t){if("string"!=typeof t)throw new Error("Cannot safe json parse value of type "+typeof t);try{return q(t)}catch(e){return t}}function j(t){return"string"==typeof t?t:D(t)||""}var z=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=t=>e+t;let i;return t.dbName&&t.storeName&&(i=C(t.dbName,t.storeName)),{name:"idb-keyval",options:t,hasItem:async t=>!(typeof await L(r(t),i)>"u"),getItem:async t=>await L(r(t),i)??null,setItem:(t,e)=>function(t,e,r=U()){return r("readwrite",(r=>(r.put(e,t),T(r.transaction))))}(r(t),e,i),removeItem:t=>function(t,e=U()){return e("readwrite",(e=>(e.delete(t),T(e.transaction))))}(r(t),i),getKeys:()=>function(t=U()){return t("readonly",(t=>{if(t.getAllKeys)return T(t.getAllKeys());const e=[];return function(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},T(t.transaction)}(t,(t=>e.push(t.key))).then((()=>e))}))}(i),clear:()=>function(t=U()){return t("readwrite",(t=>(t.clear(),T(t.transaction))))}(i)}};class F{constructor(){this.indexedDb=function(t={}){const e={mounts:{"":t.driver||O()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=t=>{for(const r of e.mountpoints)if(t.startsWith(r))return{base:r,relativeKey:t.slice(r.length),driver:e.mounts[r]};return{base:"",relativeKey:t,driver:e.mounts[""]}},i=(t,r)=>e.mountpoints.filter((e=>e.startsWith(t)||r&&t.startsWith(e))).map((r=>({relativeBase:t.length>r.length?t.slice(r.length):void 0,mountpoint:r,driver:e.mounts[r]}))),n=(t,r)=>{if(e.watching){r=I(r);for(const i of e.watchListeners)i(t,r)}},s=async()=>{if(e.watching){for(const t in e.unwatch)await e.unwatch[t]();e.unwatch={},e.watching=!1}},o=(t,e,i)=>{const n=new Map,s=t=>{let e=n.get(t.base);return e||(e={driver:t.driver,base:t.base,items:[]},n.set(t.base,e)),e};for(const i of t){const t="string"==typeof i,n=I(t?i:i.key),o=t?void 0:i.value,a=t||!i.options?e:{...e,...i.options},h=r(n);s(h).items.push({key:n,value:o,relativeKey:h.relativeKey,options:a})}return Promise.all([...n.values()].map((t=>i(t)))).then((t=>t.flat()))},a={hasItem(t,e={}){t=I(t);const{relativeKey:i,driver:n}=r(t);return A(n.hasItem,i,e)},getItem(t,e={}){t=I(t);const{relativeKey:i,driver:n}=r(t);return A(n.getItem,i,e).then((t=>_(t)))},getItems:(t,e)=>o(t,e,(t=>t.driver.getItems?A(t.driver.getItems,t.items.map((t=>({key:t.relativeKey,options:t.options}))),e).then((e=>e.map((e=>({key:x(t.base,e.key),value:_(e.value)}))))):Promise.all(t.items.map((e=>A(t.driver.getItem,e.relativeKey,e.options).then((t=>({key:e.key,value:_(t)})))))))),getItemRaw(t,e={}){t=I(t);const{relativeKey:i,driver:n}=r(t);return n.getItemRaw?A(n.getItemRaw,i,e):A(n.getItem,i,e).then((t=>function(t){return"string"!=typeof t?t:t.startsWith(M)?(S(),Buffer.from(t.slice(7),"base64")):t}(t)))},async setItem(t,e,i={}){if(void 0===e)return a.removeItem(t);t=I(t);const{relativeKey:s,driver:o}=r(t);o.setItem&&(await A(o.setItem,s,E(e),i),o.watch||n("update",t))},async setItems(t,e){await o(t,e,(async t=>{t.driver.setItems&&await A(t.driver.setItems,t.items.map((t=>({key:t.relativeKey,value:E(t.value),options:t.options}))),e),t.driver.setItem&&await Promise.all(t.items.map((e=>A(t.driver.setItem,e.relativeKey,E(e.value),e.options))))}))},async setItemRaw(t,e,i={}){if(void 0===e)return a.removeItem(t,i);t=I(t);const{relativeKey:s,driver:o}=r(t);if(o.setItemRaw)await A(o.setItemRaw,s,e,i);else{if(!o.setItem)return;await A(o.setItem,s,function(t){if("string"==typeof t)return t;S();const e=Buffer.from(t).toString("base64");return M+e}(e),i)}o.watch||n("update",t)},async removeItem(t,e={}){"boolean"==typeof e&&(e={removeMeta:e}),t=I(t);const{relativeKey:i,driver:s}=r(t);s.removeItem&&(await A(s.removeItem,i,e),(e.removeMeta||e.removeMata)&&await A(s.removeItem,i+"$",e),s.watch||n("remove",t))},async getMeta(t,e={}){"boolean"==typeof e&&(e={nativeOnly:e}),t=I(t);const{relativeKey:i,driver:n}=r(t),s=Object.create(null);if(n.getMeta&&Object.assign(s,await A(n.getMeta,i,e)),!e.nativeOnly){const t=await A(n.getItem,i+"$",e).then((t=>_(t)));t&&"object"==typeof t&&("string"==typeof t.atime&&(t.atime=new Date(t.atime)),"string"==typeof t.mtime&&(t.mtime=new Date(t.mtime)),Object.assign(s,t))}return s},setMeta(t,e,r={}){return this.setItem(t+"$",e,r)},removeMeta(t,e={}){return this.removeItem(t+"$",e)},async getKeys(t,e={}){t=N(t);const r=i(t,!0);let n=[];const s=[];for(const t of r){const r=(await A(t.driver.getKeys,t.relativeBase,e)).map((e=>t.mountpoint+I(e))).filter((t=>!n.some((e=>t.startsWith(e)))));s.push(...r),n=[t.mountpoint,...n.filter((e=>!e.startsWith(t.mountpoint)))]}return t?s.filter((e=>e.startsWith(t)&&!e.endsWith("$"))):s.filter((t=>!t.endsWith("$")))},async clear(t,e={}){t=N(t),await Promise.all(i(t,!1).map((async t=>{if(t.driver.clear)return A(t.driver.clear,t.relativeBase,e);if(t.driver.removeItem){const r=await t.driver.getKeys(t.relativeBase||"",e);return Promise.all(r.map((r=>t.driver.removeItem(r,e))))}})))},async dispose(){await Promise.all(Object.values(e.mounts).map((t=>R(t))))},watch:async t=>(await(async()=>{if(!e.watching){e.watching=!0;for(const t in e.mounts)e.unwatch[t]=await P(e.mounts[t],n,t)}})(),e.watchListeners.push(t),async()=>{e.watchListeners=e.watchListeners.filter((e=>e!==t)),0===e.watchListeners.length&&await s()}),async unwatch(){e.watchListeners=[],await s()},mount(t,r){if((t=N(t))&&e.mounts[t])throw new Error(`already mounted at ${t}`);return t&&(e.mountpoints.push(t),e.mountpoints.sort(((t,e)=>e.length-t.length))),e.mounts[t]=r,e.watching&&Promise.resolve(P(r,n,t)).then((r=>{e.unwatch[t]=r})).catch(console.error),a},async unmount(t,r=!0){(t=N(t))&&e.mounts[t]&&(e.watching&&t in e.unwatch&&(e.unwatch[t](),delete e.unwatch[t]),r&&await R(e.mounts[t]),e.mountpoints=e.mountpoints.filter((e=>e!==t)),delete e.mounts[t])},getMount(t=""){t=I(t)+":";const e=r(t);return{driver:e.driver,base:e.base}},getMounts:(t="",e={})=>(t=I(t),i(t,e.parents).map((t=>({driver:t.driver,base:t.mountpoint}))))};return a}({driver:z({dbName:"WALLET_CONNECT_V2_INDEXED_DB",storeName:"keyvaluestorage"})})}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(null!==e)return e}async setItem(t,e){await this.indexedDb.setItem(t,j(e))}async removeItem(t){await this.indexedDb.removeItem(t)}}var K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof r.g<"u"?r.g:typeof self<"u"?self:{},H={exports:{}};function V(t){var e;return[t[0],B(null!=(e=t[1])?e:"")]}!function(){let t;function e(){}t=e,t.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},t.prototype.setItem=function(t,e){this[t]=String(e)},t.prototype.removeItem=function(t){delete this[t]},t.prototype.clear=function(){const t=this;Object.keys(t).forEach((function(e){t[e]=void 0,delete t[e]}))},t.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},t.prototype.__defineGetter__("length",(function(){return Object.keys(this).length})),typeof K<"u"&&K.localStorage?H.exports=K.localStorage:typeof window<"u"&&window.localStorage?H.exports=window.localStorage:H.exports=new e}();class G{constructor(){this.localStorage=H.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(V)}async getItem(t){const e=this.localStorage.getItem(t);if(null!==e)return B(e)}async setItem(t,e){this.localStorage.setItem(t,j(e))}async removeItem(t){this.localStorage.removeItem(t)}}class W{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const t=new G;this.storage=t;try{(async(t,e,r)=>{const i="wc_storage_version",n=await e.getItem(i);if(n&&n>=1)return void r(e);const s=await t.getKeys();if(!s.length)return void r(e);const o=[];for(;s.length;){const r=s.shift();if(!r)continue;const i=r.toLowerCase();if(i.includes("wc@")||i.includes("walletconnect")||i.includes("wc_")||i.includes("wallet_connect")){const i=await t.getItem(r);await e.setItem(r,i),o.push(r)}}await e.setItem(i,1),r(e),(async(t,e)=>{e.length&&e.forEach((async e=>{await t.removeItem(e)}))})(t,o)})(t,new F,this.setInitialized)}catch{this.initialized=!0}}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)}))}}var $=r(6545),J=r(4874),Y=r.n(J);const Q="custom_context";class X{constructor(t){this.nodeValue=t,this.sizeInBytes=(new TextEncoder).encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class Z{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0}append(t){const e=new X(t);if(e.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${e.size}`);for(;this.size+e.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=e),this.tail=e):(this.head=e,this.tail=e),this.lengthInNodes++,this.sizeInBytes+=e.size}shift(){if(!this.head)return;const t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size}toArray(){const t=[];let e=this.head;for(;null!==e;)t.push(e.value),e=e.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return{next:()=>{if(!t)return{done:!0,value:null};const e=t.value;return t=t.next,{done:!1,value:e}}}}}class tt{constructor(t,e=1024e3){this.level=t??"error",this.levelValue=J.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=e,this.logs=new Z(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(t,e){e===J.levels.values.error?console.error(t):e===J.levels.values.warn?console.warn(t):e===J.levels.values.debug?console.debug(t):e===J.levels.values.trace?console.trace(t):console.log(t)}appendToLogs(t){this.logs.append(j({timestamp:(new Date).toISOString(),log:t}));const e="string"==typeof t?JSON.parse(t).level:t.level;e>=this.levelValue&&this.forwardToConsole(t,e)}getLogs(){return this.logs}clearLogs(){this.logs=new Z(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(t){const e=this.getLogArray();return e.push(j({extraMetadata:t})),new Blob(e,{type:"application/json"})}}class et{constructor(t,e=1024e3){this.baseChunkLogger=new tt(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){const e=URL.createObjectURL(this.logsToBlob(t)),r=document.createElement("a");r.href=e,r.download=`walletconnect-logs-${(new Date).toISOString()}.txt`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(e)}}class rt{constructor(t,e=1024e3){this.baseChunkLogger=new tt(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}}var it=Object.defineProperty,nt=Object.defineProperties,st=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,ut=(t,e,r)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ct=(t,e)=>{for(var r in e||(e={}))at.call(e,r)&&ut(t,r,e[r]);if(ot)for(var r of ot(e))ht.call(e,r)&&ut(t,r,e[r]);return t},lt=(t,e)=>nt(t,st(e));function ft(t){return lt(ct({},t),{level:t?.level||"info"})}function dt(t,e=Q){let r="";return r=typeof t.bindings>"u"?function(t,e=Q){return t[e]||""}(t,e):t.bindings().context||"",r}function pt(t,e,r=Q){const i=function(t,e,r=Q){const i=dt(t,r);return i.trim()?`${i}/${e}`:e}(t,e,r);return function(t,e,r=Q){return t[r]=e,t}(t.child({context:i}),i,r)}function gt(t){return typeof t.loggerOverride<"u"&&"string"!=typeof t.loggerOverride?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?function(t){var e,r;const i=new et(null==(e=t.opts)?void 0:e.level,t.maxSizeInBytes);return{logger:Y()(lt(ct({},t.opts),{level:"trace",browser:lt(ct({},null==(r=t.opts)?void 0:r.browser),{write:t=>i.write(t)})})),chunkLoggerController:i}}(t):function(t){var e;const r=new rt(null==(e=t.opts)?void 0:e.level,t.maxSizeInBytes);return{logger:Y()(lt(ct({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}(t)}var mt=r(4556);class yt extends mt.H{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}class vt extends mt.H{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}}class wt{constructor(t,e){this.logger=t,this.core=e}}class bt extends mt.H{constructor(t,e){super(),this.relayer=t,this.logger=e}}class _t extends mt.H{constructor(t){super()}}class At{constructor(t,e,r,i){this.core=t,this.logger=e,this.name=r}}class Et extends mt.H{constructor(t,e){super(),this.relayer=t,this.logger=e}}class St extends mt.H{constructor(t,e){super(),this.core=t,this.logger=e}}class Mt{constructor(t,e){this.projectId=t,this.logger=e}}class It{constructor(t,e){this.projectId=t,this.logger=e}}m();class xt{constructor(t){this.opts=t,this.protocol="wc",this.version=2}}g.EventEmitter;class Nt{constructor(t){this.client=t}}var Ot=r(4904),Pt=r(7052),Rt=r(8900);const Tt="base64url",Ct="utf8",kt=":",Ut="did",Lt="key",Dt="base58btc",qt="z",Bt="K36";function jt(t){return null!=globalThis.Buffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function zt(t=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?jt(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Ft(t,e){e||(e=t.reduce(((t,e)=>t+e.length),0));const r=zt(e);let i=0;for(const e of t)r.set(e,i),i+=e.length;return jt(r)}const Kt=function(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);t[e];){var c=r[t.charCodeAt(e)];if(255===c)return;for(var l=0,f=s-1;(0!==c||l>>0,o[f]=c%256>>>0,c=c/256>>>0;if(0!==c)throw new Error("Non-zero carry");n=l,e++}if(" "!==t[e]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,i=0,n=0,s=e.length;n!==s&&0===e[n];)n++,r++;for(var o=(s-n)*c+1>>>0,u=new Uint8Array(o);n!==s;){for(var l=e[n],f=0,d=o-1;(0!==l||f>>0,u[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var g=h.repeat(r);p{if(t instanceof Uint8Array&&"Uint8Array"===t.constructor.name)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")});class Vt{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Gt{constructor(t,e,r){if(this.name=t,this.prefix=e,void 0===e.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if("string"==typeof t){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(t){return $t(this,t)}}class Wt{constructor(t){this.decoders=t}or(t){return $t(this,t)}decode(t){const e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const $t=(t,e)=>new Wt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Jt{constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new Vt(t,e,r),this.decoder=new Gt(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Yt=({name:t,prefix:e,encode:r,decode:i})=>new Jt(t,e,r,i),Qt=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Kt(r,e);return Yt({prefix:t,name:e,encode:i,decode:t=>Ht(n(t))})},Xt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Yt({prefix:e,name:t,encode:t=>((t,e,r)=>{const i="="===e[e.length-1],n=(1<r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<((t,e,r,i)=>{const n={};for(let t=0;t=8&&(a-=8,o[u++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,i,r,t)}),Zt=Yt({prefix:"\0",name:"identity",encode:t=>{return e=t,(new TextDecoder).decode(e);var e},decode:t=>(t=>(new TextEncoder).encode(t))(t)}),te=Xt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),ee=Xt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),re=Qt({prefix:"9",name:"base10",alphabet:"0123456789"}),ie=Xt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ne=Xt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),se=Xt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),oe=Xt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ae=Xt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),he=Xt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ue=Xt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ce=Xt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),le=Xt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fe=Xt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),de=Xt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),pe=Qt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ge=Qt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),me=Qt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ye=Qt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),ve=Xt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),we=Xt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),be=Xt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_e=Xt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Ae=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Ee=Ae.reduce(((t,e,r)=>(t[r]=e,t)),[]),Se=Ae.reduce(((t,e,r)=>(t[e.codePointAt(0)]=r,t)),[]),Me=Yt({prefix:"🚀",name:"base256emoji",encode:function(t){return t.reduce(((t,e)=>t+Ee[e]),"")},decode:function(t){const e=[];for(const r of t){const t=Se[r.codePointAt(0)];if(void 0===t)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}});var Ie=128,xe=-128,Ne=Math.pow(2,31),Oe=Math.pow(2,7),Pe=Math.pow(2,14),Re=Math.pow(2,21),Te=Math.pow(2,28),Ce=Math.pow(2,35),ke=Math.pow(2,42),Ue=Math.pow(2,49),Le=Math.pow(2,56),De=Math.pow(2,63);const qe=function t(e,r,i){r=r||[];for(var n=i=i||0;e>=Ne;)r[i++]=255&e|Ie,e/=128;for(;e&xe;)r[i++]=255&e|Ie,e>>>=7;return r[i]=0|e,t.bytes=i-n+1,r},Be=function(t){return t(qe(t,e,r),e),ze=t=>Be(t),Fe=(t,e)=>{const r=e.byteLength,i=ze(t),n=i+ze(r),s=new Uint8Array(n+r);return je(t,s,0),je(r,s,i),s.set(e,n),new Ke(t,r,e,s)};class Ke{constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}}const He=({name:t,code:e,encode:r})=>new Ve(t,e,r);class Ve{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?Fe(this.code,e):e.then((t=>Fe(this.code,t)))}throw Error("Unknown type, must be binary type")}}const Ge=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),We=He({name:"sha2-256",code:18,encode:Ge("SHA-256")}),$e=He({name:"sha2-512",code:19,encode:Ge("SHA-512")}),Je=Ht,Ye={code:0,name:"identity",encode:Je,digest:t=>Fe(0,Je(t))},Qe="raw",Xe=85,Ze=t=>Ht(t),tr=t=>Ht(t),er=new TextEncoder,rr=new TextDecoder,ir="json",nr=512,sr=t=>er.encode(JSON.stringify(t)),or=t=>JSON.parse(rr.decode(t));Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"),Symbol.for("@ipld/js-cid/CID");const ar={...t,...e,...i,...n,...s,...o,...a,...h,...u,...c};function hr(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const ur=hr("utf8","u",(t=>"u"+new TextDecoder("utf8").decode(t)),(t=>(new TextEncoder).encode(t.substring(1)))),cr=hr("ascii","a",(t=>{let e="a";for(let r=0;r{const e=zt((t=t.substring(1)).length);for(let r=0;re in t?qr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kr=(t,e)=>{for(var r in e||(e={}))jr.call(e,r)&&Fr(t,r,e[r]);if(Br)for(var r of Br(e))zr.call(e,r)&&Fr(t,r,e[r]);return t};const Hr="ReactNative",Vr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Gr="js";function Wr(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function $r(){return!(0,Nr.getDocument)()&&!!(0,Nr.getNavigator)()&&navigator.product===Hr}function Jr(){return!Wr()&&!!(0,Nr.getNavigator)()&&!!(0,Nr.getDocument)()}function Yr(){return $r()?Vr.reactNative:Wr()?Vr.node:Jr()?Vr.browser:Vr.unknown}function Qr(t,e,i){const n=function(){if(Yr()===Vr.reactNative&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Platform)<"u"){const{OS:t,Version:e}=r.g.Platform;return[t,e].join("-")}const t=e?xr(e):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new Ar:"undefined"!=typeof navigator?xr(navigator.userAgent):"undefined"!=typeof process&&process.version?new wr(process.version.slice(1)):null;var e;if(null===t)return"unknown";const i=t.os?t.os.replace(" ","").toLowerCase():"unknown";return"browser"===t.type?[i,t.name,t.version].join("-"):[i,t.version].join("-")}(),s=function(){var t;const e=Yr();return e===Vr.browser?[e,(null==(t=(0,Nr.getLocation)())?void 0:t.host)||"unknown"].join(":"):e}();return[[t,e].join("-"),[Gr,i].join("-"),n,s].join("/")}function Xr(t,e){return t.filter((t=>e.includes(t))).length===t.length}function Zr(t){return Object.fromEntries(t.entries())}function ti(t){return new Map(Object.entries(t))}function ei(t=Rt.FIVE_MINUTES,e){const r=(0,Rt.toMiliseconds)(t||Rt.FIVE_MINUTES);let i,n,s;return{resolve:t=>{s&&i&&(clearTimeout(s),i(t))},reject:t=>{s&&n&&(clearTimeout(s),n(t))},done:()=>new Promise(((t,o)=>{s=setTimeout((()=>{o(new Error(e))}),r),i=t,n=o}))}}function ri(t,e,r){return new Promise((async(i,n)=>{const s=setTimeout((()=>n(new Error(r))),e);try{i(await t)}catch(t){n(t)}clearTimeout(s)}))}function ii(t,e){if("string"==typeof e&&e.startsWith(`${t}:`))return e;if("topic"===t.toLowerCase()){if("string"!=typeof e)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}if("id"===t.toLowerCase()){if("number"!=typeof e)throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function ni(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if("topic"===e&&"string"==typeof r)i.topic=r;else{if("id"!==e||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);i.id=Number(r)}return i}function si(t,e){return(0,Rt.fromMiliseconds)((e||Date.now())+(0,Rt.toMiliseconds)(t))}function oi(t){return Date.now()>=(0,Rt.toMiliseconds)(t)}function ai(t,e){return`${t}${e?`:${e}`:""}`}function hi(t=[],e=[]){return[...new Set([...t,...e])]}var ui,ci=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof r.g<"u"?r.g:typeof self<"u"?self:{},li={exports:{}};ui=li,function(){var t="input is invalid type",e="object"==typeof window,r=e?window:{};r.JS_SHA3_NO_WINDOW&&(e=!1);var i=!e&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?r=ci:i&&(r=self);var n=!r.JS_SHA3_NO_COMMON_JS&&ui.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",o="0123456789abcdef".split(""),a=[4,1024,262144,67108864],h=[0,8,16,24],u=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],c=[224,256,384,512],l=[128,256],f=["hex","buffer","arrayBuffer","array","digest"],d={128:168,256:136};(r.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),s&&(r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var p=function(t,e,r){return function(i){return new O(t,e,t).update(i)[r]()}},g=function(t,e,r){return function(i,n){return new O(t,e,n).update(i)[r]()}},m=function(t,e,r){return function(e,i,n,s){return _["cshake"+t].update(e,i,n,s)[r]()}},y=function(t,e,r){return function(e,i,n,s){return _["kmac"+t].update(e,i,n,s)[r]()}},v=function(t,e,r,i){for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var i=0;i<50;++i)this.s[i]=0}function P(t,e,r){O.call(this,t,e,r)}O.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var r,i=typeof e;if("string"!==i){if("object"!==i)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);r=!0}for(var n,o,a=this.blocks,u=this.byteCount,c=e.length,l=this.blockCount,f=0,d=this.s;f>2]|=e[f]<>2]|=o<>2]|=(192|o>>6)<>2]|=(128|63&o)<=57344?(a[n>>2]|=(224|o>>12)<>2]|=(128|o>>6&63)<>2]|=(128|63&o)<>2]|=(240|o>>18)<>2]|=(128|o>>12&63)<>2]|=(128|o>>6&63)<>2]|=(128|63&o)<=u){for(this.start=n-u,this.block=a[l],n=0;n>=8);r>0;)n.unshift(r),r=255&(t>>=8),++i;return e?n.push(i):n.unshift(i),this.update(n),n.length},O.prototype.encodeString=function(e){var r,i=typeof e;if("string"!==i){if("object"!==i)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);r=!0}var n=0,o=e.length;if(r)n=o;else for(var a=0;a=57344?n+=3:(h=65536+((1023&h)<<10|1023&e.charCodeAt(++a)),n+=4)}return n+=this.encode(8*n),this.update(e),n},O.prototype.bytepad=function(t,e){for(var r=this.encode(e),i=0;i>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+o[15&t]+o[t>>12&15]+o[t>>8&15]+o[t>>20&15]+o[t>>16&15]+o[t>>28&15]+o[t>>24&15];a%e==0&&(R(r),s=0)}return n&&(t=r[s],h+=o[t>>4&15]+o[15&t],n>1&&(h+=o[t>>12&15]+o[t>>8&15]),n>2&&(h+=o[t>>20&15]+o[t>>16&15])),h},O.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=n?new ArrayBuffer(i+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);o>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&R(i)}return s&&(t=a<<2,e=i[o],h[t]=255&e,s>1&&(h[t+1]=e>>8&255),s>2&&(h[t+2]=e>>16&255)),h},P.prototype=new O,P.prototype.finalize=function(){return this.encode(this.outputBits,!0),O.prototype.finalize.call(this)};var R=function(t){var e,r,i,n,s,o,a,h,c,l,f,d,p,g,m,y,v,w,b,_,A,E,S,M,I,x,N,O,P,R,T,C,k,U,L,D,q,B,j,z,F,K,H,V,G,W,$,J,Y,Q,X,Z,tt,et,rt,it,nt,st,ot,at,ht,ut,ct;for(i=0;i<48;i+=2)n=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],o=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],h=t[4]^t[14]^t[24]^t[34]^t[44],c=t[5]^t[15]^t[25]^t[35]^t[45],l=t[6]^t[16]^t[26]^t[36]^t[46],f=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(o<<1|a>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|o>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=n^(h<<1|c>>>31),r=s^(c<<1|h>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=o^(l<<1|f>>>31),r=a^(f<<1|l>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=h^(d<<1|p>>>31),r=c^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=l^(n<<1|s>>>31),r=f^(s<<1|n>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,g=t[0],m=t[1],W=t[11]<<4|t[10]>>>28,$=t[10]<<4|t[11]>>>28,O=t[20]<<3|t[21]>>>29,P=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,K=t[40]<<18|t[41]>>>14,H=t[41]<<18|t[40]>>>14,U=t[2]<<1|t[3]>>>31,L=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,J=t[22]<<10|t[23]>>>22,Y=t[23]<<10|t[22]>>>22,R=t[33]<<13|t[32]>>>19,T=t[32]<<13|t[33]>>>19,ut=t[42]<<2|t[43]>>>30,ct=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,q=t[15]<<6|t[14]>>>26,w=t[25]<<11|t[24]>>>21,b=t[24]<<11|t[25]>>>21,Q=t[34]<<15|t[35]>>>17,X=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,k=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,I=t[7]<<28|t[6]>>>4,it=t[17]<<23|t[16]>>>9,nt=t[16]<<23|t[17]>>>9,B=t[26]<<25|t[27]>>>7,j=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,A=t[37]<<21|t[36]>>>11,Z=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,V=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,N=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,z=t[38]<<8|t[39]>>>24,F=t[39]<<8|t[38]>>>24,E=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=g^~y&w,t[1]=m^~v&b,t[10]=M^~x&O,t[11]=I^~N&P,t[20]=U^~D&B,t[21]=L^~q&j,t[30]=V^~W&J,t[31]=G^~$&Y,t[40]=et^~it&st,t[41]=rt^~nt&ot,t[2]=y^~w&_,t[3]=v^~b&A,t[12]=x^~O&R,t[13]=N^~P&T,t[22]=D^~B&z,t[23]=q^~j&F,t[32]=W^~J&Q,t[33]=$^~Y&X,t[42]=it^~st&at,t[43]=nt^~ot&ht,t[4]=w^~_&E,t[5]=b^~A&S,t[14]=O^~R&C,t[15]=P^~T&k,t[24]=B^~z&K,t[25]=j^~F&H,t[34]=J^~Q&Z,t[35]=Y^~X&tt,t[44]=st^~at&ut,t[45]=ot^~ht&ct,t[6]=_^~E&g,t[7]=A^~S&m,t[16]=R^~C&M,t[17]=T^~k&I,t[26]=z^~K&U,t[27]=F^~H&L,t[36]=Q^~Z&V,t[37]=X^~tt&G,t[46]=at^~ut&et,t[47]=ht^~ct&rt,t[8]=E^~g&y,t[9]=S^~m&v,t[18]=C^~M&x,t[19]=k^~I&N,t[28]=K^~U&D,t[29]=H^~L&q,t[38]=Z^~V&W,t[39]=tt^~G&$,t[48]=ut^~et&it,t[49]=ct^~rt&nt,t[0]^=u[i],t[1]^=u[i+1]};if(n)ui.exports=_;else for(E=0;E{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch{t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var wi,bi;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(wi||(wi={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(bi||(bi={}));const _i="0123456789abcdef";class Ai{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==gi[r]&&this.throwArgumentError("invalid log level name","logLevel",t),!(mi>gi[r])&&console.log.apply(console,e)}debug(...t){this._log(Ai.levels.DEBUG,t)}info(...t){this._log(Ai.levels.INFO,t)}warn(...t){this._log(Ai.levels.WARNING,t)}makeError(t,e,r){if(pi)return this.makeError("censored error",e,{});e||(e=Ai.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t>4],r+=_i[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch{i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let s="";switch(e){case bi.NUMERIC_FAULT:{s="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":s+="-"+e;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case bi.CALL_EXCEPTION:case bi.INSUFFICIENT_FUNDS:case bi.MISSING_NEW:case bi.NONCE_EXPIRED:case bi.REPLACEMENT_UNDERPRICED:case bi.TRANSACTION_REPLACED:case bi.UNPREDICTABLE_GAS_LIMIT:s=e}s&&(t+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const o=new Error(t);return o.reason=n,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Ai.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){vi&&this.throwError("platform missing String.prototype.normalize",Ai.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:vi})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Ai.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Ai.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,Ai.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||null==t)&&this.throwError("missing new",Ai.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Ai.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||null==t)&&this.throwError("missing new",Ai.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return yi||(yi=new Ai("logger/5.7.0")),yi}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Ai.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),di){if(!t)return;this.globalLogger().throwError("error censorship permanent",Ai.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}pi=!!t,di=!!e}static setLogLevel(t){const e=gi[t.toLowerCase()];null!=e?mi=e:Ai.globalLogger().warn("invalid log level - "+t)}static from(t){return new Ai(t)}}Ai.errors=bi,Ai.levels=wi;const Ei=new Ai("bytes/5.7.0");function Si(t){return!!t.toHexString}function Mi(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Mi(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ii(t){return"number"==typeof t&&t==t&&t%1==0}function xi(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t||!Ii(t.length)||t.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Ni(t,e){if(e||(e={}),"number"==typeof t){Ei.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Mi(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Si(t)&&(t=t.toHexString()),Oi(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":Ei.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t>4]+Pi[15&i]}return e}return Ei.throwArgumentError("invalid hexlify value","value",t)}function Ti(t,e,r){return"string"!=typeof t?t=Ri(t):(!Oi(t)||t.length%2)&&Ei.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Ci(t,e){for("string"!=typeof t?t=Ri(t):Oi(t)||Ei.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Ei.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function ki(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(function(t){return Oi(t)&&!(t.length%2)||xi(t)}(t)){let r=Ni(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Ri(r.slice(0,32)),e.s=Ri(r.slice(32,64))):65===r.length?(e.r=Ri(r.slice(0,32)),e.s=Ri(r.slice(32,64)),e.v=r[64]):Ei.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:Ei.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Ri(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=function(t,e){(t=Ni(t)).length>e&&Ei.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),Mi(r)}(Ni(e._vs),32);e._vs=Ri(r);const i=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=i:e.recoveryParam!==i&&Ei.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const n=Ri(r);null==e.s?e.s=n:e.s!==n&&Ei.throwArgumentError("signature v mismatch _vs","signature",t)}if(null==e.recoveryParam)null==e.v?Ei.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(null==e.v)e.v=27+e.recoveryParam;else{const r=0===e.v||1===e.v?e.v:1-e.v%2;e.recoveryParam!==r&&Ei.throwArgumentError("signature recoveryParam mismatch v","signature",t)}null!=e.r&&Oi(e.r)?e.r=Ci(e.r,32):Ei.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&Oi(e.s)?e.s=Ci(e.s,32):Ei.throwArgumentError("signature missing or invalid s","signature",t);const r=Ni(e.s);r[0]>=128&&Ei.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Ri(r);e._vs&&(Oi(e._vs)||Ei.throwArgumentError("signature invalid _vs","signature",t),e._vs=Ci(e._vs,32)),null==e._vs?e._vs=i:e._vs!==i&&Ei.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function Ui(t){return"0x"+fi.keccak_256(Ni(t))}var Li={exports:{}},Di=function(t){var e=t.default;if("function"==typeof e){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})})),r}(Object.freeze({__proto__:null,default:{}}));!function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(("le"===e||"be"===e)&&(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<"u"&&typeof window.Buffer<"u"?window.Buffer:Di.Buffer}catch{}function o(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function a(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,i,n){for(var s=0,o=0,a=Math.min(t.length,i),h=e;h=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&o0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===i)for(n=0,s=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=a(t,e,i)<=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},typeof Symbol<"u"&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=c}catch{n.prototype.inspect=c}else n.prototype.inspect=c;function c(){return(this.red?""}var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,l=67108863&h,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;c+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}r.words[u]=0|l,h=0|c}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,s=0,o=0;o>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),i=0!==s||o!==this.length-1?l[6-h.length]+h+i:h+i}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=f[t],c=d[t];i="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(c).toString(t);i=(p=p.idivn(c)).isZero()?g+i:l[u-g.length]+g+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,"byte array longer than desired length"),r(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,n),o},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,s=0;n>8&255),r>16&255),6===s?(r>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,g=d>>>13,m=0|o[2],y=8191&m,v=m>>>13,w=0|o[3],b=8191&w,_=w>>>13,A=0|o[4],E=8191&A,S=A>>>13,M=0|o[5],I=8191&M,x=M>>>13,N=0|o[6],O=8191&N,P=N>>>13,R=0|o[7],T=8191&R,C=R>>>13,k=0|o[8],U=8191&k,L=k>>>13,D=0|o[9],q=8191&D,B=D>>>13,j=0|a[0],z=8191&j,F=j>>>13,K=0|a[1],H=8191&K,V=K>>>13,G=0|a[2],W=8191&G,$=G>>>13,J=0|a[3],Y=8191&J,Q=J>>>13,X=0|a[4],Z=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ct=0|a[8],lt=8191&ct,ft=ct>>>13,dt=0|a[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(i=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,F))+Math.imul(f,z)|0))<<13)|0;u=((s=Math.imul(f,F))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,z),n=(n=Math.imul(p,F))+Math.imul(g,z)|0,s=Math.imul(g,F);var yt=(u+(i=i+Math.imul(l,H)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(f,H)|0))<<13)|0;u=((s=s+Math.imul(f,V)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,z),n=(n=Math.imul(y,F))+Math.imul(v,z)|0,s=Math.imul(v,F),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(g,H)|0,s=s+Math.imul(g,V)|0;var vt=(u+(i=i+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,$)|0)+Math.imul(f,W)|0))<<13)|0;u=((s=s+Math.imul(f,$)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(b,z),n=(n=Math.imul(b,F))+Math.imul(_,z)|0,s=Math.imul(_,F),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,V)|0)+Math.imul(v,H)|0,s=s+Math.imul(v,V)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(g,W)|0,s=s+Math.imul(g,$)|0;var wt=(u+(i=i+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,Q)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,Q)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(E,z),n=(n=Math.imul(E,F))+Math.imul(S,z)|0,s=Math.imul(S,F),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,V)|0)+Math.imul(_,H)|0,s=s+Math.imul(_,V)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,$)|0)+Math.imul(v,W)|0,s=s+Math.imul(v,$)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,Q)|0;var bt=(u+(i=i+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(f,Z)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(I,z),n=(n=Math.imul(I,F))+Math.imul(x,z)|0,s=Math.imul(x,F),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,V)|0)+Math.imul(S,H)|0,s=s+Math.imul(S,V)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,$)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,$)|0,i=i+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,Q)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Z)|0,s=s+Math.imul(g,tt)|0;var _t=(u+(i=i+Math.imul(l,rt)|0)|0)+((8191&(n=(n=n+Math.imul(l,it)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(O,z),n=(n=Math.imul(O,F))+Math.imul(P,z)|0,s=Math.imul(P,F),i=i+Math.imul(I,H)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(x,H)|0,s=s+Math.imul(x,V)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,$)|0)+Math.imul(S,W)|0,s=s+Math.imul(S,$)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,Q)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,Q)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,Z)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,s=s+Math.imul(g,it)|0;var At=(u+(i=i+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(T,z),n=(n=Math.imul(T,F))+Math.imul(C,z)|0,s=Math.imul(C,F),i=i+Math.imul(O,H)|0,n=(n=n+Math.imul(O,V)|0)+Math.imul(P,H)|0,s=s+Math.imul(P,V)|0,i=i+Math.imul(I,W)|0,n=(n=n+Math.imul(I,$)|0)+Math.imul(x,W)|0,s=s+Math.imul(x,$)|0,i=i+Math.imul(E,Y)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,Q)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(_,Z)|0,s=s+Math.imul(_,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(g,st)|0,s=s+Math.imul(g,ot)|0;var Et=(u+(i=i+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,z),n=(n=Math.imul(U,F))+Math.imul(L,z)|0,s=Math.imul(L,F),i=i+Math.imul(T,H)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(C,H)|0,s=s+Math.imul(C,V)|0,i=i+Math.imul(O,W)|0,n=(n=n+Math.imul(O,$)|0)+Math.imul(P,W)|0,s=s+Math.imul(P,$)|0,i=i+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,Q)|0)+Math.imul(x,Y)|0,s=s+Math.imul(x,Q)|0,i=i+Math.imul(E,Z)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,Z)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(_,rt)|0,s=s+Math.imul(_,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(g,ht)|0,s=s+Math.imul(g,ut)|0;var St=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(q,z),n=(n=Math.imul(q,F))+Math.imul(B,z)|0,s=Math.imul(B,F),i=i+Math.imul(U,H)|0,n=(n=n+Math.imul(U,V)|0)+Math.imul(L,H)|0,s=s+Math.imul(L,V)|0,i=i+Math.imul(T,W)|0,n=(n=n+Math.imul(T,$)|0)+Math.imul(C,W)|0,s=s+Math.imul(C,$)|0,i=i+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,Q)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,Q)|0,i=i+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(x,Z)|0,s=s+Math.imul(x,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(_,st)|0,s=s+Math.imul(_,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,ut)|0,i=i+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(g,lt)|0,s=s+Math.imul(g,ft)|0;var Mt=(u+(i=i+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,gt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,gt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(q,H),n=(n=Math.imul(q,V))+Math.imul(B,H)|0,s=Math.imul(B,V),i=i+Math.imul(U,W)|0,n=(n=n+Math.imul(U,$)|0)+Math.imul(L,W)|0,s=s+Math.imul(L,$)|0,i=i+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,Q)|0,i=i+Math.imul(O,Z)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(x,rt)|0,s=s+Math.imul(x,it)|0,i=i+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(_,ht)|0,s=s+Math.imul(_,ut)|0,i=i+Math.imul(y,lt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(v,lt)|0,s=s+Math.imul(v,ft)|0;var It=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((s=s+Math.imul(g,gt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(q,W),n=(n=Math.imul(q,$))+Math.imul(B,W)|0,s=Math.imul(B,$),i=i+Math.imul(U,Y)|0,n=(n=n+Math.imul(U,Q)|0)+Math.imul(L,Y)|0,s=s+Math.imul(L,Q)|0,i=i+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(C,Z)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(x,st)|0,s=s+Math.imul(x,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,ut)|0,i=i+Math.imul(b,lt)|0,n=(n=n+Math.imul(b,ft)|0)+Math.imul(_,lt)|0,s=s+Math.imul(_,ft)|0;var xt=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((s=s+Math.imul(v,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(q,Y),n=(n=Math.imul(q,Q))+Math.imul(B,Y)|0,s=Math.imul(B,Q),i=i+Math.imul(U,Z)|0,n=(n=n+Math.imul(U,tt)|0)+Math.imul(L,Z)|0,s=s+Math.imul(L,tt)|0,i=i+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,it)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,i=i+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(x,ht)|0,s=s+Math.imul(x,ut)|0,i=i+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ft)|0)+Math.imul(S,lt)|0,s=s+Math.imul(S,ft)|0;var Nt=(u+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((s=s+Math.imul(_,gt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(q,Z),n=(n=Math.imul(q,tt))+Math.imul(B,Z)|0,s=Math.imul(B,tt),i=i+Math.imul(U,rt)|0,n=(n=n+Math.imul(U,it)|0)+Math.imul(L,rt)|0,s=s+Math.imul(L,it)|0,i=i+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,i=i+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,ft)|0)+Math.imul(x,lt)|0,s=s+Math.imul(x,ft)|0;var Ot=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,gt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((s=s+Math.imul(S,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(q,rt),n=(n=Math.imul(q,it))+Math.imul(B,rt)|0,s=Math.imul(B,it),i=i+Math.imul(U,st)|0,n=(n=n+Math.imul(U,ot)|0)+Math.imul(L,st)|0,s=s+Math.imul(L,ot)|0,i=i+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,ut)|0,i=i+Math.imul(O,lt)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,ft)|0;var Pt=(u+(i=i+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,gt)|0)+Math.imul(x,pt)|0))<<13)|0;u=((s=s+Math.imul(x,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(q,st),n=(n=Math.imul(q,ot))+Math.imul(B,st)|0,s=Math.imul(B,ot),i=i+Math.imul(U,ht)|0,n=(n=n+Math.imul(U,ut)|0)+Math.imul(L,ht)|0,s=s+Math.imul(L,ut)|0,i=i+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(C,lt)|0,s=s+Math.imul(C,ft)|0;var Rt=(u+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(q,ht),n=(n=Math.imul(q,ut))+Math.imul(B,ht)|0,s=Math.imul(B,ut),i=i+Math.imul(U,lt)|0,n=(n=n+Math.imul(U,ft)|0)+Math.imul(L,lt)|0,s=s+Math.imul(L,ft)|0;var Tt=(u+(i=i+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,gt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((s=s+Math.imul(C,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(q,lt),n=(n=Math.imul(q,ft))+Math.imul(B,lt)|0,s=Math.imul(B,ft);var Ct=(u+(i=i+Math.imul(U,pt)|0)|0)+((8191&(n=(n=n+Math.imul(U,gt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((s=s+Math.imul(L,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var kt=(u+(i=Math.imul(q,pt))|0)+((8191&(n=(n=Math.imul(q,gt))+Math.imul(B,pt)|0))<<13)|0;return u=((s=Math.imul(B,gt))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h[0]=mt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=_t,h[6]=At,h[7]=Et,h[8]=St,h[9]=Mt,h[10]=It,h[11]=xt,h[12]=Nt,h[13]=Ot,h[14]=Pt,h[15]=Rt,h[16]=Tt,h[17]=Ct,h[18]=kt,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function y(t,e,r){return m(t,e,r)}Math.imul||(g=p),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):r<63?p(this,t,e):r<1024?m(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n>=26,i+=s/67108864|0,i+=o>>>26,this.words[n]=67108863&o}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==c||u>=n);u--){var l=0|this.words[u];this.words[u]=c<<26-s|l>>>s,c=l&a}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,o=0|s.words[s.length-1];0!=(r=26-this._countBits(o))&&(s=s.ushln(r),i.iushln(r),o=0|s.words[s.length-1]);var a,h=i.length-s.length;if("mod"!==e){(a=new n(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var f=67108864*(0|i.words[s.length+l])+(0|i.words[s.length+l-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(s,f,l);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(s,1,l),i.isZero()||(i.negative^=1);a&&(a.words[l]=f)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(s=a.div.neg()),"div"!==e&&(o=a.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:s,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(s=a.div.neg()),{div:s,mod:a.mod}):this.negative&t.negative?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var s,o,a},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(i*n+(0|this.words[s]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*i;this.words[n]=s/t|0,i=s%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),o=new n(0),a=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var c=i.clone(),l=e.clone();!e.isZero();){for(var f=0,d=1;!(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(s.isOdd()||o.isOdd())&&(s.iadd(c),o.isub(l)),s.iushrn(1),o.iushrn(1);for(var p=0,g=1;!(i.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(c),h.isub(l)),a.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(a),o.isub(h)):(i.isub(e),a.isub(s),h.isub(o))}return{a,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),a=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var u=0,c=1;!(i.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var l=0,f=1;!(s.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(s.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);i.cmp(s)>=0?(i.isub(s),o.isub(a)):(s.isub(i),a.isub(o))}return(e=0===i.cmpn(1)?o:a).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new S(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function M(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(b,w),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new _;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return v[t]=e,e},S.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},S.prototype._verify2=function(t,e){r(!(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),o=0;!s.isZero()&&0===s.andln(1);)o++,s.iushrn(1);r(!s.isZero());var a=new n(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,u).cmp(h);)c.redIAdd(h);for(var l=this.pow(c,s),f=this.pow(t,s.addn(1).iushrn(1)),d=this.pow(t,s),p=o;0!==d.cmp(a);){for(var g=d,m=0;0!==g.cmp(a);m++)g=g.redSqr();r(m=0;i--){for(var u=e.words[i],c=h-1;c>=0;c--){var l=u>>c&1;s!==r[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===i&&0===c)&&(s=this.mul(s,r[o]),a=0,o=0)):a=0}h=26}return s},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new M(t)},i(M,S),M.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},M.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},M.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},M.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},M.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,ci)}(Li);var qi=Li.exports;const Bi="bignumber/5.7.0";var ji=qi.BN;const zi=new Ai(Bi),Fi={},Ki=9007199254740991;let Hi=!1;class Vi{constructor(t,e){t!==Fi&&zi.throwError("cannot call constructor directly; use BigNumber.from",Ai.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return Wi($i(this).fromTwos(t))}toTwos(t){return Wi($i(this).toTwos(t))}abs(){return"-"===this._hex[0]?Vi.from(this._hex.substring(1)):this}add(t){return Wi($i(this).add($i(t)))}sub(t){return Wi($i(this).sub($i(t)))}div(t){return Vi.from(t).isZero()&&Ji("division-by-zero","div"),Wi($i(this).div($i(t)))}mul(t){return Wi($i(this).mul($i(t)))}mod(t){const e=$i(t);return e.isNeg()&&Ji("division-by-zero","mod"),Wi($i(this).umod(e))}pow(t){const e=$i(t);return e.isNeg()&&Ji("negative-power","pow"),Wi($i(this).pow(e))}and(t){const e=$i(t);return(this.isNegative()||e.isNeg())&&Ji("unbound-bitwise-result","and"),Wi($i(this).and(e))}or(t){const e=$i(t);return(this.isNegative()||e.isNeg())&&Ji("unbound-bitwise-result","or"),Wi($i(this).or(e))}xor(t){const e=$i(t);return(this.isNegative()||e.isNeg())&&Ji("unbound-bitwise-result","xor"),Wi($i(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&Ji("negative-width","mask"),Wi($i(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&Ji("negative-width","shl"),Wi($i(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&Ji("negative-width","shr"),Wi($i(this).shrn(t))}eq(t){return $i(this).eq($i(t))}lt(t){return $i(this).lt($i(t))}lte(t){return $i(this).lte($i(t))}gt(t){return $i(this).gt($i(t))}gte(t){return $i(this).gte($i(t))}isNegative(){return"-"===this._hex[0]}isZero(){return $i(this).isZero()}toNumber(){try{return $i(this).toNumber()}catch{Ji("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return zi.throwError("this platform does not support BigInt",Ai.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?Hi||(Hi=!0,zi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?zi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ai.errors.UNEXPECTED_ARGUMENT,{}):zi.throwError("BigNumber.toString does not accept parameters",Ai.errors.UNEXPECTED_ARGUMENT,{})),$i(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof Vi)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new Vi(Fi,Gi(t)):t.match(/^-?[0-9]+$/)?new Vi(Fi,Gi(new ji(t))):zi.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&Ji("underflow","BigNumber.from",t),(t>=Ki||t<=-Ki)&&Ji("overflow","BigNumber.from",t),Vi.from(String(t));const e=t;if("bigint"==typeof e)return Vi.from(e.toString());if(xi(e))return Vi.from(Ri(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return Vi.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(Oi(t)||"-"===t[0]&&Oi(t.substring(1))))return Vi.from(t)}return zi.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function Gi(t){if("string"!=typeof t)return Gi(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&zi.throwArgumentError("invalid hex","value",t),"0x00"===(t=Gi(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function Wi(t){return Vi.from(Gi(t))}function $i(t){const e=Vi.from(t).toHexString();return"-"===e[0]?new ji("-"+e.substring(3),16):new ji(e.substring(2),16)}function Ji(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),zi.throwError(t,Ai.errors.NUMERIC_FAULT,i)}const Yi=new Ai(Bi),Qi={},Xi=Vi.from(0),Zi=Vi.from(-1);function tn(t,e,r,i){const n={fault:e,operation:r};return void 0!==i&&(n.value=i),Yi.throwError(t,Ai.errors.NUMERIC_FAULT,n)}let en="0";for(;en.length<256;)en+=en;function rn(t){if("number"!=typeof t)try{t=Vi.from(t).toNumber()}catch{}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+en.substring(0,t):Yi.throwArgumentError("invalid decimal size","decimals",t)}function nn(t,e){null==e&&(e=0);const r=rn(e),i=(t=Vi.from(t)).lt(Xi);i&&(t=t.mul(Zi));let n=t.mod(r).toString();for(;n.length2&&Yi.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");"0"===o[o.length-1];)o=o.substring(0,o.length-1);for(o.length>r.length-1&&tn("fractional component exceeds decimals","underflow","parseFixed"),""===o&&(o="0");o.lengthnull==t[e]?i:(typeof t[e]!==r&&Yi.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=n("signed","boolean",e),r=n("width","number",r),i=n("decimals","number",i)}return r%8&&Yi.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),i>80&&Yi.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new on(Qi,e,r,i)}}class an{constructor(t,e,r,i){t!==Qi&&Yi.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ai.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=i,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&Yi.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=sn(this._value,this.format.decimals),r=sn(t._value,t.format.decimals);return an.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=sn(this._value,this.format.decimals),r=sn(t._value,t.format.decimals);return an.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=sn(this._value,this.format.decimals),r=sn(t._value,t.format.decimals);return an.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=sn(this._value,this.format.decimals),r=sn(t._value,t.format.decimals);return an.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=an.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return this.isNegative()&&r&&(e=e.subUnsafe(hn.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=an.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return!this.isNegative()&&r&&(e=e.addUnsafe(hn.toFormat(e.format))),e}round(t){null==t&&(t=0);const e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&Yi.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const r=an.from("1"+en.substring(0,t),this.format),i=un.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(i).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(t){return null==t?this._hex:(t%8&&Yi.throwArgumentError("invalid byte width","width",t),Ci(Vi.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8))}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return an.fromString(this._value,t)}static fromValue(t,e,r){return null==r&&null!=e&&!function(t){return null!=t&&(Vi.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||Oi(t)||"bigint"==typeof t||xi(t))}(e)&&(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),an.fromString(nn(t,e),on.from(r))}static fromString(t,e){null==e&&(e="fixed");const r=on.from(e),i=sn(t,r.decimals);!r.signed&&i.lt(Xi)&&tn("unsigned value cannot be negative","overflow","value",t);let n=null;r.signed?n=i.toTwos(r.width).toHexString():(n=i.toHexString(),n=Ci(n,r.width/8));const s=nn(i,r.decimals);return new an(Qi,n,s,r)}static fromBytes(t,e){null==e&&(e="fixed");const r=on.from(e);if(Ni(t).length>r.width/8)throw new Error("overflow");let i=Vi.from(t);r.signed&&(i=i.fromTwos(r.width));const n=i.toTwos((r.signed?0:1)+r.width).toHexString(),s=nn(i,r.decimals);return new an(Qi,n,s,r)}static from(t,e){if("string"==typeof t)return an.fromString(t,e);if(xi(t))return an.fromBytes(t,e);try{return an.fromValue(t,0,e)}catch(t){if(t.code!==Ai.errors.INVALID_ARGUMENT)throw t}return Yi.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const hn=an.from(1),un=an.from("0.5"),cn=new Ai("strings/5.7.0");var ln,fn;function dn(t,e,r,i,n){if(t===fn.BAD_PREFIX||t===fn.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i>6==2;i++)t++;return t}return t===fn.OVERRUN?r.length-e-1:0}function pn(t,e=ln.current){e!=ln.current&&(cn.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const s=65536+((1023&i)<<10)+(1023&n);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return Ni(r)}function gn(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,i={};return t.split(",").forEach((t=>{let n=t.split(":");r+=parseInt(n[0],16),i[r]=e(n[1])})),i}function mn(t){let e=0;return t.split(",").map((t=>{let r=t.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let i=e+parseInt(r[0],16);return e=parseInt(r[1],16),{l:i,h:e}}))}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(ln||(ln={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(fn||(fn={})),Object.freeze({error:function(t,e,r,i,n){return cn.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:dn,replace:function(t,e,r,i,n){return t===fn.OVERLONG?(i.push(n),0):(i.push(65533),dn(t,e,r))}}),mn("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((t=>parseInt(t,16))),gn("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),gn("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),gn("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r0&&Array.isArray(t)?n(t,e-1):r.push(t)}))};return n(t,e),r}function wn(t){return 1&t?~t>>1:t>>1}function bn(t,e){let r=Array(t);for(let i=0,n=-1;ie[t])):r}function En(t,e,r){let i=Array(t).fill(void 0).map((()=>[]));for(let n=0;ni[e].push(t)));return i}function Sn(t,e){let r=1+e(),i=e(),n=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(r)}return e}(e);return vn(En(n.length,1+t,e).map(((t,e)=>{const s=t[0],o=t.slice(1);return Array(n[e]).fill(void 0).map(((t,e)=>{let n=e*i;return[s+e*r,o.map((t=>t+n))]}))})))}function Mn(t,e){return En(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}const In=function(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,s=[0,1];for(let t=1;t>--h&1}const l=Math.pow(2,31),f=l>>>1,d=f>>1,p=l-1;let g=0;for(let t=0;t<31;t++)g=g<<1|c();let m=[],y=0,v=l;for(;;){let t=Math.floor(((g-y+1)*n-1)/v),e=0,r=i;for(;r-e>1;){let i=e+r>>>1;t>>1|c(),o=o<<1^f,a=(a^f)<<1|f|1;y=o,v=1+a-o}let w=i-4;return m.map((e=>{switch(e-w){case 3:return w+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return w+256+(t[a++]<<8|t[a++]);case 1:return w+t[a++];default:return e-1}}))}(t))}(function(t){t=atob(t);const e=[];for(let r=0;rt-e));!function r(){let i=[];for(;;){let n=An(t,e);if(0==n.length)break;i.push({set:new Set(n),node:r()})}i.sort(((t,e)=>e.set.size-t.set.size));let n=t(),s=n%3;n=n/3|0;let o=!!(1&n);return n>>=1,{branches:i,valid:s,fe0f:o,save:1==n,check:2==n}}()}(In),new Ai(yn),new Uint8Array(32).fill(0);const xn="Ethereum Signed Message:\n";function Nn(t){return"string"==typeof t&&(t=pn(t)),Ui(function(t){const e=t.map((t=>Ni(t))),r=e.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(r);return e.reduce(((t,e)=>(i.set(e,t),t+e.length)),0),Mi(i)}([pn(xn),pn(String(t.length)),t]))}new Ai("rlp/5.7.0");const On=new Ai("address/5.7.0");function Pn(t){Oi(t,20)||On.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const i=Ni(Ui(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Rn={};for(let t=0;t<10;t++)Rn[String(t)]=String(t);for(let t=0;t<26;t++)Rn[String.fromCharCode(65+t)]=String(10+t);const Tn=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Cn(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}new Ai("properties/5.7.0"),new Ai(yn),new Uint8Array(32).fill(0),Vi.from(-1);const kn=Vi.from(0),Un=Vi.from(1);Vi.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ci(Un.toHexString(),32),Ci(kn.toHexString(),32);var Ln={},Dn={},qn=Bn;function Bn(t,e){if(!t)throw new Error(e||"Assertion failed")}Bn.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var jn={exports:{}};"function"==typeof Object.create?jn.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:jn.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var zn=qn,Fn=jn.exports;function Kn(t,e){return!(55296!=(64512&t.charCodeAt(e))||e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function Hn(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Vn(t){return 1===t.length?"0"+t:t}function Gn(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Dn.inherits=Fn,Dn.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>6|192,r[i++]=63&s|128):Kn(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=63&s|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=63&s|128)}else for(n=0;n>>0}return s},Dn.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},Dn.rotr32=function(t,e){return t>>>e|t<<32-e},Dn.rotl32=function(t,e){return t<>>32-e},Dn.sum32=function(t,e){return t+e>>>0},Dn.sum32_3=function(t,e,r){return t+e+r>>>0},Dn.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},Dn.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},Dn.sum64=function(t,e,r,i){var n=t[e],s=i+t[e+1]>>>0,o=(s>>0,t[e+1]=s},Dn.sum64_hi=function(t,e,r,i){return(e+i>>>0>>0},Dn.sum64_lo=function(t,e,r,i){return e+i>>>0},Dn.sum64_4_hi=function(t,e,r,i,n,s,o,a){var h=0,u=e;return h+=(u=u+i>>>0)>>0)>>0)>>0},Dn.sum64_4_lo=function(t,e,r,i,n,s,o,a){return e+i+s+a>>>0},Dn.sum64_5_hi=function(t,e,r,i,n,s,o,a,h,u){var c=0,l=e;return c+=(l=l+i>>>0)>>0)>>0)>>0)>>0},Dn.sum64_5_lo=function(t,e,r,i,n,s,o,a,h,u){return e+i+s+a+u>>>0},Dn.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},Dn.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},Dn.shr64_hi=function(t,e,r){return t>>>r},Dn.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0};var Wn={},$n=Dn,Jn=qn;function Yn(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Wn.BlockHash=Yn,Yn.prototype.update=function(t,e){if(t=$n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=$n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s>>3},Xn.g1_256=function(t){return Zn(t,17)^Zn(t,19)^t>>>10};var is=Dn,ns=Wn,ss=Xn,os=is.rotl32,as=is.sum32,hs=is.sum32_5,us=ss.ft_1,cs=ns.BlockHash,ls=[1518500249,1859775393,2400959708,3395469782];function fs(){if(!(this instanceof fs))return new fs;cs.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}is.inherits(fs,cs);var ds=fs;fs.blockSize=512,fs.outSize=160,fs.hmacStrength=80,fs.padLength=64,fs.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;ithis.blockSize&&(t=(new this.Hash).update(t).digest()),Co(t.length<=this.blockSize);for(var e=t.length;e>8,o=255&n;s?r.push(s,o):r.push(o)}return r},r.zero2=i,r.toHex=n,r.encode=function(t,e){return"hex"===e?n(t):t}})),jo=Lo((function(t,e){var r=e;r.assert=Do,r.toArray=Bo.toArray,r.zero2=Bo.zero2,r.toHex=Bo.toHex,r.encode=Bo.encode,r.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,h=t.andln(3)+n&3,u=e.andln(3)+s&3;3===h&&(h=-1),3===u&&(u=-1),o=1&h?3!=(i=t.andln(7)+n&7)&&5!==i||2!==u?h:-h:0,r[0].push(o),a=1&u?3!=(i=e.andln(7)+s&7)&&5!==i||2!==h?u:-u:0,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new qi(t,"hex","le")}})),zo=jo.getNAF,Fo=jo.getJSF,Ko=jo.assert;function Ho(t,e){this.type=t,this.p=new qi(e.p,16),this.red=e.prime?qi.red(e.prime):qi.mont(this.p),this.zero=new qi(0).toRed(this.red),this.one=new qi(1).toRed(this.red),this.two=new qi(2).toRed(this.red),this.n=e.n&&new qi(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Vo=Ho;function Go(t,e){this.curve=t,this.type=e,this.precomputed=null}Ho.prototype.point=function(){throw new Error("Not implemented")},Ho.prototype.validate=function(){throw new Error("Not implemented")},Ho.prototype._fixedNafMul=function(t,e){Ko(t.precomputed);var r=t._getDoubles(),i=zo(e,1,this._bitLength),n=(1<=s;h--)o=(o<<1)+i[h];a.push(o)}for(var u=this.jpoint(null,null,null),c=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var h=0;a>=0&&0===s[a];a--)h++;if(a>=0&&h++,o=o.dblp(h),a<0)break;var u=s[a];Ko(0!==u),o="affine"===t.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},Ho.prototype._wnafMulAdd=function(t,e,r,i,n){var s,o,a,h=this._wnafT1,u=this._wnafT2,c=this._wnafT3,l=0;for(s=0;s=1;s-=2){var d=s-1,p=s;if(1===h[d]&&1===h[p]){var g=[e[d],null,null,e[p]];0===e[d].y.cmp(e[p].y)?(g[1]=e[d].add(e[p]),g[2]=e[d].toJ().mixedAdd(e[p].neg())):0===e[d].y.cmp(e[p].y.redNeg())?(g[1]=e[d].toJ().mixedAdd(e[p]),g[2]=e[d].add(e[p].neg())):(g[1]=e[d].toJ().mixedAdd(e[p]),g[2]=e[d].toJ().mixedAdd(e[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=Fo(r[d],r[p]);for(l=Math.max(y[0].length,l),c[d]=new Array(l),c[p]=new Array(l),o=0;o=0;s--){for(var A=0;s>=0;){var E=!0;for(o=0;o=0&&A++,b=b.dblp(A),s<0)break;for(o=0;o0?a=u[o][S-1>>1]:S<0&&(a=u[o][-S-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},Go.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n=0&&(s=e,o=r),i.negative&&(i=i.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:n},{a:s,b:o}]},Jo.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),h=n.mul(r.b),u=s.mul(i.b);return{k1:t.sub(o).sub(a),k2:h.add(u).neg()}},Jo.prototype.pointFromX=function(t,e){(t=new qi(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},Jo.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},Jo.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},Qo.prototype.isInfinity=function(){return this.inf},Qo.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},Qo.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},Qo.prototype.getX=function(){return this.x.fromRed()},Qo.prototype.getY=function(){return this.y.fromRed()},Qo.prototype.mul=function(t){return t=new qi(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Qo.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},Qo.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},Qo.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Qo.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},Qo.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Wo(Xo,Vo.BasePoint),Jo.prototype.jpoint=function(t,e,r){return new Xo(this,t,e,r)},Xo.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},Xo.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Xo.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),l=i.redMul(u),f=h.redSqr().redIAdd(c).redISub(l).redISub(l),d=h.redMul(l.redISub(f)).redISub(s.redMul(c)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(f,d,p)},Xo.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),c=r.redMul(h),l=a.redSqr().redIAdd(u).redISub(c).redISub(c),f=a.redMul(c.redISub(l)).redISub(n.redMul(u)),d=this.z.redMul(o);return this.curve.jpoint(l,f,d)},Xo.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},Xo.prototype.inspect=function(){return this.isInfinity()?"":""},Xo.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Zo=Lo((function(t,e){var r=e;r.base=Vo,r.short=Yo,r.mont=null,r.edwards=null})),ta=Lo((function(t,e){var r,i=e,n=jo.assert;function s(t){"short"===t.type?this.curve=new Zo.short(t):"edwards"===t.type?this.curve=new Zo.edwards(t):this.curve=new Zo.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ln.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ln.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ln.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ln.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ln.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ln.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ln.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch{r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ln.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function ea(t){if(!(this instanceof ea))return new ea(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Bo.toArray(t.entropy,t.entropyEnc||"hex"),r=Bo.toArray(t.nonce,t.nonceEnc||"hex"),i=Bo.toArray(t.pers,t.persEnc||"hex");Do(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var ra=ea;ea.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},ea.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=Bo.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length"};var oa=jo.assert;function aa(t,e){if(t instanceof aa)return t;this._importDER(t,e)||(oa(t.r&&t.s,"Signature without r or s"),this.r=new qi(t.r,16),this.s=new qi(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var ha=aa;function ua(){this.place=0}function ca(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function la(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}aa.prototype._importDER=function(t,e){t=jo.toArray(t,e);var r=new ua;if(48!==t[r.place++])return!1;var i=ca(t,r);if(!1===i||i+r.place!==t.length||2!==t[r.place++])return!1;var n=ca(t,r);if(!1===n)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=ca(t,r);if(!1===o||t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new qi(s),this.s=new qi(a),this.recoveryParam=null,!0},aa.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=la(e),r=la(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];fa(i,e.length),(i=i.concat(e)).push(2),fa(i,r.length);var n=i.concat(r),s=[48];return fa(s,n.length),s=s.concat(n),jo.encode(s,t)};var da=function(){throw new Error("unsupported")},pa=jo.assert;function ga(t){if(!(this instanceof ga))return new ga(t);"string"==typeof t&&(pa(Object.prototype.hasOwnProperty.call(ta,t),"Unknown curve "+t),t=ta[t]),t instanceof ta.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var ma=ga;ga.prototype.keyPair=function(t){return new sa(this,t)},ga.prototype.keyFromPrivate=function(t,e){return sa.fromPrivate(this,t,e)},ga.prototype.keyFromPublic=function(t,e){return sa.fromPublic(this,t,e)},ga.prototype.genKeyPair=function(t){t||(t={});for(var e=new ra({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||da(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new qi(2));;){var n=new qi(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},ga.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},ga.prototype.sign=function(t,e,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new qi(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new ra({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),h=this.n.sub(new qi(1)),u=0;;u++){var c=i.k?i.k(u):new qi(a.generate(this.n.byteLength()));if(!((c=this._truncateToN(c,!0)).cmpn(1)<=0||c.cmp(h)>=0)){var l=this.g.mul(c);if(!l.isInfinity()){var f=l.getX(),d=f.umod(this.n);if(0!==d.cmpn(0)){var p=c.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var g=(l.getY().isOdd()?1:0)|(0!==f.cmp(d)?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),g^=1),new ha({r:d,s:p,recoveryParam:g})}}}}}},ga.prototype.verify=function(t,e,r,i){t=this._truncateToN(new qi(t,16)),r=this.keyFromPublic(r,i);var n=(e=new ha(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},ga.prototype.recoverPubKey=function(t,e,r,i){pa((3&r)===r,"The recovery param is more than two bits"),e=new ha(e,i);var n=this.n,s=new qi(t),o=e.r,a=e.s,h=1&r,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");o=u?this.curve.pointFromX(o.add(this.curve.n),h):this.curve.pointFromX(o,h);var c=e.r.invm(n),l=n.sub(s).mul(c).umod(n),f=a.mul(c).umod(n);return this.g.mulAdd(l,o,f)},ga.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new ha(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var ya=Lo((function(t,e){var r=e;r.version="6.5.4",r.utils=jo,r.rand=function(){throw new Error("unsupported")},r.curve=Zo,r.curves=ta,r.ec=ma,r.eddsa=null})).ec;const va=new Ai("signing-key/5.7.0");let wa=null;function ba(){return wa||(wa=new ya("secp256k1")),wa}class _a{constructor(t){Cn(this,"curve","secp256k1"),Cn(this,"privateKey",Ri(t)),32!==function(t){if("string"!=typeof t)t=Ri(t);else if(!Oi(t)||t.length%2)return null;return(t.length-2)/2}(this.privateKey)&&va.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=ba().keyFromPrivate(Ni(this.privateKey));Cn(this,"publicKey","0x"+e.getPublic(!1,"hex")),Cn(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Cn(this,"_isSigningKey",!0)}_addPoint(t){const e=ba().keyFromPublic(Ni(this.publicKey)),r=ba().keyFromPublic(Ni(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=ba().keyFromPrivate(Ni(this.privateKey)),r=Ni(t);32!==r.length&&va.throwArgumentError("bad digest length","digest",t);const i=e.sign(r,{canonical:!0});return ki({recoveryParam:i.recoveryParam,r:Ci("0x"+i.r.toString(16),32),s:Ci("0x"+i.s.toString(16),32)})}computeSharedSecret(t){const e=ba().keyFromPrivate(Ni(this.privateKey)),r=ba().keyFromPublic(Ni(Aa(t)));return Ci("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Aa(t,e){const r=Ni(t);if(32===r.length){const t=new _a(r);return e?"0x"+ba().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?Ri(r):"0x"+ba().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+ba().keyFromPublic(r).getPublic(!0,"hex"):Ri(r):va.throwArgumentError("invalid public or private key","key","[REDACTED]")}var Ea;function Sa(t,e){return function(t){return function(t){let e=null;if("string"!=typeof t&&On.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Pn(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&On.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Rn[t])).join("");for(;e.length>=Tn;){let t=e.substring(0,Tn);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&On.throwArgumentError("bad icap checksum","address",t),e=function(t){return new ji(t,36).toString(16)}(t.substring(4));e.length<40;)e="0"+e;e=Pn("0x"+e)}else On.throwArgumentError("invalid address","address",t);return e}(Ti(Ui(Ti(Aa(t),1)),12))}(function(t,e){const r=ki(e),i={r:Ni(r.r),s:Ni(r.s)};return"0x"+ba().recoverPubKey(Ni(t),i,r.recoveryParam).encode("hex",!1)}(Ni(t),e))}new Ai("transactions/5.7.0"),function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(Ea||(Ea={}));const Ma="https://rpc.walletconnect.com/v1";var Ia=Object.defineProperty,xa=Object.defineProperties,Na=Object.getOwnPropertyDescriptors,Oa=Object.getOwnPropertySymbols,Pa=Object.prototype.hasOwnProperty,Ra=Object.prototype.propertyIsEnumerable,Ta=(t,e,r)=>e in t?Ia(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;const Ca=t=>t?.split(":"),ka=t=>{const e=t&&Ca(t);if(e)return t.includes("did:pkh:")?e[3]:e[1]},Ua=t=>{const e=t&&Ca(t);if(e)return e[2]+":"+e[3]},La=t=>{const e=t&&Ca(t);if(e)return e.pop()};async function Da(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=qa(n,n.iss),o=La(n.iss);return await async function(t,e,r,i,n,s){switch(r.t){case"eip191":return function(t,e,r){return Sa(Nn(e),r).toLowerCase()===t.toLowerCase()}(t,e,r.s);case"eip1271":return await async function(t,e,r,i,n,s){try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),c=o+Nn(e).substring(2)+a+h+u,l=await fetch(`${s||Ma}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:c},"latest"]})}),{result:f}=await l.json();return!!f&&f.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(t){return console.error("isValidEip1271Signature: ",t),!1}}(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}(o,s,i,ka(n.iss),r)}const qa=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=La(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${ka(e)}`,h=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,c=t.resources?`Resources:${t.resources.map((t=>`\n- ${t}`)).join("")}`:void 0,l=Ga(t.resources);return l&&(n=function(t="",e){Ba(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;return Object.keys(e.att).forEach((t=>{const r=Object.keys(e.att[t]).map((t=>({ability:t.split("/")[0],action:t.split("/")[1]})));r.sort(((t,e)=>t.action.localeCompare(e.action)));const s={};r.forEach((t=>{s[t.ability]||(s[t.ability]=[]),s[t.ability].push(t.action)}));const o=Object.keys(s).map((e=>(n++,`(${n}) '${e}': '${s[e].join("', '")}' for '${t}'.`)));i.push(o.join(", ").replace(".,","."))})),`${t?t+" ":""}${r}${i.join(" ")}`}(n,Fa(l))),[r,i,"",n,"",s,o,a,h,u,c].filter((t=>null!=t)).join("\n")};function Ba(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(null==e||!e.length)throw new Error("No resources found in `att` property");e.forEach((e=>{const r=t.att[e];if(Array.isArray(r))throw new Error(`Resource must be an object: ${e}`);if("object"!=typeof r)throw new Error(`Resource must be an object: ${e}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${e}`);Object.keys(r).forEach((t=>{const e=r[t];if(!Array.isArray(e))throw new Error(`Ability limits ${t} must be an array of objects, found: ${e}`);if(!e.length)throw new Error(`Value of ${t} is empty array, must be an array with objects`);e.forEach((e=>{if("object"!=typeof e)throw new Error(`Ability limits (${t}) must be an array of objects, found: ${e}`)}))}))}))}function ja(t,e,r={}){e=e?.sort(((t,e)=>t.localeCompare(e)));const i=e.map((e=>({[`${t}/${e}`]:[r]})));return Object.assign({},...i)}function za(t){return Ba(t),`urn:recap:${function(t){return Buffer.from(JSON.stringify(t)).toString("base64")}(t).replace(/=/g,"")}`}function Fa(t){const e=function(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}(t.replace("urn:recap:",""));return Ba(e),e}function Ka(t,e){const r=function(t,e){Ba(t),Ba(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort(((t,e)=>t.localeCompare(e))),i={att:{}};return r.forEach((r=>{var n,s;Object.keys((null==(n=t.att)?void 0:n[r])||{}).concat(Object.keys((null==(s=e.att)?void 0:s[r])||{})).sort(((t,e)=>t.localeCompare(e))).forEach((n=>{var s,o;i.att[r]=((t,e)=>xa(t,Na(e)))(((t,e)=>{for(var r in e||(e={}))Pa.call(e,r)&&Ta(t,r,e[r]);if(Oa)for(var r of Oa(e))Ra.call(e,r)&&Ta(t,r,e[r]);return t})({},i.att[r]),{[n]:(null==(s=t.att[r])?void 0:s[n])||(null==(o=e.att[r])?void 0:o[n])})}))})),i}(Fa(t),Fa(e));return za(r)}function Ha(t){var e;const r=Fa(t);Ba(r);const i=null==(e=r.att)?void 0:e.eip155;return i?Object.keys(i).map((t=>t.split("/")[1])):[]}function Va(t){const e=Fa(t);Ba(e);const r=[];return Object.values(e.att).forEach((t=>{Object.values(t).forEach((t=>{var e;null!=(e=t?.[0])&&e.chains&&r.push(t[0].chains)}))})),[...new Set(r.flat())]}function Ga(t){if(!t)return;const e=t?.[t.length-1];return function(t){return t&&t.includes("urn:recap:")}(e)?e:void 0}const Wa="base10",$a="base16",Ja="base64pad",Ya="utf8";function Qa(){return fr((0,Pt.randomBytes)(32),$a)}function Xa(t){return fr((0,Cr.tW)(dr(t,$a)),$a)}function Za(t){return fr((0,Cr.tW)(dr(t,Ya)),$a)}function th(t){return Number(fr(t,Wa))}function eh(t){const e=dr(t,Ja),r=e.slice(0,1);if(1===th(r)){const t=33,i=t+12,n=e.slice(1,t),s=e.slice(t,i);return{type:r,sealed:e.slice(i),iv:s,senderPublicKey:n}}const i=e.slice(1,13);return{type:r,sealed:e.slice(13),iv:i}}function rh(t){const e=t?.type||0;if(1===e){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 ih(t){return 1===t.type&&"string"==typeof t.senderPublicKey&&"string"==typeof t.receiverPublicKey}function nh(t){return t?.relay||{protocol:"irn"}}function sh(t){const e=Ur[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var oh=Object.defineProperty,ah=Object.defineProperties,hh=Object.getOwnPropertyDescriptors,uh=Object.getOwnPropertySymbols,ch=Object.prototype.hasOwnProperty,lh=Object.prototype.propertyIsEnumerable,fh=(t,e,r)=>e in t?oh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dh=(t,e)=>{for(var r in e||(e={}))ch.call(e,r)&&fh(t,r,e[r]);if(uh)for(var r of uh(e))lh.call(e,r)&&fh(t,r,e[r]);return t};function ph(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach((e=>{if(e.startsWith(i)){const n=e.replace(i,""),s=t[e];r[n]=s}})),r}function gh(t){const e=(t=(t=t.includes("wc://")?t.replace("wc://",""):t).includes("wc:")?t.replace("wc:",""):t).indexOf(":"),r=-1!==t.indexOf("?")?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=Pr.parse(s),a="string"==typeof o.methods?o.methods.split(","):void 0;return{protocol:i,topic:mh(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:ph(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function mh(t){return t.startsWith("//")?t.substring(2):t}var yh=Object.defineProperty,vh=Object.defineProperties,wh=Object.getOwnPropertyDescriptors,bh=Object.getOwnPropertySymbols,_h=Object.prototype.hasOwnProperty,Ah=Object.prototype.propertyIsEnumerable,Eh=(t,e,r)=>e in t?yh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sh=(t,e)=>{for(var r in e||(e={}))_h.call(e,r)&&Eh(t,r,e[r]);if(bh)for(var r of bh(e))Ah.call(e,r)&&Eh(t,r,e[r]);return t},Mh=(t,e)=>vh(t,wh(e));function Ih(t){const e=[];return t.forEach((t=>{const[r,i]=t.split(":");e.push(`${r}:${i}`)})),e}function xh(t){return t.includes(":")}function Nh(t){return xh(t)?t.split(":")[0]:t}function Oh(t){var e,r,i;const n={};if(!Lh(t))return n;for(const[s,o]of Object.entries(t)){const t=xh(s)?[s]:o.chains,a=o.methods||[],h=o.events||[],u=Nh(s);n[u]=Mh(Sh({},n[u]),{chains:hi(t,null==(e=n[u])?void 0:e.chains),methods:hi(a,null==(r=n[u])?void 0:r.methods),events:hi(h,null==(i=n[u])?void 0:i.events)})}return n}function Ph(t,e){e=e.map((t=>t.replace("did:pkh:","")));const r=function(t){const e={};return t?.forEach((t=>{const[r,i]=t.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[]}),e[r].accounts.push(t),e[r].chains.push(`${r}:${i}`)})),e}(e);for(const[e,i]of Object.entries(r))i.methods?i.methods=hi(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return r}const Rh={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}},Th={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 Ch(t,e){const{message:r,code:i}=Th[t];return{message:e?`${r} ${e}`:r,code:i}}function kh(t,e){const{message:r,code:i}=Rh[t];return{message:e?`${r} ${e}`:r,code:i}}function Uh(t,e){return!!Array.isArray(t)&&(!(typeof e<"u"&&t.length)||t.every(e))}function Lh(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Dh(t){return typeof t>"u"}function qh(t,e){return!(!e||!Dh(t))||"string"==typeof t&&!!t.trim().length}function Bh(t,e){return!(!e||!Dh(t))||"number"==typeof t&&!isNaN(t)}function jh(t){return!(!qh(t,!1)||!t.includes(":"))&&2===t.split(":").length}function zh(t){if(qh(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function Fh(t){let e=!0;return Uh(t)?t.length&&(e=t.every((t=>qh(t,!1)))):e=!1,e}function Kh(t,e){let r=null;return Object.values(t).forEach((t=>{if(r)return;const i=function(t,e){let r=null;return Fh(t?.methods)?Fh(t?.events)||(r=kh("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=kh("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}(t,`${e}, namespace`);i&&(r=i)})),r}function Hh(t,e){let r=null;if(t&&Lh(t)){const i=Kh(t,e);i&&(r=i);const n=function(t,e){let r=null;return Object.values(t).forEach((t=>{if(r)return;const i=function(t,e){let r=null;return Uh(t)?t.forEach((t=>{r||function(t){if(qh(t,!1)&&t.includes(":")){const e=t.split(":");if(3===e.length){const t=e[0]+":"+e[1];return!!e[2]&&jh(t)}}return!1}(t)||(r=kh("UNSUPPORTED_ACCOUNTS",`${e}, account ${t} should be a string and conform to "namespace:chainId:address" format`))})):r=kh("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}(t?.accounts,`${e} namespace`);i&&(r=i)})),r}(t,e);n&&(r=n)}else r=Ch("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Vh(t){return qh(t.protocol,!0)}function Gh(t){return typeof t<"u"&&null!==typeof t}function Wh(t,e){return!(!jh(e)||!function(t){const e=[];return Object.values(t).forEach((t=>{e.push(...Ih(t.accounts))})),e}(t).includes(e))}function $h(t,e,r){let i=null;const n=function(t){const e={};return Object.keys(t).forEach((r=>{var i;r.includes(":")?e[r]=t[r]:null==(i=t[r].chains)||i.forEach((i=>{e[i]={methods:t[r].methods,events:t[r].events}}))})),e}(t),s=function(t){const e={};return Object.keys(t).forEach((r=>{if(r.includes(":"))e[r]=t[r];else{const i=Ih(t[r].accounts);i?.forEach((i=>{e[i]={accounts:t[r].accounts.filter((t=>t.includes(`${i}:`))),methods:t[r].methods,events:t[r].events}}))}})),e}(e),o=Object.keys(n),a=Object.keys(s),h=Jh(Object.keys(t)),u=Jh(Object.keys(e)),c=h.filter((t=>!u.includes(t)));return c.length&&(i=Ch("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${c.toString()}\n Received: ${Object.keys(e).toString()}`)),Xr(o,a)||(i=Ch("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(e).forEach((t=>{if(!t.includes(":")||i)return;const n=Ih(e[t].accounts);n.includes(t)||(i=Ch("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${t}\n Required: ${t}\n Approved: ${n.toString()}`))})),o.forEach((t=>{i||(Xr(n[t].methods,s[t].methods)?Xr(n[t].events,s[t].events)||(i=Ch("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${t}`)):i=Ch("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${t}`))})),i}function Jh(t){return[...new Set(t.map((t=>t.includes(":")?t.split(":")[0]:t)))]}function Yh(t,e){return Bh(t,!1)&&t<=e.max&&t>=e.min}function Qh(){const t=Yr();return new Promise((e=>{switch(t){case Vr.browser:e(Jr()&&navigator?.onLine);break;case Vr.reactNative:e(async function(){if($r()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo){const t=await(null==r.g?void 0:r.g.NetInfo.fetch());return t?.isConnected}return!0}());break;case Vr.node:default:e(!0)}}))}const Xh={};class Zh{static get(t){return Xh[t]}static set(t,e){Xh[t]=e}static delete(t){delete Xh[t]}}const tu="PARSE_ERROR",eu="INVALID_REQUEST",ru="METHOD_NOT_FOUND",iu="INVALID_PARAMS",nu="INTERNAL_ERROR",su="SERVER_ERROR",ou=[-32700,-32600,-32601,-32602,-32603],au={[tu]:{code:-32700,message:"Parse error"},[eu]:{code:-32600,message:"Invalid Request"},[ru]:{code:-32601,message:"Method not found"},[iu]:{code:-32602,message:"Invalid params"},[nu]:{code:-32603,message:"Internal error"},[su]:{code:-32e3,message:"Server error"}},hu=su;function uu(t){return Object.keys(au).includes(t)?au[t]:au[hu]}var cu=r(5682);function lu(t=3){return Date.now()*Math.pow(10,t)+Math.floor(Math.random()*Math.pow(10,t))}function fu(t=6){return BigInt(lu(t))}function du(t,e,r){return{id:r||lu(),jsonrpc:"2.0",method:t,params:e}}function pu(t,e){return{id:t,jsonrpc:"2.0",result:e}}function gu(t,e,r){return{id:t,jsonrpc:"2.0",error:mu(e,r)}}function mu(t,e){return void 0===t?uu(nu):("string"==typeof t&&(t=Object.assign(Object.assign({},uu(su)),{message:t})),void 0!==e&&(t.data=e),r=t.code,ou.includes(r)&&(t=function(t){const e=Object.values(au).find((e=>e.code===t));return e||au[hu]}(t.code)),t);var r}class yu{}class vu extends yu{constructor(){super()}}class wu extends vu{constructor(t){super()}}function bu(t){return function(t,e){const r=function(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(e&&e.length)return e[0]}(t);return void 0!==r&&new RegExp(e).test(r)}(t,"^wss?:")}function _u(t){return"object"==typeof t&&"id"in t&&"jsonrpc"in t&&"2.0"===t.jsonrpc}function Au(t){return _u(t)&&"method"in t}function Eu(t){return _u(t)&&(Su(t)||Mu(t))}function Su(t){return"result"in t}function Mu(t){return"error"in t}class Iu extends wu{constructor(t){super(t),this.events=new g.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async request(t,e){return this.requestStrict(du(t.method,t.params||[],t.id||fu().toString()),e)}async requestStrict(t,e){return new Promise((async(r,i)=>{if(!this.connection.connected)try{await this.open()}catch(t){i(t)}this.events.on(`${t.id}`,(t=>{Mu(t)?i(t.error):r(t.result)}));try{await this.connection.send(t,e)}catch(t){i(t)}}))}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),Eu(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&3e3===t.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof t&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(t=>this.onPayload(t))),this.connection.on("close",(t=>this.onClose(t))),this.connection.on("error",(t=>this.events.emit("error",t))),this.connection.on("register_error",(t=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const xu=t=>t.split("?")[0],Nu=typeof WebSocket<"u"?WebSocket:typeof r.g<"u"&&typeof r.g.WebSocket<"u"?r.g.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:r(1591);class Ou{constructor(t){if(this.url=t,this.events=new g.EventEmitter,this.registering=!1,!bu(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){return new Promise(((t,e)=>{typeof this.socket>"u"?e(new Error("Connection already closed")):(this.socket.onclose=e=>{this.onClose(e),t()},this.socket.close())}))}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(j(t))}catch(e){this.onError(t.id,e)}}register(t=this.url){if(!bu(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);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(((t,e)=>{this.events.once("register_error",(t=>{this.resetMaxListeners(),e(t)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return e(new Error("WebSocket connection is missing or invalid"));t(this.socket)}))}))}return this.url=t,this.registering=!0,new Promise(((e,i)=>{const n=new URLSearchParams(t).get("origin"),s=(0,cu.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:(a=t,!new RegExp("wss?://localhost(:d{2,5})?").test(a))},o=new Nu(t,[],s);var a;typeof WebSocket<"u"||typeof r.g<"u"&&typeof r.g.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u"?o.onerror=t=>{const e=t;i(this.emitError(e.error))}:o.on("error",(t=>{i(this.emitError(t))})),o.onopen=()=>{this.onOpen(o),e(o)}}))}onOpen(t){t.onmessage=t=>this.onPayload(t),t.onclose=t=>this.onClose(t),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const e="string"==typeof t.data?B(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const r=this.parseError(e),i=gu(t,r.message||r.toString());this.events.emit("payload",i)}parseError(t,e=this.url){return function(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable WS RPC url at ${e}`):t}(t,xu(e))}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(t){const e=this.parseError(new Error(t?.message||`WebSocket connection failed for host: ${xu(this.url)}`));return this.events.emit("register_error",e),e}}var Pu=r(8142),Ru=r.n(Pu),Tu=r(916),Cu=r.n(Tu),ku=function(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);t[e];){var c=r[t.charCodeAt(e)];if(255===c)return;for(var l=0,f=s-1;(0!==c||l>>0,o[f]=c%256>>>0,c=c/256>>>0;if(0!==c)throw new Error("Non-zero carry");n=l,e++}if(" "!==t[e]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,i=0,n=0,s=e.length;n!==s&&0===e[n];)n++,r++;for(var o=(s-n)*c+1>>>0,u=new Uint8Array(o);n!==s;){for(var l=e[n],f=0,d=o-1;(0!==l||f>>0,u[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var g=h.repeat(r);p{if(t instanceof Uint8Array&&"Uint8Array"===t.constructor.name)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")};class Lu{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Du{constructor(t,e,r){if(this.name=t,this.prefix=e,void 0===e.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if("string"==typeof t){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(t){return Bu(this,t)}}class qu{constructor(t){this.decoders=t}or(t){return Bu(this,t)}decode(t){const e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Bu=(t,e)=>new qu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class ju{constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new Lu(t,e,r),this.decoder=new Du(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const zu=({name:t,prefix:e,encode:r,decode:i})=>new ju(t,e,r,i),Fu=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=ku(r,e);return zu({prefix:t,name:e,encode:i,decode:t=>Uu(n(t))})},Ku=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>zu({prefix:e,name:t,encode:t=>((t,e,r)=>{const i="="===e[e.length-1],n=(1<r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<((t,e,r,i)=>{const n={};for(let t=0;t=8&&(a-=8,o[u++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,i,r,t)}),Hu=zu({prefix:"\0",name:"identity",encode:t=>(t=>(new TextDecoder).decode(t))(t),decode:t=>(t=>(new TextEncoder).encode(t))(t)});var Vu=Object.freeze({__proto__:null,identity:Hu});const Gu=Ku({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Wu=Object.freeze({__proto__:null,base2:Gu});const $u=Ku({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ju=Object.freeze({__proto__:null,base8:$u});const Yu=Fu({prefix:"9",name:"base10",alphabet:"0123456789"});var Qu=Object.freeze({__proto__:null,base10:Yu});const Xu=Ku({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zu=Ku({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var tc=Object.freeze({__proto__:null,base16:Xu,base16upper:Zu});const ec=Ku({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rc=Ku({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ic=Ku({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nc=Ku({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),sc=Ku({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),oc=Ku({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ac=Ku({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hc=Ku({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uc=Ku({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var cc=Object.freeze({__proto__:null,base32:ec,base32upper:rc,base32pad:ic,base32padupper:nc,base32hex:sc,base32hexupper:oc,base32hexpad:ac,base32hexpadupper:hc,base32z:uc});const lc=Fu({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fc=Fu({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var dc=Object.freeze({__proto__:null,base36:lc,base36upper:fc});const pc=Fu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gc=Fu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mc=Object.freeze({__proto__:null,base58btc:pc,base58flickr:gc});const yc=Ku({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),vc=Ku({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bc=Ku({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_c=Ku({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ac=Object.freeze({__proto__:null,base64:yc,base64pad:vc,base64url:bc,base64urlpad:_c});const Ec=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Sc=Ec.reduce(((t,e,r)=>(t[r]=e,t)),[]),Mc=Ec.reduce(((t,e,r)=>(t[e.codePointAt(0)]=r,t)),[]),Ic=zu({prefix:"🚀",name:"base256emoji",encode:function(t){return t.reduce(((t,e)=>t+Sc[e]),"")},decode:function(t){const e=[];for(const r of t){const t=Mc[r.codePointAt(0)];if(void 0===t)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}});var xc=Object.freeze({__proto__:null,base256emoji:Ic}),Nc=128,Oc=-128,Pc=Math.pow(2,31),Rc=128,Tc=127,Cc=Math.pow(2,7),kc=Math.pow(2,14),Uc=Math.pow(2,21),Lc=Math.pow(2,28),Dc=Math.pow(2,35),qc=Math.pow(2,42),Bc=Math.pow(2,49),jc=Math.pow(2,56),zc=Math.pow(2,63),Fc={encode:function t(e,r,i){r=r||[];for(var n=i=i||0;e>=Pc;)r[i++]=255&e|Nc,e/=128;for(;e&Oc;)r[i++]=255&e|Nc,e>>>=7;return r[i]=0|e,t.bytes=i-n+1,r},decode:function t(e,r){var i,n=0,s=(r=r||0,0),o=r,a=e.length;do{if(o>=a)throw t.bytes=0,new RangeError("Could not decode varint");i=e[o++],n+=s<28?(i&Tc)<=Rc);return t.bytes=o-r,n},encodingLength:function(t){return t(Kc.encode(t,e,r),e),Vc=t=>Kc.encodingLength(t),Gc=(t,e)=>{const r=e.byteLength,i=Vc(t),n=i+Vc(r),s=new Uint8Array(n+r);return Hc(t,s,0),Hc(r,s,i),s.set(e,n),new Wc(t,r,e,s)};class Wc{constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}}const $c=({name:t,code:e,encode:r})=>new Jc(t,e,r);class Jc{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?Gc(this.code,e):e.then((t=>Gc(this.code,t)))}throw Error("Unknown type, must be binary type")}}const Yc=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Qc=$c({name:"sha2-256",code:18,encode:Yc("SHA-256")}),Xc=$c({name:"sha2-512",code:19,encode:Yc("SHA-512")});Object.freeze({__proto__:null,sha256:Qc,sha512:Xc});const Zc=Uu,tl={code:0,name:"identity",encode:Zc,digest:t=>Gc(0,Zc(t))};Object.freeze({__proto__:null,identity:tl}),new TextEncoder,new TextDecoder;const el={...Vu,...Wu,...Ju,...Qu,...tc,...cc,...dc,...mc,...Ac,...xc};function rl(t){return null!=globalThis.Buffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function il(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const nl=il("utf8","u",(t=>"u"+new TextDecoder("utf8").decode(t)),(t=>(new TextEncoder).encode(t.substring(1)))),sl=il("ascii","a",(t=>{let e="a";for(let r=0;r{const e=function(t=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?rl(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}((t=t.substring(1)).length);for(let r=0;r{if(!this.initialized){const t=await this.getKeyChain();typeof t<"u"&&(this.keychain=t),this.initialized=!0}},this.has=t=>(this.isInitialized(),this.keychain.has(t)),this.set=async(t,e)=>{this.isInitialized(),this.keychain.set(t,e),await this.persist()},this.get=t=>{this.isInitialized();const e=this.keychain.get(t);if(typeof e>"u"){const{message:e}=Ch("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(e)}return e},this.del=async t=>{this.isInitialized(),this.keychain.delete(t),await this.persist()},this.core=t,this.logger=pt(e,this.name)}get context(){return dt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,Zr(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?ti(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}}class zl{constructor(t,e,r){this.core=t,this.logger=e,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=t=>(this.isInitialized(),this.keychain.has(t)),this.getClientId=async()=>(this.isInitialized(),gr(mr(await this.getClientSeed()).publicKey)),this.generateKeyPair=()=>{this.isInitialized();const t=function(){const t=kr.TZ();return{privateKey:fr(t.secretKey,$a),publicKey:fr(t.publicKey,$a)}}();return this.setPrivateKey(t.publicKey,t.privateKey)},this.signJWT=async t=>{this.isInitialized();const e=mr(await this.getClientSeed()),r=Qa(),i=ll;return await async function(t,e,r,i,n=(0,Rt.fromMiliseconds)(Date.now())){const s={alg:"EdDSA",typ:"JWT"},o={iss:gr(i.publicKey),sub:t,aud:e,iat:n,exp:n+r},a=dr([pr((h={header:s,payload:o}).header),pr(h.payload)].join("."),"utf8");var h;return function(t){return[pr(t.header),pr(t.payload),(e=t.signature,fr(e,Tt))].join(".");var e}({header:s,payload:o,signature:Ot._S(i.secretKey,a)})}(r,t,i,e)},this.generateSharedKey=(t,e,r)=>{this.isInitialized();const i=function(t,e){const r=kr.Tc(dr(t,$a),dr(e,$a),!0);return fr(new Tr.i(Cr.aD,r).expand(32),$a)}(this.getPrivateKey(t),e);return this.setSymKey(i,r)},this.setSymKey=async(t,e)=>{this.isInitialized();const r=e||Xa(t);return await this.keychain.set(r,t),r},this.deleteKeyPair=async t=>{this.isInitialized(),await this.keychain.del(t)},this.deleteSymKey=async t=>{this.isInitialized(),await this.keychain.del(t)},this.encode=async(t,e,r)=>{this.isInitialized();const i=rh(r),n=j(e);if(ih(i)){const e=i.senderPublicKey,r=i.receiverPublicKey;t=await this.generateSharedKey(e,r)}const s=this.getSymKey(t),{type:o,senderPublicKey:a}=i;return function(t){const e=function(t){return dr(`${t}`,Wa)}(typeof t.type<"u"?t.type:0);if(1===th(e)&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?dr(t.senderPublicKey,$a):void 0,i=typeof t.iv<"u"?dr(t.iv,$a):(0,Pt.randomBytes)(12);return function(t){if(1===th(t.type)){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return fr(Ft([t.type,t.senderPublicKey,t.iv,t.sealed]),Ja)}return fr(Ft([t.type,t.iv,t.sealed]),Ja)}({type:e,sealed:new Rr.g6(dr(t.symKey,$a)).seal(i,dr(t.message,Ya)),iv:i,senderPublicKey:r})}({type:o,symKey:s,message:n,senderPublicKey:a})},this.decode=async(t,e,r)=>{this.isInitialized();const i=function(t,e){const r=eh(t);return rh({type:th(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?fr(r.senderPublicKey,$a):void 0,receiverPublicKey:e?.receiverPublicKey})}(e,r);if(ih(i)){const e=i.receiverPublicKey,r=i.senderPublicKey;t=await this.generateSharedKey(e,r)}try{const r=function(t){const e=new Rr.g6(dr(t.symKey,$a)),{sealed:r,iv:i}=eh(t.encoded),n=e.open(i,r);if(null===n)throw new Error("Failed to decrypt");return fr(n,Ya)}({symKey:this.getSymKey(t),encoded:e});return B(r)}catch(e){this.logger.error(`Failed to decode message from topic: '${t}', clientId: '${await this.getClientId()}'`),this.logger.error(e)}},this.getPayloadType=t=>th(eh(t).type),this.getPayloadSenderPublicKey=t=>{const e=eh(t);return e.senderPublicKey?fr(e.senderPublicKey,$a):void 0},this.core=t,this.logger=pt(e,this.name),this.keychain=r||new jl(this.core,this.logger)}get context(){return dt(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(cl)}catch{t=Qa(),await this.keychain.set(cl,t)}return function(t,e="utf8"){const r=ol[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${t}`):rl(globalThis.Buffer.from(t,"utf-8"))}(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Fl extends wt{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=hl,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const t=await this.getRelayerMessages();typeof t<"u"&&(this.messages=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}finally{this.initialized=!0}}},this.set=async(t,e)=>{this.isInitialized();const r=Za(e);let i=this.messages.get(t);return typeof i>"u"&&(i={}),typeof i[r]<"u"||(i[r]=e,this.messages.set(t,i),await this.persist()),r},this.get=t=>{this.isInitialized();let e=this.messages.get(t);return typeof e>"u"&&(e={}),e},this.has=(t,e)=>(this.isInitialized(),typeof this.get(t)[Za(e)]<"u"),this.del=async t=>{this.isInitialized(),this.messages.delete(t),await this.persist()},this.logger=pt(t,this.name),this.core=e}get context(){return dt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,Zr(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?ti(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Kl extends bt{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new g.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,Rt.toMiliseconds)(Rt.ONE_MINUTE),this.failedPublishTimeout=(0,Rt.toMiliseconds)(Rt.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(t,e,r)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:e,opts:r}});const n=r?.ttl||fl,s=nh(r),o=r?.prompt||!1,a=r?.tag||0,h=r?.id||fu().toString(),u={topic:t,message:e,opts:{ttl:n,relay:s,prompt:o,tag:a,id:h}},c=`Failed to publish payload, please try again. id:${h} tag:${a}`,l=Date.now();let f,d=1;try{for(;void 0===f;){if(Date.now()-l>this.publishTimeout)throw new Error(c);this.logger.trace({id:h,attempts:d},`publisher.publish - attempt ${d}`),f=await await ri(this.rpcPublish(t,e,n,s,o,a,h).catch((t=>this.logger.warn(t))),this.publishTimeout,c),d++,f||await new Promise((t=>setTimeout(t,this.failedPublishTimeout)))}this.relayer.events.emit(vl,u),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:h,topic:t,message:e,opts:r}})}catch(t){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(t),null!=(i=r?.internal)&&i.throwOnFailedPublish)throw t;this.queue.set(h,u)}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.relayer=t,this.logger=pt(e,this.name),this.registerEventListeners()}get context(){return dt(this.logger)}rpcPublish(t,e,r,i,n,s,o){var a,h,u,c;const l={method:sh(i.protocol).publish,params:{topic:t,message:e,ttl:r,prompt:n,tag:s},id:o};return Dh(null==(a=l.params)?void 0:a.prompt)&&(null==(h=l.params)||delete h.prompt),Dh(null==(u=l.params)?void 0:u.tag)&&(null==(c=l.params)||delete c.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach((async t=>{const{topic:e,message:r,opts:i}=t;await this.publish(e,r,i)}))}registerEventListeners(){this.relayer.core.heartbeat.on($.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(yl);this.checkQueue()})),this.relayer.on(ml,(t=>{this.removeRequestFromQueue(t.id.toString())}))}}class Hl{constructor(){this.map=new Map,this.set=(t,e)=>{const r=this.get(t);this.exists(t,e)||this.map.set(t,[...r,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u")return void this.map.delete(t);if(!this.map.has(t))return;const r=this.get(t);if(!this.exists(t,e))return;const i=r.filter((t=>t!==e));i.length?this.map.set(t,i):this.map.delete(t)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Vl=Object.defineProperty,Gl=Object.defineProperties,Wl=Object.getOwnPropertyDescriptors,$l=Object.getOwnPropertySymbols,Jl=Object.prototype.hasOwnProperty,Yl=Object.prototype.propertyIsEnumerable,Ql=(t,e,r)=>e in t?Vl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xl=(t,e)=>{for(var r in e||(e={}))Jl.call(e,r)&&Ql(t,r,e[r]);if($l)for(var r of $l(e))Yl.call(e,r)&&Ql(t,r,e[r]);return t},Zl=(t,e)=>Gl(t,Wl(e));class tf extends Et{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new Hl,this.events=new g.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=hl,this.subscribeTimeout=(0,Rt.toMiliseconds)(Rt.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}});try{const r=nh(e),i={topic:t,relay:r};this.pending.set(t,i);const n=await this.rpcSubscribe(t,r);return"string"==typeof n&&(this.onSubscribe(n,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}})),n}catch(t){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(t),t}},this.unsubscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),typeof e?.id<"u"?await this.unsubscribeById(t,e.id,e):await this.unsubscribeByTopic(t,e)},this.isSubscribed=async t=>{if(this.topics.includes(t))return!0;const e=`${this.pendingSubscriptionWatchLabel}_${t}`;return await new Promise(((r,i)=>{const n=new Rt.Watch;n.start(e);const s=setInterval((()=>{!this.pending.has(t)&&this.topics.includes(t)&&(clearInterval(s),n.stop(e),r(!0)),n.elapsed(e)>=Il&&(clearInterval(s),n.stop(e),i(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1))},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=pt(e,this.name),this.clientId=""}get context(){return dt(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}hasSubscription(t,e){let r=!1;try{r=this.getSubscription(t).topic===e}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const r=this.topicMap.get(t);await Promise.all(r.map((async r=>await this.unsubscribeById(t,r,e))))}async unsubscribeById(t,e,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}});try{const i=nh(r);await this.rpcUnsubscribe(t,e,i);const n=kh("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}})}catch(t){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(t),t}}async rpcSubscribe(t,e){const r={method:sh(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{return await await ri(this.relayer.request(r).catch((t=>this.logger.warn(t))),this.subscribeTimeout)?Za(t+this.clientId):null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(yl)}return null}async rpcBatchSubscribe(t){if(!t.length)return;const e={method:sh(t[0].relay.protocol).batchSubscribe,params:{topics:t.map((t=>t.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:e});try{return await await ri(this.relayer.request(e).catch((t=>this.logger.warn(t))),this.subscribeTimeout)}catch{this.relayer.events.emit(yl)}}rpcUnsubscribe(t,e,r){const i={method:sh(r.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(t,e){this.setSubscription(t,Zl(Xl({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach((t=>{this.setSubscription(t.id,Xl({},t)),this.pending.delete(t.topic)}))}async onUnsubscribe(t,e,r){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,r),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e)}addSubscription(t,e){this.subscriptions.set(t,Xl({},e)),this.topicMap.set(e.topic,t),this.events.emit(Sl,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:e}=Ch("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(e)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const r=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(r.topic,t),this.events.emit(Ml,Zl(Xl({},r),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e"u"||!t.length)return;if(this.subscriptions.size){const{message:t}=Ch("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);Uh(e)&&this.onBatchSubscribe(e.map(((e,r)=>Zl(Xl({},t[r]),{id:e}))))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const t=[];this.pending.forEach((e=>{t.push(e)})),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on($.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.events.on(Sl,(async t=>{const e=Sl;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})),this.events.on(Ml,(async t=>{const e=Ml;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise((t=>{const e=setInterval((()=>{this.restartInProgress||(clearInterval(e),t())}),this.pollingInterval)}))}}var ef=Object.defineProperty,rf=Object.getOwnPropertySymbols,nf=Object.prototype.hasOwnProperty,sf=Object.prototype.propertyIsEnumerable,of=(t,e,r)=>e in t?ef(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;class af extends _t{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new g.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,Rt.toMiliseconds)(Rt.THIRTY_SECONDS+Rt.ONE_SECOND),this.request=async t=>{var e,r;this.logger.debug("Publishing Request Payload");const i=t.id||fu().toString();await this.toEstablishConnection();try{const n=this.provider.request(t);this.requestsInFlight.set(i,{promise:n,request:t}),this.logger.trace({id:i,method:t.method,topic:null==(e=t.params)?void 0:e.topic},"relayer.request - attempt to publish...");const s=await new Promise((async(t,e)=>{const r=()=>{e(new Error(`relayer.request - publish interrupted, id: ${i}`))};this.provider.on(_l,r);const s=await n;this.provider.off(_l,r),t(s)}));return this.logger.trace({id:i,method:t.method,topic:null==(r=t.params)?void 0:r.topic},"relayer.request - published"),s}catch(t){throw this.logger.debug(`Failed to Publish Request: ${i}`),t}finally{this.requestsInFlight.delete(i)}},this.resetPingTimeout=()=>{if(Wr())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout((()=>{var t,e,r;null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)||r.terminate()}),this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.startPingTimeout(),this.events.emit("relayer_connect")},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit("relayer_error",t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(wl,this.onPayloadHandler),this.provider.on(bl,this.onConnectHandler),this.provider.on(_l,this.onDisconnectHandler),this.provider.on(Al,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&"string"!=typeof t.logger?pt(t.logger,this.name):Y()(ft({level:t.logger||"error"})),this.messages=new Fl(this.logger,t.core),this.subscriber=new tf(this,this.logger),this.publisher=new Kl(this,this.logger),this.relayUrl=t?.relayUrl||dl,this.projectId=t.projectId,this.bundleId=function(){var t;try{return $r()&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Application)<"u"?null==(t=r.g.Application)?void 0:t.applicationId:void 0}catch{return}}(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pl}...`),await this.restartTransport(pl)}this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&0===this.subscriber.pending.size&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),1e4)}get context(){return dt(this.logger)}get connected(){var t,e,r;return 1===(null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)?void 0:r.readyState)}get connecting(){var t,e,r;return 0===(null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)?void 0:r.readyState)}async publish(t,e,r){this.isInitialized(),await this.publisher.publish(t,e,r),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var r;this.isInitialized();let i,n=(null==(r=this.subscriber.topicMap.get(t))?void 0:r[0])||"";const s=e=>{e.topic===t&&(this.subscriber.off(Sl,s),i())};return await Promise.all([new Promise((t=>{i=t,this.subscriber.on(Sl,s)})),new Promise((async r=>{n=await this.subscriber.subscribe(t,e)||n,r()}))]),n}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map((t=>t.promise)))}catch(t){this.logger.warn(t)}this.hasExperiencedNetworkDisruption||this.connected?await ri(this.provider.disconnect(),2e3,"provider.disconnect()").catch((()=>this.onProviderDisconnect())):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(t){await this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportDisconnect(),await this.createProvider()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise((async(t,e)=>{const r=()=>{this.provider.off(_l,r),e(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(_l,r),await ri(this.provider.connect(),(0,Rt.toMiliseconds)(Rt.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch((t=>{e(t)})),await this.subscriber.start(),this.hasExperiencedNetworkDisruption=!1,t()}))}catch(t){this.logger.error(t);const e=t;if(!this.isConnectionStalled(e.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(t){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Qh())throw new Error("No internet connection detected. Please restart your network and try again.")}startPingTimeout(){var t,e,r,i,n;if(Wr())try{null!=(e=null==(t=this.provider)?void 0:t.connection)&&e.socket&&(null==(n=null==(i=null==(r=this.provider)?void 0:r.connection)?void 0:i.socket)||n.once("ping",(()=>{this.resetPingTimeout()}))),this.resetPingTimeout()}catch(t){this.logger.warn(t)}}isConnectionStalled(t){return this.staleConnectionErrors.some((e=>t.includes(e)))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Iu(new Ou(function({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){const h=r.split("?"),u={auth:n,ua:Qr(t,e,i),projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},c=function(t,e){let r=Pr.parse(t);return r=Kr(Kr({},r),e),Pr.stringify(r)}(h[1]||"",u);return h[0]+"?"+c}({sdkVersion:"2.12.2",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:r}=t;await this.messages.set(e,r)}async shouldIgnoreMessageEvent(t){const{topic:e,message:r}=t;if(!r||0===r.length)return this.logger.debug(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;const i=this.messages.has(e,r);return i&&this.logger.debug(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),Au(t)){if(!t.method.endsWith("_subscription"))return;const e=t.params,{topic:r,message:i,publishedAt:n}=e.data,s={topic:r,message:i,publishedAt:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((t,e)=>{for(var r in e||(e={}))nf.call(e,r)&&of(t,r,e[r]);if(rf)for(var r of rf(e))sf.call(e,r)&&of(t,r,e[r]);return t})({type:"event",event:e.id},s)),this.events.emit(e.id,s),await this.acknowledgePayload(t),await this.onMessageEvent(s)}else Eu(t)&&this.events.emit(ml,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(gl,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=pu(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(wl,this.onPayloadHandler),this.provider.off(bl,this.onConnectHandler),this.provider.off(_l,this.onDisconnectHandler),this.provider.off(Al,this.onProviderErrorHandler)}async registerEventListeners(){let t=await Qh();!function(t){switch(Yr()){case Vr.browser:!function(t){!$r()&&Jr()&&(window.addEventListener("online",(()=>t(!0))),window.addEventListener("offline",(()=>t(!1))))}(t);break;case Vr.reactNative:!function(t){$r()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo&&r.g?.NetInfo.addEventListener((e=>t(e?.isConnected)))}(t);case Vr.node:}}((async e=>{t!==e&&(t=e,e?await this.restartTransport().catch((t=>this.logger.error(t))):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}))}async onProviderDisconnect(){await this.subscriber.stop(),this.events.emit("relayer_disconnect"),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&setTimeout((async()=>{await this.transportOpen().catch((t=>this.logger.error(t)))}),(0,Rt.toMiliseconds)(El))}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise((t=>{const e=setInterval((()=>{this.connected&&(clearInterval(e),t())}),this.connectionStatusPollingInterval)})),await this.transportOpen())}}var hf=Object.defineProperty,uf=Object.getOwnPropertySymbols,cf=Object.prototype.hasOwnProperty,lf=Object.prototype.propertyIsEnumerable,ff=(t,e,r)=>e in t?hf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,df=(t,e)=>{for(var r in e||(e={}))cf.call(e,r)&&ff(t,r,e[r]);if(uf)for(var r of uf(e))lf.call(e,r)&&ff(t,r,e[r]);return t};class pf extends At{constructor(t,e,r,i=hl,n=void 0){super(t,e,r,i),this.core=t,this.logger=e,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=hl,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>{this.getKey&&null!==t&&!Dh(t)?this.map.set(this.getKey(t),t):function(t){var e;return null==(e=t?.proposer)?void 0:e.publicKey}(t)?this.map.set(t.id,t):function(t){return t?.topic}(t)&&this.map.set(t.topic,t)})),this.cached=[],this.initialized=!0)},this.set=async(t,e)=>{this.isInitialized(),this.map.has(t)?await this.update(t,e):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:t,value:e}),this.map.set(t,e),await this.persist())},this.get=t=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:t}),this.getData(t)),this.getAll=t=>(this.isInitialized(),t?this.values.filter((e=>Object.keys(t).every((r=>Ru()(e[r],t[r]))))):this.values),this.update=async(t,e)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:t,update:e});const r=df(df({},this.getData(t)),e);this.map.set(t,r),await this.persist()},this.delete=async(t,e)=>{this.isInitialized(),this.map.has(t)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:t,reason:e}),this.map.delete(t),this.addToRecentlyDeleted(t),await this.persist())},this.logger=pt(e,this.name),this.storagePrefix=i,this.getKey=n}get context(){return dt(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(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const e=this.map.get(t);if(!e){if(this.recentlyDeleted.includes(t)){const{message:e}=Ch("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(e),new Error(e)}const{message:e}=Ch("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(e),new Error(e)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:t}=Ch("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}}class gf{constructor(t,e){this.core=t,this.logger=e,this.name="pairing",this.version="0.3",this.events=new(m()),this.initialized=!1,this.storagePrefix=hl,this.ignoredPayloadTypes=[1],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:t})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...t])]},this.create=async t=>{this.isInitialized();const e=Qa(),r=await this.core.crypto.setSymKey(e),i=si(Rt.FIVE_MINUTES),n={protocol:"irn"},s={topic:r,expiry:i,relay:n,active:!1},o=function(t){return`${t.protocol}:${t.topic}@${t.version}?`+Pr.stringify(dh(((t,e)=>ah(t,hh(e)))(dh({symKey:t.symKey},function(t,e="-"){const r={};return Object.keys(t).forEach((i=>{const n="relay"+e+i;t[i]&&(r[n]=t[i])})),r}(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:e,relay:n,expiryTimestamp:i,methods:t?.methods});return await this.pairings.set(r,s),await this.core.relayer.subscribe(r),this.core.expirer.set(r,i),{topic:r,uri:o}},this.pair=async t=>{this.isInitialized(),this.isValidPair(t);const{topic:e,symKey:r,relay:i,expiryTimestamp:n,methods:s}=gh(t.uri);let o;if(this.pairings.keys.includes(e)&&(o=this.pairings.get(e),o.active))throw new Error(`Pairing already exists: ${e}. Please try again with a new connection URI.`);const a=n||si(Rt.FIVE_MINUTES),h={topic:e,relay:i,expiry:a,active:!1,methods:s};return await this.pairings.set(e,h),this.core.expirer.set(e,a),t.activatePairing&&await this.activate({topic:e}),this.events.emit(Nl,h),this.core.crypto.keychain.has(e)||await this.core.crypto.setSymKey(r,e),await this.core.relayer.subscribe(e,{relay:i}),h},this.activate=async({topic:t})=>{this.isInitialized();const e=si(Rt.THIRTY_DAYS);await this.pairings.update(t,{active:!0,expiry:e}),this.core.expirer.set(t,e)},this.ping=async t=>{this.isInitialized(),await this.isValidPing(t);const{topic:e}=t;if(this.pairings.keys.includes(e)){const t=await this.sendRequest(e,"wc_pairingPing",{}),{done:r,resolve:i,reject:n}=ei();this.events.once(ai("pairing_ping",t),(({error:t})=>{t?n(t):i()})),await r()}},this.updateExpiry=async({topic:t,expiry:e})=>{this.isInitialized(),await this.pairings.update(t,{expiry:e})},this.updateMetadata=async({topic:t,metadata:e})=>{this.isInitialized(),await this.pairings.update(t,{peerMetadata:e})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async t=>{this.isInitialized(),await this.isValidDisconnect(t);const{topic:e}=t;this.pairings.keys.includes(e)&&(await this.sendRequest(e,"wc_pairingDelete",kh("USER_DISCONNECTED")),await this.deletePairing(e))},this.sendRequest=async(t,e,r)=>{const i=du(e,r),n=await this.core.crypto.encode(t,i),s=xl[e].req;return this.core.history.set(t,i),this.core.relayer.publish(t,n,s),i.id},this.sendResult=async(t,e,r)=>{const i=pu(t,r),n=await this.core.crypto.encode(e,i),s=await this.core.history.get(e,t),o=xl[s.request.method].res;await this.core.relayer.publish(e,n,o),await this.core.history.resolve(i)},this.sendError=async(t,e,r)=>{const i=gu(t,r),n=await this.core.crypto.encode(e,i),s=await this.core.history.get(e,t),o=xl[s.request.method]?xl[s.request.method].res:xl.unregistered_method.res;await this.core.relayer.publish(e,n,o),await this.core.history.resolve(i)},this.deletePairing=async(t,e)=>{await this.core.relayer.unsubscribe(t),await Promise.all([this.pairings.delete(t,kh("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(t),e?Promise.resolve():this.core.expirer.del(t)])},this.cleanup=async()=>{const t=this.pairings.getAll().filter((t=>oi(t.expiry)));await Promise.all(t.map((t=>this.deletePairing(t.topic))))},this.onRelayEventRequest=t=>{const{topic:e,payload:r}=t;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(e,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(e,r);default:return this.onUnknownRpcMethodRequest(e,r)}},this.onRelayEventResponse=async t=>{const{topic:e,payload:r}=t,i=(await this.core.history.get(e,r.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(e,r):this.onUnknownRpcMethodResponse(i)},this.onPairingPingRequest=async(t,e)=>{const{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult(r,t,!0),this.events.emit("pairing_ping",{id:r,topic:t})}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onPairingPingResponse=(t,e)=>{const{id:r}=e;setTimeout((()=>{Su(e)?this.events.emit(ai("pairing_ping",r),{}):Mu(e)&&this.events.emit(ai("pairing_ping",r),{error:e.error})}),500)},this.onPairingDeleteRequest=async(t,e)=>{const{id:r}=e;try{this.isValidDisconnect({topic:t}),await this.deletePairing(t),this.events.emit(Ol,{id:r,topic:t})}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onUnknownRpcMethodRequest=async(t,e)=>{const{id:r,method:i}=e;try{if(this.registeredMethods.includes(i))return;const e=kh("WC_METHOD_UNSUPPORTED",i);await this.sendError(r,t,e),this.logger.error(e)}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onUnknownRpcMethodResponse=t=>{this.registeredMethods.includes(t)||this.logger.error(kh("WC_METHOD_UNSUPPORTED",t))},this.isValidPair=t=>{var e;if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`pair() params: ${t}`);throw new Error(e)}if(!zh(t.uri)){const{message:e}=Ch("MISSING_OR_INVALID",`pair() uri: ${t.uri}`);throw new Error(e)}const r=gh(t.uri);if(null==(e=r?.relay)||!e.protocol){const{message:t}=Ch("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(t)}if(null==r||!r.symKey){const{message:t}=Ch("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(t)}if(null!=r&&r.expiryTimestamp&&(0,Rt.toMiliseconds)(r?.expiryTimestamp){if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidDisconnect=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidPairingTopic=async t=>{if(!qh(t,!1)){const{message:e}=Ch("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.pairings.keys.includes(t)){const{message:e}=Ch("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(oi(this.pairings.get(t).expiry)){await this.deletePairing(t);const{message:e}=Ch("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}},this.core=t,this.logger=pt(e,this.name),this.pairings=new pf(this.core,this.logger,this.name,this.storagePrefix)}get context(){return dt(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(gl,(async t=>{const{topic:e,message:r}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const i=await this.core.crypto.decode(e,r);try{Au(i)?(this.core.history.set(e,i),this.onRelayEventRequest({topic:e,payload:i})):Eu(i)&&(await this.core.history.resolve(i),await this.onRelayEventResponse({topic:e,payload:i}),this.core.history.delete(e,i.id))}catch(t){this.logger.error(t)}}))}registerExpirerEvents(){this.core.expirer.on(Ul,(async t=>{const{topic:e}=ni(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit("pairing_expire",{topic:e}))}))}}class mf extends vt{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new g.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=hl,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>this.records.set(t.id,t))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(t,e,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:t,request:e,chainId:r}),this.records.has(e.id))return;const i={id:e.id,topic:t,request:{method:e.method,params:e.params||null},chainId:r,expiry:si(Rt.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(Pl,i)},this.resolve=async t=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:t}),!this.records.has(t.id))return;const e=await this.getRecord(t.id);typeof e.response>"u"&&(e.response=Mu(t)?{error:t.error}:{result:t.result},this.records.set(e.id,e),this.persist(),this.events.emit(Rl,e))},this.get=async(t,e)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:t,id:e}),await this.getRecord(e)),this.delete=(t,e)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:e}),this.values.forEach((r=>{if(r.topic===t){if(typeof e<"u"&&r.id!==e)return;this.records.delete(r.id),this.events.emit(Tl,r)}})),this.persist()},this.exists=async(t,e)=>(this.isInitialized(),!!this.records.has(e)&&(await this.getRecord(e)).topic===t),this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=pt(e,this.name)}get context(){return dt(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 t=[];return this.values.forEach((e=>{if(typeof e.response<"u")return;const r={topic:e.topic,request:du(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(r)})),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const e=this.records.get(t);if(!e){const{message:e}=Ch("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(e)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:t}=Ch("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(Pl,(t=>{const e=Pl;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})})),this.events.on(Rl,(t=>{const e=Rl;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})})),this.events.on(Tl,(t=>{const e=Tl;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})})),this.core.heartbeat.on($.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach((e=>{(0,Rt.toMiliseconds)(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.records.delete(e.id),this.events.emit(Tl,e,!1),t=!0)})),t&&this.persist()}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}}class yf extends St{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new g.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=hl,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>this.expirations.set(t.target,t))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=t=>{try{const e=this.formatTarget(t);return typeof this.getExpiration(e)<"u"}catch{return!1}},this.set=(t,e)=>{this.isInitialized();const r=this.formatTarget(t),i={target:r,expiry:e};this.expirations.set(r,i),this.checkExpiry(r,i),this.events.emit(Cl,{target:r,expiration:i})},this.get=t=>{this.isInitialized();const e=this.formatTarget(t);return this.getExpiration(e)},this.del=t=>{if(this.isInitialized(),this.has(t)){const e=this.formatTarget(t),r=this.getExpiration(e);this.expirations.delete(e),this.events.emit(kl,{target:e,expiration:r})}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=pt(e,this.name)}get context(){return dt(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(t){if("string"==typeof t)return function(t){return ii("topic",t)}(t);if("number"==typeof t)return function(t){return ii("id",t)}(t);const{message:e}=Ch("UNKNOWN_TYPE","Target type: "+typeof t);throw new Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit("expirer_sync")}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:t}=Ch("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:e}=Ch("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(e),new Error(e)}return e}checkExpiry(t,e){const{expiry:r}=e;(0,Rt.toMiliseconds)(r)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Ul,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((t,e)=>this.checkExpiry(e,t)))}registerEventListeners(){this.core.heartbeat.on($.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(Cl,(t=>{const e=Cl;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})),this.events.on(Ul,(t=>{const e=Ul;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})),this.events.on(kl,(t=>{const e=kl;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}}class vf extends Mt{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=Ll,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async t=>{if(this.verifyDisabled||$r()||!Jr())return;const e=this.getVerifyUrl(t?.verifyUrl);this.verifyUrl!==e&&this.removeIframe(),this.verifyUrl=e;try{await this.createIframe()}catch(t){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(t)}if(!this.initialized){this.removeIframe(),this.verifyUrl=ql;try{await this.createIframe()}catch(t){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(t),this.verifyDisabled=!0}}},this.register=async t=>{this.initialized?this.sendPost(t.attestationId):(this.addToQueue(t.attestationId),await this.init())},this.resolve=async t=>{if(this.isDevEnv)return"";const e=this.getVerifyUrl(t?.verifyUrl);let r;try{r=await this.fetchAttestation(t.attestationId,e)}catch(i){this.logger.info(`failed to resolve attestation: ${t.attestationId} from url: ${e}`),this.logger.info(i),r=await this.fetchAttestation(t.attestationId,ql)}return r},this.fetchAttestation=async(t,e)=>{this.logger.info(`resolving attestation: ${t} from url: ${e}`);const r=this.startAbortTimer(2*Rt.ONE_SECOND),i=await fetch(`${e}/attestation/${t}`,{signal:this.abortController.signal});return clearTimeout(r),200===i.status?await i.json():void 0},this.addToQueue=t=>{this.queue.push(t)},this.processQueue=()=>{0!==this.queue.length&&(this.queue.forEach((t=>this.sendPost(t))),this.queue=[])},this.sendPost=t=>{var e;try{if(!this.iframe)return;null==(e=this.iframe.contentWindow)||e.postMessage(t,"*"),this.logger.info(`postMessage sent: ${t} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let t;const e=r=>{"verify_ready"===r.data&&(this.onInit(),window.removeEventListener("message",e),t())};await Promise.race([new Promise((r=>{const i=document.getElementById(Ll);if(i)return this.iframe=i,this.onInit(),r();window.addEventListener("message",e);const n=document.createElement("iframe");n.id=Ll,n.src=`${this.verifyUrl}/${this.projectId}`,n.style.display="none",document.body.append(n),this.iframe=n,t=r})),new Promise(((t,r)=>setTimeout((()=>{window.removeEventListener("message",e),r("verify iframe load timeout")}),(0,Rt.toMiliseconds)(Rt.FIVE_SECONDS))))])},this.onInit=()=>{this.initialized=!0,this.processQueue()},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=t=>{let e=t||Dl;return Bl.includes(e)||(this.logger.info(`verify url: ${e}, not included in trusted list, assigning default: ${Dl}`),e=Dl),e},this.logger=pt(e,this.name),this.verifyUrl=Dl,this.abortController=new AbortController,this.isDevEnv=Wr()&&process.env.IS_VITEST}get context(){return dt(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout((()=>this.abortController.abort()),(0,Rt.toMiliseconds)(t))}}class wf extends It{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.context="echo",this.registerDeviceToken=async t=>{const{clientId:e,token:r,notificationType:i,enableEncrypted:n=!1}=t,s=`https://echo.walletconnect.com/${this.projectId}/clients`;await Cu()(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:e,type:i,token:r,always_raw:n})})},this.logger=pt(e,this.context)}}var bf=Object.defineProperty,_f=Object.getOwnPropertySymbols,Af=Object.prototype.hasOwnProperty,Ef=Object.prototype.propertyIsEnumerable,Sf=(t,e,r)=>e in t?bf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mf=(t,e)=>{for(var r in e||(e={}))Af.call(e,r)&&Sf(t,r,e[r]);if(_f)for(var r of _f(e))Ef.call(e,r)&&Sf(t,r,e[r]);return t};class If extends yt{constructor(t){var e;super(t),this.protocol="wc",this.version=2,this.name=al,this.events=new g.EventEmitter,this.initialized=!1,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||dl,this.customStoragePrefix=null!=t&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const r=ft({level:"string"==typeof t?.logger&&t.logger?t.logger:"error"}),{logger:i,chunkLoggerController:n}=gt({opts:r,maxSizeInBytes:t?.maxLogBlobSizeInBytes,loggerOverride:t?.logger});this.logChunkController=n,null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var t,e;null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(null==(e=this.logChunkController)||e.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=pt(i,this.name),this.heartbeat=new $.HeartBeat,this.crypto=new zl(this,this.logger,t?.keychain),this.history=new mf(this,this.logger),this.expirer=new yf(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new W(Mf(Mf({},ul),t?.storageOptions)),this.relayer=new af({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new gf(this,this.logger),this.verify=new vf(this.projectId||"",this.logger),this.echoClient=new wf(this.projectId||"",this.logger)}static async init(t){const e=new If(t);await e.initialize();const r=await e.crypto.getClientId();return await e.storage.setItem("WALLETCONNECT_CLIENT_ID",r),e}get context(){return dt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var t;return null==(t=this.logChunkController)?void 0:t.logsToBlob({clientId:await this.crypto.getClientId()})}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.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const xf=If;let Nf=!1,Of=!1;const Pf={debug:1,default:2,info:2,warning:3,error:4,off:5};let Rf=Pf.default,Tf=null;const Cf=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var kf,Uf;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(kf||(kf={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(Uf||(Uf={}));const Lf="0123456789abcdef";class Df{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Pf[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Rf>Pf[r]||console.log.apply(console,e)}debug(...t){this._log(Df.levels.DEBUG,t)}info(...t){this._log(Df.levels.INFO,t)}warn(...t){this._log(Df.levels.WARNING,t)}makeError(t,e,r){if(Of)return this.makeError("censored error",e,{});e||(e=Df.errors.UNKNOWN_ERROR),r||(r={});const i=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t>4],r+=Lf[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let s="";switch(e){case Uf.NUMERIC_FAULT:{s="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":s+="-"+e;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case Uf.CALL_EXCEPTION:case Uf.INSUFFICIENT_FUNDS:case Uf.MISSING_NEW:case Uf.NONCE_EXPIRED:case Uf.REPLACEMENT_UNDERPRICED:case Uf.TRANSACTION_REPLACED:case Uf.UNPREDICTABLE_GAS_LIMIT:s=e}s&&(t+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const o=new Error(t);return o.reason=n,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Df.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),Cf&&this.throwError("platform missing String.prototype.normalize",Df.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Cf})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Df.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Df.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,Df.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Df.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Df.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Df.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Tf||(Tf=new Df("logger/5.7.0")),Tf}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Df.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Nf){if(!t)return;this.globalLogger().throwError("error censorship permanent",Df.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Of=!!t,Nf=!!e}static setLogLevel(t){const e=Pf[t.toLowerCase()];null!=e?Rf=e:Df.globalLogger().warn("invalid log level - "+t)}static from(t){return new Df(t)}}Df.errors=Uf,Df.levels=kf;const qf=new Df("bytes/5.7.0");function Bf(t){return!!t.toHexString}function jf(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return jf(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function zf(t){return"number"==typeof t&&t==t&&t%1==0}function Ff(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!zf(t.length)||t.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Kf(t,e){if(e||(e={}),"number"==typeof t){qf.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),jf(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Bf(t)&&(t=t.toHexString()),Hf(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":qf.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t>4]+Vf[15&i]}return e}return qf.throwArgumentError("invalid hexlify value","value",t)}function Wf(t,e,r){return"string"!=typeof t?t=Gf(t):(!Hf(t)||t.length%2)&&qf.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function $f(t,e){for("string"!=typeof t?t=Gf(t):Hf(t)||qf.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&qf.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function Jf(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Hf(r=t)&&!(r.length%2)||Ff(r)){let r=Kf(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Gf(r.slice(0,32)),e.s=Gf(r.slice(32,64))):65===r.length?(e.r=Gf(r.slice(0,32)),e.s=Gf(r.slice(32,64)),e.v=r[64]):qf.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:qf.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Gf(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=function(t,e){(t=Kf(t)).length>e&&qf.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),jf(r)}(Kf(e._vs),32);e._vs=Gf(r);const i=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=i:e.recoveryParam!==i&&qf.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const n=Gf(r);null==e.s?e.s=n:e.s!==n&&qf.throwArgumentError("signature v mismatch _vs","signature",t)}if(null==e.recoveryParam)null==e.v?qf.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(null==e.v)e.v=27+e.recoveryParam;else{const r=0===e.v||1===e.v?e.v:1-e.v%2;e.recoveryParam!==r&&qf.throwArgumentError("signature recoveryParam mismatch v","signature",t)}null!=e.r&&Hf(e.r)?e.r=$f(e.r,32):qf.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&Hf(e.s)?e.s=$f(e.s,32):qf.throwArgumentError("signature missing or invalid s","signature",t);const r=Kf(e.s);r[0]>=128&&qf.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Gf(r);e._vs&&(Hf(e._vs)||qf.throwArgumentError("signature invalid _vs","signature",t),e._vs=$f(e._vs,32)),null==e._vs?e._vs=i:e._vs!==i&&qf.throwArgumentError("signature _vs mismatch v and s","signature",t)}var r;return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var Yf=r(1176),Qf=r.n(Yf);function Xf(t){return"0x"+Qf().keccak_256(Kf(t))}const Zf=new Df("strings/5.7.0");var td,ed;function rd(t,e,r,i,n){if(t===ed.BAD_PREFIX||t===ed.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i>6==2;i++)t++;return t}return t===ed.OVERRUN?r.length-e-1:0}function id(t,e=td.current){e!=td.current&&(Zf.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const s=65536+((1023&i)<<10)+(1023&n);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return Kf(r)}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(td||(td={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(ed||(ed={})),Object.freeze({error:function(t,e,r,i,n){return Zf.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:rd,replace:function(t,e,r,i,n){return t===ed.OVERLONG?(i.push(n),0):(i.push(65533),rd(t,e,r))}});const nd="Ethereum Signed Message:\n";function sd(t){return"string"==typeof t&&(t=id(t)),Xf(function(t){const e=t.map((t=>Kf(t))),r=e.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(r);return e.reduce(((t,e)=>(i.set(e,t),t+e.length)),0),jf(i)}([id(nd),id(String(t.length)),t]))}var od=r(9404),ad=r.n(od),hd=ad().BN;new Df("bignumber/5.7.0");const ud=new Df("address/5.7.0");function cd(t){Hf(t,20)||ud.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const i=Kf(Xf(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const ld={};for(let t=0;t<10;t++)ld[String(t)]=String(t);for(let t=0;t<26;t++)ld[String.fromCharCode(65+t)]=String(10+t);const fd=Math.floor((dd=9007199254740991,Math.log10?Math.log10(dd):Math.log(dd)/Math.LN10));var dd;function pd(t){let e=null;if("string"!=typeof t&&ud.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=cd(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ud.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>ld[t])).join("");for(;e.length>=fd;){let t=e.substring(0,fd);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&ud.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new hd(r,36).toString(16);e.length<40;)e="0"+e;e=cd("0x"+e)}else ud.throwArgumentError("invalid address","address",t);var r;return e}var gd=r(7952),md=r.n(gd);function yd(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self&&self;var vd=wd;function wd(t,e){if(!t)throw new Error(e||"Assertion failed")}wd.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var bd=yd((function(t,e){var r=e;function i(t){return 1===t.length?"0"+t:t}function n(t){for(var e="",r=0;r>8,o=255&n;s?r.push(s,o):r.push(o)}return r},r.zero2=i,r.toHex=n,r.encode=function(t,e){return"hex"===e?n(t):t}})),_d=yd((function(t,e){var r=e;r.assert=vd,r.toArray=bd.toArray,r.zero2=bd.zero2,r.toHex=bd.toHex,r.encode=bd.encode,r.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,h=t.andln(3)+n&3,u=e.andln(3)+s&3;3===h&&(h=-1),3===u&&(u=-1),o=1&h?3!=(i=t.andln(7)+n&7)&&5!==i||2!==u?h:-h:0,r[0].push(o),a=1&u?3!=(i=e.andln(7)+s&7)&&5!==i||2!==h?u:-u:0,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new(ad())(t,"hex","le")}})),Ad=_d.getNAF,Ed=_d.getJSF,Sd=_d.assert;function Md(t,e){this.type=t,this.p=new(ad())(e.p,16),this.red=e.prime?ad().red(e.prime):ad().mont(this.p),this.zero=new(ad())(0).toRed(this.red),this.one=new(ad())(1).toRed(this.red),this.two=new(ad())(2).toRed(this.red),this.n=e.n&&new(ad())(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Id=Md;function xd(t,e){this.curve=t,this.type=e,this.precomputed=null}Md.prototype.point=function(){throw new Error("Not implemented")},Md.prototype.validate=function(){throw new Error("Not implemented")},Md.prototype._fixedNafMul=function(t,e){Sd(t.precomputed);var r=t._getDoubles(),i=Ad(e,1,this._bitLength),n=(1<=s;h--)o=(o<<1)+i[h];a.push(o)}for(var u=this.jpoint(null,null,null),c=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var h=0;a>=0&&0===s[a];a--)h++;if(a>=0&&h++,o=o.dblp(h),a<0)break;var u=s[a];Sd(0!==u),o="affine"===t.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},Md.prototype._wnafMulAdd=function(t,e,r,i,n){var s,o,a,h=this._wnafT1,u=this._wnafT2,c=this._wnafT3,l=0;for(s=0;s=1;s-=2){var d=s-1,p=s;if(1===h[d]&&1===h[p]){var g=[e[d],null,null,e[p]];0===e[d].y.cmp(e[p].y)?(g[1]=e[d].add(e[p]),g[2]=e[d].toJ().mixedAdd(e[p].neg())):0===e[d].y.cmp(e[p].y.redNeg())?(g[1]=e[d].toJ().mixedAdd(e[p]),g[2]=e[d].add(e[p].neg())):(g[1]=e[d].toJ().mixedAdd(e[p]),g[2]=e[d].toJ().mixedAdd(e[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=Ed(r[d],r[p]);for(l=Math.max(y[0].length,l),c[d]=new Array(l),c[p]=new Array(l),o=0;o=0;s--){for(var A=0;s>=0;){var E=!0;for(o=0;o=0&&A++,b=b.dblp(A),s<0)break;for(o=0;o0?a=u[o][S-1>>1]:S<0&&(a=u[o][-S-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},xd.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n=0&&(s=e,o=r),i.negative&&(i=i.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:n},{a:s,b:o}]},Pd.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),h=n.mul(r.b),u=s.mul(i.b);return{k1:t.sub(o).sub(a),k2:h.add(u).neg()}},Pd.prototype.pointFromX=function(t,e){(t=new(ad())(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},Pd.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},Pd.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},Td.prototype.isInfinity=function(){return this.inf},Td.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},Td.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},Td.prototype.getX=function(){return this.x.fromRed()},Td.prototype.getY=function(){return this.y.fromRed()},Td.prototype.mul=function(t){return t=new(ad())(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Td.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},Td.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},Td.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Td.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},Td.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Nd(Cd,Id.BasePoint),Pd.prototype.jpoint=function(t,e,r){return new Cd(this,t,e,r)},Cd.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},Cd.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Cd.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),l=i.redMul(u),f=h.redSqr().redIAdd(c).redISub(l).redISub(l),d=h.redMul(l.redISub(f)).redISub(s.redMul(c)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(f,d,p)},Cd.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),c=r.redMul(h),l=a.redSqr().redIAdd(u).redISub(c).redISub(c),f=a.redMul(c.redISub(l)).redISub(n.redMul(u)),d=this.z.redMul(o);return this.curve.jpoint(l,f,d)},Cd.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},Cd.prototype.inspect=function(){return this.isInfinity()?"":""},Cd.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var kd=yd((function(t,e){var r=e;r.base=Id,r.short=Rd,r.mont=null,r.edwards=null})),Ud=yd((function(t,e){var r,i=e,n=_d.assert;function s(t){"short"===t.type?this.curve=new kd.short(t):"edwards"===t.type?this.curve=new kd.edwards(t):this.curve=new kd.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:md().sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:md().sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:md().sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:md().sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:md().sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:md().sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:md().sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:md().sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Ld(t){if(!(this instanceof Ld))return new Ld(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=bd.toArray(t.entropy,t.entropyEnc||"hex"),r=bd.toArray(t.nonce,t.nonceEnc||"hex"),i=bd.toArray(t.pers,t.persEnc||"hex");vd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Dd=Ld;Ld.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Ld.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=bd.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length"};var zd=_d.assert;function Fd(t,e){if(t instanceof Fd)return t;this._importDER(t,e)||(zd(t.r&&t.s,"Signature without r or s"),this.r=new(ad())(t.r,16),this.s=new(ad())(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Kd=Fd;function Hd(){this.place=0}function Vd(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function Gd(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Fd.prototype._importDER=function(t,e){t=_d.toArray(t,e);var r=new Hd;if(48!==t[r.place++])return!1;var i=Vd(t,r);if(!1===i)return!1;if(i+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Vd(t,r);if(!1===n)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=Vd(t,r);if(!1===o)return!1;if(t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new(ad())(s),this.s=new(ad())(a),this.recoveryParam=null,!0},Fd.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Gd(e),r=Gd(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];Wd(i,e.length),(i=i.concat(e)).push(2),Wd(i,r.length);var n=i.concat(r),s=[48];return Wd(s,n.length),s=s.concat(n),_d.encode(s,t)};var $d=function(){throw new Error("unsupported")},Jd=_d.assert;function Yd(t){if(!(this instanceof Yd))return new Yd(t);"string"==typeof t&&(Jd(Object.prototype.hasOwnProperty.call(Ud,t),"Unknown curve "+t),t=Ud[t]),t instanceof Ud.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Qd=Yd;Yd.prototype.keyPair=function(t){return new jd(this,t)},Yd.prototype.keyFromPrivate=function(t,e){return jd.fromPrivate(this,t,e)},Yd.prototype.keyFromPublic=function(t,e){return jd.fromPublic(this,t,e)},Yd.prototype.genKeyPair=function(t){t||(t={});for(var e=new Dd({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||$d(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new(ad())(2));;){var n=new(ad())(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Yd.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Yd.prototype.sign=function(t,e,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new(ad())(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new Dd({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),h=this.n.sub(new(ad())(1)),u=0;;u++){var c=i.k?i.k(u):new(ad())(a.generate(this.n.byteLength()));if(!((c=this._truncateToN(c,!0)).cmpn(1)<=0||c.cmp(h)>=0)){var l=this.g.mul(c);if(!l.isInfinity()){var f=l.getX(),d=f.umod(this.n);if(0!==d.cmpn(0)){var p=c.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var g=(l.getY().isOdd()?1:0)|(0!==f.cmp(d)?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),g^=1),new Kd({r:d,s:p,recoveryParam:g})}}}}}},Yd.prototype.verify=function(t,e,r,i){t=this._truncateToN(new(ad())(t,16)),r=this.keyFromPublic(r,i);var n=(e=new Kd(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},Yd.prototype.recoverPubKey=function(t,e,r,i){Jd((3&r)===r,"The recovery param is more than two bits"),e=new Kd(e,i);var n=this.n,s=new(ad())(t),o=e.r,a=e.s,h=1&r,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");o=u?this.curve.pointFromX(o.add(this.curve.n),h):this.curve.pointFromX(o,h);var c=e.r.invm(n),l=n.sub(s).mul(c).umod(n),f=a.mul(c).umod(n);return this.g.mulAdd(l,o,f)},Yd.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new Kd(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Xd=yd((function(t,e){var r=e;r.version="6.5.4",r.utils=_d,r.rand=function(){throw new Error("unsupported")},r.curve=kd,r.curves=Ud,r.ec=Qd,r.eddsa=null})).ec;function Zd(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}new Df("properties/5.7.0");const tp=new Df("signing-key/5.7.0");let ep=null;function rp(){return ep||(ep=new Xd("secp256k1")),ep}class ip{constructor(t){Zd(this,"curve","secp256k1"),Zd(this,"privateKey",Gf(t)),32!==function(t){if("string"!=typeof t)t=Gf(t);else if(!Hf(t)||t.length%2)return null;return(t.length-2)/2}(this.privateKey)&&tp.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=rp().keyFromPrivate(Kf(this.privateKey));Zd(this,"publicKey","0x"+e.getPublic(!1,"hex")),Zd(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Zd(this,"_isSigningKey",!0)}_addPoint(t){const e=rp().keyFromPublic(Kf(this.publicKey)),r=rp().keyFromPublic(Kf(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=rp().keyFromPrivate(Kf(this.privateKey)),r=Kf(t);32!==r.length&&tp.throwArgumentError("bad digest length","digest",t);const i=e.sign(r,{canonical:!0});return Jf({recoveryParam:i.recoveryParam,r:$f("0x"+i.r.toString(16),32),s:$f("0x"+i.s.toString(16),32)})}computeSharedSecret(t){const e=rp().keyFromPrivate(Kf(this.privateKey)),r=rp().keyFromPublic(Kf(np(t)));return $f("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function np(t,e){const r=Kf(t);if(32===r.length){const t=new ip(r);return e?"0x"+rp().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?Gf(r):"0x"+rp().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+rp().keyFromPublic(r).getPublic(!0,"hex"):Gf(r):tp.throwArgumentError("invalid public or private key","key","[REDACTED]")}var sp;new Df("transactions/5.7.0"),function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(sp||(sp={}));class op{constructor(t){this.client=t}}class ap{constructor(t){this.opts=t}}const hp={wc_authRequest:{req:{ttl:Rt.ONE_DAY,prompt:!0,tag:3e3},res:{ttl:Rt.ONE_DAY,prompt:!1,tag:3001}}},up={min:Rt.FIVE_MINUTES,max:Rt.SEVEN_DAYS},cp="authClient",lp="wc@1:auth:",fp=`${lp}:PUB_KEY`;function dp(t){return t?.split(":")}function pp(t){const e=t&&dp(t);if(e)return e.pop()}async function gp(t,e,r,i,n){switch(r.t){case"eip191":return function(t,e,r){return function(t,e){return function(t){return pd(Wf(Xf(Wf(np(t),1)),12))}(function(t,e){const r=Jf(e),i={r:Kf(r.r),s:Kf(r.s)};return"0x"+rp().recoverPubKey(Kf(t),i,r.recoveryParam).encode("hex",!1)}(Kf(t),e))}(sd(e),r).toLowerCase()===t.toLowerCase()}(t,e,r.s);case"eip1271":return await async function(t,e,r,i,n){try{const s="0x1626ba7e",o="0000000000000000000000000000000000000000000000000000000000000040",a="0000000000000000000000000000000000000000000000000000000000000041",h=r.substring(2),u=s+sd(e).substring(2)+o+a+h,c=await Cu()(`https://rpc.walletconnect.com/v1/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:u},"latest"]})}),{result:l}=await c.json();return!!l&&l.slice(0,s.length).toLowerCase()===s.toLowerCase()}catch(t){return console.error("isValidEip1271Signature: ",t),!1}}(t,e,r.s,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function mp(t){return t.getAll().filter((t=>"requester"in t))}function yp(t,e){return mp(t).find((t=>t.id===e))}var vp=function(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);t[e];){var c=r[t.charCodeAt(e)];if(255===c)return;for(var l=0,f=s-1;(0!==c||l>>0,o[f]=c%256>>>0,c=c/256>>>0;if(0!==c)throw new Error("Non-zero carry");n=l,e++}if(" "!==t[e]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,i=0,n=0,s=e.length;n!==s&&0===e[n];)n++,r++;for(var o=(s-n)*c+1>>>0,u=new Uint8Array(o);n!==s;){for(var l=e[n],f=0,d=o-1;(0!==l||f>>0,u[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var g=h.repeat(r);p{if(t instanceof Uint8Array&&"Uint8Array"===t.constructor.name)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")};class bp{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class _p{constructor(t,e,r){if(this.name=t,this.prefix=e,void 0===e.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if("string"==typeof t){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(t){return Ep(this,t)}}class Ap{constructor(t){this.decoders=t}or(t){return Ep(this,t)}decode(t){const e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ep=(t,e)=>new Ap({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Sp{constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new bp(t,e,r),this.decoder=new _p(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Mp=({name:t,prefix:e,encode:r,decode:i})=>new Sp(t,e,r,i),Ip=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=vp(r,e);return Mp({prefix:t,name:e,encode:i,decode:t=>wp(n(t))})},xp=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Mp({prefix:e,name:t,encode:t=>((t,e,r)=>{const i="="===e[e.length-1],n=(1<r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<((t,e,r,i)=>{const n={};for(let t=0;t=8&&(a-=8,o[u++]=255&h>>a)}if(a>=r||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,i,r,t)}),Np=Mp({prefix:"\0",name:"identity",encode:t=>(t=>(new TextDecoder).decode(t))(t),decode:t=>(t=>(new TextEncoder).encode(t))(t)});var Op=Object.freeze({__proto__:null,identity:Np});const Pp=xp({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rp=Object.freeze({__proto__:null,base2:Pp});const Tp=xp({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Cp=Object.freeze({__proto__:null,base8:Tp});const kp=Ip({prefix:"9",name:"base10",alphabet:"0123456789"});var Up=Object.freeze({__proto__:null,base10:kp});const Lp=xp({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Dp=xp({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qp=Object.freeze({__proto__:null,base16:Lp,base16upper:Dp});const Bp=xp({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jp=xp({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zp=xp({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fp=xp({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Kp=xp({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hp=xp({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Vp=xp({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Gp=xp({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wp=xp({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $p=Object.freeze({__proto__:null,base32:Bp,base32upper:jp,base32pad:zp,base32padupper:Fp,base32hex:Kp,base32hexupper:Hp,base32hexpad:Vp,base32hexpadupper:Gp,base32z:Wp});const Jp=Ip({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yp=Ip({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qp=Object.freeze({__proto__:null,base36:Jp,base36upper:Yp});const Xp=Ip({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zp=Ip({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tg=Object.freeze({__proto__:null,base58btc:Xp,base58flickr:Zp});const eg=xp({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),rg=xp({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ig=xp({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ng=xp({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var sg=Object.freeze({__proto__:null,base64:eg,base64pad:rg,base64url:ig,base64urlpad:ng});const og=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ag=og.reduce(((t,e,r)=>(t[r]=e,t)),[]),hg=og.reduce(((t,e,r)=>(t[e.codePointAt(0)]=r,t)),[]),ug=Mp({prefix:"🚀",name:"base256emoji",encode:function(t){return t.reduce(((t,e)=>t+ag[e]),"")},decode:function(t){const e=[];for(const r of t){const t=hg[r.codePointAt(0)];if(void 0===t)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}});var cg=Object.freeze({__proto__:null,base256emoji:ug}),lg=128,fg=-128,dg=Math.pow(2,31),pg=Math.pow(2,7),gg=Math.pow(2,14),mg=Math.pow(2,21),yg=Math.pow(2,28),vg=Math.pow(2,35),wg=Math.pow(2,42),bg=Math.pow(2,49),_g=Math.pow(2,56),Ag=Math.pow(2,63),Eg=function t(e,r,i){r=r||[];for(var n=i=i||0;e>=dg;)r[i++]=255&e|lg,e/=128;for(;e&fg;)r[i++]=255&e|lg,e>>>=7;return r[i]=0|e,t.bytes=i-n+1,r},Sg=function(t){return t(Eg(t,e,r),e),Ig=t=>Sg(t),xg=(t,e)=>{const r=e.byteLength,i=Ig(t),n=i+Ig(r),s=new Uint8Array(n+r);return Mg(t,s,0),Mg(r,s,i),s.set(e,n),new Ng(t,r,e,s)};class Ng{constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}}const Og=({name:t,code:e,encode:r})=>new Pg(t,e,r);class Pg{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?xg(this.code,e):e.then((t=>xg(this.code,t)))}throw Error("Unknown type, must be binary type")}}const Rg=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Tg=Og({name:"sha2-256",code:18,encode:Rg("SHA-256")}),Cg=Og({name:"sha2-512",code:19,encode:Rg("SHA-512")});Object.freeze({__proto__:null,sha256:Tg,sha512:Cg});const kg=wp,Ug={code:0,name:"identity",encode:kg,digest:t=>xg(0,kg(t))};Object.freeze({__proto__:null,identity:Ug}),new TextEncoder,new TextDecoder;const Lg={...Op,...Rp,...Cp,...Up,...qp,...$p,...Qp,...tg,...sg,...cg};function Dg(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const qg=Dg("utf8","u",(t=>"u"+new TextDecoder("utf8").decode(t)),(t=>(new TextEncoder).encode(t.substring(1)))),Bg=Dg("ascii","a",(t=>{let e="a";for(let r=0;r{const e=function(t=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}((t=t.substring(1)).length);for(let r=0;re in t?Fg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jg=(t,e)=>{for(var r in e||(e={}))Gg.call(e,r)&&$g(t,r,e[r]);if(Vg)for(var r of Vg(e))Wg.call(e,r)&&$g(t,r,e[r]);return t},Yg=(t,e)=>Kg(t,Hg(e));class Qg extends op{constructor(t){super(t),this.initialized=!1,this.name="authEngine",this.init=()=>{this.initialized||(this.registerRelayerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(hp)}),this.initialized=!0)},this.request=async(t,e)=>{if(this.isInitialized(),!function(t){const e=zh(t.aud),r=new RegExp(`${t.domain}`).test(t.aud),i=!!t.nonce,n=!t.type||"eip4361"===t.type,s=t.expiry;if(s&&!Yh(s,up)){const{message:t}=Ch("MISSING_OR_INVALID",`request() expiry: ${s}. Expiry must be a number (in seconds) between ${up.min} and ${up.max}`);throw new Error(t)}return!!(e&&r&&i&&n)}(t))throw new Error("Invalid request");if(null!=e&&e.topic)return await this.requestOnKnownPairing(e.topic,t);const{chainId:r,statement:i,aud:n,domain:s,nonce:o,type:a,exp:h,nbf:u}=t,{topic:c,uri:l}=await this.client.core.pairing.create();this.client.logger.info({message:"Generated new pairing",pairing:{topic:c,uri:l}});const f=await this.client.core.crypto.generateKeyPair(),d=Xa(f);await this.client.authKeys.set(fp,{responseTopic:d,publicKey:f}),await this.client.pairingTopics.set(d,{topic:d,pairingTopic:c}),await this.client.core.relayer.subscribe(d),this.client.logger.info(`sending request to new pairing topic: ${c}`);const p=await this.sendRequest(c,"wc_authRequest",{payloadParams:{type:a??"eip4361",chainId:r,statement:i,aud:n,domain:s,version:"1",nonce:o,iat:(new Date).toISOString(),exp:h,nbf:u},requester:{publicKey:f,metadata:this.client.metadata}},{},t.expiry);return this.client.logger.info(`sent request to new pairing topic: ${c}`),{uri:l,id:p}},this.respond=async(t,e)=>{if(this.isInitialized(),!function(t,e){return!!yp(e,t.id)}(t,this.client.requests))throw new Error("Invalid response");const r=yp(this.client.requests,t.id);if(!r)throw new Error(`Could not find pending auth request with id ${t.id}`);const i=r.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),s=Xa(i),o={type:1,receiverPublicKey:i,senderPublicKey:n};if("error"in t)return void await this.sendError(r.id,s,t,o);const a={h:{t:"eip4361"},p:Yg(Jg({},r.cacaoPayload),{iss:e}),s:t.signature};await this.sendResult(r.id,s,a,o),await this.client.core.pairing.activate({topic:r.pairingTopic}),await this.client.requests.update(r.id,Jg({},a))},this.getPendingRequests=()=>mp(this.client.requests),this.formatMessage=(t,e)=>{this.client.logger.debug(`formatMessage, cacao is: ${JSON.stringify(t)}`);const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=pp(e),n=t.statement,s=`URI: ${t.aud}`,o=`Version: ${t.version}`,a=`Chain ID: ${function(t){const e=t&&dp(t);if(e)return e[3]}(e)}`;return[r,i,"",n,"",s,o,a,`Nonce: ${t.nonce}`,`Issued At: ${t.iat}`,t.exp?`Expiry: ${t.exp}`:void 0,t.resources&&t.resources.length>0?`Resources:\n${t.resources.map((t=>`- ${t}`)).join("\n")}`:void 0].filter((t=>null!=t)).join("\n")},this.setExpiry=async(t,e)=>{this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.updateExpiry({topic:t,expiry:e}),this.client.core.expirer.set(t,e)},this.sendRequest=async(t,e,r,i,n)=>{const s=du(e,r),o=await this.client.core.crypto.encode(t,s,i),a=hp[e].req;if(n&&(a.ttl=n),this.client.core.history.set(t,s),Jr()){const t=zg(JSON.stringify(s));this.client.core.verify.register({attestationId:t})}return await this.client.core.relayer.publish(t,o,Yg(Jg({},a),{internal:{throwOnFailedPublish:!0}})),s.id},this.sendResult=async(t,e,r,i)=>{const n=pu(t,r),s=await this.client.core.crypto.encode(e,n,i),o=await this.client.core.history.get(e,t),a=hp[o.request.method].res;return await this.client.core.relayer.publish(e,s,Yg(Jg({},a),{internal:{throwOnFailedPublish:!0}})),await this.client.core.history.resolve(n),n.id},this.sendError=async(t,e,r,i)=>{const n=gu(t,r.error),s=await this.client.core.crypto.encode(e,n,i),o=await this.client.core.history.get(e,t),a=hp[o.request.method].res;return await this.client.core.relayer.publish(e,s,a),await this.client.core.history.resolve(n),n.id},this.requestOnKnownPairing=async(t,e)=>{const r=this.client.core.pairing.pairings.getAll({active:!0}).find((e=>e.topic===t));if(!r)throw new Error(`Could not find pairing for provided topic ${t}`);const{publicKey:i}=this.client.authKeys.get(fp),{chainId:n,statement:s,aud:o,domain:a,nonce:h,type:u}=e,c=await this.sendRequest(r.topic,"wc_authRequest",{payloadParams:{type:u??"eip4361",chainId:n,statement:s,aud:o,domain:a,version:"1",nonce:h,iat:(new Date).toISOString()},requester:{publicKey:i,metadata:this.client.metadata}},{},e.expiry);return this.client.logger.info(`sent request to known pairing topic: ${r.topic}`),{id:c}},this.onPairingCreated=t=>{const e=this.getPendingRequests();if(e){const r=Object.values(e).find((e=>e.pairingTopic===t.topic));r&&this.handleAuthRequest(r)}},this.onRelayEventRequest=t=>{const{topic:e,payload:r}=t,i=r.method;return"wc_authRequest"===i?this.onAuthRequest(e,r):this.client.logger.info(`Unsupported request method ${i}`)},this.onRelayEventResponse=async t=>{const{topic:e,payload:r}=t,i=(await this.client.core.history.get(e,r.id)).request.method;return"wc_authRequest"===i?this.onAuthResponse(e,r):this.client.logger.info(`Unsupported response method ${i}`)},this.onAuthRequest=async(t,e)=>{const{requester:r,payloadParams:i}=e.params;this.client.logger.info({type:"onAuthRequest",topic:t,payload:e});const n=zg(JSON.stringify(e)),s=await this.getVerifyContext(n,this.client.metadata),o={requester:r,pairingTopic:t,id:e.id,cacaoPayload:i,verifyContext:s};await this.client.requests.set(e.id,o),this.handleAuthRequest(o)},this.handleAuthRequest=async t=>{const{id:e,pairingTopic:r,requester:i,cacaoPayload:n,verifyContext:s}=t;try{this.client.emit("auth_request",{id:e,topic:r,params:{requester:i,cacaoPayload:n},verifyContext:s})}catch(e){await this.sendError(t.id,t.pairingTopic,e),this.client.logger.error(e)}},this.onAuthResponse=async(t,e)=>{const{id:r}=e;if(this.client.logger.info({type:"onAuthResponse",topic:t,response:e}),Su(e)){const{pairingTopic:i}=this.client.pairingTopics.get(t);await this.client.core.pairing.activate({topic:i});const{s:n,p:s}=e.result;await this.client.requests.set(r,Jg({id:r,pairingTopic:i},e.result));const o=this.formatMessage(s,s.iss);this.client.logger.debug("reconstructed message:\n",JSON.stringify(o)),this.client.logger.debug("payload.iss:",s.iss),this.client.logger.debug("signature:",n);const a=pp(s.iss),h=function(t){const e=t&&dp(t);if(e)return e[2]+":"+e[3]}(s.iss);if(!a)throw new Error("Could not derive address from `payload.iss`");if(!h)throw new Error("Could not derive chainId from `payload.iss`");this.client.logger.debug("walletAddress extracted from `payload.iss`:",a),await gp(a,o,n,h,this.client.projectId)?this.client.emit("auth_response",{id:r,topic:t,params:e}):this.client.emit("auth_response",{id:r,topic:t,params:{message:"Invalid signature",code:-1}})}else Mu(e)&&this.client.emit("auth_response",{id:r,topic:t,params:e})},this.getVerifyContext=async(t,e)=>{const r={verified:{verifyUrl:e.verifyUrl||"",validation:"UNKNOWN",origin:e.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:t,verifyUrl:e.verifyUrl});i&&(r.verified.origin=i.origin,r.verified.isScam=i.isScam,r.verified.validation=origin===new URL(e.url).origin?"VALID":"INVALID")}catch(t){this.client.logger.error(t)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r}}isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.client.core.relayer.on(gl,(async t=>{const{topic:e,message:r}=t,{responseTopic:i,publicKey:n}=this.client.authKeys.keys.includes(fp)?this.client.authKeys.get(fp):{responseTopic:void 0,publicKey:void 0};if(i&&e!==i)return void this.client.logger.debug("[Auth] Ignoring message from unknown topic",e);const s=await this.client.core.crypto.decode(e,r,{receiverPublicKey:n});Au(s)?(this.client.core.history.set(e,s),this.onRelayEventRequest({topic:e,payload:s})):Eu(s)&&(await this.client.core.history.resolve(s),this.onRelayEventResponse({topic:e,payload:s}))}))}registerPairingEvents(){this.client.core.pairing.events.on(Nl,(t=>this.onPairingCreated(t)))}}class Xg extends ap{constructor(t){super(t),this.protocol="wc",this.version=1,this.name=cp,this.events=new g.EventEmitter,this.emit=(t,e)=>this.events.emit(t,e),this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.request=async(t,e)=>{try{return await this.engine.request(t,e)}catch(t){throw this.logger.error(t.message),t}},this.respond=async(t,e)=>{try{return await this.engine.respond(t,e)}catch(t){throw this.logger.error(t.message),t}},this.getPendingRequests=()=>{try{return this.engine.getPendingRequests()}catch(t){throw this.logger.error(t.message),t}},this.formatMessage=(t,e)=>{try{return this.engine.formatMessage(t,e)}catch(t){throw this.logger.error(t.message),t}};const e=typeof t.logger<"u"&&"string"!=typeof t.logger?t.logger:Y()(ft({level:t.logger||"error"}));this.name=t?.name||cp,this.metadata=t.metadata,this.projectId=t.projectId,this.core=t.core||new xf(t),this.logger=pt(e,this.name),this.authKeys=new pf(this.core,this.logger,"authKeys",lp,(()=>fp)),this.pairingTopics=new pf(this.core,this.logger,"pairingTopics",lp),this.requests=new pf(this.core,this.logger,"requests",lp,(t=>t.id)),this.engine=new Qg(this)}static async init(t){const e=new Xg(t);return await e.initialize(),e}get context(){return dt(this.logger)}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.authKeys.init(),await this.requests.init(),await this.pairingTopics.init(),await this.engine.init(),this.logger.info("AuthClient Initialization Success"),this.logger.info({authClient:this})}catch(t){throw this.logger.info("AuthClient Initialization Failure"),this.logger.error(t.message),t}}}const Zg=Xg,tm="client",em=`wc@2:${tm}:`,rm=tm,im="WALLETCONNECT_DEEPLINK_CHOICE",nm=Rt.SEVEN_DAYS,sm={wc_sessionPropose:{req:{ttl:Rt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Rt.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:Rt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Rt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Rt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Rt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Rt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Rt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Rt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Rt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Rt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Rt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Rt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Rt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Rt.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Rt.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Rt.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Rt.ONE_HOUR,prompt:!1,tag:1117}}},om={min:Rt.FIVE_MINUTES,max:Rt.SEVEN_DAYS},am="IDLE",hm="ACTIVE",um=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"],cm="wc@1.5:auth:",lm=`${cm}:PUB_KEY`;var fm=Object.defineProperty,dm=Object.defineProperties,pm=Object.getOwnPropertyDescriptors,gm=Object.getOwnPropertySymbols,mm=Object.prototype.hasOwnProperty,ym=Object.prototype.propertyIsEnumerable,vm=(t,e,r)=>e in t?fm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wm=(t,e)=>{for(var r in e||(e={}))mm.call(e,r)&&vm(t,r,e[r]);if(gm)for(var r of gm(e))ym.call(e,r)&&vm(t,r,e[r]);return t},bm=(t,e)=>dm(t,pm(e));class _m extends Nt{constructor(t){super(t),this.name="engine",this.events=new(m()),this.initialized=!1,this.requestQueue={state:am,queue:[]},this.sessionRequestQueue={state:am,queue:[]},this.requestQueueDelay=Rt.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(sm)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,Rt.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{await this.isInitialized();const e=bm(wm({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(e);const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:s,relays:o}=e;let a,h=r,u=!1;try{h&&(u=this.client.core.pairing.pairings.get(h).active)}catch(t){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),t}if(!h||!u){const{topic:t,uri:e}=await this.client.core.pairing.create();h=t,a=e}if(!h){const{message:t}=Ch("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(t)}const c=await this.client.core.crypto.generateKeyPair(),l=sm.wc_sessionPropose.req.ttl||Rt.FIVE_MINUTES,f=si(l),d=wm({requiredNamespaces:i,optionalNamespaces:n,relays:o??[{protocol:"irn"}],proposer:{publicKey:c,metadata:this.client.metadata},expiryTimestamp:f},s&&{sessionProperties:s}),{reject:p,resolve:g,done:m}=ei(l,"Proposal expired");this.events.once(ai("session_connect"),(async({error:t,session:e})=>{if(t)p(t);else if(e){e.self.publicKey=c;const t=bm(wm({},e),{requiredNamespaces:d.requiredNamespaces,optionalNamespaces:d.optionalNamespaces});await this.client.session.set(e.topic,t),await this.setExpiry(e.topic,e.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:e.peer.metadata}),g(t)}}));const y=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:d,throwOnFailedPublish:!0});return await this.setProposal(y,wm({id:y},d)),{uri:a,approval:m}},this.pair=async t=>{await this.isInitialized();try{return await this.client.core.pairing.pair(t)}catch(t){throw this.client.logger.error("pair() failed"),t}},this.approve=async t=>{await this.isInitialized();try{await this.isValidApprove(t)}catch(t){throw this.client.logger.error("approve() -> isValidApprove() failed"),t}const{id:e,relayProtocol:r,namespaces:i,sessionProperties:n,sessionConfig:s}=t;let o;try{o=this.client.proposal.get(e)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e}) failed`),t}let{pairingTopic:a,proposer:h,requiredNamespaces:u,optionalNamespaces:c}=o;a=a||"";const l=await this.client.core.crypto.generateKeyPair(),f=h.publicKey,d=await this.client.core.crypto.generateSharedKey(l,f),p=wm(wm({relay:{protocol:r??"irn"},namespaces:i,pairingTopic:a,controller:{publicKey:l,metadata:this.client.metadata},expiry:si(nm)},n&&{sessionProperties:n}),s&&{sessionConfig:s});await this.client.core.relayer.subscribe(d);const g=bm(wm({},p),{topic:d,requiredNamespaces:u,optionalNamespaces:c,pairingTopic:a,acknowledged:!1,self:p.controller,peer:{publicKey:h.publicKey,metadata:h.metadata},controller:l});await this.client.session.set(d,g);try{await this.sendResult({id:e,topic:a,result:{relay:{protocol:r??"irn"},responderPublicKey:l},throwOnFailedPublish:!0}),await this.sendRequest({topic:d,method:"wc_sessionSettle",params:p,throwOnFailedPublish:!0})}catch(t){throw this.client.logger.error(t),this.client.session.delete(d,kh("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(d),t}return await this.client.core.pairing.updateMetadata({topic:a,metadata:h.metadata}),await this.client.proposal.delete(e,kh("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a}),await this.setExpiry(d,si(nm)),{topic:d,acknowledged:()=>new Promise((t=>setTimeout((()=>t(this.client.session.get(d))),500)))}},this.reject=async t=>{await this.isInitialized();try{await this.isValidReject(t)}catch(t){throw this.client.logger.error("reject() -> isValidReject() failed"),t}const{id:e,reason:r}=t;let i;try{i=this.client.proposal.get(e).pairingTopic}catch(t){throw this.client.logger.error(`reject() -> proposal.get(${e}) failed`),t}i&&(await this.sendError({id:e,topic:i,error:r}),await this.client.proposal.delete(e,kh("USER_DISCONNECTED")))},this.update=async t=>{await this.isInitialized();try{await this.isValidUpdate(t)}catch(t){throw this.client.logger.error("update() -> isValidUpdate() failed"),t}const{topic:e,namespaces:r}=t,{done:i,resolve:n,reject:s}=ei(),o=lu(),a=fu().toString(),h=this.client.session.get(e).namespaces;return this.events.once(ai("session_update",o),(({error:t})=>{t?s(t):n()})),await this.client.session.update(e,{namespaces:r}),this.sendRequest({topic:e,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:a}).catch((t=>{this.client.logger.error(t),this.client.session.update(e,{namespaces:h}),s(t)})),{acknowledged:i}},this.extend=async t=>{await this.isInitialized();try{await this.isValidExtend(t)}catch(t){throw this.client.logger.error("extend() -> isValidExtend() failed"),t}const{topic:e}=t,r=lu(),{done:i,resolve:n,reject:s}=ei();return this.events.once(ai("session_extend",r),(({error:t})=>{t?s(t):n()})),await this.setExpiry(e,si(nm)),this.sendRequest({topic:e,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch((t=>{s(t)})),{acknowledged:i}},this.request=async t=>{await this.isInitialized();try{await this.isValidRequest(t)}catch(t){throw this.client.logger.error("request() -> isValidRequest() failed"),t}const{chainId:e,request:i,topic:n,expiry:s=sm.wc_sessionRequest.req.ttl}=t,o=this.client.session.get(n),a=lu(),h=fu().toString(),{done:u,resolve:c,reject:l}=ei(s,"Request expired. Please try again.");return this.events.once(ai("session_request",a),(({error:t,result:e})=>{t?l(t):c(e)})),await Promise.all([new Promise((async t=>{await this.sendRequest({clientRpcId:a,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:bm(wm({},i),{expiryTimestamp:si(s)}),chainId:e},expiry:s,throwOnFailedPublish:!0}).catch((t=>l(t))),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:e,id:a}),t()})),new Promise((async t=>{var e;if(null==(e=o.sessionConfig)||!e.disableDeepLink){const t=await async function(t,e){try{return await t.getItem(e)||(Jr()?localStorage.getItem(e):void 0)}catch(t){console.error(t)}}(this.client.core.storage,im);!async function({id:t,topic:e,wcDeepLink:i}){try{if(!i)return;const n="string"==typeof i?JSON.parse(i):i;let s=n?.href;if("string"!=typeof s)return;s.endsWith("/")&&(s=s.slice(0,-1));const o=`${s}/wc?requestId=${t}&sessionTopic=${e}`,a=Yr();a===Vr.browser?o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,"_self","noreferrer noopener"):a===Vr.reactNative&&typeof(null==r.g?void 0:r.g.Linking)<"u"&&await r.g.Linking.openURL(o)}catch(t){console.error(t)}}({id:a,topic:n,wcDeepLink:t})}t()})),u()]).then((t=>t[2]))},this.respond=async t=>{await this.isInitialized(),await this.isValidRespond(t);const{topic:e,response:r}=t,{id:i}=r;Su(r)?await this.sendResult({id:i,topic:e,result:r.result,throwOnFailedPublish:!0}):Mu(r)&&await this.sendError({id:i,topic:e,error:r.error}),this.cleanupAfterResponse(t)},this.ping=async t=>{await this.isInitialized();try{await this.isValidPing(t)}catch(t){throw this.client.logger.error("ping() -> isValidPing() failed"),t}const{topic:e}=t;if(this.client.session.keys.includes(e)){const t=lu(),r=fu().toString(),{done:i,resolve:n,reject:s}=ei();this.events.once(ai("session_ping",t),(({error:t})=>{t?s(t):n()})),await Promise.all([this.sendRequest({topic:e,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:t,relayRpcId:r}),i()])}else this.client.core.pairing.pairings.keys.includes(e)&&await this.client.core.pairing.ping({topic:e})},this.emit=async t=>{await this.isInitialized(),await this.isValidEmit(t);const{topic:e,event:r,chainId:i}=t,n=fu().toString();await this.sendRequest({topic:e,method:"wc_sessionEvent",params:{event:r,chainId:i},throwOnFailedPublish:!0,relayRpcId:n})},this.disconnect=async t=>{await this.isInitialized(),await this.isValidDisconnect(t);const{topic:e}=t;if(this.client.session.keys.includes(e))await this.sendRequest({topic:e,method:"wc_sessionDelete",params:kh("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:e,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Ch("MISMATCHED_TOPIC",`Session or pairing topic not found: ${e}`);throw new Error(t)}await this.client.core.pairing.disconnect({topic:e})}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter((e=>function(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return!!Xr(n,i)&&(i.forEach((e=>{const{accounts:i,methods:n,events:o}=t.namespaces[e],a=Ih(i),h=r[e];Xr(Dr(e,h),a)&&Xr(h.methods,n)&&Xr(h.events,o)||(s=!1)})),s)}(e,t)))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async t=>{this.isInitialized(),this.isValidAuthenticate(t);const{chains:e,statement:r="",uri:i,domain:n,nonce:s,type:o,exp:a,nbf:h,methods:u=[]}=t,c=[...t.resources||[]],{topic:l,uri:f}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"]});this.client.logger.info({message:"Generated new pairing",pairing:{topic:l,uri:f}});const d=await this.client.core.crypto.generateKeyPair(),p=Xa(d);if(await Promise.all([this.client.auth.authKeys.set(lm,{responseTopic:p,publicKey:d}),this.client.auth.pairingTopics.set(p,{topic:p,pairingTopic:l})]),await this.client.core.relayer.subscribe(p),this.client.logger.info(`sending request to new pairing topic: ${l}`),u.length>0){const{namespace:t}=Lr(e[0]);let r=function(t,e,r){const i=function(t,e,r,i={}){return r?.sort(((t,e)=>t.localeCompare(e))),{att:{[t]:ja(e,r,i)}}}(t,e,r);return za(i)}(t,"request",u);Ga(c)&&(r=Ka(r,c.pop())),c.push(r)}const g=si(sm.wc_sessionPropose.req.ttl),m={authPayload:{type:o??"caip122",chains:e,statement:r,aud:i,domain:n,version:"1",nonce:s,iat:(new Date).toISOString(),exp:a,nbf:h,resources:c},requester:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:g},y={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:e,methods:[...new Set(["personal_sign",...u])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:g},{done:v,resolve:w,reject:b}=ei(sm.wc_sessionAuthenticate.req.ttl,"Request expired"),_=async({error:t,session:e})=>{if(this.events.off(ai("session_request",E),A),t)b(t);else if(e){e.self.publicKey=d,await this.client.session.set(e.topic,e),await this.setExpiry(e.topic,e.expiry),l&&await this.client.core.pairing.updateMetadata({topic:l,metadata:e.peer.metadata});const t=this.client.session.get(e.topic);w({session:t})}},A=async t=>{if(t.error){const e=kh("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return t.error.code===e.code?void 0:(this.events.off(ai("session_connect"),_),b(t.error.message))}this.events.off(ai("session_connect"),_);const{cacaos:e,responder:r}=t.result,i=[],n=[];for(const t of e){await Da({cacao:t,projectId:this.client.core.projectId})||(this.client.logger.error(t,"Signature verification failed"),b(kh("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:e}=t,r=Ga(e.resources),s=[Ua(e.iss)],o=La(e.iss);if(r){const t=Ha(r),e=Va(r);i.push(...t),s.push(...e)}for(const t of s)n.push(`${t}:${o}`)}const s=await this.client.core.crypto.generateSharedKey(d,r.publicKey);let o;i.length>0&&(o={topic:s,acknowledged:!0,self:{publicKey:d,metadata:this.client.metadata},peer:r,controller:r.publicKey,expiry:si(nm),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:l,namespaces:Ph([...new Set(i)],[...new Set(n)])},await this.client.core.relayer.subscribe(s),await this.client.session.set(s,o),o=this.client.session.get(s)),w({auths:e,session:o})},E=lu(),S=lu();this.events.once(ai("session_connect"),_),this.events.once(ai("session_request",E),A);try{await Promise.all([this.sendRequest({topic:l,method:"wc_sessionAuthenticate",params:m,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:E}),this.sendRequest({topic:l,method:"wc_sessionPropose",params:y,expiry:sm.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:S})])}catch(t){throw this.events.off(ai("session_connect"),_),this.events.off(ai("session_request",E),A),t}return await this.setProposal(S,wm({id:S},y)),await this.client.auth.requests.set(E,{authPayload:m.authPayload,requester:m.requester,expiryTimestamp:g,id:E,pairingTopic:l,verifyContext:{}}),{uri:f,response:v}},this.approveSessionAuthenticate=async t=>{this.isInitialized();const{id:e,auths:r}=t,i=this.getPendingAuthRequest(e);if(!i)throw new Error(`Could not find pending auth request with id ${e}`);const n=i.requester.publicKey,s=await this.client.core.crypto.generateKeyPair(),o=Xa(n),a={type:1,receiverPublicKey:n,senderPublicKey:s},h=[],u=[];for(const t of r){if(!await Da({cacao:t,projectId:this.client.core.projectId})){const t=kh("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:e,topic:o,error:t,encodeOpts:a}),new Error(t.message)}const{p:r}=t,i=Ga(r.resources),n=[Ua(r.iss)],s=La(r.iss);if(i){const t=Ha(i),e=Va(i);h.push(...t),n.push(...e)}for(const t of n)u.push(`${t}:${s}`)}const c=await this.client.core.crypto.generateSharedKey(s,n);let l;return h?.length>0&&(l={topic:c,acknowledged:!0,self:{publicKey:s,metadata:this.client.metadata},peer:{publicKey:n,metadata:i.requester.metadata},controller:n,expiry:si(nm),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:"",namespaces:Ph([...new Set(h)],[...new Set(u)])},await this.client.core.relayer.subscribe(c),await this.client.session.set(c,l)),await this.sendResult({topic:o,id:e,result:{cacaos:r,responder:{publicKey:s,metadata:this.client.metadata}},encodeOpts:a,throwOnFailedPublish:!0}),await this.client.auth.requests.delete(e,{message:"fullfilled",code:0}),await this.client.core.pairing.activate({topic:i.pairingTopic}),{session:l}},this.rejectSessionAuthenticate=async t=>{await this.isInitialized();const{id:e,reason:r}=t,i=this.getPendingAuthRequest(e);if(!i)throw new Error(`Could not find pending auth request with id ${e}`);const n=i.requester.publicKey,s=await this.client.core.crypto.generateKeyPair(),o=Xa(n),a={type:1,receiverPublicKey:n,senderPublicKey:s};await this.sendError({id:e,topic:o,error:r,encodeOpts:a}),await this.client.auth.requests.delete(e,{message:"rejected",code:0}),await this.client.proposal.delete(e,kh("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:e,iss:r}=t;return qa(e,r)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const e=this.client.core.pairing.pairings.get(t.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter((r=>{var i,n;return(null==(i=r.peerMetadata)?void 0:i.url)&&(null==(n=r.peerMetadata)?void 0:n.url)===t.peer.metadata.url&&r.topic&&r.topic!==e.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((t=>this.client.core.pairing.disconnect({topic:t.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(t){this.client.logger.error(t)}},this.deleteSession=async t=>{const{topic:e,expirerHasDeleted:r=!1,emitEvent:i=!0,id:n=0}=t,{self:s}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),await this.client.session.delete(e,kh("USER_DISCONNECTED")),this.addToRecentlyDeleted(e,"session"),this.client.core.crypto.keychain.has(s.publicKey)&&await this.client.core.crypto.deleteKeyPair(s.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),r||this.client.core.expirer.del(e),this.client.core.storage.removeItem(im).catch((t=>this.client.logger.warn(t))),this.getPendingSessionRequests().forEach((t=>{t.topic===e&&this.deletePendingSessionRequest(t.id,kh("USER_DISCONNECTED"))})),i&&this.client.events.emit("session_delete",{id:n,topic:e})},this.deleteProposal=async(t,e)=>{await Promise.all([this.client.proposal.delete(t,kh("USER_DISCONNECTED")),e?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,e,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,e),r?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((e=>e.id!==t)),r&&(this.sessionRequestQueue.state=am,this.client.events.emit("session_request_expire",{id:t}))},this.setExpiry=async(t,e)=>{this.client.session.keys.includes(t)&&await this.client.session.update(t,{expiry:e}),this.client.core.expirer.set(t,e)},this.setProposal=async(t,e)=>{await this.client.proposal.set(t,e),this.client.core.expirer.set(t,si(sm.wc_sessionPropose.req.ttl))},this.setPendingSessionRequest=async t=>{const{id:e,topic:r,params:i,verifyContext:n}=t,s=i.request.expiryTimestamp||si(sm.wc_sessionRequest.req.ttl);await this.client.pendingRequest.set(e,{id:e,topic:r,params:i,verifyContext:n}),s&&this.client.core.expirer.set(e,s)},this.sendRequest=async t=>{const{topic:e,method:r,params:i,expiry:n,relayRpcId:s,clientRpcId:o,throwOnFailedPublish:a}=t,h=du(r,i,o);if(Jr()&&um.includes(r)){const t=Za(JSON.stringify(h));this.client.core.verify.register({attestationId:t})}let u;try{u=await this.client.core.crypto.encode(e,h)}catch(t){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e} failed`),t}const c=sm[r].req;return n&&(c.ttl=n),s&&(c.id=s),this.client.core.history.set(e,h),a?(c.internal=bm(wm({},c.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(e,u,c)):this.client.core.relayer.publish(e,u,c).catch((t=>this.client.logger.error(t))),h.id},this.sendResult=async t=>{const{id:e,topic:r,result:i,throwOnFailedPublish:n,encodeOpts:s}=t,o=pu(e,i);let a,h;try{a=await this.client.core.crypto.encode(r,o,s)}catch(t){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${r} failed`),t}try{h=await this.client.core.history.get(r,e)}catch(t){throw this.client.logger.error(`sendResult() -> history.get(${r}, ${e}) failed`),t}const u=sm[h.request.method].res;n?(u.internal=bm(wm({},u.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,a,u)):this.client.core.relayer.publish(r,a,u).catch((t=>this.client.logger.error(t))),await this.client.core.history.resolve(o)},this.sendError=async t=>{const{id:e,topic:r,error:i,encodeOpts:n}=t,s=gu(e,i);let o,a;try{o=await this.client.core.crypto.encode(r,s,n)}catch(t){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${r} failed`),t}try{a=await this.client.core.history.get(r,e)}catch(t){throw this.client.logger.error(`sendError() -> history.get(${r}, ${e}) failed`),t}const h=sm[a.request.method].res;this.client.core.relayer.publish(r,o,h),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const t=[],e=[];this.client.session.getAll().forEach((e=>{let r=!1;oi(e.expiry)&&(r=!0),this.client.core.crypto.keychain.has(e.topic)||(r=!0),r&&t.push(e.topic)})),this.client.proposal.getAll().forEach((t=>{oi(t.expiryTimestamp)&&e.push(t.id)})),await Promise.all([...t.map((t=>this.deleteSession({topic:t}))),...e.map((t=>this.deleteProposal(t)))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==hm){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=hm;const t=this.requestQueue.queue.shift();if(t)try{this.processRequest(t),await new Promise((t=>setTimeout(t,300)))}catch(t){this.client.logger.warn(t)}}this.requestQueue.state=am}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=t=>{const{topic:e,payload:r}=t,i=r.method;if(!this.shouldIgnorePairingRequest({topic:e,requestMethod:i}))switch(i){case"wc_sessionPropose":return this.onSessionProposeRequest(e,r);case"wc_sessionSettle":return this.onSessionSettleRequest(e,r);case"wc_sessionUpdate":return this.onSessionUpdateRequest(e,r);case"wc_sessionExtend":return this.onSessionExtendRequest(e,r);case"wc_sessionPing":return this.onSessionPingRequest(e,r);case"wc_sessionDelete":return this.onSessionDeleteRequest(e,r);case"wc_sessionRequest":return this.onSessionRequest(e,r);case"wc_sessionEvent":return this.onSessionEventRequest(e,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateRequest(e,r);default:return this.client.logger.info(`Unsupported request method ${i}`)}},this.onRelayEventResponse=async t=>{const{topic:e,payload:r}=t,i=(await this.client.core.history.get(e,r.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(e,r);case"wc_sessionSettle":return this.onSessionSettleResponse(e,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(e,r);case"wc_sessionExtend":return this.onSessionExtendResponse(e,r);case"wc_sessionPing":return this.onSessionPingResponse(e,r);case"wc_sessionRequest":return this.onSessionRequestResponse(e,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(e,r);default:return this.client.logger.info(`Unsupported response method ${i}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:e}=t,{message:r}=Ch("MISSING_OR_INVALID",`Decoded payload on topic ${e} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)},this.shouldIgnorePairingRequest=t=>{const{topic:e,requestMethod:r}=t,i=this.expectedPairingMethodMap.get(e);return!(!i||i.includes(r)||!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))},this.onSessionProposeRequest=async(t,e)=>{const{params:r,id:i}=e;try{this.isValidConnect(wm({},e.params));const n=r.expiryTimestamp||si(sm.wc_sessionPropose.req.ttl),s=wm({id:i,pairingTopic:t,expiryTimestamp:n},r);await this.setProposal(i,s);const o=Za(JSON.stringify(e)),a=await this.getVerifyContext(o,s.proposer.metadata);this.client.events.emit("session_proposal",{id:i,params:s,verifyContext:a})}catch(e){await this.sendError({id:i,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionProposeResponse=async(t,e)=>{const{id:r}=e;if(Su(e)){const{result:i}=e;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(r);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const s=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:s});const o=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:o});const a=await this.client.core.crypto.generateSharedKey(s,o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const h=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:t})}else if(Mu(e)){await this.client.proposal.delete(r,kh("USER_DISCONNECTED"));const t=ai("session_connect");if(0===this.events.listenerCount(t))throw new Error(`emitting ${t} without any listeners, 954`);this.events.emit(ai("session_connect"),{error:e.error})}},this.onSessionSettleRequest=async(t,e)=>{const{id:r,params:i}=e;try{this.isValidSessionSettleRequest(i);const{relay:r,controller:n,expiry:s,namespaces:o,sessionProperties:a,pairingTopic:h,sessionConfig:u}=e.params,c=wm(wm({topic:t,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:h,requiredNamespaces:{},optionalNamespaces:{},controller:n.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},a&&{sessionProperties:a}),u&&{sessionConfig:u});await this.sendResult({id:e.id,topic:t,result:!0,throwOnFailedPublish:!0});const l=ai("session_connect");if(0===this.events.listenerCount(l))throw new Error(`emitting ${l} without any listeners 997`);this.events.emit(ai("session_connect"),{session:c}),this.cleanupDuplicatePairings(c)}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionSettleResponse=async(t,e)=>{const{id:r}=e;Su(e)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(ai("session_approve",r),{})):Mu(e)&&(await this.client.session.delete(t,kh("USER_DISCONNECTED")),this.events.emit(ai("session_approve",r),{error:e.error}))},this.onSessionUpdateRequest=async(t,e)=>{const{params:r,id:i}=e;try{const e=`${t}_session_update`,n=Zh.get(e);if(n&&this.isRequestOutOfSync(n,i))return this.client.logger.info(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:t,error:kh("INVALID_UPDATE_REQUEST")});this.isValidUpdate(wm({topic:t},r));try{Zh.set(e,i),await this.client.session.update(t,{namespaces:r.namespaces}),await this.sendResult({id:i,topic:t,result:!0,throwOnFailedPublish:!0})}catch(t){throw Zh.delete(e),t}this.client.events.emit("session_update",{id:i,topic:t,params:r})}catch(e){await this.sendError({id:i,topic:t,error:e}),this.client.logger.error(e)}},this.isRequestOutOfSync=(t,e)=>parseInt(e.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,e)=>{const{id:r}=e,i=ai("session_update",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);Su(e)?this.events.emit(ai("session_update",r),{}):Mu(e)&&this.events.emit(ai("session_update",r),{error:e.error})},this.onSessionExtendRequest=async(t,e)=>{const{id:r}=e;try{this.isValidExtend({topic:t}),await this.setExpiry(t,si(nm)),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:r,topic:t})}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionExtendResponse=(t,e)=>{const{id:r}=e,i=ai("session_extend",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);Su(e)?this.events.emit(ai("session_extend",r),{}):Mu(e)&&this.events.emit(ai("session_extend",r),{error:e.error})},this.onSessionPingRequest=async(t,e)=>{const{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:t})}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionPingResponse=(t,e)=>{const{id:r}=e,i=ai("session_ping",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);setTimeout((()=>{Su(e)?this.events.emit(ai("session_ping",r),{}):Mu(e)&&this.events.emit(ai("session_ping",r),{error:e.error})}),500)},this.onSessionDeleteRequest=async(t,e)=>{const{id:r}=e;try{this.isValidDisconnect({topic:t,reason:e.params}),await Promise.all([new Promise((e=>{this.client.core.relayer.once(vl,(async()=>{e(await this.deleteSession({topic:t,id:r}))}))})),this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:kh("USER_DISCONNECTED")})])}catch(t){this.client.logger.error(t)}},this.onSessionRequest=async(t,e)=>{const{id:r,params:i}=e;try{await this.isValidRequest(wm({topic:t},i));const e=Za(JSON.stringify(du("wc_sessionRequest",i,r))),n=this.client.session.get(t),s={id:r,topic:t,params:i,verifyContext:await this.getVerifyContext(e,n.peer.metadata)};await this.setPendingSessionRequest(s),this.addSessionRequestToSessionRequestQueue(s),this.processSessionRequestQueue()}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionRequestResponse=(t,e)=>{const{id:r}=e,i=ai("session_request",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);Su(e)?this.events.emit(ai("session_request",r),{result:e.result}):Mu(e)&&this.events.emit(ai("session_request",r),{error:e.error})},this.onSessionEventRequest=async(t,e)=>{const{id:r,params:i}=e;try{const e=`${t}_session_event_${i.event.name}`,n=Zh.get(e);if(n&&this.isRequestOutOfSync(n,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(wm({topic:t},i)),this.client.events.emit("session_event",{id:r,topic:t,params:i}),Zh.set(e,r)}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionAuthenticateResponse=(t,e)=>{const{id:r}=e;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:e}),Su(e)?this.events.emit(ai("session_request",r),{result:e.result}):Mu(e)&&this.events.emit(ai("session_request",r),{error:e.error})},this.onSessionAuthenticateRequest=async(t,e)=>{const{requester:r,authPayload:i,expiryTimestamp:n}=e.params,s=Za(JSON.stringify(e)),o=await this.getVerifyContext(s,this.client.metadata),a={requester:r,pairingTopic:t,id:e.id,authPayload:i,verifyContext:o,expiryTimestamp:n};await this.client.auth.requests.set(e.id,a),this.client.events.emit("session_authenticate",{topic:t,params:e.params,id:e.id})},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=am,this.processSessionRequestQueue()}),(0,Rt.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:e})=>{const r=this.client.core.history.pending;r.length>0&&r.filter((e=>e.topic===t&&"wc_sessionRequest"===e.request.method)).forEach((t=>{const r=ai("session_request",t.request.id);if(0===this.events.listenerCount(r))throw new Error(`emitting ${r} without any listeners`);this.events.emit(ai("session_request",t.request.id),{error:e})}))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===hm)return void this.client.logger.info("session request queue is already active.");const t=this.sessionRequestQueue.queue[0];if(t)try{this.sessionRequestQueue.state=hm,this.client.events.emit("session_request",t)}catch(t){this.client.logger.error(t)}else this.client.logger.info("session request queue is empty.")},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const e=this.client.proposal.getAll().find((e=>e.pairingTopic===t.topic));e&&this.onSessionProposeRequest(t.topic,du("wc_sessionPropose",{requiredNamespaces:e.requiredNamespaces,optionalNamespaces:e.optionalNamespaces,relays:e.relays,proposer:e.proposer,sessionProperties:e.sessionProperties},e.id))},this.isValidConnect=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(e)}const{pairingTopic:e,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:n,relays:s}=t;if(Dh(e)||await this.isValidPairingTopic(e),!function(t,e){let r=!1;return t?t&&Uh(t)&&t.length&&t.forEach((t=>{r=Vh(t)})):r=!0,r}(s)){const{message:t}=Ch("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(t)}!Dh(r)&&0!==Lh(r)&&this.validateNamespaces(r,"requiredNamespaces"),!Dh(i)&&0!==Lh(i)&&this.validateNamespaces(i,"optionalNamespaces"),Dh(n)||this.validateSessionProps(n,"sessionProperties")},this.validateNamespaces=(t,e)=>{const r=function(t,e,r){let i=null;if(t&&Lh(t)){const n=Kh(t,e);n&&(i=n);const s=function(t,e,r){let i=null;return Object.entries(t).forEach((([t,n])=>{if(i)return;const s=function(t,e,r){let i=null;return Uh(e)&&e.length?e.forEach((t=>{i||jh(t)||(i=kh("UNSUPPORTED_CHAINS",`${r}, chain ${t} should be a string and conform to "namespace:chainId" format`))})):jh(t)||(i=kh("UNSUPPORTED_CHAINS",`${r}, 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"] }`)),i}(t,Dr(t,n),`${e} ${r}`);s&&(i=s)})),i}(t,e,r);s&&(i=s)}else i=Ch("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}(t,"connect()",e);if(r)throw new Error(r.message)},this.isValidApprove=async t=>{if(!Gh(t))throw new Error(Ch("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:e,namespaces:r,relayProtocol:i,sessionProperties:n}=t;this.checkRecentlyDeleted(e),await this.isValidProposalId(e);const s=this.client.proposal.get(e),o=Hh(r,"approve()");if(o)throw new Error(o.message);const a=$h(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!qh(i,!0)){const{message:t}=Ch("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(t)}Dh(n)||this.validateSessionProps(n,"sessionProperties")},this.isValidReject=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(e)}const{id:e,reason:r}=t;if(this.checkRecentlyDeleted(e),await this.isValidProposalId(e),!function(t){return!!(t&&"object"==typeof t&&t.code&&Bh(t.code,!1)&&t.message&&qh(t.message,!1))}(r)){const{message:t}=Ch("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(t)}},this.isValidSessionSettleRequest=t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(e)}const{relay:e,controller:r,namespaces:i,expiry:n}=t;if(!Vh(e)){const{message:t}=Ch("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(t)}const s=function(t,e){let r=null;return qh(t?.publicKey,!1)||(r=Ch("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),r}(r);if(s)throw new Error(s.message);const o=Hh(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(oi(n)){const{message:t}=Ch("EXPIRED","onSessionSettleRequest()");throw new Error(t)}},this.isValidUpdate=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(e)}const{topic:e,namespaces:r}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const i=this.client.session.get(e),n=Hh(r,"update()");if(n)throw new Error(n.message);const s=$h(i.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(e)}const{topic:e}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e)},this.isValidRequest=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(e)}const{topic:e,request:r,chainId:i,expiry:n}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const{namespaces:s}=this.client.session.get(e);if(!Wh(s,i)){const{message:t}=Ch("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(t)}if(!function(t){return!(Dh(t)||!qh(t.method,!1))}(r)){const{message:t}=Ch("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(t)}if(!function(t,e,r){return!!qh(r,!1)&&function(t,e){const r=[];return Object.values(t).forEach((t=>{Ih(t.accounts).includes(e)&&r.push(...t.methods)})),r}(t,e).includes(r)}(s,i,r.method)){const{message:t}=Ch("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(t)}if(n&&!Yh(n,om)){const{message:t}=Ch("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${om.min} and ${om.max}`);throw new Error(t)}},this.isValidRespond=async t=>{var e;if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(e)}const{topic:r,response:i}=t;try{await this.isValidSessionTopic(r)}catch(r){throw null!=(e=t?.response)&&e.id&&this.cleanupAfterResponse(t),r}if(!function(t){return!(Dh(t)||Dh(t.result)&&Dh(t.error)||!Bh(t.id,!1)||!qh(t.jsonrpc,!1))}(i)){const{message:t}=Ch("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(t)}},this.isValidPing=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e)},this.isValidEmit=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(e)}const{topic:e,event:r,chainId:i}=t;await this.isValidSessionTopic(e);const{namespaces:n}=this.client.session.get(e);if(!Wh(n,i)){const{message:t}=Ch("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(t)}if(!function(t){return!(Dh(t)||!qh(t.name,!1))}(r)){const{message:t}=Ch("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(t)}if(!function(t,e,r){return!!qh(r,!1)&&function(t,e){const r=[];return Object.values(t).forEach((t=>{Ih(t.accounts).includes(e)&&r.push(...t.events)})),r}(t,e).includes(r)}(n,i,r.name)){const{message:t}=Ch("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(t)}},this.isValidDisconnect=async t=>{if(!Gh(t)){const{message:e}=Ch("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e)},this.isValidAuthenticate=t=>{const{chains:e,uri:r,domain:i,nonce:n}=t;if(!Array.isArray(e)||0===e.length)throw new Error("chains is required and must be a non-empty array");if(!qh(r,!1))throw new Error("uri is required parameter");if(!qh(i,!1))throw new Error("domain is required parameter");if(!qh(n,!1))throw new Error("nonce is required parameter");if([...new Set(e.map((t=>Lr(t).namespace)))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:s}=Lr(e[0]);if("eip155"!==s)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async(t,e)=>{const r={verified:{verifyUrl:e.verifyUrl||Dl,validation:"UNKNOWN",origin:e.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:t,verifyUrl:e.verifyUrl});i&&(r.verified.origin=i.origin,r.verified.isScam=i.isScam,r.verified.validation=i.origin===new URL(e.url).origin?"VALID":"INVALID")}catch(t){this.client.logger.info(t)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r},this.validateSessionProps=(t,e)=>{Object.values(t).forEach((t=>{if(!qh(t,!1)){const{message:r}=Ch("MISSING_OR_INVALID",`${e} must be in Record format. Received: ${JSON.stringify(t)}`);throw new Error(r)}}))},this.getPendingAuthRequest=t=>{const e=this.client.auth.requests.get(t);return"object"==typeof e?e:void 0},this.addToRecentlyDeleted=(t,e)=>{if(this.recentlyDeletedMap.set(t,e),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let t=0;const e=this.recentlyDeletedLimit/2;for(const r of this.recentlyDeletedMap.keys()){if(t++>=e)break;this.recentlyDeletedMap.delete(r)}}},this.checkRecentlyDeleted=t=>{const e=this.recentlyDeletedMap.get(t);if(e){const{message:r}=Ch("MISSING_OR_INVALID",`Record was recently deleted - ${e}: ${t}`);throw new Error(r)}}}async isInitialized(){if(!this.initialized){const{message:t}=Ch("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(gl,(async t=>{const{topic:e,message:r}=t,{publicKey:i}=this.client.auth.authKeys.keys.includes(lm)?this.client.auth.authKeys.get(lm):{responseTopic:void 0,publicKey:void 0},n=await this.client.core.crypto.decode(e,r,{receiverPublicKey:i});try{Au(n)?(this.client.core.history.set(e,n),this.onRelayEventRequest({topic:e,payload:n})):Eu(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:e,payload:n}),this.client.core.history.delete(e,n.id)):this.onRelayEventUnknownPayload({topic:e,payload:n})}catch(t){this.client.logger.error(t)}}))}registerExpirerEvents(){this.client.core.expirer.on(Ul,(async t=>{const{topic:e,id:r}=ni(t.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,Ch("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))}))}registerPairingEvents(){this.client.core.pairing.events.on(Nl,(t=>this.onPairingCreated(t))),this.client.core.pairing.events.on(Ol,(t=>{this.addToRecentlyDeleted(t.topic,"pairing")}))}isValidPairingTopic(t){if(!qh(t,!1)){const{message:e}=Ch("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=Ch("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(oi(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=Ch("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}}async isValidSessionTopic(t){if(!qh(t,!1)){const{message:e}=Ch("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(e)}if(this.checkRecentlyDeleted(t),!this.client.session.keys.includes(t)){const{message:e}=Ch("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(e)}if(oi(this.client.session.get(t).expiry)){await this.deleteSession({topic:t});const{message:e}=Ch("EXPIRED",`session topic: ${t}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(t)){const{message:e}=Ch("MISSING_OR_INVALID",`session topic does not exist in keychain: ${t}`);throw await this.deleteSession({topic:t}),new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.checkRecentlyDeleted(t),this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else{if(!this.client.core.pairing.pairings.keys.includes(t)){if(qh(t,!1)){const{message:e}=Ch("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(e)}{const{message:e}=Ch("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(e)}}this.isValidPairingTopic(t)}}async isValidProposalId(t){if(!function(t){return"number"==typeof t}(t)){const{message:e}=Ch("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=Ch("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(e)}if(oi(this.client.proposal.get(t).expiryTimestamp)){await this.deleteProposal(t);const{message:e}=Ch("EXPIRED",`proposal id: ${t}`);throw new Error(e)}}}class Am extends pf{constructor(t,e){super(t,e,"proposal",em),this.core=t,this.logger=e}}class Em extends pf{constructor(t,e){super(t,e,"session",em),this.core=t,this.logger=e}}class Sm extends pf{constructor(t,e){super(t,e,"request",em,(t=>t.id)),this.core=t,this.logger=e}}class Mm extends pf{constructor(t,e){super(t,e,"authKeys",cm,(()=>lm)),this.core=t,this.logger=e}}class Im extends pf{constructor(t,e){super(t,e,"pairingTopics",cm),this.core=t,this.logger=e}}class xm extends pf{constructor(t,e){super(t,e,"requests",cm,(t=>t.id)),this.core=t,this.logger=e}}class Nm{constructor(t,e){this.core=t,this.logger=e,this.authKeys=new Mm(this.core,this.logger),this.pairingTopics=new Im(this.core,this.logger),this.requests=new xm(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Om extends xt{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=rm,this.events=new g.EventEmitter,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.removeAllListeners=t=>this.events.removeAllListeners(t),this.connect=async t=>{try{return await this.engine.connect(t)}catch(t){throw this.logger.error(t.message),t}},this.pair=async t=>{try{return await this.engine.pair(t)}catch(t){throw this.logger.error(t.message),t}},this.approve=async t=>{try{return await this.engine.approve(t)}catch(t){throw this.logger.error(t.message),t}},this.reject=async t=>{try{return await this.engine.reject(t)}catch(t){throw this.logger.error(t.message),t}},this.update=async t=>{try{return await this.engine.update(t)}catch(t){throw this.logger.error(t.message),t}},this.extend=async t=>{try{return await this.engine.extend(t)}catch(t){throw this.logger.error(t.message),t}},this.request=async t=>{try{return await this.engine.request(t)}catch(t){throw this.logger.error(t.message),t}},this.respond=async t=>{try{return await this.engine.respond(t)}catch(t){throw this.logger.error(t.message),t}},this.ping=async t=>{try{return await this.engine.ping(t)}catch(t){throw this.logger.error(t.message),t}},this.emit=async t=>{try{return await this.engine.emit(t)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async t=>{try{return await this.engine.disconnect(t)}catch(t){throw this.logger.error(t.message),t}},this.find=t=>{try{return this.engine.find(t)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(t){throw this.logger.error(t.message),t}},this.authenticate=async t=>{try{return await this.engine.authenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.formatAuthMessage=t=>{try{return this.engine.formatAuthMessage(t)}catch(t){throw this.logger.error(t.message),t}},this.approveSessionAuthenticate=async t=>{try{return await this.engine.approveSessionAuthenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.rejectSessionAuthenticate=async t=>{try{return await this.engine.rejectSessionAuthenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.name=t?.name||rm,this.metadata=t?.metadata||(0,Or.g)()||{name:"",description:"",url:"",icons:[""]};const e=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:Y()(ft({level:t?.logger||"error"}));this.core=t?.core||new xf(t),this.logger=pt(e,this.name),this.session=new Em(this.core,this.logger),this.proposal=new Am(this.core,this.logger),this.pendingRequest=new Sm(this.core,this.logger),this.engine=new _m(this),this.auth=new Nm(this.core,this.logger)}static async init(t){const e=new Om(t);return await e.initialize(),e}get context(){return dt(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.engine.init(),await this.auth.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}}const Pm=Em,Rm=Om;var Tm,Cm={exports:{}},km="object"==typeof Reflect?Reflect:null,Um=km&&"function"==typeof km.apply?km.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};Tm=km&&"function"==typeof km.ownKeys?km.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var Lm=Number.isNaN||function(t){return t!=t};function Dm(){Dm.init.call(this)}Cm.exports=Dm,Cm.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,s),i(r)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",n),r([].slice.call(arguments))}Wm(t,e,s,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&Wm(t,"error",e,{once:!0})}(t,n)}))},Dm.EventEmitter=Dm,Dm.prototype._events=void 0,Dm.prototype._eventsCount=0,Dm.prototype._maxListeners=void 0;var qm=10;function Bm(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function jm(t){return void 0===t._maxListeners?Dm.defaultMaxListeners:t._maxListeners}function zm(t,e,r,i){var n,s,o;if(Bm(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),void 0===o)o=s[e]=r,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=jm(t))>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,function(t){console&&console.warn&&console.warn(t)}(a)}return t}function Fm(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Km(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Fm.bind(i);return n.listener=r,i.wrapFn=n,n}function Hm(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=n[t];if(void 0===a)return!1;if("function"==typeof a)Um(a,this,e);else{var h=a.length,u=Gm(a,h);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},Dm.prototype.listeners=function(t){return Hm(this,t,!0)},Dm.prototype.rawListeners=function(t){return Hm(this,t,!1)},Dm.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):Vm.call(t,e)},Dm.prototype.listenerCount=Vm,Dm.prototype.eventNames=function(){return this._eventsCount>0?Tm(this._events):[]};Cm.exports;class $m{constructor(t){this.opts=t}}class Jm{constructor(t){this.client=t}}var Ym=Object.defineProperty,Qm=Object.defineProperties,Xm=Object.getOwnPropertyDescriptors,Zm=Object.getOwnPropertySymbols,ty=Object.prototype.hasOwnProperty,ey=Object.prototype.propertyIsEnumerable,ry=(t,e,r)=>e in t?Ym(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;class iy extends Jm{constructor(t){super(t),this.init=async()=>{this.signClient=await Rm.init({core:this.client.core,metadata:this.client.metadata}),this.authClient=await Zg.init({core:this.client.core,projectId:"",metadata:this.client.metadata})},this.pair=async t=>{await this.client.core.pairing.pair(t)},this.approveSession=async t=>{const{topic:e,acknowledged:r}=await this.signClient.approve(((t,e)=>Qm(t,Xm(e)))(((t,e)=>{for(var r in e||(e={}))ty.call(e,r)&&ry(t,r,e[r]);if(Zm)for(var r of Zm(e))ey.call(e,r)&&ry(t,r,e[r]);return t})({},t),{id:t.id,namespaces:t.namespaces,sessionProperties:t.sessionProperties,sessionConfig:t.sessionConfig}));return await r(),this.signClient.session.get(e)},this.rejectSession=async t=>await this.signClient.reject(t),this.updateSession=async t=>await this.signClient.update(t),this.extendSession=async t=>await this.signClient.extend(t),this.respondSessionRequest=async t=>await this.signClient.respond(t),this.disconnectSession=async t=>await this.signClient.disconnect(t),this.emitSessionEvent=async t=>await this.signClient.emit(t),this.getActiveSessions=()=>this.signClient.session.getAll().reduce(((t,e)=>(t[e.topic]=e,t)),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.respondAuthRequest=async(t,e)=>await this.authClient.respond(t,e),this.getPendingAuthRequests=()=>this.authClient.requests.getAll().filter((t=>"requester"in t)),this.formatMessage=(t,e)=>this.authClient.formatMessage(t,e),this.approveSessionAuthenticate=async t=>await this.signClient.approveSessionAuthenticate(t),this.rejectSessionAuthenticate=async t=>await this.signClient.rejectSessionAuthenticate(t),this.formatAuthMessage=t=>this.signClient.formatAuthMessage(t),this.registerDeviceToken=t=>this.client.core.echoClient.registerDeviceToken(t),this.on=(t,e)=>(this.setEvent(t,"on"),this.client.events.on(t,e)),this.once=(t,e)=>(this.setEvent(t,"once"),this.client.events.once(t,e)),this.off=(t,e)=>(this.setEvent(t,"off"),this.client.events.off(t,e)),this.removeListener=(t,e)=>(this.setEvent(t,"removeListener"),this.client.events.removeListener(t,e)),this.onSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onSessionProposal=t=>{this.client.events.emit("session_proposal",t)},this.onSessionDelete=t=>{this.client.events.emit("session_delete",t)},this.onAuthRequest=t=>{this.client.events.emit("auth_request",t)},this.onProposalExpire=t=>{this.client.events.emit("proposal_expire",t)},this.onSessionRequestExpire=t=>{this.client.events.emit("session_request_expire",t)},this.onSessionRequestAuthenticate=t=>{this.client.events.emit("session_authenticate",t)},this.setEvent=(t,e)=>{switch(t){case"session_request":this.signClient.events[e]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[e]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[e]("session_delete",this.onSessionDelete);break;case"auth_request":this.authClient[e]("auth_request",this.onAuthRequest);break;case"proposal_expire":this.signClient.events[e]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[e]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[e]("session_authenticate",this.onSessionRequestAuthenticate)}},this.signClient={},this.authClient={}}}const ny={decryptMessage:async t=>{const e={core:new xf({storageOptions:t.storageOptions,storage:t.storage})};await e.core.crypto.init();const r=e.core.crypto.decode(t.topic,t.encryptedMessage);return e.core=null,r},getMetadata:async t=>{const e={core:new xf({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new Pm(e.core,e.core.logger),await e.sessionStore.init();const r=e.sessionStore.get(t.topic),i=r?.peer.metadata;return e.core=null,e.sessionStore=null,i}},sy=class extends $m{constructor(t){super(t),this.events=new Cm.exports,this.on=(t,e)=>this.engine.on(t,e),this.once=(t,e)=>this.engine.once(t,e),this.off=(t,e)=>this.engine.off(t,e),this.removeListener=(t,e)=>this.engine.removeListener(t,e),this.pair=async t=>{try{return await this.engine.pair(t)}catch(t){throw this.logger.error(t.message),t}},this.approveSession=async t=>{try{return await this.engine.approveSession(t)}catch(t){throw this.logger.error(t.message),t}},this.rejectSession=async t=>{try{return await this.engine.rejectSession(t)}catch(t){throw this.logger.error(t.message),t}},this.updateSession=async t=>{try{return await this.engine.updateSession(t)}catch(t){throw this.logger.error(t.message),t}},this.extendSession=async t=>{try{return await this.engine.extendSession(t)}catch(t){throw this.logger.error(t.message),t}},this.respondSessionRequest=async t=>{try{return await this.engine.respondSessionRequest(t)}catch(t){throw this.logger.error(t.message),t}},this.disconnectSession=async t=>{try{return await this.engine.disconnectSession(t)}catch(t){throw this.logger.error(t.message),t}},this.emitSessionEvent=async t=>{try{return await this.engine.emitSessionEvent(t)}catch(t){throw this.logger.error(t.message),t}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(t){throw this.logger.error(t.message),t}},this.respondAuthRequest=async(t,e)=>{try{return await this.engine.respondAuthRequest(t,e)}catch(t){throw this.logger.error(t.message),t}},this.getPendingAuthRequests=()=>{try{return this.engine.getPendingAuthRequests()}catch(t){throw this.logger.error(t.message),t}},this.formatMessage=(t,e)=>{try{return this.engine.formatMessage(t,e)}catch(t){throw this.logger.error(t.message),t}},this.registerDeviceToken=t=>{try{return this.engine.registerDeviceToken(t)}catch(t){throw this.logger.error(t.message),t}},this.approveSessionAuthenticate=t=>{try{return this.engine.approveSessionAuthenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.rejectSessionAuthenticate=t=>{try{return this.engine.rejectSessionAuthenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.formatAuthMessage=t=>{try{return this.engine.formatAuthMessage(t)}catch(t){throw this.logger.error(t.message),t}},this.metadata=t.metadata,this.name=t.name||"Web3Wallet",this.core=t.core,this.logger=this.core.logger,this.engine=new iy(this)}static async init(t){const e=new sy(t);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("Web3Wallet Initialization Success")}catch(t){throw this.logger.info("Web3Wallet Initialization Failure"),this.logger.error(t.message),t}}};let oy=sy;oy.notifications=ny;const ay=oy;window.wc={core:null,web3wallet:null,authClient:null,statusObject:null,init:function(t){return new Promise((async(e,r)=>{if(!window.statusq){const t='missing window.statusq! Forgot to execute "ui/StatusQ/src/StatusQ/Components/private/qwebchannel/helpers.js" first?';console.error(t),r(t)}if(window.statusq.error){const t="Failed initializing WebChannel: "+window.statusq.error;console.error(t),r(t)}if(wc.statusObject=window.statusq.channel.objects.statusObject,!wc.statusObject){const t="Failed initializing WebChannel or initialization not run";console.error(t),r(t)}window.wc.core=new xf({projectId:t}),window.wc.web3wallet=await ay.init({core:window.wc.core,metadata:{name:"Status",description:"Status Wallet",url:"http://localhost",icons:["https://status.im/img/status-footer-logo.svg"]}}),window.wc.authClient=await Xg.init({projectId:t,metadata:window.wc.web3wallet.metadata}),window.wc.web3wallet.on("session_proposal",(t=>{wc.statusObject.onSessionProposal(t)})),window.wc.web3wallet.on("session_update",(t=>{wc.statusObject.onSessionUpdate(t)})),window.wc.web3wallet.on("session_extend",(t=>{wc.statusObject.onSessionExtend(t)})),window.wc.web3wallet.on("session_ping",(t=>{wc.statusObject.onSessionPing(t)})),window.wc.web3wallet.on("session_delete",(t=>{wc.statusObject.onSessionDelete(t)})),window.wc.web3wallet.on("session_expire",(t=>{wc.statusObject.onSessionExpire(t)})),window.wc.web3wallet.on("session_request",(t=>{wc.statusObject.onSessionRequest(t)})),window.wc.web3wallet.on("session_request_sent",(t=>{wc.statusObject.onSessionRequestSent(t)})),window.wc.web3wallet.on("session_event",(t=>{wc.statusObject.onSessionEvent(t)})),window.wc.web3wallet.on("proposal_expire",(t=>{wc.statusObject.onProposalExpire(t)})),window.wc.authClient.on("auth_request",(t=>{wc.statusObject.onAuthRequest(t)})),wc.statusObject.sdkInitialized(""),e("")}))},pair:async function(t){await window.wc.web3wallet.pair({uri:t})},getPairings:function(){return window.wc.web3wallet.core.pairing.getPairings()},getActiveSessions:function(){return window.wc.web3wallet.getActiveSessions()},disconnect:async function(t){await window.wc.web3wallet.disconnectSession({topic:t,reason:kh("USER_DISCONNECTED")})},ping:async function(t){await window.wc.web3wallet.engine.signClient.ping({topic:t})},approveSession:async function(t,e){const{id:r,params:i}=t,{relays:n}=i,s=function(t){const{proposal:{requiredNamespaces:e,optionalNamespaces:r={}},supportedNamespaces:i}=t,n=Oh(e),s=Oh(r),o={};Object.keys(i).forEach((t=>{const e=i[t].chains,r=i[t].methods,n=i[t].events,s=i[t].accounts;e.forEach((e=>{if(!s.some((t=>t.includes(e))))throw new Error(`No accounts provided for chain ${e} in namespace ${t}`)})),o[t]={chains:e,methods:r,events:n,accounts:s}}));const a=$h(e,o,"approve()");if(a)throw new Error(a.message);const h={};return Object.keys(e).length||Object.keys(r).length?(Object.keys(n).forEach((t=>{const e=i[t].chains.filter((e=>{var r,i;return null==(i=null==(r=n[t])?void 0:r.chains)?void 0:i.includes(e)})),r=i[t].methods.filter((e=>{var r,i;return null==(i=null==(r=n[t])?void 0:r.methods)?void 0:i.includes(e)})),s=i[t].events.filter((e=>{var r,i;return null==(i=null==(r=n[t])?void 0:r.events)?void 0:i.includes(e)})),o=e.map((e=>i[t].accounts.filter((t=>t.includes(`${e}:`))))).flat();h[t]={chains:e,methods:r,events:s,accounts:o}})),Object.keys(s).forEach((t=>{var e,r,n,o,a,u;if(!i[t])return;const c=null==(r=null==(e=s[t])?void 0:e.chains)?void 0:r.filter((e=>i[t].chains.includes(e))),l=i[t].methods.filter((e=>{var r,i;return null==(i=null==(r=s[t])?void 0:r.methods)?void 0:i.includes(e)})),f=i[t].events.filter((e=>{var r,i;return null==(i=null==(r=s[t])?void 0:r.events)?void 0:i.includes(e)})),d=c?.map((e=>i[t].accounts.filter((t=>t.includes(`${e}:`))))).flat();h[t]={chains:hi(null==(n=h[t])?void 0:n.chains,c),methods:hi(null==(o=h[t])?void 0:o.methods,l),events:hi(null==(a=h[t])?void 0:a.events,f),accounts:hi(null==(u=h[t])?void 0:u.accounts,d)}})),h):o}({proposal:i,supportedNamespaces:e});return await window.wc.web3wallet.approveSession({id:r,relayProtocol:n[0].protocol,namespaces:s})},rejectSession:async function(t){await window.wc.web3wallet.rejectSession({id:t,reason:kh("USER_REJECTED")})},auth:async function(t){await window.wc.authClient.core.pairing.pair({uri:t})},formatAuthMessage:function(t,e){const r=`did:pkh:eip155:1:${e}`;return window.wc.authClient.formatMessage(t,r)},approveAuth:async function(t,e,r){const{id:i}=t,n=`did:pkh:eip155:1:${e}`;await window.wc.authClient.respond({id:i,signature:{s:r,t:"eip191"}},n)},rejectAuth:async function(t,e){const r=`did:pkh:eip155:1:${e}`;await window.wc.authClient.respond({id:t,error:{code:4001,message:"Auth request has been rejected"}},r)},respondSessionRequest:async function(t,e,r){const i=pu(e,r);await window.wc.web3wallet.respondSessionRequest({topic:t,response:i})},rejectSessionRequest:async function(t,e,r=!1){const i=r?"SESSION_SETTLEMENT_FAILED":"USER_REJECTED";await window.wc.web3wallet.respondSessionRequest({topic:t,response:gu(e,kh(i))})}}})(); \ No newline at end of file diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/generated/bundle.js.LICENSE.txt b/ui/imports/shared/popups/walletconnect/sdk/generated/bundle.js.LICENSE.txt similarity index 100% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/generated/bundle.js.LICENSE.txt rename to ui/imports/shared/popups/walletconnect/sdk/generated/bundle.js.LICENSE.txt diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/package-lock.json b/ui/imports/shared/popups/walletconnect/sdk/package-lock.json similarity index 96% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/package-lock.json rename to ui/imports/shared/popups/walletconnect/sdk/package-lock.json index bb1256d019..4dcd34eb25 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/package-lock.json +++ b/ui/imports/shared/popups/walletconnect/sdk/package-lock.json @@ -9,12 +9,12 @@ "version": "0.1.0", "license": "MPL-2.0", "dependencies": { - "@walletconnect/web3wallet": "^1.9.0" + "@walletconnect/web3wallet": "^1.11.2" }, "devDependencies": { - "webpack": "^5.88.2", + "webpack": "^5.91.0", "webpack-cli": "^5.1.4", - "webpack-dev-server": "^4.15.1" + "webpack-dev-server": "^4.15.2" } }, "node_modules/@discoveryjs/json-ext": { @@ -380,45 +380,45 @@ "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==" }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", - "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", "dev": true, "dependencies": { - "@jridgewell/set-array": "^1.0.1", + "@jridgewell/set-array": "^1.2.1", "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", - "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "dev": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/source-map": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz", - "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", + "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", "dev": true, "dependencies": { - "@jridgewell/gen-mapping": "^0.3.0", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" } }, "node_modules/@jridgewell/sourcemap-codec": { @@ -428,9 +428,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.20", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", - "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -1098,9 +1098,9 @@ } }, "node_modules/@walletconnect/core": { - "version": "2.10.5", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.10.5.tgz", - "integrity": "sha512-QnGHkA05KzJrtqExPqXm/TsstM1uTDI8tQT0x86/DuR6LdiYEntzSpVjnv7kKK6Mo9UxlXfud431dNRfOW5uJg==", + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.12.2.tgz", + "integrity": "sha512-7Adv/b3pp9F42BkvReaaM4KS8NEvlkS7AMtwO3uF/o6aRMKtcfTJq9/jgWdKJh4RP8pPRTRFjCw6XQ/RZtT4aQ==", "dependencies": { "@walletconnect/heartbeat": "1.2.1", "@walletconnect/jsonrpc-provider": "1.0.13", @@ -1108,14 +1108,15 @@ "@walletconnect/jsonrpc-utils": "1.0.8", "@walletconnect/jsonrpc-ws-connection": "1.0.14", "@walletconnect/keyvaluestorage": "^1.1.1", - "@walletconnect/logger": "^2.0.1", + "@walletconnect/logger": "^2.1.2", "@walletconnect/relay-api": "^1.0.9", "@walletconnect/relay-auth": "^1.0.4", "@walletconnect/safe-json": "^1.0.2", "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.10.5", - "@walletconnect/utils": "2.10.5", + "@walletconnect/types": "2.12.2", + "@walletconnect/utils": "2.12.2", "events": "^3.3.0", + "isomorphic-unfetch": "3.1.0", "lodash.isequal": "4.5.0", "uint8arrays": "^3.1.0" } @@ -1206,12 +1207,12 @@ } }, "node_modules/@walletconnect/logger": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@walletconnect/logger/-/logger-2.0.1.tgz", - "integrity": "sha512-SsTKdsgWm+oDTBeNE/zHxxr5eJfZmE9/5yp/Ku+zJtcTAjELb3DXueWkDXmE9h8uHIbJzIb5wj5lPdzyrjT6hQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@walletconnect/logger/-/logger-2.1.2.tgz", + "integrity": "sha512-aAb28I3S6pYXZHQm5ESB+V6rDqIYfsnHaQyzFbwUUBFY4H0OXx/YtTl8lvhUNhMMfb9UxbwEBS253TlXUYJWSw==", "dependencies": { - "pino": "7.11.0", - "tslib": "1.14.1" + "@walletconnect/safe-json": "^1.0.2", + "pino": "7.11.0" } }, "node_modules/@walletconnect/relay-api": { @@ -1245,18 +1246,18 @@ } }, "node_modules/@walletconnect/sign-client": { - "version": "2.10.5", - "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.10.5.tgz", - "integrity": "sha512-HEYsoeGC6fGplQy0NIZSRNHgOwZwQ892UWG1Ahkcasf2R35QaBgnTVQkSCisl1PAAOKXZG7yB1YDoAAZBF+g5Q==", + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.12.2.tgz", + "integrity": "sha512-cM0ualXj6nVvLqS4BDNRk+ZWR+lubcsz/IHreH+3wYrQ2sV+C0fN6ctrd7MMGZss0C0qacWCx0pm62ZBuoKvqA==", "dependencies": { - "@walletconnect/core": "2.10.5", + "@walletconnect/core": "2.12.2", "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.1", "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/logger": "^2.0.1", + "@walletconnect/logger": "^2.1.2", "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.10.5", - "@walletconnect/utils": "2.10.5", + "@walletconnect/types": "2.12.2", + "@walletconnect/utils": "2.12.2", "events": "^3.3.0" } }, @@ -1269,9 +1270,9 @@ } }, "node_modules/@walletconnect/types": { - "version": "2.10.5", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.10.5.tgz", - "integrity": "sha512-N8xaN7/Kob93rKxKDaT6oy6symgIkAwyLqq0/dLJEhXfv7S/gyNvDka4SosjVVTc4oTvE1+OmxNIR8pB1DuwJw==", + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.12.2.tgz", + "integrity": "sha512-9CmwTlPbrFTzayTL9q7xM7s3KTJkS6kYFtH2m1/fHFgALs6pIUjf1qAx1TF2E4tv7SEzLAIzU4NqgYUt2vWXTg==", "dependencies": { "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.1", @@ -1282,9 +1283,9 @@ } }, "node_modules/@walletconnect/utils": { - "version": "2.10.5", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.10.5.tgz", - "integrity": "sha512-3yeclD9/AlPEIHBqBVzrHUO/KRAEIXVK0ViIQ5oUH+zT3TpdsDGDiW1Z0TsAQ1EiYoiiz8dOQzd80a3eZVwnrg==", + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.12.2.tgz", + "integrity": "sha512-zf50HeS3SfoLv1N9GPl2IXTZ9TsXfet4usVAsZmX9P6/Xzq7d/7QakjVQCHH/Wk1O9XkcsfeoZoUhRxoMJ5uJw==", "dependencies": { "@stablelib/chacha20poly1305": "1.0.1", "@stablelib/hkdf": "1.0.1", @@ -1294,7 +1295,7 @@ "@walletconnect/relay-api": "^1.0.9", "@walletconnect/safe-json": "^1.0.2", "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.10.5", + "@walletconnect/types": "2.12.2", "@walletconnect/window-getters": "^1.0.1", "@walletconnect/window-metadata": "^1.0.1", "detect-browser": "5.3.0", @@ -1303,18 +1304,18 @@ } }, "node_modules/@walletconnect/web3wallet": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@walletconnect/web3wallet/-/web3wallet-1.9.4.tgz", - "integrity": "sha512-daoISghTC4693wExQN1X7arUBNF9jZuHERRTYCbEokMz2y/AmocMsanFx6g6MlIJumcBX6moYResygWltYI6mg==", + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@walletconnect/web3wallet/-/web3wallet-1.11.2.tgz", + "integrity": "sha512-jrxXmZyg+czkHXg4d0jdhxajjfbgPvS9dW4UzdGdz12dXsX7CFgZxz+LWc/oakhLyngUtwHtyBlgaFWxamS3AQ==", "dependencies": { "@walletconnect/auth-client": "2.1.2", - "@walletconnect/core": "2.10.5", + "@walletconnect/core": "2.12.2", "@walletconnect/jsonrpc-provider": "1.0.13", "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/logger": "2.0.1", - "@walletconnect/sign-client": "2.10.5", - "@walletconnect/types": "2.10.5", - "@walletconnect/utils": "2.10.5" + "@walletconnect/logger": "2.1.2", + "@walletconnect/sign-client": "2.12.2", + "@walletconnect/types": "2.12.2", + "@walletconnect/utils": "2.12.2" } }, "node_modules/@walletconnect/window-getters": { @@ -1335,9 +1336,9 @@ } }, "node_modules/@webassemblyjs/ast": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", - "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", + "integrity": "sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg==", "dev": true, "dependencies": { "@webassemblyjs/helper-numbers": "1.11.6", @@ -1357,9 +1358,9 @@ "dev": true }, "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz", - "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz", + "integrity": "sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw==", "dev": true }, "node_modules/@webassemblyjs/helper-numbers": { @@ -1380,15 +1381,15 @@ "dev": true }, "node_modules/@webassemblyjs/helper-wasm-section": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz", - "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz", + "integrity": "sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g==", "dev": true, "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/ast": "1.12.1", + "@webassemblyjs/helper-buffer": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6" + "@webassemblyjs/wasm-gen": "1.12.1" } }, "node_modules/@webassemblyjs/ieee754": { @@ -1416,28 +1417,28 @@ "dev": true }, "node_modules/@webassemblyjs/wasm-edit": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz", - "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz", + "integrity": "sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g==", "dev": true, "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/ast": "1.12.1", + "@webassemblyjs/helper-buffer": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/helper-wasm-section": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-opt": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6", - "@webassemblyjs/wast-printer": "1.11.6" + "@webassemblyjs/helper-wasm-section": "1.12.1", + "@webassemblyjs/wasm-gen": "1.12.1", + "@webassemblyjs/wasm-opt": "1.12.1", + "@webassemblyjs/wasm-parser": "1.12.1", + "@webassemblyjs/wast-printer": "1.12.1" } }, "node_modules/@webassemblyjs/wasm-gen": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz", - "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz", + "integrity": "sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w==", "dev": true, "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", "@webassemblyjs/ieee754": "1.11.6", "@webassemblyjs/leb128": "1.11.6", @@ -1445,24 +1446,24 @@ } }, "node_modules/@webassemblyjs/wasm-opt": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz", - "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz", + "integrity": "sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg==", "dev": true, "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6" + "@webassemblyjs/ast": "1.12.1", + "@webassemblyjs/helper-buffer": "1.12.1", + "@webassemblyjs/wasm-gen": "1.12.1", + "@webassemblyjs/wasm-parser": "1.12.1" } }, "node_modules/@webassemblyjs/wasm-parser": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz", - "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz", + "integrity": "sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ==", "dev": true, "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-api-error": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", "@webassemblyjs/ieee754": "1.11.6", @@ -1471,12 +1472,12 @@ } }, "node_modules/@webassemblyjs/wast-printer": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz", - "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz", + "integrity": "sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA==", "dev": true, "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.12.1", "@xtuc/long": "4.2.2" } }, @@ -2305,9 +2306,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", - "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.0.tgz", + "integrity": "sha512-O+QWCviPNSSLAD9Ucn8Awv+poAkqn3T1XY5/N7kR7rQO9yfSGWkYZDwpJ+iKF7B8rxaQKWngSqACpgzeapSyoA==", "dev": true, "dependencies": { "graceful-fs": "^4.2.4", @@ -4284,9 +4285,9 @@ "dev": true }, "node_modules/serialize-javascript": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", - "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dev": true, "dependencies": { "randombytes": "^2.1.0" @@ -4634,9 +4635,9 @@ } }, "node_modules/terser": { - "version": "5.24.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.24.0.tgz", - "integrity": "sha512-ZpGR4Hy3+wBEzVEnHvstMvqpD/nABNelQn/z2r0fjVWGQsN3bpOLzQlqDxmb4CDZnXq5lpjnQ+mHQLAOpfM5iw==", + "version": "5.30.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.3.tgz", + "integrity": "sha512-STdUgOUx8rLbMGO9IOwHLpCqolkDITFFQSMYYwKE1N2lY6MVSaeoi10z/EhWxRc6ybqoVmKSkhKYH/XUpl7vSA==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -4652,16 +4653,16 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.9", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz", - "integrity": "sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==", + "version": "5.3.10", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz", + "integrity": "sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==", "dev": true, "dependencies": { - "@jridgewell/trace-mapping": "^0.3.17", + "@jridgewell/trace-mapping": "^0.3.20", "jest-worker": "^27.4.5", "schema-utils": "^3.1.1", "serialize-javascript": "^6.0.1", - "terser": "^5.16.8" + "terser": "^5.26.0" }, "engines": { "node": ">= 10.13.0" @@ -4952,9 +4953,9 @@ } }, "node_modules/watchpack": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", - "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.1.tgz", + "integrity": "sha512-8wrBCMtVhqcXP2Sup1ctSkga6uc2Bx0IIvKyT7yTFier5AXHooSI+QyQQAtTb7+E0IUCCKyTFmXqdqgum2XWGg==", "dev": true, "dependencies": { "glob-to-regexp": "^0.4.1", @@ -4979,34 +4980,34 @@ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "node_modules/webpack": { - "version": "5.89.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.89.0.tgz", - "integrity": "sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw==", + "version": "5.91.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.91.0.tgz", + "integrity": "sha512-rzVwlLeBWHJbmgTC/8TvAcu5vpJNII+MelQpylD4jNERPwpBJOE2lEcko1zJX3QJeLjTTAnQxn/OJ8bjDzVQaw==", "dev": true, "dependencies": { "@types/eslint-scope": "^3.7.3", - "@types/estree": "^1.0.0", - "@webassemblyjs/ast": "^1.11.5", - "@webassemblyjs/wasm-edit": "^1.11.5", - "@webassemblyjs/wasm-parser": "^1.11.5", + "@types/estree": "^1.0.5", + "@webassemblyjs/ast": "^1.12.1", + "@webassemblyjs/wasm-edit": "^1.12.1", + "@webassemblyjs/wasm-parser": "^1.12.1", "acorn": "^8.7.1", "acorn-import-assertions": "^1.9.0", - "browserslist": "^4.14.5", + "browserslist": "^4.21.10", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.15.0", + "enhanced-resolve": "^5.16.0", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.9", + "graceful-fs": "^4.2.11", "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", "schema-utils": "^3.2.0", "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.3.7", - "watchpack": "^2.4.0", + "terser-webpack-plugin": "^5.3.10", + "watchpack": "^2.4.1", "webpack-sources": "^3.2.3" }, "bin": { @@ -5080,9 +5081,9 @@ } }, "node_modules/webpack-dev-middleware": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", - "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz", + "integrity": "sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q==", "dev": true, "dependencies": { "colorette": "^2.0.10", @@ -5156,9 +5157,9 @@ } }, "node_modules/webpack-dev-server": { - "version": "4.15.1", - "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.15.1.tgz", - "integrity": "sha512-5hbAst3h3C3L8w6W4P96L5vaV0PxSmJhxZvWKYIdgxOQm8pNZ5dEOmmSLBVpP85ReeyRt6AS1QJNyo/oFFPeVA==", + "version": "4.15.2", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.15.2.tgz", + "integrity": "sha512-0XavAZbNJ5sDrCbkpWL8mia0o5WPOd2YGtxrEiZkBK9FjLppIUK2TgxK6qGD2P3hUXTJNNPVibrerKcx5WkR1g==", "dev": true, "dependencies": { "@types/bonjour": "^3.5.9", @@ -5189,7 +5190,7 @@ "serve-index": "^1.9.1", "sockjs": "^0.3.24", "spdy": "^4.0.2", - "webpack-dev-middleware": "^5.3.1", + "webpack-dev-middleware": "^5.3.4", "ws": "^8.13.0" }, "bin": { diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/package.json b/ui/imports/shared/popups/walletconnect/sdk/package.json similarity index 82% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/package.json rename to ui/imports/shared/popups/walletconnect/sdk/package.json index 9e8a8871c8..a08d2d598b 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/package.json +++ b/ui/imports/shared/popups/walletconnect/sdk/package.json @@ -4,9 +4,9 @@ "description": "Wallet Connect integration for status-desktop", "private": true, "devDependencies": { - "webpack": "^5.89.0", + "webpack": "^5.91.0", "webpack-cli": "^5.1.4", - "webpack-dev-server": "^4.15.1" + "webpack-dev-server": "^4.15.2" }, "license": "MPL-2.0", "scripts": { @@ -16,6 +16,6 @@ "start": "webpack serve --mode development --open" }, "dependencies": { - "@walletconnect/web3wallet": "^1.9.4" + "@walletconnect/web3wallet": "^1.11.2" } } diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/src/index.html b/ui/imports/shared/popups/walletconnect/sdk/src/index.html similarity index 71% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/src/index.html rename to ui/imports/shared/popups/walletconnect/sdk/src/index.html index 227bb57b8c..be3ffcb54f 100644 --- a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/src/index.html +++ b/ui/imports/shared/popups/walletconnect/sdk/src/index.html @@ -3,7 +3,7 @@ - + diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/src/index.js b/ui/imports/shared/popups/walletconnect/sdk/src/index.js similarity index 100% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/src/index.js rename to ui/imports/shared/popups/walletconnect/sdk/src/index.js diff --git a/ui/app/AppLayouts/Wallet/views/walletconnect/sdk/webpack.config.js b/ui/imports/shared/popups/walletconnect/sdk/webpack.config.js similarity index 100% rename from ui/app/AppLayouts/Wallet/views/walletconnect/sdk/webpack.config.js rename to ui/imports/shared/popups/walletconnect/sdk/webpack.config.js diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 8c49dd715f..c0e17b1cc5 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -337,21 +337,22 @@ QtObject { readonly property int ensUsernames: 3 readonly property int messaging: 4 readonly property int wallet:5 - readonly property int appearance: 6 - readonly property int language: 7 - readonly property int notifications: 8 - readonly property int syncingSettings: 9 - readonly property int browserSettings: 10 - readonly property int advanced: 11 - readonly property int about: 12 - readonly property int communitiesSettings: 13 - readonly property int keycard: 14 - readonly property int about_terms: 15 // a subpage under "About" - readonly property int about_privacy: 16 // a subpage under "About" + readonly property int dapps: 6 + readonly property int appearance: 7 + readonly property int language: 8 + readonly property int notifications: 9 + readonly property int syncingSettings: 10 + readonly property int browserSettings: 11 + readonly property int advanced: 12 + readonly property int about: 13 + readonly property int communitiesSettings: 14 + readonly property int keycard: 15 + readonly property int about_terms: 16 // a subpage under "About" + readonly property int about_privacy: 17 // a subpage under "About" // special treatment; these do not participate in the main settings' StackLayout - readonly property int signout: 17 - readonly property int backUpSeed: 18 + readonly property int signout: 18 + readonly property int backUpSeed: 19 } readonly property QtObject walletSettingsSubsection: QtObject { @@ -788,6 +789,11 @@ QtObject { } } + readonly property QtObject dapps: QtObject { + readonly property int connectDappPopupWidth: 480 + readonly property int footerButtonsHeight: 44 + } + readonly property QtObject localPairingAction: QtObject { readonly property int actionUnknown: 0 readonly property int actionConnect: 1 diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 4d0628d975..5c656bf365 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -97,7 +97,10 @@ QtObject { signal openTestnetPopup() + ///////////////////////////////////////////////////// + // WalletConnect POC - to remove signal popupWalletConnect() + ///////////////////////////////////////////////////// signal openAddEditSavedAddressesPopup(var params) signal openDeleteSavedAddressesPopup(var params)